blob: c2c84d236409c76457cf0657883c4e1b42a20fb7 [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
Tim Northoveree843ef2014-08-15 10:47:12 +0000206def BankedRegOperand : AsmOperandClass {
207 let Name = "BankedReg";
208 let ParserMethod = "parseBankedRegOperand";
209}
210def banked_reg : Operand<i32> {
211 let PrintMethod = "printBankedRegOperand";
212 let DecoderMethod = "DecodeBankedReg";
213 let ParserMatchClass = BankedRegOperand;
214}
215
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000216// Shift Right Immediate - A shift right immediate is encoded differently from
217// other shift immediates. The imm6 field is encoded like so:
Bill Wendling3b1459b2011-03-01 01:00:59 +0000218//
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000219// Offset Encoding
220// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
221// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
222// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
223// 64 64 - <imm> is encoded in imm6<5:0>
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000224def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000225def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000226 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000227 let DecoderMethod = "DecodeShiftRight8Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000228 let ParserMatchClass = shr_imm8_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000229}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000230def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000231def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000232 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000233 let DecoderMethod = "DecodeShiftRight16Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000234 let ParserMatchClass = shr_imm16_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000235}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000236def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000237def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000238 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000239 let DecoderMethod = "DecodeShiftRight32Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000240 let ParserMatchClass = shr_imm32_asm_operand;
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000241}
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000242def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000243def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000244 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000245 let DecoderMethod = "DecodeShiftRight64Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000246 let ParserMatchClass = shr_imm64_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000247}
248
Evan Chengcd4cdd12009-07-11 06:43:01 +0000249//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000250// ARM Assembler alias templates.
251//
252class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
253 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
254class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
255 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
256class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
257 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000258class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
259 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
Tim Northover5620faf2013-10-24 15:49:39 +0000260class VFP2DPInstAlias<string Asm, dag Result, bit Emit = 0b1>
261 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2,HasDPVFP]>;
Jim Grosbach4ab23b52011-10-03 21:12:43 +0000262class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
263 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
Jim Grosbach0a978ef2011-12-05 19:55:46 +0000264class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
265 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000266
Jim Grosbach9227f392011-12-13 20:08:32 +0000267
268class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
269 Requires<[HasVFP2]>;
270class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
271 Requires<[HasNEON]>;
272
Jim Grosbach6caa5572011-08-22 18:04:24 +0000273//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000274// ARM Instruction templates.
275//
276
Jim Grosbach6caa5572011-08-22 18:04:24 +0000277
Owen Anderson651b2302011-07-13 23:22:26 +0000278class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000279 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000280 : Instruction {
281 let Namespace = "ARM";
282
Evan Cheng2d37f192008-08-28 23:39:26 +0000283 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000284 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000285 IndexMode IM = im;
286 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000287 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000288 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000289 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000290 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000291 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000292 // The instruction is a 16-bit flag setting Thumb instruction. Used
293 // by the parser to determine whether to require the 'S' suffix on the
294 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
295 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000296
Chris Lattner7ff33462010-10-31 19:22:57 +0000297 // If this is a pseudo instruction, mark it isCodeGenOnly.
298 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000299
Jim Grosbach30694dc2011-08-15 16:52:24 +0000300 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000301 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000302 let TSFlags{6-5} = IndexModeBits;
303 let TSFlags{12-7} = Form;
304 let TSFlags{13} = isUnaryDataProc;
305 let TSFlags{14} = canXformTo16Bit;
306 let TSFlags{17-15} = D.Value;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000307 let TSFlags{18} = thumbArithFlagSetting;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000308
Evan Cheng2d37f192008-08-28 23:39:26 +0000309 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000310 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000311}
312
Johnny Chenc28e6292009-12-15 17:24:14 +0000313class Encoding {
314 field bits<32> Inst;
James Molloyd9ba4fd2012-02-09 10:56:31 +0000315 // Mask of bits that cause an encoding to be UNPREDICTABLE.
316 // If a bit is set, then if the corresponding bit in the
317 // target encoding differs from its value in the "Inst" field,
318 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
319 field bits<32> Unpredictable = 0;
320 // SoftFail is the generic name for this field, but we alias it so
321 // as to make it more obvious what it means in ARM-land.
322 field bits<32> SoftFail = Unpredictable;
Johnny Chenc28e6292009-12-15 17:24:14 +0000323}
324
Owen Anderson651b2302011-07-13 23:22:26 +0000325class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000326 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000327 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
328 let DecoderNamespace = "ARM";
329}
Johnny Chenc28e6292009-12-15 17:24:14 +0000330
331// This Encoding-less class is used by Thumb1 to specify the encoding bits later
332// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000333class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000334 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000335 : InstTemplate<am, sz, im, f, d, cstr, itin> {
336 let DecoderNamespace = "Thumb";
337}
Johnny Chenc28e6292009-12-15 17:24:14 +0000338
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000339// Pseudo-instructions for alternate assembly syntax (never used by codegen).
340// These are aliases that require C++ handling to convert to the target
341// instruction, while InstAliases can be handled directly by tblgen.
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000342class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000343 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
344 "", NoItinerary> {
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000345 let OutOperandList = oops;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000346 let InOperandList = iops;
347 let Pattern = [];
348 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000349 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000350 let isPseudo = 1;
351}
352
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000353class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
354 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
355class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
356 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
357class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
358 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
359class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
360 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
361class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
362 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000363
364// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000365class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000366 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000367 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000368 let OutOperandList = oops;
369 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000370 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000371 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000372 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000373}
374
Jim Grosbachcfb66202010-11-18 01:15:56 +0000375// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000376class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000377 list<dag> pattern>
378 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000379 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000380 list<Predicate> Predicates = [IsARM];
381}
382
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000383// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000384class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000385 list<dag> pattern>
386 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000387 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000388 list<Predicate> Predicates = [IsThumb];
389}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000390
Jim Grosbachd42257c2010-12-15 18:48:45 +0000391// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000392class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000393 list<dag> pattern>
394 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000395 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000396 list<Predicate> Predicates = [IsThumb2];
397}
Jim Grosbach95dee402011-07-08 17:40:42 +0000398
Owen Anderson651b2302011-07-13 23:22:26 +0000399class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000400 InstrItinClass itin, list<dag> pattern,
401 dag Result>
402 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
403 PseudoInstExpansion<Result>;
404
Owen Anderson651b2302011-07-13 23:22:26 +0000405class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000406 InstrItinClass itin, list<dag> pattern,
407 dag Result>
408 : tPseudoInst<oops, iops, sz, itin, pattern>,
409 PseudoInstExpansion<Result>;
410
Owen Anderson651b2302011-07-13 23:22:26 +0000411class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000412 InstrItinClass itin, list<dag> pattern,
413 dag Result>
414 : t2PseudoInst<oops, iops, sz, itin, pattern>,
415 PseudoInstExpansion<Result>;
416
Evan Cheng2d37f192008-08-28 23:39:26 +0000417// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000418class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000419 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000420 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000421 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000422 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000423 bits<4> p;
424 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000425 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000426 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000427 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000428 let Pattern = pattern;
429 list<Predicate> Predicates = [IsARM];
430}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000431
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000432// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000433class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000434 IndexMode im, Format f, InstrItinClass itin,
435 string opc, string asm, string cstr,
436 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000437 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
438 let OutOperandList = oops;
439 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000440 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000441 let Pattern = pattern;
442 let isPredicable = 0;
443 list<Predicate> Predicates = [IsARM];
444}
Evan Cheng2d37f192008-08-28 23:39:26 +0000445
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000446// Same as I except it can optionally modify CPSR. Note it's modeled as an input
447// operand since by default it's a zero register. It will become an implicit def
448// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000449class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000450 IndexMode im, Format f, InstrItinClass itin,
451 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000452 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000453 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000454 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000455 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000456 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000457 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000458
Evan Cheng2d37f192008-08-28 23:39:26 +0000459 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000460 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000461 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000462 let Pattern = pattern;
463 list<Predicate> Predicates = [IsARM];
464}
465
Evan Chenga2827232008-09-01 07:19:00 +0000466// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000467class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000468 IndexMode im, Format f, InstrItinClass itin,
469 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000470 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000471 let OutOperandList = oops;
472 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000473 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000474 let Pattern = pattern;
475 list<Predicate> Predicates = [IsARM];
476}
477
David Goodwinb062c232009-08-06 16:52:47 +0000478class AI<dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000480 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000481 opc, asm, "", pattern>;
482class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
483 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000484 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000485 opc, asm, "", pattern>;
486class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000487 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000488 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000489 asm, "", pattern>;
David Peixottob76f55f2014-01-27 21:39:04 +0000490class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
491 string asm, list<dag> pattern>
492 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
493 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000494class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000495 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000496 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000497 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000498
499// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000500class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
501 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000502 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000503 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000504 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000505}
David Goodwinb062c232009-08-06 16:52:47 +0000506class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
507 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000508 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000509 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000510 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000511}
Evan Chengfa558782008-09-01 08:25:56 +0000512
513// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000514class JTI<dag oops, dag iops, InstrItinClass itin,
515 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000516 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000517 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000518
Joey Goulye6d165c2013-08-27 17:38:16 +0000519class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000520 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000521 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000522 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000523 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000524 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000525 let Inst{27-23} = 0b00011;
526 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000527 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000528 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000529 let Inst{15-12} = Rt;
Joey Goulye6d165c2013-08-27 17:38:16 +0000530 let Inst{11-10} = 0b11;
531 let Inst{9-8} = opcod2;
532 let Inst{7-0} = 0b10011111;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000533}
Joey Goulye6d165c2013-08-27 17:38:16 +0000534class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000535 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000536 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000537 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000538 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000539 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000540 let Inst{27-23} = 0b00011;
541 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000542 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000543 let Inst{19-16} = addr;
Joey Goulye6d165c2013-08-27 17:38:16 +0000544 let Inst{11-10} = 0b11;
545 let Inst{9-8} = opcod2;
546 let Inst{7-4} = 0b1001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000547 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000548}
Joey Goulye6d165c2013-08-27 17:38:16 +0000549// Atomic load/store instructions
550class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
551 string opc, string asm, list<dag> pattern>
552 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
553
554class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
555 string opc, string asm, list<dag> pattern>
556 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
557 bits<4> Rd;
558 let Inst{15-12} = Rd;
559}
560
561// Exclusive load/store instructions
562
563class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
564 string opc, string asm, list<dag> pattern>
565 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000566 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
Joey Goulye6d165c2013-08-27 17:38:16 +0000567
568class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
569 string opc, string asm, list<dag> pattern>
570 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000571 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
Joey Goulye6d165c2013-08-27 17:38:16 +0000572 bits<4> Rd;
573 let Inst{15-12} = Rd;
574}
575
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000576class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000577 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000578 bits<4> Rt;
579 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000580 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000581 let Inst{27-23} = 0b00010;
582 let Inst{22} = b;
583 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000584 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000585 let Inst{15-12} = Rt;
586 let Inst{11-4} = 0b00001001;
587 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000588
Silviu Barangaca45af92012-04-18 14:18:57 +0000589 let Unpredictable{11-8} = 0b1111;
Owen Andersondde461c2011-10-28 18:02:13 +0000590 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000591}
Joey Goulye6d165c2013-08-27 17:38:16 +0000592// Acquire/Release load/store instructions
593class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
594 string opc, string asm, list<dag> pattern>
595 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000596 Requires<[IsARM, HasAcquireRelease]>;
Joey Goulye6d165c2013-08-27 17:38:16 +0000597
598class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
599 string opc, string asm, list<dag> pattern>
600 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000601 Requires<[IsARM, HasAcquireRelease]> {
Joey Goulye6d165c2013-08-27 17:38:16 +0000602 let Inst{15-12} = 0b1111;
603}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000604
Evan Cheng624844b2008-09-01 01:51:14 +0000605// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000606class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000608 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000609 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000610 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000611 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000612}
David Goodwinb062c232009-08-06 16:52:47 +0000613class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
614 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000615 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000616 opc, asm, "", pattern> {
617 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000618 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000619}
620class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000621 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000622 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000623 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000624 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000625 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000626}
Evan Cheng624844b2008-09-01 01:51:14 +0000627
Evan Chengcccca872008-09-01 01:27:33 +0000628// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000629
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000630// LDR/LDRB/STR/STRB/...
631class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000632 Format f, InstrItinClass itin, string opc, string asm,
633 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000634 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000635 "", pattern> {
636 let Inst{27-25} = op;
637 let Inst{24} = 1; // 24 == P
638 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000639 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000640 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000641 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000642}
Jim Grosbach2f790742010-11-13 00:35:48 +0000643// Indexed load/stores
644class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000645 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000646 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000647 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000648 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000649 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000650 let Inst{27-26} = 0b01;
651 let Inst{24} = isPre; // P bit
652 let Inst{22} = isByte; // B bit
653 let Inst{21} = isPre; // W bit
654 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000655 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000656}
Owen Anderson2aedba62011-07-26 20:54:26 +0000657class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000658 IndexMode im, Format f, InstrItinClass itin, string opc,
659 string asm, string cstr, list<dag> pattern>
660 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
661 pattern> {
662 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000663 // {12} isAdd
664 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000665 bits<14> offset;
666 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000667 let Inst{25} = 1;
668 let Inst{23} = offset{12};
669 let Inst{19-16} = Rn;
670 let Inst{11-5} = offset{11-5};
671 let Inst{4} = 0;
672 let Inst{3-0} = offset{3-0};
673}
674
675class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
676 IndexMode im, Format f, InstrItinClass itin, string opc,
677 string asm, string cstr, list<dag> pattern>
678 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
679 pattern> {
680 // AM2 store w/ two operands: (GPR, am2offset)
681 // {12} isAdd
682 // {11-0} imm12/Rm
683 bits<14> offset;
684 bits<4> Rn;
685 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000686 let Inst{23} = offset{12};
687 let Inst{19-16} = Rn;
688 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000689}
Owen Anderson2aedba62011-07-26 20:54:26 +0000690
691
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000692// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
693// but for now use this class for STRT and STRBT.
694class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
695 IndexMode im, Format f, InstrItinClass itin, string opc,
696 string asm, string cstr, list<dag> pattern>
697 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
698 pattern> {
699 // AM2 store w/ two operands: (GPR, am2offset)
700 // {17-14} Rn
701 // {13} 1 == Rm, 0 == imm12
702 // {12} isAdd
703 // {11-0} imm12/Rm
704 bits<18> addr;
705 let Inst{25} = addr{13};
706 let Inst{23} = addr{12};
707 let Inst{19-16} = addr{17-14};
708 let Inst{11-0} = addr{11-0};
709}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000710
Evan Cheng624844b2008-09-01 01:51:14 +0000711// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000712class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
713 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000714 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000715 opc, asm, "", pattern> {
716 bits<14> addr;
717 bits<4> Rt;
718 let Inst{27-25} = 0b000;
719 let Inst{24} = 1; // P bit
720 let Inst{23} = addr{8}; // U bit
721 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
722 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000723 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000724 let Inst{19-16} = addr{12-9}; // Rn
725 let Inst{15-12} = Rt; // Rt
726 let Inst{11-8} = addr{7-4}; // imm7_4/zero
727 let Inst{7-4} = op;
728 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000729
730 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000731}
Evan Cheng169eccc2008-09-01 07:00:14 +0000732
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000733class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000734 IndexMode im, Format f, InstrItinClass itin, string opc,
735 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000736 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000737 opc, asm, cstr, pattern> {
738 bits<4> Rt;
739 let Inst{27-25} = 0b000;
740 let Inst{24} = isPre; // P bit
741 let Inst{21} = isPre; // W bit
742 let Inst{20} = op20; // L bit
743 let Inst{15-12} = Rt; // Rt
744 let Inst{7-4} = op;
745}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000746
747// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
748// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000749class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000750 IndexMode im, Format f, InstrItinClass itin, string opc,
751 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000752 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000753 // {13} 1 == imm8, 0 == Rm
754 // {12-9} Rn
755 // {8} isAdd
756 // {7-4} imm7_4/zero
757 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000758 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000759 bits<4> Rt;
760 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000761 let Inst{24} = 0; // P bit
762 let Inst{21} = 1;
763 let Inst{20} = isLoad; // L bit
764 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000765 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000766 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000767}
768
Evan Cheng169eccc2008-09-01 07:00:14 +0000769// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000770class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000771 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000772 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000773 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000774 bits<14> addr;
775 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000776 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000777 let Inst{24} = 1; // P bit
778 let Inst{23} = addr{8}; // U bit
779 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
780 let Inst{21} = 0; // W bit
781 let Inst{20} = 0; // L bit
782 let Inst{19-16} = addr{12-9}; // Rn
783 let Inst{15-12} = Rt; // Rt
784 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000785 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000786 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000787 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000788}
Evan Cheng169eccc2008-09-01 07:00:14 +0000789
Evan Cheng624844b2008-09-01 01:51:14 +0000790// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000791class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
792 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000793 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000794 bits<4> p;
795 bits<16> regs;
796 bits<4> Rn;
797 let Inst{31-28} = p;
798 let Inst{27-25} = 0b100;
799 let Inst{22} = 0; // S bit
800 let Inst{19-16} = Rn;
801 let Inst{15-0} = regs;
802}
Evan Cheng2d37f192008-08-28 23:39:26 +0000803
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000804// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000805class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
806 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000807 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000808 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000809 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000810 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000811 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000812}
David Goodwinb062c232009-08-06 16:52:47 +0000813class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
814 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000815 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000816 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000817 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000818 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000819}
820
821// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000822class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
823 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000824 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000825 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000826 bits<4> Rd;
827 bits<4> Rn;
828 bits<4> Rm;
829 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000830 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000831 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000832 let Inst{19-16} = Rd;
833 let Inst{11-8} = Rm;
834 let Inst{3-0} = Rn;
835}
836// MSW multiple w/ Ra operand
837class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
838 InstrItinClass itin, string opc, string asm, list<dag> pattern>
839 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
840 bits<4> Ra;
841 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000842}
Evan Cheng2d37f192008-08-28 23:39:26 +0000843
Evan Cheng36ae4032008-11-06 03:35:07 +0000844// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000845class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000846 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000847 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000848 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000849 bits<4> Rn;
850 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000851 let Inst{4} = 0;
852 let Inst{7} = 1;
853 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000854 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000855 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000856 let Inst{11-8} = Rm;
857 let Inst{3-0} = Rn;
858}
859class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
860 InstrItinClass itin, string opc, string asm, list<dag> pattern>
861 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
862 bits<4> Rd;
863 let Inst{19-16} = Rd;
864}
865
866// AMulxyI with Ra operand
867class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
868 InstrItinClass itin, string opc, string asm, list<dag> pattern>
869 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
870 bits<4> Ra;
871 let Inst{15-12} = Ra;
872}
873// SMLAL*
874class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
875 InstrItinClass itin, string opc, string asm, list<dag> pattern>
876 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
877 bits<4> RdLo;
878 bits<4> RdHi;
879 let Inst{19-16} = RdHi;
880 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +0000881}
882
Evan Cheng49d66522008-11-06 22:15:19 +0000883// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000884class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
885 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000886 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000887 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +0000888 // All AExtI instructions have Rd and Rm register operands.
889 bits<4> Rd;
890 bits<4> Rm;
891 let Inst{15-12} = Rd;
892 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +0000893 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +0000894 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +0000895 let Inst{27-20} = opcod;
Silviu Barangaddc67a72012-05-11 09:28:27 +0000896
897 let Unpredictable{9-8} = 0b11;
Evan Cheng49d66522008-11-06 22:15:19 +0000898}
899
Evan Cheng98dc53e2008-11-07 01:41:35 +0000900// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000901class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
902 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000903 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000904 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000905 bits<4> Rd;
906 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000907 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000908 let Inst{19-16} = 0b1111;
909 let Inst{15-12} = Rd;
910 let Inst{11-8} = 0b1111;
911 let Inst{7-4} = opc7_4;
912 let Inst{3-0} = Rm;
913}
914
Bob Wilsone8a549c2012-09-29 21:43:49 +0000915// Division instructions.
916class ADivA1I<bits<3> opcod, dag oops, dag iops,
917 InstrItinClass itin, string opc, string asm, list<dag> pattern>
918 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
919 opc, asm, "", pattern> {
920 bits<4> Rd;
921 bits<4> Rn;
922 bits<4> Rm;
923 let Inst{27-23} = 0b01110;
924 let Inst{22-20} = opcod;
925 let Inst{19-16} = Rd;
926 let Inst{15-12} = 0b1111;
927 let Inst{11-8} = Rm;
928 let Inst{7-4} = 0b0001;
929 let Inst{3-0} = Rn;
930}
931
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000932// PKH instructions
Jim Grosbach3a3d8e82011-11-12 00:58:43 +0000933def PKHLSLAsmOperand : ImmAsmOperand {
Jim Grosbach27c1e252011-07-21 17:23:04 +0000934 let Name = "PKHLSLImm";
935 let ParserMethod = "parsePKHLSLImm";
936}
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000937def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
938 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000939 let ParserMatchClass = PKHLSLAsmOperand;
940}
941def PKHASRAsmOperand : AsmOperandClass {
942 let Name = "PKHASRImm";
943 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000944}
945def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
946 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +0000947 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +0000948}
Jim Grosbach94df3be2011-07-20 20:49:03 +0000949
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000950class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
951 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000952 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000953 opc, asm, "", pattern> {
954 bits<4> Rd;
955 bits<4> Rn;
956 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000957 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000958 let Inst{27-20} = opcod;
959 let Inst{19-16} = Rn;
960 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +0000961 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +0000962 let Inst{6} = tb;
963 let Inst{5-4} = 0b01;
964 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +0000965}
966
Evan Cheng2d37f192008-08-28 23:39:26 +0000967//===----------------------------------------------------------------------===//
968
969// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
970class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
971 list<Predicate> Predicates = [IsARM];
972}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +0000973class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
974 list<Predicate> Predicates = [IsARM, HasV5T];
975}
Evan Cheng2d37f192008-08-28 23:39:26 +0000976class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
977 list<Predicate> Predicates = [IsARM, HasV5TE];
978}
Bob Wilsone8a549c2012-09-29 21:43:49 +0000979// ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
980class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
981 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
982}
Evan Cheng2d37f192008-08-28 23:39:26 +0000983class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
984 list<Predicate> Predicates = [IsARM, HasV6];
985}
James Molloyfa041152015-03-23 16:15:16 +0000986class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
987 list<Predicate> Predicates = [HasVFP2];
988}
989class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
990 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
991}
Evan Chengee98fa92008-08-29 06:41:12 +0000992//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +0000993// Thumb Instruction Format Definitions.
994//
995
Owen Anderson651b2302011-07-13 23:22:26 +0000996class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000997 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +0000998 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +0000999 let OutOperandList = oops;
1000 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001001 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +00001002 let Pattern = pattern;
1003 list<Predicate> Predicates = [IsThumb];
1004}
1005
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001006// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +00001007class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001008 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001009
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001010// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001011class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1012 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001013 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +00001014 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001015
Johnny Chenc28e6292009-12-15 17:24:14 +00001016// tBL, tBX 32-bit instructions
1017class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001018 dag oops, dag iops, InstrItinClass itin, string asm,
1019 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001020 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001021 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +00001022 let Inst{31-27} = opcod1;
1023 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001024 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +00001025}
Evan Chengee98fa92008-08-29 06:41:12 +00001026
1027// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001028class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1029 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001030 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001031
Evan Chengbec1dba892009-06-23 19:38:13 +00001032// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +00001033class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001034 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001035 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001036 let OutOperandList = oops;
1037 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001038 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +00001039 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001040 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +00001041}
1042
David Goodwinb062c232009-08-06 16:52:47 +00001043class T1I<dag oops, dag iops, InstrItinClass itin,
1044 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001045 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001046class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1047 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001048 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001049
1050// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001051class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001052 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001053 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001054 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001055
1056// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +00001057class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001058 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001059 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001060 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001061 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1062 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001063 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001064 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +00001065 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001066 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +00001067 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +00001068}
1069
David Goodwinb062c232009-08-06 16:52:47 +00001070class T1sI<dag oops, dag iops, InstrItinClass itin,
1071 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001072 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001073
1074// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001075class T1sIt<dag oops, dag iops, InstrItinClass itin,
1076 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001077 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +00001078 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001079
1080// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +00001081class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001082 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001083 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001084 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001085 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001086 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001087 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001088 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001089 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +00001090}
1091
David Goodwinb062c232009-08-06 16:52:47 +00001092class T1pI<dag oops, dag iops, InstrItinClass itin,
1093 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001094 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001095
1096// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001097class T1pIt<dag oops, dag iops, InstrItinClass itin,
1098 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001099 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +00001100 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001101
Bob Wilson3968c6a2010-03-23 17:23:59 +00001102class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001103 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001104 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001105
Johnny Chen466231a2009-12-16 02:32:54 +00001106class Encoding16 : Encoding {
1107 let Inst{31-16} = 0x0000;
1108}
1109
Johnny Chenc28e6292009-12-15 17:24:14 +00001110// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +00001111class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001112 let Inst{15-10} = opcode;
1113}
1114
1115// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001116class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001117 let Inst{15-14} = 0b00;
1118 let Inst{13-9} = opcode;
1119}
1120
1121// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001122class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001123 let Inst{15-10} = 0b010000;
1124 let Inst{9-6} = opcode;
1125}
1126
1127// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001128class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001129 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001130 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001131}
1132
1133// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001134class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001135 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001136 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001137}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001138class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001139
Eric Christopher9b67db82011-05-27 03:50:53 +00001140class T1BranchCond<bits<4> opcode> : Encoding16 {
1141 let Inst{15-12} = opcode;
1142}
1143
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001144// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001145// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001146//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001147// 0b0110 => Immediate, 4 bytes
1148// 0b1000 => Immediate, 2 bytes
1149// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001150class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1151 InstrItinClass itin, string opc, string asm,
1152 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001153 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001154 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001155 bits<3> Rt;
1156 bits<8> addr;
1157 let Inst{8-6} = addr{5-3}; // Rm
1158 let Inst{5-3} = addr{2-0}; // Rn
1159 let Inst{2-0} = Rt;
1160}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001161class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1162 InstrItinClass itin, string opc, string asm,
1163 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001164 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001165 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001166 bits<3> Rt;
1167 bits<8> addr;
1168 let Inst{10-6} = addr{7-3}; // imm5
1169 let Inst{5-3} = addr{2-0}; // Rn
1170 let Inst{2-0} = Rt;
1171}
1172
Johnny Chenc28e6292009-12-15 17:24:14 +00001173// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001174class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001175 let Inst{15-12} = 0b1011;
1176 let Inst{11-5} = opcode;
1177}
1178
Evan Chengd76f0be2009-06-25 02:08:06 +00001179// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001180class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001181 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001182 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001183 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001184 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001185 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001186 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001187 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001188 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001189 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001190}
1191
Bill Wendlingb70dc872010-08-31 07:50:46 +00001192// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1193// input operand since by default it's a zero register. It will become an
1194// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001195//
Evan Chengd76f0be2009-06-25 02:08:06 +00001196// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1197// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001198class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001199 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001200 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001201 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001202 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1203 let Inst{20} = s;
1204
Evan Chengd76f0be2009-06-25 02:08:06 +00001205 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001206 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001207 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001208 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001209 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001210 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001211}
1212
1213// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001214class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001215 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001216 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001217 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001218 let OutOperandList = oops;
1219 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001220 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001221 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001222 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001223 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001224}
1225
Owen Anderson651b2302011-07-13 23:22:26 +00001226class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001227 InstrItinClass itin,
1228 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001229 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1230 let OutOperandList = oops;
1231 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001232 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001233 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001234 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001235 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001236}
1237
David Goodwinb062c232009-08-06 16:52:47 +00001238class T2I<dag oops, dag iops, InstrItinClass itin,
1239 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001240 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001241class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1242 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001243 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001244class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1245 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001246 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001247class T2Iso<dag oops, dag iops, InstrItinClass itin,
1248 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001249 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001250class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1251 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001252 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001253class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001254 string opc, string asm, string cstr, list<dag> pattern>
1255 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001256 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001257 bits<4> Rt;
1258 bits<4> Rt2;
1259 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001260 let Inst{31-25} = 0b1110100;
1261 let Inst{24} = P;
1262 let Inst{23} = addr{8};
1263 let Inst{22} = 1;
1264 let Inst{21} = W;
1265 let Inst{20} = isLoad;
1266 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001267 let Inst{15-12} = Rt{3-0};
1268 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001269 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001270}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001271class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1272 InstrItinClass itin, string opc, string asm, string cstr,
1273 list<dag> pattern>
1274 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001275 pattern> {
1276 bits<4> Rt;
1277 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001278 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001279 bits<9> imm;
1280 let Inst{31-25} = 0b1110100;
1281 let Inst{24} = P;
1282 let Inst{23} = imm{8};
1283 let Inst{22} = 1;
1284 let Inst{21} = W;
1285 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001286 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001287 let Inst{15-12} = Rt{3-0};
1288 let Inst{11-8} = Rt2{3-0};
1289 let Inst{7-0} = imm{7-0};
1290}
1291
David Goodwinb062c232009-08-06 16:52:47 +00001292class T2sI<dag oops, dag iops, InstrItinClass itin,
1293 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001294 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001295
David Goodwinb062c232009-08-06 16:52:47 +00001296class T2XI<dag oops, dag iops, InstrItinClass itin,
1297 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001298 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001299class T2JTI<dag oops, dag iops, InstrItinClass itin,
1300 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001301 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001302
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001303// Move to/from coprocessor instructions
Tim Northover2c45a382013-06-26 16:52:40 +00001304class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1305 list<dag> pattern>
1306 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001307 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001308}
1309
Bob Wilson947f04b2010-03-13 01:08:20 +00001310// Two-address instructions
1311class T2XIt<dag oops, dag iops, InstrItinClass itin,
1312 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001313 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001314
Jim Grosbachc086f682011-09-08 00:39:19 +00001315// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1316class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001317 dag oops, dag iops,
1318 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001319 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001320 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001321 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001322 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001323 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001324 let Pattern = pattern;
1325 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001326 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001327
1328 bits<4> Rt;
1329 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001330 let Inst{31-27} = 0b11111;
1331 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001332 let Inst{24} = signed;
1333 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001334 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001335 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001336 let Inst{19-16} = addr{12-9};
1337 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001338 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001339 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001340 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001341 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001342 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001343 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001344
1345 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001346}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001347
Jim Grosbachc086f682011-09-08 00:39:19 +00001348// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1349class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1350 dag oops, dag iops,
1351 AddrMode am, IndexMode im, InstrItinClass itin,
1352 string opc, string asm, string cstr, list<dag> pattern>
1353 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1354 let OutOperandList = oops;
1355 let InOperandList = !con(iops, (ins pred:$p));
1356 let AsmString = !strconcat(opc, "${p}", asm);
1357 let Pattern = pattern;
1358 list<Predicate> Predicates = [IsThumb2];
1359 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001360
Owen Andersone22c7322010-11-30 00:14:31 +00001361 bits<4> Rt;
1362 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001363 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001364 let Inst{31-27} = 0b11111;
1365 let Inst{26-25} = 0b00;
1366 let Inst{24} = signed;
1367 let Inst{23} = 0;
1368 let Inst{22-21} = opcod;
1369 let Inst{20} = load;
1370 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001371 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001372 let Inst{11} = 1;
1373 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1374 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001375 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001376 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001377 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001378
1379 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001380}
1381
David Goodwine5b969f2009-07-27 19:59:26 +00001382// Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1383class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001384 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
David Goodwine5b969f2009-07-27 19:59:26 +00001385}
1386
1387// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1388class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001389 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001390}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001391
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001392// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1393class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1394 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1395}
1396
Evan Chengeab9ca72009-06-27 02:26:13 +00001397// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1398class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001399 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001400}
1401
Evan Chengee98fa92008-08-29 06:41:12 +00001402//===----------------------------------------------------------------------===//
1403
Evan Chengac2af2f2008-11-11 02:11:05 +00001404//===----------------------------------------------------------------------===//
1405// ARM VFP Instruction templates.
1406//
1407
David Goodwin81cdd212009-07-10 17:03:29 +00001408// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001409class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001410 IndexMode im, Format f, InstrItinClass itin,
1411 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001412 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001413 bits<4> p;
1414 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001415 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001416 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001417 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001418 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001419 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001420 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001421 list<Predicate> Predicates = [HasVFP2];
1422}
1423
1424// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001425class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001426 IndexMode im, Format f, InstrItinClass itin,
1427 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001428 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001429 bits<4> p;
1430 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001431 let OutOperandList = oops;
1432 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001433 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001434 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001435 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001436 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001437 list<Predicate> Predicates = [HasVFP2];
1438}
1439
David Goodwinb062c232009-08-06 16:52:47 +00001440class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1441 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001442 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001443 opc, asm, "", pattern> {
1444 let PostEncoderMethod = "VFPThumb2PostEncoder";
1445}
David Goodwin81cdd212009-07-10 17:03:29 +00001446
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001447// ARM VFP addrmode5 loads and stores
1448class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001449 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001450 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001451 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001452 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001453 // Instruction operands.
1454 bits<5> Dd;
1455 bits<13> addr;
1456
1457 // Encode instruction operands.
1458 let Inst{23} = addr{8}; // U (add = (U == '1'))
1459 let Inst{22} = Dd{4};
1460 let Inst{19-16} = addr{12-9}; // Rn
1461 let Inst{15-12} = Dd{3-0};
1462 let Inst{7-0} = addr{7-0}; // imm8
1463
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001464 let Inst{27-24} = opcod1;
1465 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001466 let Inst{11-9} = 0b101;
1467 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001468
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001469 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001470 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001471}
1472
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001473class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001474 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001475 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001476 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001477 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001478 // Instruction operands.
1479 bits<5> Sd;
1480 bits<13> addr;
1481
1482 // Encode instruction operands.
1483 let Inst{23} = addr{8}; // U (add = (U == '1'))
1484 let Inst{22} = Sd{0};
1485 let Inst{19-16} = addr{12-9}; // Rn
1486 let Inst{15-12} = Sd{4-1};
1487 let Inst{7-0} = addr{7-0}; // imm8
1488
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001489 let Inst{27-24} = opcod1;
1490 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001491 let Inst{11-9} = 0b101;
1492 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001493
1494 // Loads & stores operate on both NEON and VFP pipelines.
1495 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001496}
1497
Bob Wilson6b853c32010-09-16 00:31:02 +00001498// VFP Load / store multiple pseudo instructions.
1499class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1500 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001501 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001502 cstr, itin> {
1503 let OutOperandList = oops;
1504 let InOperandList = !con(iops, (ins pred:$p));
1505 let Pattern = pattern;
1506 list<Predicate> Predicates = [HasVFP2];
1507}
1508
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001509// Load / store multiple
Tim Northover4173e292013-05-31 15:55:51 +00001510
1511// Unknown precision
1512class AXXI4<dag oops, dag iops, IndexMode im,
1513 string asm, string cstr, list<dag> pattern>
1514 : VFPXI<oops, iops, AddrMode4, 4, im,
1515 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1516 // Instruction operands.
1517 bits<4> Rn;
1518 bits<13> regs;
1519
1520 // Encode instruction operands.
1521 let Inst{19-16} = Rn;
1522 let Inst{22} = 0;
1523 let Inst{15-12} = regs{11-8};
1524 let Inst{7-1} = regs{7-1};
1525
1526 let Inst{27-25} = 0b110;
1527 let Inst{11-8} = 0b1011;
1528 let Inst{0} = 1;
1529}
1530
1531// Double precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001532class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001533 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001534 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001535 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001536 // Instruction operands.
1537 bits<4> Rn;
1538 bits<13> regs;
1539
1540 // Encode instruction operands.
1541 let Inst{19-16} = Rn;
1542 let Inst{22} = regs{12};
1543 let Inst{15-12} = regs{11-8};
Tim Northover4173e292013-05-31 15:55:51 +00001544 let Inst{7-1} = regs{7-1};
Bill Wendling345b48f2010-11-17 00:45:23 +00001545
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001546 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001547 let Inst{11-9} = 0b101;
1548 let Inst{8} = 1; // Double precision
Tim Northover4173e292013-05-31 15:55:51 +00001549 let Inst{0} = 0;
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001550}
1551
Tim Northover4173e292013-05-31 15:55:51 +00001552// Single Precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001553class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001554 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001555 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001556 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001557 // Instruction operands.
1558 bits<4> Rn;
1559 bits<13> regs;
1560
1561 // Encode instruction operands.
1562 let Inst{19-16} = Rn;
1563 let Inst{22} = regs{8};
1564 let Inst{15-12} = regs{12-9};
1565 let Inst{7-0} = regs{7-0};
1566
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001567 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001568 let Inst{11-9} = 0b101;
1569 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001570}
1571
Evan Chengac2af2f2008-11-11 02:11:05 +00001572// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001573class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1574 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1575 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001576 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001577 // Instruction operands.
1578 bits<5> Dd;
1579 bits<5> Dm;
1580
1581 // Encode instruction operands.
1582 let Inst{3-0} = Dm{3-0};
1583 let Inst{5} = Dm{4};
1584 let Inst{15-12} = Dd{3-0};
1585 let Inst{22} = Dd{4};
1586
Johnny Chen34a6afc2010-01-29 23:21:10 +00001587 let Inst{27-23} = opcod1;
1588 let Inst{21-20} = opcod2;
1589 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001590 let Inst{11-9} = 0b101;
1591 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001592 let Inst{7-6} = opcod4;
1593 let Inst{4} = opcod5;
Tim Northover5620faf2013-10-24 15:49:39 +00001594
1595 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001596}
1597
Joey Gouly0f12aa22013-07-09 11:26:18 +00001598// Double precision, unary, not-predicated
1599class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1600 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1601 string asm, list<dag> pattern>
1602 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1603 // Instruction operands.
1604 bits<5> Dd;
1605 bits<5> Dm;
1606
1607 let Inst{31-28} = 0b1111;
1608
1609 // Encode instruction operands.
1610 let Inst{3-0} = Dm{3-0};
1611 let Inst{5} = Dm{4};
1612 let Inst{15-12} = Dd{3-0};
1613 let Inst{22} = Dd{4};
1614
1615 let Inst{27-23} = opcod1;
1616 let Inst{21-20} = opcod2;
1617 let Inst{19-16} = opcod3;
1618 let Inst{11-9} = 0b101;
1619 let Inst{8} = 1; // Double precision
1620 let Inst{7-6} = opcod4;
1621 let Inst{4} = opcod5;
1622}
1623
Evan Chengac2af2f2008-11-11 02:11:05 +00001624// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001625class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001626 dag iops, InstrItinClass itin, string opc, string asm,
1627 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001628 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001629 // Instruction operands.
1630 bits<5> Dd;
1631 bits<5> Dn;
1632 bits<5> Dm;
1633
1634 // Encode instruction operands.
1635 let Inst{3-0} = Dm{3-0};
1636 let Inst{5} = Dm{4};
1637 let Inst{19-16} = Dn{3-0};
1638 let Inst{7} = Dn{4};
1639 let Inst{15-12} = Dd{3-0};
1640 let Inst{22} = Dd{4};
1641
Johnny Chen34a6afc2010-01-29 23:21:10 +00001642 let Inst{27-23} = opcod1;
1643 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001644 let Inst{11-9} = 0b101;
1645 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001646 let Inst{6} = op6;
1647 let Inst{4} = op4;
Tim Northover5620faf2013-10-24 15:49:39 +00001648
1649 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001650}
1651
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001652// FP, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001653class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001654 InstrItinClass itin, string asm, list<dag> pattern>
Joey Gouly2d0175e2013-07-09 09:59:04 +00001655 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1656 asm, "", pattern>
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001657{
1658 // Instruction operands.
1659 bits<5> Dd;
1660 bits<5> Dn;
1661 bits<5> Dm;
1662
1663 let Inst{31-28} = 0b1111;
1664
1665 // Encode instruction operands.
1666 let Inst{3-0} = Dm{3-0};
1667 let Inst{5} = Dm{4};
1668 let Inst{19-16} = Dn{3-0};
1669 let Inst{7} = Dn{4};
1670 let Inst{15-12} = Dd{3-0};
1671 let Inst{22} = Dd{4};
1672
1673 let Inst{27-23} = opcod1;
1674 let Inst{21-20} = opcod2;
1675 let Inst{11-9} = 0b101;
1676 let Inst{8} = 1; // double precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001677 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001678 let Inst{4} = 0;
Tim Northover5620faf2013-10-24 15:49:39 +00001679
1680 let Predicates = [HasVFP2, HasDPVFP];
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001681}
1682
Joey Gouly2d0175e2013-07-09 09:59:04 +00001683// Single precision, unary, predicated
Johnny Chen34a6afc2010-01-29 23:21:10 +00001684class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1685 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1686 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001687 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001688 // Instruction operands.
1689 bits<5> Sd;
1690 bits<5> Sm;
1691
1692 // Encode instruction operands.
1693 let Inst{3-0} = Sm{4-1};
1694 let Inst{5} = Sm{0};
1695 let Inst{15-12} = Sd{4-1};
1696 let Inst{22} = Sd{0};
1697
Johnny Chen34a6afc2010-01-29 23:21:10 +00001698 let Inst{27-23} = opcod1;
1699 let Inst{21-20} = opcod2;
1700 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001701 let Inst{11-9} = 0b101;
1702 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001703 let Inst{7-6} = opcod4;
1704 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001705}
1706
Joey Gouly2d0175e2013-07-09 09:59:04 +00001707// Single precision, unary, non-predicated
1708class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1709 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1710 string asm, list<dag> pattern>
1711 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1712 VFPUnaryFrm, itin, asm, "", pattern> {
1713 // Instruction operands.
1714 bits<5> Sd;
1715 bits<5> Sm;
1716
1717 let Inst{31-28} = 0b1111;
1718
1719 // Encode instruction operands.
1720 let Inst{3-0} = Sm{4-1};
1721 let Inst{5} = Sm{0};
1722 let Inst{15-12} = Sd{4-1};
1723 let Inst{22} = Sd{0};
1724
1725 let Inst{27-23} = opcod1;
1726 let Inst{21-20} = opcod2;
1727 let Inst{19-16} = opcod3;
1728 let Inst{11-9} = 0b101;
1729 let Inst{8} = 0; // Single precision
1730 let Inst{7-6} = opcod4;
1731 let Inst{4} = opcod5;
1732}
1733
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001734// Single precision unary, if no NEON. Same as ASuI except not available if
1735// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001736class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1737 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1738 string asm, list<dag> pattern>
1739 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1740 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001741 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1742}
1743
Evan Chengac2af2f2008-11-11 02:11:05 +00001744// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001745class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1746 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001747 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001748 // Instruction operands.
1749 bits<5> Sd;
1750 bits<5> Sn;
1751 bits<5> Sm;
1752
1753 // Encode instruction operands.
1754 let Inst{3-0} = Sm{4-1};
1755 let Inst{5} = Sm{0};
1756 let Inst{19-16} = Sn{4-1};
1757 let Inst{7} = Sn{0};
1758 let Inst{15-12} = Sd{4-1};
1759 let Inst{22} = Sd{0};
1760
Johnny Chen34a6afc2010-01-29 23:21:10 +00001761 let Inst{27-23} = opcod1;
1762 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001763 let Inst{11-9} = 0b101;
1764 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001765 let Inst{6} = op6;
1766 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001767}
1768
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001769// Single precision, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001770class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001771 InstrItinClass itin, string asm, list<dag> pattern>
1772 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1773 VFPBinaryFrm, itin, asm, "", pattern>
1774{
1775 // Instruction operands.
1776 bits<5> Sd;
1777 bits<5> Sn;
1778 bits<5> Sm;
1779
1780 let Inst{31-28} = 0b1111;
1781
1782 // Encode instruction operands.
1783 let Inst{3-0} = Sm{4-1};
1784 let Inst{5} = Sm{0};
1785 let Inst{19-16} = Sn{4-1};
1786 let Inst{7} = Sn{0};
1787 let Inst{15-12} = Sd{4-1};
1788 let Inst{22} = Sd{0};
1789
1790 let Inst{27-23} = opcod1;
1791 let Inst{21-20} = opcod2;
1792 let Inst{11-9} = 0b101;
1793 let Inst{8} = 0; // Single precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001794 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001795 let Inst{4} = 0;
1796}
1797
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001798// Single precision binary, if no NEON. Same as ASbI except not available if
1799// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001800class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001801 dag iops, InstrItinClass itin, string opc, string asm,
1802 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001803 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001804 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001805
1806 // Instruction operands.
1807 bits<5> Sd;
1808 bits<5> Sn;
1809 bits<5> Sm;
1810
1811 // Encode instruction operands.
1812 let Inst{3-0} = Sm{4-1};
1813 let Inst{5} = Sm{0};
1814 let Inst{19-16} = Sn{4-1};
1815 let Inst{7} = Sn{0};
1816 let Inst{15-12} = Sd{4-1};
1817 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001818}
1819
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001820// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00001821class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1822 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1823 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001824 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00001825 let Inst{27-23} = opcod1;
1826 let Inst{21-20} = opcod2;
1827 let Inst{19-16} = opcod3;
1828 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001829 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00001830 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001831}
1832
Johnny Chen39640592010-02-11 18:47:03 +00001833// VFP conversion between floating-point and fixed-point
1834class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001835 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1836 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00001837 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
Jim Grosbachf0d25112011-12-22 19:55:21 +00001838 bits<5> fbits;
Johnny Chen39640592010-02-11 18:47:03 +00001839 // size (fixed-point number): sx == 0 ? 16 : 32
1840 let Inst{7} = op5; // sx
Jim Grosbachf0d25112011-12-22 19:55:21 +00001841 let Inst{5} = fbits{0};
1842 let Inst{3-0} = fbits{4-1};
Johnny Chen39640592010-02-11 18:47:03 +00001843}
1844
David Goodwin85b5b022009-08-10 22:17:39 +00001845// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00001846class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00001847 dag oops, dag iops, InstrItinClass itin,
1848 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001849 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1850 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00001851 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1852}
1853
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001854class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00001855 InstrItinClass itin,
1856 string opc, string asm, list<dag> pattern>
1857 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001858 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00001859 let Inst{11-8} = opcod2;
1860 let Inst{4} = 1;
1861}
1862
David Goodwinb062c232009-08-06 16:52:47 +00001863class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1864 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1865 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00001866
Bob Wilson3968c6a2010-03-23 17:23:59 +00001867class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001868 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1869 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001870
David Goodwinb062c232009-08-06 16:52:47 +00001871class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1872 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1873 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00001874
David Goodwinb062c232009-08-06 16:52:47 +00001875class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1876 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1877 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00001878
Evan Chengac2af2f2008-11-11 02:11:05 +00001879//===----------------------------------------------------------------------===//
1880
Bob Wilson2e076c42009-06-22 23:27:02 +00001881//===----------------------------------------------------------------------===//
1882// ARM NEON Instruction templates.
1883//
Evan Chengee98fa92008-08-29 06:41:12 +00001884
Johnny Chenf833fad2010-03-20 00:17:00 +00001885class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1886 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1887 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001888 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001889 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001890 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001891 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00001892 let Pattern = pattern;
1893 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001894 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00001895}
1896
1897// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00001898class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1899 InstrItinClass itin, string opc, string asm, string cstr,
1900 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001901 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001902 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001903 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001904 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00001905 let Pattern = pattern;
1906 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00001907 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00001908}
1909
Joey Goulydf686002013-07-17 13:59:38 +00001910// Same as NeonI except it is not predicated
1911class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1912 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1913 list<dag> pattern>
1914 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1915 let OutOperandList = oops;
1916 let InOperandList = iops;
1917 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
1918 let Pattern = pattern;
1919 list<Predicate> Predicates = [HasNEON];
1920 let DecoderNamespace = "NEON";
1921
1922 let Inst{31-28} = 0b1111;
1923}
1924
Bob Wilson50820a22009-10-07 21:53:04 +00001925class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1926 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001927 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00001928 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1929 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001930 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001931 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00001932 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001933 let Inst{11-8} = op11_8;
1934 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00001935
Chris Lattner63274cb2010-11-15 05:19:05 +00001936 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00001937 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00001938
Owen Andersonad402342010-11-02 00:05:05 +00001939 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001940 bits<6> Rn;
1941 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00001942
Owen Andersonad402342010-11-02 00:05:05 +00001943 let Inst{22} = Vd{4};
1944 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00001945 let Inst{19-16} = Rn{3-0};
1946 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00001947}
1948
Owen Anderson9f20daf2010-11-02 20:47:39 +00001949class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1950 dag oops, dag iops, InstrItinClass itin,
1951 string opc, string dt, string asm, string cstr, list<dag> pattern>
1952 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1953 dt, asm, cstr, pattern> {
1954 bits<3> lane;
1955}
1956
Bob Wilson9392b0e2010-08-25 23:27:42 +00001957class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00001958 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00001959 itin> {
1960 let OutOperandList = oops;
1961 let InOperandList = !con(iops, (ins pred:$p));
1962 list<Predicate> Predicates = [HasNEON];
1963}
1964
Jim Grosbach233b3a22010-10-06 20:36:55 +00001965class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1966 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001967 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001968 itin> {
1969 let OutOperandList = oops;
1970 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00001971 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00001972 list<Predicate> Predicates = [HasNEON];
1973}
1974
Johnny Chenac5024b2010-03-23 16:43:47 +00001975class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00001976 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00001977 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1978 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00001979 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00001980 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001981 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00001982}
1983
Johnny Chen020023a2010-03-23 20:40:44 +00001984class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001985 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00001986 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001987 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00001988 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00001989 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00001990 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00001991}
1992
1993// NEON "one register and a modified immediate" format.
1994class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1995 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00001996 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001997 string opc, string dt, string asm, string cstr,
1998 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00001999 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002000 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002001 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002002 let Inst{11-8} = op11_8;
2003 let Inst{7} = op7;
2004 let Inst{6} = op6;
2005 let Inst{5} = op5;
2006 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002007
Owen Anderson284cb362010-10-26 17:40:54 +00002008 // Instruction operands.
2009 bits<5> Vd;
2010 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00002011
Owen Anderson284cb362010-10-26 17:40:54 +00002012 let Inst{15-12} = Vd{3-0};
2013 let Inst{22} = Vd{4};
2014 let Inst{24} = SIMM{7};
2015 let Inst{18-16} = SIMM{6-4};
2016 let Inst{3-0} = SIMM{3-0};
Owen Andersone0152a72011-08-09 20:55:18 +00002017 let DecoderMethod = "DecodeNEONModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00002018}
2019
2020// NEON 2 vector register format.
2021class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2022 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00002023 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002024 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002025 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002026 let Inst{24-23} = op24_23;
2027 let Inst{21-20} = op21_20;
2028 let Inst{19-18} = op19_18;
2029 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002030 let Inst{11-7} = op11_7;
2031 let Inst{6} = op6;
2032 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002033
Owen Anderson24774462010-10-25 18:43:52 +00002034 // Instruction operands.
2035 bits<5> Vd;
2036 bits<5> Vm;
2037
2038 let Inst{15-12} = Vd{3-0};
2039 let Inst{22} = Vd{4};
2040 let Inst{3-0} = Vm{3-0};
2041 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002042}
2043
Joey Gouly943dd592013-07-18 11:53:22 +00002044// Same as N2V but not predicated.
Amara Emerson33089092013-09-19 11:59:01 +00002045class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
Joey Gouly943dd592013-07-18 11:53:22 +00002046 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
Tim Northover6ad1f5c2014-04-28 13:53:00 +00002047 string Dt, list<dag> pattern>
Joey Gouly943dd592013-07-18 11:53:22 +00002048 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2049 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2050 bits<5> Vd;
2051 bits<5> Vm;
2052
2053 // Encode instruction operands
2054 let Inst{22} = Vd{4};
2055 let Inst{15-12} = Vd{3-0};
2056 let Inst{5} = Vm{4};
2057 let Inst{3-0} = Vm{3-0};
2058
2059 // Encode constant bits
2060 let Inst{27-23} = 0b00111;
2061 let Inst{21-20} = 0b11;
Amara Emerson33089092013-09-19 11:59:01 +00002062 let Inst{19-18} = op19_18;
Joey Gouly943dd592013-07-18 11:53:22 +00002063 let Inst{17-16} = op17_16;
2064 let Inst{11} = 0;
2065 let Inst{10-8} = op10_8;
2066 let Inst{7} = op7;
2067 let Inst{6} = op6;
2068 let Inst{4} = 0;
2069
2070 let DecoderNamespace = "NEON";
2071}
2072
Evan Cheng738a97a2009-11-23 21:57:23 +00002073// Same as N2V except it doesn't have a datatype suffix.
2074class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002075 bits<5> op11_7, bit op6, bit op4,
2076 dag oops, dag iops, InstrItinClass itin,
2077 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002078 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002079 let Inst{24-23} = op24_23;
2080 let Inst{21-20} = op21_20;
2081 let Inst{19-18} = op19_18;
2082 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002083 let Inst{11-7} = op11_7;
2084 let Inst{6} = op6;
2085 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002086
Owen Anderson24774462010-10-25 18:43:52 +00002087 // Instruction operands.
2088 bits<5> Vd;
2089 bits<5> Vm;
2090
2091 let Inst{15-12} = Vd{3-0};
2092 let Inst{22} = Vd{4};
2093 let Inst{3-0} = Vm{3-0};
2094 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002095}
2096
2097// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00002098class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00002099 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002100 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00002101 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002102 let Inst{24} = op24;
2103 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002104 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002105 let Inst{7} = op7;
2106 let Inst{6} = op6;
2107 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002108
Owen Anderson3665fee2010-10-26 20:56:57 +00002109 // Instruction operands.
2110 bits<5> Vd;
2111 bits<5> Vm;
2112 bits<6> SIMM;
2113
2114 let Inst{15-12} = Vd{3-0};
2115 let Inst{22} = Vd{4};
2116 let Inst{3-0} = Vm{3-0};
2117 let Inst{5} = Vm{4};
2118 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002119}
2120
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002121// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00002122
Jim Grosbacheca54e42011-05-19 17:34:53 +00002123class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2124 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2125 string opc, string dt, string asm, string cstr,
2126 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00002127 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002128 let Inst{24} = op24;
2129 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00002130 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002131 let Inst{11-8} = op11_8;
2132 let Inst{6} = op6;
2133 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00002134}
2135
2136class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2137 dag oops, dag iops, Format f, InstrItinClass itin,
2138 string opc, string dt, string asm, string cstr, list<dag> pattern>
2139 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2140 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Owen Anderson9e44cf22010-10-21 20:21:49 +00002141 // Instruction operands.
2142 bits<5> Vd;
2143 bits<5> Vn;
2144 bits<5> Vm;
2145
2146 let Inst{15-12} = Vd{3-0};
2147 let Inst{22} = Vd{4};
2148 let Inst{19-16} = Vn{3-0};
2149 let Inst{7} = Vn{4};
2150 let Inst{3-0} = Vm{3-0};
2151 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002152}
2153
Joey Goulydf686002013-07-17 13:59:38 +00002154class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2155 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
Tim Northover6ad1f5c2014-04-28 13:53:00 +00002156 string OpcodeStr, string Dt, list<dag> pattern>
Joey Goulydf686002013-07-17 13:59:38 +00002157 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2158 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2159 bits<5> Vd;
2160 bits<5> Vn;
2161 bits<5> Vm;
2162
2163 // Encode instruction operands
2164 let Inst{22} = Vd{4};
2165 let Inst{15-12} = Vd{3-0};
2166 let Inst{19-16} = Vn{3-0};
2167 let Inst{7} = Vn{4};
2168 let Inst{5} = Vm{4};
2169 let Inst{3-0} = Vm{3-0};
2170
2171 // Encode constant bits
2172 let Inst{27-23} = op27_23;
2173 let Inst{21-20} = op21_20;
2174 let Inst{11-8} = op11_8;
2175 let Inst{6} = op6;
2176 let Inst{4} = op4;
2177}
2178
Jim Grosbacheca54e42011-05-19 17:34:53 +00002179class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2180 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2181 string opc, string dt, string asm, string cstr,
2182 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002183 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2184 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2185
2186 // Instruction operands.
2187 bits<5> Vd;
2188 bits<5> Vn;
2189 bits<5> Vm;
2190 bit lane;
2191
2192 let Inst{15-12} = Vd{3-0};
2193 let Inst{22} = Vd{4};
2194 let Inst{19-16} = Vn{3-0};
2195 let Inst{7} = Vn{4};
2196 let Inst{3-0} = Vm{3-0};
2197 let Inst{5} = lane;
2198}
2199
Jim Grosbacheca54e42011-05-19 17:34:53 +00002200class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2201 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2202 string opc, string dt, string asm, string cstr,
2203 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002204 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2205 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2206
2207 // Instruction operands.
2208 bits<5> Vd;
2209 bits<5> Vn;
2210 bits<5> Vm;
2211 bits<2> lane;
2212
2213 let Inst{15-12} = Vd{3-0};
2214 let Inst{22} = Vd{4};
2215 let Inst{19-16} = Vn{3-0};
2216 let Inst{7} = Vn{4};
2217 let Inst{2-0} = Vm{2-0};
2218 let Inst{5} = lane{1};
2219 let Inst{3} = lane{0};
2220}
2221
Johnny Chen8a687232010-03-23 21:35:03 +00002222// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00002223class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2224 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002225 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002226 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002227 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002228 let Inst{24} = op24;
2229 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002230 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002231 let Inst{11-8} = op11_8;
2232 let Inst{6} = op6;
2233 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002234
Owen Andersondff239c2010-10-25 18:28:30 +00002235 // Instruction operands.
2236 bits<5> Vd;
2237 bits<5> Vn;
2238 bits<5> Vm;
2239
2240 let Inst{15-12} = Vd{3-0};
2241 let Inst{22} = Vd{4};
2242 let Inst{19-16} = Vn{3-0};
2243 let Inst{7} = Vn{4};
2244 let Inst{3-0} = Vm{3-0};
2245 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002246}
2247
2248// NEON VMOVs between scalar and core registers.
2249class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002250 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002251 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002252 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002253 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002254 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002255 let Inst{11-8} = opcod2;
2256 let Inst{6-5} = opcod3;
2257 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00002258 // A8.6.303, A8.6.328, A8.6.329
2259 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00002260
2261 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002262 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002263 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002264 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00002265 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00002266
Chris Lattner63274cb2010-11-15 05:19:05 +00002267 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002268 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00002269
Owen Andersoned9652f2010-10-27 21:28:09 +00002270 bits<5> V;
2271 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00002272 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00002273 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00002274
Owen Anderson40d24a42010-10-27 19:25:54 +00002275 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00002276 let Inst{7} = V{4};
2277 let Inst{19-16} = V{3-0};
2278 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002279}
2280class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002281 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002282 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002283 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002284 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002285class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002286 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002287 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002288 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002289 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002290class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002291 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002292 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002293 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002294 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00002295
Johnny Chen45ab3f32010-03-25 17:01:27 +00002296// Vector Duplicate Lane (from scalar to all elements)
2297class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2298 InstrItinClass itin, string opc, string dt, string asm,
2299 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00002300 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00002301 let Inst{24-23} = 0b11;
2302 let Inst{21-20} = 0b11;
2303 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002304 let Inst{11-7} = 0b11000;
2305 let Inst{6} = op6;
2306 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00002307
Owen Anderson40d24a42010-10-27 19:25:54 +00002308 bits<5> Vd;
2309 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002310
Owen Anderson40d24a42010-10-27 19:25:54 +00002311 let Inst{22} = Vd{4};
2312 let Inst{15-12} = Vd{3-0};
2313 let Inst{5} = Vm{4};
2314 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00002315}
2316
David Goodwin3b9c52c2009-08-04 17:53:06 +00002317// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2318// for single-precision FP.
2319class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2320 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2321}
Jim Grosbach7996b152011-11-14 22:28:39 +00002322
2323// VFP/NEON Instruction aliases for type suffices.
2324class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
Jim Grosbachfdf9e152011-12-05 20:29:59 +00002325 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002326
Jim Grosbach3d6c0e02011-11-14 23:11:19 +00002327multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002328 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2329 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2330 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2331 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002332}
2333
Jim Grosbach681db342012-01-24 17:23:29 +00002334multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2335 let Predicates = [HasNEON] in {
2336 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2337 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2338 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2339 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2340}
2341}
2342
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002343// The same alias classes using AsmPseudo instead, for the more complex
2344// stuff in NEON that InstAlias can't quite handle.
2345// Note that we can't use anonymous defm references here like we can
2346// above, as we care about the ultimate instruction enum names generated, unlike
2347// for instalias defs.
2348class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002349 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbach585ce302011-12-07 01:17:58 +00002350
2351// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2352def : TokenAlias<".s8", ".i8">;
2353def : TokenAlias<".u8", ".i8">;
2354def : TokenAlias<".s16", ".i16">;
2355def : TokenAlias<".u16", ".i16">;
2356def : TokenAlias<".s32", ".i32">;
2357def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002358def : TokenAlias<".s64", ".i64">;
2359def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002360
2361def : TokenAlias<".i8", ".8">;
2362def : TokenAlias<".i16", ".16">;
2363def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002364def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002365
2366def : TokenAlias<".p8", ".8">;
2367def : TokenAlias<".p16", ".16">;
2368
2369def : TokenAlias<".f32", ".32">;
2370def : TokenAlias<".f64", ".64">;
2371def : TokenAlias<".f", ".f32">;
2372def : TokenAlias<".d", ".f64">;