LDM_RET restores pc, do not set 's' bit which would restore CPSR from SPSR.
[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
139 // Ctrl flow instructions
140 class ABLpredI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
141          string asm, list<dag> pattern>
142   : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
143       asm,"",pattern> {
144   let Inst{27-24} = opcod;
145 }
146 class ABLI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
147           list<dag> pattern>
148   : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
149        "", pattern> {
150   let Inst{27-24} = opcod;
151 }
152 // FIXME: BX
153 class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
154             list<dag> pattern>
155   : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
156        "", pattern>;
157 class ABI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
158           list<dag> pattern>
159   : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
160        "", pattern> {
161   let Inst{27-24} = opcod;
162 }
163 class ABccI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
164          string asm, list<dag> pattern>
165   : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
166       asm,"",pattern> {
167   let Inst{27-24} = opcod;
168 }
169
170 // BR_JT instructions
171 // == mov pc
172 class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
173   : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
174        asm, "", pattern> {
175   let Inst{20}    = 0; // S Bit
176   let Inst{24-21} = opcod;
177   let Inst{27-26} = {0,0};
178 }
179 // == add pc
180 class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
181   : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
182        asm, "", pattern> {
183   let Inst{20}    = 0; // S bit
184   let Inst{24-21} = opcod;
185   let Inst{27-26} = {0,0};
186 }
187 // == ldr pc
188 class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
189   : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
190        asm, "", pattern> {
191   let Inst{20}    = 1; // L bit
192   let Inst{21}    = 0; // W bit
193   let Inst{22}    = 0; // B bit
194   let Inst{24}    = 1; // P bit
195   let Inst{27-26} = {0,1};
196 }
197
198
199 // addrmode1 instructions
200 class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
201           string asm, list<dag> pattern>
202   : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
203       asm, "", pattern> {
204   let Inst{24-21} = opcod;
205   let Inst{27-26} = {0,0};
206 }
207 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
208            string asm, list<dag> pattern>
209   : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
210        asm, "", pattern> {
211   let Inst{24-21} = opcod;
212   let Inst{27-26} = {0,0};
213 }
214 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
215            list<dag> pattern>
216   : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
217        "", pattern> {
218   let Inst{24-21} = opcod;
219   let Inst{27-26} = {0,0};
220 }
221 class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
222             string asm, list<dag> pattern>
223   : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
224       asm, "", pattern>;
225
226
227 // addrmode2 loads and stores
228 class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
229           string asm, list<dag> pattern>
230   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
231       asm, "", pattern> {
232   let Inst{27-26} = {0,1};
233 }
234 class AXI2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
235            list<dag> pattern>
236   : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
237        "", pattern>;
238
239 // loads
240 class AI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
241           string asm, list<dag> pattern>
242   : AI2<opcod, oops, iops, f, opc, 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 }
248 class AXI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
249            list<dag> pattern>
250   : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
251        "", pattern> {
252   let Inst{20}    = 1; // L bit
253   let Inst{21}    = 0; // W bit
254   let Inst{22}    = 0; // B bit
255   let Inst{24}    = 1; // P bit
256 }
257 class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
258           string asm, list<dag> pattern>
259   : AI2<opcod, oops, iops, f, opc, asm, pattern> {
260   let Inst{20}    = 1; // L bit
261   let Inst{21}    = 0; // W bit
262   let Inst{22}    = 1; // B bit
263   let Inst{24}    = 1; // P bit
264 }
265 class AXI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
266            list<dag> pattern>
267   : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
268        "", pattern> {
269   let Inst{20}    = 1; // L bit
270   let Inst{21}    = 0; // W bit
271   let Inst{22}    = 1; // B bit
272   let Inst{24}    = 1; // P bit
273 }
274
275 // stores
276 class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
277           string asm, list<dag> pattern>
278   : AI2<opcod, oops, iops, f, opc, 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 }
284 class AXI2stw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
285            list<dag> pattern>
286   : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
287        "", pattern> {
288   let Inst{20}    = 0; // L bit
289   let Inst{21}    = 0; // W bit
290   let Inst{22}    = 0; // B bit
291   let Inst{24}    = 1; // P bit
292 }
293 class AI2stb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
294           string asm, list<dag> pattern>
295   : AI2<opcod, oops, iops, f, opc, asm, pattern> {
296   let Inst{20}    = 0; // L bit
297   let Inst{21}    = 0; // W bit
298   let Inst{22}    = 1; // B bit
299   let Inst{24}    = 1; // P bit
300 }
301 class AXI2stb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
302            list<dag> pattern>
303   : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
304        "", 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 }
310
311 // Pre-indexed loads
312 class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
313             string asm, string cstr, list<dag> pattern>
314   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
315       asm, cstr, pattern> {
316   let Inst{20}    = 1; // L bit
317   let Inst{21}    = 1; // W bit
318   let Inst{22}    = 0; // B bit
319   let Inst{24}    = 1; // P bit
320 }
321 class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
322             string asm, string cstr, list<dag> pattern>
323   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
324       asm, cstr, pattern> {
325   let Inst{20}    = 1; // L bit
326   let Inst{21}    = 1; // W bit
327   let Inst{22}    = 1; // B bit
328   let Inst{24}    = 1; // P bit
329 }
330
331 // Pre-indexed stores
332 class AI2stwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
333             string asm, string cstr, list<dag> pattern>
334   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
335       asm, cstr, pattern> {
336   let Inst{20}    = 0; // L bit
337   let Inst{21}    = 1; // W bit
338   let Inst{22}    = 0; // B bit
339   let Inst{24}    = 1; // P bit
340 }
341 class AI2stbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
342             string asm, string cstr, list<dag> pattern>
343   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
344       asm, cstr, pattern> {
345   let Inst{20}    = 0; // L bit
346   let Inst{21}    = 1; // W bit
347   let Inst{22}    = 1; // B bit
348   let Inst{24}    = 1; // P bit
349 }
350
351 // Post-indexed loads
352 class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
353             string asm, string cstr, list<dag> pattern>
354   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
355       asm, cstr,pattern> {
356   let Inst{20}    = 1; // L bit
357   let Inst{21}    = 0; // W bit
358   let Inst{22}    = 0; // B bit
359   let Inst{24}    = 0; // P bit
360 }
361 class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
362             string asm, string cstr, list<dag> pattern>
363   : I<opcod, 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}    = 1; // B bit
368   let Inst{24}    = 0; // P bit
369 }
370
371 // Post-indexed stores
372 class AI2stwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
373             string asm, string cstr, list<dag> pattern>
374   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
375       asm, cstr,pattern> {
376   let Inst{20}    = 0; // L bit
377   let Inst{21}    = 0; // W bit
378   let Inst{22}    = 0; // B bit
379   let Inst{24}    = 0; // P bit
380 }
381 class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
382             string asm, string cstr, list<dag> pattern>
383   : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
384       asm, cstr,pattern> {
385   let Inst{20}    = 0; // L bit
386   let Inst{21}    = 0; // W bit
387   let Inst{22}    = 1; // B bit
388   let Inst{24}    = 0; // P bit
389 }
390
391 // addrmode3 instructions
392 class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
393           string asm, list<dag> pattern>
394   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
395       asm, "", pattern>;
396 class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
397            list<dag> pattern>
398   : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
399        "", pattern>;
400
401 // loads
402 class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
403           string asm, list<dag> pattern>
404   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
405       asm, "", pattern> {
406   let Inst{4}     = 1;
407   let Inst{5}     = 1; // H bit
408   let Inst{6}     = 0; // S bit
409   let Inst{7}     = 1;
410   let Inst{20}    = 1; // L bit
411   let Inst{21}    = 0; // W bit
412   let Inst{24}    = 1; // P bit
413 }
414 class AXI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
415            list<dag> pattern>
416   : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
417        "", pattern> {
418   let Inst{4}     = 1;
419   let Inst{5}     = 1; // H bit
420   let Inst{6}     = 0; // S bit
421   let Inst{7}     = 1;
422   let Inst{20}    = 1; // L bit
423   let Inst{21}    = 0; // W bit
424   let Inst{24}    = 1; // P bit
425 }
426 class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
427           string asm, list<dag> pattern>
428   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
429       asm, "", pattern> {
430   let Inst{4}     = 1;
431   let Inst{5}     = 1; // H bit
432   let Inst{6}     = 1; // S bit
433   let Inst{7}     = 1;
434   let Inst{20}    = 1; // L bit
435   let Inst{21}    = 0; // W bit
436   let Inst{24}    = 1; // P bit
437 }
438 class AXI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
439            list<dag> pattern>
440   : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
441        "", pattern> {
442   let Inst{4}     = 1;
443   let Inst{5}     = 1; // H bit
444   let Inst{6}     = 1; // S bit
445   let Inst{7}     = 1;
446   let Inst{20}    = 1; // L bit
447   let Inst{21}    = 0; // W bit
448   let Inst{24}    = 1; // P bit
449 }
450 class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
451           string asm, list<dag> pattern>
452   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
453       asm, "", pattern> {
454   let Inst{4}     = 1;
455   let Inst{5}     = 0; // H bit
456   let Inst{6}     = 1; // S bit
457   let Inst{7}     = 1;
458   let Inst{20}    = 1; // L bit
459   let Inst{21}    = 0; // W bit
460   let Inst{24}    = 1; // P bit
461 }
462 class AXI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
463            list<dag> pattern>
464   : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
465        "", pattern> {
466   let Inst{4}     = 1;
467   let Inst{5}     = 0; // H bit
468   let Inst{6}     = 1; // S bit
469   let Inst{7}     = 1;
470   let Inst{20}    = 1; // L bit
471   let Inst{21}    = 0; // W bit
472   let Inst{24}    = 1; // P bit
473 }
474 class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc,
475           string asm, list<dag> pattern>
476   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
477       asm, "", pattern> {
478   let Inst{4}     = 1;
479   let Inst{5}     = 0; // H bit
480   let Inst{6}     = 1; // S bit
481   let Inst{7}     = 1;
482   let Inst{20}    = 0; // L bit
483   let Inst{21}    = 0; // W bit
484   let Inst{24}    = 1; // P bit
485 }
486
487 // stores
488 class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc,
489           string asm, list<dag> pattern>
490   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
491       asm, "", pattern> {
492   let Inst{4}     = 1;
493   let Inst{5}     = 1; // H bit
494   let Inst{6}     = 0; // S bit
495   let Inst{7}     = 1;
496   let Inst{20}    = 0; // L bit
497   let Inst{21}    = 0; // W bit
498   let Inst{24}    = 1; // P bit
499 }
500 class AXI3sth<bits<4> opcod, dag oops, dag iops, Format f, string asm,
501            list<dag> pattern>
502   : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
503        "", pattern> {
504   let Inst{4}     = 1;
505   let Inst{5}     = 1; // H bit
506   let Inst{6}     = 0; // S bit
507   let Inst{7}     = 1;
508   let Inst{20}    = 0; // L bit
509   let Inst{21}    = 0; // W bit
510   let Inst{24}    = 1; // P bit
511 }
512 class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc,
513           string asm, list<dag> pattern>
514   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
515       asm, "", pattern> {
516   let Inst{4}     = 1;
517   let Inst{5}     = 1; // H bit
518   let Inst{6}     = 1; // S bit
519   let Inst{7}     = 1;
520   let Inst{20}    = 0; // L bit
521   let Inst{21}    = 0; // W bit
522   let Inst{24}    = 1; // P bit
523 }
524
525 // Pre-indexed loads
526 class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
527             string asm, string cstr, list<dag> pattern>
528   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
529       asm, cstr, pattern> {
530   let Inst{4}     = 1;
531   let Inst{5}     = 1; // H bit
532   let Inst{6}     = 0; // S bit
533   let Inst{7}     = 1;
534   let Inst{20}    = 1; // L bit
535   let Inst{21}    = 1; // W bit
536   let Inst{24}    = 1; // P bit
537 }
538 class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
539             string asm, string cstr, list<dag> pattern>
540   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
541       asm, cstr, pattern> {
542   let Inst{4}     = 1;
543   let Inst{5}     = 1; // H bit
544   let Inst{6}     = 1; // S bit
545   let Inst{7}     = 1;
546   let Inst{20}    = 1; // L bit
547   let Inst{21}    = 1; // W bit
548   let Inst{24}    = 1; // P bit
549 }
550 class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
551             string asm, string cstr, list<dag> pattern>
552   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
553       asm, cstr, pattern> {
554   let Inst{4}     = 1;
555   let Inst{5}     = 0; // H bit
556   let Inst{6}     = 1; // S bit
557   let Inst{7}     = 1;
558   let Inst{20}    = 1; // L bit
559   let Inst{21}    = 1; // W bit
560   let Inst{24}    = 1; // P bit
561 }
562
563 // Pre-indexed stores
564 class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
565             string asm, string cstr, list<dag> pattern>
566   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
567       asm, cstr, pattern> {
568   let Inst{4}     = 1;
569   let Inst{5}     = 1; // H bit
570   let Inst{6}     = 0; // S bit
571   let Inst{7}     = 1;
572   let Inst{20}    = 0; // L bit
573   let Inst{21}    = 1; // W bit
574   let Inst{24}    = 1; // P bit
575 }
576
577 // Post-indexed loads
578 class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
579             string asm, string cstr, list<dag> pattern>
580   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
581       asm, cstr,pattern> {
582   let Inst{4}     = 1;
583   let Inst{5}     = 1; // H bit
584   let Inst{6}     = 0; // S bit
585   let Inst{7}     = 1;
586   let Inst{20}    = 1; // L bit
587   let Inst{21}    = 1; // W bit
588   let Inst{24}    = 0; // P bit
589 }
590 class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
591             string asm, string cstr, list<dag> pattern>
592   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
593       asm, cstr,pattern> {
594   let Inst{4}     = 1;
595   let Inst{5}     = 1; // H bit
596   let Inst{6}     = 1; // S bit
597   let Inst{7}     = 1;
598   let Inst{20}    = 1; // L bit
599   let Inst{21}    = 1; // W bit
600   let Inst{24}    = 0; // P bit
601 }
602 class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
603             string asm, string cstr, list<dag> pattern>
604   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
605       asm, cstr,pattern> {
606   let Inst{4}     = 1;
607   let Inst{5}     = 0; // H bit
608   let Inst{6}     = 1; // S bit
609   let Inst{7}     = 1;
610   let Inst{20}    = 1; // L bit
611   let Inst{21}    = 1; // W bit
612   let Inst{24}    = 0; // P bit
613 }
614
615 // Post-indexed stores
616 class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
617             string asm, string cstr, list<dag> pattern>
618   : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
619       asm, cstr,pattern> {
620   let Inst{4}     = 1;
621   let Inst{5}     = 1; // H bit
622   let Inst{6}     = 0; // S bit
623   let Inst{7}     = 1;
624   let Inst{20}    = 0; // L bit
625   let Inst{21}    = 1; // W bit
626   let Inst{24}    = 0; // P bit
627 }
628
629
630 // addrmode4 instructions
631 class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
632           string asm, list<dag> pattern>
633   : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
634       asm, "", pattern> {
635   let Inst{25-27} = {0,0,1};
636 }
637 class AXI4ld<bits<4> opcod, dag oops, dag iops, Format f, string asm,
638            list<dag> pattern>
639   : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
640        "", pattern> {
641   let Inst{20}    = 1; // L bit
642   let Inst{22}    = 0; // S bit
643   let Inst{27-25} = 0b100;
644 }
645 class AXI4ldpc<bits<4> opcod, dag oops, dag iops, Format f, string asm,
646            list<dag> pattern>
647   : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
648        "", pattern> {
649   let Inst{20}    = 1; // L bit
650   let Inst{27-25} = 0b100;
651 }
652 class AXI4st<bits<4> opcod, dag oops, dag iops, Format f, string asm,
653            list<dag> pattern>
654   : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
655        "", pattern> {
656   let Inst{20}    = 0; // L bit
657   let Inst{22}    = 0; // S bit
658   let Inst{27-25} = 0b100;
659 }
660
661 // addrmode6
662 // Unsigned multiply, multiply-accumulate instructions.
663 class AI6<bits<4> opcod, dag oops, dag iops, Format f, string opc,
664          string asm, list<dag> pattern>
665   : I<opcod, oops, iops, AddrMode6, Size4Bytes, IndexModeNone, f, opc,
666       asm,"",pattern>
667 {
668   // FIXME: bits 7-4 should be a sub-mode (for SMLAxx, SMLAWy, ...)
669   let Inst{7-4}   = 0b1001;
670   let Inst{27-24} = 0b0000;
671   let Inst{23-20} = opcod;
672 }
673 class AsI6<bits<4> opcod, dag oops, dag iops, Format f, string opc,
674           string asm, list<dag> pattern>
675   : sI<opcod, oops, iops, AddrMode6, Size4Bytes, IndexModeNone, f, opc,
676        asm,"",pattern>
677 {
678   // FIXME: bits 7-4 should be a sub-mode (for SMLAxx, SMLAWy, ...)
679   let Inst{7-4}   = 0b1001;
680   let Inst{27-24} = 0b0000;
681   let Inst{23-20} = opcod;
682 }
683
684 //===----------------------------------------------------------------------===//
685
686 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
687 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
688   list<Predicate> Predicates = [IsARM];
689 }
690 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
691   list<Predicate> Predicates = [IsARM, HasV5TE];
692 }
693 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
694   list<Predicate> Predicates = [IsARM, HasV6];
695 }
696
697 //===----------------------------------------------------------------------===//
698 //
699 // Thumb Instruction Format Definitions.
700 //
701
702
703 // TI - Thumb instruction.
704
705 class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
706              string asm, string cstr, list<dag> pattern>
707   // FIXME: Set all opcodes to 0 for now.
708   : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> {
709   let OutOperandList = outs;
710   let InOperandList = ins;
711   let AsmString   = asm;
712   let Pattern = pattern;
713   list<Predicate> Predicates = [IsThumb];
714 }
715
716 class TI<dag outs, dag ins, string asm, list<dag> pattern>
717   : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
718 class TI1<dag outs, dag ins, string asm, list<dag> pattern>
719   : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
720 class TI2<dag outs, dag ins, string asm, list<dag> pattern>
721   : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
722 class TI4<dag outs, dag ins, string asm, list<dag> pattern>
723   : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
724 class TIs<dag outs, dag ins, string asm, list<dag> pattern>
725   : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
726
727 // Two-address instructions
728 class TIt<dag outs, dag ins, string asm, list<dag> pattern>
729   : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
730
731 // BL, BLX(1) are translated by assembler into two instructions
732 class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
733   : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
734
735 // BR_JT instructions
736 class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
737   : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
738
739
740 //===----------------------------------------------------------------------===//
741
742
743 // ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
744 class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
745   list<Predicate> Predicates = [IsThumb];
746 }
747
748 class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
749   list<Predicate> Predicates = [IsThumb, HasV5T];
750 }