blob: e9d572089b776a2bb0694e9f33dff20f81ea5b2f [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]>;
Jim Grosbachbc978a62012-03-05 23:16:31 +0000209defm : VFPDTAnyInstAlias<"vpush${p}", "$r",
210 (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>;
211defm : VFPDTAnyInstAlias<"vpush${p}", "$r",
212 (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>;
213defm : VFPDTAnyInstAlias<"vpop${p}", "$r",
214 (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>;
215defm : VFPDTAnyInstAlias<"vpop${p}", "$r",
216 (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>;
Jim Grosbach0d06bb92011-06-27 20:00:07 +0000217
Evan Chenga8e29892007-01-19 07:51:42 +0000218// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
219
220//===----------------------------------------------------------------------===//
221// FP Binary Operations.
222//
223
Bill Wendling69661192010-11-01 06:00:39 +0000224def VADDD : ADbI<0b11100, 0b11, 0, 0,
225 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
226 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
227 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
Bill Wendling174777b2010-10-12 22:08:41 +0000228
Bill Wendling69661192010-11-01 06:00:39 +0000229def VADDS : ASbIn<0b11100, 0b11, 0, 0,
230 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
231 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000232 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000233 // Some single precision VFP instructions may be executed on both NEON and
234 // VFP pipelines on A8.
235 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000236}
Evan Chenga8e29892007-01-19 07:51:42 +0000237
Bill Wendling69661192010-11-01 06:00:39 +0000238def VSUBD : ADbI<0b11100, 0b11, 1, 0,
239 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
240 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
241 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
Jim Grosbach499e8862010-10-12 21:22:40 +0000242
Bill Wendling69661192010-11-01 06:00:39 +0000243def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
244 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
245 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000246 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000247 // Some single precision VFP instructions may be executed on both NEON and
248 // VFP pipelines on A8.
249 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000250}
Evan Chenga8e29892007-01-19 07:51:42 +0000251
Bill Wendling69661192010-11-01 06:00:39 +0000252def VDIVD : ADbI<0b11101, 0b00, 0, 0,
253 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
254 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
255 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000256
Bill Wendling69661192010-11-01 06:00:39 +0000257def VDIVS : ASbI<0b11101, 0b00, 0, 0,
258 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
259 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
260 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000261
Bill Wendling69661192010-11-01 06:00:39 +0000262def VMULD : ADbI<0b11100, 0b10, 0, 0,
263 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
264 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
265 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000266
Bill Wendling69661192010-11-01 06:00:39 +0000267def VMULS : ASbIn<0b11100, 0b10, 0, 0,
268 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
269 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000270 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000271 // Some single precision VFP instructions may be executed on both NEON and
272 // VFP pipelines on A8.
273 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000274}
Jim Grosbache5165492009-11-09 00:11:35 +0000275
Bill Wendling69661192010-11-01 06:00:39 +0000276def VNMULD : ADbI<0b11100, 0b10, 1, 0,
277 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
278 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
279 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000280
Bill Wendling69661192010-11-01 06:00:39 +0000281def VNMULS : ASbI<0b11100, 0b10, 1, 0,
282 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
283 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000284 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000285 // Some single precision VFP instructions may be executed on both NEON and
286 // VFP pipelines on A8.
287 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000288}
Evan Chenga8e29892007-01-19 07:51:42 +0000289
Chris Lattner72939122007-05-03 00:32:00 +0000290// Match reassociated forms only if not sign dependent rounding.
Chris Lattnerd10a53d2010-03-08 18:51:21 +0000291def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
Jim Grosbache5165492009-11-09 00:11:35 +0000292 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000293def : Pat<(fmul (fneg SPR:$a), SPR:$b),
Jim Grosbache5165492009-11-09 00:11:35 +0000294 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
Chris Lattner72939122007-05-03 00:32:00 +0000295
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000296// These are encoded as unary instructions.
Lang Hames4f92b5e2012-03-06 00:19:55 +0000297let Defs = [FPSCR_NZCV] in {
Bill Wendling69661192010-11-01 06:00:39 +0000298def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
299 (outs), (ins DPR:$Dd, DPR:$Dm),
300 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
301 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000302
Bill Wendling69661192010-11-01 06:00:39 +0000303def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
304 (outs), (ins SPR:$Sd, SPR:$Sm),
305 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000306 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000307 // Some single precision VFP instructions may be executed on both NEON and
308 // VFP pipelines on A8.
309 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000310}
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000311
Bill Wendling67a704d2010-10-13 20:58:46 +0000312// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000313def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
314 (outs), (ins DPR:$Dd, DPR:$Dm),
315 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
316 [/* For disassembly only; pattern left blank */]>;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000317
Bill Wendling69661192010-11-01 06:00:39 +0000318def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
319 (outs), (ins SPR:$Sd, SPR:$Sm),
320 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000321 [/* For disassembly only; pattern left blank */]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000322 // Some single precision VFP instructions may be executed on both NEON and
323 // VFP pipelines on A8.
324 let D = VFPNeonA8Domain;
Bill Wendlingdd3bc112010-10-12 22:55:35 +0000325}
Lang Hames4f92b5e2012-03-06 00:19:55 +0000326} // Defs = [FPSCR_NZCV]
Evan Chenga8e29892007-01-19 07:51:42 +0000327
328//===----------------------------------------------------------------------===//
329// FP Unary Operations.
330//
331
Bill Wendling69661192010-11-01 06:00:39 +0000332def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
333 (outs DPR:$Dd), (ins DPR:$Dm),
334 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
335 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000336
Bill Wendling69661192010-11-01 06:00:39 +0000337def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
338 (outs SPR:$Sd), (ins SPR:$Sm),
339 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000340 [(set SPR:$Sd, (fabs SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000341 // Some single precision VFP instructions may be executed on both NEON and
342 // VFP pipelines on A8.
343 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000344}
Evan Chenga8e29892007-01-19 07:51:42 +0000345
Lang Hames4f92b5e2012-03-06 00:19:55 +0000346let Defs = [FPSCR_NZCV] in {
Bill Wendling69661192010-11-01 06:00:39 +0000347def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
348 (outs), (ins DPR:$Dd),
349 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
350 [(arm_cmpfp0 (f64 DPR:$Dd))]> {
351 let Inst{3-0} = 0b0000;
352 let Inst{5} = 0;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000353}
354
Bill Wendling69661192010-11-01 06:00:39 +0000355def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
356 (outs), (ins SPR:$Sd),
357 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
358 [(arm_cmpfp0 SPR:$Sd)]> {
359 let Inst{3-0} = 0b0000;
360 let Inst{5} = 0;
Evan Cheng5eda2822011-02-16 00:35:02 +0000361
Evan Cheng6557bce2011-02-22 19:53:14 +0000362 // Some single precision VFP instructions may be executed on both NEON and
363 // VFP pipelines on A8.
364 let D = VFPNeonA8Domain;
Bill Wendling1fc6d882010-10-13 00:38:07 +0000365}
Evan Chenga8e29892007-01-19 07:51:42 +0000366
Bill Wendling67a704d2010-10-13 20:58:46 +0000367// FIXME: Verify encoding after integrated assembler is working.
Bill Wendling69661192010-11-01 06:00:39 +0000368def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
369 (outs), (ins DPR:$Dd),
370 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
371 [/* For disassembly only; pattern left blank */]> {
372 let Inst{3-0} = 0b0000;
373 let Inst{5} = 0;
Bill Wendling67a704d2010-10-13 20:58:46 +0000374}
Johnny Chen7edd8e32010-02-08 19:41:48 +0000375
Bill Wendling69661192010-11-01 06:00:39 +0000376def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
377 (outs), (ins SPR:$Sd),
378 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
379 [/* For disassembly only; pattern left blank */]> {
380 let Inst{3-0} = 0b0000;
381 let Inst{5} = 0;
Evan Cheng5eda2822011-02-16 00:35:02 +0000382
Evan Cheng6557bce2011-02-22 19:53:14 +0000383 // Some single precision VFP instructions may be executed on both NEON and
384 // VFP pipelines on A8.
385 let D = VFPNeonA8Domain;
Bill Wendling67a704d2010-10-13 20:58:46 +0000386}
Lang Hames4f92b5e2012-03-06 00:19:55 +0000387} // Defs = [FPSCR_NZCV]
Evan Chenga8e29892007-01-19 07:51:42 +0000388
Bill Wendling54908dd2010-10-13 00:56:35 +0000389def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
390 (outs DPR:$Dd), (ins SPR:$Sm),
391 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
392 [(set DPR:$Dd, (fextend SPR:$Sm))]> {
393 // Instruction operands.
394 bits<5> Dd;
395 bits<5> Sm;
396
397 // Encode instruction operands.
398 let Inst{3-0} = Sm{4-1};
399 let Inst{5} = Sm{0};
400 let Inst{15-12} = Dd{3-0};
401 let Inst{22} = Dd{4};
402}
Evan Chenga8e29892007-01-19 07:51:42 +0000403
Evan Cheng96581d32008-11-11 02:11:05 +0000404// Special case encoding: bits 11-8 is 0b1011.
Bill Wendling54908dd2010-10-13 00:56:35 +0000405def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
406 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
407 [(set SPR:$Sd, (fround DPR:$Dm))]> {
408 // Instruction operands.
409 bits<5> Sd;
410 bits<5> Dm;
411
412 // Encode instruction operands.
413 let Inst{3-0} = Dm{3-0};
414 let Inst{5} = Dm{4};
415 let Inst{15-12} = Sd{4-1};
416 let Inst{22} = Sd{0};
417
Evan Cheng96581d32008-11-11 02:11:05 +0000418 let Inst{27-23} = 0b11101;
419 let Inst{21-16} = 0b110111;
420 let Inst{11-8} = 0b1011;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000421 let Inst{7-6} = 0b11;
422 let Inst{4} = 0;
Evan Cheng96581d32008-11-11 02:11:05 +0000423}
Evan Chenga8e29892007-01-19 07:51:42 +0000424
Johnny Chen2d658df2010-02-09 17:21:56 +0000425// Between half-precision and single-precision. For disassembly only.
426
Bill Wendling67a704d2010-10-13 20:58:46 +0000427// FIXME: Verify encoding after integrated assembler is working.
Owen Anderson838130e2011-08-22 21:34:00 +0000428def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
429 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000430 [/* For disassembly only; pattern left blank */]>;
431
Bob Wilson76a312b2010-03-19 22:51:32 +0000432def : ARMPat<(f32_to_f16 SPR:$a),
433 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000434
Owen Anderson838130e2011-08-22 21:34:00 +0000435def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
436 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm",
Anton Korobeynikovf0d50072010-03-18 22:35:37 +0000437 [/* For disassembly only; pattern left blank */]>;
438
Bob Wilson76a312b2010-03-19 22:51:32 +0000439def : ARMPat<(f16_to_f32 GPR:$a),
440 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
Johnny Chen2d658df2010-02-09 17:21:56 +0000441
Owen Anderson838130e2011-08-22 21:34:00 +0000442def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
443 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm",
Johnny Chen2d658df2010-02-09 17:21:56 +0000444 [/* For disassembly only; pattern left blank */]>;
445
Owen Anderson838130e2011-08-22 21:34:00 +0000446def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
447 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm",
Johnny Chen2d658df2010-02-09 17:21:56 +0000448 [/* For disassembly only; pattern left blank */]>;
449
Bill Wendling69661192010-11-01 06:00:39 +0000450def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
451 (outs DPR:$Dd), (ins DPR:$Dm),
452 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
453 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000454
Bill Wendling69661192010-11-01 06:00:39 +0000455def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
456 (outs SPR:$Sd), (ins SPR:$Sm),
457 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
Evan Cheng5eda2822011-02-16 00:35:02 +0000458 [(set SPR:$Sd, (fneg SPR:$Sm))]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000459 // Some single precision VFP instructions may be executed on both NEON and
460 // VFP pipelines on A8.
461 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000462}
Evan Chenga8e29892007-01-19 07:51:42 +0000463
Bill Wendling69661192010-11-01 06:00:39 +0000464def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
465 (outs DPR:$Dd), (ins DPR:$Dm),
466 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
467 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000468
Bill Wendling69661192010-11-01 06:00:39 +0000469def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
470 (outs SPR:$Sd), (ins SPR:$Sm),
471 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
472 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000473
Bill Wendling67a704d2010-10-13 20:58:46 +0000474let neverHasSideEffects = 1 in {
Bill Wendling69661192010-11-01 06:00:39 +0000475def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
476 (outs DPR:$Dd), (ins DPR:$Dm),
477 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000478
Bill Wendling69661192010-11-01 06:00:39 +0000479def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
480 (outs SPR:$Sd), (ins SPR:$Sm),
481 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
Bill Wendling67a704d2010-10-13 20:58:46 +0000482} // neverHasSideEffects
483
Evan Chenga8e29892007-01-19 07:51:42 +0000484//===----------------------------------------------------------------------===//
485// FP <-> GPR Copies. Int <-> FP Conversions.
486//
487
Bill Wendling7d31a162010-10-20 22:44:54 +0000488def VMOVRS : AVConv2I<0b11100001, 0b1010,
489 (outs GPR:$Rt), (ins SPR:$Sn),
490 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
491 [(set GPR:$Rt, (bitconvert SPR:$Sn))]> {
492 // Instruction operands.
493 bits<4> Rt;
494 bits<5> Sn;
Evan Chenga8e29892007-01-19 07:51:42 +0000495
Bill Wendling7d31a162010-10-20 22:44:54 +0000496 // Encode instruction operands.
497 let Inst{19-16} = Sn{4-1};
498 let Inst{7} = Sn{0};
499 let Inst{15-12} = Rt;
500
501 let Inst{6-5} = 0b00;
502 let Inst{3-0} = 0b0000;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000503
504 // Some single precision VFP instructions may be executed on both NEON and VFP
505 // pipelines.
506 let D = VFPNeonDomain;
Bill Wendling7d31a162010-10-20 22:44:54 +0000507}
508
509def VMOVSR : AVConv4I<0b11100000, 0b1010,
510 (outs SPR:$Sn), (ins GPR:$Rt),
511 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
512 [(set SPR:$Sn, (bitconvert GPR:$Rt))]> {
513 // Instruction operands.
514 bits<5> Sn;
515 bits<4> Rt;
516
517 // Encode instruction operands.
518 let Inst{19-16} = Sn{4-1};
519 let Inst{7} = Sn{0};
520 let Inst{15-12} = Rt;
521
522 let Inst{6-5} = 0b00;
523 let Inst{3-0} = 0b0000;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000524
525 // Some single precision VFP instructions may be executed on both NEON and VFP
526 // pipelines.
527 let D = VFPNeonDomain;
Bill Wendling7d31a162010-10-20 22:44:54 +0000528}
Evan Chenga8e29892007-01-19 07:51:42 +0000529
Evan Cheng020cc1b2010-05-13 00:16:46 +0000530let neverHasSideEffects = 1 in {
Jim Grosbache5165492009-11-09 00:11:35 +0000531def VMOVRRD : AVConv3I<0b11000101, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000532 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
533 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
Johnny Chen7acca672010-02-05 18:04:58 +0000534 [/* FIXME: Can't write pattern for multiple result instr*/]> {
Bill Wendling01aabda2010-10-20 23:37:40 +0000535 // Instruction operands.
536 bits<5> Dm;
537 bits<4> Rt;
538 bits<4> Rt2;
539
540 // Encode instruction operands.
541 let Inst{3-0} = Dm{3-0};
542 let Inst{5} = Dm{4};
543 let Inst{15-12} = Rt;
544 let Inst{19-16} = Rt2;
545
Johnny Chen7acca672010-02-05 18:04:58 +0000546 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000547
548 // Some single precision VFP instructions may be executed on both NEON and VFP
549 // pipelines.
550 let D = VFPNeonDomain;
Johnny Chen7acca672010-02-05 18:04:58 +0000551}
Evan Chenga8e29892007-01-19 07:51:42 +0000552
Johnny Chen23401d62010-02-08 17:26:09 +0000553def VMOVRRS : AVConv3I<0b11000101, 0b1010,
Owen Anderson694e0ff2011-08-29 23:15:25 +0000554 (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2),
555 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000556 [/* For disassembly only; pattern left blank */]> {
Owen Anderson694e0ff2011-08-29 23:15:25 +0000557 bits<5> src1;
558 bits<4> Rt;
559 bits<4> Rt2;
560
561 // Encode instruction operands.
562 let Inst{3-0} = src1{3-0};
563 let Inst{5} = src1{4};
564 let Inst{15-12} = Rt;
565 let Inst{19-16} = Rt2;
566
Johnny Chen23401d62010-02-08 17:26:09 +0000567 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000568
569 // Some single precision VFP instructions may be executed on both NEON and VFP
570 // pipelines.
571 let D = VFPNeonDomain;
Owen Anderson357ec682011-08-22 20:27:12 +0000572 let DecoderMethod = "DecodeVMOVRRS";
Johnny Chen23401d62010-02-08 17:26:09 +0000573}
Evan Cheng020cc1b2010-05-13 00:16:46 +0000574} // neverHasSideEffects
Johnny Chen23401d62010-02-08 17:26:09 +0000575
Evan Chenga8e29892007-01-19 07:51:42 +0000576// FMDHR: GPR -> SPR
577// FMDLR: GPR -> SPR
578
Jim Grosbache5165492009-11-09 00:11:35 +0000579def VMOVDRR : AVConv5I<0b11000100, 0b1011,
Bill Wendling01aabda2010-10-20 23:37:40 +0000580 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
581 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
582 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]> {
583 // Instruction operands.
584 bits<5> Dm;
585 bits<4> Rt;
586 bits<4> Rt2;
587
588 // Encode instruction operands.
589 let Inst{3-0} = Dm{3-0};
590 let Inst{5} = Dm{4};
591 let Inst{15-12} = Rt;
592 let Inst{19-16} = Rt2;
593
594 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000595
596 // Some single precision VFP instructions may be executed on both NEON and VFP
597 // pipelines.
598 let D = VFPNeonDomain;
Johnny Chen7acca672010-02-05 18:04:58 +0000599}
Evan Chenga8e29892007-01-19 07:51:42 +0000600
Evan Cheng020cc1b2010-05-13 00:16:46 +0000601let neverHasSideEffects = 1 in
Johnny Chen23401d62010-02-08 17:26:09 +0000602def VMOVSRR : AVConv5I<0b11000100, 0b1010,
603 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
Anton Korobeynikova31c6fb2010-04-07 18:20:02 +0000604 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
Johnny Chen23401d62010-02-08 17:26:09 +0000605 [/* For disassembly only; pattern left blank */]> {
Owen Anderson694e0ff2011-08-29 23:15:25 +0000606 // Instruction operands.
607 bits<5> dst1;
608 bits<4> src1;
609 bits<4> src2;
610
611 // Encode instruction operands.
612 let Inst{3-0} = dst1{3-0};
613 let Inst{5} = dst1{4};
614 let Inst{15-12} = src1;
615 let Inst{19-16} = src2;
616
Johnny Chen23401d62010-02-08 17:26:09 +0000617 let Inst{7-6} = 0b00;
Bob Wilsonb34d8372011-04-19 18:11:38 +0000618
619 // Some single precision VFP instructions may be executed on both NEON and VFP
620 // pipelines.
621 let D = VFPNeonDomain;
Owen Anderson357ec682011-08-22 20:27:12 +0000622
623 let DecoderMethod = "DecodeVMOVSRR";
Johnny Chen23401d62010-02-08 17:26:09 +0000624}
625
Evan Chenga8e29892007-01-19 07:51:42 +0000626// FMRDH: SPR -> GPR
627// FMRDL: SPR -> GPR
628// FMRRS: SPR -> GPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000629// FMRX: SPR system reg -> GPR
Evan Chenga8e29892007-01-19 07:51:42 +0000630// FMSRR: GPR -> SPR
Bill Wendling67a704d2010-10-13 20:58:46 +0000631// FMXR: GPR -> VFP system reg
Evan Chenga8e29892007-01-19 07:51:42 +0000632
633
Bill Wendling67a704d2010-10-13 20:58:46 +0000634// Int -> FP:
Evan Chenga8e29892007-01-19 07:51:42 +0000635
Bill Wendling67a704d2010-10-13 20:58:46 +0000636class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
637 bits<4> opcod4, dag oops, dag iops,
638 InstrItinClass itin, string opc, string asm,
639 list<dag> pattern>
640 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
641 pattern> {
642 // Instruction operands.
643 bits<5> Dd;
644 bits<5> Sm;
645
646 // Encode instruction operands.
647 let Inst{3-0} = Sm{4-1};
648 let Inst{5} = Sm{0};
649 let Inst{15-12} = Dd{3-0};
650 let Inst{22} = Dd{4};
651}
652
653class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
654 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
655 string opc, string asm, list<dag> pattern>
656 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
657 pattern> {
658 // Instruction operands.
659 bits<5> Sd;
660 bits<5> Sm;
661
662 // Encode instruction operands.
663 let Inst{3-0} = Sm{4-1};
664 let Inst{5} = Sm{0};
665 let Inst{15-12} = Sd{4-1};
666 let Inst{22} = Sd{0};
667}
668
669def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
670 (outs DPR:$Dd), (ins SPR:$Sm),
671 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
672 [(set DPR:$Dd, (f64 (arm_sitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000673 let Inst{7} = 1; // s32
Evan Cheng78be83d2008-11-11 19:40:26 +0000674}
Evan Chenga8e29892007-01-19 07:51:42 +0000675
Bill Wendling67a704d2010-10-13 20:58:46 +0000676def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
677 (outs SPR:$Sd),(ins SPR:$Sm),
678 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
679 [(set SPR:$Sd, (arm_sitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000680 let Inst{7} = 1; // s32
Evan Cheng5eda2822011-02-16 00:35:02 +0000681
Evan Cheng6557bce2011-02-22 19:53:14 +0000682 // Some single precision VFP instructions may be executed on both NEON and
683 // VFP pipelines on A8.
684 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000685}
Evan Chenga8e29892007-01-19 07:51:42 +0000686
Bill Wendling67a704d2010-10-13 20:58:46 +0000687def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
688 (outs DPR:$Dd), (ins SPR:$Sm),
689 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
690 [(set DPR:$Dd, (f64 (arm_uitof SPR:$Sm)))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000691 let Inst{7} = 0; // u32
692}
Evan Chenga8e29892007-01-19 07:51:42 +0000693
Bill Wendling67a704d2010-10-13 20:58:46 +0000694def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
695 (outs SPR:$Sd), (ins SPR:$Sm),
696 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
697 [(set SPR:$Sd, (arm_uitof SPR:$Sm))]> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000698 let Inst{7} = 0; // u32
Evan Cheng5eda2822011-02-16 00:35:02 +0000699
Evan Cheng6557bce2011-02-22 19:53:14 +0000700 // Some single precision VFP instructions may be executed on both NEON and
701 // VFP pipelines on A8.
702 let D = VFPNeonA8Domain;
Johnny Chen69a8c7f2010-01-29 23:21:10 +0000703}
Evan Chenga8e29892007-01-19 07:51:42 +0000704
Bill Wendling67a704d2010-10-13 20:58:46 +0000705// FP -> Int:
706
707class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
708 bits<4> opcod4, dag oops, dag iops,
709 InstrItinClass itin, string opc, string asm,
710 list<dag> pattern>
711 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
712 pattern> {
713 // Instruction operands.
714 bits<5> Sd;
715 bits<5> Dm;
716
717 // Encode instruction operands.
718 let Inst{3-0} = Dm{3-0};
719 let Inst{5} = Dm{4};
720 let Inst{15-12} = Sd{4-1};
721 let Inst{22} = Sd{0};
722}
723
724class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
725 bits<4> opcod4, dag oops, dag iops,
726 InstrItinClass itin, string opc, string asm,
727 list<dag> pattern>
728 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
729 pattern> {
730 // Instruction operands.
731 bits<5> Sd;
732 bits<5> Sm;
733
734 // Encode instruction operands.
735 let Inst{3-0} = Sm{4-1};
736 let Inst{5} = Sm{0};
737 let Inst{15-12} = Sd{4-1};
738 let Inst{22} = Sd{0};
739}
740
Evan Chenga8e29892007-01-19 07:51:42 +0000741// Always set Z bit in the instruction, i.e. "round towards zero" variants.
Bill Wendling67a704d2010-10-13 20:58:46 +0000742def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
743 (outs SPR:$Sd), (ins DPR:$Dm),
744 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
745 [(set SPR:$Sd, (arm_ftosi (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000746 let Inst{7} = 1; // Z bit
747}
Evan Chenga8e29892007-01-19 07:51:42 +0000748
Bill Wendling67a704d2010-10-13 20:58:46 +0000749def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
750 (outs SPR:$Sd), (ins SPR:$Sm),
751 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
752 [(set SPR:$Sd, (arm_ftosi SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000753 let Inst{7} = 1; // Z bit
Evan Cheng5eda2822011-02-16 00:35:02 +0000754
Evan Cheng6557bce2011-02-22 19:53:14 +0000755 // Some single precision VFP instructions may be executed on both NEON and
756 // VFP pipelines on A8.
757 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000758}
Evan Chenga8e29892007-01-19 07:51:42 +0000759
Bill Wendling67a704d2010-10-13 20:58:46 +0000760def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
761 (outs SPR:$Sd), (ins DPR:$Dm),
762 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
763 [(set SPR:$Sd, (arm_ftoui (f64 DPR:$Dm)))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000764 let Inst{7} = 1; // Z bit
765}
Evan Chenga8e29892007-01-19 07:51:42 +0000766
Bill Wendling67a704d2010-10-13 20:58:46 +0000767def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
768 (outs SPR:$Sd), (ins SPR:$Sm),
769 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
770 [(set SPR:$Sd, (arm_ftoui SPR:$Sm))]> {
Evan Cheng78be83d2008-11-11 19:40:26 +0000771 let Inst{7} = 1; // Z bit
Evan Cheng5eda2822011-02-16 00:35:02 +0000772
Evan Cheng6557bce2011-02-22 19:53:14 +0000773 // Some single precision VFP instructions may be executed on both NEON and
774 // VFP pipelines on A8.
775 let D = VFPNeonA8Domain;
Evan Cheng78be83d2008-11-11 19:40:26 +0000776}
Evan Chenga8e29892007-01-19 07:51:42 +0000777
Johnny Chen15b423f2010-02-08 22:02:41 +0000778// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
Nate Begemand1fb5832010-08-03 21:31:55 +0000779let Uses = [FPSCR] in {
Bill Wendling67a704d2010-10-13 20:58:46 +0000780// FIXME: Verify encoding after integrated assembler is working.
781def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
782 (outs SPR:$Sd), (ins DPR:$Dm),
783 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
784 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000785 let Inst{7} = 0; // Z bit
786}
787
Bill Wendling67a704d2010-10-13 20:58:46 +0000788def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
789 (outs SPR:$Sd), (ins SPR:$Sm),
790 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
791 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000792 let Inst{7} = 0; // Z bit
793}
794
Bill Wendling67a704d2010-10-13 20:58:46 +0000795def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
796 (outs SPR:$Sd), (ins DPR:$Dm),
797 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
Bill Wendling88cf0382010-10-14 01:02:08 +0000798 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
Johnny Chen15b423f2010-02-08 22:02:41 +0000799 let Inst{7} = 0; // Z bit
800}
801
Bill Wendling67a704d2010-10-13 20:58:46 +0000802def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
803 (outs SPR:$Sd), (ins SPR:$Sm),
804 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
805 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]> {
Johnny Chen15b423f2010-02-08 22:02:41 +0000806 let Inst{7} = 0; // Z bit
807}
Nate Begemand1fb5832010-08-03 21:31:55 +0000808}
Johnny Chen15b423f2010-02-08 22:02:41 +0000809
Johnny Chen27bb8d02010-02-11 18:17:16 +0000810// Convert between floating-point and fixed-point
811// Data type for fixed-point naming convention:
812// S16 (U=0, sx=0) -> SH
813// U16 (U=1, sx=0) -> UH
814// S32 (U=0, sx=1) -> SL
815// U32 (U=1, sx=1) -> UL
816
Jim Grosbach8c748112011-12-22 19:45:01 +0000817let Constraints = "$a = $dst" in {
Johnny Chen27bb8d02010-02-11 18:17:16 +0000818
819// FP to Fixed-Point:
820
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000821// Single Precision register
822class AVConv1XInsS_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
823 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
824 list<dag> pattern>
825 : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> {
826 bits<5> dst;
827 // if dp_operation then UInt(D:Vd) else UInt(Vd:D);
828 let Inst{22} = dst{0};
829 let Inst{15-12} = dst{4-1};
830}
831
832// Double Precision register
833class AVConv1XInsD_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
834 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
835 list<dag> pattern>
836 : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> {
837 bits<5> dst;
838 // if dp_operation then UInt(D:Vd) else UInt(Vd:D);
839 let Inst{22} = dst{4};
840 let Inst{15-12} = dst{3-0};
841}
842
843def VTOSHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000844 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000845 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000846 // Some single precision VFP instructions may be executed on both NEON and
847 // VFP pipelines on A8.
848 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000849}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000850
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000851def VTOUHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000852 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000853 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000854 // Some single precision VFP instructions may be executed on both NEON and
855 // VFP pipelines on A8.
856 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000857}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000858
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000859def VTOSLS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000860 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000861 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000862 // Some single precision VFP instructions may be executed on both NEON and
863 // VFP pipelines on A8.
864 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000865}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000866
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000867def VTOULS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000868 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000869 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000870 // Some single precision VFP instructions may be executed on both NEON and
871 // VFP pipelines on A8.
872 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000873}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000874
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000875def VTOSHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000876 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000877 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000878
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000879def VTOUHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000880 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000881 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000882
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000883def VTOSLD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000884 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000885 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000886
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000887def VTOULD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000888 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000889 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000890
891// Fixed-Point to FP:
892
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000893def VSHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000894 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000895 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000896 // Some single precision VFP instructions may be executed on both NEON and
897 // VFP pipelines on A8.
898 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000899}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000900
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000901def VUHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000902 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000903 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000904 // Some single precision VFP instructions may be executed on both NEON and
905 // VFP pipelines on A8.
906 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000907}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000908
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000909def VSLTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000910 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000911 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000912 // Some single precision VFP instructions may be executed on both NEON and
913 // VFP pipelines on A8.
914 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000915}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000916
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000917def VULTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000918 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000919 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits", []> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000920 // Some single precision VFP instructions may be executed on both NEON and
921 // VFP pipelines on A8.
922 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000923}
Johnny Chen27bb8d02010-02-11 18:17:16 +0000924
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000925def VSHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000926 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000927 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000928
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000929def VUHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 0,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000930 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000931 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000932
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000933def VSLTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000934 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000935 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000936
Kristof Beyls8a6bcc32012-03-15 17:50:29 +0000937def VULTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 1,
Jim Grosbach4050bc42011-12-22 22:19:05 +0000938 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
Jim Grosbach8c748112011-12-22 19:45:01 +0000939 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", []>;
Johnny Chen27bb8d02010-02-11 18:17:16 +0000940
Jim Grosbach8c748112011-12-22 19:45:01 +0000941} // End of 'let Constraints = "$a = $dst" in'
Johnny Chen27bb8d02010-02-11 18:17:16 +0000942
Evan Chenga8e29892007-01-19 07:51:42 +0000943//===----------------------------------------------------------------------===//
Cameron Zwarich375db7f2011-07-07 08:28:52 +0000944// FP Multiply-Accumulate Operations.
Evan Chenga8e29892007-01-19 07:51:42 +0000945//
946
Evan Cheng529916c2010-11-12 20:32:20 +0000947def VMLAD : ADbI<0b11100, 0b00, 0, 0,
948 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
949 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000950 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
951 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000952 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000953 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000954
Bill Wendling69661192010-11-01 06:00:39 +0000955def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
956 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
957 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000958 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
959 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000960 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000961 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000962 // Some single precision VFP instructions may be executed on both NEON and
963 // VFP pipelines on A8.
964 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000965}
Evan Chenga8e29892007-01-19 07:51:42 +0000966
Evan Cheng48575f62010-12-05 22:04:16 +0000967def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000968 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000969 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +0000970def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000971 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000972 Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx,NoVFP4]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000973
Evan Cheng529916c2010-11-12 20:32:20 +0000974def VMLSD : ADbI<0b11100, 0b00, 1, 0,
975 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
976 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +0000977 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
978 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000979 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000980 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +0000981
Bill Wendling69661192010-11-01 06:00:39 +0000982def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
983 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
984 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +0000985 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
986 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +0000987 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000988 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +0000989 // Some single precision VFP instructions may be executed on both NEON and
990 // VFP pipelines on A8.
991 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +0000992}
Evan Chenga8e29892007-01-19 07:51:42 +0000993
Evan Cheng48575f62010-12-05 22:04:16 +0000994def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
Evan Cheng529916c2010-11-12 20:32:20 +0000995 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000996 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +0000997def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
Evan Cheng529916c2010-11-12 20:32:20 +0000998 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +0000999 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
David Goodwinb84f3d42009-08-04 18:44:29 +00001000
Evan Cheng529916c2010-11-12 20:32:20 +00001001def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
1002 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1003 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +00001004 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1005 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +00001006 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001007 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Chenga8e29892007-01-19 07:51:42 +00001008
Bill Wendling69661192010-11-01 06:00:39 +00001009def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
1010 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1011 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +00001012 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1013 SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +00001014 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001015 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +00001016 // Some single precision VFP instructions may be executed on both NEON and
1017 // VFP pipelines on A8.
1018 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +00001019}
Bill Wendling88cf0382010-10-14 01:02:08 +00001020
Evan Cheng48575f62010-12-05 22:04:16 +00001021def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001022 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001023 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +00001024def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001025 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001026 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +00001027
Evan Cheng529916c2010-11-12 20:32:20 +00001028def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
1029 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1030 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
Evan Cheng48575f62010-12-05 22:04:16 +00001031 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1032 (f64 DPR:$Ddin)))]>,
Evan Cheng529916c2010-11-12 20:32:20 +00001033 RegConstraint<"$Ddin = $Dd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001034 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +00001035
Bill Wendling69661192010-11-01 06:00:39 +00001036def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
1037 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1038 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
Evan Cheng48575f62010-12-05 22:04:16 +00001039 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
Evan Cheng529916c2010-11-12 20:32:20 +00001040 RegConstraint<"$Sdin = $Sd">,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001041 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
Evan Cheng6557bce2011-02-22 19:53:14 +00001042 // Some single precision VFP instructions may be executed on both NEON and
1043 // VFP pipelines on A8.
1044 let D = VFPNeonA8Domain;
Evan Cheng5eda2822011-02-16 00:35:02 +00001045}
Bill Wendling88cf0382010-10-14 01:02:08 +00001046
Evan Cheng48575f62010-12-05 22:04:16 +00001047def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001048 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001049 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
Evan Cheng48575f62010-12-05 22:04:16 +00001050def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
Evan Cheng529916c2010-11-12 20:32:20 +00001051 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001052 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
Bill Wendling88cf0382010-10-14 01:02:08 +00001053
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001054//===----------------------------------------------------------------------===//
1055// Fused FP Multiply-Accumulate Operations.
1056//
1057def VFMAD : ADbI<0b11101, 0b10, 0, 0,
1058 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1059 IIC_fpFMAC64, "vfma", ".f64\t$Dd, $Dn, $Dm",
1060 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1061 (f64 DPR:$Ddin)))]>,
1062 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001063 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001064
1065def VFMAS : ASbIn<0b11101, 0b10, 0, 0,
1066 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1067 IIC_fpFMAC32, "vfma", ".f32\t$Sd, $Sn, $Sm",
1068 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
1069 SPR:$Sdin))]>,
1070 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001071 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001072 // Some single precision VFP instructions may be executed on both NEON and
1073 // VFP pipelines.
1074}
1075
1076def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1077 (VFMAD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001078 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001079def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1080 (VFMAS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001081 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001082
1083def VFMSD : ADbI<0b11101, 0b10, 1, 0,
1084 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1085 IIC_fpFMAC64, "vfms", ".f64\t$Dd, $Dn, $Dm",
1086 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1087 (f64 DPR:$Ddin)))]>,
1088 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001089 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001090
1091def VFMSS : ASbIn<0b11101, 0b10, 1, 0,
1092 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1093 IIC_fpFMAC32, "vfms", ".f32\t$Sd, $Sn, $Sm",
1094 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1095 SPR:$Sdin))]>,
1096 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001097 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001098 // Some single precision VFP instructions may be executed on both NEON and
1099 // VFP pipelines.
1100}
1101
1102def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1103 (VFMSD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001104 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001105def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1106 (VFMSS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001107 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001108
1109def VFNMAD : ADbI<0b11101, 0b01, 1, 0,
1110 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1111 IIC_fpFMAC64, "vfnma", ".f64\t$Dd, $Dn, $Dm",
1112 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1113 (f64 DPR:$Ddin)))]>,
1114 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001115 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001116
1117def VFNMAS : ASbI<0b11101, 0b01, 1, 0,
1118 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1119 IIC_fpFMAC32, "vfnma", ".f32\t$Sd, $Sn, $Sm",
1120 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1121 SPR:$Sdin))]>,
1122 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001123 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001124 // Some single precision VFP instructions may be executed on both NEON and
1125 // VFP pipelines.
1126}
1127
1128def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
1129 (VFNMAD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001130 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001131def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
1132 (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001133 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001134
1135def VFNMSD : ADbI<0b11101, 0b01, 0, 0,
1136 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1137 IIC_fpFMAC64, "vfnms", ".f64\t$Dd, $Dn, $Dm",
1138 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1139 (f64 DPR:$Ddin)))]>,
1140 RegConstraint<"$Ddin = $Dd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001141 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001142
1143def VFNMSS : ASbI<0b11101, 0b01, 0, 0,
1144 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1145 IIC_fpFMAC32, "vfnms", ".f32\t$Sd, $Sn, $Sm",
1146 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
1147 RegConstraint<"$Sdin = $Sd">,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001148 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001149 // Some single precision VFP instructions may be executed on both NEON and
1150 // VFP pipelines.
1151}
1152
1153def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
1154 (VFNMSD DPR:$dstin, DPR:$a, DPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001155 Requires<[HasVFP4,FPContractions]>;
Anton Korobeynikov4b4e6222012-01-22 12:07:33 +00001156def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
1157 (VFNMSS SPR:$dstin, SPR:$a, SPR:$b)>,
Sebastian Pop74bebde2012-03-05 17:39:52 +00001158 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
Evan Chenga8e29892007-01-19 07:51:42 +00001159
1160//===----------------------------------------------------------------------===//
1161// FP Conditional moves.
1162//
1163
Evan Cheng020cc1b2010-05-13 00:16:46 +00001164let neverHasSideEffects = 1 in {
Jim Grosbachf219f312011-03-11 23:09:50 +00001165def VMOVDcc : ARMPseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001166 4, IIC_fpUNA64,
Bill Wendling69661192010-11-01 06:00:39 +00001167 [/*(set DPR:$Dd, (ARMcmov DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
1168 RegConstraint<"$Dn = $Dd">;
Evan Chenga8e29892007-01-19 07:51:42 +00001169
Jim Grosbachf219f312011-03-11 23:09:50 +00001170def VMOVScc : ARMPseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, pred:$p),
Owen Anderson16884412011-07-13 23:22:26 +00001171 4, IIC_fpUNA32,
Bill Wendling69661192010-11-01 06:00:39 +00001172 [/*(set SPR:$Sd, (ARMcmov SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
1173 RegConstraint<"$Sn = $Sd">;
Evan Cheng020cc1b2010-05-13 00:16:46 +00001174} // neverHasSideEffects
Evan Cheng78be83d2008-11-11 19:40:26 +00001175
1176//===----------------------------------------------------------------------===//
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001177// Move from VFP System Register to ARM core register.
Evan Cheng78be83d2008-11-11 19:40:26 +00001178//
1179
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001180class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1181 list<dag> pattern>:
1182 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
Evan Cheng39382422009-10-28 01:44:26 +00001183
Bill Wendling88cf0382010-10-14 01:02:08 +00001184 // Instruction operand.
1185 bits<4> Rt;
1186
Johnny Chenc9745042010-02-09 22:35:38 +00001187 let Inst{27-20} = 0b11101111;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001188 let Inst{19-16} = opc19_16;
1189 let Inst{15-12} = Rt;
Johnny Chenc9745042010-02-09 22:35:38 +00001190 let Inst{11-8} = 0b1010;
1191 let Inst{7} = 0;
Bill Wendling88cf0382010-10-14 01:02:08 +00001192 let Inst{6-5} = 0b00;
Johnny Chenc9745042010-02-09 22:35:38 +00001193 let Inst{4} = 1;
Bill Wendling88cf0382010-10-14 01:02:08 +00001194 let Inst{3-0} = 0b0000;
Johnny Chenc9745042010-02-09 22:35:38 +00001195}
Johnny Chenc9745042010-02-09 22:35:38 +00001196
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001197// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
1198// to APSR.
Lang Hames4f92b5e2012-03-06 00:19:55 +00001199let Defs = [CPSR], Uses = [FPSCR_NZCV], Rt = 0b1111 /* apsr_nzcv */ in
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001200def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
Jim Grosbachb84ad4a2012-03-15 21:34:14 +00001201 "vmrs", "\tAPSR_nzcv, fpscr", [(arm_fmstat)]>;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001202
1203// Application level FPSCR -> GPR
1204let hasSideEffects = 1, Uses = [FPSCR] in
1205def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPR:$Rt), (ins),
1206 "vmrs", "\t$Rt, fpscr",
1207 [(set GPR:$Rt, (int_arm_get_fpscr))]>;
1208
1209// System level FPEXC, FPSID -> GPR
1210let Uses = [FPSCR] in {
1211 def VMRS_FPEXC : MovFromVFP<0b1000 /* fpexc */, (outs GPR:$Rt), (ins),
1212 "vmrs", "\t$Rt, fpexc", []>;
1213 def VMRS_FPSID : MovFromVFP<0b0000 /* fpsid */, (outs GPR:$Rt), (ins),
1214 "vmrs", "\t$Rt, fpsid", []>;
Jim Grosbach9426ac72012-03-16 00:27:18 +00001215 def VMRS_MVFR0 : MovFromVFP<0b0111 /* mvfr0 */, (outs GPR:$Rt), (ins),
1216 "vmrs", "\t$Rt, mvfr0", []>;
1217 def VMRS_MVFR1 : MovFromVFP<0b0110 /* mvfr1 */, (outs GPR:$Rt), (ins),
1218 "vmrs", "\t$Rt, mvfr1", []>;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001219}
1220
1221//===----------------------------------------------------------------------===//
1222// Move from ARM core register to VFP System Register.
1223//
1224
1225class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1226 list<dag> pattern>:
1227 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
1228
Bill Wendling88cf0382010-10-14 01:02:08 +00001229 // Instruction operand.
1230 bits<4> src;
1231
1232 // Encode instruction operand.
1233 let Inst{15-12} = src;
1234
Johnny Chenc9745042010-02-09 22:35:38 +00001235 let Inst{27-20} = 0b11101110;
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001236 let Inst{19-16} = opc19_16;
Johnny Chenc9745042010-02-09 22:35:38 +00001237 let Inst{11-8} = 0b1010;
1238 let Inst{7} = 0;
1239 let Inst{4} = 1;
1240}
Evan Cheng39382422009-10-28 01:44:26 +00001241
Bruno Cardoso Lopes61505902011-01-18 21:58:20 +00001242let Defs = [FPSCR] in {
1243 // Application level GPR -> FPSCR
1244 def VMSR : MovToVFP<0b0001 /* fpscr */, (outs), (ins GPR:$src),
1245 "vmsr", "\tfpscr, $src", [(int_arm_set_fpscr GPR:$src)]>;
1246 // System level GPR -> FPEXC
1247 def VMSR_FPEXC : MovToVFP<0b1000 /* fpexc */, (outs), (ins GPR:$src),
1248 "vmsr", "\tfpexc, $src", []>;
1249 // System level GPR -> FPSID
1250 def VMSR_FPSID : MovToVFP<0b0000 /* fpsid */, (outs), (ins GPR:$src),
1251 "vmsr", "\tfpsid, $src", []>;
1252}
1253
1254//===----------------------------------------------------------------------===//
1255// Misc.
1256//
1257
Evan Cheng39382422009-10-28 01:44:26 +00001258// Materialize FP immediates. VFP3 only.
Jim Grosbache5165492009-11-09 00:11:35 +00001259let isReMaterializable = 1 in {
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001260def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
Anton Korobeynikov63401e32010-04-07 18:19:56 +00001261 VFPMiscFrm, IIC_fpUNA64,
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001262 "vmov", ".f64\t$Dd, $imm",
1263 [(set DPR:$Dd, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001264 bits<5> Dd;
1265 bits<8> imm;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001266
Jim Grosbache5165492009-11-09 00:11:35 +00001267 let Inst{27-23} = 0b11101;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001268 let Inst{22} = Dd{4};
Jim Grosbache5165492009-11-09 00:11:35 +00001269 let Inst{21-20} = 0b11;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001270 let Inst{19-16} = imm{7-4};
1271 let Inst{15-12} = Dd{3-0};
Jim Grosbache5165492009-11-09 00:11:35 +00001272 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001273 let Inst{8} = 1; // Double precision.
Jim Grosbache5165492009-11-09 00:11:35 +00001274 let Inst{7-4} = 0b0000;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001275 let Inst{3-0} = imm{3-0};
Jim Grosbache5165492009-11-09 00:11:35 +00001276}
1277
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001278def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
1279 VFPMiscFrm, IIC_fpUNA32,
1280 "vmov", ".f32\t$Sd, $imm",
1281 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001282 bits<5> Sd;
1283 bits<8> imm;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001284
Evan Cheng39382422009-10-28 01:44:26 +00001285 let Inst{27-23} = 0b11101;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001286 let Inst{22} = Sd{0};
Evan Cheng39382422009-10-28 01:44:26 +00001287 let Inst{21-20} = 0b11;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001288 let Inst{19-16} = imm{7-4};
1289 let Inst{15-12} = Sd{4-1};
Evan Cheng39382422009-10-28 01:44:26 +00001290 let Inst{11-9} = 0b101;
Bill Wendlingbbbdcd42010-10-14 02:33:26 +00001291 let Inst{8} = 0; // Single precision.
Evan Cheng39382422009-10-28 01:44:26 +00001292 let Inst{7-4} = 0b0000;
Jim Grosbach4ebbf7b2011-09-30 00:50:06 +00001293 let Inst{3-0} = imm{3-0};
Evan Cheng39382422009-10-28 01:44:26 +00001294}
Evan Cheng39382422009-10-28 01:44:26 +00001295}
Jim Grosbach5cd5ac62011-10-03 21:12:43 +00001296
1297//===----------------------------------------------------------------------===//
1298// Assembler aliases.
1299//
Jim Grosbach67ca1ad2011-12-08 00:49:29 +00001300// A few mnemnoic aliases for pre-unifixed syntax. We don't guarantee to
1301// support them all, but supporting at least some of the basics is
1302// good to be friendly.
Jim Grosbach21d7fb82011-12-09 23:34:09 +00001303def : VFP2MnemonicAlias<"flds", "vldr">;
1304def : VFP2MnemonicAlias<"fldd", "vldr">;
1305def : VFP2MnemonicAlias<"fmrs", "vmov">;
1306def : VFP2MnemonicAlias<"fmsr", "vmov">;
1307def : VFP2MnemonicAlias<"fsqrts", "vsqrt">;
1308def : VFP2MnemonicAlias<"fsqrtd", "vsqrt">;
1309def : VFP2MnemonicAlias<"fadds", "vadd.f32">;
1310def : VFP2MnemonicAlias<"faddd", "vadd.f64">;
1311def : VFP2MnemonicAlias<"fmrdd", "vmov">;
1312def : VFP2MnemonicAlias<"fmrds", "vmov">;
1313def : VFP2MnemonicAlias<"fmrrd", "vmov">;
1314def : VFP2MnemonicAlias<"fmdrr", "vmov">;
Jim Grosbach68490192011-12-19 19:43:50 +00001315def : VFP2MnemonicAlias<"fmuls", "vmul.f32">;
Jim Grosbach21d7fb82011-12-09 23:34:09 +00001316def : VFP2MnemonicAlias<"fmuld", "vmul.f64">;
1317def : VFP2MnemonicAlias<"fnegs", "vneg.f32">;
1318def : VFP2MnemonicAlias<"fnegd", "vneg.f64">;
Jim Grosbach48171e72011-12-10 00:01:02 +00001319def : VFP2MnemonicAlias<"ftosizd", "vcvt.s32.f64">;
1320def : VFP2MnemonicAlias<"ftosid", "vcvtr.s32.f64">;
1321def : VFP2MnemonicAlias<"ftosizs", "vcvt.s32.f32">;
1322def : VFP2MnemonicAlias<"ftosis", "vcvtr.s32.f32">;
1323def : VFP2MnemonicAlias<"ftouizd", "vcvt.u32.f64">;
1324def : VFP2MnemonicAlias<"ftouid", "vcvtr.u32.f64">;
1325def : VFP2MnemonicAlias<"ftouizs", "vcvt.u32.f32">;
1326def : VFP2MnemonicAlias<"ftouis", "vcvtr.u32.f32">;
1327def : VFP2MnemonicAlias<"fsitod", "vcvt.f64.s32">;
1328def : VFP2MnemonicAlias<"fsitos", "vcvt.f32.s32">;
1329def : VFP2MnemonicAlias<"fuitod", "vcvt.f64.u32">;
1330def : VFP2MnemonicAlias<"fuitos", "vcvt.f32.u32">;
Jim Grosbachf1015402011-12-13 20:13:48 +00001331def : VFP2MnemonicAlias<"fsts", "vstr">;
1332def : VFP2MnemonicAlias<"fstd", "vstr">;
Jim Grosbach0f293de2011-12-13 20:40:37 +00001333def : VFP2MnemonicAlias<"fmacd", "vmla.f64">;
1334def : VFP2MnemonicAlias<"fmacs", "vmla.f32">;
Jim Grosbach9c397892011-12-19 19:02:41 +00001335def : VFP2MnemonicAlias<"fcpys", "vmov.f32">;
1336def : VFP2MnemonicAlias<"fcpyd", "vmov.f64">;
Jim Grosbach1aa149f2011-12-22 19:20:45 +00001337def : VFP2MnemonicAlias<"fcmps", "vcmp.f32">;
1338def : VFP2MnemonicAlias<"fcmpd", "vcmp.f64">;
Jim Grosbach9c397892011-12-19 19:02:41 +00001339def : VFP2MnemonicAlias<"fdivs", "vdiv.f32">;
1340def : VFP2MnemonicAlias<"fdivd", "vdiv.f64">;
Jim Grosbach66cba302012-03-16 21:06:13 +00001341def : VFP2MnemonicAlias<"fmrx", "vmrs">;
1342def : VFP2MnemonicAlias<"fmxr", "vmsr">;
Jim Grosbach67ca1ad2011-12-08 00:49:29 +00001343
Jim Grosbach6357cae2012-03-15 20:48:18 +00001344// Be friendly and accept the old form of zero-compare
1345def : VFP2InstAlias<"fcmpzd${p} $val", (VCMPZD DPR:$val, pred:$p)>;
1346def : VFP2InstAlias<"fcmpzs${p} $val", (VCMPZS SPR:$val, pred:$p)>;
1347
1348
Jim Grosbach5cd5ac62011-10-03 21:12:43 +00001349def : VFP2InstAlias<"fmstat${p}", (FMSTAT pred:$p)>;
Jim Grosbach48171e72011-12-10 00:01:02 +00001350def : VFP2InstAlias<"fadds${p} $Sd, $Sn, $Sm",
1351 (VADDS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
1352def : VFP2InstAlias<"faddd${p} $Dd, $Dn, $Dm",
1353 (VADDD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
1354def : VFP2InstAlias<"fsubs${p} $Sd, $Sn, $Sm",
1355 (VSUBS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
1356def : VFP2InstAlias<"fsubd${p} $Dd, $Dn, $Dm",
1357 (VSUBD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
Jim Grosbach5cd5ac62011-10-03 21:12:43 +00001358
Jim Grosbach976c0da2011-12-08 22:51:25 +00001359// No need for the size suffix on VSQRT. It's implied by the register classes.
1360def : VFP2InstAlias<"vsqrt${p} $Sd, $Sm", (VSQRTS SPR:$Sd, SPR:$Sm, pred:$p)>;
1361def : VFP2InstAlias<"vsqrt${p} $Dd, $Dm", (VSQRTD DPR:$Dd, DPR:$Dm, pred:$p)>;
1362
Jim Grosbachffc658b2011-11-14 23:03:21 +00001363// VLDR/VSTR accept an optional type suffix.
Jim Grosbach1ceef1a2011-12-07 01:50:36 +00001364def : VFP2InstAlias<"vldr${p}.32 $Sd, $addr",
1365 (VLDRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
1366def : VFP2InstAlias<"vstr${p}.32 $Sd, $addr",
1367 (VSTRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
1368def : VFP2InstAlias<"vldr${p}.64 $Dd, $addr",
1369 (VLDRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
1370def : VFP2InstAlias<"vstr${p}.64 $Dd, $addr",
1371 (VSTRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
Jim Grosbachbfb0a172011-11-15 20:14:51 +00001372
1373// VMUL has a two-operand form (implied destination operand)
1374def : VFP2InstAlias<"vmul${p}.f64 $Dn, $Dm",
1375 (VMULD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1376def : VFP2InstAlias<"vmul${p}.f32 $Sn, $Sm",
1377 (VMULS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
Jim Grosbach88d012a2011-11-15 22:15:10 +00001378// VADD has a two-operand form (implied destination operand)
1379def : VFP2InstAlias<"vadd${p}.f64 $Dn, $Dm",
1380 (VADDD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1381def : VFP2InstAlias<"vadd${p}.f32 $Sn, $Sm",
1382 (VADDS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
1383// VSUB has a two-operand form (implied destination operand)
1384def : VFP2InstAlias<"vsub${p}.f64 $Dn, $Dm",
1385 (VSUBD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1386def : VFP2InstAlias<"vsub${p}.f32 $Sn, $Sm",
1387 (VSUBS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
Jim Grosbacha68e90c2011-11-15 20:29:42 +00001388
Jim Grosbachaf33a0c2011-12-21 23:24:15 +00001389// VMOV can accept optional 32-bit or less data type suffix suffix.
1390def : VFP2InstAlias<"vmov${p}.8 $Rt, $Sn",
Jim Grosbacha68e90c2011-11-15 20:29:42 +00001391 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
Jim Grosbachaf33a0c2011-12-21 23:24:15 +00001392def : VFP2InstAlias<"vmov${p}.16 $Rt, $Sn",
1393 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1394def : VFP2InstAlias<"vmov${p}.32 $Rt, $Sn",
1395 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1396def : VFP2InstAlias<"vmov${p}.8 $Sn, $Rt",
1397 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1398def : VFP2InstAlias<"vmov${p}.16 $Sn, $Rt",
1399 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1400def : VFP2InstAlias<"vmov${p}.32 $Sn, $Rt",
Jim Grosbacha68e90c2011-11-15 20:29:42 +00001401 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1402
1403def : VFP2InstAlias<"vmov${p}.f64 $Rt, $Rt2, $Dn",
1404 (VMOVRRD GPR:$Rt, GPR:$Rt2, DPR:$Dn, pred:$p)>;
1405def : VFP2InstAlias<"vmov${p}.f64 $Dn, $Rt, $Rt2",
1406 (VMOVDRR DPR:$Dn, GPR:$Rt, GPR:$Rt2, pred:$p)>;
Jim Grosbacheaf20562011-11-15 21:18:35 +00001407
1408// VMOVS doesn't need the .f32 to disambiguate from the NEON encoding the way
1409// VMOVD does.
1410def : VFP2InstAlias<"vmov${p} $Sd, $Sm",
1411 (VMOVS SPR:$Sd, SPR:$Sm, pred:$p)>;