1 //===- X86InstrFPStack.td - FPU Instruction Set ------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the X86 x87 FPU instruction set, defining the
10 // instructions, and properties of the instructions which are needed for code
11 // generation, machine code emission, and analysis.
13 //===----------------------------------------------------------------------===//
15 //===----------------------------------------------------------------------===//
16 // FPStack specific DAG Nodes.
17 //===----------------------------------------------------------------------===//
19 def SDTX86Fld : SDTypeProfile<1, 1, [SDTCisFP<0>,
21 def SDTX86Fst : SDTypeProfile<0, 2, [SDTCisFP<0>,
23 def SDTX86Fild : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisPtrTy<1>]>;
24 def SDTX86Fnstsw : SDTypeProfile<1, 1, [SDTCisVT<0, i16>, SDTCisVT<1, i16>]>;
26 def SDTX86CwdStore : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
28 def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
29 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
30 def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
31 [SDNPHasChain, SDNPInGlue, SDNPMayStore,
33 def X86fild : SDNode<"X86ISD::FILD", SDTX86Fild,
34 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
35 def X86fildflag : SDNode<"X86ISD::FILD_FLAG", SDTX86Fild,
36 [SDNPHasChain, SDNPOutGlue, SDNPMayLoad,
38 def X86fp_stsw : SDNode<"X86ISD::FNSTSW16r", SDTX86Fnstsw>;
39 def X86fp_to_mem : SDNode<"X86ISD::FP_TO_INT_IN_MEM", SDTX86Fst,
40 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
41 def X86fp_cwd_get16 : SDNode<"X86ISD::FNSTCW16m", SDTX86CwdStore,
42 [SDNPHasChain, SDNPMayStore, SDNPSideEffect,
45 def X86fstf32 : PatFrag<(ops node:$val, node:$ptr),
46 (X86fst node:$val, node:$ptr), [{
47 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f32;
49 def X86fstf64 : PatFrag<(ops node:$val, node:$ptr),
50 (X86fst node:$val, node:$ptr), [{
51 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f64;
53 def X86fstf80 : PatFrag<(ops node:$val, node:$ptr),
54 (X86fst node:$val, node:$ptr), [{
55 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f80;
58 def X86fldf32 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{
59 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f32;
61 def X86fldf64 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{
62 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f64;
64 def X86fldf80 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{
65 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f80;
68 def X86fild16 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{
69 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
71 def X86fild32 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{
72 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
74 def X86fild64 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{
75 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
78 def X86fildflag64 : PatFrag<(ops node:$ptr), (X86fildflag node:$ptr), [{
79 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
82 def X86fp_to_i16mem : PatFrag<(ops node:$val, node:$ptr),
83 (X86fp_to_mem node:$val, node:$ptr), [{
84 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
86 def X86fp_to_i32mem : PatFrag<(ops node:$val, node:$ptr),
87 (X86fp_to_mem node:$val, node:$ptr), [{
88 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
90 def X86fp_to_i64mem : PatFrag<(ops node:$val, node:$ptr),
91 (X86fp_to_mem node:$val, node:$ptr), [{
92 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
95 //===----------------------------------------------------------------------===//
96 // FPStack pattern fragments
97 //===----------------------------------------------------------------------===//
99 def fpimm0 : FPImmLeaf<fAny, [{
100 return Imm.isExactlyValue(+0.0);
103 def fpimmneg0 : FPImmLeaf<fAny, [{
104 return Imm.isExactlyValue(-0.0);
107 def fpimm1 : FPImmLeaf<fAny, [{
108 return Imm.isExactlyValue(+1.0);
111 def fpimmneg1 : FPImmLeaf<fAny, [{
112 return Imm.isExactlyValue(-1.0);
115 // Some 'special' instructions - expanded after instruction selection.
116 let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
117 def FP32_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP32:$src),
118 [(X86fp_to_i16mem RFP32:$src, addr:$dst)]>;
119 def FP32_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP32:$src),
120 [(X86fp_to_i32mem RFP32:$src, addr:$dst)]>;
121 def FP32_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP32:$src),
122 [(X86fp_to_i64mem RFP32:$src, addr:$dst)]>;
123 def FP64_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP64:$src),
124 [(X86fp_to_i16mem RFP64:$src, addr:$dst)]>;
125 def FP64_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP64:$src),
126 [(X86fp_to_i32mem RFP64:$src, addr:$dst)]>;
127 def FP64_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP64:$src),
128 [(X86fp_to_i64mem RFP64:$src, addr:$dst)]>;
129 def FP80_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP80:$src),
130 [(X86fp_to_i16mem RFP80:$src, addr:$dst)]>;
131 def FP80_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP80:$src),
132 [(X86fp_to_i32mem RFP80:$src, addr:$dst)]>;
133 def FP80_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP80:$src),
134 [(X86fp_to_i64mem RFP80:$src, addr:$dst)]>;
137 // All FP Stack operations are represented with four instructions here. The
138 // first three instructions, generated by the instruction selector, use "RFP32"
139 // "RFP64" or "RFP80" registers: traditional register files to reference 32-bit,
140 // 64-bit or 80-bit floating point values. These sizes apply to the values,
141 // not the registers, which are always 80 bits; RFP32, RFP64 and RFP80 can be
142 // copied to each other without losing information. These instructions are all
143 // pseudo instructions and use the "_Fp" suffix.
144 // In some cases there are additional variants with a mixture of different
146 // The second instruction is defined with FPI, which is the actual instruction
147 // emitted by the assembler. These use "RST" registers, although frequently
148 // the actual register(s) used are implicit. These are always 80 bits.
149 // The FP stackifier pass converts one to the other after register allocation
152 // Note that the FpI instruction should have instruction selection info (e.g.
153 // a pattern) and the FPI instruction should have emission info (e.g. opcode
154 // encoding and asm printing info).
156 // FpIf32, FpIf64 - Floating Point Pseudo Instruction template.
157 // f32 instructions can use SSE1 and are predicated on FPStackf32 == !SSE1.
158 // f64 instructions can use SSE2 and are predicated on FPStackf64 == !SSE2.
159 // f80 instructions cannot use SSE and use neither of these.
160 class FpIf32<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
161 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32]>;
162 class FpIf64<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
163 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64]>;
165 // Factoring for arithmetic.
166 multiclass FPBinary_rr<SDNode OpNode> {
167 // Register op register -> register
168 // These are separated out because they have no reversed form.
169 def _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2), TwoArgFP,
170 [(set RFP32:$dst, (OpNode RFP32:$src1, RFP32:$src2))]>;
171 def _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2), TwoArgFP,
172 [(set RFP64:$dst, (OpNode RFP64:$src1, RFP64:$src2))]>;
173 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2), TwoArgFP,
174 [(set RFP80:$dst, (OpNode RFP80:$src1, RFP80:$src2))]>;
176 // The FopST0 series are not included here because of the irregularities
177 // in where the 'r' goes in assembly output.
178 // These instructions cannot address 80-bit memory.
179 multiclass FPBinary<SDNode OpNode, Format fp, string asmstring,
181 let mayLoad = 1, hasSideEffects = 1 in {
182 // ST(0) = ST(0) + [mem]
183 def _Fp32m : FpIf32<(outs RFP32:$dst),
184 (ins RFP32:$src1, f32mem:$src2), OneArgFPRW,
187 (OpNode RFP32:$src1, (loadf32 addr:$src2))),
189 (OpNode (loadf32 addr:$src2), RFP32:$src1)))]>;
190 def _Fp64m : FpIf64<(outs RFP64:$dst),
191 (ins RFP64:$src1, f64mem:$src2), OneArgFPRW,
194 (OpNode RFP64:$src1, (loadf64 addr:$src2))),
196 (OpNode (loadf64 addr:$src2), RFP64:$src1)))]>;
197 def _Fp64m32: FpIf64<(outs RFP64:$dst),
198 (ins RFP64:$src1, f32mem:$src2), OneArgFPRW,
201 (OpNode RFP64:$src1, (f64 (extloadf32 addr:$src2)))),
203 (OpNode (f64 (extloadf32 addr:$src2)), RFP64:$src1)))]>;
204 def _Fp80m32: FpI_<(outs RFP80:$dst),
205 (ins RFP80:$src1, f32mem:$src2), OneArgFPRW,
208 (OpNode RFP80:$src1, (f80 (extloadf32 addr:$src2)))),
210 (OpNode (f80 (extloadf32 addr:$src2)), RFP80:$src1)))]>;
211 def _Fp80m64: FpI_<(outs RFP80:$dst),
212 (ins RFP80:$src1, f64mem:$src2), OneArgFPRW,
215 (OpNode RFP80:$src1, (f80 (extloadf64 addr:$src2)))),
217 (OpNode (f80 (extloadf64 addr:$src2)), RFP80:$src1)))]>;
218 def _F32m : FPI<0xD8, fp, (outs), (ins f32mem:$src),
219 !strconcat("f", asmstring, "{s}\t$src")>;
220 def _F64m : FPI<0xDC, fp, (outs), (ins f64mem:$src),
221 !strconcat("f", asmstring, "{l}\t$src")>;
222 // ST(0) = ST(0) + [memint]
223 def _FpI16m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i16mem:$src2),
227 (OpNode RFP32:$src1, (X86fild16 addr:$src2))),
229 (OpNode (X86fild16 addr:$src2), RFP32:$src1)))]>;
230 def _FpI32m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i32mem:$src2),
234 (OpNode RFP32:$src1, (X86fild32 addr:$src2))),
236 (OpNode (X86fild32 addr:$src2), RFP32:$src1)))]>;
237 def _FpI16m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i16mem:$src2),
241 (OpNode RFP64:$src1, (X86fild16 addr:$src2))),
243 (OpNode (X86fild16 addr:$src2), RFP64:$src1)))]>;
244 def _FpI32m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i32mem:$src2),
248 (OpNode RFP64:$src1, (X86fild32 addr:$src2))),
250 (OpNode (X86fild32 addr:$src2), RFP64:$src1)))]>;
251 def _FpI16m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i16mem:$src2),
255 (OpNode RFP80:$src1, (X86fild16 addr:$src2))),
257 (OpNode (X86fild16 addr:$src2), RFP80:$src1)))]>;
258 def _FpI32m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i32mem:$src2),
262 (OpNode RFP80:$src1, (X86fild32 addr:$src2))),
264 (OpNode (X86fild32 addr:$src2), RFP80:$src1)))]>;
265 def _FI16m : FPI<0xDE, fp, (outs), (ins i16mem:$src),
266 !strconcat("fi", asmstring, "{s}\t$src")>;
267 def _FI32m : FPI<0xDA, fp, (outs), (ins i32mem:$src),
268 !strconcat("fi", asmstring, "{l}\t$src")>;
269 } // mayLoad = 1, hasSideEffects = 1
272 let Defs = [FPSW], Uses = [FPCW] in {
273 // FPBinary_rr just defines pseudo-instructions, no need to set a scheduling
275 let hasNoSchedulingInfo = 1 in {
276 defm ADD : FPBinary_rr<fadd>;
277 defm SUB : FPBinary_rr<fsub>;
278 defm MUL : FPBinary_rr<fmul>;
279 defm DIV : FPBinary_rr<fdiv>;
282 // Sets the scheduling resources for the actual NAME#_F<size>m defintions.
283 let SchedRW = [WriteFAddLd] in {
284 defm ADD : FPBinary<fadd, MRM0m, "add">;
285 defm SUB : FPBinary<fsub, MRM4m, "sub">;
286 defm SUBR: FPBinary<fsub ,MRM5m, "subr", 0>;
289 let SchedRW = [WriteFMulLd] in {
290 defm MUL : FPBinary<fmul, MRM1m, "mul">;
293 let SchedRW = [WriteFDivLd] in {
294 defm DIV : FPBinary<fdiv, MRM6m, "div">;
295 defm DIVR: FPBinary<fdiv, MRM7m, "divr", 0>;
299 class FPST0rInst<Format fp, string asm>
300 : FPI<0xD8, fp, (outs), (ins RSTi:$op), asm>;
301 class FPrST0Inst<Format fp, string asm>
302 : FPI<0xDC, fp, (outs), (ins RSTi:$op), asm>;
303 class FPrST0PInst<Format fp, string asm>
304 : FPI<0xDE, fp, (outs), (ins RSTi:$op), asm>;
306 // NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
307 // of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
308 // we have to put some 'r's in and take them out of weird places.
309 let SchedRW = [WriteFAdd], Defs = [FPSW], Uses = [FPCW] in {
310 def ADD_FST0r : FPST0rInst <MRM0r, "fadd\t{$op, %st|st, $op}">;
311 def ADD_FrST0 : FPrST0Inst <MRM0r, "fadd\t{%st, $op|$op, st}">;
312 def ADD_FPrST0 : FPrST0PInst<MRM0r, "faddp\t{%st, $op|$op, st}">;
313 def SUBR_FST0r : FPST0rInst <MRM5r, "fsubr\t{$op, %st|st, $op}">;
314 def SUB_FrST0 : FPrST0Inst <MRM5r, "fsub{r}\t{%st, $op|$op, st}">;
315 def SUB_FPrST0 : FPrST0PInst<MRM5r, "fsub{r}p\t{%st, $op|$op, st}">;
316 def SUB_FST0r : FPST0rInst <MRM4r, "fsub\t{$op, %st|st, $op}">;
317 def SUBR_FrST0 : FPrST0Inst <MRM4r, "fsub{|r}\t{%st, $op|$op, st}">;
318 def SUBR_FPrST0 : FPrST0PInst<MRM4r, "fsub{|r}p\t{%st, $op|$op, st}">;
320 let SchedRW = [WriteFCom], Defs = [FPSW], Uses = [FPCW] in {
321 def COM_FST0r : FPST0rInst <MRM2r, "fcom\t$op">;
322 def COMP_FST0r : FPST0rInst <MRM3r, "fcomp\t$op">;
324 let SchedRW = [WriteFMul], Defs = [FPSW], Uses = [FPCW] in {
325 def MUL_FST0r : FPST0rInst <MRM1r, "fmul\t{$op, %st|st, $op}">;
326 def MUL_FrST0 : FPrST0Inst <MRM1r, "fmul\t{%st, $op|$op, st}">;
327 def MUL_FPrST0 : FPrST0PInst<MRM1r, "fmulp\t{%st, $op|$op, st}">;
329 let SchedRW = [WriteFDiv], Defs = [FPSW], Uses = [FPCW] in {
330 def DIVR_FST0r : FPST0rInst <MRM7r, "fdivr\t{$op, %st|st, $op}">;
331 def DIV_FrST0 : FPrST0Inst <MRM7r, "fdiv{r}\t{%st, $op|$op, st}">;
332 def DIV_FPrST0 : FPrST0PInst<MRM7r, "fdiv{r}p\t{%st, $op|$op, st}">;
333 def DIV_FST0r : FPST0rInst <MRM6r, "fdiv\t{$op, %st|st, $op}">;
334 def DIVR_FrST0 : FPrST0Inst <MRM6r, "fdiv{|r}\t{%st, $op|$op, st}">;
335 def DIVR_FPrST0 : FPrST0PInst<MRM6r, "fdiv{|r}p\t{%st, $op|$op, st}">;
339 multiclass FPUnary<SDNode OpNode, Format fp, string asmstring> {
340 def _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src), OneArgFPRW,
341 [(set RFP32:$dst, (OpNode RFP32:$src))]>;
342 def _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src), OneArgFPRW,
343 [(set RFP64:$dst, (OpNode RFP64:$src))]>;
344 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src), OneArgFPRW,
345 [(set RFP80:$dst, (OpNode RFP80:$src))]>;
346 def _F : FPI<0xD9, fp, (outs), (ins), asmstring>;
349 let Defs = [FPSW], Uses = [FPCW] in {
351 let SchedRW = [WriteFSign] in {
352 defm CHS : FPUnary<fneg, MRM_E0, "fchs">;
353 defm ABS : FPUnary<fabs, MRM_E1, "fabs">;
356 let SchedRW = [WriteFSqrt80] in
357 defm SQRT: FPUnary<fsqrt,MRM_FA, "fsqrt">;
359 let SchedRW = [WriteMicrocoded] in {
360 defm SIN : FPUnary<fsin, MRM_FE, "fsin">;
361 defm COS : FPUnary<fcos, MRM_FF, "fcos">;
364 let SchedRW = [WriteFCom] in {
365 let hasSideEffects = 0 in {
366 def TST_Fp32 : FpIf32<(outs), (ins RFP32:$src), OneArgFP, []>;
367 def TST_Fp64 : FpIf64<(outs), (ins RFP64:$src), OneArgFP, []>;
368 def TST_Fp80 : FpI_<(outs), (ins RFP80:$src), OneArgFP, []>;
371 def TST_F : FPI<0xD9, MRM_E4, (outs), (ins), "ftst">;
375 // Versions of FP instructions that take a single memory operand. Added for the
376 // disassembler; remove as they are included with patterns elsewhere.
377 let SchedRW = [WriteFComLd], Defs = [FPSW], Uses = [FPCW] in {
378 def FCOM32m : FPI<0xD8, MRM2m, (outs), (ins f32mem:$src), "fcom{s}\t$src">;
379 def FCOMP32m : FPI<0xD8, MRM3m, (outs), (ins f32mem:$src), "fcomp{s}\t$src">;
381 def FCOM64m : FPI<0xDC, MRM2m, (outs), (ins f64mem:$src), "fcom{l}\t$src">;
382 def FCOMP64m : FPI<0xDC, MRM3m, (outs), (ins f64mem:$src), "fcomp{l}\t$src">;
384 def FICOM16m : FPI<0xDE, MRM2m, (outs), (ins i16mem:$src), "ficom{s}\t$src">;
385 def FICOMP16m: FPI<0xDE, MRM3m, (outs), (ins i16mem:$src), "ficomp{s}\t$src">;
387 def FICOM32m : FPI<0xDA, MRM2m, (outs), (ins i32mem:$src), "ficom{l}\t$src">;
388 def FICOMP32m: FPI<0xDA, MRM3m, (outs), (ins i32mem:$src), "ficomp{l}\t$src">;
391 let SchedRW = [WriteMicrocoded] in {
392 def FLDENVm : FPI<0xD9, MRM4m, (outs), (ins f32mem:$src), "fldenv\t$src">;
393 def FSTENVm : FPI<0xD9, MRM6m, (outs), (ins f32mem:$dst), "fnstenv\t$dst">;
395 def FRSTORm : FPI<0xDD, MRM4m, (outs), (ins f32mem:$dst), "frstor\t$dst">;
396 def FSAVEm : FPI<0xDD, MRM6m, (outs), (ins f32mem:$dst), "fnsave\t$dst">;
397 def FNSTSWm : FPI<0xDD, MRM7m, (outs), (ins i16mem:$dst), "fnstsw\t$dst">;
399 def FBLDm : FPI<0xDF, MRM4m, (outs), (ins f80mem:$src), "fbld\t$src">;
400 def FBSTPm : FPI<0xDF, MRM6m, (outs), (ins f80mem:$dst), "fbstp\t$dst">;
403 // Floating point cmovs.
404 class FpIf32CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
405 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32, HasCMov]>;
406 class FpIf64CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
407 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64, HasCMov]>;
409 multiclass FPCMov<PatLeaf cc> {
410 def _Fp32 : FpIf32CMov<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2),
412 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2,
414 def _Fp64 : FpIf64CMov<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2),
416 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2,
418 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2),
420 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2,
425 let Defs = [FPSW] in {
426 let SchedRW = [WriteFCMOV] in {
427 let Uses = [EFLAGS], Constraints = "$src1 = $dst" in {
428 defm CMOVB : FPCMov<X86_COND_B>;
429 defm CMOVBE : FPCMov<X86_COND_BE>;
430 defm CMOVE : FPCMov<X86_COND_E>;
431 defm CMOVP : FPCMov<X86_COND_P>;
432 defm CMOVNB : FPCMov<X86_COND_AE>;
433 defm CMOVNBE: FPCMov<X86_COND_A>;
434 defm CMOVNE : FPCMov<X86_COND_NE>;
435 defm CMOVNP : FPCMov<X86_COND_NP>;
436 } // Uses = [EFLAGS], Constraints = "$src1 = $dst"
438 let Predicates = [HasCMov] in {
439 // These are not factored because there's no clean way to pass DA/DB.
440 def CMOVB_F : FPI<0xDA, MRM0r, (outs), (ins RSTi:$op),
441 "fcmovb\t{$op, %st|st, $op}">;
442 def CMOVBE_F : FPI<0xDA, MRM2r, (outs), (ins RSTi:$op),
443 "fcmovbe\t{$op, %st|st, $op}">;
444 def CMOVE_F : FPI<0xDA, MRM1r, (outs), (ins RSTi:$op),
445 "fcmove\t{$op, %st|st, $op}">;
446 def CMOVP_F : FPI<0xDA, MRM3r, (outs), (ins RSTi:$op),
447 "fcmovu\t{$op, %st|st, $op}">;
448 def CMOVNB_F : FPI<0xDB, MRM0r, (outs), (ins RSTi:$op),
449 "fcmovnb\t{$op, %st|st, $op}">;
450 def CMOVNBE_F: FPI<0xDB, MRM2r, (outs), (ins RSTi:$op),
451 "fcmovnbe\t{$op, %st|st, $op}">;
452 def CMOVNE_F : FPI<0xDB, MRM1r, (outs), (ins RSTi:$op),
453 "fcmovne\t{$op, %st|st, $op}">;
454 def CMOVNP_F : FPI<0xDB, MRM3r, (outs), (ins RSTi:$op),
455 "fcmovnu\t{$op, %st|st, $op}">;
456 } // Predicates = [HasCMov]
459 // Floating point loads & stores.
460 let SchedRW = [WriteLoad], Uses = [FPCW] in {
461 let canFoldAsLoad = 1 in {
462 def LD_Fp32m : FpIf32<(outs RFP32:$dst), (ins f32mem:$src), ZeroArgFP,
463 [(set RFP32:$dst, (loadf32 addr:$src))]>;
464 def LD_Fp64m : FpIf64<(outs RFP64:$dst), (ins f64mem:$src), ZeroArgFP,
465 [(set RFP64:$dst, (loadf64 addr:$src))]>;
466 def LD_Fp80m : FpI_<(outs RFP80:$dst), (ins f80mem:$src), ZeroArgFP,
467 [(set RFP80:$dst, (loadf80 addr:$src))]>;
469 def LD_Fp32m64 : FpIf64<(outs RFP64:$dst), (ins f32mem:$src), ZeroArgFP,
470 [(set RFP64:$dst, (f64 (extloadf32 addr:$src)))]>;
471 def LD_Fp64m80 : FpI_<(outs RFP80:$dst), (ins f64mem:$src), ZeroArgFP,
472 [(set RFP80:$dst, (f80 (extloadf64 addr:$src)))]>;
473 def LD_Fp32m80 : FpI_<(outs RFP80:$dst), (ins f32mem:$src), ZeroArgFP,
474 [(set RFP80:$dst, (f80 (extloadf32 addr:$src)))]>;
475 def ILD_Fp16m32: FpIf32<(outs RFP32:$dst), (ins i16mem:$src), ZeroArgFP,
476 [(set RFP32:$dst, (X86fild16 addr:$src))]>;
477 def ILD_Fp32m32: FpIf32<(outs RFP32:$dst), (ins i32mem:$src), ZeroArgFP,
478 [(set RFP32:$dst, (X86fild32 addr:$src))]>;
479 def ILD_Fp64m32: FpIf32<(outs RFP32:$dst), (ins i64mem:$src), ZeroArgFP,
480 [(set RFP32:$dst, (X86fild64 addr:$src))]>;
481 def ILD_Fp16m64: FpIf64<(outs RFP64:$dst), (ins i16mem:$src), ZeroArgFP,
482 [(set RFP64:$dst, (X86fild16 addr:$src))]>;
483 def ILD_Fp32m64: FpIf64<(outs RFP64:$dst), (ins i32mem:$src), ZeroArgFP,
484 [(set RFP64:$dst, (X86fild32 addr:$src))]>;
485 def ILD_Fp64m64: FpIf64<(outs RFP64:$dst), (ins i64mem:$src), ZeroArgFP,
486 [(set RFP64:$dst, (X86fild64 addr:$src))]>;
487 def ILD_Fp16m80: FpI_<(outs RFP80:$dst), (ins i16mem:$src), ZeroArgFP,
488 [(set RFP80:$dst, (X86fild16 addr:$src))]>;
489 def ILD_Fp32m80: FpI_<(outs RFP80:$dst), (ins i32mem:$src), ZeroArgFP,
490 [(set RFP80:$dst, (X86fild32 addr:$src))]>;
491 def ILD_Fp64m80: FpI_<(outs RFP80:$dst), (ins i64mem:$src), ZeroArgFP,
492 [(set RFP80:$dst, (X86fild64 addr:$src))]>;
495 let SchedRW = [WriteStore], Uses = [FPCW] in {
496 def ST_Fp32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP,
497 [(store RFP32:$src, addr:$op)]>;
498 def ST_Fp64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP,
499 [(truncstoref32 RFP64:$src, addr:$op)]>;
500 def ST_Fp64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP,
501 [(store RFP64:$src, addr:$op)]>;
502 def ST_Fp80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP,
503 [(truncstoref32 RFP80:$src, addr:$op)]>;
504 def ST_Fp80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP,
505 [(truncstoref64 RFP80:$src, addr:$op)]>;
506 // FST does not support 80-bit memory target; FSTP must be used.
508 let mayStore = 1, hasSideEffects = 0 in {
509 def ST_FpP32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP, []>;
510 def ST_FpP64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP, []>;
511 def ST_FpP64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP, []>;
512 def ST_FpP80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP, []>;
513 def ST_FpP80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP, []>;
516 def ST_FpP80m : FpI_<(outs), (ins f80mem:$op, RFP80:$src), OneArgFP,
517 [(store RFP80:$src, addr:$op)]>;
519 let mayStore = 1, hasSideEffects = 0 in {
520 def IST_Fp16m32 : FpIf32<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP, []>;
521 def IST_Fp32m32 : FpIf32<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP, []>;
522 def IST_Fp64m32 : FpIf32<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP, []>;
523 def IST_Fp16m64 : FpIf64<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP, []>;
524 def IST_Fp32m64 : FpIf64<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP, []>;
525 def IST_Fp64m64 : FpIf64<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP, []>;
526 def IST_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP, []>;
527 def IST_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP, []>;
528 def IST_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP, []>;
530 } // SchedRW, Uses = [FPCW]
532 let mayLoad = 1, SchedRW = [WriteLoad], Uses = [FPCW] in {
533 def LD_F32m : FPI<0xD9, MRM0m, (outs), (ins f32mem:$src), "fld{s}\t$src">;
534 def LD_F64m : FPI<0xDD, MRM0m, (outs), (ins f64mem:$src), "fld{l}\t$src">;
535 def LD_F80m : FPI<0xDB, MRM5m, (outs), (ins f80mem:$src), "fld{t}\t$src">;
536 def ILD_F16m : FPI<0xDF, MRM0m, (outs), (ins i16mem:$src), "fild{s}\t$src">;
537 def ILD_F32m : FPI<0xDB, MRM0m, (outs), (ins i32mem:$src), "fild{l}\t$src">;
538 def ILD_F64m : FPI<0xDF, MRM5m, (outs), (ins i64mem:$src), "fild{ll}\t$src">;
540 let mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in {
541 def ST_F32m : FPI<0xD9, MRM2m, (outs), (ins f32mem:$dst), "fst{s}\t$dst">;
542 def ST_F64m : FPI<0xDD, MRM2m, (outs), (ins f64mem:$dst), "fst{l}\t$dst">;
543 def ST_FP32m : FPI<0xD9, MRM3m, (outs), (ins f32mem:$dst), "fstp{s}\t$dst">;
544 def ST_FP64m : FPI<0xDD, MRM3m, (outs), (ins f64mem:$dst), "fstp{l}\t$dst">;
545 def ST_FP80m : FPI<0xDB, MRM7m, (outs), (ins f80mem:$dst), "fstp{t}\t$dst">;
546 def IST_F16m : FPI<0xDF, MRM2m, (outs), (ins i16mem:$dst), "fist{s}\t$dst">;
547 def IST_F32m : FPI<0xDB, MRM2m, (outs), (ins i32mem:$dst), "fist{l}\t$dst">;
548 def IST_FP16m : FPI<0xDF, MRM3m, (outs), (ins i16mem:$dst), "fistp{s}\t$dst">;
549 def IST_FP32m : FPI<0xDB, MRM3m, (outs), (ins i32mem:$dst), "fistp{l}\t$dst">;
550 def IST_FP64m : FPI<0xDF, MRM7m, (outs), (ins i64mem:$dst), "fistp{ll}\t$dst">;
553 // FISTTP requires SSE3 even though it's a FPStack op.
554 let Predicates = [HasSSE3], SchedRW = [WriteStore], Uses = [FPCW] in {
555 def ISTT_Fp16m32 : FpI_<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP,
556 [(X86fp_to_i16mem RFP32:$src, addr:$op)]>;
557 def ISTT_Fp32m32 : FpI_<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP,
558 [(X86fp_to_i32mem RFP32:$src, addr:$op)]>;
559 def ISTT_Fp64m32 : FpI_<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP,
560 [(X86fp_to_i64mem RFP32:$src, addr:$op)]>;
561 def ISTT_Fp16m64 : FpI_<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP,
562 [(X86fp_to_i16mem RFP64:$src, addr:$op)]>;
563 def ISTT_Fp32m64 : FpI_<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP,
564 [(X86fp_to_i32mem RFP64:$src, addr:$op)]>;
565 def ISTT_Fp64m64 : FpI_<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP,
566 [(X86fp_to_i64mem RFP64:$src, addr:$op)]>;
567 def ISTT_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP,
568 [(X86fp_to_i16mem RFP80:$src, addr:$op)]>;
569 def ISTT_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP,
570 [(X86fp_to_i32mem RFP80:$src, addr:$op)]>;
571 def ISTT_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP,
572 [(X86fp_to_i64mem RFP80:$src, addr:$op)]>;
573 } // Predicates = [HasSSE3]
575 let mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in {
576 def ISTT_FP16m : FPI<0xDF, MRM1m, (outs), (ins i16mem:$dst), "fisttp{s}\t$dst">;
577 def ISTT_FP32m : FPI<0xDB, MRM1m, (outs), (ins i32mem:$dst), "fisttp{l}\t$dst">;
578 def ISTT_FP64m : FPI<0xDD, MRM1m, (outs), (ins i64mem:$dst), "fisttp{ll}\t$dst">;
581 // FP Stack manipulation instructions.
582 let SchedRW = [WriteMove], Uses = [FPCW] in {
583 def LD_Frr : FPI<0xD9, MRM0r, (outs), (ins RSTi:$op), "fld\t$op">;
584 def ST_Frr : FPI<0xDD, MRM2r, (outs), (ins RSTi:$op), "fst\t$op">;
585 def ST_FPrr : FPI<0xDD, MRM3r, (outs), (ins RSTi:$op), "fstp\t$op">;
586 def XCH_F : FPI<0xD9, MRM1r, (outs), (ins RSTi:$op), "fxch\t$op">;
589 // Floating point constant loads.
590 let SchedRW = [WriteZero], Uses = [FPCW] in {
591 def LD_Fp032 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
592 [(set RFP32:$dst, fpimm0)]>;
593 def LD_Fp132 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
594 [(set RFP32:$dst, fpimm1)]>;
595 def LD_Fp064 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP,
596 [(set RFP64:$dst, fpimm0)]>;
597 def LD_Fp164 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP,
598 [(set RFP64:$dst, fpimm1)]>;
599 def LD_Fp080 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP,
600 [(set RFP80:$dst, fpimm0)]>;
601 def LD_Fp180 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP,
602 [(set RFP80:$dst, fpimm1)]>;
605 let SchedRW = [WriteFLD0], Uses = [FPCW] in
606 def LD_F0 : FPI<0xD9, MRM_EE, (outs), (ins), "fldz">;
608 let SchedRW = [WriteFLD1], Uses = [FPCW] in
609 def LD_F1 : FPI<0xD9, MRM_E8, (outs), (ins), "fld1">;
611 let SchedRW = [WriteFLDC], Uses = [FPCW] in {
612 def FLDL2T : I<0xD9, MRM_E9, (outs), (ins), "fldl2t", []>;
613 def FLDL2E : I<0xD9, MRM_EA, (outs), (ins), "fldl2e", []>;
614 def FLDPI : I<0xD9, MRM_EB, (outs), (ins), "fldpi", []>;
615 def FLDLG2 : I<0xD9, MRM_EC, (outs), (ins), "fldlg2", []>;
616 def FLDLN2 : I<0xD9, MRM_ED, (outs), (ins), "fldln2", []>;
619 // Floating point compares.
620 let SchedRW = [WriteFCom], Uses = [FPCW] in {
621 def UCOM_Fpr32 : FpIf32<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
622 [(set FPSW, (trunc (X86cmp RFP32:$lhs, RFP32:$rhs)))]>;
623 def UCOM_Fpr64 : FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
624 [(set FPSW, (trunc (X86cmp RFP64:$lhs, RFP64:$rhs)))]>;
625 def UCOM_Fpr80 : FpI_ <(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
626 [(set FPSW, (trunc (X86cmp RFP80:$lhs, RFP80:$rhs)))]>;
630 let SchedRW = [WriteFCom] in {
631 // CC = ST(0) cmp ST(i)
632 let Defs = [EFLAGS, FPSW], Uses = [FPCW] in {
633 def UCOM_FpIr32: FpI_<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
634 [(set EFLAGS, (X86cmp RFP32:$lhs, RFP32:$rhs))]>,
635 Requires<[FPStackf32, HasCMov]>;
636 def UCOM_FpIr64: FpI_<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
637 [(set EFLAGS, (X86cmp RFP64:$lhs, RFP64:$rhs))]>,
638 Requires<[FPStackf64, HasCMov]>;
639 def UCOM_FpIr80: FpI_<(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
640 [(set EFLAGS, (X86cmp RFP80:$lhs, RFP80:$rhs))]>,
644 let Defs = [FPSW], Uses = [ST0, FPCW] in {
645 def UCOM_Fr : FPI<0xDD, MRM4r, // FPSW = cmp ST(0) with ST(i)
646 (outs), (ins RSTi:$reg), "fucom\t$reg">;
647 def UCOM_FPr : FPI<0xDD, MRM5r, // FPSW = cmp ST(0) with ST(i), pop
648 (outs), (ins RSTi:$reg), "fucomp\t$reg">;
649 def UCOM_FPPr : FPI<0xDA, MRM_E9, // cmp ST(0) with ST(1), pop, pop
650 (outs), (ins), "fucompp">;
653 let Defs = [EFLAGS, FPSW], Uses = [ST0, FPCW] in {
654 def UCOM_FIr : FPI<0xDB, MRM5r, // CC = cmp ST(0) with ST(i)
655 (outs), (ins RSTi:$reg), "fucomi\t{$reg, %st|st, $reg}">;
656 def UCOM_FIPr : FPI<0xDF, MRM5r, // CC = cmp ST(0) with ST(i), pop
657 (outs), (ins RSTi:$reg), "fucompi\t{$reg, %st|st, $reg}">;
659 def COM_FIr : FPI<0xDB, MRM6r, (outs), (ins RSTi:$reg),
660 "fcomi\t{$reg, %st|st, $reg}">;
661 def COM_FIPr : FPI<0xDF, MRM6r, (outs), (ins RSTi:$reg),
662 "fcompi\t{$reg, %st|st, $reg}">;
666 // Floating point flag ops.
667 let SchedRW = [WriteALU] in {
668 let Defs = [AX], Uses = [FPSW] in
669 def FNSTSW16r : I<0xDF, MRM_E0, // AX = fp flags
670 (outs), (ins), "fnstsw\t{%ax|ax}",
671 [(set AX, (X86fp_stsw FPSW))]>;
672 let Defs = [FPSW], Uses = [FPCW] in
673 def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
674 (outs), (ins i16mem:$dst), "fnstcw\t$dst",
675 [(X86fp_cwd_get16 addr:$dst)]>;
677 let Defs = [FPSW,FPCW], mayLoad = 1 in
678 def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
679 (outs), (ins i16mem:$dst), "fldcw\t$dst", []>,
682 // FPU control instructions
683 let SchedRW = [WriteMicrocoded] in {
684 let Defs = [FPSW] in {
685 def FNINIT : I<0xDB, MRM_E3, (outs), (ins), "fninit", []>;
686 def FFREE : FPI<0xDD, MRM0r, (outs), (ins RSTi:$reg), "ffree\t$reg">;
687 def FFREEP : FPI<0xDF, MRM0r, (outs), (ins RSTi:$reg), "ffreep\t$reg">;
690 def FNCLEX : I<0xDB, MRM_E2, (outs), (ins), "fnclex", []>;
694 // Operand-less floating-point instructions for the disassembler.
695 def FNOP : I<0xD9, MRM_D0, (outs), (ins), "fnop", []>, Sched<[WriteNop]>;
697 let SchedRW = [WriteMicrocoded] in {
698 let Defs = [FPSW] in {
699 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
700 def FXAM : I<0xD9, MRM_E5, (outs), (ins), "fxam", []>;
701 def F2XM1 : I<0xD9, MRM_F0, (outs), (ins), "f2xm1", []>;
702 def FYL2X : I<0xD9, MRM_F1, (outs), (ins), "fyl2x", []>;
703 def FPTAN : I<0xD9, MRM_F2, (outs), (ins), "fptan", []>;
704 def FPATAN : I<0xD9, MRM_F3, (outs), (ins), "fpatan", []>;
705 def FXTRACT : I<0xD9, MRM_F4, (outs), (ins), "fxtract", []>;
706 def FPREM1 : I<0xD9, MRM_F5, (outs), (ins), "fprem1", []>;
707 def FDECSTP : I<0xD9, MRM_F6, (outs), (ins), "fdecstp", []>;
708 def FINCSTP : I<0xD9, MRM_F7, (outs), (ins), "fincstp", []>;
709 def FPREM : I<0xD9, MRM_F8, (outs), (ins), "fprem", []>;
710 def FYL2XP1 : I<0xD9, MRM_F9, (outs), (ins), "fyl2xp1", []>;
711 def FSINCOS : I<0xD9, MRM_FB, (outs), (ins), "fsincos", []>;
712 def FRNDINT : I<0xD9, MRM_FC, (outs), (ins), "frndint", []>;
713 def FSCALE : I<0xD9, MRM_FD, (outs), (ins), "fscale", []>;
714 def FCOMPP : I<0xDE, MRM_D9, (outs), (ins), "fcompp", []>;
717 def FXSAVE : I<0xAE, MRM0m, (outs), (ins opaquemem:$dst),
718 "fxsave\t$dst", [(int_x86_fxsave addr:$dst)]>, TB,
720 def FXSAVE64 : RI<0xAE, MRM0m, (outs), (ins opaquemem:$dst),
721 "fxsave64\t$dst", [(int_x86_fxsave64 addr:$dst)]>,
722 TB, Requires<[HasFXSR, In64BitMode]>;
723 def FXRSTOR : I<0xAE, MRM1m, (outs), (ins opaquemem:$src),
724 "fxrstor\t$src", [(int_x86_fxrstor addr:$src)]>,
725 TB, Requires<[HasFXSR]>;
726 def FXRSTOR64 : RI<0xAE, MRM1m, (outs), (ins opaquemem:$src),
727 "fxrstor64\t$src", [(int_x86_fxrstor64 addr:$src)]>,
728 TB, Requires<[HasFXSR, In64BitMode]>;
731 //===----------------------------------------------------------------------===//
732 // Non-Instruction Patterns
733 //===----------------------------------------------------------------------===//
735 // Required for RET of f32 / f64 / f80 values.
736 def : Pat<(X86fldf32 addr:$src), (LD_Fp32m addr:$src)>;
737 def : Pat<(X86fldf64 addr:$src), (LD_Fp64m addr:$src)>;
738 def : Pat<(X86fldf80 addr:$src), (LD_Fp80m addr:$src)>;
740 // Required for CALL which return f32 / f64 / f80 values.
741 def : Pat<(X86fstf32 RFP32:$src, addr:$op), (ST_Fp32m addr:$op, RFP32:$src)>;
742 def : Pat<(X86fstf32 RFP64:$src, addr:$op), (ST_Fp64m32 addr:$op, RFP64:$src)>;
743 def : Pat<(X86fstf64 RFP64:$src, addr:$op), (ST_Fp64m addr:$op, RFP64:$src)>;
744 def : Pat<(X86fstf32 RFP80:$src, addr:$op), (ST_Fp80m32 addr:$op, RFP80:$src)>;
745 def : Pat<(X86fstf64 RFP80:$src, addr:$op), (ST_Fp80m64 addr:$op, RFP80:$src)>;
746 def : Pat<(X86fstf80 RFP80:$src, addr:$op), (ST_FpP80m addr:$op, RFP80:$src)>;
748 // Floating point constant -0.0 and -1.0
749 def : Pat<(f32 fpimmneg0), (CHS_Fp32 (LD_Fp032))>, Requires<[FPStackf32]>;
750 def : Pat<(f32 fpimmneg1), (CHS_Fp32 (LD_Fp132))>, Requires<[FPStackf32]>;
751 def : Pat<(f64 fpimmneg0), (CHS_Fp64 (LD_Fp064))>, Requires<[FPStackf64]>;
752 def : Pat<(f64 fpimmneg1), (CHS_Fp64 (LD_Fp164))>, Requires<[FPStackf64]>;
753 def : Pat<(f80 fpimmneg0), (CHS_Fp80 (LD_Fp080))>;
754 def : Pat<(f80 fpimmneg1), (CHS_Fp80 (LD_Fp180))>;
756 // Used to conv. i64 to f64 since there isn't a SSE version.
757 def : Pat<(X86fildflag64 addr:$src), (ILD_Fp64m64 addr:$src)>;
759 // FP extensions map onto simple pseudo-value conversions if they are to/from
761 def : Pat<(f64 (fpextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP64)>,
762 Requires<[FPStackf32]>;
763 def : Pat<(f80 (fpextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP80)>,
764 Requires<[FPStackf32]>;
765 def : Pat<(f80 (fpextend RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP80)>,
766 Requires<[FPStackf64]>;
768 // FP truncations map onto simple pseudo-value conversions if they are to/from
769 // the FP stack. We have validated that only value-preserving truncations make
771 def : Pat<(f32 (fpround RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP32)>,
772 Requires<[FPStackf32]>;
773 def : Pat<(f32 (fpround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP32)>,
774 Requires<[FPStackf32]>;
775 def : Pat<(f64 (fpround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP64)>,
776 Requires<[FPStackf64]>;