aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/ARM/ARMInstrVFP.td
blob: b3fe2fff9728e95fd840ffe43388722611b83643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
//===- ARMInstrVFP.td - VFP support for ARM -------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file describes the ARM VP instruction set.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// ARM VFP Instruction templates.
//

// ARM Float Instruction
class ASI<dag outs, dag ins, string opc, string asm, list<dag> pattern>
  : AI<0x0, outs, ins, VFPFrm, opc, asm, pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

class ASI5<dag outs, dag ins, string opc, string asm, list<dag> pattern>
  : I<0x0, outs, ins, AddrMode5, Size4Bytes, IndexModeNone,
      VFPFrm, opc, asm, "", pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

// ARM Double Instruction
class ADI<dag outs, dag ins, string opc, string asm, list<dag> pattern>
  : AI<0x0, outs, ins, VFPFrm, opc, asm, pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

class ADI5<dag outs, dag ins, string opc, string asm, list<dag> pattern>
  : I<0x0, outs, ins, AddrMode5, Size4Bytes, IndexModeNone,
      VFPFrm, opc, asm, "", pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

// Special cases.
class AXSI<dag outs, dag ins, string asm, list<dag> pattern>
  : XI<0x0, outs, ins, AddrModeNone, Size4Bytes, IndexModeNone,
       VFPFrm, asm, "", pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

class AXSI5<dag outs, dag ins, string asm, list<dag> pattern>
  : XI<0x0, outs, ins, AddrMode5, Size4Bytes, IndexModeNone,
       VFPFrm, asm, "", pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

class AXDI<dag outs, dag ins, string asm, list<dag> pattern>
  : XI<0x0, outs, ins, AddrModeNone, Size4Bytes, IndexModeNone,
       VFPFrm, asm, "", pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}

class AXDI5<dag outs, dag ins, string asm, list<dag> pattern>
  : XI<0x0, outs, ins, AddrMode5, Size4Bytes, IndexModeNone,
       VFPFrm, asm, "", pattern> {
  // TODO: Mark the instructions with the appropriate subtarget info.
}


def SDT_FTOI :
SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
def SDT_ITOF :
SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
def SDT_CMPFP0 :
SDTypeProfile<0, 1, [SDTCisFP<0>]>;
def SDT_FMDRR :
SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
                     SDTCisSameAs<1, 2>]>;

def arm_ftoui  : SDNode<"ARMISD::FTOUI", SDT_FTOI>;
def arm_ftosi  : SDNode<"ARMISD::FTOSI", SDT_FTOI>;
def arm_sitof  : SDNode<"ARMISD::SITOF", SDT_ITOF>;
def arm_uitof  : SDNode<"ARMISD::UITOF", SDT_ITOF>;
def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTRet, [SDNPInFlag,SDNPOutFlag]>;
def arm_cmpfp  : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutFlag]>;
def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutFlag]>;
def arm_fmdrr  : SDNode<"ARMISD::FMDRR", SDT_FMDRR>;

//===----------------------------------------------------------------------===//
//  Load / store Instructions.
//

let isLoad = 1 in {
def FLDD  : ADI5<(outs DPR:$dst), (ins addrmode5:$addr),
                 "fldd", " $dst, $addr",
                 [(set DPR:$dst, (load addrmode5:$addr))]>;

def FLDS  : ASI5<(outs SPR:$dst), (ins addrmode5:$addr),
                 "flds", " $dst, $addr",
                 [(set SPR:$dst, (load addrmode5:$addr))]>;
} // isLoad

let isStore = 1 in {
def FSTD  : ADI5<(outs), (ins DPR:$src, addrmode5:$addr),
                 "fstd", " $src, $addr",
                 [(store DPR:$src, addrmode5:$addr)]>;

def FSTS  : ASI5<(outs), (ins SPR:$src, addrmode5:$addr),
                 "fsts", " $src, $addr",
                 [(store SPR:$src, addrmode5:$addr)]>;
} // isStore

//===----------------------------------------------------------------------===//
//  Load / store multiple Instructions.
//

let isLoad = 1 in {
def FLDMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$dst1,
                           variable_ops),
                  "fldm${addr:submode}d${p} ${addr:base}, $dst1",
                  []>;

def FLDMS : AXSI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$dst1,
                           variable_ops),
                  "fldm${addr:submode}s${p} ${addr:base}, $dst1",
                  []>;
} // isLoad

let isStore = 1 in {
def FSTMD : AXDI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$src1,
                           variable_ops),
                 "fstm${addr:submode}d${p} ${addr:base}, $src1",
                 []>;

def FSTMS : AXSI5<(outs), (ins addrmode5:$addr, pred:$p, reglist:$src1,
                           variable_ops),
                 "fstm${addr:submode}s${p} ${addr:base}, $src1",
                 []>;
} // isStore

// FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores

