blob: b1a7715db98eb84e0200fd752aef1afeec222c58 [file] [log] [blame]
Evan Cheng37f25d92008-08-28 23:39:26 +00001//===- ARMInstrFormats.td - ARM Instruction Formats --*- tablegen -*---------=//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// ARM Instruction Format Definitions.
13//
14
15// Format specifies the encoding used by the instruction. This is part of the
16// ad-hoc solution used to emit machine instruction encodings by our machine
17// code emitter.
18class Format<bits<5> val> {
19 bits<5> Value = val;
20}
21
22def Pseudo : Format<1>;
23def MulFrm : Format<2>;
24def MulSMLAW : Format<3>;
25def MulSMULW : Format<4>;
26def MulSMLA : Format<5>;
27def MulSMUL : Format<6>;
28def Branch : Format<7>;
29def BranchMisc : Format<8>;
30
31def DPRdIm : Format<9>;
32def DPRdReg : Format<10>;
33def DPRdSoReg : Format<11>;
34def DPRdMisc : Format<12>;
35def DPRnIm : Format<13>;
36def DPRnReg : Format<14>;
37def DPRnSoReg : Format<15>;
38def DPRIm : Format<16>;
39def DPRReg : Format<17>;
40def DPRSoReg : Format<18>;
41def DPRImS : Format<19>;
42def DPRRegS : Format<20>;
43def DPRSoRegS : Format<21>;
44
45def LdFrm : Format<22>;
46def StFrm : Format<23>;
47
48def ArithMisc : Format<24>;
49def ThumbFrm : Format<25>;
50def VFPFrm : Format<26>;
51
52
53
54//===----------------------------------------------------------------------===//
55
56// ARM Instruction templates.
57//
58
59class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im,
60 Format f, string cstr>
61 : Instruction {
62 let Namespace = "ARM";
63
64 bits<4> Opcode = opcod;
65 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;
76
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
114class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
115 string asm, list<dag> pattern>
116 : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
117 asm,"",pattern>;
118class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc,
119 string asm, list<dag> pattern>
120 : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc,
121 asm,"",pattern>;
122class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
123 string asm, list<dag> pattern>
124 : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
125 asm, "", pattern>;
126class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc,
127 string asm, list<dag> pattern>
128 : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc,
129 asm, "", pattern>;
130class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
131 string asm, list<dag> pattern>
132 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc,
133 asm, "", pattern>;
134class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc,
135 string asm, list<dag> pattern>
136 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc,
137 asm, "", pattern>;
138class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc,
139 string asm, list<dag> pattern>
140 : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc,
141 asm, "", pattern>;
142class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc,
143 string asm, list<dag> pattern>
144 : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc,
145 asm, "", pattern>;
146
147// Pre-indexed ops
148class AI2pr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
149 string asm, string cstr, list<dag> pattern>
150 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc,
151 asm, cstr, pattern>;
152class AI3pr<bits<4> opcod, dag oops, dag iops, Format f, string opc,
153 string asm, string cstr, list<dag> pattern>
154 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc,
155 asm, cstr, pattern>;
156
157// Post-indexed ops
158class AI2po<bits<4> opcod, dag oops, dag iops, Format f, string opc,
159 string asm, string cstr, list<dag> pattern>
160 : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc,
161 asm, cstr,pattern>;
162class AI3po<bits<4> opcod, dag oops, dag iops, Format f, string opc,
163 string asm, string cstr, list<dag> pattern>
164 : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc,
165 asm, cstr,pattern>;
166
167
168// Special cases.
169class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz,
170 IndexMode im, Format f, string asm, string cstr, list<dag> pattern>
171 : InstARM<opcod, am, sz, im, f, cstr> {
172 let OutOperandList = oops;
173 let InOperandList = iops;
174 let AsmString = asm;
175 let Pattern = pattern;
176 list<Predicate> Predicates = [IsARM];
177}
178
179class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm,
180 list<dag> pattern>
181 : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm,
182 "", pattern>;
183class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm,
184 list<dag> pattern>
185 : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm,
186 "", pattern>;
187class AXI2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
188 list<dag> pattern>
189 : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm,
190 "", pattern>;
191class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm,
192 list<dag> pattern>
193 : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm,
194 "", pattern>;
195class AXI4<bits<4> opcod, dag oops, dag iops, Format f, string asm,
196 list<dag> pattern>
197 : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm,
198 "", pattern>;
199
200class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm,
201 list<dag> pattern>
202 : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm,
203 "", pattern>;
204
205// BR_JT instructions
206class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
207 : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc,
208 asm, "", pattern>;
209class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
210 : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc,
211 asm, "", pattern>;
212class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern>
213 : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc,
214 asm, "", pattern>;
215
216
217//===----------------------------------------------------------------------===//
218
219// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
220class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
221 list<Predicate> Predicates = [IsARM];
222}
223class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
224 list<Predicate> Predicates = [IsARM, HasV5TE];
225}
226class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
227 list<Predicate> Predicates = [IsARM, HasV6];
228}