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 opc, string asm, list<dag> pattern>
20 : AI<ops, opc, asm, pattern> {
21 // TODO: Mark the instructions with the appropriate subtarget info.
24 class ASI5<dag ops, string opc, string asm, list<dag> pattern>
25 : I<ops, AddrMode5, Size4Bytes, IndexModeNone, opc, asm, "", pattern> {
26 // TODO: Mark the instructions with the appropriate subtarget info.
29 // ARM Double Instruction
30 class ADI<dag ops, string opc, string asm, list<dag> pattern>
31 : AI<ops, opc, asm, pattern> {
32 // TODO: Mark the instructions with the appropriate subtarget info.
35 class ADI5<dag ops, string opc, string asm, list<dag> pattern>
36 : I<ops, AddrMode5, Size4Bytes, IndexModeNone, opc, asm, "", pattern> {
37 // TODO: Mark the instructions with the appropriate subtarget info.
41 class AXSI<dag ops, string asm, list<dag> pattern>
42 : XI<ops, AddrModeNone, Size4Bytes, IndexModeNone, asm, "", pattern> {
43 // TODO: Mark the instructions with the appropriate subtarget info.
46 class AXSI5<dag ops, string asm, list<dag> pattern>
47 : XI<ops, AddrMode5, Size4Bytes, IndexModeNone, asm, "", pattern> {
48 // TODO: Mark the instructions with the appropriate subtarget info.
51 class AXDI<dag ops, string asm, list<dag> pattern>
52 : XI<ops, AddrModeNone, Size4Bytes, IndexModeNone, asm, "", pattern> {
53 // TODO: Mark the instructions with the appropriate subtarget info.
56 class AXDI5<dag ops, string asm, list<dag> pattern>
57 : XI<ops, AddrMode5, Size4Bytes, IndexModeNone, asm, "", pattern> {
58 // TODO: Mark the instructions with the appropriate subtarget info.
63 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
65 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
67 SDTypeProfile<0, 1, [SDTCisFP<0>]>;
69 SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
72 def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
73 def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
74 def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
75 def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
76 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTRet, [SDNPInFlag,SDNPOutFlag]>;
77 def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
78 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutFlag]>;
79 def arm_fmdrr : SDNode<"ARMISD::FMDRR", SDT_FMDRR>;
81 //===----------------------------------------------------------------------===//
82 // Load / store Instructions.
86 def FLDD : ADI5<(ops DPR:$dst, addrmode5:$addr),
87 "fldd", " $dst, $addr",
88 [(set DPR:$dst, (load addrmode5:$addr))]>;
90 def FLDS : ASI5<(ops SPR:$dst, addrmode5:$addr),
91 "flds", " $dst, $addr",
92 [(set SPR:$dst, (load addrmode5:$addr))]>;
96 def FSTD : ADI5<(ops DPR:$src, addrmode5:$addr),
97 "fstd", " $src, $addr",
98 [(store DPR:$src, addrmode5:$addr)]>;
100 def FSTS : ASI5<(ops SPR:$src, addrmode5:$addr),
101 "fsts", " $src, $addr",
102 [(store SPR:$src, addrmode5:$addr)]>;
105 //===----------------------------------------------------------------------===//
106 // Load / store multiple Instructions.
110 def FLDMD : AXDI5<(ops addrmode5:$addr, pred:$p, reglist:$dst1, variable_ops),
111 "fldm${addr:submode}d${p} ${addr:base}, $dst1",
114 def FLDMS : AXSI5<(ops addrmode5:$addr, pred:$p, reglist:$dst1, variable_ops),
115 "fldm${addr:submode}s${p} ${addr:base}, $dst1",
120 def FSTMD : AXDI5<(ops addrmode5:$addr, pred:$p, reglist:$src1, variable_ops),
121 "fstm${addr:submode}d${p} ${addr:base}, $src1",
124 def FSTMS : AXSI5<(ops addrmode5:$addr, pred:$p, reglist:$src1, variable_ops),
125 "fstm${addr:submode}s${p} ${addr:base}, $src1",
129 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
131 //===----------------------------------------------------------------------===//
132 // FP Binary Operations.
135 def FADDD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
136 "faddd", " $dst, $a, $b",
137 [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>;
139 def FADDS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
140 "fadds", " $dst, $a, $b",
141 [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>;
143 def FCMPED : ADI<(ops DPR:$a, DPR:$b),
145 [(arm_cmpfp DPR:$a, DPR:$b)]>;
147 def FCMPES : ASI<(ops SPR:$a, SPR:$b),
149 [(arm_cmpfp SPR:$a, SPR:$b)]>;
151 def FDIVD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
152 "fdivd", " $dst, $a, $b",
153 [(set DPR:$dst, (fdiv DPR:$a, DPR:$b))]>;
155 def FDIVS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
156 "fdivs", " $dst, $a, $b",
157 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
159 def FMULD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
160 "fmuld", " $dst, $a, $b",
161 [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>;
163 def FMULS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
164 "fmuls", " $dst, $a, $b",
165 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
167 def FNMULD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
168 "fnmuld", " $dst, $a, $b",
169 [(set DPR:$dst, (fneg (fmul DPR:$a, DPR:$b)))]>;
171 def FNMULS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
172 "fnmuls", " $dst, $a, $b",
173 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
175 // Match reassociated forms only if not sign dependent rounding.
176 def : Pat<(fmul (fneg DPR:$a), DPR:$b),
177 (FNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
178 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
179 (FNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
182 def FSUBD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
183 "fsubd", " $dst, $a, $b",
184 [(set DPR:$dst, (fsub DPR:$a, DPR:$b))]>;
186 def FSUBS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
187 "fsubs", " $dst, $a, $b",
188 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
190 //===----------------------------------------------------------------------===//
191 // FP Unary Operations.
194 def FABSD : ADI<(ops DPR:$dst, DPR:$a),
195 "fabsd", " $dst, $a",
196 [(set DPR:$dst, (fabs DPR:$a))]>;
198 def FABSS : ASI<(ops SPR:$dst, SPR:$a),
199 "fabss", " $dst, $a",
200 [(set SPR:$dst, (fabs SPR:$a))]>;
202 def FCMPEZD : ADI<(ops DPR:$a),
204 [(arm_cmpfp0 DPR:$a)]>;
206 def FCMPEZS : ASI<(ops SPR:$a),
208 [(arm_cmpfp0 SPR:$a)]>;
210 def FCVTDS : ADI<(ops DPR:$dst, SPR:$a),
211 "fcvtds", " $dst, $a",
212 [(set DPR:$dst, (fextend SPR:$a))]>;
214 def FCVTSD : ADI<(ops SPR:$dst, DPR:$a),
215 "fcvtsd", " $dst, $a",
216 [(set SPR:$dst, (fround DPR:$a))]>;
218 def FCPYD : ADI<(ops DPR:$dst, DPR:$a),
219 "fcpyd", " $dst, $a",
220 [/*(set DPR:$dst, DPR:$a)*/]>;
222 def FCPYS : ASI<(ops SPR:$dst, SPR:$a),
223 "fcpys", " $dst, $a",
224 [/*(set SPR:$dst, SPR:$a)*/]>;
226 def FNEGD : ADI<(ops DPR:$dst, DPR:$a),
227 "fnegd", " $dst, $a",
228 [(set DPR:$dst, (fneg DPR:$a))]>;
230 def FNEGS : ASI<(ops SPR:$dst, SPR:$a),
231 "fnegs", " $dst, $a",
232 [(set SPR:$dst, (fneg SPR:$a))]>;
234 def FSQRTD : ADI<(ops DPR:$dst, DPR:$a),
235 "fsqrtd", " $dst, $a",
236 [(set DPR:$dst, (fsqrt DPR:$a))]>;
238 def FSQRTS : ASI<(ops SPR:$dst, SPR:$a),
239 "fsqrts", " $dst, $a",
240 [(set SPR:$dst, (fsqrt SPR:$a))]>;
242 //===----------------------------------------------------------------------===//
243 // FP <-> GPR Copies. Int <-> FP Conversions.
246 def IMPLICIT_DEF_SPR : PseudoInst<(ops SPR:$rD, pred:$p),
247 "@ IMPLICIT_DEF_SPR $rD",
248 [(set SPR:$rD, (undef))]>;
249 def IMPLICIT_DEF_DPR : PseudoInst<(ops DPR:$rD, pred:$p),
250 "@ IMPLICIT_DEF_DPR $rD",
251 [(set DPR:$rD, (undef))]>;
253 def FMRS : ASI<(ops GPR:$dst, SPR:$src),
254 "fmrs", " $dst, $src",
255 [(set GPR:$dst, (bitconvert SPR:$src))]>;
257 def FMSR : ASI<(ops SPR:$dst, GPR:$src),
258 "fmsr", " $dst, $src",
259 [(set SPR:$dst, (bitconvert GPR:$src))]>;
262 def FMRRD : ADI<(ops GPR:$dst1, GPR:$dst2, DPR:$src),
263 "fmrrd", " $dst1, $dst2, $src",
264 [/* FIXME: Can't write pattern for multiple result instr*/]>;
269 def FMDRR : ADI<(ops DPR:$dst, GPR:$src1, GPR:$src2),
270 "fmdrr", " $dst, $src1, $src2",
271 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]>;
276 // FMRX : SPR system reg -> GPR
280 let clobbersPred = 1 in
281 def FMSTAT : ASI<(ops), "fmstat", "", [(arm_fmstat)]>;
283 // FMXR: GPR -> VFP Sstem reg
288 def FSITOD : ADI<(ops DPR:$dst, SPR:$a),
289 "fsitod", " $dst, $a",
290 [(set DPR:$dst, (arm_sitof SPR:$a))]>;
292 def FSITOS : ASI<(ops SPR:$dst, SPR:$a),
293 "fsitos", " $dst, $a",
294 [(set SPR:$dst, (arm_sitof SPR:$a))]>;
296 def FUITOD : ADI<(ops DPR:$dst, SPR:$a),
297 "fuitod", " $dst, $a",
298 [(set DPR:$dst, (arm_uitof SPR:$a))]>;
300 def FUITOS : ASI<(ops SPR:$dst, SPR:$a),
301 "fuitos", " $dst, $a",
302 [(set SPR:$dst, (arm_uitof SPR:$a))]>;
305 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
307 def FTOSIZD : ADI<(ops SPR:$dst, DPR:$a),
308 "ftosizd", " $dst, $a",
309 [(set SPR:$dst, (arm_ftosi DPR:$a))]>;
311 def FTOSIZS : ASI<(ops SPR:$dst, SPR:$a),
312 "ftosizs", " $dst, $a",
313 [(set SPR:$dst, (arm_ftosi SPR:$a))]>;
315 def FTOUIZD : ADI<(ops SPR:$dst, DPR:$a),
316 "ftouizd", " $dst, $a",
317 [(set SPR:$dst, (arm_ftoui DPR:$a))]>;
319 def FTOUIZS : ASI<(ops SPR:$dst, SPR:$a),
320 "ftouizs", " $dst, $a",
321 [(set SPR:$dst, (arm_ftoui SPR:$a))]>;
323 //===----------------------------------------------------------------------===//
324 // FP FMA Operations.
327 def FMACD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
328 "fmacd", " $dst, $a, $b",
329 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
330 RegConstraint<"$dstin = $dst">;
332 def FMACS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
333 "fmacs", " $dst, $a, $b",
334 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
335 RegConstraint<"$dstin = $dst">;
337 def FMSCD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
338 "fmscd", " $dst, $a, $b",
339 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
340 RegConstraint<"$dstin = $dst">;
342 def FMSCS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
343 "fmscs", " $dst, $a, $b",
344 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
345 RegConstraint<"$dstin = $dst">;
347 def FNMACD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
348 "fnmacd", " $dst, $a, $b",
349 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
350 RegConstraint<"$dstin = $dst">;
352 def FNMACS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
353 "fnmacs", " $dst, $a, $b",
354 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
355 RegConstraint<"$dstin = $dst">;
357 def FNMSCD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
358 "fnmscd", " $dst, $a, $b",
359 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
360 RegConstraint<"$dstin = $dst">;
362 def FNMSCS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
363 "fnmscs", " $dst, $a, $b",
364 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
365 RegConstraint<"$dstin = $dst">;
367 //===----------------------------------------------------------------------===//
368 // FP Conditional moves.
371 def FCPYDcc : AXDI<(ops DPR:$dst, DPR:$false, DPR:$true, ccop:$cc),
372 "fcpyd$cc $dst, $true",
373 [(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))]>,
374 RegConstraint<"$false = $dst">;
376 def FCPYScc : AXSI<(ops SPR:$dst, SPR:$false, SPR:$true, ccop:$cc),
377 "fcpys$cc $dst, $true",
378 [(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))]>,
379 RegConstraint<"$false = $dst">;
381 def FNEGDcc : AXDI<(ops DPR:$dst, DPR:$false, DPR:$true, ccop:$cc),
382 "fnegd$cc $dst, $true",
383 [(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))]>,
384 RegConstraint<"$false = $dst">;
386 def FNEGScc : AXSI<(ops SPR:$dst, SPR:$false, SPR:$true, ccop:$cc),
387 "fnegs$cc $dst, $true",
388 [(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))]>,
389 RegConstraint<"$false = $dst">;