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