blob: 4bb9f0462e945b732d97a7565b4e4c927748332b [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- ARMInstrVFP.td - VFP support for ARM -------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
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.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the ARM VP instruction set.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// ARM VFP Instruction templates.
16//
17
18// ARM Float Instruction
19class 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.
22}
23
24class 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.
27}
28
29// ARM Double Instruction
30class 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.
33}
34
35class 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.
38}
39
40// Special cases.
41class 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.
44}
45
46class 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.
49}
50
51class 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.
54}
55
56class 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.
59}
60
61
62def SDT_FTOI :
63SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
64def SDT_ITOF :
65SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
66def SDT_CMPFP0 :
67SDTypeProfile<0, 1, [SDTCisFP<0>]>;
68def SDT_FMDRR :
69SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
70 SDTCisSameAs<1, 2>]>;
71
72def arm_ftoui : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
73def arm_ftosi : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
74def arm_sitof : SDNode<"ARMISD::SITOF", SDT_ITOF>;
75def arm_uitof : SDNode<"ARMISD::UITOF", SDT_ITOF>;
76def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTRet, [SDNPInFlag,SDNPOutFlag]>;
77def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
78def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutFlag]>;
79def arm_fmdrr : SDNode<"ARMISD::FMDRR", SDT_FMDRR>;
80
81//===----------------------------------------------------------------------===//
82// Load / store Instructions.
83//
84
85let isLoad = 1 in {
86def FLDD : ADI5<(ops DPR:$dst, addrmode5:$addr),
87 "fldd", " $dst, $addr",
88 [(set DPR:$dst, (load addrmode5:$addr))]>;
89
90def FLDS : ASI5<(ops SPR:$dst, addrmode5:$addr),
91 "flds", " $dst, $addr",
92 [(set SPR:$dst, (load addrmode5:$addr))]>;
93} // isLoad
94
95let isStore = 1 in {
96def FSTD : ADI5<(ops DPR:$src, addrmode5:$addr),
97 "fstd", " $src, $addr",
98 [(store DPR:$src, addrmode5:$addr)]>;
99
100def FSTS : ASI5<(ops SPR:$src, addrmode5:$addr),
101 "fsts", " $src, $addr",
102 [(store SPR:$src, addrmode5:$addr)]>;
103} // isStore
104
105//===----------------------------------------------------------------------===//
106// Load / store multiple Instructions.
107//
108
109let isLoad = 1 in {
110def FLDMD : AXDI5<(ops addrmode5:$addr, pred:$p, reglist:$dst1, variable_ops),
111 "fldm${addr:submode}d${p} ${addr:base}, $dst1",
112 []>;
113
114def FLDMS : AXSI5<(ops addrmode5:$addr, pred:$p, reglist:$dst1, variable_ops),
115 "fldm${addr:submode}s${p} ${addr:base}, $dst1",
116 []>;
117} // isLoad
118
119let isStore = 1 in {
120def FSTMD : AXDI5<(ops addrmode5:$addr, pred:$p, reglist:$src1, variable_ops),
121 "fstm${addr:submode}d${p} ${addr:base}, $src1",
122 []>;
123
124def FSTMS : AXSI5<(ops addrmode5:$addr, pred:$p, reglist:$src1, variable_ops),
125 "fstm${addr:submode}s${p} ${addr:base}, $src1",
126 []>;
127} // isStore
128
129// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
130
131//===----------------------------------------------------------------------===//
132// FP Binary Operations.
133//
134
135def FADDD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
136 "faddd", " $dst, $a, $b",
137 [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>;
138
139def FADDS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
140 "fadds", " $dst, $a, $b",
141 [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>;
142
143def FCMPED : ADI<(ops DPR:$a, DPR:$b),
144 "fcmped", " $a, $b",
145 [(arm_cmpfp DPR:$a, DPR:$b)]>;
146
147def FCMPES : ASI<(ops SPR:$a, SPR:$b),
148 "fcmpes", " $a, $b",
149 [(arm_cmpfp SPR:$a, SPR:$b)]>;
150
151def FDIVD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
152 "fdivd", " $dst, $a, $b",
153 [(set DPR:$dst, (fdiv DPR:$a, DPR:$b))]>;
154
155def FDIVS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
156 "fdivs", " $dst, $a, $b",
157 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
158
159def FMULD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
160 "fmuld", " $dst, $a, $b",
161 [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>;
162
163def FMULS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
164 "fmuls", " $dst, $a, $b",
165 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
166
167def FNMULD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
168 "fnmuld", " $dst, $a, $b",
169 [(set DPR:$dst, (fneg (fmul DPR:$a, DPR:$b)))]>;
170
171def FNMULS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
172 "fnmuls", " $dst, $a, $b",
173 [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
174
175// Match reassociated forms only if not sign dependent rounding.
176def : Pat<(fmul (fneg DPR:$a), DPR:$b),
177 (FNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
178def : Pat<(fmul (fneg SPR:$a), SPR:$b),
179 (FNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
180
181
182def FSUBD : ADI<(ops DPR:$dst, DPR:$a, DPR:$b),
183 "fsubd", " $dst, $a, $b",
184 [(set DPR:$dst, (fsub DPR:$a, DPR:$b))]>;
185
186def FSUBS : ASI<(ops SPR:$dst, SPR:$a, SPR:$b),
187 "fsubs", " $dst, $a, $b",
188 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
189
190//===----------------------------------------------------------------------===//
191// FP Unary Operations.
192//
193
194def FABSD : ADI<(ops DPR:$dst, DPR:$a),
195 "fabsd", " $dst, $a",
196 [(set DPR:$dst, (fabs DPR:$a))]>;
197
198def FABSS : ASI<(ops SPR:$dst, SPR:$a),
199 "fabss", " $dst, $a",
200 [(set SPR:$dst, (fabs SPR:$a))]>;
201
202def FCMPEZD : ADI<(ops DPR:$a),
203 "fcmpezd", " $a",
204 [(arm_cmpfp0 DPR:$a)]>;
205
206def FCMPEZS : ASI<(ops SPR:$a),
207 "fcmpezs", " $a",
208 [(arm_cmpfp0 SPR:$a)]>;
209
210def FCVTDS : ADI<(ops DPR:$dst, SPR:$a),
211 "fcvtds", " $dst, $a",
212 [(set DPR:$dst, (fextend SPR:$a))]>;
213
214def FCVTSD : ADI<(ops SPR:$dst, DPR:$a),
215 "fcvtsd", " $dst, $a",
216 [(set SPR:$dst, (fround DPR:$a))]>;
217
218def FCPYD : ADI<(ops DPR:$dst, DPR:$a),
219 "fcpyd", " $dst, $a", []>;
220
221def FCPYS : ASI<(ops SPR:$dst, SPR:$a),
222 "fcpys", " $dst, $a", []>;
223
224def FNEGD : ADI<(ops DPR:$dst, DPR:$a),
225 "fnegd", " $dst, $a",
226 [(set DPR:$dst, (fneg DPR:$a))]>;
227
228def FNEGS : ASI<(ops SPR:$dst, SPR:$a),
229 "fnegs", " $dst, $a",
230 [(set SPR:$dst, (fneg SPR:$a))]>;
231
232def FSQRTD : ADI<(ops DPR:$dst, DPR:$a),
233 "fsqrtd", " $dst, $a",
234 [(set DPR:$dst, (fsqrt DPR:$a))]>;
235
236def FSQRTS : ASI<(ops SPR:$dst, SPR:$a),
237 "fsqrts", " $dst, $a",
238 [(set SPR:$dst, (fsqrt SPR:$a))]>;
239
240//===----------------------------------------------------------------------===//
241// FP <-> GPR Copies. Int <-> FP Conversions.
242//
243
244def IMPLICIT_DEF_SPR : PseudoInst<(ops SPR:$rD, pred:$p),
245 "@ IMPLICIT_DEF_SPR $rD",
246 [(set SPR:$rD, (undef))]>;
247def IMPLICIT_DEF_DPR : PseudoInst<(ops DPR:$rD, pred:$p),
248 "@ IMPLICIT_DEF_DPR $rD",
249 [(set DPR:$rD, (undef))]>;
250
251def FMRS : ASI<(ops GPR:$dst, SPR:$src),
252 "fmrs", " $dst, $src",
253 [(set GPR:$dst, (bitconvert SPR:$src))]>;
254
255def FMSR : ASI<(ops SPR:$dst, GPR:$src),
256 "fmsr", " $dst, $src",
257 [(set SPR:$dst, (bitconvert GPR:$src))]>;
258
259
260def FMRRD : ADI<(ops GPR:$dst1, GPR:$dst2, DPR:$src),
261 "fmrrd", " $dst1, $dst2, $src",
262 [/* FIXME: Can't write pattern for multiple result instr*/]>;
263
264// FMDHR: GPR -> SPR
265// FMDLR: GPR -> SPR
266
267def FMDRR : ADI<(ops DPR:$dst, GPR:$src1, GPR:$src2),
268 "fmdrr", " $dst, $src1, $src2",
269 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]>;
270
271// FMRDH: SPR -> GPR
272// FMRDL: SPR -> GPR
273// FMRRS: SPR -> GPR
274// FMRX : SPR system reg -> GPR
275
276// FMSRR: GPR -> SPR
277
278def FMSTAT : ASI<(ops), "fmstat", "", [(arm_fmstat)]>, Imp<[], [CPSR]>;
279
280// FMXR: GPR -> VFP Sstem reg
281
282
283// Int to FP:
284
285def FSITOD : ADI<(ops DPR:$dst, SPR:$a),
286 "fsitod", " $dst, $a",
287 [(set DPR:$dst, (arm_sitof SPR:$a))]>;
288
289def FSITOS : ASI<(ops SPR:$dst, SPR:$a),
290 "fsitos", " $dst, $a",
291 [(set SPR:$dst, (arm_sitof SPR:$a))]>;
292
293def FUITOD : ADI<(ops DPR:$dst, SPR:$a),
294 "fuitod", " $dst, $a",
295 [(set DPR:$dst, (arm_uitof SPR:$a))]>;
296
297def FUITOS : ASI<(ops SPR:$dst, SPR:$a),
298 "fuitos", " $dst, $a",
299 [(set SPR:$dst, (arm_uitof SPR:$a))]>;
300
301// FP to Int:
302// Always set Z bit in the instruction, i.e. "round towards zero" variants.
303
304def FTOSIZD : ADI<(ops SPR:$dst, DPR:$a),
305 "ftosizd", " $dst, $a",
306 [(set SPR:$dst, (arm_ftosi DPR:$a))]>;
307
308def FTOSIZS : ASI<(ops SPR:$dst, SPR:$a),
309 "ftosizs", " $dst, $a",
310 [(set SPR:$dst, (arm_ftosi SPR:$a))]>;
311
312def FTOUIZD : ADI<(ops SPR:$dst, DPR:$a),
313 "ftouizd", " $dst, $a",
314 [(set SPR:$dst, (arm_ftoui DPR:$a))]>;
315
316def FTOUIZS : ASI<(ops SPR:$dst, SPR:$a),
317 "ftouizs", " $dst, $a",
318 [(set SPR:$dst, (arm_ftoui SPR:$a))]>;
319
320//===----------------------------------------------------------------------===//
321// FP FMA Operations.
322//
323
324def FMACD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
325 "fmacd", " $dst, $a, $b",
326 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
327 RegConstraint<"$dstin = $dst">;
328
329def FMACS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
330 "fmacs", " $dst, $a, $b",
331 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
332 RegConstraint<"$dstin = $dst">;
333
334def FMSCD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
335 "fmscd", " $dst, $a, $b",
336 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
337 RegConstraint<"$dstin = $dst">;
338
339def FMSCS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
340 "fmscs", " $dst, $a, $b",
341 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
342 RegConstraint<"$dstin = $dst">;
343
344def FNMACD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
345 "fnmacd", " $dst, $a, $b",
346 [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
347 RegConstraint<"$dstin = $dst">;
348
349def FNMACS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
350 "fnmacs", " $dst, $a, $b",
351 [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
352 RegConstraint<"$dstin = $dst">;
353
354def FNMSCD : ADI<(ops DPR:$dst, DPR:$dstin, DPR:$a, DPR:$b),
355 "fnmscd", " $dst, $a, $b",
356 [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
357 RegConstraint<"$dstin = $dst">;
358
359def FNMSCS : ASI<(ops SPR:$dst, SPR:$dstin, SPR:$a, SPR:$b),
360 "fnmscs", " $dst, $a, $b",
361 [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
362 RegConstraint<"$dstin = $dst">;
363
364//===----------------------------------------------------------------------===//
365// FP Conditional moves.
366//
367
368def FCPYDcc : ADI<(ops DPR:$dst, DPR:$false, DPR:$true),
369 "fcpyd", " $dst, $true",
370 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
371 RegConstraint<"$false = $dst">;
372
373def FCPYScc : ASI<(ops SPR:$dst, SPR:$false, SPR:$true),
374 "fcpys", " $dst, $true",
375 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
376 RegConstraint<"$false = $dst">;
377
378def FNEGDcc : ADI<(ops DPR:$dst, DPR:$false, DPR:$true),
379 "fnegd", " $dst, $true",
380 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
381 RegConstraint<"$false = $dst">;
382
383def FNEGScc : ASI<(ops SPR:$dst, SPR:$false, SPR:$true),
384 "fnegs", " $dst, $true",
385 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
386 RegConstraint<"$false = $dst">;