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