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