1 //===- ARMInstrVFP.td - VFP support for ARM -------------------------------===//
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 //===----------------------------------------------------------------------===//
15 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
17 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
19 SDTypeProfile<0, 1, [SDTCisFP<0>]>;
21 SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
24 def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
25 def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
26 def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
27 def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
28 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInFlag,SDNPOutFlag]>;
29 def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
30 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0",SDT_CMPFP0, [SDNPOutFlag]>;
31 def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
33 //===----------------------------------------------------------------------===//
34 // Operand Definitions.
38 def vfp_f32imm : Operand<f32>,
39 PatLeaf<(f32 fpimm), [{
40 return ARM::getVFPf32Imm(N->getValueAPF()) != -1;
42 let PrintMethod = "printVFPf32ImmOperand";
45 def vfp_f64imm : Operand<f64>,
46 PatLeaf<(f64 fpimm), [{
47 return ARM::getVFPf64Imm(N->getValueAPF()) != -1;
49 let PrintMethod = "printVFPf64ImmOperand";
53 //===----------------------------------------------------------------------===//
54 // Load / store Instructions.
57 let canFoldAsLoad = 1, isReMaterializable = 1 in {
58 def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$dst), (ins addrmode5:$addr),
59 IIC_fpLoad64, "vldr", ".64\t$dst, $addr",
60 [(set DPR:$dst, (f64 (load addrmode5:$addr)))]>;
62 def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$dst), (ins addrmode5:$addr),
63 IIC_fpLoad32, "vldr", ".32\t$dst, $addr",
64 [(set SPR:$dst, (load addrmode5:$addr))]>;
67 def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$src, addrmode5:$addr),
68 IIC_fpStore64, "vstr", ".64\t$src, $addr",
69 [(store (f64 DPR:$src), addrmode5:$addr)]>;
71 def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$src, addrmode5:$addr),
72 IIC_fpStore32, "vstr", ".32\t$src, $addr",
73 [(store SPR:$src, addrmode5:$addr)]>;
75 //===----------------------------------------------------------------------===//
76 // Load / store multiple Instructions.
79 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
80 def VLDMD : AXDI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dsts,
81 variable_ops), IndexModeNone, IIC_fpLoad_m,
82 "vldm${addr:submode}${p}\t$addr, $dsts", "", []> {
86 def VLDMS : AXSI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dsts,
87 variable_ops), IndexModeNone, IIC_fpLoad_m,
88 "vldm${addr:submode}${p}\t$addr, $dsts", "", []> {
92 def VLDMD_UPD : AXDI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
93 reglist:$dsts, variable_ops),
94 IndexModeUpd, IIC_fpLoad_mu,
95 "vldm${addr:submode}${p}\t$addr!, $dsts",
96 "$addr.addr = $wb", []> {
100 def VLDMS_UPD : AXSI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
101 reglist:$dsts, variable_ops),
102 IndexModeUpd, IIC_fpLoad_mu,
103 "vldm${addr:submode}${p}\t$addr!, $dsts",
104 "$addr.addr = $wb", []> {
107 } // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
109 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
110 def VSTMD : AXDI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$srcs,
111 variable_ops), IndexModeNone, IIC_fpStore_m,
112 "vstm${addr:submode}${p}\t$addr, $srcs", "", []> {
116 def VSTMS : AXSI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$srcs,
117 variable_ops), IndexModeNone, IIC_fpStore_m,
118 "vstm${addr:submode}${p}\t$addr, $srcs", "", []> {
122 def VSTMD_UPD : AXDI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
123 reglist:$srcs, variable_ops),
124 IndexModeUpd, IIC_fpStore_mu,
125 "vstm${addr:submode}${p}\t$addr!, $srcs",
126 "$addr.addr = $wb", []> {
130 def VSTMS_UPD : AXSI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
131 reglist:$srcs, variable_ops),
132 IndexModeUpd, IIC_fpStore_mu,
133 "vstm${addr:submode}${p}\t$addr!, $srcs",
134 "$addr.addr = $wb", []> {
137 } // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
139 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
142 // FIXME: Can these be placed into the base class?
143 class ADbI_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
144 dag iops, InstrItinClass itin, string opc, string asm,
146 : ADbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
147 // Instruction operands.
152 // Encode instruction operands.
153 let Inst{3-0} = Dm{3-0};
155 let Inst{19-16} = Dn{3-0};
157 let Inst{15-12} = Dd{3-0};
158 let Inst{22} = Dd{4};
161 class ADuI_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
162 bits<2> opcod4, bit opcod5, dag oops, dag iops,
163 InstrItinClass itin, string opc, string asm,
165 : ADuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc,
167 // Instruction operands.
171 // Encode instruction operands.
172 let Inst{3-0} = Dm{3-0};
174 let Inst{15-12} = Dd{3-0};
175 let Inst{22} = Dd{4};
178 class ASbI_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
179 dag iops, InstrItinClass itin, string opc, string asm,
181 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
182 // Instruction operands.
187 // Encode instruction operands.
188 let Inst{3-0} = Sm{4-1};
190 let Inst{19-16} = Sn{4-1};
192 let Inst{15-12} = Sd{4-1};
193 let Inst{22} = Sd{0};
196 class ASbIn_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
197 dag iops, InstrItinClass itin, string opc, string asm,
199 : ASbIn<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
200 // Instruction operands.
205 // Encode instruction operands.
206 let Inst{3-0} = Sm{4-1};
208 let Inst{19-16} = Sn{4-1};
210 let Inst{15-12} = Sd{4-1};
211 let Inst{22} = Sd{0};
214 class ASuI_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
215 bits<2> opcod4, bit opcod5, dag oops, dag iops,
216 InstrItinClass itin, string opc, string asm,
218 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc,
220 // Instruction operands.
224 // Encode instruction operands.
225 let Inst{3-0} = Sm{4-1};
227 let Inst{15-12} = Sd{4-1};
228 let Inst{22} = Sd{0};
231 class ASuIn_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
232 bits<2> opcod4, bit opcod5, dag oops, dag iops,
233 InstrItinClass itin, string opc, string asm,
235 : ASuIn<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc,
237 // Instruction operands.
241 // Encode instruction operands.
242 let Inst{3-0} = Sm{4-1};
244 let Inst{15-12} = Sd{4-1};
245 let Inst{22} = Sd{0};
248 //===----------------------------------------------------------------------===//
249 // FP Binary Operations.
252 def VADDD : ADbI_Encode<0b11100, 0b11, 0, 0,
253 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
254 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
255 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
257 def VADDS : ASbIn_Encode<0b11100, 0b11, 0, 0,
258 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
259 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
260 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>;
262 def VSUBD : ADbI_Encode<0b11100, 0b11, 1, 0,
263 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
264 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
265 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
267 def VSUBS : ASbIn_Encode<0b11100, 0b11, 1, 0,
268 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
269 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
270 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>;
272 def VDIVD : ADbI_Encode<0b11101, 0b00, 0, 0,
273 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
274 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
275 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
277 def VDIVS : ASbI_Encode<0b11101, 0b00, 0, 0,
278 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
279 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
280 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
282 def VMULD : ADbI_Encode<0b11100, 0b10, 0, 0,
283 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
284 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
285 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
287 def VMULS : ASbIn_Encode<0b11100, 0b10, 0, 0,
288 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
289 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
290 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>;
292 def VNMULD : ADbI_Encode<0b11100, 0b10, 1, 0,
293 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
294 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
295 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
297 def VNMULS : ASbI_Encode<0b11100, 0b10, 1, 0,
298 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
299 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
300 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>;
302 // Match reassociated forms only if not sign dependent rounding.
303 def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
304 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
305 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
306 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
308 // These are encoded as unary instructions.
309 let Defs = [FPSCR] in {
310 def VCMPED : ADuI_Encode<0b11101, 0b11, 0b0100, 0b11, 0,
311 (outs),(ins DPR:$Dd, DPR:$Dm),
312 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
313 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
315 def VCMPES : ASuI_Encode<0b11101, 0b11, 0b0100, 0b11, 0,
316 (outs),(ins SPR:$Sd, SPR:$Sm),
317 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
318 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]>;
320 def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins DPR:$a, DPR:$b),
321 IIC_fpCMP64, "vcmp", ".f64\t$a, $b",
322 [/* For disassembly only; pattern left blank */]>;
324 def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins SPR:$a, SPR:$b),
325 IIC_fpCMP32, "vcmp", ".f32\t$a, $b",
326 [/* For disassembly only; pattern left blank */]>;
329 //===----------------------------------------------------------------------===//
330 // FP Unary Operations.
333 def VABSD : ADuI_Encode<0b11101, 0b11, 0b0000, 0b11, 0,
334 (outs DPR:$Dd), (ins DPR:$Dm),
335 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
336 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
338 def VABSS : ASuIn_Encode<0b11101, 0b11, 0b0000, 0b11, 0,
339 (outs SPR:$Sd), (ins SPR:$Sm),
340 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
341 [(set SPR:$Sd, (fabs SPR:$Sm))]>;
343 let Defs = [FPSCR] in {
344 def VCMPEZD : ADuI_Encode<0b11101, 0b11, 0b0101, 0b11, 0,
345 (outs), (ins DPR:$Dd),
346 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
347 [(arm_cmpfp0 (f64 DPR:$Dd))]> {
348 let Inst{3-0} = 0b0000;
352 def VCMPEZS : ASuI_Encode<0b11101, 0b11, 0b0101, 0b11, 0,
353 (outs), (ins SPR:$Sd),
354 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
355 [(arm_cmpfp0 SPR:$Sd)]> {
356 let Inst{3-0} = 0b0000;
360 def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins DPR:$a),
361 IIC_fpCMP64, "vcmp", ".f64\t$a, #0",
362 [/* For disassembly only; pattern left blank */]>;
364 def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins SPR:$a),
365 IIC_fpCMP32, "vcmp", ".f32\t$a, #0",
366 [/* For disassembly only; pattern left blank */]>;
369 def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
370 IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
371 [(set DPR:$dst, (fextend SPR:$a))]>;
373 // Special case encoding: bits 11-8 is 0b1011.
374 def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
375 IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
376 [(set SPR:$dst, (fround DPR:$a))]> {
377 let Inst{27-23} = 0b11101;
378 let Inst{21-16} = 0b110111;
379 let Inst{11-8} = 0b1011;
380 let Inst{7-6} = 0b11;
384 // Between half-precision and single-precision. For disassembly only.
386 def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
387 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
388 [/* For disassembly only; pattern left blank */]>;
390 def : ARMPat<(f32_to_f16 SPR:$a),
391 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
393 def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
394 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
395 [/* For disassembly only; pattern left blank */]>;
397 def : ARMPat<(f16_to_f32 GPR:$a),
398 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
400 def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
401 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
402 [/* For disassembly only; pattern left blank */]>;
404 def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
405 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
406 [/* For disassembly only; pattern left blank */]>;
408 let neverHasSideEffects = 1 in {
409 def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
410 IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
412 def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
413 IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
414 } // neverHasSideEffects
416 def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
417 IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
418 [(set DPR:$dst, (fneg (f64 DPR:$a)))]>;
420 def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
421 IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
422 [(set SPR:$dst, (fneg SPR:$a))]>;
424 def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
425 IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
426 [(set DPR:$dst, (fsqrt (f64 DPR:$a)))]>;
428 def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
429 IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
430 [(set SPR:$dst, (fsqrt SPR:$a))]>;
432 //===----------------------------------------------------------------------===//
433 // FP <-> GPR Copies. Int <-> FP Conversions.
436 def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
437 IIC_fpMOVSI, "vmov", "\t$dst, $src",
438 [(set GPR:$dst, (bitconvert SPR:$src))]>;
440 def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
441 IIC_fpMOVIS, "vmov", "\t$dst, $src",
442 [(set SPR:$dst, (bitconvert GPR:$src))]>;
444 let neverHasSideEffects = 1 in {
445 def VMOVRRD : AVConv3I<0b11000101, 0b1011,
446 (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
447 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
448 [/* FIXME: Can't write pattern for multiple result instr*/]> {
449 let Inst{7-6} = 0b00;
452 def VMOVRRS : AVConv3I<0b11000101, 0b1010,
453 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
454 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
455 [/* For disassembly only; pattern left blank */]> {
456 let Inst{7-6} = 0b00;
458 } // neverHasSideEffects
463 def VMOVDRR : AVConv5I<0b11000100, 0b1011,
464 (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
465 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
466 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
467 let Inst{7-6} = 0b00;
470 let neverHasSideEffects = 1 in
471 def VMOVSRR : AVConv5I<0b11000100, 0b1010,
472 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
473 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
474 [/* For disassembly only; pattern left blank */]> {
475 let Inst{7-6} = 0b00;
481 // FMRX : SPR system reg -> GPR
485 // FMXR: GPR -> VFP system reg
490 def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
491 (outs DPR:$dst), (ins SPR:$a),
492 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
493 [(set DPR:$dst, (f64 (arm_sitof SPR:$a)))]> {
494 let Inst{7} = 1; // s32
497 def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
498 (outs SPR:$dst),(ins SPR:$a),
499 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
500 [(set SPR:$dst, (arm_sitof SPR:$a))]> {
501 let Inst{7} = 1; // s32
504 def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
505 (outs DPR:$dst), (ins SPR:$a),
506 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
507 [(set DPR:$dst, (f64 (arm_uitof SPR:$a)))]> {
508 let Inst{7} = 0; // u32
511 def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
512 (outs SPR:$dst), (ins SPR:$a),
513 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
514 [(set SPR:$dst, (arm_uitof SPR:$a))]> {
515 let Inst{7} = 0; // u32
519 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
521 def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
522 (outs SPR:$dst), (ins DPR:$a),
523 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
524 [(set SPR:$dst, (arm_ftosi (f64 DPR:$a)))]> {
525 let Inst{7} = 1; // Z bit
528 def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
529 (outs SPR:$dst), (ins SPR:$a),
530 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
531 [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
532 let Inst{7} = 1; // Z bit
535 def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
536 (outs SPR:$dst), (ins DPR:$a),
537 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
538 [(set SPR:$dst, (arm_ftoui (f64 DPR:$a)))]> {
539 let Inst{7} = 1; // Z bit
542 def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
543 (outs SPR:$dst), (ins SPR:$a),
544 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
545 [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
546 let Inst{7} = 1; // Z bit
549 // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
550 // For disassembly only.
551 let Uses = [FPSCR] in {
552 def VTOSIRD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
553 (outs SPR:$dst), (ins DPR:$a),
554 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$dst, $a",
555 [(set SPR:$dst, (int_arm_vcvtr (f64 DPR:$a)))]> {
556 let Inst{7} = 0; // Z bit
559 def VTOSIRS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
560 (outs SPR:$dst), (ins SPR:$a),
561 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$dst, $a",
562 [(set SPR:$dst, (int_arm_vcvtr SPR:$a))]> {
563 let Inst{7} = 0; // Z bit
566 def VTOUIRD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
567 (outs SPR:$dst), (ins DPR:$a),
568 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$dst, $a",
569 [(set SPR:$dst, (int_arm_vcvtru (f64 DPR:$a)))]> {
570 let Inst{7} = 0; // Z bit
573 def VTOUIRS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
574 (outs SPR:$dst), (ins SPR:$a),
575 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$dst, $a",
576 [(set SPR:$dst, (int_arm_vcvtru SPR:$a))]> {
577 let Inst{7} = 0; // Z bit
581 // Convert between floating-point and fixed-point
582 // Data type for fixed-point naming convention:
583 // S16 (U=0, sx=0) -> SH
584 // U16 (U=1, sx=0) -> UH
585 // S32 (U=0, sx=1) -> SL
586 // U32 (U=1, sx=1) -> UL
588 let Constraints = "$a = $dst" in {
590 // FP to Fixed-Point:
592 let isCodeGenOnly = 1 in {
593 def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
594 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
595 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
596 [/* For disassembly only; pattern left blank */]>;
598 def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
599 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
600 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
601 [/* For disassembly only; pattern left blank */]>;
603 def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
604 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
605 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
606 [/* For disassembly only; pattern left blank */]>;
608 def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
609 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
610 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
611 [/* For disassembly only; pattern left blank */]>;
613 def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
614 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
615 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
616 [/* For disassembly only; pattern left blank */]>;
618 def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
619 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
620 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
621 [/* For disassembly only; pattern left blank */]>;
623 def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
624 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
625 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
626 [/* For disassembly only; pattern left blank */]>;
628 def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
629 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
630 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
631 [/* For disassembly only; pattern left blank */]>;
634 // Fixed-Point to FP:
636 let isCodeGenOnly = 1 in {
637 def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
638 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
639 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
640 [/* For disassembly only; pattern left blank */]>;
642 def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
643 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
644 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
645 [/* For disassembly only; pattern left blank */]>;
647 def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
648 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
649 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
650 [/* For disassembly only; pattern left blank */]>;
652 def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
653 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
654 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
655 [/* For disassembly only; pattern left blank */]>;
657 def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
658 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
659 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
660 [/* For disassembly only; pattern left blank */]>;
662 def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
663 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
664 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
665 [/* For disassembly only; pattern left blank */]>;
667 def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
668 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
669 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
670 [/* For disassembly only; pattern left blank */]>;
672 def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
673 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
674 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
675 [/* For disassembly only; pattern left blank */]>;
678 } // End of 'let Constraints = "$src = $dst" in'
680 //===----------------------------------------------------------------------===//
681 // FP FMA Operations.
684 def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
685 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
686 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
687 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b),
688 (f64 DPR:$dstin)))]>,
689 RegConstraint<"$dstin = $dst">;
691 def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
692 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
693 IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
694 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
695 RegConstraint<"$dstin = $dst">;
697 def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
698 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
699 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
700 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b),
701 (f64 DPR:$dstin)))]>,
702 RegConstraint<"$dstin = $dst">;
704 def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
705 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
706 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
707 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
708 RegConstraint<"$dstin = $dst">;
710 def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
711 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
712 IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
713 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)),
714 (f64 DPR:$dstin)))]>,
715 RegConstraint<"$dstin = $dst">;
717 def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
718 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
719 IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
720 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
721 RegConstraint<"$dstin = $dst">;
723 def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
724 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
725 def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
726 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
728 def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
729 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
730 IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
731 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)),
732 (f64 DPR:$dstin)))]>,
733 RegConstraint<"$dstin = $dst">;
735 def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
736 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
737 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
738 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
739 RegConstraint<"$dstin = $dst">;
741 //===----------------------------------------------------------------------===//
742 // FP Conditional moves.
745 let neverHasSideEffects = 1 in {
746 def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
747 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
748 IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
749 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
750 RegConstraint<"$false = $dst">;
752 def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
753 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
754 IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
755 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
756 RegConstraint<"$false = $dst">;
758 def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
759 (outs DPR:$dst), (ins DPR:$false, DPR:$true),
760 IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
761 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
762 RegConstraint<"$false = $dst">;
764 def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
765 (outs SPR:$dst), (ins SPR:$false, SPR:$true),
766 IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
767 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
768 RegConstraint<"$false = $dst">;
769 } // neverHasSideEffects
771 //===----------------------------------------------------------------------===//
775 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
777 let Defs = [CPSR], Uses = [FPSCR] in
778 def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
779 "\tapsr_nzcv, fpscr",
781 let Inst{27-20} = 0b11101111;
782 let Inst{19-16} = 0b0001;
783 let Inst{15-12} = 0b1111;
784 let Inst{11-8} = 0b1010;
789 // FPSCR <-> GPR (for disassembly only)
790 let hasSideEffects = 1, Uses = [FPSCR] in
791 def VMRS : VFPAI<(outs GPR:$dst), (ins), VFPMiscFrm, IIC_fpSTAT,
792 "vmrs", "\t$dst, fpscr",
793 [(set GPR:$dst, (int_arm_get_fpscr))]> {
794 let Inst{27-20} = 0b11101111;
795 let Inst{19-16} = 0b0001;
796 let Inst{11-8} = 0b1010;
801 let Defs = [FPSCR] in
802 def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
803 "vmsr", "\tfpscr, $src",
804 [(int_arm_set_fpscr GPR:$src)]> {
805 let Inst{27-20} = 0b11101110;
806 let Inst{19-16} = 0b0001;
807 let Inst{11-8} = 0b1010;
812 // Materialize FP immediates. VFP3 only.
813 let isReMaterializable = 1 in {
814 def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
815 VFPMiscFrm, IIC_fpUNA64,
816 "vmov", ".f64\t$dst, $imm",
817 [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
818 let Inst{27-23} = 0b11101;
819 let Inst{21-20} = 0b11;
820 let Inst{11-9} = 0b101;
822 let Inst{7-4} = 0b0000;
825 def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
826 VFPMiscFrm, IIC_fpUNA32,
827 "vmov", ".f32\t$dst, $imm",
828 [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
829 let Inst{27-23} = 0b11101;
830 let Inst{21-20} = 0b11;
831 let Inst{11-9} = 0b101;
833 let Inst{7-4} = 0b0000;