1 //===-- ARMInstrVFP.td - VFP support for ARM ---------------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the ARM VFP instruction set.
11 //===----------------------------------------------------------------------===//
13 def SDT_CMPFP0 : SDTypeProfile<0, 2, [SDTCisFP<0>, SDTCisVT<1, i32>]>;
14 def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
16 def SDT_VMOVRRD : SDTypeProfile<2, 1, [SDTCisVT<0, i32>, SDTCisSameAs<0, 1>,
19 def SDT_VMOVSR : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisVT<1, i32>]>;
21 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInGlue, SDNPOutGlue]>;
22 def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMFCmp, [SDNPOutGlue]>;
23 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutGlue]>;
24 def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
25 def arm_fmrrd : SDNode<"ARMISD::VMOVRRD", SDT_VMOVRRD>;
26 def arm_vmovsr : SDNode<"ARMISD::VMOVSR", SDT_VMOVSR>;
28 def SDT_VMOVhr : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, i32>] >;
29 def SDT_VMOVrh : SDTypeProfile<1, 1, [SDTCisVT<0, i32>, SDTCisFP<1>] >;
30 def arm_vmovhr : SDNode<"ARMISD::VMOVhr", SDT_VMOVhr>;
31 def arm_vmovrh : SDNode<"ARMISD::VMOVrh", SDT_VMOVrh>;
33 //===----------------------------------------------------------------------===//
34 // Operand Definitions.
37 // 8-bit floating-point immediate encodings.
38 def FPImmOperand : AsmOperandClass {
40 let ParserMethod = "parseFPImm";
43 def vfp_f16imm : Operand<f16>,
44 PatLeaf<(f16 fpimm), [{
45 return ARM_AM::getFP16Imm(N->getValueAPF()) != -1;
46 }], SDNodeXForm<fpimm, [{
47 APFloat InVal = N->getValueAPF();
48 uint32_t enc = ARM_AM::getFP16Imm(InVal);
49 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
51 let PrintMethod = "printFPImmOperand";
52 let ParserMatchClass = FPImmOperand;
55 def vfp_f32imm : Operand<f32>,
56 PatLeaf<(f32 fpimm), [{
57 return ARM_AM::getFP32Imm(N->getValueAPF()) != -1;
58 }], SDNodeXForm<fpimm, [{
59 APFloat InVal = N->getValueAPF();
60 uint32_t enc = ARM_AM::getFP32Imm(InVal);
61 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
63 let PrintMethod = "printFPImmOperand";
64 let ParserMatchClass = FPImmOperand;
67 def vfp_f64imm : Operand<f64>,
68 PatLeaf<(f64 fpimm), [{
69 return ARM_AM::getFP64Imm(N->getValueAPF()) != -1;
70 }], SDNodeXForm<fpimm, [{
71 APFloat InVal = N->getValueAPF();
72 uint32_t enc = ARM_AM::getFP64Imm(InVal);
73 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32);
75 let PrintMethod = "printFPImmOperand";
76 let ParserMatchClass = FPImmOperand;
79 def alignedload16 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
80 return cast<LoadSDNode>(N)->getAlignment() >= 2;
83 def alignedload32 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
84 return cast<LoadSDNode>(N)->getAlignment() >= 4;
87 def alignedstore16 : PatFrag<(ops node:$val, node:$ptr),
88 (store node:$val, node:$ptr), [{
89 return cast<StoreSDNode>(N)->getAlignment() >= 2;
92 def alignedstore32 : PatFrag<(ops node:$val, node:$ptr),
93 (store node:$val, node:$ptr), [{
94 return cast<StoreSDNode>(N)->getAlignment() >= 4;
97 // The VCVT to/from fixed-point instructions encode the 'fbits' operand
98 // (the number of fixed bits) differently than it appears in the assembly
99 // source. It's encoded as "Size - fbits" where Size is the size of the
100 // fixed-point representation (32 or 16) and fbits is the value appearing
101 // in the assembly source, an integer in [0,16] or (0,32], depending on size.
102 def fbits32_asm_operand : AsmOperandClass { let Name = "FBits32"; }
103 def fbits32 : Operand<i32> {
104 let PrintMethod = "printFBits32";
105 let ParserMatchClass = fbits32_asm_operand;
108 def fbits16_asm_operand : AsmOperandClass { let Name = "FBits16"; }
109 def fbits16 : Operand<i32> {
110 let PrintMethod = "printFBits16";
111 let ParserMatchClass = fbits16_asm_operand;
114 //===----------------------------------------------------------------------===//
115 // Load / store Instructions.
118 let canFoldAsLoad = 1, isReMaterializable = 1 in {
120 def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
121 IIC_fpLoad64, "vldr", "\t$Dd, $addr",
122 [(set DPR:$Dd, (f64 (alignedload32 addrmode5:$addr)))]>;
124 def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
125 IIC_fpLoad32, "vldr", "\t$Sd, $addr",
126 [(set SPR:$Sd, (alignedload32 addrmode5:$addr))]> {
127 // Some single precision VFP instructions may be executed on both NEON and VFP
129 let D = VFPNeonDomain;
132 def VLDRH : AHI5<0b1101, 0b01, (outs HPR:$Sd), (ins addrmode5fp16:$addr),
133 IIC_fpLoad16, "vldr", ".16\t$Sd, $addr",
134 [(set HPR:$Sd, (alignedload16 addrmode5fp16:$addr))]>,
135 Requires<[HasFullFP16]>;
137 } // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
139 def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
140 IIC_fpStore64, "vstr", "\t$Dd, $addr",
141 [(alignedstore32 (f64 DPR:$Dd), addrmode5:$addr)]>;
143 def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
144 IIC_fpStore32, "vstr", "\t$Sd, $addr",
145 [(alignedstore32 SPR:$Sd, addrmode5:$addr)]> {
146 // Some single precision VFP instructions may be executed on both NEON and VFP
148 let D = VFPNeonDomain;
151 def VSTRH : AHI5<0b1101, 0b00, (outs), (ins HPR:$Sd, addrmode5fp16:$addr),
152 IIC_fpStore16, "vstr", ".16\t$Sd, $addr",
153 [(alignedstore16 HPR:$Sd, addrmode5fp16:$addr)]>,
154 Requires<[HasFullFP16]>;
156 //===----------------------------------------------------------------------===//
157 // Load / store multiple Instructions.
160 multiclass vfp_ldst_mult<string asm, bit L_bit,
161 InstrItinClass itin, InstrItinClass itin_upd> {
164 AXDI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
166 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
167 let Inst{24-23} = 0b01; // Increment After
168 let Inst{21} = 0; // No writeback
169 let Inst{20} = L_bit;
172 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
174 IndexModeUpd, itin_upd,
175 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
176 let Inst{24-23} = 0b01; // Increment After
177 let Inst{21} = 1; // Writeback
178 let Inst{20} = L_bit;
181 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs,
183 IndexModeUpd, itin_upd,
184 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
185 let Inst{24-23} = 0b10; // Decrement Before
186 let Inst{21} = 1; // Writeback
187 let Inst{20} = L_bit;
192 AXSI4<(outs), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, variable_ops),
194 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> {
195 let Inst{24-23} = 0b01; // Increment After
196 let Inst{21} = 0; // No writeback
197 let Inst{20} = L_bit;
199 // Some single precision VFP instructions may be executed on both NEON and
201 let D = VFPNeonDomain;
204 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
206 IndexModeUpd, itin_upd,
207 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
208 let Inst{24-23} = 0b01; // Increment After
209 let Inst{21} = 1; // Writeback
210 let Inst{20} = L_bit;
212 // Some single precision VFP instructions may be executed on both NEON and
214 let D = VFPNeonDomain;
217 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs,
219 IndexModeUpd, itin_upd,
220 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
221 let Inst{24-23} = 0b10; // Decrement Before
222 let Inst{21} = 1; // Writeback
223 let Inst{20} = L_bit;
225 // Some single precision VFP instructions may be executed on both NEON and
227 let D = VFPNeonDomain;
231 let hasSideEffects = 0 in {
233 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
234 defm VLDM : vfp_ldst_mult<"vldm", 1, IIC_fpLoad_m, IIC_fpLoad_mu>;
236 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
237 defm VSTM : vfp_ldst_mult<"vstm", 0, IIC_fpStore_m, IIC_fpStore_mu>;
241 def : MnemonicAlias<"vldm", "vldmia">;
242 def : MnemonicAlias<"vstm", "vstmia">;
245 //===----------------------------------------------------------------------===//
246 // Lazy load / store multiple Instructions
249 def VLLDM : AXSI4<(outs), (ins GPRnopc:$Rn, pred:$p), IndexModeNone,
250 IIC_fpLoad_m, "vlldm${p}\t$Rn", "", []>,
251 Requires<[HasV8MMainline, Has8MSecExt]> {
252 let Inst{24-23} = 0b00;
262 def VLSTM : AXSI4<(outs), (ins GPRnopc:$Rn, pred:$p), IndexModeNone,
263 IIC_fpStore_m, "vlstm${p}\t$Rn", "", []>,
264 Requires<[HasV8MMainline, Has8MSecExt]> {
265 let Inst{24-23} = 0b00;
274 def : InstAlias<"vpush${p} $r", (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r), 0>,
276 def : InstAlias<"vpush${p} $r", (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r), 0>,
278 def : InstAlias<"vpop${p} $r", (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r), 0>,
280 def : InstAlias<"vpop${p} $r", (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r), 0>,
282 defm : VFPDTAnyInstAlias<"vpush${p}", "$r",
283 (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>;
284 defm : VFPDTAnyInstAlias<"vpush${p}", "$r",
285 (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>;
286 defm : VFPDTAnyInstAlias<"vpop${p}", "$r",
287 (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>;
288 defm : VFPDTAnyInstAlias<"vpop${p}", "$r",
289 (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>;
291 // FLDMX, FSTMX - Load and store multiple unknown precision registers for
293 // These instruction are deprecated so we don't want them to get selected.
294 // However, there is no UAL syntax for them, so we keep them around for
295 // (dis)assembly only.
296 multiclass vfp_ldstx_mult<string asm, bit L_bit> {
299 AXXI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
300 IndexModeNone, !strconcat(asm, "iax${p}\t$Rn, $regs"), "", []> {
301 let Inst{24-23} = 0b01; // Increment After
302 let Inst{21} = 0; // No writeback
303 let Inst{20} = L_bit;
306 AXXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
307 IndexModeUpd, !strconcat(asm, "iax${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
308 let Inst{24-23} = 0b01; // Increment After
309 let Inst{21} = 1; // Writeback
310 let Inst{20} = L_bit;
313 AXXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops),
314 IndexModeUpd, !strconcat(asm, "dbx${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
315 let Inst{24-23} = 0b10; // Decrement Before
316 let Inst{21} = 1; // Writeback
317 let Inst{20} = L_bit;
321 defm FLDM : vfp_ldstx_mult<"fldm", 1>;
322 defm FSTM : vfp_ldstx_mult<"fstm", 0>;
324 def : VFP2MnemonicAlias<"fldmeax", "fldmdbx">;
325 def : VFP2MnemonicAlias<"fldmfdx", "fldmiax">;
327 def : VFP2MnemonicAlias<"fstmeax", "fstmiax">;
328 def : VFP2MnemonicAlias<"fstmfdx", "fstmdbx">;
330 //===----------------------------------------------------------------------===//
331 // FP Binary Operations.
334 let TwoOperandAliasConstraint = "$Dn = $Dd" in
335 def VADDD : ADbI<0b11100, 0b11, 0, 0,
336 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
337 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
338 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>,
339 Sched<[WriteFPALU64]>;
341 let TwoOperandAliasConstraint = "$Sn = $Sd" in
342 def VADDS : ASbIn<0b11100, 0b11, 0, 0,
343 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
344 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
345 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>,
346 Sched<[WriteFPALU32]> {
347 // Some single precision VFP instructions may be executed on both NEON and
348 // VFP pipelines on A8.
349 let D = VFPNeonA8Domain;
352 let TwoOperandAliasConstraint = "$Sn = $Sd" in
353 def VADDH : AHbI<0b11100, 0b11, 0, 0,
354 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
355 IIC_fpALU16, "vadd", ".f16\t$Sd, $Sn, $Sm",
356 [(set HPR:$Sd, (fadd HPR:$Sn, HPR:$Sm))]>,
357 Sched<[WriteFPALU32]>;
359 let TwoOperandAliasConstraint = "$Dn = $Dd" in
360 def VSUBD : ADbI<0b11100, 0b11, 1, 0,
361 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
362 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
363 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>,
364 Sched<[WriteFPALU64]>;
366 let TwoOperandAliasConstraint = "$Sn = $Sd" in
367 def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
368 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
369 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
370 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>,
371 Sched<[WriteFPALU32]>{
372 // Some single precision VFP instructions may be executed on both NEON and
373 // VFP pipelines on A8.
374 let D = VFPNeonA8Domain;
377 let TwoOperandAliasConstraint = "$Sn = $Sd" in
378 def VSUBH : AHbI<0b11100, 0b11, 1, 0,
379 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
380 IIC_fpALU16, "vsub", ".f16\t$Sd, $Sn, $Sm",
381 [(set HPR:$Sd, (fsub HPR:$Sn, HPR:$Sm))]>,
382 Sched<[WriteFPALU32]>;
384 let TwoOperandAliasConstraint = "$Dn = $Dd" in
385 def VDIVD : ADbI<0b11101, 0b00, 0, 0,
386 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
387 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
388 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>,
389 Sched<[WriteFPDIV64]>;
391 let TwoOperandAliasConstraint = "$Sn = $Sd" in
392 def VDIVS : ASbI<0b11101, 0b00, 0, 0,
393 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
394 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
395 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>,
396 Sched<[WriteFPDIV32]>;
398 let TwoOperandAliasConstraint = "$Sn = $Sd" in
399 def VDIVH : AHbI<0b11101, 0b00, 0, 0,
400 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
401 IIC_fpDIV16, "vdiv", ".f16\t$Sd, $Sn, $Sm",
402 [(set HPR:$Sd, (fdiv HPR:$Sn, HPR:$Sm))]>,
403 Sched<[WriteFPDIV32]>;
405 let TwoOperandAliasConstraint = "$Dn = $Dd" in
406 def VMULD : ADbI<0b11100, 0b10, 0, 0,
407 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
408 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
409 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>,
410 Sched<[WriteFPMUL64, ReadFPMUL, ReadFPMUL]>;
412 let TwoOperandAliasConstraint = "$Sn = $Sd" in
413 def VMULS : ASbIn<0b11100, 0b10, 0, 0,
414 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
415 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
416 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>,
417 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]> {
418 // Some single precision VFP instructions may be executed on both NEON and
419 // VFP pipelines on A8.
420 let D = VFPNeonA8Domain;
423 let TwoOperandAliasConstraint = "$Sn = $Sd" in
424 def VMULH : AHbI<0b11100, 0b10, 0, 0,
425 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
426 IIC_fpMUL16, "vmul", ".f16\t$Sd, $Sn, $Sm",
427 [(set HPR:$Sd, (fmul HPR:$Sn, HPR:$Sm))]>,
428 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]>;
430 def VNMULD : ADbI<0b11100, 0b10, 1, 0,
431 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
432 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
433 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>,
434 Sched<[WriteFPMUL64, ReadFPMUL, ReadFPMUL]>;
436 def VNMULS : ASbI<0b11100, 0b10, 1, 0,
437 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
438 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
439 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>,
440 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]> {
441 // Some single precision VFP instructions may be executed on both NEON and
442 // VFP pipelines on A8.
443 let D = VFPNeonA8Domain;
446 def VNMULH : AHbI<0b11100, 0b10, 1, 0,
447 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
448 IIC_fpMUL16, "vnmul", ".f16\t$Sd, $Sn, $Sm",
449 [(set HPR:$Sd, (fneg (fmul HPR:$Sn, HPR:$Sm)))]>,
450 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]>;
452 multiclass vsel_inst<string op, bits<2> opc, int CC> {
453 let DecoderNamespace = "VFPV8", PostEncoderMethod = "",
454 Uses = [CPSR], AddedComplexity = 4 in {
455 def H : AHbInp<0b11100, opc, 0,
456 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
457 NoItinerary, !strconcat("vsel", op, ".f16\t$Sd, $Sn, $Sm"),
458 [(set HPR:$Sd, (ARMcmov HPR:$Sm, HPR:$Sn, CC))]>,
459 Requires<[HasFullFP16]>;
461 def S : ASbInp<0b11100, opc, 0,
462 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
463 NoItinerary, !strconcat("vsel", op, ".f32\t$Sd, $Sn, $Sm"),
464 [(set SPR:$Sd, (ARMcmov SPR:$Sm, SPR:$Sn, CC))]>,
465 Requires<[HasFPARMv8]>;
467 def D : ADbInp<0b11100, opc, 0,
468 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
469 NoItinerary, !strconcat("vsel", op, ".f64\t$Dd, $Dn, $Dm"),
470 [(set DPR:$Dd, (ARMcmov (f64 DPR:$Dm), (f64 DPR:$Dn), CC))]>,
471 Requires<[HasFPARMv8, HasDPVFP]>;
475 // The CC constants here match ARMCC::CondCodes.
476 defm VSELGT : vsel_inst<"gt", 0b11, 12>;
477 defm VSELGE : vsel_inst<"ge", 0b10, 10>;
478 defm VSELEQ : vsel_inst<"eq", 0b00, 0>;
479 defm VSELVS : vsel_inst<"vs", 0b01, 6>;
481 multiclass vmaxmin_inst<string op, bit opc, SDNode SD> {
482 let DecoderNamespace = "VFPV8", PostEncoderMethod = "" in {
483 def H : AHbInp<0b11101, 0b00, opc,
484 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm),
485 NoItinerary, !strconcat(op, ".f16\t$Sd, $Sn, $Sm"),
486 [(set HPR:$Sd, (SD HPR:$Sn, HPR:$Sm))]>,
487 Requires<[HasFullFP16]>;
489 def S : ASbInp<0b11101, 0b00, opc,
490 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
491 NoItinerary, !strconcat(op, ".f32\t$Sd, $Sn, $Sm"),
492 [(set SPR:$Sd, (SD SPR:$Sn, SPR:$Sm))]>,
493 Requires<[HasFPARMv8]>;
495 def D : ADbInp<0b11101, 0b00, opc,
496 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
497 NoItinerary, !strconcat(op, ".f64\t$Dd, $Dn, $Dm"),
498 [(set DPR:$Dd, (f64 (SD (f64 DPR:$Dn), (f64 DPR:$Dm))))]>,
499 Requires<[HasFPARMv8, HasDPVFP]>;
503 defm VMAXNM : vmaxmin_inst<"vmaxnm", 0, fmaxnum>;
504 defm VMINNM : vmaxmin_inst<"vminnm", 1, fminnum>;
506 // Match reassociated forms only if not sign dependent rounding.
507 def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
508 (VNMULD DPR:$a, DPR:$b)>,
509 Requires<[NoHonorSignDependentRounding,HasDPVFP]>;
510 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
511 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
513 // These are encoded as unary instructions.
514 let Defs = [FPSCR_NZCV] in {
515 def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
516 (outs), (ins DPR:$Dd, DPR:$Dm),
517 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
518 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm), (i32 1))]>;
520 def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
521 (outs), (ins SPR:$Sd, SPR:$Sm),
522 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
523 [(arm_cmpfp SPR:$Sd, SPR:$Sm, (i32 1))]> {
524 // Some single precision VFP instructions may be executed on both NEON and
525 // VFP pipelines on A8.
526 let D = VFPNeonA8Domain;
529 def VCMPEH : AHuI<0b11101, 0b11, 0b0100, 0b11, 0,
530 (outs), (ins HPR:$Sd, HPR:$Sm),
531 IIC_fpCMP16, "vcmpe", ".f16\t$Sd, $Sm",
532 [(arm_cmpfp HPR:$Sd, HPR:$Sm, (i32 1))]>;
534 def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
535 (outs), (ins DPR:$Dd, DPR:$Dm),
536 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
537 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm), (i32 0))]>;
539 def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
540 (outs), (ins SPR:$Sd, SPR:$Sm),
541 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
542 [(arm_cmpfp SPR:$Sd, SPR:$Sm, (i32 0))]> {
543 // Some single precision VFP instructions may be executed on both NEON and
544 // VFP pipelines on A8.
545 let D = VFPNeonA8Domain;
548 def VCMPH : AHuI<0b11101, 0b11, 0b0100, 0b01, 0,
549 (outs), (ins HPR:$Sd, HPR:$Sm),
550 IIC_fpCMP16, "vcmp", ".f16\t$Sd, $Sm",
551 [(arm_cmpfp HPR:$Sd, HPR:$Sm, (i32 0))]>;
552 } // Defs = [FPSCR_NZCV]
554 //===----------------------------------------------------------------------===//
555 // FP Unary Operations.
558 def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
559 (outs DPR:$Dd), (ins DPR:$Dm),
560 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
561 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
563 def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
564 (outs SPR:$Sd), (ins SPR:$Sm),
565 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
566 [(set SPR:$Sd, (fabs SPR:$Sm))]> {
567 // Some single precision VFP instructions may be executed on both NEON and
568 // VFP pipelines on A8.
569 let D = VFPNeonA8Domain;
572 def VABSH : AHuI<0b11101, 0b11, 0b0000, 0b11, 0,
573 (outs SPR:$Sd), (ins SPR:$Sm),
574 IIC_fpUNA16, "vabs", ".f16\t$Sd, $Sm",
577 let Defs = [FPSCR_NZCV] in {
578 def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
579 (outs), (ins DPR:$Dd),
580 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
581 [(arm_cmpfp0 (f64 DPR:$Dd), (i32 1))]> {
582 let Inst{3-0} = 0b0000;
586 def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
587 (outs), (ins SPR:$Sd),
588 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
589 [(arm_cmpfp0 SPR:$Sd, (i32 1))]> {
590 let Inst{3-0} = 0b0000;
593 // Some single precision VFP instructions may be executed on both NEON and
594 // VFP pipelines on A8.
595 let D = VFPNeonA8Domain;
598 def VCMPEZH : AHuI<0b11101, 0b11, 0b0101, 0b11, 0,
599 (outs), (ins HPR:$Sd),
600 IIC_fpCMP16, "vcmpe", ".f16\t$Sd, #0",
601 [(arm_cmpfp0 HPR:$Sd, (i32 1))]> {
602 let Inst{3-0} = 0b0000;
606 def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
607 (outs), (ins DPR:$Dd),
608 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
609 [(arm_cmpfp0 (f64 DPR:$Dd), (i32 0))]> {
610 let Inst{3-0} = 0b0000;
614 def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
615 (outs), (ins SPR:$Sd),
616 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
617 [(arm_cmpfp0 SPR:$Sd, (i32 0))]> {
618 let Inst{3-0} = 0b0000;
621 // Some single precision VFP instructions may be executed on both NEON and
622 // VFP pipelines on A8.
623 let D = VFPNeonA8Domain;
626 def VCMPZH : AHuI<0b11101, 0b11, 0b0101, 0b01, 0,
627 (outs), (ins HPR:$Sd),
628 IIC_fpCMP16, "vcmp", ".f16\t$Sd, #0",
629 [(arm_cmpfp0 HPR:$Sd, (i32 0))]> {
630 let Inst{3-0} = 0b0000;
633 } // Defs = [FPSCR_NZCV]
635 def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
636 (outs DPR:$Dd), (ins SPR:$Sm),
637 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
638 [(set DPR:$Dd, (fpextend SPR:$Sm))]>,
639 Sched<[WriteFPCVT]> {
640 // Instruction operands.
644 // Encode instruction operands.
645 let Inst{3-0} = Sm{4-1};
647 let Inst{15-12} = Dd{3-0};
648 let Inst{22} = Dd{4};
650 let Predicates = [HasVFP2, HasDPVFP];
653 // Special case encoding: bits 11-8 is 0b1011.
654 def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
655 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
656 [(set SPR:$Sd, (fpround DPR:$Dm))]>,
657 Sched<[WriteFPCVT]> {
658 // Instruction operands.
662 // Encode instruction operands.
663 let Inst{3-0} = Dm{3-0};
665 let Inst{15-12} = Sd{4-1};
666 let Inst{22} = Sd{0};
668 let Inst{27-23} = 0b11101;
669 let Inst{21-16} = 0b110111;
670 let Inst{11-8} = 0b1011;
671 let Inst{7-6} = 0b11;
674 let Predicates = [HasVFP2, HasDPVFP];
677 // Between half, single and double-precision.
678 def VCVTBHS: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
679 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm",
680 [/* Intentionally left blank, see patterns below */]>,
684 def : FullFP16Pat<(f32 (fpextend HPR:$Sm)),
685 (VCVTBHS (COPY_TO_REGCLASS HPR:$Sm, SPR))>;
686 def : FP16Pat<(f16_to_fp GPR:$a),
687 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
689 def VCVTBSH: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm),
690 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm",
691 [/* Intentionally left blank, see patterns below */]>,
695 def : FullFP16Pat<(f16 (fpround SPR:$Sm)),
696 (COPY_TO_REGCLASS (VCVTBSH SPR:$Sm), HPR)>;
697 def : FP16Pat<(fp_to_f16 SPR:$a),
698 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
700 def VCVTTHS: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
701 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm",
702 [/* For disassembly only; pattern left blank */]>,
706 def VCVTTSH: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm),
707 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm",
708 [/* For disassembly only; pattern left blank */]>,
712 def VCVTBHD : ADuI<0b11101, 0b11, 0b0010, 0b01, 0,
713 (outs DPR:$Dd), (ins SPR:$Sm),
714 NoItinerary, "vcvtb", ".f64.f16\t$Dd, $Sm",
715 [/* Intentionally left blank, see patterns below */]>,
716 Requires<[HasFPARMv8, HasDPVFP]>,
717 Sched<[WriteFPCVT]> {
718 // Instruction operands.
721 // Encode instruction operands.
722 let Inst{3-0} = Sm{4-1};
726 def : FullFP16Pat<(f64 (fpextend HPR:$Sm)),
727 (VCVTBHD (COPY_TO_REGCLASS HPR:$Sm, SPR))>,
728 Requires<[HasFPARMv8, HasDPVFP]>;
729 def : FP16Pat<(f64 (f16_to_fp GPR:$a)),
730 (VCVTBHD (COPY_TO_REGCLASS GPR:$a, SPR))>,
731 Requires<[HasFPARMv8, HasDPVFP]>;
733 def VCVTBDH : ADuI<0b11101, 0b11, 0b0011, 0b01, 0,
734 (outs SPR:$Sd), (ins DPR:$Dm),
735 NoItinerary, "vcvtb", ".f16.f64\t$Sd, $Dm",
736 [/* Intentionally left blank, see patterns below */]>,
737 Requires<[HasFPARMv8, HasDPVFP]> {
738 // Instruction operands.
742 // Encode instruction operands.
743 let Inst{3-0} = Dm{3-0};
745 let Inst{15-12} = Sd{4-1};
746 let Inst{22} = Sd{0};
749 def : FullFP16Pat<(f16 (fpround DPR:$Dm)),
750 (COPY_TO_REGCLASS (VCVTBDH DPR:$Dm), HPR)>,
751 Requires<[HasFPARMv8, HasDPVFP]>;
752 def : FP16Pat<(fp_to_f16 (f64 DPR:$a)),
753 (i32 (COPY_TO_REGCLASS (VCVTBDH DPR:$a), GPR))>,
754 Requires<[HasFPARMv8, HasDPVFP]>;
756 def VCVTTHD : ADuI<0b11101, 0b11, 0b0010, 0b11, 0,
757 (outs DPR:$Dd), (ins SPR:$Sm),
758 NoItinerary, "vcvtt", ".f64.f16\t$Dd, $Sm",
759 []>, Requires<[HasFPARMv8, HasDPVFP]> {
760 // Instruction operands.
763 // Encode instruction operands.
764 let Inst{3-0} = Sm{4-1};
768 def VCVTTDH : ADuI<0b11101, 0b11, 0b0011, 0b11, 0,
769 (outs SPR:$Sd), (ins DPR:$Dm),
770 NoItinerary, "vcvtt", ".f16.f64\t$Sd, $Dm",
771 []>, Requires<[HasFPARMv8, HasDPVFP]> {
772 // Instruction operands.
776 // Encode instruction operands.
777 let Inst{15-12} = Sd{4-1};
778 let Inst{22} = Sd{0};
779 let Inst{3-0} = Dm{3-0};
783 multiclass vcvt_inst<string opc, bits<2> rm,
784 SDPatternOperator node = null_frag> {
785 let PostEncoderMethod = "", DecoderNamespace = "VFPV8" in {
786 def SH : AHuInp<0b11101, 0b11, 0b1100, 0b11, 0,
787 (outs SPR:$Sd), (ins HPR:$Sm),
788 NoItinerary, !strconcat("vcvt", opc, ".s32.f16\t$Sd, $Sm"),
790 Requires<[HasFullFP16]> {
791 let Inst{17-16} = rm;
794 def UH : AHuInp<0b11101, 0b11, 0b1100, 0b01, 0,
795 (outs SPR:$Sd), (ins HPR:$Sm),
796 NoItinerary, !strconcat("vcvt", opc, ".u32.f16\t$Sd, $Sm"),
798 Requires<[HasFullFP16]> {
799 let Inst{17-16} = rm;
802 def SS : ASuInp<0b11101, 0b11, 0b1100, 0b11, 0,
803 (outs SPR:$Sd), (ins SPR:$Sm),
804 NoItinerary, !strconcat("vcvt", opc, ".s32.f32\t$Sd, $Sm"),
806 Requires<[HasFPARMv8]> {
807 let Inst{17-16} = rm;
810 def US : ASuInp<0b11101, 0b11, 0b1100, 0b01, 0,
811 (outs SPR:$Sd), (ins SPR:$Sm),
812 NoItinerary, !strconcat("vcvt", opc, ".u32.f32\t$Sd, $Sm"),
814 Requires<[HasFPARMv8]> {
815 let Inst{17-16} = rm;
818 def SD : ASuInp<0b11101, 0b11, 0b1100, 0b11, 0,
819 (outs SPR:$Sd), (ins DPR:$Dm),
820 NoItinerary, !strconcat("vcvt", opc, ".s32.f64\t$Sd, $Dm"),
822 Requires<[HasFPARMv8, HasDPVFP]> {
825 let Inst{17-16} = rm;
827 // Encode instruction operands
828 let Inst{3-0} = Dm{3-0};
833 def UD : ASuInp<0b11101, 0b11, 0b1100, 0b01, 0,
834 (outs SPR:$Sd), (ins DPR:$Dm),
835 NoItinerary, !strconcat("vcvt", opc, ".u32.f64\t$Sd, $Dm"),
837 Requires<[HasFPARMv8, HasDPVFP]> {
840 let Inst{17-16} = rm;
842 // Encode instruction operands
843 let Inst{3-0} = Dm{3-0};
849 let Predicates = [HasFPARMv8] in {
850 let Predicates = [HasFullFP16] in {
851 def : Pat<(i32 (fp_to_sint (node HPR:$a))),
853 (!cast<Instruction>(NAME#"SH") HPR:$a),
856 def : Pat<(i32 (fp_to_uint (node HPR:$a))),
858 (!cast<Instruction>(NAME#"UH") HPR:$a),
861 def : Pat<(i32 (fp_to_sint (node SPR:$a))),
863 (!cast<Instruction>(NAME#"SS") SPR:$a),
865 def : Pat<(i32 (fp_to_uint (node SPR:$a))),
867 (!cast<Instruction>(NAME#"US") SPR:$a),
870 let Predicates = [HasFPARMv8, HasDPVFP] in {
871 def : Pat<(i32 (fp_to_sint (node (f64 DPR:$a)))),
873 (!cast<Instruction>(NAME#"SD") DPR:$a),
875 def : Pat<(i32 (fp_to_uint (node (f64 DPR:$a)))),
877 (!cast<Instruction>(NAME#"UD") DPR:$a),
882 defm VCVTA : vcvt_inst<"a", 0b00, fround>;
883 defm VCVTN : vcvt_inst<"n", 0b01>;
884 defm VCVTP : vcvt_inst<"p", 0b10, fceil>;
885 defm VCVTM : vcvt_inst<"m", 0b11, ffloor>;
887 def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
888 (outs DPR:$Dd), (ins DPR:$Dm),
889 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
890 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
892 def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
893 (outs SPR:$Sd), (ins SPR:$Sm),
894 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
895 [(set SPR:$Sd, (fneg SPR:$Sm))]> {
896 // Some single precision VFP instructions may be executed on both NEON and
897 // VFP pipelines on A8.
898 let D = VFPNeonA8Domain;
901 def VNEGH : AHuI<0b11101, 0b11, 0b0001, 0b01, 0,
902 (outs HPR:$Sd), (ins HPR:$Sm),
903 IIC_fpUNA16, "vneg", ".f16\t$Sd, $Sm",
904 [(set HPR:$Sd, (fneg HPR:$Sm))]>;
906 multiclass vrint_inst_zrx<string opc, bit op, bit op2, SDPatternOperator node> {
907 def H : AHuI<0b11101, 0b11, 0b0110, 0b11, 0,
908 (outs SPR:$Sd), (ins SPR:$Sm),
909 NoItinerary, !strconcat("vrint", opc), ".f16\t$Sd, $Sm",
911 Requires<[HasFullFP16]> {
916 def S : ASuI<0b11101, 0b11, 0b0110, 0b11, 0,
917 (outs SPR:$Sd), (ins SPR:$Sm),
918 NoItinerary, !strconcat("vrint", opc), ".f32\t$Sd, $Sm",
919 [(set (f32 SPR:$Sd), (node (f32 SPR:$Sm)))]>,
920 Requires<[HasFPARMv8]> {
924 def D : ADuI<0b11101, 0b11, 0b0110, 0b11, 0,
925 (outs DPR:$Dd), (ins DPR:$Dm),
926 NoItinerary, !strconcat("vrint", opc), ".f64\t$Dd, $Dm",
927 [(set (f64 DPR:$Dd), (node (f64 DPR:$Dm)))]>,
928 Requires<[HasFPARMv8, HasDPVFP]> {
933 def : InstAlias<!strconcat("vrint", opc, "$p.f16.f16\t$Sd, $Sm"),
934 (!cast<Instruction>(NAME#"H") SPR:$Sd, SPR:$Sm, pred:$p), 0>,
935 Requires<[HasFullFP16]>;
936 def : InstAlias<!strconcat("vrint", opc, "$p.f32.f32\t$Sd, $Sm"),
937 (!cast<Instruction>(NAME#"S") SPR:$Sd, SPR:$Sm, pred:$p), 0>,
938 Requires<[HasFPARMv8]>;
939 def : InstAlias<!strconcat("vrint", opc, "$p.f64.f64\t$Dd, $Dm"),
940 (!cast<Instruction>(NAME#"D") DPR:$Dd, DPR:$Dm, pred:$p), 0>,
941 Requires<[HasFPARMv8,HasDPVFP]>;
944 defm VRINTZ : vrint_inst_zrx<"z", 0, 1, ftrunc>;
945 defm VRINTR : vrint_inst_zrx<"r", 0, 0, fnearbyint>;
946 defm VRINTX : vrint_inst_zrx<"x", 1, 0, frint>;
948 multiclass vrint_inst_anpm<string opc, bits<2> rm,
949 SDPatternOperator node = null_frag> {
950 let PostEncoderMethod = "", DecoderNamespace = "VFPV8" in {
951 def H : AHuInp<0b11101, 0b11, 0b1000, 0b01, 0,
952 (outs SPR:$Sd), (ins SPR:$Sm),
953 NoItinerary, !strconcat("vrint", opc, ".f16\t$Sd, $Sm"),
955 Requires<[HasFullFP16]> {
956 let Inst{17-16} = rm;
958 def S : ASuInp<0b11101, 0b11, 0b1000, 0b01, 0,
959 (outs SPR:$Sd), (ins SPR:$Sm),
960 NoItinerary, !strconcat("vrint", opc, ".f32\t$Sd, $Sm"),
961 [(set (f32 SPR:$Sd), (node (f32 SPR:$Sm)))]>,
962 Requires<[HasFPARMv8]> {
963 let Inst{17-16} = rm;
965 def D : ADuInp<0b11101, 0b11, 0b1000, 0b01, 0,
966 (outs DPR:$Dd), (ins DPR:$Dm),
967 NoItinerary, !strconcat("vrint", opc, ".f64\t$Dd, $Dm"),
968 [(set (f64 DPR:$Dd), (node (f64 DPR:$Dm)))]>,
969 Requires<[HasFPARMv8, HasDPVFP]> {
970 let Inst{17-16} = rm;
974 def : InstAlias<!strconcat("vrint", opc, ".f32.f32\t$Sd, $Sm"),
975 (!cast<Instruction>(NAME#"S") SPR:$Sd, SPR:$Sm), 0>,
976 Requires<[HasFPARMv8]>;
977 def : InstAlias<!strconcat("vrint", opc, ".f64.f64\t$Dd, $Dm"),
978 (!cast<Instruction>(NAME#"D") DPR:$Dd, DPR:$Dm), 0>,
979 Requires<[HasFPARMv8,HasDPVFP]>;
982 defm VRINTA : vrint_inst_anpm<"a", 0b00, fround>;
983 defm VRINTN : vrint_inst_anpm<"n", 0b01, int_arm_neon_vrintn>;
984 defm VRINTP : vrint_inst_anpm<"p", 0b10, fceil>;
985 defm VRINTM : vrint_inst_anpm<"m", 0b11, ffloor>;
987 def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
988 (outs DPR:$Dd), (ins DPR:$Dm),
989 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
990 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>,
991 Sched<[WriteFPSQRT64]>;
993 def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
994 (outs SPR:$Sd), (ins SPR:$Sm),
995 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
996 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>,
997 Sched<[WriteFPSQRT32]>;
999 def VSQRTH : AHuI<0b11101, 0b11, 0b0001, 0b11, 0,
1000 (outs SPR:$Sd), (ins SPR:$Sm),
1001 IIC_fpSQRT16, "vsqrt", ".f16\t$Sd, $Sm",
1004 let hasSideEffects = 0 in {
1005 let isMoveReg = 1 in {
1006 def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
1007 (outs DPR:$Dd), (ins DPR:$Dm),
1008 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
1010 def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
1011 (outs SPR:$Sd), (ins SPR:$Sm),
1012 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
1015 let PostEncoderMethod = "", DecoderNamespace = "VFPV8" in {
1016 def VMOVH : ASuInp<0b11101, 0b11, 0b0000, 0b01, 0,
1017 (outs SPR:$Sd), (ins SPR:$Sm),
1018 IIC_fpUNA16, "vmovx.f16\t$Sd, $Sm", []>,
1019 Requires<[HasFullFP16]>;
1021 def VINSH : ASuInp<0b11101, 0b11, 0b0000, 0b11, 0,
1022 (outs SPR:$Sd), (ins SPR:$Sm),
1023 IIC_fpUNA16, "vins.f16\t$Sd, $Sm", []>,
1024 Requires<[HasFullFP16]>;
1025 } // PostEncoderMethod
1028 //===----------------------------------------------------------------------===//
1029 // FP <-> GPR Copies. Int <-> FP Conversions.
1032 let isMoveReg = 1 in {
1033 def VMOVRS : AVConv2I<0b11100001, 0b1010,
1034 (outs GPR:$Rt), (ins SPR:$Sn),
1035 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
1036 [(set GPR:$Rt, (bitconvert SPR:$Sn))]>,
1037 Sched<[WriteFPMOV]> {
1038 // Instruction operands.
1042 // Encode instruction operands.
1043 let Inst{19-16} = Sn{4-1};
1044 let Inst{7} = Sn{0};
1045 let Inst{15-12} = Rt;
1047 let Inst{6-5} = 0b00;
1048 let Inst{3-0} = 0b0000;
1050 // Some single precision VFP instructions may be executed on both NEON and VFP
1052 let D = VFPNeonDomain;
1055 // Bitcast i32 -> f32. NEON prefers to use VMOVDRR.
1056 def VMOVSR : AVConv4I<0b11100000, 0b1010,
1057 (outs SPR:$Sn), (ins GPR:$Rt),
1058 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
1059 [(set SPR:$Sn, (bitconvert GPR:$Rt))]>,
1060 Requires<[HasVFP2, UseVMOVSR]>,
1061 Sched<[WriteFPMOV]> {
1062 // Instruction operands.
1066 // Encode instruction operands.
1067 let Inst{19-16} = Sn{4-1};
1068 let Inst{7} = Sn{0};
1069 let Inst{15-12} = Rt;
1071 let Inst{6-5} = 0b00;
1072 let Inst{3-0} = 0b0000;
1074 // Some single precision VFP instructions may be executed on both NEON and VFP
1076 let D = VFPNeonDomain;
1079 def : Pat<(arm_vmovsr GPR:$Rt), (VMOVSR GPR:$Rt)>, Requires<[HasVFP2, UseVMOVSR]>;
1081 let hasSideEffects = 0 in {
1082 def VMOVRRD : AVConv3I<0b11000101, 0b1011,
1083 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
1084 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
1085 [(set GPR:$Rt, GPR:$Rt2, (arm_fmrrd DPR:$Dm))]>,
1086 Sched<[WriteFPMOV]> {
1087 // Instruction operands.
1092 // Encode instruction operands.
1093 let Inst{3-0} = Dm{3-0};
1094 let Inst{5} = Dm{4};
1095 let Inst{15-12} = Rt;
1096 let Inst{19-16} = Rt2;
1098 let Inst{7-6} = 0b00;
1100 // Some single precision VFP instructions may be executed on both NEON and VFP
1102 let D = VFPNeonDomain;
1104 // This instruction is equivalent to
1105 // $Rt = EXTRACT_SUBREG $Dm, ssub_0
1106 // $Rt2 = EXTRACT_SUBREG $Dm, ssub_1
1107 let isExtractSubreg = 1;
1110 def VMOVRRS : AVConv3I<0b11000101, 0b1010,
1111 (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2),
1112 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2",
1113 [/* For disassembly only; pattern left blank */]>,
1114 Sched<[WriteFPMOV]> {
1119 // Encode instruction operands.
1120 let Inst{3-0} = src1{4-1};
1121 let Inst{5} = src1{0};
1122 let Inst{15-12} = Rt;
1123 let Inst{19-16} = Rt2;
1125 let Inst{7-6} = 0b00;
1127 // Some single precision VFP instructions may be executed on both NEON and VFP
1129 let D = VFPNeonDomain;
1130 let DecoderMethod = "DecodeVMOVRRS";
1134 // FMDHR: GPR -> SPR
1135 // FMDLR: GPR -> SPR
1137 def VMOVDRR : AVConv5I<0b11000100, 0b1011,
1138 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
1139 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
1140 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]>,
1141 Sched<[WriteFPMOV]> {
1142 // Instruction operands.
1147 // Encode instruction operands.
1148 let Inst{3-0} = Dm{3-0};
1149 let Inst{5} = Dm{4};
1150 let Inst{15-12} = Rt;
1151 let Inst{19-16} = Rt2;
1153 let Inst{7-6} = 0b00;
1155 // Some single precision VFP instructions may be executed on both NEON and VFP
1157 let D = VFPNeonDomain;
1159 // This instruction is equivalent to
1160 // $Dm = REG_SEQUENCE $Rt, ssub_0, $Rt2, ssub_1
1161 let isRegSequence = 1;
1164 // Hoist an fabs or a fneg of a value coming from integer registers
1165 // and do the fabs/fneg on the integer value. This is never a lose
1166 // and could enable the conversion to float to be removed completely.
1167 def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)),
1168 (VMOVDRR GPR:$Rl, (BFC GPR:$Rh, (i32 0x7FFFFFFF)))>,
1169 Requires<[IsARM, HasV6T2]>;
1170 def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)),
1171 (VMOVDRR GPR:$Rl, (t2BFC GPR:$Rh, (i32 0x7FFFFFFF)))>,
1172 Requires<[IsThumb2, HasV6T2]>;
1173 def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)),
1174 (VMOVDRR GPR:$Rl, (EORri GPR:$Rh, (i32 0x80000000)))>,
1176 def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)),
1177 (VMOVDRR GPR:$Rl, (t2EORri GPR:$Rh, (i32 0x80000000)))>,
1178 Requires<[IsThumb2]>;
1180 let hasSideEffects = 0 in
1181 def VMOVSRR : AVConv5I<0b11000100, 0b1010,
1182 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
1183 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
1184 [/* For disassembly only; pattern left blank */]>,
1185 Sched<[WriteFPMOV]> {
1186 // Instruction operands.
1191 // Encode instruction operands.
1192 let Inst{3-0} = dst1{4-1};
1193 let Inst{5} = dst1{0};
1194 let Inst{15-12} = src1;
1195 let Inst{19-16} = src2;
1197 let Inst{7-6} = 0b00;
1199 // Some single precision VFP instructions may be executed on both NEON and VFP
1201 let D = VFPNeonDomain;
1203 let DecoderMethod = "DecodeVMOVSRR";
1206 // Move H->R, clearing top 16 bits
1207 def VMOVRH : AVConv2I<0b11100001, 0b1001,
1208 (outs GPR:$Rt), (ins HPR:$Sn),
1209 IIC_fpMOVSI, "vmov", ".f16\t$Rt, $Sn",
1210 [(set GPR:$Rt, (arm_vmovrh HPR:$Sn))]>,
1211 Requires<[HasFullFP16]>,
1212 Sched<[WriteFPMOV]> {
1213 // Instruction operands.
1217 // Encode instruction operands.
1218 let Inst{19-16} = Sn{4-1};
1219 let Inst{7} = Sn{0};
1220 let Inst{15-12} = Rt;
1222 let Inst{6-5} = 0b00;
1223 let Inst{3-0} = 0b0000;
1226 // Move R->H, clearing top 16 bits
1227 def VMOVHR : AVConv4I<0b11100000, 0b1001,
1228 (outs HPR:$Sn), (ins GPR:$Rt),
1229 IIC_fpMOVIS, "vmov", ".f16\t$Sn, $Rt",
1230 [(set HPR:$Sn, (arm_vmovhr GPR:$Rt))]>,
1231 Requires<[HasFullFP16]>,
1232 Sched<[WriteFPMOV]> {
1233 // Instruction operands.
1237 // Encode instruction operands.
1238 let Inst{19-16} = Sn{4-1};
1239 let Inst{7} = Sn{0};
1240 let Inst{15-12} = Rt;
1242 let Inst{6-5} = 0b00;
1243 let Inst{3-0} = 0b0000;
1246 // FMRDH: SPR -> GPR
1247 // FMRDL: SPR -> GPR
1248 // FMRRS: SPR -> GPR
1249 // FMRX: SPR system reg -> GPR
1250 // FMSRR: GPR -> SPR
1251 // FMXR: GPR -> VFP system reg
1256 class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
1257 bits<4> opcod4, dag oops, dag iops,
1258 InstrItinClass itin, string opc, string asm,
1260 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1262 // Instruction operands.
1266 // Encode instruction operands.
1267 let Inst{3-0} = Sm{4-1};
1268 let Inst{5} = Sm{0};
1269 let Inst{15-12} = Dd{3-0};
1270 let Inst{22} = Dd{4};
1272 let Predicates = [HasVFP2, HasDPVFP];
1275 class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
1276 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
1277 string opc, string asm, list<dag> pattern>
1278 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1280 // Instruction operands.
1284 // Encode instruction operands.
1285 let Inst{3-0} = Sm{4-1};
1286 let Inst{5} = Sm{0};
1287 let Inst{15-12} = Sd{4-1};
1288 let Inst{22} = Sd{0};
1291 class AVConv1IHs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
1292 bits<4> opcod4, dag oops, dag iops,
1293 InstrItinClass itin, string opc, string asm,
1295 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1297 // Instruction operands.
1301 // Encode instruction operands.
1302 let Inst{3-0} = Sm{4-1};
1303 let Inst{5} = Sm{0};
1304 let Inst{15-12} = Sd{4-1};
1305 let Inst{22} = Sd{0};
1307 let Predicates = [HasFullFP16];
1310 def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
1311 (outs DPR:$Dd), (ins SPR:$Sm),
1312 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
1314 Sched<[WriteFPCVT]> {
1315 let Inst{7} = 1; // s32
1318 let Predicates=[HasVFP2, HasDPVFP] in {
1319 def : VFPPat<(f64 (sint_to_fp GPR:$a)),
1320 (VSITOD (COPY_TO_REGCLASS GPR:$a, SPR))>;
1322 def : VFPPat<(f64 (sint_to_fp (i32 (alignedload32 addrmode5:$a)))),
1323 (VSITOD (VLDRS addrmode5:$a))>;
1326 def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
1327 (outs SPR:$Sd),(ins SPR:$Sm),
1328 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
1330 Sched<[WriteFPCVT]> {
1331 let Inst{7} = 1; // s32
1333 // Some single precision VFP instructions may be executed on both NEON and
1334 // VFP pipelines on A8.
1335 let D = VFPNeonA8Domain;
1338 def : VFPNoNEONPat<(f32 (sint_to_fp GPR:$a)),
1339 (VSITOS (COPY_TO_REGCLASS GPR:$a, SPR))>;
1341 def : VFPNoNEONPat<(f32 (sint_to_fp (i32 (alignedload32 addrmode5:$a)))),
1342 (VSITOS (VLDRS addrmode5:$a))>;
1344 def VSITOH : AVConv1IHs_Encode<0b11101, 0b11, 0b1000, 0b1001,
1345 (outs HPR:$Sd), (ins SPR:$Sm),
1346 IIC_fpCVTIH, "vcvt", ".f16.s32\t$Sd, $Sm",
1348 Sched<[WriteFPCVT]> {
1349 let Inst{7} = 1; // s32
1352 def : VFPNoNEONPat<(f16 (sint_to_fp GPR:$a)),
1353 (VSITOH (COPY_TO_REGCLASS GPR:$a, SPR))>;
1355 def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
1356 (outs DPR:$Dd), (ins SPR:$Sm),
1357 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
1359 Sched<[WriteFPCVT]> {
1360 let Inst{7} = 0; // u32
1363 let Predicates=[HasVFP2, HasDPVFP] in {
1364 def : VFPPat<(f64 (uint_to_fp GPR:$a)),
1365 (VUITOD (COPY_TO_REGCLASS GPR:$a, SPR))>;
1367 def : VFPPat<(f64 (uint_to_fp (i32 (alignedload32 addrmode5:$a)))),
1368 (VUITOD (VLDRS addrmode5:$a))>;
1371 def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
1372 (outs SPR:$Sd), (ins SPR:$Sm),
1373 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
1375 Sched<[WriteFPCVT]> {
1376 let Inst{7} = 0; // u32
1378 // Some single precision VFP instructions may be executed on both NEON and
1379 // VFP pipelines on A8.
1380 let D = VFPNeonA8Domain;
1383 def : VFPNoNEONPat<(f32 (uint_to_fp GPR:$a)),
1384 (VUITOS (COPY_TO_REGCLASS GPR:$a, SPR))>;
1386 def : VFPNoNEONPat<(f32 (uint_to_fp (i32 (alignedload32 addrmode5:$a)))),
1387 (VUITOS (VLDRS addrmode5:$a))>;
1389 def VUITOH : AVConv1IHs_Encode<0b11101, 0b11, 0b1000, 0b1001,
1390 (outs HPR:$Sd), (ins SPR:$Sm),
1391 IIC_fpCVTIH, "vcvt", ".f16.u32\t$Sd, $Sm",
1393 Sched<[WriteFPCVT]> {
1394 let Inst{7} = 0; // u32
1397 def : VFPNoNEONPat<(f16 (uint_to_fp GPR:$a)),
1398 (VUITOH (COPY_TO_REGCLASS GPR:$a, SPR))>;
1402 class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
1403 bits<4> opcod4, dag oops, dag iops,
1404 InstrItinClass itin, string opc, string asm,
1406 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1408 // Instruction operands.
1412 // Encode instruction operands.
1413 let Inst{3-0} = Dm{3-0};
1414 let Inst{5} = Dm{4};
1415 let Inst{15-12} = Sd{4-1};
1416 let Inst{22} = Sd{0};
1418 let Predicates = [HasVFP2, HasDPVFP];
1421 class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
1422 bits<4> opcod4, dag oops, dag iops,
1423 InstrItinClass itin, string opc, string asm,
1425 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1427 // Instruction operands.
1431 // Encode instruction operands.
1432 let Inst{3-0} = Sm{4-1};
1433 let Inst{5} = Sm{0};
1434 let Inst{15-12} = Sd{4-1};
1435 let Inst{22} = Sd{0};
1438 class AVConv1IsH_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
1439 bits<4> opcod4, dag oops, dag iops,
1440 InstrItinClass itin, string opc, string asm,
1442 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1444 // Instruction operands.
1448 // Encode instruction operands.
1449 let Inst{3-0} = Sm{4-1};
1450 let Inst{5} = Sm{0};
1451 let Inst{15-12} = Sd{4-1};
1452 let Inst{22} = Sd{0};
1454 let Predicates = [HasFullFP16];
1457 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
1458 def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
1459 (outs SPR:$Sd), (ins DPR:$Dm),
1460 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
1462 Sched<[WriteFPCVT]> {
1463 let Inst{7} = 1; // Z bit
1466 let Predicates=[HasVFP2, HasDPVFP] in {
1467 def : VFPPat<(i32 (fp_to_sint (f64 DPR:$a))),
1468 (COPY_TO_REGCLASS (VTOSIZD DPR:$a), GPR)>;
1470 def : VFPPat<(alignedstore32 (i32 (fp_to_sint (f64 DPR:$a))), addrmode5:$ptr),
1471 (VSTRS (VTOSIZD DPR:$a), addrmode5:$ptr)>;
1474 def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
1475 (outs SPR:$Sd), (ins SPR:$Sm),
1476 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
1478 Sched<[WriteFPCVT]> {
1479 let Inst{7} = 1; // Z bit
1481 // Some single precision VFP instructions may be executed on both NEON and
1482 // VFP pipelines on A8.
1483 let D = VFPNeonA8Domain;
1486 def : VFPNoNEONPat<(i32 (fp_to_sint SPR:$a)),
1487 (COPY_TO_REGCLASS (VTOSIZS SPR:$a), GPR)>;
1489 def : VFPNoNEONPat<(alignedstore32 (i32 (fp_to_sint (f32 SPR:$a))),
1491 (VSTRS (VTOSIZS SPR:$a), addrmode5:$ptr)>;
1493 def VTOSIZH : AVConv1IsH_Encode<0b11101, 0b11, 0b1101, 0b1001,
1494 (outs SPR:$Sd), (ins HPR:$Sm),
1495 IIC_fpCVTHI, "vcvt", ".s32.f16\t$Sd, $Sm",
1497 Sched<[WriteFPCVT]> {
1498 let Inst{7} = 1; // Z bit
1501 def : VFPNoNEONPat<(i32 (fp_to_sint HPR:$a)),
1502 (COPY_TO_REGCLASS (VTOSIZH HPR:$a), GPR)>;
1504 def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
1505 (outs SPR:$Sd), (ins DPR:$Dm),
1506 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
1508 Sched<[WriteFPCVT]> {
1509 let Inst{7} = 1; // Z bit
1512 let Predicates=[HasVFP2, HasDPVFP] in {
1513 def : VFPPat<(i32 (fp_to_uint (f64 DPR:$a))),
1514 (COPY_TO_REGCLASS (VTOUIZD DPR:$a), GPR)>;
1516 def : VFPPat<(alignedstore32 (i32 (fp_to_uint (f64 DPR:$a))), addrmode5:$ptr),
1517 (VSTRS (VTOUIZD DPR:$a), addrmode5:$ptr)>;
1520 def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
1521 (outs SPR:$Sd), (ins SPR:$Sm),
1522 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
1524 Sched<[WriteFPCVT]> {
1525 let Inst{7} = 1; // Z bit
1527 // Some single precision VFP instructions may be executed on both NEON and
1528 // VFP pipelines on A8.
1529 let D = VFPNeonA8Domain;
1532 def : VFPNoNEONPat<(i32 (fp_to_uint SPR:$a)),
1533 (COPY_TO_REGCLASS (VTOUIZS SPR:$a), GPR)>;
1535 def : VFPNoNEONPat<(alignedstore32 (i32 (fp_to_uint (f32 SPR:$a))),
1537 (VSTRS (VTOUIZS SPR:$a), addrmode5:$ptr)>;
1539 def VTOUIZH : AVConv1IsH_Encode<0b11101, 0b11, 0b1100, 0b1001,
1540 (outs SPR:$Sd), (ins HPR:$Sm),
1541 IIC_fpCVTHI, "vcvt", ".u32.f16\t$Sd, $Sm",
1543 Sched<[WriteFPCVT]> {
1544 let Inst{7} = 1; // Z bit
1547 def : VFPNoNEONPat<(i32 (fp_to_uint HPR:$a)),
1548 (COPY_TO_REGCLASS (VTOUIZH HPR:$a), GPR)>;
1550 // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
1551 let Uses = [FPSCR] in {
1552 def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
1553 (outs SPR:$Sd), (ins DPR:$Dm),
1554 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
1555 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>,
1556 Sched<[WriteFPCVT]> {
1557 let Inst{7} = 0; // Z bit
1560 def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
1561 (outs SPR:$Sd), (ins SPR:$Sm),
1562 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
1563 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]>,
1564 Sched<[WriteFPCVT]> {
1565 let Inst{7} = 0; // Z bit
1568 def VTOSIRH : AVConv1IsH_Encode<0b11101, 0b11, 0b1101, 0b1001,
1569 (outs SPR:$Sd), (ins SPR:$Sm),
1570 IIC_fpCVTHI, "vcvtr", ".s32.f16\t$Sd, $Sm",
1572 Sched<[WriteFPCVT]> {
1573 let Inst{7} = 0; // Z bit
1576 def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
1577 (outs SPR:$Sd), (ins DPR:$Dm),
1578 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
1579 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>,
1580 Sched<[WriteFPCVT]> {
1581 let Inst{7} = 0; // Z bit
1584 def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
1585 (outs SPR:$Sd), (ins SPR:$Sm),
1586 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
1587 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]>,
1588 Sched<[WriteFPCVT]> {
1589 let Inst{7} = 0; // Z bit
1592 def VTOUIRH : AVConv1IsH_Encode<0b11101, 0b11, 0b1100, 0b1001,
1593 (outs SPR:$Sd), (ins SPR:$Sm),
1594 IIC_fpCVTHI, "vcvtr", ".u32.f16\t$Sd, $Sm",
1596 Sched<[WriteFPCVT]> {
1597 let Inst{7} = 0; // Z bit
1601 // v8.3-a Javascript Convert to Signed fixed-point
1602 def VJCVT : AVConv1IsD_Encode<0b11101, 0b11, 0b1001, 0b1011,
1603 (outs SPR:$Sd), (ins DPR:$Dm),
1604 IIC_fpCVTDI, "vjcvt", ".s32.f64\t$Sd, $Dm",
1606 Requires<[HasFPARMv8, HasV8_3a]> {
1607 let Inst{7} = 1; // Z bit
1610 // Convert between floating-point and fixed-point
1611 // Data type for fixed-point naming convention:
1612 // S16 (U=0, sx=0) -> SH
1613 // U16 (U=1, sx=0) -> UH
1614 // S32 (U=0, sx=1) -> SL
1615 // U32 (U=1, sx=1) -> UL
1617 let Constraints = "$a = $dst" in {
1619 // FP to Fixed-Point:
1621 // Single Precision register
1622 class AVConv1XInsS_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4,
1623 bit op5, dag oops, dag iops, InstrItinClass itin,
1624 string opc, string asm, list<dag> pattern>
1625 : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> {
1627 // if dp_operation then UInt(D:Vd) else UInt(Vd:D);
1628 let Inst{22} = dst{0};
1629 let Inst{15-12} = dst{4-1};
1632 // Double Precision register
1633 class AVConv1XInsD_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4,
1634 bit op5, dag oops, dag iops, InstrItinClass itin,
1635 string opc, string asm, list<dag> pattern>
1636 : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> {
1638 // if dp_operation then UInt(D:Vd) else UInt(Vd:D);
1639 let Inst{22} = dst{4};
1640 let Inst{15-12} = dst{3-0};
1642 let Predicates = [HasVFP2, HasDPVFP];
1645 def VTOSHH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1001, 0,
1646 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1647 IIC_fpCVTHI, "vcvt", ".s16.f16\t$dst, $a, $fbits", []>,
1648 Requires<[HasFullFP16]>,
1649 Sched<[WriteFPCVT]>;
1651 def VTOUHH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1001, 0,
1652 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1653 IIC_fpCVTHI, "vcvt", ".u16.f16\t$dst, $a, $fbits", []>,
1654 Requires<[HasFullFP16]>,
1655 Sched<[WriteFPCVT]>;
1657 def VTOSLH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1001, 1,
1658 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1659 IIC_fpCVTHI, "vcvt", ".s32.f16\t$dst, $a, $fbits", []>,
1660 Requires<[HasFullFP16]>,
1661 Sched<[WriteFPCVT]>;
1663 def VTOULH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1001, 1,
1664 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1665 IIC_fpCVTHI, "vcvt", ".u32.f16\t$dst, $a, $fbits", []>,
1666 Requires<[HasFullFP16]>,
1667 Sched<[WriteFPCVT]>;
1669 def VTOSHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 0,
1670 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1671 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", []>,
1672 Sched<[WriteFPCVT]> {
1673 // Some single precision VFP instructions may be executed on both NEON and
1674 // VFP pipelines on A8.
1675 let D = VFPNeonA8Domain;
1678 def VTOUHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 0,
1679 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1680 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits", []> {
1681 // Some single precision VFP instructions may be executed on both NEON and
1682 // VFP pipelines on A8.
1683 let D = VFPNeonA8Domain;
1686 def VTOSLS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 1,
1687 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1688 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits", []> {
1689 // Some single precision VFP instructions may be executed on both NEON and
1690 // VFP pipelines on A8.
1691 let D = VFPNeonA8Domain;
1694 def VTOULS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 1,
1695 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1696 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits", []> {
1697 // Some single precision VFP instructions may be executed on both NEON and
1698 // VFP pipelines on A8.
1699 let D = VFPNeonA8Domain;
1702 def VTOSHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 0,
1703 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
1704 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits", []>,
1705 Sched<[WriteFPCVT]>;
1707 def VTOUHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 0,
1708 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
1709 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits", []>,
1710 Sched<[WriteFPCVT]>;
1712 def VTOSLD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 1,
1713 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
1714 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits", []>,
1715 Sched<[WriteFPCVT]>;
1717 def VTOULD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 1,
1718 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
1719 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", []>,
1720 Sched<[WriteFPCVT]>;
1722 // Fixed-Point to FP:
1724 def VSHTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1001, 0,
1725 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1726 IIC_fpCVTIH, "vcvt", ".f16.s16\t$dst, $a, $fbits", []>,
1727 Requires<[HasFullFP16]>,
1728 Sched<[WriteFPCVT]>;
1730 def VUHTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1001, 0,
1731 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1732 IIC_fpCVTIH, "vcvt", ".f16.u16\t$dst, $a, $fbits", []>,
1733 Requires<[HasFullFP16]>,
1734 Sched<[WriteFPCVT]>;
1736 def VSLTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1001, 1,
1737 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1738 IIC_fpCVTIH, "vcvt", ".f16.s32\t$dst, $a, $fbits", []>,
1739 Requires<[HasFullFP16]>,
1740 Sched<[WriteFPCVT]>;
1742 def VULTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1001, 1,
1743 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1744 IIC_fpCVTIH, "vcvt", ".f16.u32\t$dst, $a, $fbits", []>,
1745 Requires<[HasFullFP16]>,
1746 Sched<[WriteFPCVT]>;
1748 def VSHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 0,
1749 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1750 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", []>,
1751 Sched<[WriteFPCVT]> {
1752 // Some single precision VFP instructions may be executed on both NEON and
1753 // VFP pipelines on A8.
1754 let D = VFPNeonA8Domain;
1757 def VUHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 0,
1758 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits),
1759 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits", []>,
1760 Sched<[WriteFPCVT]> {
1761 // Some single precision VFP instructions may be executed on both NEON and
1762 // VFP pipelines on A8.
1763 let D = VFPNeonA8Domain;
1766 def VSLTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 1,
1767 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1768 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits", []>,
1769 Sched<[WriteFPCVT]> {
1770 // Some single precision VFP instructions may be executed on both NEON and
1771 // VFP pipelines on A8.
1772 let D = VFPNeonA8Domain;
1775 def VULTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 1,
1776 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits),
1777 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits", []>,
1778 Sched<[WriteFPCVT]> {
1779 // Some single precision VFP instructions may be executed on both NEON and
1780 // VFP pipelines on A8.
1781 let D = VFPNeonA8Domain;
1784 def VSHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 0,
1785 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
1786 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits", []>,
1787 Sched<[WriteFPCVT]>;
1789 def VUHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 0,
1790 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits),
1791 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits", []>,
1792 Sched<[WriteFPCVT]>;
1794 def VSLTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 1,
1795 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
1796 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits", []>,
1797 Sched<[WriteFPCVT]>;
1799 def VULTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 1,
1800 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits),
1801 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", []>,
1802 Sched<[WriteFPCVT]>;
1804 } // End of 'let Constraints = "$a = $dst" in'
1806 //===----------------------------------------------------------------------===//
1807 // FP Multiply-Accumulate Operations.
1810 def VMLAD : ADbI<0b11100, 0b00, 0, 0,
1811 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1812 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
1813 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1814 (f64 DPR:$Ddin)))]>,
1815 RegConstraint<"$Ddin = $Dd">,
1816 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
1817 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
1819 def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
1820 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1821 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
1822 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
1824 RegConstraint<"$Sdin = $Sd">,
1825 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
1826 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
1827 // Some single precision VFP instructions may be executed on both NEON and
1828 // VFP pipelines on A8.
1829 let D = VFPNeonA8Domain;
1832 def VMLAH : AHbI<0b11100, 0b00, 0, 0,
1833 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
1834 IIC_fpMAC16, "vmla", ".f16\t$Sd, $Sn, $Sm",
1835 [(set HPR:$Sd, (fadd_mlx (fmul_su HPR:$Sn, HPR:$Sm),
1837 RegConstraint<"$Sdin = $Sd">,
1838 Requires<[HasFullFP16,UseFPVMLx]>;
1840 def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1841 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
1842 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
1843 def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1844 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
1845 Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx]>;
1846 def : Pat<(fadd_mlx HPR:$dstin, (fmul_su HPR:$a, HPR:$b)),
1847 (VMLAH HPR:$dstin, HPR:$a, HPR:$b)>,
1848 Requires<[HasFullFP16,DontUseNEONForFP, UseFPVMLx]>;
1851 def VMLSD : ADbI<0b11100, 0b00, 1, 0,
1852 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1853 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
1854 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1855 (f64 DPR:$Ddin)))]>,
1856 RegConstraint<"$Ddin = $Dd">,
1857 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
1858 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
1860 def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
1861 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1862 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
1863 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1865 RegConstraint<"$Sdin = $Sd">,
1866 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
1867 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
1868 // Some single precision VFP instructions may be executed on both NEON and
1869 // VFP pipelines on A8.
1870 let D = VFPNeonA8Domain;
1873 def VMLSH : AHbI<0b11100, 0b00, 1, 0,
1874 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
1875 IIC_fpMAC16, "vmls", ".f16\t$Sd, $Sn, $Sm",
1876 [(set HPR:$Sd, (fadd_mlx (fneg (fmul_su HPR:$Sn, HPR:$Sm)),
1878 RegConstraint<"$Sdin = $Sd">,
1879 Requires<[HasFullFP16,UseFPVMLx]>;
1881 def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
1882 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
1883 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
1884 def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
1885 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
1886 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
1887 def : Pat<(fsub_mlx HPR:$dstin, (fmul_su HPR:$a, HPR:$b)),
1888 (VMLSH HPR:$dstin, HPR:$a, HPR:$b)>,
1889 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
1891 def VNMLAD : ADbI<0b11100, 0b01, 1, 0,
1892 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1893 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
1894 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
1895 (f64 DPR:$Ddin)))]>,
1896 RegConstraint<"$Ddin = $Dd">,
1897 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
1898 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
1900 def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
1901 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1902 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
1903 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
1905 RegConstraint<"$Sdin = $Sd">,
1906 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
1907 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
1908 // Some single precision VFP instructions may be executed on both NEON and
1909 // VFP pipelines on A8.
1910 let D = VFPNeonA8Domain;
1913 def VNMLAH : AHbI<0b11100, 0b01, 1, 0,
1914 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
1915 IIC_fpMAC16, "vnmla", ".f16\t$Sd, $Sn, $Sm",
1916 [(set HPR:$Sd, (fsub_mlx (fneg (fmul_su HPR:$Sn, HPR:$Sm)),
1918 RegConstraint<"$Sdin = $Sd">,
1919 Requires<[HasFullFP16,UseFPVMLx]>;
1921 // (-(a * b) - dst) -> -(dst + (a * b))
1922 def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
1923 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
1924 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
1925 def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
1926 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
1927 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
1928 def : Pat<(fsub_mlx (fneg (fmul_su HPR:$a, HPR:$b)), HPR:$dstin),
1929 (VNMLAH HPR:$dstin, HPR:$a, HPR:$b)>,
1930 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
1932 // (-dst - (a * b)) -> -(dst + (a * b))
1933 def : Pat<(fsub_mlx (fneg DPR:$dstin), (fmul_su DPR:$a, (f64 DPR:$b))),
1934 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>,
1935 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
1936 def : Pat<(fsub_mlx (fneg SPR:$dstin), (fmul_su SPR:$a, SPR:$b)),
1937 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>,
1938 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
1939 def : Pat<(fsub_mlx (fneg HPR:$dstin), (fmul_su HPR:$a, HPR:$b)),
1940 (VNMLAH HPR:$dstin, HPR:$a, HPR:$b)>,
1941 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
1943 def VNMLSD : ADbI<0b11100, 0b01, 0, 0,
1944 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1945 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
1946 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1947 (f64 DPR:$Ddin)))]>,
1948 RegConstraint<"$Ddin = $Dd">,
1949 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>,
1950 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
1952 def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
1953 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1954 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
1955 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
1956 RegConstraint<"$Sdin = $Sd">,
1957 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>,
1958 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
1959 // Some single precision VFP instructions may be executed on both NEON and
1960 // VFP pipelines on A8.
1961 let D = VFPNeonA8Domain;
1964 def VNMLSH : AHbI<0b11100, 0b01, 0, 0,
1965 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
1966 IIC_fpMAC16, "vnmls", ".f16\t$Sd, $Sn, $Sm",
1967 [(set HPR:$Sd, (fsub_mlx (fmul_su HPR:$Sn, HPR:$Sm), HPR:$Sdin))]>,
1968 RegConstraint<"$Sdin = $Sd">,
1969 Requires<[HasFullFP16,UseFPVMLx]>;
1971 def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
1972 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>,
1973 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>;
1974 def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
1975 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>,
1976 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>;
1977 def : Pat<(fsub_mlx (fmul_su HPR:$a, HPR:$b), HPR:$dstin),
1978 (VNMLSH HPR:$dstin, HPR:$a, HPR:$b)>,
1979 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>;
1981 //===----------------------------------------------------------------------===//
1982 // Fused FP Multiply-Accumulate Operations.
1984 def VFMAD : ADbI<0b11101, 0b10, 0, 0,
1985 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
1986 IIC_fpFMAC64, "vfma", ".f64\t$Dd, $Dn, $Dm",
1987 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm),
1988 (f64 DPR:$Ddin)))]>,
1989 RegConstraint<"$Ddin = $Dd">,
1990 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
1991 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
1993 def VFMAS : ASbIn<0b11101, 0b10, 0, 0,
1994 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
1995 IIC_fpFMAC32, "vfma", ".f32\t$Sd, $Sn, $Sm",
1996 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm),
1998 RegConstraint<"$Sdin = $Sd">,
1999 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
2000 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
2001 // Some single precision VFP instructions may be executed on both NEON and
2005 def VFMAH : AHbI<0b11101, 0b10, 0, 0,
2006 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
2007 IIC_fpFMAC16, "vfma", ".f16\t$Sd, $Sn, $Sm",
2008 [(set HPR:$Sd, (fadd_mlx (fmul_su HPR:$Sn, HPR:$Sm),
2010 RegConstraint<"$Sdin = $Sd">,
2011 Requires<[HasFullFP16,UseFusedMAC]>,
2012 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2014 def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
2015 (VFMAD DPR:$dstin, DPR:$a, DPR:$b)>,
2016 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
2017 def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
2018 (VFMAS SPR:$dstin, SPR:$a, SPR:$b)>,
2019 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
2020 def : Pat<(fadd_mlx HPR:$dstin, (fmul_su HPR:$a, HPR:$b)),
2021 (VFMAH HPR:$dstin, HPR:$a, HPR:$b)>,
2022 Requires<[HasFullFP16,DontUseNEONForFP,UseFusedMAC]>;
2024 // Match @llvm.fma.* intrinsics
2025 // (fma x, y, z) -> (vfms z, x, y)
2026 def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, DPR:$Ddin)),
2027 (VFMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2028 Requires<[HasVFP4,HasDPVFP]>;
2029 def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, SPR:$Sdin)),
2030 (VFMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2031 Requires<[HasVFP4]>;
2033 def VFMSD : ADbI<0b11101, 0b10, 1, 0,
2034 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
2035 IIC_fpFMAC64, "vfms", ".f64\t$Dd, $Dn, $Dm",
2036 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
2037 (f64 DPR:$Ddin)))]>,
2038 RegConstraint<"$Ddin = $Dd">,
2039 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
2040 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2042 def VFMSS : ASbIn<0b11101, 0b10, 1, 0,
2043 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
2044 IIC_fpFMAC32, "vfms", ".f32\t$Sd, $Sn, $Sm",
2045 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
2047 RegConstraint<"$Sdin = $Sd">,
2048 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
2049 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
2050 // Some single precision VFP instructions may be executed on both NEON and
2054 def VFMSH : AHbI<0b11101, 0b10, 1, 0,
2055 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
2056 IIC_fpFMAC16, "vfms", ".f16\t$Sd, $Sn, $Sm",
2057 [(set HPR:$Sd, (fadd_mlx (fneg (fmul_su HPR:$Sn, HPR:$Sm)),
2059 RegConstraint<"$Sdin = $Sd">,
2060 Requires<[HasFullFP16,UseFusedMAC]>,
2061 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2063 def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))),
2064 (VFMSD DPR:$dstin, DPR:$a, DPR:$b)>,
2065 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
2066 def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)),
2067 (VFMSS SPR:$dstin, SPR:$a, SPR:$b)>,
2068 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
2069 def : Pat<(fsub_mlx HPR:$dstin, (fmul_su HPR:$a, HPR:$b)),
2070 (VFMSH HPR:$dstin, HPR:$a, HPR:$b)>,
2071 Requires<[HasFullFP16,DontUseNEONForFP,UseFusedMAC]>;
2073 // Match @llvm.fma.* intrinsics
2074 // (fma (fneg x), y, z) -> (vfms z, x, y)
2075 def : Pat<(f64 (fma (fneg DPR:$Dn), DPR:$Dm, DPR:$Ddin)),
2076 (VFMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2077 Requires<[HasVFP4,HasDPVFP]>;
2078 def : Pat<(f32 (fma (fneg SPR:$Sn), SPR:$Sm, SPR:$Sdin)),
2079 (VFMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2080 Requires<[HasVFP4]>;
2081 // (fma x, (fneg y), z) -> (vfms z, x, y)
2082 def : Pat<(f64 (fma DPR:$Dn, (fneg DPR:$Dm), DPR:$Ddin)),
2083 (VFMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2084 Requires<[HasVFP4,HasDPVFP]>;
2085 def : Pat<(f32 (fma SPR:$Sn, (fneg SPR:$Sm), SPR:$Sdin)),
2086 (VFMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2087 Requires<[HasVFP4]>;
2089 def VFNMAD : ADbI<0b11101, 0b01, 1, 0,
2090 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
2091 IIC_fpFMAC64, "vfnma", ".f64\t$Dd, $Dn, $Dm",
2092 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)),
2093 (f64 DPR:$Ddin)))]>,
2094 RegConstraint<"$Ddin = $Dd">,
2095 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
2096 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2098 def VFNMAS : ASbI<0b11101, 0b01, 1, 0,
2099 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
2100 IIC_fpFMAC32, "vfnma", ".f32\t$Sd, $Sn, $Sm",
2101 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)),
2103 RegConstraint<"$Sdin = $Sd">,
2104 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
2105 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
2106 // Some single precision VFP instructions may be executed on both NEON and
2110 def VFNMAH : AHbI<0b11101, 0b01, 1, 0,
2111 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
2112 IIC_fpFMAC16, "vfnma", ".f16\t$Sd, $Sn, $Sm",
2113 [(set HPR:$Sd, (fsub_mlx (fneg (fmul_su HPR:$Sn, HPR:$Sm)),
2115 RegConstraint<"$Sdin = $Sd">,
2116 Requires<[HasFullFP16,UseFusedMAC]>,
2117 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2119 def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin),
2120 (VFNMAD DPR:$dstin, DPR:$a, DPR:$b)>,
2121 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
2122 def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin),
2123 (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>,
2124 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
2126 // Match @llvm.fma.* intrinsics
2127 // (fneg (fma x, y, z)) -> (vfnma z, x, y)
2128 def : Pat<(fneg (fma (f64 DPR:$Dn), (f64 DPR:$Dm), (f64 DPR:$Ddin))),
2129 (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2130 Requires<[HasVFP4,HasDPVFP]>;
2131 def : Pat<(fneg (fma (f32 SPR:$Sn), (f32 SPR:$Sm), (f32 SPR:$Sdin))),
2132 (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2133 Requires<[HasVFP4]>;
2134 // (fma (fneg x), y, (fneg z)) -> (vfnma z, x, y)
2135 def : Pat<(f64 (fma (fneg DPR:$Dn), DPR:$Dm, (fneg DPR:$Ddin))),
2136 (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2137 Requires<[HasVFP4,HasDPVFP]>;
2138 def : Pat<(f32 (fma (fneg SPR:$Sn), SPR:$Sm, (fneg SPR:$Sdin))),
2139 (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2140 Requires<[HasVFP4]>;
2142 def VFNMSD : ADbI<0b11101, 0b01, 0, 0,
2143 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
2144 IIC_fpFMAC64, "vfnms", ".f64\t$Dd, $Dn, $Dm",
2145 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm),
2146 (f64 DPR:$Ddin)))]>,
2147 RegConstraint<"$Ddin = $Dd">,
2148 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>,
2149 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2151 def VFNMSS : ASbI<0b11101, 0b01, 0, 0,
2152 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
2153 IIC_fpFMAC32, "vfnms", ".f32\t$Sd, $Sn, $Sm",
2154 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
2155 RegConstraint<"$Sdin = $Sd">,
2156 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>,
2157 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> {
2158 // Some single precision VFP instructions may be executed on both NEON and
2162 def VFNMSH : AHbI<0b11101, 0b01, 0, 0,
2163 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm),
2164 IIC_fpFMAC16, "vfnms", ".f16\t$Sd, $Sn, $Sm",
2165 [(set HPR:$Sd, (fsub_mlx (fmul_su HPR:$Sn, HPR:$Sm), HPR:$Sdin))]>,
2166 RegConstraint<"$Sdin = $Sd">,
2167 Requires<[HasFullFP16,UseFusedMAC]>,
2168 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>;
2170 def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin),
2171 (VFNMSD DPR:$dstin, DPR:$a, DPR:$b)>,
2172 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>;
2173 def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin),
2174 (VFNMSS SPR:$dstin, SPR:$a, SPR:$b)>,
2175 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>;
2177 // Match @llvm.fma.* intrinsics
2179 // (fma x, y, (fneg z)) -> (vfnms z, x, y))
2180 def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, (fneg DPR:$Ddin))),
2181 (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2182 Requires<[HasVFP4,HasDPVFP]>;
2183 def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, (fneg SPR:$Sdin))),
2184 (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2185 Requires<[HasVFP4]>;
2186 // (fneg (fma (fneg x), y, z)) -> (vfnms z, x, y)
2187 def : Pat<(fneg (f64 (fma (fneg DPR:$Dn), DPR:$Dm, DPR:$Ddin))),
2188 (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2189 Requires<[HasVFP4,HasDPVFP]>;
2190 def : Pat<(fneg (f32 (fma (fneg SPR:$Sn), SPR:$Sm, SPR:$Sdin))),
2191 (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2192 Requires<[HasVFP4]>;
2193 // (fneg (fma x, (fneg y), z) -> (vfnms z, x, y)
2194 def : Pat<(fneg (f64 (fma DPR:$Dn, (fneg DPR:$Dm), DPR:$Ddin))),
2195 (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>,
2196 Requires<[HasVFP4,HasDPVFP]>;
2197 def : Pat<(fneg (f32 (fma SPR:$Sn, (fneg SPR:$Sm), SPR:$Sdin))),
2198 (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>,
2199 Requires<[HasVFP4]>;
2201 //===----------------------------------------------------------------------===//
2202 // FP Conditional moves.
2205 let hasSideEffects = 0 in {
2206 def VMOVDcc : PseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, cmovpred:$p),
2208 [(set (f64 DPR:$Dd),
2209 (ARMcmov DPR:$Dn, DPR:$Dm, cmovpred:$p))]>,
2210 RegConstraint<"$Dn = $Dd">, Requires<[HasVFP2,HasDPVFP]>;
2212 def VMOVScc : PseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, cmovpred:$p),
2214 [(set (f32 SPR:$Sd),
2215 (ARMcmov SPR:$Sn, SPR:$Sm, cmovpred:$p))]>,
2216 RegConstraint<"$Sn = $Sd">, Requires<[HasVFP2]>;
2219 //===----------------------------------------------------------------------===//
2220 // Move from VFP System Register to ARM core register.
2223 class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
2225 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
2227 // Instruction operand.
2230 let Inst{27-20} = 0b11101111;
2231 let Inst{19-16} = opc19_16;
2232 let Inst{15-12} = Rt;
2233 let Inst{11-8} = 0b1010;
2235 let Inst{6-5} = 0b00;
2237 let Inst{3-0} = 0b0000;
2240 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
2242 let Defs = [CPSR], Uses = [FPSCR_NZCV], Rt = 0b1111 /* apsr_nzcv */ in
2243 def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
2244 "vmrs", "\tAPSR_nzcv, fpscr", [(arm_fmstat)]>;
2246 let DecoderMethod = "DecodeForVMRSandVMSR" in {
2247 // Application level FPSCR -> GPR
2248 let hasSideEffects = 1, Uses = [FPSCR] in
2249 def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPRnopc:$Rt), (ins),
2250 "vmrs", "\t$Rt, fpscr",
2251 [(set GPRnopc:$Rt, (int_arm_get_fpscr))]>;
2253 // System level FPEXC, FPSID -> GPR
2254 let Uses = [FPSCR] in {
2255 def VMRS_FPEXC : MovFromVFP<0b1000 /* fpexc */, (outs GPRnopc:$Rt), (ins),
2256 "vmrs", "\t$Rt, fpexc", []>;
2257 def VMRS_FPSID : MovFromVFP<0b0000 /* fpsid */, (outs GPRnopc:$Rt), (ins),
2258 "vmrs", "\t$Rt, fpsid", []>;
2259 def VMRS_MVFR0 : MovFromVFP<0b0111 /* mvfr0 */, (outs GPRnopc:$Rt), (ins),
2260 "vmrs", "\t$Rt, mvfr0", []>;
2261 def VMRS_MVFR1 : MovFromVFP<0b0110 /* mvfr1 */, (outs GPRnopc:$Rt), (ins),
2262 "vmrs", "\t$Rt, mvfr1", []>;
2263 let Predicates = [HasFPARMv8] in {
2264 def VMRS_MVFR2 : MovFromVFP<0b0101 /* mvfr2 */, (outs GPRnopc:$Rt), (ins),
2265 "vmrs", "\t$Rt, mvfr2", []>;
2267 def VMRS_FPINST : MovFromVFP<0b1001 /* fpinst */, (outs GPRnopc:$Rt), (ins),
2268 "vmrs", "\t$Rt, fpinst", []>;
2269 def VMRS_FPINST2 : MovFromVFP<0b1010 /* fpinst2 */, (outs GPRnopc:$Rt),
2270 (ins), "vmrs", "\t$Rt, fpinst2", []>;
2274 //===----------------------------------------------------------------------===//
2275 // Move from ARM core register to VFP System Register.
2278 class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
2280 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> {
2282 // Instruction operand.
2285 // Encode instruction operand.
2286 let Inst{15-12} = src;
2288 let Inst{27-20} = 0b11101110;
2289 let Inst{19-16} = opc19_16;
2290 let Inst{11-8} = 0b1010;
2295 let DecoderMethod = "DecodeForVMRSandVMSR" in {
2296 let Defs = [FPSCR] in {
2297 // Application level GPR -> FPSCR
2298 def VMSR : MovToVFP<0b0001 /* fpscr */, (outs), (ins GPRnopc:$src),
2299 "vmsr", "\tfpscr, $src",
2300 [(int_arm_set_fpscr GPRnopc:$src)]>;
2301 // System level GPR -> FPEXC
2302 def VMSR_FPEXC : MovToVFP<0b1000 /* fpexc */, (outs), (ins GPRnopc:$src),
2303 "vmsr", "\tfpexc, $src", []>;
2304 // System level GPR -> FPSID
2305 def VMSR_FPSID : MovToVFP<0b0000 /* fpsid */, (outs), (ins GPRnopc:$src),
2306 "vmsr", "\tfpsid, $src", []>;
2307 def VMSR_FPINST : MovToVFP<0b1001 /* fpinst */, (outs), (ins GPRnopc:$src),
2308 "vmsr", "\tfpinst, $src", []>;
2309 def VMSR_FPINST2 : MovToVFP<0b1010 /* fpinst2 */, (outs), (ins GPRnopc:$src),
2310 "vmsr", "\tfpinst2, $src", []>;
2314 //===----------------------------------------------------------------------===//
2318 // Materialize FP immediates. VFP3 only.
2319 let isReMaterializable = 1 in {
2320 def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
2321 VFPMiscFrm, IIC_fpUNA64,
2322 "vmov", ".f64\t$Dd, $imm",
2323 [(set DPR:$Dd, vfp_f64imm:$imm)]>,
2324 Requires<[HasVFP3,HasDPVFP]> {
2328 let Inst{27-23} = 0b11101;
2329 let Inst{22} = Dd{4};
2330 let Inst{21-20} = 0b11;
2331 let Inst{19-16} = imm{7-4};
2332 let Inst{15-12} = Dd{3-0};
2333 let Inst{11-9} = 0b101;
2334 let Inst{8} = 1; // Double precision.
2335 let Inst{7-4} = 0b0000;
2336 let Inst{3-0} = imm{3-0};
2339 def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
2340 VFPMiscFrm, IIC_fpUNA32,
2341 "vmov", ".f32\t$Sd, $imm",
2342 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
2346 let Inst{27-23} = 0b11101;
2347 let Inst{22} = Sd{0};
2348 let Inst{21-20} = 0b11;
2349 let Inst{19-16} = imm{7-4};
2350 let Inst{15-12} = Sd{4-1};
2351 let Inst{11-9} = 0b101;
2352 let Inst{8} = 0; // Single precision.
2353 let Inst{7-4} = 0b0000;
2354 let Inst{3-0} = imm{3-0};
2357 def FCONSTH : VFPAI<(outs HPR:$Sd), (ins vfp_f16imm:$imm),
2358 VFPMiscFrm, IIC_fpUNA16,
2359 "vmov", ".f16\t$Sd, $imm",
2360 [(set HPR:$Sd, vfp_f16imm:$imm)]>,
2361 Requires<[HasFullFP16]> {
2365 let Inst{27-23} = 0b11101;
2366 let Inst{22} = Sd{0};
2367 let Inst{21-20} = 0b11;
2368 let Inst{19-16} = imm{7-4};
2369 let Inst{15-12} = Sd{4-1};
2370 let Inst{11-8} = 0b1001; // Half precision
2371 let Inst{7-4} = 0b0000;
2372 let Inst{3-0} = imm{3-0};
2376 //===----------------------------------------------------------------------===//
2377 // Assembler aliases.
2379 // A few mnemonic aliases for pre-unifixed syntax. We don't guarantee to
2380 // support them all, but supporting at least some of the basics is
2381 // good to be friendly.
2382 def : VFP2MnemonicAlias<"flds", "vldr">;
2383 def : VFP2MnemonicAlias<"fldd", "vldr">;
2384 def : VFP2MnemonicAlias<"fmrs", "vmov">;
2385 def : VFP2MnemonicAlias<"fmsr", "vmov">;
2386 def : VFP2MnemonicAlias<"fsqrts", "vsqrt">;
2387 def : VFP2MnemonicAlias<"fsqrtd", "vsqrt">;
2388 def : VFP2MnemonicAlias<"fadds", "vadd.f32">;
2389 def : VFP2MnemonicAlias<"faddd", "vadd.f64">;
2390 def : VFP2MnemonicAlias<"fmrdd", "vmov">;
2391 def : VFP2MnemonicAlias<"fmrds", "vmov">;
2392 def : VFP2MnemonicAlias<"fmrrd", "vmov">;
2393 def : VFP2MnemonicAlias<"fmdrr", "vmov">;
2394 def : VFP2MnemonicAlias<"fmuls", "vmul.f32">;
2395 def : VFP2MnemonicAlias<"fmuld", "vmul.f64">;
2396 def : VFP2MnemonicAlias<"fnegs", "vneg.f32">;
2397 def : VFP2MnemonicAlias<"fnegd", "vneg.f64">;
2398 def : VFP2MnemonicAlias<"ftosizd", "vcvt.s32.f64">;
2399 def : VFP2MnemonicAlias<"ftosid", "vcvtr.s32.f64">;
2400 def : VFP2MnemonicAlias<"ftosizs", "vcvt.s32.f32">;
2401 def : VFP2MnemonicAlias<"ftosis", "vcvtr.s32.f32">;
2402 def : VFP2MnemonicAlias<"ftouizd", "vcvt.u32.f64">;
2403 def : VFP2MnemonicAlias<"ftouid", "vcvtr.u32.f64">;
2404 def : VFP2MnemonicAlias<"ftouizs", "vcvt.u32.f32">;
2405 def : VFP2MnemonicAlias<"ftouis", "vcvtr.u32.f32">;
2406 def : VFP2MnemonicAlias<"fsitod", "vcvt.f64.s32">;
2407 def : VFP2MnemonicAlias<"fsitos", "vcvt.f32.s32">;
2408 def : VFP2MnemonicAlias<"fuitod", "vcvt.f64.u32">;
2409 def : VFP2MnemonicAlias<"fuitos", "vcvt.f32.u32">;
2410 def : VFP2MnemonicAlias<"fsts", "vstr">;
2411 def : VFP2MnemonicAlias<"fstd", "vstr">;
2412 def : VFP2MnemonicAlias<"fmacd", "vmla.f64">;
2413 def : VFP2MnemonicAlias<"fmacs", "vmla.f32">;
2414 def : VFP2MnemonicAlias<"fcpys", "vmov.f32">;
2415 def : VFP2MnemonicAlias<"fcpyd", "vmov.f64">;
2416 def : VFP2MnemonicAlias<"fcmps", "vcmp.f32">;
2417 def : VFP2MnemonicAlias<"fcmpd", "vcmp.f64">;
2418 def : VFP2MnemonicAlias<"fdivs", "vdiv.f32">;
2419 def : VFP2MnemonicAlias<"fdivd", "vdiv.f64">;
2420 def : VFP2MnemonicAlias<"fmrx", "vmrs">;
2421 def : VFP2MnemonicAlias<"fmxr", "vmsr">;
2423 // Be friendly and accept the old form of zero-compare
2424 def : VFP2DPInstAlias<"fcmpzd${p} $val", (VCMPZD DPR:$val, pred:$p)>;
2425 def : VFP2InstAlias<"fcmpzs${p} $val", (VCMPZS SPR:$val, pred:$p)>;
2428 def : VFP2InstAlias<"fmstat${p}", (FMSTAT pred:$p)>;
2429 def : VFP2InstAlias<"fadds${p} $Sd, $Sn, $Sm",
2430 (VADDS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
2431 def : VFP2DPInstAlias<"faddd${p} $Dd, $Dn, $Dm",
2432 (VADDD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
2433 def : VFP2InstAlias<"fsubs${p} $Sd, $Sn, $Sm",
2434 (VSUBS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>;
2435 def : VFP2DPInstAlias<"fsubd${p} $Dd, $Dn, $Dm",
2436 (VSUBD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>;
2438 // No need for the size suffix on VSQRT. It's implied by the register classes.
2439 def : VFP2InstAlias<"vsqrt${p} $Sd, $Sm", (VSQRTS SPR:$Sd, SPR:$Sm, pred:$p)>;
2440 def : VFP2DPInstAlias<"vsqrt${p} $Dd, $Dm", (VSQRTD DPR:$Dd, DPR:$Dm, pred:$p)>;
2442 // VLDR/VSTR accept an optional type suffix.
2443 def : VFP2InstAlias<"vldr${p}.32 $Sd, $addr",
2444 (VLDRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
2445 def : VFP2InstAlias<"vstr${p}.32 $Sd, $addr",
2446 (VSTRS SPR:$Sd, addrmode5:$addr, pred:$p)>;
2447 def : VFP2InstAlias<"vldr${p}.64 $Dd, $addr",
2448 (VLDRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
2449 def : VFP2InstAlias<"vstr${p}.64 $Dd, $addr",
2450 (VSTRD DPR:$Dd, addrmode5:$addr, pred:$p)>;
2452 // VMOV can accept optional 32-bit or less data type suffix suffix.
2453 def : VFP2InstAlias<"vmov${p}.8 $Rt, $Sn",
2454 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
2455 def : VFP2InstAlias<"vmov${p}.16 $Rt, $Sn",
2456 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
2457 def : VFP2InstAlias<"vmov${p}.32 $Rt, $Sn",
2458 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>;
2459 def : VFP2InstAlias<"vmov${p}.8 $Sn, $Rt",
2460 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
2461 def : VFP2InstAlias<"vmov${p}.16 $Sn, $Rt",
2462 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
2463 def : VFP2InstAlias<"vmov${p}.32 $Sn, $Rt",
2464 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>;
2466 def : VFP2InstAlias<"vmov${p}.f64 $Rt, $Rt2, $Dn",
2467 (VMOVRRD GPR:$Rt, GPR:$Rt2, DPR:$Dn, pred:$p)>;
2468 def : VFP2InstAlias<"vmov${p}.f64 $Dn, $Rt, $Rt2",
2469 (VMOVDRR DPR:$Dn, GPR:$Rt, GPR:$Rt2, pred:$p)>;
2471 // VMOVS doesn't need the .f32 to disambiguate from the NEON encoding the way
2473 def : VFP2InstAlias<"vmov${p} $Sd, $Sm",
2474 (VMOVS SPR:$Sd, SPR:$Sm, pred:$p)>;
2476 // FCONSTD/FCONSTS alias for vmov.f64/vmov.f32
2477 // These aliases provide added functionality over vmov.f instructions by
2478 // allowing users to write assembly containing encoded floating point constants
2479 // (e.g. #0x70 vs #1.0). Without these alises there is no way for the
2480 // assembler to accept encoded fp constants (but the equivalent fp-literal is
2481 // accepted directly by vmovf).
2482 def : VFP3InstAlias<"fconstd${p} $Dd, $val",
2483 (FCONSTD DPR:$Dd, vfp_f64imm:$val, pred:$p)>;
2484 def : VFP3InstAlias<"fconsts${p} $Sd, $val",
2485 (FCONSTS SPR:$Sd, vfp_f32imm:$val, pred:$p)>;