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