blob: 9df7e6fdff02c4fe5ea06830fb4882f6dda4add0 [file] [log] [blame]
Evan Cheng7b0249b2008-08-28 23:39:26 +00001//===- ARMInstrFormats.td - ARM Instruction Formats --*- tablegen -*---------=//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
18class Format<bits<5> val> {
19 bits<5> Value = val;
20}
21
22def Pseudo : Format<1>;
Evan Cheng86a926a2008-11-05 18:35:52 +000023def MulFrm1 : Format<2>;
24def MulFrm2 : Format<3>;
25def MulSMLAW : Format<4>;
26def MulSMULW : Format<5>;
27def MulSMLA : Format<6>;
28def MulSMUL : Format<7>;
29def Branch : Format<8>;
30def BranchMisc : Format<9>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000031
Evan Cheng86a926a2008-11-05 18:35:52 +000032def DPFrm : Format<10>;
33def DPSoRegFrm : Format<11>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000034
Evan Cheng86a926a2008-11-05 18:35:52 +000035def LdFrm : Format<12>;
36def StFrm : Format<13>;
37def LdMiscFrm : Format<14>;
38def StMiscFrm : Format<15>;
39def LdMulFrm : Format<16>;
40def StMulFrm : Format<17>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000041
Evan Cheng86a926a2008-11-05 18:35:52 +000042def ArithMisc : Format<18>;
43def ThumbFrm : Format<19>;
44def VFPFrm : Format<20>;
Evan Cheng7b0249b2008-08-28 23:39:26 +000045
Evan Cheng86a926a2008-11-05 18:35:52 +000046// Misc flag for data processing instructions that indicates whether
47// the instruction has a Rn register operand.
48class UnaryDP { bit isUnaryDataProc = 1; }
Evan Cheng7b0249b2008-08-28 23:39:26 +000049
Evan Cheng7b0249b2008-08-28 23:39:26 +000050//===----------------------------------------------------------------------===//
51
52// ARM Instruction templates.
53//
54
55class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
56 Format f, string cstr>
57 : Instruction {
Evan Chengd0750352008-08-29 07:40:52 +000058 field bits<32> Inst;
59
Evan Cheng7b0249b2008-08-28 23:39:26 +000060 let Namespace = "ARM";
61
62 bits<4> Opcode = opcod;
Evan Cheng86a926a2008-11-05 18:35:52 +000063
64 // TSFlagsFields
Evan Cheng7b0249b2008-08-28 23:39:26 +000065 AddrMode AM = am;
66 bits<4> AddrModeBits = AM.Value;
67
68 SizeFlagVal SZ = sz;
69 bits<3> SizeFlag = SZ.Value;
70
71 IndexMode IM = im;
72 bits<2> IndexModeBits = IM.Value;
73
74 Format F = f;
75 bits<5> Form = F.Value;
Evan Cheng86a926a2008-11-05 18:35:52 +000076
77 //
78 // Attributes specific to ARM instructions...
79 //
80 bit isUnaryDataProc = 0;
Evan Cheng7b0249b2008-08-28 23:39:26 +000081
82 let Constraints = cstr;
83}
84
85class PseudoInst<dag oops, dag iops, string asm, list<dag> pattern>
86 : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, ""> {
87 let OutOperandList = oops;
88 let InOperandList = iops;
89 let AsmString = asm;
90 let Pattern = pattern;
91}
92
93// Almost all ARM instructions are predicable.
94class I<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
95 IndexMode im, Format f, string opc, string asm, string cstr,
96 list<dag> pattern>
97 : InstARM<opcod, am, sz, im, f, cstr> {
98 let OutOperandList = oops;
99 let InOperandList = !con(iops, (ops pred:$p));
100 let AsmString = !strconcat(opc, !strconcat("${p}", asm));
101 let Pattern = pattern;
102 list<Predicate> Predicates = [IsARM];
103}
104
105// Same as I except it can optionally modify CPSR. Note it's modeled as
106// an input operand since by default it's a zero register. It will
107// become an implicit def once it's "flipped".
108class sI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
109 IndexMode im, Format f, string opc, string asm, string cstr,
110 list<dag> pattern>
111 : InstARM<opcod, am, sz, im, f, cstr> {
112 let OutOperandList = oops;
113 let InOperandList = !con(iops, (ops pred:$p, cc_out:$s));
114 let AsmString = !strconcat(opc, !strconcat("${p}${s}", asm));
115 let Pattern = pattern;
116 list<Predicate> Predicates = [IsARM];
117}
118
Evan Chengc5409a82008-09-01 07:19:00 +0000119// Special cases
120class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
121 IndexMode im, Format f, string asm, string cstr, list<dag> pattern>
122 : InstARM<opcod, am, sz, im, f, cstr> {
123 let OutOperandList = oops;
124 let InOperandList = iops;
125 let AsmString = asm;
126 let Pattern = pattern;
127 list<Predicate> Predicates = [IsARM];
128}
129
Evan Cheng7b0249b2008-08-28 23:39:26 +0000130class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
131 string asm, list<dag> pattern>
132 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
133 asm,"",pattern>;
134class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
135 string asm, list<dag> pattern>
136 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
137 asm,"",pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000138class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
139 list<dag> pattern>
140 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
141 "", pattern>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000142
143// Ctrl flow instructions
144class ABLpredI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
145 string asm, list<dag> pattern>
146 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
147 asm,"",pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000148 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000149}
150class ABLI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
151 list<dag> pattern>
152 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
153 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000154 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000155}
Evan Cheng10a9eb82008-09-01 08:25:56 +0000156// FIXME: BX
Evan Chengc5409a82008-09-01 07:19:00 +0000157class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
158 list<dag> pattern>
159 : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
160 "", pattern>;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000161class ABI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
162 list<dag> pattern>
163 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
164 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000165 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000166}
167class ABccI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
168 string asm, list<dag> pattern>
169 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
170 asm,"",pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000171 let Inst{27-24} = opcod;
Evan Cheng10a9eb82008-09-01 08:25:56 +0000172}
173
174// BR_JT instructions
175// == mov pc
176class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
177 : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
178 asm, "", pattern> {
179 let Inst{20} = 0; // S Bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000180 let Inst{24-21} = opcod;
181 let Inst{27-26} = {0,0};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000182}
Evan Cheng18e5d102008-09-17 07:16:21 +0000183// == add pc
Evan Cheng10a9eb82008-09-01 08:25:56 +0000184class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
185 : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
186 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000187 let Inst{20} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000188 let Inst{24-21} = opcod;
189 let Inst{27-26} = {0,0};
Evan Cheng18e5d102008-09-17 07:16:21 +0000190}
191// == ldr pc
192class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
193 : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
194 asm, "", pattern> {
Evan Cheng10a9eb82008-09-01 08:25:56 +0000195 let Inst{20} = 1; // L bit
196 let Inst{21} = 0; // W bit
197 let Inst{22} = 0; // B bit
198 let Inst{24} = 1; // P bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000199 let Inst{27-26} = {0,1};
Evan Cheng10a9eb82008-09-01 08:25:56 +0000200}
201
Evan Cheng2e62b662008-09-01 01:51:14 +0000202
203// addrmode1 instructions
Evan Cheng7b0249b2008-08-28 23:39:26 +0000204class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
205 string asm, list<dag> pattern>
206 : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd0750352008-08-29 07:40:52 +0000207 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000208 let Inst{24-21} = opcod;
209 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000210}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000211class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
212 string asm, list<dag> pattern>
213 : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd0750352008-08-29 07:40:52 +0000214 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000215 let Inst{24-21} = opcod;
216 let Inst{27-26} = {0,0};
Evan Chengd0750352008-08-29 07:40:52 +0000217}
Evan Chengc5409a82008-09-01 07:19:00 +0000218class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
219 list<dag> pattern>
220 : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
221 "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000222 let Inst{24-21} = opcod;
223 let Inst{27-26} = {0,0};
Evan Chengc5409a82008-09-01 07:19:00 +0000224}
Evan Cheng2e62b662008-09-01 01:51:14 +0000225class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
226 string asm, list<dag> pattern>
227 : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
228 asm, "", pattern>;
Evan Chengda020022008-08-31 19:02:21 +0000229
Evan Cheng2e62b662008-09-01 01:51:14 +0000230
231// addrmode2 loads and stores
Evan Cheng7b0249b2008-08-28 23:39:26 +0000232class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
233 string asm, list<dag> pattern>
234 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
Evan Chengda020022008-08-31 19:02:21 +0000235 asm, "", pattern> {
Jim Grosbach88c246f2008-10-14 20:36:24 +0000236 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000237}
Evan 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>
Evan Chengc41fb3152008-11-05 23:22:34 +0000242 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
243 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000244 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000245 let Inst{21} = 0; // W bit
246 let Inst{22} = 0; // B bit
247 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000248 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000249}
Evan Chengae7b1d72008-09-01 07:34:13 +0000250class AXI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
251 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000252 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
253 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000254 let Inst{20} = 1; // L bit
255 let Inst{21} = 0; // W bit
256 let Inst{22} = 0; // B bit
257 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000258 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000259}
Evan Chengda020022008-08-31 19:02:21 +0000260class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
261 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000262 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
263 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000264 let Inst{20} = 1; // L bit
Evan Chengda020022008-08-31 19:02:21 +0000265 let Inst{21} = 0; // W bit
266 let Inst{22} = 1; // B bit
267 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000268 let Inst{27-26} = {0,1};
Evan Chengda020022008-08-31 19:02:21 +0000269}
Evan Chengae7b1d72008-09-01 07:34:13 +0000270class AXI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
271 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000272 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
273 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000274 let Inst{20} = 1; // L bit
275 let Inst{21} = 0; // W bit
276 let Inst{22} = 1; // B bit
277 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000278 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000279}
Evan Chengda020022008-08-31 19:02:21 +0000280
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000281// stores
282class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc,
283 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000284 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
285 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000286 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000287 let Inst{21} = 0; // W bit
288 let Inst{22} = 0; // B bit
289 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000290 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000291}
Evan Chengae7b1d72008-09-01 07:34:13 +0000292class AXI2stw<bits<4> opcod, dag oops, dag iops, Format f, string asm,
293 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000294 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
295 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000296 let Inst{20} = 0; // L bit
297 let Inst{21} = 0; // W bit
298 let Inst{22} = 0; // B bit
299 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000300 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000301}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000302class AI2stb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
303 string asm, list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000304 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
305 asm, "", pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000306 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000307 let Inst{21} = 0; // W bit
308 let Inst{22} = 1; // B bit
309 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000310 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000311}
Evan Chengae7b1d72008-09-01 07:34:13 +0000312class AXI2stb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
313 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000314 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f,
315 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000316 let Inst{20} = 0; // L bit
317 let Inst{21} = 0; // W bit
318 let Inst{22} = 1; // B bit
319 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000320 let Inst{27-26} = {0,1};
Evan Chengae7b1d72008-09-01 07:34:13 +0000321}
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000322
Evan Chengac92c3f2008-09-01 07:00:14 +0000323// Pre-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000324class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000325 string asm, string cstr, list<dag> pattern>
326 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000327 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000328 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000329 let Inst{21} = 1; // W bit
330 let Inst{22} = 0; // B bit
331 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000332 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000333}
334class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
335 string asm, string cstr, list<dag> pattern>
336 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
337 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000338 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000339 let Inst{21} = 1; // W bit
340 let Inst{22} = 1; // B bit
341 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000342 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000343}
344
Evan Chengac92c3f2008-09-01 07:00:14 +0000345// Pre-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000346class AI2stwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
347 string asm, string cstr, list<dag> pattern>
348 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
349 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000350 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000351 let Inst{21} = 1; // W bit
352 let Inst{22} = 0; // B bit
353 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000354 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000355}
356class AI2stbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
357 string asm, string cstr, list<dag> pattern>
358 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
359 asm, cstr, pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000360 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000361 let Inst{21} = 1; // W bit
362 let Inst{22} = 1; // B bit
363 let Inst{24} = 1; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000364 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000365}
366
Evan Chengac92c3f2008-09-01 07:00:14 +0000367// Post-indexed loads
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000368class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000369 string asm, string cstr, list<dag> pattern>
370 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000371 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000372 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000373 let Inst{21} = 0; // W bit
374 let Inst{22} = 0; // B bit
375 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000376 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000377}
378class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
379 string asm, string cstr, list<dag> pattern>
380 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
381 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000382 let Inst{20} = 1; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000383 let Inst{21} = 0; // W bit
384 let Inst{22} = 1; // B bit
385 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000386 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000387}
388
Evan Chengac92c3f2008-09-01 07:00:14 +0000389// Post-indexed stores
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000390class AI2stwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
391 string asm, string cstr, list<dag> pattern>
392 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
393 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000394 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000395 let Inst{21} = 0; // W bit
396 let Inst{22} = 0; // B bit
397 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000398 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000399}
400class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
401 string asm, string cstr, list<dag> pattern>
402 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
403 asm, cstr,pattern> {
Evan Chengac92c3f2008-09-01 07:00:14 +0000404 let Inst{20} = 0; // L bit
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000405 let Inst{21} = 0; // W bit
406 let Inst{22} = 1; // B bit
407 let Inst{24} = 0; // P bit
Evan Chengc41fb3152008-11-05 23:22:34 +0000408 let Inst{27-26} = {0,1};
Evan Cheng1a7c1cc2008-09-01 01:27:33 +0000409}
410
Evan Cheng2e62b662008-09-01 01:51:14 +0000411// addrmode3 instructions
412class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
413 string asm, list<dag> pattern>
414 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
415 asm, "", pattern>;
Evan Chengc5409a82008-09-01 07:19:00 +0000416class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
417 list<dag> pattern>
418 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
419 "", pattern>;
Evan Cheng2e62b662008-09-01 01:51:14 +0000420
Evan Chengac92c3f2008-09-01 07:00:14 +0000421// loads
422class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
423 string asm, list<dag> pattern>
424 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
425 asm, "", pattern> {
426 let Inst{4} = 1;
427 let Inst{5} = 1; // H bit
428 let Inst{6} = 0; // S bit
429 let Inst{7} = 1;
430 let Inst{20} = 1; // L bit
431 let Inst{21} = 0; // W bit
432 let Inst{24} = 1; // P bit
433}
Evan Chengae7b1d72008-09-01 07:34:13 +0000434class AXI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
435 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000436 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
437 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000438 let Inst{4} = 1;
439 let Inst{5} = 1; // H bit
440 let Inst{6} = 0; // S bit
441 let Inst{7} = 1;
442 let Inst{20} = 1; // L bit
443 let Inst{21} = 0; // W bit
444 let Inst{24} = 1; // P bit
445}
Evan Chengac92c3f2008-09-01 07:00:14 +0000446class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc,
447 string asm, list<dag> pattern>
448 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
449 asm, "", pattern> {
450 let Inst{4} = 1;
451 let Inst{5} = 1; // H bit
452 let Inst{6} = 1; // S bit
453 let Inst{7} = 1;
454 let Inst{20} = 1; // L bit
455 let Inst{21} = 0; // W bit
456 let Inst{24} = 1; // P bit
457}
Evan Chengae7b1d72008-09-01 07:34:13 +0000458class AXI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string asm,
459 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000460 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
461 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000462 let Inst{4} = 1;
463 let Inst{5} = 1; // H bit
464 let Inst{6} = 1; // S bit
465 let Inst{7} = 1;
466 let Inst{20} = 1; // L bit
467 let Inst{21} = 0; // W bit
468 let Inst{24} = 1; // P bit
469}
Evan Chengac92c3f2008-09-01 07:00:14 +0000470class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc,
471 string asm, list<dag> pattern>
472 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
473 asm, "", pattern> {
474 let Inst{4} = 1;
475 let Inst{5} = 0; // H bit
476 let Inst{6} = 1; // S bit
477 let Inst{7} = 1;
478 let Inst{20} = 1; // L bit
479 let Inst{21} = 0; // W bit
480 let Inst{24} = 1; // P bit
481}
Evan Chengae7b1d72008-09-01 07:34:13 +0000482class AXI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string asm,
483 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000484 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
485 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000486 let Inst{4} = 1;
487 let Inst{5} = 0; // H bit
488 let Inst{6} = 1; // S bit
489 let Inst{7} = 1;
490 let Inst{20} = 1; // L bit
491 let Inst{21} = 0; // W bit
492 let Inst{24} = 1; // P bit
493}
Evan Chengac92c3f2008-09-01 07:00:14 +0000494class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc,
495 string asm, list<dag> pattern>
496 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
497 asm, "", pattern> {
498 let Inst{4} = 1;
499 let Inst{5} = 0; // H bit
500 let Inst{6} = 1; // S bit
501 let Inst{7} = 1;
502 let Inst{20} = 0; // L bit
503 let Inst{21} = 0; // W bit
504 let Inst{24} = 1; // P bit
505}
506
507// stores
508class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc,
509 string asm, list<dag> pattern>
510 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
511 asm, "", pattern> {
512 let Inst{4} = 1;
513 let Inst{5} = 1; // H bit
514 let Inst{6} = 0; // S bit
515 let Inst{7} = 1;
516 let Inst{20} = 0; // L bit
517 let Inst{21} = 0; // W bit
518 let Inst{24} = 1; // P bit
519}
Evan Chengae7b1d72008-09-01 07:34:13 +0000520class AXI3sth<bits<4> opcod, dag oops, dag iops, Format f, string asm,
521 list<dag> pattern>
Evan Chengc41fb3152008-11-05 23:22:34 +0000522 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f,
523 asm, "", pattern> {
Evan Chengae7b1d72008-09-01 07:34:13 +0000524 let Inst{4} = 1;
525 let Inst{5} = 1; // H bit
526 let Inst{6} = 0; // S bit
527 let Inst{7} = 1;
528 let Inst{20} = 0; // L bit
529 let Inst{21} = 0; // W bit
530 let Inst{24} = 1; // P bit
531}
Evan Chengac92c3f2008-09-01 07:00:14 +0000532class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc,
533 string asm, list<dag> pattern>
534 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
535 asm, "", pattern> {
536 let Inst{4} = 1;
537 let Inst{5} = 1; // H bit
538 let Inst{6} = 1; // S bit
539 let Inst{7} = 1;
540 let Inst{20} = 0; // L bit
541 let Inst{21} = 0; // W bit
542 let Inst{24} = 1; // P bit
543}
544
545// Pre-indexed loads
546class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
547 string asm, string cstr, list<dag> pattern>
548 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
549 asm, cstr, pattern> {
550 let Inst{4} = 1;
551 let Inst{5} = 1; // H bit
552 let Inst{6} = 0; // S bit
553 let Inst{7} = 1;
554 let Inst{20} = 1; // L bit
555 let Inst{21} = 1; // W bit
556 let Inst{24} = 1; // P bit
557}
558class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
559 string asm, string cstr, list<dag> pattern>
560 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
561 asm, cstr, pattern> {
562 let Inst{4} = 1;
563 let Inst{5} = 1; // H bit
564 let Inst{6} = 1; // S bit
565 let Inst{7} = 1;
566 let Inst{20} = 1; // L bit
567 let Inst{21} = 1; // W bit
568 let Inst{24} = 1; // P bit
569}
570class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
571 string asm, string cstr, list<dag> pattern>
572 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
573 asm, cstr, pattern> {
574 let Inst{4} = 1;
575 let Inst{5} = 0; // H bit
576 let Inst{6} = 1; // S bit
577 let Inst{7} = 1;
578 let Inst{20} = 1; // L bit
579 let Inst{21} = 1; // W bit
580 let Inst{24} = 1; // P bit
581}
582
583// Pre-indexed stores
584class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
585 string asm, string cstr, list<dag> pattern>
586 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
587 asm, cstr, pattern> {
588 let Inst{4} = 1;
589 let Inst{5} = 1; // H bit
590 let Inst{6} = 0; // S bit
591 let Inst{7} = 1;
592 let Inst{20} = 0; // L bit
593 let Inst{21} = 1; // W bit
594 let Inst{24} = 1; // P bit
595}
596
597// Post-indexed loads
598class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
599 string asm, string cstr, list<dag> pattern>
600 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
601 asm, cstr,pattern> {
602 let Inst{4} = 1;
603 let Inst{5} = 1; // H bit
604 let Inst{6} = 0; // S bit
605 let Inst{7} = 1;
606 let Inst{20} = 1; // L bit
607 let Inst{21} = 1; // W bit
608 let Inst{24} = 0; // P bit
609}
610class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
611 string asm, string cstr, list<dag> pattern>
612 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
613 asm, cstr,pattern> {
614 let Inst{4} = 1;
615 let Inst{5} = 1; // H bit
616 let Inst{6} = 1; // S bit
617 let Inst{7} = 1;
618 let Inst{20} = 1; // L bit
619 let Inst{21} = 1; // W bit
620 let Inst{24} = 0; // P bit
621}
622class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
623 string asm, string cstr, list<dag> pattern>
624 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
625 asm, cstr,pattern> {
626 let Inst{4} = 1;
627 let Inst{5} = 0; // H bit
628 let Inst{6} = 1; // S bit
629 let Inst{7} = 1;
630 let Inst{20} = 1; // L bit
631 let Inst{21} = 1; // W bit
632 let Inst{24} = 0; // P bit
633}
634
635// Post-indexed stores
636class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc,
637 string asm, string cstr, list<dag> pattern>
638 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
639 asm, cstr,pattern> {
640 let Inst{4} = 1;
641 let Inst{5} = 1; // H bit
642 let Inst{6} = 0; // S bit
643 let Inst{7} = 1;
644 let Inst{20} = 0; // L bit
645 let Inst{21} = 1; // W bit
646 let Inst{24} = 0; // P bit
647}
648
649
Evan Cheng2e62b662008-09-01 01:51:14 +0000650// addrmode4 instructions
651class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
652 string asm, list<dag> pattern>
653 : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
Evan Chengd36b01c2008-09-01 07:48:18 +0000654 asm, "", pattern> {
Evan Cheng18e5d102008-09-17 07:16:21 +0000655 let Inst{25-27} = {0,0,1};
Evan Chengd36b01c2008-09-01 07:48:18 +0000656}
657class AXI4ld<bits<4> opcod, dag oops, dag iops, Format f, string asm,
Evan Cheng7b0249b2008-08-28 23:39:26 +0000658 list<dag> pattern>
659 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
Evan Chengd36b01c2008-09-01 07:48:18 +0000660 "", pattern> {
661 let Inst{20} = 1; // L bit
662 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000663 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000664}
665class AXI4ldpc<bits<4> opcod, dag oops, dag iops, Format f, string asm,
666 list<dag> pattern>
667 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
668 "", pattern> {
669 let Inst{20} = 1; // L bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000670 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000671}
672class AXI4st<bits<4> opcod, dag oops, dag iops, Format f, string asm,
673 list<dag> pattern>
674 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
675 "", pattern> {
676 let Inst{20} = 0; // L bit
677 let Inst{22} = 0; // S bit
Jim Grosbach88c246f2008-10-14 20:36:24 +0000678 let Inst{27-25} = 0b100;
Evan Chengd36b01c2008-09-01 07:48:18 +0000679}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000680
Jim Grosbach1feed042008-11-03 18:38:31 +0000681// Unsigned multiply, multiply-accumulate instructions.
Evan Cheng86a926a2008-11-05 18:35:52 +0000682class AMul1I<bits<4> opcod, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000683 string asm, list<dag> pattern>
Evan Cheng86a926a2008-11-05 18:35:52 +0000684 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm1, opc,
685 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000686 // FIXME: bits 7-4 should be a sub-mode (for SMLAxx, SMLAWy, ...)
687 let Inst{7-4} = 0b1001;
688 let Inst{27-24} = 0b0000;
689 let Inst{23-20} = opcod;
690}
Evan Cheng86a926a2008-11-05 18:35:52 +0000691class AsMul1I<bits<4> opcod, dag oops, dag iops, string opc,
Jim Grosbach1feed042008-11-03 18:38:31 +0000692 string asm, list<dag> pattern>
Evan Cheng86a926a2008-11-05 18:35:52 +0000693 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm1, opc,
694 asm,"",pattern> {
Jim Grosbach1feed042008-11-03 18:38:31 +0000695 // FIXME: bits 7-4 should be a sub-mode (for SMLAxx, SMLAWy, ...)
696 let Inst{7-4} = 0b1001;
697 let Inst{27-24} = 0b0000;
698 let Inst{23-20} = opcod;
699}
Evan Cheng7b0249b2008-08-28 23:39:26 +0000700
Evan Cheng7b0249b2008-08-28 23:39:26 +0000701//===----------------------------------------------------------------------===//
702
703// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
704class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
705 list<Predicate> Predicates = [IsARM];
706}
707class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
708 list<Predicate> Predicates = [IsARM, HasV5TE];
709}
710class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
711 list<Predicate> Predicates = [IsARM, HasV6];
712}
Evan Cheng34a46e12008-08-29 06:41:12 +0000713
714//===----------------------------------------------------------------------===//
715//
716// Thumb Instruction Format Definitions.
717//
718
719
720// TI - Thumb instruction.
721
722class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz,
723 string asm, string cstr, list<dag> pattern>
724 // FIXME: Set all opcodes to 0 for now.
725 : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> {
726 let OutOperandList = outs;
727 let InOperandList = ins;
728 let AsmString = asm;
729 let Pattern = pattern;
730 list<Predicate> Predicates = [IsThumb];
731}
732
733class TI<dag outs, dag ins, string asm, list<dag> pattern>
734 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>;
735class TI1<dag outs, dag ins, string asm, list<dag> pattern>
736 : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>;
737class TI2<dag outs, dag ins, string asm, list<dag> pattern>
738 : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>;
739class TI4<dag outs, dag ins, string asm, list<dag> pattern>
740 : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>;
741class TIs<dag outs, dag ins, string asm, list<dag> pattern>
742 : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>;
743
744// Two-address instructions
745class TIt<dag outs, dag ins, string asm, list<dag> pattern>
746 : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>;
747
748// BL, BLX(1) are translated by assembler into two instructions
749class TIx2<dag outs, dag ins, string asm, list<dag> pattern>
750 : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>;
751
752// BR_JT instructions
753class TJTI<dag outs, dag ins, string asm, list<dag> pattern>
754 : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>;
755
756
757//===----------------------------------------------------------------------===//
758
759
760// ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode.
761class ThumbPat<dag pattern, dag result> : Pat<pattern, result> {
762 list<Predicate> Predicates = [IsThumb];
763}
764
765class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> {
766 list<Predicate> Predicates = [IsThumb, HasV5T];
767}