Debian Codegraph @

suite/synctools/tablegen/X86/back/X86InstrFPStack.td

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