1 //===- ARMInstrVFP.td - VFP support for ARM ----------------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM VFP instruction set.
12 //===----------------------------------------------------------------------===//
14 def SDT_FTOI : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
15 def SDT_ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
16 def SDT_CMPFP0 : SDTypeProfile<0, 1, [SDTCisFP<0>]>;
17 def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
20 def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
21 def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
22 def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
23 def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
24 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInFlag, SDNPOutFlag]>;
25 def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
26 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutFlag]>;
27 def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>;
30 //===----------------------------------------------------------------------===//
31 // Operand Definitions.
34 def vfp_f32imm : Operand<f32>,
35 PatLeaf<(f32 fpimm), [{
36 return ARM::getVFPf32Imm(N->getValueAPF()) != -1;
38 let PrintMethod = "printVFPf32ImmOperand";
41 def vfp_f64imm : Operand<f64>,
42 PatLeaf<(f64 fpimm), [{
43 return ARM::getVFPf64Imm(N->getValueAPF()) != -1;
45 let PrintMethod = "printVFPf64ImmOperand";
49 //===----------------------------------------------------------------------===//
50 // Load / store Instructions.
53 let canFoldAsLoad = 1, isReMaterializable = 1 in {
55 def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr),
56 IIC_fpLoad64, "vldr", ".64\t$Dd, $addr",
57 [(set DPR:$Dd, (f64 (load addrmode5:$addr)))]>;
59 def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr),
60 IIC_fpLoad32, "vldr", ".32\t$Sd, $addr",
61 [(set SPR:$Sd, (load addrmode5:$addr))]>;
63 } // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in'
65 def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr),
66 IIC_fpStore64, "vstr", ".64\t$Dd, $addr",
67 [(store (f64 DPR:$Dd), addrmode5:$addr)]>;
69 def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr),
70 IIC_fpStore32, "vstr", ".32\t$Sd, $addr",
71 [(store SPR:$Sd, addrmode5:$addr)]>;
73 //===----------------------------------------------------------------------===//
74 // Load / store multiple Instructions.
77 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1,
78 isCodeGenOnly = 1 in {
79 def VLDMD : AXDI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
80 reglist:$dsts, variable_ops),
81 IndexModeNone, IIC_fpLoad_m,
82 "vldm${amode}${p}\t$Rn, $dsts", "", []> {
83 let Inst{21} = 0; // wback = (W == '1')
84 let Inst{20} = 1; // Load
87 def VLDMS : AXSI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
88 reglist:$dsts, variable_ops),
89 IndexModeNone, IIC_fpLoad_m,
90 "vldm${amode}${p}\t$Rn, $dsts", "", []> {
91 let Inst{21} = 0; // wback = (W == '1')
92 let Inst{20} = 1; // Load
95 def VLDMD_UPD : AXDI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
96 reglist:$dsts, variable_ops),
97 IndexModeUpd, IIC_fpLoad_mu,
98 "vldm${amode}${p}\t$Rn!, $dsts",
100 let Inst{21} = 1; // wback = (W == '1')
101 let Inst{20} = 1; // Load
104 def VLDMS_UPD : AXSI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
105 reglist:$dsts, variable_ops),
106 IndexModeUpd, IIC_fpLoad_mu,
107 "vldm${amode}${p}\t$Rn!, $dsts",
109 let Inst{21} = 1; // wback = (W == '1')
110 let Inst{20} = 1; // Load
112 } // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
114 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1,
115 isCodeGenOnly = 1 in {
116 def VSTMD : AXDI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
117 reglist:$srcs, variable_ops),
118 IndexModeNone, IIC_fpStore_m,
119 "vstm${amode}${p}\t$Rn, $srcs", "", []> {
120 let Inst{21} = 0; // wback = (W == '1')
121 let Inst{20} = 0; // Store
124 def VSTMS : AXSI4<(outs), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
125 reglist:$srcs, variable_ops), IndexModeNone,
127 "vstm${amode}${p}\t$Rn, $srcs", "", []> {
128 let Inst{21} = 0; // wback = (W == '1')
129 let Inst{20} = 0; // Store
132 def VSTMD_UPD : AXDI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
133 reglist:$srcs, variable_ops),
134 IndexModeUpd, IIC_fpStore_mu,
135 "vstm${amode}${p}\t$Rn!, $srcs",
137 let Inst{21} = 1; // wback = (W == '1')
138 let Inst{20} = 0; // Store
141 def VSTMS_UPD : AXSI4<(outs GPR:$wb), (ins GPR:$Rn, ldstm_mode:$amode, pred:$p,
142 reglist:$srcs, variable_ops),
143 IndexModeUpd, IIC_fpStore_mu,
144 "vstm${amode}${p}\t$Rn!, $srcs",
146 let Inst{21} = 1; // wback = (W == '1')
147 let Inst{20} = 0; // Store
149 } // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
151 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
153 //===----------------------------------------------------------------------===//
154 // FP Binary Operations.
157 def VADDD : ADbI<0b11100, 0b11, 0, 0,
158 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
159 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
160 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
162 def VADDS : ASbIn<0b11100, 0b11, 0, 0,
163 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
164 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
165 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>;
167 def VSUBD : ADbI<0b11100, 0b11, 1, 0,
168 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
169 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
170 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
172 def VSUBS : ASbIn<0b11100, 0b11, 1, 0,
173 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
174 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
175 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>;
177 def VDIVD : ADbI<0b11101, 0b00, 0, 0,
178 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
179 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
180 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
182 def VDIVS : ASbI<0b11101, 0b00, 0, 0,
183 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
184 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
185 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
187 def VMULD : ADbI<0b11100, 0b10, 0, 0,
188 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
189 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
190 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
192 def VMULS : ASbIn<0b11100, 0b10, 0, 0,
193 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
194 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
195 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>;
197 def VNMULD : ADbI<0b11100, 0b10, 1, 0,
198 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
199 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
200 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
202 def VNMULS : ASbI<0b11100, 0b10, 1, 0,
203 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
204 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
205 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>;
207 // Match reassociated forms only if not sign dependent rounding.
208 def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
209 (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
210 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
211 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
213 // These are encoded as unary instructions.
214 let Defs = [FPSCR] in {
215 def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
216 (outs), (ins DPR:$Dd, DPR:$Dm),
217 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
218 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
220 def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0,
221 (outs), (ins SPR:$Sd, SPR:$Sm),
222 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
223 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]>;
225 // FIXME: Verify encoding after integrated assembler is working.
226 def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0,
227 (outs), (ins DPR:$Dd, DPR:$Dm),
228 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
229 [/* For disassembly only; pattern left blank */]>;
231 def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
232 (outs), (ins SPR:$Sd, SPR:$Sm),
233 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
234 [/* For disassembly only; pattern left blank */]>;
237 //===----------------------------------------------------------------------===//
238 // FP Unary Operations.
241 def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0,
242 (outs DPR:$Dd), (ins DPR:$Dm),
243 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
244 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
246 def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
247 (outs SPR:$Sd), (ins SPR:$Sm),
248 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
249 [(set SPR:$Sd, (fabs SPR:$Sm))]>;
251 let Defs = [FPSCR] in {
252 def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
253 (outs), (ins DPR:$Dd),
254 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
255 [(arm_cmpfp0 (f64 DPR:$Dd))]> {
256 let Inst{3-0} = 0b0000;
260 def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0,
261 (outs), (ins SPR:$Sd),
262 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
263 [(arm_cmpfp0 SPR:$Sd)]> {
264 let Inst{3-0} = 0b0000;
268 // FIXME: Verify encoding after integrated assembler is working.
269 def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0,
270 (outs), (ins DPR:$Dd),
271 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
272 [/* For disassembly only; pattern left blank */]> {
273 let Inst{3-0} = 0b0000;
277 def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
278 (outs), (ins SPR:$Sd),
279 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
280 [/* For disassembly only; pattern left blank */]> {
281 let Inst{3-0} = 0b0000;
286 def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
287 (outs DPR:$Dd), (ins SPR:$Sm),
288 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
289 [(set DPR:$Dd, (fextend SPR:$Sm))]> {
290 // Instruction operands.
294 // Encode instruction operands.
295 let Inst{3-0} = Sm{4-1};
297 let Inst{15-12} = Dd{3-0};
298 let Inst{22} = Dd{4};
301 // Special case encoding: bits 11-8 is 0b1011.
302 def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
303 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
304 [(set SPR:$Sd, (fround DPR:$Dm))]> {
305 // Instruction operands.
309 // Encode instruction operands.
310 let Inst{3-0} = Dm{3-0};
312 let Inst{15-12} = Sd{4-1};
313 let Inst{22} = Sd{0};
315 let Inst{27-23} = 0b11101;
316 let Inst{21-16} = 0b110111;
317 let Inst{11-8} = 0b1011;
318 let Inst{7-6} = 0b11;
322 // Between half-precision and single-precision. For disassembly only.
324 // FIXME: Verify encoding after integrated assembler is working.
325 def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
326 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
327 [/* For disassembly only; pattern left blank */]>;
329 def : ARMPat<(f32_to_f16 SPR:$a),
330 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
332 def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
333 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
334 [/* For disassembly only; pattern left blank */]>;
336 def : ARMPat<(f16_to_f32 GPR:$a),
337 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
339 def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
340 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
341 [/* For disassembly only; pattern left blank */]>;
343 def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
344 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
345 [/* For disassembly only; pattern left blank */]>;
347 def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
348 (outs DPR:$Dd), (ins DPR:$Dm),
349 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
350 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
352 def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,
353 (outs SPR:$Sd), (ins SPR:$Sm),
354 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
355 [(set SPR:$Sd, (fneg SPR:$Sm))]>;
357 def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0,
358 (outs DPR:$Dd), (ins DPR:$Dm),
359 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
360 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>;
362 def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0,
363 (outs SPR:$Sd), (ins SPR:$Sm),
364 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
365 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>;
367 let neverHasSideEffects = 1 in {
368 def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
369 (outs DPR:$Dd), (ins DPR:$Dm),
370 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
372 def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
373 (outs SPR:$Sd), (ins SPR:$Sm),
374 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
375 } // neverHasSideEffects
377 //===----------------------------------------------------------------------===//
378 // FP <-> GPR Copies. Int <-> FP Conversions.
381 def VMOVRS : AVConv2I<0b11100001, 0b1010,
382 (outs GPR:$Rt), (ins SPR:$Sn),
383 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn",
384 [(set GPR:$Rt, (bitconvert SPR:$Sn))]> {
385 // Instruction operands.
389 // Encode instruction operands.
390 let Inst{19-16} = Sn{4-1};
392 let Inst{15-12} = Rt;
394 let Inst{6-5} = 0b00;
395 let Inst{3-0} = 0b0000;
398 def VMOVSR : AVConv4I<0b11100000, 0b1010,
399 (outs SPR:$Sn), (ins GPR:$Rt),
400 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt",
401 [(set SPR:$Sn, (bitconvert GPR:$Rt))]> {
402 // Instruction operands.
406 // Encode instruction operands.
407 let Inst{19-16} = Sn{4-1};
409 let Inst{15-12} = Rt;
411 let Inst{6-5} = 0b00;
412 let Inst{3-0} = 0b0000;
415 let neverHasSideEffects = 1 in {
416 def VMOVRRD : AVConv3I<0b11000101, 0b1011,
417 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm),
418 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm",
419 [/* FIXME: Can't write pattern for multiple result instr*/]> {
420 // Instruction operands.
425 // Encode instruction operands.
426 let Inst{3-0} = Dm{3-0};
428 let Inst{15-12} = Rt;
429 let Inst{19-16} = Rt2;
431 let Inst{7-6} = 0b00;
434 def VMOVRRS : AVConv3I<0b11000101, 0b1010,
435 (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
436 IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
437 [/* For disassembly only; pattern left blank */]> {
438 let Inst{7-6} = 0b00;
440 } // neverHasSideEffects
445 def VMOVDRR : AVConv5I<0b11000100, 0b1011,
446 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2),
447 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2",
448 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]> {
449 // Instruction operands.
454 // Encode instruction operands.
455 let Inst{3-0} = Dm{3-0};
457 let Inst{15-12} = Rt;
458 let Inst{19-16} = Rt2;
460 let Inst{7-6} = 0b00;
463 let neverHasSideEffects = 1 in
464 def VMOVSRR : AVConv5I<0b11000100, 0b1010,
465 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
466 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
467 [/* For disassembly only; pattern left blank */]> {
468 let Inst{7-6} = 0b00;
474 // FMRX: SPR system reg -> GPR
476 // FMXR: GPR -> VFP system reg
481 class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
482 bits<4> opcod4, dag oops, dag iops,
483 InstrItinClass itin, string opc, string asm,
485 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
487 // Instruction operands.
491 // Encode instruction operands.
492 let Inst{3-0} = Sm{4-1};
494 let Inst{15-12} = Dd{3-0};
495 let Inst{22} = Dd{4};
498 class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
499 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
500 string opc, string asm, list<dag> pattern>
501 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
503 // Instruction operands.
507 // Encode instruction operands.
508 let Inst{3-0} = Sm{4-1};
510 let Inst{15-12} = Sd{4-1};
511 let Inst{22} = Sd{0};
514 def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
515 (outs DPR:$Dd), (ins SPR:$Sm),
516 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
517 [(set DPR:$Dd, (f64 (arm_sitof SPR:$Sm)))]> {
518 let Inst{7} = 1; // s32
521 def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
522 (outs SPR:$Sd),(ins SPR:$Sm),
523 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
524 [(set SPR:$Sd, (arm_sitof SPR:$Sm))]> {
525 let Inst{7} = 1; // s32
528 def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
529 (outs DPR:$Dd), (ins SPR:$Sm),
530 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
531 [(set DPR:$Dd, (f64 (arm_uitof SPR:$Sm)))]> {
532 let Inst{7} = 0; // u32
535 def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
536 (outs SPR:$Sd), (ins SPR:$Sm),
537 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
538 [(set SPR:$Sd, (arm_uitof SPR:$Sm))]> {
539 let Inst{7} = 0; // u32
544 class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
545 bits<4> opcod4, dag oops, dag iops,
546 InstrItinClass itin, string opc, string asm,
548 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
550 // Instruction operands.
554 // Encode instruction operands.
555 let Inst{3-0} = Dm{3-0};
557 let Inst{15-12} = Sd{4-1};
558 let Inst{22} = Sd{0};
561 class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
562 bits<4> opcod4, dag oops, dag iops,
563 InstrItinClass itin, string opc, string asm,
565 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
567 // Instruction operands.
571 // Encode instruction operands.
572 let Inst{3-0} = Sm{4-1};
574 let Inst{15-12} = Sd{4-1};
575 let Inst{22} = Sd{0};
578 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
579 def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
580 (outs SPR:$Sd), (ins DPR:$Dm),
581 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
582 [(set SPR:$Sd, (arm_ftosi (f64 DPR:$Dm)))]> {
583 let Inst{7} = 1; // Z bit
586 def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
587 (outs SPR:$Sd), (ins SPR:$Sm),
588 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
589 [(set SPR:$Sd, (arm_ftosi SPR:$Sm))]> {
590 let Inst{7} = 1; // Z bit
593 def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
594 (outs SPR:$Sd), (ins DPR:$Dm),
595 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
596 [(set SPR:$Sd, (arm_ftoui (f64 DPR:$Dm)))]> {
597 let Inst{7} = 1; // Z bit
600 def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
601 (outs SPR:$Sd), (ins SPR:$Sm),
602 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
603 [(set SPR:$Sd, (arm_ftoui SPR:$Sm))]> {
604 let Inst{7} = 1; // Z bit
607 // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
608 // For disassembly only.
609 let Uses = [FPSCR] in {
610 // FIXME: Verify encoding after integrated assembler is working.
611 def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
612 (outs SPR:$Sd), (ins DPR:$Dm),
613 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
614 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>{
615 let Inst{7} = 0; // Z bit
618 def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
619 (outs SPR:$Sd), (ins SPR:$Sm),
620 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
621 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]> {
622 let Inst{7} = 0; // Z bit
625 def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
626 (outs SPR:$Sd), (ins DPR:$Dm),
627 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
628 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
629 let Inst{7} = 0; // Z bit
632 def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
633 (outs SPR:$Sd), (ins SPR:$Sm),
634 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
635 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]> {
636 let Inst{7} = 0; // Z bit
640 // Convert between floating-point and fixed-point
641 // Data type for fixed-point naming convention:
642 // S16 (U=0, sx=0) -> SH
643 // U16 (U=1, sx=0) -> UH
644 // S32 (U=0, sx=1) -> SL
645 // U32 (U=1, sx=1) -> UL
647 // FIXME: Marking these as codegen only seems wrong. They are real
649 let Constraints = "$a = $dst", isCodeGenOnly = 1 in {
651 // FP to Fixed-Point:
653 def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
654 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
655 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
656 [/* For disassembly only; pattern left blank */]>;
658 def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
659 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
660 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
661 [/* For disassembly only; pattern left blank */]>;
663 def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
664 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
665 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
666 [/* For disassembly only; pattern left blank */]>;
668 def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
669 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
670 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
671 [/* For disassembly only; pattern left blank */]>;
673 def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
674 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
675 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
676 [/* For disassembly only; pattern left blank */]>;
678 def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
679 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
680 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
681 [/* For disassembly only; pattern left blank */]>;
683 def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
684 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
685 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
686 [/* For disassembly only; pattern left blank */]>;
688 def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
689 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
690 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
691 [/* For disassembly only; pattern left blank */]>;
693 // Fixed-Point to FP:
695 def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
696 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
697 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
698 [/* For disassembly only; pattern left blank */]>;
700 def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
701 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
702 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
703 [/* For disassembly only; pattern left blank */]>;
705 def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
706 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
707 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
708 [/* For disassembly only; pattern left blank */]>;
710 def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
711 (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
712 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
713 [/* For disassembly only; pattern left blank */]>;
715 def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
716 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
717 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
718 [/* For disassembly only; pattern left blank */]>;
720 def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
721 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
722 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
723 [/* For disassembly only; pattern left blank */]>;
725 def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
726 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
727 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
728 [/* For disassembly only; pattern left blank */]>;
730 def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
731 (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
732 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
733 [/* For disassembly only; pattern left blank */]>;
735 } // End of 'let Constraints = "$a = $dst", isCodeGenOnly = 1 in'
737 //===----------------------------------------------------------------------===//
738 // FP FMA Operations.
741 def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
742 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
743 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
744 [(set DPR:$Dd, (fadd (fmul DPR:$Dn, DPR:$Dm),
746 RegConstraint<"$Ddin = $Dd">;
748 def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
749 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
750 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
751 [(set SPR:$Sd, (fadd (fmul SPR:$Sn, SPR:$Sm),
753 RegConstraint<"$Sdin = $Sd">;
755 def : Pat<(fadd DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
756 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
757 def : Pat<(fadd SPR:$dstin, (fmul SPR:$a, SPR:$b)),
758 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
760 def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
761 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
762 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
763 [(set DPR:$Dd, (fadd (fneg (fmul DPR:$Dn,DPR:$Dm)),
765 RegConstraint<"$Ddin = $Dd">;
767 def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
768 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
769 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
770 [(set SPR:$Sd, (fadd (fneg (fmul SPR:$Sn, SPR:$Sm)),
772 RegConstraint<"$Sdin = $Sd">;
774 def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
775 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
776 def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
777 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
779 def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
780 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
781 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
782 [(set DPR:$Dd,(fsub (fneg (fmul DPR:$Dn,DPR:$Dm)),
784 RegConstraint<"$Ddin = $Dd">;
786 def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
787 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
788 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
789 [(set SPR:$Sd, (fsub (fneg (fmul SPR:$Sn, SPR:$Sm)),
791 RegConstraint<"$Sdin = $Sd">;
793 def : Pat<(fsub (fneg (fmul DPR:$a, (f64 DPR:$b))), DPR:$dstin),
794 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
795 def : Pat<(fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin),
796 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
798 def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
799 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
800 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
801 [(set DPR:$Dd, (fsub (fmul DPR:$Dn, DPR:$Dm),
803 RegConstraint<"$Ddin = $Dd">;
805 def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
806 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
807 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
808 [(set SPR:$Sd, (fsub (fmul SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>,
809 RegConstraint<"$Sdin = $Sd">;
811 def : Pat<(fsub (fmul DPR:$a, (f64 DPR:$b)), DPR:$dstin),
812 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
813 def : Pat<(fsub (fmul SPR:$a, SPR:$b), SPR:$dstin),
814 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
817 //===----------------------------------------------------------------------===//
818 // FP Conditional moves.
821 let neverHasSideEffects = 1 in {
822 def VMOVDcc : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
823 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
824 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm",
825 [/*(set DPR:$Dd, (ARMcmov DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
826 RegConstraint<"$Dn = $Dd">;
828 def VMOVScc : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
829 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
830 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm",
831 [/*(set SPR:$Sd, (ARMcmov SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
832 RegConstraint<"$Sn = $Sd">;
834 def VNEGDcc : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
835 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
836 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
837 [/*(set DPR:$Dd, (ARMcneg DPR:$Dn, DPR:$Dm, imm:$cc))*/]>,
838 RegConstraint<"$Dn = $Dd">;
840 def VNEGScc : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
841 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
842 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
843 [/*(set SPR:$Sd, (ARMcneg SPR:$Sn, SPR:$Sm, imm:$cc))*/]>,
844 RegConstraint<"$Sn = $Sd">;
845 } // neverHasSideEffects
847 //===----------------------------------------------------------------------===//
851 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
853 let Defs = [CPSR], Uses = [FPSCR] in
854 def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT,
855 "vmrs", "\tapsr_nzcv, fpscr",
857 let Inst{27-20} = 0b11101111;
858 let Inst{19-16} = 0b0001;
859 let Inst{15-12} = 0b1111;
860 let Inst{11-8} = 0b1010;
862 let Inst{6-5} = 0b00;
864 let Inst{3-0} = 0b0000;
868 let hasSideEffects = 1, Uses = [FPSCR] in
869 def VMRS : VFPAI<(outs GPR:$Rt), (ins), VFPMiscFrm, IIC_fpSTAT,
870 "vmrs", "\t$Rt, fpscr",
871 [(set GPR:$Rt, (int_arm_get_fpscr))]> {
872 // Instruction operand.
875 // Encode instruction operand.
876 let Inst{15-12} = Rt;
878 let Inst{27-20} = 0b11101111;
879 let Inst{19-16} = 0b0001;
880 let Inst{11-8} = 0b1010;
882 let Inst{6-5} = 0b00;
884 let Inst{3-0} = 0b0000;
887 let Defs = [FPSCR] in
888 def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT,
889 "vmsr", "\tfpscr, $src",
890 [(int_arm_set_fpscr GPR:$src)]> {
891 // Instruction operand.
894 // Encode instruction operand.
895 let Inst{15-12} = src;
897 let Inst{27-20} = 0b11101110;
898 let Inst{19-16} = 0b0001;
899 let Inst{11-8} = 0b1010;
904 // Materialize FP immediates. VFP3 only.
905 let isReMaterializable = 1 in {
906 def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm),
907 VFPMiscFrm, IIC_fpUNA64,
908 "vmov", ".f64\t$Dd, $imm",
909 [(set DPR:$Dd, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
910 // Instruction operands.
914 // Encode instruction operands.
915 let Inst{15-12} = Dd{3-0};
916 let Inst{22} = Dd{4};
917 let Inst{19} = imm{31};
918 let Inst{18-16} = imm{22-20};
919 let Inst{3-0} = imm{19-16};
921 // Encode remaining instruction bits.
922 let Inst{27-23} = 0b11101;
923 let Inst{21-20} = 0b11;
924 let Inst{11-9} = 0b101;
925 let Inst{8} = 1; // Double precision.
926 let Inst{7-4} = 0b0000;
929 def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm),
930 VFPMiscFrm, IIC_fpUNA32,
931 "vmov", ".f32\t$Sd, $imm",
932 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
933 // Instruction operands.
937 // Encode instruction operands.
938 let Inst{15-12} = Sd{4-1};
939 let Inst{22} = Sd{0};
940 let Inst{19} = imm{31}; // The immediate is handled as a double.
941 let Inst{18-16} = imm{22-20};
942 let Inst{3-0} = imm{19-16};
944 // Encode remaining instruction bits.
945 let Inst{27-23} = 0b11101;
946 let Inst{21-20} = 0b11;
947 let Inst{11-9} = 0b101;
948 let Inst{8} = 0; // Single precision.
949 let Inst{7-4} = 0b0000;