blob: cecccc8d730fcc17a501e5dae24e05882a858786 [file] [log] [blame]
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001//===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
Bob Wilson3968c6a2010-03-23 17:23:59 +00002//
Evan Cheng2d37f192008-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 Wilson3968c6a2010-03-23 17:23:59 +00007//
Evan Cheng2d37f192008-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 Wilson69ba1bc2010-03-17 21:13:43 +000018class Format<bits<6> val> {
19 bits<6> Value = val;
Evan Cheng2d37f192008-08-28 23:39:26 +000020}
21
Evan Chengfabdcce2008-11-13 23:36:57 +000022def Pseudo : Format<0>;
23def MulFrm : Format<1>;
24def BrFrm : Format<2>;
25def BrMiscFrm : Format<3>;
Evan Cheng2d37f192008-08-28 23:39:26 +000026
Evan Chengfabdcce2008-11-13 23:36:57 +000027def DPFrm : Format<4>;
Owen Anderson04912702011-07-21 23:38:37 +000028def DPSoRegRegFrm : Format<5>;
Evan Cheng2d37f192008-08-28 23:39:26 +000029
Evan Chengfabdcce2008-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 Cheng2d37f192008-08-28 23:39:26 +000035
Johnny Chen0dab68f2010-03-19 17:39:00 +000036def LdStExFrm : Format<11>;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +000037
Johnny Chen0dab68f2010-03-19 17:39:00 +000038def ArithMiscFrm : Format<12>;
Bob Wilson96649842010-08-11 00:01:18 +000039def SatFrm : Format<13>;
40def ExtFrm : Format<14>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000041
Bob Wilson96649842010-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 Cheng8cbbcb12008-11-11 21:48:44 +000052
Bob Wilson96649842010-08-11 00:01:18 +000053def ThumbFrm : Format<25>;
54def MiscFrm : Format<26>;
Evan Cheng2d37f192008-08-28 23:39:26 +000055
Bob Wilson96649842010-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>;
Owen Anderson04912702011-07-21 23:38:37 +000071def DPSoRegImmFrm : Format<42>;
Johnny Chenf833fad2010-03-20 00:17:00 +000072
Evan Cheng14965762009-07-08 01:46:35 +000073// Misc flags.
74
Bill Wendlingcbb08ca2010-12-01 02:42:55 +000075// The instruction has an Rn register operand.
Evan Cheng14965762009-07-08 01:46:35 +000076// UnaryDP - Indicates this is a unary data processing instruction, i.e.
77// it doesn't have a Rn operand.
78class UnaryDP { bit isUnaryDataProc = 1; }
79
80// Xform16Bit - Indicates this Thumb2 instruction may be transformed into
81// a 16-bit Thumb instruction if certain conditions are met.
82class Xform16Bit { bit canXformTo16Bit = 1; }
Evan Cheng2d37f192008-08-28 23:39:26 +000083
Evan Cheng2d37f192008-08-28 23:39:26 +000084//===----------------------------------------------------------------------===//
Bob Wilsona4d86b62010-03-18 23:57:57 +000085// ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
Evan Chengb23b50d2009-06-29 07:51:04 +000086//
87
Jim Grosbachec86bac2011-01-18 19:59:19 +000088// FIXME: Once the JIT is MC-ized, these can go away.
Evan Chengb23b50d2009-06-29 07:51:04 +000089// Addressing mode.
Jim Grosbache9298992010-10-05 18:14:55 +000090class AddrMode<bits<5> val> {
91 bits<5> Value = val;
Evan Chengb23b50d2009-06-29 07:51:04 +000092}
Bill Wendlingb70dc872010-08-31 07:50:46 +000093def AddrModeNone : AddrMode<0>;
94def AddrMode1 : AddrMode<1>;
95def AddrMode2 : AddrMode<2>;
96def AddrMode3 : AddrMode<3>;
97def AddrMode4 : AddrMode<4>;
98def AddrMode5 : AddrMode<5>;
99def AddrMode6 : AddrMode<6>;
100def AddrModeT1_1 : AddrMode<7>;
101def AddrModeT1_2 : AddrMode<8>;
102def AddrModeT1_4 : AddrMode<9>;
103def AddrModeT1_s : AddrMode<10>;
104def AddrModeT2_i12 : AddrMode<11>;
105def AddrModeT2_i8 : AddrMode<12>;
106def AddrModeT2_so : AddrMode<13>;
107def AddrModeT2_pc : AddrMode<14>;
Bob Wilsondeb35af2009-07-01 23:16:05 +0000108def AddrModeT2_i8s4 : AddrMode<15>;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000109def AddrMode_i12 : AddrMode<16>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000110
Evan Chengb23b50d2009-06-29 07:51:04 +0000111// Load / store index mode.
112class IndexMode<bits<2> val> {
113 bits<2> Value = val;
114}
115def IndexModeNone : IndexMode<0>;
116def IndexModePre : IndexMode<1>;
117def IndexModePost : IndexMode<2>;
Bob Wilsonf1e8f7f2010-03-13 07:34:35 +0000118def IndexModeUpd : IndexMode<3>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000119
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000120// Instruction execution domain.
Evan Cheng04ad35b2011-02-22 19:53:14 +0000121class Domain<bits<3> val> {
122 bits<3> Value = val;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000123}
124def GenericDomain : Domain<0>;
125def VFPDomain : Domain<1>; // Instructions in VFP domain only
126def NeonDomain : Domain<2>; // Instructions in Neon domain only
127def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng97e64282011-02-23 02:35:33 +0000128def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000129
Evan Chengb23b50d2009-06-29 07:51:04 +0000130//===----------------------------------------------------------------------===//
Evan Chengcd4cdd12009-07-11 06:43:01 +0000131// ARM special operands.
132//
133
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000134// ARM imod and iflag operands, used only by the CPS instruction.
135def imod_op : Operand<i32> {
136 let PrintMethod = "printCPSIMod";
137}
138
Jim Grosbacheeaab222011-07-25 20:38:18 +0000139def ProcIFlagsOperand : AsmOperandClass {
140 let Name = "ProcIFlags";
141 let ParserMethod = "parseProcIFlagsOperand";
142}
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000143def iflags_op : Operand<i32> {
144 let PrintMethod = "printCPSIFlag";
145 let ParserMatchClass = ProcIFlagsOperand;
146}
147
Evan Chengcd4cdd12009-07-11 06:43:01 +0000148// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
149// register whose default is 0 (no register).
Jim Grosbacheeaab222011-07-25 20:38:18 +0000150def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
Jim Grosbachf86cd372011-08-19 20:46:54 +0000151def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
Evan Chengcd4cdd12009-07-11 06:43:01 +0000152 (ops (i32 14), (i32 zero_reg))> {
153 let PrintMethod = "printPredicateOperand";
Daniel Dunbard8042b72010-08-11 06:36:53 +0000154 let ParserMatchClass = CondCodeOperand;
Jim Grosbachdbb60f92011-08-19 20:30:19 +0000155 let DecoderMethod = "DecodePredicateOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000156}
157
158// Conditional code result for instructions whose 's' bit is set, e.g. subs.
Jim Grosbacheeaab222011-07-25 20:38:18 +0000159def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
Evan Chengcd4cdd12009-07-11 06:43:01 +0000160def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000161 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000162 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000163 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000164 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000165}
166
167// Same as cc_out except it defaults to setting CPSR.
168def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000169 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000170 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000171 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000172 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000173}
174
Johnny Chen9a3e2392010-03-10 18:59:38 +0000175// ARM special operands for disassembly only.
176//
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000177def SetEndAsmOperand : ImmAsmOperand {
Jim Grosbach0a547702011-07-22 17:44:50 +0000178 let Name = "SetEndImm";
179 let ParserMethod = "parseSetEndImm";
180}
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000181def setend_op : Operand<i32> {
182 let PrintMethod = "printSetendOperand";
Jim Grosbach0a547702011-07-22 17:44:50 +0000183 let ParserMatchClass = SetEndAsmOperand;
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000184}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000185
Jim Grosbacheeaab222011-07-25 20:38:18 +0000186def MSRMaskOperand : AsmOperandClass {
187 let Name = "MSRMask";
188 let ParserMethod = "parseMSRMaskOperand";
189}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000190def msr_mask : Operand<i32> {
191 let PrintMethod = "printMSRMaskOperand";
Owen Anderson60663402011-08-11 20:21:46 +0000192 let DecoderMethod = "DecodeMSRMask";
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000193 let ParserMatchClass = MSRMaskOperand;
Johnny Chen9a3e2392010-03-10 18:59:38 +0000194}
195
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000196// Shift Right Immediate - A shift right immediate is encoded differently from
197// other shift immediates. The imm6 field is encoded like so:
Bill Wendling3b1459b2011-03-01 01:00:59 +0000198//
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000199// Offset Encoding
200// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
201// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
202// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
203// 64 64 - <imm> is encoded in imm6<5:0>
204def shr_imm8 : Operand<i32> {
205 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000206 let DecoderMethod = "DecodeShiftRight8Imm";
Bill Wendling3b1459b2011-03-01 01:00:59 +0000207}
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000208def shr_imm16 : Operand<i32> {
209 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000210 let DecoderMethod = "DecodeShiftRight16Imm";
Bill Wendling3b1459b2011-03-01 01:00:59 +0000211}
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000212def shr_imm32 : Operand<i32> {
213 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000214 let DecoderMethod = "DecodeShiftRight32Imm";
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000215}
216def shr_imm64 : Operand<i32> {
217 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000218 let DecoderMethod = "DecodeShiftRight64Imm";
Bill Wendling3b1459b2011-03-01 01:00:59 +0000219}
220
Evan Chengcd4cdd12009-07-11 06:43:01 +0000221//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000222// ARM Assembler alias templates.
223//
224class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
225 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
226class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
227 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
228class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
229 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000230class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
231 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
232class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
233 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
Jim Grosbach0a978ef2011-12-05 19:55:46 +0000234class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
235 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000236
237//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000238// ARM Instruction templates.
239//
240
Jim Grosbach6caa5572011-08-22 18:04:24 +0000241
Owen Anderson651b2302011-07-13 23:22:26 +0000242class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000243 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000244 : Instruction {
245 let Namespace = "ARM";
246
Evan Cheng2d37f192008-08-28 23:39:26 +0000247 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000248 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000249 IndexMode IM = im;
250 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000251 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000252 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000253 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000254 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000255 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000256 // The instruction is a 16-bit flag setting Thumb instruction. Used
257 // by the parser to determine whether to require the 'S' suffix on the
258 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
259 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000260
Chris Lattner7ff33462010-10-31 19:22:57 +0000261 // If this is a pseudo instruction, mark it isCodeGenOnly.
262 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000263
Jim Grosbach30694dc2011-08-15 16:52:24 +0000264 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000265 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000266 let TSFlags{6-5} = IndexModeBits;
267 let TSFlags{12-7} = Form;
268 let TSFlags{13} = isUnaryDataProc;
269 let TSFlags{14} = canXformTo16Bit;
270 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000271 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000272
Evan Cheng2d37f192008-08-28 23:39:26 +0000273 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000274 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000275}
276
Johnny Chenc28e6292009-12-15 17:24:14 +0000277class Encoding {
278 field bits<32> Inst;
279}
280
Owen Anderson651b2302011-07-13 23:22:26 +0000281class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000282 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000283 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
284 let DecoderNamespace = "ARM";
285}
Johnny Chenc28e6292009-12-15 17:24:14 +0000286
287// This Encoding-less class is used by Thumb1 to specify the encoding bits later
288// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000289class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000290 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000291 : InstTemplate<am, sz, im, f, d, cstr, itin> {
292 let DecoderNamespace = "Thumb";
293}
Johnny Chenc28e6292009-12-15 17:24:14 +0000294
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000295// Pseudo-instructions for alternate assembly syntax (never used by codegen).
296// These are aliases that require C++ handling to convert to the target
297// instruction, while InstAliases can be handled directly by tblgen.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000298class AsmPseudoInst<string asm, dag iops>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000299 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
300 "", NoItinerary> {
Jim Grosbach61db5a52011-11-10 16:44:55 +0000301 let OutOperandList = (outs);
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000302 let InOperandList = iops;
303 let Pattern = [];
304 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000305 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000306 let isPseudo = 1;
307}
308
Jim Grosbach61db5a52011-11-10 16:44:55 +0000309class ARMAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
310 Requires<[IsARM]>;
311class tAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
312 Requires<[IsThumb]>;
313class t2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
314 Requires<[IsThumb2]>;
315class VFP2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
316 Requires<[HasVFP2]>;
317class NEONAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
318 Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000319
320// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000321class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000322 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000323 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000324 let OutOperandList = oops;
325 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000326 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000327 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000328 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000329}
330
Jim Grosbachcfb66202010-11-18 01:15:56 +0000331// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000332class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000333 list<dag> pattern>
334 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000335 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000336 list<Predicate> Predicates = [IsARM];
337}
338
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000339// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000340class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000341 list<dag> pattern>
342 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000343 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000344 list<Predicate> Predicates = [IsThumb];
345}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000346
Jim Grosbachd42257c2010-12-15 18:48:45 +0000347// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000348class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000349 list<dag> pattern>
350 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000351 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000352 list<Predicate> Predicates = [IsThumb2];
353}
Jim Grosbach95dee402011-07-08 17:40:42 +0000354
Owen Anderson651b2302011-07-13 23:22:26 +0000355class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000356 InstrItinClass itin, list<dag> pattern,
357 dag Result>
358 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
359 PseudoInstExpansion<Result>;
360
Owen Anderson651b2302011-07-13 23:22:26 +0000361class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000362 InstrItinClass itin, list<dag> pattern,
363 dag Result>
364 : tPseudoInst<oops, iops, sz, itin, pattern>,
365 PseudoInstExpansion<Result>;
366
Owen Anderson651b2302011-07-13 23:22:26 +0000367class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000368 InstrItinClass itin, list<dag> pattern,
369 dag Result>
370 : t2PseudoInst<oops, iops, sz, itin, pattern>,
371 PseudoInstExpansion<Result>;
372
Evan Cheng2d37f192008-08-28 23:39:26 +0000373// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000374class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000375 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000376 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000377 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000378 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000379 bits<4> p;
380 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000381 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000382 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000383 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000384 let Pattern = pattern;
385 list<Predicate> Predicates = [IsARM];
386}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000387
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000388// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000389class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000390 IndexMode im, Format f, InstrItinClass itin,
391 string opc, string asm, string cstr,
392 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000393 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
394 let OutOperandList = oops;
395 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000396 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000397 let Pattern = pattern;
398 let isPredicable = 0;
399 list<Predicate> Predicates = [IsARM];
400}
Evan Cheng2d37f192008-08-28 23:39:26 +0000401
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000402// Same as I except it can optionally modify CPSR. Note it's modeled as an input
403// operand since by default it's a zero register. It will become an implicit def
404// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000405class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000406 IndexMode im, Format f, InstrItinClass itin,
407 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000408 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000409 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000410 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000411 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000412 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000413 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000414
Evan Cheng2d37f192008-08-28 23:39:26 +0000415 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000416 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000417 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000418 let Pattern = pattern;
419 list<Predicate> Predicates = [IsARM];
420}
421
Evan Chenga2827232008-09-01 07:19:00 +0000422// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000423class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000424 IndexMode im, Format f, InstrItinClass itin,
425 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000426 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000427 let OutOperandList = oops;
428 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000429 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000430 let Pattern = pattern;
431 list<Predicate> Predicates = [IsARM];
432}
433
David Goodwinb062c232009-08-06 16:52:47 +0000434class AI<dag oops, dag iops, Format f, InstrItinClass itin,
435 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000436 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000437 opc, asm, "", pattern>;
438class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
439 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000440 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000441 opc, asm, "", pattern>;
442class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000443 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000444 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000445 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000446class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000447 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000448 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000449 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000450
451// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000452class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
453 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000454 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000455 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000456 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000457}
David Goodwinb062c232009-08-06 16:52:47 +0000458class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
459 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000460 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000461 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000462 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000463}
Evan Chengfa558782008-09-01 08:25:56 +0000464
465// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000466class JTI<dag oops, dag iops, InstrItinClass itin,
467 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000468 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000469 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000470
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000471// Atomic load/store instructions
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000472class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
473 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000474 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000475 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000476 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000477 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000478 let Inst{27-23} = 0b00011;
479 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000480 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000481 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000482 let Inst{15-12} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000483 let Inst{11-0} = 0b111110011111;
484}
485class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
486 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000487 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000488 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000489 bits<4> Rd;
490 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000491 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000492 let Inst{27-23} = 0b00011;
493 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000494 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000495 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000496 let Inst{15-12} = Rd;
Johnny Chen098bd1b2009-12-11 19:37:26 +0000497 let Inst{11-4} = 0b11111001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000498 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000499}
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000500class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000501 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000502 bits<4> Rt;
503 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000504 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000505 let Inst{27-23} = 0b00010;
506 let Inst{22} = b;
507 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000508 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000509 let Inst{15-12} = Rt;
510 let Inst{11-4} = 0b00001001;
511 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000512
513 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000514}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000515
Evan Cheng624844b2008-09-01 01:51:14 +0000516// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000517class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
518 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000519 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000520 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000521 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000522 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000523}
David Goodwinb062c232009-08-06 16:52:47 +0000524class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
525 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000526 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000527 opc, asm, "", pattern> {
528 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000529 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000530}
531class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000532 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000533 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000534 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000535 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000536 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000537}
Evan Cheng624844b2008-09-01 01:51:14 +0000538
Evan Chengcccca872008-09-01 01:27:33 +0000539// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000540
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000541// LDR/LDRB/STR/STRB/...
542class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000543 Format f, InstrItinClass itin, string opc, string asm,
544 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000545 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000546 "", pattern> {
547 let Inst{27-25} = op;
548 let Inst{24} = 1; // 24 == P
549 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000550 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000551 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000552 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000553}
Jim Grosbach2f790742010-11-13 00:35:48 +0000554// Indexed load/stores
555class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000556 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000557 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000558 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000559 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000560 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000561 let Inst{27-26} = 0b01;
562 let Inst{24} = isPre; // P bit
563 let Inst{22} = isByte; // B bit
564 let Inst{21} = isPre; // W bit
565 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000566 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000567}
Owen Anderson2aedba62011-07-26 20:54:26 +0000568class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000569 IndexMode im, Format f, InstrItinClass itin, string opc,
570 string asm, string cstr, list<dag> pattern>
571 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
572 pattern> {
573 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000574 // {12} isAdd
575 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000576 bits<14> offset;
577 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000578 let Inst{25} = 1;
579 let Inst{23} = offset{12};
580 let Inst{19-16} = Rn;
581 let Inst{11-5} = offset{11-5};
582 let Inst{4} = 0;
583 let Inst{3-0} = offset{3-0};
584}
585
586class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
587 IndexMode im, Format f, InstrItinClass itin, string opc,
588 string asm, string cstr, list<dag> pattern>
589 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
590 pattern> {
591 // AM2 store w/ two operands: (GPR, am2offset)
592 // {12} isAdd
593 // {11-0} imm12/Rm
594 bits<14> offset;
595 bits<4> Rn;
596 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000597 let Inst{23} = offset{12};
598 let Inst{19-16} = Rn;
599 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000600}
Owen Anderson2aedba62011-07-26 20:54:26 +0000601
602
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000603// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
604// but for now use this class for STRT and STRBT.
605class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
606 IndexMode im, Format f, InstrItinClass itin, string opc,
607 string asm, string cstr, list<dag> pattern>
608 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
609 pattern> {
610 // AM2 store w/ two operands: (GPR, am2offset)
611 // {17-14} Rn
612 // {13} 1 == Rm, 0 == imm12
613 // {12} isAdd
614 // {11-0} imm12/Rm
615 bits<18> addr;
616 let Inst{25} = addr{13};
617 let Inst{23} = addr{12};
618 let Inst{19-16} = addr{17-14};
619 let Inst{11-0} = addr{11-0};
620}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000621
Evan Cheng624844b2008-09-01 01:51:14 +0000622// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000623class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
624 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000625 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000626 opc, asm, "", pattern> {
627 bits<14> addr;
628 bits<4> Rt;
629 let Inst{27-25} = 0b000;
630 let Inst{24} = 1; // P bit
631 let Inst{23} = addr{8}; // U bit
632 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
633 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000634 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000635 let Inst{19-16} = addr{12-9}; // Rn
636 let Inst{15-12} = Rt; // Rt
637 let Inst{11-8} = addr{7-4}; // imm7_4/zero
638 let Inst{7-4} = op;
639 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000640
641 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000642}
Evan Cheng169eccc2008-09-01 07:00:14 +0000643
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000644class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000645 IndexMode im, Format f, InstrItinClass itin, string opc,
646 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000647 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000648 opc, asm, cstr, pattern> {
649 bits<4> Rt;
650 let Inst{27-25} = 0b000;
651 let Inst{24} = isPre; // P bit
652 let Inst{21} = isPre; // W bit
653 let Inst{20} = op20; // L bit
654 let Inst{15-12} = Rt; // Rt
655 let Inst{7-4} = op;
656}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000657
658// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
659// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000660class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000661 IndexMode im, Format f, InstrItinClass itin, string opc,
662 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000663 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000664 // {13} 1 == imm8, 0 == Rm
665 // {12-9} Rn
666 // {8} isAdd
667 // {7-4} imm7_4/zero
668 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000669 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000670 bits<4> Rt;
671 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000672 let Inst{24} = 0; // P bit
673 let Inst{21} = 1;
674 let Inst{20} = isLoad; // L bit
675 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000676 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000677 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000678}
679
Evan Cheng169eccc2008-09-01 07:00:14 +0000680// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000681class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000682 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000683 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000684 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000685 bits<14> addr;
686 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000687 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000688 let Inst{24} = 1; // P bit
689 let Inst{23} = addr{8}; // U bit
690 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
691 let Inst{21} = 0; // W bit
692 let Inst{20} = 0; // L bit
693 let Inst{19-16} = addr{12-9}; // Rn
694 let Inst{15-12} = Rt; // Rt
695 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000696 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000697 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000698 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000699}
Evan Cheng169eccc2008-09-01 07:00:14 +0000700
Evan Cheng624844b2008-09-01 01:51:14 +0000701// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000702class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
703 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000704 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000705 bits<4> p;
706 bits<16> regs;
707 bits<4> Rn;
708 let Inst{31-28} = p;
709 let Inst{27-25} = 0b100;
710 let Inst{22} = 0; // S bit
711 let Inst{19-16} = Rn;
712 let Inst{15-0} = regs;
713}
Evan Cheng2d37f192008-08-28 23:39:26 +0000714
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000715// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000716class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
717 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000718 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000719 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000720 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000721 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000722 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000723}
David Goodwinb062c232009-08-06 16:52:47 +0000724class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
725 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000726 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000727 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000728 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000729 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000730}
731
732// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000733class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
734 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000735 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000736 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000737 bits<4> Rd;
738 bits<4> Rn;
739 bits<4> Rm;
740 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000741 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000742 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000743 let Inst{19-16} = Rd;
744 let Inst{11-8} = Rm;
745 let Inst{3-0} = Rn;
746}
747// MSW multiple w/ Ra operand
748class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
749 InstrItinClass itin, string opc, string asm, list<dag> pattern>
750 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
751 bits<4> Ra;
752 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000753}
Evan Cheng2d37f192008-08-28 23:39:26 +0000754
Evan Cheng36ae4032008-11-06 03:35:07 +0000755// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000756class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000757 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000758 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000759 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000760 bits<4> Rn;
761 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000762 let Inst{4} = 0;
763 let Inst{7} = 1;
764 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000765 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000766 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000767 let Inst{11-8} = Rm;
768 let Inst{3-0} = Rn;
769}
770class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
771 InstrItinClass itin, string opc, string asm, list<dag> pattern>
772 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
773 bits<4> Rd;
774 let Inst{19-16} = Rd;
775}
776
777// AMulxyI with Ra operand
778class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
779 InstrItinClass itin, string opc, string asm, list<dag> pattern>
780 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
781 bits<4> Ra;
782 let Inst{15-12} = Ra;
783}
784// SMLAL*
785class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
786 InstrItinClass itin, string opc, string asm, list<dag> pattern>
787 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
788 bits<4> RdLo;
789 bits<4> RdHi;
790 let Inst{19-16} = RdHi;
791 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000792}
793
Evan Cheng49d66522008-11-06 22:15:19 +0000794// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000795class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
796 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000797 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000798 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000799 // All AExtI instructions have Rd and Rm register operands.
800 bits<4> Rd;
801 bits<4> Rm;
802 let Inst{15-12} = Rd;
803 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000804 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000805 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000806 let Inst{27-20} = opcod;
807}
808
Evan Cheng98dc53e2008-11-07 01:41:35 +0000809// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000810class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
811 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000812 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000813 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000814 bits<4> Rd;
815 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000816 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000817 let Inst{19-16} = 0b1111;
818 let Inst{15-12} = Rd;
819 let Inst{11-8} = 0b1111;
820 let Inst{7-4} = opc7_4;
821 let Inst{3-0} = Rm;
822}
823
824// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000825def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000826 let Name = "PKHLSLImm";
827 let ParserMethod = "parsePKHLSLImm";
828}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000829def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
830 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000831 let ParserMatchClass = PKHLSLAsmOperand;
832}
833def PKHASRAsmOperand : AsmOperandClass {
834 let Name = "PKHASRImm";
835 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000836}
837def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
838 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000839 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000840}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000841
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000842class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
843 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000844 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000845 opc, asm, "", pattern> {
846 bits<4> Rd;
847 bits<4> Rn;
848 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000849 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000850 let Inst{27-20} = opcod;
851 let Inst{19-16} = Rn;
852 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000853 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000854 let Inst{6} = tb;
855 let Inst{5-4} = 0b01;
856 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000857}
858
Evan Cheng2d37f192008-08-28 23:39:26 +0000859//===----------------------------------------------------------------------===//
860
861// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
862class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
863 list<Predicate> Predicates = [IsARM];
864}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000865class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
866 list<Predicate> Predicates = [IsARM, HasV5T];
867}
Evan Cheng2d37f192008-08-28 23:39:26 +0000868class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
869 list<Predicate> Predicates = [IsARM, HasV5TE];
870}
871class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
872 list<Predicate> Predicates = [IsARM, HasV6];
873}
Evan Chengee98fa92008-08-29 06:41:12 +0000874
875//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000876// Thumb Instruction Format Definitions.
877//
878
Owen Anderson651b2302011-07-13 23:22:26 +0000879class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000880 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000881 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000882 let OutOperandList = oops;
883 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000884 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000885 let Pattern = pattern;
886 list<Predicate> Predicates = [IsThumb];
887}
888
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000889// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000890class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000891 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000892
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000893// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000894class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
895 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000896 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000897 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000898
Johnny Chenc28e6292009-12-15 17:24:14 +0000899// tBL, tBX 32-bit instructions
900class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000901 dag oops, dag iops, InstrItinClass itin, string asm,
902 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000903 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000904 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +0000905 let Inst{31-27} = opcod1;
906 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000907 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +0000908}
Evan Chengee98fa92008-08-29 06:41:12 +0000909
910// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000911class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
912 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000913 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000914
Evan Chengbec1dba892009-06-23 19:38:13 +0000915// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +0000916class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000917 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000918 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000919 let OutOperandList = oops;
920 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000921 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +0000922 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000923 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +0000924}
925
David Goodwinb062c232009-08-06 16:52:47 +0000926class T1I<dag oops, dag iops, InstrItinClass itin,
927 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000928 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +0000929class T1Ix2<dag oops, dag iops, InstrItinClass itin,
930 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000931 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000932
933// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000934class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000935 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000936 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000937 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000938
939// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +0000940class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000941 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000942 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000943 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000944 let OutOperandList = !con(oops, (outs s_cc_out:$s));
945 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000946 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000947 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000948 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000949 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +0000950 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000951}
952
David Goodwinb062c232009-08-06 16:52:47 +0000953class T1sI<dag oops, dag iops, InstrItinClass itin,
954 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000955 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000956
957// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000958class T1sIt<dag oops, dag iops, InstrItinClass itin,
959 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000960 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +0000961 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000962
963// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +0000964class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000965 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000966 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000967 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000968 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000969 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000970 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000971 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000972 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000973}
974
David Goodwinb062c232009-08-06 16:52:47 +0000975class T1pI<dag oops, dag iops, InstrItinClass itin,
976 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000977 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000978
979// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000980class T1pIt<dag oops, dag iops, InstrItinClass itin,
981 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000982 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +0000983 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000984
Bob Wilson3968c6a2010-03-23 17:23:59 +0000985class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +0000986 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000987 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000988
Johnny Chen466231a2009-12-16 02:32:54 +0000989class Encoding16 : Encoding {
990 let Inst{31-16} = 0x0000;
991}
992
Johnny Chenc28e6292009-12-15 17:24:14 +0000993// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +0000994class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000995 let Inst{15-10} = opcode;
996}
997
998// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000999class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001000 let Inst{15-14} = 0b00;
1001 let Inst{13-9} = opcode;
1002}
1003
1004// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001005class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001006 let Inst{15-10} = 0b010000;
1007 let Inst{9-6} = opcode;
1008}
1009
1010// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001011class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001012 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001013 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001014}
1015
1016// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001017class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001018 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001019 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001020}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001021class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001022
Eric Christopher9b67db82011-05-27 03:50:53 +00001023class T1BranchCond<bits<4> opcode> : Encoding16 {
1024 let Inst{15-12} = opcode;
1025}
1026
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001027// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001028// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001029//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001030// 0b0110 => Immediate, 4 bytes
1031// 0b1000 => Immediate, 2 bytes
1032// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001033class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1034 InstrItinClass itin, string opc, string asm,
1035 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001036 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001037 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001038 bits<3> Rt;
1039 bits<8> addr;
1040 let Inst{8-6} = addr{5-3}; // Rm
1041 let Inst{5-3} = addr{2-0}; // Rn
1042 let Inst{2-0} = Rt;
1043}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001044class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1045 InstrItinClass itin, string opc, string asm,
1046 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001047 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001048 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001049 bits<3> Rt;
1050 bits<8> addr;
1051 let Inst{10-6} = addr{7-3}; // imm5
1052 let Inst{5-3} = addr{2-0}; // Rn
1053 let Inst{2-0} = Rt;
1054}
1055
Johnny Chenc28e6292009-12-15 17:24:14 +00001056// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001057class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001058 let Inst{15-12} = 0b1011;
1059 let Inst{11-5} = opcode;
1060}
1061
Evan Chengd76f0be2009-06-25 02:08:06 +00001062// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001063class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001064 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001065 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001066 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001067 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001068 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001069 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001070 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001071 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001072 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001073}
1074
Bill Wendlingb70dc872010-08-31 07:50:46 +00001075// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1076// input operand since by default it's a zero register. It will become an
1077// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001078//
Evan Chengd76f0be2009-06-25 02:08:06 +00001079// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1080// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001081class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001082 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001083 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001084 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001085 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1086 let Inst{20} = s;
1087
Evan Chengd76f0be2009-06-25 02:08:06 +00001088 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001089 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001090 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001091 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001092 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001093 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001094}
1095
1096// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001097class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001098 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001099 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001100 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001101 let OutOperandList = oops;
1102 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001103 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001104 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001105 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001106 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001107}
1108
Owen Anderson651b2302011-07-13 23:22:26 +00001109class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001110 InstrItinClass itin,
1111 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001112 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1113 let OutOperandList = oops;
1114 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001115 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001116 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001117 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001118 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001119}
1120
David Goodwinb062c232009-08-06 16:52:47 +00001121class T2I<dag oops, dag iops, InstrItinClass itin,
1122 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001123 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001124class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1125 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001126 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001127class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1128 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001129 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001130class T2Iso<dag oops, dag iops, InstrItinClass itin,
1131 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001132 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001133class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1134 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001135 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001136class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001137 string opc, string asm, string cstr, list<dag> pattern>
1138 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001139 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001140 bits<4> Rt;
1141 bits<4> Rt2;
1142 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001143 let Inst{31-25} = 0b1110100;
1144 let Inst{24} = P;
1145 let Inst{23} = addr{8};
1146 let Inst{22} = 1;
1147 let Inst{21} = W;
1148 let Inst{20} = isLoad;
1149 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001150 let Inst{15-12} = Rt{3-0};
1151 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001152 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001153}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001154class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1155 InstrItinClass itin, string opc, string asm, string cstr,
1156 list<dag> pattern>
1157 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001158 pattern> {
1159 bits<4> Rt;
1160 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001161 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001162 bits<9> imm;
1163 let Inst{31-25} = 0b1110100;
1164 let Inst{24} = P;
1165 let Inst{23} = imm{8};
1166 let Inst{22} = 1;
1167 let Inst{21} = W;
1168 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001169 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001170 let Inst{15-12} = Rt{3-0};
1171 let Inst{11-8} = Rt2{3-0};
1172 let Inst{7-0} = imm{7-0};
1173}
1174
David Goodwinb062c232009-08-06 16:52:47 +00001175class T2sI<dag oops, dag iops, InstrItinClass itin,
1176 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001177 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001178
David Goodwinb062c232009-08-06 16:52:47 +00001179class T2XI<dag oops, dag iops, InstrItinClass itin,
1180 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001181 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001182class T2JTI<dag oops, dag iops, InstrItinClass itin,
1183 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001184 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001185
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001186// Move to/from coprocessor instructions
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001187class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbachadb29b62011-07-13 21:14:23 +00001188 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001189 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001190}
1191
Bob Wilson947f04b2010-03-13 01:08:20 +00001192// Two-address instructions
1193class T2XIt<dag oops, dag iops, InstrItinClass itin,
1194 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001195 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001196
Jim Grosbachc086f682011-09-08 00:39:19 +00001197// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1198class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001199 dag oops, dag iops,
1200 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001201 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001202 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001203 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001204 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001205 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001206 let Pattern = pattern;
1207 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001208 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001209
1210 bits<4> Rt;
1211 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001212 let Inst{31-27} = 0b11111;
1213 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001214 let Inst{24} = signed;
1215 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001216 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001217 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001218 let Inst{19-16} = addr{12-9};
1219 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001220 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001221 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001222 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001223 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001224 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001225 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001226
1227 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001228}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001229
Jim Grosbachc086f682011-09-08 00:39:19 +00001230// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1231class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1232 dag oops, dag iops,
1233 AddrMode am, IndexMode im, InstrItinClass itin,
1234 string opc, string asm, string cstr, list<dag> pattern>
1235 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1236 let OutOperandList = oops;
1237 let InOperandList = !con(iops, (ins pred:$p));
1238 let AsmString = !strconcat(opc, "${p}", asm);
1239 let Pattern = pattern;
1240 list<Predicate> Predicates = [IsThumb2];
1241 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001242
Owen Andersone22c7322010-11-30 00:14:31 +00001243 bits<4> Rt;
1244 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001245 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001246 let Inst{31-27} = 0b11111;
1247 let Inst{26-25} = 0b00;
1248 let Inst{24} = signed;
1249 let Inst{23} = 0;
1250 let Inst{22-21} = opcod;
1251 let Inst{20} = load;
1252 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001253 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001254 let Inst{11} = 1;
1255 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1256 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001257 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001258 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001259 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001260
1261 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001262}
1263
David Goodwine5b969f2009-07-27 19:59:26 +00001264// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1265class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001266 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001267}
1268
1269// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1270class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001271 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001272}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001273
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001274// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1275class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1276 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1277}
1278
Evan Chengeab9ca72009-06-27 02:26:13 +00001279// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1280class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001281 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001282}
1283
Evan Chengee98fa92008-08-29 06:41:12 +00001284//===----------------------------------------------------------------------===//
1285
Evan Chengac2af2f2008-11-11 02:11:05 +00001286//===----------------------------------------------------------------------===//
1287// ARM VFP Instruction templates.
1288//
1289
David Goodwin81cdd212009-07-10 17:03:29 +00001290// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001291class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001292 IndexMode im, Format f, InstrItinClass itin,
1293 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001294 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001295 bits<4> p;
1296 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001297 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001298 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001299 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001300 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001301 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001302 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001303 list<Predicate> Predicates = [HasVFP2];
1304}
1305
1306// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001307class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001308 IndexMode im, Format f, InstrItinClass itin,
1309 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001310 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001311 bits<4> p;
1312 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001313 let OutOperandList = oops;
1314 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001315 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001316 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001317 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001318 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001319 list<Predicate> Predicates = [HasVFP2];
1320}
1321
David Goodwinb062c232009-08-06 16:52:47 +00001322class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1323 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001324 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001325 opc, asm, "", pattern> {
1326 let PostEncoderMethod = "VFPThumb2PostEncoder";
1327}
David Goodwin81cdd212009-07-10 17:03:29 +00001328
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001329// ARM VFP addrmode5 loads and stores
1330class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001331 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001332 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001333 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001334 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001335 // Instruction operands.
1336 bits<5> Dd;
1337 bits<13> addr;
1338
1339 // Encode instruction operands.
1340 let Inst{23} = addr{8}; // U (add = (U == '1'))
1341 let Inst{22} = Dd{4};
1342 let Inst{19-16} = addr{12-9}; // Rn
1343 let Inst{15-12} = Dd{3-0};
1344 let Inst{7-0} = addr{7-0}; // imm8
1345
Evan Chengac2af2f2008-11-11 02:11:05 +00001346 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001347 let Inst{27-24} = opcod1;
1348 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001349 let Inst{11-9} = 0b101;
1350 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001351
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001352 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001353 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001354}
1355
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001356class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001357 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001358 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001359 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001360 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001361 // Instruction operands.
1362 bits<5> Sd;
1363 bits<13> addr;
1364
1365 // Encode instruction operands.
1366 let Inst{23} = addr{8}; // U (add = (U == '1'))
1367 let Inst{22} = Sd{0};
1368 let Inst{19-16} = addr{12-9}; // Rn
1369 let Inst{15-12} = Sd{4-1};
1370 let Inst{7-0} = addr{7-0}; // imm8
1371
Evan Chengac2af2f2008-11-11 02:11:05 +00001372 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001373 let Inst{27-24} = opcod1;
1374 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001375 let Inst{11-9} = 0b101;
1376 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001377
1378 // Loads & stores operate on both NEON and VFP pipelines.
1379 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001380}
1381
Bob Wilson6b853c32010-09-16 00:31:02 +00001382// VFP Load / store multiple pseudo instructions.
1383class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1384 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001385 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001386 cstr, itin> {
1387 let OutOperandList = oops;
1388 let InOperandList = !con(iops, (ins pred:$p));
1389 let Pattern = pattern;
1390 list<Predicate> Predicates = [HasVFP2];
1391}
1392
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001393// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001394class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001395 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001396 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001397 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001398 // Instruction operands.
1399 bits<4> Rn;
1400 bits<13> regs;
1401
1402 // Encode instruction operands.
1403 let Inst{19-16} = Rn;
1404 let Inst{22} = regs{12};
1405 let Inst{15-12} = regs{11-8};
1406 let Inst{7-0} = regs{7-0};
1407
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001408 // TODO: Mark the instructions with the appropriate subtarget info.
1409 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001410 let Inst{11-9} = 0b101;
1411 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001412}
1413
Jim Grosbachabcbe242010-09-08 00:25:50 +00001414class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001415 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001416 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001417 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001418 // Instruction operands.
1419 bits<4> Rn;
1420 bits<13> regs;
1421
1422 // Encode instruction operands.
1423 let Inst{19-16} = Rn;
1424 let Inst{22} = regs{8};
1425 let Inst{15-12} = regs{12-9};
1426 let Inst{7-0} = regs{7-0};
1427
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001428 // TODO: Mark the instructions with the appropriate subtarget info.
1429 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001430 let Inst{11-9} = 0b101;
1431 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001432}
1433
Evan Chengac2af2f2008-11-11 02:11:05 +00001434// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001435class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1436 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1437 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001438 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001439 // Instruction operands.
1440 bits<5> Dd;
1441 bits<5> Dm;
1442
1443 // Encode instruction operands.
1444 let Inst{3-0} = Dm{3-0};
1445 let Inst{5} = Dm{4};
1446 let Inst{15-12} = Dd{3-0};
1447 let Inst{22} = Dd{4};
1448
Johnny Chen34a6afc2010-01-29 23:21:10 +00001449 let Inst{27-23} = opcod1;
1450 let Inst{21-20} = opcod2;
1451 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001452 let Inst{11-9} = 0b101;
1453 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001454 let Inst{7-6} = opcod4;
1455 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001456}
1457
1458// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001459class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001460 dag iops, InstrItinClass itin, string opc, string asm,
1461 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001462 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001463 // Instruction operands.
1464 bits<5> Dd;
1465 bits<5> Dn;
1466 bits<5> Dm;
1467
1468 // Encode instruction operands.
1469 let Inst{3-0} = Dm{3-0};
1470 let Inst{5} = Dm{4};
1471 let Inst{19-16} = Dn{3-0};
1472 let Inst{7} = Dn{4};
1473 let Inst{15-12} = Dd{3-0};
1474 let Inst{22} = Dd{4};
1475
Johnny Chen34a6afc2010-01-29 23:21:10 +00001476 let Inst{27-23} = opcod1;
1477 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001478 let Inst{11-9} = 0b101;
1479 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001480 let Inst{6} = op6;
1481 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001482}
1483
1484// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001485class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1486 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1487 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001488 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001489 // Instruction operands.
1490 bits<5> Sd;
1491 bits<5> Sm;
1492
1493 // Encode instruction operands.
1494 let Inst{3-0} = Sm{4-1};
1495 let Inst{5} = Sm{0};
1496 let Inst{15-12} = Sd{4-1};
1497 let Inst{22} = Sd{0};
1498
Johnny Chen34a6afc2010-01-29 23:21:10 +00001499 let Inst{27-23} = opcod1;
1500 let Inst{21-20} = opcod2;
1501 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001502 let Inst{11-9} = 0b101;
1503 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001504 let Inst{7-6} = opcod4;
1505 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001506}
1507
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001508// Single precision unary, if no NEON. Same as ASuI except not available if
1509// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001510class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1511 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1512 string asm, list<dag> pattern>
1513 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1514 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001515 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1516}
1517
Evan Chengac2af2f2008-11-11 02:11:05 +00001518// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001519class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1520 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001521 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001522 // Instruction operands.
1523 bits<5> Sd;
1524 bits<5> Sn;
1525 bits<5> Sm;
1526
1527 // Encode instruction operands.
1528 let Inst{3-0} = Sm{4-1};
1529 let Inst{5} = Sm{0};
1530 let Inst{19-16} = Sn{4-1};
1531 let Inst{7} = Sn{0};
1532 let Inst{15-12} = Sd{4-1};
1533 let Inst{22} = Sd{0};
1534
Johnny Chen34a6afc2010-01-29 23:21:10 +00001535 let Inst{27-23} = opcod1;
1536 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001537 let Inst{11-9} = 0b101;
1538 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001539 let Inst{6} = op6;
1540 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001541}
1542
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001543// Single precision binary, if no NEON. Same as ASbI except not available if
1544// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001545class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001546 dag iops, InstrItinClass itin, string opc, string asm,
1547 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001548 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001549 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001550
1551 // Instruction operands.
1552 bits<5> Sd;
1553 bits<5> Sn;
1554 bits<5> Sm;
1555
1556 // Encode instruction operands.
1557 let Inst{3-0} = Sm{4-1};
1558 let Inst{5} = Sm{0};
1559 let Inst{19-16} = Sn{4-1};
1560 let Inst{7} = Sn{0};
1561 let Inst{15-12} = Sd{4-1};
1562 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001563}
1564
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001565// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001566class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1567 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1568 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001569 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001570 let Inst{27-23} = opcod1;
1571 let Inst{21-20} = opcod2;
1572 let Inst{19-16} = opcod3;
1573 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001574 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001575 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001576}
1577
Johnny Chen39640592010-02-11 18:47:03 +00001578// VFP conversion between floating-point and fixed-point
1579class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001580 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1581 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001582 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1583 // size (fixed-point number): sx == 0 ? 16 : 32
1584 let Inst{7} = op5; // sx
1585}
1586
David Goodwin85b5b022009-08-10 22:17:39 +00001587// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001588class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001589 dag oops, dag iops, InstrItinClass itin,
1590 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001591 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1592 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001593 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1594}
1595
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001596class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001597 InstrItinClass itin,
1598 string opc, string asm, list<dag> pattern>
1599 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001600 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001601 let Inst{11-8} = opcod2;
1602 let Inst{4} = 1;
1603}
1604
David Goodwinb062c232009-08-06 16:52:47 +00001605class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1606 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1607 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001608
Bob Wilson3968c6a2010-03-23 17:23:59 +00001609class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001610 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1611 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001612
David Goodwinb062c232009-08-06 16:52:47 +00001613class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1614 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1615 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001616
David Goodwinb062c232009-08-06 16:52:47 +00001617class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1618 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1619 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001620
Evan Chengac2af2f2008-11-11 02:11:05 +00001621//===----------------------------------------------------------------------===//
1622
Bob Wilson2e076c42009-06-22 23:27:02 +00001623//===----------------------------------------------------------------------===//
1624// ARM NEON Instruction templates.
1625//
Evan Chengee98fa92008-08-29 06:41:12 +00001626
Johnny Chenf833fad2010-03-20 00:17:00 +00001627class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1628 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1629 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001630 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001631 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001632 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001633 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001634 let Pattern = pattern;
1635 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001636 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001637}
1638
1639// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001640class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1641 InstrItinClass itin, string opc, string asm, string cstr,
1642 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001643 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001644 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001645 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001646 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001647 let Pattern = pattern;
1648 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001649 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001650}
1651
Bob Wilson50820a22009-10-07 21:53:04 +00001652class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1653 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001654 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001655 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1656 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001657 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001658 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001659 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001660 let Inst{11-8} = op11_8;
1661 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001662
Chris Lattner63274cb2010-11-15 05:19:05 +00001663 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001664 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001665
Owen Andersonad402342010-11-02 00:05:05 +00001666 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001667 bits<6> Rn;
1668 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001669
Owen Andersonad402342010-11-02 00:05:05 +00001670 let Inst{22} = Vd{4};
1671 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001672 let Inst{19-16} = Rn{3-0};
1673 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001674}
1675
Owen Anderson9f20daf2010-11-02 20:47:39 +00001676class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1677 dag oops, dag iops, InstrItinClass itin,
1678 string opc, string dt, string asm, string cstr, list<dag> pattern>
1679 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1680 dt, asm, cstr, pattern> {
1681 bits<3> lane;
1682}
1683
Bob Wilson9392b0e2010-08-25 23:27:42 +00001684class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001685 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001686 itin> {
1687 let OutOperandList = oops;
1688 let InOperandList = !con(iops, (ins pred:$p));
1689 list<Predicate> Predicates = [HasNEON];
1690}
1691
Jim Grosbach233b3a22010-10-06 20:36:55 +00001692class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1693 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001694 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001695 itin> {
1696 let OutOperandList = oops;
1697 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001698 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001699 list<Predicate> Predicates = [HasNEON];
1700}
1701
Johnny Chenac5024b2010-03-23 16:43:47 +00001702class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001703 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001704 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1705 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001706 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001707 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001708 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001709}
1710
Johnny Chen020023a2010-03-23 20:40:44 +00001711class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001712 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001713 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001714 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001715 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001716 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001717 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001718}
1719
1720// NEON "one register and a modified immediate" format.
1721class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1722 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001723 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001724 string opc, string dt, string asm, string cstr,
1725 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001726 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001727 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001728 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001729 let Inst{11-8} = op11_8;
1730 let Inst{7} = op7;
1731 let Inst{6} = op6;
1732 let Inst{5} = op5;
1733 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001734
Owen Anderson284cb362010-10-26 17:40:54 +00001735 // Instruction operands.
1736 bits<5> Vd;
1737 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001738
Owen Anderson284cb362010-10-26 17:40:54 +00001739 let Inst{15-12} = Vd{3-0};
1740 let Inst{22} = Vd{4};
1741 let Inst{24} = SIMM{7};
1742 let Inst{18-16} = SIMM{6-4};
1743 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001744 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001745}
1746
1747// NEON 2 vector register format.
1748class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1749 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001750 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001751 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001752 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001753 let Inst{24-23} = op24_23;
1754 let Inst{21-20} = op21_20;
1755 let Inst{19-18} = op19_18;
1756 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001757 let Inst{11-7} = op11_7;
1758 let Inst{6} = op6;
1759 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001760
Owen Anderson24774462010-10-25 18:43:52 +00001761 // Instruction operands.
1762 bits<5> Vd;
1763 bits<5> Vm;
1764
1765 let Inst{15-12} = Vd{3-0};
1766 let Inst{22} = Vd{4};
1767 let Inst{3-0} = Vm{3-0};
1768 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001769}
1770
1771// Same as N2V except it doesn't have a datatype suffix.
1772class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001773 bits<5> op11_7, bit op6, bit op4,
1774 dag oops, dag iops, InstrItinClass itin,
1775 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001776 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001777 let Inst{24-23} = op24_23;
1778 let Inst{21-20} = op21_20;
1779 let Inst{19-18} = op19_18;
1780 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001781 let Inst{11-7} = op11_7;
1782 let Inst{6} = op6;
1783 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001784
Owen Anderson24774462010-10-25 18:43:52 +00001785 // Instruction operands.
1786 bits<5> Vd;
1787 bits<5> Vm;
1788
1789 let Inst{15-12} = Vd{3-0};
1790 let Inst{22} = Vd{4};
1791 let Inst{3-0} = Vm{3-0};
1792 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001793}
1794
1795// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001796class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001797 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001798 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001799 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001800 let Inst{24} = op24;
1801 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001802 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001803 let Inst{7} = op7;
1804 let Inst{6} = op6;
1805 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001806
Owen Anderson3665fee2010-10-26 20:56:57 +00001807 // Instruction operands.
1808 bits<5> Vd;
1809 bits<5> Vm;
1810 bits<6> SIMM;
1811
1812 let Inst{15-12} = Vd{3-0};
1813 let Inst{22} = Vd{4};
1814 let Inst{3-0} = Vm{3-0};
1815 let Inst{5} = Vm{4};
1816 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001817}
1818
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001819// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00001820
Jim Grosbacheca54e42011-05-19 17:34:53 +00001821class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1822 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1823 string opc, string dt, string asm, string cstr,
1824 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00001825 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001826 let Inst{24} = op24;
1827 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00001828 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001829 let Inst{11-8} = op11_8;
1830 let Inst{6} = op6;
1831 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00001832}
1833
1834class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1835 dag oops, dag iops, Format f, InstrItinClass itin,
1836 string opc, string dt, string asm, string cstr, list<dag> pattern>
1837 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1838 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbach5876e412010-11-19 22:42:55 +00001839
Owen Anderson9e44cf22010-10-21 20:21:49 +00001840 // Instruction operands.
1841 bits<5> Vd;
1842 bits<5> Vn;
1843 bits<5> Vm;
1844
1845 let Inst{15-12} = Vd{3-0};
1846 let Inst{22} = Vd{4};
1847 let Inst{19-16} = Vn{3-0};
1848 let Inst{7} = Vn{4};
1849 let Inst{3-0} = Vm{3-0};
1850 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001851}
1852
Jim Grosbacheca54e42011-05-19 17:34:53 +00001853class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1854 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1855 string opc, string dt, string asm, string cstr,
1856 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001857 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1858 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1859
1860 // Instruction operands.
1861 bits<5> Vd;
1862 bits<5> Vn;
1863 bits<5> Vm;
1864 bit lane;
1865
1866 let Inst{15-12} = Vd{3-0};
1867 let Inst{22} = Vd{4};
1868 let Inst{19-16} = Vn{3-0};
1869 let Inst{7} = Vn{4};
1870 let Inst{3-0} = Vm{3-0};
1871 let Inst{5} = lane;
1872}
1873
Jim Grosbacheca54e42011-05-19 17:34:53 +00001874class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1875 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1876 string opc, string dt, string asm, string cstr,
1877 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001878 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1879 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1880
1881 // Instruction operands.
1882 bits<5> Vd;
1883 bits<5> Vn;
1884 bits<5> Vm;
1885 bits<2> lane;
1886
1887 let Inst{15-12} = Vd{3-0};
1888 let Inst{22} = Vd{4};
1889 let Inst{19-16} = Vn{3-0};
1890 let Inst{7} = Vn{4};
1891 let Inst{2-0} = Vm{2-0};
1892 let Inst{5} = lane{1};
1893 let Inst{3} = lane{0};
1894}
1895
Johnny Chen8a687232010-03-23 21:35:03 +00001896// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001897class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1898 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001899 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001900 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001901 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001902 let Inst{24} = op24;
1903 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001904 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001905 let Inst{11-8} = op11_8;
1906 let Inst{6} = op6;
1907 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001908
Owen Andersondff239c2010-10-25 18:28:30 +00001909 // Instruction operands.
1910 bits<5> Vd;
1911 bits<5> Vn;
1912 bits<5> Vm;
1913
1914 let Inst{15-12} = Vd{3-0};
1915 let Inst{22} = Vd{4};
1916 let Inst{19-16} = Vn{3-0};
1917 let Inst{7} = Vn{4};
1918 let Inst{3-0} = Vm{3-0};
1919 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001920}
1921
1922// NEON VMOVs between scalar and core registers.
1923class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001924 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001925 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001926 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001927 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001928 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001929 let Inst{11-8} = opcod2;
1930 let Inst{6-5} = opcod3;
1931 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00001932 // A8.6.303, A8.6.328, A8.6.329
1933 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00001934
1935 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001936 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001937 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001938 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001939 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001940
Chris Lattner63274cb2010-11-15 05:19:05 +00001941 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001942 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00001943
Owen Andersoned9652f2010-10-27 21:28:09 +00001944 bits<5> V;
1945 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001946 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001947 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001948
Owen Anderson40d24a42010-10-27 19:25:54 +00001949 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001950 let Inst{7} = V{4};
1951 let Inst{19-16} = V{3-0};
1952 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001953}
1954class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001955 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001956 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001957 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001958 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001959class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001960 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001961 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001962 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001963 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001964class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001965 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001966 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001967 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001968 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001969
Johnny Chen45ab3f32010-03-25 17:01:27 +00001970// Vector Duplicate Lane (from scalar to all elements)
1971class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1972 InstrItinClass itin, string opc, string dt, string asm,
1973 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001974 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001975 let Inst{24-23} = 0b11;
1976 let Inst{21-20} = 0b11;
1977 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001978 let Inst{11-7} = 0b11000;
1979 let Inst{6} = op6;
1980 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001981
Owen Anderson40d24a42010-10-27 19:25:54 +00001982 bits<5> Vd;
1983 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001984
Owen Anderson40d24a42010-10-27 19:25:54 +00001985 let Inst{22} = Vd{4};
1986 let Inst{15-12} = Vd{3-0};
1987 let Inst{5} = Vm{4};
1988 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00001989}
1990
David Goodwin3b9c52c2009-08-04 17:53:06 +00001991// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1992// for single-precision FP.
1993class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1994 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1995}
Jim Grosbach7996b152011-11-14 22:28:39 +00001996
1997// VFP/NEON Instruction aliases for type suffices.
1998class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
Jim Grosbachfdf9e152011-12-05 20:29:59 +00001999 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002000
Jim Grosbach3d6c0e02011-11-14 23:11:19 +00002001multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002002 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2003 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2004 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2005 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002006}
2007
2008// The same alias classes using AsmPseudo instead, for the more complex
2009// stuff in NEON that InstAlias can't quite handle.
2010// Note that we can't use anonymous defm references here like we can
2011// above, as we care about the ultimate instruction enum names generated, unlike
2012// for instalias defs.
2013class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002014 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002015multiclass NEONDT8ReqAsmPseudoInst<string opc, string asm, dag iops> {
2016 def I8 : NEONDataTypeAsmPseudoInst<opc, ".i8", asm, iops>;
2017 def S8 : NEONDataTypeAsmPseudoInst<opc, ".s8", asm, iops>;
2018 def U8 : NEONDataTypeAsmPseudoInst<opc, ".u8", asm, iops>;
2019 def P8 : NEONDataTypeAsmPseudoInst<opc, ".p8", asm, iops>;
2020}
2021// NEONDT8ReqAsmPseudoInst plus plain ".8"
2022multiclass NEONDT8AsmPseudoInst<string opc, string asm, dag iops> {
2023 def _8 : NEONDataTypeAsmPseudoInst<opc, ".8", asm, iops>;
2024 defm _ : NEONDT8ReqAsmPseudoInst<opc, asm, iops>;
2025}
2026multiclass NEONDT16ReqAsmPseudoInst<string opc, string asm, dag iops> {
2027 def I16 : NEONDataTypeAsmPseudoInst<opc, ".i16", asm, iops>;
2028 def S16 : NEONDataTypeAsmPseudoInst<opc, ".s16", asm, iops>;
2029 def U16 : NEONDataTypeAsmPseudoInst<opc, ".u16", asm, iops>;
2030 def P16 : NEONDataTypeAsmPseudoInst<opc, ".p16", asm, iops>;
2031}
2032// NEONDT16ReqAsmPseudoInst plus plain ".16"
2033multiclass NEONDT16AsmPseudoInst<string opc, string asm, dag iops> {
2034 def _16 : NEONDataTypeAsmPseudoInst<opc, ".16", asm, iops>;
2035 defm _ : NEONDT16ReqAsmPseudoInst<opc, asm, iops>;
2036}
2037multiclass NEONDT32ReqAsmPseudoInst<string opc, string asm, dag iops> {
2038 def I32 : NEONDataTypeAsmPseudoInst<opc, ".i32", asm, iops>;
2039 def S32 : NEONDataTypeAsmPseudoInst<opc, ".s32", asm, iops>;
2040 def U32 : NEONDataTypeAsmPseudoInst<opc, ".u32", asm, iops>;
2041 def F32 : NEONDataTypeAsmPseudoInst<opc, ".f32", asm, iops>;
2042 def F : NEONDataTypeAsmPseudoInst<opc, ".f", asm, iops>;
2043}
2044// NEONDT32ReqAsmPseudoInst plus plain ".32"
2045multiclass NEONDT32AsmPseudoInst<string opc, string asm, dag iops> {
2046 def _32 : NEONDataTypeAsmPseudoInst<opc, ".32", asm, iops>;
2047 defm _ : NEONDT32ReqAsmPseudoInst<opc, asm, iops>;
2048}
2049multiclass NEONDT64ReqAsmPseudoInst<string opc, string asm, dag iops> {
2050 def I64 : NEONDataTypeAsmPseudoInst<opc, ".i64", asm, iops>;
2051 def S64 : NEONDataTypeAsmPseudoInst<opc, ".s64", asm, iops>;
2052 def U64 : NEONDataTypeAsmPseudoInst<opc, ".u64", asm, iops>;
2053 def F64 : NEONDataTypeAsmPseudoInst<opc, ".f64", asm, iops>;
2054 def D : NEONDataTypeAsmPseudoInst<opc, ".d", asm, iops>;
2055}
2056// NEONDT64ReqAsmPseudoInst plus plain ".64"
2057multiclass NEONDT64AsmPseudoInst<string opc, string asm, dag iops> {
2058 def _64 : NEONDataTypeAsmPseudoInst<opc, ".64", asm, iops>;
2059 defm _ : NEONDT64ReqAsmPseudoInst<opc, asm, iops>;
2060}
2061multiclass NEONDT64NoF64ReqAsmPseudoInst<string opc, string asm, dag iops> {
2062 def I64 : NEONDataTypeAsmPseudoInst<opc, ".i64", asm, iops>;
2063 def S64 : NEONDataTypeAsmPseudoInst<opc, ".s64", asm, iops>;
2064 def U64 : NEONDataTypeAsmPseudoInst<opc, ".u64", asm, iops>;
2065 def D : NEONDataTypeAsmPseudoInst<opc, ".d", asm, iops>;
2066}
2067// NEONDT64ReqAsmPseudoInst plus plain ".64"
2068multiclass NEONDT64NoF64AsmPseudoInst<string opc, string asm, dag iops> {
2069 def _64 : NEONDataTypeAsmPseudoInst<opc, ".64", asm, iops>;
2070 defm _ : NEONDT64ReqAsmPseudoInst<opc, asm, iops>;
2071}
2072multiclass NEONDTAnyAsmPseudoInst<string opc, string asm, dag iops> {
2073 defm _ : NEONDT8AsmPseudoInst<opc, asm, iops>;
2074 defm _ : NEONDT16AsmPseudoInst<opc, asm, iops>;
2075 defm _ : NEONDT32AsmPseudoInst<opc, asm, iops>;
2076 defm _ : NEONDT64AsmPseudoInst<opc, asm, iops>;
2077}
2078multiclass NEONDTAnyNoF64AsmPseudoInst<string opc, string asm, dag iops> {
2079 defm _ : NEONDT8AsmPseudoInst<opc, asm, iops>;
2080 defm _ : NEONDT16AsmPseudoInst<opc, asm, iops>;
2081 defm _ : NEONDT32AsmPseudoInst<opc, asm, iops>;
2082 defm _ : NEONDT64NoF64AsmPseudoInst<opc, asm, iops>;
Jim Grosbach003cea62011-11-15 22:54:42 +00002083}
Jim Grosbach585ce302011-12-07 01:17:58 +00002084
2085// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2086def : TokenAlias<".s8", ".i8">;
2087def : TokenAlias<".u8", ".i8">;
2088def : TokenAlias<".s16", ".i16">;
2089def : TokenAlias<".u16", ".i16">;
2090def : TokenAlias<".s32", ".i32">;
2091def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002092def : TokenAlias<".s64", ".i64">;
2093def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002094
2095def : TokenAlias<".i8", ".8">;
2096def : TokenAlias<".i16", ".16">;
2097def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002098def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002099
2100def : TokenAlias<".p8", ".8">;
2101def : TokenAlias<".p16", ".16">;
2102
2103def : TokenAlias<".f32", ".32">;
2104def : TokenAlias<".f64", ".64">;
2105def : TokenAlias<".f", ".f32">;
2106def : TokenAlias<".d", ".f64">;