1 //===-- ARMInstrVFP.td - VFP support for ARM ---------------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM VFP instruction set.
12 //===----------------------------------------------------------------------===//
14 def SDT_FTOI : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
15 def SDT_ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
16 def SDT_CMPFP0 : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
17 def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
20 def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
21 def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
22 def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
23 def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
24 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInGlue, SDNPOutGlue]>;
25 def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutGlue]>;
26 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutGlue]>;
27 def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
30 //===----------------------------------------------------------------------===//
31 // Operand Definitions.
34 // 8-bit floating-point immediate encodings.
35 def FPImmOperand : AsmOperandClass {
37 let ParserMethod = "parseFPImm";
40 def vfp_f32imm : Operand<f32>,
41 PatLeaf<(f32 fpimm), [{
42 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);
48 let PrintMethod = "printFPImmOperand";
49 let ParserMatchClass = FPImmOperand;
52 def vfp_f64imm : Operand<f64>,
53 PatLeaf<(f64 fpimm), [{
54 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);
60 let PrintMethod = "printFPImmOperand";
61 let ParserMatchClass = FPImmOperand;
64 // 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.
69 def fbits32_asm_operand : AsmOperandClass { let Name = "FBits32"; }
70 def fbits32 : Operand<i32> {
71 let PrintMethod = "printFBits32";
72 let ParserMatchClass = fbits32_asm_operand;
75 def fbits16_asm_operand : AsmOperandClass { let Name = "FBits16"; }
76 def fbits16 : Operand<i32> {
77 let PrintMethod = "printFBits16";
78 let ParserMatchClass = fbits16_asm_operand;
81 //===----------------------------------------------------------------------===//
82 // Load / store Instructions.
85 let canFoldAsLoad = 1, isReMaterializable = 1 in {
87 def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
88 IIC_fpLoad64, "vldr", "\t$Dd, $addr",
89 [(set DPR:$Dd, (f64 (load addrmode5:$addr)))]>;
91 def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
92 IIC_fpLoad32, "vldr", "\t$Sd, $addr",
93 [(set SPR:$Sd, (load addrmode5:$addr))]> {
94 // Some single precision VFP instructions may be executed on both NEON and VFP
96 let D = VFPNeonDomain;
99 } // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
101 def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
102 IIC_fpStore64, "vstr", "\t$Dd, $addr",
103 [(store (f64 DPR:$Dd), addrmode5:$addr)]>;
105 def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
106 IIC_fpStore32, "vstr", "\t$Sd, $addr",
107 [(store SPR:$Sd, addrmode5:$addr)]> {
108 // Some single precision VFP instructions may be executed on both NEON and VFP
110 let D = VFPNeonDomain;
113 //===----------------------------------------------------------------------===//
114 // Load / store multiple Instructions.
117 multiclass vfp_ldst_mult<string asm, bit L_bit,
118 InstrItinClass itin, InstrItinClass itin_upd> {
121 AXDI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
123 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
124 let Inst{24-23} = 0b01; // Increment After
125 let Inst{21} = 0; // No writeback
126 let Inst{20} = L_bit;
129 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
131 IndexModeUpd, itin_upd,
132 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
133 let Inst{24-23} = 0b01; // Increment After
134 let Inst{21} = 1; // Writeback
135 let Inst{20} = L_bit;
138 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
140 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;
149 AXSI4<(outs), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, variable_ops),
151 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
152 let Inst{24-23} = 0b01; // Increment After
153 let Inst{21} = 0; // No writeback
154 let Inst{20} = L_bit;
156 // Some single precision VFP instructions may be executed on both NEON and
158 let D = VFPNeonDomain;
161 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
163 IndexModeUpd, itin_upd,
164 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
165 let Inst{24-23} = 0b01; // Increment After
166 let Inst{21} = 1; // Writeback
167 let Inst{20} = L_bit;
169 // Some single precision VFP instructions may be executed on both NEON and
171 let D = VFPNeonDomain;
174 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
176 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;
182 // Some single precision VFP instructions may be executed on both NEON and
184 let D = VFPNeonDomain;
188 let neverHasSideEffects = 1 in {
190 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
191 defm VLDM : vfp_ldst_mult<"vldm", 1, IIC_fpLoad_m, IIC_fpLoad_mu>;
193 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
194 defm VSTM : vfp_ldst_mult<"vstm", 0, IIC_fpLoad_m, IIC_fpLoad_mu>;
196 } // neverHasSideEffects
198 def : MnemonicAlias<"vldm", "vldmia">;
199 def : MnemonicAlias<"vstm", "vstmia">;
201 def : InstAlias<"vpush${p} $r", (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>,
203 def : InstAlias<"vpush${p} $r", (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>,
205 def : InstAlias<"vpop${p} $r", (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>,
207 def : InstAlias<"vpop${p} $r", (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>,
210 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
212 //===----------------------------------------------------------------------===//
213 // FP Binary Operations.
216 def 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)))]>;
221 def VADDS : ASbIn<0b11100, 0b11, 0, 0,
222 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
223 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
224 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]> {
225 // Some single precision VFP instructions may be executed on both NEON and
226 // VFP pipelines on A8.
227 let D = VFPNeonA8Domain;
230 def 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)))]>;
235 def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
236 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
237 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
238 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]> {
239 // Some single precision VFP instructions may be executed on both NEON and
240 // VFP pipelines on A8.
241 let D = VFPNeonA8Domain;
244 def 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)))]>;
249 def 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))]>;
254 def 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)))]>;
259 def VMULS : ASbIn<0b11100, 0b10, 0, 0,
260 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
261 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
262 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]> {
263 // Some single precision VFP instructions may be executed on both NEON and
264 // VFP pipelines on A8.
265 let D = VFPNeonA8Domain;
268 def 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))))]>;
273 def VNMULS : ASbI<0b11100, 0b10, 1, 0,
274 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
275 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
276 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]> {
277 // Some single precision VFP instructions may be executed on both NEON and
278 // VFP pipelines on A8.
279 let D = VFPNeonA8Domain;
282 // Match reassociated forms only if not sign dependent rounding.
283 def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
284 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
285 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
286 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
288 // These are encoded as unary instructions.
289 let Defs = [FPSCR] in {
290 def 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))]>;
295 def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
296 (outs), (ins SPR:$Sd, SPR:$Sm),
297 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
298 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> {
299 // Some single precision VFP instructions may be executed on both NEON and
300 // VFP pipelines on A8.
301 let D = VFPNeonA8Domain;
304 // FIXME: Verify encoding after integrated assembler is working.
305 def 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 */]>;
310 def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
311 (outs), (ins SPR:$Sd, SPR:$Sm),
312 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
313 [/* For disassembly only; pattern left blank */]> {
314 // Some single precision VFP instructions may be executed on both NEON and
315 // VFP pipelines on A8.
316 let D = VFPNeonA8Domain;
320 //===----------------------------------------------------------------------===//
321 // FP Unary Operations.
324 def 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)))]>;
329 def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
330 (outs SPR:$Sd), (ins SPR:$Sm),
331 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
332 [(set SPR:$Sd, (fabs SPR:$Sm))]> {
333 // Some single precision VFP instructions may be executed on both NEON and
334 // VFP pipelines on A8.
335 let D = VFPNeonA8Domain;
338 let Defs = [FPSCR] in {
339 def 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;
347 def 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;
354 // Some single precision VFP instructions may be executed on both NEON and
355 // VFP pipelines on A8.
356 let D = VFPNeonA8Domain;
359 // FIXME: Verify encoding after integrated assembler is working.
360 def 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;
368 def 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;
375 // Some single precision VFP instructions may be executed on both NEON and
376 // VFP pipelines on A8.
377 let D = VFPNeonA8Domain;
381 def 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.
389 // Encode instruction operands.
390 let Inst{3-0} = Sm{4-1};
392 let Inst{15-12} = Dd{3-0};
393 let Inst{22} = Dd{4};
396 // Special case encoding: bits 11-8 is 0b1011.
397 def 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.
404 // Encode instruction operands.
405 let Inst{3-0} = Dm{3-0};
407 let Inst{15-12} = Sd{4-1};
408 let Inst{22} = Sd{0};
410 let Inst{27-23} = 0b11101;
411 let Inst{21-16} = 0b110111;
412 let Inst{11-8} = 0b1011;
413 let Inst{7-6} = 0b11;
417 // Between half-precision and single-precision. For disassembly only.
419 // FIXME: Verify encoding after integrated assembler is working.
420 def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
421 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm",
422 [/* For disassembly only; pattern left blank */]>;
424 def : ARMPat<(f32_to_f16 SPR:$a),
425 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
427 def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
428 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm",
429 [/* For disassembly only; pattern left blank */]>;
431 def : ARMPat<(f16_to_f32 GPR:$a),
432 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
434 def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
435 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm",
436 [/* For disassembly only; pattern left blank */]>;
438 def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
439 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm",
440 [/* For disassembly only; pattern left blank */]>;
442 def 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)))]>;
447 def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
448 (outs SPR:$Sd), (ins SPR:$Sm),
449 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
450 [(set SPR:$Sd, (fneg SPR:$Sm))]> {
451 // Some single precision VFP instructions may be executed on both NEON and
452 // VFP pipelines on A8.
453 let D = VFPNeonA8Domain;
456 def 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)))]>;
461 def 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))]>;
466 let neverHasSideEffects = 1 in {
467 def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
468 (outs DPR:$Dd), (ins DPR:$Dm),
469 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
471 def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
472 (outs SPR:$Sd), (ins SPR:$Sm),
473 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
474 } // neverHasSideEffects
476 //===----------------------------------------------------------------------===//
477 // FP <-> GPR Copies. Int <-> FP Conversions.
480 def 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.
488 // Encode instruction operands.
489 let Inst{19-16} = Sn{4-1};
491 let Inst{15-12} = Rt;
493 let Inst{6-5} = 0b00;
494 let Inst{3-0} = 0b0000;
496 // Some single precision VFP instructions may be executed on both NEON and VFP
498 let D = VFPNeonDomain;
501 def 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.
509 // Encode instruction operands.
510 let Inst{19-16} = Sn{4-1};
512 let Inst{15-12} = Rt;
514 let Inst{6-5} = 0b00;
515 let Inst{3-0} = 0b0000;
517 // Some single precision VFP instructions may be executed on both NEON and VFP
519 let D = VFPNeonDomain;
522 let neverHasSideEffects = 1 in {
523 def VMOVRRD : AVConv3I<0b11000101, 0b1011,
524 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
525 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
526 [/* FIXME: Can't write pattern for multiple result instr*/]> {
527 // Instruction operands.
532 // Encode instruction operands.
533 let Inst{3-0} = Dm{3-0};
535 let Inst{15-12} = Rt;
536 let Inst{19-16} = Rt2;
538 let Inst{7-6} = 0b00;
540 // Some single precision VFP instructions may be executed on both NEON and VFP
542 let D = VFPNeonDomain;
545 def VMOVRRS : AVConv3I<0b11000101, 0b1010,
546 (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2),
547 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2",
548 [/* For disassembly only; pattern left blank */]> {
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;
559 let Inst{7-6} = 0b00;
561 // Some single precision VFP instructions may be executed on both NEON and VFP
563 let D = VFPNeonDomain;
564 let DecoderMethod = "DecodeVMOVRRS";
566 } // neverHasSideEffects
571 def VMOVDRR : AVConv5I<0b11000100, 0b1011,
572 (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.
580 // Encode instruction operands.
581 let Inst{3-0} = Dm{3-0};
583 let Inst{15-12} = Rt;
584 let Inst{19-16} = Rt2;
586 let Inst{7-6} = 0b00;
588 // Some single precision VFP instructions may be executed on both NEON and VFP
590 let D = VFPNeonDomain;
593 let neverHasSideEffects = 1 in
594 def VMOVSRR : AVConv5I<0b11000100, 0b1010,
595 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
596 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
597 [/* For disassembly only; pattern left blank */]> {
598 // Instruction operands.
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;
609 let Inst{7-6} = 0b00;
611 // Some single precision VFP instructions may be executed on both NEON and VFP
613 let D = VFPNeonDomain;
615 let DecoderMethod = "DecodeVMOVSRR";
621 // FMRX: SPR system reg -> GPR
623 // FMXR: GPR -> VFP system reg
628 class 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,
632 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
634 // Instruction operands.
638 // Encode instruction operands.
639 let Inst{3-0} = Sm{4-1};
641 let Inst{15-12} = Dd{3-0};
642 let Inst{22} = Dd{4};
645 class 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,
650 // Instruction operands.
654 // Encode instruction operands.
655 let Inst{3-0} = Sm{4-1};
657 let Inst{15-12} = Sd{4-1};
658 let Inst{22} = Sd{0};
661 def 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)))]> {
665 let Inst{7} = 1; // s32
668 def 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))]> {
672 let Inst{7} = 1; // s32
674 // Some single precision VFP instructions may be executed on both NEON and
675 // VFP pipelines on A8.
676 let D = VFPNeonA8Domain;
679 def 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)))]> {
683 let Inst{7} = 0; // u32
686 def 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))]> {
690 let Inst{7} = 0; // u32
692 // Some single precision VFP instructions may be executed on both NEON and
693 // VFP pipelines on A8.
694 let D = VFPNeonA8Domain;
699 class 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,
703 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
705 // Instruction operands.
709 // Encode instruction operands.
710 let Inst{3-0} = Dm{3-0};
712 let Inst{15-12} = Sd{4-1};
713 let Inst{22} = Sd{0};
716 class 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,
720 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
722 // Instruction operands.
726 // Encode instruction operands.
727 let Inst{3-0} = Sm{4-1};
729 let Inst{15-12} = Sd{4-1};
730 let Inst{22} = Sd{0};
733 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
734 def 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)))]> {
738 let Inst{7} = 1; // Z bit
741 def 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))]> {
745 let Inst{7} = 1; // Z bit
747 // Some single precision VFP instructions may be executed on both NEON and
748 // VFP pipelines on A8.
749 let D = VFPNeonA8Domain;
752 def 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)))]> {
756 let Inst{7} = 1; // Z bit
759 def 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))]> {
763 let Inst{7} = 1; // Z bit
765 // Some single precision VFP instructions may be executed on both NEON and
766 // VFP pipelines on A8.
767 let D = VFPNeonA8Domain;
770 // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
771 let Uses = [FPSCR] in {
772 // FIXME: Verify encoding after integrated assembler is working.
773 def 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)))]>{
777 let Inst{7} = 0; // Z bit
780 def 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))]> {
784 let Inst{7} = 0; // Z bit
787 def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
788 (outs SPR:$Sd), (ins DPR:$Dm),
789 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
790 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
791 let Inst{7} = 0; // Z bit
794 def 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))]> {
798 let Inst{7} = 0; // Z bit
802 // 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
809 let Constraints = "$a = $dst" in {
811 // FP to Fixed-Point:
813 def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
814 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
815 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", []> {
816 // Some single precision VFP instructions may be executed on both NEON and
817 // VFP pipelines on A8.
818 let D = VFPNeonA8Domain;
821 def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
822 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
823 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits", []> {
824 // Some single precision VFP instructions may be executed on both NEON and
825 // VFP pipelines on A8.
826 let D = VFPNeonA8Domain;
829 def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
830 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
831 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits", []> {
832 // Some single precision VFP instructions may be executed on both NEON and
833 // VFP pipelines on A8.
834 let D = VFPNeonA8Domain;
837 def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
838 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
839 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits", []> {
840 // Some single precision VFP instructions may be executed on both NEON and
841 // VFP pipelines on A8.
842 let D = VFPNeonA8Domain;
845 def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
846 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
847 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits", []>;
849 def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
850 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
851 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits", []>;
853 def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
854 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
855 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits", []>;
857 def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
858 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
859 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", []>;
861 // Fixed-Point to FP:
863 def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
864 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
865 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", []> {
866 // Some single precision VFP instructions may be executed on both NEON and
867 // VFP pipelines on A8.
868 let D = VFPNeonA8Domain;
871 def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
872 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
873 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits", []> {
874 // Some single precision VFP instructions may be executed on both NEON and
875 // VFP pipelines on A8.
876 let D = VFPNeonA8Domain;
879 def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
880 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
881 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits", []> {
882 // Some single precision VFP instructions may be executed on both NEON and
883 // VFP pipelines on A8.
884 let D = VFPNeonA8Domain;
887 def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
888 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
889 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits", []> {
890 // Some single precision VFP instructions may be executed on both NEON and
891 // VFP pipelines on A8.
892 let D = VFPNeonA8Domain;
895 def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
896 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
897 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits", []>;
899 def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
900 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
901 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits", []>;
903 def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
904 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
905 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits", []>;
907 def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
908 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
909 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", []>;
911 } // End of 'let Constraints = "$a = $dst" in'
913 //===----------------------------------------------------------------------===//
914 // FP Multiply-Accumulate Operations.
917 def 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",
920 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
922 RegConstraint<"$Ddin = $Dd">,
923 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
925 def 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",
928 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
930 RegConstraint<"$Sdin = $Sd">,
931 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
932 // Some single precision VFP instructions may be executed on both NEON and
933 // VFP pipelines on A8.
934 let D = VFPNeonA8Domain;
937 def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
938 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
939 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
940 def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
941 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
942 Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx,NoVFP4]>;
944 def 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",
947 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
949 RegConstraint<"$Ddin = $Dd">,
950 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
952 def 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",
955 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
957 RegConstraint<"$Sdin = $Sd">,
958 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
959 // Some single precision VFP instructions may be executed on both NEON and
960 // VFP pipelines on A8.
961 let D = VFPNeonA8Domain;
964 def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
965 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
966 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
967 def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
968 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
969 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
971 def 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",
974 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
976 RegConstraint<"$Ddin = $Dd">,
977 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
979 def 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",
982 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
984 RegConstraint<"$Sdin = $Sd">,
985 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
986 // Some single precision VFP instructions may be executed on both NEON and
987 // VFP pipelines on A8.
988 let D = VFPNeonA8Domain;
991 def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
992 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
993 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
994 def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
995 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
996 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
998 def 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",
1001 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1002 (f64 DPR:$Ddin)))]>,
1003 RegConstraint<"$Ddin = $Dd">,
1004 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
1006 def 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",
1009 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
1010 RegConstraint<"$Sdin = $Sd">,
1011 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]> {
1012 // Some single precision VFP instructions may be executed on both NEON and
1013 // VFP pipelines on A8.
1014 let D = VFPNeonA8Domain;
1017 def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
1018 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
1019 Requires<[HasVFP2,UseFPVMLx,NoVFP4]>;
1020 def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
1021 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
1022 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx,NoVFP4]>;
1024 //===----------------------------------------------------------------------===//
1025 // Fused FP Multiply-Accumulate Operations.
1027 def 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">,
1033 Requires<[HasVFP4,FPContractions]>;
1035 def 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),
1040 RegConstraint<"$Sdin = $Sd">,
1041 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
1042 // Some single precision VFP instructions may be executed on both NEON and
1046 def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1047 (VFMAD DPR:$dstin, DPR:$a, DPR:$b)>,
1048 Requires<[HasVFP4,FPContractions]>;
1049 def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1050 (VFMAS SPR:$dstin, SPR:$a, SPR:$b)>,
1051 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
1053 def 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">,
1059 Requires<[HasVFP4,FPContractions]>;
1061 def 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)),
1066 RegConstraint<"$Sdin = $Sd">,
1067 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
1068 // Some single precision VFP instructions may be executed on both NEON and
1072 def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1073 (VFMSD DPR:$dstin, DPR:$a, DPR:$b)>,
1074 Requires<[HasVFP4,FPContractions]>;
1075 def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1076 (VFMSS SPR:$dstin, SPR:$a, SPR:$b)>,
1077 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
1079 def 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">,
1085 Requires<[HasVFP4,FPContractions]>;
1087 def 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)),
1092 RegConstraint<"$Sdin = $Sd">,
1093 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
1094 // Some single precision VFP instructions may be executed on both NEON and
1098 def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
1099 (VFNMAD DPR:$dstin, DPR:$a, DPR:$b)>,
1100 Requires<[HasVFP4,FPContractions]>;
1101 def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
1102 (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
1103 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
1105 def 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">,
1111 Requires<[HasVFP4,FPContractions]>;
1113 def 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">,
1118 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]> {
1119 // Some single precision VFP instructions may be executed on both NEON and
1123 def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
1124 (VFNMSD DPR:$dstin, DPR:$a, DPR:$b)>,
1125 Requires<[HasVFP4,FPContractions]>;
1126 def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
1127 (VFNMSS SPR:$dstin, SPR:$a, SPR:$b)>,
1128 Requires<[HasVFP4,DontUseNEONForFP,FPContractions]>;
1130 //===----------------------------------------------------------------------===//
1131 // FP Conditional moves.
1134 let neverHasSideEffects = 1 in {
1135 def VMOVDcc : ARMPseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, pred:$p),
1137 [/*(set DPR:$Dd, (ARMcmov DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
1138 RegConstraint<"$Dn = $Dd">;
1140 def VMOVScc : ARMPseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, pred:$p),
1142 [/*(set SPR:$Sd, (ARMcmov SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
1143 RegConstraint<"$Sn = $Sd">;
1144 } // neverHasSideEffects
1146 //===----------------------------------------------------------------------===//
1147 // Move from VFP System Register to ARM core register.
1150 class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1152 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
1154 // Instruction operand.
1157 let Inst{27-20} = 0b11101111;
1158 let Inst{19-16} = opc19_16;
1159 let Inst{15-12} = Rt;
1160 let Inst{11-8} = 0b1010;
1162 let Inst{6-5} = 0b00;
1164 let Inst{3-0} = 0b0000;
1167 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
1169 let Defs = [CPSR], Uses = [FPSCR], Rt = 0b1111 /* apsr_nzcv */ in
1170 def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
1171 "vmrs", "\tapsr_nzcv, fpscr", [(arm_fmstat)]>;
1173 // Application level FPSCR -> GPR
1174 let hasSideEffects = 1, Uses = [FPSCR] in
1175 def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPR:$Rt), (ins),
1176 "vmrs", "\t$Rt, fpscr",
1177 [(set GPR:$Rt, (int_arm_get_fpscr))]>;
1179 // System level FPEXC, FPSID -> GPR
1180 let 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", []>;
1187 //===----------------------------------------------------------------------===//
1188 // Move from ARM core register to VFP System Register.
1191 class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
1193 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
1195 // Instruction operand.
1198 // Encode instruction operand.
1199 let Inst{15-12} = src;
1201 let Inst{27-20} = 0b11101110;
1202 let Inst{19-16} = opc19_16;
1203 let Inst{11-8} = 0b1010;
1208 let 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", []>;
1220 //===----------------------------------------------------------------------===//
1224 // Materialize FP immediates. VFP3 only.
1225 let isReMaterializable = 1 in {
1226 def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
1227 VFPMiscFrm, IIC_fpUNA64,
1228 "vmov", ".f64\t$Dd, $imm",
1229 [(set DPR:$Dd, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
1233 let Inst{27-23} = 0b11101;
1234 let Inst{22} = Dd{4};
1235 let Inst{21-20} = 0b11;
1236 let Inst{19-16} = imm{7-4};
1237 let Inst{15-12} = Dd{3-0};
1238 let Inst{11-9} = 0b101;
1239 let Inst{8} = 1; // Double precision.
1240 let Inst{7-4} = 0b0000;
1241 let Inst{3-0} = imm{3-0};
1244 def 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]> {
1251 let Inst{27-23} = 0b11101;
1252 let Inst{22} = Sd{0};
1253 let Inst{21-20} = 0b11;
1254 let Inst{19-16} = imm{7-4};
1255 let Inst{15-12} = Sd{4-1};
1256 let Inst{11-9} = 0b101;
1257 let Inst{8} = 0; // Single precision.
1258 let Inst{7-4} = 0b0000;
1259 let Inst{3-0} = imm{3-0};
1263 //===----------------------------------------------------------------------===//
1264 // Assembler aliases.
1266 // 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.
1269 def : VFP2MnemonicAlias<"flds", "vldr">;
1270 def : VFP2MnemonicAlias<"fldd", "vldr">;
1271 def : VFP2MnemonicAlias<"fmrs", "vmov">;
1272 def : VFP2MnemonicAlias<"fmsr", "vmov">;
1273 def : VFP2MnemonicAlias<"fsqrts", "vsqrt">;
1274 def : VFP2MnemonicAlias<"fsqrtd", "vsqrt">;
1275 def : VFP2MnemonicAlias<"fadds", "vadd.f32">;
1276 def : VFP2MnemonicAlias<"faddd", "vadd.f64">;
1277 def : VFP2MnemonicAlias<"fmrdd", "vmov">;
1278 def : VFP2MnemonicAlias<"fmrds", "vmov">;
1279 def : VFP2MnemonicAlias<"fmrrd", "vmov">;
1280 def : VFP2MnemonicAlias<"fmdrr", "vmov">;
1281 def : VFP2MnemonicAlias<"fmuls", "vmul.f32">;
1282 def : VFP2MnemonicAlias<"fmuld", "vmul.f64">;
1283 def : VFP2MnemonicAlias<"fnegs", "vneg.f32">;
1284 def : VFP2MnemonicAlias<"fnegd", "vneg.f64">;
1285 def : VFP2MnemonicAlias<"ftosizd", "vcvt.s32.f64">;
1286 def : VFP2MnemonicAlias<"ftosid", "vcvtr.s32.f64">;
1287 def : VFP2MnemonicAlias<"ftosizs", "vcvt.s32.f32">;
1288 def : VFP2MnemonicAlias<"ftosis", "vcvtr.s32.f32">;
1289 def : VFP2MnemonicAlias<"ftouizd", "vcvt.u32.f64">;
1290 def : VFP2MnemonicAlias<"ftouid", "vcvtr.u32.f64">;
1291 def : VFP2MnemonicAlias<"ftouizs", "vcvt.u32.f32">;
1292 def : VFP2MnemonicAlias<"ftouis", "vcvtr.u32.f32">;
1293 def : VFP2MnemonicAlias<"fsitod", "vcvt.f64.s32">;
1294 def : VFP2MnemonicAlias<"fsitos", "vcvt.f32.s32">;
1295 def : VFP2MnemonicAlias<"fuitod", "vcvt.f64.u32">;
1296 def : VFP2MnemonicAlias<"fuitos", "vcvt.f32.u32">;
1297 def : VFP2MnemonicAlias<"fsts", "vstr">;
1298 def : VFP2MnemonicAlias<"fstd", "vstr">;
1299 def : VFP2MnemonicAlias<"fmacd", "vmla.f64">;
1300 def : VFP2MnemonicAlias<"fmacs", "vmla.f32">;
1301 def : VFP2MnemonicAlias<"fcpys", "vmov.f32">;
1302 def : VFP2MnemonicAlias<"fcpyd", "vmov.f64">;
1303 def : VFP2MnemonicAlias<"fcmps", "vcmp.f32">;
1304 def : VFP2MnemonicAlias<"fcmpd", "vcmp.f64">;
1305 def : VFP2MnemonicAlias<"fdivs", "vdiv.f32">;
1306 def : VFP2MnemonicAlias<"fdivd", "vdiv.f64">;
1308 def : VFP2InstAlias<"fmstat${p}", (FMSTAT pred:$p)>;
1309 def : VFP2InstAlias<"fadds${p} $Sd, $Sn, $Sm",
1310 (VADDS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
1311 def : VFP2InstAlias<"faddd${p} $Dd, $Dn, $Dm",
1312 (VADDD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
1313 def : VFP2InstAlias<"fsubs${p} $Sd, $Sn, $Sm",
1314 (VSUBS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
1315 def : VFP2InstAlias<"fsubd${p} $Dd, $Dn, $Dm",
1316 (VSUBD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
1318 // No need for the size suffix on VSQRT. It's implied by the register classes.
1319 def : VFP2InstAlias<"vsqrt${p} $Sd, $Sm", (VSQRTS SPR:$Sd, SPR:$Sm, pred:$p)>;
1320 def : VFP2InstAlias<"vsqrt${p} $Dd, $Dm", (VSQRTD DPR:$Dd, DPR:$Dm, pred:$p)>;
1322 // VLDR/VSTR accept an optional type suffix.
1323 def : VFP2InstAlias<"vldr${p}.32 $Sd, $addr",
1324 (VLDRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
1325 def : VFP2InstAlias<"vstr${p}.32 $Sd, $addr",
1326 (VSTRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
1327 def : VFP2InstAlias<"vldr${p}.64 $Dd, $addr",
1328 (VLDRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
1329 def : VFP2InstAlias<"vstr${p}.64 $Dd, $addr",
1330 (VSTRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
1332 // VMUL has a two-operand form (implied destination operand)
1333 def : VFP2InstAlias<"vmul${p}.f64 $Dn, $Dm",
1334 (VMULD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1335 def : VFP2InstAlias<"vmul${p}.f32 $Sn, $Sm",
1336 (VMULS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
1337 // VADD has a two-operand form (implied destination operand)
1338 def : VFP2InstAlias<"vadd${p}.f64 $Dn, $Dm",
1339 (VADDD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1340 def : 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)
1343 def : VFP2InstAlias<"vsub${p}.f64 $Dn, $Dm",
1344 (VSUBD DPR:$Dn, DPR:$Dn, DPR:$Dm, pred:$p)>;
1345 def : VFP2InstAlias<"vsub${p}.f32 $Sn, $Sm",
1346 (VSUBS SPR:$Sn, SPR:$Sn, SPR:$Sm, pred:$p)>;
1348 // VMOV can accept optional 32-bit or less data type suffix suffix.
1349 def : VFP2InstAlias<"vmov${p}.8 $Rt, $Sn",
1350 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1351 def : VFP2InstAlias<"vmov${p}.16 $Rt, $Sn",
1352 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1353 def : VFP2InstAlias<"vmov${p}.32 $Rt, $Sn",
1354 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
1355 def : VFP2InstAlias<"vmov${p}.8 $Sn, $Rt",
1356 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1357 def : VFP2InstAlias<"vmov${p}.16 $Sn, $Rt",
1358 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1359 def : VFP2InstAlias<"vmov${p}.32 $Sn, $Rt",
1360 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
1362 def : VFP2InstAlias<"vmov${p}.f64 $Rt, $Rt2, $Dn",
1363 (VMOVRRD GPR:$Rt, GPR:$Rt2, DPR:$Dn, pred:$p)>;
1364 def : VFP2InstAlias<"vmov${p}.f64 $Dn, $Rt, $Rt2",
1365 (VMOVDRR DPR:$Dn, GPR:$Rt, GPR:$Rt2, pred:$p)>;
1367 // VMOVS doesn't need the .f32 to disambiguate from the NEON encoding the way
1369 def : VFP2InstAlias<"vmov${p} $Sd, $Sm",
1370 (VMOVS SPR:$Sd, SPR:$Sm, pred:$p)>;