blob: 6d5b6a461574a1da8d43fe9c63f803ff2c97adee [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 Grosbach6caa5572011-08-22 18:04:24 +0000234
235//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000236// ARM Instruction templates.
237//
238
Jim Grosbach6caa5572011-08-22 18:04:24 +0000239
Owen Anderson651b2302011-07-13 23:22:26 +0000240class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000241 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000242 : Instruction {
243 let Namespace = "ARM";
244
Evan Cheng2d37f192008-08-28 23:39:26 +0000245 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000246 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000247 IndexMode IM = im;
248 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000249 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000250 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000251 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000252 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000253 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000254 // The instruction is a 16-bit flag setting Thumb instruction. Used
255 // by the parser to determine whether to require the 'S' suffix on the
256 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
257 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000258
Chris Lattner7ff33462010-10-31 19:22:57 +0000259 // If this is a pseudo instruction, mark it isCodeGenOnly.
260 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000261
Jim Grosbach30694dc2011-08-15 16:52:24 +0000262 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000263 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000264 let TSFlags{6-5} = IndexModeBits;
265 let TSFlags{12-7} = Form;
266 let TSFlags{13} = isUnaryDataProc;
267 let TSFlags{14} = canXformTo16Bit;
268 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000269 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000270
Evan Cheng2d37f192008-08-28 23:39:26 +0000271 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000272 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000273}
274
Johnny Chenc28e6292009-12-15 17:24:14 +0000275class Encoding {
276 field bits<32> Inst;
277}
278
Owen Anderson651b2302011-07-13 23:22:26 +0000279class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000280 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000281 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
282 let DecoderNamespace = "ARM";
283}
Johnny Chenc28e6292009-12-15 17:24:14 +0000284
285// This Encoding-less class is used by Thumb1 to specify the encoding bits later
286// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000287class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000288 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000289 : InstTemplate<am, sz, im, f, d, cstr, itin> {
290 let DecoderNamespace = "Thumb";
291}
Johnny Chenc28e6292009-12-15 17:24:14 +0000292
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000293// Pseudo-instructions for alternate assembly syntax (never used by codegen).
294// These are aliases that require C++ handling to convert to the target
295// instruction, while InstAliases can be handled directly by tblgen.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000296class AsmPseudoInst<string asm, dag iops>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000297 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
298 "", NoItinerary> {
Jim Grosbach61db5a52011-11-10 16:44:55 +0000299 let OutOperandList = (outs);
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000300 let InOperandList = iops;
301 let Pattern = [];
302 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000303 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000304 let isPseudo = 1;
305}
306
Jim Grosbach61db5a52011-11-10 16:44:55 +0000307class ARMAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
308 Requires<[IsARM]>;
309class tAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
310 Requires<[IsThumb]>;
311class t2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
312 Requires<[IsThumb2]>;
313class VFP2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
314 Requires<[HasVFP2]>;
315class NEONAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
316 Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000317
318// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000319class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000320 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000321 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000322 let OutOperandList = oops;
323 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000324 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000325 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000326 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000327}
328
Jim Grosbachcfb66202010-11-18 01:15:56 +0000329// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000330class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000331 list<dag> pattern>
332 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000333 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000334 list<Predicate> Predicates = [IsARM];
335}
336
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000337// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000338class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000339 list<dag> pattern>
340 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000341 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000342 list<Predicate> Predicates = [IsThumb];
343}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000344
Jim Grosbachd42257c2010-12-15 18:48:45 +0000345// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000346class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000347 list<dag> pattern>
348 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000349 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000350 list<Predicate> Predicates = [IsThumb2];
351}
Jim Grosbach95dee402011-07-08 17:40:42 +0000352
Owen Anderson651b2302011-07-13 23:22:26 +0000353class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000354 InstrItinClass itin, list<dag> pattern,
355 dag Result>
356 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
357 PseudoInstExpansion<Result>;
358
Owen Anderson651b2302011-07-13 23:22:26 +0000359class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000360 InstrItinClass itin, list<dag> pattern,
361 dag Result>
362 : tPseudoInst<oops, iops, sz, itin, pattern>,
363 PseudoInstExpansion<Result>;
364
Owen Anderson651b2302011-07-13 23:22:26 +0000365class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000366 InstrItinClass itin, list<dag> pattern,
367 dag Result>
368 : t2PseudoInst<oops, iops, sz, itin, pattern>,
369 PseudoInstExpansion<Result>;
370
Evan Cheng2d37f192008-08-28 23:39:26 +0000371// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000372class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000373 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000374 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000375 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000376 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000377 bits<4> p;
378 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000379 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000380 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000381 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000382 let Pattern = pattern;
383 list<Predicate> Predicates = [IsARM];
384}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000385
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000386// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000387class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000388 IndexMode im, Format f, InstrItinClass itin,
389 string opc, string asm, string cstr,
390 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000391 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
392 let OutOperandList = oops;
393 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000394 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000395 let Pattern = pattern;
396 let isPredicable = 0;
397 list<Predicate> Predicates = [IsARM];
398}
Evan Cheng2d37f192008-08-28 23:39:26 +0000399
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000400// Same as I except it can optionally modify CPSR. Note it's modeled as an input
401// operand since by default it's a zero register. It will become an implicit def
402// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000403class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000404 IndexMode im, Format f, InstrItinClass itin,
405 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000406 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000407 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000408 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000409 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000410 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000411 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000412
Evan Cheng2d37f192008-08-28 23:39:26 +0000413 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000414 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000415 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000416 let Pattern = pattern;
417 list<Predicate> Predicates = [IsARM];
418}
419
Evan Chenga2827232008-09-01 07:19:00 +0000420// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000421class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000422 IndexMode im, Format f, InstrItinClass itin,
423 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000424 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000425 let OutOperandList = oops;
426 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000427 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000428 let Pattern = pattern;
429 list<Predicate> Predicates = [IsARM];
430}
431
David Goodwinb062c232009-08-06 16:52:47 +0000432class AI<dag oops, dag iops, Format f, InstrItinClass itin,
433 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000434 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000435 opc, asm, "", pattern>;
436class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
437 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000438 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000439 opc, asm, "", pattern>;
440class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000441 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000442 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000443 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000444class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000445 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000446 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000447 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000448
449// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000450class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
451 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000452 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000453 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000454 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000455}
David Goodwinb062c232009-08-06 16:52:47 +0000456class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
457 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000458 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000459 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000460 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000461}
Evan Chengfa558782008-09-01 08:25:56 +0000462
463// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000464class JTI<dag oops, dag iops, InstrItinClass itin,
465 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000466 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000467 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000468
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000469// Atomic load/store instructions
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000470class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
471 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000472 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000473 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000474 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000475 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000476 let Inst{27-23} = 0b00011;
477 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000478 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000479 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000480 let Inst{15-12} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000481 let Inst{11-0} = 0b111110011111;
482}
483class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
484 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000485 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000486 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000487 bits<4> Rd;
488 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000489 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000490 let Inst{27-23} = 0b00011;
491 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000492 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000493 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000494 let Inst{15-12} = Rd;
Johnny Chen098bd1b2009-12-11 19:37:26 +0000495 let Inst{11-4} = 0b11111001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000496 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000497}
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000498class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000499 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000500 bits<4> Rt;
501 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000502 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000503 let Inst{27-23} = 0b00010;
504 let Inst{22} = b;
505 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000506 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000507 let Inst{15-12} = Rt;
508 let Inst{11-4} = 0b00001001;
509 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000510
511 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000512}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000513
Evan Cheng624844b2008-09-01 01:51:14 +0000514// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000515class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
516 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000517 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000518 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000519 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000520 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000521}
David Goodwinb062c232009-08-06 16:52:47 +0000522class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
523 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000524 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000525 opc, asm, "", pattern> {
526 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000527 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000528}
529class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000530 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000531 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000532 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000533 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000534 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000535}
Evan Cheng624844b2008-09-01 01:51:14 +0000536
Evan Chengcccca872008-09-01 01:27:33 +0000537// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000538
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000539// LDR/LDRB/STR/STRB/...
540class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000541 Format f, InstrItinClass itin, string opc, string asm,
542 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000543 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000544 "", pattern> {
545 let Inst{27-25} = op;
546 let Inst{24} = 1; // 24 == P
547 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000548 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000549 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000550 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000551}
Jim Grosbach2f790742010-11-13 00:35:48 +0000552// Indexed load/stores
553class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000554 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000555 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000556 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000557 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000558 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000559 let Inst{27-26} = 0b01;
560 let Inst{24} = isPre; // P bit
561 let Inst{22} = isByte; // B bit
562 let Inst{21} = isPre; // W bit
563 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000564 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000565}
Owen Anderson2aedba62011-07-26 20:54:26 +0000566class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000567 IndexMode im, Format f, InstrItinClass itin, string opc,
568 string asm, string cstr, list<dag> pattern>
569 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
570 pattern> {
571 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000572 // {12} isAdd
573 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000574 bits<14> offset;
575 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000576 let Inst{25} = 1;
577 let Inst{23} = offset{12};
578 let Inst{19-16} = Rn;
579 let Inst{11-5} = offset{11-5};
580 let Inst{4} = 0;
581 let Inst{3-0} = offset{3-0};
582}
583
584class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
585 IndexMode im, Format f, InstrItinClass itin, string opc,
586 string asm, string cstr, list<dag> pattern>
587 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
588 pattern> {
589 // AM2 store w/ two operands: (GPR, am2offset)
590 // {12} isAdd
591 // {11-0} imm12/Rm
592 bits<14> offset;
593 bits<4> Rn;
594 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000595 let Inst{23} = offset{12};
596 let Inst{19-16} = Rn;
597 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000598}
Owen Anderson2aedba62011-07-26 20:54:26 +0000599
600
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000601// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
602// but for now use this class for STRT and STRBT.
603class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
604 IndexMode im, Format f, InstrItinClass itin, string opc,
605 string asm, string cstr, list<dag> pattern>
606 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
607 pattern> {
608 // AM2 store w/ two operands: (GPR, am2offset)
609 // {17-14} Rn
610 // {13} 1 == Rm, 0 == imm12
611 // {12} isAdd
612 // {11-0} imm12/Rm
613 bits<18> addr;
614 let Inst{25} = addr{13};
615 let Inst{23} = addr{12};
616 let Inst{19-16} = addr{17-14};
617 let Inst{11-0} = addr{11-0};
618}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000619
Evan Cheng624844b2008-09-01 01:51:14 +0000620// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000621class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
622 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000623 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000624 opc, asm, "", pattern> {
625 bits<14> addr;
626 bits<4> Rt;
627 let Inst{27-25} = 0b000;
628 let Inst{24} = 1; // P bit
629 let Inst{23} = addr{8}; // U bit
630 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
631 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000632 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000633 let Inst{19-16} = addr{12-9}; // Rn
634 let Inst{15-12} = Rt; // Rt
635 let Inst{11-8} = addr{7-4}; // imm7_4/zero
636 let Inst{7-4} = op;
637 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000638
639 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000640}
Evan Cheng169eccc2008-09-01 07:00:14 +0000641
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000642class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000643 IndexMode im, Format f, InstrItinClass itin, string opc,
644 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000645 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000646 opc, asm, cstr, pattern> {
647 bits<4> Rt;
648 let Inst{27-25} = 0b000;
649 let Inst{24} = isPre; // P bit
650 let Inst{21} = isPre; // W bit
651 let Inst{20} = op20; // L bit
652 let Inst{15-12} = Rt; // Rt
653 let Inst{7-4} = op;
654}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000655
656// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
657// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000658class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000659 IndexMode im, Format f, InstrItinClass itin, string opc,
660 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000661 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000662 // {13} 1 == imm8, 0 == Rm
663 // {12-9} Rn
664 // {8} isAdd
665 // {7-4} imm7_4/zero
666 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000667 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000668 bits<4> Rt;
669 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000670 let Inst{24} = 0; // P bit
671 let Inst{21} = 1;
672 let Inst{20} = isLoad; // L bit
673 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000674 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000675 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000676}
677
Evan Cheng169eccc2008-09-01 07:00:14 +0000678// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000679class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000680 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000681 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000682 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000683 bits<14> addr;
684 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000685 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000686 let Inst{24} = 1; // P bit
687 let Inst{23} = addr{8}; // U bit
688 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
689 let Inst{21} = 0; // W bit
690 let Inst{20} = 0; // L bit
691 let Inst{19-16} = addr{12-9}; // Rn
692 let Inst{15-12} = Rt; // Rt
693 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000694 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000695 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000696 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000697}
Evan Cheng169eccc2008-09-01 07:00:14 +0000698
Evan Cheng624844b2008-09-01 01:51:14 +0000699// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000700class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
701 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000702 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000703 bits<4> p;
704 bits<16> regs;
705 bits<4> Rn;
706 let Inst{31-28} = p;
707 let Inst{27-25} = 0b100;
708 let Inst{22} = 0; // S bit
709 let Inst{19-16} = Rn;
710 let Inst{15-0} = regs;
711}
Evan Cheng2d37f192008-08-28 23:39:26 +0000712
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000713// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000714class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
715 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000716 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000717 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000718 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000719 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000720 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000721}
David Goodwinb062c232009-08-06 16:52:47 +0000722class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
723 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000724 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000725 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000726 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000727 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000728}
729
730// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000731class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
732 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000733 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000734 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000735 bits<4> Rd;
736 bits<4> Rn;
737 bits<4> Rm;
738 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000739 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000740 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000741 let Inst{19-16} = Rd;
742 let Inst{11-8} = Rm;
743 let Inst{3-0} = Rn;
744}
745// MSW multiple w/ Ra operand
746class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
747 InstrItinClass itin, string opc, string asm, list<dag> pattern>
748 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
749 bits<4> Ra;
750 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000751}
Evan Cheng2d37f192008-08-28 23:39:26 +0000752
Evan Cheng36ae4032008-11-06 03:35:07 +0000753// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000754class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000755 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000756 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000757 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000758 bits<4> Rn;
759 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000760 let Inst{4} = 0;
761 let Inst{7} = 1;
762 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000763 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000764 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000765 let Inst{11-8} = Rm;
766 let Inst{3-0} = Rn;
767}
768class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
769 InstrItinClass itin, string opc, string asm, list<dag> pattern>
770 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
771 bits<4> Rd;
772 let Inst{19-16} = Rd;
773}
774
775// AMulxyI with Ra operand
776class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
777 InstrItinClass itin, string opc, string asm, list<dag> pattern>
778 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
779 bits<4> Ra;
780 let Inst{15-12} = Ra;
781}
782// SMLAL*
783class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
784 InstrItinClass itin, string opc, string asm, list<dag> pattern>
785 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
786 bits<4> RdLo;
787 bits<4> RdHi;
788 let Inst{19-16} = RdHi;
789 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000790}
791
Evan Cheng49d66522008-11-06 22:15:19 +0000792// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000793class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
794 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000795 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000796 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000797 // All AExtI instructions have Rd and Rm register operands.
798 bits<4> Rd;
799 bits<4> Rm;
800 let Inst{15-12} = Rd;
801 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000802 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000803 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000804 let Inst{27-20} = opcod;
805}
806
Evan Cheng98dc53e2008-11-07 01:41:35 +0000807// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000808class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
809 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000810 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000811 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000812 bits<4> Rd;
813 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000814 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000815 let Inst{19-16} = 0b1111;
816 let Inst{15-12} = Rd;
817 let Inst{11-8} = 0b1111;
818 let Inst{7-4} = opc7_4;
819 let Inst{3-0} = Rm;
820}
821
822// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000823def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000824 let Name = "PKHLSLImm";
825 let ParserMethod = "parsePKHLSLImm";
826}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000827def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
828 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000829 let ParserMatchClass = PKHLSLAsmOperand;
830}
831def PKHASRAsmOperand : AsmOperandClass {
832 let Name = "PKHASRImm";
833 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000834}
835def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
836 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000837 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000838}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000839
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000840class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
841 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000842 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000843 opc, asm, "", pattern> {
844 bits<4> Rd;
845 bits<4> Rn;
846 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000847 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000848 let Inst{27-20} = opcod;
849 let Inst{19-16} = Rn;
850 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000851 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000852 let Inst{6} = tb;
853 let Inst{5-4} = 0b01;
854 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000855}
856
Evan Cheng2d37f192008-08-28 23:39:26 +0000857//===----------------------------------------------------------------------===//
858
859// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
860class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
861 list<Predicate> Predicates = [IsARM];
862}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000863class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
864 list<Predicate> Predicates = [IsARM, HasV5T];
865}
Evan Cheng2d37f192008-08-28 23:39:26 +0000866class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
867 list<Predicate> Predicates = [IsARM, HasV5TE];
868}
869class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
870 list<Predicate> Predicates = [IsARM, HasV6];
871}
Evan Chengee98fa92008-08-29 06:41:12 +0000872
873//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000874// Thumb Instruction Format Definitions.
875//
876
Owen Anderson651b2302011-07-13 23:22:26 +0000877class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000878 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000879 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000880 let OutOperandList = oops;
881 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000882 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000883 let Pattern = pattern;
884 list<Predicate> Predicates = [IsThumb];
885}
886
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000887// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000888class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000889 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000890
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000891// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000892class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
893 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000894 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000895 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000896
Johnny Chenc28e6292009-12-15 17:24:14 +0000897// tBL, tBX 32-bit instructions
898class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000899 dag oops, dag iops, InstrItinClass itin, string asm,
900 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000901 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000902 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +0000903 let Inst{31-27} = opcod1;
904 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000905 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +0000906}
Evan Chengee98fa92008-08-29 06:41:12 +0000907
908// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000909class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
910 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000911 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000912
Evan Chengbec1dba892009-06-23 19:38:13 +0000913// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +0000914class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000915 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000916 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000917 let OutOperandList = oops;
918 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000919 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +0000920 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000921 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +0000922}
923
David Goodwinb062c232009-08-06 16:52:47 +0000924class T1I<dag oops, dag iops, InstrItinClass itin,
925 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000926 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +0000927class T1Ix2<dag oops, dag iops, InstrItinClass itin,
928 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000929 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000930
931// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000932class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000933 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000934 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000935 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000936
937// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +0000938class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000939 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000940 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000941 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000942 let OutOperandList = !con(oops, (outs s_cc_out:$s));
943 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000944 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000945 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000946 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000947 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +0000948 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000949}
950
David Goodwinb062c232009-08-06 16:52:47 +0000951class T1sI<dag oops, dag iops, InstrItinClass itin,
952 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000953 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000954
955// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000956class T1sIt<dag oops, dag iops, InstrItinClass itin,
957 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000958 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +0000959 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000960
961// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +0000962class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000963 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000964 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000965 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000966 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000967 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000968 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000969 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000970 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000971}
972
David Goodwinb062c232009-08-06 16:52:47 +0000973class T1pI<dag oops, dag iops, InstrItinClass itin,
974 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000975 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000976
977// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000978class T1pIt<dag oops, dag iops, InstrItinClass itin,
979 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000980 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +0000981 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000982
Bob Wilson3968c6a2010-03-23 17:23:59 +0000983class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +0000984 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000985 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000986
Johnny Chen466231a2009-12-16 02:32:54 +0000987class Encoding16 : Encoding {
988 let Inst{31-16} = 0x0000;
989}
990
Johnny Chenc28e6292009-12-15 17:24:14 +0000991// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +0000992class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000993 let Inst{15-10} = opcode;
994}
995
996// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000997class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000998 let Inst{15-14} = 0b00;
999 let Inst{13-9} = opcode;
1000}
1001
1002// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001003class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001004 let Inst{15-10} = 0b010000;
1005 let Inst{9-6} = opcode;
1006}
1007
1008// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001009class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001010 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001011 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001012}
1013
1014// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001015class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001016 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001017 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001018}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001019class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001020
Eric Christopher9b67db82011-05-27 03:50:53 +00001021class T1BranchCond<bits<4> opcode> : Encoding16 {
1022 let Inst{15-12} = opcode;
1023}
1024
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001025// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001026// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001027//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001028// 0b0110 => Immediate, 4 bytes
1029// 0b1000 => Immediate, 2 bytes
1030// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001031class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1032 InstrItinClass itin, string opc, string asm,
1033 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001034 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001035 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001036 bits<3> Rt;
1037 bits<8> addr;
1038 let Inst{8-6} = addr{5-3}; // Rm
1039 let Inst{5-3} = addr{2-0}; // Rn
1040 let Inst{2-0} = Rt;
1041}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001042class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1043 InstrItinClass itin, string opc, string asm,
1044 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001045 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001046 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001047 bits<3> Rt;
1048 bits<8> addr;
1049 let Inst{10-6} = addr{7-3}; // imm5
1050 let Inst{5-3} = addr{2-0}; // Rn
1051 let Inst{2-0} = Rt;
1052}
1053
Johnny Chenc28e6292009-12-15 17:24:14 +00001054// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001055class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001056 let Inst{15-12} = 0b1011;
1057 let Inst{11-5} = opcode;
1058}
1059
Evan Chengd76f0be2009-06-25 02:08:06 +00001060// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001061class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001062 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001063 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001064 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001065 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001066 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001067 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001068 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001069 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001070 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001071}
1072
Bill Wendlingb70dc872010-08-31 07:50:46 +00001073// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1074// input operand since by default it's a zero register. It will become an
1075// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001076//
Evan Chengd76f0be2009-06-25 02:08:06 +00001077// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1078// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001079class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001080 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001081 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001082 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001083 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1084 let Inst{20} = s;
1085
Evan Chengd76f0be2009-06-25 02:08:06 +00001086 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001087 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001088 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001089 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001090 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001091 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001092}
1093
1094// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001095class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001096 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001097 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001098 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001099 let OutOperandList = oops;
1100 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001101 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001102 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001103 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001104 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001105}
1106
Owen Anderson651b2302011-07-13 23:22:26 +00001107class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001108 InstrItinClass itin,
1109 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001110 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1111 let OutOperandList = oops;
1112 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001113 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001114 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001115 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001116 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001117}
1118
David Goodwinb062c232009-08-06 16:52:47 +00001119class T2I<dag oops, dag iops, InstrItinClass itin,
1120 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001121 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001122class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1123 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001124 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001125class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1126 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001127 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001128class T2Iso<dag oops, dag iops, InstrItinClass itin,
1129 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001130 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001131class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1132 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001133 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001134class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001135 string opc, string asm, string cstr, list<dag> pattern>
1136 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001137 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001138 bits<4> Rt;
1139 bits<4> Rt2;
1140 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001141 let Inst{31-25} = 0b1110100;
1142 let Inst{24} = P;
1143 let Inst{23} = addr{8};
1144 let Inst{22} = 1;
1145 let Inst{21} = W;
1146 let Inst{20} = isLoad;
1147 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001148 let Inst{15-12} = Rt{3-0};
1149 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001150 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001151}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001152class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1153 InstrItinClass itin, string opc, string asm, string cstr,
1154 list<dag> pattern>
1155 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001156 pattern> {
1157 bits<4> Rt;
1158 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001159 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001160 bits<9> imm;
1161 let Inst{31-25} = 0b1110100;
1162 let Inst{24} = P;
1163 let Inst{23} = imm{8};
1164 let Inst{22} = 1;
1165 let Inst{21} = W;
1166 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001167 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001168 let Inst{15-12} = Rt{3-0};
1169 let Inst{11-8} = Rt2{3-0};
1170 let Inst{7-0} = imm{7-0};
1171}
1172
David Goodwinb062c232009-08-06 16:52:47 +00001173class T2sI<dag oops, dag iops, InstrItinClass itin,
1174 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001175 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001176
David Goodwinb062c232009-08-06 16:52:47 +00001177class T2XI<dag oops, dag iops, InstrItinClass itin,
1178 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001179 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001180class T2JTI<dag oops, dag iops, InstrItinClass itin,
1181 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001182 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001183
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001184// Move to/from coprocessor instructions
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001185class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbachadb29b62011-07-13 21:14:23 +00001186 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001187 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001188}
1189
Bob Wilson947f04b2010-03-13 01:08:20 +00001190// Two-address instructions
1191class T2XIt<dag oops, dag iops, InstrItinClass itin,
1192 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001193 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001194
Jim Grosbachc086f682011-09-08 00:39:19 +00001195// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1196class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001197 dag oops, dag iops,
1198 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001199 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001200 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001201 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001202 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001203 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001204 let Pattern = pattern;
1205 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001206 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001207
1208 bits<4> Rt;
1209 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001210 let Inst{31-27} = 0b11111;
1211 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001212 let Inst{24} = signed;
1213 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001214 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001215 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001216 let Inst{19-16} = addr{12-9};
1217 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001218 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001219 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001220 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001221 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001222 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001223 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001224
1225 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001226}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001227
Jim Grosbachc086f682011-09-08 00:39:19 +00001228// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1229class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1230 dag oops, dag iops,
1231 AddrMode am, IndexMode im, InstrItinClass itin,
1232 string opc, string asm, string cstr, list<dag> pattern>
1233 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1234 let OutOperandList = oops;
1235 let InOperandList = !con(iops, (ins pred:$p));
1236 let AsmString = !strconcat(opc, "${p}", asm);
1237 let Pattern = pattern;
1238 list<Predicate> Predicates = [IsThumb2];
1239 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001240
Owen Andersone22c7322010-11-30 00:14:31 +00001241 bits<4> Rt;
1242 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001243 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001244 let Inst{31-27} = 0b11111;
1245 let Inst{26-25} = 0b00;
1246 let Inst{24} = signed;
1247 let Inst{23} = 0;
1248 let Inst{22-21} = opcod;
1249 let Inst{20} = load;
1250 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001251 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001252 let Inst{11} = 1;
1253 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1254 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001255 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001256 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001257 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001258
1259 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001260}
1261
David Goodwine5b969f2009-07-27 19:59:26 +00001262// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1263class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001264 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001265}
1266
1267// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1268class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001269 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001270}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001271
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001272// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1273class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1274 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1275}
1276
Evan Chengeab9ca72009-06-27 02:26:13 +00001277// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1278class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001279 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001280}
1281
Evan Chengee98fa92008-08-29 06:41:12 +00001282//===----------------------------------------------------------------------===//
1283
Evan Chengac2af2f2008-11-11 02:11:05 +00001284//===----------------------------------------------------------------------===//
1285// ARM VFP Instruction templates.
1286//
1287
David Goodwin81cdd212009-07-10 17:03:29 +00001288// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001289class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001290 IndexMode im, Format f, InstrItinClass itin,
1291 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001292 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001293 bits<4> p;
1294 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001295 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001296 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001297 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001298 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001299 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001300 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001301 list<Predicate> Predicates = [HasVFP2];
1302}
1303
1304// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001305class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001306 IndexMode im, Format f, InstrItinClass itin,
1307 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001308 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001309 bits<4> p;
1310 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001311 let OutOperandList = oops;
1312 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001313 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001314 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001315 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001316 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001317 list<Predicate> Predicates = [HasVFP2];
1318}
1319
David Goodwinb062c232009-08-06 16:52:47 +00001320class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1321 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001322 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001323 opc, asm, "", pattern> {
1324 let PostEncoderMethod = "VFPThumb2PostEncoder";
1325}
David Goodwin81cdd212009-07-10 17:03:29 +00001326
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001327// ARM VFP addrmode5 loads and stores
1328class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001329 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001330 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001331 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001332 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001333 // Instruction operands.
1334 bits<5> Dd;
1335 bits<13> addr;
1336
1337 // Encode instruction operands.
1338 let Inst{23} = addr{8}; // U (add = (U == '1'))
1339 let Inst{22} = Dd{4};
1340 let Inst{19-16} = addr{12-9}; // Rn
1341 let Inst{15-12} = Dd{3-0};
1342 let Inst{7-0} = addr{7-0}; // imm8
1343
Evan Chengac2af2f2008-11-11 02:11:05 +00001344 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001345 let Inst{27-24} = opcod1;
1346 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001347 let Inst{11-9} = 0b101;
1348 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001349
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001350 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001351 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001352}
1353
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001354class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001355 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001356 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001357 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001358 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001359 // Instruction operands.
1360 bits<5> Sd;
1361 bits<13> addr;
1362
1363 // Encode instruction operands.
1364 let Inst{23} = addr{8}; // U (add = (U == '1'))
1365 let Inst{22} = Sd{0};
1366 let Inst{19-16} = addr{12-9}; // Rn
1367 let Inst{15-12} = Sd{4-1};
1368 let Inst{7-0} = addr{7-0}; // imm8
1369
Evan Chengac2af2f2008-11-11 02:11:05 +00001370 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001371 let Inst{27-24} = opcod1;
1372 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001373 let Inst{11-9} = 0b101;
1374 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001375
1376 // Loads & stores operate on both NEON and VFP pipelines.
1377 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001378}
1379
Bob Wilson6b853c32010-09-16 00:31:02 +00001380// VFP Load / store multiple pseudo instructions.
1381class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1382 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001383 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001384 cstr, itin> {
1385 let OutOperandList = oops;
1386 let InOperandList = !con(iops, (ins pred:$p));
1387 let Pattern = pattern;
1388 list<Predicate> Predicates = [HasVFP2];
1389}
1390
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001391// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001392class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001393 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001394 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001395 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001396 // Instruction operands.
1397 bits<4> Rn;
1398 bits<13> regs;
1399
1400 // Encode instruction operands.
1401 let Inst{19-16} = Rn;
1402 let Inst{22} = regs{12};
1403 let Inst{15-12} = regs{11-8};
1404 let Inst{7-0} = regs{7-0};
1405
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001406 // TODO: Mark the instructions with the appropriate subtarget info.
1407 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001408 let Inst{11-9} = 0b101;
1409 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001410}
1411
Jim Grosbachabcbe242010-09-08 00:25:50 +00001412class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001413 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001414 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001415 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001416 // Instruction operands.
1417 bits<4> Rn;
1418 bits<13> regs;
1419
1420 // Encode instruction operands.
1421 let Inst{19-16} = Rn;
1422 let Inst{22} = regs{8};
1423 let Inst{15-12} = regs{12-9};
1424 let Inst{7-0} = regs{7-0};
1425
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001426 // TODO: Mark the instructions with the appropriate subtarget info.
1427 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001428 let Inst{11-9} = 0b101;
1429 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001430}
1431
Evan Chengac2af2f2008-11-11 02:11:05 +00001432// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001433class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1434 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1435 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001436 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001437 // Instruction operands.
1438 bits<5> Dd;
1439 bits<5> Dm;
1440
1441 // Encode instruction operands.
1442 let Inst{3-0} = Dm{3-0};
1443 let Inst{5} = Dm{4};
1444 let Inst{15-12} = Dd{3-0};
1445 let Inst{22} = Dd{4};
1446
Johnny Chen34a6afc2010-01-29 23:21:10 +00001447 let Inst{27-23} = opcod1;
1448 let Inst{21-20} = opcod2;
1449 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001450 let Inst{11-9} = 0b101;
1451 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001452 let Inst{7-6} = opcod4;
1453 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001454}
1455
1456// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001457class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001458 dag iops, InstrItinClass itin, string opc, string asm,
1459 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001460 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001461 // Instruction operands.
1462 bits<5> Dd;
1463 bits<5> Dn;
1464 bits<5> Dm;
1465
1466 // Encode instruction operands.
1467 let Inst{3-0} = Dm{3-0};
1468 let Inst{5} = Dm{4};
1469 let Inst{19-16} = Dn{3-0};
1470 let Inst{7} = Dn{4};
1471 let Inst{15-12} = Dd{3-0};
1472 let Inst{22} = Dd{4};
1473
Johnny Chen34a6afc2010-01-29 23:21:10 +00001474 let Inst{27-23} = opcod1;
1475 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001476 let Inst{11-9} = 0b101;
1477 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001478 let Inst{6} = op6;
1479 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001480}
1481
1482// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001483class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1484 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1485 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001486 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001487 // Instruction operands.
1488 bits<5> Sd;
1489 bits<5> Sm;
1490
1491 // Encode instruction operands.
1492 let Inst{3-0} = Sm{4-1};
1493 let Inst{5} = Sm{0};
1494 let Inst{15-12} = Sd{4-1};
1495 let Inst{22} = Sd{0};
1496
Johnny Chen34a6afc2010-01-29 23:21:10 +00001497 let Inst{27-23} = opcod1;
1498 let Inst{21-20} = opcod2;
1499 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001500 let Inst{11-9} = 0b101;
1501 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001502 let Inst{7-6} = opcod4;
1503 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001504}
1505
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001506// Single precision unary, if no NEON. Same as ASuI except not available if
1507// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001508class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1509 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1510 string asm, list<dag> pattern>
1511 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1512 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001513 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1514}
1515
Evan Chengac2af2f2008-11-11 02:11:05 +00001516// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001517class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1518 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001519 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001520 // Instruction operands.
1521 bits<5> Sd;
1522 bits<5> Sn;
1523 bits<5> Sm;
1524
1525 // Encode instruction operands.
1526 let Inst{3-0} = Sm{4-1};
1527 let Inst{5} = Sm{0};
1528 let Inst{19-16} = Sn{4-1};
1529 let Inst{7} = Sn{0};
1530 let Inst{15-12} = Sd{4-1};
1531 let Inst{22} = Sd{0};
1532
Johnny Chen34a6afc2010-01-29 23:21:10 +00001533 let Inst{27-23} = opcod1;
1534 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001535 let Inst{11-9} = 0b101;
1536 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001537 let Inst{6} = op6;
1538 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001539}
1540
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001541// Single precision binary, if no NEON. Same as ASbI except not available if
1542// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001543class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001544 dag iops, InstrItinClass itin, string opc, string asm,
1545 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001546 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001547 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001548
1549 // Instruction operands.
1550 bits<5> Sd;
1551 bits<5> Sn;
1552 bits<5> Sm;
1553
1554 // Encode instruction operands.
1555 let Inst{3-0} = Sm{4-1};
1556 let Inst{5} = Sm{0};
1557 let Inst{19-16} = Sn{4-1};
1558 let Inst{7} = Sn{0};
1559 let Inst{15-12} = Sd{4-1};
1560 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001561}
1562
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001563// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001564class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1565 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1566 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001567 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001568 let Inst{27-23} = opcod1;
1569 let Inst{21-20} = opcod2;
1570 let Inst{19-16} = opcod3;
1571 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001572 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001573 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001574}
1575
Johnny Chen39640592010-02-11 18:47:03 +00001576// VFP conversion between floating-point and fixed-point
1577class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001578 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1579 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001580 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1581 // size (fixed-point number): sx == 0 ? 16 : 32
1582 let Inst{7} = op5; // sx
1583}
1584
David Goodwin85b5b022009-08-10 22:17:39 +00001585// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001586class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001587 dag oops, dag iops, InstrItinClass itin,
1588 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001589 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1590 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001591 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1592}
1593
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001594class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001595 InstrItinClass itin,
1596 string opc, string asm, list<dag> pattern>
1597 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001598 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001599 let Inst{11-8} = opcod2;
1600 let Inst{4} = 1;
1601}
1602
David Goodwinb062c232009-08-06 16:52:47 +00001603class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1604 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1605 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001606
Bob Wilson3968c6a2010-03-23 17:23:59 +00001607class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001608 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1609 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001610
David Goodwinb062c232009-08-06 16:52:47 +00001611class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1612 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1613 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001614
David Goodwinb062c232009-08-06 16:52:47 +00001615class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1616 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1617 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001618
Evan Chengac2af2f2008-11-11 02:11:05 +00001619//===----------------------------------------------------------------------===//
1620
Bob Wilson2e076c42009-06-22 23:27:02 +00001621//===----------------------------------------------------------------------===//
1622// ARM NEON Instruction templates.
1623//
Evan Chengee98fa92008-08-29 06:41:12 +00001624
Johnny Chenf833fad2010-03-20 00:17:00 +00001625class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1626 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1627 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001628 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001629 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001630 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001631 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001632 let Pattern = pattern;
1633 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001634 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001635}
1636
1637// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001638class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1639 InstrItinClass itin, string opc, string asm, string cstr,
1640 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001641 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001642 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001643 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001644 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001645 let Pattern = pattern;
1646 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001647 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001648}
1649
Bob Wilson50820a22009-10-07 21:53:04 +00001650class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1651 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001652 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001653 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1654 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001655 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001656 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001657 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001658 let Inst{11-8} = op11_8;
1659 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001660
Chris Lattner63274cb2010-11-15 05:19:05 +00001661 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001662 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001663
Owen Andersonad402342010-11-02 00:05:05 +00001664 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001665 bits<6> Rn;
1666 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001667
Owen Andersonad402342010-11-02 00:05:05 +00001668 let Inst{22} = Vd{4};
1669 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001670 let Inst{19-16} = Rn{3-0};
1671 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001672}
1673
Owen Anderson9f20daf2010-11-02 20:47:39 +00001674class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1675 dag oops, dag iops, InstrItinClass itin,
1676 string opc, string dt, string asm, string cstr, list<dag> pattern>
1677 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1678 dt, asm, cstr, pattern> {
1679 bits<3> lane;
1680}
1681
Bob Wilson9392b0e2010-08-25 23:27:42 +00001682class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001683 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001684 itin> {
1685 let OutOperandList = oops;
1686 let InOperandList = !con(iops, (ins pred:$p));
1687 list<Predicate> Predicates = [HasNEON];
1688}
1689
Jim Grosbach233b3a22010-10-06 20:36:55 +00001690class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1691 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001692 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001693 itin> {
1694 let OutOperandList = oops;
1695 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001696 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001697 list<Predicate> Predicates = [HasNEON];
1698}
1699
Johnny Chenac5024b2010-03-23 16:43:47 +00001700class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001701 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001702 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1703 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001704 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001705 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001706 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001707}
1708
Johnny Chen020023a2010-03-23 20:40:44 +00001709class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001710 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001711 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001712 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001713 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001714 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001715 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001716}
1717
1718// NEON "one register and a modified immediate" format.
1719class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1720 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001721 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001722 string opc, string dt, string asm, string cstr,
1723 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001724 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001725 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001726 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001727 let Inst{11-8} = op11_8;
1728 let Inst{7} = op7;
1729 let Inst{6} = op6;
1730 let Inst{5} = op5;
1731 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001732
Owen Anderson284cb362010-10-26 17:40:54 +00001733 // Instruction operands.
1734 bits<5> Vd;
1735 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001736
Owen Anderson284cb362010-10-26 17:40:54 +00001737 let Inst{15-12} = Vd{3-0};
1738 let Inst{22} = Vd{4};
1739 let Inst{24} = SIMM{7};
1740 let Inst{18-16} = SIMM{6-4};
1741 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001742 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001743}
1744
1745// NEON 2 vector register format.
1746class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1747 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001748 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001749 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001750 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001751 let Inst{24-23} = op24_23;
1752 let Inst{21-20} = op21_20;
1753 let Inst{19-18} = op19_18;
1754 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001755 let Inst{11-7} = op11_7;
1756 let Inst{6} = op6;
1757 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001758
Owen Anderson24774462010-10-25 18:43:52 +00001759 // Instruction operands.
1760 bits<5> Vd;
1761 bits<5> Vm;
1762
1763 let Inst{15-12} = Vd{3-0};
1764 let Inst{22} = Vd{4};
1765 let Inst{3-0} = Vm{3-0};
1766 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001767}
1768
1769// Same as N2V except it doesn't have a datatype suffix.
1770class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001771 bits<5> op11_7, bit op6, bit op4,
1772 dag oops, dag iops, InstrItinClass itin,
1773 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001774 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001775 let Inst{24-23} = op24_23;
1776 let Inst{21-20} = op21_20;
1777 let Inst{19-18} = op19_18;
1778 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001779 let Inst{11-7} = op11_7;
1780 let Inst{6} = op6;
1781 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001782
Owen Anderson24774462010-10-25 18:43:52 +00001783 // Instruction operands.
1784 bits<5> Vd;
1785 bits<5> Vm;
1786
1787 let Inst{15-12} = Vd{3-0};
1788 let Inst{22} = Vd{4};
1789 let Inst{3-0} = Vm{3-0};
1790 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001791}
1792
1793// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001794class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001795 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001796 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001797 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001798 let Inst{24} = op24;
1799 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001800 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001801 let Inst{7} = op7;
1802 let Inst{6} = op6;
1803 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001804
Owen Anderson3665fee2010-10-26 20:56:57 +00001805 // Instruction operands.
1806 bits<5> Vd;
1807 bits<5> Vm;
1808 bits<6> SIMM;
1809
1810 let Inst{15-12} = Vd{3-0};
1811 let Inst{22} = Vd{4};
1812 let Inst{3-0} = Vm{3-0};
1813 let Inst{5} = Vm{4};
1814 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001815}
1816
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001817// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00001818
Jim Grosbacheca54e42011-05-19 17:34:53 +00001819class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1820 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1821 string opc, string dt, string asm, string cstr,
1822 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00001823 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001824 let Inst{24} = op24;
1825 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00001826 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001827 let Inst{11-8} = op11_8;
1828 let Inst{6} = op6;
1829 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00001830}
1831
1832class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1833 dag oops, dag iops, Format f, InstrItinClass itin,
1834 string opc, string dt, string asm, string cstr, list<dag> pattern>
1835 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1836 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbach5876e412010-11-19 22:42:55 +00001837
Owen Anderson9e44cf22010-10-21 20:21:49 +00001838 // Instruction operands.
1839 bits<5> Vd;
1840 bits<5> Vn;
1841 bits<5> Vm;
1842
1843 let Inst{15-12} = Vd{3-0};
1844 let Inst{22} = Vd{4};
1845 let Inst{19-16} = Vn{3-0};
1846 let Inst{7} = Vn{4};
1847 let Inst{3-0} = Vm{3-0};
1848 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001849}
1850
Jim Grosbacheca54e42011-05-19 17:34:53 +00001851class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1852 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1853 string opc, string dt, string asm, string cstr,
1854 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001855 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1856 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1857
1858 // Instruction operands.
1859 bits<5> Vd;
1860 bits<5> Vn;
1861 bits<5> Vm;
1862 bit lane;
1863
1864 let Inst{15-12} = Vd{3-0};
1865 let Inst{22} = Vd{4};
1866 let Inst{19-16} = Vn{3-0};
1867 let Inst{7} = Vn{4};
1868 let Inst{3-0} = Vm{3-0};
1869 let Inst{5} = lane;
1870}
1871
Jim Grosbacheca54e42011-05-19 17:34:53 +00001872class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1873 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1874 string opc, string dt, string asm, string cstr,
1875 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001876 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1877 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1878
1879 // Instruction operands.
1880 bits<5> Vd;
1881 bits<5> Vn;
1882 bits<5> Vm;
1883 bits<2> lane;
1884
1885 let Inst{15-12} = Vd{3-0};
1886 let Inst{22} = Vd{4};
1887 let Inst{19-16} = Vn{3-0};
1888 let Inst{7} = Vn{4};
1889 let Inst{2-0} = Vm{2-0};
1890 let Inst{5} = lane{1};
1891 let Inst{3} = lane{0};
1892}
1893
Johnny Chen8a687232010-03-23 21:35:03 +00001894// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001895class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1896 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001897 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001898 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001899 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001900 let Inst{24} = op24;
1901 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001902 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001903 let Inst{11-8} = op11_8;
1904 let Inst{6} = op6;
1905 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001906
Owen Andersondff239c2010-10-25 18:28:30 +00001907 // Instruction operands.
1908 bits<5> Vd;
1909 bits<5> Vn;
1910 bits<5> Vm;
1911
1912 let Inst{15-12} = Vd{3-0};
1913 let Inst{22} = Vd{4};
1914 let Inst{19-16} = Vn{3-0};
1915 let Inst{7} = Vn{4};
1916 let Inst{3-0} = Vm{3-0};
1917 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001918}
1919
1920// NEON VMOVs between scalar and core registers.
1921class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001922 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001923 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001924 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001925 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001926 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001927 let Inst{11-8} = opcod2;
1928 let Inst{6-5} = opcod3;
1929 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00001930 // A8.6.303, A8.6.328, A8.6.329
1931 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00001932
1933 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001934 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001935 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001936 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001937 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001938
Chris Lattner63274cb2010-11-15 05:19:05 +00001939 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001940 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00001941
Owen Andersoned9652f2010-10-27 21:28:09 +00001942 bits<5> V;
1943 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001944 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001945 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001946
Owen Anderson40d24a42010-10-27 19:25:54 +00001947 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001948 let Inst{7} = V{4};
1949 let Inst{19-16} = V{3-0};
1950 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001951}
1952class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001953 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001954 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001955 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001956 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001957class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001958 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001959 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001960 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001961 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001962class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001963 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001964 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001965 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001966 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001967
Johnny Chen45ab3f32010-03-25 17:01:27 +00001968// Vector Duplicate Lane (from scalar to all elements)
1969class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1970 InstrItinClass itin, string opc, string dt, string asm,
1971 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001972 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001973 let Inst{24-23} = 0b11;
1974 let Inst{21-20} = 0b11;
1975 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001976 let Inst{11-7} = 0b11000;
1977 let Inst{6} = op6;
1978 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001979
Owen Anderson40d24a42010-10-27 19:25:54 +00001980 bits<5> Vd;
1981 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001982
Owen Anderson40d24a42010-10-27 19:25:54 +00001983 let Inst{22} = Vd{4};
1984 let Inst{15-12} = Vd{3-0};
1985 let Inst{5} = Vm{4};
1986 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00001987}
1988
David Goodwin3b9c52c2009-08-04 17:53:06 +00001989// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1990// for single-precision FP.
1991class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1992 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1993}
Jim Grosbach7996b152011-11-14 22:28:39 +00001994
1995// VFP/NEON Instruction aliases for type suffices.
1996class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
1997 InstAlias<!strconcat(opc, dt, asm), Result>;
1998multiclass VFPDT32InstAlias<string opc, string asm, dag Result> {
1999 def I32 : VFPDataTypeInstAlias<opc, ".i32", asm, Result>;
2000 def S32 : VFPDataTypeInstAlias<opc, ".s32", asm, Result>;
2001 def U32 : VFPDataTypeInstAlias<opc, ".u32", asm, Result>;
2002 def F32 : VFPDataTypeInstAlias<opc, ".f32", asm, Result>;
2003 def F : VFPDataTypeInstAlias<opc, ".f", asm, Result>;
2004}
2005multiclass VFPDT64InstAlias<string opc, string asm, dag Result> {
2006 def I64 : VFPDataTypeInstAlias<opc, ".i64", asm, Result>;
2007 def S64 : VFPDataTypeInstAlias<opc, ".s64", asm, Result>;
2008 def U64 : VFPDataTypeInstAlias<opc, ".u64", asm, Result>;
2009 def F64 : VFPDataTypeInstAlias<opc, ".f64", asm, Result>;
2010 def D : VFPDataTypeInstAlias<opc, ".d", asm, Result>;
2011}
2012