blob: 43f11948974280757b41dcb9c90a8476e8933754 [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 Grosbach0a547702011-07-22 17:44:50 +0000177def SetEndAsmOperand : AsmOperandClass {
178 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 Grosbacha74c7ccd2010-11-18 01:38:26 +0000293class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000294 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000295 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000296 let OutOperandList = oops;
297 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000298 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000299 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000300 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000301}
302
Jim Grosbachcfb66202010-11-18 01:15:56 +0000303// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000304class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000305 list<dag> pattern>
306 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000307 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000308 list<Predicate> Predicates = [IsARM];
309}
310
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000311// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000312class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000313 list<dag> pattern>
314 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000315 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000316 list<Predicate> Predicates = [IsThumb];
317}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000318
Jim Grosbachd42257c2010-12-15 18:48:45 +0000319// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000320class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000321 list<dag> pattern>
322 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000323 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000324 list<Predicate> Predicates = [IsThumb2];
325}
Jim Grosbach95dee402011-07-08 17:40:42 +0000326
Owen Anderson651b2302011-07-13 23:22:26 +0000327class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000328 InstrItinClass itin, list<dag> pattern,
329 dag Result>
330 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
331 PseudoInstExpansion<Result>;
332
Owen Anderson651b2302011-07-13 23:22:26 +0000333class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000334 InstrItinClass itin, list<dag> pattern,
335 dag Result>
336 : tPseudoInst<oops, iops, sz, itin, pattern>,
337 PseudoInstExpansion<Result>;
338
Owen Anderson651b2302011-07-13 23:22:26 +0000339class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000340 InstrItinClass itin, list<dag> pattern,
341 dag Result>
342 : t2PseudoInst<oops, iops, sz, itin, pattern>,
343 PseudoInstExpansion<Result>;
344
Evan Cheng2d37f192008-08-28 23:39:26 +0000345// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000346class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000347 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000348 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000349 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000350 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000351 bits<4> p;
352 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000353 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000354 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000355 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000356 let Pattern = pattern;
357 list<Predicate> Predicates = [IsARM];
358}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000359
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000360// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000361class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000362 IndexMode im, Format f, InstrItinClass itin,
363 string opc, string asm, string cstr,
364 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000365 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
366 let OutOperandList = oops;
367 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000368 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000369 let Pattern = pattern;
370 let isPredicable = 0;
371 list<Predicate> Predicates = [IsARM];
372}
Evan Cheng2d37f192008-08-28 23:39:26 +0000373
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000374// Same as I except it can optionally modify CPSR. Note it's modeled as an input
375// operand since by default it's a zero register. It will become an implicit def
376// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000377class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000378 IndexMode im, Format f, InstrItinClass itin,
379 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000380 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000381 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000382 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000383 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000384 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000385 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000386
Evan Cheng2d37f192008-08-28 23:39:26 +0000387 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000388 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000389 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000390 let Pattern = pattern;
391 list<Predicate> Predicates = [IsARM];
392}
393
Evan Chenga2827232008-09-01 07:19:00 +0000394// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000395class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000396 IndexMode im, Format f, InstrItinClass itin,
397 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000398 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000399 let OutOperandList = oops;
400 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000401 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000402 let Pattern = pattern;
403 list<Predicate> Predicates = [IsARM];
404}
405
David Goodwinb062c232009-08-06 16:52:47 +0000406class AI<dag oops, dag iops, Format f, InstrItinClass itin,
407 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000408 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000409 opc, asm, "", pattern>;
410class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
411 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000412 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000413 opc, asm, "", pattern>;
414class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000415 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000416 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000417 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000418class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000419 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000420 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000421 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000422
423// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000424class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
425 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000426 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000427 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000428 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000429}
David Goodwinb062c232009-08-06 16:52:47 +0000430class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
431 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000432 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000433 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000434 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000435}
Evan Chengfa558782008-09-01 08:25:56 +0000436
437// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000438class JTI<dag oops, dag iops, InstrItinClass itin,
439 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000440 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000441 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000442
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000443// Atomic load/store instructions
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000444class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
445 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000446 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000447 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000448 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000449 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000450 let Inst{27-23} = 0b00011;
451 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000452 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000453 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000454 let Inst{15-12} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000455 let Inst{11-0} = 0b111110011111;
456}
457class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
458 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000459 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000460 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000461 bits<4> Rd;
462 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000463 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000464 let Inst{27-23} = 0b00011;
465 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000466 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000467 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000468 let Inst{15-12} = Rd;
Johnny Chen098bd1b2009-12-11 19:37:26 +0000469 let Inst{11-4} = 0b11111001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000470 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000471}
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000472class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000473 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000474 bits<4> Rt;
475 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000476 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000477 let Inst{27-23} = 0b00010;
478 let Inst{22} = b;
479 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000480 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000481 let Inst{15-12} = Rt;
482 let Inst{11-4} = 0b00001001;
483 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000484
485 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000486}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000487
Evan Cheng624844b2008-09-01 01:51:14 +0000488// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000489class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
490 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000491 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000492 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000493 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000494 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000495}
David Goodwinb062c232009-08-06 16:52:47 +0000496class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
497 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000498 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000499 opc, asm, "", pattern> {
500 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000501 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000502}
503class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000504 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000505 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000506 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000507 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000508 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000509}
Evan Cheng624844b2008-09-01 01:51:14 +0000510
Evan Chengcccca872008-09-01 01:27:33 +0000511// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000512
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000513// LDR/LDRB/STR/STRB/...
514class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000515 Format f, InstrItinClass itin, string opc, string asm,
516 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000517 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000518 "", pattern> {
519 let Inst{27-25} = op;
520 let Inst{24} = 1; // 24 == P
521 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000522 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000523 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000524 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000525}
Jim Grosbach2f790742010-11-13 00:35:48 +0000526// Indexed load/stores
527class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000528 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000529 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000530 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000531 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000532 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000533 let Inst{27-26} = 0b01;
534 let Inst{24} = isPre; // P bit
535 let Inst{22} = isByte; // B bit
536 let Inst{21} = isPre; // W bit
537 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000538 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000539}
Owen Anderson2aedba62011-07-26 20:54:26 +0000540class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000541 IndexMode im, Format f, InstrItinClass itin, string opc,
542 string asm, string cstr, list<dag> pattern>
543 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
544 pattern> {
545 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000546 // {12} isAdd
547 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000548 bits<14> offset;
549 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000550 let Inst{25} = 1;
551 let Inst{23} = offset{12};
552 let Inst{19-16} = Rn;
553 let Inst{11-5} = offset{11-5};
554 let Inst{4} = 0;
555 let Inst{3-0} = offset{3-0};
556}
557
558class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
559 IndexMode im, Format f, InstrItinClass itin, string opc,
560 string asm, string cstr, list<dag> pattern>
561 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
562 pattern> {
563 // AM2 store w/ two operands: (GPR, am2offset)
564 // {12} isAdd
565 // {11-0} imm12/Rm
566 bits<14> offset;
567 bits<4> Rn;
568 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000569 let Inst{23} = offset{12};
570 let Inst{19-16} = Rn;
571 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000572}
Owen Anderson2aedba62011-07-26 20:54:26 +0000573
574
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000575// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
576// but for now use this class for STRT and STRBT.
577class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
578 IndexMode im, Format f, InstrItinClass itin, string opc,
579 string asm, string cstr, list<dag> pattern>
580 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
581 pattern> {
582 // AM2 store w/ two operands: (GPR, am2offset)
583 // {17-14} Rn
584 // {13} 1 == Rm, 0 == imm12
585 // {12} isAdd
586 // {11-0} imm12/Rm
587 bits<18> addr;
588 let Inst{25} = addr{13};
589 let Inst{23} = addr{12};
590 let Inst{19-16} = addr{17-14};
591 let Inst{11-0} = addr{11-0};
592}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000593
Evan Cheng624844b2008-09-01 01:51:14 +0000594// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000595class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
596 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000597 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000598 opc, asm, "", pattern> {
599 bits<14> addr;
600 bits<4> Rt;
601 let Inst{27-25} = 0b000;
602 let Inst{24} = 1; // P bit
603 let Inst{23} = addr{8}; // U bit
604 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
605 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000606 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000607 let Inst{19-16} = addr{12-9}; // Rn
608 let Inst{15-12} = Rt; // Rt
609 let Inst{11-8} = addr{7-4}; // imm7_4/zero
610 let Inst{7-4} = op;
611 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000612
613 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000614}
Evan Cheng169eccc2008-09-01 07:00:14 +0000615
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000616class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000617 IndexMode im, Format f, InstrItinClass itin, string opc,
618 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000619 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000620 opc, asm, cstr, pattern> {
621 bits<4> Rt;
622 let Inst{27-25} = 0b000;
623 let Inst{24} = isPre; // P bit
624 let Inst{21} = isPre; // W bit
625 let Inst{20} = op20; // L bit
626 let Inst{15-12} = Rt; // Rt
627 let Inst{7-4} = op;
628}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000629
630// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
631// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000632class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000633 IndexMode im, Format f, InstrItinClass itin, string opc,
634 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000635 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000636 // {13} 1 == imm8, 0 == Rm
637 // {12-9} Rn
638 // {8} isAdd
639 // {7-4} imm7_4/zero
640 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000641 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000642 bits<4> Rt;
643 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000644 let Inst{24} = 0; // P bit
645 let Inst{21} = 1;
646 let Inst{20} = isLoad; // L bit
647 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000648 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000649 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000650}
651
Evan Cheng169eccc2008-09-01 07:00:14 +0000652// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000653class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000654 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000655 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000656 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000657 bits<14> addr;
658 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000659 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000660 let Inst{24} = 1; // P bit
661 let Inst{23} = addr{8}; // U bit
662 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
663 let Inst{21} = 0; // W bit
664 let Inst{20} = 0; // L bit
665 let Inst{19-16} = addr{12-9}; // Rn
666 let Inst{15-12} = Rt; // Rt
667 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000668 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000669 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000670 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000671}
Evan Cheng169eccc2008-09-01 07:00:14 +0000672
Evan Cheng624844b2008-09-01 01:51:14 +0000673// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000674class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
675 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000676 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000677 bits<4> p;
678 bits<16> regs;
679 bits<4> Rn;
680 let Inst{31-28} = p;
681 let Inst{27-25} = 0b100;
682 let Inst{22} = 0; // S bit
683 let Inst{19-16} = Rn;
684 let Inst{15-0} = regs;
685}
Evan Cheng2d37f192008-08-28 23:39:26 +0000686
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000687// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000688class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
689 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000690 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000691 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000692 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000693 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000694 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000695}
David Goodwinb062c232009-08-06 16:52:47 +0000696class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
697 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000698 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000699 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000700 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000701 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000702}
703
704// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000705class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
706 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000707 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000708 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000709 bits<4> Rd;
710 bits<4> Rn;
711 bits<4> Rm;
712 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000713 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000714 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000715 let Inst{19-16} = Rd;
716 let Inst{11-8} = Rm;
717 let Inst{3-0} = Rn;
718}
719// MSW multiple w/ Ra operand
720class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
721 InstrItinClass itin, string opc, string asm, list<dag> pattern>
722 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
723 bits<4> Ra;
724 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000725}
Evan Cheng2d37f192008-08-28 23:39:26 +0000726
Evan Cheng36ae4032008-11-06 03:35:07 +0000727// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000728class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000729 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000730 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000731 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000732 bits<4> Rn;
733 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000734 let Inst{4} = 0;
735 let Inst{7} = 1;
736 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000737 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000738 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000739 let Inst{11-8} = Rm;
740 let Inst{3-0} = Rn;
741}
742class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
743 InstrItinClass itin, string opc, string asm, list<dag> pattern>
744 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
745 bits<4> Rd;
746 let Inst{19-16} = Rd;
747}
748
749// AMulxyI with Ra operand
750class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
751 InstrItinClass itin, string opc, string asm, list<dag> pattern>
752 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
753 bits<4> Ra;
754 let Inst{15-12} = Ra;
755}
756// SMLAL*
757class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
758 InstrItinClass itin, string opc, string asm, list<dag> pattern>
759 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
760 bits<4> RdLo;
761 bits<4> RdHi;
762 let Inst{19-16} = RdHi;
763 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000764}
765
Evan Cheng49d66522008-11-06 22:15:19 +0000766// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000767class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
768 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000769 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000770 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000771 // All AExtI instructions have Rd and Rm register operands.
772 bits<4> Rd;
773 bits<4> Rm;
774 let Inst{15-12} = Rd;
775 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000776 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000777 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000778 let Inst{27-20} = opcod;
779}
780
Evan Cheng98dc53e2008-11-07 01:41:35 +0000781// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000782class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
783 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000784 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000785 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000786 bits<4> Rd;
787 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000788 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000789 let Inst{19-16} = 0b1111;
790 let Inst{15-12} = Rd;
791 let Inst{11-8} = 0b1111;
792 let Inst{7-4} = opc7_4;
793 let Inst{3-0} = Rm;
794}
795
796// PKH instructions
Jim Grosbach27c1e252011-07-21 17:23:04 +0000797def PKHLSLAsmOperand : AsmOperandClass {
798 let Name = "PKHLSLImm";
799 let ParserMethod = "parsePKHLSLImm";
800}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000801def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
802 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000803 let ParserMatchClass = PKHLSLAsmOperand;
804}
805def PKHASRAsmOperand : AsmOperandClass {
806 let Name = "PKHASRImm";
807 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000808}
809def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
810 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000811 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000812}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000813
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000814class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
815 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000816 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000817 opc, asm, "", pattern> {
818 bits<4> Rd;
819 bits<4> Rn;
820 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000821 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000822 let Inst{27-20} = opcod;
823 let Inst{19-16} = Rn;
824 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000825 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000826 let Inst{6} = tb;
827 let Inst{5-4} = 0b01;
828 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000829}
830
Evan Cheng2d37f192008-08-28 23:39:26 +0000831//===----------------------------------------------------------------------===//
832
833// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
834class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
835 list<Predicate> Predicates = [IsARM];
836}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000837class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
838 list<Predicate> Predicates = [IsARM, HasV5T];
839}
Evan Cheng2d37f192008-08-28 23:39:26 +0000840class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
841 list<Predicate> Predicates = [IsARM, HasV5TE];
842}
843class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
844 list<Predicate> Predicates = [IsARM, HasV6];
845}
Evan Chengee98fa92008-08-29 06:41:12 +0000846
847//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000848// Thumb Instruction Format Definitions.
849//
850
Owen Anderson651b2302011-07-13 23:22:26 +0000851class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000852 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000853 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000854 let OutOperandList = oops;
855 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000856 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000857 let Pattern = pattern;
858 list<Predicate> Predicates = [IsThumb];
859}
860
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000861// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000862class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000863 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000864
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000865// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000866class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
867 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000868 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000869 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000870
Johnny Chenc28e6292009-12-15 17:24:14 +0000871// tBL, tBX 32-bit instructions
872class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000873 dag oops, dag iops, InstrItinClass itin, string asm,
874 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000875 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000876 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +0000877 let Inst{31-27} = opcod1;
878 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000879 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +0000880}
Evan Chengee98fa92008-08-29 06:41:12 +0000881
882// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000883class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
884 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000885 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000886
Evan Chengbec1dba892009-06-23 19:38:13 +0000887// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +0000888class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000889 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000890 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000891 let OutOperandList = oops;
892 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000893 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +0000894 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000895 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +0000896}
897
David Goodwinb062c232009-08-06 16:52:47 +0000898class T1I<dag oops, dag iops, InstrItinClass itin,
899 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000900 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +0000901class T1Ix2<dag oops, dag iops, InstrItinClass itin,
902 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000903 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000904
905// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000906class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000907 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000908 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +0000909 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000910
911// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +0000912class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000913 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000914 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000915 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000916 let OutOperandList = !con(oops, (outs s_cc_out:$s));
917 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000918 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000919 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000920 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000921 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +0000922 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000923}
924
David Goodwinb062c232009-08-06 16:52:47 +0000925class T1sI<dag oops, dag iops, InstrItinClass itin,
926 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000927 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000928
929// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000930class T1sIt<dag oops, dag iops, InstrItinClass itin,
931 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000932 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +0000933 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000934
935// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +0000936class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000937 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +0000938 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000939 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000940 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000941 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000942 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +0000943 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +0000944 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +0000945}
946
David Goodwinb062c232009-08-06 16:52:47 +0000947class T1pI<dag oops, dag iops, InstrItinClass itin,
948 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000949 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000950
951// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +0000952class T1pIt<dag oops, dag iops, InstrItinClass itin,
953 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000954 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +0000955 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +0000956
Bob Wilson3968c6a2010-03-23 17:23:59 +0000957class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +0000958 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000959 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +0000960
Johnny Chen466231a2009-12-16 02:32:54 +0000961class Encoding16 : Encoding {
962 let Inst{31-16} = 0x0000;
963}
964
Johnny Chenc28e6292009-12-15 17:24:14 +0000965// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +0000966class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000967 let Inst{15-10} = opcode;
968}
969
970// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000971class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000972 let Inst{15-14} = 0b00;
973 let Inst{13-9} = opcode;
974}
975
976// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000977class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000978 let Inst{15-10} = 0b010000;
979 let Inst{9-6} = opcode;
980}
981
982// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000983class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000984 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +0000985 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +0000986}
987
988// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +0000989class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +0000990 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000991 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +0000992}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000993class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +0000994
Eric Christopher9b67db82011-05-27 03:50:53 +0000995class T1BranchCond<bits<4> opcode> : Encoding16 {
996 let Inst{15-12} = opcode;
997}
998
Bill Wendlinga9e3df72010-11-30 22:57:21 +0000999// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001000// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001001//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001002// 0b0110 => Immediate, 4 bytes
1003// 0b1000 => Immediate, 2 bytes
1004// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001005class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1006 InstrItinClass itin, string opc, string asm,
1007 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001008 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001009 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001010 bits<3> Rt;
1011 bits<8> addr;
1012 let Inst{8-6} = addr{5-3}; // Rm
1013 let Inst{5-3} = addr{2-0}; // Rn
1014 let Inst{2-0} = Rt;
1015}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001016class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1017 InstrItinClass itin, string opc, string asm,
1018 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001019 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001020 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001021 bits<3> Rt;
1022 bits<8> addr;
1023 let Inst{10-6} = addr{7-3}; // imm5
1024 let Inst{5-3} = addr{2-0}; // Rn
1025 let Inst{2-0} = Rt;
1026}
1027
Johnny Chenc28e6292009-12-15 17:24:14 +00001028// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001029class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001030 let Inst{15-12} = 0b1011;
1031 let Inst{11-5} = opcode;
1032}
1033
Evan Chengd76f0be2009-06-25 02:08:06 +00001034// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001035class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001036 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001037 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001038 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001039 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001040 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001041 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001042 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001043 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001044 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001045}
1046
Bill Wendlingb70dc872010-08-31 07:50:46 +00001047// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1048// input operand since by default it's a zero register. It will become an
1049// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001050//
Evan Chengd76f0be2009-06-25 02:08:06 +00001051// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1052// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001053class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001054 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001055 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001056 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001057 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1058 let Inst{20} = s;
1059
Evan Chengd76f0be2009-06-25 02:08:06 +00001060 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001061 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001062 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001063 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001064 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001065 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001066}
1067
1068// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001069class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001070 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001071 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001072 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001073 let OutOperandList = oops;
1074 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001075 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001076 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001077 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001078 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001079}
1080
Owen Anderson651b2302011-07-13 23:22:26 +00001081class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001082 InstrItinClass itin,
1083 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001084 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1085 let OutOperandList = oops;
1086 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001087 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001088 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001089 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001090 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001091}
1092
David Goodwinb062c232009-08-06 16:52:47 +00001093class T2I<dag oops, dag iops, InstrItinClass itin,
1094 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001095 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001096class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1097 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001098 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001099class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1100 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001101 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001102class T2Iso<dag oops, dag iops, InstrItinClass itin,
1103 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001104 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001105class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1106 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001107 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001108class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001109 string opc, string asm, string cstr, list<dag> pattern>
1110 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001111 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001112 bits<4> Rt;
1113 bits<4> Rt2;
1114 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001115 let Inst{31-25} = 0b1110100;
1116 let Inst{24} = P;
1117 let Inst{23} = addr{8};
1118 let Inst{22} = 1;
1119 let Inst{21} = W;
1120 let Inst{20} = isLoad;
1121 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001122 let Inst{15-12} = Rt{3-0};
1123 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001124 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001125}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001126class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1127 InstrItinClass itin, string opc, string asm, string cstr,
1128 list<dag> pattern>
1129 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001130 pattern> {
1131 bits<4> Rt;
1132 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001133 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001134 bits<9> imm;
1135 let Inst{31-25} = 0b1110100;
1136 let Inst{24} = P;
1137 let Inst{23} = imm{8};
1138 let Inst{22} = 1;
1139 let Inst{21} = W;
1140 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001141 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001142 let Inst{15-12} = Rt{3-0};
1143 let Inst{11-8} = Rt2{3-0};
1144 let Inst{7-0} = imm{7-0};
1145}
1146
David Goodwinb062c232009-08-06 16:52:47 +00001147class T2sI<dag oops, dag iops, InstrItinClass itin,
1148 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001149 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001150
David Goodwinb062c232009-08-06 16:52:47 +00001151class T2XI<dag oops, dag iops, InstrItinClass itin,
1152 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001153 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001154class T2JTI<dag oops, dag iops, InstrItinClass itin,
1155 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001156 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001157
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001158// Move to/from coprocessor instructions
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001159class T2Cop<bits<4> opc, dag oops, dag iops, string asm, list<dag> pattern>
Jim Grosbachadb29b62011-07-13 21:14:23 +00001160 : T2XI <oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001161 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001162}
1163
Bob Wilson947f04b2010-03-13 01:08:20 +00001164// Two-address instructions
1165class T2XIt<dag oops, dag iops, InstrItinClass itin,
1166 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001167 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001168
Jim Grosbachc086f682011-09-08 00:39:19 +00001169// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1170class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001171 dag oops, dag iops,
1172 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001173 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001174 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001175 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001176 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001177 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001178 let Pattern = pattern;
1179 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001180 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001181
1182 bits<4> Rt;
1183 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001184 let Inst{31-27} = 0b11111;
1185 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001186 let Inst{24} = signed;
1187 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001188 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001189 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001190 let Inst{19-16} = addr{12-9};
1191 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001192 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001193 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001194 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001195 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001196 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001197 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001198
1199 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001200}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001201
Jim Grosbachc086f682011-09-08 00:39:19 +00001202// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1203class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1204 dag oops, dag iops,
1205 AddrMode am, IndexMode im, InstrItinClass itin,
1206 string opc, string asm, string cstr, list<dag> pattern>
1207 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1208 let OutOperandList = oops;
1209 let InOperandList = !con(iops, (ins pred:$p));
1210 let AsmString = !strconcat(opc, "${p}", asm);
1211 let Pattern = pattern;
1212 list<Predicate> Predicates = [IsThumb2];
1213 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001214
Owen Andersone22c7322010-11-30 00:14:31 +00001215 bits<4> Rt;
1216 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001217 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001218 let Inst{31-27} = 0b11111;
1219 let Inst{26-25} = 0b00;
1220 let Inst{24} = signed;
1221 let Inst{23} = 0;
1222 let Inst{22-21} = opcod;
1223 let Inst{20} = load;
1224 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001225 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001226 let Inst{11} = 1;
1227 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1228 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001229 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001230 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001231 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001232
1233 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001234}
1235
David Goodwine5b969f2009-07-27 19:59:26 +00001236// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1237class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001238 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001239}
1240
1241// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1242class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001243 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001244}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001245
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001246// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1247class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1248 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1249}
1250
Evan Chengeab9ca72009-06-27 02:26:13 +00001251// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1252class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001253 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001254}
1255
Evan Chengee98fa92008-08-29 06:41:12 +00001256//===----------------------------------------------------------------------===//
1257
Evan Chengac2af2f2008-11-11 02:11:05 +00001258//===----------------------------------------------------------------------===//
1259// ARM VFP Instruction templates.
1260//
1261
David Goodwin81cdd212009-07-10 17:03:29 +00001262// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001263class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001264 IndexMode im, Format f, InstrItinClass itin,
1265 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001266 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001267 bits<4> p;
1268 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001269 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001270 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001271 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001272 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001273 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001274 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001275 list<Predicate> Predicates = [HasVFP2];
1276}
1277
1278// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001279class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001280 IndexMode im, Format f, InstrItinClass itin,
1281 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001282 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001283 bits<4> p;
1284 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001285 let OutOperandList = oops;
1286 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001287 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001288 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001289 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001290 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001291 list<Predicate> Predicates = [HasVFP2];
1292}
1293
David Goodwinb062c232009-08-06 16:52:47 +00001294class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1295 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001296 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001297 opc, asm, "", pattern> {
1298 let PostEncoderMethod = "VFPThumb2PostEncoder";
1299}
David Goodwin81cdd212009-07-10 17:03:29 +00001300
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001301// ARM VFP addrmode5 loads and stores
1302class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001303 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001304 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001305 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001306 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001307 // Instruction operands.
1308 bits<5> Dd;
1309 bits<13> addr;
1310
1311 // Encode instruction operands.
1312 let Inst{23} = addr{8}; // U (add = (U == '1'))
1313 let Inst{22} = Dd{4};
1314 let Inst{19-16} = addr{12-9}; // Rn
1315 let Inst{15-12} = Dd{3-0};
1316 let Inst{7-0} = addr{7-0}; // imm8
1317
Evan Chengac2af2f2008-11-11 02:11:05 +00001318 // TODO: Mark the instructions with the appropriate subtarget info.
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001319 let Inst{27-24} = opcod1;
1320 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001321 let Inst{11-9} = 0b101;
1322 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001323
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001324 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001325 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001326}
1327
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001328class ASI5<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> Sd;
1335 bits<13> addr;
1336
1337 // Encode instruction operands.
1338 let Inst{23} = addr{8}; // U (add = (U == '1'))
1339 let Inst{22} = Sd{0};
1340 let Inst{19-16} = addr{12-9}; // Rn
1341 let Inst{15-12} = Sd{4-1};
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} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001349
1350 // Loads & stores operate on both NEON and VFP pipelines.
1351 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001352}
1353
Bob Wilson6b853c32010-09-16 00:31:02 +00001354// VFP Load / store multiple pseudo instructions.
1355class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1356 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001357 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001358 cstr, itin> {
1359 let OutOperandList = oops;
1360 let InOperandList = !con(iops, (ins pred:$p));
1361 let Pattern = pattern;
1362 list<Predicate> Predicates = [HasVFP2];
1363}
1364
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001365// Load / store multiple
Jim Grosbachabcbe242010-09-08 00:25:50 +00001366class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001367 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001368 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001369 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001370 // Instruction operands.
1371 bits<4> Rn;
1372 bits<13> regs;
1373
1374 // Encode instruction operands.
1375 let Inst{19-16} = Rn;
1376 let Inst{22} = regs{12};
1377 let Inst{15-12} = regs{11-8};
1378 let Inst{7-0} = regs{7-0};
1379
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001380 // TODO: Mark the instructions with the appropriate subtarget info.
1381 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001382 let Inst{11-9} = 0b101;
1383 let Inst{8} = 1; // Double precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001384}
1385
Jim Grosbachabcbe242010-09-08 00:25:50 +00001386class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001387 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001388 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001389 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001390 // Instruction operands.
1391 bits<4> Rn;
1392 bits<13> regs;
1393
1394 // Encode instruction operands.
1395 let Inst{19-16} = Rn;
1396 let Inst{22} = regs{8};
1397 let Inst{15-12} = regs{12-9};
1398 let Inst{7-0} = regs{7-0};
1399
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001400 // TODO: Mark the instructions with the appropriate subtarget info.
1401 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001402 let Inst{11-9} = 0b101;
1403 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001404}
1405
Evan Chengac2af2f2008-11-11 02:11:05 +00001406// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001407class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1408 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1409 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001410 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001411 // Instruction operands.
1412 bits<5> Dd;
1413 bits<5> Dm;
1414
1415 // Encode instruction operands.
1416 let Inst{3-0} = Dm{3-0};
1417 let Inst{5} = Dm{4};
1418 let Inst{15-12} = Dd{3-0};
1419 let Inst{22} = Dd{4};
1420
Johnny Chen34a6afc2010-01-29 23:21:10 +00001421 let Inst{27-23} = opcod1;
1422 let Inst{21-20} = opcod2;
1423 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001424 let Inst{11-9} = 0b101;
1425 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001426 let Inst{7-6} = opcod4;
1427 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001428}
1429
1430// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001431class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001432 dag iops, InstrItinClass itin, string opc, string asm,
1433 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001434 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001435 // Instruction operands.
1436 bits<5> Dd;
1437 bits<5> Dn;
1438 bits<5> Dm;
1439
1440 // Encode instruction operands.
1441 let Inst{3-0} = Dm{3-0};
1442 let Inst{5} = Dm{4};
1443 let Inst{19-16} = Dn{3-0};
1444 let Inst{7} = Dn{4};
1445 let Inst{15-12} = Dd{3-0};
1446 let Inst{22} = Dd{4};
1447
Johnny Chen34a6afc2010-01-29 23:21:10 +00001448 let Inst{27-23} = opcod1;
1449 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001450 let Inst{11-9} = 0b101;
1451 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001452 let Inst{6} = op6;
1453 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001454}
1455
1456// Single precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001457class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1458 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1459 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001460 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001461 // Instruction operands.
1462 bits<5> Sd;
1463 bits<5> Sm;
1464
1465 // Encode instruction operands.
1466 let Inst{3-0} = Sm{4-1};
1467 let Inst{5} = Sm{0};
1468 let Inst{15-12} = Sd{4-1};
1469 let Inst{22} = Sd{0};
1470
Johnny Chen34a6afc2010-01-29 23:21:10 +00001471 let Inst{27-23} = opcod1;
1472 let Inst{21-20} = opcod2;
1473 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001474 let Inst{11-9} = 0b101;
1475 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001476 let Inst{7-6} = opcod4;
1477 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001478}
1479
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001480// Single precision unary, if no NEON. Same as ASuI except not available if
1481// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001482class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1483 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1484 string asm, list<dag> pattern>
1485 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1486 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001487 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1488}
1489
Evan Chengac2af2f2008-11-11 02:11:05 +00001490// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001491class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1492 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001493 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001494 // Instruction operands.
1495 bits<5> Sd;
1496 bits<5> Sn;
1497 bits<5> Sm;
1498
1499 // Encode instruction operands.
1500 let Inst{3-0} = Sm{4-1};
1501 let Inst{5} = Sm{0};
1502 let Inst{19-16} = Sn{4-1};
1503 let Inst{7} = Sn{0};
1504 let Inst{15-12} = Sd{4-1};
1505 let Inst{22} = Sd{0};
1506
Johnny Chen34a6afc2010-01-29 23:21:10 +00001507 let Inst{27-23} = opcod1;
1508 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001509 let Inst{11-9} = 0b101;
1510 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001511 let Inst{6} = op6;
1512 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001513}
1514
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001515// Single precision binary, if no NEON. Same as ASbI except not available if
1516// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001517class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001518 dag iops, InstrItinClass itin, string opc, string asm,
1519 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001520 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001521 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001522
1523 // Instruction operands.
1524 bits<5> Sd;
1525 bits<5> Sn;
1526 bits<5> Sm;
1527
1528 // Encode instruction operands.
1529 let Inst{3-0} = Sm{4-1};
1530 let Inst{5} = Sm{0};
1531 let Inst{19-16} = Sn{4-1};
1532 let Inst{7} = Sn{0};
1533 let Inst{15-12} = Sd{4-1};
1534 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001535}
1536
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001537// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001538class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1539 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1540 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001541 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001542 let Inst{27-23} = opcod1;
1543 let Inst{21-20} = opcod2;
1544 let Inst{19-16} = opcod3;
1545 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001546 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001547 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001548}
1549
Johnny Chen39640592010-02-11 18:47:03 +00001550// VFP conversion between floating-point and fixed-point
1551class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001552 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1553 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001554 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1555 // size (fixed-point number): sx == 0 ? 16 : 32
1556 let Inst{7} = op5; // sx
1557}
1558
David Goodwin85b5b022009-08-10 22:17:39 +00001559// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001560class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001561 dag oops, dag iops, InstrItinClass itin,
1562 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001563 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1564 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001565 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1566}
1567
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001568class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001569 InstrItinClass itin,
1570 string opc, string asm, list<dag> pattern>
1571 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001572 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001573 let Inst{11-8} = opcod2;
1574 let Inst{4} = 1;
1575}
1576
David Goodwinb062c232009-08-06 16:52:47 +00001577class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1578 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1579 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001580
Bob Wilson3968c6a2010-03-23 17:23:59 +00001581class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001582 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1583 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001584
David Goodwinb062c232009-08-06 16:52:47 +00001585class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1586 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1587 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001588
David Goodwinb062c232009-08-06 16:52:47 +00001589class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1590 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1591 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001592
Evan Chengac2af2f2008-11-11 02:11:05 +00001593//===----------------------------------------------------------------------===//
1594
Bob Wilson2e076c42009-06-22 23:27:02 +00001595//===----------------------------------------------------------------------===//
1596// ARM NEON Instruction templates.
1597//
Evan Chengee98fa92008-08-29 06:41:12 +00001598
Johnny Chenf833fad2010-03-20 00:17:00 +00001599class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1600 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1601 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001602 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001603 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001604 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001605 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001606 let Pattern = pattern;
1607 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001608 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001609}
1610
1611// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001612class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1613 InstrItinClass itin, string opc, string asm, string cstr,
1614 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001615 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001616 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001617 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001618 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001619 let Pattern = pattern;
1620 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001621 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001622}
1623
Bob Wilson50820a22009-10-07 21:53:04 +00001624class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1625 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001626 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001627 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1628 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001629 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001630 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001631 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001632 let Inst{11-8} = op11_8;
1633 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001634
Chris Lattner63274cb2010-11-15 05:19:05 +00001635 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001636 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001637
Owen Andersonad402342010-11-02 00:05:05 +00001638 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001639 bits<6> Rn;
1640 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001641
Owen Andersonad402342010-11-02 00:05:05 +00001642 let Inst{22} = Vd{4};
1643 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001644 let Inst{19-16} = Rn{3-0};
1645 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001646}
1647
Owen Anderson9f20daf2010-11-02 20:47:39 +00001648class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1649 dag oops, dag iops, InstrItinClass itin,
1650 string opc, string dt, string asm, string cstr, list<dag> pattern>
1651 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1652 dt, asm, cstr, pattern> {
1653 bits<3> lane;
1654}
1655
Bob Wilson9392b0e2010-08-25 23:27:42 +00001656class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001657 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001658 itin> {
1659 let OutOperandList = oops;
1660 let InOperandList = !con(iops, (ins pred:$p));
1661 list<Predicate> Predicates = [HasNEON];
1662}
1663
Jim Grosbach233b3a22010-10-06 20:36:55 +00001664class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1665 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001666 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001667 itin> {
1668 let OutOperandList = oops;
1669 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001670 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001671 list<Predicate> Predicates = [HasNEON];
1672}
1673
Johnny Chenac5024b2010-03-23 16:43:47 +00001674class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001675 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001676 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1677 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001678 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001679 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001680 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001681}
1682
Johnny Chen020023a2010-03-23 20:40:44 +00001683class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001684 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001685 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001686 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001687 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001688 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001689 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001690}
1691
1692// NEON "one register and a modified immediate" format.
1693class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1694 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001695 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001696 string opc, string dt, string asm, string cstr,
1697 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001698 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001699 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001700 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001701 let Inst{11-8} = op11_8;
1702 let Inst{7} = op7;
1703 let Inst{6} = op6;
1704 let Inst{5} = op5;
1705 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001706
Owen Anderson284cb362010-10-26 17:40:54 +00001707 // Instruction operands.
1708 bits<5> Vd;
1709 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001710
Owen Anderson284cb362010-10-26 17:40:54 +00001711 let Inst{15-12} = Vd{3-0};
1712 let Inst{22} = Vd{4};
1713 let Inst{24} = SIMM{7};
1714 let Inst{18-16} = SIMM{6-4};
1715 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001716 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001717}
1718
1719// NEON 2 vector register format.
1720class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1721 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001722 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001723 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001724 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001725 let Inst{24-23} = op24_23;
1726 let Inst{21-20} = op21_20;
1727 let Inst{19-18} = op19_18;
1728 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001729 let Inst{11-7} = op11_7;
1730 let Inst{6} = op6;
1731 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001732
Owen Anderson24774462010-10-25 18:43:52 +00001733 // Instruction operands.
1734 bits<5> Vd;
1735 bits<5> Vm;
1736
1737 let Inst{15-12} = Vd{3-0};
1738 let Inst{22} = Vd{4};
1739 let Inst{3-0} = Vm{3-0};
1740 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001741}
1742
1743// Same as N2V except it doesn't have a datatype suffix.
1744class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001745 bits<5> op11_7, bit op6, bit op4,
1746 dag oops, dag iops, InstrItinClass itin,
1747 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001748 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001749 let Inst{24-23} = op24_23;
1750 let Inst{21-20} = op21_20;
1751 let Inst{19-18} = op19_18;
1752 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001753 let Inst{11-7} = op11_7;
1754 let Inst{6} = op6;
1755 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001756
Owen Anderson24774462010-10-25 18:43:52 +00001757 // Instruction operands.
1758 bits<5> Vd;
1759 bits<5> Vm;
1760
1761 let Inst{15-12} = Vd{3-0};
1762 let Inst{22} = Vd{4};
1763 let Inst{3-0} = Vm{3-0};
1764 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001765}
1766
1767// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00001768class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00001769 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001770 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00001771 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001772 let Inst{24} = op24;
1773 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001774 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001775 let Inst{7} = op7;
1776 let Inst{6} = op6;
1777 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001778
Owen Anderson3665fee2010-10-26 20:56:57 +00001779 // Instruction operands.
1780 bits<5> Vd;
1781 bits<5> Vm;
1782 bits<6> SIMM;
1783
1784 let Inst{15-12} = Vd{3-0};
1785 let Inst{22} = Vd{4};
1786 let Inst{3-0} = Vm{3-0};
1787 let Inst{5} = Vm{4};
1788 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001789}
1790
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001791// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00001792
Jim Grosbacheca54e42011-05-19 17:34:53 +00001793class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1794 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1795 string opc, string dt, string asm, string cstr,
1796 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +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;
Evan Cheng738a97a2009-11-23 21:57:23 +00001800 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001801 let Inst{11-8} = op11_8;
1802 let Inst{6} = op6;
1803 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00001804}
1805
1806class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1807 dag oops, dag iops, Format f, InstrItinClass itin,
1808 string opc, string dt, string asm, string cstr, list<dag> pattern>
1809 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1810 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Jim Grosbach5876e412010-11-19 22:42:55 +00001811
Owen Anderson9e44cf22010-10-21 20:21:49 +00001812 // Instruction operands.
1813 bits<5> Vd;
1814 bits<5> Vn;
1815 bits<5> Vm;
1816
1817 let Inst{15-12} = Vd{3-0};
1818 let Inst{22} = Vd{4};
1819 let Inst{19-16} = Vn{3-0};
1820 let Inst{7} = Vn{4};
1821 let Inst{3-0} = Vm{3-0};
1822 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00001823}
1824
Jim Grosbacheca54e42011-05-19 17:34:53 +00001825class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1826 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1827 string opc, string dt, string asm, string cstr,
1828 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001829 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1830 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1831
1832 // Instruction operands.
1833 bits<5> Vd;
1834 bits<5> Vn;
1835 bits<5> Vm;
1836 bit lane;
1837
1838 let Inst{15-12} = Vd{3-0};
1839 let Inst{22} = Vd{4};
1840 let Inst{19-16} = Vn{3-0};
1841 let Inst{7} = Vn{4};
1842 let Inst{3-0} = Vm{3-0};
1843 let Inst{5} = lane;
1844}
1845
Jim Grosbacheca54e42011-05-19 17:34:53 +00001846class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1847 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1848 string opc, string dt, string asm, string cstr,
1849 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00001850 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1851 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1852
1853 // Instruction operands.
1854 bits<5> Vd;
1855 bits<5> Vn;
1856 bits<5> Vm;
1857 bits<2> lane;
1858
1859 let Inst{15-12} = Vd{3-0};
1860 let Inst{22} = Vd{4};
1861 let Inst{19-16} = Vn{3-0};
1862 let Inst{7} = Vn{4};
1863 let Inst{2-0} = Vm{2-0};
1864 let Inst{5} = lane{1};
1865 let Inst{3} = lane{0};
1866}
1867
Johnny Chen8a687232010-03-23 21:35:03 +00001868// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00001869class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1870 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001871 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001872 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00001873 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001874 let Inst{24} = op24;
1875 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001876 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001877 let Inst{11-8} = op11_8;
1878 let Inst{6} = op6;
1879 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001880
Owen Andersondff239c2010-10-25 18:28:30 +00001881 // Instruction operands.
1882 bits<5> Vd;
1883 bits<5> Vn;
1884 bits<5> Vm;
1885
1886 let Inst{15-12} = Vd{3-0};
1887 let Inst{22} = Vd{4};
1888 let Inst{19-16} = Vn{3-0};
1889 let Inst{7} = Vn{4};
1890 let Inst{3-0} = Vm{3-0};
1891 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00001892}
1893
1894// NEON VMOVs between scalar and core registers.
1895class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001896 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001897 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001898 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001899 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001900 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001901 let Inst{11-8} = opcod2;
1902 let Inst{6-5} = opcod3;
1903 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00001904 // A8.6.303, A8.6.328, A8.6.329
1905 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00001906
1907 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001908 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001909 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001910 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00001911 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00001912
Chris Lattner63274cb2010-11-15 05:19:05 +00001913 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001914 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00001915
Owen Andersoned9652f2010-10-27 21:28:09 +00001916 bits<5> V;
1917 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00001918 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00001919 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00001920
Owen Anderson40d24a42010-10-27 19:25:54 +00001921 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00001922 let Inst{7} = V{4};
1923 let Inst{19-16} = V{3-0};
1924 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00001925}
1926class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001927 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001928 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001929 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001930 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001931class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001932 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001933 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001934 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001935 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00001936class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00001937 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001938 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00001939 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001940 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00001941
Johnny Chen45ab3f32010-03-25 17:01:27 +00001942// Vector Duplicate Lane (from scalar to all elements)
1943class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1944 InstrItinClass itin, string opc, string dt, string asm,
1945 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00001946 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00001947 let Inst{24-23} = 0b11;
1948 let Inst{21-20} = 0b11;
1949 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001950 let Inst{11-7} = 0b11000;
1951 let Inst{6} = op6;
1952 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00001953
Owen Anderson40d24a42010-10-27 19:25:54 +00001954 bits<5> Vd;
1955 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001956
Owen Anderson40d24a42010-10-27 19:25:54 +00001957 let Inst{22} = Vd{4};
1958 let Inst{15-12} = Vd{3-0};
1959 let Inst{5} = Vm{4};
1960 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00001961}
1962
David Goodwin3b9c52c2009-08-04 17:53:06 +00001963// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1964// for single-precision FP.
1965class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1966 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
1967}