//===----------------------------------------------------------------------===//
// FP Binary Operations.
//

def FADDD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
                 "faddd", " $dst, $a, $b",
                 [(set DPR:$dst, (fadd DPR:$a, DPR:$b))]>;

def FADDS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
                 "fadds", " $dst, $a, $b",
                 [(set SPR:$dst, (fadd SPR:$a, SPR:$b))]>;

def FCMPED : ADI<(outs), (ins DPR:$a, DPR:$b),
                 "fcmped", " $a, $b",
                 [(arm_cmpfp DPR:$a, DPR:$b)]>;

def FCMPES : ASI<(outs), (ins SPR:$a, SPR:$b),
                 "fcmpes", " $a, $b",
                 [(arm_cmpfp SPR:$a, SPR:$b)]>;

def FDIVD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
                 "fdivd", " $dst, $a, $b",
                 [(set DPR:$dst, (fdiv DPR:$a, DPR:$b))]>;

def FDIVS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
                 "fdivs", " $dst, $a, $b",
                 [(set SPR:$dst, (fdiv SPR:$a, SPR:$b))]>;

def FMULD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
                 "fmuld", " $dst, $a, $b",
                 [(set DPR:$dst, (fmul DPR:$a, DPR:$b))]>;

def FMULS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
                 "fmuls", " $dst, $a, $b",
                 [(set SPR:$dst, (fmul SPR:$a, SPR:$b))]>;
                 
def FNMULD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
                  "fnmuld", " $dst, $a, $b",
                  [(set DPR:$dst, (fneg (fmul DPR:$a, DPR:$b)))]>;

def FNMULS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
                  "fnmuls", " $dst, $a, $b",
                  [(set SPR:$dst, (fneg (fmul SPR:$a, SPR:$b)))]>;

