7e6c4d2a247061a354a6bc6507ac2864416a4a17
[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 VFP 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<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<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<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<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<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<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<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<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", SDTNone, [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 isSimpleLoad = 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 } // isSimpleLoad
100
101 def FSTD  : ADI5<(outs), (ins DPR:$src, addrmode5:$addr),
102                  "fstd", " $src, $addr",
103                  [(store DPR:$src, addrmode5:$addr)]>;
104
105 def FSTS  : ASI5<(outs), (ins SPR:$src, addrmode5:$addr),
106                  "fsts", " $src, $addr",
107                  [(store SPR:$src, addrmode5:$addr)]>;
108
109 //===----------------------------------------------------------------------===//
110 //  Load / store multiple Instructions.
111 //
112
113 let mayLoad = 1 in {
114 def FLDMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$dst1,
115                            variable_ops),
116                   "fldm${addr:submode}d${p} ${addr:base}, $dst1",
117                   []>;
118
119 def FLDMS : AXSI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$dst1,
120                            variable_ops),
121                   "fldm${addr:submode}s${p} ${addr:base}, $dst1",
122                   []>;
123 }
124
125 let mayStore = 1 in {
126 def FSTMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$src1,
127                            variable_ops),
128                  "fstm${addr:submode}d${p} ${addr:base}, $src1",
129                  []>;
130
131 def FSTMS : AXSI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$src1,
132                            variable_ops),
133                  "fstm${addr:submode}s${p} ${addr:base}, $src1",
134                  []>;
135 } // mayStore
136
137 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
138
139 //===----------------------------------------------------------------------===//
140 // FP Binary Operations.
141 //
142
143 def FADDD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
144                  "faddd", " $dst, $a, $b",
145                  [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>;
146
147 def FADDS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
148                  "fadds", " $dst, $a, $b",
149                  [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>;
150
151 def FCMPED : ADI<(outs), (ins DPR:$a, DPR:$b),
152                  "fcmped", " $a, $b",
153                  [(arm_cmpfp DPR:$a, DPR:$b)]>;
154
155 def FCMPES : ASI<(outs), (ins SPR:$a, SPR:$b),
156                  "fcmpes", " $a, $b",
157                  [(arm_cmpfp SPR:$a, SPR:$b)]>;
158
159 def FDIVD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
160                  "fdivd", " $dst, $a, $b",
161                  [(set DPR:$dst, (fdiv DPR:$a, DPR:$b))]>;
162
163 def FDIVS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
164                  "fdivs", " $dst, $a, $b",
165                  [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;
166
167 def FMULD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
168                  "fmuld", " $dst, $a, $b",
169                  [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>;
170
171 def FMULS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
172                  "fmuls", " $dst, $a, $b",
173                  [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
174                  
175 def FNMULD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
176                   "fnmuld", " $dst, $a, $b",
177                   [(set DPR:$dst, (fneg (fmul DPR:$a, DPR:$b)))]>;
178
179 def FNMULS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
180                   "fnmuls", " $dst, $a, $b",
181                   [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;
182
183 // Match reassociated forms only if not sign dependent rounding.
184 def : Pat<(fmul (fneg DPR:$a), DPR:$b),
185           (FNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
186 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
187           (FNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
188
189
190 def FSUBD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
191                  "fsubd", " $dst, $a, $b",
192                  [(set DPR:$dst, (fsub DPR:$a, DPR:$b))]>;
193
194 def FSUBS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
195                  "fsubs", " $dst, $a, $b",
196                  [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;
197
198 //===----------------------------------------------------------------------===//
199 // FP Unary Operations.
200 //
201
202 def FABSD  : ADI<(outs DPR:$dst), (ins DPR:$a),
203                  "fabsd", " $dst, $a",
204                  [(set DPR:$dst, (fabs DPR:$a))]>;
205
206 def FABSS  : ASI<(outs SPR:$dst), (ins SPR:$a),
207                  "fabss", " $dst, $a",
208                  [(set SPR:$dst, (fabs SPR:$a))]>;
209
210 def FCMPEZD : ADI<(outs), (ins DPR:$a),
211                   "fcmpezd", " $a",
212                   [(arm_cmpfp0 DPR:$a)]>;
213
214 def FCMPEZS : ASI<(outs), (ins SPR:$a),
215                   "fcmpezs", " $a",
216                   [(arm_cmpfp0 SPR:$a)]>;
217
218 def FCVTDS : ADI<(outs DPR:$dst), (ins SPR:$a),
219                  "fcvtds", " $dst, $a",
220                  [(set DPR:$dst, (fextend SPR:$a))]>;
221
222 def FCVTSD : ADI<(outs SPR:$dst), (ins DPR:$a),
223                  "fcvtsd", " $dst, $a",
224                  [(set SPR:$dst, (fround DPR:$a))]>;
225
226 def FCPYD  : ADI<(outs DPR:$dst), (ins DPR:$a),
227                  "fcpyd", " $dst, $a", []>;
228
229 def FCPYS  : ASI<(outs SPR:$dst), (ins SPR:$a),
230                  "fcpys", " $dst, $a", []>;
231
232 def FNEGD  : ADI<(outs DPR:$dst), (ins DPR:$a),
233                  "fnegd", " $dst, $a",
234                  [(set DPR:$dst, (fneg DPR:$a))]>;
235
236 def FNEGS  : ASI<(outs SPR:$dst), (ins SPR:$a),
237                  "fnegs", " $dst, $a",
238                  [(set SPR:$dst, (fneg SPR:$a))]>;
239
240 def FSQRTD  : ADI<(outs DPR:$dst), (ins DPR:$a),
241                  "fsqrtd", " $dst, $a",
242                  [(set DPR:$dst, (fsqrt DPR:$a))]>;
243
244 def FSQRTS  : ASI<(outs SPR:$dst), (ins SPR:$a),
245                  "fsqrts", " $dst, $a",
246                  [(set SPR:$dst, (fsqrt SPR:$a))]>;
247
248 //===----------------------------------------------------------------------===//
249 // FP <-> GPR Copies.  Int <-> FP Conversions.
250 //
251
252 def FMRS   : ASI<(outs GPR:$dst), (ins SPR:$src),
253                  "fmrs", " $dst, $src",
254                  [(set GPR:$dst, (bitconvert SPR:$src))]>;
255
256 def FMSR   : ASI<(outs SPR:$dst), (ins GPR:$src),
257                  "fmsr", " $dst, $src",
258                  [(set SPR:$dst, (bitconvert GPR:$src))]>;
259
260
261 def FMRRD  : ADI<(outs GPR:$dst1, GPR:$dst2), (ins DPR:$src),
262                  "fmrrd", " $dst1, $dst2, $src",
263                  [/* FIXME: Can't write pattern for multiple result instr*/]>;
264
265 // FMDHR: GPR -> SPR
266 // FMDLR: GPR -> SPR
267
268 def FMDRR : ADI<(outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
269                 "fmdrr", " $dst, $src1, $src2",
270                 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]>;
271
272 // FMRDH: SPR -> GPR
273 // FMRDL: SPR -> GPR
274 // FMRRS: SPR -> GPR
275 // FMRX : SPR system reg -> GPR
276
277 // FMSRR: GPR -> SPR
278
279 let Defs = [CPSR] in
280 def FMSTAT : ASI<(outs), (ins), "fmstat", "", [(arm_fmstat)]>;
281
282 // FMXR: GPR -> VFP Sstem reg
283
284
285 // Int to FP:
286
287 def FSITOD : ADI<(outs DPR:$dst), (ins SPR:$a),
288                  "fsitod", " $dst, $a",
289                  [(set DPR:$dst, (arm_sitof SPR:$a))]>;
290
291 def FSITOS : ASI<(outs SPR:$dst), (ins SPR:$a),
292                  "fsitos", " $dst, $a",
293                  [(set SPR:$dst, (arm_sitof SPR:$a))]>;
294
295 def FUITOD : ADI<(outs DPR:$dst), (ins SPR:$a),
296                  "fuitod", " $dst, $a",
297                  [(set DPR:$dst, (arm_uitof SPR:$a))]>;
298
299 def FUITOS : ASI<(outs SPR:$dst), (ins SPR:$a),
300                  "fuitos", " $dst, $a",
301                  [(set SPR:$dst, (arm_uitof SPR:$a))]>;
302
303 // FP to Int:
304 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
305
306 def FTOSIZD : ADI<(outs SPR:$dst), (ins DPR:$a),
307                  "ftosizd", " $dst, $a",
308                  [(set SPR:$dst, (arm_ftosi DPR:$a))]>;
309
310 def FTOSIZS : ASI<(outs SPR:$dst), (ins SPR:$a),
311                  "ftosizs", " $dst, $a",
312                  [(set SPR:$dst, (arm_ftosi SPR:$a))]>;
313
314 def FTOUIZD : ADI<(outs SPR:$dst), (ins DPR:$a),
315                  "ftouizd", " $dst, $a",
316                  [(set SPR:$dst, (arm_ftoui DPR:$a))]>;
317
318 def FTOUIZS : ASI<(outs SPR:$dst), (ins SPR:$a),
319                  "ftouizs", " $dst, $a",
320                  [(set SPR:$dst, (arm_ftoui SPR:$a))]>;
321
322 //===----------------------------------------------------------------------===//
323 // FP FMA Operations.
324 //
325
326 def FMACD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
327                 "fmacd", " $dst, $a, $b",
328                 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
329                 RegConstraint<"$dstin = $dst">;
330
331 def FMACS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
332                 "fmacs", " $dst, $a, $b",
333                 [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
334                 RegConstraint<"$dstin = $dst">;
335
336 def FMSCD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
337                 "fmscd", " $dst, $a, $b",
338                 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
339                 RegConstraint<"$dstin = $dst">;
340
341 def FMSCS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
342                 "fmscs", " $dst, $a, $b",
343                 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
344                 RegConstraint<"$dstin = $dst">;
345
346 def FNMACD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
347                  "fnmacd", " $dst, $a, $b",
348              [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
349                 RegConstraint<"$dstin = $dst">;
350
351 def FNMACS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
352                 "fnmacs", " $dst, $a, $b",
353              [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
354                 RegConstraint<"$dstin = $dst">;
355
356 def FNMSCD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
357                  "fnmscd", " $dst, $a, $b",
358              [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
359                 RegConstraint<"$dstin = $dst">;
360
361 def FNMSCS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
362                 "fnmscs", " $dst, $a, $b",
363              [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
364                 RegConstraint<"$dstin = $dst">;
365
366 //===----------------------------------------------------------------------===//
367 // FP Conditional moves.
368 //
369
370 def FCPYDcc  : ADI<(outs DPR:$dst), (ins DPR:$false, DPR:$true),
371                     "fcpyd", " $dst, $true",
372                 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
373                     RegConstraint<"$false = $dst">;
374
375 def FCPYScc  : ASI<(outs SPR:$dst), (ins SPR:$false, SPR:$true),
376                     "fcpys", " $dst, $true",
377                 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
378                     RegConstraint<"$false = $dst">;
379
380 def FNEGDcc  : ADI<(outs DPR:$dst), (ins DPR:$false, DPR:$true),
381                     "fnegd", " $dst, $true",
382                 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
383                     RegConstraint<"$false = $dst">;
384
385 def FNEGScc  : ASI<(outs SPR:$dst), (ins SPR:$false, SPR:$true),
386                     "fnegs", " $dst, $true",
387                 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
388                     RegConstraint<"$false = $dst">;