blob: e505e1a9ae727d097fda505ef31e8751284badf2 [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +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
Tim Northover42180442013-08-22 09:57:11 +0000158// Selectable predicate operand for CMOV instructions. We can't use a normal
159// predicate because the default values interfere with instruction selection. In
160// all other respects it is identical though: pseudo-instruction expansion
161// relies on the MachineOperands being compatible.
162def cmovpred : Operand<i32>, PredicateOp,
163 ComplexPattern<i32, 2, "SelectCMOVPred"> {
164 let MIOperandInfo = (ops i32imm, i32imm);
165 let PrintMethod = "printPredicateOperand";
166}
167
Evan Chengcd4cdd12009-07-11 06:43:01 +0000168// Conditional code result for instructions whose 's' bit is set, e.g. subs.
Jim Grosbacheeaab222011-07-25 20:38:18 +0000169def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
Evan Chengcd4cdd12009-07-11 06:43:01 +0000170def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000171 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000172 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000173 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000174 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000175}
176
177// Same as cc_out except it defaults to setting CPSR.
178def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000179 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000180 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000181 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000182 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000183}
184
Johnny Chen9a3e2392010-03-10 18:59:38 +0000185// ARM special operands for disassembly only.
186//
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000187def SetEndAsmOperand : ImmAsmOperand {
Jim Grosbach0a547702011-07-22 17:44:50 +0000188 let Name = "SetEndImm";
189 let ParserMethod = "parseSetEndImm";
190}
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000191def setend_op : Operand<i32> {
192 let PrintMethod = "printSetendOperand";
Jim Grosbach0a547702011-07-22 17:44:50 +0000193 let ParserMatchClass = SetEndAsmOperand;
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000194}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000195
Jim Grosbacheeaab222011-07-25 20:38:18 +0000196def MSRMaskOperand : AsmOperandClass {
197 let Name = "MSRMask";
198 let ParserMethod = "parseMSRMaskOperand";
199}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000200def msr_mask : Operand<i32> {
201 let PrintMethod = "printMSRMaskOperand";
Owen Anderson60663402011-08-11 20:21:46 +0000202 let DecoderMethod = "DecodeMSRMask";
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000203 let ParserMatchClass = MSRMaskOperand;
Johnny Chen9a3e2392010-03-10 18:59:38 +0000204}
205
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000206// Shift Right Immediate - A shift right immediate is encoded differently from
207// other shift immediates. The imm6 field is encoded like so:
Bill Wendling3b1459b2011-03-01 01:00:59 +0000208//
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000209// Offset Encoding
210// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
211// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
212// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
213// 64 64 - <imm> is encoded in imm6<5:0>
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000214def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000215def shr_imm8 : Operand<i32> {
216 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000217 let DecoderMethod = "DecodeShiftRight8Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000218 let ParserMatchClass = shr_imm8_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000219}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000220def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000221def shr_imm16 : Operand<i32> {
222 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000223 let DecoderMethod = "DecodeShiftRight16Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000224 let ParserMatchClass = shr_imm16_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000225}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000226def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000227def shr_imm32 : Operand<i32> {
228 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000229 let DecoderMethod = "DecodeShiftRight32Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000230 let ParserMatchClass = shr_imm32_asm_operand;
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000231}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000232def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; }
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000233def shr_imm64 : Operand<i32> {
234 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000235 let DecoderMethod = "DecodeShiftRight64Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000236 let ParserMatchClass = shr_imm64_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000237}
238
Evan Chengcd4cdd12009-07-11 06:43:01 +0000239//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000240// ARM Assembler alias templates.
241//
242class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
243 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
244class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
245 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
246class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
247 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000248class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
249 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
250class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
251 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
Jim Grosbach0a978ef2011-12-05 19:55:46 +0000252class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
253 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000254
Jim Grosbach9227f392011-12-13 20:08:32 +0000255
256class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
257 Requires<[HasVFP2]>;
258class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
259 Requires<[HasNEON]>;
260
Jim Grosbach6caa5572011-08-22 18:04:24 +0000261//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000262// ARM Instruction templates.
263//
264
Jim Grosbach6caa5572011-08-22 18:04:24 +0000265
Owen Anderson651b2302011-07-13 23:22:26 +0000266class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000267 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000268 : Instruction {
269 let Namespace = "ARM";
270
Evan Cheng2d37f192008-08-28 23:39:26 +0000271 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000272 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000273 IndexMode IM = im;
274 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000275 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000276 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000277 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000278 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000279 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000280 // The instruction is a 16-bit flag setting Thumb instruction. Used
281 // by the parser to determine whether to require the 'S' suffix on the
282 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
283 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000284
Chris Lattner7ff33462010-10-31 19:22:57 +0000285 // If this is a pseudo instruction, mark it isCodeGenOnly.
286 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000287
Jim Grosbach30694dc2011-08-15 16:52:24 +0000288 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000289 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000290 let TSFlags{6-5} = IndexModeBits;
291 let TSFlags{12-7} = Form;
292 let TSFlags{13} = isUnaryDataProc;
293 let TSFlags{14} = canXformTo16Bit;
294 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000295 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000296
Evan Cheng2d37f192008-08-28 23:39:26 +0000297 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000298 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000299}
300
Johnny Chenc28e6292009-12-15 17:24:14 +0000301class Encoding {
302 field bits<32> Inst;
James Molloyd9ba4fd2012-02-09 10:56:31 +0000303 // Mask of bits that cause an encoding to be UNPREDICTABLE.
304 // If a bit is set, then if the corresponding bit in the
305 // target encoding differs from its value in the "Inst" field,
306 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
307 field bits<32> Unpredictable = 0;
308 // SoftFail is the generic name for this field, but we alias it so
309 // as to make it more obvious what it means in ARM-land.
310 field bits<32> SoftFail = Unpredictable;
Johnny Chenc28e6292009-12-15 17:24:14 +0000311}
312
Owen Anderson651b2302011-07-13 23:22:26 +0000313class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000314 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000315 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
316 let DecoderNamespace = "ARM";
317}
Johnny Chenc28e6292009-12-15 17:24:14 +0000318
319// This Encoding-less class is used by Thumb1 to specify the encoding bits later
320// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000321class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000322 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000323 : InstTemplate<am, sz, im, f, d, cstr, itin> {
324 let DecoderNamespace = "Thumb";
325}
Johnny Chenc28e6292009-12-15 17:24:14 +0000326
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000327// Pseudo-instructions for alternate assembly syntax (never used by codegen).
328// These are aliases that require C++ handling to convert to the target
329// instruction, while InstAliases can be handled directly by tblgen.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000330class AsmPseudoInst<string asm, dag iops>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000331 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
332 "", NoItinerary> {
Jim Grosbach61db5a52011-11-10 16:44:55 +0000333 let OutOperandList = (outs);
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000334 let InOperandList = iops;
335 let Pattern = [];
336 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000337 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000338 let isPseudo = 1;
339}
340
Jim Grosbach61db5a52011-11-10 16:44:55 +0000341class ARMAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
342 Requires<[IsARM]>;
343class tAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
344 Requires<[IsThumb]>;
345class t2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
346 Requires<[IsThumb2]>;
347class VFP2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
348 Requires<[HasVFP2]>;
349class NEONAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
350 Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000351
352// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000353class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000354 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000355 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000356 let OutOperandList = oops;
357 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000358 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000359 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000360 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000361}
362
Jim Grosbachcfb66202010-11-18 01:15:56 +0000363// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000364class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000365 list<dag> pattern>
366 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000367 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000368 list<Predicate> Predicates = [IsARM];
369}
370
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000371// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000372class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000373 list<dag> pattern>
374 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000375 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000376 list<Predicate> Predicates = [IsThumb];
377}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000378
Jim Grosbachd42257c2010-12-15 18:48:45 +0000379// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000380class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000381 list<dag> pattern>
382 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000383 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000384 list<Predicate> Predicates = [IsThumb2];
385}
Jim Grosbach95dee402011-07-08 17:40:42 +0000386
Owen Anderson651b2302011-07-13 23:22:26 +0000387class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000388 InstrItinClass itin, list<dag> pattern,
389 dag Result>
390 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
391 PseudoInstExpansion<Result>;
392
Owen Anderson651b2302011-07-13 23:22:26 +0000393class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000394 InstrItinClass itin, list<dag> pattern,
395 dag Result>
396 : tPseudoInst<oops, iops, sz, itin, pattern>,
397 PseudoInstExpansion<Result>;
398
Owen Anderson651b2302011-07-13 23:22:26 +0000399class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000400 InstrItinClass itin, list<dag> pattern,
401 dag Result>
402 : t2PseudoInst<oops, iops, sz, itin, pattern>,
403 PseudoInstExpansion<Result>;
404
Evan Cheng2d37f192008-08-28 23:39:26 +0000405// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000406class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000407 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000408 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000409 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000410 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000411 bits<4> p;
412 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000413 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000414 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000415 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000416 let Pattern = pattern;
417 list<Predicate> Predicates = [IsARM];
418}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000419
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000420// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000421class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000422 IndexMode im, Format f, InstrItinClass itin,
423 string opc, string asm, string cstr,
424 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000425 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
426 let OutOperandList = oops;
427 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000428 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000429 let Pattern = pattern;
430 let isPredicable = 0;
431 list<Predicate> Predicates = [IsARM];
432}
Evan Cheng2d37f192008-08-28 23:39:26 +0000433
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000434// Same as I except it can optionally modify CPSR. Note it's modeled as an input
435// operand since by default it's a zero register. It will become an implicit def
436// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000437class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000438 IndexMode im, Format f, InstrItinClass itin,
439 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000440 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000441 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000442 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000443 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000444 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000445 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000446
Evan Cheng2d37f192008-08-28 23:39:26 +0000447 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000448 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000449 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000450 let Pattern = pattern;
451 list<Predicate> Predicates = [IsARM];
452}
453
Evan Chenga2827232008-09-01 07:19:00 +0000454// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000455class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000456 IndexMode im, Format f, InstrItinClass itin,
457 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000458 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000459 let OutOperandList = oops;
460 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000461 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000462 let Pattern = pattern;
463 list<Predicate> Predicates = [IsARM];
464}
465
David Goodwinb062c232009-08-06 16:52:47 +0000466class AI<dag oops, dag iops, Format f, InstrItinClass itin,
467 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000468 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000469 opc, asm, "", pattern>;
470class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
471 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000472 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000473 opc, asm, "", pattern>;
474class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000475 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000476 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000477 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000478class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000479 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000480 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000481 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000482
483// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000484class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
485 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000486 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000487 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000488 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000489}
David Goodwinb062c232009-08-06 16:52:47 +0000490class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
491 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000492 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000493 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000494 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000495}
Evan Chengfa558782008-09-01 08:25:56 +0000496
497// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000498class JTI<dag oops, dag iops, InstrItinClass itin,
499 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000500 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000501 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000502
Joey Goulye6d165c2013-08-27 17:38:16 +0000503class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000504 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000505 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000506 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000507 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000508 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000509 let Inst{27-23} = 0b00011;
510 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000511 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000512 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000513 let Inst{15-12} = Rt;
Joey Goulye6d165c2013-08-27 17:38:16 +0000514 let Inst{11-10} = 0b11;
515 let Inst{9-8} = opcod2;
516 let Inst{7-0} = 0b10011111;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000517}
Joey Goulye6d165c2013-08-27 17:38:16 +0000518class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000519 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000520 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000521 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000522 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000523 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000524 let Inst{27-23} = 0b00011;
525 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000526 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000527 let Inst{19-16} = addr;
Joey Goulye6d165c2013-08-27 17:38:16 +0000528 let Inst{11-10} = 0b11;
529 let Inst{9-8} = opcod2;
530 let Inst{7-4} = 0b1001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000531 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000532}
Joey Goulye6d165c2013-08-27 17:38:16 +0000533// Atomic load/store instructions
534class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
535 string opc, string asm, list<dag> pattern>
536 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
537
538class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
539 string opc, string asm, list<dag> pattern>
540 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
541 bits<4> Rd;
542 let Inst{15-12} = Rd;
543}
544
545// Exclusive load/store instructions
546
547class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
548 string opc, string asm, list<dag> pattern>
549 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
550 Requires<[IsARM, HasV8]>;
551
552class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
553 string opc, string asm, list<dag> pattern>
554 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
555 Requires<[IsARM, HasV8]> {
556 bits<4> Rd;
557 let Inst{15-12} = Rd;
558}
559
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000560class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000561 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000562 bits<4> Rt;
563 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000564 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000565 let Inst{27-23} = 0b00010;
566 let Inst{22} = b;
567 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000568 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000569 let Inst{15-12} = Rt;
570 let Inst{11-4} = 0b00001001;
571 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000572
Silviu Barangaca45af92012-04-18 14:18:57 +0000573 let Unpredictable{11-8} = 0b1111;
Owen Andersondde461c2011-10-28 18:02:13 +0000574 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000575}
Joey Goulye6d165c2013-08-27 17:38:16 +0000576// Acquire/Release load/store instructions
577class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
578 string opc, string asm, list<dag> pattern>
579 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
580 Requires<[IsARM, HasV8]>;
581
582class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
583 string opc, string asm, list<dag> pattern>
584 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
585 Requires<[IsARM, HasV8]> {
586 let Inst{15-12} = 0b1111;
587}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000588
Evan Cheng624844b2008-09-01 01:51:14 +0000589// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000590class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
591 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000592 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000593 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000594 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000595 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000596}
David Goodwinb062c232009-08-06 16:52:47 +0000597class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
598 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000599 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000600 opc, asm, "", pattern> {
601 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000602 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000603}
604class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000605 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000606 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000607 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000608 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000609 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000610}
Evan Cheng624844b2008-09-01 01:51:14 +0000611
Evan Chengcccca872008-09-01 01:27:33 +0000612// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000613
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000614// LDR/LDRB/STR/STRB/...
615class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000616 Format f, InstrItinClass itin, string opc, string asm,
617 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000618 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000619 "", pattern> {
620 let Inst{27-25} = op;
621 let Inst{24} = 1; // 24 == P
622 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000623 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000624 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000625 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000626}
Jim Grosbach2f790742010-11-13 00:35:48 +0000627// Indexed load/stores
628class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000629 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000630 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000631 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000632 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000633 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000634 let Inst{27-26} = 0b01;
635 let Inst{24} = isPre; // P bit
636 let Inst{22} = isByte; // B bit
637 let Inst{21} = isPre; // W bit
638 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000639 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000640}
Owen Anderson2aedba62011-07-26 20:54:26 +0000641class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000642 IndexMode im, Format f, InstrItinClass itin, string opc,
643 string asm, string cstr, list<dag> pattern>
644 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
645 pattern> {
646 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000647 // {12} isAdd
648 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000649 bits<14> offset;
650 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000651 let Inst{25} = 1;
652 let Inst{23} = offset{12};
653 let Inst{19-16} = Rn;
654 let Inst{11-5} = offset{11-5};
655 let Inst{4} = 0;
656 let Inst{3-0} = offset{3-0};
657}
658
659class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
660 IndexMode im, Format f, InstrItinClass itin, string opc,
661 string asm, string cstr, list<dag> pattern>
662 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
663 pattern> {
664 // AM2 store w/ two operands: (GPR, am2offset)
665 // {12} isAdd
666 // {11-0} imm12/Rm
667 bits<14> offset;
668 bits<4> Rn;
669 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000670 let Inst{23} = offset{12};
671 let Inst{19-16} = Rn;
672 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000673}
Owen Anderson2aedba62011-07-26 20:54:26 +0000674
675
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000676// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
677// but for now use this class for STRT and STRBT.
678class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
679 IndexMode im, Format f, InstrItinClass itin, string opc,
680 string asm, string cstr, list<dag> pattern>
681 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
682 pattern> {
683 // AM2 store w/ two operands: (GPR, am2offset)
684 // {17-14} Rn
685 // {13} 1 == Rm, 0 == imm12
686 // {12} isAdd
687 // {11-0} imm12/Rm
688 bits<18> addr;
689 let Inst{25} = addr{13};
690 let Inst{23} = addr{12};
691 let Inst{19-16} = addr{17-14};
692 let Inst{11-0} = addr{11-0};
693}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000694
Evan Cheng624844b2008-09-01 01:51:14 +0000695// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000696class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
697 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000698 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000699 opc, asm, "", pattern> {
700 bits<14> addr;
701 bits<4> Rt;
702 let Inst{27-25} = 0b000;
703 let Inst{24} = 1; // P bit
704 let Inst{23} = addr{8}; // U bit
705 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
706 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000707 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000708 let Inst{19-16} = addr{12-9}; // Rn
709 let Inst{15-12} = Rt; // Rt
710 let Inst{11-8} = addr{7-4}; // imm7_4/zero
711 let Inst{7-4} = op;
712 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000713
714 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000715}
Evan Cheng169eccc2008-09-01 07:00:14 +0000716
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000717class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000718 IndexMode im, Format f, InstrItinClass itin, string opc,
719 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000720 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000721 opc, asm, cstr, pattern> {
722 bits<4> Rt;
723 let Inst{27-25} = 0b000;
724 let Inst{24} = isPre; // P bit
725 let Inst{21} = isPre; // W bit
726 let Inst{20} = op20; // L bit
727 let Inst{15-12} = Rt; // Rt
728 let Inst{7-4} = op;
729}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000730
731// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
732// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000733class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000734 IndexMode im, Format f, InstrItinClass itin, string opc,
735 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000736 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000737 // {13} 1 == imm8, 0 == Rm
738 // {12-9} Rn
739 // {8} isAdd
740 // {7-4} imm7_4/zero
741 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000742 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000743 bits<4> Rt;
744 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000745 let Inst{24} = 0; // P bit
746 let Inst{21} = 1;
747 let Inst{20} = isLoad; // L bit
748 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000749 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000750 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000751}
752
Evan Cheng169eccc2008-09-01 07:00:14 +0000753// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000754class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000755 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000756 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000757 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000758 bits<14> addr;
759 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000760 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000761 let Inst{24} = 1; // P bit
762 let Inst{23} = addr{8}; // U bit
763 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
764 let Inst{21} = 0; // W bit
765 let Inst{20} = 0; // L bit
766 let Inst{19-16} = addr{12-9}; // Rn
767 let Inst{15-12} = Rt; // Rt
768 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000769 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000770 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000771 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000772}
Evan Cheng169eccc2008-09-01 07:00:14 +0000773
Evan Cheng624844b2008-09-01 01:51:14 +0000774// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000775class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
776 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000777 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000778 bits<4> p;
779 bits<16> regs;
780 bits<4> Rn;
781 let Inst{31-28} = p;
782 let Inst{27-25} = 0b100;
783 let Inst{22} = 0; // S bit
784 let Inst{19-16} = Rn;
785 let Inst{15-0} = regs;
786}
Evan Cheng2d37f192008-08-28 23:39:26 +0000787
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000788// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000789class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
790 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000791 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000792 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000793 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000794 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000795 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000796}
David Goodwinb062c232009-08-06 16:52:47 +0000797class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
798 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000799 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000800 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000801 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000802 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000803}
804
805// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000806class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
807 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000808 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000809 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000810 bits<4> Rd;
811 bits<4> Rn;
812 bits<4> Rm;
813 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000814 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000815 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000816 let Inst{19-16} = Rd;
817 let Inst{11-8} = Rm;
818 let Inst{3-0} = Rn;
819}
820// MSW multiple w/ Ra operand
821class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
822 InstrItinClass itin, string opc, string asm, list<dag> pattern>
823 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
824 bits<4> Ra;
825 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000826}
Evan Cheng2d37f192008-08-28 23:39:26 +0000827
Evan Cheng36ae4032008-11-06 03:35:07 +0000828// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000829class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000830 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000831 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000832 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000833 bits<4> Rn;
834 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000835 let Inst{4} = 0;
836 let Inst{7} = 1;
837 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000838 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000839 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000840 let Inst{11-8} = Rm;
841 let Inst{3-0} = Rn;
842}
843class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
844 InstrItinClass itin, string opc, string asm, list<dag> pattern>
845 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
846 bits<4> Rd;
847 let Inst{19-16} = Rd;
848}
849
850// AMulxyI with Ra operand
851class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
852 InstrItinClass itin, string opc, string asm, list<dag> pattern>
853 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
854 bits<4> Ra;
855 let Inst{15-12} = Ra;
856}
857// SMLAL*
858class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
859 InstrItinClass itin, string opc, string asm, list<dag> pattern>
860 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
861 bits<4> RdLo;
862 bits<4> RdHi;
863 let Inst{19-16} = RdHi;
864 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000865}
866
Evan Cheng49d66522008-11-06 22:15:19 +0000867// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000868class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
869 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000870 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000871 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000872 // All AExtI instructions have Rd and Rm register operands.
873 bits<4> Rd;
874 bits<4> Rm;
875 let Inst{15-12} = Rd;
876 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000877 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000878 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000879 let Inst{27-20} = opcod;
Silviu Barangaddc67a72012-05-11 09:28:27 +0000880
881 let Unpredictable{9-8} = 0b11;
Evan Cheng49d66522008-11-06 22:15:19 +0000882}
883
Evan Cheng98dc53e2008-11-07 01:41:35 +0000884// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000885class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
886 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000887 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000888 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000889 bits<4> Rd;
890 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000891 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000892 let Inst{19-16} = 0b1111;
893 let Inst{15-12} = Rd;
894 let Inst{11-8} = 0b1111;
895 let Inst{7-4} = opc7_4;
896 let Inst{3-0} = Rm;
897}
898
Bob Wilsone8a549c2012-09-29 21:43:49 +0000899// Division instructions.
900class ADivA1I<bits<3> opcod, dag oops, dag iops,
901 InstrItinClass itin, string opc, string asm, list<dag> pattern>
902 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
903 opc, asm, "", pattern> {
904 bits<4> Rd;
905 bits<4> Rn;
906 bits<4> Rm;
907 let Inst{27-23} = 0b01110;
908 let Inst{22-20} = opcod;
909 let Inst{19-16} = Rd;
910 let Inst{15-12} = 0b1111;
911 let Inst{11-8} = Rm;
912 let Inst{7-4} = 0b0001;
913 let Inst{3-0} = Rn;
914}
915
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000916// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000917def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000918 let Name = "PKHLSLImm";
919 let ParserMethod = "parsePKHLSLImm";
920}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000921def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
922 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000923 let ParserMatchClass = PKHLSLAsmOperand;
924}
925def PKHASRAsmOperand : AsmOperandClass {
926 let Name = "PKHASRImm";
927 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000928}
929def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
930 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000931 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000932}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000933
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000934class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
935 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000936 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000937 opc, asm, "", pattern> {
938 bits<4> Rd;
939 bits<4> Rn;
940 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000941 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000942 let Inst{27-20} = opcod;
943 let Inst{19-16} = Rn;
944 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000945 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000946 let Inst{6} = tb;
947 let Inst{5-4} = 0b01;
948 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000949}
950
Evan Cheng2d37f192008-08-28 23:39:26 +0000951//===----------------------------------------------------------------------===//
952
953// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
954class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
955 list<Predicate> Predicates = [IsARM];
956}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000957class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
958 list<Predicate> Predicates = [IsARM, HasV5T];
959}
Evan Cheng2d37f192008-08-28 23:39:26 +0000960class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
961 list<Predicate> Predicates = [IsARM, HasV5TE];
962}
Bob Wilsone8a549c2012-09-29 21:43:49 +0000963// ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
964class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
965 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
966}
Evan Cheng2d37f192008-08-28 23:39:26 +0000967class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
968 list<Predicate> Predicates = [IsARM, HasV6];
969}
Evan Chengee98fa92008-08-29 06:41:12 +0000970
971//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000972// Thumb Instruction Format Definitions.
973//
974
Owen Anderson651b2302011-07-13 23:22:26 +0000975class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000976 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000977 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000978 let OutOperandList = oops;
979 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000980 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000981 let Pattern = pattern;
982 list<Predicate> Predicates = [IsThumb];
983}
984
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000985// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000986class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000987 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000988
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000989// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000990class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
991 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000992 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000993 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000994
Johnny Chenc28e6292009-12-15 17:24:14 +0000995// tBL, tBX 32-bit instructions
996class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000997 dag oops, dag iops, InstrItinClass itin, string asm,
998 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000999 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001000 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +00001001 let Inst{31-27} = opcod1;
1002 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001003 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +00001004}
Evan Chengee98fa92008-08-29 06:41:12 +00001005
1006// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001007class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1008 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001009 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001010
Evan Chengbec1dba892009-06-23 19:38:13 +00001011// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +00001012class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001013 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001014 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001015 let OutOperandList = oops;
1016 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001017 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +00001018 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001019 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +00001020}
1021
David Goodwinb062c232009-08-06 16:52:47 +00001022class T1I<dag oops, dag iops, InstrItinClass itin,
1023 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001024 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001025class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1026 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001027 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001028
1029// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001030class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001031 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001032 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001033 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001034
1035// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +00001036class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001037 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001038 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001039 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001040 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1041 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001042 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001043 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +00001044 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001045 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +00001046 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +00001047}
1048
David Goodwinb062c232009-08-06 16:52:47 +00001049class T1sI<dag oops, dag iops, InstrItinClass itin,
1050 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001051 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001052
1053// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001054class T1sIt<dag oops, dag iops, InstrItinClass itin,
1055 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001056 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +00001057 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001058
1059// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +00001060class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001061 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001062 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001063 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001064 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001065 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001066 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001067 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001068 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +00001069}
1070
David Goodwinb062c232009-08-06 16:52:47 +00001071class T1pI<dag oops, dag iops, InstrItinClass itin,
1072 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001073 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001074
1075// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001076class T1pIt<dag oops, dag iops, InstrItinClass itin,
1077 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001078 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +00001079 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001080
Bob Wilson3968c6a2010-03-23 17:23:59 +00001081class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001082 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001083 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001084
Johnny Chen466231a2009-12-16 02:32:54 +00001085class Encoding16 : Encoding {
1086 let Inst{31-16} = 0x0000;
1087}
1088
Johnny Chenc28e6292009-12-15 17:24:14 +00001089// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +00001090class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001091 let Inst{15-10} = opcode;
1092}
1093
1094// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001095class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001096 let Inst{15-14} = 0b00;
1097 let Inst{13-9} = opcode;
1098}
1099
1100// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001101class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001102 let Inst{15-10} = 0b010000;
1103 let Inst{9-6} = opcode;
1104}
1105
1106// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001107class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001108 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001109 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001110}
1111
1112// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001113class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001114 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001115 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001116}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001117class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001118
Eric Christopher9b67db82011-05-27 03:50:53 +00001119class T1BranchCond<bits<4> opcode> : Encoding16 {
1120 let Inst{15-12} = opcode;
1121}
1122
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001123// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001124// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001125//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001126// 0b0110 => Immediate, 4 bytes
1127// 0b1000 => Immediate, 2 bytes
1128// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001129class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1130 InstrItinClass itin, string opc, string asm,
1131 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001132 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001133 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001134 bits<3> Rt;
1135 bits<8> addr;
1136 let Inst{8-6} = addr{5-3}; // Rm
1137 let Inst{5-3} = addr{2-0}; // Rn
1138 let Inst{2-0} = Rt;
1139}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001140class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1141 InstrItinClass itin, string opc, string asm,
1142 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001143 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001144 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001145 bits<3> Rt;
1146 bits<8> addr;
1147 let Inst{10-6} = addr{7-3}; // imm5
1148 let Inst{5-3} = addr{2-0}; // Rn
1149 let Inst{2-0} = Rt;
1150}
1151
Johnny Chenc28e6292009-12-15 17:24:14 +00001152// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001153class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001154 let Inst{15-12} = 0b1011;
1155 let Inst{11-5} = opcode;
1156}
1157
Evan Chengd76f0be2009-06-25 02:08:06 +00001158// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001159class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001160 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001161 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001162 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001163 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001164 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001165 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001166 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001167 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001168 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001169}
1170
Bill Wendlingb70dc872010-08-31 07:50:46 +00001171// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1172// input operand since by default it's a zero register. It will become an
1173// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001174//
Evan Chengd76f0be2009-06-25 02:08:06 +00001175// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1176// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001177class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001178 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001179 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001180 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001181 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1182 let Inst{20} = s;
1183
Evan Chengd76f0be2009-06-25 02:08:06 +00001184 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001185 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001186 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001187 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001188 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001189 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001190}
1191
1192// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001193class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001194 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001195 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001196 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001197 let OutOperandList = oops;
1198 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001199 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001200 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001201 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001202 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001203}
1204
Owen Anderson651b2302011-07-13 23:22:26 +00001205class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001206 InstrItinClass itin,
1207 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001208 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1209 let OutOperandList = oops;
1210 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001211 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001212 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001213 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001214 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001215}
1216
David Goodwinb062c232009-08-06 16:52:47 +00001217class T2I<dag oops, dag iops, InstrItinClass itin,
1218 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001219 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001220class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1221 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001222 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001223class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1224 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001225 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001226class T2Iso<dag oops, dag iops, InstrItinClass itin,
1227 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001228 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001229class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1230 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001231 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001232class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001233 string opc, string asm, string cstr, list<dag> pattern>
1234 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001235 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001236 bits<4> Rt;
1237 bits<4> Rt2;
1238 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001239 let Inst{31-25} = 0b1110100;
1240 let Inst{24} = P;
1241 let Inst{23} = addr{8};
1242 let Inst{22} = 1;
1243 let Inst{21} = W;
1244 let Inst{20} = isLoad;
1245 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001246 let Inst{15-12} = Rt{3-0};
1247 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001248 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001249}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001250class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1251 InstrItinClass itin, string opc, string asm, string cstr,
1252 list<dag> pattern>
1253 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001254 pattern> {
1255 bits<4> Rt;
1256 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001257 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001258 bits<9> imm;
1259 let Inst{31-25} = 0b1110100;
1260 let Inst{24} = P;
1261 let Inst{23} = imm{8};
1262 let Inst{22} = 1;
1263 let Inst{21} = W;
1264 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001265 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001266 let Inst{15-12} = Rt{3-0};
1267 let Inst{11-8} = Rt2{3-0};
1268 let Inst{7-0} = imm{7-0};
1269}
1270
David Goodwinb062c232009-08-06 16:52:47 +00001271class T2sI<dag oops, dag iops, InstrItinClass itin,
1272 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001273 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001274
David Goodwinb062c232009-08-06 16:52:47 +00001275class T2XI<dag oops, dag iops, InstrItinClass itin,
1276 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001277 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001278class T2JTI<dag oops, dag iops, InstrItinClass itin,
1279 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001280 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001281
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001282// Move to/from coprocessor instructions
Tim Northover2c45a382013-06-26 16:52:40 +00001283class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1284 list<dag> pattern>
1285 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001286 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001287}
1288
Bob Wilson947f04b2010-03-13 01:08:20 +00001289// Two-address instructions
1290class T2XIt<dag oops, dag iops, InstrItinClass itin,
1291 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001292 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001293
Jim Grosbachc086f682011-09-08 00:39:19 +00001294// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1295class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001296 dag oops, dag iops,
1297 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001298 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001299 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001300 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001301 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001302 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001303 let Pattern = pattern;
1304 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001305 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001306
1307 bits<4> Rt;
1308 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001309 let Inst{31-27} = 0b11111;
1310 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001311 let Inst{24} = signed;
1312 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001313 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001314 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001315 let Inst{19-16} = addr{12-9};
1316 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001317 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001318 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001319 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001320 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001321 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001322 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001323
1324 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001325}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001326
Jim Grosbachc086f682011-09-08 00:39:19 +00001327// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1328class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1329 dag oops, dag iops,
1330 AddrMode am, IndexMode im, InstrItinClass itin,
1331 string opc, string asm, string cstr, list<dag> pattern>
1332 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1333 let OutOperandList = oops;
1334 let InOperandList = !con(iops, (ins pred:$p));
1335 let AsmString = !strconcat(opc, "${p}", asm);
1336 let Pattern = pattern;
1337 list<Predicate> Predicates = [IsThumb2];
1338 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001339
Owen Andersone22c7322010-11-30 00:14:31 +00001340 bits<4> Rt;
1341 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001342 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001343 let Inst{31-27} = 0b11111;
1344 let Inst{26-25} = 0b00;
1345 let Inst{24} = signed;
1346 let Inst{23} = 0;
1347 let Inst{22-21} = opcod;
1348 let Inst{20} = load;
1349 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001350 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001351 let Inst{11} = 1;
1352 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1353 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001354 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001355 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001356 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001357
1358 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001359}
1360
David Goodwine5b969f2009-07-27 19:59:26 +00001361// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1362class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001363 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001364}
1365
1366// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1367class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001368 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001369}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001370
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001371// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1372class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1373 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1374}
1375
Evan Chengeab9ca72009-06-27 02:26:13 +00001376// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1377class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001378 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001379}
1380
Evan Chengee98fa92008-08-29 06:41:12 +00001381//===----------------------------------------------------------------------===//
1382
Evan Chengac2af2f2008-11-11 02:11:05 +00001383//===----------------------------------------------------------------------===//
1384// ARM VFP Instruction templates.
1385//
1386
David Goodwin81cdd212009-07-10 17:03:29 +00001387// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001388class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001389 IndexMode im, Format f, InstrItinClass itin,
1390 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001391 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001392 bits<4> p;
1393 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001394 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001395 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001396 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001397 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001398 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001399 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001400 list<Predicate> Predicates = [HasVFP2];
1401}
1402
1403// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001404class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001405 IndexMode im, Format f, InstrItinClass itin,
1406 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001407 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001408 bits<4> p;
1409 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001410 let OutOperandList = oops;
1411 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001412 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001413 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001414 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001415 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001416 list<Predicate> Predicates = [HasVFP2];
1417}
1418
David Goodwinb062c232009-08-06 16:52:47 +00001419class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1420 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001421 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001422 opc, asm, "", pattern> {
1423 let PostEncoderMethod = "VFPThumb2PostEncoder";
1424}
David Goodwin81cdd212009-07-10 17:03:29 +00001425
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001426// ARM VFP addrmode5 loads and stores
1427class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001428 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001429 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001430 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001431 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001432 // Instruction operands.
1433 bits<5> Dd;
1434 bits<13> addr;
1435
1436 // Encode instruction operands.
1437 let Inst{23} = addr{8}; // U (add = (U == '1'))
1438 let Inst{22} = Dd{4};
1439 let Inst{19-16} = addr{12-9}; // Rn
1440 let Inst{15-12} = Dd{3-0};
1441 let Inst{7-0} = addr{7-0}; // imm8
1442
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001443 let Inst{27-24} = opcod1;
1444 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001445 let Inst{11-9} = 0b101;
1446 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001447
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001448 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001449 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001450}
1451
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001452class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001453 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001454 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001455 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001456 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001457 // Instruction operands.
1458 bits<5> Sd;
1459 bits<13> addr;
1460
1461 // Encode instruction operands.
1462 let Inst{23} = addr{8}; // U (add = (U == '1'))
1463 let Inst{22} = Sd{0};
1464 let Inst{19-16} = addr{12-9}; // Rn
1465 let Inst{15-12} = Sd{4-1};
1466 let Inst{7-0} = addr{7-0}; // imm8
1467
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001468 let Inst{27-24} = opcod1;
1469 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001470 let Inst{11-9} = 0b101;
1471 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001472
1473 // Loads & stores operate on both NEON and VFP pipelines.
1474 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001475}
1476
Bob Wilson6b853c32010-09-16 00:31:02 +00001477// VFP Load / store multiple pseudo instructions.
1478class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1479 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001480 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001481 cstr, itin> {
1482 let OutOperandList = oops;
1483 let InOperandList = !con(iops, (ins pred:$p));
1484 let Pattern = pattern;
1485 list<Predicate> Predicates = [HasVFP2];
1486}
1487
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001488// Load / store multiple
Tim Northover4173e292013-05-31 15:55:51 +00001489
1490// Unknown precision
1491class AXXI4<dag oops, dag iops, IndexMode im,
1492 string asm, string cstr, list<dag> pattern>
1493 : VFPXI<oops, iops, AddrMode4, 4, im,
1494 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1495 // Instruction operands.
1496 bits<4> Rn;
1497 bits<13> regs;
1498
1499 // Encode instruction operands.
1500 let Inst{19-16} = Rn;
1501 let Inst{22} = 0;
1502 let Inst{15-12} = regs{11-8};
1503 let Inst{7-1} = regs{7-1};
1504
1505 let Inst{27-25} = 0b110;
1506 let Inst{11-8} = 0b1011;
1507 let Inst{0} = 1;
1508}
1509
1510// Double precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001511class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001512 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001513 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001514 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001515 // Instruction operands.
1516 bits<4> Rn;
1517 bits<13> regs;
1518
1519 // Encode instruction operands.
1520 let Inst{19-16} = Rn;
1521 let Inst{22} = regs{12};
1522 let Inst{15-12} = regs{11-8};
Tim Northover4173e292013-05-31 15:55:51 +00001523 let Inst{7-1} = regs{7-1};
Bill Wendling345b48f2010-11-17 00:45:23 +00001524
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001525 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001526 let Inst{11-9} = 0b101;
1527 let Inst{8} = 1; // Double precision
Tim Northover4173e292013-05-31 15:55:51 +00001528 let Inst{0} = 0;
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001529}
1530
Tim Northover4173e292013-05-31 15:55:51 +00001531// Single Precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001532class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001533 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001534 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001535 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001536 // Instruction operands.
1537 bits<4> Rn;
1538 bits<13> regs;
1539
1540 // Encode instruction operands.
1541 let Inst{19-16} = Rn;
1542 let Inst{22} = regs{8};
1543 let Inst{15-12} = regs{12-9};
1544 let Inst{7-0} = regs{7-0};
1545
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001546 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001547 let Inst{11-9} = 0b101;
1548 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001549}
1550
Evan Chengac2af2f2008-11-11 02:11:05 +00001551// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001552class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1553 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1554 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001555 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001556 // Instruction operands.
1557 bits<5> Dd;
1558 bits<5> Dm;
1559
1560 // Encode instruction operands.
1561 let Inst{3-0} = Dm{3-0};
1562 let Inst{5} = Dm{4};
1563 let Inst{15-12} = Dd{3-0};
1564 let Inst{22} = Dd{4};
1565
Johnny Chen34a6afc2010-01-29 23:21:10 +00001566 let Inst{27-23} = opcod1;
1567 let Inst{21-20} = opcod2;
1568 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001569 let Inst{11-9} = 0b101;
1570 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001571 let Inst{7-6} = opcod4;
1572 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001573}
1574
Joey Gouly0f12aa22013-07-09 11:26:18 +00001575// Double precision, unary, not-predicated
1576class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1577 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1578 string asm, list<dag> pattern>
1579 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1580 // Instruction operands.
1581 bits<5> Dd;
1582 bits<5> Dm;
1583
1584 let Inst{31-28} = 0b1111;
1585
1586 // Encode instruction operands.
1587 let Inst{3-0} = Dm{3-0};
1588 let Inst{5} = Dm{4};
1589 let Inst{15-12} = Dd{3-0};
1590 let Inst{22} = Dd{4};
1591
1592 let Inst{27-23} = opcod1;
1593 let Inst{21-20} = opcod2;
1594 let Inst{19-16} = opcod3;
1595 let Inst{11-9} = 0b101;
1596 let Inst{8} = 1; // Double precision
1597 let Inst{7-6} = opcod4;
1598 let Inst{4} = opcod5;
1599}
1600
Evan Chengac2af2f2008-11-11 02:11:05 +00001601// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001602class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001603 dag iops, InstrItinClass itin, string opc, string asm,
1604 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001605 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001606 // Instruction operands.
1607 bits<5> Dd;
1608 bits<5> Dn;
1609 bits<5> Dm;
1610
1611 // Encode instruction operands.
1612 let Inst{3-0} = Dm{3-0};
1613 let Inst{5} = Dm{4};
1614 let Inst{19-16} = Dn{3-0};
1615 let Inst{7} = Dn{4};
1616 let Inst{15-12} = Dd{3-0};
1617 let Inst{22} = Dd{4};
1618
Johnny Chen34a6afc2010-01-29 23:21:10 +00001619 let Inst{27-23} = opcod1;
1620 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001621 let Inst{11-9} = 0b101;
1622 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001623 let Inst{6} = op6;
1624 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001625}
1626
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001627// FP, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001628class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001629 InstrItinClass itin, string asm, list<dag> pattern>
Joey Gouly2d0175e2013-07-09 09:59:04 +00001630 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1631 asm, "", pattern>
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001632{
1633 // Instruction operands.
1634 bits<5> Dd;
1635 bits<5> Dn;
1636 bits<5> Dm;
1637
1638 let Inst{31-28} = 0b1111;
1639
1640 // Encode instruction operands.
1641 let Inst{3-0} = Dm{3-0};
1642 let Inst{5} = Dm{4};
1643 let Inst{19-16} = Dn{3-0};
1644 let Inst{7} = Dn{4};
1645 let Inst{15-12} = Dd{3-0};
1646 let Inst{22} = Dd{4};
1647
1648 let Inst{27-23} = opcod1;
1649 let Inst{21-20} = opcod2;
1650 let Inst{11-9} = 0b101;
1651 let Inst{8} = 1; // double precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001652 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001653 let Inst{4} = 0;
1654}
1655
Joey Gouly2d0175e2013-07-09 09:59:04 +00001656// Single precision, unary, predicated
Johnny Chen34a6afc2010-01-29 23:21:10 +00001657class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1658 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1659 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001660 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001661 // Instruction operands.
1662 bits<5> Sd;
1663 bits<5> Sm;
1664
1665 // Encode instruction operands.
1666 let Inst{3-0} = Sm{4-1};
1667 let Inst{5} = Sm{0};
1668 let Inst{15-12} = Sd{4-1};
1669 let Inst{22} = Sd{0};
1670
Johnny Chen34a6afc2010-01-29 23:21:10 +00001671 let Inst{27-23} = opcod1;
1672 let Inst{21-20} = opcod2;
1673 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001674 let Inst{11-9} = 0b101;
1675 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001676 let Inst{7-6} = opcod4;
1677 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001678}
1679
Joey Gouly2d0175e2013-07-09 09:59:04 +00001680// Single precision, unary, non-predicated
1681class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1682 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1683 string asm, list<dag> pattern>
1684 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1685 VFPUnaryFrm, itin, asm, "", pattern> {
1686 // Instruction operands.
1687 bits<5> Sd;
1688 bits<5> Sm;
1689
1690 let Inst{31-28} = 0b1111;
1691
1692 // Encode instruction operands.
1693 let Inst{3-0} = Sm{4-1};
1694 let Inst{5} = Sm{0};
1695 let Inst{15-12} = Sd{4-1};
1696 let Inst{22} = Sd{0};
1697
1698 let Inst{27-23} = opcod1;
1699 let Inst{21-20} = opcod2;
1700 let Inst{19-16} = opcod3;
1701 let Inst{11-9} = 0b101;
1702 let Inst{8} = 0; // Single precision
1703 let Inst{7-6} = opcod4;
1704 let Inst{4} = opcod5;
1705}
1706
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001707// Single precision unary, if no NEON. Same as ASuI except not available if
1708// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001709class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1710 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1711 string asm, list<dag> pattern>
1712 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1713 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001714 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1715}
1716
Evan Chengac2af2f2008-11-11 02:11:05 +00001717// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001718class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1719 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001720 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001721 // Instruction operands.
1722 bits<5> Sd;
1723 bits<5> Sn;
1724 bits<5> Sm;
1725
1726 // Encode instruction operands.
1727 let Inst{3-0} = Sm{4-1};
1728 let Inst{5} = Sm{0};
1729 let Inst{19-16} = Sn{4-1};
1730 let Inst{7} = Sn{0};
1731 let Inst{15-12} = Sd{4-1};
1732 let Inst{22} = Sd{0};
1733
Johnny Chen34a6afc2010-01-29 23:21:10 +00001734 let Inst{27-23} = opcod1;
1735 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001736 let Inst{11-9} = 0b101;
1737 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001738 let Inst{6} = op6;
1739 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001740}
1741
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001742// Single precision, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001743class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001744 InstrItinClass itin, string asm, list<dag> pattern>
1745 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1746 VFPBinaryFrm, itin, asm, "", pattern>
1747{
1748 // Instruction operands.
1749 bits<5> Sd;
1750 bits<5> Sn;
1751 bits<5> Sm;
1752
1753 let Inst{31-28} = 0b1111;
1754
1755 // Encode instruction operands.
1756 let Inst{3-0} = Sm{4-1};
1757 let Inst{5} = Sm{0};
1758 let Inst{19-16} = Sn{4-1};
1759 let Inst{7} = Sn{0};
1760 let Inst{15-12} = Sd{4-1};
1761 let Inst{22} = Sd{0};
1762
1763 let Inst{27-23} = opcod1;
1764 let Inst{21-20} = opcod2;
1765 let Inst{11-9} = 0b101;
1766 let Inst{8} = 0; // Single precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001767 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001768 let Inst{4} = 0;
1769}
1770
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001771// Single precision binary, if no NEON. Same as ASbI except not available if
1772// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001773class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001774 dag iops, InstrItinClass itin, string opc, string asm,
1775 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001776 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001777 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001778
1779 // Instruction operands.
1780 bits<5> Sd;
1781 bits<5> Sn;
1782 bits<5> Sm;
1783
1784 // Encode instruction operands.
1785 let Inst{3-0} = Sm{4-1};
1786 let Inst{5} = Sm{0};
1787 let Inst{19-16} = Sn{4-1};
1788 let Inst{7} = Sn{0};
1789 let Inst{15-12} = Sd{4-1};
1790 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001791}
1792
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001793// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001794class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1795 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1796 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001797 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001798 let Inst{27-23} = opcod1;
1799 let Inst{21-20} = opcod2;
1800 let Inst{19-16} = opcod3;
1801 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001802 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001803 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001804}
1805
Johnny Chen39640592010-02-11 18:47:03 +00001806// VFP conversion between floating-point and fixed-point
1807class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001808 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1809 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001810 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
Jim Grosbachf0d25112011-12-22 19:55:21 +00001811 bits<5> fbits;
Johnny Chen39640592010-02-11 18:47:03 +00001812 // size (fixed-point number): sx == 0 ? 16 : 32
1813 let Inst{7} = op5; // sx
Jim Grosbachf0d25112011-12-22 19:55:21 +00001814 let Inst{5} = fbits{0};
1815 let Inst{3-0} = fbits{4-1};
Johnny Chen39640592010-02-11 18:47:03 +00001816}
1817
David Goodwin85b5b022009-08-10 22:17:39 +00001818// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001819class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001820 dag oops, dag iops, InstrItinClass itin,
1821 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001822 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1823 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001824 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1825}
1826
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001827class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001828 InstrItinClass itin,
1829 string opc, string asm, list<dag> pattern>
1830 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001831 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001832 let Inst{11-8} = opcod2;
1833 let Inst{4} = 1;
1834}
1835
David Goodwinb062c232009-08-06 16:52:47 +00001836class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1837 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1838 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001839
Bob Wilson3968c6a2010-03-23 17:23:59 +00001840class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001841 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1842 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001843
David Goodwinb062c232009-08-06 16:52:47 +00001844class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1845 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1846 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001847
David Goodwinb062c232009-08-06 16:52:47 +00001848class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1849 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1850 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001851
Evan Chengac2af2f2008-11-11 02:11:05 +00001852//===----------------------------------------------------------------------===//
1853
Bob Wilson2e076c42009-06-22 23:27:02 +00001854//===----------------------------------------------------------------------===//
1855// ARM NEON Instruction templates.
1856//
Evan Chengee98fa92008-08-29 06:41:12 +00001857
Johnny Chenf833fad2010-03-20 00:17:00 +00001858class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1859 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1860 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001861 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001862 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001863 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001864 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001865 let Pattern = pattern;
1866 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001867 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001868}
1869
1870// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001871class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1872 InstrItinClass itin, string opc, string asm, string cstr,
1873 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001874 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001875 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001876 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001877 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001878 let Pattern = pattern;
1879 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001880 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001881}
1882
Joey Goulydf686002013-07-17 13:59:38 +00001883// Same as NeonI except it is not predicated
1884class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1885 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1886 list<dag> pattern>
1887 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1888 let OutOperandList = oops;
1889 let InOperandList = iops;
1890 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
1891 let Pattern = pattern;
1892 list<Predicate> Predicates = [HasNEON];
1893 let DecoderNamespace = "NEON";
1894
1895 let Inst{31-28} = 0b1111;
1896}
1897
Bob Wilson50820a22009-10-07 21:53:04 +00001898class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1899 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001900 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001901 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1902 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001903 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001904 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001905 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001906 let Inst{11-8} = op11_8;
1907 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001908
Chris Lattner63274cb2010-11-15 05:19:05 +00001909 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001910 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001911
Owen Andersonad402342010-11-02 00:05:05 +00001912 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001913 bits<6> Rn;
1914 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001915
Owen Andersonad402342010-11-02 00:05:05 +00001916 let Inst{22} = Vd{4};
1917 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001918 let Inst{19-16} = Rn{3-0};
1919 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001920}
1921
Owen Anderson9f20daf2010-11-02 20:47:39 +00001922class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1923 dag oops, dag iops, InstrItinClass itin,
1924 string opc, string dt, string asm, string cstr, list<dag> pattern>
1925 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1926 dt, asm, cstr, pattern> {
1927 bits<3> lane;
1928}
1929
Bob Wilson9392b0e2010-08-25 23:27:42 +00001930class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001931 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001932 itin> {
1933 let OutOperandList = oops;
1934 let InOperandList = !con(iops, (ins pred:$p));
1935 list<Predicate> Predicates = [HasNEON];
1936}
1937
Jim Grosbach233b3a22010-10-06 20:36:55 +00001938class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1939 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001940 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001941 itin> {
1942 let OutOperandList = oops;
1943 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001944 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001945 list<Predicate> Predicates = [HasNEON];
1946}
1947
Johnny Chenac5024b2010-03-23 16:43:47 +00001948class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001949 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001950 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1951 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001952 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001953 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001954 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001955}
1956
Johnny Chen020023a2010-03-23 20:40:44 +00001957class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001958 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001959 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001960 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001961 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001962 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001963 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001964}
1965
1966// NEON "one register and a modified immediate" format.
1967class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1968 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001969 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001970 string opc, string dt, string asm, string cstr,
1971 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001972 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001973 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001974 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001975 let Inst{11-8} = op11_8;
1976 let Inst{7} = op7;
1977 let Inst{6} = op6;
1978 let Inst{5} = op5;
1979 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001980
Owen Anderson284cb362010-10-26 17:40:54 +00001981 // Instruction operands.
1982 bits<5> Vd;
1983 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001984
Owen Anderson284cb362010-10-26 17:40:54 +00001985 let Inst{15-12} = Vd{3-0};
1986 let Inst{22} = Vd{4};
1987 let Inst{24} = SIMM{7};
1988 let Inst{18-16} = SIMM{6-4};
1989 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00001990 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00001991}
1992
1993// NEON 2 vector register format.
1994class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1995 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001996 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001997 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00001998 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001999 let Inst{24-23} = op24_23;
2000 let Inst{21-20} = op21_20;
2001 let Inst{19-18} = op19_18;
2002 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002003 let Inst{11-7} = op11_7;
2004 let Inst{6} = op6;
2005 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002006
Owen Anderson24774462010-10-25 18:43:52 +00002007 // Instruction operands.
2008 bits<5> Vd;
2009 bits<5> Vm;
2010
2011 let Inst{15-12} = Vd{3-0};
2012 let Inst{22} = Vd{4};
2013 let Inst{3-0} = Vm{3-0};
2014 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002015}
2016
Joey Gouly943dd592013-07-18 11:53:22 +00002017// Same as N2V but not predicated.
2018class N2Vnp<bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2019 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2020 string Dt, ValueType ResTy, ValueType OpTy, list<dag> pattern>
2021 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2022 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2023 bits<5> Vd;
2024 bits<5> Vm;
2025
2026 // Encode instruction operands
2027 let Inst{22} = Vd{4};
2028 let Inst{15-12} = Vd{3-0};
2029 let Inst{5} = Vm{4};
2030 let Inst{3-0} = Vm{3-0};
2031
2032 // Encode constant bits
2033 let Inst{27-23} = 0b00111;
2034 let Inst{21-20} = 0b11;
2035 let Inst{19-18} = 0b10;
2036 let Inst{17-16} = op17_16;
2037 let Inst{11} = 0;
2038 let Inst{10-8} = op10_8;
2039 let Inst{7} = op7;
2040 let Inst{6} = op6;
2041 let Inst{4} = 0;
2042
2043 let DecoderNamespace = "NEON";
2044}
2045
Evan Cheng738a97a2009-11-23 21:57:23 +00002046// Same as N2V except it doesn't have a datatype suffix.
2047class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002048 bits<5> op11_7, bit op6, bit op4,
2049 dag oops, dag iops, InstrItinClass itin,
2050 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002051 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002052 let Inst{24-23} = op24_23;
2053 let Inst{21-20} = op21_20;
2054 let Inst{19-18} = op19_18;
2055 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002056 let Inst{11-7} = op11_7;
2057 let Inst{6} = op6;
2058 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002059
Owen Anderson24774462010-10-25 18:43:52 +00002060 // Instruction operands.
2061 bits<5> Vd;
2062 bits<5> Vm;
2063
2064 let Inst{15-12} = Vd{3-0};
2065 let Inst{22} = Vd{4};
2066 let Inst{3-0} = Vm{3-0};
2067 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002068}
2069
2070// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00002071class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00002072 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002073 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00002074 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002075 let Inst{24} = op24;
2076 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002077 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002078 let Inst{7} = op7;
2079 let Inst{6} = op6;
2080 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002081
Owen Anderson3665fee2010-10-26 20:56:57 +00002082 // Instruction operands.
2083 bits<5> Vd;
2084 bits<5> Vm;
2085 bits<6> SIMM;
2086
2087 let Inst{15-12} = Vd{3-0};
2088 let Inst{22} = Vd{4};
2089 let Inst{3-0} = Vm{3-0};
2090 let Inst{5} = Vm{4};
2091 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002092}
2093
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002094// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00002095
Jim Grosbacheca54e42011-05-19 17:34:53 +00002096class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2097 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2098 string opc, string dt, string asm, string cstr,
2099 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00002100 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002101 let Inst{24} = op24;
2102 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00002103 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002104 let Inst{11-8} = op11_8;
2105 let Inst{6} = op6;
2106 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00002107}
2108
2109class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2110 dag oops, dag iops, Format f, InstrItinClass itin,
2111 string opc, string dt, string asm, string cstr, list<dag> pattern>
2112 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2113 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Owen Anderson9e44cf22010-10-21 20:21:49 +00002114 // Instruction operands.
2115 bits<5> Vd;
2116 bits<5> Vn;
2117 bits<5> Vm;
2118
2119 let Inst{15-12} = Vd{3-0};
2120 let Inst{22} = Vd{4};
2121 let Inst{19-16} = Vn{3-0};
2122 let Inst{7} = Vn{4};
2123 let Inst{3-0} = Vm{3-0};
2124 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002125}
2126
Joey Goulydf686002013-07-17 13:59:38 +00002127class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2128 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2129 string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy,
2130 SDPatternOperator IntOp, bit Commutable, list<dag> pattern>
2131 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2132 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2133 bits<5> Vd;
2134 bits<5> Vn;
2135 bits<5> Vm;
2136
2137 // Encode instruction operands
2138 let Inst{22} = Vd{4};
2139 let Inst{15-12} = Vd{3-0};
2140 let Inst{19-16} = Vn{3-0};
2141 let Inst{7} = Vn{4};
2142 let Inst{5} = Vm{4};
2143 let Inst{3-0} = Vm{3-0};
2144
2145 // Encode constant bits
2146 let Inst{27-23} = op27_23;
2147 let Inst{21-20} = op21_20;
2148 let Inst{11-8} = op11_8;
2149 let Inst{6} = op6;
2150 let Inst{4} = op4;
2151}
2152
Jim Grosbacheca54e42011-05-19 17:34:53 +00002153class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2154 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2155 string opc, string dt, string asm, string cstr,
2156 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002157 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2158 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2159
2160 // Instruction operands.
2161 bits<5> Vd;
2162 bits<5> Vn;
2163 bits<5> Vm;
2164 bit lane;
2165
2166 let Inst{15-12} = Vd{3-0};
2167 let Inst{22} = Vd{4};
2168 let Inst{19-16} = Vn{3-0};
2169 let Inst{7} = Vn{4};
2170 let Inst{3-0} = Vm{3-0};
2171 let Inst{5} = lane;
2172}
2173
Jim Grosbacheca54e42011-05-19 17:34:53 +00002174class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2175 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2176 string opc, string dt, string asm, string cstr,
2177 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002178 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2179 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2180
2181 // Instruction operands.
2182 bits<5> Vd;
2183 bits<5> Vn;
2184 bits<5> Vm;
2185 bits<2> lane;
2186
2187 let Inst{15-12} = Vd{3-0};
2188 let Inst{22} = Vd{4};
2189 let Inst{19-16} = Vn{3-0};
2190 let Inst{7} = Vn{4};
2191 let Inst{2-0} = Vm{2-0};
2192 let Inst{5} = lane{1};
2193 let Inst{3} = lane{0};
2194}
2195
Johnny Chen8a687232010-03-23 21:35:03 +00002196// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00002197class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2198 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002199 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002200 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002201 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002202 let Inst{24} = op24;
2203 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002204 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002205 let Inst{11-8} = op11_8;
2206 let Inst{6} = op6;
2207 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002208
Owen Andersondff239c2010-10-25 18:28:30 +00002209 // Instruction operands.
2210 bits<5> Vd;
2211 bits<5> Vn;
2212 bits<5> Vm;
2213
2214 let Inst{15-12} = Vd{3-0};
2215 let Inst{22} = Vd{4};
2216 let Inst{19-16} = Vn{3-0};
2217 let Inst{7} = Vn{4};
2218 let Inst{3-0} = Vm{3-0};
2219 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002220}
2221
2222// NEON VMOVs between scalar and core registers.
2223class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002224 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002225 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002226 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002227 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002228 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002229 let Inst{11-8} = opcod2;
2230 let Inst{6-5} = opcod3;
2231 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00002232 // A8.6.303, A8.6.328, A8.6.329
2233 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00002234
2235 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002236 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002237 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002238 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00002239 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00002240
Chris Lattner63274cb2010-11-15 05:19:05 +00002241 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002242 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00002243
Owen Andersoned9652f2010-10-27 21:28:09 +00002244 bits<5> V;
2245 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00002246 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00002247 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00002248
Owen Anderson40d24a42010-10-27 19:25:54 +00002249 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00002250 let Inst{7} = V{4};
2251 let Inst{19-16} = V{3-0};
2252 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002253}
2254class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002255 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002256 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002257 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002258 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002259class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002260 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002261 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002262 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002263 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002264class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002265 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002266 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002267 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002268 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00002269
Johnny Chen45ab3f32010-03-25 17:01:27 +00002270// Vector Duplicate Lane (from scalar to all elements)
2271class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2272 InstrItinClass itin, string opc, string dt, string asm,
2273 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00002274 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00002275 let Inst{24-23} = 0b11;
2276 let Inst{21-20} = 0b11;
2277 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002278 let Inst{11-7} = 0b11000;
2279 let Inst{6} = op6;
2280 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00002281
Owen Anderson40d24a42010-10-27 19:25:54 +00002282 bits<5> Vd;
2283 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002284
Owen Anderson40d24a42010-10-27 19:25:54 +00002285 let Inst{22} = Vd{4};
2286 let Inst{15-12} = Vd{3-0};
2287 let Inst{5} = Vm{4};
2288 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00002289}
2290
David Goodwin3b9c52c2009-08-04 17:53:06 +00002291// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2292// for single-precision FP.
2293class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2294 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2295}
Jim Grosbach7996b152011-11-14 22:28:39 +00002296
2297// VFP/NEON Instruction aliases for type suffices.
2298class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
Jim Grosbachfdf9e152011-12-05 20:29:59 +00002299 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002300
Jim Grosbach3d6c0e02011-11-14 23:11:19 +00002301multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002302 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2303 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2304 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2305 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002306}
2307
Jim Grosbach681db342012-01-24 17:23:29 +00002308multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2309 let Predicates = [HasNEON] in {
2310 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2311 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2312 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2313 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2314}
2315}
2316
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002317// The same alias classes using AsmPseudo instead, for the more complex
2318// stuff in NEON that InstAlias can't quite handle.
2319// Note that we can't use anonymous defm references here like we can
2320// above, as we care about the ultimate instruction enum names generated, unlike
2321// for instalias defs.
2322class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002323 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbach585ce302011-12-07 01:17:58 +00002324
2325// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2326def : TokenAlias<".s8", ".i8">;
2327def : TokenAlias<".u8", ".i8">;
2328def : TokenAlias<".s16", ".i16">;
2329def : TokenAlias<".u16", ".i16">;
2330def : TokenAlias<".s32", ".i32">;
2331def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002332def : TokenAlias<".s64", ".i64">;
2333def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002334
2335def : TokenAlias<".i8", ".8">;
2336def : TokenAlias<".i16", ".16">;
2337def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002338def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002339
2340def : TokenAlias<".p8", ".8">;
2341def : TokenAlias<".p16", ".16">;
2342
2343def : TokenAlias<".f32", ".32">;
2344def : TokenAlias<".f64", ".64">;
2345def : TokenAlias<".f", ".f32">;
2346def : TokenAlias<".d", ".f64">;