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