blob: 3ac9b1e79ba37621528a9bc014f6f125a5963772 [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 Chengee80fb72008-11-06 01:21:28 +000023def 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>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000030
Evan Chengee80fb72008-11-06 01:21:28 +000031def DPFrm : Format<9>;
32def DPSoRegFrm : Format<10>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000033
Evan Chengee80fb72008-11-06 01:21:28 +000034def LdFrm : Format<11>;
35def StFrm : Format<12>;
36def LdMiscFrm : Format<13>;
37def StMiscFrm : Format<14>;
38def LdMulFrm : Format<15>;
39def StMulFrm : Format<16>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000040
Evan Chengee80fb72008-11-06 01:21:28 +000041def ArithMisc : Format<17>;
42def ThumbFrm : Format<18>;
43def VFPFrm : Format<19>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000044
Evan Cheng86a926a2008-11-05 18:35:52 +000045// Misc flag for data processing instructions that indicates whether
46// the instruction has a Rn register operand.
47class UnaryDP { bit isUnaryDataProc = 1; }
Evan Cheng7b0249b2008-08-28 23:39:26 +000048
Evan Cheng7b0249b2008-08-28 23:39:26 +000049//===----------------------------------------------------------------------===//
50
51// ARM Instruction templates.
52//
53
54class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
55 Format f, string cstr>
56 : Instruction {
Evan Chengd0750352008-08-29 07:40:52 +000057 field bits<32> Inst;
58
Evan Cheng7b0249b2008-08-28 23:39:26 +000059 let Namespace = "ARM";
60
61 bits<4> Opcode = opcod;
Evan Cheng86a926a2008-11-05 18:35:52 +000062
63 // TSFlagsFields
Evan Cheng7b0249b2008-08-28 23:39:26 +000064 AddrMode AM = am;
65 bits<4> AddrModeBits = AM.Value;
66
67 SizeFlagVal SZ = sz;
68 bits<3> SizeFlag = SZ.Value;
69
70 IndexMode IM = im;
71 bits<2> IndexModeBits = IM.Value;
72
73 Format F = f;
74 bits<5> Form = F.Value;
Evan Cheng86a926a2008-11-05 18:35:52 +000075
76 //
77 // Attributes specific to ARM instructions...
78 //
79 bit isUnaryDataProc = 0;
Evan Cheng7b0249b2008-08-28 23:39:26 +000080
81 let Constraints = cstr;
82}
83
84class PseudoInst<dag oops, dag iops, string asm, list<dag> pattern>
85 : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, ""> {
86 let OutOperandList = oops;
87 let InOperandList = iops;
88 let AsmString = asm;
89 let Pattern = pattern;
90}
91
92// Almost all ARM instructions are predicable.
93class I<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
94 IndexMode im, Format f, string opc, string asm, string cstr,
95 list<dag> pattern>
96 : InstARM<opcod, am, sz, im, f, cstr> {
97 let OutOperandList = oops;
98 let InOperandList = !con(iops, (ops pred:$p));
99 let AsmString = !strconcat(opc, !strconcat("${p}", asm));
100 let Pattern = pattern;
101 list<Predicate> Predicates = [IsARM];
102}
103
104// Same as I except it can optionally modify CPSR. Note it's modeled as
105// an input operand since by default it's a zero register. It will
106// become an implicit def once it's "flipped".
107class sI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
108 IndexMode im, Format f, string opc, string asm, string cstr,
109 list<dag> pattern>
110 : InstARM<opcod, am, sz, im, f, cstr> {
111 let OutOperandList = oops;
112 let InOperandList = !con(iops, (ops pred:$p, cc_out:$s));
113 let AsmString = !strconcat(opc, !strconcat("${p}${s}", asm));
114 let Pattern = pattern;
115 list<Predicate> Predicates = [IsARM];
116}
117
Evan Chengc5409a82008-09-01 07:19:00 +0000118// Special cases
119class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
120 IndexMode im, Format f, string asm, string cstr, list<dag> pattern>
121 : InstARM<opcod, am, sz, im, f, cstr> {
122 let OutOperandList = oops;
123 let InOperandList = iops;
124 let AsmString = asm;
125 let Pattern = pattern;
126 list<Predicate> Predicates = [IsARM];
127}
128
Evan Cheng7b0249b2008-08-28 23:39:26 +0000129class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
130 string asm, list<dag> pattern>
131 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
132 asm,"",pattern>;
133class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
134 string asm, list<dag> pattern>
135 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
136 asm,"",pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000137class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
138 list<dag> pattern>
139 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
140 "", pattern>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000141
142// Ctrl flow instructions
143class ABLpredI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
144 string asm, list<dag> pattern>
145 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
146 asm,"",pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000147 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000148}
149class ABLI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
150 list<dag> pattern>
151 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
152 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000153 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000154}
Evan Cheng10a9eb82008-09-01 08:25:56 +0000155// FIXME: BX
Evan Chengc5409a82008-09-01 07:19:00 +0000156class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
157 list<dag> pattern>
158 : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
159 "", pattern>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000160class ABI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
161 list<dag> pattern>
162 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
163 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000164 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000165}
166class ABccI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
167 string asm, list<dag> pattern>
168 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
169 asm,"",pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000170 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000171}
172
173// BR_JT instructions
174// == mov pc
175class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
176 : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
177 asm, "", pattern> {
178 let Inst{20} = 0; // S Bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000179 let Inst{24-21} = opcod;
180 let Inst{27-26} = {0,0};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000181}
Evan Cheng18e5d102008-09-17 07:16:21 +0000182// == add pc
Evan Cheng10a9eb82008-09-01 08:25:56 +0000183class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
184 : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
185 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000186 let Inst{20} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000187 let Inst{24-21} = opcod;
188 let Inst{27-26} = {0,0};
Evan Cheng18e5d102008-09-17 07:16:21 +0000189}
190// == ldr pc
191class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
192 : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
193 asm, "", pattern> {
Evan Cheng10a9eb82008-09-01 08:25:56 +0000194 let Inst{20} = 1; // L bit
195 let Inst{21} = 0; // W bit
196 let Inst{22} = 0; // B bit
197 let Inst{24} = 1; // P bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000198 let Inst{27-26} = {0,1};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000199}
200
Evan Cheng2e62b662008-09-01 01:51:14 +0000201
202// addrmode1 instructions
Evan Cheng7b0249b2008-08-28 23:39:26 +0000203class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
204 string asm, list<dag> pattern>
205 : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd0750352008-08-29 07:40:52 +0000206 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000207 let Inst{24-21} = opcod;
208 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000209}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000210class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
211 string asm, list<dag> pattern>
212 : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd0750352008-08-29 07:40:52 +0000213 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000214 let Inst{24-21} = opcod;
215 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000216}
Evan Chengc5409a82008-09-01 07:19:00 +0000217class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
218 list<dag> pattern>
219 : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
220 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000221 let Inst{24-21} = opcod;
222 let Inst{27-26} = {0,0};
Evan Chengc5409a82008-09-01 07:19:00 +0000223}
Evan Cheng2e62b662008-09-01 01:51:14 +0000224class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
225 string asm, list<dag> pattern>
226 : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
227 asm, "", pattern>;
Evan Chengda020022008-08-31 19:02:21 +0000228
Evan Cheng2e62b662008-09-01 01:51:14 +0000229
230// addrmode2 loads and stores
Evan Cheng7b0249b2008-08-28 23:39:26 +0000231class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
232 string asm, list<dag> pattern>
233 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
Evan Chengda020022008-08-31 19:02:21 +0000234 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000235 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000236}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000237
238// loads
Evan Chengda020022008-08-31 19:02:21 +0000239class AI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
240 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000241 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
242 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
Evan Chengc41fb3152008-11-05 23:22:34 +0000247 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000248}
Evan Chengae7b1d72008-09-01 07:34:13 +0000249class AXI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
250 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000251 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
252 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000253 let Inst{20} = 1; // L bit
254 let Inst{21} = 0; // W bit
255 let Inst{22} = 0; // B bit
256 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000257 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000258}
Evan Chengda020022008-08-31 19:02:21 +0000259class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
260 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000261 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
262 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000263 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000264 let Inst{21} = 0; // W bit
265 let Inst{22} = 1; // B bit
266 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000267 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000268}
Evan Chengae7b1d72008-09-01 07:34:13 +0000269class AXI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
270 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000271 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
272 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000273 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
Evan Chengc41fb3152008-11-05 23:22:34 +0000277 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000278}
Evan Chengda020022008-08-31 19:02:21 +0000279
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000280// stores
281class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
282 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000283 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
284 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000285 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000286 let Inst{21} = 0; // W bit
287 let Inst{22} = 0; // B bit
288 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000289 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000290}
Evan Chengae7b1d72008-09-01 07:34:13 +0000291class AXI2stw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
292 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000293 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
294 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000295 let Inst{20} = 0; // L bit
296 let Inst{21} = 0; // W bit
297 let Inst{22} = 0; // B bit
298 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000299 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000300}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000301class AI2stb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
302 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000303 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
304 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000305 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000306 let Inst{21} = 0; // W bit
307 let Inst{22} = 1; // B bit
308 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000309 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000310}
Evan Chengae7b1d72008-09-01 07:34:13 +0000311class AXI2stb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
312 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000313 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
314 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000315 let Inst{20} = 0; // L bit
316 let Inst{21} = 0; // W bit
317 let Inst{22} = 1; // B bit
318 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000319 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000320}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000321
Evan Chengac92c3f2008-09-01 07:00:14 +0000322// Pre-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000323class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000324 string asm, string cstr, list<dag> pattern>
325 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000326 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000327 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000328 let Inst{21} = 1; // W bit
329 let Inst{22} = 0; // B bit
330 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000331 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000332}
333class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
334 string asm, string cstr, list<dag> pattern>
335 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
336 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000337 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000338 let Inst{21} = 1; // W bit
339 let Inst{22} = 1; // B bit
340 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000341 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000342}
343
Evan Chengac92c3f2008-09-01 07:00:14 +0000344// Pre-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000345class AI2stwpr<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} = 0; // B bit
352 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000353 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000354}
355class AI2stbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
356 string asm, string cstr, list<dag> pattern>
357 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
358 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000359 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000360 let Inst{21} = 1; // W bit
361 let Inst{22} = 1; // B bit
362 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000363 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000364}
365
Evan Chengac92c3f2008-09-01 07:00:14 +0000366// Post-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000367class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000368 string asm, string cstr, list<dag> pattern>
369 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000370 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000371 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000372 let Inst{21} = 0; // W bit
373 let Inst{22} = 0; // B bit
374 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000375 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000376}
377class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
378 string asm, string cstr, list<dag> pattern>
379 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
380 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000381 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000382 let Inst{21} = 0; // W bit
383 let Inst{22} = 1; // B bit
384 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000385 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000386}
387
Evan Chengac92c3f2008-09-01 07:00:14 +0000388// Post-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000389class AI2stwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
390 string asm, string cstr, list<dag> pattern>
391 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
392 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000393 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000394 let Inst{21} = 0; // W bit
395 let Inst{22} = 0; // B bit
396 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000397 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000398}
399class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
400 string asm, string cstr, list<dag> pattern>
401 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
402 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000403 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000404 let Inst{21} = 0; // W bit
405 let Inst{22} = 1; // B bit
406 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000407 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000408}
409
Evan Cheng2e62b662008-09-01 01:51:14 +0000410// addrmode3 instructions
411class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
412 string asm, list<dag> pattern>
413 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
414 asm, "", pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000415class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
416 list<dag> pattern>
417 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
418 "", pattern>;
Evan Cheng2e62b662008-09-01 01:51:14 +0000419
Evan Chengac92c3f2008-09-01 07:00:14 +0000420// loads
421class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
422 string asm, list<dag> pattern>
423 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
424 asm, "", pattern> {
425 let Inst{4} = 1;
426 let Inst{5} = 1; // H bit
427 let Inst{6} = 0; // S bit
428 let Inst{7} = 1;
429 let Inst{20} = 1; // L bit
430 let Inst{21} = 0; // W bit
431 let Inst{24} = 1; // P bit
432}
Evan Chengae7b1d72008-09-01 07:34:13 +0000433class AXI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
434 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000435 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
436 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000437 let Inst{4} = 1;
438 let Inst{5} = 1; // H bit
439 let Inst{6} = 0; // S bit
440 let Inst{7} = 1;
441 let Inst{20} = 1; // L bit
442 let Inst{21} = 0; // W bit
443 let Inst{24} = 1; // P bit
444}
Evan Chengac92c3f2008-09-01 07:00:14 +0000445class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
446 string asm, list<dag> pattern>
447 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
448 asm, "", pattern> {
449 let Inst{4} = 1;
450 let Inst{5} = 1; // H bit
451 let Inst{6} = 1; // S bit
452 let Inst{7} = 1;
453 let Inst{20} = 1; // L bit
454 let Inst{21} = 0; // W bit
455 let Inst{24} = 1; // P bit
456}
Evan Chengae7b1d72008-09-01 07:34:13 +0000457class AXI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
458 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000459 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
460 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000461 let Inst{4} = 1;
462 let Inst{5} = 1; // H bit
463 let Inst{6} = 1; // S bit
464 let Inst{7} = 1;
465 let Inst{20} = 1; // L bit
466 let Inst{21} = 0; // W bit
467 let Inst{24} = 1; // P bit
468}
Evan Chengac92c3f2008-09-01 07:00:14 +0000469class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
470 string asm, list<dag> pattern>
471 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
472 asm, "", pattern> {
473 let Inst{4} = 1;
474 let Inst{5} = 0; // H bit
475 let Inst{6} = 1; // S bit
476 let Inst{7} = 1;
477 let Inst{20} = 1; // L bit
478 let Inst{21} = 0; // W bit
479 let Inst{24} = 1; // P bit
480}
Evan Chengae7b1d72008-09-01 07:34:13 +0000481class AXI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
482 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000483 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
484 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000485 let Inst{4} = 1;
486 let Inst{5} = 0; // H bit
487 let Inst{6} = 1; // S bit
488 let Inst{7} = 1;
489 let Inst{20} = 1; // L bit
490 let Inst{21} = 0; // W bit
491 let Inst{24} = 1; // P bit
492}
Evan Chengac92c3f2008-09-01 07:00:14 +0000493class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc,
494 string asm, list<dag> pattern>
495 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
496 asm, "", pattern> {
497 let Inst{4} = 1;
498 let Inst{5} = 0; // H bit
499 let Inst{6} = 1; // S bit
500 let Inst{7} = 1;
501 let Inst{20} = 0; // L bit
502 let Inst{21} = 0; // W bit
503 let Inst{24} = 1; // P bit
504}
505
506// stores
507class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc,
508 string asm, list<dag> pattern>
509 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
510 asm, "", pattern> {
511 let Inst{4} = 1;
512 let Inst{5} = 1; // H bit
513 let Inst{6} = 0; // S bit
514 let Inst{7} = 1;
515 let Inst{20} = 0; // L bit
516 let Inst{21} = 0; // W bit
517 let Inst{24} = 1; // P bit
518}
Evan Chengae7b1d72008-09-01 07:34:13 +0000519class AXI3sth<bits<4> opcod, dag oops, dag iops, Format f, string asm,
520 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000521 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
522 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000523 let Inst{4} = 1;
524 let Inst{5} = 1; // H bit
525 let Inst{6} = 0; // S bit
526 let Inst{7} = 1;
527 let Inst{20} = 0; // L bit
528 let Inst{21} = 0; // W bit
529 let Inst{24} = 1; // P bit
530}
Evan Chengac92c3f2008-09-01 07:00:14 +0000531class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc,
532 string asm, list<dag> pattern>
533 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
534 asm, "", pattern> {
535 let Inst{4} = 1;
536 let Inst{5} = 1; // H bit
537 let Inst{6} = 1; // S bit
538 let Inst{7} = 1;
539 let Inst{20} = 0; // L bit
540 let Inst{21} = 0; // W bit
541 let Inst{24} = 1; // P bit
542}
543
544// Pre-indexed loads
545class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
546 string asm, string cstr, list<dag> pattern>
547 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
548 asm, cstr, pattern> {
549 let Inst{4} = 1;
550 let Inst{5} = 1; // H bit
551 let Inst{6} = 0; // S bit
552 let Inst{7} = 1;
553 let Inst{20} = 1; // L bit
554 let Inst{21} = 1; // W bit
555 let Inst{24} = 1; // P bit
556}
557class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
558 string asm, string cstr, list<dag> pattern>
559 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
560 asm, cstr, pattern> {
561 let Inst{4} = 1;
562 let Inst{5} = 1; // H bit
563 let Inst{6} = 1; // S bit
564 let Inst{7} = 1;
565 let Inst{20} = 1; // L bit
566 let Inst{21} = 1; // W bit
567 let Inst{24} = 1; // P bit
568}
569class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
570 string asm, string cstr, list<dag> pattern>
571 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
572 asm, cstr, pattern> {
573 let Inst{4} = 1;
574 let Inst{5} = 0; // H bit
575 let Inst{6} = 1; // S bit
576 let Inst{7} = 1;
577 let Inst{20} = 1; // L bit
578 let Inst{21} = 1; // W bit
579 let Inst{24} = 1; // P bit
580}
581
582// Pre-indexed stores
583class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
584 string asm, string cstr, list<dag> pattern>
585 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
586 asm, cstr, pattern> {
587 let Inst{4} = 1;
588 let Inst{5} = 1; // H bit
589 let Inst{6} = 0; // S bit
590 let Inst{7} = 1;
591 let Inst{20} = 0; // L bit
592 let Inst{21} = 1; // W bit
593 let Inst{24} = 1; // P bit
594}
595
596// Post-indexed loads
597class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
598 string asm, string cstr, list<dag> pattern>
599 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
600 asm, cstr,pattern> {
601 let Inst{4} = 1;
602 let Inst{5} = 1; // H bit
603 let Inst{6} = 0; // S bit
604 let Inst{7} = 1;
605 let Inst{20} = 1; // L bit
606 let Inst{21} = 1; // W bit
607 let Inst{24} = 0; // P bit
608}
609class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
610 string asm, string cstr, list<dag> pattern>
611 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
612 asm, cstr,pattern> {
613 let Inst{4} = 1;
614 let Inst{5} = 1; // H bit
615 let Inst{6} = 1; // S bit
616 let Inst{7} = 1;
617 let Inst{20} = 1; // L bit
618 let Inst{21} = 1; // W bit
619 let Inst{24} = 0; // P bit
620}
621class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
622 string asm, string cstr, list<dag> pattern>
623 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
624 asm, cstr,pattern> {
625 let Inst{4} = 1;
626 let Inst{5} = 0; // H bit
627 let Inst{6} = 1; // S bit
628 let Inst{7} = 1;
629 let Inst{20} = 1; // L bit
630 let Inst{21} = 1; // W bit
631 let Inst{24} = 0; // P bit
632}
633
634// Post-indexed stores
635class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
636 string asm, string cstr, list<dag> pattern>
637 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
638 asm, cstr,pattern> {
639 let Inst{4} = 1;
640 let Inst{5} = 1; // H bit
641 let Inst{6} = 0; // S bit
642 let Inst{7} = 1;
643 let Inst{20} = 0; // L bit
644 let Inst{21} = 1; // W bit
645 let Inst{24} = 0; // P bit
646}
647
648
Evan Cheng2e62b662008-09-01 01:51:14 +0000649// addrmode4 instructions
650class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
651 string asm, list<dag> pattern>
652 : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd36b01c2008-09-01 07:48:18 +0000653 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000654 let Inst{25-27} = {0,0,1};
Evan Chengd36b01c2008-09-01 07:48:18 +0000655}
656class AXI4ld<bits<4> opcod, dag oops, dag iops, Format f, string asm,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000657 list<dag> pattern>
658 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
Evan Chengd36b01c2008-09-01 07:48:18 +0000659 "", pattern> {
660 let Inst{20} = 1; // 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}
664class AXI4ldpc<bits<4> opcod, dag oops, dag iops, Format f, string asm,
665 list<dag> pattern>
666 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
667 "", pattern> {
668 let Inst{20} = 1; // L bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000669 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000670}
671class AXI4st<bits<4> opcod, dag oops, dag iops, Format f, string asm,
672 list<dag> pattern>
673 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
674 "", pattern> {
675 let Inst{20} = 0; // L bit
676 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000677 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000678}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000679
Jim Grosbach1feed042008-11-03 18:38:31 +0000680// Unsigned multiply, multiply-accumulate instructions.
Evan Chengee80fb72008-11-06 01:21:28 +0000681class AMul1I<bits<7> mulopc, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000682 string asm, list<dag> pattern>
Evan Chengee80fb72008-11-06 01:21:28 +0000683 : I<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
Evan Cheng86a926a2008-11-05 18:35:52 +0000684 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000685 let Inst{7-4} = 0b1001;
Evan Chengee80fb72008-11-06 01:21:28 +0000686 let Inst{20} = 0; // S bit
687 let Inst{27-21} = mulopc;
Jim Grosbach1feed042008-11-03 18:38:31 +0000688}
Evan Chengee80fb72008-11-06 01:21:28 +0000689class AsMul1I<bits<7> mulopc, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000690 string asm, list<dag> pattern>
Evan Chengee80fb72008-11-06 01:21:28 +0000691 : sI<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
Evan Cheng86a926a2008-11-05 18:35:52 +0000692 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000693 let Inst{7-4} = 0b1001;
Evan Chengee80fb72008-11-06 01:21:28 +0000694 let Inst{27-21} = mulopc;
695}
696
697// Most significant word multiply
698class AMul2I<bits<7> mulopc, dag oops, dag iops, string opc,
699 string asm, list<dag> pattern>
700 : I<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
701 asm,"",pattern> {
702 let Inst{7-4} = 0b1001;
703 let Inst{20} = 1;
704 let Inst{27-21} = mulopc;
Jim Grosbach1feed042008-11-03 18:38:31 +0000705}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000706
Evan Cheng7b0249b2008-08-28 23:39:26 +0000707//===----------------------------------------------------------------------===//
708
709// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
710class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
711 list<Predicate> Predicates = [IsARM];
712}
713class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
714 list<Predicate> Predicates = [IsARM, HasV5TE];
715}
716class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
717 list<Predicate> Predicates = [IsARM, HasV6];
718}
Evan Cheng34a46e12008-08-29 06:41:12 +0000719
720//===----------------------------------------------------------------------===//
721//
722// Thumb Instruction Format Definitions.
723//
724
725
726// TI - Thumb instruction.
727
728class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
729 string asm, string cstr, list<dag> pattern>
730 // FIXME: Set all opcodes to 0 for now.
731 : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> {
732 let OutOperandList = outs;
733 let InOperandList = ins;
734 let AsmString = asm;
735 let Pattern = pattern;
736 list<Predicate> Predicates = [IsThumb];
737}
738
739class TI<dag outs, dag ins, string asm, list<dag> pattern>
740 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
741class TI1<dag outs, dag ins, string asm, list<dag> pattern>
742 : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
743class TI2<dag outs, dag ins, string asm, list<dag> pattern>
744 : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
745class TI4<dag outs, dag ins, string asm, list<dag> pattern>
746 : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
747class TIs<dag outs, dag ins, string asm, list<dag> pattern>
748 : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
749
750// Two-address instructions
751class TIt<dag outs, dag ins, string asm, list<dag> pattern>
752 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
753
754// BL, BLX(1) are translated by assembler into two instructions
755class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
756 : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
757
758// BR_JT instructions
759class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
760 : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
761
762
763//===----------------------------------------------------------------------===//
764
765
766// ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
767class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
768 list<Predicate> Predicates = [IsThumb];
769}
770
771class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
772 list<Predicate> Predicates = [IsThumb, HasV5T];
773}