blob: d284cd0dd5bb4a918a76eb09b3313ebbb6881642 [file] [log] [blame]
Evan Cheng7b0249b2008-08-28 23:39:26 +00001//===- 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.
18class Format<bits<5> val> {
19 bits<5> Value = val;
20}
21
22def Pseudo : Format<1>;
Evan Cheng86a926a2008-11-05 18:35:52 +000023def MulFrm1 : Format<2>;
24def MulFrm2 : Format<3>;
25def MulSMLAW : Format<4>;
26def MulSMULW : Format<5>;
27def MulSMLA : Format<6>;
28def MulSMUL : Format<7>;
29def Branch : Format<8>;
30def BranchMisc : Format<9>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000031
Evan Cheng86a926a2008-11-05 18:35:52 +000032def DPFrm : Format<10>;
33def DPSoRegFrm : Format<11>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000034
Evan Cheng86a926a2008-11-05 18:35:52 +000035def LdFrm : Format<12>;
36def StFrm : Format<13>;
37def LdMiscFrm : Format<14>;
38def StMiscFrm : Format<15>;
39def LdMulFrm : Format<16>;
40def StMulFrm : Format<17>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000041
Evan Cheng86a926a2008-11-05 18:35:52 +000042def ArithMisc : Format<18>;
43def ThumbFrm : Format<19>;
44def VFPFrm : Format<20>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000045
Evan Cheng86a926a2008-11-05 18:35:52 +000046// Misc flag for data processing instructions that indicates whether
47// the instruction has a Rn register operand.
48class UnaryDP { bit isUnaryDataProc = 1; }
Evan Cheng7b0249b2008-08-28 23:39:26 +000049
Evan Cheng7b0249b2008-08-28 23:39:26 +000050//===----------------------------------------------------------------------===//
51
52// ARM Instruction templates.
53//
54
55class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
56 Format f, string cstr>
57 : Instruction {
Evan Chengd0750352008-08-29 07:40:52 +000058 field bits<32> Inst;
59
Evan Cheng7b0249b2008-08-28 23:39:26 +000060 let Namespace = "ARM";
61
62 bits<4> Opcode = opcod;
Evan Cheng86a926a2008-11-05 18:35:52 +000063
64 // TSFlagsFields
Evan Cheng7b0249b2008-08-28 23:39:26 +000065 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;
Evan Cheng86a926a2008-11-05 18:35:52 +000076
77 //
78 // Attributes specific to ARM instructions...
79 //
80 bit isUnaryDataProc = 0;
Evan Cheng7b0249b2008-08-28 23:39:26 +000081
82 let Constraints = cstr;
83}
84
85class 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.
94class 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".
108class 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
Evan Chengc5409a82008-09-01 07:19:00 +0000119// Special cases
120class 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
Evan Cheng7b0249b2008-08-28 23:39:26 +0000130class 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>;
134class 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>;
Evan Chengc5409a82008-09-01 07:19:00 +0000138class 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>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000142
143// Ctrl flow instructions
144class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000148 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000149}
150class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000154 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000155}
Evan Cheng10a9eb82008-09-01 08:25:56 +0000156// FIXME: BX
Evan Chengc5409a82008-09-01 07:19:00 +0000157class 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>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000161class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000165 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000166}
167class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000171 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000172}
173
174// BR_JT instructions
175// == mov pc
176class 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
Jim Grosbach88c246f2008-10-14 20:36:24 +0000180 let Inst{24-21} = opcod;
181 let Inst{27-26} = {0,0};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000182}
Evan Cheng18e5d102008-09-17 07:16:21 +0000183// == add pc
Evan Cheng10a9eb82008-09-01 08:25:56 +0000184class 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> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000187 let Inst{20} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000188 let Inst{24-21} = opcod;
189 let Inst{27-26} = {0,0};
Evan Cheng18e5d102008-09-17 07:16:21 +0000190}
191// == ldr pc
192class 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> {
Evan Cheng10a9eb82008-09-01 08:25:56 +0000195 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
Jim Grosbach88c246f2008-10-14 20:36:24 +0000199 let Inst{27-26} = {0,1};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000200}
201
Evan Cheng2e62b662008-09-01 01:51:14 +0000202
203// addrmode1 instructions
Evan Cheng7b0249b2008-08-28 23:39:26 +0000204class 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,
Evan Chengd0750352008-08-29 07:40:52 +0000207 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000208 let Inst{24-21} = opcod;
209 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000210}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000211class 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,
Evan Chengd0750352008-08-29 07:40:52 +0000214 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000215 let Inst{24-21} = opcod;
216 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000217}
Evan Chengc5409a82008-09-01 07:19:00 +0000218class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000222 let Inst{24-21} = opcod;
223 let Inst{27-26} = {0,0};
Evan Chengc5409a82008-09-01 07:19:00 +0000224}
Evan Cheng2e62b662008-09-01 01:51:14 +0000225class 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>;
Evan Chengda020022008-08-31 19:02:21 +0000229
Evan Cheng2e62b662008-09-01 01:51:14 +0000230
231// addrmode2 loads and stores
Evan Cheng7b0249b2008-08-28 23:39:26 +0000232class 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,
Evan Chengda020022008-08-31 19:02:21 +0000235 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000236 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000237}
Evan Chengc5409a82008-09-01 07:19:00 +0000238class AXI2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
239 list<dag> pattern>
240 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
241 "", pattern>;
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000242
243// loads
Evan Chengda020022008-08-31 19:02:21 +0000244class AI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
245 string asm, list<dag> pattern>
246 : AI2<opcod, oops, iops, f, opc, asm, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000247 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000248 let Inst{21} = 0; // W bit
249 let Inst{22} = 0; // B bit
250 let Inst{24} = 1; // P bit
251}
Evan Chengae7b1d72008-09-01 07:34:13 +0000252class AXI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
253 list<dag> pattern>
254 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
255 "", pattern> {
256 let Inst{20} = 1; // L bit
257 let Inst{21} = 0; // W bit
258 let Inst{22} = 0; // B bit
259 let Inst{24} = 1; // P bit
260}
Evan Chengda020022008-08-31 19:02:21 +0000261class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
262 string asm, list<dag> pattern>
263 : AI2<opcod, oops, iops, f, opc, asm, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000264 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000265 let Inst{21} = 0; // W bit
266 let Inst{22} = 1; // B bit
267 let Inst{24} = 1; // P bit
268}
Evan Chengae7b1d72008-09-01 07:34:13 +0000269class 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, asm,
272 "", 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}
Evan Chengda020022008-08-31 19:02:21 +0000278
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000279// stores
280class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
281 string asm, list<dag> pattern>
282 : AI2<opcod, oops, iops, f, opc, asm, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000283 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000284 let Inst{21} = 0; // W bit
285 let Inst{22} = 0; // B bit
286 let Inst{24} = 1; // P bit
287}
Evan Chengae7b1d72008-09-01 07:34:13 +0000288class AXI2stw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
289 list<dag> pattern>
290 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
291 "", pattern> {
292 let Inst{20} = 0; // L bit
293 let Inst{21} = 0; // W bit
294 let Inst{22} = 0; // B bit
295 let Inst{24} = 1; // P bit
296}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000297class AI2stb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
298 string asm, list<dag> pattern>
299 : AI2<opcod, oops, iops, f, opc, asm, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000300 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000301 let Inst{21} = 0; // W bit
302 let Inst{22} = 1; // B bit
303 let Inst{24} = 1; // P bit
304}
Evan Chengae7b1d72008-09-01 07:34:13 +0000305class AXI2stb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
306 list<dag> pattern>
307 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
308 "", pattern> {
309 let Inst{20} = 0; // L bit
310 let Inst{21} = 0; // W bit
311 let Inst{22} = 1; // B bit
312 let Inst{24} = 1; // P bit
313}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000314
Evan Chengac92c3f2008-09-01 07:00:14 +0000315// Pre-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000316class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000317 string asm, string cstr, list<dag> pattern>
318 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000319 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000320 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000321 let Inst{21} = 1; // W bit
322 let Inst{22} = 0; // B bit
323 let Inst{24} = 1; // P bit
324}
325class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
326 string asm, string cstr, list<dag> pattern>
327 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
328 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000329 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000330 let Inst{21} = 1; // W bit
331 let Inst{22} = 1; // B bit
332 let Inst{24} = 1; // P bit
333}
334
Evan Chengac92c3f2008-09-01 07:00:14 +0000335// Pre-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000336class AI2stwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
337 string asm, string cstr, list<dag> pattern>
338 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
339 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000340 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000341 let Inst{21} = 1; // W bit
342 let Inst{22} = 0; // B bit
343 let Inst{24} = 1; // P bit
344}
345class AI2stbpr<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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000349 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000350 let Inst{21} = 1; // W bit
351 let Inst{22} = 1; // B bit
352 let Inst{24} = 1; // P bit
353}
354
Evan Chengac92c3f2008-09-01 07:00:14 +0000355// Post-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000356class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000357 string asm, string cstr, list<dag> pattern>
358 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000359 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000360 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000361 let Inst{21} = 0; // W bit
362 let Inst{22} = 0; // B bit
363 let Inst{24} = 0; // P bit
364}
365class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
366 string asm, string cstr, list<dag> pattern>
367 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
368 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000369 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000370 let Inst{21} = 0; // W bit
371 let Inst{22} = 1; // B bit
372 let Inst{24} = 0; // P bit
373}
374
Evan Chengac92c3f2008-09-01 07:00:14 +0000375// Post-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000376class AI2stwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
377 string asm, string cstr, list<dag> pattern>
378 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
379 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000380 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000381 let Inst{21} = 0; // W bit
382 let Inst{22} = 0; // B bit
383 let Inst{24} = 0; // P bit
384}
385class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
386 string asm, string cstr, list<dag> pattern>
387 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
388 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000389 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000390 let Inst{21} = 0; // W bit
391 let Inst{22} = 1; // B bit
392 let Inst{24} = 0; // P bit
393}
394
Evan Cheng2e62b662008-09-01 01:51:14 +0000395// addrmode3 instructions
396class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
397 string asm, list<dag> pattern>
398 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
399 asm, "", pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000400class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
401 list<dag> pattern>
402 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
403 "", pattern>;
Evan Cheng2e62b662008-09-01 01:51:14 +0000404
Evan Chengac92c3f2008-09-01 07:00:14 +0000405// loads
406class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
407 string asm, list<dag> pattern>
408 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
409 asm, "", pattern> {
410 let Inst{4} = 1;
411 let Inst{5} = 1; // H bit
412 let Inst{6} = 0; // S bit
413 let Inst{7} = 1;
414 let Inst{20} = 1; // L bit
415 let Inst{21} = 0; // W bit
416 let Inst{24} = 1; // P bit
417}
Evan Chengae7b1d72008-09-01 07:34:13 +0000418class AXI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
419 list<dag> pattern>
420 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
421 "", pattern> {
422 let Inst{4} = 1;
423 let Inst{5} = 1; // H bit
424 let Inst{6} = 0; // S bit
425 let Inst{7} = 1;
426 let Inst{20} = 1; // L bit
427 let Inst{21} = 0; // W bit
428 let Inst{24} = 1; // P bit
429}
Evan Chengac92c3f2008-09-01 07:00:14 +0000430class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
431 string asm, list<dag> pattern>
432 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
433 asm, "", pattern> {
434 let Inst{4} = 1;
435 let Inst{5} = 1; // H bit
436 let Inst{6} = 1; // S bit
437 let Inst{7} = 1;
438 let Inst{20} = 1; // L bit
439 let Inst{21} = 0; // W bit
440 let Inst{24} = 1; // P bit
441}
Evan Chengae7b1d72008-09-01 07:34:13 +0000442class AXI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
443 list<dag> pattern>
444 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
445 "", pattern> {
446 let Inst{4} = 1;
447 let Inst{5} = 1; // H bit
448 let Inst{6} = 1; // S bit
449 let Inst{7} = 1;
450 let Inst{20} = 1; // L bit
451 let Inst{21} = 0; // W bit
452 let Inst{24} = 1; // P bit
453}
Evan Chengac92c3f2008-09-01 07:00:14 +0000454class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
455 string asm, list<dag> pattern>
456 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
457 asm, "", pattern> {
458 let Inst{4} = 1;
459 let Inst{5} = 0; // H bit
460 let Inst{6} = 1; // S bit
461 let Inst{7} = 1;
462 let Inst{20} = 1; // L bit
463 let Inst{21} = 0; // W bit
464 let Inst{24} = 1; // P bit
465}
Evan Chengae7b1d72008-09-01 07:34:13 +0000466class AXI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
467 list<dag> pattern>
468 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
469 "", pattern> {
470 let Inst{4} = 1;
471 let Inst{5} = 0; // H bit
472 let Inst{6} = 1; // S bit
473 let Inst{7} = 1;
474 let Inst{20} = 1; // L bit
475 let Inst{21} = 0; // W bit
476 let Inst{24} = 1; // P bit
477}
Evan Chengac92c3f2008-09-01 07:00:14 +0000478class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc,
479 string asm, list<dag> pattern>
480 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
481 asm, "", pattern> {
482 let Inst{4} = 1;
483 let Inst{5} = 0; // H bit
484 let Inst{6} = 1; // S bit
485 let Inst{7} = 1;
486 let Inst{20} = 0; // L bit
487 let Inst{21} = 0; // W bit
488 let Inst{24} = 1; // P bit
489}
490
491// stores
492class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc,
493 string asm, list<dag> pattern>
494 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
495 asm, "", pattern> {
496 let Inst{4} = 1;
497 let Inst{5} = 1; // H bit
498 let Inst{6} = 0; // S bit
499 let Inst{7} = 1;
500 let Inst{20} = 0; // L bit
501 let Inst{21} = 0; // W bit
502 let Inst{24} = 1; // P bit
503}
Evan Chengae7b1d72008-09-01 07:34:13 +0000504class AXI3sth<bits<4> opcod, dag oops, dag iops, Format f, string asm,
505 list<dag> pattern>
506 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
507 "", pattern> {
508 let Inst{4} = 1;
509 let Inst{5} = 1; // H bit
510 let Inst{6} = 0; // S bit
511 let Inst{7} = 1;
512 let Inst{20} = 0; // L bit
513 let Inst{21} = 0; // W bit
514 let Inst{24} = 1; // P bit
515}
Evan Chengac92c3f2008-09-01 07:00:14 +0000516class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc,
517 string asm, list<dag> pattern>
518 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
519 asm, "", pattern> {
520 let Inst{4} = 1;
521 let Inst{5} = 1; // H bit
522 let Inst{6} = 1; // S bit
523 let Inst{7} = 1;
524 let Inst{20} = 0; // L bit
525 let Inst{21} = 0; // W bit
526 let Inst{24} = 1; // P bit
527}
528
529// Pre-indexed loads
530class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
531 string asm, string cstr, list<dag> pattern>
532 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
533 asm, cstr, pattern> {
534 let Inst{4} = 1;
535 let Inst{5} = 1; // H bit
536 let Inst{6} = 0; // S bit
537 let Inst{7} = 1;
538 let Inst{20} = 1; // L bit
539 let Inst{21} = 1; // W bit
540 let Inst{24} = 1; // P bit
541}
542class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
543 string asm, string cstr, list<dag> pattern>
544 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
545 asm, cstr, pattern> {
546 let Inst{4} = 1;
547 let Inst{5} = 1; // H bit
548 let Inst{6} = 1; // S bit
549 let Inst{7} = 1;
550 let Inst{20} = 1; // L bit
551 let Inst{21} = 1; // W bit
552 let Inst{24} = 1; // P bit
553}
554class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
555 string asm, string cstr, list<dag> pattern>
556 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
557 asm, cstr, pattern> {
558 let Inst{4} = 1;
559 let Inst{5} = 0; // H bit
560 let Inst{6} = 1; // S bit
561 let Inst{7} = 1;
562 let Inst{20} = 1; // L bit
563 let Inst{21} = 1; // W bit
564 let Inst{24} = 1; // P bit
565}
566
567// Pre-indexed stores
568class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
569 string asm, string cstr, list<dag> pattern>
570 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
571 asm, cstr, pattern> {
572 let Inst{4} = 1;
573 let Inst{5} = 1; // H bit
574 let Inst{6} = 0; // S bit
575 let Inst{7} = 1;
576 let Inst{20} = 0; // L bit
577 let Inst{21} = 1; // W bit
578 let Inst{24} = 1; // P bit
579}
580
581// Post-indexed loads
582class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
583 string asm, string cstr, list<dag> pattern>
584 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
585 asm, cstr,pattern> {
586 let Inst{4} = 1;
587 let Inst{5} = 1; // H bit
588 let Inst{6} = 0; // S bit
589 let Inst{7} = 1;
590 let Inst{20} = 1; // L bit
591 let Inst{21} = 1; // W bit
592 let Inst{24} = 0; // P bit
593}
594class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
595 string asm, string cstr, list<dag> pattern>
596 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
597 asm, cstr,pattern> {
598 let Inst{4} = 1;
599 let Inst{5} = 1; // H bit
600 let Inst{6} = 1; // S bit
601 let Inst{7} = 1;
602 let Inst{20} = 1; // L bit
603 let Inst{21} = 1; // W bit
604 let Inst{24} = 0; // P bit
605}
606class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
607 string asm, string cstr, list<dag> pattern>
608 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
609 asm, cstr,pattern> {
610 let Inst{4} = 1;
611 let Inst{5} = 0; // H bit
612 let Inst{6} = 1; // S bit
613 let Inst{7} = 1;
614 let Inst{20} = 1; // L bit
615 let Inst{21} = 1; // W bit
616 let Inst{24} = 0; // P bit
617}
618
619// Post-indexed stores
620class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
621 string asm, string cstr, list<dag> pattern>
622 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
623 asm, cstr,pattern> {
624 let Inst{4} = 1;
625 let Inst{5} = 1; // H bit
626 let Inst{6} = 0; // S bit
627 let Inst{7} = 1;
628 let Inst{20} = 0; // L bit
629 let Inst{21} = 1; // W bit
630 let Inst{24} = 0; // P bit
631}
632
633
Evan Cheng2e62b662008-09-01 01:51:14 +0000634// addrmode4 instructions
635class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
636 string asm, list<dag> pattern>
637 : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd36b01c2008-09-01 07:48:18 +0000638 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000639 let Inst{25-27} = {0,0,1};
Evan Chengd36b01c2008-09-01 07:48:18 +0000640}
641class AXI4ld<bits<4> opcod, dag oops, dag iops, Format f, string asm,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000642 list<dag> pattern>
643 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
Evan Chengd36b01c2008-09-01 07:48:18 +0000644 "", pattern> {
645 let Inst{20} = 1; // L bit
646 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000647 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000648}
649class AXI4ldpc<bits<4> opcod, dag oops, dag iops, Format f, string asm,
650 list<dag> pattern>
651 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
652 "", pattern> {
653 let Inst{20} = 1; // L bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000654 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000655}
656class AXI4st<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} = 0; // L bit
661 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000662 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000663}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000664
Jim Grosbach1feed042008-11-03 18:38:31 +0000665// Unsigned multiply, multiply-accumulate instructions.
Evan Cheng86a926a2008-11-05 18:35:52 +0000666class AMul1I<bits<4> opcod, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000667 string asm, list<dag> pattern>
Evan Cheng86a926a2008-11-05 18:35:52 +0000668 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm1, opc,
669 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000670 // FIXME: bits 7-4 should be a sub-mode (for SMLAxx, SMLAWy, ...)
671 let Inst{7-4} = 0b1001;
672 let Inst{27-24} = 0b0000;
673 let Inst{23-20} = opcod;
674}
Evan Cheng86a926a2008-11-05 18:35:52 +0000675class AsMul1I<bits<4> opcod, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000676 string asm, list<dag> pattern>
Evan Cheng86a926a2008-11-05 18:35:52 +0000677 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm1, opc,
678 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000679 // FIXME: bits 7-4 should be a sub-mode (for SMLAxx, SMLAWy, ...)
680 let Inst{7-4} = 0b1001;
681 let Inst{27-24} = 0b0000;
682 let Inst{23-20} = opcod;
683}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000684
Evan Cheng7b0249b2008-08-28 23:39:26 +0000685//===----------------------------------------------------------------------===//
686
687// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
688class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
689 list<Predicate> Predicates = [IsARM];
690}
691class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
692 list<Predicate> Predicates = [IsARM, HasV5TE];
693}
694class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
695 list<Predicate> Predicates = [IsARM, HasV6];
696}
Evan Cheng34a46e12008-08-29 06:41:12 +0000697
698//===----------------------------------------------------------------------===//
699//
700// Thumb Instruction Format Definitions.
701//
702
703
704// TI - Thumb instruction.
705
706class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
707 string asm, string cstr, list<dag> pattern>
708 // FIXME: Set all opcodes to 0 for now.
709 : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> {
710 let OutOperandList = outs;
711 let InOperandList = ins;
712 let AsmString = asm;
713 let Pattern = pattern;
714 list<Predicate> Predicates = [IsThumb];
715}
716
717class TI<dag outs, dag ins, string asm, list<dag> pattern>
718 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
719class TI1<dag outs, dag ins, string asm, list<dag> pattern>
720 : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
721class TI2<dag outs, dag ins, string asm, list<dag> pattern>
722 : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
723class TI4<dag outs, dag ins, string asm, list<dag> pattern>
724 : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
725class TIs<dag outs, dag ins, string asm, list<dag> pattern>
726 : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
727
728// Two-address instructions
729class TIt<dag outs, dag ins, string asm, list<dag> pattern>
730 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
731
732// BL, BLX(1) are translated by assembler into two instructions
733class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
734 : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
735
736// BR_JT instructions
737class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
738 : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
739
740
741//===----------------------------------------------------------------------===//
742
743
744// ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
745class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
746 list<Predicate> Predicates = [IsThumb];
747}
748
749class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
750 list<Predicate> Predicates = [IsThumb, HasV5T];
751}