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