1 //===- ARMInstrVFP.td - VFP support for ARM -------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM VP instruction set.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM VFP Instruction templates.
18 // ARM Float Instruction
19 class ASI<dag ops, string asm, list<dag> pattern> : AI<ops, asm, pattern> {
20 // TODO: Mark the instructions with the appropriate subtarget info.
23 class ASI5<dag ops, string asm, list<dag> pattern>
24 : I<ops, AddrMode5, Size4Bytes, IndexModeNone, asm, "", pattern> {
25 // TODO: Mark the instructions with the appropriate subtarget info.
28 // ARM Double Instruction
29 class ADI<dag ops, string asm, list<dag> pattern> : AI<ops, asm, pattern> {
30 // TODO: Mark the instructions with the appropriate subtarget info.
33 class ADI5<dag ops, string asm, list<dag> pattern>
34 : I<ops, AddrMode5, Size4Bytes, IndexModeNone, asm, "", pattern> {
35 // TODO: Mark the instructions with the appropriate subtarget info.
39 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
41 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
43 SDTypeProfile<0, 1, [SDTCisFP<0>]>;
45 SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
48 def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
49 def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
50 def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
51 def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
52 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTRet, [SDNPInFlag,SDNPOutFlag]>;
53 def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
54 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutFlag]>;
55 def arm_fmdrr : SDNode<"ARMISD::FMDRR", SDT_FMDRR>;
57 //===----------------------------------------------------------------------===//
58 // Load / store Instructions.
62 def FLDD : ADI5<(ops DPR:$dst, addrmode5:$addr),
64 [(set DPR:$dst, (load addrmode5:$addr))]>;
66 def FLDS : ASI5<(ops SPR:$dst, addrmode5:$addr),
68 [(set SPR:$dst, (load addrmode5:$addr))]>;
72 def FSTD : ADI5<(ops DPR:$src, addrmode5:$addr),
74 [(store DPR:$src, addrmode5:$addr)]>;
76 def FSTS : ASI5<(ops SPR:$src, addrmode5:$addr),
78 [(store SPR:$src, addrmode5:$addr)]>;
81 // avoid copying result of FTOUIZ to int reg when we're just storing it
82 let AddedComplexity = 1 in
83 def : ARMPat<(store (i32 (bitconvert SPR:$src)), addrmode5:$addr),
84 (FSTS SPR:$src, addrmode5:$addr)>;
86 //===----------------------------------------------------------------------===//
87 // Load / store multiple Instructions.
91 def FLDMD : ADI5<(ops addrmode5:$addr, reglist:$dst1, variable_ops),
92 "fldm${addr:submode}d ${addr:base}, $dst1",
95 def FLDMS : ASI5<(ops addrmode5:$addr, reglist:$dst1, variable_ops),
96 "fldm${addr:submode}s ${addr:base}, $dst1",
101 def FSTMD : ADI5<(ops addrmode5:$addr, reglist:$src1, variable_ops),
102 "fstm${addr:submode}d ${addr:base}, $src1",
105 def FSTMS : ASI5<(ops addrmode5:$addr, reglist:$src1, variable_ops),
106 "fstm${addr:submode}s ${addr:base}, $src1",
110 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
112 //===----------------------------------------------------------------------===//
113 // FP Binary Operations.
116 def FADDD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
117 "faddd $dst, $a, $b",
118 [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>;
120 def FADDS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
121 "fadds $dst, $a, $b",
122 [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>;
124 def FCMPED : ADI<(ops DPR:$a, DPR:$b),
126 [(arm_cmpfp DPR:$a, DPR:$b)]>;
128 def FCMPES : ASI<(ops SPR:$a, SPR:$b),
130 [(arm_cmpfp SPR:$a, SPR:$b)]>;
132 def FDIVD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
133 "fdivd $dst, $a, $b",
134 [(set DPR:$dst, (fdiv DPR:$a, DPR:$b))]>;
136 def FDIVS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
137 "fdivs $dst, $a, $b",
138 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
140 def FMULD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
141 "fmuld $dst, $a, $b",
142 [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>;
144 def FMULS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
145 "fmuls $dst, $a, $b",
146 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
148 def FNMULD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
149 "fnmuld $dst, $a, $b",
150 [(set DPR:$dst, (fneg (fmul DPR:$a, DPR:$b)))]>;
152 def FNMULS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
153 "fnmuls $dst, $a, $b",
154 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
156 // Match reassociated forms only if not sign dependent rounding.
157 def : Pat<(fmul (fneg DPR:$a), DPR:$b),
158 (FNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
159 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
160 (FNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
163 def FSUBD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
164 "fsubd $dst, $a, $b",
165 [(set DPR:$dst, (fsub DPR:$a, DPR:$b))]>;
167 def FSUBS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
168 "fsubs $dst, $a, $b",
169 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
171 //===----------------------------------------------------------------------===//
172 // FP Unary Operations.
175 def FABSD : ADI<(ops DPR:$dst, DPR:$a),
177 [(set DPR:$dst, (fabs DPR:$a))]>;
179 def FABSS : ASI<(ops SPR:$dst, SPR:$a),
181 [(set SPR:$dst, (fabs SPR:$a))]>;
183 def FCMPEZD : ADI<(ops DPR:$a),
185 [(arm_cmpfp0 DPR:$a)]>;
187 def FCMPEZS : ASI<(ops SPR:$a),
189 [(arm_cmpfp0 SPR:$a)]>;
191 def FCVTDS : ADI<(ops DPR:$dst, SPR:$a),
193 [(set DPR:$dst, (fextend SPR:$a))]>;
195 def FCVTSD : ADI<(ops SPR:$dst, DPR:$a),
197 [(set SPR:$dst, (fround DPR:$a))]>;
199 def FCPYD : ADI<(ops DPR:$dst, DPR:$a),
201 [/*(set DPR:$dst, DPR:$a)*/]>;
203 def FCPYS : ASI<(ops SPR:$dst, SPR:$a),
205 [/*(set SPR:$dst, SPR:$a)*/]>;
207 def FNEGD : ADI<(ops DPR:$dst, DPR:$a),
209 [(set DPR:$dst, (fneg DPR:$a))]>;
211 def FNEGS : ASI<(ops SPR:$dst, SPR:$a),
213 [(set SPR:$dst, (fneg SPR:$a))]>;
215 def FSQRTD : ADI<(ops DPR:$dst, DPR:$a),
217 [(set DPR:$dst, (fsqrt DPR:$a))]>;
219 def FSQRTS : ASI<(ops SPR:$dst, SPR:$a),
221 [(set SPR:$dst, (fsqrt SPR:$a))]>;
223 //===----------------------------------------------------------------------===//
224 // FP <-> GPR Copies. Int <-> FP Conversions.
227 def IMPLICIT_DEF_SPR : PseudoInst<(ops SPR:$rD),
228 "@ IMPLICIT_DEF_SPR $rD",
229 [(set SPR:$rD, (undef))]>;
230 def IMPLICIT_DEF_DPR : PseudoInst<(ops DPR:$rD),
231 "@ IMPLICIT_DEF_DPR $rD",
232 [(set DPR:$rD, (undef))]>;
234 def FMRS : ASI<(ops GPR:$dst, SPR:$src),
236 [(set GPR:$dst, (bitconvert SPR:$src))]>;
238 def FMSR : ASI<(ops SPR:$dst, GPR:$src),
240 [(set SPR:$dst, (bitconvert GPR:$src))]>;
243 def FMRRD : ADI<(ops GPR:$dst1, GPR:$dst2, DPR:$src),
244 "fmrrd $dst1, $dst2, $src",
245 [/* FIXME: Can't write pattern for multiple result instr*/]>;
250 def FMDRR : ADI<(ops DPR:$dst, GPR:$src1, GPR:$src2),
251 "fmdrr $dst, $src1, $src2",
252 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]>;
257 // FMRX : SPR system reg -> GPR
262 def FMSTAT : ASI<(ops), "fmstat", [(arm_fmstat)]>;
264 // FMXR: GPR -> VFP Sstem reg
269 def FSITOD : ADI<(ops DPR:$dst, SPR:$a),
271 [(set DPR:$dst, (arm_sitof SPR:$a))]>;
273 def FSITOS : ASI<(ops SPR:$dst, SPR:$a),
275 [(set SPR:$dst, (arm_sitof SPR:$a))]>;
277 def FUITOD : ADI<(ops DPR:$dst, SPR:$a),
279 [(set DPR:$dst, (arm_uitof SPR:$a))]>;
281 def FUITOS : ASI<(ops SPR:$dst, SPR:$a),
283 [(set SPR:$dst, (arm_uitof SPR:$a))]>;
286 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
288 def FTOSIZD : ADI<(ops SPR:$dst, DPR:$a),
290 [(set SPR:$dst, (arm_ftosi DPR:$a))]>;
292 def FTOSIZS : ASI<(ops SPR:$dst, SPR:$a),
294 [(set SPR:$dst, (arm_ftosi SPR:$a))]>;
296 def FTOUIZD : ADI<(ops SPR:$dst, DPR:$a),
298 [(set SPR:$dst, (arm_ftoui DPR:$a))]>;
300 def FTOUIZS : ASI<(ops SPR:$dst, SPR:$a),
302 [(set SPR:$dst, (arm_ftoui SPR:$a))]>;
304 //===----------------------------------------------------------------------===//
305 // FP FMA Operations.
308 def FMACD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
309 "fmacd $dst, $a, $b",
310 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
311 RegConstraint<"$dstin = $dst">;
313 def FMACS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
314 "fmacs $dst, $a, $b",
315 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
316 RegConstraint<"$dstin = $dst">;
318 def FMSCD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
319 "fmscd $dst, $a, $b",
320 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
321 RegConstraint<"$dstin = $dst">;
323 def FMSCS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
324 "fmscs $dst, $a, $b",
325 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
326 RegConstraint<"$dstin = $dst">;
328 def FNMACD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
329 "fnmacd $dst, $a, $b",
330 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
331 RegConstraint<"$dstin = $dst">;
333 def FNMACS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
334 "fnmacs $dst, $a, $b",
335 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
336 RegConstraint<"$dstin = $dst">;
338 def FNMSCD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
339 "fnmscd $dst, $a, $b",
340 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
341 RegConstraint<"$dstin = $dst">;
343 def FNMSCS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
344 "fnmscs $dst, $a, $b",
345 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
346 RegConstraint<"$dstin = $dst">;
348 //===----------------------------------------------------------------------===//
349 // FP Conditional moves.
352 def FCPYDcc : ADI<(ops DPR:$dst, DPR:$false, DPR:$true, CCOp:$cc),
353 "fcpyd$cc $dst, $true",
354 [(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))]>,
355 RegConstraint<"$false = $dst">;
357 def FCPYScc : ASI<(ops SPR:$dst, SPR:$false, SPR:$true, CCOp:$cc),
358 "fcpys$cc $dst, $true",
359 [(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))]>,
360 RegConstraint<"$false = $dst">;
362 def FNEGDcc : ADI<(ops DPR:$dst, DPR:$false, DPR:$true, CCOp:$cc),
363 "fnegd$cc $dst, $true",
364 [(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))]>,
365 RegConstraint<"$false = $dst">;
367 def FNEGScc : ASI<(ops SPR:$dst, SPR:$false, SPR:$true, CCOp:$cc),
368 "fnegs$cc $dst, $true",
369 [(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))]>,
370 RegConstraint<"$false = $dst">;