Add encoding for 'fmstat'.
[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 //===----------------------------------------------------------------------===//
35 // Operand Definitions.
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 // FIXME: Verify encoding after integrated assembler is working.
321 def VCMPD  : ADuI_Encode<0b11101, 0b11, 0b0100, 0b01, 0,
322                          (outs), (ins DPR:$Dd, DPR:$Dm),
323                          IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm",
324                          [/* For disassembly only; pattern left blank */]>;
325
326 def VCMPS  : ASuI_Encode<0b11101, 0b11, 0b0100, 0b01, 0,
327                          (outs), (ins SPR:$Sd, SPR:$Sm),
328                          IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm",
329                          [/* For disassembly only; pattern left blank */]>;
330 }
331
332 //===----------------------------------------------------------------------===//
333 // FP Unary Operations.
334 //
335
336 def VABSD  : ADuI_Encode<0b11101, 0b11, 0b0000, 0b11, 0,
337                          (outs DPR:$Dd), (ins DPR:$Dm),
338                          IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm",
339                          [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>;
340
341 def VABSS  : ASuIn_Encode<0b11101, 0b11, 0b0000, 0b11, 0,
342                           (outs SPR:$Sd), (ins SPR:$Sm),
343                           IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm",
344                           [(set SPR:$Sd, (fabs SPR:$Sm))]>;
345
346 let Defs = [FPSCR] in {
347 def VCMPEZD : ADuI_Encode<0b11101, 0b11, 0b0101, 0b11, 0,
348                           (outs), (ins DPR:$Dd),
349                           IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
350                           [(arm_cmpfp0 (f64 DPR:$Dd))]> {
351   let Inst{3-0}   = 0b0000;
352   let Inst{5}     = 0;
353 }
354
355 def VCMPEZS : ASuI_Encode<0b11101, 0b11, 0b0101, 0b11, 0,
356                          (outs), (ins SPR:$Sd),
357                          IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0",
358                          [(arm_cmpfp0 SPR:$Sd)]> {
359   let Inst{3-0}   = 0b0000;
360   let Inst{5}     = 0;
361 }
362
363 // FIXME: Verify encoding after integrated assembler is working.
364 def VCMPZD  : ADuI_Encode<0b11101, 0b11, 0b0101, 0b01, 0,
365                           (outs), (ins DPR:$Dd),
366                           IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0",
367                           [/* For disassembly only; pattern left blank */]> {
368   let Inst{3-0}   = 0b0000;
369   let Inst{5}     = 0;
370 }
371
372 def VCMPZS  : ASuI_Encode<0b11101, 0b11, 0b0101, 0b01, 0,
373                           (outs), (ins SPR:$Sd),
374                           IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0",
375                           [/* For disassembly only; pattern left blank */]> {
376   let Inst{3-0}   = 0b0000;
377   let Inst{5}     = 0;
378 }
379 }
380
381 def VCVTDS  : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
382                    (outs DPR:$Dd), (ins SPR:$Sm),
383                    IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm",
384                    [(set DPR:$Dd, (fextend SPR:$Sm))]> {
385   // Instruction operands.
386   bits<5> Dd;
387   bits<5> Sm;
388
389   // Encode instruction operands.
390   let Inst{3-0}   = Sm{4-1};
391   let Inst{5}     = Sm{0};
392   let Inst{15-12} = Dd{3-0};
393   let Inst{22}    = Dd{4};
394 }
395
396 // Special case encoding: bits 11-8 is 0b1011.
397 def VCVTSD  : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm,
398                     IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm",
399                     [(set SPR:$Sd, (fround DPR:$Dm))]> {
400   // Instruction operands.
401   bits<5> Sd;
402   bits<5> Dm;
403
404   // Encode instruction operands.
405   let Inst{3-0}   = Dm{3-0};
406   let Inst{5}     = Dm{4};
407   let Inst{15-12} = Sd{4-1};
408   let Inst{22}    = Sd{0};
409
410   let Inst{27-23} = 0b11101;
411   let Inst{21-16} = 0b110111;
412   let Inst{11-8}  = 0b1011;
413   let Inst{7-6}   = 0b11;
414   let Inst{4}     = 0;
415 }
416
417 // Between half-precision and single-precision.  For disassembly only.
418
419 // FIXME: Verify encoding after integrated assembler is working.
420 def VCVTBSH: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
421                  /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$dst, $a",
422                  [/* For disassembly only; pattern left blank */]>;
423
424 def : ARMPat<(f32_to_f16 SPR:$a),
425              (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>;
426
427 def VCVTBHS: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$dst), (ins SPR:$a),
428                  /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$dst, $a",
429                  [/* For disassembly only; pattern left blank */]>;
430
431 def : ARMPat<(f16_to_f32 GPR:$a),
432              (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>;
433
434 def VCVTTSH: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
435                  /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$dst, $a",
436                  [/* For disassembly only; pattern left blank */]>;
437
438 def VCVTTHS: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$dst), (ins SPR:$a),
439                  /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$dst, $a",
440                  [/* For disassembly only; pattern left blank */]>;
441
442 def VNEGD  : ADuI_Encode<0b11101, 0b11, 0b0001, 0b01, 0,
443                          (outs DPR:$Dd), (ins DPR:$Dm),
444                          IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm",
445                          [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>;
446
447 def VNEGS  : ASuIn_Encode<0b11101, 0b11, 0b0001, 0b01, 0,
448                           (outs SPR:$Sd), (ins SPR:$Sm),
449                           IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm",
450                           [(set SPR:$Sd, (fneg SPR:$Sm))]>;
451
452 def VSQRTD : ADuI_Encode<0b11101, 0b11, 0b0001, 0b11, 0,
453                          (outs DPR:$Dd), (ins DPR:$Dm),
454                          IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm",
455                          [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>;
456
457 def VSQRTS : ASuI_Encode<0b11101, 0b11, 0b0001, 0b11, 0,
458                          (outs SPR:$Sd), (ins SPR:$Sm),
459                          IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm",
460                          [(set SPR:$Sd, (fsqrt SPR:$Sm))]>;
461
462 let neverHasSideEffects = 1 in {
463 def VMOVD  : ADuI_Encode<0b11101, 0b11, 0b0000, 0b01, 0,
464                          (outs DPR:$Dd), (ins DPR:$Dm),
465                          IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>;
466
467 def VMOVS  : ASuI_Encode<0b11101, 0b11, 0b0000, 0b01, 0,
468                          (outs SPR:$Sd), (ins SPR:$Sm),
469                          IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>;
470 } // neverHasSideEffects
471
472 //===----------------------------------------------------------------------===//
473 // FP <-> GPR Copies.  Int <-> FP Conversions.
474 //
475
476 def VMOVRS : AVConv2I<0b11100001, 0b1010, (outs GPR:$dst), (ins SPR:$src),
477                  IIC_fpMOVSI, "vmov", "\t$dst, $src",
478                  [(set GPR:$dst, (bitconvert SPR:$src))]>;
479
480 def VMOVSR : AVConv4I<0b11100000, 0b1010, (outs SPR:$dst), (ins GPR:$src),
481                  IIC_fpMOVIS, "vmov", "\t$dst, $src",
482                  [(set SPR:$dst, (bitconvert GPR:$src))]>;
483
484 let neverHasSideEffects = 1 in {
485 def VMOVRRD  : AVConv3I<0b11000101, 0b1011,
486                       (outs GPR:$wb, GPR:$dst2), (ins DPR:$src),
487                  IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src",
488                  [/* FIXME: Can't write pattern for multiple result instr*/]> {
489   let Inst{7-6} = 0b00;
490 }
491
492 def VMOVRRS  : AVConv3I<0b11000101, 0b1010,
493                       (outs GPR:$wb, GPR:$dst2), (ins SPR:$src1, SPR:$src2),
494                  IIC_fpMOVDI, "vmov", "\t$wb, $dst2, $src1, $src2",
495                  [/* For disassembly only; pattern left blank */]> {
496   let Inst{7-6} = 0b00;
497 }
498 } // neverHasSideEffects
499
500 // FMDHR: GPR -> SPR
501 // FMDLR: GPR -> SPR
502
503 def VMOVDRR : AVConv5I<0b11000100, 0b1011,
504                      (outs DPR:$dst), (ins GPR:$src1, GPR:$src2),
505                 IIC_fpMOVID, "vmov", "\t$dst, $src1, $src2",
506                 [(set DPR:$dst, (arm_fmdrr GPR:$src1, GPR:$src2))]> {
507   let Inst{7-6} = 0b00;
508 }
509
510 let neverHasSideEffects = 1 in
511 def VMOVSRR : AVConv5I<0b11000100, 0b1010,
512                      (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2),
513                 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2",
514                 [/* For disassembly only; pattern left blank */]> {
515   let Inst{7-6} = 0b00;
516 }
517
518 // FMRDH: SPR -> GPR
519 // FMRDL: SPR -> GPR
520 // FMRRS: SPR -> GPR
521 // FMRX:  SPR system reg -> GPR
522 // FMSRR: GPR -> SPR
523 // FMXR:  GPR -> VFP system reg
524
525
526 // Int -> FP:
527
528 class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
529                         bits<4> opcod4, dag oops, dag iops,
530                         InstrItinClass itin, string opc, string asm,
531                         list<dag> pattern>
532   : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
533              pattern> {
534   // Instruction operands.
535   bits<5> Dd;
536   bits<5> Sm;
537
538   // Encode instruction operands.
539   let Inst{3-0}   = Sm{4-1};
540   let Inst{5}     = Sm{0};
541   let Inst{15-12} = Dd{3-0};
542   let Inst{22}    = Dd{4};
543 }
544
545 class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
546                          bits<4> opcod4, dag oops, dag iops,InstrItinClass itin,
547                          string opc, string asm, list<dag> pattern>
548   : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
549               pattern> {
550   // Instruction operands.
551   bits<5> Sd;
552   bits<5> Sm;
553
554   // Encode instruction operands.
555   let Inst{3-0}   = Sm{4-1};
556   let Inst{5}     = Sm{0};
557   let Inst{15-12} = Sd{4-1};
558   let Inst{22}    = Sd{0};
559 }
560
561 def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
562                                (outs DPR:$Dd), (ins SPR:$Sm),
563                                IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm",
564                                [(set DPR:$Dd, (f64 (arm_sitof SPR:$Sm)))]> {
565   let Inst{7} = 1; // s32
566 }
567
568 def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
569                                 (outs SPR:$Sd),(ins SPR:$Sm),
570                                 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm",
571                                 [(set SPR:$Sd, (arm_sitof SPR:$Sm))]> {
572   let Inst{7} = 1; // s32
573 }
574
575 def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011,
576                                (outs DPR:$Dd), (ins SPR:$Sm),
577                                IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm",
578                                [(set DPR:$Dd, (f64 (arm_uitof SPR:$Sm)))]> {
579   let Inst{7} = 0; // u32
580 }
581
582 def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010,
583                                 (outs SPR:$Sd), (ins SPR:$Sm),
584                                 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm",
585                                 [(set SPR:$Sd, (arm_uitof SPR:$Sm))]> {
586   let Inst{7} = 0; // u32
587 }
588
589 // FP -> Int:
590
591 class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
592                         bits<4> opcod4, dag oops, dag iops,
593                         InstrItinClass itin, string opc, string asm,
594                         list<dag> pattern>
595   : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
596              pattern> {
597   // Instruction operands.
598   bits<5> Sd;
599   bits<5> Dm;
600
601   // Encode instruction operands.
602   let Inst{3-0}   = Dm{3-0};
603   let Inst{5}     = Dm{4};
604   let Inst{15-12} = Sd{4-1};
605   let Inst{22}    = Sd{0};
606 }
607
608 class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3,
609                          bits<4> opcod4, dag oops, dag iops,
610                          InstrItinClass itin, string opc, string asm,
611                          list<dag> pattern>
612   : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
613               pattern> {
614   // Instruction operands.
615   bits<5> Sd;
616   bits<5> Sm;
617
618   // Encode instruction operands.
619   let Inst{3-0}   = Sm{4-1};
620   let Inst{5}     = Sm{0};
621   let Inst{15-12} = Sd{4-1};
622   let Inst{22}    = Sd{0};
623 }
624
625 // Always set Z bit in the instruction, i.e. "round towards zero" variants.
626 def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
627                                 (outs SPR:$Sd), (ins DPR:$Dm),
628                                 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm",
629                                 [(set SPR:$Sd, (arm_ftosi (f64 DPR:$Dm)))]> {
630   let Inst{7} = 1; // Z bit
631 }
632
633 def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
634                                  (outs SPR:$Sd), (ins SPR:$Sm),
635                                  IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm",
636                                  [(set SPR:$Sd, (arm_ftosi SPR:$Sm))]> {
637   let Inst{7} = 1; // Z bit
638 }
639
640 def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
641                                (outs SPR:$Sd), (ins DPR:$Dm),
642                                IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm",
643                                [(set SPR:$Sd, (arm_ftoui (f64 DPR:$Dm)))]> {
644   let Inst{7} = 1; // Z bit
645 }
646
647 def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
648                                  (outs SPR:$Sd), (ins SPR:$Sm),
649                                  IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm",
650                                  [(set SPR:$Sd, (arm_ftoui SPR:$Sm))]> {
651   let Inst{7} = 1; // Z bit
652 }
653
654 // And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR.
655 // For disassembly only.
656 let Uses = [FPSCR] in {
657 // FIXME: Verify encoding after integrated assembler is working.
658 def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011,
659                                 (outs SPR:$Sd), (ins DPR:$Dm),
660                                 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm",
661                                 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>{
662   let Inst{7} = 0; // Z bit
663 }
664
665 def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010,
666                                  (outs SPR:$Sd), (ins SPR:$Sm),
667                                  IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm",
668                                  [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]> {
669   let Inst{7} = 0; // Z bit
670 }
671
672 def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011,
673                                 (outs SPR:$Sd), (ins DPR:$Dm),
674                                 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm",
675                                 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>{
676   let Inst{7} = 0; // Z bit
677 }
678
679 def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010,
680                                  (outs SPR:$Sd), (ins SPR:$Sm),
681                                  IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm",
682                                  [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]> {
683   let Inst{7} = 0; // Z bit
684 }
685 }
686
687 // Convert between floating-point and fixed-point
688 // Data type for fixed-point naming convention:
689 //   S16 (U=0, sx=0) -> SH
690 //   U16 (U=1, sx=0) -> UH
691 //   S32 (U=0, sx=1) -> SL
692 //   U32 (U=1, sx=1) -> UL
693
694 let Constraints = "$a = $dst" in {
695
696 // FP to Fixed-Point:
697
698 let isCodeGenOnly = 1 in {
699 def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0,
700                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
701                  IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits",
702                  [/* For disassembly only; pattern left blank */]>;
703
704 def VTOUHS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 0,
705                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
706                  IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits",
707                  [/* For disassembly only; pattern left blank */]>;
708
709 def VTOSLS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 1,
710                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
711                  IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits",
712                  [/* For disassembly only; pattern left blank */]>;
713
714 def VTOULS : AVConv1XI<0b11101, 0b11, 0b1111, 0b1010, 1,
715                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
716                  IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits",
717                  [/* For disassembly only; pattern left blank */]>;
718
719 def VTOSHD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 0,
720                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
721                  IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits",
722                  [/* For disassembly only; pattern left blank */]>;
723
724 def VTOUHD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 0,
725                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
726                  IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits",
727                  [/* For disassembly only; pattern left blank */]>;
728
729 def VTOSLD : AVConv1XI<0b11101, 0b11, 0b1110, 0b1011, 1,
730                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
731                  IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits",
732                  [/* For disassembly only; pattern left blank */]>;
733
734 def VTOULD : AVConv1XI<0b11101, 0b11, 0b1111, 0b1011, 1,
735                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
736                  IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits",
737                  [/* For disassembly only; pattern left blank */]>;
738 } // End of 'let isCodeGenOnly = 1 in'
739
740 // Fixed-Point to FP:
741
742 let isCodeGenOnly = 1 in {
743 def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0,
744                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
745                  IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits",
746                  [/* For disassembly only; pattern left blank */]>;
747
748 def VUHTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 0,
749                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
750                  IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits",
751                  [/* For disassembly only; pattern left blank */]>;
752
753 def VSLTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 1,
754                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
755                  IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits",
756                  [/* For disassembly only; pattern left blank */]>;
757
758 def VULTOS : AVConv1XI<0b11101, 0b11, 0b1011, 0b1010, 1,
759                        (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits),
760                  IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits",
761                  [/* For disassembly only; pattern left blank */]>;
762
763 def VSHTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 0,
764                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
765                  IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits",
766                  [/* For disassembly only; pattern left blank */]>;
767
768 def VUHTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 0,
769                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
770                  IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits",
771                  [/* For disassembly only; pattern left blank */]>;
772
773 def VSLTOD : AVConv1XI<0b11101, 0b11, 0b1010, 0b1011, 1,
774                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
775                  IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits",
776                  [/* For disassembly only; pattern left blank */]>;
777
778 def VULTOD : AVConv1XI<0b11101, 0b11, 0b1011, 0b1011, 1,
779                        (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits),
780                  IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits",
781                  [/* For disassembly only; pattern left blank */]>;
782 } // End of 'let isCodeGenOnly = 1 in'
783
784 } // End of 'let Constraints = "$src = $dst" in'
785
786 //===----------------------------------------------------------------------===//
787 // FP FMA Operations.
788 //
789
790 class ADbI_vmlX_Encode<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4,
791                        dag oops, dag iops, InstrItinClass itin, string opc,
792                        string asm, list<dag> pattern>
793   : ADbI_vmlX<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
794   // Instruction operands.
795   bits<5> Dd;
796   bits<5> Dn;
797   bits<5> Dm;
798
799   // Encode instruction operands.
800   let Inst{19-16} = Dn{3-0};
801   let Inst{7}     = Dn{4};
802   let Inst{15-12} = Dd{3-0};
803   let Inst{22}    = Dd{4};
804   let Inst{3-0}   = Dm{3-0};
805   let Inst{5}     = Dm{4};
806 }
807
808 def VMLAD : ADbI_vmlX_Encode<0b11100, 0b00, 0, 0,
809                              (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
810                              IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm",
811                              [(set DPR:$Dd, (fadd (fmul DPR:$Dn, DPR:$Dm),
812                                                   (f64 DPR:$Ddin)))]>,
813                              RegConstraint<"$Ddin = $Dd">;
814
815 def VMLAS : ASbIn_Encode<0b11100, 0b00, 0, 0,
816                          (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
817                          IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm",
818                          [(set SPR:$Sd, (fadd (fmul SPR:$Sn, SPR:$Sm),
819                                               SPR:$Sdin))]>,
820                          RegConstraint<"$Sdin = $Sd">;
821
822 def : Pat<(fadd DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
823           (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
824 def : Pat<(fadd SPR:$dstin, (fmul SPR:$a, SPR:$b)),
825           (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
826
827 def VMLSD : ADbI_vmlX_Encode<0b11100, 0b00, 1, 0,
828                              (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
829                              IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm",
830                              [(set DPR:$Dd, (fadd (fneg (fmul DPR:$Dn,DPR:$Dm)),
831                                                         (f64 DPR:$Ddin)))]>,
832                              RegConstraint<"$Ddin = $Dd">;
833
834 def VMLSS : ASbIn_Encode<0b11100, 0b00, 1, 0,
835                          (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
836                          IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm",
837                          [(set SPR:$Sd, (fadd (fneg (fmul SPR:$Sn, SPR:$Sm)),
838                                                     SPR:$Sdin))]>,
839                          RegConstraint<"$Sdin = $Sd">;
840
841 def : Pat<(fsub DPR:$dstin, (fmul DPR:$a, (f64 DPR:$b))),
842           (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
843 def : Pat<(fsub SPR:$dstin, (fmul SPR:$a, SPR:$b)),
844           (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
845
846 def VNMLAD : ADbI_vmlX_Encode<0b11100, 0b01, 1, 0,
847                               (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
848                               IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm",
849                               [(set DPR:$Dd,(fsub (fneg (fmul DPR:$Dn,DPR:$Dm)),
850                                                   (f64 DPR:$Ddin)))]>,
851                 RegConstraint<"$Ddin = $Dd">;
852
853 def VNMLAS : ASbI_Encode<0b11100, 0b01, 1, 0,
854                          (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
855                          IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm",
856                          [(set SPR:$Sd, (fsub (fneg (fmul SPR:$Sn, SPR:$Sm)),
857                                               SPR:$Sdin))]>,
858                          RegConstraint<"$Sdin = $Sd">;
859
860 def : Pat<(fsub (fneg (fmul DPR:$a, (f64 DPR:$b))), DPR:$dstin),
861           (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
862 def : Pat<(fsub (fneg (fmul SPR:$a, SPR:$b)), SPR:$dstin),
863           (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
864
865 def VNMLSD : ADbI_vmlX_Encode<0b11100, 0b01, 0, 0,
866                               (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm),
867                               IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm",
868                               [(set DPR:$Dd, (fsub (fmul DPR:$Dn, DPR:$Dm),
869                                                    (f64 DPR:$Ddin)))]>,
870                               RegConstraint<"$Ddin = $Dd">;
871
872 def VNMLSS : ASbI_Encode<0b11100, 0b01, 0, 0,
873                          (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm),
874                          IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm",
875                          [(set SPR:$Sd, (fsub (fmul SPR:$Sn, SPR:$Sm),
876                                               SPR:$Sdin))]>,
877                          RegConstraint<"$Sdin = $Sd">;
878
879 def : Pat<(fsub (fmul DPR:$a, (f64 DPR:$b)), DPR:$dstin),
880           (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>, Requires<[DontUseNEONForFP]>;
881 def : Pat<(fsub (fmul SPR:$a, SPR:$b), SPR:$dstin),
882           (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>, Requires<[DontUseNEONForFP]>;
883
884
885 //===----------------------------------------------------------------------===//
886 // FP Conditional moves.
887 //
888
889 let neverHasSideEffects = 1 in {
890 def VMOVDcc  : ADuI<0b11101, 0b11, 0b0000, 0b01, 0,
891                     (outs DPR:$dst), (ins DPR:$false, DPR:$true),
892                     IIC_fpUNA64, "vmov", ".f64\t$dst, $true",
893                 [/*(set DPR:$dst, (ARMcmov DPR:$false, DPR:$true, imm:$cc))*/]>,
894                     RegConstraint<"$false = $dst">;
895
896 def VMOVScc  : ASuI<0b11101, 0b11, 0b0000, 0b01, 0,
897                     (outs SPR:$dst), (ins SPR:$false, SPR:$true),
898                     IIC_fpUNA32, "vmov", ".f32\t$dst, $true",
899                 [/*(set SPR:$dst, (ARMcmov SPR:$false, SPR:$true, imm:$cc))*/]>,
900                     RegConstraint<"$false = $dst">;
901
902 def VNEGDcc  : ADuI<0b11101, 0b11, 0b0001, 0b01, 0,
903                     (outs DPR:$dst), (ins DPR:$false, DPR:$true),
904                     IIC_fpUNA64, "vneg", ".f64\t$dst, $true",
905                 [/*(set DPR:$dst, (ARMcneg DPR:$false, DPR:$true, imm:$cc))*/]>,
906                     RegConstraint<"$false = $dst">;
907
908 def VNEGScc  : ASuI<0b11101, 0b11, 0b0001, 0b01, 0,
909                     (outs SPR:$dst), (ins SPR:$false, SPR:$true),
910                     IIC_fpUNA32, "vneg", ".f32\t$dst, $true",
911                 [/*(set SPR:$dst, (ARMcneg SPR:$false, SPR:$true, imm:$cc))*/]>,
912                     RegConstraint<"$false = $dst">;
913 } // neverHasSideEffects
914
915 //===----------------------------------------------------------------------===//
916 // Misc.
917 //
918
919 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
920 // to APSR.
921 let Defs = [CPSR], Uses = [FPSCR] in
922 def FMSTAT : VFPAI<(outs), (ins), VFPMiscFrm, IIC_fpSTAT, "vmrs",
923                    "\tapsr_nzcv, fpscr",
924              [(arm_fmstat)]> {
925   let Inst{27-20} = 0b11101111;
926   let Inst{19-16} = 0b0001;
927   let Inst{15-12} = 0b1111;
928   let Inst{11-8}  = 0b1010;
929   let Inst{7}     = 0;
930   let Inst{6-5}   = 0b00;
931   let Inst{4}     = 1;
932   let Inst{3-0}   = 0b0000;
933 }
934
935 // FPSCR <-> GPR (for disassembly only)
936 let hasSideEffects = 1, Uses = [FPSCR] in
937 def VMRS : VFPAI<(outs GPR:$Rt), (ins), VFPMiscFrm, IIC_fpSTAT,
938                  "vmrs", "\t$Rt, fpscr",
939                  [(set GPR:$Rt, (int_arm_get_fpscr))]> {
940   // Instruction operand.
941   bits<4> Rt;
942
943   // Encode instruction operand.
944   let Inst{15-12} = Rt;
945
946   let Inst{27-20} = 0b11101111;
947   let Inst{19-16} = 0b0001;
948   let Inst{11-8}  = 0b1010;
949   let Inst{7}     = 0;
950   let Inst{6-5}   = 0b00;
951   let Inst{4}     = 1;
952   let Inst{3-0}   = 0b0000;
953 }
954
955 let Defs = [FPSCR] in 
956 def VMSR : VFPAI<(outs), (ins GPR:$src), VFPMiscFrm, IIC_fpSTAT, 
957                  "vmsr", "\tfpscr, $src",
958                  [(int_arm_set_fpscr GPR:$src)]> {
959   // Instruction operand.
960   bits<4> src;
961
962   // Encode instruction operand.
963   let Inst{15-12} = src;
964
965   let Inst{27-20} = 0b11101110;
966   let Inst{19-16} = 0b0001;
967   let Inst{11-8}  = 0b1010;
968   let Inst{7}     = 0;
969   let Inst{4}     = 1;
970 }
971
972 // Materialize FP immediates. VFP3 only.
973 let isReMaterializable = 1 in {
974 def FCONSTD : VFPAI<(outs DPR:$dst), (ins vfp_f64imm:$imm),
975                     VFPMiscFrm, IIC_fpUNA64,
976                     "vmov", ".f64\t$dst, $imm",
977                     [(set DPR:$dst, vfp_f64imm:$imm)]>, Requires<[HasVFP3]> {
978   let Inst{27-23} = 0b11101;
979   let Inst{21-20} = 0b11;
980   let Inst{11-9}  = 0b101;
981   let Inst{8}     = 1;
982   let Inst{7-4}   = 0b0000;
983 }
984
985 def FCONSTS : VFPAI<(outs SPR:$dst), (ins vfp_f32imm:$imm),
986                     VFPMiscFrm, IIC_fpUNA32,
987                     "vmov", ".f32\t$dst, $imm",
988                     [(set SPR:$dst, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> {
989   let Inst{27-23} = 0b11101;
990   let Inst{21-20} = 0b11;
991   let Inst{11-9}  = 0b101;
992   let Inst{8}     = 0;
993   let Inst{7-4}   = 0b0000;
994 }
995 }