blob: 8e3f2c7e2bfcc061b25cea3fdd8c17cd4bca5a00 [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]>;
Tim Northover5620faf2013-10-24 15:49:39 +0000250class VFP2DPInstAlias<string Asm, dag Result, bit Emit = 0b1>
251 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2,HasDPVFP]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000252class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
253 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
Jim Grosbach0a978ef2011-12-05 19:55:46 +0000254class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
255 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000256
Jim Grosbach9227f392011-12-13 20:08:32 +0000257
258class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
259 Requires<[HasVFP2]>;
260class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
261 Requires<[HasNEON]>;
262
Jim Grosbach6caa5572011-08-22 18:04:24 +0000263//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000264// ARM Instruction templates.
265//
266
Jim Grosbach6caa5572011-08-22 18:04:24 +0000267
Owen Anderson651b2302011-07-13 23:22:26 +0000268class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000269 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000270 : Instruction {
271 let Namespace = "ARM";
272
Evan Cheng2d37f192008-08-28 23:39:26 +0000273 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000274 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000275 IndexMode IM = im;
276 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000277 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000278 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000279 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000280 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000281 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000282 // The instruction is a 16-bit flag setting Thumb instruction. Used
283 // by the parser to determine whether to require the 'S' suffix on the
284 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
285 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000286
Chris Lattner7ff33462010-10-31 19:22:57 +0000287 // If this is a pseudo instruction, mark it isCodeGenOnly.
288 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000289
Jim Grosbach30694dc2011-08-15 16:52:24 +0000290 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000291 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000292 let TSFlags{6-5} = IndexModeBits;
293 let TSFlags{12-7} = Form;
294 let TSFlags{13} = isUnaryDataProc;
295 let TSFlags{14} = canXformTo16Bit;
296 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000297 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000298
Evan Cheng2d37f192008-08-28 23:39:26 +0000299 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000300 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000301}
302
Johnny Chenc28e6292009-12-15 17:24:14 +0000303class Encoding {
304 field bits<32> Inst;
James Molloyd9ba4fd2012-02-09 10:56:31 +0000305 // Mask of bits that cause an encoding to be UNPREDICTABLE.
306 // If a bit is set, then if the corresponding bit in the
307 // target encoding differs from its value in the "Inst" field,
308 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
309 field bits<32> Unpredictable = 0;
310 // SoftFail is the generic name for this field, but we alias it so
311 // as to make it more obvious what it means in ARM-land.
312 field bits<32> SoftFail = Unpredictable;
Johnny Chenc28e6292009-12-15 17:24:14 +0000313}
314
Owen Anderson651b2302011-07-13 23:22:26 +0000315class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000316 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000317 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
318 let DecoderNamespace = "ARM";
319}
Johnny Chenc28e6292009-12-15 17:24:14 +0000320
321// This Encoding-less class is used by Thumb1 to specify the encoding bits later
322// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000323class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000324 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000325 : InstTemplate<am, sz, im, f, d, cstr, itin> {
326 let DecoderNamespace = "Thumb";
327}
Johnny Chenc28e6292009-12-15 17:24:14 +0000328
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000329// Pseudo-instructions for alternate assembly syntax (never used by codegen).
330// These are aliases that require C++ handling to convert to the target
331// instruction, while InstAliases can be handled directly by tblgen.
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000332class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000333 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
334 "", NoItinerary> {
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000335 let OutOperandList = oops;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000336 let InOperandList = iops;
337 let Pattern = [];
338 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000339 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000340 let isPseudo = 1;
341}
342
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000343class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
344 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
345class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
346 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
347class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
348 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
349class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
350 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
351class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
352 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000353
354// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000355class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000356 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000357 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000358 let OutOperandList = oops;
359 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000360 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000361 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000362 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000363}
364
Jim Grosbachcfb66202010-11-18 01:15:56 +0000365// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000366class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000367 list<dag> pattern>
368 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000369 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000370 list<Predicate> Predicates = [IsARM];
371}
372
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000373// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000374class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000375 list<dag> pattern>
376 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000377 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000378 list<Predicate> Predicates = [IsThumb];
379}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000380
Jim Grosbachd42257c2010-12-15 18:48:45 +0000381// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000382class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000383 list<dag> pattern>
384 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000385 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000386 list<Predicate> Predicates = [IsThumb2];
387}
Jim Grosbach95dee402011-07-08 17:40:42 +0000388
Owen Anderson651b2302011-07-13 23:22:26 +0000389class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000390 InstrItinClass itin, list<dag> pattern,
391 dag Result>
392 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
393 PseudoInstExpansion<Result>;
394
Owen Anderson651b2302011-07-13 23:22:26 +0000395class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000396 InstrItinClass itin, list<dag> pattern,
397 dag Result>
398 : tPseudoInst<oops, iops, sz, itin, pattern>,
399 PseudoInstExpansion<Result>;
400
Owen Anderson651b2302011-07-13 23:22:26 +0000401class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000402 InstrItinClass itin, list<dag> pattern,
403 dag Result>
404 : t2PseudoInst<oops, iops, sz, itin, pattern>,
405 PseudoInstExpansion<Result>;
406
Evan Cheng2d37f192008-08-28 23:39:26 +0000407// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000408class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000409 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000410 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000411 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000412 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000413 bits<4> p;
414 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000415 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000416 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000417 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000418 let Pattern = pattern;
419 list<Predicate> Predicates = [IsARM];
420}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000421
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000422// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000423class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000424 IndexMode im, Format f, InstrItinClass itin,
425 string opc, string asm, string cstr,
426 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000427 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
428 let OutOperandList = oops;
429 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000430 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000431 let Pattern = pattern;
432 let isPredicable = 0;
433 list<Predicate> Predicates = [IsARM];
434}
Evan Cheng2d37f192008-08-28 23:39:26 +0000435
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000436// Same as I except it can optionally modify CPSR. Note it's modeled as an input
437// operand since by default it's a zero register. It will become an implicit def
438// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000439class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000440 IndexMode im, Format f, InstrItinClass itin,
441 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000442 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000443 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000444 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000445 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000446 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000447 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000448
Evan Cheng2d37f192008-08-28 23:39:26 +0000449 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000450 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000451 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000452 let Pattern = pattern;
453 list<Predicate> Predicates = [IsARM];
454}
455
Evan Chenga2827232008-09-01 07:19:00 +0000456// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000457class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000458 IndexMode im, Format f, InstrItinClass itin,
459 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000460 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000461 let OutOperandList = oops;
462 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000463 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000464 let Pattern = pattern;
465 list<Predicate> Predicates = [IsARM];
466}
467
David Goodwinb062c232009-08-06 16:52:47 +0000468class AI<dag oops, dag iops, Format f, InstrItinClass itin,
469 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000470 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000471 opc, asm, "", pattern>;
472class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
473 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000474 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000475 opc, asm, "", pattern>;
476class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000477 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000478 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000479 asm, "", pattern>;
David Peixottob76f55f2014-01-27 21:39:04 +0000480class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
481 string asm, list<dag> pattern>
482 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
483 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000484class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000485 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000486 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000487 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000488
489// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000490class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
491 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000492 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000493 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000494 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000495}
David Goodwinb062c232009-08-06 16:52:47 +0000496class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
497 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000498 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000499 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000500 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000501}
Evan Chengfa558782008-09-01 08:25:56 +0000502
503// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000504class JTI<dag oops, dag iops, InstrItinClass itin,
505 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000506 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000507 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000508
Joey Goulye6d165c2013-08-27 17:38:16 +0000509class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000510 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000511 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000512 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000513 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000514 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000515 let Inst{27-23} = 0b00011;
516 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000517 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000518 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000519 let Inst{15-12} = Rt;
Joey Goulye6d165c2013-08-27 17:38:16 +0000520 let Inst{11-10} = 0b11;
521 let Inst{9-8} = opcod2;
522 let Inst{7-0} = 0b10011111;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000523}
Joey Goulye6d165c2013-08-27 17:38:16 +0000524class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000525 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000526 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000527 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000528 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000529 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000530 let Inst{27-23} = 0b00011;
531 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000532 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000533 let Inst{19-16} = addr;
Joey Goulye6d165c2013-08-27 17:38:16 +0000534 let Inst{11-10} = 0b11;
535 let Inst{9-8} = opcod2;
536 let Inst{7-4} = 0b1001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000537 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000538}
Joey Goulye6d165c2013-08-27 17:38:16 +0000539// Atomic load/store instructions
540class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
541 string opc, string asm, list<dag> pattern>
542 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
543
544class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
545 string opc, string asm, list<dag> pattern>
546 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
547 bits<4> Rd;
548 let Inst{15-12} = Rd;
549}
550
551// Exclusive load/store instructions
552
553class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
554 string opc, string asm, list<dag> pattern>
555 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
556 Requires<[IsARM, HasV8]>;
557
558class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
559 string opc, string asm, list<dag> pattern>
560 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
561 Requires<[IsARM, HasV8]> {
562 bits<4> Rd;
563 let Inst{15-12} = Rd;
564}
565
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000566class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000567 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000568 bits<4> Rt;
569 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000570 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000571 let Inst{27-23} = 0b00010;
572 let Inst{22} = b;
573 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000574 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000575 let Inst{15-12} = Rt;
576 let Inst{11-4} = 0b00001001;
577 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000578
Silviu Barangaca45af92012-04-18 14:18:57 +0000579 let Unpredictable{11-8} = 0b1111;
Owen Andersondde461c2011-10-28 18:02:13 +0000580 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000581}
Joey Goulye6d165c2013-08-27 17:38:16 +0000582// Acquire/Release load/store instructions
583class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
584 string opc, string asm, list<dag> pattern>
585 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
586 Requires<[IsARM, HasV8]>;
587
588class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
589 string opc, string asm, list<dag> pattern>
590 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
591 Requires<[IsARM, HasV8]> {
592 let Inst{15-12} = 0b1111;
593}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000594
Evan Cheng624844b2008-09-01 01:51:14 +0000595// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000596class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
597 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000598 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000599 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000600 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000601 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000602}
David Goodwinb062c232009-08-06 16:52:47 +0000603class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
604 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000605 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000606 opc, asm, "", pattern> {
607 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000608 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000609}
610class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000611 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000612 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000613 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000614 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000615 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000616}
Evan Cheng624844b2008-09-01 01:51:14 +0000617
Evan Chengcccca872008-09-01 01:27:33 +0000618// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000619
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000620// LDR/LDRB/STR/STRB/...
621class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000622 Format f, InstrItinClass itin, string opc, string asm,
623 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000624 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000625 "", pattern> {
626 let Inst{27-25} = op;
627 let Inst{24} = 1; // 24 == P
628 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000629 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000630 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000631 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000632}
Jim Grosbach2f790742010-11-13 00:35:48 +0000633// Indexed load/stores
634class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000635 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000636 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000637 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000638 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000639 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000640 let Inst{27-26} = 0b01;
641 let Inst{24} = isPre; // P bit
642 let Inst{22} = isByte; // B bit
643 let Inst{21} = isPre; // W bit
644 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000645 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000646}
Owen Anderson2aedba62011-07-26 20:54:26 +0000647class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000648 IndexMode im, Format f, InstrItinClass itin, string opc,
649 string asm, string cstr, list<dag> pattern>
650 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
651 pattern> {
652 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000653 // {12} isAdd
654 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000655 bits<14> offset;
656 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000657 let Inst{25} = 1;
658 let Inst{23} = offset{12};
659 let Inst{19-16} = Rn;
660 let Inst{11-5} = offset{11-5};
661 let Inst{4} = 0;
662 let Inst{3-0} = offset{3-0};
663}
664
665class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
666 IndexMode im, Format f, InstrItinClass itin, string opc,
667 string asm, string cstr, list<dag> pattern>
668 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
669 pattern> {
670 // AM2 store w/ two operands: (GPR, am2offset)
671 // {12} isAdd
672 // {11-0} imm12/Rm
673 bits<14> offset;
674 bits<4> Rn;
675 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000676 let Inst{23} = offset{12};
677 let Inst{19-16} = Rn;
678 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000679}
Owen Anderson2aedba62011-07-26 20:54:26 +0000680
681
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000682// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
683// but for now use this class for STRT and STRBT.
684class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
685 IndexMode im, Format f, InstrItinClass itin, string opc,
686 string asm, string cstr, list<dag> pattern>
687 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
688 pattern> {
689 // AM2 store w/ two operands: (GPR, am2offset)
690 // {17-14} Rn
691 // {13} 1 == Rm, 0 == imm12
692 // {12} isAdd
693 // {11-0} imm12/Rm
694 bits<18> addr;
695 let Inst{25} = addr{13};
696 let Inst{23} = addr{12};
697 let Inst{19-16} = addr{17-14};
698 let Inst{11-0} = addr{11-0};
699}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000700
Evan Cheng624844b2008-09-01 01:51:14 +0000701// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000702class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
703 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000704 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000705 opc, asm, "", pattern> {
706 bits<14> addr;
707 bits<4> Rt;
708 let Inst{27-25} = 0b000;
709 let Inst{24} = 1; // P bit
710 let Inst{23} = addr{8}; // U bit
711 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
712 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000713 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000714 let Inst{19-16} = addr{12-9}; // Rn
715 let Inst{15-12} = Rt; // Rt
716 let Inst{11-8} = addr{7-4}; // imm7_4/zero
717 let Inst{7-4} = op;
718 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000719
720 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000721}
Evan Cheng169eccc2008-09-01 07:00:14 +0000722
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000723class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000724 IndexMode im, Format f, InstrItinClass itin, string opc,
725 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000726 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000727 opc, asm, cstr, pattern> {
728 bits<4> Rt;
729 let Inst{27-25} = 0b000;
730 let Inst{24} = isPre; // P bit
731 let Inst{21} = isPre; // W bit
732 let Inst{20} = op20; // L bit
733 let Inst{15-12} = Rt; // Rt
734 let Inst{7-4} = op;
735}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000736
737// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
738// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000739class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000740 IndexMode im, Format f, InstrItinClass itin, string opc,
741 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000742 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000743 // {13} 1 == imm8, 0 == Rm
744 // {12-9} Rn
745 // {8} isAdd
746 // {7-4} imm7_4/zero
747 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000748 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000749 bits<4> Rt;
750 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000751 let Inst{24} = 0; // P bit
752 let Inst{21} = 1;
753 let Inst{20} = isLoad; // L bit
754 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000755 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000756 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000757}
758
Evan Cheng169eccc2008-09-01 07:00:14 +0000759// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000760class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000761 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000762 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000763 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000764 bits<14> addr;
765 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000766 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000767 let Inst{24} = 1; // P bit
768 let Inst{23} = addr{8}; // U bit
769 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
770 let Inst{21} = 0; // W bit
771 let Inst{20} = 0; // L bit
772 let Inst{19-16} = addr{12-9}; // Rn
773 let Inst{15-12} = Rt; // Rt
774 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000775 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000776 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000777 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000778}
Evan Cheng169eccc2008-09-01 07:00:14 +0000779
Evan Cheng624844b2008-09-01 01:51:14 +0000780// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000781class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
782 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000783 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000784 bits<4> p;
785 bits<16> regs;
786 bits<4> Rn;
787 let Inst{31-28} = p;
788 let Inst{27-25} = 0b100;
789 let Inst{22} = 0; // S bit
790 let Inst{19-16} = Rn;
791 let Inst{15-0} = regs;
792}
Evan Cheng2d37f192008-08-28 23:39:26 +0000793
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000794// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000795class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
796 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000797 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000798 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000799 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000800 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000801 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000802}
David Goodwinb062c232009-08-06 16:52:47 +0000803class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
804 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000805 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000806 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000807 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000808 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000809}
810
811// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000812class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
813 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000814 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000815 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000816 bits<4> Rd;
817 bits<4> Rn;
818 bits<4> Rm;
819 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000820 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000821 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000822 let Inst{19-16} = Rd;
823 let Inst{11-8} = Rm;
824 let Inst{3-0} = Rn;
825}
826// MSW multiple w/ Ra operand
827class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
828 InstrItinClass itin, string opc, string asm, list<dag> pattern>
829 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
830 bits<4> Ra;
831 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000832}
Evan Cheng2d37f192008-08-28 23:39:26 +0000833
Evan Cheng36ae4032008-11-06 03:35:07 +0000834// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000835class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000836 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000837 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000838 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000839 bits<4> Rn;
840 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000841 let Inst{4} = 0;
842 let Inst{7} = 1;
843 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000844 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000845 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000846 let Inst{11-8} = Rm;
847 let Inst{3-0} = Rn;
848}
849class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
850 InstrItinClass itin, string opc, string asm, list<dag> pattern>
851 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
852 bits<4> Rd;
853 let Inst{19-16} = Rd;
854}
855
856// AMulxyI with Ra operand
857class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
858 InstrItinClass itin, string opc, string asm, list<dag> pattern>
859 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
860 bits<4> Ra;
861 let Inst{15-12} = Ra;
862}
863// SMLAL*
864class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
865 InstrItinClass itin, string opc, string asm, list<dag> pattern>
866 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
867 bits<4> RdLo;
868 bits<4> RdHi;
869 let Inst{19-16} = RdHi;
870 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000871}
872
Evan Cheng49d66522008-11-06 22:15:19 +0000873// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000874class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
875 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000876 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000877 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000878 // All AExtI instructions have Rd and Rm register operands.
879 bits<4> Rd;
880 bits<4> Rm;
881 let Inst{15-12} = Rd;
882 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000883 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000884 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000885 let Inst{27-20} = opcod;
Silviu Barangaddc67a72012-05-11 09:28:27 +0000886
887 let Unpredictable{9-8} = 0b11;
Evan Cheng49d66522008-11-06 22:15:19 +0000888}
889
Evan Cheng98dc53e2008-11-07 01:41:35 +0000890// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000891class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
892 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000893 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000894 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000895 bits<4> Rd;
896 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000897 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000898 let Inst{19-16} = 0b1111;
899 let Inst{15-12} = Rd;
900 let Inst{11-8} = 0b1111;
901 let Inst{7-4} = opc7_4;
902 let Inst{3-0} = Rm;
903}
904
Bob Wilsone8a549c2012-09-29 21:43:49 +0000905// Division instructions.
906class ADivA1I<bits<3> opcod, dag oops, dag iops,
907 InstrItinClass itin, string opc, string asm, list<dag> pattern>
908 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
909 opc, asm, "", pattern> {
910 bits<4> Rd;
911 bits<4> Rn;
912 bits<4> Rm;
913 let Inst{27-23} = 0b01110;
914 let Inst{22-20} = opcod;
915 let Inst{19-16} = Rd;
916 let Inst{15-12} = 0b1111;
917 let Inst{11-8} = Rm;
918 let Inst{7-4} = 0b0001;
919 let Inst{3-0} = Rn;
920}
921
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000922// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000923def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000924 let Name = "PKHLSLImm";
925 let ParserMethod = "parsePKHLSLImm";
926}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000927def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
928 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000929 let ParserMatchClass = PKHLSLAsmOperand;
930}
931def PKHASRAsmOperand : AsmOperandClass {
932 let Name = "PKHASRImm";
933 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000934}
935def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
936 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000937 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000938}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000939
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000940class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
941 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000942 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000943 opc, asm, "", pattern> {
944 bits<4> Rd;
945 bits<4> Rn;
946 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000947 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000948 let Inst{27-20} = opcod;
949 let Inst{19-16} = Rn;
950 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000951 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000952 let Inst{6} = tb;
953 let Inst{5-4} = 0b01;
954 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000955}
956
Evan Cheng2d37f192008-08-28 23:39:26 +0000957//===----------------------------------------------------------------------===//
958
959// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
960class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
961 list<Predicate> Predicates = [IsARM];
962}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000963class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
964 list<Predicate> Predicates = [IsARM, HasV5T];
965}
Evan Cheng2d37f192008-08-28 23:39:26 +0000966class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
967 list<Predicate> Predicates = [IsARM, HasV5TE];
968}
Bob Wilsone8a549c2012-09-29 21:43:49 +0000969// ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
970class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
971 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
972}
Evan Cheng2d37f192008-08-28 23:39:26 +0000973class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
974 list<Predicate> Predicates = [IsARM, HasV6];
975}
Evan Chengee98fa92008-08-29 06:41:12 +0000976
977//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000978// Thumb Instruction Format Definitions.
979//
980
Owen Anderson651b2302011-07-13 23:22:26 +0000981class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000982 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000983 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000984 let OutOperandList = oops;
985 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000986 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +0000987 let Pattern = pattern;
988 list<Predicate> Predicates = [IsThumb];
989}
990
Bill Wendlingcbb08ca2010-12-01 02:42:55 +0000991// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +0000992class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000993 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +0000994
Evan Cheng7cc6aca2009-08-04 23:47:55 +0000995// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +0000996class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
997 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000998 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +0000999 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001000
Johnny Chenc28e6292009-12-15 17:24:14 +00001001// tBL, tBX 32-bit instructions
1002class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001003 dag oops, dag iops, InstrItinClass itin, string asm,
1004 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001005 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001006 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +00001007 let Inst{31-27} = opcod1;
1008 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001009 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +00001010}
Evan Chengee98fa92008-08-29 06:41:12 +00001011
1012// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001013class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1014 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001015 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001016
Evan Chengbec1dba892009-06-23 19:38:13 +00001017// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +00001018class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001019 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001020 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001021 let OutOperandList = oops;
1022 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001023 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +00001024 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001025 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +00001026}
1027
David Goodwinb062c232009-08-06 16:52:47 +00001028class T1I<dag oops, dag iops, InstrItinClass itin,
1029 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001030 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001031class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1032 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001033 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001034
1035// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001036class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001037 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001038 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001039 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001040
1041// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +00001042class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001043 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001044 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001045 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001046 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1047 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001048 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001049 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +00001050 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001051 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +00001052 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +00001053}
1054
David Goodwinb062c232009-08-06 16:52:47 +00001055class T1sI<dag oops, dag iops, InstrItinClass itin,
1056 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001057 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001058
1059// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001060class T1sIt<dag oops, dag iops, InstrItinClass itin,
1061 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001062 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +00001063 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001064
1065// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +00001066class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001067 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001068 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001069 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001070 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001071 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001072 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001073 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001074 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +00001075}
1076
David Goodwinb062c232009-08-06 16:52:47 +00001077class T1pI<dag oops, dag iops, InstrItinClass itin,
1078 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001079 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001080
1081// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001082class T1pIt<dag oops, dag iops, InstrItinClass itin,
1083 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001084 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +00001085 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001086
Bob Wilson3968c6a2010-03-23 17:23:59 +00001087class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001088 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001089 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001090
Johnny Chen466231a2009-12-16 02:32:54 +00001091class Encoding16 : Encoding {
1092 let Inst{31-16} = 0x0000;
1093}
1094
Johnny Chenc28e6292009-12-15 17:24:14 +00001095// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +00001096class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001097 let Inst{15-10} = opcode;
1098}
1099
1100// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001101class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001102 let Inst{15-14} = 0b00;
1103 let Inst{13-9} = opcode;
1104}
1105
1106// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001107class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001108 let Inst{15-10} = 0b010000;
1109 let Inst{9-6} = opcode;
1110}
1111
1112// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001113class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001114 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001115 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001116}
1117
1118// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001119class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001120 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001121 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001122}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001123class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001124
Eric Christopher9b67db82011-05-27 03:50:53 +00001125class T1BranchCond<bits<4> opcode> : Encoding16 {
1126 let Inst{15-12} = opcode;
1127}
1128
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001129// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001130// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001131//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001132// 0b0110 => Immediate, 4 bytes
1133// 0b1000 => Immediate, 2 bytes
1134// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001135class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1136 InstrItinClass itin, string opc, string asm,
1137 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001138 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001139 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001140 bits<3> Rt;
1141 bits<8> addr;
1142 let Inst{8-6} = addr{5-3}; // Rm
1143 let Inst{5-3} = addr{2-0}; // Rn
1144 let Inst{2-0} = Rt;
1145}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001146class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1147 InstrItinClass itin, string opc, string asm,
1148 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001149 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001150 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001151 bits<3> Rt;
1152 bits<8> addr;
1153 let Inst{10-6} = addr{7-3}; // imm5
1154 let Inst{5-3} = addr{2-0}; // Rn
1155 let Inst{2-0} = Rt;
1156}
1157
Johnny Chenc28e6292009-12-15 17:24:14 +00001158// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001159class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001160 let Inst{15-12} = 0b1011;
1161 let Inst{11-5} = opcode;
1162}
1163
Evan Chengd76f0be2009-06-25 02:08:06 +00001164// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001165class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001166 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001167 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001168 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001169 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001170 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001171 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001172 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001173 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001174 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001175}
1176
Bill Wendlingb70dc872010-08-31 07:50:46 +00001177// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1178// input operand since by default it's a zero register. It will become an
1179// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001180//
Evan Chengd76f0be2009-06-25 02:08:06 +00001181// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1182// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001183class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001184 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001185 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001186 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001187 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1188 let Inst{20} = s;
1189
Evan Chengd76f0be2009-06-25 02:08:06 +00001190 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001191 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001192 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001193 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001194 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001195 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001196}
1197
1198// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001199class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001200 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001201 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001202 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001203 let OutOperandList = oops;
1204 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001205 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001206 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001207 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001208 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001209}
1210
Owen Anderson651b2302011-07-13 23:22:26 +00001211class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001212 InstrItinClass itin,
1213 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001214 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1215 let OutOperandList = oops;
1216 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001217 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001218 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001219 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001220 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001221}
1222
David Goodwinb062c232009-08-06 16:52:47 +00001223class T2I<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, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001226class T2Ii12<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_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001229class T2Ii8<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_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001232class T2Iso<dag oops, dag iops, InstrItinClass itin,
1233 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001234 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001235class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1236 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001237 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001238class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001239 string opc, string asm, string cstr, list<dag> pattern>
1240 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001241 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001242 bits<4> Rt;
1243 bits<4> Rt2;
1244 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001245 let Inst{31-25} = 0b1110100;
1246 let Inst{24} = P;
1247 let Inst{23} = addr{8};
1248 let Inst{22} = 1;
1249 let Inst{21} = W;
1250 let Inst{20} = isLoad;
1251 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001252 let Inst{15-12} = Rt{3-0};
1253 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001254 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001255}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001256class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1257 InstrItinClass itin, string opc, string asm, string cstr,
1258 list<dag> pattern>
1259 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001260 pattern> {
1261 bits<4> Rt;
1262 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001263 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001264 bits<9> imm;
1265 let Inst{31-25} = 0b1110100;
1266 let Inst{24} = P;
1267 let Inst{23} = imm{8};
1268 let Inst{22} = 1;
1269 let Inst{21} = W;
1270 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001271 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001272 let Inst{15-12} = Rt{3-0};
1273 let Inst{11-8} = Rt2{3-0};
1274 let Inst{7-0} = imm{7-0};
1275}
1276
David Goodwinb062c232009-08-06 16:52:47 +00001277class T2sI<dag oops, dag iops, InstrItinClass itin,
1278 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001279 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001280
David Goodwinb062c232009-08-06 16:52:47 +00001281class T2XI<dag oops, dag iops, InstrItinClass itin,
1282 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001283 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001284class T2JTI<dag oops, dag iops, InstrItinClass itin,
1285 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001286 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001287
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001288// Move to/from coprocessor instructions
Tim Northover2c45a382013-06-26 16:52:40 +00001289class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1290 list<dag> pattern>
1291 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001292 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001293}
1294
Bob Wilson947f04b2010-03-13 01:08:20 +00001295// Two-address instructions
1296class T2XIt<dag oops, dag iops, InstrItinClass itin,
1297 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001298 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001299
Jim Grosbachc086f682011-09-08 00:39:19 +00001300// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1301class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001302 dag oops, dag iops,
1303 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001304 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001305 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001306 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001307 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001308 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001309 let Pattern = pattern;
1310 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001311 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001312
1313 bits<4> Rt;
1314 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001315 let Inst{31-27} = 0b11111;
1316 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001317 let Inst{24} = signed;
1318 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001319 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001320 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001321 let Inst{19-16} = addr{12-9};
1322 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001323 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001324 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001325 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001326 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001327 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001328 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001329
1330 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001331}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001332
Jim Grosbachc086f682011-09-08 00:39:19 +00001333// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1334class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1335 dag oops, dag iops,
1336 AddrMode am, IndexMode im, InstrItinClass itin,
1337 string opc, string asm, string cstr, list<dag> pattern>
1338 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1339 let OutOperandList = oops;
1340 let InOperandList = !con(iops, (ins pred:$p));
1341 let AsmString = !strconcat(opc, "${p}", asm);
1342 let Pattern = pattern;
1343 list<Predicate> Predicates = [IsThumb2];
1344 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001345
Owen Andersone22c7322010-11-30 00:14:31 +00001346 bits<4> Rt;
1347 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001348 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001349 let Inst{31-27} = 0b11111;
1350 let Inst{26-25} = 0b00;
1351 let Inst{24} = signed;
1352 let Inst{23} = 0;
1353 let Inst{22-21} = opcod;
1354 let Inst{20} = load;
1355 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001356 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001357 let Inst{11} = 1;
1358 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1359 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001360 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001361 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001362 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001363
1364 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001365}
1366
David Goodwine5b969f2009-07-27 19:59:26 +00001367// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1368class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001369 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001370}
1371
1372// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1373class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001374 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001375}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001376
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001377// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1378class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1379 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1380}
1381
Evan Chengeab9ca72009-06-27 02:26:13 +00001382// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1383class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001384 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001385}
1386
Evan Chengee98fa92008-08-29 06:41:12 +00001387//===----------------------------------------------------------------------===//
1388
Evan Chengac2af2f2008-11-11 02:11:05 +00001389//===----------------------------------------------------------------------===//
1390// ARM VFP Instruction templates.
1391//
1392
David Goodwin81cdd212009-07-10 17:03:29 +00001393// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001394class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001395 IndexMode im, Format f, InstrItinClass itin,
1396 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001397 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001398 bits<4> p;
1399 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001400 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001401 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001402 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001403 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001404 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001405 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001406 list<Predicate> Predicates = [HasVFP2];
1407}
1408
1409// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001410class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001411 IndexMode im, Format f, InstrItinClass itin,
1412 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001413 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001414 bits<4> p;
1415 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001416 let OutOperandList = oops;
1417 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001418 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001419 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001420 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001421 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001422 list<Predicate> Predicates = [HasVFP2];
1423}
1424
David Goodwinb062c232009-08-06 16:52:47 +00001425class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1426 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001427 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001428 opc, asm, "", pattern> {
1429 let PostEncoderMethod = "VFPThumb2PostEncoder";
1430}
David Goodwin81cdd212009-07-10 17:03:29 +00001431
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001432// ARM VFP addrmode5 loads and stores
1433class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001434 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001435 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001436 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001437 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001438 // Instruction operands.
1439 bits<5> Dd;
1440 bits<13> addr;
1441
1442 // Encode instruction operands.
1443 let Inst{23} = addr{8}; // U (add = (U == '1'))
1444 let Inst{22} = Dd{4};
1445 let Inst{19-16} = addr{12-9}; // Rn
1446 let Inst{15-12} = Dd{3-0};
1447 let Inst{7-0} = addr{7-0}; // imm8
1448
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001449 let Inst{27-24} = opcod1;
1450 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001451 let Inst{11-9} = 0b101;
1452 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001453
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001454 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001455 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001456}
1457
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001458class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001459 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001460 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001461 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001462 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001463 // Instruction operands.
1464 bits<5> Sd;
1465 bits<13> addr;
1466
1467 // Encode instruction operands.
1468 let Inst{23} = addr{8}; // U (add = (U == '1'))
1469 let Inst{22} = Sd{0};
1470 let Inst{19-16} = addr{12-9}; // Rn
1471 let Inst{15-12} = Sd{4-1};
1472 let Inst{7-0} = addr{7-0}; // imm8
1473
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001474 let Inst{27-24} = opcod1;
1475 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001476 let Inst{11-9} = 0b101;
1477 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001478
1479 // Loads & stores operate on both NEON and VFP pipelines.
1480 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001481}
1482
Bob Wilson6b853c32010-09-16 00:31:02 +00001483// VFP Load / store multiple pseudo instructions.
1484class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1485 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001486 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001487 cstr, itin> {
1488 let OutOperandList = oops;
1489 let InOperandList = !con(iops, (ins pred:$p));
1490 let Pattern = pattern;
1491 list<Predicate> Predicates = [HasVFP2];
1492}
1493
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001494// Load / store multiple
Tim Northover4173e292013-05-31 15:55:51 +00001495
1496// Unknown precision
1497class AXXI4<dag oops, dag iops, IndexMode im,
1498 string asm, string cstr, list<dag> pattern>
1499 : VFPXI<oops, iops, AddrMode4, 4, im,
1500 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1501 // Instruction operands.
1502 bits<4> Rn;
1503 bits<13> regs;
1504
1505 // Encode instruction operands.
1506 let Inst{19-16} = Rn;
1507 let Inst{22} = 0;
1508 let Inst{15-12} = regs{11-8};
1509 let Inst{7-1} = regs{7-1};
1510
1511 let Inst{27-25} = 0b110;
1512 let Inst{11-8} = 0b1011;
1513 let Inst{0} = 1;
1514}
1515
1516// Double precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001517class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001518 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001519 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001520 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001521 // Instruction operands.
1522 bits<4> Rn;
1523 bits<13> regs;
1524
1525 // Encode instruction operands.
1526 let Inst{19-16} = Rn;
1527 let Inst{22} = regs{12};
1528 let Inst{15-12} = regs{11-8};
Tim Northover4173e292013-05-31 15:55:51 +00001529 let Inst{7-1} = regs{7-1};
Bill Wendling345b48f2010-11-17 00:45:23 +00001530
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001531 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001532 let Inst{11-9} = 0b101;
1533 let Inst{8} = 1; // Double precision
Tim Northover4173e292013-05-31 15:55:51 +00001534 let Inst{0} = 0;
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001535}
1536
Tim Northover4173e292013-05-31 15:55:51 +00001537// Single Precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001538class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001539 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001540 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001541 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001542 // Instruction operands.
1543 bits<4> Rn;
1544 bits<13> regs;
1545
1546 // Encode instruction operands.
1547 let Inst{19-16} = Rn;
1548 let Inst{22} = regs{8};
1549 let Inst{15-12} = regs{12-9};
1550 let Inst{7-0} = regs{7-0};
1551
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001552 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001553 let Inst{11-9} = 0b101;
1554 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001555}
1556
Evan Chengac2af2f2008-11-11 02:11:05 +00001557// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001558class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1559 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1560 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001561 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001562 // Instruction operands.
1563 bits<5> Dd;
1564 bits<5> Dm;
1565
1566 // Encode instruction operands.
1567 let Inst{3-0} = Dm{3-0};
1568 let Inst{5} = Dm{4};
1569 let Inst{15-12} = Dd{3-0};
1570 let Inst{22} = Dd{4};
1571
Johnny Chen34a6afc2010-01-29 23:21:10 +00001572 let Inst{27-23} = opcod1;
1573 let Inst{21-20} = opcod2;
1574 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001575 let Inst{11-9} = 0b101;
1576 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001577 let Inst{7-6} = opcod4;
1578 let Inst{4} = opcod5;
Tim Northover5620faf2013-10-24 15:49:39 +00001579
1580 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001581}
1582
Joey Gouly0f12aa22013-07-09 11:26:18 +00001583// Double precision, unary, not-predicated
1584class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1585 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1586 string asm, list<dag> pattern>
1587 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1588 // Instruction operands.
1589 bits<5> Dd;
1590 bits<5> Dm;
1591
1592 let Inst{31-28} = 0b1111;
1593
1594 // Encode instruction operands.
1595 let Inst{3-0} = Dm{3-0};
1596 let Inst{5} = Dm{4};
1597 let Inst{15-12} = Dd{3-0};
1598 let Inst{22} = Dd{4};
1599
1600 let Inst{27-23} = opcod1;
1601 let Inst{21-20} = opcod2;
1602 let Inst{19-16} = opcod3;
1603 let Inst{11-9} = 0b101;
1604 let Inst{8} = 1; // Double precision
1605 let Inst{7-6} = opcod4;
1606 let Inst{4} = opcod5;
1607}
1608
Evan Chengac2af2f2008-11-11 02:11:05 +00001609// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001610class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001611 dag iops, InstrItinClass itin, string opc, string asm,
1612 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001613 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001614 // Instruction operands.
1615 bits<5> Dd;
1616 bits<5> Dn;
1617 bits<5> Dm;
1618
1619 // Encode instruction operands.
1620 let Inst{3-0} = Dm{3-0};
1621 let Inst{5} = Dm{4};
1622 let Inst{19-16} = Dn{3-0};
1623 let Inst{7} = Dn{4};
1624 let Inst{15-12} = Dd{3-0};
1625 let Inst{22} = Dd{4};
1626
Johnny Chen34a6afc2010-01-29 23:21:10 +00001627 let Inst{27-23} = opcod1;
1628 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001629 let Inst{11-9} = 0b101;
1630 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001631 let Inst{6} = op6;
1632 let Inst{4} = op4;
Tim Northover5620faf2013-10-24 15:49:39 +00001633
1634 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001635}
1636
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001637// FP, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001638class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001639 InstrItinClass itin, string asm, list<dag> pattern>
Joey Gouly2d0175e2013-07-09 09:59:04 +00001640 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1641 asm, "", pattern>
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001642{
1643 // Instruction operands.
1644 bits<5> Dd;
1645 bits<5> Dn;
1646 bits<5> Dm;
1647
1648 let Inst{31-28} = 0b1111;
1649
1650 // Encode instruction operands.
1651 let Inst{3-0} = Dm{3-0};
1652 let Inst{5} = Dm{4};
1653 let Inst{19-16} = Dn{3-0};
1654 let Inst{7} = Dn{4};
1655 let Inst{15-12} = Dd{3-0};
1656 let Inst{22} = Dd{4};
1657
1658 let Inst{27-23} = opcod1;
1659 let Inst{21-20} = opcod2;
1660 let Inst{11-9} = 0b101;
1661 let Inst{8} = 1; // double precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001662 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001663 let Inst{4} = 0;
Tim Northover5620faf2013-10-24 15:49:39 +00001664
1665 let Predicates = [HasVFP2, HasDPVFP];
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001666}
1667
Joey Gouly2d0175e2013-07-09 09:59:04 +00001668// Single precision, unary, predicated
Johnny Chen34a6afc2010-01-29 23:21:10 +00001669class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1670 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1671 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001672 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001673 // Instruction operands.
1674 bits<5> Sd;
1675 bits<5> Sm;
1676
1677 // Encode instruction operands.
1678 let Inst{3-0} = Sm{4-1};
1679 let Inst{5} = Sm{0};
1680 let Inst{15-12} = Sd{4-1};
1681 let Inst{22} = Sd{0};
1682
Johnny Chen34a6afc2010-01-29 23:21:10 +00001683 let Inst{27-23} = opcod1;
1684 let Inst{21-20} = opcod2;
1685 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001686 let Inst{11-9} = 0b101;
1687 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001688 let Inst{7-6} = opcod4;
1689 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001690}
1691
Joey Gouly2d0175e2013-07-09 09:59:04 +00001692// Single precision, unary, non-predicated
1693class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1694 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1695 string asm, list<dag> pattern>
1696 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1697 VFPUnaryFrm, itin, asm, "", pattern> {
1698 // Instruction operands.
1699 bits<5> Sd;
1700 bits<5> Sm;
1701
1702 let Inst{31-28} = 0b1111;
1703
1704 // Encode instruction operands.
1705 let Inst{3-0} = Sm{4-1};
1706 let Inst{5} = Sm{0};
1707 let Inst{15-12} = Sd{4-1};
1708 let Inst{22} = Sd{0};
1709
1710 let Inst{27-23} = opcod1;
1711 let Inst{21-20} = opcod2;
1712 let Inst{19-16} = opcod3;
1713 let Inst{11-9} = 0b101;
1714 let Inst{8} = 0; // Single precision
1715 let Inst{7-6} = opcod4;
1716 let Inst{4} = opcod5;
1717}
1718
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001719// Single precision unary, if no NEON. Same as ASuI except not available if
1720// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001721class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1722 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1723 string asm, list<dag> pattern>
1724 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1725 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001726 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1727}
1728
Evan Chengac2af2f2008-11-11 02:11:05 +00001729// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001730class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1731 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001732 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001733 // Instruction operands.
1734 bits<5> Sd;
1735 bits<5> Sn;
1736 bits<5> Sm;
1737
1738 // Encode instruction operands.
1739 let Inst{3-0} = Sm{4-1};
1740 let Inst{5} = Sm{0};
1741 let Inst{19-16} = Sn{4-1};
1742 let Inst{7} = Sn{0};
1743 let Inst{15-12} = Sd{4-1};
1744 let Inst{22} = Sd{0};
1745
Johnny Chen34a6afc2010-01-29 23:21:10 +00001746 let Inst{27-23} = opcod1;
1747 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001748 let Inst{11-9} = 0b101;
1749 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001750 let Inst{6} = op6;
1751 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001752}
1753
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001754// Single precision, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001755class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001756 InstrItinClass itin, string asm, list<dag> pattern>
1757 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1758 VFPBinaryFrm, itin, asm, "", pattern>
1759{
1760 // Instruction operands.
1761 bits<5> Sd;
1762 bits<5> Sn;
1763 bits<5> Sm;
1764
1765 let Inst{31-28} = 0b1111;
1766
1767 // Encode instruction operands.
1768 let Inst{3-0} = Sm{4-1};
1769 let Inst{5} = Sm{0};
1770 let Inst{19-16} = Sn{4-1};
1771 let Inst{7} = Sn{0};
1772 let Inst{15-12} = Sd{4-1};
1773 let Inst{22} = Sd{0};
1774
1775 let Inst{27-23} = opcod1;
1776 let Inst{21-20} = opcod2;
1777 let Inst{11-9} = 0b101;
1778 let Inst{8} = 0; // Single precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001779 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001780 let Inst{4} = 0;
1781}
1782
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001783// Single precision binary, if no NEON. Same as ASbI except not available if
1784// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001785class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001786 dag iops, InstrItinClass itin, string opc, string asm,
1787 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001788 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001789 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001790
1791 // Instruction operands.
1792 bits<5> Sd;
1793 bits<5> Sn;
1794 bits<5> Sm;
1795
1796 // Encode instruction operands.
1797 let Inst{3-0} = Sm{4-1};
1798 let Inst{5} = Sm{0};
1799 let Inst{19-16} = Sn{4-1};
1800 let Inst{7} = Sn{0};
1801 let Inst{15-12} = Sd{4-1};
1802 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001803}
1804
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001805// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001806class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1807 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1808 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001809 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001810 let Inst{27-23} = opcod1;
1811 let Inst{21-20} = opcod2;
1812 let Inst{19-16} = opcod3;
1813 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001814 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001815 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001816}
1817
Johnny Chen39640592010-02-11 18:47:03 +00001818// VFP conversion between floating-point and fixed-point
1819class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001820 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1821 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001822 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
Jim Grosbachf0d25112011-12-22 19:55:21 +00001823 bits<5> fbits;
Johnny Chen39640592010-02-11 18:47:03 +00001824 // size (fixed-point number): sx == 0 ? 16 : 32
1825 let Inst{7} = op5; // sx
Jim Grosbachf0d25112011-12-22 19:55:21 +00001826 let Inst{5} = fbits{0};
1827 let Inst{3-0} = fbits{4-1};
Johnny Chen39640592010-02-11 18:47:03 +00001828}
1829
David Goodwin85b5b022009-08-10 22:17:39 +00001830// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001831class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001832 dag oops, dag iops, InstrItinClass itin,
1833 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001834 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1835 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001836 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1837}
1838
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001839class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001840 InstrItinClass itin,
1841 string opc, string asm, list<dag> pattern>
1842 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001843 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001844 let Inst{11-8} = opcod2;
1845 let Inst{4} = 1;
1846}
1847
David Goodwinb062c232009-08-06 16:52:47 +00001848class AVConv2I<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, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001851
Bob Wilson3968c6a2010-03-23 17:23:59 +00001852class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001853 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1854 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001855
David Goodwinb062c232009-08-06 16:52:47 +00001856class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1857 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1858 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001859
David Goodwinb062c232009-08-06 16:52:47 +00001860class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1861 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1862 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001863
Evan Chengac2af2f2008-11-11 02:11:05 +00001864//===----------------------------------------------------------------------===//
1865
Bob Wilson2e076c42009-06-22 23:27:02 +00001866//===----------------------------------------------------------------------===//
1867// ARM NEON Instruction templates.
1868//
Evan Chengee98fa92008-08-29 06:41:12 +00001869
Johnny Chenf833fad2010-03-20 00:17:00 +00001870class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1871 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1872 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001873 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001874 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001875 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001876 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001877 let Pattern = pattern;
1878 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001879 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001880}
1881
1882// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001883class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1884 InstrItinClass itin, string opc, string asm, string cstr,
1885 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001886 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001887 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001888 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001889 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001890 let Pattern = pattern;
1891 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001892 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001893}
1894
Joey Goulydf686002013-07-17 13:59:38 +00001895// Same as NeonI except it is not predicated
1896class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1897 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1898 list<dag> pattern>
1899 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1900 let OutOperandList = oops;
1901 let InOperandList = iops;
1902 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
1903 let Pattern = pattern;
1904 list<Predicate> Predicates = [HasNEON];
1905 let DecoderNamespace = "NEON";
1906
1907 let Inst{31-28} = 0b1111;
1908}
1909
Bob Wilson50820a22009-10-07 21:53:04 +00001910class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1911 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001912 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001913 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1914 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001915 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001916 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001917 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001918 let Inst{11-8} = op11_8;
1919 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001920
Chris Lattner63274cb2010-11-15 05:19:05 +00001921 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001922 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001923
Owen Andersonad402342010-11-02 00:05:05 +00001924 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001925 bits<6> Rn;
1926 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001927
Owen Andersonad402342010-11-02 00:05:05 +00001928 let Inst{22} = Vd{4};
1929 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001930 let Inst{19-16} = Rn{3-0};
1931 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001932}
1933
Owen Anderson9f20daf2010-11-02 20:47:39 +00001934class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1935 dag oops, dag iops, InstrItinClass itin,
1936 string opc, string dt, string asm, string cstr, list<dag> pattern>
1937 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1938 dt, asm, cstr, pattern> {
1939 bits<3> lane;
1940}
1941
Bob Wilson9392b0e2010-08-25 23:27:42 +00001942class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001943 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001944 itin> {
1945 let OutOperandList = oops;
1946 let InOperandList = !con(iops, (ins pred:$p));
1947 list<Predicate> Predicates = [HasNEON];
1948}
1949
Jim Grosbach233b3a22010-10-06 20:36:55 +00001950class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1951 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001952 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001953 itin> {
1954 let OutOperandList = oops;
1955 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001956 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001957 list<Predicate> Predicates = [HasNEON];
1958}
1959
Johnny Chenac5024b2010-03-23 16:43:47 +00001960class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001961 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001962 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1963 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001964 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001965 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001966 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001967}
1968
Johnny Chen020023a2010-03-23 20:40:44 +00001969class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001970 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001971 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001972 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001973 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001974 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001975 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001976}
1977
1978// NEON "one register and a modified immediate" format.
1979class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1980 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001981 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001982 string opc, string dt, string asm, string cstr,
1983 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001984 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00001985 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00001986 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001987 let Inst{11-8} = op11_8;
1988 let Inst{7} = op7;
1989 let Inst{6} = op6;
1990 let Inst{5} = op5;
1991 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001992
Owen Anderson284cb362010-10-26 17:40:54 +00001993 // Instruction operands.
1994 bits<5> Vd;
1995 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00001996
Owen Anderson284cb362010-10-26 17:40:54 +00001997 let Inst{15-12} = Vd{3-0};
1998 let Inst{22} = Vd{4};
1999 let Inst{24} = SIMM{7};
2000 let Inst{18-16} = SIMM{6-4};
2001 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00002002 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00002003}
2004
2005// NEON 2 vector register format.
2006class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2007 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00002008 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002009 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002010 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002011 let Inst{24-23} = op24_23;
2012 let Inst{21-20} = op21_20;
2013 let Inst{19-18} = op19_18;
2014 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002015 let Inst{11-7} = op11_7;
2016 let Inst{6} = op6;
2017 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002018
Owen Anderson24774462010-10-25 18:43:52 +00002019 // Instruction operands.
2020 bits<5> Vd;
2021 bits<5> Vm;
2022
2023 let Inst{15-12} = Vd{3-0};
2024 let Inst{22} = Vd{4};
2025 let Inst{3-0} = Vm{3-0};
2026 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002027}
2028
Joey Gouly943dd592013-07-18 11:53:22 +00002029// Same as N2V but not predicated.
Amara Emerson33089092013-09-19 11:59:01 +00002030class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
Joey Gouly943dd592013-07-18 11:53:22 +00002031 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2032 string Dt, ValueType ResTy, ValueType OpTy, list<dag> pattern>
2033 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2034 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2035 bits<5> Vd;
2036 bits<5> Vm;
2037
2038 // Encode instruction operands
2039 let Inst{22} = Vd{4};
2040 let Inst{15-12} = Vd{3-0};
2041 let Inst{5} = Vm{4};
2042 let Inst{3-0} = Vm{3-0};
2043
2044 // Encode constant bits
2045 let Inst{27-23} = 0b00111;
2046 let Inst{21-20} = 0b11;
Amara Emerson33089092013-09-19 11:59:01 +00002047 let Inst{19-18} = op19_18;
Joey Gouly943dd592013-07-18 11:53:22 +00002048 let Inst{17-16} = op17_16;
2049 let Inst{11} = 0;
2050 let Inst{10-8} = op10_8;
2051 let Inst{7} = op7;
2052 let Inst{6} = op6;
2053 let Inst{4} = 0;
2054
2055 let DecoderNamespace = "NEON";
2056}
2057
Evan Cheng738a97a2009-11-23 21:57:23 +00002058// Same as N2V except it doesn't have a datatype suffix.
2059class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002060 bits<5> op11_7, bit op6, bit op4,
2061 dag oops, dag iops, InstrItinClass itin,
2062 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002063 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002064 let Inst{24-23} = op24_23;
2065 let Inst{21-20} = op21_20;
2066 let Inst{19-18} = op19_18;
2067 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002068 let Inst{11-7} = op11_7;
2069 let Inst{6} = op6;
2070 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002071
Owen Anderson24774462010-10-25 18:43:52 +00002072 // Instruction operands.
2073 bits<5> Vd;
2074 bits<5> Vm;
2075
2076 let Inst{15-12} = Vd{3-0};
2077 let Inst{22} = Vd{4};
2078 let Inst{3-0} = Vm{3-0};
2079 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002080}
2081
2082// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00002083class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00002084 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002085 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00002086 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002087 let Inst{24} = op24;
2088 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002089 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002090 let Inst{7} = op7;
2091 let Inst{6} = op6;
2092 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002093
Owen Anderson3665fee2010-10-26 20:56:57 +00002094 // Instruction operands.
2095 bits<5> Vd;
2096 bits<5> Vm;
2097 bits<6> SIMM;
2098
2099 let Inst{15-12} = Vd{3-0};
2100 let Inst{22} = Vd{4};
2101 let Inst{3-0} = Vm{3-0};
2102 let Inst{5} = Vm{4};
2103 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002104}
2105
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002106// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00002107
Jim Grosbacheca54e42011-05-19 17:34:53 +00002108class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2109 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2110 string opc, string dt, string asm, string cstr,
2111 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00002112 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002113 let Inst{24} = op24;
2114 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00002115 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002116 let Inst{11-8} = op11_8;
2117 let Inst{6} = op6;
2118 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00002119}
2120
2121class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2122 dag oops, dag iops, Format f, InstrItinClass itin,
2123 string opc, string dt, string asm, string cstr, list<dag> pattern>
2124 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2125 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Owen Anderson9e44cf22010-10-21 20:21:49 +00002126 // Instruction operands.
2127 bits<5> Vd;
2128 bits<5> Vn;
2129 bits<5> Vm;
2130
2131 let Inst{15-12} = Vd{3-0};
2132 let Inst{22} = Vd{4};
2133 let Inst{19-16} = Vn{3-0};
2134 let Inst{7} = Vn{4};
2135 let Inst{3-0} = Vm{3-0};
2136 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002137}
2138
Joey Goulydf686002013-07-17 13:59:38 +00002139class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2140 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2141 string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy,
2142 SDPatternOperator IntOp, bit Commutable, list<dag> pattern>
2143 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2144 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2145 bits<5> Vd;
2146 bits<5> Vn;
2147 bits<5> Vm;
2148
2149 // Encode instruction operands
2150 let Inst{22} = Vd{4};
2151 let Inst{15-12} = Vd{3-0};
2152 let Inst{19-16} = Vn{3-0};
2153 let Inst{7} = Vn{4};
2154 let Inst{5} = Vm{4};
2155 let Inst{3-0} = Vm{3-0};
2156
2157 // Encode constant bits
2158 let Inst{27-23} = op27_23;
2159 let Inst{21-20} = op21_20;
2160 let Inst{11-8} = op11_8;
2161 let Inst{6} = op6;
2162 let Inst{4} = op4;
2163}
2164
Jim Grosbacheca54e42011-05-19 17:34:53 +00002165class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2166 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2167 string opc, string dt, string asm, string cstr,
2168 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002169 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2170 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2171
2172 // Instruction operands.
2173 bits<5> Vd;
2174 bits<5> Vn;
2175 bits<5> Vm;
2176 bit lane;
2177
2178 let Inst{15-12} = Vd{3-0};
2179 let Inst{22} = Vd{4};
2180 let Inst{19-16} = Vn{3-0};
2181 let Inst{7} = Vn{4};
2182 let Inst{3-0} = Vm{3-0};
2183 let Inst{5} = lane;
2184}
2185
Jim Grosbacheca54e42011-05-19 17:34:53 +00002186class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2187 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2188 string opc, string dt, string asm, string cstr,
2189 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002190 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2191 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2192
2193 // Instruction operands.
2194 bits<5> Vd;
2195 bits<5> Vn;
2196 bits<5> Vm;
2197 bits<2> lane;
2198
2199 let Inst{15-12} = Vd{3-0};
2200 let Inst{22} = Vd{4};
2201 let Inst{19-16} = Vn{3-0};
2202 let Inst{7} = Vn{4};
2203 let Inst{2-0} = Vm{2-0};
2204 let Inst{5} = lane{1};
2205 let Inst{3} = lane{0};
2206}
2207
Johnny Chen8a687232010-03-23 21:35:03 +00002208// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00002209class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2210 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002211 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002212 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002213 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002214 let Inst{24} = op24;
2215 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002216 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002217 let Inst{11-8} = op11_8;
2218 let Inst{6} = op6;
2219 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002220
Owen Andersondff239c2010-10-25 18:28:30 +00002221 // Instruction operands.
2222 bits<5> Vd;
2223 bits<5> Vn;
2224 bits<5> Vm;
2225
2226 let Inst{15-12} = Vd{3-0};
2227 let Inst{22} = Vd{4};
2228 let Inst{19-16} = Vn{3-0};
2229 let Inst{7} = Vn{4};
2230 let Inst{3-0} = Vm{3-0};
2231 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002232}
2233
2234// NEON VMOVs between scalar and core registers.
2235class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002236 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002237 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002238 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002239 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002240 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002241 let Inst{11-8} = opcod2;
2242 let Inst{6-5} = opcod3;
2243 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00002244 // A8.6.303, A8.6.328, A8.6.329
2245 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00002246
2247 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002248 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002249 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002250 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00002251 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00002252
Chris Lattner63274cb2010-11-15 05:19:05 +00002253 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002254 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00002255
Owen Andersoned9652f2010-10-27 21:28:09 +00002256 bits<5> V;
2257 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00002258 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00002259 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00002260
Owen Anderson40d24a42010-10-27 19:25:54 +00002261 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00002262 let Inst{7} = V{4};
2263 let Inst{19-16} = V{3-0};
2264 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002265}
2266class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002267 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002268 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002269 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002270 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002271class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002272 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002273 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002274 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002275 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002276class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002277 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002278 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002279 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002280 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00002281
Johnny Chen45ab3f32010-03-25 17:01:27 +00002282// Vector Duplicate Lane (from scalar to all elements)
2283class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2284 InstrItinClass itin, string opc, string dt, string asm,
2285 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00002286 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00002287 let Inst{24-23} = 0b11;
2288 let Inst{21-20} = 0b11;
2289 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002290 let Inst{11-7} = 0b11000;
2291 let Inst{6} = op6;
2292 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00002293
Owen Anderson40d24a42010-10-27 19:25:54 +00002294 bits<5> Vd;
2295 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002296
Owen Anderson40d24a42010-10-27 19:25:54 +00002297 let Inst{22} = Vd{4};
2298 let Inst{15-12} = Vd{3-0};
2299 let Inst{5} = Vm{4};
2300 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00002301}
2302
David Goodwin3b9c52c2009-08-04 17:53:06 +00002303// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2304// for single-precision FP.
2305class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2306 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2307}
Jim Grosbach7996b152011-11-14 22:28:39 +00002308
2309// VFP/NEON Instruction aliases for type suffices.
2310class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
Jim Grosbachfdf9e152011-12-05 20:29:59 +00002311 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002312
Jim Grosbach3d6c0e02011-11-14 23:11:19 +00002313multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002314 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2315 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2316 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2317 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002318}
2319
Jim Grosbach681db342012-01-24 17:23:29 +00002320multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2321 let Predicates = [HasNEON] in {
2322 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2323 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2324 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2325 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2326}
2327}
2328
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002329// The same alias classes using AsmPseudo instead, for the more complex
2330// stuff in NEON that InstAlias can't quite handle.
2331// Note that we can't use anonymous defm references here like we can
2332// above, as we care about the ultimate instruction enum names generated, unlike
2333// for instalias defs.
2334class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002335 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbach585ce302011-12-07 01:17:58 +00002336
2337// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2338def : TokenAlias<".s8", ".i8">;
2339def : TokenAlias<".u8", ".i8">;
2340def : TokenAlias<".s16", ".i16">;
2341def : TokenAlias<".u16", ".i16">;
2342def : TokenAlias<".s32", ".i32">;
2343def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002344def : TokenAlias<".s64", ".i64">;
2345def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002346
2347def : TokenAlias<".i8", ".8">;
2348def : TokenAlias<".i16", ".16">;
2349def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002350def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002351
2352def : TokenAlias<".p8", ".8">;
2353def : TokenAlias<".p16", ".16">;
2354
2355def : TokenAlias<".f32", ".32">;
2356def : TokenAlias<".f64", ".64">;
2357def : TokenAlias<".f", ".f32">;
2358def : TokenAlias<".d", ".f64">;