blob: 50e81a5406f327c2b8718f2993282072fd7761d0 [file] [log] [blame]
Arnold Schwaighofer48abc5c2007-10-12 21:30:57 +00001//==- X86InstrFPStack.td - Describe the X86 Instruction Set --*- tablegen -*-=//
Evan Chengffcb95b2006-02-21 19:13:53 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chengffcb95b2006-02-21 19:13:53 +00007//
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
Evan Cheng06a8aa12006-03-17 19:55:52 +000016//===----------------------------------------------------------------------===//
Evan Cheng2246f842006-03-18 01:23:20 +000017// FPStack specific DAG Nodes.
18//===----------------------------------------------------------------------===//
19
Chris Lattner6fa2f9c2008-03-09 07:05:32 +000020def SDTX86FpGet2 : SDTypeProfile<2, 0, [SDTCisVT<0, f80>,
21 SDTCisVT<1, f80>]>;
Dale Johannesen411d9c52007-07-03 17:07:33 +000022def SDTX86Fld : SDTypeProfile<1, 2, [SDTCisFP<0>,
Dale Johannesenbf6b8272007-07-10 20:53:41 +000023 SDTCisPtrTy<1>,
24 SDTCisVT<2, OtherVT>]>;
Dale Johannesen411d9c52007-07-03 17:07:33 +000025def SDTX86Fst : SDTypeProfile<0, 3, [SDTCisFP<0>,
Dale Johannesenbf6b8272007-07-10 20:53:41 +000026 SDTCisPtrTy<1>,
27 SDTCisVT<2, OtherVT>]>;
Dale Johannesen411d9c52007-07-03 17:07:33 +000028def SDTX86Fild : SDTypeProfile<1, 2, [SDTCisFP<0>, SDTCisPtrTy<1>,
29 SDTCisVT<2, OtherVT>]>;
30def SDTX86FpToIMem : SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisPtrTy<1>]>;
Evan Cheng2246f842006-03-18 01:23:20 +000031
Anton Korobeynikov45b22fa2007-11-16 01:31:51 +000032def SDTX86CwdStore : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
33
Chris Lattnerba7e7562008-01-10 07:59:24 +000034def X86fld : SDNode<"X86ISD::FLD", SDTX86Fld,
35 [SDNPHasChain, SDNPMayLoad]>;
36def X86fst : SDNode<"X86ISD::FST", SDTX86Fst,
37 [SDNPHasChain, SDNPInFlag, SDNPMayStore]>;
38def X86fild : SDNode<"X86ISD::FILD", SDTX86Fild,
39 [SDNPHasChain, SDNPMayLoad]>;
40def X86fildflag : SDNode<"X86ISD::FILD_FLAG", SDTX86Fild,
41 [SDNPHasChain, SDNPOutFlag, SDNPMayLoad]>;
Evan Cheng2246f842006-03-18 01:23:20 +000042def X86fp_to_i16mem : SDNode<"X86ISD::FP_TO_INT16_IN_MEM", SDTX86FpToIMem,
Chris Lattner07290932010-09-22 01:05:16 +000043 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
Evan Cheng2246f842006-03-18 01:23:20 +000044def X86fp_to_i32mem : SDNode<"X86ISD::FP_TO_INT32_IN_MEM", SDTX86FpToIMem,
Chris Lattner07290932010-09-22 01:05:16 +000045 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
Evan Cheng2246f842006-03-18 01:23:20 +000046def X86fp_to_i64mem : SDNode<"X86ISD::FP_TO_INT64_IN_MEM", SDTX86FpToIMem,
Chris Lattner07290932010-09-22 01:05:16 +000047 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
Anton Korobeynikov45b22fa2007-11-16 01:31:51 +000048def X86fp_cwd_get16 : SDNode<"X86ISD::FNSTCW16m", SDTX86CwdStore,
Chris Lattner07290932010-09-22 01:05:16 +000049 [SDNPHasChain, SDNPMayStore, SDNPSideEffect,
50 SDNPMemOperand]>;
Evan Cheng2246f842006-03-18 01:23:20 +000051
52//===----------------------------------------------------------------------===//
Evan Cheng06a8aa12006-03-17 19:55:52 +000053// FPStack pattern fragments
54//===----------------------------------------------------------------------===//
55
Dale Johannesen849f2142007-07-03 00:53:03 +000056def fpimm0 : PatLeaf<(fpimm), [{
Evan Cheng06a8aa12006-03-17 19:55:52 +000057 return N->isExactlyValue(+0.0);
58}]>;
59
Dale Johannesen849f2142007-07-03 00:53:03 +000060def fpimmneg0 : PatLeaf<(fpimm), [{
Evan Cheng06a8aa12006-03-17 19:55:52 +000061 return N->isExactlyValue(-0.0);
62}]>;
63
Dale Johannesen849f2142007-07-03 00:53:03 +000064def fpimm1 : PatLeaf<(fpimm), [{
Evan Cheng06a8aa12006-03-17 19:55:52 +000065 return N->isExactlyValue(+1.0);
66}]>;
67
Dale Johannesen849f2142007-07-03 00:53:03 +000068def fpimmneg1 : PatLeaf<(fpimm), [{
Evan Cheng06a8aa12006-03-17 19:55:52 +000069 return N->isExactlyValue(-1.0);
70}]>;
71
Evan Cheng4e4c71e2006-02-21 20:00:20 +000072// Some 'special' instructions
Dan Gohman533297b2009-10-29 18:10:34 +000073let usesCustomInserter = 1 in { // Expanded after instruction selection.
Dale Johannesen849f2142007-07-03 00:53:03 +000074 def FP32_TO_INT16_IN_MEM : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +000075 (outs), (ins i16mem:$dst, RFP32:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +000076 "##FP32_TO_INT16_IN_MEM PSEUDO!",
Dale Johannesen411d9c52007-07-03 17:07:33 +000077 [(X86fp_to_i16mem RFP32:$src, addr:$dst)]>;
Dale Johannesen849f2142007-07-03 00:53:03 +000078 def FP32_TO_INT32_IN_MEM : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +000079 (outs), (ins i32mem:$dst, RFP32:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +000080 "##FP32_TO_INT32_IN_MEM PSEUDO!",
Dale Johannesen411d9c52007-07-03 17:07:33 +000081 [(X86fp_to_i32mem RFP32:$src, addr:$dst)]>;
Dale Johannesen849f2142007-07-03 00:53:03 +000082 def FP32_TO_INT64_IN_MEM : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +000083 (outs), (ins i64mem:$dst, RFP32:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +000084 "##FP32_TO_INT64_IN_MEM PSEUDO!",
Dale Johannesen411d9c52007-07-03 17:07:33 +000085 [(X86fp_to_i64mem RFP32:$src, addr:$dst)]>;
Dale Johannesen849f2142007-07-03 00:53:03 +000086 def FP64_TO_INT16_IN_MEM : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +000087 (outs), (ins i16mem:$dst, RFP64:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +000088 "##FP64_TO_INT16_IN_MEM PSEUDO!",
Dale Johannesen411d9c52007-07-03 17:07:33 +000089 [(X86fp_to_i16mem RFP64:$src, addr:$dst)]>;
Dale Johannesen849f2142007-07-03 00:53:03 +000090 def FP64_TO_INT32_IN_MEM : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +000091 (outs), (ins i32mem:$dst, RFP64:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +000092 "##FP64_TO_INT32_IN_MEM PSEUDO!",
Dale Johannesen411d9c52007-07-03 17:07:33 +000093 [(X86fp_to_i32mem RFP64:$src, addr:$dst)]>;
Dale Johannesen849f2142007-07-03 00:53:03 +000094 def FP64_TO_INT64_IN_MEM : I<0, Pseudo,
Evan Cheng64d80e32007-07-19 01:14:50 +000095 (outs), (ins i64mem:$dst, RFP64:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +000096 "##FP64_TO_INT64_IN_MEM PSEUDO!",
Dale Johannesen411d9c52007-07-03 17:07:33 +000097 [(X86fp_to_i64mem RFP64:$src, addr:$dst)]>;
Dale Johannesena996d522007-08-07 01:17:37 +000098 def FP80_TO_INT16_IN_MEM : I<0, Pseudo,
99 (outs), (ins i16mem:$dst, RFP80:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +0000100 "##FP80_TO_INT16_IN_MEM PSEUDO!",
Dale Johannesena996d522007-08-07 01:17:37 +0000101 [(X86fp_to_i16mem RFP80:$src, addr:$dst)]>;
102 def FP80_TO_INT32_IN_MEM : I<0, Pseudo,
103 (outs), (ins i32mem:$dst, RFP80:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +0000104 "##FP80_TO_INT32_IN_MEM PSEUDO!",
Dale Johannesena996d522007-08-07 01:17:37 +0000105 [(X86fp_to_i32mem RFP80:$src, addr:$dst)]>;
106 def FP80_TO_INT64_IN_MEM : I<0, Pseudo,
107 (outs), (ins i64mem:$dst, RFP80:$src),
Dale Johannesen27c31052008-03-25 23:29:30 +0000108 "##FP80_TO_INT64_IN_MEM PSEUDO!",
Dale Johannesena996d522007-08-07 01:17:37 +0000109 [(X86fp_to_i64mem RFP80:$src, addr:$dst)]>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000110}
111
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000112// All FP Stack operations are represented with four instructions here. The
113// first three instructions, generated by the instruction selector, use "RFP32"
114// "RFP64" or "RFP80" registers: traditional register files to reference 32-bit,
115// 64-bit or 80-bit floating point values. These sizes apply to the values,
116// not the registers, which are always 80 bits; RFP32, RFP64 and RFP80 can be
117// copied to each other without losing information. These instructions are all
118// pseudo instructions and use the "_Fp" suffix.
119// In some cases there are additional variants with a mixture of different
120// register sizes.
Evan Chengffcb95b2006-02-21 19:13:53 +0000121// The second instruction is defined with FPI, which is the actual instruction
Dale Johannesene377d4d2007-07-04 21:07:47 +0000122// emitted by the assembler. These use "RST" registers, although frequently
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000123// the actual register(s) used are implicit. These are always 80 bits.
Dale Johannesene377d4d2007-07-04 21:07:47 +0000124// The FP stackifier pass converts one to the other after register allocation
125// occurs.
Evan Chengffcb95b2006-02-21 19:13:53 +0000126//
127// Note that the FpI instruction should have instruction selection info (e.g.
128// a pattern) and the FPI instruction should have emission info (e.g. opcode
129// encoding and asm printing info).
130
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000131// Pseudo Instructions for FP stack return values.
Chris Lattner8e6da152008-03-10 21:08:41 +0000132def FpGET_ST0_32 : FpI_<(outs RFP32:$dst), (ins), SpecialFP, []>; // FPR = ST(0)
133def FpGET_ST0_64 : FpI_<(outs RFP64:$dst), (ins), SpecialFP, []>; // FPR = ST(0)
134def FpGET_ST0_80 : FpI_<(outs RFP80:$dst), (ins), SpecialFP, []>; // FPR = ST(0)
Evan Chengffcb95b2006-02-21 19:13:53 +0000135
Chris Lattner24e0a542008-03-21 06:38:26 +0000136// FpGET_ST1* should only be issued *after* an FpGET_ST0* has been issued when
137// there are two values live out on the stack from a call or inlineasm. This
138// magic is handled by the stackifier. It is not valid to emit FpGET_ST1* and
139// then FpGET_ST0*. In addition, it is invalid for any FP-using operations to
140// occur between them.
141def FpGET_ST1_32 : FpI_<(outs RFP32:$dst), (ins), SpecialFP, []>; // FPR = ST(1)
142def FpGET_ST1_64 : FpI_<(outs RFP64:$dst), (ins), SpecialFP, []>; // FPR = ST(1)
143def FpGET_ST1_80 : FpI_<(outs RFP80:$dst), (ins), SpecialFP, []>; // FPR = ST(1)
144
Evan Cheng071a2792007-09-11 19:55:27 +0000145let Defs = [ST0] in {
Chris Lattner8e6da152008-03-10 21:08:41 +0000146def FpSET_ST0_32 : FpI_<(outs), (ins RFP32:$src), SpecialFP, []>; // ST(0) = FPR
147def FpSET_ST0_64 : FpI_<(outs), (ins RFP64:$src), SpecialFP, []>; // ST(0) = FPR
148def FpSET_ST0_80 : FpI_<(outs), (ins RFP80:$src), SpecialFP, []>; // ST(0) = FPR
Evan Cheng071a2792007-09-11 19:55:27 +0000149}
Dale Johannesen6a308112007-08-06 21:31:06 +0000150
Evan Chenga0eedac2009-02-09 23:32:07 +0000151let Defs = [ST1] in {
152def FpSET_ST1_32 : FpI_<(outs), (ins RFP32:$src), SpecialFP, []>; // ST(1) = FPR
153def FpSET_ST1_64 : FpI_<(outs), (ins RFP64:$src), SpecialFP, []>; // ST(1) = FPR
154def FpSET_ST1_80 : FpI_<(outs), (ins RFP80:$src), SpecialFP, []>; // ST(1) = FPR
155}
156
Bob Wilson3b7bbfd2010-08-26 18:08:11 +0000157// FpIf32, FpIf64 - Floating Point Pseudo Instruction template.
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000158// f32 instructions can use SSE1 and are predicated on FPStackf32 == !SSE1.
159// f64 instructions can use SSE2 and are predicated on FPStackf64 == !SSE2.
160// f80 instructions cannot use SSE and use neither of these.
161class FpIf32<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
162 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32]>;
163class FpIf64<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
164 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000165
Dale Johannesen59a58732007-08-05 18:49:15 +0000166// Register copies. Just copies, the shortening ones do not truncate.
Chris Lattnera731c9f2008-01-11 07:18:17 +0000167let neverHasSideEffects = 1 in {
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000168 def MOV_Fp3232 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src), SpecialFP, []>;
169 def MOV_Fp3264 : FpIf32<(outs RFP64:$dst), (ins RFP32:$src), SpecialFP, []>;
170 def MOV_Fp6432 : FpIf32<(outs RFP32:$dst), (ins RFP64:$src), SpecialFP, []>;
171 def MOV_Fp6464 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src), SpecialFP, []>;
172 def MOV_Fp8032 : FpIf32<(outs RFP32:$dst), (ins RFP80:$src), SpecialFP, []>;
173 def MOV_Fp3280 : FpIf32<(outs RFP80:$dst), (ins RFP32:$src), SpecialFP, []>;
174 def MOV_Fp8064 : FpIf64<(outs RFP64:$dst), (ins RFP80:$src), SpecialFP, []>;
175 def MOV_Fp6480 : FpIf64<(outs RFP80:$dst), (ins RFP64:$src), SpecialFP, []>;
176 def MOV_Fp8080 : FpI_ <(outs RFP80:$dst), (ins RFP80:$src), SpecialFP, []>;
Chris Lattnera731c9f2008-01-11 07:18:17 +0000177}
Evan Chengffcb95b2006-02-21 19:13:53 +0000178
Dale Johannesene377d4d2007-07-04 21:07:47 +0000179// Factoring for arithmetic.
180multiclass FPBinary_rr<SDNode OpNode> {
181// Register op register -> register
182// These are separated out because they have no reversed form.
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000183def _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2), TwoArgFP,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000184 [(set RFP32:$dst, (OpNode RFP32:$src1, RFP32:$src2))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000185def _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2), TwoArgFP,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000186 [(set RFP64:$dst, (OpNode RFP64:$src1, RFP64:$src2))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000187def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2), TwoArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000188 [(set RFP80:$dst, (OpNode RFP80:$src1, RFP80:$src2))]>;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000189}
190// The FopST0 series are not included here because of the irregularities
191// in where the 'r' goes in assembly output.
Dale Johannesen59a58732007-08-05 18:49:15 +0000192// These instructions cannot address 80-bit memory.
Dale Johannesene377d4d2007-07-04 21:07:47 +0000193multiclass FPBinary<SDNode OpNode, Format fp, string asmstring> {
194// ST(0) = ST(0) + [mem]
Sean Callanan108934c2009-12-18 00:01:26 +0000195def _Fp32m : FpIf32<(outs RFP32:$dst),
196 (ins RFP32:$src1, f32mem:$src2), OneArgFPRW,
Dale Johannesenbf6b8272007-07-10 20:53:41 +0000197 [(set RFP32:$dst,
198 (OpNode RFP32:$src1, (loadf32 addr:$src2)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000199def _Fp64m : FpIf64<(outs RFP64:$dst),
200 (ins RFP64:$src1, f64mem:$src2), OneArgFPRW,
Dale Johannesenbf6b8272007-07-10 20:53:41 +0000201 [(set RFP64:$dst,
202 (OpNode RFP64:$src1, (loadf64 addr:$src2)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000203def _Fp64m32: FpIf64<(outs RFP64:$dst),
204 (ins RFP64:$src1, f32mem:$src2), OneArgFPRW,
Dale Johannesenafdc7fd2007-07-10 21:53:30 +0000205 [(set RFP64:$dst,
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000206 (OpNode RFP64:$src1, (f64 (extloadf32 addr:$src2))))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000207def _Fp80m32: FpI_<(outs RFP80:$dst),
208 (ins RFP80:$src1, f32mem:$src2), OneArgFPRW,
Dale Johannesen59a58732007-08-05 18:49:15 +0000209 [(set RFP80:$dst,
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000210 (OpNode RFP80:$src1, (f80 (extloadf32 addr:$src2))))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000211def _Fp80m64: FpI_<(outs RFP80:$dst),
212 (ins RFP80:$src1, f64mem:$src2), OneArgFPRW,
Dale Johannesen59a58732007-08-05 18:49:15 +0000213 [(set RFP80:$dst,
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000214 (OpNode RFP80:$src1, (f80 (extloadf64 addr:$src2))))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000215def _F32m : FPI<0xD8, fp, (outs), (ins f32mem:$src),
Sean Callanan108934c2009-12-18 00:01:26 +0000216 !strconcat("f", !strconcat(asmstring, "{s}\t$src"))> {
217 let mayLoad = 1;
218}
Evan Cheng64d80e32007-07-19 01:14:50 +0000219def _F64m : FPI<0xDC, fp, (outs), (ins f64mem:$src),
Sean Callanan108934c2009-12-18 00:01:26 +0000220 !strconcat("f", !strconcat(asmstring, "{l}\t$src"))> {
221 let mayLoad = 1;
222}
Dale Johannesene377d4d2007-07-04 21:07:47 +0000223// ST(0) = ST(0) + [memint]
Sean Callanan108934c2009-12-18 00:01:26 +0000224def _FpI16m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i16mem:$src2),
225 OneArgFPRW,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000226 [(set RFP32:$dst, (OpNode RFP32:$src1,
227 (X86fild addr:$src2, i16)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000228def _FpI32m32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src1, i32mem:$src2),
229 OneArgFPRW,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000230 [(set RFP32:$dst, (OpNode RFP32:$src1,
231 (X86fild addr:$src2, i32)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000232def _FpI16m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i16mem:$src2),
233 OneArgFPRW,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000234 [(set RFP64:$dst, (OpNode RFP64:$src1,
235 (X86fild addr:$src2, i16)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000236def _FpI32m64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src1, i32mem:$src2),
237 OneArgFPRW,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000238 [(set RFP64:$dst, (OpNode RFP64:$src1,
239 (X86fild addr:$src2, i32)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000240def _FpI16m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i16mem:$src2),
241 OneArgFPRW,
Dale Johannesen59a58732007-08-05 18:49:15 +0000242 [(set RFP80:$dst, (OpNode RFP80:$src1,
243 (X86fild addr:$src2, i16)))]>;
Sean Callanan108934c2009-12-18 00:01:26 +0000244def _FpI32m80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, i32mem:$src2),
245 OneArgFPRW,
Dale Johannesen59a58732007-08-05 18:49:15 +0000246 [(set RFP80:$dst, (OpNode RFP80:$src1,
247 (X86fild addr:$src2, i32)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000248def _FI16m : FPI<0xDE, fp, (outs), (ins i16mem:$src),
Sean Callanan108934c2009-12-18 00:01:26 +0000249 !strconcat("fi", !strconcat(asmstring, "{s}\t$src"))> {
250 let mayLoad = 1;
251}
Evan Cheng64d80e32007-07-19 01:14:50 +0000252def _FI32m : FPI<0xDA, fp, (outs), (ins i32mem:$src),
Sean Callanan108934c2009-12-18 00:01:26 +0000253 !strconcat("fi", !strconcat(asmstring, "{l}\t$src"))> {
254 let mayLoad = 1;
255}
Dale Johannesene377d4d2007-07-04 21:07:47 +0000256}
257
258defm ADD : FPBinary_rr<fadd>;
259defm SUB : FPBinary_rr<fsub>;
260defm MUL : FPBinary_rr<fmul>;
261defm DIV : FPBinary_rr<fdiv>;
262defm ADD : FPBinary<fadd, MRM0m, "add">;
263defm SUB : FPBinary<fsub, MRM4m, "sub">;
264defm SUBR: FPBinary<fsub ,MRM5m, "subr">;
265defm MUL : FPBinary<fmul, MRM1m, "mul">;
266defm DIV : FPBinary<fdiv, MRM6m, "div">;
267defm DIVR: FPBinary<fdiv, MRM7m, "divr">;
Evan Chengffcb95b2006-02-21 19:13:53 +0000268
269class FPST0rInst<bits<8> o, string asm>
Evan Cheng64d80e32007-07-19 01:14:50 +0000270 : FPI<o, AddRegFrm, (outs), (ins RST:$op), asm>, D8;
Evan Chengffcb95b2006-02-21 19:13:53 +0000271class FPrST0Inst<bits<8> o, string asm>
Evan Cheng64d80e32007-07-19 01:14:50 +0000272 : FPI<o, AddRegFrm, (outs), (ins RST:$op), asm>, DC;
Evan Chengffcb95b2006-02-21 19:13:53 +0000273class FPrST0PInst<bits<8> o, string asm>
Evan Cheng64d80e32007-07-19 01:14:50 +0000274 : FPI<o, AddRegFrm, (outs), (ins RST:$op), asm>, DE;
Evan Chengffcb95b2006-02-21 19:13:53 +0000275
Evan Chengffcb95b2006-02-21 19:13:53 +0000276// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
277// of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
278// we have to put some 'r's in and take them out of weird places.
Dan Gohmanb1576f52007-07-31 20:11:57 +0000279def ADD_FST0r : FPST0rInst <0xC0, "fadd\t$op">;
280def ADD_FrST0 : FPrST0Inst <0xC0, "fadd\t{%st(0), $op|$op, %ST(0)}">;
281def ADD_FPrST0 : FPrST0PInst<0xC0, "faddp\t$op">;
282def SUBR_FST0r : FPST0rInst <0xE8, "fsubr\t$op">;
283def SUB_FrST0 : FPrST0Inst <0xE8, "fsub{r}\t{%st(0), $op|$op, %ST(0)}">;
284def SUB_FPrST0 : FPrST0PInst<0xE8, "fsub{r}p\t$op">;
285def SUB_FST0r : FPST0rInst <0xE0, "fsub\t$op">;
286def SUBR_FrST0 : FPrST0Inst <0xE0, "fsub{|r}\t{%st(0), $op|$op, %ST(0)}">;
287def SUBR_FPrST0 : FPrST0PInst<0xE0, "fsub{|r}p\t$op">;
288def MUL_FST0r : FPST0rInst <0xC8, "fmul\t$op">;
289def MUL_FrST0 : FPrST0Inst <0xC8, "fmul\t{%st(0), $op|$op, %ST(0)}">;
290def MUL_FPrST0 : FPrST0PInst<0xC8, "fmulp\t$op">;
291def DIVR_FST0r : FPST0rInst <0xF8, "fdivr\t$op">;
292def DIV_FrST0 : FPrST0Inst <0xF8, "fdiv{r}\t{%st(0), $op|$op, %ST(0)}">;
293def DIV_FPrST0 : FPrST0PInst<0xF8, "fdiv{r}p\t$op">;
294def DIV_FST0r : FPST0rInst <0xF0, "fdiv\t$op">;
295def DIVR_FrST0 : FPrST0Inst <0xF0, "fdiv{|r}\t{%st(0), $op|$op, %ST(0)}">;
296def DIVR_FPrST0 : FPrST0PInst<0xF0, "fdiv{|r}p\t$op">;
Evan Chengffcb95b2006-02-21 19:13:53 +0000297
Sean Callanan108934c2009-12-18 00:01:26 +0000298def COM_FST0r : FPST0rInst <0xD0, "fcom\t$op">;
299def COMP_FST0r : FPST0rInst <0xD8, "fcomp\t$op">;
300
Evan Chengffcb95b2006-02-21 19:13:53 +0000301// Unary operations.
Dale Johannesene377d4d2007-07-04 21:07:47 +0000302multiclass FPUnary<SDNode OpNode, bits<8> opcode, string asmstring> {
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000303def _Fp32 : FpIf32<(outs RFP32:$dst), (ins RFP32:$src), OneArgFPRW,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000304 [(set RFP32:$dst, (OpNode RFP32:$src))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000305def _Fp64 : FpIf64<(outs RFP64:$dst), (ins RFP64:$src), OneArgFPRW,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000306 [(set RFP64:$dst, (OpNode RFP64:$src))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000307def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src), OneArgFPRW,
Dale Johannesen59a58732007-08-05 18:49:15 +0000308 [(set RFP80:$dst, (OpNode RFP80:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000309def _F : FPI<opcode, RawFrm, (outs), (ins), asmstring>, D9;
Evan Chengffcb95b2006-02-21 19:13:53 +0000310}
311
Dale Johannesene377d4d2007-07-04 21:07:47 +0000312defm CHS : FPUnary<fneg, 0xE0, "fchs">;
313defm ABS : FPUnary<fabs, 0xE1, "fabs">;
314defm SQRT: FPUnary<fsqrt,0xFA, "fsqrt">;
315defm SIN : FPUnary<fsin, 0xFE, "fsin">;
316defm COS : FPUnary<fcos, 0xFF, "fcos">;
317
Chris Lattnera731c9f2008-01-11 07:18:17 +0000318let neverHasSideEffects = 1 in {
319def TST_Fp32 : FpIf32<(outs), (ins RFP32:$src), OneArgFP, []>;
320def TST_Fp64 : FpIf64<(outs), (ins RFP64:$src), OneArgFP, []>;
321def TST_Fp80 : FpI_<(outs), (ins RFP80:$src), OneArgFP, []>;
322}
Evan Cheng64d80e32007-07-19 01:14:50 +0000323def TST_F : FPI<0xE4, RawFrm, (outs), (ins), "ftst">, D9;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000324
Sean Callanan5ab94032009-09-16 01:13:52 +0000325// Versions of FP instructions that take a single memory operand. Added for the
326// disassembler; remove as they are included with patterns elsewhere.
Kevin Enderby9d0838f2010-05-03 21:31:40 +0000327def FCOM32m : FPI<0xD8, MRM2m, (outs), (ins f32mem:$src), "fcom{s}\t$src">;
328def FCOMP32m : FPI<0xD8, MRM3m, (outs), (ins f32mem:$src), "fcomp{s}\t$src">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000329
330def FLDENVm : FPI<0xD9, MRM4m, (outs), (ins f32mem:$src), "fldenv\t$src">;
Sean Callanan108934c2009-12-18 00:01:26 +0000331def FSTENVm : FPI<0xD9, MRM6m, (outs f32mem:$dst), (ins), "fnstenv\t$dst">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000332
333def FICOM32m : FPI<0xDA, MRM2m, (outs), (ins i32mem:$src), "ficom{l}\t$src">;
334def FICOMP32m: FPI<0xDA, MRM3m, (outs), (ins i32mem:$src), "ficomp{l}\t$src">;
335
Kevin Enderby9d0838f2010-05-03 21:31:40 +0000336def FCOM64m : FPI<0xDC, MRM2m, (outs), (ins f64mem:$src), "fcom{l}\t$src">;
337def FCOMP64m : FPI<0xDC, MRM3m, (outs), (ins f64mem:$src), "fcomp{l}\t$src">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000338
Sean Callanan5ab94032009-09-16 01:13:52 +0000339def FRSTORm : FPI<0xDD, MRM4m, (outs f32mem:$dst), (ins), "frstor\t$dst">;
Sean Callanan108934c2009-12-18 00:01:26 +0000340def FSAVEm : FPI<0xDD, MRM6m, (outs f32mem:$dst), (ins), "fnsave\t$dst">;
341def FNSTSWm : FPI<0xDD, MRM7m, (outs f32mem:$dst), (ins), "fnstsw\t$dst">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000342
Kevin Enderby9d0838f2010-05-03 21:31:40 +0000343def FICOM16m : FPI<0xDE, MRM2m, (outs), (ins i16mem:$src), "ficom{s}\t$src">;
344def FICOMP16m: FPI<0xDE, MRM3m, (outs), (ins i16mem:$src), "ficomp{s}\t$src">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000345
346def FBLDm : FPI<0xDF, MRM4m, (outs), (ins f32mem:$src), "fbld\t$src">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000347def FBSTPm : FPI<0xDF, MRM6m, (outs f32mem:$dst), (ins), "fbstp\t$dst">;
Sean Callanan5ab94032009-09-16 01:13:52 +0000348
Dale Johannesene377d4d2007-07-04 21:07:47 +0000349// Floating point cmovs.
Chris Lattner314a1132010-03-14 18:31:44 +0000350class FpIf32CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
351 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf32, HasCMov]>;
352class FpIf64CMov<dag outs, dag ins, FPFormat fp, list<dag> pattern> :
353 FpI_<outs, ins, fp, pattern>, Requires<[FPStackf64, HasCMov]>;
354
Dale Johannesene377d4d2007-07-04 21:07:47 +0000355multiclass FPCMov<PatLeaf cc> {
Chris Lattner314a1132010-03-14 18:31:44 +0000356 def _Fp32 : FpIf32CMov<(outs RFP32:$dst), (ins RFP32:$src1, RFP32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +0000357 CondMovFP,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000358 [(set RFP32:$dst, (X86cmov RFP32:$src1, RFP32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000359 cc, EFLAGS))]>;
Chris Lattner314a1132010-03-14 18:31:44 +0000360 def _Fp64 : FpIf64CMov<(outs RFP64:$dst), (ins RFP64:$src1, RFP64:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +0000361 CondMovFP,
Dale Johannesene377d4d2007-07-04 21:07:47 +0000362 [(set RFP64:$dst, (X86cmov RFP64:$src1, RFP64:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000363 cc, EFLAGS))]>;
364 def _Fp80 : FpI_<(outs RFP80:$dst), (ins RFP80:$src1, RFP80:$src2),
365 CondMovFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000366 [(set RFP80:$dst, (X86cmov RFP80:$src1, RFP80:$src2,
Chris Lattner314a1132010-03-14 18:31:44 +0000367 cc, EFLAGS))]>,
368 Requires<[HasCMov]>;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000369}
Chris Lattner314a1132010-03-14 18:31:44 +0000370
Eric Christopher96ab7f42010-06-18 23:56:07 +0000371let Uses = [EFLAGS], Constraints = "$src1 = $dst" in {
Dale Johannesene377d4d2007-07-04 21:07:47 +0000372defm CMOVB : FPCMov<X86_COND_B>;
373defm CMOVBE : FPCMov<X86_COND_BE>;
374defm CMOVE : FPCMov<X86_COND_E>;
375defm CMOVP : FPCMov<X86_COND_P>;
376defm CMOVNB : FPCMov<X86_COND_AE>;
377defm CMOVNBE: FPCMov<X86_COND_A>;
378defm CMOVNE : FPCMov<X86_COND_NE>;
379defm CMOVNP : FPCMov<X86_COND_NP>;
Eric Christopher96ab7f42010-06-18 23:56:07 +0000380} // Uses = [EFLAGS], Constraints = "$src1 = $dst"
Dale Johannesene377d4d2007-07-04 21:07:47 +0000381
Chris Lattner314a1132010-03-14 18:31:44 +0000382let Predicates = [HasCMov] in {
Dale Johannesene377d4d2007-07-04 21:07:47 +0000383// These are not factored because there's no clean way to pass DA/DB.
Evan Cheng64d80e32007-07-19 01:14:50 +0000384def CMOVB_F : FPI<0xC0, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000385 "fcmovb\t{$op, %st(0)|%ST(0), $op}">, DA;
Evan Cheng64d80e32007-07-19 01:14:50 +0000386def CMOVBE_F : FPI<0xD0, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000387 "fcmovbe\t{$op, %st(0)|%ST(0), $op}">, DA;
Evan Cheng64d80e32007-07-19 01:14:50 +0000388def CMOVE_F : FPI<0xC8, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000389 "fcmove\t{$op, %st(0)|%ST(0), $op}">, DA;
Evan Cheng64d80e32007-07-19 01:14:50 +0000390def CMOVP_F : FPI<0xD8, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000391 "fcmovu\t {$op, %st(0)|%ST(0), $op}">, DA;
Evan Cheng64d80e32007-07-19 01:14:50 +0000392def CMOVNB_F : FPI<0xC0, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000393 "fcmovnb\t{$op, %st(0)|%ST(0), $op}">, DB;
Evan Cheng64d80e32007-07-19 01:14:50 +0000394def CMOVNBE_F: FPI<0xD0, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000395 "fcmovnbe\t{$op, %st(0)|%ST(0), $op}">, DB;
Evan Cheng64d80e32007-07-19 01:14:50 +0000396def CMOVNE_F : FPI<0xC8, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000397 "fcmovne\t{$op, %st(0)|%ST(0), $op}">, DB;
Evan Cheng64d80e32007-07-19 01:14:50 +0000398def CMOVNP_F : FPI<0xD8, AddRegFrm, (outs RST:$op), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000399 "fcmovnu\t{$op, %st(0)|%ST(0), $op}">, DB;
Chris Lattner314a1132010-03-14 18:31:44 +0000400} // Predicates = [HasCMov]
Evan Chengffcb95b2006-02-21 19:13:53 +0000401
402// Floating point loads & stores.
Dan Gohman15511cf2008-12-03 18:15:48 +0000403let canFoldAsLoad = 1 in {
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000404def LD_Fp32m : FpIf32<(outs RFP32:$dst), (ins f32mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000405 [(set RFP32:$dst, (loadf32 addr:$src))]>;
Dan Gohmanbc9d98b2010-02-27 23:47:46 +0000406let isReMaterializable = 1 in
Bill Wendling691de382007-12-17 22:17:14 +0000407 def LD_Fp64m : FpIf64<(outs RFP64:$dst), (ins f64mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000408 [(set RFP64:$dst, (loadf64 addr:$src))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000409def LD_Fp80m : FpI_<(outs RFP80:$dst), (ins f80mem:$src), ZeroArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000410 [(set RFP80:$dst, (loadf80 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000411}
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000412def LD_Fp32m64 : FpIf64<(outs RFP64:$dst), (ins f32mem:$src), ZeroArgFP,
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000413 [(set RFP64:$dst, (f64 (extloadf32 addr:$src)))]>;
414def LD_Fp64m80 : FpI_<(outs RFP80:$dst), (ins f64mem:$src), ZeroArgFP,
415 [(set RFP80:$dst, (f80 (extloadf64 addr:$src)))]>;
416def LD_Fp32m80 : FpI_<(outs RFP80:$dst), (ins f32mem:$src), ZeroArgFP,
417 [(set RFP80:$dst, (f80 (extloadf32 addr:$src)))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000418def ILD_Fp16m32: FpIf32<(outs RFP32:$dst), (ins i16mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000419 [(set RFP32:$dst, (X86fild addr:$src, i16))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000420def ILD_Fp32m32: FpIf32<(outs RFP32:$dst), (ins i32mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000421 [(set RFP32:$dst, (X86fild addr:$src, i32))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000422def ILD_Fp64m32: FpIf32<(outs RFP32:$dst), (ins i64mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000423 [(set RFP32:$dst, (X86fild addr:$src, i64))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000424def ILD_Fp16m64: FpIf64<(outs RFP64:$dst), (ins i16mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000425 [(set RFP64:$dst, (X86fild addr:$src, i16))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000426def ILD_Fp32m64: FpIf64<(outs RFP64:$dst), (ins i32mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000427 [(set RFP64:$dst, (X86fild addr:$src, i32))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000428def ILD_Fp64m64: FpIf64<(outs RFP64:$dst), (ins i64mem:$src), ZeroArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000429 [(set RFP64:$dst, (X86fild addr:$src, i64))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000430def ILD_Fp16m80: FpI_<(outs RFP80:$dst), (ins i16mem:$src), ZeroArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000431 [(set RFP80:$dst, (X86fild addr:$src, i16))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000432def ILD_Fp32m80: FpI_<(outs RFP80:$dst), (ins i32mem:$src), ZeroArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000433 [(set RFP80:$dst, (X86fild addr:$src, i32))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000434def ILD_Fp64m80: FpI_<(outs RFP80:$dst), (ins i64mem:$src), ZeroArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000435 [(set RFP80:$dst, (X86fild addr:$src, i64))]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000436
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000437def ST_Fp32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000438 [(store RFP32:$src, addr:$op)]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000439def ST_Fp64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000440 [(truncstoref32 RFP64:$src, addr:$op)]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000441def ST_Fp64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000442 [(store RFP64:$src, addr:$op)]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000443def ST_Fp80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000444 [(truncstoref32 RFP80:$src, addr:$op)]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000445def ST_Fp80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000446 [(truncstoref64 RFP80:$src, addr:$op)]>;
447// FST does not support 80-bit memory target; FSTP must be used.
Evan Chengffcb95b2006-02-21 19:13:53 +0000448
Chris Lattnera731c9f2008-01-11 07:18:17 +0000449let mayStore = 1, neverHasSideEffects = 1 in {
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000450def ST_FpP32m : FpIf32<(outs), (ins f32mem:$op, RFP32:$src), OneArgFP, []>;
451def ST_FpP64m32 : FpIf64<(outs), (ins f32mem:$op, RFP64:$src), OneArgFP, []>;
452def ST_FpP64m : FpIf64<(outs), (ins f64mem:$op, RFP64:$src), OneArgFP, []>;
453def ST_FpP80m32 : FpI_<(outs), (ins f32mem:$op, RFP80:$src), OneArgFP, []>;
454def ST_FpP80m64 : FpI_<(outs), (ins f64mem:$op, RFP80:$src), OneArgFP, []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000455}
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000456def ST_FpP80m : FpI_<(outs), (ins f80mem:$op, RFP80:$src), OneArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000457 [(store RFP80:$src, addr:$op)]>;
Chris Lattnera731c9f2008-01-11 07:18:17 +0000458let mayStore = 1, neverHasSideEffects = 1 in {
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000459def IST_Fp16m32 : FpIf32<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP, []>;
460def IST_Fp32m32 : FpIf32<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP, []>;
461def IST_Fp64m32 : FpIf32<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP, []>;
462def IST_Fp16m64 : FpIf64<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP, []>;
463def IST_Fp32m64 : FpIf64<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP, []>;
464def IST_Fp64m64 : FpIf64<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP, []>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000465def IST_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP, []>;
466def IST_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP, []>;
467def IST_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP, []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000468}
Evan Chengffcb95b2006-02-21 19:13:53 +0000469
Chris Lattnerba7e7562008-01-10 07:59:24 +0000470let mayLoad = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000471def LD_F32m : FPI<0xD9, MRM0m, (outs), (ins f32mem:$src), "fld{s}\t$src">;
472def LD_F64m : FPI<0xDD, MRM0m, (outs), (ins f64mem:$src), "fld{l}\t$src">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000473def LD_F80m : FPI<0xDB, MRM5m, (outs), (ins f80mem:$src), "fld{t}\t$src">;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000474def ILD_F16m : FPI<0xDF, MRM0m, (outs), (ins i16mem:$src), "fild{s}\t$src">;
475def ILD_F32m : FPI<0xDB, MRM0m, (outs), (ins i32mem:$src), "fild{l}\t$src">;
476def ILD_F64m : FPI<0xDF, MRM5m, (outs), (ins i64mem:$src), "fild{ll}\t$src">;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000477}
478let mayStore = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000479def ST_F32m : FPI<0xD9, MRM2m, (outs), (ins f32mem:$dst), "fst{s}\t$dst">;
480def ST_F64m : FPI<0xDD, MRM2m, (outs), (ins f64mem:$dst), "fst{l}\t$dst">;
481def ST_FP32m : FPI<0xD9, MRM3m, (outs), (ins f32mem:$dst), "fstp{s}\t$dst">;
482def ST_FP64m : FPI<0xDD, MRM3m, (outs), (ins f64mem:$dst), "fstp{l}\t$dst">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000483def ST_FP80m : FPI<0xDB, MRM7m, (outs), (ins f80mem:$dst), "fstp{t}\t$dst">;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000484def IST_F16m : FPI<0xDF, MRM2m, (outs), (ins i16mem:$dst), "fist{s}\t$dst">;
485def IST_F32m : FPI<0xDB, MRM2m, (outs), (ins i32mem:$dst), "fist{l}\t$dst">;
486def IST_FP16m : FPI<0xDF, MRM3m, (outs), (ins i16mem:$dst), "fistp{s}\t$dst">;
487def IST_FP32m : FPI<0xDB, MRM3m, (outs), (ins i32mem:$dst), "fistp{l}\t$dst">;
488def IST_FP64m : FPI<0xDF, MRM7m, (outs), (ins i64mem:$dst), "fistp{ll}\t$dst">;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000489}
Evan Chengffcb95b2006-02-21 19:13:53 +0000490
491// FISTTP requires SSE3 even though it's a FPStack op.
Evan Cheng64d80e32007-07-19 01:14:50 +0000492def ISTT_Fp16m32 : FpI_<(outs), (ins i16mem:$op, RFP32:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000493 [(X86fp_to_i16mem RFP32:$src, addr:$op)]>,
494 Requires<[HasSSE3]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000495def ISTT_Fp32m32 : FpI_<(outs), (ins i32mem:$op, RFP32:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000496 [(X86fp_to_i32mem RFP32:$src, addr:$op)]>,
497 Requires<[HasSSE3]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000498def ISTT_Fp64m32 : FpI_<(outs), (ins i64mem:$op, RFP32:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000499 [(X86fp_to_i64mem RFP32:$src, addr:$op)]>,
500 Requires<[HasSSE3]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000501def ISTT_Fp16m64 : FpI_<(outs), (ins i16mem:$op, RFP64:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000502 [(X86fp_to_i16mem RFP64:$src, addr:$op)]>,
503 Requires<[HasSSE3]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000504def ISTT_Fp32m64 : FpI_<(outs), (ins i32mem:$op, RFP64:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000505 [(X86fp_to_i32mem RFP64:$src, addr:$op)]>,
506 Requires<[HasSSE3]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000507def ISTT_Fp64m64 : FpI_<(outs), (ins i64mem:$op, RFP64:$src), OneArgFP,
Dale Johannesen411d9c52007-07-03 17:07:33 +0000508 [(X86fp_to_i64mem RFP64:$src, addr:$op)]>,
509 Requires<[HasSSE3]>;
Dale Johannesena996d522007-08-07 01:17:37 +0000510def ISTT_Fp16m80 : FpI_<(outs), (ins i16mem:$op, RFP80:$src), OneArgFP,
511 [(X86fp_to_i16mem RFP80:$src, addr:$op)]>,
512 Requires<[HasSSE3]>;
513def ISTT_Fp32m80 : FpI_<(outs), (ins i32mem:$op, RFP80:$src), OneArgFP,
514 [(X86fp_to_i32mem RFP80:$src, addr:$op)]>,
515 Requires<[HasSSE3]>;
516def ISTT_Fp64m80 : FpI_<(outs), (ins i64mem:$op, RFP80:$src), OneArgFP,
517 [(X86fp_to_i64mem RFP80:$src, addr:$op)]>,
518 Requires<[HasSSE3]>;
Evan Chengffcb95b2006-02-21 19:13:53 +0000519
Chris Lattnerba7e7562008-01-10 07:59:24 +0000520let mayStore = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000521def ISTT_FP16m : FPI<0xDF, MRM1m, (outs), (ins i16mem:$dst), "fisttp{s}\t$dst">;
522def ISTT_FP32m : FPI<0xDB, MRM1m, (outs), (ins i32mem:$dst), "fisttp{l}\t$dst">;
Sean Callanan108934c2009-12-18 00:01:26 +0000523def ISTT_FP64m : FPI<0xDD, MRM1m, (outs), (ins i64mem:$dst),
524 "fisttp{ll}\t$dst">;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000525}
Evan Chengffcb95b2006-02-21 19:13:53 +0000526
527// FP Stack manipulation instructions.
Dan Gohmanb1576f52007-07-31 20:11:57 +0000528def LD_Frr : FPI<0xC0, AddRegFrm, (outs), (ins RST:$op), "fld\t$op">, D9;
529def ST_Frr : FPI<0xD0, AddRegFrm, (outs), (ins RST:$op), "fst\t$op">, DD;
530def ST_FPrr : FPI<0xD8, AddRegFrm, (outs), (ins RST:$op), "fstp\t$op">, DD;
531def XCH_F : FPI<0xC8, AddRegFrm, (outs), (ins RST:$op), "fxch\t$op">, D9;
Evan Chengffcb95b2006-02-21 19:13:53 +0000532
533// Floating point constant loads.
Chris Lattnerdd415272008-01-10 05:45:39 +0000534let isReMaterializable = 1 in {
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000535def LD_Fp032 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
Dale Johannesen849f2142007-07-03 00:53:03 +0000536 [(set RFP32:$dst, fpimm0)]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000537def LD_Fp132 : FpIf32<(outs RFP32:$dst), (ins), ZeroArgFP,
Dale Johannesen849f2142007-07-03 00:53:03 +0000538 [(set RFP32:$dst, fpimm1)]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000539def LD_Fp064 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP,
Dale Johannesen849f2142007-07-03 00:53:03 +0000540 [(set RFP64:$dst, fpimm0)]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000541def LD_Fp164 : FpIf64<(outs RFP64:$dst), (ins), ZeroArgFP,
Dale Johannesen849f2142007-07-03 00:53:03 +0000542 [(set RFP64:$dst, fpimm1)]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000543def LD_Fp080 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000544 [(set RFP80:$dst, fpimm0)]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000545def LD_Fp180 : FpI_<(outs RFP80:$dst), (ins), ZeroArgFP,
Dale Johannesen59a58732007-08-05 18:49:15 +0000546 [(set RFP80:$dst, fpimm1)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000547}
Evan Chengffcb95b2006-02-21 19:13:53 +0000548
Evan Cheng64d80e32007-07-19 01:14:50 +0000549def LD_F0 : FPI<0xEE, RawFrm, (outs), (ins), "fldz">, D9;
550def LD_F1 : FPI<0xE8, RawFrm, (outs), (ins), "fld1">, D9;
Evan Chengffcb95b2006-02-21 19:13:53 +0000551
552
553// Floating point compares.
Evan Cheng4e4d2d72007-09-25 19:08:02 +0000554let Defs = [EFLAGS] in {
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000555def UCOM_Fpr32 : FpIf32<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
Chris Lattnera731c9f2008-01-11 07:18:17 +0000556 []>; // FPSW = cmp ST(0) with ST(i)
557def UCOM_Fpr64 : FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
558 []>; // FPSW = cmp ST(0) with ST(i)
559def UCOM_Fpr80 : FpI_ <(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
560 []>; // FPSW = cmp ST(0) with ST(i)
561
Chris Lattnere3486a42010-03-19 00:01:11 +0000562// CC = ST(0) cmp ST(i)
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000563def UCOM_FpIr32: FpIf32<(outs), (ins RFP32:$lhs, RFP32:$rhs), CompareFP,
Chris Lattnere3486a42010-03-19 00:01:11 +0000564 [(set EFLAGS, (X86cmp RFP32:$lhs, RFP32:$rhs))]>;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000565def UCOM_FpIr64: FpIf64<(outs), (ins RFP64:$lhs, RFP64:$rhs), CompareFP,
Chris Lattnere3486a42010-03-19 00:01:11 +0000566 [(set EFLAGS, (X86cmp RFP64:$lhs, RFP64:$rhs))]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000567def UCOM_FpIr80: FpI_<(outs), (ins RFP80:$lhs, RFP80:$rhs), CompareFP,
Chris Lattnere3486a42010-03-19 00:01:11 +0000568 [(set EFLAGS, (X86cmp RFP80:$lhs, RFP80:$rhs))]>;
Evan Cheng4e4d2d72007-09-25 19:08:02 +0000569}
570
Evan Cheng24f2ea32007-09-14 21:48:26 +0000571let Defs = [EFLAGS], Uses = [ST0] in {
Dale Johannesene377d4d2007-07-04 21:07:47 +0000572def UCOM_Fr : FPI<0xE0, AddRegFrm, // FPSW = cmp ST(0) with ST(i)
Evan Cheng64d80e32007-07-19 01:14:50 +0000573 (outs), (ins RST:$reg),
Evan Cheng071a2792007-09-11 19:55:27 +0000574 "fucom\t$reg">, DD;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000575def UCOM_FPr : FPI<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
Evan Cheng64d80e32007-07-19 01:14:50 +0000576 (outs), (ins RST:$reg),
Evan Cheng071a2792007-09-11 19:55:27 +0000577 "fucomp\t$reg">, DD;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000578def UCOM_FPPr : FPI<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
Evan Cheng64d80e32007-07-19 01:14:50 +0000579 (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000580 "fucompp">, DA;
Evan Chengffcb95b2006-02-21 19:13:53 +0000581
Dale Johannesene377d4d2007-07-04 21:07:47 +0000582def UCOM_FIr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i)
Evan Cheng64d80e32007-07-19 01:14:50 +0000583 (outs), (ins RST:$reg),
Evan Cheng071a2792007-09-11 19:55:27 +0000584 "fucomi\t{$reg, %st(0)|%ST(0), $reg}">, DB;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000585def UCOM_FIPr : FPI<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
Evan Cheng64d80e32007-07-19 01:14:50 +0000586 (outs), (ins RST:$reg),
Evan Cheng071a2792007-09-11 19:55:27 +0000587 "fucomip\t{$reg, %st(0)|%ST(0), $reg}">, DF;
588}
Evan Chengffcb95b2006-02-21 19:13:53 +0000589
Sean Callanan108934c2009-12-18 00:01:26 +0000590def COM_FIr : FPI<0xF0, AddRegFrm, (outs), (ins RST:$reg),
591 "fcomi\t{$reg, %st(0)|%ST(0), $reg}">, DB;
592def COM_FIPr : FPI<0xF0, AddRegFrm, (outs), (ins RST:$reg),
593 "fcomip\t{$reg, %st(0)|%ST(0), $reg}">, DF;
594
Evan Chengffcb95b2006-02-21 19:13:53 +0000595// Floating point flag ops.
Evan Cheng071a2792007-09-11 19:55:27 +0000596let Defs = [AX] in
Evan Chengffcb95b2006-02-21 19:13:53 +0000597def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
Sean Callanan108934c2009-12-18 00:01:26 +0000598 (outs), (ins), "fnstsw %ax", []>, DF;
Evan Chengffcb95b2006-02-21 19:13:53 +0000599
600def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
Anton Korobeynikov45b22fa2007-11-16 01:31:51 +0000601 (outs), (ins i16mem:$dst), "fnstcw\t$dst",
602 [(X86fp_cwd_get16 addr:$dst)]>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000603
604let mayLoad = 1 in
Evan Chengffcb95b2006-02-21 19:13:53 +0000605def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
Dan Gohmanb1576f52007-07-31 20:11:57 +0000606 (outs), (ins i16mem:$dst), "fldcw\t$dst", []>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000607
Sean Callanan108934c2009-12-18 00:01:26 +0000608// Register free
609
610def FFREE : FPI<0xC0, AddRegFrm, (outs), (ins RST:$reg),
611 "ffree\t$reg">, DD;
612
613// Clear exceptions
614
615def FNCLEX : I<0xE2, RawFrm, (outs), (ins), "fnclex", []>, DB;
616
617// Operandless floating-point instructions for the disassembler
618
619def FNOP : I<0xD0, RawFrm, (outs), (ins), "fnop", []>, D9;
620def FXAM : I<0xE5, RawFrm, (outs), (ins), "fxam", []>, D9;
621def FLDL2T : I<0xE9, RawFrm, (outs), (ins), "fldl2t", []>, D9;
622def FLDL2E : I<0xEA, RawFrm, (outs), (ins), "fldl2e", []>, D9;
623def FLDPI : I<0xEB, RawFrm, (outs), (ins), "fldpi", []>, D9;
624def FLDLG2 : I<0xEC, RawFrm, (outs), (ins), "fldlg2", []>, D9;
625def FLDLN2 : I<0xED, RawFrm, (outs), (ins), "fldln2", []>, D9;
626def F2XM1 : I<0xF0, RawFrm, (outs), (ins), "f2xm1", []>, D9;
627def FYL2X : I<0xF1, RawFrm, (outs), (ins), "fyl2x", []>, D9;
628def FPTAN : I<0xF2, RawFrm, (outs), (ins), "fptan", []>, D9;
629def FPATAN : I<0xF3, RawFrm, (outs), (ins), "fpatan", []>, D9;
630def FXTRACT : I<0xF4, RawFrm, (outs), (ins), "fxtract", []>, D9;
631def FPREM1 : I<0xF5, RawFrm, (outs), (ins), "fprem1", []>, D9;
632def FDECSTP : I<0xF6, RawFrm, (outs), (ins), "fdecstp", []>, D9;
633def FINCSTP : I<0xF7, RawFrm, (outs), (ins), "fincstp", []>, D9;
634def FPREM : I<0xF8, RawFrm, (outs), (ins), "fprem", []>, D9;
635def FYL2XP1 : I<0xF9, RawFrm, (outs), (ins), "fyl2xp1", []>, D9;
636def FSINCOS : I<0xFB, RawFrm, (outs), (ins), "fsincos", []>, D9;
637def FRNDINT : I<0xFC, RawFrm, (outs), (ins), "frndint", []>, D9;
638def FSCALE : I<0xFD, RawFrm, (outs), (ins), "fscale", []>, D9;
639def FCOMPP : I<0xD9, RawFrm, (outs), (ins), "fcompp", []>, DE;
640
641def FXSAVE : I<0xAE, MRM0m, (outs opaque512mem:$dst), (ins),
642 "fxsave\t$dst", []>, TB;
643def FXRSTOR : I<0xAE, MRM1m, (outs), (ins opaque512mem:$src),
644 "fxrstor\t$src", []>, TB;
645
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000646//===----------------------------------------------------------------------===//
647// Non-Instruction Patterns
648//===----------------------------------------------------------------------===//
649
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000650// Required for RET of f32 / f64 / f80 values.
Dale Johannesene377d4d2007-07-04 21:07:47 +0000651def : Pat<(X86fld addr:$src, f32), (LD_Fp32m addr:$src)>;
652def : Pat<(X86fld addr:$src, f64), (LD_Fp64m addr:$src)>;
Dale Johannesen59a58732007-08-05 18:49:15 +0000653def : Pat<(X86fld addr:$src, f80), (LD_Fp80m addr:$src)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000654
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000655// Required for CALL which return f32 / f64 / f80 values.
Dale Johannesene377d4d2007-07-04 21:07:47 +0000656def : Pat<(X86fst RFP32:$src, addr:$op, f32), (ST_Fp32m addr:$op, RFP32:$src)>;
Sean Callanan108934c2009-12-18 00:01:26 +0000657def : Pat<(X86fst RFP64:$src, addr:$op, f32), (ST_Fp64m32 addr:$op,
658 RFP64:$src)>;
Dale Johannesene377d4d2007-07-04 21:07:47 +0000659def : Pat<(X86fst RFP64:$src, addr:$op, f64), (ST_Fp64m addr:$op, RFP64:$src)>;
Sean Callanan108934c2009-12-18 00:01:26 +0000660def : Pat<(X86fst RFP80:$src, addr:$op, f32), (ST_Fp80m32 addr:$op,
661 RFP80:$src)>;
662def : Pat<(X86fst RFP80:$src, addr:$op, f64), (ST_Fp80m64 addr:$op,
663 RFP80:$src)>;
664def : Pat<(X86fst RFP80:$src, addr:$op, f80), (ST_FpP80m addr:$op,
665 RFP80:$src)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000666
667// Floating point constant -0.0 and -1.0
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000668def : Pat<(f32 fpimmneg0), (CHS_Fp32 (LD_Fp032))>, Requires<[FPStackf32]>;
669def : Pat<(f32 fpimmneg1), (CHS_Fp32 (LD_Fp132))>, Requires<[FPStackf32]>;
670def : Pat<(f64 fpimmneg0), (CHS_Fp64 (LD_Fp064))>, Requires<[FPStackf64]>;
671def : Pat<(f64 fpimmneg1), (CHS_Fp64 (LD_Fp164))>, Requires<[FPStackf64]>;
Dale Johannesencdbe4d32007-08-07 20:29:26 +0000672def : Pat<(f80 fpimmneg0), (CHS_Fp80 (LD_Fp080))>;
673def : Pat<(f80 fpimmneg1), (CHS_Fp80 (LD_Fp180))>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +0000674
675// Used to conv. i64 to f64 since there isn't a SSE version.
Dale Johannesene377d4d2007-07-04 21:07:47 +0000676def : Pat<(X86fildflag addr:$src, i64), (ILD_Fp64m64 addr:$src)>;
Dale Johannesen849f2142007-07-03 00:53:03 +0000677
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000678// FP extensions map onto simple pseudo-value conversions if they are to/from
679// the FP stack.
Jakob Stoklund Olesena66450d2010-07-11 18:19:39 +0000680def : Pat<(f64 (fextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP64)>,
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000681 Requires<[FPStackf32]>;
Jakob Stoklund Olesena66450d2010-07-11 18:19:39 +0000682def : Pat<(f80 (fextend RFP32:$src)), (COPY_TO_REGCLASS RFP32:$src, RFP80)>,
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000683 Requires<[FPStackf32]>;
Jakob Stoklund Olesena66450d2010-07-11 18:19:39 +0000684def : Pat<(f80 (fextend RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP80)>,
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000685 Requires<[FPStackf64]>;
686
687// FP truncations map onto simple pseudo-value conversions if they are to/from
688// the FP stack. We have validated that only value-preserving truncations make
689// it through isel.
Jakob Stoklund Olesena66450d2010-07-11 18:19:39 +0000690def : Pat<(f32 (fround RFP64:$src)), (COPY_TO_REGCLASS RFP64:$src, RFP32)>,
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000691 Requires<[FPStackf32]>;
Jakob Stoklund Olesena66450d2010-07-11 18:19:39 +0000692def : Pat<(f32 (fround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP32)>,
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000693 Requires<[FPStackf32]>;
Jakob Stoklund Olesena66450d2010-07-11 18:19:39 +0000694def : Pat<(f64 (fround RFP80:$src)), (COPY_TO_REGCLASS RFP80:$src, RFP64)>,
Chris Lattner6fa2f9c2008-03-09 07:05:32 +0000695 Requires<[FPStackf64]>;