Remove opcode from instruction TS flags; add MOVCC support; fix addrmode3 encoding...
[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<5> val> {
19   bits<5> Value = val;
20 }
21
22 def Pseudo      : Format<1>;
23 def MulFrm      : Format<2>;
24 def Branch      : Format<3>;
25 def BranchMisc  : Format<4>;
26
27 def DPFrm       : Format<5>;
28 def DPSoRegFrm  : Format<6>;
29
30 def LdFrm       : Format<7>;
31 def StFrm       : Format<8>;
32 def LdMiscFrm   : Format<9>;
33 def StMiscFrm   : Format<10>;
34 def LdMulFrm    : Format<11>;
35 def StMulFrm    : Format<12>;
36
37 def ArithMisc   : Format<13>;
38 def ThumbFrm    : Format<14>;
39 def VFPFrm      : Format<15>;
40
41 // Misc flag for data processing instructions that indicates whether
42 // the instruction has a Rn register operand.
43 class UnaryDP  { bit isUnaryDataProc = 1; }
44
45 //===----------------------------------------------------------------------===//
46
47 // ARM Instruction templates.
48 //
49
50 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
51               Format f, string cstr>
52   : Instruction {
53   field bits<32> Inst;
54
55   let Namespace = "ARM";
56
57   // TSFlagsFields
58   AddrMode AM = am;
59   bits<4> AddrModeBits = AM.Value;
60   
61   SizeFlagVal SZ = sz;
62   bits<3> SizeFlag = SZ.Value;
63
64   IndexMode IM = im;
65   bits<2> IndexModeBits = IM.Value;
66   
67   Format F = f;
68   bits<5> Form = F.Value;
69
70   //
71   // Attributes specific to ARM instructions...
72   //
73   bit isUnaryDataProc = 0;
74   
75   let Constraints = cstr;
76 }
77
78 class PseudoInst<dag oops, dag iops, string asm, list<dag> pattern>
79   : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, ""> {
80   let OutOperandList = oops;
81   let InOperandList = iops;
82   let AsmString   = asm;
83   let Pattern = pattern;
84 }
85
86 // Almost all ARM instructions are predicable.
87 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
88         IndexMode im, Format f, string opc, string asm, string cstr,
89         list<dag> pattern>
90   : InstARM<am, sz, im, f, cstr> {
91   let OutOperandList = oops;
92   let InOperandList = !con(iops, (ops pred:$p));
93   let AsmString   = !strconcat(opc, !strconcat("${p}", asm));
94   let Pattern = pattern;
95   list<Predicate> Predicates = [IsARM];
96 }
97
98 // Same as I except it can optionally modify CPSR. Note it's modeled as
99 // an input operand since by default it's a zero register. It will
100 // become an implicit def once it's "flipped".
101 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
102          IndexMode im, Format f, string opc, string asm, string cstr,
103          list<dag> pattern>
104   : InstARM<am, sz, im, f, cstr> {
105   let OutOperandList = oops;
106   let InOperandList = !con(iops, (ops pred:$p, cc_out:$s));
107   let AsmString   = !strconcat(opc, !strconcat("${p}${s}", asm));
108   let Pattern = pattern;
109   list<Predicate> Predicates = [IsARM];
110 }
111
112 // Special cases
113 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
114          IndexMode im, Format f, string asm, string cstr, list<dag> pattern>
115   : InstARM<am, sz, im, f, cstr> {
116   let OutOperandList = oops;
117   let InOperandList = iops;
118   let AsmString   = asm;
119   let Pattern = pattern;
120   list<Predicate> Predicates = [IsARM];
121 }
122
123 class AI<dag oops, dag iops, Format f, string opc,
124          string asm, list<dag> pattern>
125   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
126       asm,"",pattern>;
127 class AsI<dag oops, dag iops, Format f, string opc,
128           string asm, list<dag> pattern>
129   : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
130        asm,"",pattern>;
131 class AXI<dag oops, dag iops, Format f, string asm,
132           list<dag> pattern>
133   : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
134        "", pattern>;
135
136 // Ctrl flow instructions
137 class ABLpredI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
138          string asm, list<dag> pattern>
139   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
140       asm,"",pattern> {
141   let Inst{27-24} = opcod;
142 }
143 class ABLI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
144           list<dag> pattern>
145   : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
146        "", pattern> {
147   let Inst{27-24} = opcod;
148 }
149 // FIXME: BX
150 class AXIx2<dag oops, dag iops, Format f, string asm,
151             list<dag> pattern>
152   : XI<oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
153        "", pattern>;
154 class ABI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
155           list<dag> pattern>
156   : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
157        "", pattern> {
158   let Inst{27-24} = opcod;
159 }
160 class ABccI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
161          string asm, list<dag> pattern>
162   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
163       asm,"",pattern> {
164   let Inst{27-24} = opcod;
165 }
166
167 // BR_JT instructions
168 // == mov pc
169 class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
170   : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
171        asm, "", pattern> {
172   let Inst{20}    = 0; // S Bit
173   let Inst{24-21} = opcod;
174   let Inst{27-26} = {0,0};
175 }
176 // == add pc
177 class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
178   : XI<oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
179        asm, "", pattern> {
180   let Inst{20}    = 0; // S bit
181   let Inst{24-21} = opcod;
182   let Inst{27-26} = {0,0};
183 }
184 // == ldr pc
185 class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
186   : XI<oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
187        asm, "", pattern> {
188   let Inst{20}    = 1; // L bit
189   let Inst{21}    = 0; // W bit
190   let Inst{22}    = 0; // B bit
191   let Inst{24}    = 1; // P bit
192   let Inst{27-26} = {0,1};
193 }
194
195
196 // addrmode1 instructions
197 class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
198           string asm, list<dag> pattern>
199   : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
200       asm, "", pattern> {
201   let Inst{24-21} = opcod;
202   let Inst{27-26} = {0,0};
203 }
204 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
205            string asm, list<dag> pattern>
206   : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
207        asm, "", pattern> {
208   let Inst{24-21} = opcod;
209   let Inst{27-26} = {0,0};
210 }
211 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
212            list<dag> pattern>
213   : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
214        "", pattern> {
215   let Inst{24-21} = opcod;
216   let Inst{27-26} = {0,0};
217 }
218 class AI1x2<dag oops, dag iops, Format f, string opc,
219             string asm, list<dag> pattern>
220   : I<oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
221       asm, "", pattern>;
222
223
224 // addrmode2 loads and stores
225 class AI2<dag oops, dag iops, Format f, string opc,
226           string asm, list<dag> pattern>
227   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
228       asm, "", pattern> {
229   let Inst{27-26} = {0,1};
230 }
231
232 // loads
233 class AI2ldw<dag oops, dag iops, Format f, string opc,
234           string asm, list<dag> pattern>
235   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
236       asm, "", pattern> {
237   let Inst{20}    = 1; // L bit
238   let Inst{21}    = 0; // W bit
239   let Inst{22}    = 0; // B bit
240   let Inst{24}    = 1; // P bit
241   let Inst{27-26} = {0,1};
242 }
243 class AXI2ldw<dag oops, dag iops, Format f, string asm,
244            list<dag> pattern>
245   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
246        asm, "", pattern> {
247   let Inst{20}    = 1; // L bit
248   let Inst{21}    = 0; // W bit
249   let Inst{22}    = 0; // B bit
250   let Inst{24}    = 1; // P bit
251   let Inst{27-26} = {0,1};
252 }
253 class AI2ldb<dag oops, dag iops, Format f, string opc,
254           string asm, list<dag> pattern>
255   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
256       asm, "", pattern> {
257   let Inst{20}    = 1; // L bit
258   let Inst{21}    = 0; // W bit
259   let Inst{22}    = 1; // B bit
260   let Inst{24}    = 1; // P bit
261   let Inst{27-26} = {0,1};
262 }
263 class AXI2ldb<dag oops, dag iops, Format f, string asm,
264            list<dag> pattern>
265   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
266        asm, "", pattern> {
267   let Inst{20}    = 1; // L bit
268   let Inst{21}    = 0; // W bit
269   let Inst{22}    = 1; // B bit
270   let Inst{24}    = 1; // P bit
271   let Inst{27-26} = {0,1};
272 }
273
274 // stores
275 class AI2stw<dag oops, dag iops, Format f, string opc,
276           string asm, list<dag> pattern>
277   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
278       asm, "", pattern> {
279   let Inst{20}    = 0; // L bit
280   let Inst{21}    = 0; // W bit
281   let Inst{22}    = 0; // B bit
282   let Inst{24}    = 1; // P bit
283   let Inst{27-26} = {0,1};
284 }
285 class AXI2stw<dag oops, dag iops, Format f, string asm,
286            list<dag> pattern>
287   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
288        asm, "", pattern> {
289   let Inst{20}    = 0; // L bit
290   let Inst{21}    = 0; // W bit
291   let Inst{22}    = 0; // B bit
292   let Inst{24}    = 1; // P bit
293   let Inst{27-26} = {0,1};
294 }
295 class AI2stb<dag oops, dag iops, Format f, string opc,
296           string asm, list<dag> pattern>
297   : I<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
298       asm, "", pattern> {
299   let Inst{20}    = 0; // L bit
300   let Inst{21}    = 0; // W bit
301   let Inst{22}    = 1; // B bit
302   let Inst{24}    = 1; // P bit
303   let Inst{27-26} = {0,1};
304 }
305 class AXI2stb<dag oops, dag iops, Format f, string asm,
306            list<dag> pattern>
307   : XI<oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
308        asm, "", pattern> {
309   let Inst{20}    = 0; // L bit
310   let Inst{21}    = 0; // W bit
311   let Inst{22}    = 1; // B bit
312   let Inst{24}    = 1; // P bit
313   let Inst{27-26} = {0,1};
314 }
315
316 // Pre-indexed loads
317 class AI2ldwpr<dag oops, dag iops, Format f, string opc,
318             string asm, string cstr, list<dag> pattern>
319   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
320       asm, cstr, pattern> {
321   let Inst{20}    = 1; // L bit
322   let Inst{21}    = 1; // W bit
323   let Inst{22}    = 0; // B bit
324   let Inst{24}    = 1; // P bit
325   let Inst{27-26} = {0,1};
326 }
327 class AI2ldbpr<dag oops, dag iops, Format f, string opc,
328             string asm, string cstr, list<dag> pattern>
329   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
330       asm, cstr, pattern> {
331   let Inst{20}    = 1; // L bit
332   let Inst{21}    = 1; // W bit
333   let Inst{22}    = 1; // B bit
334   let Inst{24}    = 1; // P bit
335   let Inst{27-26} = {0,1};
336 }
337
338 // Pre-indexed stores
339 class AI2stwpr<dag oops, dag iops, Format f, string opc,
340             string asm, string cstr, list<dag> pattern>
341   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
342       asm, cstr, pattern> {
343   let Inst{20}    = 0; // L bit
344   let Inst{21}    = 1; // W bit
345   let Inst{22}    = 0; // B bit
346   let Inst{24}    = 1; // P bit
347   let Inst{27-26} = {0,1};
348 }
349 class AI2stbpr<dag oops, dag iops, Format f, string opc,
350             string asm, string cstr, list<dag> pattern>
351   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
352       asm, cstr, pattern> {
353   let Inst{20}    = 0; // L bit
354   let Inst{21}    = 1; // W bit
355   let Inst{22}    = 1; // B bit
356   let Inst{24}    = 1; // P bit
357   let Inst{27-26} = {0,1};
358 }
359
360 // Post-indexed loads
361 class AI2ldwpo<dag oops, dag iops, Format f, string opc,
362             string asm, string cstr, list<dag> pattern>
363   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
364       asm, cstr,pattern> {
365   let Inst{20}    = 1; // L bit
366   let Inst{21}    = 0; // W bit
367   let Inst{22}    = 0; // B bit
368   let Inst{24}    = 0; // P bit
369   let Inst{27-26} = {0,1};
370 }
371 class AI2ldbpo<dag oops, dag iops, Format f, string opc,
372             string asm, string cstr, list<dag> pattern>
373   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
374       asm, cstr,pattern> {
375   let Inst{20}    = 1; // L bit
376   let Inst{21}    = 0; // W bit
377   let Inst{22}    = 1; // B bit
378   let Inst{24}    = 0; // P bit
379   let Inst{27-26} = {0,1};
380 }
381
382 // Post-indexed stores
383 class AI2stwpo<dag oops, dag iops, Format f, string opc,
384             string asm, string cstr, list<dag> pattern>
385   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
386       asm, cstr,pattern> {
387   let Inst{20}    = 0; // L bit
388   let Inst{21}    = 0; // W bit
389   let Inst{22}    = 0; // B bit
390   let Inst{24}    = 0; // P bit
391   let Inst{27-26} = {0,1};
392 }
393 class AI2stbpo<dag oops, dag iops, Format f, string opc,
394             string asm, string cstr, list<dag> pattern>
395   : I<oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
396       asm, cstr,pattern> {
397   let Inst{20}    = 0; // L bit
398   let Inst{21}    = 0; // W bit
399   let Inst{22}    = 1; // B bit
400   let Inst{24}    = 0; // P bit
401   let Inst{27-26} = {0,1};
402 }
403
404 // addrmode3 instructions
405 class AI3<dag oops, dag iops, Format f, string opc,
406           string asm, list<dag> pattern>
407   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
408       asm, "", pattern>;
409 class AXI3<dag oops, dag iops, Format f, string asm,
410            list<dag> pattern>
411   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
412        "", pattern>;
413
414 // loads
415 class AI3ldh<dag oops, dag iops, Format f, string opc,
416           string asm, list<dag> pattern>
417   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
418       asm, "", pattern> {
419   let Inst{4}     = 1;
420   let Inst{5}     = 1; // H bit
421   let Inst{6}     = 0; // S bit
422   let Inst{7}     = 1;
423   let Inst{20}    = 1; // L bit
424   let Inst{21}    = 0; // W bit
425   let Inst{24}    = 1; // P bit
426 }
427 class AXI3ldh<dag oops, dag iops, Format f, string asm,
428            list<dag> pattern>
429   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
430        asm, "", pattern> {
431   let Inst{4}     = 1;
432   let Inst{5}     = 1; // H bit
433   let Inst{6}     = 0; // S bit
434   let Inst{7}     = 1;
435   let Inst{20}    = 1; // L bit
436   let Inst{21}    = 0; // W bit
437   let Inst{24}    = 1; // P bit
438 }
439 class AI3ldsh<dag oops, dag iops, Format f, string opc,
440           string asm, list<dag> pattern>
441   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
442       asm, "", pattern> {
443   let Inst{4}     = 1;
444   let Inst{5}     = 1; // H bit
445   let Inst{6}     = 1; // S bit
446   let Inst{7}     = 1;
447   let Inst{20}    = 1; // L bit
448   let Inst{21}    = 0; // W bit
449   let Inst{24}    = 1; // P bit
450 }
451 class AXI3ldsh<dag oops, dag iops, Format f, string asm,
452            list<dag> pattern>
453   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
454        asm, "", pattern> {
455   let Inst{4}     = 1;
456   let Inst{5}     = 1; // H bit
457   let Inst{6}     = 1; // S bit
458   let Inst{7}     = 1;
459   let Inst{20}    = 1; // L bit
460   let Inst{21}    = 0; // W bit
461   let Inst{24}    = 1; // P bit
462 }
463 class AI3ldsb<dag oops, dag iops, Format f, string opc,
464           string asm, list<dag> pattern>
465   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
466       asm, "", pattern> {
467   let Inst{4}     = 1;
468   let Inst{5}     = 0; // H bit
469   let Inst{6}     = 1; // S bit
470   let Inst{7}     = 1;
471   let Inst{20}    = 1; // L bit
472   let Inst{21}    = 0; // W bit
473   let Inst{24}    = 1; // P bit
474 }
475 class AXI3ldsb<dag oops, dag iops, Format f, string asm,
476            list<dag> pattern>
477   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
478        asm, "", pattern> {
479   let Inst{4}     = 1;
480   let Inst{5}     = 0; // H bit
481   let Inst{6}     = 1; // S bit
482   let Inst{7}     = 1;
483   let Inst{20}    = 1; // L bit
484   let Inst{21}    = 0; // W bit
485   let Inst{24}    = 1; // P bit
486 }
487 class AI3ldd<dag oops, dag iops, Format f, string opc,
488           string asm, list<dag> pattern>
489   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
490       asm, "", pattern> {
491   let Inst{4}     = 1;
492   let Inst{5}     = 0; // H bit
493   let Inst{6}     = 1; // S bit
494   let Inst{7}     = 1;
495   let Inst{20}    = 0; // L bit
496   let Inst{21}    = 0; // W bit
497   let Inst{24}    = 1; // P bit
498 }
499
500 // stores
501 class AI3sth<dag oops, dag iops, Format f, string opc,
502           string asm, list<dag> pattern>
503   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
504       asm, "", pattern> {
505   let Inst{4}     = 1;
506   let Inst{5}     = 1; // H bit
507   let Inst{6}     = 0; // S bit
508   let Inst{7}     = 1;
509   let Inst{20}    = 0; // L bit
510   let Inst{21}    = 0; // W bit
511   let Inst{24}    = 1; // P bit
512 }
513 class AXI3sth<dag oops, dag iops, Format f, string asm,
514            list<dag> pattern>
515   : XI<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
516        asm, "", pattern> {
517   let Inst{4}     = 1;
518   let Inst{5}     = 1; // H bit
519   let Inst{6}     = 0; // S bit
520   let Inst{7}     = 1;
521   let Inst{20}    = 0; // L bit
522   let Inst{21}    = 0; // W bit
523   let Inst{24}    = 1; // P bit
524 }
525 class AI3std<dag oops, dag iops, Format f, string opc,
526           string asm, list<dag> pattern>
527   : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
528       asm, "", pattern> {
529   let Inst{4}     = 1;
530   let Inst{5}     = 1; // H bit
531   let Inst{6}     = 1; // S bit
532   let Inst{7}     = 1;
533   let Inst{20}    = 0; // L bit
534   let Inst{21}    = 0; // W bit
535   let Inst{24}    = 1; // P bit
536 }
537
538 // Pre-indexed loads
539 class AI3ldhpr<dag oops, dag iops, Format f, string opc,
540             string asm, string cstr, list<dag> pattern>
541   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
542       asm, cstr, pattern> {
543   let Inst{4}     = 1;
544   let Inst{5}     = 1; // H bit
545   let Inst{6}     = 0; // S bit
546   let Inst{7}     = 1;
547   let Inst{20}    = 1; // L bit
548   let Inst{21}    = 1; // W bit
549   let Inst{24}    = 1; // P bit
550 }
551 class AI3ldshpr<dag oops, dag iops, Format f, string opc,
552             string asm, string cstr, list<dag> pattern>
553   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
554       asm, cstr, pattern> {
555   let Inst{4}     = 1;
556   let Inst{5}     = 1; // H bit
557   let Inst{6}     = 1; // S bit
558   let Inst{7}     = 1;
559   let Inst{20}    = 1; // L bit
560   let Inst{21}    = 1; // W bit
561   let Inst{24}    = 1; // P bit
562 }
563 class AI3ldsbpr<dag oops, dag iops, Format f, string opc,
564             string asm, string cstr, list<dag> pattern>
565   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
566       asm, cstr, pattern> {
567   let Inst{4}     = 1;
568   let Inst{5}     = 0; // H bit
569   let Inst{6}     = 1; // S bit
570   let Inst{7}     = 1;
571   let Inst{20}    = 1; // L bit
572   let Inst{21}    = 1; // W bit
573   let Inst{24}    = 1; // P bit
574 }
575
576 // Pre-indexed stores
577 class AI3sthpr<dag oops, dag iops, Format f, string opc,
578             string asm, string cstr, list<dag> pattern>
579   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
580       asm, cstr, pattern> {
581   let Inst{4}     = 1;
582   let Inst{5}     = 1; // H bit
583   let Inst{6}     = 0; // S bit
584   let Inst{7}     = 1;
585   let Inst{20}    = 0; // L bit
586   let Inst{21}    = 1; // W bit
587   let Inst{24}    = 1; // P bit
588 }
589
590 // Post-indexed loads
591 class AI3ldhpo<dag oops, dag iops, Format f, string opc,
592             string asm, string cstr, list<dag> pattern>
593   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
594       asm, cstr,pattern> {
595   let Inst{4}     = 1;
596   let Inst{5}     = 1; // H bit
597   let Inst{6}     = 0; // S bit
598   let Inst{7}     = 1;
599   let Inst{20}    = 1; // L bit
600   let Inst{21}    = 1; // W bit
601   let Inst{24}    = 0; // P bit
602 }
603 class AI3ldshpo<dag oops, dag iops, Format f, string opc,
604             string asm, string cstr, list<dag> pattern>
605   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
606       asm, cstr,pattern> {
607   let Inst{4}     = 1;
608   let Inst{5}     = 1; // H bit
609   let Inst{6}     = 1; // S bit
610   let Inst{7}     = 1;
611   let Inst{20}    = 1; // L bit
612   let Inst{21}    = 1; // W bit
613   let Inst{24}    = 0; // P bit
614 }
615 class AI3ldsbpo<dag oops, dag iops, Format f, string opc,
616             string asm, string cstr, list<dag> pattern>
617   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
618       asm, cstr,pattern> {
619   let Inst{4}     = 1;
620   let Inst{5}     = 0; // H bit
621   let Inst{6}     = 1; // S bit
622   let Inst{7}     = 1;
623   let Inst{20}    = 1; // L bit
624   let Inst{21}    = 1; // W bit
625   let Inst{24}    = 0; // P bit
626 }
627
628 // Post-indexed stores
629 class AI3sthpo<dag oops, dag iops, Format f, string opc,
630             string asm, string cstr, list<dag> pattern>
631   : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
632       asm, cstr,pattern> {
633   let Inst{4}     = 1;
634   let Inst{5}     = 1; // H bit
635   let Inst{6}     = 0; // S bit
636   let Inst{7}     = 1;
637   let Inst{20}    = 0; // L bit
638   let Inst{21}    = 1; // W bit
639   let Inst{24}    = 0; // P bit
640 }
641
642
643 // addrmode4 instructions
644 class AI4<dag oops, dag iops, Format f, string opc,
645           string asm, list<dag> pattern>
646   : I<oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
647       asm, "", pattern> {
648   let Inst{25-27} = {0,0,1};
649 }
650 class AXI4ld<dag oops, dag iops, Format f, string asm,
651            list<dag> pattern>
652   : XI<oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
653        "", pattern> {
654   let Inst{20}    = 1; // L bit
655   let Inst{22}    = 0; // S bit
656   let Inst{27-25} = 0b100;
657 }
658 class AXI4ldpc<dag oops, dag iops, Format f, string asm,
659            list<dag> pattern>
660   : XI<oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
661        "", pattern> {
662   let Inst{20}    = 1; // L bit
663   let Inst{27-25} = 0b100;
664 }
665 class AXI4st<dag oops, dag iops, Format f, string asm,
666            list<dag> pattern>
667   : XI<oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
668        "", pattern> {
669   let Inst{20}    = 0; // L bit
670   let Inst{22}    = 0; // S bit
671   let Inst{27-25} = 0b100;
672 }
673
674 // Unsigned multiply, multiply-accumulate instructions.
675 class AMul1I<bits<7> opcod, dag oops, dag iops, string opc,
676          string asm, list<dag> pattern>
677   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
678       asm,"",pattern> {
679   let Inst{7-4}   = 0b1001;
680   let Inst{20}    = 0; // S bit
681   let Inst{27-21} = opcod;
682 }
683 class AsMul1I<bits<7> opcod, dag oops, dag iops, string opc,
684           string asm, list<dag> pattern>
685   : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
686        asm,"",pattern> {
687   let Inst{7-4}   = 0b1001;
688   let Inst{27-21} = opcod;
689 }
690
691 // Most significant word multiply
692 class AMul2I<bits<7> opcod, dag oops, dag iops, string opc,
693          string asm, list<dag> pattern>
694   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
695       asm,"",pattern> {
696   let Inst{7-4}   = 0b1001;
697   let Inst{20}    = 1;
698   let Inst{27-21} = opcod;
699 }
700
701 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
702 class AMulxyI<bits<7> opcod, dag oops, dag iops, string opc,
703          string asm, list<dag> pattern>
704   : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
705       asm,"",pattern> {
706   let Inst{4}     = 0;
707   let Inst{7}     = 1;
708   let Inst{20}    = 0;
709   let Inst{27-21} = opcod;
710 }
711
712 //===----------------------------------------------------------------------===//
713
714 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
715 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
716   list<Predicate> Predicates = [IsARM];
717 }
718 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
719   list<Predicate> Predicates = [IsARM, HasV5TE];
720 }
721 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
722   list<Predicate> Predicates = [IsARM, HasV6];
723 }
724
725 //===----------------------------------------------------------------------===//
726 //
727 // Thumb Instruction Format Definitions.
728 //
729
730
731 // TI - Thumb instruction.
732
733 class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
734              string asm, string cstr, list<dag> pattern>
735   : InstARM<am, sz, IndexModeNone, ThumbFrm, cstr> {
736   let OutOperandList = outs;
737   let InOperandList = ins;
738   let AsmString   = asm;
739   let Pattern = pattern;
740   list<Predicate> Predicates = [IsThumb];
741 }
742
743 class TI<dag outs, dag ins, string asm, list<dag> pattern>
744   : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
745 class TI1<dag outs, dag ins, string asm, list<dag> pattern>
746   : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
747 class TI2<dag outs, dag ins, string asm, list<dag> pattern>
748   : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
749 class TI4<dag outs, dag ins, string asm, list<dag> pattern>
750   : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
751 class TIs<dag outs, dag ins, string asm, list<dag> pattern>
752   : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
753
754 // Two-address instructions
755 class TIt<dag outs, dag ins, string asm, list<dag> pattern>
756   : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
757
758 // BL, BLX(1) are translated by assembler into two instructions
759 class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
760   : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
761
762 // BR_JT instructions
763 class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
764   : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
765
766
767 //===----------------------------------------------------------------------===//
768
769
770 // ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
771 class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
772   list<Predicate> Predicates = [IsThumb];
773 }
774
775 class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
776   list<Predicate> Predicates = [IsThumb, HasV5T];
777 }