1*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 2*9880d681SAndroid Build Coastguard Worker// Random ideas for the X86 backend: FP stack related stuff 3*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard WorkerSome targets (e.g. athlons) prefer freep to fstp ST(0): 8*9880d681SAndroid Build Coastguard Workerhttp://gcc.gnu.org/ml/gcc-patches/2004-04/msg00659.html 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard WorkerThis should use fiadd on chips where it is profitable: 13*9880d681SAndroid Build Coastguard Workerdouble foo(double P, int *I) { return P+*I; } 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard WorkerWe have fiadd patterns now but the followings have the same cost and 16*9880d681SAndroid Build Coastguard Workercomplexity. We need a way to specify the later is more profitable. 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Workerdef FpADD32m : FpI<(ops RFP:$dst, RFP:$src1, f32mem:$src2), OneArgFPRW, 19*9880d681SAndroid Build Coastguard Worker [(set RFP:$dst, (fadd RFP:$src1, 20*9880d681SAndroid Build Coastguard Worker (extloadf64f32 addr:$src2)))]>; 21*9880d681SAndroid Build Coastguard Worker // ST(0) = ST(0) + [mem32] 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Workerdef FpIADD32m : FpI<(ops RFP:$dst, RFP:$src1, i32mem:$src2), OneArgFPRW, 24*9880d681SAndroid Build Coastguard Worker [(set RFP:$dst, (fadd RFP:$src1, 25*9880d681SAndroid Build Coastguard Worker (X86fild addr:$src2, i32)))]>; 26*9880d681SAndroid Build Coastguard Worker // ST(0) = ST(0) + [mem32int] 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 29*9880d681SAndroid Build Coastguard Worker 30*9880d681SAndroid Build Coastguard WorkerThe FP stackifier should handle simple permutates to reduce number of shuffle 31*9880d681SAndroid Build Coastguard Workerinstructions, e.g. turning: 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Workerfld P -> fld Q 34*9880d681SAndroid Build Coastguard Workerfld Q fld P 35*9880d681SAndroid Build Coastguard Workerfxch 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Workeror: 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerfxch -> fucomi 40*9880d681SAndroid Build Coastguard Workerfucomi jl X 41*9880d681SAndroid Build Coastguard Workerjg X 42*9880d681SAndroid Build Coastguard Worker 43*9880d681SAndroid Build Coastguard WorkerIdeas: 44*9880d681SAndroid Build Coastguard Workerhttp://gcc.gnu.org/ml/gcc-patches/2004-11/msg02410.html 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard WorkerAdd a target specific hook to DAG combiner to handle SINT_TO_FP and 50*9880d681SAndroid Build Coastguard WorkerFP_TO_SINT when the source operand is already in memory. 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard WorkerOpen code rint,floor,ceil,trunc: 55*9880d681SAndroid Build Coastguard Workerhttp://gcc.gnu.org/ml/gcc-patches/2004-08/msg02006.html 56*9880d681SAndroid Build Coastguard Workerhttp://gcc.gnu.org/ml/gcc-patches/2004-08/msg02011.html 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard WorkerOpencode the sincos[f] libcall. 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard WorkerNone of the FPStack instructions are handled in 63*9880d681SAndroid Build Coastguard WorkerX86RegisterInfo::foldMemoryOperand, which prevents the spiller from 64*9880d681SAndroid Build Coastguard Workerfolding spill code into the instructions. 65*9880d681SAndroid Build Coastguard Worker 66*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard WorkerCurrently the x86 codegen isn't very good at mixing SSE and FPStack 69*9880d681SAndroid Build Coastguard Workercode: 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Workerunsigned int foo(double x) { return x; } 72*9880d681SAndroid Build Coastguard Worker 73*9880d681SAndroid Build Coastguard Workerfoo: 74*9880d681SAndroid Build Coastguard Worker subl $20, %esp 75*9880d681SAndroid Build Coastguard Worker movsd 24(%esp), %xmm0 76*9880d681SAndroid Build Coastguard Worker movsd %xmm0, 8(%esp) 77*9880d681SAndroid Build Coastguard Worker fldl 8(%esp) 78*9880d681SAndroid Build Coastguard Worker fisttpll (%esp) 79*9880d681SAndroid Build Coastguard Worker movl (%esp), %eax 80*9880d681SAndroid Build Coastguard Worker addl $20, %esp 81*9880d681SAndroid Build Coastguard Worker ret 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard WorkerThis just requires being smarter when custom expanding fptoui. 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Worker//===---------------------------------------------------------------------===// 86