blob: 2a30e777ee0ea82c18347a8a18570bcf9e72bb60 [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>;
Evan Cheng38396be2008-11-06 03:35:07 +000024def Branch : Format<3>;
25def BranchMisc : Format<4>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000026
Evan Cheng38396be2008-11-06 03:35:07 +000027def DPFrm : Format<5>;
28def DPSoRegFrm : Format<6>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000029
Evan Cheng38396be2008-11-06 03:35:07 +000030def LdFrm : Format<7>;
31def StFrm : Format<8>;
32def LdMiscFrm : Format<9>;
33def StMiscFrm : Format<10>;
34def LdMulFrm : Format<11>;
35def StMulFrm : Format<12>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000036
Evan Cheng38396be2008-11-06 03:35:07 +000037def ArithMisc : Format<13>;
38def ThumbFrm : Format<14>;
39def VFPFrm : Format<15>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000040
Evan Cheng86a926a2008-11-05 18:35:52 +000041// Misc flag for data processing instructions that indicates whether
42// the instruction has a Rn register operand.
43class UnaryDP { bit isUnaryDataProc = 1; }
Evan Cheng7b0249b2008-08-28 23:39:26 +000044
Evan Cheng7b0249b2008-08-28 23:39:26 +000045//===----------------------------------------------------------------------===//
46
47// ARM Instruction templates.
48//
49
50class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
51 Format f, string cstr>
52 : Instruction {
Evan Chengd0750352008-08-29 07:40:52 +000053 field bits<32> Inst;
54
Evan Cheng7b0249b2008-08-28 23:39:26 +000055 let Namespace = "ARM";
56
57 bits<4> Opcode = opcod;
Evan Cheng86a926a2008-11-05 18:35:52 +000058
59 // TSFlagsFields
Evan Cheng7b0249b2008-08-28 23:39:26 +000060 AddrMode AM = am;
61 bits<4> AddrModeBits = AM.Value;
62
63 SizeFlagVal SZ = sz;
64 bits<3> SizeFlag = SZ.Value;
65
66 IndexMode IM = im;
67 bits<2> IndexModeBits = IM.Value;
68
69 Format F = f;
70 bits<5> Form = F.Value;
Evan Cheng86a926a2008-11-05 18:35:52 +000071
72 //
73 // Attributes specific to ARM instructions...
74 //
75 bit isUnaryDataProc = 0;
Evan Cheng7b0249b2008-08-28 23:39:26 +000076
77 let Constraints = cstr;
78}
79
80class PseudoInst<dag oops, dag iops, string asm, list<dag> pattern>
81 : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, ""> {
82 let OutOperandList = oops;
83 let InOperandList = iops;
84 let AsmString = asm;
85 let Pattern = pattern;
86}
87
88// Almost all ARM instructions are predicable.
89class I<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
90 IndexMode im, Format f, string opc, string asm, string cstr,
91 list<dag> pattern>
92 : InstARM<opcod, am, sz, im, f, cstr> {
93 let OutOperandList = oops;
94 let InOperandList = !con(iops, (ops pred:$p));
95 let AsmString = !strconcat(opc, !strconcat("${p}", asm));
96 let Pattern = pattern;
97 list<Predicate> Predicates = [IsARM];
98}
99
100// Same as I except it can optionally modify CPSR. Note it's modeled as
101// an input operand since by default it's a zero register. It will
102// become an implicit def once it's "flipped".
103class sI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
104 IndexMode im, Format f, string opc, string asm, string cstr,
105 list<dag> pattern>
106 : InstARM<opcod, am, sz, im, f, cstr> {
107 let OutOperandList = oops;
108 let InOperandList = !con(iops, (ops pred:$p, cc_out:$s));
109 let AsmString = !strconcat(opc, !strconcat("${p}${s}", asm));
110 let Pattern = pattern;
111 list<Predicate> Predicates = [IsARM];
112}
113
Evan Chengc5409a82008-09-01 07:19:00 +0000114// Special cases
115class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
116 IndexMode im, Format f, string asm, string cstr, list<dag> pattern>
117 : InstARM<opcod, am, sz, im, f, cstr> {
118 let OutOperandList = oops;
119 let InOperandList = iops;
120 let AsmString = asm;
121 let Pattern = pattern;
122 list<Predicate> Predicates = [IsARM];
123}
124
Evan Cheng7b0249b2008-08-28 23:39:26 +0000125class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
126 string asm, list<dag> pattern>
127 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
128 asm,"",pattern>;
129class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
130 string asm, list<dag> pattern>
131 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
132 asm,"",pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000133class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
134 list<dag> pattern>
135 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
136 "", pattern>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000137
138// Ctrl flow instructions
139class ABLpredI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
140 string asm, list<dag> pattern>
141 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
142 asm,"",pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000143 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000144}
145class ABLI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
146 list<dag> pattern>
147 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
148 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000149 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000150}
Evan Cheng10a9eb82008-09-01 08:25:56 +0000151// FIXME: BX
Evan Chengc5409a82008-09-01 07:19:00 +0000152class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
153 list<dag> pattern>
154 : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
155 "", pattern>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000156class ABI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
157 list<dag> pattern>
158 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
159 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000160 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000161}
162class ABccI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
163 string asm, list<dag> pattern>
164 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
165 asm,"",pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000166 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000167}
168
169// BR_JT instructions
170// == mov pc
171class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
172 : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
173 asm, "", pattern> {
174 let Inst{20} = 0; // S Bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000175 let Inst{24-21} = opcod;
176 let Inst{27-26} = {0,0};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000177}
Evan Cheng18e5d102008-09-17 07:16:21 +0000178// == add pc
Evan Cheng10a9eb82008-09-01 08:25:56 +0000179class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
180 : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
181 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000182 let Inst{20} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000183 let Inst{24-21} = opcod;
184 let Inst{27-26} = {0,0};
Evan Cheng18e5d102008-09-17 07:16:21 +0000185}
186// == ldr pc
187class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
188 : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
189 asm, "", pattern> {
Evan Cheng10a9eb82008-09-01 08:25:56 +0000190 let Inst{20} = 1; // L bit
191 let Inst{21} = 0; // W bit
192 let Inst{22} = 0; // B bit
193 let Inst{24} = 1; // P bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000194 let Inst{27-26} = {0,1};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000195}
196
Evan Cheng2e62b662008-09-01 01:51:14 +0000197
198// addrmode1 instructions
Evan Cheng7b0249b2008-08-28 23:39:26 +0000199class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
200 string asm, list<dag> pattern>
201 : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd0750352008-08-29 07:40:52 +0000202 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000203 let Inst{24-21} = opcod;
204 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000205}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000206class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
207 string asm, list<dag> pattern>
208 : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd0750352008-08-29 07:40:52 +0000209 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000210 let Inst{24-21} = opcod;
211 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000212}
Evan Chengc5409a82008-09-01 07:19:00 +0000213class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
214 list<dag> pattern>
215 : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
216 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000217 let Inst{24-21} = opcod;
218 let Inst{27-26} = {0,0};
Evan Chengc5409a82008-09-01 07:19:00 +0000219}
Evan Cheng2e62b662008-09-01 01:51:14 +0000220class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
221 string asm, list<dag> pattern>
222 : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
223 asm, "", pattern>;
Evan Chengda020022008-08-31 19:02:21 +0000224
Evan Cheng2e62b662008-09-01 01:51:14 +0000225
226// addrmode2 loads and stores
Evan Cheng7b0249b2008-08-28 23:39:26 +0000227class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
228 string asm, list<dag> pattern>
229 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
Evan Chengda020022008-08-31 19:02:21 +0000230 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000231 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000232}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000233
234// loads
Evan Chengda020022008-08-31 19:02:21 +0000235class AI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
236 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000237 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
238 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000239 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000240 let Inst{21} = 0; // W bit
241 let Inst{22} = 0; // B bit
242 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000243 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000244}
Evan Chengae7b1d72008-09-01 07:34:13 +0000245class AXI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
246 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000247 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
248 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000249 let Inst{20} = 1; // L bit
250 let Inst{21} = 0; // W bit
251 let Inst{22} = 0; // B bit
252 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000253 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000254}
Evan Chengda020022008-08-31 19:02:21 +0000255class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
256 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000257 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
258 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000259 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000260 let Inst{21} = 0; // W bit
261 let Inst{22} = 1; // B bit
262 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000263 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000264}
Evan Chengae7b1d72008-09-01 07:34:13 +0000265class AXI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
266 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000267 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
268 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000269 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
Evan Chengc41fb3152008-11-05 23:22:34 +0000273 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000274}
Evan Chengda020022008-08-31 19:02:21 +0000275
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000276// stores
277class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
278 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000279 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
280 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000281 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000282 let Inst{21} = 0; // W bit
283 let Inst{22} = 0; // B bit
284 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000285 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000286}
Evan Chengae7b1d72008-09-01 07:34:13 +0000287class AXI2stw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
288 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000289 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
290 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000291 let Inst{20} = 0; // L bit
292 let Inst{21} = 0; // W bit
293 let Inst{22} = 0; // B bit
294 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000295 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000296}
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>
Evan Chengc41fb3152008-11-05 23:22:34 +0000299 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
300 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000301 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000302 let Inst{21} = 0; // W bit
303 let Inst{22} = 1; // B bit
304 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000305 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000306}
Evan Chengae7b1d72008-09-01 07:34:13 +0000307class AXI2stb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
308 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000309 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
310 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000311 let Inst{20} = 0; // L bit
312 let Inst{21} = 0; // W bit
313 let Inst{22} = 1; // B bit
314 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000315 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000316}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000317
Evan Chengac92c3f2008-09-01 07:00:14 +0000318// Pre-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000319class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000320 string asm, string cstr, list<dag> pattern>
321 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000322 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000323 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000324 let Inst{21} = 1; // W bit
325 let Inst{22} = 0; // B bit
326 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000327 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000328}
329class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
330 string asm, string cstr, list<dag> pattern>
331 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
332 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000333 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000334 let Inst{21} = 1; // W bit
335 let Inst{22} = 1; // B bit
336 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000337 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000338}
339
Evan Chengac92c3f2008-09-01 07:00:14 +0000340// Pre-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000341class AI2stwpr<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} = 0; // B bit
348 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000349 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000350}
351class AI2stbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
352 string asm, string cstr, list<dag> pattern>
353 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
354 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000355 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000356 let Inst{21} = 1; // W bit
357 let Inst{22} = 1; // B bit
358 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000359 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000360}
361
Evan Chengac92c3f2008-09-01 07:00:14 +0000362// Post-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000363class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000364 string asm, string cstr, list<dag> pattern>
365 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000366 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000367 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000368 let Inst{21} = 0; // W bit
369 let Inst{22} = 0; // B bit
370 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000371 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000372}
373class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
374 string asm, string cstr, list<dag> pattern>
375 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
376 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000377 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000378 let Inst{21} = 0; // W bit
379 let Inst{22} = 1; // B bit
380 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000381 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000382}
383
Evan Chengac92c3f2008-09-01 07:00:14 +0000384// Post-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000385class AI2stwpo<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} = 0; // B bit
392 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000393 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000394}
395class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
396 string asm, string cstr, list<dag> pattern>
397 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
398 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000399 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000400 let Inst{21} = 0; // W bit
401 let Inst{22} = 1; // B bit
402 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000403 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000404}
405
Evan Cheng2e62b662008-09-01 01:51:14 +0000406// addrmode3 instructions
407class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
408 string asm, list<dag> pattern>
409 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
410 asm, "", pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000411class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
412 list<dag> pattern>
413 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
414 "", pattern>;
Evan Cheng2e62b662008-09-01 01:51:14 +0000415
Evan Chengac92c3f2008-09-01 07:00:14 +0000416// loads
417class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
418 string asm, list<dag> pattern>
419 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
420 asm, "", pattern> {
421 let Inst{4} = 1;
422 let Inst{5} = 1; // H bit
423 let Inst{6} = 0; // S bit
424 let Inst{7} = 1;
425 let Inst{20} = 1; // L bit
426 let Inst{21} = 0; // W bit
427 let Inst{24} = 1; // P bit
428}
Evan Chengae7b1d72008-09-01 07:34:13 +0000429class AXI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
430 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000431 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
432 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000433 let Inst{4} = 1;
434 let Inst{5} = 1; // H bit
435 let Inst{6} = 0; // S bit
436 let Inst{7} = 1;
437 let Inst{20} = 1; // L bit
438 let Inst{21} = 0; // W bit
439 let Inst{24} = 1; // P bit
440}
Evan Chengac92c3f2008-09-01 07:00:14 +0000441class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
442 string asm, list<dag> pattern>
443 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
444 asm, "", pattern> {
445 let Inst{4} = 1;
446 let Inst{5} = 1; // H bit
447 let Inst{6} = 1; // S bit
448 let Inst{7} = 1;
449 let Inst{20} = 1; // L bit
450 let Inst{21} = 0; // W bit
451 let Inst{24} = 1; // P bit
452}
Evan Chengae7b1d72008-09-01 07:34:13 +0000453class AXI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
454 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000455 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
456 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000457 let Inst{4} = 1;
458 let Inst{5} = 1; // H bit
459 let Inst{6} = 1; // S bit
460 let Inst{7} = 1;
461 let Inst{20} = 1; // L bit
462 let Inst{21} = 0; // W bit
463 let Inst{24} = 1; // P bit
464}
Evan Chengac92c3f2008-09-01 07:00:14 +0000465class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
466 string asm, list<dag> pattern>
467 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
468 asm, "", pattern> {
469 let Inst{4} = 1;
470 let Inst{5} = 0; // H bit
471 let Inst{6} = 1; // S bit
472 let Inst{7} = 1;
473 let Inst{20} = 1; // L bit
474 let Inst{21} = 0; // W bit
475 let Inst{24} = 1; // P bit
476}
Evan Chengae7b1d72008-09-01 07:34:13 +0000477class AXI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
478 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000479 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
480 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000481 let Inst{4} = 1;
482 let Inst{5} = 0; // H bit
483 let Inst{6} = 1; // S bit
484 let Inst{7} = 1;
485 let Inst{20} = 1; // L bit
486 let Inst{21} = 0; // W bit
487 let Inst{24} = 1; // P bit
488}
Evan Chengac92c3f2008-09-01 07:00:14 +0000489class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc,
490 string asm, list<dag> pattern>
491 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
492 asm, "", pattern> {
493 let Inst{4} = 1;
494 let Inst{5} = 0; // H bit
495 let Inst{6} = 1; // S bit
496 let Inst{7} = 1;
497 let Inst{20} = 0; // L bit
498 let Inst{21} = 0; // W bit
499 let Inst{24} = 1; // P bit
500}
501
502// stores
503class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc,
504 string asm, list<dag> pattern>
505 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
506 asm, "", pattern> {
507 let Inst{4} = 1;
508 let Inst{5} = 1; // H bit
509 let Inst{6} = 0; // S bit
510 let Inst{7} = 1;
511 let Inst{20} = 0; // L bit
512 let Inst{21} = 0; // W bit
513 let Inst{24} = 1; // P bit
514}
Evan Chengae7b1d72008-09-01 07:34:13 +0000515class AXI3sth<bits<4> opcod, dag oops, dag iops, Format f, string asm,
516 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000517 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
518 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000519 let Inst{4} = 1;
520 let Inst{5} = 1; // H bit
521 let Inst{6} = 0; // S bit
522 let Inst{7} = 1;
523 let Inst{20} = 0; // L bit
524 let Inst{21} = 0; // W bit
525 let Inst{24} = 1; // P bit
526}
Evan Chengac92c3f2008-09-01 07:00:14 +0000527class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc,
528 string asm, list<dag> pattern>
529 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
530 asm, "", pattern> {
531 let Inst{4} = 1;
532 let Inst{5} = 1; // H bit
533 let Inst{6} = 1; // S bit
534 let Inst{7} = 1;
535 let Inst{20} = 0; // L bit
536 let Inst{21} = 0; // W bit
537 let Inst{24} = 1; // P bit
538}
539
540// Pre-indexed loads
541class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
542 string asm, string cstr, list<dag> pattern>
543 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
544 asm, cstr, pattern> {
545 let Inst{4} = 1;
546 let Inst{5} = 1; // H bit
547 let Inst{6} = 0; // S bit
548 let Inst{7} = 1;
549 let Inst{20} = 1; // L bit
550 let Inst{21} = 1; // W bit
551 let Inst{24} = 1; // P bit
552}
553class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
554 string asm, string cstr, list<dag> pattern>
555 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
556 asm, cstr, pattern> {
557 let Inst{4} = 1;
558 let Inst{5} = 1; // H bit
559 let Inst{6} = 1; // S bit
560 let Inst{7} = 1;
561 let Inst{20} = 1; // L bit
562 let Inst{21} = 1; // W bit
563 let Inst{24} = 1; // P bit
564}
565class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
566 string asm, string cstr, list<dag> pattern>
567 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
568 asm, cstr, pattern> {
569 let Inst{4} = 1;
570 let Inst{5} = 0; // H bit
571 let Inst{6} = 1; // S bit
572 let Inst{7} = 1;
573 let Inst{20} = 1; // L bit
574 let Inst{21} = 1; // W bit
575 let Inst{24} = 1; // P bit
576}
577
578// Pre-indexed stores
579class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
580 string asm, string cstr, list<dag> pattern>
581 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
582 asm, cstr, pattern> {
583 let Inst{4} = 1;
584 let Inst{5} = 1; // H bit
585 let Inst{6} = 0; // S bit
586 let Inst{7} = 1;
587 let Inst{20} = 0; // L bit
588 let Inst{21} = 1; // W bit
589 let Inst{24} = 1; // P bit
590}
591
592// Post-indexed loads
593class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
594 string asm, string cstr, list<dag> pattern>
595 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
596 asm, cstr,pattern> {
597 let Inst{4} = 1;
598 let Inst{5} = 1; // H bit
599 let Inst{6} = 0; // S bit
600 let Inst{7} = 1;
601 let Inst{20} = 1; // L bit
602 let Inst{21} = 1; // W bit
603 let Inst{24} = 0; // P bit
604}
605class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
606 string asm, string cstr, list<dag> pattern>
607 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
608 asm, cstr,pattern> {
609 let Inst{4} = 1;
610 let Inst{5} = 1; // H bit
611 let Inst{6} = 1; // S bit
612 let Inst{7} = 1;
613 let Inst{20} = 1; // L bit
614 let Inst{21} = 1; // W bit
615 let Inst{24} = 0; // P bit
616}
617class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
618 string asm, string cstr, list<dag> pattern>
619 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
620 asm, cstr,pattern> {
621 let Inst{4} = 1;
622 let Inst{5} = 0; // H bit
623 let Inst{6} = 1; // S bit
624 let Inst{7} = 1;
625 let Inst{20} = 1; // L bit
626 let Inst{21} = 1; // W bit
627 let Inst{24} = 0; // P bit
628}
629
630// Post-indexed stores
631class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
632 string asm, string cstr, list<dag> pattern>
633 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
634 asm, cstr,pattern> {
635 let Inst{4} = 1;
636 let Inst{5} = 1; // H bit
637 let Inst{6} = 0; // S bit
638 let Inst{7} = 1;
639 let Inst{20} = 0; // L bit
640 let Inst{21} = 1; // W bit
641 let Inst{24} = 0; // P bit
642}
643
644
Evan Cheng2e62b662008-09-01 01:51:14 +0000645// addrmode4 instructions
646class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
647 string asm, list<dag> pattern>
648 : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd36b01c2008-09-01 07:48:18 +0000649 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000650 let Inst{25-27} = {0,0,1};
Evan Chengd36b01c2008-09-01 07:48:18 +0000651}
652class AXI4ld<bits<4> opcod, dag oops, dag iops, Format f, string asm,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000653 list<dag> pattern>
654 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
Evan Chengd36b01c2008-09-01 07:48:18 +0000655 "", pattern> {
656 let Inst{20} = 1; // L bit
657 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000658 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000659}
660class AXI4ldpc<bits<4> opcod, dag oops, dag iops, Format f, string asm,
661 list<dag> pattern>
662 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
663 "", pattern> {
664 let Inst{20} = 1; // L bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000665 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000666}
667class AXI4st<bits<4> opcod, dag oops, dag iops, Format f, string asm,
668 list<dag> pattern>
669 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
670 "", pattern> {
671 let Inst{20} = 0; // L bit
672 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000673 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000674}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000675
Jim Grosbach1feed042008-11-03 18:38:31 +0000676// Unsigned multiply, multiply-accumulate instructions.
Evan Chengee80fb72008-11-06 01:21:28 +0000677class AMul1I<bits<7> mulopc, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000678 string asm, list<dag> pattern>
Evan Chengee80fb72008-11-06 01:21:28 +0000679 : I<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
Evan Cheng86a926a2008-11-05 18:35:52 +0000680 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000681 let Inst{7-4} = 0b1001;
Evan Chengee80fb72008-11-06 01:21:28 +0000682 let Inst{20} = 0; // S bit
683 let Inst{27-21} = mulopc;
Jim Grosbach1feed042008-11-03 18:38:31 +0000684}
Evan Chengee80fb72008-11-06 01:21:28 +0000685class AsMul1I<bits<7> mulopc, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000686 string asm, list<dag> pattern>
Evan Chengee80fb72008-11-06 01:21:28 +0000687 : sI<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
Evan Cheng86a926a2008-11-05 18:35:52 +0000688 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000689 let Inst{7-4} = 0b1001;
Evan Chengee80fb72008-11-06 01:21:28 +0000690 let Inst{27-21} = mulopc;
691}
692
693// Most significant word multiply
694class AMul2I<bits<7> mulopc, dag oops, dag iops, string opc,
695 string asm, list<dag> pattern>
696 : I<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
697 asm,"",pattern> {
698 let Inst{7-4} = 0b1001;
699 let Inst{20} = 1;
700 let Inst{27-21} = mulopc;
Jim Grosbach1feed042008-11-03 18:38:31 +0000701}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000702
Evan Cheng38396be2008-11-06 03:35:07 +0000703// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
704class AMulxyI<bits<7> mulopc, dag oops, dag iops, string opc,
705 string asm, list<dag> pattern>
706 : I<0, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, opc,
707 asm,"",pattern> {
708 let Inst{4} = 0;
709 let Inst{7} = 1;
710 let Inst{20} = 0;
711 let Inst{27-21} = mulopc;
712}
713
Evan Cheng7b0249b2008-08-28 23:39:26 +0000714//===----------------------------------------------------------------------===//
715
716// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
717class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
718 list<Predicate> Predicates = [IsARM];
719}
720class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
721 list<Predicate> Predicates = [IsARM, HasV5TE];
722}
723class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
724 list<Predicate> Predicates = [IsARM, HasV6];
725}
Evan Cheng34a46e12008-08-29 06:41:12 +0000726
727//===----------------------------------------------------------------------===//
728//
729// Thumb Instruction Format Definitions.
730//
731
732
733// TI - Thumb instruction.
734
735class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
736 string asm, string cstr, list<dag> pattern>
737 // FIXME: Set all opcodes to 0 for now.
738 : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> {
739 let OutOperandList = outs;
740 let InOperandList = ins;
741 let AsmString = asm;
742 let Pattern = pattern;
743 list<Predicate> Predicates = [IsThumb];
744}
745
746class TI<dag outs, dag ins, string asm, list<dag> pattern>
747 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
748class TI1<dag outs, dag ins, string asm, list<dag> pattern>
749 : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
750class TI2<dag outs, dag ins, string asm, list<dag> pattern>
751 : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
752class TI4<dag outs, dag ins, string asm, list<dag> pattern>
753 : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
754class TIs<dag outs, dag ins, string asm, list<dag> pattern>
755 : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
756
757// Two-address instructions
758class TIt<dag outs, dag ins, string asm, list<dag> pattern>
759 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
760
761// BL, BLX(1) are translated by assembler into two instructions
762class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
763 : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
764
765// BR_JT instructions
766class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
767 : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
768
769
770//===----------------------------------------------------------------------===//
771
772
773// ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
774class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
775 list<Predicate> Predicates = [IsThumb];
776}
777
778class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
779 list<Predicate> Predicates = [IsThumb, HasV5T];
780}