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 SDTX86Fist : SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisPtrTy<1>]>;
26 def SDTX86CwdStore : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
27 def SDTX86CwdLoad : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
29 def X86fp80_add : SDNode<"X86ISD::FP80_ADD", SDTFPBinOp, [SDNPCommutative]>;
30 def X86strict_fp80_add : SDNode<"X86ISD::STRICT_FP80_ADD", SDTFPBinOp,
31 [SDNPHasChain,SDNPCommutative]>;
32 def any_X86fp80_add : PatFrags<(ops node:$lhs, node:$rhs),
33 [(X86strict_fp80_add node:$lhs, node:$rhs),
34 (X86fp80_add node:$lhs, node:$rhs)]>;
36 def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
37 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
38 def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
39 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
40 def X86fild : SDNode<"X86ISD::FILD", SDTX86Fild,
41 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
42 def X86fist : SDNode<"X86ISD::FIST", SDTX86Fist,
43 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
44 def X86fp_to_mem : SDNode<"X86ISD::FP_TO_INT_IN_MEM", SDTX86Fst,
45 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
46 def X86fp_cwd_get16 : SDNode<"X86ISD::FNSTCW16m", SDTX86CwdStore,
47 [SDNPHasChain, SDNPMayStore, SDNPSideEffect,
49 def X86fp_cwd_set16 : SDNode<"X86ISD::FLDCW16m", SDTX86CwdLoad,
50 [SDNPHasChain, SDNPMayLoad, SDNPSideEffect,
53 def X86fstf32 : PatFrag<(ops node:$val, node:$ptr),
54 (X86fst node:$val, node:$ptr), [{
55 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f32;
57 def X86fstf64 : PatFrag<(ops node:$val, node:$ptr),
58 (X86fst node:$val, node:$ptr), [{
59 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f64;
61 def X86fstf80 : PatFrag<(ops node:$val, node:$ptr),
62 (X86fst node:$val, node:$ptr), [{
63 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f80;
66 def X86fldf32 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{
67 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f32;
69 def X86fldf64 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{
70 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f64;
72 def X86fldf80 : PatFrag<(ops node:$ptr), (X86fld node:$ptr), [{
73 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::f80;
76 def X86fild16 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{
77 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
79 def X86fild32 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{
80 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
82 def X86fild64 : PatFrag<(ops node:$ptr), (X86fild node:$ptr), [{
83 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
86 def X86fist32 : PatFrag<(ops node:$val, node:$ptr),
87 (X86fist node:$val, node:$ptr), [{
88 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
91 def X86fist64 : PatFrag<(ops node:$val, node:$ptr),
92 (X86fist node:$val, node:$ptr), [{
93 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
96 def X86fp_to_i16mem : PatFrag<(ops node:$val, node:$ptr),
97 (X86fp_to_mem node:$val, node:$ptr), [{
98 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
100 def X86fp_to_i32mem : PatFrag<(ops node:$val, node:$ptr),
101 (X86fp_to_mem node:$val, node:$ptr), [{
102 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
104 def X86fp_to_i64mem : PatFrag<(ops node:$val, node:$ptr),
105 (X86fp_to_mem node:$val, node:$ptr), [{
106 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i64;
109 //===----------------------------------------------------------------------===//
110 // FPStack pattern fragments
111 //===----------------------------------------------------------------------===//
113 def fpimm0 : FPImmLeaf<fAny, [{
114 return Imm.isExactlyValue(+0.0);
117 def fpimmneg0 : FPImmLeaf<fAny, [{
118 return Imm.isExactlyValue(-0.0);
121 def fpimm1 : FPImmLeaf<fAny, [{
122 return Imm.isExactlyValue(+1.0);
125 def fpimmneg1 : FPImmLeaf<fAny, [{
126 return Imm.isExactlyValue(-1.0);
129 // Some 'special' instructions - expanded after instruction selection.
130 // Clobbers EFLAGS due to OR instruction used internally.
131 // FIXME: Can we model this in SelectionDAG?
132 let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [EFLAGS] in {
133 def FP32_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP32:$src),
134 [(X86fp_to_i16mem RFP32:$src, addr:$dst)]>;
135 def FP32_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP32:$src),
136 [(X86fp_to_i32mem RFP32:$src, addr:$dst)]>;
137 def FP32_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP32:$src),
138 [(X86fp_to_i64mem RFP32:$src, addr:$dst)]>;
139 def FP64_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP64:$src),
140 [(X86fp_to_i16mem RFP64:$src, addr:$dst)]>;
141 def FP64_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP64:$src),
142 [(X86fp_to_i32mem RFP64:$src, addr:$dst)]>;
143 def FP64_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP64:$src),
144 [(X86fp_to_i64mem RFP64:$src, addr:$dst)]>;
145 def FP80_TO_INT16_IN_MEM : PseudoI<(outs), (ins i16mem:$dst, RFP80:$src),
146 [(X86fp_to_i16mem RFP80:$src, addr:$dst)]>;
147 def FP80_TO_INT32_IN_MEM : PseudoI<(outs), (ins i32mem:$dst, RFP80:$src),
148 [(X86fp_to_i32mem RFP80:$src, addr:$dst)]>;
149 def FP80_TO_INT64_IN_MEM : PseudoI<(outs), (ins i64mem:$dst, RFP80:$src),
150 [(X86fp_to_i64mem RFP80:$src, addr:$dst)]>;
152 def FP80_ADDr : PseudoI<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2),
154 (any_X86fp80_add RFP80:$src1, RFP80:$src2))]>;
155 def FP80_ADDm32 : PseudoI<(outs RFP80:$dst), (ins RFP80:$src1, f32mem:$src2),
157 (any_X86fp80_add RFP80:$src1,
158 (f80 (extloadf32 addr:$src2))))]>;
161 // All FP Stack operations are represented with four instructions here. The
162 // first three instructions, generated by the instruction selector, use "RFP32"
163 // "RFP64" or "RFP80" registers: traditional register files to reference 32-bit,
164 // 64-bit or 80-bit floating point values. These sizes apply to the values,
165 // not the registers, which are always 80 bits; RFP32, RFP64 and RFP80 can be
166 // copied to each other without losing information. These instructions are all
167 // pseudo instructions and use the "_Fp" suffix.
168 // In some cases there are additional variants with a mixture of different
170 // The second instruction is defined with FPI, which is the actual instruction
171 // emitted by the assembler. These use "RST" registers, although frequently
172 // the actual register(s) used are implicit. These are always 80 bits.
173 // The FP stackifier pass converts one to the other after register allocation
176 // Note that the FpI instruction should have instruction selection info (e.g.
177 // a pattern) and the FPI instruction should have emission info (e.g. opcode
178 // encoding and asm printing info).
180 // FpIf32, FpIf64 - Floating Point Pseudo Instruction template.
181 // f32 instructions can use SSE1 and are predicated on FPStackf32 == !SSE1.
182 // f64 instructions can use SSE2 and are predicated on FPStackf64 == !SSE2.
183 // f80 instructions cannot use SSE and use neither of these.
184 class FpIf32<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
185 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32]>;
186 class FpIf64<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
187 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64]>;
189 // Factoring for arithmetic.
190 multiclass FPBinary_rr<SDPatternOperator OpNode> {
191 // Register op register -> register
192 // These are separated out because they have no reversed form.
193 def _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2), TwoArgFP,
194 [(set RFP32:$dst, (OpNode RFP32:$src1, RFP32:$src2))]>;
195 def _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2), TwoArgFP,
196 [(set RFP64:$dst, (OpNode RFP64:$src1, RFP64:$src2))]>;
197 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2), TwoArgFP,
198 [(set RFP80:$dst, (OpNode RFP80:$src1, RFP80:$src2))]>;
200 // The FopST0 series are not included here because of the irregularities
201 // in where the 'r' goes in assembly output.
202 // These instructions cannot address 80-bit memory.
203 multiclass FPBinary<SDPatternOperator OpNode, Format fp, string asmstring,
205 // ST(0) = ST(0) + [mem]
206 def _Fp32m : FpIf32<(outs RFP32:$dst),
207 (ins RFP32:$src1, f32mem:$src2), OneArgFPRW,
210 (OpNode RFP32:$src1, (loadf32 addr:$src2))),
212 (OpNode (loadf32 addr:$src2), RFP32:$src1)))]>;
213 def _Fp64m : FpIf64<(outs RFP64:$dst),
214 (ins RFP64:$src1, f64mem:$src2), OneArgFPRW,
217 (OpNode RFP64:$src1, (loadf64 addr:$src2))),
219 (OpNode (loadf64 addr:$src2), RFP64:$src1)))]>;
220 def _Fp64m32: FpIf64<(outs RFP64:$dst),
221 (ins RFP64:$src1, f32mem:$src2), OneArgFPRW,
224 (OpNode RFP64:$src1, (f64 (extloadf32 addr:$src2)))),
226 (OpNode (f64 (extloadf32 addr:$src2)), RFP64:$src1)))]>;
227 def _Fp80m32: FpI_<(outs RFP80:$dst),
228 (ins RFP80:$src1, f32mem:$src2), OneArgFPRW,
231 (OpNode RFP80:$src1, (f80 (extloadf32 addr:$src2)))),
233 (OpNode (f80 (extloadf32 addr:$src2)), RFP80:$src1)))]>;
234 def _Fp80m64: FpI_<(outs RFP80:$dst),
235 (ins RFP80:$src1, f64mem:$src2), OneArgFPRW,
238 (OpNode RFP80:$src1, (f80 (extloadf64 addr:$src2)))),
240 (OpNode (f80 (extloadf64 addr:$src2)), RFP80:$src1)))]>;
242 def _F32m : FPI<0xD8, fp, (outs), (ins f32mem:$src),
243 !strconcat("f", asmstring, "{s}\t$src")>;
245 def _F64m : FPI<0xDC, fp, (outs), (ins f64mem:$src),
246 !strconcat("f", asmstring, "{l}\t$src")>;
247 // ST(0) = ST(0) + [memint]
248 def _FpI16m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i16mem:$src2),
252 (OpNode RFP32:$src1, (X86fild16 addr:$src2))),
254 (OpNode (X86fild16 addr:$src2), RFP32:$src1)))]>;
255 def _FpI32m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i32mem:$src2),
259 (OpNode RFP32:$src1, (X86fild32 addr:$src2))),
261 (OpNode (X86fild32 addr:$src2), RFP32:$src1)))]>;
262 def _FpI16m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i16mem:$src2),
266 (OpNode RFP64:$src1, (X86fild16 addr:$src2))),
268 (OpNode (X86fild16 addr:$src2), RFP64:$src1)))]>;
269 def _FpI32m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i32mem:$src2),
273 (OpNode RFP64:$src1, (X86fild32 addr:$src2))),
275 (OpNode (X86fild32 addr:$src2), RFP64:$src1)))]>;
276 def _FpI16m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i16mem:$src2),
280 (OpNode RFP80:$src1, (X86fild16 addr:$src2))),
282 (OpNode (X86fild16 addr:$src2), RFP80:$src1)))]>;
283 def _FpI32m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i32mem:$src2),
287 (OpNode RFP80:$src1, (X86fild32 addr:$src2))),
289 (OpNode (X86fild32 addr:$src2), RFP80:$src1)))]>;
291 def _FI16m : FPI<0xDE, fp, (outs), (ins i16mem:$src),
292 !strconcat("fi", asmstring, "{s}\t$src")>;
294 def _FI32m : FPI<0xDA, fp, (outs), (ins i32mem:$src),
295 !strconcat("fi", asmstring, "{l}\t$src")>;
298 let Uses = [FPCW], mayRaiseFPException = 1 in {
299 // FPBinary_rr just defines pseudo-instructions, no need to set a scheduling
301 let hasNoSchedulingInfo = 1 in {
302 defm ADD : FPBinary_rr<any_fadd>;
303 defm SUB : FPBinary_rr<any_fsub>;
304 defm MUL : FPBinary_rr<any_fmul>;
305 defm DIV : FPBinary_rr<any_fdiv>;
308 // Sets the scheduling resources for the actual NAME#_F<size>m definitions.
309 let SchedRW = [WriteFAddLd] in {
310 defm ADD : FPBinary<any_fadd, MRM0m, "add">;
311 defm SUB : FPBinary<any_fsub, MRM4m, "sub">;
312 defm SUBR: FPBinary<any_fsub ,MRM5m, "subr", 0>;
315 let SchedRW = [WriteFMulLd] in {
316 defm MUL : FPBinary<any_fmul, MRM1m, "mul">;
319 let SchedRW = [WriteFDivLd] in {
320 defm DIV : FPBinary<any_fdiv, MRM6m, "div">;
321 defm DIVR: FPBinary<any_fdiv, MRM7m, "divr", 0>;
323 } // Uses = [FPCW], mayRaiseFPException = 1
325 class FPST0rInst<Format fp, string asm>
326 : FPI<0xD8, fp, (outs), (ins RSTi:$op), asm>;
327 class FPrST0Inst<Format fp, string asm>
328 : FPI<0xDC, fp, (outs), (ins RSTi:$op), asm>;
329 class FPrST0PInst<Format fp, string asm>
330 : FPI<0xDE, fp, (outs), (ins RSTi:$op), asm>;
332 // NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
333 // of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
334 // we have to put some 'r's in and take them out of weird places.
335 let SchedRW = [WriteFAdd], Uses = [FPCW], mayRaiseFPException = 1 in {
336 def ADD_FST0r : FPST0rInst <MRM0r, "fadd\t{$op, %st|st, $op}">;
337 def ADD_FrST0 : FPrST0Inst <MRM0r, "fadd\t{%st, $op|$op, st}">;
338 def ADD_FPrST0 : FPrST0PInst<MRM0r, "faddp\t{%st, $op|$op, st}">;
339 def SUBR_FST0r : FPST0rInst <MRM5r, "fsubr\t{$op, %st|st, $op}">;
340 def SUB_FrST0 : FPrST0Inst <MRM5r, "fsub{r}\t{%st, $op|$op, st}">;
341 def SUB_FPrST0 : FPrST0PInst<MRM5r, "fsub{r}p\t{%st, $op|$op, st}">;
342 def SUB_FST0r : FPST0rInst <MRM4r, "fsub\t{$op, %st|st, $op}">;
343 def SUBR_FrST0 : FPrST0Inst <MRM4r, "fsub{|r}\t{%st, $op|$op, st}">;
344 def SUBR_FPrST0 : FPrST0PInst<MRM4r, "fsub{|r}p\t{%st, $op|$op, st}">;
346 let SchedRW = [WriteFCom], Uses = [FPCW], mayRaiseFPException = 1 in {
347 def COM_FST0r : FPST0rInst <MRM2r, "fcom\t$op">;
348 def COMP_FST0r : FPST0rInst <MRM3r, "fcomp\t$op">;
350 let SchedRW = [WriteFMul], Uses = [FPCW], mayRaiseFPException = 1 in {
351 def MUL_FST0r : FPST0rInst <MRM1r, "fmul\t{$op, %st|st, $op}">;
352 def MUL_FrST0 : FPrST0Inst <MRM1r, "fmul\t{%st, $op|$op, st}">;
353 def MUL_FPrST0 : FPrST0PInst<MRM1r, "fmulp\t{%st, $op|$op, st}">;
355 let SchedRW = [WriteFDiv], Uses = [FPCW], mayRaiseFPException = 1 in {
356 def DIVR_FST0r : FPST0rInst <MRM7r, "fdivr\t{$op, %st|st, $op}">;
357 def DIV_FrST0 : FPrST0Inst <MRM7r, "fdiv{r}\t{%st, $op|$op, st}">;
358 def DIV_FPrST0 : FPrST0PInst<MRM7r, "fdiv{r}p\t{%st, $op|$op, st}">;
359 def DIV_FST0r : FPST0rInst <MRM6r, "fdiv\t{$op, %st|st, $op}">;
360 def DIVR_FrST0 : FPrST0Inst <MRM6r, "fdiv{|r}\t{%st, $op|$op, st}">;
361 def DIVR_FPrST0 : FPrST0PInst<MRM6r, "fdiv{|r}p\t{%st, $op|$op, st}">;
365 multiclass FPUnary<SDPatternOperator OpNode, Format fp, string asmstring> {
366 def _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src), OneArgFPRW,
367 [(set RFP32:$dst, (OpNode RFP32:$src))]>;
368 def _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src), OneArgFPRW,
369 [(set RFP64:$dst, (OpNode RFP64:$src))]>;
370 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src), OneArgFPRW,
371 [(set RFP80:$dst, (OpNode RFP80:$src))]>;
372 def _F : FPI<0xD9, fp, (outs), (ins), asmstring>;
375 let SchedRW = [WriteFSign] in {
376 defm CHS : FPUnary<fneg, MRM_E0, "fchs">;
377 defm ABS : FPUnary<fabs, MRM_E1, "fabs">;
380 let Uses = [FPCW], mayRaiseFPException = 1 in {
381 let SchedRW = [WriteFSqrt80] in
382 defm SQRT: FPUnary<any_fsqrt,MRM_FA, "fsqrt">;
384 let SchedRW = [WriteFCom] in {
385 let hasSideEffects = 0 in {
386 def TST_Fp32 : FpIf32<(outs), (ins RFP32:$src), OneArgFP, []>;
387 def TST_Fp64 : FpIf64<(outs), (ins RFP64:$src), OneArgFP, []>;
388 def TST_Fp80 : FpI_<(outs), (ins RFP80:$src), OneArgFP, []>;
391 def TST_F : FPI<0xD9, MRM_E4, (outs), (ins), "ftst">;
393 } // Uses = [FPCW], mayRaiseFPException = 1
395 let SchedRW = [WriteFTest], Defs = [FPSW] in {
396 def XAM_Fp32 : FpIf32<(outs), (ins RFP32:$src), OneArgFP, []>;
397 def XAM_Fp64 : FpIf64<(outs), (ins RFP64:$src), OneArgFP, []>;
398 def XAM_Fp80 : FpI_<(outs), (ins RFP80:$src), OneArgFP, []>;
399 def XAM_F : FPI<0xD9, MRM_E5, (outs), (ins), "fxam">;
402 // Versions of FP instructions that take a single memory operand. Added for the
403 // disassembler; remove as they are included with patterns elsewhere.
404 let SchedRW = [WriteFComLd], Uses = [FPCW], mayRaiseFPException = 1,
406 def FCOM32m : FPI<0xD8, MRM2m, (outs), (ins f32mem:$src), "fcom{s}\t$src">;
407 def FCOMP32m : FPI<0xD8, MRM3m, (outs), (ins f32mem:$src), "fcomp{s}\t$src">;
409 def FCOM64m : FPI<0xDC, MRM2m, (outs), (ins f64mem:$src), "fcom{l}\t$src">;
410 def FCOMP64m : FPI<0xDC, MRM3m, (outs), (ins f64mem:$src), "fcomp{l}\t$src">;
412 def FICOM16m : FPI<0xDE, MRM2m, (outs), (ins i16mem:$src), "ficom{s}\t$src">;
413 def FICOMP16m: FPI<0xDE, MRM3m, (outs), (ins i16mem:$src), "ficomp{s}\t$src">;
415 def FICOM32m : FPI<0xDA, MRM2m, (outs), (ins i32mem:$src), "ficom{l}\t$src">;
416 def FICOMP32m: FPI<0xDA, MRM3m, (outs), (ins i32mem:$src), "ficomp{l}\t$src">;
419 let SchedRW = [WriteMicrocoded] in {
420 let Defs = [FPSW, FPCW], mayLoad = 1 in {
421 def FLDENVm : FPI<0xD9, MRM4m, (outs), (ins anymem:$src), "fldenv\t$src">;
422 def FRSTORm : FPI<0xDD, MRM4m, (outs), (ins anymem:$src), "frstor\t$src">;
425 let Defs = [FPSW, FPCW], Uses = [FPSW, FPCW], mayStore = 1 in {
426 def FSTENVm : FPI<0xD9, MRM6m, (outs), (ins anymem:$dst), "fnstenv\t$dst">;
427 def FSAVEm : FPI<0xDD, MRM6m, (outs), (ins anymem:$dst), "fnsave\t$dst">;
430 let Uses = [FPSW], mayStore = 1 in
431 def FNSTSWm : FPI<0xDD, MRM7m, (outs), (ins i16mem:$dst), "fnstsw\t$dst">;
434 def FBLDm : FPI<0xDF, MRM4m, (outs), (ins f80mem:$src), "fbld\t$src">;
435 let Uses = [FPCW] ,mayRaiseFPException = 1, mayStore = 1 in
436 def FBSTPm : FPI<0xDF, MRM6m, (outs), (ins f80mem:$dst), "fbstp\t$dst">;
439 // Floating point cmovs.
440 class FpIf32CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
441 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32, HasCMOV]>;
442 class FpIf64CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
443 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64, HasCMOV]>;
445 multiclass FPCMov<PatLeaf cc> {
446 def _Fp32 : FpIf32CMov<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2),
448 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2,
450 def _Fp64 : FpIf64CMov<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2),
452 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2,
454 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2),
456 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2,
461 let SchedRW = [WriteFCMOV] in {
462 let Uses = [EFLAGS], Constraints = "$src1 = $dst" in {
463 defm CMOVB : FPCMov<X86_COND_B>;
464 defm CMOVBE : FPCMov<X86_COND_BE>;
465 defm CMOVE : FPCMov<X86_COND_E>;
466 defm CMOVP : FPCMov<X86_COND_P>;
467 defm CMOVNB : FPCMov<X86_COND_AE>;
468 defm CMOVNBE: FPCMov<X86_COND_A>;
469 defm CMOVNE : FPCMov<X86_COND_NE>;
470 defm CMOVNP : FPCMov<X86_COND_NP>;
471 } // Uses = [EFLAGS], Constraints = "$src1 = $dst"
473 let Predicates = [HasCMOV] in {
474 // These are not factored because there's no clean way to pass DA/DB.
475 def CMOVB_F : FPI<0xDA, MRM0r, (outs), (ins RSTi:$op),
476 "fcmovb\t{$op, %st|st, $op}">;
477 def CMOVBE_F : FPI<0xDA, MRM2r, (outs), (ins RSTi:$op),
478 "fcmovbe\t{$op, %st|st, $op}">;
479 def CMOVE_F : FPI<0xDA, MRM1r, (outs), (ins RSTi:$op),
480 "fcmove\t{$op, %st|st, $op}">;
481 def CMOVP_F : FPI<0xDA, MRM3r, (outs), (ins RSTi:$op),
482 "fcmovu\t{$op, %st|st, $op}">;
483 def CMOVNB_F : FPI<0xDB, MRM0r, (outs), (ins RSTi:$op),
484 "fcmovnb\t{$op, %st|st, $op}">;
485 def CMOVNBE_F: FPI<0xDB, MRM2r, (outs), (ins RSTi:$op),
486 "fcmovnbe\t{$op, %st|st, $op}">;
487 def CMOVNE_F : FPI<0xDB, MRM1r, (outs), (ins RSTi:$op),
488 "fcmovne\t{$op, %st|st, $op}">;
489 def CMOVNP_F : FPI<0xDB, MRM3r, (outs), (ins RSTi:$op),
490 "fcmovnu\t{$op, %st|st, $op}">;
491 } // Predicates = [HasCMOV]
494 let mayRaiseFPException = 1 in {
495 // Floating point loads & stores.
496 let SchedRW = [WriteLoad], Uses = [FPCW] in {
497 let canFoldAsLoad = 1 in {
498 def LD_Fp32m : FpIf32<(outs RFP32:$dst), (ins f32mem:$src), ZeroArgFP,
499 [(set RFP32:$dst, (loadf32 addr:$src))]>;
500 def LD_Fp64m : FpIf64<(outs RFP64:$dst), (ins f64mem:$src), ZeroArgFP,
501 [(set RFP64:$dst, (loadf64 addr:$src))]>;
502 def LD_Fp80m : FpI_<(outs RFP80:$dst), (ins f80mem:$src), ZeroArgFP,
503 [(set RFP80:$dst, (loadf80 addr:$src))]>;
505 def LD_Fp32m64 : FpIf64<(outs RFP64:$dst), (ins f32mem:$src), ZeroArgFP,
506 [(set RFP64:$dst, (f64 (extloadf32 addr:$src)))]>;
507 def LD_Fp64m80 : FpI_<(outs RFP80:$dst), (ins f64mem:$src), ZeroArgFP,
508 [(set RFP80:$dst, (f80 (extloadf64 addr:$src)))]>;
509 def LD_Fp32m80 : FpI_<(outs RFP80:$dst), (ins f32mem:$src), ZeroArgFP,
510 [(set RFP80:$dst, (f80 (extloadf32 addr:$src)))]>;
511 let mayRaiseFPException = 0 in {
512 def ILD_Fp16m32: FpIf32<(outs RFP32:$dst), (ins i16mem:$src), ZeroArgFP,
513 [(set RFP32:$dst, (X86fild16 addr:$src))]>;
514 def ILD_Fp32m32: FpIf32<(outs RFP32:$dst), (ins i32mem:$src), ZeroArgFP,
515 [(set RFP32:$dst, (X86fild32 addr:$src))]>;
516 def ILD_Fp64m32: FpIf32<(outs RFP32:$dst), (ins i64mem:$src), ZeroArgFP,
517 [(set RFP32:$dst, (X86fild64 addr:$src))]>;
518 def ILD_Fp16m64: FpIf64<(outs RFP64:$dst), (ins i16mem:$src), ZeroArgFP,
519 [(set RFP64:$dst, (X86fild16 addr:$src))]>;
520 def ILD_Fp32m64: FpIf64<(outs RFP64:$dst), (ins i32mem:$src), ZeroArgFP,
521 [(set RFP64:$dst, (X86fild32 addr:$src))]>;
522 def ILD_Fp64m64: FpIf64<(outs RFP64:$dst), (ins i64mem:$src), ZeroArgFP,
523 [(set RFP64:$dst, (X86fild64 addr:$src))]>;
524 def ILD_Fp16m80: FpI_<(outs RFP80:$dst), (ins i16mem:$src), ZeroArgFP,
525 [(set RFP80:$dst, (X86fild16 addr:$src))]>;
526 def ILD_Fp32m80: FpI_<(outs RFP80:$dst), (ins i32mem:$src), ZeroArgFP,
527 [(set RFP80:$dst, (X86fild32 addr:$src))]>;
528 def ILD_Fp64m80: FpI_<(outs RFP80:$dst), (ins i64mem:$src), ZeroArgFP,
529 [(set RFP80:$dst, (X86fild64 addr:$src))]>;
530 } // mayRaiseFPException = 0
533 let SchedRW = [WriteStore], Uses = [FPCW] in {
534 def ST_Fp32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP,
535 [(store RFP32:$src, addr:$op)]>;
536 def ST_Fp64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP,
537 [(truncstoref32 RFP64:$src, addr:$op)]>;
538 def ST_Fp64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP,
539 [(store RFP64:$src, addr:$op)]>;
540 def ST_Fp80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP,
541 [(truncstoref32 RFP80:$src, addr:$op)]>;
542 def ST_Fp80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP,
543 [(truncstoref64 RFP80:$src, addr:$op)]>;
544 // FST does not support 80-bit memory target; FSTP must be used.
546 let mayStore = 1, hasSideEffects = 0 in {
547 def ST_FpP32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP, []>;
548 def ST_FpP64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP, []>;
549 def ST_FpP64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP, []>;
550 def ST_FpP80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP, []>;
551 def ST_FpP80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP, []>;
554 def ST_FpP80m : FpI_<(outs), (ins f80mem:$op, RFP80:$src), OneArgFP,
555 [(store RFP80:$src, addr:$op)]>;
557 let mayStore = 1, hasSideEffects = 0 in {
558 def IST_Fp16m32 : FpIf32<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP, []>;
559 def IST_Fp32m32 : FpIf32<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP,
560 [(X86fist32 RFP32:$src, addr:$op)]>;
561 def IST_Fp64m32 : FpIf32<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP,
562 [(X86fist64 RFP32:$src, addr:$op)]>;
563 def IST_Fp16m64 : FpIf64<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP, []>;
564 def IST_Fp32m64 : FpIf64<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP,
565 [(X86fist32 RFP64:$src, addr:$op)]>;
566 def IST_Fp64m64 : FpIf64<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP,
567 [(X86fist64 RFP64:$src, addr:$op)]>;
568 def IST_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP, []>;
569 def IST_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP,
570 [(X86fist32 RFP80:$src, addr:$op)]>;
571 def IST_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP,
572 [(X86fist64 RFP80:$src, addr:$op)]>;
574 } // SchedRW, Uses = [FPCW]
576 let mayLoad = 1, SchedRW = [WriteLoad], Uses = [FPCW] in {
577 def LD_F32m : FPI<0xD9, MRM0m, (outs), (ins f32mem:$src), "fld{s}\t$src">;
578 def LD_F64m : FPI<0xDD, MRM0m, (outs), (ins f64mem:$src), "fld{l}\t$src">;
579 def LD_F80m : FPI<0xDB, MRM5m, (outs), (ins f80mem:$src), "fld{t}\t$src">;
580 let mayRaiseFPException = 0 in {
581 def ILD_F16m : FPI<0xDF, MRM0m, (outs), (ins i16mem:$src), "fild{s}\t$src">;
582 def ILD_F32m : FPI<0xDB, MRM0m, (outs), (ins i32mem:$src), "fild{l}\t$src">;
583 def ILD_F64m : FPI<0xDF, MRM5m, (outs), (ins i64mem:$src), "fild{ll}\t$src">;
586 let mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in {
587 def ST_F32m : FPI<0xD9, MRM2m, (outs), (ins f32mem:$dst), "fst{s}\t$dst">;
588 def ST_F64m : FPI<0xDD, MRM2m, (outs), (ins f64mem:$dst), "fst{l}\t$dst">;
589 def ST_FP32m : FPI<0xD9, MRM3m, (outs), (ins f32mem:$dst), "fstp{s}\t$dst">;
590 def ST_FP64m : FPI<0xDD, MRM3m, (outs), (ins f64mem:$dst), "fstp{l}\t$dst">;
591 def ST_FP80m : FPI<0xDB, MRM7m, (outs), (ins f80mem:$dst), "fstp{t}\t$dst">;
592 def IST_F16m : FPI<0xDF, MRM2m, (outs), (ins i16mem:$dst), "fist{s}\t$dst">;
593 def IST_F32m : FPI<0xDB, MRM2m, (outs), (ins i32mem:$dst), "fist{l}\t$dst">;
594 def IST_FP16m : FPI<0xDF, MRM3m, (outs), (ins i16mem:$dst), "fistp{s}\t$dst">;
595 def IST_FP32m : FPI<0xDB, MRM3m, (outs), (ins i32mem:$dst), "fistp{l}\t$dst">;
596 def IST_FP64m : FPI<0xDF, MRM7m, (outs), (ins i64mem:$dst), "fistp{ll}\t$dst">;
599 // FISTTP requires SSE3 even though it's a FPStack op.
600 let Predicates = [HasSSE3], SchedRW = [WriteStore], Uses = [FPCW] in {
601 def ISTT_Fp16m32 : FpI_<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP,
602 [(X86fp_to_i16mem RFP32:$src, addr:$op)]>;
603 def ISTT_Fp32m32 : FpI_<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP,
604 [(X86fp_to_i32mem RFP32:$src, addr:$op)]>;
605 def ISTT_Fp64m32 : FpI_<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP,
606 [(X86fp_to_i64mem RFP32:$src, addr:$op)]>;
607 def ISTT_Fp16m64 : FpI_<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP,
608 [(X86fp_to_i16mem RFP64:$src, addr:$op)]>;
609 def ISTT_Fp32m64 : FpI_<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP,
610 [(X86fp_to_i32mem RFP64:$src, addr:$op)]>;
611 def ISTT_Fp64m64 : FpI_<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP,
612 [(X86fp_to_i64mem RFP64:$src, addr:$op)]>;
613 def ISTT_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP,
614 [(X86fp_to_i16mem RFP80:$src, addr:$op)]>;
615 def ISTT_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP,
616 [(X86fp_to_i32mem RFP80:$src, addr:$op)]>;
617 def ISTT_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP,
618 [(X86fp_to_i64mem RFP80:$src, addr:$op)]>;
619 } // Predicates = [HasSSE3]
621 let mayStore = 1, SchedRW = [WriteStore], Uses = [FPCW] in {
622 def ISTT_FP16m : FPI<0xDF, MRM1m, (outs), (ins i16mem:$dst), "fisttp{s}\t$dst">;
623 def ISTT_FP32m : FPI<0xDB, MRM1m, (outs), (ins i32mem:$dst), "fisttp{l}\t$dst">;
624 def ISTT_FP64m : FPI<0xDD, MRM1m, (outs), (ins i64mem:$dst), "fisttp{ll}\t$dst">;
627 // FP Stack manipulation instructions.
628 let SchedRW = [WriteMove], Uses = [FPCW] in {
629 def LD_Frr : FPI<0xD9, MRM0r, (outs), (ins RSTi:$op), "fld\t$op">;
630 def ST_Frr : FPI<0xDD, MRM2r, (outs), (ins RSTi:$op), "fst\t$op">;
631 def ST_FPrr : FPI<0xDD, MRM3r, (outs), (ins RSTi:$op), "fstp\t$op">;
632 let mayRaiseFPException = 0 in
633 def XCH_F : FPI<0xD9, MRM1r, (outs), (ins RSTi:$op), "fxch\t$op">;
636 // Floating point constant loads.
637 let SchedRW = [WriteZero], Uses = [FPCW] in {
638 def LD_Fp032 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
639 [(set RFP32:$dst, fpimm0)]>;
640 def LD_Fp132 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
641 [(set RFP32:$dst, fpimm1)]>;
642 def LD_Fp064 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP,
643 [(set RFP64:$dst, fpimm0)]>;
644 def LD_Fp164 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP,
645 [(set RFP64:$dst, fpimm1)]>;
646 def LD_Fp080 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP,
647 [(set RFP80:$dst, fpimm0)]>;
648 def LD_Fp180 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP,
649 [(set RFP80:$dst, fpimm1)]>;
652 let SchedRW = [WriteFLD0], Uses = [FPCW], mayRaiseFPException = 0 in
653 def LD_F0 : FPI<0xD9, MRM_EE, (outs), (ins), "fldz">;
655 let SchedRW = [WriteFLD1], Uses = [FPCW], mayRaiseFPException = 0 in
656 def LD_F1 : FPI<0xD9, MRM_E8, (outs), (ins), "fld1">;
658 let SchedRW = [WriteFLDC], Defs = [FPSW], Uses = [FPCW], mayRaiseFPException = 0 in {
659 def FLDL2T : I<0xD9, MRM_E9, (outs), (ins), "fldl2t", []>;
660 def FLDL2E : I<0xD9, MRM_EA, (outs), (ins), "fldl2e", []>;
661 def FLDPI : I<0xD9, MRM_EB, (outs), (ins), "fldpi", []>;
662 def FLDLG2 : I<0xD9, MRM_EC, (outs), (ins), "fldlg2", []>;
663 def FLDLN2 : I<0xD9, MRM_ED, (outs), (ins), "fldln2", []>;
666 // Floating point compares.
667 let SchedRW = [WriteFCom], Uses = [FPCW], hasSideEffects = 0 in {
668 def UCOM_Fpr32 : FpIf32<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP, []>;
669 def UCOM_Fpr64 : FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP, []>;
670 def UCOM_Fpr80 : FpI_ <(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP, []>;
671 def COM_Fpr32 : FpIf32<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP, []>;
672 def COM_Fpr64 : FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP, []>;
673 def COM_Fpr80 : FpI_ <(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP, []>;
675 } // mayRaiseFPException = 1
677 let SchedRW = [WriteFCom], mayRaiseFPException = 1 in {
678 // CC = ST(0) cmp ST(i)
679 let Defs = [EFLAGS, FPSW], Uses = [FPCW] in {
680 def UCOM_FpIr32: FpI_<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
681 [(set EFLAGS, (X86any_fcmp RFP32:$lhs, RFP32:$rhs))]>,
682 Requires<[FPStackf32, HasCMOV]>;
683 def UCOM_FpIr64: FpI_<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
684 [(set EFLAGS, (X86any_fcmp RFP64:$lhs, RFP64:$rhs))]>,
685 Requires<[FPStackf64, HasCMOV]>;
686 def UCOM_FpIr80: FpI_<(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
687 [(set EFLAGS, (X86any_fcmp RFP80:$lhs, RFP80:$rhs))]>,
689 def COM_FpIr32: FpI_<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
690 [(set EFLAGS, (X86strict_fcmps RFP32:$lhs, RFP32:$rhs))]>,
691 Requires<[FPStackf32, HasCMOV]>;
692 def COM_FpIr64: FpI_<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
693 [(set EFLAGS, (X86strict_fcmps RFP64:$lhs, RFP64:$rhs))]>,
694 Requires<[FPStackf64, HasCMOV]>;
695 def COM_FpIr80: FpI_<(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
696 [(set EFLAGS, (X86strict_fcmps RFP80:$lhs, RFP80:$rhs))]>,
700 let Uses = [ST0, FPCW] in {
701 def UCOM_Fr : FPI<0xDD, MRM4r, // FPSW = cmp ST(0) with ST(i)
702 (outs), (ins RSTi:$reg), "fucom\t$reg">;
703 def UCOM_FPr : FPI<0xDD, MRM5r, // FPSW = cmp ST(0) with ST(i), pop
704 (outs), (ins RSTi:$reg), "fucomp\t$reg">;
705 def UCOM_FPPr : FPI<0xDA, MRM_E9, // cmp ST(0) with ST(1), pop, pop
706 (outs), (ins), "fucompp">;
709 let Defs = [EFLAGS, FPSW], Uses = [ST0, FPCW] in {
710 def UCOM_FIr : FPI<0xDB, MRM5r, // CC = cmp ST(0) with ST(i)
711 (outs), (ins RSTi:$reg), "fucomi\t{$reg, %st|st, $reg}">;
712 def UCOM_FIPr : FPI<0xDF, MRM5r, // CC = cmp ST(0) with ST(i), pop
713 (outs), (ins RSTi:$reg), "fucompi\t{$reg, %st|st, $reg}">;
715 def COM_FIr : FPI<0xDB, MRM6r, (outs), (ins RSTi:$reg),
716 "fcomi\t{$reg, %st|st, $reg}">;
717 def COM_FIPr : FPI<0xDF, MRM6r, (outs), (ins RSTi:$reg),
718 "fcompi\t{$reg, %st|st, $reg}">;
722 // Floating point flag ops.
723 let SchedRW = [WriteALU] in {
724 let Defs = [AX, FPSW], Uses = [FPSW], hasSideEffects = 0 in
725 def FNSTSW16r : I<0xDF, MRM_E0, // AX = fp flags
726 (outs), (ins), "fnstsw\t{%ax|ax}", []>;
727 let Defs = [FPSW], Uses = [FPCW] in
728 def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
729 (outs), (ins i16mem:$dst), "fnstcw\t$dst",
730 [(X86fp_cwd_get16 addr:$dst)]>;
732 let Defs = [FPSW,FPCW], mayLoad = 1 in
733 def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
734 (outs), (ins i16mem:$dst), "fldcw\t$dst",
735 [(X86fp_cwd_set16 addr:$dst)]>,
738 // FPU control instructions
739 let SchedRW = [WriteMicrocoded] in {
740 def FFREE : FPI<0xDD, MRM0r, (outs), (ins RSTi:$reg), "ffree\t$reg">;
741 def FFREEP : FPI<0xDF, MRM0r, (outs), (ins RSTi:$reg), "ffreep\t$reg">;
743 let Defs = [FPSW, FPCW] in
744 def FNINIT : I<0xDB, MRM_E3, (outs), (ins), "fninit", []>;
747 def FNCLEX : I<0xDB, MRM_E2, (outs), (ins), "fnclex", []>;
750 // Operand-less floating-point instructions for the disassembler.
752 def FNOP : I<0xD9, MRM_D0, (outs), (ins), "fnop", []>, Sched<[WriteNop]>;
754 let SchedRW = [WriteMicrocoded] in {
755 let Defs = [FPSW] in {
756 def WAIT : I<0x9B, RawFrm, (outs), (ins), "wait", []>;
757 def FDECSTP : I<0xD9, MRM_F6, (outs), (ins), "fdecstp", []>;
758 def FINCSTP : I<0xD9, MRM_F7, (outs), (ins), "fincstp", []>;
759 let Uses = [FPCW], mayRaiseFPException = 1 in {
760 def F2XM1 : I<0xD9, MRM_F0, (outs), (ins), "f2xm1", []>;
761 def FYL2X : I<0xD9, MRM_F1, (outs), (ins), "fyl2x", []>;
762 def FPTAN : I<0xD9, MRM_F2, (outs), (ins), "fptan", []>;
763 def FPATAN : I<0xD9, MRM_F3, (outs), (ins), "fpatan", []>;
764 def FXTRACT : I<0xD9, MRM_F4, (outs), (ins), "fxtract", []>;
765 def FPREM1 : I<0xD9, MRM_F5, (outs), (ins), "fprem1", []>;
766 def FPREM : I<0xD9, MRM_F8, (outs), (ins), "fprem", []>;
767 def FYL2XP1 : I<0xD9, MRM_F9, (outs), (ins), "fyl2xp1", []>;
768 def FSIN : I<0xD9, MRM_FE, (outs), (ins), "fsin", []>;
769 def FCOS : I<0xD9, MRM_FF, (outs), (ins), "fcos", []>;
770 def FSINCOS : I<0xD9, MRM_FB, (outs), (ins), "fsincos", []>;
771 def FRNDINT : I<0xD9, MRM_FC, (outs), (ins), "frndint", []>;
772 def FSCALE : I<0xD9, MRM_FD, (outs), (ins), "fscale", []>;
773 def FCOMPP : I<0xDE, MRM_D9, (outs), (ins), "fcompp", []>;
774 } // Uses = [FPCW], mayRaiseFPException = 1
777 let Uses = [FPSW, FPCW] in {
778 def FXSAVE : I<0xAE, MRM0m, (outs), (ins opaquemem:$dst),
779 "fxsave\t$dst", [(int_x86_fxsave addr:$dst)]>, PS,
781 def FXSAVE64 : RI<0xAE, MRM0m, (outs), (ins opaquemem:$dst),
782 "fxsave64\t$dst", [(int_x86_fxsave64 addr:$dst)]>,
783 PS, Requires<[HasFXSR, In64BitMode]>;
784 } // Uses = [FPSW, FPCW]
786 let Defs = [FPSW, FPCW] in {
787 def FXRSTOR : I<0xAE, MRM1m, (outs), (ins opaquemem:$src),
788 "fxrstor\t$src", [(int_x86_fxrstor addr:$src)]>,
789 PS, Requires<[HasFXSR]>;
790 def FXRSTOR64 : RI<0xAE, MRM1m, (outs), (ins opaquemem:$src),
791 "fxrstor64\t$src", [(int_x86_fxrstor64 addr:$src)]>,
792 PS, Requires<[HasFXSR, In64BitMode]>;
793 } // Defs = [FPSW, FPCW]
796 //===----------------------------------------------------------------------===//
797 // Non-Instruction Patterns
798 //===----------------------------------------------------------------------===//
800 // Required for RET of f32 / f64 / f80 values.
801 def : Pat<(X86fldf32 addr:$src), (LD_Fp32m addr:$src)>;
802 def : Pat<(X86fldf32 addr:$src), (LD_Fp32m64 addr:$src)>;
803 def : Pat<(X86fldf64 addr:$src), (LD_Fp64m addr:$src)>;
804 def : Pat<(X86fldf32 addr:$src), (LD_Fp32m80 addr:$src)>;
805 def : Pat<(X86fldf64 addr:$src), (LD_Fp64m80 addr:$src)>;
806 def : Pat<(X86fldf80 addr:$src), (LD_Fp80m addr:$src)>;
808 // Required for CALL which return f32 / f64 / f80 values.
809 def : Pat<(X86fstf32 RFP32:$src, addr:$op), (ST_Fp32m addr:$op, RFP32:$src)>;
810 def : Pat<(X86fstf32 RFP64:$src, addr:$op), (ST_Fp64m32 addr:$op, RFP64:$src)>;
811 def : Pat<(X86fstf64 RFP64:$src, addr:$op), (ST_Fp64m addr:$op, RFP64:$src)>;
812 def : Pat<(X86fstf32 RFP80:$src, addr:$op), (ST_Fp80m32 addr:$op, RFP80:$src)>;
813 def : Pat<(X86fstf64 RFP80:$src, addr:$op), (ST_Fp80m64 addr:$op, RFP80:$src)>;
814 def : Pat<(X86fstf80 RFP80:$src, addr:$op), (ST_FpP80m addr:$op, RFP80:$src)>;
816 // Floating point constant -0.0 and -1.0
817 def : Pat<(f32 fpimmneg0), (CHS_Fp32 (LD_Fp032))>, Requires<[FPStackf32]>;
818 def : Pat<(f32 fpimmneg1), (CHS_Fp32 (LD_Fp132))>, Requires<[FPStackf32]>;
819 def : Pat<(f64 fpimmneg0), (CHS_Fp64 (LD_Fp064))>, Requires<[FPStackf64]>;
820 def : Pat<(f64 fpimmneg1), (CHS_Fp64 (LD_Fp164))>, Requires<[FPStackf64]>;
821 def : Pat<(f80 fpimmneg0), (CHS_Fp80 (LD_Fp080))>;
822 def : Pat<(f80 fpimmneg1), (CHS_Fp80 (LD_Fp180))>;
824 // FP extensions map onto simple pseudo-value conversions if they are to/from
826 def : Pat<(f64 (any_fpextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP64)>,
827 Requires<[FPStackf32]>;
828 def : Pat<(f80 (any_fpextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP80)>,
829 Requires<[FPStackf32]>;
830 def : Pat<(f80 (any_fpextend RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP80)>,
831 Requires<[FPStackf64]>;
833 // FP truncations map onto simple pseudo-value conversions if they are to/from
834 // the FP stack. We have validated that only value-preserving truncations make
836 def : Pat<(f32 (any_fpround RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP32)>,
837 Requires<[FPStackf32]>;
838 def : Pat<(f32 (any_fpround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP32)>,
839 Requires<[FPStackf32]>;
840 def : Pat<(f64 (any_fpround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP64)>,
841 Requires<[FPStackf64]>;