Add VCMPZ and VABS.
[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 def SDT_FTOI :
15 SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisFP<1>]>;
16 def SDT_ITOF :
17 SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, f32>]>;
18 def SDT_CMPFP0 :
19 SDTypeProfile<0, 1, [SDTCisFP<0>]>;
20 def SDT_VMOVDRR :
21 SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>,
22                      SDTCisSameAs<1, 2>]>;
23
24 def arm_ftoui  : SDNode<"ARMISD::FTOUI",  SDT_FTOI>;
25 def arm_ftosi  : SDNode<"ARMISD::FTOSI",  SDT_FTOI>;
26 def arm_sitof  : SDNode<"ARMISD::SITOF",  SDT_ITOF>;
27 def arm_uitof  : SDNode<"ARMISD::UITOF",  SDT_ITOF>;
28 def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInFlag,SDNPOutFlag]>;
29 def arm_cmpfp  : SDNode<"ARMISD::CMPFP",  SDT_ARMCmp, [SDNPOutFlag]>;
30 def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0",SDT_CMPFP0, [SDNPOutFlag]>;
31 def arm_fmdrr  : SDNode<"ARMISD::VMOVDRR",  SDT_VMOVDRR>;
32
33 //===----------------------------------------------------------------------===//
34 // Operand Definitions.
35 //
36
37
38 def vfp_f32imm : Operand<f32>,
39                  PatLeaf<(f32 fpimm), [{
40       return ARM::getVFPf32Imm(N->getValueAPF()) != -1;
41     }]> {
42   let PrintMethod = "printVFPf32ImmOperand";
43 }
44
45 def vfp_f64imm : Operand<f64>,
46                  PatLeaf<(f64 fpimm), [{
47       return ARM::getVFPf64Imm(N->getValueAPF()) != -1;
48     }]> {
49   let PrintMethod = "printVFPf64ImmOperand";
50 }
51
52
53 //===----------------------------------------------------------------------===//
54 //  Load / store Instructions.
55 //
56
57 let canFoldAsLoad = 1, isReMaterializable = 1 in {
58 def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$dst), (ins addrmode5:$addr),
59                  IIC_fpLoad64, "vldr", ".64\t$dst, $addr",
60                  [(set DPR:$dst, (f64 (load addrmode5:$addr)))]>;
61
62 def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$dst), (ins addrmode5:$addr),
63                  IIC_fpLoad32, "vldr", ".32\t$dst, $addr",
64                  [(set SPR:$dst, (load addrmode5:$addr))]>;
65 } // canFoldAsLoad
66
67 def VSTRD  : ADI5<0b1101, 0b00, (outs), (ins DPR:$src, addrmode5:$addr),
68                  IIC_fpStore64, "vstr", ".64\t$src, $addr",
69                  [(store (f64 DPR:$src), addrmode5:$addr)]>;
70
71 def VSTRS  : ASI5<0b1101, 0b00, (outs), (ins SPR:$src, addrmode5:$addr),
72                  IIC_fpStore32, "vstr", ".32\t$src, $addr",
73                  [(store SPR:$src, addrmode5:$addr)]>;
74
75 //===----------------------------------------------------------------------===//
76 //  Load / store multiple Instructions.
77 //
78
79 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
80 def VLDMD : AXDI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dsts,
81                            variable_ops), IndexModeNone, IIC_fpLoad_m,
82                   "vldm${addr:submode}${p}\t$addr, $dsts", "", []> {
83   let Inst{20} = 1;
84 }
85
86 def VLDMS : AXSI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$dsts,
87                            variable_ops), IndexModeNone, IIC_fpLoad_m,
88                   "vldm${addr:submode}${p}\t$addr, $dsts", "", []> {
89   let Inst{20} = 1;
90 }
91
92 def VLDMD_UPD : AXDI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
93                                        reglist:$dsts, variable_ops),
94                       IndexModeUpd, IIC_fpLoad_mu,
95                       "vldm${addr:submode}${p}\t$addr!, $dsts",
96                       "$addr.addr = $wb", []> {
97   let Inst{20} = 1;
98 }
99
100 def VLDMS_UPD : AXSI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
101                                        reglist:$dsts, variable_ops),
102                       IndexModeUpd, IIC_fpLoad_mu, 
103                       "vldm${addr:submode}${p}\t$addr!, $dsts",
104                       "$addr.addr = $wb", []> {
105   let Inst{20} = 1;
106 }
107 } // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq
108
109 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
110 def VSTMD : AXDI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$srcs,
111                            variable_ops), IndexModeNone, IIC_fpStore_m,
112                   "vstm${addr:submode}${p}\t$addr, $srcs", "", []> {
113   let Inst{20} = 0;
114 }
115
116 def VSTMS : AXSI4<(outs), (ins addrmode4:$addr, pred:$p, reglist:$srcs,
117                            variable_ops), IndexModeNone, IIC_fpStore_m,
118                   "vstm${addr:submode}${p}\t$addr, $srcs", "", []> {
119   let Inst{20} = 0;
120 }
121
122 def VSTMD_UPD : AXDI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
123                                        reglist:$srcs, variable_ops),
124                       IndexModeUpd, IIC_fpStore_mu,
125                       "vstm${addr:submode}${p}\t$addr!, $srcs",
126                       "$addr.addr = $wb", []> {
127   let Inst{20} = 0;
128 }
129
130 def VSTMS_UPD : AXSI4<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p,
131                                        reglist:$srcs, variable_ops),
132                       IndexModeUpd, IIC_fpStore_mu,
133                       "vstm${addr:submode}${p}\t$addr!, $srcs",
134                       "$addr.addr = $wb", []> {
135   let Inst{20} = 0;
136 }
137 } // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq
138
139 // FLDMX, FSTMX - mixing S/D registers for pre-armv6 cores
140
141
142 // FIXME: Can these be placed into the base class?
143 class ADbI_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
144                   dag iops, InstrItinClass itin, string opc, string asm,
145                   list<dag> pattern>
146   : ADbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
147   // Instruction operands.
148   bits<5> Dd;
149   bits<5> Dn;
150   bits<5> Dm;
151
152   // Encode instruction operands.
153   let Inst{3-0}   = Dm{3-0};
154   let Inst{5}     = Dm{4};
155   let Inst{19-16} = Dn{3-0};
156   let Inst{7}     = Dn{4};
157   let Inst{15-12} = Dd{3-0};
158   let Inst{22}    = Dd{4};
159 }
160
161 class ADuI_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
162                   bits<2> opcod4, bit opcod5, dag oops, dag iops,
163                   InstrItinClass itin, string opc, string asm,
164                   list<dag> pattern>
165   : ADuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc,
166          asm, pattern> {
167   // Instruction operands.
168   bits<5> Dd;
169   bits<5> Dm;
170
171   // Encode instruction operands.
172   let Inst{3-0}   = Dm{3-0};
173   let Inst{5}     = Dm{4};
174   let Inst{15-12} = Dd{3-0};
175   let Inst{22}    = Dd{4};
176 }
177
178 class ASbI_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
179                   dag iops, InstrItinClass itin, string opc, string asm,
180                   list<dag> pattern>
181   : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
182   // Instruction operands.
183   bits<5> Sd;
184   bits<5> Sn;
185   bits<5> Sm;
186
187   // Encode instruction operands.
188   let Inst{3-0}   = Sm{4-1};
189   let Inst{5}     = Sm{0};
190   let Inst{19-16} = Sn{4-1};
191   let Inst{7}     = Sn{0};
192   let Inst{15-12} = Sd{4-1};
193   let Inst{22}    = Sd{0};
194 }
195
196 class ASbIn_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
197                    dag iops, InstrItinClass itin, string opc, string asm,
198                    list<dag> pattern>
199   : ASbIn<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
200   // Instruction operands.
201   bits<5> Sd;
202   bits<5> Sn;
203   bits<5> Sm;
204
205   // Encode instruction operands.
206   let Inst{3-0}   = Sm{4-1};
207   let Inst{5}     = Sm{0};
208   let Inst{19-16} = Sn{4-1};
209   let Inst{7}     = Sn{0};
210   let Inst{15-12} = Sd{4-1};
211   let Inst{22}    = Sd{0};
212 }
213
214 class ASuI_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
215                   bits<2> opcod4, bit opcod5, dag oops, dag iops,
216                   InstrItinClass itin, string opc, string asm,
217                   list<dag> pattern>
218   : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc,
219          asm, pattern> {
220   // Instruction operands.
221   bits<5> Sd;
222   bits<5> Sm;
223
224   // Encode instruction operands.
225   let Inst{3-0}   = Sm{4-1};
226   let Inst{5}     = Sm{0};
227   let Inst{15-12} = Sd{4-1};
228   let Inst{22}    = Sd{0};
229 }
230
231 class ASuIn_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
232                    bits<2> opcod4, bit opcod5, dag oops, dag iops,
233                    InstrItinClass itin, string opc, string asm,
234                    list<dag> pattern>
235   : ASuIn<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc,
236           asm, pattern> {
237   // Instruction operands.
238   bits<5> Sd;
239   bits<5> Sm;
240
241   // Encode instruction operands.
242   let Inst{3-0}   = Sm{4-1};
243   let Inst{5}     = Sm{0};
244   let Inst{15-12} = Sd{4-1};
245   let Inst{22}    = Sd{0};
246 }
247
248 //===----------------------------------------------------------------------===//
249 // FP Binary Operations.
250 //
251
252 def VADDD  : ADbI_Encode<0b11100, 0b11, 0, 0,
253                         (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
254                         IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm",
255                         [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>;
256
257 def VADDS  : ASbIn_Encode<0b11100, 0b11, 0, 0,
258                           (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
259                           IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm",
260                           [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>;
261
262 def VSUBD  : ADbI_Encode<0b11100, 0b11, 1, 0,
263                          (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
264                          IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm",
265                          [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>;
266
267 def VSUBS  : ASbIn_Encode<0b11100, 0b11, 1, 0,
268                           (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
269                           IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm",
270                           [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>;
271
272 def VDIVD  : ADbI_Encode<0b11101, 0b00, 0, 0,
273                          (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
274                          IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm",
275                          [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>;
276
277 def VDIVS  : ASbI_Encode<0b11101, 0b00, 0, 0,
278                          (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
279                          IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm",
280                          [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>;
281
282 def VMULD  : ADbI_Encode<0b11100, 0b10, 0, 0,
283                          (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
284                          IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm",
285                          [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>;
286
287 def VMULS  : ASbIn_Encode<0b11100, 0b10, 0, 0,
288                           (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
289                           IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm",
290                           [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>;
291
292 def VNMULD : ADbI_Encode<0b11100, 0b10, 1, 0,
293                          (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm),
294                          IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm",
295                          [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>;
296
297 def VNMULS : ASbI_Encode<0b11100, 0b10, 1, 0,
298                          (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm),
299                          IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm",
300                          [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>;
301
302 // Match reassociated forms only if not sign dependent rounding.
303 def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)),
304           (VNMULD DPR:$a, DPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
305 def : Pat<(fmul (fneg SPR:$a), SPR:$b),
306           (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
307
308 // These are encoded as unary instructions.
309 let Defs = [FPSCR] in {
310 def VCMPED : ADuI_Encode<0b11101, 0b11, 0b0100, 0b11, 0,
311                          (outs),(ins DPR:$Dd, DPR:$Dm),
312                          IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
313                          [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>;
314
315 def VCMPES : ASuI_Encode<0b11101, 0b11, 0b0100, 0b11, 0,
316                          (outs),(ins SPR:$Sd, SPR:$Sm),
317                          IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm",
318                          [(arm_cmpfp SPR:$Sd, SPR:$Sm)]>;
319
320 def VCMPD  : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins DPR:$a, DPR:$b),
321                  IIC_fpCMP64, "vcmp", ".f64\t$a, $b",
322                  [/* For disassembly only; pattern left blank */]>;
323
324 def VCMPS  : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, (outs), (ins SPR:$a, SPR:$b),
325                  IIC_fpCMP32, "vcmp", ".f32\t$a, $b",
326                  [/* For disassembly only; pattern left blank */]>;
327 }
328
329 //===----------------------------------------------------------------------===//
330 // FP Unary Operations.
331 //
332
333 def VABSD  : ADuI_Encode<0b11101, 0b11, 0b0000, 0b11, 0,
334                          (outs DPR:$Dd), (ins DPR:$Dm),
335                          IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
336                          [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
337
338 def VABSS  : ASuIn_Encode<0b11101, 0b11, 0b0000, 0b11, 0,
339                           (outs SPR:$Sd), (ins SPR:$Sm),
340                           IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
341                           [(set SPR:$Sd, (fabs SPR:$Sm))]>;
342
343 let Defs = [FPSCR] in {
344 def VCMPEZD : ADuI_Encode<0b11101, 0b11, 0b0101, 0b11, 0,
345                           (outs), (ins DPR:$Dd),
346                           IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
347                           [(arm_cmpfp0 (f64 DPR:$Dd))]> {
348   let Inst{3-0}   = 0b0000;
349   let Inst{5}     = 0;
350 }
351
352 def VCMPEZS : ASuI_Encode<0b11101, 0b11, 0b0101, 0b11, 0,
353                          (outs), (ins SPR:$Sd),
354                          IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
355                          [(arm_cmpfp0 SPR:$Sd)]> {
356   let Inst{3-0}   = 0b0000;
357   let Inst{5}     = 0;
358 }
359
360 def VCMPZD  : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins DPR:$a),
361                   IIC_fpCMP64, "vcmp", ".f64\t$a, #0",
362                   [/* For disassembly only; pattern left blank */]>;
363
364 def VCMPZS  : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, (outs), (ins SPR:$a),
365                   IIC_fpCMP32, "vcmp", ".f32\t$a, #0",
366                   [/* For disassembly only; pattern left blank */]>;
367 }
368
369 def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, (outs DPR:$dst), (ins SPR:$a),
370                  IIC_fpCVTDS, "vcvt", ".f64.f32\t$dst, $a",
371                  [(set DPR:$dst, (fextend SPR:$a))]>;
372
373 // Special case encoding: bits 11-8 is 0b1011.
374 def VCVTSD : VFPAI<(outs SPR:$dst), (ins DPR:$a), VFPUnaryFrm,
375                    IIC_fpCVTSD, "vcvt", ".f32.f64\t$dst, $a",
376                    [(set SPR:$dst, (fround DPR:$a))]> {
377   let Inst{27-23} = 0b11101;
378   let Inst{21-16} = 0b110111;
379   let Inst{11-8}  = 0b1011;
380   let Inst{7-6}   = 0b11;
381   let Inst{4}     = 0;
382 }
383
384 // Between half-precision and single-precision.  For disassembly only.
385
386 def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
387                  /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
388                  [/* For disassembly only; pattern left blank */]>;
389
390 def : ARMPat<(f32_to_f16 SPR:$a),
391              (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
392
393 def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
394                  /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
395                  [/* For disassembly only; pattern left blank */]>;
396
397 def : ARMPat<(f16_to_f32 GPR:$a),
398              (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
399
400 def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
401                  /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
402                  [/* For disassembly only; pattern left blank */]>;
403
404 def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
405                  /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
406                  [/* For disassembly only; pattern left blank */]>;
407
408 let neverHasSideEffects = 1 in {
409 def VMOVD: ADuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
410                  IIC_fpUNA64, "vmov", ".f64\t$dst, $a", []>;
411
412 def VMOVS: ASuI<0b11101, 0b11, 0b0000, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
413                  IIC_fpUNA32, "vmov", ".f32\t$dst, $a", []>;
414 } // neverHasSideEffects
415
416 def VNEGD  : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, (outs DPR:$dst), (ins DPR:$a),
417                  IIC_fpUNA64, "vneg", ".f64\t$dst, $a",
418                  [(set DPR:$dst, (fneg (f64 DPR:$a)))]>;
419
420 def VNEGS  : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0,(outs SPR:$dst), (ins SPR:$a),
421                   IIC_fpUNA32, "vneg", ".f32\t$dst, $a",
422                   [(set SPR:$dst, (fneg SPR:$a))]>;
423
424 def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs DPR:$dst), (ins DPR:$a),
425                  IIC_fpSQRT64, "vsqrt", ".f64\t$dst, $a",
426                  [(set DPR:$dst, (fsqrt (f64 DPR:$a)))]>;
427
428 def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
429                  IIC_fpSQRT32, "vsqrt", ".f32\t$dst, $a",
430                  [(set SPR:$dst, (fsqrt SPR:$a))]>;
431
432 //===----------------------------------------------------------------------===//
433 // FP <-> GPR Copies.  Int <-> FP Conversions.
434 //
435
436 def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
437                  IIC_fpMOVSI, "vmov", "\t$dst, $src",
438                  [(set GPR:$dst, (bitconvert SPR:$src))]>;
439
440 def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
441                  IIC_fpMOVIS, "vmov", "\t$dst, $src",
442                  [(set SPR:$dst, (bitconvert GPR:$src))]>;
443
444 let neverHasSideEffects = 1 in {
445 def VMOVRRD  : AVConv3I<0b11000101, 0b1011,
446                       (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
447                  IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
448                  [/* FIXME: Can't write pattern for multiple result instr*/]> {
449   let Inst{7-6} = 0b00;
450 }
451
452 def VMOVRRS  : AVConv3I<0b11000101, 0b1010,
453                       (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
454                  IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
455                  [/* For disassembly only; pattern left blank */]> {
456   let Inst{7-6} = 0b00;
457 }
458 } // neverHasSideEffects
459
460 // FMDHR: GPR -> SPR
461 // FMDLR: GPR -> SPR
462
463 def VMOVDRR : AVConv5I<0b11000100, 0b1011,
464                      (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
465                 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
466                 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
467   let Inst{7-6} = 0b00;
468 }
469
470 let neverHasSideEffects = 1 in
471 def VMOVSRR : AVConv5I<0b11000100, 0b1010,
472                      (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
473                 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
474                 [/* For disassembly only; pattern left blank */]> {
475   let Inst{7-6} = 0b00;
476 }
477
478 // FMRDH: SPR -> GPR
479 // FMRDL: SPR -> GPR
480 // FMRRS: SPR -> GPR
481 // FMRX : SPR system reg -> GPR
482
483 // FMSRR: GPR -> SPR
484
485 // FMXR: GPR -> VFP system reg
486
487
488 // Int to FP:
489
490 def VSITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
491                  (outs DPR:$dst), (ins SPR:$a),
492                  IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a",
493                  [(set DPR:$dst, (f64 (arm_sitof SPR:$a)))]> {
494   let Inst{7} = 1; // s32
495 }
496
497 def VSITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
498                  (outs SPR:$dst),(ins SPR:$a),
499                  IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a",
500                  [(set SPR:$dst, (arm_sitof SPR:$a))]> {
501   let Inst{7} = 1; // s32
502 }
503
504 def VUITOD : AVConv1I<0b11101, 0b11, 0b1000, 0b1011,
505                  (outs DPR:$dst), (ins SPR:$a),
506                  IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a",
507                  [(set DPR:$dst, (f64 (arm_uitof SPR:$a)))]> {
508   let Inst{7} = 0; // u32
509 }
510
511 def VUITOS : AVConv1In<0b11101, 0b11, 0b1000, 0b1010,
512                  (outs SPR:$dst), (ins SPR:$a),
513                  IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a",
514                  [(set SPR:$dst, (arm_uitof SPR:$a))]> {
515   let Inst{7} = 0; // u32
516 }
517
518 // FP to Int:
519 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
520
521 def VTOSIZD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
522                        (outs SPR:$dst), (ins DPR:$a),
523                  IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a",
524                  [(set SPR:$dst, (arm_ftosi (f64 DPR:$a)))]> {
525   let Inst{7} = 1; // Z bit
526 }
527
528 def VTOSIZS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
529                         (outs SPR:$dst), (ins SPR:$a),
530                  IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a",
531                  [(set SPR:$dst, (arm_ftosi SPR:$a))]> {
532   let Inst{7} = 1; // Z bit
533 }
534
535 def VTOUIZD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
536                        (outs SPR:$dst), (ins DPR:$a),
537                  IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a",
538                  [(set SPR:$dst, (arm_ftoui (f64 DPR:$a)))]> {
539   let Inst{7} = 1; // Z bit
540 }
541
542 def VTOUIZS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
543                         (outs SPR:$dst), (ins SPR:$a),
544                  IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a",
545                  [(set SPR:$dst, (arm_ftoui SPR:$a))]> {
546   let Inst{7} = 1; // Z bit
547 }
548
549 // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
550 // For disassembly only.
551 let Uses = [FPSCR] in {
552 def VTOSIRD : AVConv1I<0b11101, 0b11, 0b1101, 0b1011,
553                        (outs SPR:$dst), (ins DPR:$a),
554                  IIC_fpCVTDI, "vcvtr", ".s32.f64\t$dst, $a",
555                  [(set SPR:$dst, (int_arm_vcvtr (f64 DPR:$a)))]> {
556   let Inst{7} = 0; // Z bit
557 }
558
559 def VTOSIRS : AVConv1In<0b11101, 0b11, 0b1101, 0b1010,
560                         (outs SPR:$dst), (ins SPR:$a),
561                  IIC_fpCVTSI, "vcvtr", ".s32.f32\t$dst, $a",
562                  [(set SPR:$dst, (int_arm_vcvtr SPR:$a))]> {
563   let Inst{7} = 0; // Z bit
564 }
565
566 def VTOUIRD : AVConv1I<0b11101, 0b11, 0b1100, 0b1011,
567                        (outs SPR:$dst), (ins DPR:$a),
568                  IIC_fpCVTDI, "vcvtr", ".u32.f64\t$dst, $a",
569                  [(set SPR:$dst, (int_arm_vcvtru (f64 DPR:$a)))]> {
570   let Inst{7} = 0; // Z bit
571 }
572
573 def VTOUIRS : AVConv1In<0b11101, 0b11, 0b1100, 0b1010,
574                         (outs SPR:$dst), (ins SPR:$a),
575                  IIC_fpCVTSI, "vcvtr", ".u32.f32\t$dst, $a",
576                  [(set SPR:$dst, (int_arm_vcvtru SPR:$a))]> {
577   let Inst{7} = 0; // Z bit
578 }
579 }
580
581 // Convert between floating-point and fixed-point
582 // Data type for fixed-point naming convention:
583 //   S16 (U=0, sx=0) -> SH
584 //   U16 (U=1, sx=0) -> UH
585 //   S32 (U=0, sx=1) -> SL
586 //   U32 (U=1, sx=1) -> UL
587
588 let Constraints = "$a = $dst" in {
589
590 // FP to Fixed-Point:
591
592 let isCodeGenOnly = 1 in {
593 def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
594                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
595                  IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
596                  [/* For disassembly only; pattern left blank */]>;
597
598 def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
599                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
600                  IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
601                  [/* For disassembly only; pattern left blank */]>;
602
603 def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
604                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
605                  IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
606                  [/* For disassembly only; pattern left blank */]>;
607
608 def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
609                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
610                  IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
611                  [/* For disassembly only; pattern left blank */]>;
612
613 def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
614                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
615                  IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
616                  [/* For disassembly only; pattern left blank */]>;
617
618 def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
619                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
620                  IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
621                  [/* For disassembly only; pattern left blank */]>;
622
623 def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
624                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
625                  IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
626                  [/* For disassembly only; pattern left blank */]>;
627
628 def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
629                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
630                  IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
631                  [/* For disassembly only; pattern left blank */]>;
632 }
633
634 // Fixed-Point to FP:
635
636 let isCodeGenOnly = 1 in {
637 def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
638                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
639                  IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
640                  [/* For disassembly only; pattern left blank */]>;
641
642 def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
643                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
644                  IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
645                  [/* For disassembly only; pattern left blank */]>;
646
647 def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
648                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
649                  IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
650                  [/* For disassembly only; pattern left blank */]>;
651
652 def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
653                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
654                  IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
655                  [/* For disassembly only; pattern left blank */]>;
656
657 def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
658                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
659                  IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
660                  [/* For disassembly only; pattern left blank */]>;
661
662 def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
663                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
664                  IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
665                  [/* For disassembly only; pattern left blank */]>;
666
667 def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
668                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
669                  IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
670                  [/* For disassembly only; pattern left blank */]>;
671
672 def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
673                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
674                  IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
675                  [/* For disassembly only; pattern left blank */]>;
676 }
677
678 } // End of 'let Constraints = "$src = $dst" in'
679
680 //===----------------------------------------------------------------------===//
681 // FP FMA Operations.
682 //
683
684 def VMLAD : ADbI_vmlX<0b11100, 0b00, 0, 0,
685                 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
686                 IIC_fpMAC64, "vmla", ".f64\t$dst, $a, $b",
687                 [(set DPR:$dst, (fadd (fmul DPR:$a, DPR:$b),
688                                       (f64 DPR:$dstin)))]>,
689                 RegConstraint<"$dstin = $dst">;
690
691 def VMLAS : ASbIn<0b11100, 0b00, 0, 0,
692                  (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
693                  IIC_fpMAC32, "vmla", ".f32\t$dst, $a, $b",
694                  [(set SPR:$dst, (fadd (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
695                  RegConstraint<"$dstin = $dst">;
696
697 def VNMLSD : ADbI_vmlX<0b11100, 0b01, 0, 0,
698                 (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
699                 IIC_fpMAC64, "vnmls", ".f64\t$dst, $a, $b",
700                 [(set DPR:$dst, (fsub (fmul DPR:$a, DPR:$b),
701                                 (f64 DPR:$dstin)))]>,
702                 RegConstraint<"$dstin = $dst">;
703
704 def VNMLSS : ASbI<0b11100, 0b01, 0, 0,
705                 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
706                 IIC_fpMAC32, "vnmls", ".f32\t$dst, $a, $b",
707                 [(set SPR:$dst, (fsub (fmul SPR:$a, SPR:$b), SPR:$dstin))]>,
708                 RegConstraint<"$dstin = $dst">;
709
710 def VMLSD : ADbI_vmlX<0b11100, 0b00, 1, 0,
711                  (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
712                  IIC_fpMAC64, "vmls", ".f64\t$dst, $a, $b",
713              [(set DPR:$dst, (fadd (fneg (fmul DPR:$a, DPR:$b)),
714                              (f64 DPR:$dstin)))]>,
715                 RegConstraint<"$dstin = $dst">;
716
717 def VMLSS : ASbIn<0b11100, 0b00, 1, 0,
718                   (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
719                   IIC_fpMAC32, "vmls", ".f32\t$dst, $a, $b",
720              [(set SPR:$dst, (fadd (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
721                 RegConstraint<"$dstin = $dst">;
722
723 def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
724           (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
725 def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
726           (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
727
728 def VNMLAD : ADbI_vmlX<0b11100, 0b01, 1, 0,
729                  (outs DPR:$dst), (ins DPR:$dstin, DPR:$a, DPR:$b),
730                  IIC_fpMAC64, "vnmla", ".f64\t$dst, $a, $b",
731              [(set DPR:$dst, (fsub (fneg (fmul DPR:$a, DPR:$b)),
732                              (f64 DPR:$dstin)))]>,
733                 RegConstraint<"$dstin = $dst">;
734
735 def VNMLAS : ASbI<0b11100, 0b01, 1, 0,
736                 (outs SPR:$dst), (ins SPR:$dstin, SPR:$a, SPR:$b),
737                 IIC_fpMAC32, "vnmla", ".f32\t$dst, $a, $b",
738              [(set SPR:$dst, (fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin))]>,
739                 RegConstraint<"$dstin = $dst">;
740
741 //===----------------------------------------------------------------------===//
742 // FP Conditional moves.
743 //
744
745 let neverHasSideEffects = 1 in {
746 def VMOVDcc  : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
747                     (outs DPR:$dst), (ins DPR:$false, DPR:$true),
748                     IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
749                 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
750                     RegConstraint<"$false = $dst">;
751
752 def VMOVScc  : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
753                     (outs SPR:$dst), (ins SPR:$false, SPR:$true),
754                     IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
755                 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
756                     RegConstraint<"$false = $dst">;
757
758 def VNEGDcc  : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
759                     (outs DPR:$dst), (ins DPR:$false, DPR:$true),
760                     IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
761                 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
762                     RegConstraint<"$false = $dst">;
763
764 def VNEGScc  : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
765                     (outs SPR:$dst), (ins SPR:$false, SPR:$true),
766                     IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
767                 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
768                     RegConstraint<"$false = $dst">;
769 } // neverHasSideEffects
770
771 //===----------------------------------------------------------------------===//
772 // Misc.
773 //
774
775 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
776 // to APSR.
777 let Defs = [CPSR], Uses = [FPSCR] in
778 def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
779                    "\tapsr_nzcv, fpscr",
780              [(arm_fmstat)]> {
781   let Inst{27-20} = 0b11101111;
782   let Inst{19-16} = 0b0001;
783   let Inst{15-12} = 0b1111;
784   let Inst{11-8}  = 0b1010;
785   let Inst{7}     = 0;
786   let Inst{4}     = 1;
787 }
788
789 // FPSCR <-> GPR (for disassembly only)
790 let hasSideEffects = 1, Uses = [FPSCR] in
791 def VMRS : VFPAI<(outs GPR:$dst), (ins), VFPMiscFrm, IIC_fpSTAT,
792                  "vmrs", "\t$dst, fpscr",
793              [(set GPR:$dst, (int_arm_get_fpscr))]> {
794   let Inst{27-20} = 0b11101111;
795   let Inst{19-16} = 0b0001;
796   let Inst{11-8}  = 0b1010;
797   let Inst{7}     = 0;
798   let Inst{4}     = 1;
799 }
800
801 let Defs = [FPSCR] in 
802 def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT, 
803                  "vmsr", "\tfpscr, $src",
804              [(int_arm_set_fpscr GPR:$src)]> {
805   let Inst{27-20} = 0b11101110;
806   let Inst{19-16} = 0b0001;
807   let Inst{11-8}  = 0b1010;
808   let Inst{7}     = 0;
809   let Inst{4}     = 1;
810 }
811
812 // Materialize FP immediates. VFP3 only.
813 let isReMaterializable = 1 in {
814 def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
815                     VFPMiscFrm, IIC_fpUNA64,
816                     "vmov", ".f64\t$dst, $imm",
817                     [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
818   let Inst{27-23} = 0b11101;
819   let Inst{21-20} = 0b11;
820   let Inst{11-9}  = 0b101;
821   let Inst{8}     = 1;
822   let Inst{7-4}   = 0b0000;
823 }
824
825 def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
826                     VFPMiscFrm, IIC_fpUNA32,
827                     "vmov", ".f32\t$dst, $imm",
828                     [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
829   let Inst{27-23} = 0b11101;
830   let Inst{21-20} = 0b11;
831   let Inst{11-9}  = 0b101;
832   let Inst{8}     = 0;
833   let Inst{7-4}   = 0b0000;
834 }
835 }