Split out the "size" field from the encoding. The newer documentation has it as
[oota-llvm.git] / lib / Target / ARM / ARMInstrFormats.td
1 //===- ARMInstrFormats.td - ARM Instruction Formats --*- tablegen -*---------=//
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 //===----------------------------------------------------------------------===//
11 //
12 // ARM Instruction Format Definitions.
13 //
14
15 // Format specifies the encoding used by the instruction.  This is part of the
16 // ad-hoc solution used to emit machine instruction encodings by our machine
17 // code emitter.
18 class Format<bits<6> val> {
19   bits<6> Value = val;
20 }
21
22 def Pseudo        : Format<0>;
23 def MulFrm        : Format<1>;
24 def BrFrm         : Format<2>;
25 def BrMiscFrm     : Format<3>;
26
27 def DPFrm         : Format<4>;
28 def DPSoRegFrm    : Format<5>;
29
30 def LdFrm         : Format<6>;
31 def StFrm         : Format<7>;
32 def LdMiscFrm     : Format<8>;
33 def StMiscFrm     : Format<9>;
34 def LdStMulFrm    : Format<10>;
35
36 def LdStExFrm     : Format<11>;
37
38 def ArithMiscFrm  : Format<12>;
39 def SatFrm        : Format<13>;
40 def ExtFrm        : Format<14>;
41
42 def VFPUnaryFrm   : Format<15>;
43 def VFPBinaryFrm  : Format<16>;
44 def VFPConv1Frm   : Format<17>;
45 def VFPConv2Frm   : Format<18>;
46 def VFPConv3Frm   : Format<19>;
47 def VFPConv4Frm   : Format<20>;
48 def VFPConv5Frm   : Format<21>;
49 def VFPLdStFrm    : Format<22>;
50 def VFPLdStMulFrm : Format<23>;
51 def VFPMiscFrm    : Format<24>;
52
53 def ThumbFrm      : Format<25>;
54 def MiscFrm       : Format<26>;
55
56 def NGetLnFrm     : Format<27>;
57 def NSetLnFrm     : Format<28>;
58 def NDupFrm       : Format<29>;
59 def NLdStFrm      : Format<30>;
60 def N1RegModImmFrm: Format<31>;
61 def N2RegFrm      : Format<32>;
62 def NVCVTFrm      : Format<33>;
63 def NVDupLnFrm    : Format<34>;
64 def N2RegVShLFrm  : Format<35>;
65 def N2RegVShRFrm  : Format<36>;
66 def N3RegFrm      : Format<37>;
67 def N3RegVShFrm   : Format<38>;
68 def NVExtFrm      : Format<39>;
69 def NVMulSLFrm    : Format<40>;
70 def NVTBLFrm      : Format<41>;
71
72 // Misc flags.
73
74 // the instruction has a Rn register operand.
75 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
76 // it doesn't have a Rn operand.
77 class UnaryDP    { bit isUnaryDataProc = 1; }
78
79 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80 // a 16-bit Thumb instruction if certain conditions are met.
81 class Xform16Bit { bit canXformTo16Bit = 1; }
82
83 //===----------------------------------------------------------------------===//
84 // ARM Instruction flags.  These need to match ARMBaseInstrInfo.h.
85 //
86
87 // Addressing mode.
88 class AddrMode<bits<5> val> {
89   bits<5> Value = val;
90 }
91 def AddrModeNone    : AddrMode<0>;
92 def AddrMode1       : AddrMode<1>;
93 def AddrMode2       : AddrMode<2>;
94 def AddrMode3       : AddrMode<3>;
95 def AddrMode4       : AddrMode<4>;
96 def AddrMode5       : AddrMode<5>;
97 def AddrMode6       : AddrMode<6>;
98 def AddrModeT1_1    : AddrMode<7>;
99 def AddrModeT1_2    : AddrMode<8>;
100 def AddrModeT1_4    : AddrMode<9>;
101 def AddrModeT1_s    : AddrMode<10>;
102 def AddrModeT2_i12  : AddrMode<11>;
103 def AddrModeT2_i8   : AddrMode<12>;
104 def AddrModeT2_so   : AddrMode<13>;
105 def AddrModeT2_pc   : AddrMode<14>;
106 def AddrModeT2_i8s4 : AddrMode<15>;
107
108 // Instruction size.
109 class SizeFlagVal<bits<3> val> {
110   bits<3> Value = val;
111 }
112 def SizeInvalid  : SizeFlagVal<0>;  // Unset.
113 def SizeSpecial  : SizeFlagVal<1>;  // Pseudo or special.
114 def Size8Bytes   : SizeFlagVal<2>;
115 def Size4Bytes   : SizeFlagVal<3>;
116 def Size2Bytes   : SizeFlagVal<4>;
117
118 // Load / store index mode.
119 class IndexMode<bits<2> val> {
120   bits<2> Value = val;
121 }
122 def IndexModeNone : IndexMode<0>;
123 def IndexModePre  : IndexMode<1>;
124 def IndexModePost : IndexMode<2>;
125 def IndexModeUpd  : IndexMode<3>;
126
127 // Instruction execution domain.
128 class Domain<bits<2> val> {
129   bits<2> Value = val;
130 }
131 def GenericDomain : Domain<0>;
132 def VFPDomain     : Domain<1>; // Instructions in VFP domain only
133 def NeonDomain    : Domain<2>; // Instructions in Neon domain only
134 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
135
136 //===----------------------------------------------------------------------===//
137
138 // ARM special operands.
139 //
140
141 def CondCodeOperand : AsmOperandClass {
142   let Name = "CondCode";
143   let SuperClasses = [];
144 }
145
146 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
147 // register whose default is 0 (no register).
148 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
149                                      (ops (i32 14), (i32 zero_reg))> {
150   let PrintMethod = "printPredicateOperand";
151   let ParserMatchClass = CondCodeOperand;
152 }
153
154 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
155 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
156   let PrintMethod = "printSBitModifierOperand";
157 }
158
159 // Same as cc_out except it defaults to setting CPSR.
160 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
161   let PrintMethod = "printSBitModifierOperand";
162 }
163
164 // ARM special operands for disassembly only.
165 //
166
167 def cps_opt : Operand<i32> {
168   let PrintMethod = "printCPSOptionOperand";
169 }
170
171 def msr_mask : Operand<i32> {
172   let PrintMethod = "printMSRMaskOperand";
173 }
174
175 // A8.6.117, A8.6.118.  Different instructions are generated for #0 and #-0.
176 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
177 def neg_zero : Operand<i32> {
178   let PrintMethod = "printNegZeroOperand";
179 }
180
181 //===----------------------------------------------------------------------===//
182
183 // ARM Instruction templates.
184 //
185
186 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
187                    Format f, Domain d, string cstr, InstrItinClass itin>
188   : Instruction {
189   let Namespace = "ARM";
190
191   AddrMode AM = am;
192   SizeFlagVal SZ = sz;
193   IndexMode IM = im;
194   bits<2> IndexModeBits = IM.Value;
195   Format F = f;
196   bits<6> Form = F.Value;
197   Domain D = d;
198   bit isUnaryDataProc = 0;
199   bit canXformTo16Bit = 0;
200
201   // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
202   let TSFlags{4-0}   = AM.Value;
203   let TSFlags{7-5}   = SZ.Value;
204   let TSFlags{9-8}   = IndexModeBits;
205   let TSFlags{15-10} = Form;
206   let TSFlags{16}    = isUnaryDataProc;
207   let TSFlags{17}    = canXformTo16Bit;
208   let TSFlags{19-18} = D.Value;
209
210   let Constraints = cstr;
211   let Itinerary = itin;
212 }
213
214 class Encoding {
215   field bits<32> Inst;
216 }
217
218 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
219               Format f, Domain d, string cstr, InstrItinClass itin>
220   : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
221
222 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
223 // on by adding flavors to specific instructions.
224 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
225                 Format f, Domain d, string cstr, InstrItinClass itin>
226   : InstTemplate<am, sz, im, f, d, cstr, itin>;
227
228 class PseudoInst<dag oops, dag iops, InstrItinClass itin,
229                  string asm, list<dag> pattern>
230   : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
231             "", itin> {
232   let OutOperandList = oops;
233   let InOperandList = iops;
234   let AsmString = asm;
235   let Pattern = pattern;
236 }
237
238 // Almost all ARM instructions are predicable.
239 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
240         IndexMode im, Format f, InstrItinClass itin,
241         string opc, string asm, string cstr,
242         list<dag> pattern>
243   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
244   bits<4> p;
245   let Inst{31-28} = p;
246   let OutOperandList = oops;
247   let InOperandList = !con(iops, (ins pred:$p));
248   let AsmString = !strconcat(opc, "${p}", asm);
249   let Pattern = pattern;
250   list<Predicate> Predicates = [IsARM];
251 }
252
253 // A few are not predicable
254 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
255            IndexMode im, Format f, InstrItinClass itin,
256            string opc, string asm, string cstr,
257            list<dag> pattern>
258   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
259   let OutOperandList = oops;
260   let InOperandList = iops;
261   let AsmString = !strconcat(opc, asm);
262   let Pattern = pattern;
263   let isPredicable = 0;
264   list<Predicate> Predicates = [IsARM];
265 }
266
267 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
268 // operand since by default it's a zero register. It will become an implicit def
269 // once it's "flipped".
270 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
271          IndexMode im, Format f, InstrItinClass itin,
272          string opc, string asm, string cstr,
273          list<dag> pattern>
274   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
275   bits<4> p; // Predicate operand
276   let Inst{31-28} = p;
277   // FIXME: The 's' operand needs to be handled, but the current generic
278   //        get-value handlers don't know how to deal with it.
279
280   let OutOperandList = oops;
281   let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
282   let AsmString = !strconcat(opc, "${p}${s}", asm);
283   let Pattern = pattern;
284   list<Predicate> Predicates = [IsARM];
285 }
286
287 // Special cases
288 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
289          IndexMode im, Format f, InstrItinClass itin,
290          string asm, string cstr, list<dag> pattern>
291   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
292   let OutOperandList = oops;
293   let InOperandList = iops;
294   let AsmString = asm;
295   let Pattern = pattern;
296   list<Predicate> Predicates = [IsARM];
297 }
298
299 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
300          string opc, string asm, list<dag> pattern>
301   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
302       opc, asm, "", pattern>;
303 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
304           string opc, string asm, list<dag> pattern>
305   : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
306        opc, asm, "", pattern>;
307 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
308           string asm, list<dag> pattern>
309   : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
310        asm, "", pattern>;
311 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
312             string opc, string asm, list<dag> pattern>
313   : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
314          opc, asm, "", pattern>;
315
316 // Ctrl flow instructions
317 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
318           string opc, string asm, list<dag> pattern>
319   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
320       opc, asm, "", pattern> {
321   let Inst{27-24} = opcod;
322 }
323 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
324            string asm, list<dag> pattern>
325   : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
326        asm, "", pattern> {
327   let Inst{27-24} = opcod;
328 }
329 class ABXIx2<dag oops, dag iops, InstrItinClass itin,
330              string asm, list<dag> pattern>
331   : XI<oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, Pseudo, itin,
332        asm, "", pattern>;
333
334 // BR_JT instructions
335 class JTI<dag oops, dag iops, InstrItinClass itin,
336           string asm, list<dag> pattern>
337   : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
338        asm, "", pattern>;
339
340 // Atomic load/store instructions
341 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
342               string opc, string asm, list<dag> pattern>
343   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
344       opc, asm, "", pattern> {
345   let Inst{27-23} = 0b00011;
346   let Inst{22-21} = opcod;
347   let Inst{20}    = 1;
348   let Inst{11-0}  = 0b111110011111;
349 }
350 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
351               string opc, string asm, list<dag> pattern>
352   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
353       opc, asm, "", pattern> {
354   let Inst{27-23} = 0b00011;
355   let Inst{22-21} = opcod;
356   let Inst{20}    = 0;
357   let Inst{11-4}  = 0b11111001;
358 }
359
360 // addrmode1 instructions
361 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
362           string opc, string asm, list<dag> pattern>
363   : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
364       opc, asm, "", pattern> {
365   let Inst{24-21} = opcod;
366   let Inst{27-26} = 0b00;
367 }
368 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
369            string opc, string asm, list<dag> pattern>
370   : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
371        opc, asm, "", pattern> {
372   let Inst{24-21} = opcod;
373   let Inst{27-26} = 0b00;
374 }
375 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
376            string asm, list<dag> pattern>
377   : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
378        asm, "", pattern> {
379   let Inst{24-21} = opcod;
380   let Inst{27-26} = 0b00;
381 }
382 class AI1x2<dag oops, dag iops, Format f, InstrItinClass itin,
383             string opc, string asm, list<dag> pattern>
384   : I<oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, itin,
385       opc, asm, "", pattern>;
386
387
388 // addrmode2 loads and stores
389 class AI2<dag oops, dag iops, Format f, InstrItinClass itin,
390           string opc, string asm, list<dag> pattern>
391   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
392       opc, asm, "", pattern> {
393   let Inst{27-26} = 0b01;
394 }
395
396 // loads
397 class AI2ldw<dag oops, dag iops, Format f, InstrItinClass itin,
398              string opc, string asm, list<dag> pattern>
399   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
400       opc, asm, "", pattern> {
401   let Inst{20}    = 1; // L bit
402   let Inst{21}    = 0; // W bit
403   let Inst{22}    = 0; // B bit
404   let Inst{24}    = 1; // P bit
405   let Inst{27-26} = 0b01;
406 }
407 class AXI2ldw<dag oops, dag iops, Format f, InstrItinClass itin,
408               string asm, list<dag> pattern>
409   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
410        asm, "", pattern> {
411   let Inst{20}    = 1; // L bit
412   let Inst{21}    = 0; // W bit
413   let Inst{22}    = 0; // B bit
414   let Inst{24}    = 1; // P bit
415   let Inst{27-26} = 0b01;
416 }
417 class AI2ldb<dag oops, dag iops, Format f, InstrItinClass itin,
418              string opc, string asm, list<dag> pattern>
419   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
420       opc, asm, "", pattern> {
421   let Inst{20}    = 1; // L bit
422   let Inst{21}    = 0; // W bit
423   let Inst{22}    = 1; // B bit
424   let Inst{24}    = 1; // P bit
425   let Inst{27-26} = 0b01;
426 }
427 class AXI2ldb<dag oops, dag iops, Format f, InstrItinClass itin,
428               string asm, list<dag> pattern>
429   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
430        asm, "", pattern> {
431   let Inst{20}    = 1; // L bit
432   let Inst{21}    = 0; // W bit
433   let Inst{22}    = 1; // B bit
434   let Inst{24}    = 1; // P bit
435   let Inst{27-26} = 0b01;
436 }
437
438 // stores
439 class AI2stw<dag oops, dag iops, Format f, InstrItinClass itin,
440              string opc, string asm, list<dag> pattern>
441   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
442       opc, asm, "", pattern> {
443   let Inst{20}    = 0; // L bit
444   let Inst{21}    = 0; // W bit
445   let Inst{22}    = 0; // B bit
446   let Inst{24}    = 1; // P bit
447   let Inst{27-26} = 0b01;
448 }
449 class AXI2stw<dag oops, dag iops, Format f, InstrItinClass itin,
450               string asm, list<dag> pattern>
451   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
452        asm, "", pattern> {
453   let Inst{20}    = 0; // L bit
454   let Inst{21}    = 0; // W bit
455   let Inst{22}    = 0; // B bit
456   let Inst{24}    = 1; // P bit
457   let Inst{27-26} = 0b01;
458 }
459 class AI2stb<dag oops, dag iops, Format f, InstrItinClass itin,
460              string opc, string asm, list<dag> pattern>
461   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
462       opc, asm, "", pattern> {
463   let Inst{20}    = 0; // L bit
464   let Inst{21}    = 0; // W bit
465   let Inst{22}    = 1; // B bit
466   let Inst{24}    = 1; // P bit
467   let Inst{27-26} = 0b01;
468 }
469 class AXI2stb<dag oops, dag iops, Format f, InstrItinClass itin,
470               string asm, list<dag> pattern>
471   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, itin,
472        asm, "", pattern> {
473   let Inst{20}    = 0; // L bit
474   let Inst{21}    = 0; // W bit
475   let Inst{22}    = 1; // B bit
476   let Inst{24}    = 1; // P bit
477   let Inst{27-26} = 0b01;
478 }
479
480 // Pre-indexed loads
481 class AI2ldwpr<dag oops, dag iops, Format f, InstrItinClass itin,
482                string opc, string asm, string cstr, list<dag> pattern>
483   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
484       opc, asm, cstr, pattern> {
485   let Inst{20}    = 1; // L bit
486   let Inst{21}    = 1; // W bit
487   let Inst{22}    = 0; // B bit
488   let Inst{24}    = 1; // P bit
489   let Inst{27-26} = 0b01;
490 }
491 class AI2ldbpr<dag oops, dag iops, Format f, InstrItinClass itin,
492                string opc, string asm, string cstr, list<dag> pattern>
493   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
494       opc, asm, cstr, pattern> {
495   let Inst{20}    = 1; // L bit
496   let Inst{21}    = 1; // W bit
497   let Inst{22}    = 1; // B bit
498   let Inst{24}    = 1; // P bit
499   let Inst{27-26} = 0b01;
500 }
501
502 // Pre-indexed stores
503 class AI2stwpr<dag oops, dag iops, Format f, InstrItinClass itin,
504                string opc, string asm, string cstr, list<dag> pattern>
505   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
506       opc, asm, cstr, pattern> {
507   let Inst{20}    = 0; // L bit
508   let Inst{21}    = 1; // W bit
509   let Inst{22}    = 0; // B bit
510   let Inst{24}    = 1; // P bit
511   let Inst{27-26} = 0b01;
512 }
513 class AI2stbpr<dag oops, dag iops, Format f, InstrItinClass itin,
514                string opc, string asm, string cstr, list<dag> pattern>
515   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, itin,
516       opc, asm, cstr, pattern> {
517   let Inst{20}    = 0; // L bit
518   let Inst{21}    = 1; // W bit
519   let Inst{22}    = 1; // B bit
520   let Inst{24}    = 1; // P bit
521   let Inst{27-26} = 0b01;
522 }
523
524 // Post-indexed loads
525 class AI2ldwpo<dag oops, dag iops, Format f, InstrItinClass itin,
526                string opc, string asm, string cstr, list<dag> pattern>
527   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
528       opc, asm, cstr,pattern> {
529   let Inst{20}    = 1; // L bit
530   let Inst{21}    = 0; // W bit
531   let Inst{22}    = 0; // B bit
532   let Inst{24}    = 0; // P bit
533   let Inst{27-26} = 0b01;
534 }
535 class AI2ldbpo<dag oops, dag iops, Format f, InstrItinClass itin,
536                string opc, string asm, string cstr, list<dag> pattern>
537   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
538       opc, asm, cstr,pattern> {
539   let Inst{20}    = 1; // L bit
540   let Inst{21}    = 0; // W bit
541   let Inst{22}    = 1; // B bit
542   let Inst{24}    = 0; // P bit
543   let Inst{27-26} = 0b01;
544 }
545
546 // Post-indexed stores
547 class AI2stwpo<dag oops, dag iops, Format f, InstrItinClass itin,
548                string opc, string asm, string cstr, list<dag> pattern>
549   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
550       opc, asm, cstr,pattern> {
551   let Inst{20}    = 0; // L bit
552   let Inst{21}    = 0; // W bit
553   let Inst{22}    = 0; // B bit
554   let Inst{24}    = 0; // P bit
555   let Inst{27-26} = 0b01;
556 }
557 class AI2stbpo<dag oops, dag iops, Format f, InstrItinClass itin,
558                string opc, string asm, string cstr, list<dag> pattern>
559   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, itin,
560       opc, asm, cstr,pattern> {
561   let Inst{20}    = 0; // L bit
562   let Inst{21}    = 0; // W bit
563   let Inst{22}    = 1; // B bit
564   let Inst{24}    = 0; // P bit
565   let Inst{27-26} = 0b01;
566 }
567
568 // addrmode3 instructions
569 class AI3<dag oops, dag iops, Format f, InstrItinClass itin,
570           string opc, string asm, list<dag> pattern>
571   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
572       opc, asm, "", pattern>;
573 class AXI3<dag oops, dag iops, Format f, InstrItinClass itin,
574            string asm, list<dag> pattern>
575   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
576        asm, "", pattern>;
577
578 // loads
579 class AI3ldh<dag oops, dag iops, Format f, InstrItinClass itin,
580              string opc, string asm, list<dag> pattern>
581   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
582       opc, asm, "", pattern> {
583   let Inst{4}     = 1;
584   let Inst{5}     = 1; // H bit
585   let Inst{6}     = 0; // S bit
586   let Inst{7}     = 1;
587   let Inst{20}    = 1; // L bit
588   let Inst{21}    = 0; // W bit
589   let Inst{24}    = 1; // P bit
590   let Inst{27-25} = 0b000;
591 }
592 class AXI3ldh<dag oops, dag iops, Format f, InstrItinClass itin,
593               string asm, list<dag> pattern>
594   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
595        asm, "", pattern> {
596   let Inst{4}     = 1;
597   let Inst{5}     = 1; // H bit
598   let Inst{6}     = 0; // S bit
599   let Inst{7}     = 1;
600   let Inst{20}    = 1; // L bit
601   let Inst{21}    = 0; // W bit
602   let Inst{24}    = 1; // P bit
603 }
604 class AI3ldsh<dag oops, dag iops, Format f, InstrItinClass itin,
605               string opc, string asm, list<dag> pattern>
606   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
607       opc, asm, "", pattern> {
608   let Inst{4}     = 1;
609   let Inst{5}     = 1; // H bit
610   let Inst{6}     = 1; // S bit
611   let Inst{7}     = 1;
612   let Inst{20}    = 1; // L bit
613   let Inst{21}    = 0; // W bit
614   let Inst{24}    = 1; // P bit
615   let Inst{27-25} = 0b000;
616 }
617 class AXI3ldsh<dag oops, dag iops, Format f, InstrItinClass itin,
618                string asm, list<dag> pattern>
619   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
620        asm, "", pattern> {
621   let Inst{4}     = 1;
622   let Inst{5}     = 1; // H bit
623   let Inst{6}     = 1; // S bit
624   let Inst{7}     = 1;
625   let Inst{20}    = 1; // L bit
626   let Inst{21}    = 0; // W bit
627   let Inst{24}    = 1; // P bit
628 }
629 class AI3ldsb<dag oops, dag iops, Format f, InstrItinClass itin,
630               string opc, string asm, list<dag> pattern>
631   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
632       opc, asm, "", pattern> {
633   let Inst{4}     = 1;
634   let Inst{5}     = 0; // H bit
635   let Inst{6}     = 1; // S bit
636   let Inst{7}     = 1;
637   let Inst{20}    = 1; // L bit
638   let Inst{21}    = 0; // W bit
639   let Inst{24}    = 1; // P bit
640   let Inst{27-25} = 0b000;
641 }
642 class AXI3ldsb<dag oops, dag iops, Format f, InstrItinClass itin,
643                string asm, list<dag> pattern>
644   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
645        asm, "", pattern> {
646   let Inst{4}     = 1;
647   let Inst{5}     = 0; // H bit
648   let Inst{6}     = 1; // S bit
649   let Inst{7}     = 1;
650   let Inst{20}    = 1; // L bit
651   let Inst{21}    = 0; // W bit
652   let Inst{24}    = 1; // P bit
653 }
654 class AI3ldd<dag oops, dag iops, Format f, InstrItinClass itin,
655              string opc, string asm, list<dag> pattern>
656   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
657       opc, asm, "", pattern> {
658   let Inst{4}     = 1;
659   let Inst{5}     = 0; // H bit
660   let Inst{6}     = 1; // S bit
661   let Inst{7}     = 1;
662   let Inst{20}    = 0; // L bit
663   let Inst{21}    = 0; // W bit
664   let Inst{24}    = 1; // P bit
665   let Inst{27-25} = 0b000;
666 }
667
668 // stores
669 class AI3sth<dag oops, dag iops, Format f, InstrItinClass itin,
670              string opc, string asm, list<dag> pattern>
671   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
672       opc, asm, "", pattern> {
673   let Inst{4}     = 1;
674   let Inst{5}     = 1; // H bit
675   let Inst{6}     = 0; // S bit
676   let Inst{7}     = 1;
677   let Inst{20}    = 0; // L bit
678   let Inst{21}    = 0; // W bit
679   let Inst{24}    = 1; // P bit
680   let Inst{27-25} = 0b000;
681 }
682 class AXI3sth<dag oops, dag iops, Format f, InstrItinClass itin,
683               string asm, list<dag> pattern>
684   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
685        asm, "", pattern> {
686   let Inst{4}     = 1;
687   let Inst{5}     = 1; // H bit
688   let Inst{6}     = 0; // S bit
689   let Inst{7}     = 1;
690   let Inst{20}    = 0; // L bit
691   let Inst{21}    = 0; // W bit
692   let Inst{24}    = 1; // P bit
693 }
694 class AI3std<dag oops, dag iops, Format f, InstrItinClass itin,
695              string opc, string asm, list<dag> pattern>
696   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
697       opc, asm, "", pattern> {
698   let Inst{4}     = 1;
699   let Inst{5}     = 1; // H bit
700   let Inst{6}     = 1; // S bit
701   let Inst{7}     = 1;
702   let Inst{20}    = 0; // L bit
703   let Inst{21}    = 0; // W bit
704   let Inst{24}    = 1; // P bit
705   let Inst{27-25} = 0b000;
706 }
707
708 // Pre-indexed loads
709 class AI3ldhpr<dag oops, dag iops, Format f, InstrItinClass itin,
710                string opc, string asm, string cstr, list<dag> pattern>
711   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
712       opc, asm, cstr, pattern> {
713   let Inst{4}     = 1;
714   let Inst{5}     = 1; // H bit
715   let Inst{6}     = 0; // S bit
716   let Inst{7}     = 1;
717   let Inst{20}    = 1; // L bit
718   let Inst{21}    = 1; // W bit
719   let Inst{24}    = 1; // P bit
720   let Inst{27-25} = 0b000;
721 }
722 class AI3ldshpr<dag oops, dag iops, Format f, InstrItinClass itin,
723                 string opc, string asm, string cstr, list<dag> pattern>
724   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
725       opc, asm, cstr, pattern> {
726   let Inst{4}     = 1;
727   let Inst{5}     = 1; // H bit
728   let Inst{6}     = 1; // S bit
729   let Inst{7}     = 1;
730   let Inst{20}    = 1; // L bit
731   let Inst{21}    = 1; // W bit
732   let Inst{24}    = 1; // P bit
733   let Inst{27-25} = 0b000;
734 }
735 class AI3ldsbpr<dag oops, dag iops, Format f, InstrItinClass itin,
736                 string opc, string asm, string cstr, list<dag> pattern>
737   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
738       opc, asm, cstr, pattern> {
739   let Inst{4}     = 1;
740   let Inst{5}     = 0; // H bit
741   let Inst{6}     = 1; // S bit
742   let Inst{7}     = 1;
743   let Inst{20}    = 1; // L bit
744   let Inst{21}    = 1; // W bit
745   let Inst{24}    = 1; // P bit
746   let Inst{27-25} = 0b000;
747 }
748 class AI3lddpr<dag oops, dag iops, Format f, InstrItinClass itin,
749              string opc, string asm, string cstr, list<dag> pattern>
750   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
751       opc, asm, cstr, pattern> {
752   let Inst{4}     = 1;
753   let Inst{5}     = 0; // H bit
754   let Inst{6}     = 1; // S bit
755   let Inst{7}     = 1;
756   let Inst{20}    = 0; // L bit
757   let Inst{21}    = 1; // W bit
758   let Inst{24}    = 1; // P bit
759   let Inst{27-25} = 0b000;
760 }
761
762
763 // Pre-indexed stores
764 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
765                string opc, string asm, string cstr, list<dag> pattern>
766   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
767       opc, asm, cstr, pattern> {
768   let Inst{4}     = 1;
769   let Inst{5}     = 1; // H bit
770   let Inst{6}     = 0; // S bit
771   let Inst{7}     = 1;
772   let Inst{20}    = 0; // L bit
773   let Inst{21}    = 1; // W bit
774   let Inst{24}    = 1; // P bit
775   let Inst{27-25} = 0b000;
776 }
777 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
778              string opc, string asm, string cstr, list<dag> pattern>
779   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
780       opc, asm, cstr, pattern> {
781   let Inst{4}     = 1;
782   let Inst{5}     = 1; // H bit
783   let Inst{6}     = 1; // S bit
784   let Inst{7}     = 1;
785   let Inst{20}    = 0; // L bit
786   let Inst{21}    = 1; // W bit
787   let Inst{24}    = 1; // P bit
788   let Inst{27-25} = 0b000;
789 }
790
791 // Post-indexed loads
792 class AI3ldhpo<dag oops, dag iops, Format f, InstrItinClass itin,
793                string opc, string asm, string cstr, list<dag> pattern>
794   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
795       opc, asm, cstr,pattern> {
796   let Inst{4}     = 1;
797   let Inst{5}     = 1; // H bit
798   let Inst{6}     = 0; // S bit
799   let Inst{7}     = 1;
800   let Inst{20}    = 1; // L bit
801   let Inst{21}    = 0; // W bit
802   let Inst{24}    = 0; // P bit
803   let Inst{27-25} = 0b000;
804 }
805 class AI3ldshpo<dag oops, dag iops, Format f, InstrItinClass itin,
806                 string opc, string asm, string cstr, list<dag> pattern>
807   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
808       opc, asm, cstr,pattern> {
809   let Inst{4}     = 1;
810   let Inst{5}     = 1; // H bit
811   let Inst{6}     = 1; // S bit
812   let Inst{7}     = 1;
813   let Inst{20}    = 1; // L bit
814   let Inst{21}    = 0; // W bit
815   let Inst{24}    = 0; // P bit
816   let Inst{27-25} = 0b000;
817 }
818 class AI3ldsbpo<dag oops, dag iops, Format f, InstrItinClass itin,
819                 string opc, string asm, string cstr, list<dag> pattern>
820   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
821       opc, asm, cstr,pattern> {
822   let Inst{4}     = 1;
823   let Inst{5}     = 0; // H bit
824   let Inst{6}     = 1; // S bit
825   let Inst{7}     = 1;
826   let Inst{20}    = 1; // L bit
827   let Inst{21}    = 0; // W bit
828   let Inst{24}    = 0; // P bit
829   let Inst{27-25} = 0b000;
830 }
831 class AI3lddpo<dag oops, dag iops, Format f, InstrItinClass itin,
832              string opc, string asm, string cstr, list<dag> pattern>
833   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
834       opc, asm, cstr, pattern> {
835   let Inst{4}     = 1;
836   let Inst{5}     = 0; // H bit
837   let Inst{6}     = 1; // S bit
838   let Inst{7}     = 1;
839   let Inst{20}    = 0; // L bit
840   let Inst{21}    = 0; // W bit
841   let Inst{24}    = 0; // P bit
842   let Inst{27-25} = 0b000;
843 }
844
845 // Post-indexed stores
846 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
847                string opc, string asm, string cstr, list<dag> pattern>
848   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
849       opc, asm, cstr,pattern> {
850   let Inst{4}     = 1;
851   let Inst{5}     = 1; // H bit
852   let Inst{6}     = 0; // S bit
853   let Inst{7}     = 1;
854   let Inst{20}    = 0; // L bit
855   let Inst{21}    = 0; // W bit
856   let Inst{24}    = 0; // P bit
857   let Inst{27-25} = 0b000;
858 }
859 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
860              string opc, string asm, string cstr, list<dag> pattern>
861   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
862       opc, asm, cstr, pattern> {
863   let Inst{4}     = 1;
864   let Inst{5}     = 1; // H bit
865   let Inst{6}     = 1; // S bit
866   let Inst{7}     = 1;
867   let Inst{20}    = 0; // L bit
868   let Inst{21}    = 0; // W bit
869   let Inst{24}    = 0; // P bit
870   let Inst{27-25} = 0b000;
871 }
872
873 // addrmode4 instructions
874 class AXI4ld<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
875              string asm, string cstr, list<dag> pattern>
876   : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin,
877        asm, cstr, pattern> {
878   let Inst{20}    = 1; // L bit
879   let Inst{22}    = 0; // S bit
880   let Inst{27-25} = 0b100;
881 }
882 class AXI4st<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
883              string asm, string cstr, list<dag> pattern>
884   : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin,
885        asm, cstr, pattern> {
886   let Inst{20}    = 0; // L bit
887   let Inst{22}    = 0; // S bit
888   let Inst{27-25} = 0b100;
889 }
890
891 // Unsigned multiply, multiply-accumulate instructions.
892 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
893              string opc, string asm, list<dag> pattern>
894   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
895       opc, asm, "", pattern> {
896   let Inst{7-4}   = 0b1001;
897   let Inst{20}    = 0; // S bit
898   let Inst{27-21} = opcod;
899 }
900 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
901               string opc, string asm, list<dag> pattern>
902   : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
903        opc, asm, "", pattern> {
904   let Inst{7-4}   = 0b1001;
905   let Inst{27-21} = opcod;
906 }
907
908 // Most significant word multiply
909 class AMul2I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
910              string opc, string asm, list<dag> pattern>
911   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
912       opc, asm, "", pattern> {
913   let Inst{7-4}   = 0b1001;
914   let Inst{20}    = 1;
915   let Inst{27-21} = opcod;
916 }
917
918 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
919 class AMulxyI<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
920               string opc, string asm, list<dag> pattern>
921   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
922       opc, asm, "", pattern> {
923   let Inst{4}     = 0;
924   let Inst{7}     = 1;
925   let Inst{20}    = 0;
926   let Inst{27-21} = opcod;
927 }
928
929 // Extend instructions.
930 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
931             string opc, string asm, list<dag> pattern>
932   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
933       opc, asm, "", pattern> {
934   let Inst{7-4}   = 0b0111;
935   let Inst{27-20} = opcod;
936 }
937
938 // Misc Arithmetic instructions.
939 class AMiscA1I<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
940                string opc, string asm, list<dag> pattern>
941   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
942       opc, asm, "", pattern> {
943   let Inst{27-20} = opcod;
944 }
945
946 //===----------------------------------------------------------------------===//
947
948 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
949 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
950   list<Predicate> Predicates = [IsARM];
951 }
952 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
953   list<Predicate> Predicates = [IsARM, HasV5TE];
954 }
955 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
956   list<Predicate> Predicates = [IsARM, HasV6];
957 }
958
959 //===----------------------------------------------------------------------===//
960 //
961 // Thumb Instruction Format Definitions.
962 //
963
964 // TI - Thumb instruction.
965
966 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
967              InstrItinClass itin, string asm, string cstr, list<dag> pattern>
968   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
969   let OutOperandList = oops;
970   let InOperandList = iops;
971   let AsmString = asm;
972   let Pattern = pattern;
973   list<Predicate> Predicates = [IsThumb];
974 }
975
976 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
977   : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
978
979 // Two-address instructions
980 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
981           list<dag> pattern>
982   : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
983            pattern>;
984
985 // tBL, tBX 32-bit instructions
986 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
987            dag oops, dag iops, InstrItinClass itin, string asm,
988            list<dag> pattern>
989     : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
990       Encoding {
991   let Inst{31-27} = opcod1;
992   let Inst{15-14} = opcod2;
993   let Inst{12}    = opcod3;
994 }
995
996 // BR_JT instructions
997 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
998            list<dag> pattern>
999   : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1000
1001 // Thumb1 only
1002 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1003               InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1004   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1005   let OutOperandList = oops;
1006   let InOperandList = iops;
1007   let AsmString = asm;
1008   let Pattern = pattern;
1009   list<Predicate> Predicates = [IsThumb1Only];
1010 }
1011
1012 class T1I<dag oops, dag iops, InstrItinClass itin,
1013           string asm, list<dag> pattern>
1014   : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
1015 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1016             string asm, list<dag> pattern>
1017   : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1018 class T1JTI<dag oops, dag iops, InstrItinClass itin,
1019             string asm, list<dag> pattern>
1020   : Thumb1I<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1021
1022 // Two-address instructions
1023 class T1It<dag oops, dag iops, InstrItinClass itin,
1024            string asm, string cstr, list<dag> pattern>
1025   : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
1026             asm, cstr, pattern>;
1027
1028 // Thumb1 instruction that can either be predicated or set CPSR.
1029 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1030                InstrItinClass itin,
1031                string opc, string asm, string cstr, list<dag> pattern>
1032   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1033   let OutOperandList = !con(oops, (outs s_cc_out:$s));
1034   let InOperandList = !con(iops, (ins pred:$p));
1035   let AsmString = !strconcat(opc, "${s}${p}", asm);
1036   let Pattern = pattern;
1037   list<Predicate> Predicates = [IsThumb1Only];
1038 }
1039
1040 class T1sI<dag oops, dag iops, InstrItinClass itin,
1041            string opc, string asm, list<dag> pattern>
1042   : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
1043
1044 // Two-address instructions
1045 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1046             string opc, string asm, list<dag> pattern>
1047   : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
1048              "$lhs = $dst", pattern>;
1049
1050 // Thumb1 instruction that can be predicated.
1051 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1052                InstrItinClass itin,
1053                string opc, string asm, string cstr, list<dag> pattern>
1054   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1055   let OutOperandList = oops;
1056   let InOperandList = !con(iops, (ins pred:$p));
1057   let AsmString = !strconcat(opc, "${p}", asm);
1058   let Pattern = pattern;
1059   list<Predicate> Predicates = [IsThumb1Only];
1060 }
1061
1062 class T1pI<dag oops, dag iops, InstrItinClass itin,
1063            string opc, string asm, list<dag> pattern>
1064   : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
1065
1066 // Two-address instructions
1067 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1068             string opc, string asm, list<dag> pattern>
1069   : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
1070              "$lhs = $dst", pattern>;
1071
1072 class T1pI1<dag oops, dag iops, InstrItinClass itin,
1073             string opc, string asm, list<dag> pattern>
1074   : Thumb1pI<oops, iops, AddrModeT1_1, Size2Bytes, itin, opc, asm, "", pattern>;
1075 class T1pI2<dag oops, dag iops, InstrItinClass itin,
1076             string opc, string asm, list<dag> pattern>
1077   : Thumb1pI<oops, iops, AddrModeT1_2, Size2Bytes, itin, opc, asm, "", pattern>;
1078 class T1pI4<dag oops, dag iops, InstrItinClass itin,
1079             string opc, string asm, list<dag> pattern>
1080   : Thumb1pI<oops, iops, AddrModeT1_4, Size2Bytes, itin, opc, asm, "", pattern>;
1081 class T1pIs<dag oops, dag iops,
1082             InstrItinClass itin, string opc, string asm, list<dag> pattern>
1083   : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
1084
1085 class Encoding16 : Encoding {
1086   let Inst{31-16} = 0x0000;
1087 }
1088
1089 // A6.2 16-bit Thumb instruction encoding
1090 class T1Encoding<bits<6> opcode> : Encoding16 {
1091   let Inst{15-10} = opcode;
1092 }
1093
1094 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1095 class T1General<bits<5> opcode> : Encoding16 {
1096   let Inst{15-14} = 0b00;
1097   let Inst{13-9} = opcode;
1098 }
1099
1100 // A6.2.2 Data-processing encoding.
1101 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1102   let Inst{15-10} = 0b010000;
1103   let Inst{9-6} = opcode;
1104 }
1105
1106 // A6.2.3 Special data instructions and branch and exchange encoding.
1107 class T1Special<bits<4> opcode> : Encoding16 {
1108   let Inst{15-10} = 0b010001;
1109   let Inst{9-6} = opcode;
1110 }
1111
1112 // A6.2.4 Load/store single data item encoding.
1113 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1114   let Inst{15-12} = opA;
1115   let Inst{11-9}  = opB;
1116 }
1117 class T1LdSt<bits<3> opB>     : T1LoadStore<0b0101, opB>;
1118 class T1LdSt4Imm<bits<3> opB> : T1LoadStore<0b0110, opB>; // Immediate, 4 bytes
1119 class T1LdSt1Imm<bits<3> opB> : T1LoadStore<0b0111, opB>; // Immediate, 1 byte
1120 class T1LdSt2Imm<bits<3> opB> : T1LoadStore<0b1000, opB>; // Immediate, 2 bytes
1121 class T1LdStSP<bits<3> opB>   : T1LoadStore<0b1001, opB>; // SP relative
1122
1123 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1124 class T1Misc<bits<7> opcode> : Encoding16 {
1125   let Inst{15-12} = 0b1011;
1126   let Inst{11-5} = opcode;
1127 }
1128
1129 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1130 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1131               InstrItinClass itin,
1132               string opc, string asm, string cstr, list<dag> pattern>
1133   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1134   let OutOperandList = oops;
1135   let InOperandList = !con(iops, (ins pred:$p));
1136   let AsmString = !strconcat(opc, "${p}", asm);
1137   let Pattern = pattern;
1138   list<Predicate> Predicates = [IsThumb2];
1139 }
1140
1141 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1142 // input operand since by default it's a zero register. It will become an
1143 // implicit def once it's "flipped".
1144 // 
1145 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1146 // more consistent.
1147 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1148                InstrItinClass itin,
1149                string opc, string asm, string cstr, list<dag> pattern>
1150   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1151   let OutOperandList = oops;
1152   let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1153   let AsmString = !strconcat(opc, "${s}${p}", asm);
1154   let Pattern = pattern;
1155   list<Predicate> Predicates = [IsThumb2];
1156 }
1157
1158 // Special cases
1159 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1160                InstrItinClass itin,
1161                string asm, string cstr, list<dag> pattern>
1162   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1163   let OutOperandList = oops;
1164   let InOperandList = iops;
1165   let AsmString = asm;
1166   let Pattern = pattern;
1167   list<Predicate> Predicates = [IsThumb2];
1168 }
1169
1170 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1171               InstrItinClass itin,
1172               string asm, string cstr, list<dag> pattern>
1173   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1174   let OutOperandList = oops;
1175   let InOperandList = iops;
1176   let AsmString = asm;
1177   let Pattern = pattern;
1178   list<Predicate> Predicates = [IsThumb1Only];
1179 }
1180
1181 class T2I<dag oops, dag iops, InstrItinClass itin,
1182           string opc, string asm, list<dag> pattern>
1183   : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1184 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1185              string opc, string asm, list<dag> pattern>
1186   : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
1187 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1188             string opc, string asm, list<dag> pattern>
1189   : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1190 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1191             string opc, string asm, list<dag> pattern>
1192   : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1193 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1194             string opc, string asm, list<dag> pattern>
1195   : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1196 class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
1197               string opc, string asm, list<dag> pattern>
1198   : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1199             pattern> {
1200   let Inst{31-27} = 0b11101;
1201   let Inst{26-25} = 0b00;
1202   let Inst{24}    = P;
1203   let Inst{23}    = ?; // The U bit.
1204   let Inst{22}    = 1;
1205   let Inst{21}    = W;
1206   let Inst{20}    = load;
1207 }
1208
1209 class T2sI<dag oops, dag iops, InstrItinClass itin,
1210            string opc, string asm, list<dag> pattern>
1211   : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1212
1213 class T2XI<dag oops, dag iops, InstrItinClass itin,
1214            string asm, list<dag> pattern>
1215   : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1216 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1217             string asm, list<dag> pattern>
1218   : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1219
1220 class T2Ix2<dag oops, dag iops, InstrItinClass itin,
1221             string opc, string asm, list<dag> pattern>
1222   : Thumb2I<oops, iops, AddrModeNone, Size8Bytes, itin, opc, asm, "", pattern>;
1223
1224 // Two-address instructions
1225 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1226             string asm, string cstr, list<dag> pattern>
1227   : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1228
1229 // T2Iidxldst - Thumb2 indexed load / store instructions.
1230 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1231                  dag oops, dag iops,
1232                  AddrMode am, IndexMode im, InstrItinClass itin,
1233                  string opc, string asm, string cstr, list<dag> pattern>
1234   : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1235   let OutOperandList = oops;
1236   let InOperandList = !con(iops, (ins pred:$p));
1237   let AsmString = !strconcat(opc, "${p}", asm);
1238   let Pattern = pattern;
1239   list<Predicate> Predicates = [IsThumb2];
1240   let Inst{31-27} = 0b11111;
1241   let Inst{26-25} = 0b00;
1242   let Inst{24}    = signed;
1243   let Inst{23}    = 0;
1244   let Inst{22-21} = opcod;
1245   let Inst{20}    = load;
1246   let Inst{11}    = 1;
1247   // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1248   let Inst{10}    = pre; // The P bit.
1249   let Inst{8}     = 1; // The W bit.
1250 }
1251
1252 // Helper class for disassembly only
1253 // A6.3.16 & A6.3.17
1254 // T2Imac - Thumb2 multiply [accumulate, and absolute difference] instructions.
1255 class T2I_mac<bit long, bits<3> op22_20, bits<4> op7_4, dag oops, dag iops,
1256              InstrItinClass itin, string opc, string asm, list<dag> pattern>
1257   : T2I<oops, iops, itin, opc, asm, pattern> {
1258   let Inst{31-27} = 0b11111;
1259   let Inst{26-24} = 0b011;
1260   let Inst{23}    = long;
1261   let Inst{22-20} = op22_20;
1262   let Inst{7-4}   = op7_4;
1263 }
1264
1265 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1266 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1267   list<Predicate> Predicates = [IsThumb1Only, HasV5T];
1268 }
1269
1270 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1271 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1272   list<Predicate> Predicates = [IsThumb1Only];
1273 }
1274
1275 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1276 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1277   list<Predicate> Predicates = [IsThumb2];
1278 }
1279
1280 //===----------------------------------------------------------------------===//
1281
1282 //===----------------------------------------------------------------------===//
1283 // ARM VFP Instruction templates.
1284 //
1285
1286 // Almost all VFP instructions are predicable.
1287 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1288            IndexMode im, Format f, InstrItinClass itin,
1289            string opc, string asm, string cstr, list<dag> pattern>
1290   : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1291   bits<4> p;
1292   let Inst{31-28} = p;
1293   let OutOperandList = oops;
1294   let InOperandList = !con(iops, (ins pred:$p));
1295   let AsmString = !strconcat(opc, "${p}", asm);
1296   let Pattern = pattern;
1297   list<Predicate> Predicates = [HasVFP2];
1298 }
1299
1300 // Special cases
1301 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1302             IndexMode im, Format f, InstrItinClass itin,
1303             string asm, string cstr, list<dag> pattern>
1304   : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1305   let OutOperandList = oops;
1306   let InOperandList = iops;
1307   let AsmString = asm;
1308   let Pattern = pattern;
1309   list<Predicate> Predicates = [HasVFP2];
1310 }
1311
1312 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1313             string opc, string asm, list<dag> pattern>
1314   : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1315          opc, asm, "", pattern>;
1316
1317 // ARM VFP addrmode5 loads and stores
1318 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1319            InstrItinClass itin,
1320            string opc, string asm, list<dag> pattern>
1321   : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1322          VFPLdStFrm, itin, opc, asm, "", pattern> {
1323   // TODO: Mark the instructions with the appropriate subtarget info.
1324   let Inst{27-24} = opcod1;
1325   let Inst{21-20} = opcod2;
1326   let Inst{11-9}  = 0b101;
1327   let Inst{8}     = 1;          // Double precision
1328
1329   // 64-bit loads & stores operate on both NEON and VFP pipelines.
1330   let D = VFPNeonDomain;
1331 }
1332
1333 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1334            InstrItinClass itin,
1335            string opc, string asm, list<dag> pattern>
1336   : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1337          VFPLdStFrm, itin, opc, asm, "", pattern> {
1338   // TODO: Mark the instructions with the appropriate subtarget info.
1339   let Inst{27-24} = opcod1;
1340   let Inst{21-20} = opcod2;
1341   let Inst{11-9}  = 0b101;
1342   let Inst{8}     = 0;          // Single precision
1343 }
1344
1345 // VFP Load / store multiple pseudo instructions.
1346 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1347                      list<dag> pattern>
1348   : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1349             cstr, itin> {
1350   let OutOperandList = oops;
1351   let InOperandList = !con(iops, (ins pred:$p));
1352   let Pattern = pattern;
1353   list<Predicate> Predicates = [HasVFP2];
1354 }
1355
1356 // Load / store multiple
1357 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1358             string asm, string cstr, list<dag> pattern>
1359   : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1360           VFPLdStMulFrm, itin, asm, cstr, pattern> {
1361   // TODO: Mark the instructions with the appropriate subtarget info.
1362   let Inst{27-25} = 0b110;
1363   let Inst{11-9}  = 0b101;
1364   let Inst{8}     = 1;          // Double precision
1365
1366   // 64-bit loads & stores operate on both NEON and VFP pipelines.
1367   let D = VFPNeonDomain;
1368 }
1369
1370 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1371             string asm, string cstr, list<dag> pattern>
1372   : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1373           VFPLdStMulFrm, itin, asm, cstr, pattern> {
1374   // TODO: Mark the instructions with the appropriate subtarget info.
1375   let Inst{27-25} = 0b110;
1376   let Inst{11-9}  = 0b101;
1377   let Inst{8}     = 0;          // Single precision
1378 }
1379
1380 // Double precision, unary
1381 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1382            bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1383            string asm, list<dag> pattern>
1384   : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1385   let Inst{27-23} = opcod1;
1386   let Inst{21-20} = opcod2;
1387   let Inst{19-16} = opcod3;
1388   let Inst{11-9}  = 0b101;
1389   let Inst{8}     = 1;          // Double precision
1390   let Inst{7-6}   = opcod4;
1391   let Inst{4}     = opcod5;
1392 }
1393
1394 // Double precision, binary
1395 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1396            dag iops, InstrItinClass itin, string opc, string asm,
1397            list<dag> pattern>
1398   : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1399   let Inst{27-23} = opcod1;
1400   let Inst{21-20} = opcod2;
1401   let Inst{11-9}  = 0b101;
1402   let Inst{8}     = 1;          // Double precision
1403   let Inst{6}     = op6;
1404   let Inst{4}     = op4;
1405 }
1406
1407 // Double precision, binary, VML[AS] (for additional predicate)
1408 class ADbI_vmlX<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1409            dag iops, InstrItinClass itin, string opc, string asm,
1410            list<dag> pattern>
1411   : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1412   let Inst{27-23} = opcod1;
1413   let Inst{21-20} = opcod2;
1414   let Inst{11-9}  = 0b101;
1415   let Inst{8}     = 1;          // Double precision
1416   let Inst{6}     = op6;
1417   let Inst{4}     = op4;
1418   list<Predicate> Predicates = [HasVFP2, UseVMLx];
1419 }
1420
1421 // Single precision, unary
1422 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1423            bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1424            string asm, list<dag> pattern>
1425   : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1426   let Inst{27-23} = opcod1;
1427   let Inst{21-20} = opcod2;
1428   let Inst{19-16} = opcod3;
1429   let Inst{11-9}  = 0b101;
1430   let Inst{8}     = 0;          // Single precision
1431   let Inst{7-6}   = opcod4;
1432   let Inst{4}     = opcod5;
1433 }
1434
1435 // Single precision unary, if no NEON
1436 // Same as ASuI except not available if NEON is enabled
1437 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1438             bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1439             string asm, list<dag> pattern>
1440   : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1441          pattern> {
1442   list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1443 }
1444
1445 // Single precision, binary
1446 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1447            InstrItinClass itin, string opc, string asm, list<dag> pattern>
1448   : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1449   let Inst{27-23} = opcod1;
1450   let Inst{21-20} = opcod2;
1451   let Inst{11-9}  = 0b101;
1452   let Inst{8}     = 0;          // Single precision
1453   let Inst{6}     = op6;
1454   let Inst{4}     = op4;
1455 }
1456
1457 // Single precision binary, if no NEON
1458 // Same as ASbI except not available if NEON is enabled
1459 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1460             dag iops, InstrItinClass itin, string opc, string asm,
1461             list<dag> pattern>
1462   : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1463   list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1464 }
1465
1466 // VFP conversion instructions
1467 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1468                dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1469                list<dag> pattern>
1470   : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1471   let Inst{27-23} = opcod1;
1472   let Inst{21-20} = opcod2;
1473   let Inst{19-16} = opcod3;
1474   let Inst{11-8}  = opcod4;
1475   let Inst{6}     = 1;
1476   let Inst{4}     = 0;
1477 }
1478
1479 // VFP conversion between floating-point and fixed-point
1480 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1481                 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1482                 list<dag> pattern>
1483   : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1484   // size (fixed-point number): sx == 0 ? 16 : 32
1485   let Inst{7} = op5; // sx
1486 }
1487
1488 // VFP conversion instructions, if no NEON
1489 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1490                 dag oops, dag iops, InstrItinClass itin,
1491                 string opc, string asm, list<dag> pattern>
1492   : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1493              pattern> {
1494   list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1495 }
1496
1497 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1498                InstrItinClass itin,
1499                string opc, string asm, list<dag> pattern>
1500   : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1501   let Inst{27-20} = opcod1;
1502   let Inst{11-8}  = opcod2;
1503   let Inst{4}     = 1;
1504 }
1505
1506 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1507                InstrItinClass itin, string opc, string asm, list<dag> pattern>
1508   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1509
1510 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1511                InstrItinClass itin, string opc, string asm, list<dag> pattern>
1512   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1513
1514 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1515                InstrItinClass itin, string opc, string asm, list<dag> pattern>
1516   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1517
1518 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1519                InstrItinClass itin, string opc, string asm, list<dag> pattern>
1520   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1521
1522 //===----------------------------------------------------------------------===//
1523
1524 //===----------------------------------------------------------------------===//
1525 // ARM NEON Instruction templates.
1526 //
1527
1528 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1529             InstrItinClass itin, string opc, string dt, string asm, string cstr,
1530             list<dag> pattern>
1531   : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1532   let OutOperandList = oops;
1533   let InOperandList = !con(iops, (ins pred:$p));
1534   let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1535   let Pattern = pattern;
1536   list<Predicate> Predicates = [HasNEON];
1537 }
1538
1539 // Same as NeonI except it does not have a "data type" specifier.
1540 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1541              InstrItinClass itin, string opc, string asm, string cstr,
1542              list<dag> pattern>
1543   : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1544   let OutOperandList = oops;
1545   let InOperandList = !con(iops, (ins pred:$p));
1546   let AsmString = !strconcat(opc, "${p}", "\t", asm);
1547   let Pattern = pattern;
1548   list<Predicate> Predicates = [HasNEON];
1549 }
1550
1551 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1552             dag oops, dag iops, InstrItinClass itin,
1553             string opc, string dt, string asm, string cstr, list<dag> pattern>
1554   : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1555           cstr, pattern> {
1556   let Inst{31-24} = 0b11110100;
1557   let Inst{23}    = op23;
1558   let Inst{21-20} = op21_20;
1559   let Inst{11-8}  = op11_8;
1560   let Inst{7-4}   = op7_4;
1561 }
1562
1563 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1564   : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1565             itin> {
1566   let OutOperandList = oops;
1567   let InOperandList = !con(iops, (ins pred:$p));
1568   list<Predicate> Predicates = [HasNEON];
1569 }
1570
1571 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1572                   list<dag> pattern>
1573   : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1574             itin> {
1575   let OutOperandList = oops;
1576   let InOperandList = !con(iops, (ins pred:$p));
1577   let Pattern = pattern;
1578   list<Predicate> Predicates = [HasNEON];
1579 }
1580
1581 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1582              string opc, string dt, string asm, string cstr, list<dag> pattern>
1583   : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1584           pattern> {
1585   let Inst{31-25} = 0b1111001;
1586 }
1587
1588 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1589               string opc, string asm, string cstr, list<dag> pattern>
1590   : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1591            cstr, pattern> {
1592   let Inst{31-25} = 0b1111001;
1593 }
1594
1595 // NEON "one register and a modified immediate" format.
1596 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1597                bit op5, bit op4,
1598                dag oops, dag iops, InstrItinClass itin,
1599                string opc, string dt, string asm, string cstr,
1600                list<dag> pattern>
1601   : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1602   let Inst{23}    = op23;
1603   let Inst{21-19} = op21_19;
1604   let Inst{11-8}  = op11_8;
1605   let Inst{7}     = op7;
1606   let Inst{6}     = op6;
1607   let Inst{5}     = op5;
1608   let Inst{4}     = op4;
1609 }
1610
1611 // NEON 2 vector register format.
1612 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1613           bits<5> op11_7, bit op6, bit op4,
1614           dag oops, dag iops, InstrItinClass itin,
1615           string opc, string dt, string asm, string cstr, list<dag> pattern>
1616   : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1617   let Inst{24-23} = op24_23;
1618   let Inst{21-20} = op21_20;
1619   let Inst{19-18} = op19_18;
1620   let Inst{17-16} = op17_16;
1621   let Inst{11-7}  = op11_7;
1622   let Inst{6}     = op6;
1623   let Inst{4}     = op4;
1624 }
1625
1626 // Same as N2V except it doesn't have a datatype suffix.
1627 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1628            bits<5> op11_7, bit op6, bit op4,
1629            dag oops, dag iops, InstrItinClass itin,
1630            string opc, string asm, string cstr, list<dag> pattern>
1631   : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1632   let Inst{24-23} = op24_23;
1633   let Inst{21-20} = op21_20;
1634   let Inst{19-18} = op19_18;
1635   let Inst{17-16} = op17_16;
1636   let Inst{11-7}  = op11_7;
1637   let Inst{6}     = op6;
1638   let Inst{4}     = op4;
1639 }
1640
1641 // NEON 2 vector register with immediate.
1642 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1643              dag oops, dag iops, Format f, InstrItinClass itin,
1644              string opc, string dt, string asm, string cstr, list<dag> pattern>
1645   : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1646   let Inst{24}   = op24;
1647   let Inst{23}   = op23;
1648   let Inst{11-8} = op11_8;
1649   let Inst{7}    = op7;
1650   let Inst{6}    = op6;
1651   let Inst{4}    = op4;
1652 }
1653
1654 // NEON 3 vector register format.
1655 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1656           dag oops, dag iops, Format f, InstrItinClass itin,
1657           string opc, string dt, string asm, string cstr, list<dag> pattern>
1658   : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1659   let Inst{24}    = op24;
1660   let Inst{23}    = op23;
1661   let Inst{21-20} = op21_20;
1662   let Inst{11-8}  = op11_8;
1663   let Inst{6}     = op6;
1664   let Inst{4}     = op4;
1665 }
1666
1667 // Same as N3V except it doesn't have a data type suffix.
1668 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1669            bit op4,
1670            dag oops, dag iops, Format f, InstrItinClass itin,
1671            string opc, string asm, string cstr, list<dag> pattern>
1672   : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1673   let Inst{24}    = op24;
1674   let Inst{23}    = op23;
1675   let Inst{21-20} = op21_20;
1676   let Inst{11-8}  = op11_8;
1677   let Inst{6}     = op6;
1678   let Inst{4}     = op4;
1679 }
1680
1681 // NEON VMOVs between scalar and core registers.
1682 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1683                dag oops, dag iops, Format f, InstrItinClass itin,
1684                string opc, string dt, string asm, list<dag> pattern>
1685   : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, GenericDomain,
1686             "", itin> {
1687   let Inst{27-20} = opcod1;
1688   let Inst{11-8}  = opcod2;
1689   let Inst{6-5}   = opcod3;
1690   let Inst{4}     = 1;
1691
1692   let OutOperandList = oops;
1693   let InOperandList = !con(iops, (ins pred:$p));
1694   let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1695   let Pattern = pattern;
1696   list<Predicate> Predicates = [HasNEON];
1697 }
1698 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1699                 dag oops, dag iops, InstrItinClass itin,
1700                 string opc, string dt, string asm, list<dag> pattern>
1701   : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1702              opc, dt, asm, pattern>;
1703 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1704                 dag oops, dag iops, InstrItinClass itin,
1705                 string opc, string dt, string asm, list<dag> pattern>
1706   : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1707              opc, dt, asm, pattern>;
1708 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1709             dag oops, dag iops, InstrItinClass itin,
1710             string opc, string dt, string asm, list<dag> pattern>
1711   : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1712              opc, dt, asm, pattern>;
1713
1714 // Vector Duplicate Lane (from scalar to all elements)
1715 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1716                 InstrItinClass itin, string opc, string dt, string asm,
1717                 list<dag> pattern>
1718   : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1719   let Inst{24-23} = 0b11;
1720   let Inst{21-20} = 0b11;
1721   let Inst{19-16} = op19_16;
1722   let Inst{11-7}  = 0b11000;
1723   let Inst{6}     = op6;
1724   let Inst{4}     = 0;
1725 }
1726
1727 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1728 // for single-precision FP.
1729 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1730   list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1731 }