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