blob: 3ccf22f80b7da31ec3e2f835057513e9819d39ac [file] [log] [blame]
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson01135592010-03-23 17:23:59 +00002//
Evan Cheng37f25d92008-08-28 23:39:26 +00003// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bob Wilson01135592010-03-23 17:23:59 +00007//
Evan Cheng37f25d92008-08-28 23:39:26 +00008//===----------------------------------------------------------------------===//
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.
Bob Wilson89ef7b72010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng37f25d92008-08-28 23:39:26 +000020}
21
Evan Chengffa6d962008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng37f25d92008-08-28 23:39:26 +000026
Evan Chengffa6d962008-11-13 23:36:57 +000027def DPFrm : Format<4>;
28def DPSoRegFrm : Format<5>;
Evan Cheng37f25d92008-08-28 23:39:26 +000029
Evan Chengffa6d962008-11-13 23:36:57 +000030def LdFrm : Format<6>;
31def StFrm : Format<7>;
32def LdMiscFrm : Format<8>;
33def StMiscFrm : Format<9>;
34def LdStMulFrm : Format<10>;
Evan Cheng37f25d92008-08-28 23:39:26 +000035
Johnny Chen81f04d52010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5278eb82009-12-11 01:42:04 +000037
Johnny Chen81f04d52010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson9a1c1892010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000041
Bob Wilson9a1c1892010-08-11 00:01:18 +000042def VFPUnaryFrm : Format<15>;
43def VFPBinaryFrm : Format<16>;
44def VFPConv1Frm : Format<17>;
45def VFPConv2Frm : Format<18>;
46def VFPConv3Frm : Format<19>;
47def VFPConv4Frm : Format<20>;
48def VFPConv5Frm : Format<21>;
49def VFPLdStFrm : Format<22>;
50def VFPLdStMulFrm : Format<23>;
51def VFPMiscFrm : Format<24>;
Evan Chengcd8e66a2008-11-11 21:48:44 +000052
Bob Wilson9a1c1892010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng37f25d92008-08-28 23:39:26 +000055
Bob Wilson9a1c1892010-08-11 00:01:18 +000056def NGetLnFrm : Format<27>;
57def NSetLnFrm : Format<28>;
58def NDupFrm : Format<29>;
59def NLdStFrm : Format<30>;
60def N1RegModImmFrm: Format<31>;
61def N2RegFrm : Format<32>;
62def NVCVTFrm : Format<33>;
63def NVDupLnFrm : Format<34>;
64def N2RegVShLFrm : Format<35>;
65def N2RegVShRFrm : Format<36>;
66def N3RegFrm : Format<37>;
67def N3RegVShFrm : Format<38>;
68def NVExtFrm : Format<39>;
69def NVMulSLFrm : Format<40>;
70def NVTBLFrm : Format<41>;
Johnny Chencaa608e2010-03-20 00:17:00 +000071
Evan Cheng34a0fa32009-07-08 01:46:35 +000072// Misc flags.
73
Bill Wendling43f7b2d2010-12-01 02:42:55 +000074// The instruction has an Rn register operand.
Evan Cheng34a0fa32009-07-08 01:46:35 +000075// UnaryDP - Indicates this is a unary data processing instruction, i.e.
76// it doesn't have a Rn operand.
77class UnaryDP { bit isUnaryDataProc = 1; }
78
79// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80// a 16-bit Thumb instruction if certain conditions are met.
81class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng37f25d92008-08-28 23:39:26 +000082
Evan Cheng37f25d92008-08-28 23:39:26 +000083//===----------------------------------------------------------------------===//
Bob Wilson50622ce2010-03-18 23:57:57 +000084// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Cheng055b0312009-06-29 07:51:04 +000085//
86
Jim Grosbachff12a8b2011-01-18 19:59:19 +000087// FIXME: Once the JIT is MC-ized, these can go away.
Evan Cheng055b0312009-06-29 07:51:04 +000088// Addressing mode.
Jim Grosbachd86609f2010-10-05 18:14:55 +000089class AddrMode<bits<5> val> {
90 bits<5> Value = val;
Evan Cheng055b0312009-06-29 07:51:04 +000091}
Bill Wendlingda2ae632010-08-31 07:50:46 +000092def AddrModeNone : AddrMode<0>;
93def AddrMode1 : AddrMode<1>;
94def AddrMode2 : AddrMode<2>;
95def AddrMode3 : AddrMode<3>;
96def AddrMode4 : AddrMode<4>;
97def AddrMode5 : AddrMode<5>;
98def AddrMode6 : AddrMode<6>;
99def AddrModeT1_1 : AddrMode<7>;
100def AddrModeT1_2 : AddrMode<8>;
101def AddrModeT1_4 : AddrMode<9>;
102def AddrModeT1_s : AddrMode<10>;
103def AddrModeT2_i12 : AddrMode<11>;
104def AddrModeT2_i8 : AddrMode<12>;
105def AddrModeT2_so : AddrMode<13>;
106def AddrModeT2_pc : AddrMode<14>;
Bob Wilson8b024a52009-07-01 23:16:05 +0000107def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach3e556122010-10-26 22:37:02 +0000108def AddrMode_i12 : AddrMode<16>;
Evan Cheng055b0312009-06-29 07:51:04 +0000109
Evan Cheng055b0312009-06-29 07:51:04 +0000110// Load / store index mode.
111class IndexMode<bits<2> val> {
112 bits<2> Value = val;
113}
114def IndexModeNone : IndexMode<0>;
115def IndexModePre : IndexMode<1>;
116def IndexModePost : IndexMode<2>;
Bob Wilsonbffb5b32010-03-13 07:34:35 +0000117def IndexModeUpd : IndexMode<3>;
Evan Cheng055b0312009-06-29 07:51:04 +0000118
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000119// Instruction execution domain.
Evan Cheng6557bce2011-02-22 19:53:14 +0000120class Domain<bits<3> val> {
121 bits<3> Value = val;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000122}
123def GenericDomain : Domain<0>;
124def VFPDomain : Domain<1>; // Instructions in VFP domain only
125def NeonDomain : Domain<2>; // Instructions in Neon domain only
126def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng2b943562011-02-23 02:35:33 +0000127def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000128
Evan Cheng055b0312009-06-29 07:51:04 +0000129//===----------------------------------------------------------------------===//
Evan Cheng446c4282009-07-11 06:43:01 +0000130// ARM special operands.
131//
132
Daniel Dunbar8462b302010-08-11 06:36:53 +0000133def CondCodeOperand : AsmOperandClass {
134 let Name = "CondCode";
135 let SuperClasses = [];
136}
137
Jim Grosbachd67641b2010-12-06 18:21:12 +0000138def CCOutOperand : AsmOperandClass {
139 let Name = "CCOut";
140 let SuperClasses = [];
141}
142
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000143def MemBarrierOptOperand : AsmOperandClass {
144 let Name = "MemBarrierOpt";
145 let SuperClasses = [];
Jim Grosbachf922c472011-02-12 01:34:40 +0000146 let ParserMethod = "tryParseMemBarrierOptOperand";
Bruno Cardoso Lopes706d9462011-02-07 22:09:15 +0000147}
148
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000149def ProcIFlagsOperand : AsmOperandClass {
150 let Name = "ProcIFlags";
151 let SuperClasses = [];
152 let ParserMethod = "tryParseProcIFlagsOperand";
153}
154
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000155def MSRMaskOperand : AsmOperandClass {
156 let Name = "MSRMask";
157 let SuperClasses = [];
158 let ParserMethod = "tryParseMSRMaskOperand";
159}
160
Bruno Cardoso Lopesa2b6e412011-02-14 13:09:44 +0000161// ARM imod and iflag operands, used only by the CPS instruction.
162def imod_op : Operand<i32> {
163 let PrintMethod = "printCPSIMod";
164}
165
166def iflags_op : Operand<i32> {
167 let PrintMethod = "printCPSIFlag";
168 let ParserMatchClass = ProcIFlagsOperand;
169}
170
Evan Cheng446c4282009-07-11 06:43:01 +0000171// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
172// register whose default is 0 (no register).
173def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
174 (ops (i32 14), (i32 zero_reg))> {
175 let PrintMethod = "printPredicateOperand";
Daniel Dunbar8462b302010-08-11 06:36:53 +0000176 let ParserMatchClass = CondCodeOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000177}
178
179// Conditional code result for instructions whose 's' bit is set, e.g. subs.
180def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000181 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000182 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000183 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000184}
185
186// Same as cc_out except it defaults to setting CPSR.
187def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner2ac19022010-11-15 05:19:05 +0000188 let EncoderMethod = "getCCOutOpValue";
Evan Cheng446c4282009-07-11 06:43:01 +0000189 let PrintMethod = "printSBitModifierOperand";
Jim Grosbachd67641b2010-12-06 18:21:12 +0000190 let ParserMatchClass = CCOutOperand;
Evan Cheng446c4282009-07-11 06:43:01 +0000191}
192
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000193// ARM special operands for disassembly only.
194//
Jim Grosbachb3af5de2010-10-13 21:00:04 +0000195def setend_op : Operand<i32> {
196 let PrintMethod = "printSetendOperand";
197}
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000198
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000199def msr_mask : Operand<i32> {
200 let PrintMethod = "printMSRMaskOperand";
Bruno Cardoso Lopes584bf7b2011-02-18 19:45:59 +0000201 let ParserMatchClass = MSRMaskOperand;
Johnny Chendd0f3cf2010-03-10 18:59:38 +0000202}
203
Bill Wendling3116dce2011-03-07 23:38:41 +0000204// Shift Right Immediate - A shift right immediate is encoded differently from
205// other shift immediates. The imm6 field is encoded like so:
Bill Wendlinga656b632011-03-01 01:00:59 +0000206//
Bill Wendling3116dce2011-03-07 23:38:41 +0000207// Offset Encoding
208// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
209// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
210// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
211// 64 64 - <imm> is encoded in imm6<5:0>
212def shr_imm8 : Operand<i32> {
213 let EncoderMethod = "getShiftRight8Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000214}
Bill Wendling3116dce2011-03-07 23:38:41 +0000215def shr_imm16 : Operand<i32> {
216 let EncoderMethod = "getShiftRight16Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000217}
Bill Wendling3116dce2011-03-07 23:38:41 +0000218def shr_imm32 : Operand<i32> {
219 let EncoderMethod = "getShiftRight32Imm";
220}
221def shr_imm64 : Operand<i32> {
222 let EncoderMethod = "getShiftRight64Imm";
Bill Wendlinga656b632011-03-01 01:00:59 +0000223}
224
Evan Cheng446c4282009-07-11 06:43:01 +0000225//===----------------------------------------------------------------------===//
Evan Cheng37f25d92008-08-28 23:39:26 +0000226// ARM Instruction templates.
227//
228
Owen Anderson16884412011-07-13 23:22:26 +0000229class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chend68e1192009-12-15 17:24:14 +0000230 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng37f25d92008-08-28 23:39:26 +0000231 : Instruction {
232 let Namespace = "ARM";
233
Evan Cheng37f25d92008-08-28 23:39:26 +0000234 AddrMode AM = am;
Owen Anderson16884412011-07-13 23:22:26 +0000235 int Size = sz;
Evan Cheng37f25d92008-08-28 23:39:26 +0000236 IndexMode IM = im;
237 bits<2> IndexModeBits = IM.Value;
Evan Cheng37f25d92008-08-28 23:39:26 +0000238 Format F = f;
Bob Wilson89ef7b72010-03-17 21:13:43 +0000239 bits<6> Form = F.Value;
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000240 Domain D = d;
Evan Chengedda31c2008-11-05 18:35:52 +0000241 bit isUnaryDataProc = 0;
Evan Cheng34a0fa32009-07-08 01:46:35 +0000242 bit canXformTo16Bit = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +0000243
Chris Lattner150d20e2010-10-31 19:22:57 +0000244 // If this is a pseudo instruction, mark it isCodeGenOnly.
245 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson01135592010-03-23 17:23:59 +0000246
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000247 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
Jim Grosbachd86609f2010-10-05 18:14:55 +0000248 let TSFlags{4-0} = AM.Value;
Owen Anderson16884412011-07-13 23:22:26 +0000249 let TSFlags{6-5} = IndexModeBits;
250 let TSFlags{12-7} = Form;
251 let TSFlags{13} = isUnaryDataProc;
252 let TSFlags{14} = canXformTo16Bit;
253 let TSFlags{17-15} = D.Value;
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +0000254
Evan Cheng37f25d92008-08-28 23:39:26 +0000255 let Constraints = cstr;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000256 let Itinerary = itin;
Evan Cheng37f25d92008-08-28 23:39:26 +0000257}
258
Johnny Chend68e1192009-12-15 17:24:14 +0000259class Encoding {
260 field bits<32> Inst;
261}
262
Owen Anderson16884412011-07-13 23:22:26 +0000263class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chend68e1192009-12-15 17:24:14 +0000264 Format f, Domain d, string cstr, InstrItinClass itin>
265 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
266
267// This Encoding-less class is used by Thumb1 to specify the encoding bits later
268// on by adding flavors to specific instructions.
Owen Anderson16884412011-07-13 23:22:26 +0000269class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chend68e1192009-12-15 17:24:14 +0000270 Format f, Domain d, string cstr, InstrItinClass itin>
271 : InstTemplate<am, sz, im, f, d, cstr, itin>;
272
Jim Grosbach99594eb2010-11-18 01:38:26 +0000273class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000274 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbachd1689ae2011-07-06 21:35:46 +0000275 GenericDomain, "", itin> {
Evan Cheng37f25d92008-08-28 23:39:26 +0000276 let OutOperandList = oops;
277 let InOperandList = iops;
Evan Cheng37f25d92008-08-28 23:39:26 +0000278 let Pattern = pattern;
Jim Grosbacha768c3d2011-03-10 19:06:39 +0000279 let isCodeGenOnly = 1;
Jim Grosbachd1689ae2011-07-06 21:35:46 +0000280 let isPseudo = 1;
Evan Cheng37f25d92008-08-28 23:39:26 +0000281}
282
Jim Grosbach53694262010-11-18 01:15:56 +0000283// PseudoInst that's ARM-mode only.
Owen Anderson16884412011-07-13 23:22:26 +0000284class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach99594eb2010-11-18 01:38:26 +0000285 list<dag> pattern>
286 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson16884412011-07-13 23:22:26 +0000287 let Size = sz;
Jim Grosbach53694262010-11-18 01:15:56 +0000288 list<Predicate> Predicates = [IsARM];
289}
290
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000291// PseudoInst that's Thumb-mode only.
Owen Anderson16884412011-07-13 23:22:26 +0000292class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000293 list<dag> pattern>
294 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson16884412011-07-13 23:22:26 +0000295 let Size = sz;
Jim Grosbachf1aa47d2010-11-29 19:32:47 +0000296 list<Predicate> Predicates = [IsThumb];
297}
Jim Grosbach53694262010-11-18 01:15:56 +0000298
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000299// PseudoInst that's Thumb2-mode only.
Owen Anderson16884412011-07-13 23:22:26 +0000300class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000301 list<dag> pattern>
302 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson16884412011-07-13 23:22:26 +0000303 let Size = sz;
Jim Grosbach41b1d4e2010-12-15 18:48:45 +0000304 list<Predicate> Predicates = [IsThumb2];
305}
Jim Grosbach53e3fc42011-07-08 17:40:42 +0000306
Owen Anderson16884412011-07-13 23:22:26 +0000307class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach53e3fc42011-07-08 17:40:42 +0000308 InstrItinClass itin, list<dag> pattern,
309 dag Result>
310 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
311 PseudoInstExpansion<Result>;
312
Owen Anderson16884412011-07-13 23:22:26 +0000313class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach53e3fc42011-07-08 17:40:42 +0000314 InstrItinClass itin, list<dag> pattern,
315 dag Result>
316 : tPseudoInst<oops, iops, sz, itin, pattern>,
317 PseudoInstExpansion<Result>;
318
Owen Anderson16884412011-07-13 23:22:26 +0000319class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach53e3fc42011-07-08 17:40:42 +0000320 InstrItinClass itin, list<dag> pattern,
321 dag Result>
322 : t2PseudoInst<oops, iops, sz, itin, pattern>,
323 PseudoInstExpansion<Result>;
324
Evan Cheng37f25d92008-08-28 23:39:26 +0000325// Almost all ARM instructions are predicable.
Owen Anderson16884412011-07-13 23:22:26 +0000326class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson01135592010-03-23 17:23:59 +0000327 IndexMode im, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000328 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000329 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000330 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000331 bits<4> p;
332 let Inst{31-28} = p;
Evan Cheng37f25d92008-08-28 23:39:26 +0000333 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000334 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000335 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000336 let Pattern = pattern;
337 list<Predicate> Predicates = [IsARM];
338}
Bill Wendlingda2ae632010-08-31 07:50:46 +0000339
Jim Grosbachf6b28622009-12-14 18:31:20 +0000340// A few are not predicable
Owen Anderson16884412011-07-13 23:22:26 +0000341class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson01135592010-03-23 17:23:59 +0000342 IndexMode im, Format f, InstrItinClass itin,
343 string opc, string asm, string cstr,
344 list<dag> pattern>
Jim Grosbachf6b28622009-12-14 18:31:20 +0000345 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
346 let OutOperandList = oops;
347 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000348 let AsmString = !strconcat(opc, asm);
Jim Grosbachf6b28622009-12-14 18:31:20 +0000349 let Pattern = pattern;
350 let isPredicable = 0;
351 list<Predicate> Predicates = [IsARM];
352}
Evan Cheng37f25d92008-08-28 23:39:26 +0000353
Bill Wendling4822bce2010-08-30 01:47:35 +0000354// Same as I except it can optionally modify CPSR. Note it's modeled as an input
355// operand since by default it's a zero register. It will become an implicit def
356// once it's "flipped".
Owen Anderson16884412011-07-13 23:22:26 +0000357class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000358 IndexMode im, Format f, InstrItinClass itin,
359 string opc, string asm, string cstr,
Evan Cheng37f25d92008-08-28 23:39:26 +0000360 list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000361 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach62547262010-10-11 18:51:51 +0000362 bits<4> p; // Predicate operand
Jim Grosbach08bd5492010-10-12 23:00:24 +0000363 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach62547262010-10-11 18:51:51 +0000364 let Inst{31-28} = p;
Jim Grosbach08bd5492010-10-12 23:00:24 +0000365 let Inst{20} = s;
Jim Grosbach62547262010-10-11 18:51:51 +0000366
Evan Cheng37f25d92008-08-28 23:39:26 +0000367 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000368 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilsoncfbece52010-10-15 03:23:44 +0000369 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng37f25d92008-08-28 23:39:26 +0000370 let Pattern = pattern;
371 list<Predicate> Predicates = [IsARM];
372}
373
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000374// Special cases
Owen Anderson16884412011-07-13 23:22:26 +0000375class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000376 IndexMode im, Format f, InstrItinClass itin,
377 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +0000378 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000379 let OutOperandList = oops;
380 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000381 let AsmString = asm;
Evan Cheng4bbd5f82008-09-01 07:19:00 +0000382 let Pattern = pattern;
383 list<Predicate> Predicates = [IsARM];
384}
385
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000386class AI<dag oops, dag iops, Format f, InstrItinClass itin,
387 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000388 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000389 opc, asm, "", pattern>;
390class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
391 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000392 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000393 opc, asm, "", pattern>;
394class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000395 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000396 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng97f48c32008-11-06 22:15:19 +0000397 asm, "", pattern>;
Jim Grosbachf6b28622009-12-14 18:31:20 +0000398class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +0000399 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000400 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson01135592010-03-23 17:23:59 +0000401 opc, asm, "", pattern>;
Evan Cheng3aac7882008-09-01 08:25:56 +0000402
403// Ctrl flow instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000404class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
405 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000406 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000407 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000408 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000409}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000410class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
411 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000412 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000413 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000414 let Inst{27-24} = opcod;
Evan Cheng3aac7882008-09-01 08:25:56 +0000415}
Evan Cheng3aac7882008-09-01 08:25:56 +0000416
417// BR_JT instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000418class JTI<dag oops, dag iops, InstrItinClass itin,
419 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000420 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng4df60f52008-11-07 09:06:08 +0000421 asm, "", pattern>;
Evan Cheng0d14fc82008-09-01 01:51:14 +0000422
Jim Grosbach5278eb82009-12-11 01:42:04 +0000423// Atomic load/store instructions
Jim Grosbach5278eb82009-12-11 01:42:04 +0000424class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
425 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000426 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5278eb82009-12-11 01:42:04 +0000427 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000428 bits<4> Rt;
429 bits<4> Rn;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000430 let Inst{27-23} = 0b00011;
431 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000432 let Inst{20} = 1;
Jim Grosbach86875a22010-10-29 19:58:57 +0000433 let Inst{19-16} = Rn;
434 let Inst{15-12} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000435 let Inst{11-0} = 0b111110011111;
436}
437class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
438 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000439 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5278eb82009-12-11 01:42:04 +0000440 opc, asm, "", pattern> {
Jim Grosbach86875a22010-10-29 19:58:57 +0000441 bits<4> Rd;
442 bits<4> Rt;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000443 bits<4> addr;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000444 let Inst{27-23} = 0b00011;
445 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000446 let Inst{20} = 0;
Bruno Cardoso Lopes505f3cd2011-03-24 21:04:58 +0000447 let Inst{19-16} = addr;
Jim Grosbach86875a22010-10-29 19:58:57 +0000448 let Inst{15-12} = Rd;
Johnny Chen0291d7e2009-12-11 19:37:26 +0000449 let Inst{11-4} = 0b11111001;
Jim Grosbach86875a22010-10-29 19:58:57 +0000450 let Inst{3-0} = Rt;
Jim Grosbach5278eb82009-12-11 01:42:04 +0000451}
Jim Grosbachf32ecc62010-10-29 20:21:36 +0000452class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
453 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
454 bits<4> Rt;
455 bits<4> Rt2;
456 bits<4> Rn;
457 let Inst{27-23} = 0b00010;
458 let Inst{22} = b;
459 let Inst{21-20} = 0b00;
460 let Inst{19-16} = Rn;
461 let Inst{15-12} = Rt;
462 let Inst{11-4} = 0b00001001;
463 let Inst{3-0} = Rt2;
464}
Jim Grosbach5278eb82009-12-11 01:42:04 +0000465
Evan Cheng0d14fc82008-09-01 01:51:14 +0000466// addrmode1 instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000467class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
468 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000469 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000470 opc, asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000471 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000472 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000473}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000474class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
475 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000476 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000477 opc, asm, "", pattern> {
478 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000479 let Inst{27-26} = 0b00;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000480}
481class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng37f25d92008-08-28 23:39:26 +0000482 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000483 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Cheng612b79e2008-08-29 07:40:52 +0000484 asm, "", pattern> {
Jim Grosbach26421962008-10-14 20:36:24 +0000485 let Inst{24-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000486 let Inst{27-26} = 0b00;
Evan Cheng612b79e2008-08-29 07:40:52 +0000487}
Evan Cheng0d14fc82008-09-01 01:51:14 +0000488
Evan Cheng93912732008-09-01 01:27:33 +0000489// loads
Jim Grosbach3e556122010-10-26 22:37:02 +0000490
Jim Grosbach9558b4c2010-11-19 21:07:51 +0000491// LDR/LDRB/STR/STRB/...
492class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000493 Format f, InstrItinClass itin, string opc, string asm,
494 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000495 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach3e556122010-10-26 22:37:02 +0000496 "", pattern> {
497 let Inst{27-25} = op;
498 let Inst{24} = 1; // 24 == P
499 // 23 == U
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000500 let Inst{22} = isByte;
Jim Grosbach3e556122010-10-26 22:37:02 +0000501 let Inst{21} = 0; // 21 == W
Jim Grosbach7e3383c2010-10-27 23:12:14 +0000502 let Inst{20} = isLd;
Jim Grosbach3e556122010-10-26 22:37:02 +0000503}
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000504// Indexed load/stores
505class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach953557f42010-11-19 21:35:06 +0000506 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000507 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000508 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000509 opc, asm, cstr, pattern> {
Jim Grosbach99f53d12010-11-15 20:47:07 +0000510 bits<4> Rt;
Jim Grosbach9e0bfb52010-11-13 00:35:48 +0000511 let Inst{27-26} = 0b01;
512 let Inst{24} = isPre; // P bit
513 let Inst{22} = isByte; // B bit
514 let Inst{21} = isPre; // W bit
515 let Inst{20} = isLd; // L bit
Jim Grosbach99f53d12010-11-15 20:47:07 +0000516 let Inst{15-12} = Rt;
Jim Grosbach3e556122010-10-26 22:37:02 +0000517}
Jim Grosbach953557f42010-11-19 21:35:06 +0000518class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
519 IndexMode im, Format f, InstrItinClass itin, string opc,
520 string asm, string cstr, list<dag> pattern>
521 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
522 pattern> {
523 // AM2 store w/ two operands: (GPR, am2offset)
524 // {13} 1 == Rm, 0 == imm12
525 // {12} isAdd
526 // {11-0} imm12/Rm
Bruno Cardoso Lopesb41aaab2011-03-31 15:54:36 +0000527 bits<14> offset;
528 bits<4> Rn;
529 let Inst{25} = offset{13};
530 let Inst{23} = offset{12};
531 let Inst{19-16} = Rn;
532 let Inst{11-0} = offset{11-0};
Jim Grosbach953557f42010-11-19 21:35:06 +0000533}
Bruno Cardoso Lopesae085542011-03-31 23:26:08 +0000534// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
535// but for now use this class for STRT and STRBT.
536class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
537 IndexMode im, Format f, InstrItinClass itin, string opc,
538 string asm, string cstr, list<dag> pattern>
539 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
540 pattern> {
541 // AM2 store w/ two operands: (GPR, am2offset)
542 // {17-14} Rn
543 // {13} 1 == Rm, 0 == imm12
544 // {12} isAdd
545 // {11-0} imm12/Rm
546 bits<18> addr;
547 let Inst{25} = addr{13};
548 let Inst{23} = addr{12};
549 let Inst{19-16} = addr{17-14};
550 let Inst{11-0} = addr{11-0};
551}
Jim Grosbach3e556122010-10-26 22:37:02 +0000552
Evan Cheng0d14fc82008-09-01 01:51:14 +0000553// addrmode3 instructions
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000554class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
555 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000556 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach160f8f02010-11-18 00:46:58 +0000557 opc, asm, "", pattern> {
558 bits<14> addr;
559 bits<4> Rt;
560 let Inst{27-25} = 0b000;
561 let Inst{24} = 1; // P bit
562 let Inst{23} = addr{8}; // U bit
563 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
564 let Inst{21} = 0; // W bit
Jim Grosbachf1ce7cc2010-11-19 18:16:46 +0000565 let Inst{20} = op20; // L bit
Jim Grosbach160f8f02010-11-18 00:46:58 +0000566 let Inst{19-16} = addr{12-9}; // Rn
567 let Inst{15-12} = Rt; // Rt
568 let Inst{11-8} = addr{7-4}; // imm7_4/zero
569 let Inst{7-4} = op;
570 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
571}
Evan Cheng840917b2008-09-01 07:00:14 +0000572
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000573class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
574 IndexMode im, Format f, InstrItinClass itin, string opc,
575 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000576 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000577 opc, asm, cstr, pattern> {
578 bits<4> Rt;
579 let Inst{27-25} = 0b000;
580 let Inst{24} = isPre; // P bit
581 let Inst{21} = isPre; // W bit
582 let Inst{20} = op20; // L bit
583 let Inst{15-12} = Rt; // Rt
584 let Inst{7-4} = op;
585}
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000586
587// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
588// but for now use this class for LDRSBT, LDRHT, LDSHT.
589class AI3ldstidxT<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
590 IndexMode im, Format f, InstrItinClass itin, string opc,
591 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000592 : I<oops, iops, AddrMode3, 4, im, f, itin,
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000593 opc, asm, cstr, pattern> {
594 // {13} 1 == imm8, 0 == Rm
595 // {12-9} Rn
596 // {8} isAdd
597 // {7-4} imm7_4/zero
598 // {3-0} imm3_0/Rm
599 bits<14> addr;
600 bits<4> Rt;
601 let Inst{27-25} = 0b000;
602 let Inst{24} = isPre; // P bit
603 let Inst{23} = addr{8}; // U bit
604 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
605 let Inst{20} = op20; // L bit
606 let Inst{19-16} = addr{12-9}; // Rn
607 let Inst{15-12} = Rt; // Rt
608 let Inst{11-8} = addr{7-4}; // imm7_4/zero
609 let Inst{7-4} = op;
610 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
611 let AsmMatchConverter = "CvtLdWriteBackRegAddrMode3";
612}
613
Jim Grosbach2dc77682010-11-29 18:37:44 +0000614class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
615 IndexMode im, Format f, InstrItinClass itin, string opc,
616 string asm, string cstr, list<dag> pattern>
617 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
618 pattern> {
619 // AM3 store w/ two operands: (GPR, am3offset)
620 bits<14> offset;
621 bits<4> Rt;
622 bits<4> Rn;
623 let Inst{27-25} = 0b000;
624 let Inst{23} = offset{8};
625 let Inst{22} = offset{9};
626 let Inst{19-16} = Rn;
627 let Inst{15-12} = Rt; // Rt
628 let Inst{11-8} = offset{7-4}; // imm7_4/zero
629 let Inst{7-4} = op;
630 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
631}
Jim Grosbach9cb15b52010-11-19 19:41:26 +0000632
Evan Cheng840917b2008-09-01 07:00:14 +0000633// stores
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000634class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000635 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000636 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000637 opc, asm, "", pattern> {
Jim Grosbach570a9222010-11-11 01:09:40 +0000638 bits<14> addr;
639 bits<4> Rt;
Evan Chengdda0f4c2009-07-08 22:51:32 +0000640 let Inst{27-25} = 0b000;
Jim Grosbach570a9222010-11-11 01:09:40 +0000641 let Inst{24} = 1; // P bit
642 let Inst{23} = addr{8}; // U bit
643 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
644 let Inst{21} = 0; // W bit
645 let Inst{20} = 0; // L bit
646 let Inst{19-16} = addr{12-9}; // Rn
647 let Inst{15-12} = Rt; // Rt
648 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach2aeb6122010-11-19 22:14:31 +0000649 let Inst{7-4} = op;
Jim Grosbach570a9222010-11-11 01:09:40 +0000650 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000651}
Evan Cheng840917b2008-09-01 07:00:14 +0000652
Evan Cheng840917b2008-09-01 07:00:14 +0000653// Pre-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000654class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
655 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000656 : I<oops, iops, AddrMode3, 4, IndexModePre, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000657 opc, asm, cstr, pattern> {
Evan Cheng840917b2008-09-01 07:00:14 +0000658 let Inst{4} = 1;
659 let Inst{5} = 1; // H bit
660 let Inst{6} = 0; // S bit
661 let Inst{7} = 1;
662 let Inst{20} = 0; // L bit
663 let Inst{21} = 1; // W bit
664 let Inst{24} = 1; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000665 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000666}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000667class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
668 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000669 : I<oops, iops, AddrMode3, 4, IndexModePre, f, itin,
Johnny Chen39a4bb32010-02-18 22:31:18 +0000670 opc, asm, cstr, pattern> {
671 let Inst{4} = 1;
672 let Inst{5} = 1; // H bit
673 let Inst{6} = 1; // S bit
674 let Inst{7} = 1;
675 let Inst{20} = 0; // L bit
676 let Inst{21} = 1; // W bit
677 let Inst{24} = 1; // P bit
678 let Inst{27-25} = 0b000;
679}
Evan Cheng840917b2008-09-01 07:00:14 +0000680
Evan Cheng840917b2008-09-01 07:00:14 +0000681// Post-indexed stores
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000682class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
683 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000684 : I<oops, iops, AddrMode3, 4, IndexModePost, f, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000685 opc, asm, cstr,pattern> {
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000686 // {13} 1 == imm8, 0 == Rm
687 // {12-9} Rn
688 // {8} isAdd
689 // {7-4} imm7_4/zero
690 // {3-0} imm3_0/Rm
691 bits<14> addr;
692 bits<4> Rt;
693 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Evan Cheng840917b2008-09-01 07:00:14 +0000694 let Inst{4} = 1;
695 let Inst{5} = 1; // H bit
696 let Inst{6} = 0; // S bit
697 let Inst{7} = 1;
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000698 let Inst{11-8} = addr{7-4}; // imm7_4/zero
699 let Inst{15-12} = Rt; // Rt
700 let Inst{19-16} = addr{12-9}; // Rn
Evan Cheng840917b2008-09-01 07:00:14 +0000701 let Inst{20} = 0; // L bit
Johnny Chenad4df4c2010-03-01 19:22:00 +0000702 let Inst{21} = 0; // W bit
Bruno Cardoso Lopesac79e4c2011-04-04 17:18:19 +0000703 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
704 let Inst{23} = addr{8}; // U bit
Evan Cheng840917b2008-09-01 07:00:14 +0000705 let Inst{24} = 0; // P bit
Evan Chengdda0f4c2009-07-08 22:51:32 +0000706 let Inst{27-25} = 0b000;
Evan Cheng840917b2008-09-01 07:00:14 +0000707}
Johnny Chen39a4bb32010-02-18 22:31:18 +0000708class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
709 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000710 : I<oops, iops, AddrMode3, 4, IndexModePost, f, itin,
Johnny Chen39a4bb32010-02-18 22:31:18 +0000711 opc, asm, cstr, pattern> {
712 let Inst{4} = 1;
713 let Inst{5} = 1; // H bit
714 let Inst{6} = 1; // S bit
715 let Inst{7} = 1;
716 let Inst{20} = 0; // L bit
717 let Inst{21} = 0; // W bit
718 let Inst{24} = 0; // P bit
719 let Inst{27-25} = 0b000;
720}
Evan Cheng840917b2008-09-01 07:00:14 +0000721
Evan Cheng0d14fc82008-09-01 01:51:14 +0000722// addrmode4 instructions
Bill Wendling6c470b82010-11-13 09:09:38 +0000723class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
724 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000725 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendling6c470b82010-11-13 09:09:38 +0000726 bits<4> p;
727 bits<16> regs;
728 bits<4> Rn;
729 let Inst{31-28} = p;
730 let Inst{27-25} = 0b100;
731 let Inst{22} = 0; // S bit
732 let Inst{19-16} = Rn;
733 let Inst{15-0} = regs;
734}
Evan Cheng37f25d92008-08-28 23:39:26 +0000735
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000736// Unsigned multiply, multiply-accumulate instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000737class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
738 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000739 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000740 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000741 let Inst{7-4} = 0b1001;
Evan Chengfbc9d412008-11-06 01:21:28 +0000742 let Inst{20} = 0; // S bit
Evan Chengd87293c2008-11-06 08:47:38 +0000743 let Inst{27-21} = opcod;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000744}
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000745class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
746 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000747 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000748 opc, asm, "", pattern> {
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000749 let Inst{7-4} = 0b1001;
Evan Chengd87293c2008-11-06 08:47:38 +0000750 let Inst{27-21} = opcod;
Evan Chengfbc9d412008-11-06 01:21:28 +0000751}
752
753// Most significant word multiply
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000754class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
755 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000756 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000757 opc, asm, "", pattern> {
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000758 bits<4> Rd;
759 bits<4> Rn;
760 bits<4> Rm;
761 let Inst{7-4} = opc7_4;
Evan Chengfbc9d412008-11-06 01:21:28 +0000762 let Inst{20} = 1;
Evan Chengd87293c2008-11-06 08:47:38 +0000763 let Inst{27-21} = opcod;
Jim Grosbach9463d0e2010-10-22 17:16:17 +0000764 let Inst{19-16} = Rd;
765 let Inst{11-8} = Rm;
766 let Inst{3-0} = Rn;
767}
768// MSW multiple w/ Ra operand
769class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
770 InstrItinClass itin, string opc, string asm, list<dag> pattern>
771 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
772 bits<4> Ra;
773 let Inst{15-12} = Ra;
Jim Grosbach0a4b9dc2008-11-03 18:38:31 +0000774}
Evan Cheng37f25d92008-08-28 23:39:26 +0000775
Evan Chengeb4f52e2008-11-06 03:35:07 +0000776// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach3870b752010-10-22 18:35:16 +0000777class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbach929a7052010-10-22 17:42:06 +0000778 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000779 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000780 opc, asm, "", pattern> {
Jim Grosbach3870b752010-10-22 18:35:16 +0000781 bits<4> Rn;
782 bits<4> Rm;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000783 let Inst{4} = 0;
784 let Inst{7} = 1;
785 let Inst{20} = 0;
Evan Chengd87293c2008-11-06 08:47:38 +0000786 let Inst{27-21} = opcod;
Jim Grosbach929a7052010-10-22 17:42:06 +0000787 let Inst{6-5} = bit6_5;
Jim Grosbach3870b752010-10-22 18:35:16 +0000788 let Inst{11-8} = Rm;
789 let Inst{3-0} = Rn;
790}
791class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
792 InstrItinClass itin, string opc, string asm, list<dag> pattern>
793 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
794 bits<4> Rd;
795 let Inst{19-16} = Rd;
796}
797
798// AMulxyI with Ra operand
799class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
800 InstrItinClass itin, string opc, string asm, list<dag> pattern>
801 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
802 bits<4> Ra;
803 let Inst{15-12} = Ra;
804}
805// SMLAL*
806class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
807 InstrItinClass itin, string opc, string asm, list<dag> pattern>
808 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
809 bits<4> RdLo;
810 bits<4> RdHi;
811 let Inst{19-16} = RdHi;
812 let Inst{15-12} = RdLo;
Evan Chengeb4f52e2008-11-06 03:35:07 +0000813}
814
Evan Cheng97f48c32008-11-06 22:15:19 +0000815// Extend instructions.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000816class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
817 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000818 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000819 opc, asm, "", pattern> {
Jim Grosbachb35ad412010-10-13 19:56:10 +0000820 // All AExtI instructions have Rd and Rm register operands.
821 bits<4> Rd;
822 bits<4> Rm;
823 let Inst{15-12} = Rd;
824 let Inst{3-0} = Rm;
Evan Cheng97f48c32008-11-06 22:15:19 +0000825 let Inst{7-4} = 0b0111;
Jim Grosbachb35ad412010-10-13 19:56:10 +0000826 let Inst{9-8} = 0b00;
Evan Cheng97f48c32008-11-06 22:15:19 +0000827 let Inst{27-20} = opcod;
828}
829
Evan Cheng8b59db32008-11-07 01:41:35 +0000830// Misc Arithmetic instructions.
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000831class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
832 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000833 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000834 opc, asm, "", pattern> {
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000835 bits<4> Rd;
836 bits<4> Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000837 let Inst{27-20} = opcod;
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000838 let Inst{19-16} = 0b1111;
839 let Inst{15-12} = Rd;
840 let Inst{11-8} = 0b1111;
841 let Inst{7-4} = opc7_4;
842 let Inst{3-0} = Rm;
843}
844
845// PKH instructions
846class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
847 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000848 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbachf8da5f52010-10-22 22:12:16 +0000849 opc, asm, "", pattern> {
850 bits<4> Rd;
851 bits<4> Rn;
852 bits<4> Rm;
853 bits<8> sh;
854 let Inst{27-20} = opcod;
855 let Inst{19-16} = Rn;
856 let Inst{15-12} = Rd;
857 let Inst{11-7} = sh{7-3};
858 let Inst{6} = tb;
859 let Inst{5-4} = 0b01;
860 let Inst{3-0} = Rm;
Evan Cheng8b59db32008-11-07 01:41:35 +0000861}
862
Evan Cheng37f25d92008-08-28 23:39:26 +0000863//===----------------------------------------------------------------------===//
864
865// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
866class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
867 list<Predicate> Predicates = [IsARM];
868}
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +0000869class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
870 list<Predicate> Predicates = [IsARM, HasV5T];
871}
Evan Cheng37f25d92008-08-28 23:39:26 +0000872class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
873 list<Predicate> Predicates = [IsARM, HasV5TE];
874}
875class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
876 list<Predicate> Predicates = [IsARM, HasV6];
877}
Evan Cheng13096642008-08-29 06:41:12 +0000878
879//===----------------------------------------------------------------------===//
Evan Cheng13096642008-08-29 06:41:12 +0000880// Thumb Instruction Format Definitions.
881//
882
Owen Anderson16884412011-07-13 23:22:26 +0000883class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000884 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000885 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000886 let OutOperandList = oops;
887 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000888 let AsmString = asm;
Evan Cheng13096642008-08-29 06:41:12 +0000889 let Pattern = pattern;
890 list<Predicate> Predicates = [IsThumb];
891}
892
Bill Wendling43f7b2d2010-12-01 02:42:55 +0000893// TI - Thumb instruction.
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000894class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000895 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000896
Evan Cheng35d6c412009-08-04 23:47:55 +0000897// Two-address instructions
Bob Wilson01135592010-03-23 17:23:59 +0000898class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
899 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000900 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson01135592010-03-23 17:23:59 +0000901 pattern>;
Evan Cheng35d6c412009-08-04 23:47:55 +0000902
Johnny Chend68e1192009-12-15 17:24:14 +0000903// tBL, tBX 32-bit instructions
904class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson01135592010-03-23 17:23:59 +0000905 dag oops, dag iops, InstrItinClass itin, string asm,
906 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000907 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson01135592010-03-23 17:23:59 +0000908 Encoding {
Johnny Chend68e1192009-12-15 17:24:14 +0000909 let Inst{31-27} = opcod1;
910 let Inst{15-14} = opcod2;
Bill Wendlingda2ae632010-08-31 07:50:46 +0000911 let Inst{12} = opcod3;
Johnny Chend68e1192009-12-15 17:24:14 +0000912}
Evan Cheng13096642008-08-29 06:41:12 +0000913
914// BR_JT instructions
Bob Wilson01135592010-03-23 17:23:59 +0000915class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
916 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000917 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng13096642008-08-29 06:41:12 +0000918
Evan Cheng09c39fc2009-06-23 19:38:13 +0000919// Thumb1 only
Owen Anderson16884412011-07-13 23:22:26 +0000920class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000921 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000922 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000923 let OutOperandList = oops;
924 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +0000925 let AsmString = asm;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000926 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000927 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng09c39fc2009-06-23 19:38:13 +0000928}
929
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000930class T1I<dag oops, dag iops, InstrItinClass itin,
931 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000932 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000933class T1Ix2<dag oops, dag iops, InstrItinClass itin,
934 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000935 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000936
937// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000938class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000939 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000940 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson815baeb2010-03-13 01:08:20 +0000941 asm, cstr, pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000942
943// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson16884412011-07-13 23:22:26 +0000944class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000945 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000946 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000947 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerb7d52262010-03-18 21:06:54 +0000948 let OutOperandList = !con(oops, (outs s_cc_out:$s));
949 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000950 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000951 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000952 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000953}
954
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000955class T1sI<dag oops, dag iops, InstrItinClass itin,
956 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000957 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000958
959// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000960class T1sIt<dag oops, dag iops, InstrItinClass itin,
961 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000962 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling3f8c1102010-11-30 23:54:45 +0000963 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000964
965// Thumb1 instruction that can be predicated.
Owen Anderson16884412011-07-13 23:22:26 +0000966class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000967 InstrItinClass itin,
Evan Cheng446c4282009-07-11 06:43:01 +0000968 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chend68e1192009-12-15 17:24:14 +0000969 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng446c4282009-07-11 06:43:01 +0000970 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +0000971 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +0000972 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng446c4282009-07-11 06:43:01 +0000973 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +0000974 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Cheng446c4282009-07-11 06:43:01 +0000975}
976
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000977class T1pI<dag oops, dag iops, InstrItinClass itin,
978 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000979 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000980
981// Two-address instructions
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000982class T1pIt<dag oops, dag iops, InstrItinClass itin,
983 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000984 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling0b424dc2010-12-01 01:32:02 +0000985 "$Rn = $Rdn", pattern>;
Evan Cheng446c4282009-07-11 06:43:01 +0000986
Bob Wilson01135592010-03-23 17:23:59 +0000987class T1pIs<dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +0000988 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +0000989 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000990
Johnny Chenbbc71b22009-12-16 02:32:54 +0000991class Encoding16 : Encoding {
992 let Inst{31-16} = 0x0000;
993}
994
Johnny Chend68e1192009-12-15 17:24:14 +0000995// A6.2 16-bit Thumb instruction encoding
Johnny Chenbbc71b22009-12-16 02:32:54 +0000996class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +0000997 let Inst{15-10} = opcode;
998}
999
1000// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001001class T1General<bits<5> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001002 let Inst{15-14} = 0b00;
1003 let Inst{13-9} = opcode;
1004}
1005
1006// A6.2.2 Data-processing encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001007class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001008 let Inst{15-10} = 0b010000;
1009 let Inst{9-6} = opcode;
1010}
1011
1012// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001013class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001014 let Inst{15-10} = 0b010001;
Bill Wendling6bc105a2010-11-17 00:45:23 +00001015 let Inst{9-6} = opcode;
Johnny Chend68e1192009-12-15 17:24:14 +00001016}
1017
1018// A6.2.4 Load/store single data item encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001019class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001020 let Inst{15-12} = opA;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001021 let Inst{11-9} = opB;
Johnny Chend68e1192009-12-15 17:24:14 +00001022}
Bill Wendlingda2ae632010-08-31 07:50:46 +00001023class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chend68e1192009-12-15 17:24:14 +00001024
Eric Christopher33281b22011-05-27 03:50:53 +00001025class T1BranchCond<bits<4> opcode> : Encoding16 {
1026 let Inst{15-12} = opcode;
1027}
1028
Bill Wendling1fd374e2010-11-30 22:57:21 +00001029// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling3f8c1102010-11-30 23:54:45 +00001030// following bits are used for "opA" (see A6.2.4):
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001031//
Bill Wendling1fd374e2010-11-30 22:57:21 +00001032// 0b0110 => Immediate, 4 bytes
1033// 0b1000 => Immediate, 2 bytes
1034// 0b0111 => Immediate, 1 byte
Bill Wendling40062fb2010-12-01 01:38:08 +00001035class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1036 InstrItinClass itin, string opc, string asm,
1037 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001038 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001039 T1LoadStore<0b0101, opcode> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001040 bits<3> Rt;
1041 bits<8> addr;
1042 let Inst{8-6} = addr{5-3}; // Rm
1043 let Inst{5-3} = addr{2-0}; // Rn
1044 let Inst{2-0} = Rt;
1045}
Bill Wendling40062fb2010-12-01 01:38:08 +00001046class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1047 InstrItinClass itin, string opc, string asm,
1048 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001049 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling2cbc9fe2010-11-30 23:16:25 +00001050 T1LoadStore<opA, {opB,?,?}> {
Bill Wendling1fd374e2010-11-30 22:57:21 +00001051 bits<3> Rt;
1052 bits<8> addr;
1053 let Inst{10-6} = addr{7-3}; // imm5
1054 let Inst{5-3} = addr{2-0}; // Rn
1055 let Inst{2-0} = Rt;
1056}
1057
Johnny Chend68e1192009-12-15 17:24:14 +00001058// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chenbbc71b22009-12-16 02:32:54 +00001059class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chend68e1192009-12-15 17:24:14 +00001060 let Inst{15-12} = 0b1011;
1061 let Inst{11-5} = opcode;
1062}
1063
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001064// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson16884412011-07-13 23:22:26 +00001065class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001066 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001067 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001068 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001069 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001070 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001071 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001072 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001073 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001074}
1075
Bill Wendlingda2ae632010-08-31 07:50:46 +00001076// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1077// input operand since by default it's a zero register. It will become an
1078// implicit def once it's "flipped".
Jim Grosbach3a378662010-10-13 23:12:26 +00001079//
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001080// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1081// more consistent.
Owen Anderson16884412011-07-13 23:22:26 +00001082class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001083 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001084 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001085 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersonbdf71442010-12-07 20:50:15 +00001086 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1087 let Inst{20} = s;
1088
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001089 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001090 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner78caacc2010-10-06 00:05:18 +00001091 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001092 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001093 list<Predicate> Predicates = [IsThumb2];
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001094}
1095
1096// Special cases
Owen Anderson16884412011-07-13 23:22:26 +00001097class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001098 InstrItinClass itin,
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001099 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001100 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001101 let OutOperandList = oops;
1102 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001103 let AsmString = asm;
Evan Chengf49810c2009-06-23 17:48:47 +00001104 let Pattern = pattern;
Evan Chengd770d9e2009-07-02 06:38:40 +00001105 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001106}
1107
Owen Anderson16884412011-07-13 23:22:26 +00001108class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson01135592010-03-23 17:23:59 +00001109 InstrItinClass itin,
1110 string asm, string cstr, list<dag> pattern>
Jim Grosbachd1228742009-12-01 18:10:36 +00001111 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1112 let OutOperandList = oops;
1113 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001114 let AsmString = asm;
Jim Grosbachd1228742009-12-01 18:10:36 +00001115 let Pattern = pattern;
Jim Grosbach6797f892010-11-01 17:08:58 +00001116 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Jim Grosbachd1228742009-12-01 18:10:36 +00001117}
1118
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001119class T2I<dag oops, dag iops, InstrItinClass itin,
1120 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001121 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001122class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1123 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001124 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001125class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1126 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001127 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001128class T2Iso<dag oops, dag iops, InstrItinClass itin,
1129 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001130 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001131class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1132 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001133 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001134class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001135 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001136 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, "",
Johnny Chend68e1192009-12-15 17:24:14 +00001137 pattern> {
Owen Anderson9d63d902010-12-01 19:18:46 +00001138 bits<4> Rt;
1139 bits<4> Rt2;
1140 bits<13> addr;
Jim Grosbach04da9bf2010-12-10 20:51:35 +00001141 let Inst{31-25} = 0b1110100;
1142 let Inst{24} = P;
1143 let Inst{23} = addr{8};
1144 let Inst{22} = 1;
1145 let Inst{21} = W;
1146 let Inst{20} = isLoad;
1147 let Inst{19-16} = addr{12-9};
Owen Anderson9d63d902010-12-01 19:18:46 +00001148 let Inst{15-12} = Rt{3-0};
1149 let Inst{11-8} = Rt2{3-0};
Owen Anderson9d63d902010-12-01 19:18:46 +00001150 let Inst{7-0} = addr{7-0};
Johnny Chend68e1192009-12-15 17:24:14 +00001151}
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001152
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001153class T2sI<dag oops, dag iops, InstrItinClass itin,
1154 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001155 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Cheng0aa1d8c2009-06-25 02:08:06 +00001156
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001157class T2XI<dag oops, dag iops, InstrItinClass itin,
1158 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001159 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001160class T2JTI<dag oops, dag iops, InstrItinClass itin,
1161 string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001162 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengf49810c2009-06-23 17:48:47 +00001163
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001164// Move to/from coprocessor instructions
Jim Grosbach0d8dae22011-07-13 21:17:59 +00001165class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbach9bb098a2011-07-13 21:14:23 +00001166 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbach0d8dae22011-07-13 21:17:59 +00001167 let Inst{31-28} = opc;
Bruno Cardoso Lopes6b3a9992011-01-20 16:58:48 +00001168}
1169
Bob Wilson815baeb2010-03-13 01:08:20 +00001170// Two-address instructions
1171class T2XIt<dag oops, dag iops, InstrItinClass itin,
1172 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001173 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng5adb66a2009-09-28 09:14:39 +00001174
Evan Chenge88d5ce2009-07-02 07:28:31 +00001175// T2Iidxldst - Thumb2 indexed load / store instructions.
Johnny Chend68e1192009-12-15 17:24:14 +00001176class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1177 dag oops, dag iops,
1178 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Chenge88d5ce2009-07-02 07:28:31 +00001179 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001180 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chenge88d5ce2009-07-02 07:28:31 +00001181 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001182 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001183 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chenge88d5ce2009-07-02 07:28:31 +00001184 let Pattern = pattern;
1185 list<Predicate> Predicates = [IsThumb2];
Johnny Chend68e1192009-12-15 17:24:14 +00001186 let Inst{31-27} = 0b11111;
1187 let Inst{26-25} = 0b00;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001188 let Inst{24} = signed;
1189 let Inst{23} = 0;
Johnny Chend68e1192009-12-15 17:24:14 +00001190 let Inst{22-21} = opcod;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001191 let Inst{20} = load;
1192 let Inst{11} = 1;
Johnny Chend68e1192009-12-15 17:24:14 +00001193 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingda2ae632010-08-31 07:50:46 +00001194 let Inst{10} = pre; // The P bit.
1195 let Inst{8} = 1; // The W bit.
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001196
Owen Anderson6af50f72010-11-30 00:14:31 +00001197 bits<9> addr;
1198 let Inst{7-0} = addr{7-0};
Jim Grosbacha79bd0e2010-12-10 20:47:29 +00001199 let Inst{9} = addr{8}; // Sign bit
1200
Owen Anderson6af50f72010-11-30 00:14:31 +00001201 bits<4> Rt;
1202 bits<4> Rn;
1203 let Inst{15-12} = Rt{3-0};
1204 let Inst{19-16} = Rn{3-0};
Evan Chenge88d5ce2009-07-02 07:28:31 +00001205}
1206
David Goodwinc9d138f2009-07-27 19:59:26 +00001207// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1208class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001209 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwinc9d138f2009-07-27 19:59:26 +00001210}
1211
1212// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1213class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbach6797f892010-11-01 17:08:58 +00001214 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwinc9d138f2009-07-27 19:59:26 +00001215}
Evan Chenge88d5ce2009-07-02 07:28:31 +00001216
Bruno Cardoso Lopes54ad87a2011-05-03 17:29:22 +00001217// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1218class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1219 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1220}
1221
Evan Cheng9cb9e672009-06-27 02:26:13 +00001222// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1223class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Chengd770d9e2009-07-02 06:38:40 +00001224 list<Predicate> Predicates = [IsThumb2];
Evan Chengf49810c2009-06-23 17:48:47 +00001225}
1226
Evan Cheng13096642008-08-29 06:41:12 +00001227//===----------------------------------------------------------------------===//
1228
Evan Cheng96581d32008-11-11 02:11:05 +00001229//===----------------------------------------------------------------------===//
1230// ARM VFP Instruction templates.
1231//
1232
David Goodwin3ca524e2009-07-10 17:03:29 +00001233// Almost all VFP instructions are predicable.
Owen Anderson16884412011-07-13 23:22:26 +00001234class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001235 IndexMode im, Format f, InstrItinClass itin,
1236 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001237 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach499e8862010-10-12 21:22:40 +00001238 bits<4> p;
1239 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001240 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001241 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001242 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin3ca524e2009-07-10 17:03:29 +00001243 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001244 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001245 list<Predicate> Predicates = [HasVFP2];
1246}
1247
1248// Special cases
Owen Anderson16884412011-07-13 23:22:26 +00001249class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001250 IndexMode im, Format f, InstrItinClass itin,
1251 string asm, string cstr, list<dag> pattern>
Anton Korobeynikovf95215f2009-11-02 00:10:38 +00001252 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001253 bits<4> p;
1254 let Inst{31-28} = p;
David Goodwin3ca524e2009-07-10 17:03:29 +00001255 let OutOperandList = oops;
1256 let InOperandList = iops;
Bob Wilsond3038462010-05-24 20:08:34 +00001257 let AsmString = asm;
David Goodwin3ca524e2009-07-10 17:03:29 +00001258 let Pattern = pattern;
Bill Wendlingcf590262010-12-01 21:54:50 +00001259 let PostEncoderMethod = "VFPThumb2PostEncoder";
David Goodwin3ca524e2009-07-10 17:03:29 +00001260 list<Predicate> Predicates = [HasVFP2];
1261}
1262
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001263class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1264 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001265 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendlingcf590262010-12-01 21:54:50 +00001266 opc, asm, "", pattern> {
1267 let PostEncoderMethod = "VFPThumb2PostEncoder";
1268}
David Goodwin3ca524e2009-07-10 17:03:29 +00001269
Evan Chengcd8e66a2008-11-11 21:48:44 +00001270// ARM VFP addrmode5 loads and stores
1271class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001272 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001273 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001274 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001275 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001276 // Instruction operands.
1277 bits<5> Dd;
1278 bits<13> addr;
1279
1280 // Encode instruction operands.
1281 let Inst{23} = addr{8}; // U (add = (U == '1'))
1282 let Inst{22} = Dd{4};
1283 let Inst{19-16} = addr{12-9}; // Rn
1284 let Inst{15-12} = Dd{3-0};
1285 let Inst{7-0} = addr{7-0}; // imm8
1286
Evan Cheng96581d32008-11-11 02:11:05 +00001287 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001288 let Inst{27-24} = opcod1;
1289 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001290 let Inst{11-9} = 0b101;
1291 let Inst{8} = 1; // Double precision
Anton Korobeynikov2e1da9f2009-11-02 00:11:06 +00001292
Evan Cheng5eda2822011-02-16 00:35:02 +00001293 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenfddb7662010-04-05 03:10:20 +00001294 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001295}
1296
Evan Chengcd8e66a2008-11-11 21:48:44 +00001297class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001298 InstrItinClass itin,
Evan Chengcd8e66a2008-11-11 21:48:44 +00001299 string opc, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001300 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson01135592010-03-23 17:23:59 +00001301 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendling2f46f1f2010-11-04 00:59:42 +00001302 // Instruction operands.
1303 bits<5> Sd;
1304 bits<13> addr;
1305
1306 // Encode instruction operands.
1307 let Inst{23} = addr{8}; // U (add = (U == '1'))
1308 let Inst{22} = Sd{0};
1309 let Inst{19-16} = addr{12-9}; // Rn
1310 let Inst{15-12} = Sd{4-1};
1311 let Inst{7-0} = addr{7-0}; // imm8
1312
Evan Cheng96581d32008-11-11 02:11:05 +00001313 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Chengcd8e66a2008-11-11 21:48:44 +00001314 let Inst{27-24} = opcod1;
1315 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001316 let Inst{11-9} = 0b101;
1317 let Inst{8} = 0; // Single precision
Evan Cheng5eda2822011-02-16 00:35:02 +00001318
1319 // Loads & stores operate on both NEON and VFP pipelines.
1320 let D = VFPNeonDomain;
Evan Cheng96581d32008-11-11 02:11:05 +00001321}
1322
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001323// VFP Load / store multiple pseudo instructions.
1324class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1325 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001326 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson9d4ebc02010-09-16 00:31:02 +00001327 cstr, itin> {
1328 let OutOperandList = oops;
1329 let InOperandList = !con(iops, (ins pred:$p));
1330 let Pattern = pattern;
1331 list<Predicate> Predicates = [HasVFP2];
1332}
1333
Evan Chengcd8e66a2008-11-11 21:48:44 +00001334// Load / store multiple
Jim Grosbach72db1822010-09-08 00:25:50 +00001335class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001336 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001337 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson01135592010-03-23 17:23:59 +00001338 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001339 // Instruction operands.
1340 bits<4> Rn;
1341 bits<13> regs;
1342
1343 // Encode instruction operands.
1344 let Inst{19-16} = Rn;
1345 let Inst{22} = regs{12};
1346 let Inst{15-12} = regs{11-8};
1347 let Inst{7-0} = regs{7-0};
1348
Evan Chengcd8e66a2008-11-11 21:48:44 +00001349 // TODO: Mark the instructions with the appropriate subtarget info.
1350 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001351 let Inst{11-9} = 0b101;
1352 let Inst{8} = 1; // Double precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001353}
1354
Jim Grosbach72db1822010-09-08 00:25:50 +00001355class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson815baeb2010-03-13 01:08:20 +00001356 string asm, string cstr, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001357 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson01135592010-03-23 17:23:59 +00001358 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling6bc105a2010-11-17 00:45:23 +00001359 // Instruction operands.
1360 bits<4> Rn;
1361 bits<13> regs;
1362
1363 // Encode instruction operands.
1364 let Inst{19-16} = Rn;
1365 let Inst{22} = regs{8};
1366 let Inst{15-12} = regs{12-9};
1367 let Inst{7-0} = regs{7-0};
1368
Evan Chengcd8e66a2008-11-11 21:48:44 +00001369 // TODO: Mark the instructions with the appropriate subtarget info.
1370 let Inst{27-25} = 0b110;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001371 let Inst{11-9} = 0b101;
1372 let Inst{8} = 0; // Single precision
Evan Chengcd8e66a2008-11-11 21:48:44 +00001373}
1374
Evan Cheng96581d32008-11-11 02:11:05 +00001375// Double precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001376class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1377 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1378 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001379 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001380 // Instruction operands.
1381 bits<5> Dd;
1382 bits<5> Dm;
1383
1384 // Encode instruction operands.
1385 let Inst{3-0} = Dm{3-0};
1386 let Inst{5} = Dm{4};
1387 let Inst{15-12} = Dd{3-0};
1388 let Inst{22} = Dd{4};
1389
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001390 let Inst{27-23} = opcod1;
1391 let Inst{21-20} = opcod2;
1392 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001393 let Inst{11-9} = 0b101;
1394 let Inst{8} = 1; // Double precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001395 let Inst{7-6} = opcod4;
1396 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001397}
1398
1399// Double precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001400class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001401 dag iops, InstrItinClass itin, string opc, string asm,
1402 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001403 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001404 // Instruction operands.
1405 bits<5> Dd;
1406 bits<5> Dn;
1407 bits<5> Dm;
1408
1409 // Encode instruction operands.
1410 let Inst{3-0} = Dm{3-0};
1411 let Inst{5} = Dm{4};
1412 let Inst{19-16} = Dn{3-0};
1413 let Inst{7} = Dn{4};
1414 let Inst{15-12} = Dd{3-0};
1415 let Inst{22} = Dd{4};
1416
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001417 let Inst{27-23} = opcod1;
1418 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001419 let Inst{11-9} = 0b101;
1420 let Inst{8} = 1; // Double precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001421 let Inst{6} = op6;
1422 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001423}
1424
1425// Single precision, unary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001426class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1427 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1428 string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001429 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001430 // Instruction operands.
1431 bits<5> Sd;
1432 bits<5> Sm;
1433
1434 // Encode instruction operands.
1435 let Inst{3-0} = Sm{4-1};
1436 let Inst{5} = Sm{0};
1437 let Inst{15-12} = Sd{4-1};
1438 let Inst{22} = Sd{0};
1439
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001440 let Inst{27-23} = opcod1;
1441 let Inst{21-20} = opcod2;
1442 let Inst{19-16} = opcod3;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001443 let Inst{11-9} = 0b101;
1444 let Inst{8} = 0; // Single precision
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001445 let Inst{7-6} = opcod4;
1446 let Inst{4} = opcod5;
Evan Cheng96581d32008-11-11 02:11:05 +00001447}
1448
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001449// Single precision unary, if no NEON. Same as ASuI except not available if
1450// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001451class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1452 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1453 string asm, list<dag> pattern>
1454 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1455 pattern> {
David Goodwin53e44712009-08-04 20:39:05 +00001456 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1457}
1458
Evan Cheng96581d32008-11-11 02:11:05 +00001459// Single precision, binary
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001460class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1461 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001462 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling69661192010-11-01 06:00:39 +00001463 // Instruction operands.
1464 bits<5> Sd;
1465 bits<5> Sn;
1466 bits<5> Sm;
1467
1468 // Encode instruction operands.
1469 let Inst{3-0} = Sm{4-1};
1470 let Inst{5} = Sm{0};
1471 let Inst{19-16} = Sn{4-1};
1472 let Inst{7} = Sn{0};
1473 let Inst{15-12} = Sd{4-1};
1474 let Inst{22} = Sd{0};
1475
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001476 let Inst{27-23} = opcod1;
1477 let Inst{21-20} = opcod2;
Bill Wendlinga0c14ef2010-10-12 22:03:19 +00001478 let Inst{11-9} = 0b101;
1479 let Inst{8} = 0; // Single precision
Bill Wendlingda2ae632010-08-31 07:50:46 +00001480 let Inst{6} = op6;
1481 let Inst{4} = op4;
Evan Cheng96581d32008-11-11 02:11:05 +00001482}
1483
Bill Wendling43f7b2d2010-12-01 02:42:55 +00001484// Single precision binary, if no NEON. Same as ASbI except not available if
1485// NEON is enabled.
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001486class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson01135592010-03-23 17:23:59 +00001487 dag iops, InstrItinClass itin, string opc, string asm,
1488 list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001489 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin42a83f22009-08-04 17:53:06 +00001490 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling69661192010-11-01 06:00:39 +00001491
1492 // Instruction operands.
1493 bits<5> Sd;
1494 bits<5> Sn;
1495 bits<5> Sm;
1496
1497 // Encode instruction operands.
1498 let Inst{3-0} = Sm{4-1};
1499 let Inst{5} = Sm{0};
1500 let Inst{19-16} = Sn{4-1};
1501 let Inst{7} = Sn{0};
1502 let Inst{15-12} = Sd{4-1};
1503 let Inst{22} = Sd{0};
David Goodwin42a83f22009-08-04 17:53:06 +00001504}
1505
Evan Cheng80a11982008-11-12 06:41:41 +00001506// VFP conversion instructions
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001507class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1508 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1509 list<dag> pattern>
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001510 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001511 let Inst{27-23} = opcod1;
1512 let Inst{21-20} = opcod2;
1513 let Inst{19-16} = opcod3;
1514 let Inst{11-8} = opcod4;
Evan Cheng80a11982008-11-12 06:41:41 +00001515 let Inst{6} = 1;
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001516 let Inst{4} = 0;
Evan Cheng80a11982008-11-12 06:41:41 +00001517}
1518
Johnny Chen811663f2010-02-11 18:47:03 +00001519// VFP conversion between floating-point and fixed-point
1520class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson01135592010-03-23 17:23:59 +00001521 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1522 list<dag> pattern>
Johnny Chen811663f2010-02-11 18:47:03 +00001523 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1524 // size (fixed-point number): sx == 0 ? 16 : 32
1525 let Inst{7} = op5; // sx
1526}
1527
David Goodwin338268c2009-08-10 22:17:39 +00001528// VFP conversion instructions, if no NEON
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001529class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin338268c2009-08-10 22:17:39 +00001530 dag oops, dag iops, InstrItinClass itin,
1531 string opc, string asm, list<dag> pattern>
Johnny Chen69a8c7f2010-01-29 23:21:10 +00001532 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1533 pattern> {
David Goodwin338268c2009-08-10 22:17:39 +00001534 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1535}
1536
Evan Cheng80a11982008-11-12 06:41:41 +00001537class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001538 InstrItinClass itin,
1539 string opc, string asm, list<dag> pattern>
1540 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng80a11982008-11-12 06:41:41 +00001541 let Inst{27-20} = opcod1;
Evan Cheng78be83d2008-11-11 19:40:26 +00001542 let Inst{11-8} = opcod2;
1543 let Inst{4} = 1;
1544}
1545
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001546class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1547 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1548 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng0a0ab132008-11-11 22:46:12 +00001549
Bob Wilson01135592010-03-23 17:23:59 +00001550class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001551 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1552 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001553
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001554class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1555 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1556 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng80a11982008-11-12 06:41:41 +00001557
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001558class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1559 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1560 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng78be83d2008-11-11 19:40:26 +00001561
Evan Cheng96581d32008-11-11 02:11:05 +00001562//===----------------------------------------------------------------------===//
1563
Bob Wilson5bafff32009-06-22 23:27:02 +00001564//===----------------------------------------------------------------------===//
1565// ARM NEON Instruction templates.
1566//
Evan Cheng13096642008-08-29 06:41:12 +00001567
Johnny Chencaa608e2010-03-20 00:17:00 +00001568class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1569 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1570 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001571 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Chengf81bf152009-11-23 21:57:23 +00001572 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001573 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001574 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001575 let Pattern = pattern;
1576 list<Predicate> Predicates = [HasNEON];
1577}
1578
1579// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen927b88f2010-03-23 20:40:44 +00001580class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1581 InstrItinClass itin, string opc, string asm, string cstr,
1582 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001583 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001584 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001585 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001586 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson5bafff32009-06-22 23:27:02 +00001587 let Pattern = pattern;
1588 list<Predicate> Predicates = [HasNEON];
Evan Cheng13096642008-08-29 06:41:12 +00001589}
1590
Bob Wilsonb07c1712009-10-07 21:53:04 +00001591class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1592 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001593 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chencaa608e2010-03-20 00:17:00 +00001594 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1595 cstr, pattern> {
Bob Wilson205a5ca2009-07-08 18:11:30 +00001596 let Inst{31-24} = 0b11110100;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001597 let Inst{23} = op23;
Jim Grosbach780d2072009-10-20 00:19:08 +00001598 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001599 let Inst{11-8} = op11_8;
1600 let Inst{7-4} = op7_4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001601
Chris Lattner2ac19022010-11-15 05:19:05 +00001602 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001603
Owen Andersond9aa7d32010-11-02 00:05:05 +00001604 bits<5> Vd;
Owen Andersonf431eda2010-11-02 23:47:29 +00001605 bits<6> Rn;
1606 bits<4> Rm;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001607
Owen Andersond9aa7d32010-11-02 00:05:05 +00001608 let Inst{22} = Vd{4};
1609 let Inst{15-12} = Vd{3-0};
Owen Andersonf431eda2010-11-02 23:47:29 +00001610 let Inst{19-16} = Rn{3-0};
1611 let Inst{3-0} = Rm{3-0};
Bob Wilson205a5ca2009-07-08 18:11:30 +00001612}
1613
Owen Andersond138d702010-11-02 20:47:39 +00001614class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1615 dag oops, dag iops, InstrItinClass itin,
1616 string opc, string dt, string asm, string cstr, list<dag> pattern>
1617 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1618 dt, asm, cstr, pattern> {
1619 bits<3> lane;
1620}
1621
Bob Wilson709d5922010-08-25 23:27:42 +00001622class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson16884412011-07-13 23:22:26 +00001623 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson709d5922010-08-25 23:27:42 +00001624 itin> {
1625 let OutOperandList = oops;
1626 let InOperandList = !con(iops, (ins pred:$p));
1627 list<Predicate> Predicates = [HasNEON];
1628}
1629
Jim Grosbach7cd27292010-10-06 20:36:55 +00001630class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1631 list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001632 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonbd916c52010-09-13 23:55:10 +00001633 itin> {
1634 let OutOperandList = oops;
1635 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach7cd27292010-10-06 20:36:55 +00001636 let Pattern = pattern;
Bob Wilsonbd916c52010-09-13 23:55:10 +00001637 list<Predicate> Predicates = [HasNEON];
1638}
1639
Johnny Chen785516a2010-03-23 16:43:47 +00001640class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001641 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen785516a2010-03-23 16:43:47 +00001642 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1643 pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001644 let Inst{31-25} = 0b1111001;
Chris Lattner2ac19022010-11-15 05:19:05 +00001645 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Evan Chengf81bf152009-11-23 21:57:23 +00001646}
1647
Johnny Chen927b88f2010-03-23 20:40:44 +00001648class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001649 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen927b88f2010-03-23 20:40:44 +00001650 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson01135592010-03-23 17:23:59 +00001651 cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001652 let Inst{31-25} = 0b1111001;
Owen Andersonac00e962010-12-10 22:32:08 +00001653 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Bob Wilson5bafff32009-06-22 23:27:02 +00001654}
1655
1656// NEON "one register and a modified immediate" format.
1657class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1658 bit op5, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001659 dag oops, dag iops, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001660 string opc, string dt, string asm, string cstr,
1661 list<dag> pattern>
Johnny Chena2711742010-03-23 23:09:14 +00001662 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001663 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001664 let Inst{21-19} = op21_19;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001665 let Inst{11-8} = op11_8;
1666 let Inst{7} = op7;
1667 let Inst{6} = op6;
1668 let Inst{5} = op5;
1669 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001670
Owen Andersona88ea032010-10-26 17:40:54 +00001671 // Instruction operands.
1672 bits<5> Vd;
1673 bits<13> SIMM;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001674
Owen Andersona88ea032010-10-26 17:40:54 +00001675 let Inst{15-12} = Vd{3-0};
1676 let Inst{22} = Vd{4};
1677 let Inst{24} = SIMM{7};
1678 let Inst{18-16} = SIMM{6-4};
1679 let Inst{3-0} = SIMM{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001680}
1681
1682// NEON 2 vector register format.
1683class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1684 bits<5> op11_7, bit op6, bit op4,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001685 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001686 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001687 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Chengf81bf152009-11-23 21:57:23 +00001688 let Inst{24-23} = op24_23;
1689 let Inst{21-20} = op21_20;
1690 let Inst{19-18} = op19_18;
1691 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001692 let Inst{11-7} = op11_7;
1693 let Inst{6} = op6;
1694 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001695
Owen Anderson162875a2010-10-25 18:43:52 +00001696 // Instruction operands.
1697 bits<5> Vd;
1698 bits<5> Vm;
1699
1700 let Inst{15-12} = Vd{3-0};
1701 let Inst{22} = Vd{4};
1702 let Inst{3-0} = Vm{3-0};
1703 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001704}
1705
1706// Same as N2V except it doesn't have a datatype suffix.
1707class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson01135592010-03-23 17:23:59 +00001708 bits<5> op11_7, bit op6, bit op4,
1709 dag oops, dag iops, InstrItinClass itin,
1710 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc5f413a2010-03-24 00:57:50 +00001711 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001712 let Inst{24-23} = op24_23;
1713 let Inst{21-20} = op21_20;
1714 let Inst{19-18} = op19_18;
1715 let Inst{17-16} = op17_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001716 let Inst{11-7} = op11_7;
1717 let Inst{6} = op6;
1718 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001719
Owen Anderson162875a2010-10-25 18:43:52 +00001720 // Instruction operands.
1721 bits<5> Vd;
1722 bits<5> Vm;
1723
1724 let Inst{15-12} = Vd{3-0};
1725 let Inst{22} = Vd{4};
1726 let Inst{3-0} = Vm{3-0};
1727 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001728}
1729
1730// NEON 2 vector register with immediate.
Bob Wilson507df402009-10-21 02:15:46 +00001731class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chenfa80bec2010-03-25 20:39:04 +00001732 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001733 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenfa80bec2010-03-25 20:39:04 +00001734 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001735 let Inst{24} = op24;
1736 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001737 let Inst{11-8} = op11_8;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001738 let Inst{7} = op7;
1739 let Inst{6} = op6;
1740 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001741
Owen Anderson3557d002010-10-26 20:56:57 +00001742 // Instruction operands.
1743 bits<5> Vd;
1744 bits<5> Vm;
1745 bits<6> SIMM;
1746
1747 let Inst{15-12} = Vd{3-0};
1748 let Inst{22} = Vd{4};
1749 let Inst{3-0} = Vm{3-0};
1750 let Inst{5} = Vm{4};
1751 let Inst{21-16} = SIMM{5-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001752}
1753
Bob Wilson10bc69c2010-03-27 03:56:52 +00001754// NEON 3 vector register format.
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001755
Jim Grosbach6635b042011-05-19 17:34:53 +00001756class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1757 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1758 string opc, string dt, string asm, string cstr,
1759 list<dag> pattern>
Johnny Chenc6e704d2010-03-26 21:26:28 +00001760 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001761 let Inst{24} = op24;
1762 let Inst{23} = op23;
Evan Chengf81bf152009-11-23 21:57:23 +00001763 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001764 let Inst{11-8} = op11_8;
1765 let Inst{6} = op6;
1766 let Inst{4} = op4;
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001767}
1768
1769class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1770 dag oops, dag iops, Format f, InstrItinClass itin,
1771 string opc, string dt, string asm, string cstr, list<dag> pattern>
1772 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1773 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001774
Owen Andersond451f882010-10-21 20:21:49 +00001775 // Instruction operands.
1776 bits<5> Vd;
1777 bits<5> Vn;
1778 bits<5> Vm;
1779
1780 let Inst{15-12} = Vd{3-0};
1781 let Inst{22} = Vd{4};
1782 let Inst{19-16} = Vn{3-0};
1783 let Inst{7} = Vn{4};
1784 let Inst{3-0} = Vm{3-0};
1785 let Inst{5} = Vm{4};
Evan Chengf81bf152009-11-23 21:57:23 +00001786}
1787
Jim Grosbach6635b042011-05-19 17:34:53 +00001788class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1789 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1790 string opc, string dt, string asm, string cstr,
1791 list<dag> pattern>
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001792 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1793 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1794
1795 // Instruction operands.
1796 bits<5> Vd;
1797 bits<5> Vn;
1798 bits<5> Vm;
1799 bit lane;
1800
1801 let Inst{15-12} = Vd{3-0};
1802 let Inst{22} = Vd{4};
1803 let Inst{19-16} = Vn{3-0};
1804 let Inst{7} = Vn{4};
1805 let Inst{3-0} = Vm{3-0};
1806 let Inst{5} = lane;
1807}
1808
Jim Grosbach6635b042011-05-19 17:34:53 +00001809class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1810 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1811 string opc, string dt, string asm, string cstr,
1812 list<dag> pattern>
Owen Anderson6a7d36a2011-03-30 23:45:29 +00001813 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1814 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1815
1816 // Instruction operands.
1817 bits<5> Vd;
1818 bits<5> Vn;
1819 bits<5> Vm;
1820 bits<2> lane;
1821
1822 let Inst{15-12} = Vd{3-0};
1823 let Inst{22} = Vd{4};
1824 let Inst{19-16} = Vn{3-0};
1825 let Inst{7} = Vn{4};
1826 let Inst{2-0} = Vm{2-0};
1827 let Inst{5} = lane{1};
1828 let Inst{3} = lane{0};
1829}
1830
Johnny Chen841e8282010-03-23 21:35:03 +00001831// Same as N3V except it doesn't have a data type suffix.
Bob Wilson01135592010-03-23 17:23:59 +00001832class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1833 bit op4,
Bob Wilson10bc69c2010-03-27 03:56:52 +00001834 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson01135592010-03-23 17:23:59 +00001835 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilson10bc69c2010-03-27 03:56:52 +00001836 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingda2ae632010-08-31 07:50:46 +00001837 let Inst{24} = op24;
1838 let Inst{23} = op23;
Bob Wilson5bafff32009-06-22 23:27:02 +00001839 let Inst{21-20} = op21_20;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001840 let Inst{11-8} = op11_8;
1841 let Inst{6} = op6;
1842 let Inst{4} = op4;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001843
Owen Anderson8c71eff2010-10-25 18:28:30 +00001844 // Instruction operands.
1845 bits<5> Vd;
1846 bits<5> Vn;
1847 bits<5> Vm;
1848
1849 let Inst{15-12} = Vd{3-0};
1850 let Inst{22} = Vd{4};
1851 let Inst{19-16} = Vn{3-0};
1852 let Inst{7} = Vn{4};
1853 let Inst{3-0} = Vm{3-0};
1854 let Inst{5} = Vm{4};
Bob Wilson5bafff32009-06-22 23:27:02 +00001855}
1856
1857// NEON VMOVs between scalar and core registers.
1858class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001859 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001860 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson16884412011-07-13 23:22:26 +00001861 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson01135592010-03-23 17:23:59 +00001862 "", itin> {
Bob Wilson5bafff32009-06-22 23:27:02 +00001863 let Inst{27-20} = opcod1;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001864 let Inst{11-8} = opcod2;
1865 let Inst{6-5} = opcod3;
1866 let Inst{4} = 1;
Johnny Chena9611542011-04-06 18:27:46 +00001867 // A8.6.303, A8.6.328, A8.6.329
1868 let Inst{3-0} = 0b0000;
Evan Chengf81bf152009-11-23 21:57:23 +00001869
1870 let OutOperandList = oops;
Chris Lattnerb7d52262010-03-18 21:06:54 +00001871 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner78caacc2010-10-06 00:05:18 +00001872 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Chengf81bf152009-11-23 21:57:23 +00001873 let Pattern = pattern;
Bob Wilson5bafff32009-06-22 23:27:02 +00001874 list<Predicate> Predicates = [HasNEON];
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001875
Chris Lattner2ac19022010-11-15 05:19:05 +00001876 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001877
Owen Andersond2fbdb72010-10-27 21:28:09 +00001878 bits<5> V;
1879 bits<4> R;
Owen Andersonf587a9352010-10-27 19:25:54 +00001880 bits<4> p;
Owen Andersond2fbdb72010-10-27 21:28:09 +00001881 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001882
Owen Andersonf587a9352010-10-27 19:25:54 +00001883 let Inst{31-28} = p{3-0};
Owen Andersond2fbdb72010-10-27 21:28:09 +00001884 let Inst{7} = V{4};
1885 let Inst{19-16} = V{3-0};
1886 let Inst{15-12} = R{3-0};
Bob Wilson5bafff32009-06-22 23:27:02 +00001887}
1888class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001889 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001890 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001891 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001892 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001893class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001894 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001895 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001896 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001897 opc, dt, asm, pattern>;
Bob Wilson5bafff32009-06-22 23:27:02 +00001898class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwin8b7d7ad2009-08-06 16:52:47 +00001899 dag oops, dag iops, InstrItinClass itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001900 string opc, string dt, string asm, list<dag> pattern>
Bob Wilson184723d2010-06-25 23:56:05 +00001901 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Chengf81bf152009-11-23 21:57:23 +00001902 opc, dt, asm, pattern>;
David Goodwin42a83f22009-08-04 17:53:06 +00001903
Johnny Chene4614f72010-03-25 17:01:27 +00001904// Vector Duplicate Lane (from scalar to all elements)
1905class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1906 InstrItinClass itin, string opc, string dt, string asm,
1907 list<dag> pattern>
Johnny Chen2d2898e2010-03-25 21:49:12 +00001908 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chene4614f72010-03-25 17:01:27 +00001909 let Inst{24-23} = 0b11;
1910 let Inst{21-20} = 0b11;
1911 let Inst{19-16} = op19_16;
Bill Wendlingda2ae632010-08-31 07:50:46 +00001912 let Inst{11-7} = 0b11000;
1913 let Inst{6} = op6;
1914 let Inst{4} = 0;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001915
Owen Andersonf587a9352010-10-27 19:25:54 +00001916 bits<5> Vd;
1917 bits<5> Vm;
1918 bits<4> lane;
Jim Grosbacha30a51b2010-11-19 22:42:55 +00001919
Owen Andersonf587a9352010-10-27 19:25:54 +00001920 let Inst{22} = Vd{4};
1921 let Inst{15-12} = Vd{3-0};
1922 let Inst{5} = Vm{4};
1923 let Inst{3-0} = Vm{3-0};
Johnny Chene4614f72010-03-25 17:01:27 +00001924}
1925
David Goodwin42a83f22009-08-04 17:53:06 +00001926// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1927// for single-precision FP.
1928class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1929 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1930}