// Match reassociated forms only if not sign dependent rounding.
def : Pat<(fmul (fneg DPR:$a), DPR:$b),
          (FNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
def : Pat<(fmul (fneg SPR:$a), SPR:$b),
          (FNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;


def FSUBD  : ADI<(outs DPR:$dst), (ins DPR:$a, DPR:$b),
                 "fsubd", " $dst, $a, $b",
                 [(set DPR:$dst, (fsub DPR:$a, DPR:$b))]>;

def FSUBS  : ASI<(outs SPR:$dst), (ins SPR:$a, SPR:$b),
                 "fsubs", " $dst, $a, $b",
                 [(set SPR:$dst, (fsub SPR:$a, SPR:$b))]>;

//===----------------------------------------------------------------------===//
// FP Unary Operations.
//

def FABSD  : ADI<(outs DPR:$dst), (ins DPR:$a),
                 "fabsd", " $dst, $a",
                 [(set DPR:$dst, (fabs DPR:$a))]>;

def FABSS  : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "fabss", " $dst, $a",
                 [(set SPR:$dst, (fabs SPR:$a))]>;

def FCMPEZD : ADI<(outs), (ins DPR:$a),
                  "fcmpezd", " $a",
                  [(arm_cmpfp0 DPR:$a)]>;

def FCMPEZS : ASI<(outs), (ins SPR:$a),
                  "fcmpezs", " $a",
                  [(arm_cmpfp0 SPR:$a)]>;

def FCVTDS : ADI<(outs DPR:$dst), (ins SPR:$a),
                 "fcvtds", " $dst, $a",
                 [(set DPR:$dst, (fextend SPR:$a))]>;

def FCVTSD : ADI<(outs SPR:$dst), (ins DPR:$a),
                 "fcvtsd", " $dst, $a",
                 [(set SPR:$dst, (fround DPR:$a))]>;

def FCPYD  : ADI<(outs DPR:$dst), (ins DPR:$a),
                 "fcpyd", " $dst, $a", []>;

def FCPYS  : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "fcpys", " $dst, $a", []>;

def FNEGD  : ADI<(outs DPR:$dst), (ins DPR:$a),
                 "fnegd", " $dst, $a",
                 [(set DPR:$dst, (fneg DPR:$a))]>;

def FNEGS  : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "fnegs", " $dst, $a",
                 [(set SPR:$dst, (fneg SPR:$a))]>;

def FSQRTD  : ADI<(outs DPR:$dst), (ins DPR:$a),
                 "fsqrtd", " $dst, $a",
                 [(set DPR:$dst, (fsqrt DPR:$a))]>;

def FSQRTS  : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "fsqrts", " $dst, $a",
                 [(set SPR:$dst, (fsqrt SPR:$a))]>;

//===----------------------------------------------------------------------===//
// FP <-> GPR Copies.  Int <-> FP Conversions.
//

let isImplicitDef = 1 in {
def IMPLICIT_DEF_SPR : PseudoInst<(outs SPR:$rD), (ins pred:$p),
                                  "@ IMPLICIT_DEF_SPR $rD",
                                  [(set SPR:$rD, (undef))]>;
def IMPLICIT_DEF_DPR : PseudoInst<(outs DPR:$rD), (ins pred:$p),
                                  "@ IMPLICIT_DEF_DPR $rD",
                                  [(set DPR:$rD, (undef))]>;
}

def FMRS   : ASI<(outs GPR:$dst), (ins SPR:$src),
                 "fmrs", " $dst, $src",
                 [(set GPR:$dst, (bitconvert SPR:$src))]>;

def FMSR   : ASI<(outs SPR:$dst), (ins GPR:$src),
                 "fmsr", " $dst, $src",
                 [(set SPR:$dst, (bitconvert GPR:$src))]>;


def FMRRD  : ADI<(outs GPR:$dst1, GPR:$dst2), (ins DPR:$src),
                 "fmrrd", " $dst1, $dst2, $src",
                 [/* FIXME: Can't write pattern for multiple result instr*/]>;

// FMDHR: GPR -> SPR
// FMDLR: GPR -> SPR

def FMDRR : ADI<(outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
                "fmdrr", " $dst, $src1, $src2",
                [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]>;

// FMRDH: SPR -> GPR
// FMRDL: SPR -> GPR
// FMRRS: SPR -> GPR
// FMRX : SPR system reg -> GPR

// FMSRR: GPR -> SPR

let Defs = [CPSR] in
def FMSTAT : ASI<(outs), (ins), "fmstat", "", [(arm_fmstat)]>;

// FMXR: GPR -> VFP Sstem reg


// Int to FP:

def FSITOD : ADI<(outs DPR:$dst), (ins SPR:$a),
                 "fsitod", " $dst, $a",
                 [(set DPR:$dst, (arm_sitof SPR:$a))]>;

def FSITOS : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "fsitos", " $dst, $a",
                 [(set SPR:$dst, (arm_sitof SPR:$a))]>;

def FUITOD : ADI<(outs DPR:$dst), (ins SPR:$a),
                 "fuitod", " $dst, $a",
                 [(set DPR:$dst, (arm_uitof SPR:$a))]>;

def FUITOS : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "fuitos", " $dst, $a",
                 [(set SPR:$dst, (arm_uitof SPR:$a))]>;

// FP to Int:
// Always set Z bit in the instruction, i.e. "round towards zero" variants.

def FTOSIZD : ADI<(outs SPR:$dst), (ins DPR:$a),
                 "ftosizd", " $dst, $a",
                 [(set SPR:$dst, (arm_ftosi DPR:$a))]>;

def FTOSIZS : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "ftosizs", " $dst, $a",
                 [(set SPR:$dst, (arm_ftosi SPR:$a))]>;

def FTOUIZD : ADI<(outs SPR:$dst), (ins DPR:$a),
                 "ftouizd", " $dst, $a",
                 [(set SPR:$dst, (arm_ftoui DPR:$a))]>;

def FTOUIZS : ASI<(outs SPR:$dst), (ins SPR:$a),
                 "ftouizs", " $dst, $a",
                 [(set SPR:$dst, (arm_ftoui SPR:$a))]>;

//===----------------------------------------------------------------------===//
// FP FMA Operations.
//

def FMACD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
                "fmacd", " $dst, $a, $b",
                [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FMACS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
                "fmacs", " $dst, $a, $b",
                [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FMSCD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
                "fmscd", " $dst, $a, $b",
                [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b), DPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FMSCS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
                "fmscs", " $dst, $a, $b",
                [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FNMACD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
                 "fnmacd", " $dst, $a, $b",
             [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FNMACS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
                "fnmacs", " $dst, $a, $b",
             [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FNMSCD : ADI<(outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
                 "fnmscd", " $dst, $a, $b",
             [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)), DPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

def FNMSCS : ASI<(outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
                "fnmscs", " $dst, $a, $b",
             [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
                RegConstraint<"$dstin = $dst">;

//===----------------------------------------------------------------------===//
// FP Conditional moves.
//

def FCPYDcc  : ADI<(outs DPR:$dst), (ins DPR:$false, DPR:$true),
                    "fcpyd", " $dst, $true",
                [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
                    RegConstraint<"$false = $dst">;

def FCPYScc  : ASI<(outs SPR:$dst), (ins SPR:$false, SPR:$true),
                    "fcpys", " $dst, $true",
                [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
                    RegConstraint<"$false = $dst">;

def FNEGDcc  : ADI<(outs DPR:$dst), (ins DPR:$false, DPR:$true),
                    "fnegd", " $dst, $true",
                [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
                    RegConstraint<"$false = $dst">;

def FNEGScc  : ASI<(outs SPR:$dst), (ins SPR:$false, SPR:$true),
                    "fnegs", " $dst, $true",
                [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
                    RegConstraint<"$false = $dst">;