blob: aa10af756d723d08bfd7e146f031f32367c71dd3 [file] [log] [blame]
Jia Liu31d157a2012-02-18 12:03:15 +00001//===-- ARMInstrVFP.td - VFP support for ARM ---------------*- tablegen -*-===//
Evan Chenga8e29892007-01-19 07:51:42 +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 Chenga8e29892007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
Jim Grosbache5d20f92008-09-11 21:41:29 +000010// This file describes the ARM VFP instruction set.
Evan Chenga8e29892007-01-19 07:51:42 +000011//
12//===----------------------------------------------------------------------===//
13
Bill Wendling2695d8e2010-10-15 21:50:45 +000014def SDT_FTOI : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
15def SDT_ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
16def SDT_CMPFP0 : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
17def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
18 SDTCisSameAs<1, 2>]>;
Evan Chenga8e29892007-01-19 07:51:42 +000019
Bill Wendling2695d8e2010-10-15 21:50:45 +000020def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
21def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
22def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
23def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
Chris Lattner036609b2010-12-23 18:28:41 +000024def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInGlue, SDNPOutGlue]>;
25def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutGlue]>;
26def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutGlue]>;
Bill Wendling2695d8e2010-10-15 21:50:45 +000027def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
Evan Chenga8e29892007-01-19 07:51:42 +000028
Bill Wendling88cf0382010-10-14 01:02:08 +000029
Evan Chenga8e29892007-01-19 07:51:42 +000030//===----------------------------------------------------------------------===//
Evan Cheng39382422009-10-28 01:44:26 +000031// Operand Definitions.
32//
33
Jim Grosbach9d390362011-10-03 23:38:36 +000034// 8-bit floating-point immediate encodings.
35def FPImmOperand : AsmOperandClass {
36 let Name = "FPImm";
37 let ParserMethod = "parseFPImm";
38}
39
Evan Cheng39382422009-10-28 01:44:26 +000040def vfp_f32imm : Operand<f32>,
41 PatLeaf<(f32 fpimm), [{
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +000042 return ARM_AM::getFP32Imm(N->getValueAPF()) != -1;
43 }], SDNodeXForm<fpimm, [{
44 APFloat InVal = N->getValueAPF();
45 uint32_t enc = ARM_AM::getFP32Imm(InVal);
46 return CurDAG->getTargetConstant(enc, MVT::i32);
47 }]>> {
48 let PrintMethod = "printFPImmOperand";
Jim Grosbach9d390362011-10-03 23:38:36 +000049 let ParserMatchClass = FPImmOperand;
Evan Cheng39382422009-10-28 01:44:26 +000050}
51
52def vfp_f64imm : Operand<f64>,
53 PatLeaf<(f64 fpimm), [{
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +000054 return ARM_AM::getFP64Imm(N->getValueAPF()) != -1;
55 }], SDNodeXForm<fpimm, [{
56 APFloat InVal = N->getValueAPF();
57 uint32_t enc = ARM_AM::getFP64Imm(InVal);
58 return CurDAG->getTargetConstant(enc, MVT::i32);
59 }]>> {
60 let PrintMethod = "printFPImmOperand";
Jim Grosbach9d390362011-10-03 23:38:36 +000061 let ParserMatchClass = FPImmOperand;
Evan Cheng39382422009-10-28 01:44:26 +000062}
63
Jim Grosbach4050bc42011-12-22 22:19:05 +000064// The VCVT to/from fixed-point instructions encode the 'fbits' operand
65// (the number of fixed bits) differently than it appears in the assembly
66// source. It's encoded as "Size - fbits" where Size is the size of the
67// fixed-point representation (32 or 16) and fbits is the value appearing
68// in the assembly source, an integer in [0,16] or (0,32], depending on size.
69def fbits32_asm_operand : AsmOperandClass { let Name = "FBits32"; }
70def fbits32 : Operand<i32> {
71 let PrintMethod = "printFBits32";
72 let ParserMatchClass = fbits32_asm_operand;
73}
74
75def fbits16_asm_operand : AsmOperandClass { let Name = "FBits16"; }
76def fbits16 : Operand<i32> {
77 let PrintMethod = "printFBits16";
78 let ParserMatchClass = fbits16_asm_operand;
79}
Evan Cheng39382422009-10-28 01:44:26 +000080
81//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +000082// Load / store Instructions.
83//
84
Dan Gohmanbc9d98b2010-02-27 23:47:46 +000085let canFoldAsLoad = 1, isReMaterializable = 1 in {
Bill Wendling92b5a2e2010-11-03 01:49:29 +000086
Bill Wendling7d31a162010-10-20 22:44:54 +000087def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
Jim Grosbachffc658b2011-11-14 23:03:21 +000088 IIC_fpLoad64, "vldr", "\t$Dd, $addr",
Bill Wendling2f46f1f2010-11-04 00:59:42 +000089 [(set DPR:$Dd, (f64 (load addrmode5:$addr)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +000090
Bill Wendling92b5a2e2010-11-03 01:49:29 +000091def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
Jim Grosbachffc658b2011-11-14 23:03:21 +000092 IIC_fpLoad32, "vldr", "\t$Sd, $addr",
Evan Cheng5eda2822011-02-16 00:35:02 +000093 [(set SPR:$Sd, (load addrmode5:$addr))]> {
94 // Some single precision VFP instructions may be executed on both NEON and VFP
95 // pipelines.
96 let D = VFPNeonDomain;
97}
Bill Wendling92b5a2e2010-11-03 01:49:29 +000098
99} // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
Evan Chenga8e29892007-01-19 07:51:42 +0000100
Bill Wendling2f46f1f2010-11-04 00:59:42 +0000101def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
Jim Grosbachffc658b2011-11-14 23:03:21 +0000102 IIC_fpStore64, "vstr", "\t$Dd, $addr",
Bill Wendling2f46f1f2010-11-04 00:59:42 +0000103 [(store (f64 DPR:$Dd), addrmode5:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000104
Bill Wendling2f46f1f2010-11-04 00:59:42 +0000105def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
Jim Grosbachffc658b2011-11-14 23:03:21 +0000106 IIC_fpStore32, "vstr", "\t$Sd, $addr",
Evan Cheng5eda2822011-02-16 00:35:02 +0000107 [(store SPR:$Sd, addrmode5:$addr)]> {
108 // Some single precision VFP instructions may be executed on both NEON and VFP
109 // pipelines.
110 let D = VFPNeonDomain;
111}
Evan Chenga8e29892007-01-19 07:51:42 +0000112
113//===----------------------------------------------------------------------===//
114// Load / store multiple Instructions.
115//
116
Bill Wendling73fe34a2010-11-16 01:16:36 +0000117multiclass vfp_ldst_mult<string asm, bit L_bit,
118 InstrItinClass itin, InstrItinClass itin_upd> {
119 // Double Precision
120 def DIA :
Bill Wendling0f630752010-11-17 04:32:08 +0000121 AXDI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000122 IndexModeNone, itin,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000123 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000124 let Inst{24-23} = 0b01; // Increment After
125 let Inst{21} = 0; // No writeback
126 let Inst{20} = L_bit;
127 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000128 def DIA_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000129 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
130 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000131 IndexModeUpd, itin_upd,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000132 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000133 let Inst{24-23} = 0b01; // Increment After
134 let Inst{21} = 1; // Writeback
135 let Inst{20} = L_bit;
136 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000137 def DDB_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000138 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
139 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000140 IndexModeUpd, itin_upd,
141 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
142 let Inst{24-23} = 0b10; // Decrement Before
143 let Inst{21} = 1; // Writeback
144 let Inst{20} = L_bit;
145 }
Bill Wendling6c470b82010-11-13 09:09:38 +0000146
Bill Wendling73fe34a2010-11-16 01:16:36 +0000147 // Single Precision
148 def SIA :
Bill Wendling0f630752010-11-17 04:32:08 +0000149 AXSI4<(outs), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000150 IndexModeNone, itin,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000151 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000152 let Inst{24-23} = 0b01; // Increment After
153 let Inst{21} = 0; // No writeback
154 let Inst{20} = L_bit;
Evan Cheng5eda2822011-02-16 00:35:02 +0000155
156 // Some single precision VFP instructions may be executed on both NEON and
157 // VFP pipelines.
158 let D = VFPNeonDomain;
Bill Wendling6c470b82010-11-13 09:09:38 +0000159 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000160 def SIA_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000161 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
162 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000163 IndexModeUpd, itin_upd,
Bill Wendling73fe34a2010-11-16 01:16:36 +0000164 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000165 let Inst{24-23} = 0b01; // Increment After
166 let Inst{21} = 1; // Writeback
167 let Inst{20} = L_bit;
Evan Cheng5eda2822011-02-16 00:35:02 +0000168
169 // Some single precision VFP instructions may be executed on both NEON and
170 // VFP pipelines.
171 let D = VFPNeonDomain;
Bill Wendling6c470b82010-11-13 09:09:38 +0000172 }
Bill Wendling73fe34a2010-11-16 01:16:36 +0000173 def SDB_UPD :
Jim Grosbachf921c0fe2011-06-13 22:54:22 +0000174 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
175 variable_ops),
Bill Wendling6c470b82010-11-13 09:09:38 +0000176 IndexModeUpd, itin_upd,
177 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
178 let Inst{24-23} = 0b10; // Decrement Before
179 let Inst{21} = 1; // Writeback
180 let Inst{20} = L_bit;
Evan Cheng5eda2822011-02-16 00:35:02 +0000181
182 // Some single precision VFP instructions may be executed on both NEON and
183 // VFP pipelines.
184 let D = VFPNeonDomain;
Bill Wendling6c470b82010-11-13 09:09:38 +0000185 }
186}
187
Bill Wendlingddc918b2010-11-13 10:57:02 +0000188let neverHasSideEffects = 1 in {
189
Bill Wendling73fe34a2010-11-16 01:16:36 +0000190let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
191defm VLDM : vfp_ldst_mult<"vldm", 1, IIC_fpLoad_m, IIC_fpLoad_mu>;
Bill Wendlingddc918b2010-11-13 10:57:02 +0000192
Bill Wendling73fe34a2010-11-16 01:16:36 +0000193let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
194defm VSTM : vfp_ldst_mult<"vstm", 0, IIC_fpLoad_m, IIC_fpLoad_mu>;
Bill Wendlingddc918b2010-11-13 10:57:02 +0000195
196} // neverHasSideEffects
197
Bill Wendling73c57e12010-11-16 02:00:24 +0000198def : MnemonicAlias<"vldm", "vldmia">;
199def : MnemonicAlias<"vstm", "vstmia">;
200
Jim Grosbach0d06bb92011-06-27 20:00:07 +0000201def : InstAlias<"vpush${p} $r", (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>,
202 Requires<[HasVFP2]>;
203def : InstAlias<"vpush${p} $r", (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>,
204 Requires<[HasVFP2]>;
205def : InstAlias<"vpop${p} $r", (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>,
206 Requires<[HasVFP2]>;
207def : InstAlias<"vpop${p} $r", (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>,
208 Requires<[HasVFP2]>;
209
Evan Chenga8e29892007-01-19 07:51:42 +0000210// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
211
212//===----------------------------------------------------------------------===//
213// FP Binary Operations.
214//
215
Bill Wendling69661192010-11-01 06:00:39 +0000216def VADDD : ADbI<0b11100, 0b11, 0, 0,
217 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
218 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
219 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
Bill Wendling174777b2010-10-12 22:08:41 +0000220
Bill Wendling69661192010-11-01 06:00:39 +0000221def VADDS : ASbIn<0b11100, 0b11, 0, 0,
222 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
223 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000224 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000225 // Some single precision VFP instructions may be executed on both NEON and
226 // VFP pipelines on A8.
227 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000228}
Evan Chenga8e29892007-01-19 07:51:42 +0000229
Bill Wendling69661192010-11-01 06:00:39 +0000230def VSUBD : ADbI<0b11100, 0b11, 1, 0,
231 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
232 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
233 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
Jim Grosbach499e8862010-10-12 21:22:40 +0000234
Bill Wendling69661192010-11-01 06:00:39 +0000235def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
236 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
237 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000238 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000239 // Some single precision VFP instructions may be executed on both NEON and
240 // VFP pipelines on A8.
241 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000242}
Evan Chenga8e29892007-01-19 07:51:42 +0000243
Bill Wendling69661192010-11-01 06:00:39 +0000244def VDIVD : ADbI<0b11101, 0b00, 0, 0,
245 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
246 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
247 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000248
Bill Wendling69661192010-11-01 06:00:39 +0000249def VDIVS : ASbI<0b11101, 0b00, 0, 0,
250 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
251 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
252 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000253
Bill Wendling69661192010-11-01 06:00:39 +0000254def VMULD : ADbI<0b11100, 0b10, 0, 0,
255 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
256 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
257 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000258
Bill Wendling69661192010-11-01 06:00:39 +0000259def VMULS : ASbIn<0b11100, 0b10, 0, 0,
260 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
261 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000262 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000263 // Some single precision VFP instructions may be executed on both NEON and
264 // VFP pipelines on A8.
265 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000266}
Jim Grosbache5165492009-11-09 00:11:35 +0000267
Bill Wendling69661192010-11-01 06:00:39 +0000268def VNMULD : ADbI<0b11100, 0b10, 1, 0,
269 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
270 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
271 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000272
Bill Wendling69661192010-11-01 06:00:39 +0000273def VNMULS : ASbI<0b11100, 0b10, 1, 0,
274 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
275 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000276 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000277 // Some single precision VFP instructions may be executed on both NEON and
278 // VFP pipelines on A8.
279 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000280}
Evan Chenga8e29892007-01-19 07:51:42 +0000281
Chris Lattner72939122007-05-03 00:32:00 +0000282// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000283def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000284 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000285def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000286 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000287
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000288// These are encoded as unary instructions.
289let Defs = [FPSCR] in {
Bill Wendling69661192010-11-01 06:00:39 +0000290def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
291 (outs), (ins DPR:$Dd, DPR:$Dm),
292 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
293 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000294
Bill Wendling69661192010-11-01 06:00:39 +0000295def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
296 (outs), (ins SPR:$Sd, SPR:$Sm),
297 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000298 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000299 // Some single precision VFP instructions may be executed on both NEON and
300 // VFP pipelines on A8.
301 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000302}
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000303
Bill Wendling67a704d2010-10-13 20:58:46 +0000304// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000305def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
306 (outs), (ins DPR:$Dd, DPR:$Dm),
307 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
308 [/* For disassembly only; pattern left blank */]>;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000309
Bill Wendling69661192010-11-01 06:00:39 +0000310def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
311 (outs), (ins SPR:$Sd, SPR:$Sm),
312 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000313 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000314 // Some single precision VFP instructions may be executed on both NEON and
315 // VFP pipelines on A8.
316 let D = VFPNeonA8Domain;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000317}
Evan Cheng5eda2822011-02-16 00:35:02 +0000318} // Defs = [FPSCR]
Evan Chenga8e29892007-01-19 07:51:42 +0000319
320//===----------------------------------------------------------------------===//
321// FP Unary Operations.
322//
323
Bill Wendling69661192010-11-01 06:00:39 +0000324def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
325 (outs DPR:$Dd), (ins DPR:$Dm),
326 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
327 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000328
Bill Wendling69661192010-11-01 06:00:39 +0000329def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
330 (outs SPR:$Sd), (ins SPR:$Sm),
331 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000332 [(set SPR:$Sd, (fabs SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000333 // Some single precision VFP instructions may be executed on both NEON and
334 // VFP pipelines on A8.
335 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000336}
Evan Chenga8e29892007-01-19 07:51:42 +0000337
Evan Cheng91449a82009-07-20 02:12:31 +0000338let Defs = [FPSCR] in {
Bill Wendling69661192010-11-01 06:00:39 +0000339def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
340 (outs), (ins DPR:$Dd),
341 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
342 [(arm_cmpfp0 (f64 DPR:$Dd))]> {
343 let Inst{3-0} = 0b0000;
344 let Inst{5} = 0;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000345}
346
Bill Wendling69661192010-11-01 06:00:39 +0000347def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
348 (outs), (ins SPR:$Sd),
349 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
350 [(arm_cmpfp0 SPR:$Sd)]> {
351 let Inst{3-0} = 0b0000;
352 let Inst{5} = 0;
Evan Cheng5eda2822011-02-16 00:35:02 +0000353
Evan Cheng6557bce2011-02-22 19:53:14 +0000354 // Some single precision VFP instructions may be executed on both NEON and
355 // VFP pipelines on A8.
356 let D = VFPNeonA8Domain;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000357}
Evan Chenga8e29892007-01-19 07:51:42 +0000358
Bill Wendling67a704d2010-10-13 20:58:46 +0000359// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000360def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
361 (outs), (ins DPR:$Dd),
362 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
363 [/* For disassembly only; pattern left blank */]> {
364 let Inst{3-0} = 0b0000;
365 let Inst{5} = 0;
Bill Wendling67a704d2010-10-13 20:58:46 +0000366}
Johnny Chen7edd8e32010-02-08 19:41:48 +0000367
Bill Wendling69661192010-11-01 06:00:39 +0000368def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
369 (outs), (ins SPR:$Sd),
370 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
371 [/* For disassembly only; pattern left blank */]> {
372 let Inst{3-0} = 0b0000;
373 let Inst{5} = 0;
Evan Cheng5eda2822011-02-16 00:35:02 +0000374
Evan Cheng6557bce2011-02-22 19:53:14 +0000375 // Some single precision VFP instructions may be executed on both NEON and
376 // VFP pipelines on A8.
377 let D = VFPNeonA8Domain;
Bill Wendling67a704d2010-10-13 20:58:46 +0000378}
Evan Cheng5eda2822011-02-16 00:35:02 +0000379} // Defs = [FPSCR]
Evan Chenga8e29892007-01-19 07:51:42 +0000380
Bill Wendling54908dd2010-10-13 00:56:35 +0000381def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
382 (outs DPR:$Dd), (ins SPR:$Sm),
383 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
384 [(set DPR:$Dd, (fextend SPR:$Sm))]> {
385 // Instruction operands.
386 bits<5> Dd;
387 bits<5> Sm;
388
389 // Encode instruction operands.
390 let Inst{3-0} = Sm{4-1};
391 let Inst{5} = Sm{0};
392 let Inst{15-12} = Dd{3-0};
393 let Inst{22} = Dd{4};
394}
Evan Chenga8e29892007-01-19 07:51:42 +0000395
Evan Cheng96581d32008-11-11 02:11:05 +0000396// Special case encoding: bits 11-8 is 0b1011.
Bill Wendling54908dd2010-10-13 00:56:35 +0000397def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
398 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
399 [(set SPR:$Sd, (fround DPR:$Dm))]> {
400 // Instruction operands.
401 bits<5> Sd;
402 bits<5> Dm;
403
404 // Encode instruction operands.
405 let Inst{3-0} = Dm{3-0};
406 let Inst{5} = Dm{4};
407 let Inst{15-12} = Sd{4-1};
408 let Inst{22} = Sd{0};
409
Evan Cheng96581d32008-11-11 02:11:05 +0000410 let Inst{27-23} = 0b11101;
411 let Inst{21-16} = 0b110111;
412 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000413 let Inst{7-6} = 0b11;
414 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000415}
Evan Chenga8e29892007-01-19 07:51:42 +0000416
Johnny Chen2d658df2010-02-09 17:21:56 +0000417// Between half-precision and single-precision. For disassembly only.
418
Bill Wendling67a704d2010-10-13 20:58:46 +0000419// FIXME: Verify encoding after integrated assembler is working.
Owen Anderson838130e2011-08-22 21:34:00 +0000420def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
421 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000422 [/* For disassembly only; pattern left blank */]>;
423
Bob Wilson76a312b2010-03-19 22:51:32 +0000424def : ARMPat<(f32_to_f16 SPR:$a),
425 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000426
Owen Anderson838130e2011-08-22 21:34:00 +0000427def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
428 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000429 [/* For disassembly only; pattern left blank */]>;
430
Bob Wilson76a312b2010-03-19 22:51:32 +0000431def : ARMPat<(f16_to_f32 GPR:$a),
432 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000433
Owen Anderson838130e2011-08-22 21:34:00 +0000434def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
435 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm",
Johnny Chen2d658df2010-02-09 17:21:56 +0000436 [/* For disassembly only; pattern left blank */]>;
437
Owen Anderson838130e2011-08-22 21:34:00 +0000438def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
439 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm",
Johnny Chen2d658df2010-02-09 17:21:56 +0000440 [/* For disassembly only; pattern left blank */]>;
441
Bill Wendling69661192010-11-01 06:00:39 +0000442def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
443 (outs DPR:$Dd), (ins DPR:$Dm),
444 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
445 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000446
Bill Wendling69661192010-11-01 06:00:39 +0000447def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
448 (outs SPR:$Sd), (ins SPR:$Sm),
449 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000450 [(set SPR:$Sd, (fneg SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000451 // Some single precision VFP instructions may be executed on both NEON and
452 // VFP pipelines on A8.
453 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000454}
Evan Chenga8e29892007-01-19 07:51:42 +0000455
Bill Wendling69661192010-11-01 06:00:39 +0000456def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
457 (outs DPR:$Dd), (ins DPR:$Dm),
458 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
459 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000460
Bill Wendling69661192010-11-01 06:00:39 +0000461def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
462 (outs SPR:$Sd), (ins SPR:$Sm),
463 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
464 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000465
Bill Wendling67a704d2010-10-13 20:58:46 +0000466let neverHasSideEffects = 1 in {
Bill Wendling69661192010-11-01 06:00:39 +0000467def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
468 (outs DPR:$Dd), (ins DPR:$Dm),
469 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000470
Bill Wendling69661192010-11-01 06:00:39 +0000471def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
472 (outs SPR:$Sd), (ins SPR:$Sm),
473 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000474} // neverHasSideEffects
475
Evan Chenga8e29892007-01-19 07:51:42 +0000476//===----------------------------------------------------------------------===//
477// FP <-> GPR Copies. Int <-> FP Conversions.
478//
479
Bill Wendling7d31a162010-10-20 22:44:54 +0000480def VMOVRS : AVConv2I<0b11100001, 0b1010,
481 (outs GPR:$Rt), (ins SPR:$Sn),
482 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
483 [(set GPR:$Rt, (bitconvert SPR:$Sn))]> {
484 // Instruction operands.
485 bits<4> Rt;
486 bits<5> Sn;
Evan Chenga8e29892007-01-19 07:51:42 +0000487
Bill Wendling7d31a162010-10-20 22:44:54 +0000488 // Encode instruction operands.
489 let Inst{19-16} = Sn{4-1};
490 let Inst{7} = Sn{0};
491 let Inst{15-12} = Rt;
492
493 let Inst{6-5} = 0b00;
494 let Inst{3-0} = 0b0000;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000495
496 // Some single precision VFP instructions may be executed on both NEON and VFP
497 // pipelines.
498 let D = VFPNeonDomain;
Bill Wendling7d31a162010-10-20 22:44:54 +0000499}
500
501def VMOVSR : AVConv4I<0b11100000, 0b1010,
502 (outs SPR:$Sn), (ins GPR:$Rt),
503 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
504 [(set SPR:$Sn, (bitconvert GPR:$Rt))]> {
505 // Instruction operands.
506 bits<5> Sn;
507 bits<4> Rt;
508
509 // Encode instruction operands.
510 let Inst{19-16} = Sn{4-1};
511 let Inst{7} = Sn{0};
512 let Inst{15-12} = Rt;
513
514 let Inst{6-5} = 0b00;
515 let Inst{3-0} = 0b0000;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000516
517 // Some single precision VFP instructions may be executed on both NEON and VFP
518 // pipelines.
519 let D = VFPNeonDomain;
Bill Wendling7d31a162010-10-20 22:44:54 +0000520}
Evan Chenga8e29892007-01-19 07:51:42 +0000521
Evan Cheng020cc1b2010-05-13 00:16:46 +0000522let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000523def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000524 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
525 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
Johnny Chen7acca672010-02-05 18:04:58 +0000526 [/* FIXME: Can't write pattern for multiple result instr*/]> {
Bill Wendling01aabda2010-10-20 23:37:40 +0000527 // Instruction operands.
528 bits<5> Dm;
529 bits<4> Rt;
530 bits<4> Rt2;
531
532 // Encode instruction operands.
533 let Inst{3-0} = Dm{3-0};
534 let Inst{5} = Dm{4};
535 let Inst{15-12} = Rt;
536 let Inst{19-16} = Rt2;
537
Johnny Chen7acca672010-02-05 18:04:58 +0000538 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000539
540 // Some single precision VFP instructions may be executed on both NEON and VFP
541 // pipelines.
542 let D = VFPNeonDomain;
Johnny Chen7acca672010-02-05 18:04:58 +0000543}
Evan Chenga8e29892007-01-19 07:51:42 +0000544
Johnny Chen23401d62010-02-08 17:26:09 +0000545def VMOVRRS : AVConv3I<0b11000101, 0b1010,
Owen Anderson694e0ff2011-08-29 23:15:25 +0000546 (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2),
547 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000548 [/* For disassembly only; pattern left blank */]> {
Owen Anderson694e0ff2011-08-29 23:15:25 +0000549 bits<5> src1;
550 bits<4> Rt;
551 bits<4> Rt2;
552
553 // Encode instruction operands.
554 let Inst{3-0} = src1{3-0};
555 let Inst{5} = src1{4};
556 let Inst{15-12} = Rt;
557 let Inst{19-16} = Rt2;
558
Johnny Chen23401d62010-02-08 17:26:09 +0000559 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000560
561 // Some single precision VFP instructions may be executed on both NEON and VFP
562 // pipelines.
563 let D = VFPNeonDomain;
Owen Anderson357ec682011-08-22 20:27:12 +0000564 let DecoderMethod = "DecodeVMOVRRS";
Johnny Chen23401d62010-02-08 17:26:09 +0000565}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000566} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000567
Evan Chenga8e29892007-01-19 07:51:42 +0000568// FMDHR: GPR -> SPR
569// FMDLR: GPR -> SPR
570
Jim Grosbache5165492009-11-09 00:11:35 +0000571def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000572 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
573 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
574 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]> {
575 // Instruction operands.
576 bits<5> Dm;
577 bits<4> Rt;
578 bits<4> Rt2;
579
580 // Encode instruction operands.
581 let Inst{3-0} = Dm{3-0};
582 let Inst{5} = Dm{4};
583 let Inst{15-12} = Rt;
584 let Inst{19-16} = Rt2;
585
586 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000587
588 // Some single precision VFP instructions may be executed on both NEON and VFP
589 // pipelines.
590 let D = VFPNeonDomain;
Johnny Chen7acca672010-02-05 18:04:58 +0000591}
Evan Chenga8e29892007-01-19 07:51:42 +0000592
Evan Cheng020cc1b2010-05-13 00:16:46 +0000593let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000594def VMOVSRR : AVConv5I<0b11000100, 0b1010,
595 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000596 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000597 [/* For disassembly only; pattern left blank */]> {
Owen Anderson694e0ff2011-08-29 23:15:25 +0000598 // Instruction operands.
599 bits<5> dst1;
600 bits<4> src1;
601 bits<4> src2;
602
603 // Encode instruction operands.
604 let Inst{3-0} = dst1{3-0};
605 let Inst{5} = dst1{4};
606 let Inst{15-12} = src1;
607 let Inst{19-16} = src2;
608
Johnny Chen23401d62010-02-08 17:26:09 +0000609 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000610
611 // Some single precision VFP instructions may be executed on both NEON and VFP
612 // pipelines.
613 let D = VFPNeonDomain;
Owen Anderson357ec682011-08-22 20:27:12 +0000614
615 let DecoderMethod = "DecodeVMOVSRR";
Johnny Chen23401d62010-02-08 17:26:09 +0000616}
617
Evan Chenga8e29892007-01-19 07:51:42 +0000618// FMRDH: SPR -> GPR
619// FMRDL: SPR -> GPR
620// FMRRS: SPR -> GPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000621// FMRX: SPR system reg -> GPR
Evan Chenga8e29892007-01-19 07:51:42 +0000622// FMSRR: GPR -> SPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000623// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000624
625
Bill Wendling67a704d2010-10-13 20:58:46 +0000626// Int -> FP:
Evan Chenga8e29892007-01-19 07:51:42 +0000627
Bill Wendling67a704d2010-10-13 20:58:46 +0000628class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
629 bits<4> opcod4, dag oops, dag iops,
630 InstrItinClass itin, string opc, string asm,
631 list<dag> pattern>
632 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
633 pattern> {
634 // Instruction operands.
635 bits<5> Dd;
636 bits<5> Sm;
637
638 // Encode instruction operands.
639 let Inst{3-0} = Sm{4-1};
640 let Inst{5} = Sm{0};
641 let Inst{15-12} = Dd{3-0};
642 let Inst{22} = Dd{4};
643}
644
645class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
646 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
647 string opc, string asm, list<dag> pattern>
648 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
649 pattern> {
650 // Instruction operands.
651 bits<5> Sd;
652 bits<5> Sm;
653
654 // Encode instruction operands.
655 let Inst{3-0} = Sm{4-1};
656 let Inst{5} = Sm{0};
657 let Inst{15-12} = Sd{4-1};
658 let Inst{22} = Sd{0};
659}
660
661def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
662 (outs DPR:$Dd), (ins SPR:$Sm),
663 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
664 [(set DPR:$Dd, (f64 (arm_sitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000665 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000666}
Evan Chenga8e29892007-01-19 07:51:42 +0000667
Bill Wendling67a704d2010-10-13 20:58:46 +0000668def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
669 (outs SPR:$Sd),(ins SPR:$Sm),
670 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
671 [(set SPR:$Sd, (arm_sitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000672 let Inst{7} = 1; // s32
Evan Cheng5eda2822011-02-16 00:35:02 +0000673
Evan Cheng6557bce2011-02-22 19:53:14 +0000674 // Some single precision VFP instructions may be executed on both NEON and
675 // VFP pipelines on A8.
676 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000677}
Evan Chenga8e29892007-01-19 07:51:42 +0000678
Bill Wendling67a704d2010-10-13 20:58:46 +0000679def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
680 (outs DPR:$Dd), (ins SPR:$Sm),
681 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
682 [(set DPR:$Dd, (f64 (arm_uitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000683 let Inst{7} = 0; // u32
684}
Evan Chenga8e29892007-01-19 07:51:42 +0000685
Bill Wendling67a704d2010-10-13 20:58:46 +0000686def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
687 (outs SPR:$Sd), (ins SPR:$Sm),
688 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
689 [(set SPR:$Sd, (arm_uitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000690 let Inst{7} = 0; // u32
Evan Cheng5eda2822011-02-16 00:35:02 +0000691
Evan Cheng6557bce2011-02-22 19:53:14 +0000692 // Some single precision VFP instructions may be executed on both NEON and
693 // VFP pipelines on A8.
694 let D = VFPNeonA8Domain;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000695}
Evan Chenga8e29892007-01-19 07:51:42 +0000696
Bill Wendling67a704d2010-10-13 20:58:46 +0000697// FP -> Int:
698
699class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
700 bits<4> opcod4, dag oops, dag iops,
701 InstrItinClass itin, string opc, string asm,
702 list<dag> pattern>
703 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
704 pattern> {
705 // Instruction operands.
706 bits<5> Sd;
707 bits<5> Dm;
708
709 // Encode instruction operands.
710 let Inst{3-0} = Dm{3-0};
711 let Inst{5} = Dm{4};
712 let Inst{15-12} = Sd{4-1};
713 let Inst{22} = Sd{0};
714}
715
716class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
717 bits<4> opcod4, dag oops, dag iops,
718 InstrItinClass itin, string opc, string asm,
719 list<dag> pattern>
720 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
721 pattern> {
722 // Instruction operands.
723 bits<5> Sd;
724 bits<5> Sm;
725
726 // Encode instruction operands.
727 let Inst{3-0} = Sm{4-1};
728 let Inst{5} = Sm{0};
729 let Inst{15-12} = Sd{4-1};
730 let Inst{22} = Sd{0};
731}
732
Evan Chenga8e29892007-01-19 07:51:42 +0000733// Always set Z bit in the instruction, i.e. "round towards zero" variants.
Bill Wendling67a704d2010-10-13 20:58:46 +0000734def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
735 (outs SPR:$Sd), (ins DPR:$Dm),
736 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
737 [(set SPR:$Sd, (arm_ftosi (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000738 let Inst{7} = 1; // Z bit
739}
Evan Chenga8e29892007-01-19 07:51:42 +0000740
Bill Wendling67a704d2010-10-13 20:58:46 +0000741def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
742 (outs SPR:$Sd), (ins SPR:$Sm),
743 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
744 [(set SPR:$Sd, (arm_ftosi SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000745 let Inst{7} = 1; // Z bit
Evan Cheng5eda2822011-02-16 00:35:02 +0000746
Evan Cheng6557bce2011-02-22 19:53:14 +0000747 // Some single precision VFP instructions may be executed on both NEON and
748 // VFP pipelines on A8.
749 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000750}
Evan Chenga8e29892007-01-19 07:51:42 +0000751
Bill Wendling67a704d2010-10-13 20:58:46 +0000752def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
753 (outs SPR:$Sd), (ins DPR:$Dm),
754 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
755 [(set SPR:$Sd, (arm_ftoui (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000756 let Inst{7} = 1; // Z bit
757}
Evan Chenga8e29892007-01-19 07:51:42 +0000758
Bill Wendling67a704d2010-10-13 20:58:46 +0000759def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
760 (outs SPR:$Sd), (ins SPR:$Sm),
761 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
762 [(set SPR:$Sd, (arm_ftoui SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000763 let Inst{7} = 1; // Z bit
Evan Cheng5eda2822011-02-16 00:35:02 +0000764
Evan Cheng6557bce2011-02-22 19:53:14 +0000765 // Some single precision VFP instructions may be executed on both NEON and
766 // VFP pipelines on A8.
767 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000768}
Evan Chenga8e29892007-01-19 07:51:42 +0000769
Johnny Chen15b423f2010-02-08 22:02:41 +0000770// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
Nate Begemand1fb5832010-08-03 21:31:55 +0000771let Uses = [FPSCR] in {
Bill Wendling67a704d2010-10-13 20:58:46 +0000772// FIXME: Verify encoding after integrated assembler is working.
773def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
774 (outs SPR:$Sd), (ins DPR:$Dm),
775 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
776 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000777 let Inst{7} = 0; // Z bit
778}
779
Bill Wendling67a704d2010-10-13 20:58:46 +0000780def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
781 (outs SPR:$Sd), (ins SPR:$Sm),
782 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
783 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000784 let Inst{7} = 0; // Z bit
785}
786
Bill Wendling67a704d2010-10-13 20:58:46 +0000787def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
788 (outs SPR:$Sd), (ins DPR:$Dm),
789 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
Bill Wendling88cf0382010-10-14 01:02:08 +0000790 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000791 let Inst{7} = 0; // Z bit
792}
793
Bill Wendling67a704d2010-10-13 20:58:46 +0000794def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
795 (outs SPR:$Sd), (ins SPR:$Sm),
796 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
797 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000798 let Inst{7} = 0; // Z bit
799}
Nate Begemand1fb5832010-08-03 21:31:55 +0000800}
Johnny Chen15b423f2010-02-08 22:02:41 +0000801
Johnny Chen27bb8d02010-02-11 18:17:16 +0000802// Convert between floating-point and fixed-point
803// Data type for fixed-point naming convention:
804// S16 (U=0, sx=0) -> SH
805// U16 (U=1, sx=0) -> UH
806// S32 (U=0, sx=1) -> SL
807// U32 (U=1, sx=1) -> UL
808
Jim Grosbach8c748112011-12-22 19:45:01 +0000809let Constraints = "$a = $dst" in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000810
811// FP to Fixed-Point:
812
813def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000814 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000815 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000816 // Some single precision VFP instructions may be executed on both NEON and
817 // VFP pipelines on A8.
818 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000819}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000820
821def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000822 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000823 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000824 // Some single precision VFP instructions may be executed on both NEON and
825 // VFP pipelines on A8.
826 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000827}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000828
829def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000830 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000831 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000832 // Some single precision VFP instructions may be executed on both NEON and
833 // VFP pipelines on A8.
834 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000835}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000836
837def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000838 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000839 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000840 // Some single precision VFP instructions may be executed on both NEON and
841 // VFP pipelines on A8.
842 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000843}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000844
845def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000846 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000847 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000848
849def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000850 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000851 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000852
853def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000854 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000855 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000856
857def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000858 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000859 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000860
861// Fixed-Point to FP:
862
863def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000864 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000865 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000866 // Some single precision VFP instructions may be executed on both NEON and
867 // VFP pipelines on A8.
868 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000869}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000870
871def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000872 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000873 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000874 // Some single precision VFP instructions may be executed on both NEON and
875 // VFP pipelines on A8.
876 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000877}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000878
879def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000880 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000881 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000882 // Some single precision VFP instructions may be executed on both NEON and
883 // VFP pipelines on A8.
884 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000885}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000886
887def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000888 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000889 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000890 // Some single precision VFP instructions may be executed on both NEON and
891 // VFP pipelines on A8.
892 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000893}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000894
895def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000896 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000897 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000898
899def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000900 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000901 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000902
903def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000904 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000905 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000906
907def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000908 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000909 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000910
Jim Grosbach8c748112011-12-22 19:45:01 +0000911} // End of 'let Constraints = "$a = $dst" in'
Johnny Chen27bb8d02010-02-11 18:17:16 +0000912
Evan Chenga8e29892007-01-19 07:51:42 +0000913//===----------------------------------------------------------------------===//
Cameron Zwarich375db7f2011-07-07 08:28:52 +0000914// FP Multiply-Accumulate Operations.
Evan Chenga8e29892007-01-19 07:51:42 +0000915//
916
Evan Cheng529916c2010-11-12 20:32:20 +0000917def VMLAD : ADbI<0b11100, 0b00, 0, 0,
918 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
919 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000920 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
921 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000922 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000923 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000924
Bill Wendling69661192010-11-01 06:00:39 +0000925def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
926 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
927 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000928 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
929 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000930 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000931 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000932 // Some single precision VFP instructions may be executed on both NEON and
933 // VFP pipelines on A8.
934 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000935}
Evan Chenga8e29892007-01-19 07:51:42 +0000936
Evan Cheng48575f62010-12-05 22:04:16 +0000937def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000938 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000939 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +0000940def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000941 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000942 Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx,NoVFP4]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000943
Evan Cheng529916c2010-11-12 20:32:20 +0000944def VMLSD : ADbI<0b11100, 0b00, 1, 0,
945 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
946 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000947 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
948 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000949 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000950 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000951
Bill Wendling69661192010-11-01 06:00:39 +0000952def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
953 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
954 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000955 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
956 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000957 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000958 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000959 // Some single precision VFP instructions may be executed on both NEON and
960 // VFP pipelines on A8.
961 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000962}
Evan Chenga8e29892007-01-19 07:51:42 +0000963
Evan Cheng48575f62010-12-05 22:04:16 +0000964def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000965 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000966 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +0000967def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000968 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000969 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
David Goodwinb84f3d42009-08-04 18:44:29 +0000970
Evan Cheng529916c2010-11-12 20:32:20 +0000971def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
972 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
973 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000974 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
975 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000976 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000977 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000978
Bill Wendling69661192010-11-01 06:00:39 +0000979def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
980 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
981 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000982 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
983 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000984 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000985 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000986 // Some single precision VFP instructions may be executed on both NEON and
987 // VFP pipelines on A8.
988 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000989}
Bill Wendling88cf0382010-10-14 01:02:08 +0000990
Evan Cheng48575f62010-12-05 22:04:16 +0000991def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000992 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000993 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +0000994def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +0000995 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000996 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000997
Evan Cheng529916c2010-11-12 20:32:20 +0000998def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
999 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1000 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +00001001 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1002 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +00001003 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001004 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +00001005
Bill Wendling69661192010-11-01 06:00:39 +00001006def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
1007 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1008 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +00001009 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +00001010 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001011 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +00001012 // Some single precision VFP instructions may be executed on both NEON and
1013 // VFP pipelines on A8.
1014 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +00001015}
Bill Wendling88cf0382010-10-14 01:02:08 +00001016
Evan Cheng48575f62010-12-05 22:04:16 +00001017def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001018 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001019 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +00001020def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001021 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001022 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +00001023
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001024//===----------------------------------------------------------------------===//
1025// Fused FP Multiply-Accumulate Operations.
1026//
1027def VFMAD : ADbI<0b11101, 0b10, 0, 0,
1028 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1029 IIC_fpFMAC64, "vfma", ".f64\t$Dd, $Dn, $Dm",
1030 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1031 (f64 DPR:$Ddin)))]>,
1032 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001033 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001034
1035def VFMAS : ASbIn<0b11101, 0b10, 0, 0,
1036 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1037 IIC_fpFMAC32, "vfma", ".f32\t$Sd, $Sn, $Sm",
1038 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
1039 SPR:$Sdin))]>,
1040 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001041 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001042 // Some single precision VFP instructions may be executed on both NEON and
1043 // VFP pipelines.
1044}
1045
1046def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1047 (VFMAD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001048 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001049def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1050 (VFMAS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001051 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001052
1053def VFMSD : ADbI<0b11101, 0b10, 1, 0,
1054 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1055 IIC_fpFMAC64, "vfms", ".f64\t$Dd, $Dn, $Dm",
1056 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1057 (f64 DPR:$Ddin)))]>,
1058 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001059 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001060
1061def VFMSS : ASbIn<0b11101, 0b10, 1, 0,
1062 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1063 IIC_fpFMAC32, "vfms", ".f32\t$Sd, $Sn, $Sm",
1064 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1065 SPR:$Sdin))]>,
1066 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001067 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001068 // Some single precision VFP instructions may be executed on both NEON and
1069 // VFP pipelines.
1070}
1071
1072def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1073 (VFMSD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001074 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001075def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1076 (VFMSS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001077 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001078
1079def VFNMAD : ADbI<0b11101, 0b01, 1, 0,
1080 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1081 IIC_fpFMAC64, "vfnma", ".f64\t$Dd, $Dn, $Dm",
1082 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1083 (f64 DPR:$Ddin)))]>,
1084 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001085 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001086
1087def VFNMAS : ASbI<0b11101, 0b01, 1, 0,
1088 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1089 IIC_fpFMAC32, "vfnma", ".f32\t$Sd, $Sn, $Sm",
1090 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1091 SPR:$Sdin))]>,
1092 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001093 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001094 // Some single precision VFP instructions may be executed on both NEON and
1095 // VFP pipelines.
1096}
1097
1098def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
1099 (VFNMAD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001100 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001101def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
1102 (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001103 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001104
1105def VFNMSD : ADbI<0b11101, 0b01, 0, 0,
1106 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1107 IIC_fpFMAC64, "vfnms", ".f64\t$Dd, $Dn, $Dm",
1108 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1109 (f64 DPR:$Ddin)))]>,
1110 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001111 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001112
1113def VFNMSS : ASbI<0b11101, 0b01, 0, 0,
1114 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1115 IIC_fpFMAC32, "vfnms", ".f32\t$Sd, $Sn, $Sm",
1116 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
1117 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001118 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001119 // Some single precision VFP instructions may be executed on both NEON and
1120 // VFP pipelines.
1121}
1122
1123def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
1124 (VFNMSD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001125 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001126def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
1127 (VFNMSS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001128 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Evan Chenga8e29892007-01-19 07:51:42 +00001129
1130//===----------------------------------------------------------------------===//
1131// FP Conditional moves.
1132//
1133
Evan Cheng020cc1b2010-05-13 00:16:46 +00001134let neverHasSideEffects = 1 in {
Jim Grosbachf219f312011-03-11 23:09:50 +00001135def VMOVDcc : ARMPseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001136 4, IIC_fpUNA64,
Bill Wendling69661192010-11-01 06:00:39 +00001137 [/*(set DPR:$Dd, (ARMcmov DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
1138 RegConstraint<"$Dn = $Dd">;
Evan Chenga8e29892007-01-19 07:51:42 +00001139
Jim Grosbachf219f312011-03-11 23:09:50 +00001140def VMOVScc : ARMPseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001141 4, IIC_fpUNA32,
Bill Wendling69661192010-11-01 06:00:39 +00001142 [/*(set SPR:$Sd, (ARMcmov SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
1143 RegConstraint<"$Sn = $Sd">;
Evan Cheng020cc1b2010-05-13 00:16:46 +00001144} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +00001145
1146//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001147// Move from VFP System Register to ARM core register.
Evan Cheng78be83d2008-11-11 19:40:26 +00001148//
1149
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001150class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1151 list<dag> pattern>:
1152 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
Evan Cheng39382422009-10-28 01:44:26 +00001153
Bill Wendling88cf0382010-10-14 01:02:08 +00001154 // Instruction operand.
1155 bits<4> Rt;
1156
Johnny Chenc9745042010-02-09 22:35:38 +00001157 let Inst{27-20} = 0b11101111;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001158 let Inst{19-16} = opc19_16;
1159 let Inst{15-12} = Rt;
Johnny Chenc9745042010-02-09 22:35:38 +00001160 let Inst{11-8} = 0b1010;
1161 let Inst{7} = 0;
Bill Wendling88cf0382010-10-14 01:02:08 +00001162 let Inst{6-5} = 0b00;
Johnny Chenc9745042010-02-09 22:35:38 +00001163 let Inst{4} = 1;
Bill Wendling88cf0382010-10-14 01:02:08 +00001164 let Inst{3-0} = 0b0000;
Johnny Chenc9745042010-02-09 22:35:38 +00001165}
Johnny Chenc9745042010-02-09 22:35:38 +00001166
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001167// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
1168// to APSR.
1169let Defs = [CPSR], Uses = [FPSCR], Rt = 0b1111 /* apsr_nzcv */ in
1170def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
1171 "vmrs", "\tapsr_nzcv, fpscr", [(arm_fmstat)]>;
1172
1173// Application level FPSCR -> GPR
1174let hasSideEffects = 1, Uses = [FPSCR] in
1175def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPR:$Rt), (ins),
1176 "vmrs", "\t$Rt, fpscr",
1177 [(set GPR:$Rt, (int_arm_get_fpscr))]>;
1178
1179// System level FPEXC, FPSID -> GPR
1180let Uses = [FPSCR] in {
1181 def VMRS_FPEXC : MovFromVFP<0b1000 /* fpexc */, (outs GPR:$Rt), (ins),
1182 "vmrs", "\t$Rt, fpexc", []>;
1183 def VMRS_FPSID : MovFromVFP<0b0000 /* fpsid */, (outs GPR:$Rt), (ins),
1184 "vmrs", "\t$Rt, fpsid", []>;
1185}
1186
1187//===----------------------------------------------------------------------===//
1188// Move from ARM core register to VFP System Register.
1189//
1190
1191class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1192 list<dag> pattern>:
1193 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
1194
Bill Wendling88cf0382010-10-14 01:02:08 +00001195 // Instruction operand.
1196 bits<4> src;
1197
1198 // Encode instruction operand.
1199 let Inst{15-12} = src;
1200
Johnny Chenc9745042010-02-09 22:35:38 +00001201 let Inst{27-20} = 0b11101110;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001202 let Inst{19-16} = opc19_16;
Johnny Chenc9745042010-02-09 22:35:38 +00001203 let Inst{11-8} = 0b1010;
1204 let Inst{7} = 0;
1205 let Inst{4} = 1;
1206}
Evan Cheng39382422009-10-28 01:44:26 +00001207
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001208let Defs = [FPSCR] in {
1209 // Application level GPR -> FPSCR
1210 def VMSR : MovToVFP<0b0001 /* fpscr */, (outs), (ins GPR:$src),
1211 "vmsr", "\tfpscr, $src", [(int_arm_set_fpscr GPR:$src)]>;
1212 // System level GPR -> FPEXC
1213 def VMSR_FPEXC : MovToVFP<0b1000 /* fpexc */, (outs), (ins GPR:$src),
1214 "vmsr", "\tfpexc, $src", []>;
1215 // System level GPR -> FPSID
1216 def VMSR_FPSID : MovToVFP<0b0000 /* fpsid */, (outs), (ins GPR:$src),
1217 "vmsr", "\tfpsid, $src", []>;
1218}
1219
1220//===----------------------------------------------------------------------===//
1221// Misc.
1222//
1223
Evan Cheng39382422009-10-28 01:44:26 +00001224// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +00001225let isReMaterializable = 1 in {
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001226def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +00001227 VFPMiscFrm, IIC_fpUNA64,
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001228 "vmov", ".f64\t$Dd, $imm",
1229 [(set DPR:$Dd, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001230 bits<5> Dd;
1231 bits<8> imm;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001232
Jim Grosbache5165492009-11-09 00:11:35 +00001233 let Inst{27-23} = 0b11101;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001234 let Inst{22} = Dd{4};
Jim Grosbache5165492009-11-09 00:11:35 +00001235 let Inst{21-20} = 0b11;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001236 let Inst{19-16} = imm{7-4};
1237 let Inst{15-12} = Dd{3-0};
Jim Grosbache5165492009-11-09 00:11:35 +00001238 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001239 let Inst{8} = 1; // Double precision.
Jim Grosbache5165492009-11-09 00:11:35 +00001240 let Inst{7-4} = 0b0000;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001241 let Inst{3-0} = imm{3-0};
Jim Grosbache5165492009-11-09 00:11:35 +00001242}
1243
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001244def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
1245 VFPMiscFrm, IIC_fpUNA32,
1246 "vmov", ".f32\t$Sd, $imm",
1247 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001248 bits<5> Sd;
1249 bits<8> imm;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001250
Evan Cheng39382422009-10-28 01:44:26 +00001251 let Inst{27-23} = 0b11101;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001252 let Inst{22} = Sd{0};
Evan Cheng39382422009-10-28 01:44:26 +00001253 let Inst{21-20} = 0b11;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001254 let Inst{19-16} = imm{7-4};
1255 let Inst{15-12} = Sd{4-1};
Evan Cheng39382422009-10-28 01:44:26 +00001256 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001257 let Inst{8} = 0; // Single precision.
Evan Cheng39382422009-10-28 01:44:26 +00001258 let Inst{7-4} = 0b0000;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001259 let Inst{3-0} = imm{3-0};
Evan Cheng39382422009-10-28 01:44:26 +00001260}
Evan Cheng39382422009-10-28 01:44:26 +00001261}
Jim Grosbach5cd5ac62011-10-03 21:12:43 +00001262
1263//===----------------------------------------------------------------------===//
1264// Assembler aliases.
1265//
Jim Grosbach67ca1ad2011-12-08 00:49:29 +00001266// A few mnemnoic aliases for pre-unifixed syntax. We don't guarantee to
1267// support them all, but supporting at least some of the basics is
1268// good to be friendly.
Jim Grosbach21d7fb82011-12-09 23:34:09 +00001269def : VFP2MnemonicAlias<"flds", "vldr">;
1270def : VFP2MnemonicAlias<"fldd", "vldr">;
1271def : VFP2MnemonicAlias<"fmrs", "vmov">;
1272def : VFP2MnemonicAlias<"fmsr", "vmov">;
1273def : VFP2MnemonicAlias<"fsqrts", "vsqrt">;
1274def : VFP2MnemonicAlias<"fsqrtd", "vsqrt">;
1275def : VFP2MnemonicAlias<"fadds", "vadd.f32">;
1276def : VFP2MnemonicAlias<"faddd", "vadd.f64">;
1277def : VFP2MnemonicAlias<"fmrdd", "vmov">;
1278def : VFP2MnemonicAlias<"fmrds", "vmov">;
1279def : VFP2MnemonicAlias<"fmrrd", "vmov">;
1280def : VFP2MnemonicAlias<"fmdrr", "vmov">;
Jim Grosbach68490192011-12-19 19:43:50 +00001281def : VFP2MnemonicAlias<"fmuls", "vmul.f32">;
Jim Grosbach21d7fb82011-12-09 23:34:09 +00001282def : VFP2MnemonicAlias<"fmuld", "vmul.f64">;
1283def : VFP2MnemonicAlias<"fnegs", "vneg.f32">;
1284def : VFP2MnemonicAlias<"fnegd", "vneg.f64">;
Jim Grosbach48171e72011-12-10 00:01:02 +00001285def : VFP2MnemonicAlias<"ftosizd", "vcvt.s32.f64">;
1286def : VFP2MnemonicAlias<"ftosid", "vcvtr.s32.f64">;
1287def : VFP2MnemonicAlias<"ftosizs", "vcvt.s32.f32">;
1288def : VFP2MnemonicAlias<"ftosis", "vcvtr.s32.f32">;
1289def : VFP2MnemonicAlias<"ftouizd", "vcvt.u32.f64">;
1290def : VFP2MnemonicAlias<"ftouid", "vcvtr.u32.f64">;
1291def : VFP2MnemonicAlias<"ftouizs", "vcvt.u32.f32">;
1292def : VFP2MnemonicAlias<"ftouis", "vcvtr.u32.f32">;
1293def : VFP2MnemonicAlias<"fsitod", "vcvt.f64.s32">;
1294def : VFP2MnemonicAlias<"fsitos", "vcvt.f32.s32">;
1295def : VFP2MnemonicAlias<"fuitod", "vcvt.f64.u32">;
1296def : VFP2MnemonicAlias<"fuitos", "vcvt.f32.u32">;
Jim Grosbachf1015402011-12-13 20:13:48 +00001297def : VFP2MnemonicAlias<"fsts", "vstr">;
1298def : VFP2MnemonicAlias<"fstd", "vstr">;
Jim Grosbach0f293de2011-12-13 20:40:37 +00001299def : VFP2MnemonicAlias<"fmacd", "vmla.f64">;
1300def : VFP2MnemonicAlias<"fmacs", "vmla.f32">;
Jim Grosbach9c397892011-12-19 19:02:41 +00001301def : VFP2MnemonicAlias<"fcpys", "vmov.f32">;
1302def : VFP2MnemonicAlias<"fcpyd", "vmov.f64">;
Jim Grosbach1aa149f2011-12-22 19:20:45 +00001303def : VFP2MnemonicAlias<"fcmps", "vcmp.f32">;
1304def : VFP2MnemonicAlias<"fcmpd", "vcmp.f64">;
Jim Grosbach9c397892011-12-19 19:02:41 +00001305def : VFP2MnemonicAlias<"fdivs", "vdiv.f32">;
1306def : VFP2MnemonicAlias<"fdivd", "vdiv.f64">;
Jim Grosbach67ca1ad2011-12-08 00:49:29 +00001307
Jim Grosbach5cd5ac62011-10-03 21:12:43 +00001308def : VFP2InstAlias<"fmstat${p}", (FMSTAT pred:$p)>;
Jim Grosbach48171e72011-12-10 00:01:02 +00001309def : VFP2InstAlias<"fadds${p} $Sd, $Sn, $Sm",
1310 (VADDS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
1311def : VFP2InstAlias<"faddd${p} $Dd, $Dn, $Dm",
1312 (VADDD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
1313def : VFP2InstAlias<"fsubs${p} $Sd, $Sn, $Sm",
1314 (VSUBS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
1315def : VFP2InstAlias<"fsubd${p} $Dd, $Dn, $Dm",
1316 (VSUBD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
Jim Grosbach5cd5ac62011-10-03 21:12:43 +00001317
Jim Grosbach976c0da2011-12-08 22:51:25 +00001318// No need for the size suffix on VSQRT. It's implied by the register classes.
1319def : VFP2InstAlias<"vsqrt${p} $Sd, $Sm", (VSQRTS SPR:$Sd, SPR:$Sm, pred:$p)>;
1320def : VFP2InstAlias<"vsqrt${p} $Dd, $Dm", (VSQRTD DPR:$Dd, DPR:$Dm, pred:$p)>;
1321
Jim Grosbachffc658b2011-11-14 23:03:21 +00001322// VLDR/VSTR accept an optional type suffix.
Jim Grosbach1ceef1a2011-12-07 01:50:36 +00001323def : VFP2InstAlias<"vldr${p}.32 $Sd, $addr",
1324 (VLDRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
1325def : VFP2InstAlias<"vstr${p}.32 $Sd, $addr",
1326 (VSTRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
1327def : VFP2InstAlias<"vldr${p}.64 $Dd, $addr",
1328 (VLDRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
1329def : VFP2InstAlias<"vstr${p}.64 $Dd, $addr",
1330 (VSTRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
Jim Grosbachbfb0a172011-11-15 20:14:51 +00001331
1332// VMUL has a two-operand form (implied destination operand)
1333def : VFP2InstAlias<"vmul${p}.f64 $Dn, $Dm",
1334 (VMULD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1335def : VFP2InstAlias<"vmul${p}.f32 $Sn, $Sm",
1336 (VMULS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
Jim Grosbach88d012a2011-11-15 22:15:10 +00001337// VADD has a two-operand form (implied destination operand)
1338def : VFP2InstAlias<"vadd${p}.f64 $Dn, $Dm",
1339 (VADDD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1340def : VFP2InstAlias<"vadd${p}.f32 $Sn, $Sm",
1341 (VADDS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
1342// VSUB has a two-operand form (implied destination operand)
1343def : VFP2InstAlias<"vsub${p}.f64 $Dn, $Dm",
1344 (VSUBD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1345def : VFP2InstAlias<"vsub${p}.f32 $Sn, $Sm",
1346 (VSUBS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
Jim Grosbacha68e90c2011-11-15 20:29:42 +00001347
Jim Grosbachaf33a0c2011-12-21 23:24:15 +00001348// VMOV can accept optional 32-bit or less data type suffix suffix.
1349def : VFP2InstAlias<"vmov${p}.8 $Rt, $Sn",
Jim Grosbacha68e90c2011-11-15 20:29:42 +00001350 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
Jim Grosbachaf33a0c2011-12-21 23:24:15 +00001351def : VFP2InstAlias<"vmov${p}.16 $Rt, $Sn",
1352 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1353def : VFP2InstAlias<"vmov${p}.32 $Rt, $Sn",
1354 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1355def : VFP2InstAlias<"vmov${p}.8 $Sn, $Rt",
1356 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1357def : VFP2InstAlias<"vmov${p}.16 $Sn, $Rt",
1358 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1359def : VFP2InstAlias<"vmov${p}.32 $Sn, $Rt",
Jim Grosbacha68e90c2011-11-15 20:29:42 +00001360 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1361
1362def : VFP2InstAlias<"vmov${p}.f64 $Rt, $Rt2, $Dn",
1363 (VMOVRRD GPR:$Rt, GPR:$Rt2, DPR:$Dn, pred:$p)>;
1364def : VFP2InstAlias<"vmov${p}.f64 $Dn, $Rt, $Rt2",
1365 (VMOVDRR DPR:$Dn, GPR:$Rt, GPR:$Rt2, pred:$p)>;
Jim Grosbacheaf20562011-11-15 21:18:35 +00001366
1367// VMOVS doesn't need the .f32 to disambiguate from the NEON encoding the way
1368// VMOVD does.
1369def : VFP2InstAlias<"vmov${p} $Sd, $Sm",
1370 (VMOVS SPR:$Sd, SPR:$Sm, pred:$p)>;