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