blob: 80ffabebeef8da356e5b79e642c1dae1b89e5d17 [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>;
23def MulFrm : Format<2>;
24def MulSMLAW : Format<3>;
25def MulSMULW : Format<4>;
26def MulSMLA : Format<5>;
27def MulSMUL : Format<6>;
28def Branch : Format<7>;
29def BranchMisc : Format<8>;
30
Evan Cheng4c7e67a2008-09-13 01:35:33 +000031def DPRdIm : Format<9>;
32def DPRdReg : Format<10>;
33def DPRdSoReg : Format<11>;
34def DPRdMisc : Format<12>;
35def DPRnIm : Format<13>;
36def DPRnReg : Format<14>;
37def DPRnSoReg : Format<15>;
38def DPRIm : Format<16>;
39def DPRReg : Format<17>;
40def DPRSoReg : Format<18>;
41def DPRImS : Format<19>;
42def DPRRegS : Format<20>;
43def DPRSoRegS : Format<21>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000044
Evan Cheng4c7e67a2008-09-13 01:35:33 +000045def LdFrm : Format<22>;
46def StFrm : Format<23>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000047
Evan Cheng4c7e67a2008-09-13 01:35:33 +000048def ArithMisc : Format<24>;
49def ThumbFrm : Format<25>;
50def VFPFrm : Format<26>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000051
52
Evan Cheng7b0249b2008-08-28 23:39:26 +000053//===----------------------------------------------------------------------===//
54
55// ARM Instruction templates.
56//
57
58class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
59 Format f, string cstr>
60 : Instruction {
Evan Chengd0750352008-08-29 07:40:52 +000061 field bits<32> Inst;
62
Evan Cheng7b0249b2008-08-28 23:39:26 +000063 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
81class 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.
90class 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".
104class 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
Evan Chengc5409a82008-09-01 07:19:00 +0000115// Special cases
116class 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
Evan Cheng7b0249b2008-08-28 23:39:26 +0000126class 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>;
130class 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>;
Evan Chengc5409a82008-09-01 07:19:00 +0000134class 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>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000138
139// Ctrl flow instructions
140class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000144 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000145}
146class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000150 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000151}
Evan Cheng10a9eb82008-09-01 08:25:56 +0000152// FIXME: BX
Evan Chengc5409a82008-09-01 07:19:00 +0000153class 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>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000157class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000161 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000162}
163class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000167 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000168}
169
170// BR_JT instructions
171// == mov pc
172class 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
Jim Grosbach88c246f2008-10-14 20:36:24 +0000176 let Inst{24-21} = opcod;
177 let Inst{27-26} = {0,0};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000178}
Evan Cheng18e5d102008-09-17 07:16:21 +0000179// == add pc
Evan Cheng10a9eb82008-09-01 08:25:56 +0000180class 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> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000183 let Inst{20} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000184 let Inst{24-21} = opcod;
185 let Inst{27-26} = {0,0};
Evan Cheng18e5d102008-09-17 07:16:21 +0000186}
187// == ldr pc
188class 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> {
Evan Cheng10a9eb82008-09-01 08:25:56 +0000191 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
Jim Grosbach88c246f2008-10-14 20:36:24 +0000195 let Inst{27-26} = {0,1};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000196}
197
Evan Cheng2e62b662008-09-01 01:51:14 +0000198
199// addrmode1 instructions
Evan Cheng7b0249b2008-08-28 23:39:26 +0000200class 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,
Evan Chengd0750352008-08-29 07:40:52 +0000203 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000204 let Inst{24-21} = opcod;
205 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000206}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000207class 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,
Evan Chengd0750352008-08-29 07:40:52 +0000210 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000211 let Inst{24-21} = opcod;
212 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000213}
Evan Chengc5409a82008-09-01 07:19:00 +0000214class 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> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000218 let Inst{24-21} = opcod;
219 let Inst{27-26} = {0,0};
Evan Chengc5409a82008-09-01 07:19:00 +0000220}
Evan Cheng2e62b662008-09-01 01:51:14 +0000221class 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>;
Evan Chengda020022008-08-31 19:02:21 +0000225
Evan Cheng2e62b662008-09-01 01:51:14 +0000226
227// addrmode2 loads and stores
Evan Cheng7b0249b2008-08-28 23:39:26 +0000228class 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,
Evan Chengda020022008-08-31 19:02:21 +0000231 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000232 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000233}
Evan Chengc5409a82008-09-01 07:19:00 +0000234class 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>;
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000238
239// loads
Evan Chengda020022008-08-31 19:02:21 +0000240class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000243 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000244 let Inst{21} = 0; // W bit
245 let Inst{22} = 0; // B bit
246 let Inst{24} = 1; // P bit
247}
Evan Chengae7b1d72008-09-01 07:34:13 +0000248class 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}
Evan Chengda020022008-08-31 19:02:21 +0000257class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000260 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000261 let Inst{21} = 0; // W bit
262 let Inst{22} = 1; // B bit
263 let Inst{24} = 1; // P bit
264}
Evan Chengae7b1d72008-09-01 07:34:13 +0000265class 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}
Evan Chengda020022008-08-31 19:02:21 +0000274
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000275// stores
276class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000279 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000280 let Inst{21} = 0; // W bit
281 let Inst{22} = 0; // B bit
282 let Inst{24} = 1; // P bit
283}
Evan Chengae7b1d72008-09-01 07:34:13 +0000284class 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}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000293class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000296 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000297 let Inst{21} = 0; // W bit
298 let Inst{22} = 1; // B bit
299 let Inst{24} = 1; // P bit
300}
Evan Chengae7b1d72008-09-01 07:34:13 +0000301class 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}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000310
Evan Chengac92c3f2008-09-01 07:00:14 +0000311// Pre-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000312class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000313 string asm, string cstr, list<dag> pattern>
314 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000315 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000316 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000317 let Inst{21} = 1; // W bit
318 let Inst{22} = 0; // B bit
319 let Inst{24} = 1; // P bit
320}
321class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000325 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000326 let Inst{21} = 1; // W bit
327 let Inst{22} = 1; // B bit
328 let Inst{24} = 1; // P bit
329}
330
Evan Chengac92c3f2008-09-01 07:00:14 +0000331// Pre-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000332class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000336 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000337 let Inst{21} = 1; // W bit
338 let Inst{22} = 0; // B bit
339 let Inst{24} = 1; // P bit
340}
341class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000345 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000346 let Inst{21} = 1; // W bit
347 let Inst{22} = 1; // B bit
348 let Inst{24} = 1; // P bit
349}
350
Evan Chengac92c3f2008-09-01 07:00:14 +0000351// Post-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000352class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000353 string asm, string cstr, list<dag> pattern>
354 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000355 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000356 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000357 let Inst{21} = 0; // W bit
358 let Inst{22} = 0; // B bit
359 let Inst{24} = 0; // P bit
360}
361class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000365 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000366 let Inst{21} = 0; // W bit
367 let Inst{22} = 1; // B bit
368 let Inst{24} = 0; // P bit
369}
370
Evan Chengac92c3f2008-09-01 07:00:14 +0000371// Post-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000372class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000376 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000377 let Inst{21} = 0; // W bit
378 let Inst{22} = 0; // B bit
379 let Inst{24} = 0; // P bit
380}
381class 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> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000385 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000386 let Inst{21} = 0; // W bit
387 let Inst{22} = 1; // B bit
388 let Inst{24} = 0; // P bit
389}
390
Evan Cheng2e62b662008-09-01 01:51:14 +0000391// addrmode3 instructions
392class 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>;
Evan Chengc5409a82008-09-01 07:19:00 +0000396class 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>;
Evan Cheng2e62b662008-09-01 01:51:14 +0000400
Evan Chengac92c3f2008-09-01 07:00:14 +0000401// loads
402class 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}
Evan Chengae7b1d72008-09-01 07:34:13 +0000414class 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}
Evan Chengac92c3f2008-09-01 07:00:14 +0000426class 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}
Evan Chengae7b1d72008-09-01 07:34:13 +0000438class 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}
Evan Chengac92c3f2008-09-01 07:00:14 +0000450class 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}
Evan Chengae7b1d72008-09-01 07:34:13 +0000462class 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}
Evan Chengac92c3f2008-09-01 07:00:14 +0000474class 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
488class 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}
Evan Chengae7b1d72008-09-01 07:34:13 +0000500class 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}
Evan Chengac92c3f2008-09-01 07:00:14 +0000512class 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
526class 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}
538class 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}
550class 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
564class 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
578class 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}
590class 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}
602class 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
616class 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
Evan Cheng2e62b662008-09-01 01:51:14 +0000630// addrmode4 instructions
631class 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,
Evan Chengd36b01c2008-09-01 07:48:18 +0000634 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000635 let Inst{25-27} = {0,0,1};
Evan Chengd36b01c2008-09-01 07:48:18 +0000636}
637class AXI4ld<bits<4> opcod, dag oops, dag iops, Format f, string asm,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000638 list<dag> pattern>
639 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
Evan Chengd36b01c2008-09-01 07:48:18 +0000640 "", pattern> {
641 let Inst{20} = 1; // L bit
642 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000643 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000644}
645class 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{22} = 1; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000651 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000652}
653class AXI4st<bits<4> opcod, dag oops, dag iops, Format f, string asm,
654 list<dag> pattern>
655 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
656 "", pattern> {
657 let Inst{20} = 0; // L bit
658 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000659 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000660}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000661
Evan Cheng7b0249b2008-08-28 23:39:26 +0000662
Evan Cheng7b0249b2008-08-28 23:39:26 +0000663//===----------------------------------------------------------------------===//
664
665// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
666class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
667 list<Predicate> Predicates = [IsARM];
668}
669class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
670 list<Predicate> Predicates = [IsARM, HasV5TE];
671}
672class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
673 list<Predicate> Predicates = [IsARM, HasV6];
674}
Evan Cheng34a46e12008-08-29 06:41:12 +0000675
676//===----------------------------------------------------------------------===//
677//
678// Thumb Instruction Format Definitions.
679//
680
681
682// TI - Thumb instruction.
683
684class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
685 string asm, string cstr, list<dag> pattern>
686 // FIXME: Set all opcodes to 0 for now.
687 : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> {
688 let OutOperandList = outs;
689 let InOperandList = ins;
690 let AsmString = asm;
691 let Pattern = pattern;
692 list<Predicate> Predicates = [IsThumb];
693}
694
695class TI<dag outs, dag ins, string asm, list<dag> pattern>
696 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
697class TI1<dag outs, dag ins, string asm, list<dag> pattern>
698 : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
699class TI2<dag outs, dag ins, string asm, list<dag> pattern>
700 : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
701class TI4<dag outs, dag ins, string asm, list<dag> pattern>
702 : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
703class TIs<dag outs, dag ins, string asm, list<dag> pattern>
704 : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
705
706// Two-address instructions
707class TIt<dag outs, dag ins, string asm, list<dag> pattern>
708 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
709
710// BL, BLX(1) are translated by assembler into two instructions
711class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
712 : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
713
714// BR_JT instructions
715class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
716 : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
717
718
719//===----------------------------------------------------------------------===//
720
721
722// ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
723class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
724 list<Predicate> Predicates = [IsThumb];
725}
726
727class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
728 list<Predicate> Predicates = [IsThumb, HasV5T];
729}