blob: 1da32ad2af6ceeeac50dc5d37cd84d879d29e254 [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//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Bob Wilson3968c6a2010-03-23 17:23:59 +00006//
Evan Cheng2d37f192008-08-28 23:39:26 +00007//===----------------------------------------------------------------------===//
8
9//===----------------------------------------------------------------------===//
10//
11// ARM Instruction Format Definitions.
12//
13
14// Format specifies the encoding used by the instruction. This is part of the
15// ad-hoc solution used to emit machine instruction encodings by our machine
16// code emitter.
Bob Wilson69ba1bc2010-03-17 21:13:43 +000017class Format<bits<6> val> {
18 bits<6> Value = val;
Evan Cheng2d37f192008-08-28 23:39:26 +000019}
20
Evan Chengfabdcce2008-11-13 23:36:57 +000021def Pseudo : Format<0>;
22def MulFrm : Format<1>;
23def BrFrm : Format<2>;
24def BrMiscFrm : Format<3>;
Evan Cheng2d37f192008-08-28 23:39:26 +000025
Evan Chengfabdcce2008-11-13 23:36:57 +000026def DPFrm : Format<4>;
Owen Anderson04912702011-07-21 23:38:37 +000027def DPSoRegRegFrm : Format<5>;
Evan Cheng2d37f192008-08-28 23:39:26 +000028
Evan Chengfabdcce2008-11-13 23:36:57 +000029def LdFrm : Format<6>;
30def StFrm : Format<7>;
31def LdMiscFrm : Format<8>;
32def StMiscFrm : Format<9>;
33def LdStMulFrm : Format<10>;
Evan Cheng2d37f192008-08-28 23:39:26 +000034
Johnny Chen0dab68f2010-03-19 17:39:00 +000035def LdStExFrm : Format<11>;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +000036
Johnny Chen0dab68f2010-03-19 17:39:00 +000037def ArithMiscFrm : Format<12>;
Bob Wilson96649842010-08-11 00:01:18 +000038def SatFrm : Format<13>;
39def ExtFrm : Format<14>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000040
Bob Wilson96649842010-08-11 00:01:18 +000041def VFPUnaryFrm : Format<15>;
42def VFPBinaryFrm : Format<16>;
43def VFPConv1Frm : Format<17>;
44def VFPConv2Frm : Format<18>;
45def VFPConv3Frm : Format<19>;
46def VFPConv4Frm : Format<20>;
47def VFPConv5Frm : Format<21>;
48def VFPLdStFrm : Format<22>;
49def VFPLdStMulFrm : Format<23>;
50def VFPMiscFrm : Format<24>;
Evan Cheng8cbbcb12008-11-11 21:48:44 +000051
Bob Wilson96649842010-08-11 00:01:18 +000052def ThumbFrm : Format<25>;
53def MiscFrm : Format<26>;
Evan Cheng2d37f192008-08-28 23:39:26 +000054
Bob Wilson96649842010-08-11 00:01:18 +000055def NGetLnFrm : Format<27>;
56def NSetLnFrm : Format<28>;
57def NDupFrm : Format<29>;
58def NLdStFrm : Format<30>;
59def N1RegModImmFrm: Format<31>;
60def N2RegFrm : Format<32>;
61def NVCVTFrm : Format<33>;
62def NVDupLnFrm : Format<34>;
63def N2RegVShLFrm : Format<35>;
64def N2RegVShRFrm : Format<36>;
65def N3RegFrm : Format<37>;
66def N3RegVShFrm : Format<38>;
67def NVExtFrm : Format<39>;
68def NVMulSLFrm : Format<40>;
69def NVTBLFrm : Format<41>;
Owen Anderson04912702011-07-21 23:38:37 +000070def DPSoRegImmFrm : Format<42>;
Sam Parker963da5b2017-09-29 13:11:33 +000071def N3RegCplxFrm : Format<43>;
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>;
Sjoerd Meijer011de9c2018-01-26 09:26:40 +0000110def AddrMode5FP16 : AddrMode<17>;
Tim Northoverbb7d7b32018-09-07 09:21:25 +0000111def AddrModeT2_ldrex : AddrMode<18>;
Simon Tatham8c865ca2019-06-11 09:29:18 +0000112def AddrModeT2_i7s4 : AddrMode<19>;
Simon Tathame6824162019-06-25 11:24:18 +0000113def AddrModeT2_i7s2 : AddrMode<20>;
114def AddrModeT2_i7 : AddrMode<21>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000115
Evan Chengb23b50d2009-06-29 07:51:04 +0000116// Load / store index mode.
117class IndexMode<bits<2> val> {
118 bits<2> Value = val;
119}
120def IndexModeNone : IndexMode<0>;
121def IndexModePre : IndexMode<1>;
122def IndexModePost : IndexMode<2>;
Bob Wilsonf1e8f7f2010-03-13 07:34:35 +0000123def IndexModeUpd : IndexMode<3>;
Evan Chengb23b50d2009-06-29 07:51:04 +0000124
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000125// Instruction execution domain.
Sjoerd Meijer5857bf52019-05-30 08:07:06 +0000126class Domain<bits<4> val> {
127 bits<4> Value = val;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000128}
129def GenericDomain : Domain<0>;
130def VFPDomain : Domain<1>; // Instructions in VFP domain only
131def NeonDomain : Domain<2>; // Instructions in Neon domain only
132def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
Evan Cheng97e64282011-02-23 02:35:33 +0000133def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
Sjoerd Meijer5857bf52019-05-30 08:07:06 +0000134def MVEDomain : Domain<8>; // Instructions in MVE and ARMv8.1m
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000135
Evan Chengb23b50d2009-06-29 07:51:04 +0000136//===----------------------------------------------------------------------===//
Evan Chengcd4cdd12009-07-11 06:43:01 +0000137// ARM special operands.
138//
139
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000140// ARM imod and iflag operands, used only by the CPS instruction.
141def imod_op : Operand<i32> {
142 let PrintMethod = "printCPSIMod";
143}
144
Jim Grosbacheeaab222011-07-25 20:38:18 +0000145def ProcIFlagsOperand : AsmOperandClass {
146 let Name = "ProcIFlags";
147 let ParserMethod = "parseProcIFlagsOperand";
148}
Bruno Cardoso Lopes90d1dfe2011-02-14 13:09:44 +0000149def iflags_op : Operand<i32> {
150 let PrintMethod = "printCPSIFlag";
151 let ParserMatchClass = ProcIFlagsOperand;
152}
153
Evan Chengcd4cdd12009-07-11 06:43:01 +0000154// ARM Predicate operand. Default to 14 = always (AL). Second part is CC
155// register whose default is 0 (no register).
Jim Grosbacheeaab222011-07-25 20:38:18 +0000156def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
Jim Grosbachf86cd372011-08-19 20:46:54 +0000157def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
Evan Chengcd4cdd12009-07-11 06:43:01 +0000158 (ops (i32 14), (i32 zero_reg))> {
159 let PrintMethod = "printPredicateOperand";
Daniel Dunbard8042b72010-08-11 06:36:53 +0000160 let ParserMatchClass = CondCodeOperand;
Jim Grosbachdbb60f92011-08-19 20:30:19 +0000161 let DecoderMethod = "DecodePredicateOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000162}
163
Tim Northover42180442013-08-22 09:57:11 +0000164// Selectable predicate operand for CMOV instructions. We can't use a normal
165// predicate because the default values interfere with instruction selection. In
166// all other respects it is identical though: pseudo-instruction expansion
167// relies on the MachineOperands being compatible.
168def cmovpred : Operand<i32>, PredicateOp,
169 ComplexPattern<i32, 2, "SelectCMOVPred"> {
170 let MIOperandInfo = (ops i32imm, i32imm);
171 let PrintMethod = "printPredicateOperand";
172}
173
Evan Chengcd4cdd12009-07-11 06:43:01 +0000174// Conditional code result for instructions whose 's' bit is set, e.g. subs.
Jim Grosbacheeaab222011-07-25 20:38:18 +0000175def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
Evan Chengcd4cdd12009-07-11 06:43:01 +0000176def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000177 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000178 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000179 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000180 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000181}
182
183// Same as cc_out except it defaults to setting CPSR.
184def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
Chris Lattner63274cb2010-11-15 05:19:05 +0000185 let EncoderMethod = "getCCOutOpValue";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000186 let PrintMethod = "printSBitModifierOperand";
Jim Grosbach0bfb4d52010-12-06 18:21:12 +0000187 let ParserMatchClass = CCOutOperand;
Jim Grosbach9c920492011-08-19 19:41:46 +0000188 let DecoderMethod = "DecodeCCOutOperand";
Evan Chengcd4cdd12009-07-11 06:43:01 +0000189}
190
David Green57cc65ff2019-09-03 10:53:07 +0000191// Transform to generate the inverse of a condition code during ISel
192def inv_cond_XFORM : SDNodeXForm<imm, [{
193 ARMCC::CondCodes CC = static_cast<ARMCC::CondCodes>(N->getZExtValue());
194 return CurDAG->getTargetConstant(ARMCC::getOppositeCondition(CC), SDLoc(N),
195 MVT::i32);
196}]>;
197
Simon Tatham286e1d22019-06-13 13:11:13 +0000198// VPT predicate
199
200def VPTPredNOperand : AsmOperandClass {
201 let Name = "VPTPredN";
202 let PredicateMethod = "isVPTPred";
203}
204def VPTPredROperand : AsmOperandClass {
205 let Name = "VPTPredR";
206 let PredicateMethod = "isVPTPred";
207}
208def undef_tied_input;
209
210// Operand classes for the cluster of MC operands describing a
211// VPT-predicated MVE instruction.
212//
213// There are two of these classes. Both of them have the same first
214// two options:
215//
216// $cond (an integer) indicates the instruction's predication status:
217// * ARMVCC::None means it's unpredicated
218// * ARMVCC::Then means it's in a VPT block and appears with the T suffix
219// * ARMVCC::Else means it's in a VPT block and appears with the E suffix.
220// During code generation, unpredicated and predicated instructions
221// are indicated by setting this parameter to 'None' or to 'Then'; the
222// third value 'Else' is only used for assembly and disassembly.
223//
224// $cond_reg (type VCCR) gives the input predicate register. This is
225// always either zero_reg or VPR, but needs to be modelled as an
226// explicit operand so that it can be register-allocated and spilled
227// when these operands are used in code generation).
228//
229// For 'vpred_r', there's an extra operand $inactive, which specifies
230// the vector register which will supply any lanes of the output
231// register that the predication mask prevents from being written by
232// this instruction. It's always tied to the actual output register
233// (i.e. must be allocated into the same physical reg), but again,
234// code generation will need to model it as a separate input value.
235//
236// 'vpred_n' doesn't have that extra operand: it only has $cond and
237// $cond_reg. This variant is used for any instruction that can't, or
238// doesn't want to, tie $inactive to the output register. Sometimes
239// that's because another input parameter is already tied to it (e.g.
240// instructions that both read and write their Qd register even when
241// unpredicated, either because they only partially overwrite it like
242// a narrowing integer conversion, or simply because the instruction
243// encoding doesn't have enough register fields to make the output
244// independent of all inputs). It can also be because the instruction
245// is defined to set disabled output lanes to zero rather than leaving
246// them unchanged (vector loads), or because it doesn't output a
247// vector register at all (stores, compares). In any of these
248// situations it's unnecessary to have an extra operand tied to the
249// output, and inconvenient to leave it there unused.
250
251// Base class for both kinds of vpred.
252class vpred_ops<dag extra_op, dag extra_mi> : OperandWithDefaultOps<OtherVT,
253 !con((ops (i32 0), (i32 zero_reg)), extra_op)> {
254 let PrintMethod = "printVPTPredicateOperand";
255 let OperandNamespace = "ARM";
256 let MIOperandInfo = !con((ops i32imm:$cond, VCCR:$cond_reg), extra_mi);
257
258 // For convenience, we provide a string value that can be appended
259 // to the constraints string. It's empty for vpred_n, and for
260 // vpred_r it ties the $inactive operand to the output q-register
261 // (which by convention will be called $Qd).
262 string vpred_constraint;
263}
264
265def vpred_r : vpred_ops<(ops (v4i32 undef_tied_input)), (ops MQPR:$inactive)> {
266 let ParserMatchClass = VPTPredROperand;
267 let OperandType = "OPERAND_VPRED_R";
268 let DecoderMethod = "DecodeVpredROperand";
269 let vpred_constraint = ",$Qd = $vp.inactive";
270}
271
272def vpred_n : vpred_ops<(ops), (ops)> {
273 let ParserMatchClass = VPTPredNOperand;
274 let OperandType = "OPERAND_VPRED_N";
275 let vpred_constraint = "";
276}
277
Johnny Chen9a3e2392010-03-10 18:59:38 +0000278// ARM special operands for disassembly only.
279//
Sjoerd Meijer11794702017-04-03 14:50:04 +0000280def SetEndAsmOperand : ImmAsmOperand<0,1> {
Jim Grosbach0a547702011-07-22 17:44:50 +0000281 let Name = "SetEndImm";
282 let ParserMethod = "parseSetEndImm";
283}
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000284def setend_op : Operand<i32> {
285 let PrintMethod = "printSetendOperand";
Jim Grosbach0a547702011-07-22 17:44:50 +0000286 let ParserMatchClass = SetEndAsmOperand;
Jim Grosbach7e72ec62010-10-13 21:00:04 +0000287}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000288
Jim Grosbacheeaab222011-07-25 20:38:18 +0000289def MSRMaskOperand : AsmOperandClass {
290 let Name = "MSRMask";
291 let ParserMethod = "parseMSRMaskOperand";
292}
Johnny Chen9a3e2392010-03-10 18:59:38 +0000293def msr_mask : Operand<i32> {
294 let PrintMethod = "printMSRMaskOperand";
Owen Anderson60663402011-08-11 20:21:46 +0000295 let DecoderMethod = "DecodeMSRMask";
Bruno Cardoso Lopes9cd43972011-02-18 19:45:59 +0000296 let ParserMatchClass = MSRMaskOperand;
Johnny Chen9a3e2392010-03-10 18:59:38 +0000297}
298
Tim Northoveree843ef2014-08-15 10:47:12 +0000299def BankedRegOperand : AsmOperandClass {
300 let Name = "BankedReg";
301 let ParserMethod = "parseBankedRegOperand";
302}
303def banked_reg : Operand<i32> {
304 let PrintMethod = "printBankedRegOperand";
305 let DecoderMethod = "DecodeBankedReg";
306 let ParserMatchClass = BankedRegOperand;
307}
308
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000309// Shift Right Immediate - A shift right immediate is encoded differently from
310// other shift immediates. The imm6 field is encoded like so:
Bill Wendling3b1459b2011-03-01 01:00:59 +0000311//
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000312// Offset Encoding
313// 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
314// 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
315// 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
316// 64 64 - <imm> is encoded in imm6<5:0>
Sjoerd Meijer11794702017-04-03 14:50:04 +0000317def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000318def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000319 let EncoderMethod = "getShiftRight8Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000320 let DecoderMethod = "DecodeShiftRight8Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000321 let ParserMatchClass = shr_imm8_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000322}
Sjoerd Meijer11794702017-04-03 14:50:04 +0000323def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000324def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000325 let EncoderMethod = "getShiftRight16Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000326 let DecoderMethod = "DecodeShiftRight16Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000327 let ParserMatchClass = shr_imm16_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000328}
Sjoerd Meijer11794702017-04-03 14:50:04 +0000329def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000330def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000331 let EncoderMethod = "getShiftRight32Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000332 let DecoderMethod = "DecodeShiftRight32Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000333 let ParserMatchClass = shr_imm32_asm_operand;
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000334}
Sjoerd Meijer11794702017-04-03 14:50:04 +0000335def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
Tim Northover170daaf2014-02-10 14:04:07 +0000336def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
Bill Wendling77ad1dc2011-03-07 23:38:41 +0000337 let EncoderMethod = "getShiftRight64Imm";
Owen Andersone0152a72011-08-09 20:55:18 +0000338 let DecoderMethod = "DecodeShiftRight64Imm";
Jim Grosbachba7d6ed2011-12-08 22:06:06 +0000339 let ParserMatchClass = shr_imm64_asm_operand;
Bill Wendling3b1459b2011-03-01 01:00:59 +0000340}
341
Renato Golin3f126132016-05-12 21:22:31 +0000342
343// ARM Assembler operand for ldr Rd, =expression which generates an offset
344// to a constant pool entry or a MOV depending on the value of expression
345def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
346def const_pool_asm_imm : Operand<i32> {
347 let ParserMatchClass = const_pool_asm_operand;
348}
349
350
Evan Chengcd4cdd12009-07-11 06:43:01 +0000351//===----------------------------------------------------------------------===//
Jim Grosbach6caa5572011-08-22 18:04:24 +0000352// ARM Assembler alias templates.
353//
Sjoerd Meijer9da258d2016-06-03 13:19:43 +0000354// Note: When EmitPriority == 1, the alias will be used for printing
355class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
356 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
Sanne Wouda2409c642017-03-21 14:59:17 +0000357class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
358 : InstAlias<Asm, Result, EmitPriority>,
359 Requires<[IsARM,UseNegativeImmediates]>;
Sjoerd Meijer9da258d2016-06-03 13:19:43 +0000360class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
361 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
Sanne Wouda2409c642017-03-21 14:59:17 +0000362class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
363 : InstAlias<Asm, Result, EmitPriority>,
364 Requires<[IsThumb,UseNegativeImmediates]>;
Sjoerd Meijer9da258d2016-06-03 13:19:43 +0000365class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
366 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
Sanne Wouda2409c642017-03-21 14:59:17 +0000367class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
368 : InstAlias<Asm, Result, EmitPriority>,
369 Requires<[IsThumb2,UseNegativeImmediates]>;
Sjoerd Meijer9da258d2016-06-03 13:19:43 +0000370class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
371 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
372class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
373 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
374class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
375 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
376class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
377 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
Mikhail Maltsevd1cc2e12019-06-14 14:31:13 +0000378class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
379 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
Jim Grosbach6caa5572011-08-22 18:04:24 +0000380
Jim Grosbach9227f392011-12-13 20:08:32 +0000381
382class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
383 Requires<[HasVFP2]>;
384class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
385 Requires<[HasNEON]>;
386
Jim Grosbach6caa5572011-08-22 18:04:24 +0000387//===----------------------------------------------------------------------===//
Evan Cheng2d37f192008-08-28 23:39:26 +0000388// ARM Instruction templates.
389//
390
Jim Grosbach6caa5572011-08-22 18:04:24 +0000391
Owen Anderson651b2302011-07-13 23:22:26 +0000392class InstTemplate<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000393 Format f, Domain d, string cstr, InstrItinClass itin>
Evan Cheng2d37f192008-08-28 23:39:26 +0000394 : Instruction {
395 let Namespace = "ARM";
396
Evan Cheng2d37f192008-08-28 23:39:26 +0000397 AddrMode AM = am;
Owen Anderson651b2302011-07-13 23:22:26 +0000398 int Size = sz;
Evan Cheng2d37f192008-08-28 23:39:26 +0000399 IndexMode IM = im;
400 bits<2> IndexModeBits = IM.Value;
Evan Cheng2d37f192008-08-28 23:39:26 +0000401 Format F = f;
Bob Wilson69ba1bc2010-03-17 21:13:43 +0000402 bits<6> Form = F.Value;
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000403 Domain D = d;
Evan Cheng81889d012008-11-05 18:35:52 +0000404 bit isUnaryDataProc = 0;
Evan Cheng14965762009-07-08 01:46:35 +0000405 bit canXformTo16Bit = 0;
Jim Grosbach3e941ae2011-08-16 20:45:50 +0000406 // The instruction is a 16-bit flag setting Thumb instruction. Used
407 // by the parser to determine whether to require the 'S' suffix on the
408 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
409 bit thumbArithFlagSetting = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +0000410
Sam Parkerce392782019-10-15 13:12:51 +0000411 bit validForTailPredication = 0;
Sam Parker26a475a2019-09-17 07:43:04 +0000412
Chris Lattner7ff33462010-10-31 19:22:57 +0000413 // If this is a pseudo instruction, mark it isCodeGenOnly.
414 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
Bob Wilson3968c6a2010-03-23 17:23:59 +0000415
Jim Grosbach30694dc2011-08-15 16:52:24 +0000416 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
Jim Grosbache9298992010-10-05 18:14:55 +0000417 let TSFlags{4-0} = AM.Value;
Owen Anderson651b2302011-07-13 23:22:26 +0000418 let TSFlags{6-5} = IndexModeBits;
419 let TSFlags{12-7} = Form;
420 let TSFlags{13} = isUnaryDataProc;
421 let TSFlags{14} = canXformTo16Bit;
Sjoerd Meijer5857bf52019-05-30 08:07:06 +0000422 let TSFlags{18-15} = D.Value;
423 let TSFlags{19} = thumbArithFlagSetting;
Sam Parkerce392782019-10-15 13:12:51 +0000424 let TSFlags{20} = validForTailPredication;
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000425
Evan Cheng2d37f192008-08-28 23:39:26 +0000426 let Constraints = cstr;
David Goodwinb062c232009-08-06 16:52:47 +0000427 let Itinerary = itin;
Evan Cheng2d37f192008-08-28 23:39:26 +0000428}
429
Johnny Chenc28e6292009-12-15 17:24:14 +0000430class Encoding {
431 field bits<32> Inst;
James Molloyd9ba4fd2012-02-09 10:56:31 +0000432 // Mask of bits that cause an encoding to be UNPREDICTABLE.
433 // If a bit is set, then if the corresponding bit in the
434 // target encoding differs from its value in the "Inst" field,
435 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
436 field bits<32> Unpredictable = 0;
437 // SoftFail is the generic name for this field, but we alias it so
438 // as to make it more obvious what it means in ARM-land.
439 field bits<32> SoftFail = Unpredictable;
Johnny Chenc28e6292009-12-15 17:24:14 +0000440}
441
Owen Anderson651b2302011-07-13 23:22:26 +0000442class InstARM<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000443 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000444 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
445 let DecoderNamespace = "ARM";
446}
Johnny Chenc28e6292009-12-15 17:24:14 +0000447
448// This Encoding-less class is used by Thumb1 to specify the encoding bits later
449// on by adding flavors to specific instructions.
Owen Anderson651b2302011-07-13 23:22:26 +0000450class InstThumb<AddrMode am, int sz, IndexMode im,
Johnny Chenc28e6292009-12-15 17:24:14 +0000451 Format f, Domain d, string cstr, InstrItinClass itin>
Owen Andersonc78e03c2011-07-19 21:06:00 +0000452 : InstTemplate<am, sz, im, f, d, cstr, itin> {
453 let DecoderNamespace = "Thumb";
454}
Johnny Chenc28e6292009-12-15 17:24:14 +0000455
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000456// Pseudo-instructions for alternate assembly syntax (never used by codegen).
457// These are aliases that require C++ handling to convert to the target
458// instruction, while InstAliases can be handled directly by tblgen.
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000459class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000460 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
461 "", NoItinerary> {
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000462 let OutOperandList = oops;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000463 let InOperandList = iops;
464 let Pattern = [];
465 let isCodeGenOnly = 0; // So we get asm matcher for it.
Jim Grosbach61db5a52011-11-10 16:44:55 +0000466 let AsmString = asm;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000467 let isPseudo = 1;
David Green120a5e92019-09-29 08:38:48 +0000468 let hasNoSchedulingInfo = 1;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000469}
470
Saleem Abdulrasoolfb3950e2014-01-12 04:36:01 +0000471class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
472 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
473class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
474 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
475class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
476 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
477class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
478 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
479class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
480 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
Simon Tatham2f5188f2019-06-19 16:43:53 +0000481class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
482 : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
Jim Grosbachfb2f1d62011-11-01 01:24:45 +0000483
484// Pseudo instructions for the code generator.
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000485class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000486 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000487 GenericDomain, "", itin> {
Evan Cheng2d37f192008-08-28 23:39:26 +0000488 let OutOperandList = oops;
489 let InOperandList = iops;
Evan Cheng2d37f192008-08-28 23:39:26 +0000490 let Pattern = pattern;
Jim Grosbache1756822011-03-10 19:06:39 +0000491 let isCodeGenOnly = 1;
Jim Grosbach7c301ea2011-07-06 21:35:46 +0000492 let isPseudo = 1;
Evan Cheng2d37f192008-08-28 23:39:26 +0000493}
494
Jim Grosbachcfb66202010-11-18 01:15:56 +0000495// PseudoInst that's ARM-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000496class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbacha74c7ccd2010-11-18 01:38:26 +0000497 list<dag> pattern>
498 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000499 let Size = sz;
Jim Grosbachcfb66202010-11-18 01:15:56 +0000500 list<Predicate> Predicates = [IsARM];
501}
502
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000503// PseudoInst that's Thumb-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000504class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000505 list<dag> pattern>
506 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000507 let Size = sz;
Jim Grosbach58bc36a2010-11-29 19:32:47 +0000508 list<Predicate> Predicates = [IsThumb];
509}
Jim Grosbachcfb66202010-11-18 01:15:56 +0000510
Prakhar Bahuguna52a7dd72016-12-15 07:59:08 +0000511// PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
512class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
513 list<dag> pattern>
514 : PseudoInst<oops, iops, itin, pattern> {
515 let Size = sz;
516 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
517}
518
Jim Grosbachd42257c2010-12-15 18:48:45 +0000519// PseudoInst that's Thumb2-mode only.
Owen Anderson651b2302011-07-13 23:22:26 +0000520class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
Jim Grosbachd42257c2010-12-15 18:48:45 +0000521 list<dag> pattern>
522 : PseudoInst<oops, iops, itin, pattern> {
Owen Anderson651b2302011-07-13 23:22:26 +0000523 let Size = sz;
Jim Grosbachd42257c2010-12-15 18:48:45 +0000524 list<Predicate> Predicates = [IsThumb2];
525}
Jim Grosbach95dee402011-07-08 17:40:42 +0000526
Owen Anderson651b2302011-07-13 23:22:26 +0000527class ARMPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000528 InstrItinClass itin, list<dag> pattern,
529 dag Result>
530 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
531 PseudoInstExpansion<Result>;
532
Owen Anderson651b2302011-07-13 23:22:26 +0000533class tPseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000534 InstrItinClass itin, list<dag> pattern,
535 dag Result>
536 : tPseudoInst<oops, iops, sz, itin, pattern>,
537 PseudoInstExpansion<Result>;
538
Owen Anderson651b2302011-07-13 23:22:26 +0000539class t2PseudoExpand<dag oops, dag iops, int sz,
Jim Grosbach95dee402011-07-08 17:40:42 +0000540 InstrItinClass itin, list<dag> pattern,
541 dag Result>
542 : t2PseudoInst<oops, iops, sz, itin, pattern>,
543 PseudoInstExpansion<Result>;
544
Evan Cheng2d37f192008-08-28 23:39:26 +0000545// Almost all ARM instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +0000546class I<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000547 IndexMode im, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000548 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000549 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000550 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000551 bits<4> p;
552 let Inst{31-28} = p;
Evan Cheng2d37f192008-08-28 23:39:26 +0000553 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000554 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +0000555 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000556 let Pattern = pattern;
557 list<Predicate> Predicates = [IsARM];
558}
Bill Wendlingb70dc872010-08-31 07:50:46 +0000559
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000560// A few are not predicable
Owen Anderson651b2302011-07-13 23:22:26 +0000561class InoP<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000562 IndexMode im, Format f, InstrItinClass itin,
563 string opc, string asm, string cstr,
564 list<dag> pattern>
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000565 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
566 let OutOperandList = oops;
567 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000568 let AsmString = !strconcat(opc, asm);
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000569 let Pattern = pattern;
570 let isPredicable = 0;
571 list<Predicate> Predicates = [IsARM];
572}
Evan Cheng2d37f192008-08-28 23:39:26 +0000573
Bill Wendlingf8dfa462010-08-30 01:47:35 +0000574// Same as I except it can optionally modify CPSR. Note it's modeled as an input
575// operand since by default it's a zero register. It will become an implicit def
576// once it's "flipped".
Owen Anderson651b2302011-07-13 23:22:26 +0000577class sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000578 IndexMode im, Format f, InstrItinClass itin,
579 string opc, string asm, string cstr,
Evan Cheng2d37f192008-08-28 23:39:26 +0000580 list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000581 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Jim Grosbach5476a272010-10-11 18:51:51 +0000582 bits<4> p; // Predicate operand
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000583 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
Jim Grosbach5476a272010-10-11 18:51:51 +0000584 let Inst{31-28} = p;
Jim Grosbachd9d31da2010-10-12 23:00:24 +0000585 let Inst{20} = s;
Jim Grosbach5476a272010-10-11 18:51:51 +0000586
Evan Cheng2d37f192008-08-28 23:39:26 +0000587 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +0000588 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Bob Wilson59351842010-10-15 03:23:44 +0000589 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Cheng2d37f192008-08-28 23:39:26 +0000590 let Pattern = pattern;
591 list<Predicate> Predicates = [IsARM];
592}
593
Evan Chenga2827232008-09-01 07:19:00 +0000594// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +0000595class XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +0000596 IndexMode im, Format f, InstrItinClass itin,
597 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +0000598 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
Evan Chenga2827232008-09-01 07:19:00 +0000599 let OutOperandList = oops;
600 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +0000601 let AsmString = asm;
Evan Chenga2827232008-09-01 07:19:00 +0000602 let Pattern = pattern;
603 list<Predicate> Predicates = [IsARM];
604}
605
David Goodwinb062c232009-08-06 16:52:47 +0000606class AI<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, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000609 opc, asm, "", pattern>;
610class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
611 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000612 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000613 opc, asm, "", pattern>;
614class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000615 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000616 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Evan Cheng49d66522008-11-06 22:15:19 +0000617 asm, "", pattern>;
David Peixottob76f55f2014-01-27 21:39:04 +0000618class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
619 string asm, list<dag> pattern>
620 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
621 asm, "", pattern>;
Jim Grosbach5e0d2a22009-12-14 18:31:20 +0000622class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000623 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000624 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +0000625 opc, asm, "", pattern>;
Evan Chengfa558782008-09-01 08:25:56 +0000626
627// Ctrl flow instructions
David Goodwinb062c232009-08-06 16:52:47 +0000628class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
629 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000630 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000631 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000632 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000633}
David Goodwinb062c232009-08-06 16:52:47 +0000634class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
635 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000636 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000637 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000638 let Inst{27-24} = opcod;
Evan Chengfa558782008-09-01 08:25:56 +0000639}
Evan Chengfa558782008-09-01 08:25:56 +0000640
641// BR_JT instructions
David Goodwinb062c232009-08-06 16:52:47 +0000642class JTI<dag oops, dag iops, InstrItinClass itin,
643 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000644 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
Evan Cheng7095cd22008-11-07 09:06:08 +0000645 asm, "", pattern>;
Evan Cheng624844b2008-09-01 01:51:14 +0000646
Joey Goulye6d165c2013-08-27 17:38:16 +0000647class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000648 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000649 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000650 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000651 bits<4> Rt;
Jim Grosbachcb311932011-07-26 17:44:46 +0000652 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000653 let Inst{27-23} = 0b00011;
654 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000655 let Inst{20} = 1;
Jim Grosbachcb311932011-07-26 17:44:46 +0000656 let Inst{19-16} = addr;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000657 let Inst{15-12} = Rt;
Joey Goulye6d165c2013-08-27 17:38:16 +0000658 let Inst{11-10} = 0b11;
659 let Inst{9-8} = opcod2;
660 let Inst{7-0} = 0b10011111;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000661}
Joey Goulye6d165c2013-08-27 17:38:16 +0000662class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000663 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000664 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000665 opc, asm, "", pattern> {
Jim Grosbach4e57b522010-10-29 19:58:57 +0000666 bits<4> Rt;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000667 bits<4> addr;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000668 let Inst{27-23} = 0b00011;
669 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000670 let Inst{20} = 0;
Bruno Cardoso Lopesf170f8b2011-03-24 21:04:58 +0000671 let Inst{19-16} = addr;
Joey Goulye6d165c2013-08-27 17:38:16 +0000672 let Inst{11-10} = 0b11;
673 let Inst{9-8} = opcod2;
674 let Inst{7-4} = 0b1001;
Jim Grosbach4e57b522010-10-29 19:58:57 +0000675 let Inst{3-0} = Rt;
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000676}
Joey Goulye6d165c2013-08-27 17:38:16 +0000677// Atomic load/store instructions
678class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
679 string opc, string asm, list<dag> pattern>
680 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
681
682class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
683 string opc, string asm, list<dag> pattern>
684 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
685 bits<4> Rd;
686 let Inst{15-12} = Rd;
687}
688
689// Exclusive load/store instructions
690
691class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
692 string opc, string asm, list<dag> pattern>
693 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000694 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
Joey Goulye6d165c2013-08-27 17:38:16 +0000695
696class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
697 string opc, string asm, list<dag> pattern>
698 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000699 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
Joey Goulye6d165c2013-08-27 17:38:16 +0000700 bits<4> Rd;
701 let Inst{15-12} = Rd;
702}
703
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000704class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
Jim Grosbach15e8d742011-07-26 17:15:11 +0000705 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000706 bits<4> Rt;
707 bits<4> Rt2;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000708 bits<4> addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000709 let Inst{27-23} = 0b00010;
710 let Inst{22} = b;
711 let Inst{21-20} = 0b00;
Jim Grosbach15e8d742011-07-26 17:15:11 +0000712 let Inst{19-16} = addr;
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000713 let Inst{15-12} = Rt;
714 let Inst{11-4} = 0b00001001;
715 let Inst{3-0} = Rt2;
Owen Andersondde461c2011-10-28 18:02:13 +0000716
Silviu Barangaca45af92012-04-18 14:18:57 +0000717 let Unpredictable{11-8} = 0b1111;
Owen Andersondde461c2011-10-28 18:02:13 +0000718 let DecoderMethod = "DecodeSwap";
Jim Grosbach3b7e05b2010-10-29 20:21:36 +0000719}
Joey Goulye6d165c2013-08-27 17:38:16 +0000720// Acquire/Release load/store instructions
721class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
722 string opc, string asm, list<dag> pattern>
723 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000724 Requires<[IsARM, HasAcquireRelease]>;
Joey Goulye6d165c2013-08-27 17:38:16 +0000725
726class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
727 string opc, string asm, list<dag> pattern>
728 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
Bradley Smith4c21cba2016-01-15 10:23:46 +0000729 Requires<[IsARM, HasAcquireRelease]> {
Joey Goulye6d165c2013-08-27 17:38:16 +0000730 let Inst{15-12} = 0b1111;
731}
Jim Grosbach5c4e99f2009-12-11 01:42:04 +0000732
Evan Cheng624844b2008-09-01 01:51:14 +0000733// addrmode1 instructions
David Goodwinb062c232009-08-06 16:52:47 +0000734class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
735 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000736 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000737 opc, asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000738 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000739 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000740}
David Goodwinb062c232009-08-06 16:52:47 +0000741class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
742 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000743 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000744 opc, asm, "", pattern> {
745 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000746 let Inst{27-26} = 0b00;
David Goodwinb062c232009-08-06 16:52:47 +0000747}
748class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng2d37f192008-08-28 23:39:26 +0000749 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000750 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
Evan Chengc139c222008-08-29 07:40:52 +0000751 asm, "", pattern> {
Jim Grosbachb7c01f52008-10-14 20:36:24 +0000752 let Inst{24-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +0000753 let Inst{27-26} = 0b00;
Evan Chengc139c222008-08-29 07:40:52 +0000754}
Evan Cheng624844b2008-09-01 01:51:14 +0000755
Evan Chengcccca872008-09-01 01:27:33 +0000756// loads
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000757
Jim Grosbach4a22eba2010-11-19 21:07:51 +0000758// LDR/LDRB/STR/STRB/...
759class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
Jim Grosbach338de3e2010-10-27 23:12:14 +0000760 Format f, InstrItinClass itin, string opc, string asm,
761 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000762 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000763 "", pattern> {
764 let Inst{27-25} = op;
765 let Inst{24} = 1; // 24 == P
766 // 23 == U
Jim Grosbach2f790742010-11-13 00:35:48 +0000767 let Inst{22} = isByte;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000768 let Inst{21} = 0; // 21 == W
Jim Grosbach338de3e2010-10-27 23:12:14 +0000769 let Inst{20} = isLd;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000770}
Jim Grosbach2f790742010-11-13 00:35:48 +0000771// Indexed load/stores
772class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000773 IndexMode im, Format f, InstrItinClass itin, string opc,
Jim Grosbach2f790742010-11-13 00:35:48 +0000774 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000775 : I<oops, iops, AddrMode2, 4, im, f, itin,
Jim Grosbach2f790742010-11-13 00:35:48 +0000776 opc, asm, cstr, pattern> {
Jim Grosbach38b469e2010-11-15 20:47:07 +0000777 bits<4> Rt;
Jim Grosbach2f790742010-11-13 00:35:48 +0000778 let Inst{27-26} = 0b01;
779 let Inst{24} = isPre; // P bit
780 let Inst{22} = isByte; // B bit
781 let Inst{21} = isPre; // W bit
782 let Inst{20} = isLd; // L bit
Jim Grosbach38b469e2010-11-15 20:47:07 +0000783 let Inst{15-12} = Rt;
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000784}
Owen Anderson2aedba62011-07-26 20:54:26 +0000785class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000786 IndexMode im, Format f, InstrItinClass itin, string opc,
787 string asm, string cstr, list<dag> pattern>
788 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
789 pattern> {
790 // AM2 store w/ two operands: (GPR, am2offset)
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000791 // {12} isAdd
792 // {11-0} imm12/Rm
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000793 bits<14> offset;
794 bits<4> Rn;
Owen Anderson2aedba62011-07-26 20:54:26 +0000795 let Inst{25} = 1;
796 let Inst{23} = offset{12};
797 let Inst{19-16} = Rn;
798 let Inst{11-5} = offset{11-5};
799 let Inst{4} = 0;
800 let Inst{3-0} = offset{3-0};
801}
802
803class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
804 IndexMode im, Format f, InstrItinClass itin, string opc,
805 string asm, string cstr, list<dag> pattern>
806 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
807 pattern> {
808 // AM2 store w/ two operands: (GPR, am2offset)
809 // {12} isAdd
810 // {11-0} imm12/Rm
811 bits<14> offset;
812 bits<4> Rn;
813 let Inst{25} = 0;
Bruno Cardoso Lopesc2452a62011-03-31 15:54:36 +0000814 let Inst{23} = offset{12};
815 let Inst{19-16} = Rn;
816 let Inst{11-0} = offset{11-0};
Jim Grosbach6e9aace2010-11-19 21:35:06 +0000817}
Owen Anderson2aedba62011-07-26 20:54:26 +0000818
819
Bruno Cardoso Lopesab830502011-03-31 23:26:08 +0000820// FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
821// but for now use this class for STRT and STRBT.
822class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
823 IndexMode im, Format f, InstrItinClass itin, string opc,
824 string asm, string cstr, list<dag> pattern>
825 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
826 pattern> {
827 // AM2 store w/ two operands: (GPR, am2offset)
828 // {17-14} Rn
829 // {13} 1 == Rm, 0 == imm12
830 // {12} isAdd
831 // {11-0} imm12/Rm
832 bits<18> addr;
833 let Inst{25} = addr{13};
834 let Inst{23} = addr{12};
835 let Inst{19-16} = addr{17-14};
836 let Inst{11-0} = addr{11-0};
837}
Jim Grosbach1e4d9a12010-10-26 22:37:02 +0000838
Evan Cheng624844b2008-09-01 01:51:14 +0000839// addrmode3 instructions
Jim Grosbach76aed402010-11-19 18:16:46 +0000840class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
841 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000842 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000843 opc, asm, "", pattern> {
844 bits<14> addr;
845 bits<4> Rt;
846 let Inst{27-25} = 0b000;
847 let Inst{24} = 1; // P bit
848 let Inst{23} = addr{8}; // U bit
849 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
850 let Inst{21} = 0; // W bit
Jim Grosbach76aed402010-11-19 18:16:46 +0000851 let Inst{20} = op20; // L bit
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000852 let Inst{19-16} = addr{12-9}; // Rn
853 let Inst{15-12} = Rt; // Rt
854 let Inst{11-8} = addr{7-4}; // imm7_4/zero
855 let Inst{7-4} = op;
856 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Andersone0152a72011-08-09 20:55:18 +0000857
858 let DecoderMethod = "DecodeAddrMode3Instruction";
Jim Grosbach8e7f8df2010-11-18 00:46:58 +0000859}
Evan Cheng169eccc2008-09-01 07:00:14 +0000860
Jim Grosbach2ea19d12011-08-11 20:41:13 +0000861class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000862 IndexMode im, Format f, InstrItinClass itin, string opc,
863 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000864 : I<oops, iops, AddrMode3, 4, im, f, itin,
Jim Grosbach003c6e72010-11-19 19:41:26 +0000865 opc, asm, cstr, pattern> {
866 bits<4> Rt;
867 let Inst{27-25} = 0b000;
868 let Inst{24} = isPre; // P bit
869 let Inst{21} = isPre; // W bit
870 let Inst{20} = op20; // L bit
871 let Inst{15-12} = Rt; // Rt
872 let Inst{7-4} = op;
873}
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000874
875// FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
876// but for now use this class for LDRSBT, LDRHT, LDSHT.
Jim Grosbachd3595712011-08-03 23:50:40 +0000877class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000878 IndexMode im, Format f, InstrItinClass itin, string opc,
879 string asm, string cstr, list<dag> pattern>
Jim Grosbachd3595712011-08-03 23:50:40 +0000880 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000881 // {13} 1 == imm8, 0 == Rm
882 // {12-9} Rn
883 // {8} isAdd
884 // {7-4} imm7_4/zero
885 // {3-0} imm3_0/Rm
Jim Grosbachd3595712011-08-03 23:50:40 +0000886 bits<4> addr;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000887 bits<4> Rt;
888 let Inst{27-25} = 0b000;
Jim Grosbachd3595712011-08-03 23:50:40 +0000889 let Inst{24} = 0; // P bit
890 let Inst{21} = 1;
891 let Inst{20} = isLoad; // L bit
892 let Inst{19-16} = addr; // Rn
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000893 let Inst{15-12} = Rt; // Rt
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000894 let Inst{7-4} = op;
Bruno Cardoso Lopesbda36322011-04-04 17:18:19 +0000895}
896
Evan Cheng169eccc2008-09-01 07:00:14 +0000897// stores
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000898class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
David Goodwinb062c232009-08-06 16:52:47 +0000899 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000900 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000901 opc, asm, "", pattern> {
Jim Grosbach607efcb2010-11-11 01:09:40 +0000902 bits<14> addr;
903 bits<4> Rt;
Evan Cheng5edd90c2009-07-08 22:51:32 +0000904 let Inst{27-25} = 0b000;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000905 let Inst{24} = 1; // P bit
906 let Inst{23} = addr{8}; // U bit
907 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
908 let Inst{21} = 0; // W bit
909 let Inst{20} = 0; // L bit
910 let Inst{19-16} = addr{12-9}; // Rn
911 let Inst{15-12} = Rt; // Rt
912 let Inst{11-8} = addr{7-4}; // imm7_4/zero
Jim Grosbach09d7bfd2010-11-19 22:14:31 +0000913 let Inst{7-4} = op;
Jim Grosbach607efcb2010-11-11 01:09:40 +0000914 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
Owen Anderson60138ea2011-08-12 20:02:50 +0000915 let DecoderMethod = "DecodeAddrMode3Instruction";
Evan Cheng169eccc2008-09-01 07:00:14 +0000916}
Evan Cheng169eccc2008-09-01 07:00:14 +0000917
Evan Cheng624844b2008-09-01 01:51:14 +0000918// addrmode4 instructions
Bill Wendlinge69afc62010-11-13 09:09:38 +0000919class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
920 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000921 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
Bill Wendlinge69afc62010-11-13 09:09:38 +0000922 bits<4> p;
923 bits<16> regs;
924 bits<4> Rn;
925 let Inst{31-28} = p;
926 let Inst{27-25} = 0b100;
927 let Inst{22} = 0; // S bit
928 let Inst{19-16} = Rn;
929 let Inst{15-0} = regs;
930}
Evan Cheng2d37f192008-08-28 23:39:26 +0000931
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000932// Unsigned multiply, multiply-accumulate instructions.
David Goodwinb062c232009-08-06 16:52:47 +0000933class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
934 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000935 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000936 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000937 let Inst{7-4} = 0b1001;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000938 let Inst{20} = 0; // S bit
Evan Cheng47b546d2008-11-06 08:47:38 +0000939 let Inst{27-21} = opcod;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000940}
David Goodwinb062c232009-08-06 16:52:47 +0000941class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
942 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000943 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000944 opc, asm, "", pattern> {
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000945 let Inst{7-4} = 0b1001;
Evan Cheng47b546d2008-11-06 08:47:38 +0000946 let Inst{27-21} = opcod;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000947}
948
949// Most significant word multiply
Jim Grosbach22261602010-10-22 17:16:17 +0000950class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
951 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000952 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000953 opc, asm, "", pattern> {
Jim Grosbach22261602010-10-22 17:16:17 +0000954 bits<4> Rd;
955 bits<4> Rn;
956 bits<4> Rm;
957 let Inst{7-4} = opc7_4;
Evan Cheng2686c8f2008-11-06 01:21:28 +0000958 let Inst{20} = 1;
Evan Cheng47b546d2008-11-06 08:47:38 +0000959 let Inst{27-21} = opcod;
Jim Grosbach22261602010-10-22 17:16:17 +0000960 let Inst{19-16} = Rd;
961 let Inst{11-8} = Rm;
962 let Inst{3-0} = Rn;
963}
964// MSW multiple w/ Ra operand
965class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
966 InstrItinClass itin, string opc, string asm, list<dag> pattern>
967 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
968 bits<4> Ra;
969 let Inst{15-12} = Ra;
Jim Grosbach4d0549e2008-11-03 18:38:31 +0000970}
Evan Cheng2d37f192008-08-28 23:39:26 +0000971
Evan Cheng36ae4032008-11-06 03:35:07 +0000972// SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
Jim Grosbach6956a602010-10-22 18:35:16 +0000973class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
Jim Grosbachf98df082010-10-22 17:42:06 +0000974 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +0000975 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +0000976 opc, asm, "", pattern> {
Jim Grosbach6956a602010-10-22 18:35:16 +0000977 bits<4> Rn;
978 bits<4> Rm;
Evan Cheng36ae4032008-11-06 03:35:07 +0000979 let Inst{4} = 0;
980 let Inst{7} = 1;
981 let Inst{20} = 0;
Evan Cheng47b546d2008-11-06 08:47:38 +0000982 let Inst{27-21} = opcod;
Jim Grosbachf98df082010-10-22 17:42:06 +0000983 let Inst{6-5} = bit6_5;
Jim Grosbach6956a602010-10-22 18:35:16 +0000984 let Inst{11-8} = Rm;
985 let Inst{3-0} = Rn;
986}
987class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
988 InstrItinClass itin, string opc, string asm, list<dag> pattern>
989 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
990 bits<4> Rd;
991 let Inst{19-16} = Rd;
992}
993
994// AMulxyI with Ra operand
995class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
996 InstrItinClass itin, string opc, string asm, list<dag> pattern>
997 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
998 bits<4> Ra;
999 let Inst{15-12} = Ra;
1000}
1001// SMLAL*
1002class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1003 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1004 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1005 bits<4> RdLo;
1006 bits<4> RdHi;
1007 let Inst{19-16} = RdHi;
1008 let Inst{15-12} = RdLo;
Evan Cheng36ae4032008-11-06 03:35:07 +00001009}
1010
Evan Cheng49d66522008-11-06 22:15:19 +00001011// Extend instructions.
David Goodwinb062c232009-08-06 16:52:47 +00001012class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1013 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001014 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +00001015 opc, asm, "", pattern> {
Jim Grosbach1e7db682010-10-13 19:56:10 +00001016 // All AExtI instructions have Rd and Rm register operands.
1017 bits<4> Rd;
1018 bits<4> Rm;
1019 let Inst{15-12} = Rd;
1020 let Inst{3-0} = Rm;
Evan Cheng49d66522008-11-06 22:15:19 +00001021 let Inst{7-4} = 0b0111;
Jim Grosbach1e7db682010-10-13 19:56:10 +00001022 let Inst{9-8} = 0b00;
Evan Cheng49d66522008-11-06 22:15:19 +00001023 let Inst{27-20} = opcod;
Silviu Barangaddc67a72012-05-11 09:28:27 +00001024
1025 let Unpredictable{9-8} = 0b11;
Evan Cheng49d66522008-11-06 22:15:19 +00001026}
1027
Evan Cheng98dc53e2008-11-07 01:41:35 +00001028// Misc Arithmetic instructions.
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001029class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1030 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001031 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
David Goodwinb062c232009-08-06 16:52:47 +00001032 opc, asm, "", pattern> {
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001033 bits<4> Rd;
1034 bits<4> Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +00001035 let Inst{27-20} = opcod;
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001036 let Inst{19-16} = 0b1111;
1037 let Inst{15-12} = Rd;
1038 let Inst{11-8} = 0b1111;
1039 let Inst{7-4} = opc7_4;
1040 let Inst{3-0} = Rm;
1041}
1042
Bob Wilsone8a549c2012-09-29 21:43:49 +00001043// Division instructions.
1044class ADivA1I<bits<3> opcod, dag oops, dag iops,
1045 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1046 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1047 opc, asm, "", pattern> {
1048 bits<4> Rd;
1049 bits<4> Rn;
1050 bits<4> Rm;
1051 let Inst{27-23} = 0b01110;
1052 let Inst{22-20} = opcod;
1053 let Inst{19-16} = Rd;
1054 let Inst{15-12} = 0b1111;
1055 let Inst{11-8} = Rm;
1056 let Inst{7-4} = 0b0001;
1057 let Inst{3-0} = Rn;
1058}
1059
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001060// PKH instructions
Sjoerd Meijer11794702017-04-03 14:50:04 +00001061def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
Jim Grosbach27c1e252011-07-21 17:23:04 +00001062 let Name = "PKHLSLImm";
1063 let ParserMethod = "parsePKHLSLImm";
1064}
Jim Grosbacha288b1c2011-07-20 21:40:26 +00001065def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1066 let PrintMethod = "printPKHLSLShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +00001067 let ParserMatchClass = PKHLSLAsmOperand;
1068}
1069def PKHASRAsmOperand : AsmOperandClass {
1070 let Name = "PKHASRImm";
1071 let ParserMethod = "parsePKHASRImm";
Jim Grosbacha288b1c2011-07-20 21:40:26 +00001072}
1073def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1074 let PrintMethod = "printPKHASRShiftImm";
Jim Grosbach27c1e252011-07-21 17:23:04 +00001075 let ParserMatchClass = PKHASRAsmOperand;
Jim Grosbacha288b1c2011-07-20 21:40:26 +00001076}
Jim Grosbach94df3be2011-07-20 20:49:03 +00001077
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001078class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1079 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001080 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001081 opc, asm, "", pattern> {
1082 bits<4> Rd;
1083 bits<4> Rn;
1084 bits<4> Rm;
Jim Grosbacha98f8002011-07-20 20:32:09 +00001085 bits<5> sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001086 let Inst{27-20} = opcod;
1087 let Inst{19-16} = Rn;
1088 let Inst{15-12} = Rd;
Jim Grosbacha98f8002011-07-20 20:32:09 +00001089 let Inst{11-7} = sh;
Jim Grosbach2c9ae052010-10-22 22:12:16 +00001090 let Inst{6} = tb;
1091 let Inst{5-4} = 0b01;
1092 let Inst{3-0} = Rm;
Evan Cheng98dc53e2008-11-07 01:41:35 +00001093}
1094
Evan Cheng2d37f192008-08-28 23:39:26 +00001095//===----------------------------------------------------------------------===//
1096
1097// ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1098class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1099 list<Predicate> Predicates = [IsARM];
1100}
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001101class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1102 list<Predicate> Predicates = [IsARM, HasV5T];
1103}
Evan Cheng2d37f192008-08-28 23:39:26 +00001104class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1105 list<Predicate> Predicates = [IsARM, HasV5TE];
1106}
Bob Wilsone8a549c2012-09-29 21:43:49 +00001107// ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1108class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1109 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1110}
Evan Cheng2d37f192008-08-28 23:39:26 +00001111class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1112 list<Predicate> Predicates = [IsARM, HasV6];
1113}
James Molloyfa041152015-03-23 16:15:16 +00001114class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1115 list<Predicate> Predicates = [HasVFP2];
1116}
1117class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1118 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1119}
Sam Parker18bc3a02016-08-02 12:44:27 +00001120class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1121 list<Predicate> Predicates = [IsThumb2, HasDSP];
1122}
1123class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1124 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1125}
Sjoerd Meijer3ddb7fb2018-01-29 11:28:06 +00001126class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1127 list<Predicate> Predicates = [HasFP16];
1128}
1129class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1130 list<Predicate> Predicates = [HasFullFP16];
1131}
Evan Chengee98fa92008-08-29 06:41:12 +00001132//===----------------------------------------------------------------------===//
Evan Chengee98fa92008-08-29 06:41:12 +00001133// Thumb Instruction Format Definitions.
1134//
1135
Owen Anderson651b2302011-07-13 23:22:26 +00001136class ThumbI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001137 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001138 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001139 let OutOperandList = oops;
1140 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001141 let AsmString = asm;
Evan Chengee98fa92008-08-29 06:41:12 +00001142 let Pattern = pattern;
1143 list<Predicate> Predicates = [IsThumb];
1144}
1145
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001146// TI - Thumb instruction.
David Goodwinb062c232009-08-06 16:52:47 +00001147class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001148 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001149
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001150// Two-address instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001151class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1152 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001153 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
Bob Wilson3968c6a2010-03-23 17:23:59 +00001154 pattern>;
Evan Cheng7cc6aca2009-08-04 23:47:55 +00001155
Johnny Chenc28e6292009-12-15 17:24:14 +00001156// tBL, tBX 32-bit instructions
1157class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001158 dag oops, dag iops, InstrItinClass itin, string asm,
1159 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001160 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001161 Encoding {
Johnny Chenc28e6292009-12-15 17:24:14 +00001162 let Inst{31-27} = opcod1;
1163 let Inst{15-14} = opcod2;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001164 let Inst{12} = opcod3;
Johnny Chenc28e6292009-12-15 17:24:14 +00001165}
Evan Chengee98fa92008-08-29 06:41:12 +00001166
1167// BR_JT instructions
Bob Wilson3968c6a2010-03-23 17:23:59 +00001168class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1169 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001170 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Chengee98fa92008-08-29 06:41:12 +00001171
Evan Chengbec1dba892009-06-23 19:38:13 +00001172// Thumb1 only
Owen Anderson651b2302011-07-13 23:22:26 +00001173class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001174 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001175 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001176 let OutOperandList = oops;
1177 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001178 let AsmString = asm;
Evan Chengbec1dba892009-06-23 19:38:13 +00001179 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001180 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengbec1dba892009-06-23 19:38:13 +00001181}
1182
David Goodwinb062c232009-08-06 16:52:47 +00001183class T1I<dag oops, dag iops, InstrItinClass itin,
1184 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001185 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001186class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1187 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001188 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001189
1190// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001191class T1It<dag oops, dag iops, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001192 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001193 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001194 asm, cstr, pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001195
1196// Thumb1 instruction that can either be predicated or set CPSR.
Owen Anderson651b2302011-07-13 23:22:26 +00001197class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001198 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001199 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001200 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001201 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1202 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001203 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001204 let Pattern = pattern;
Jim Grosbach3e941ae2011-08-16 20:45:50 +00001205 let thumbArithFlagSetting = 1;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001206 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Anderson91a8f9b2011-08-16 23:45:44 +00001207 let DecoderNamespace = "ThumbSBit";
Evan Chengcd4cdd12009-07-11 06:43:01 +00001208}
1209
David Goodwinb062c232009-08-06 16:52:47 +00001210class T1sI<dag oops, dag iops, InstrItinClass itin,
1211 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001212 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001213
1214// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001215class T1sIt<dag oops, dag iops, InstrItinClass itin,
1216 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001217 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling05632cb2010-11-30 23:54:45 +00001218 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001219
1220// Thumb1 instruction that can be predicated.
Owen Anderson651b2302011-07-13 23:22:26 +00001221class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001222 InstrItinClass itin,
Evan Chengcd4cdd12009-07-11 06:43:01 +00001223 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chenc28e6292009-12-15 17:24:14 +00001224 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengcd4cdd12009-07-11 06:43:01 +00001225 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001226 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001227 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengcd4cdd12009-07-11 06:43:01 +00001228 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001229 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Evan Chengcd4cdd12009-07-11 06:43:01 +00001230}
1231
David Goodwinb062c232009-08-06 16:52:47 +00001232class T1pI<dag oops, dag iops, InstrItinClass itin,
1233 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001234 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001235
1236// Two-address instructions
David Goodwinb062c232009-08-06 16:52:47 +00001237class T1pIt<dag oops, dag iops, InstrItinClass itin,
1238 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001239 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
Bill Wendling7c646b92010-12-01 01:32:02 +00001240 "$Rn = $Rdn", pattern>;
Evan Chengcd4cdd12009-07-11 06:43:01 +00001241
Bob Wilson3968c6a2010-03-23 17:23:59 +00001242class T1pIs<dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001243 InstrItinClass itin, string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001244 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
Evan Chengbec1dba892009-06-23 19:38:13 +00001245
Johnny Chen466231a2009-12-16 02:32:54 +00001246class Encoding16 : Encoding {
1247 let Inst{31-16} = 0x0000;
1248}
1249
Johnny Chenc28e6292009-12-15 17:24:14 +00001250// A6.2 16-bit Thumb instruction encoding
Johnny Chen466231a2009-12-16 02:32:54 +00001251class T1Encoding<bits<6> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001252 let Inst{15-10} = opcode;
1253}
1254
1255// A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001256class T1General<bits<5> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001257 let Inst{15-14} = 0b00;
1258 let Inst{13-9} = opcode;
1259}
1260
1261// A6.2.2 Data-processing encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001262class T1DataProcessing<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001263 let Inst{15-10} = 0b010000;
1264 let Inst{9-6} = opcode;
1265}
1266
1267// A6.2.3 Special data instructions and branch and exchange encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001268class T1Special<bits<4> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001269 let Inst{15-10} = 0b010001;
Bill Wendling345b48f2010-11-17 00:45:23 +00001270 let Inst{9-6} = opcode;
Johnny Chenc28e6292009-12-15 17:24:14 +00001271}
1272
1273// A6.2.4 Load/store single data item encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001274class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001275 let Inst{15-12} = opA;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001276 let Inst{11-9} = opB;
Johnny Chenc28e6292009-12-15 17:24:14 +00001277}
Bill Wendlingb70dc872010-08-31 07:50:46 +00001278class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
Johnny Chenc28e6292009-12-15 17:24:14 +00001279
Eric Christopher9b67db82011-05-27 03:50:53 +00001280class T1BranchCond<bits<4> opcode> : Encoding16 {
1281 let Inst{15-12} = opcode;
1282}
1283
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001284// Helper classes to encode Thumb1 loads and stores. For immediates, the
Bill Wendling05632cb2010-11-30 23:54:45 +00001285// following bits are used for "opA" (see A6.2.4):
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001286//
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001287// 0b0110 => Immediate, 4 bytes
1288// 0b1000 => Immediate, 2 bytes
1289// 0b0111 => Immediate, 1 byte
Bill Wendlingc25545a2010-12-01 01:38:08 +00001290class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1291 InstrItinClass itin, string opc, string asm,
1292 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001293 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001294 T1LoadStore<0b0101, opcode> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001295 bits<3> Rt;
1296 bits<8> addr;
1297 let Inst{8-6} = addr{5-3}; // Rm
1298 let Inst{5-3} = addr{2-0}; // Rn
1299 let Inst{2-0} = Rt;
1300}
Bill Wendlingc25545a2010-12-01 01:38:08 +00001301class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1302 InstrItinClass itin, string opc, string asm,
1303 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001304 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
Bill Wendling5c51fcd2010-11-30 23:16:25 +00001305 T1LoadStore<opA, {opB,?,?}> {
Bill Wendlinga9e3df72010-11-30 22:57:21 +00001306 bits<3> Rt;
1307 bits<8> addr;
1308 let Inst{10-6} = addr{7-3}; // imm5
1309 let Inst{5-3} = addr{2-0}; // Rn
1310 let Inst{2-0} = Rt;
1311}
1312
Johnny Chenc28e6292009-12-15 17:24:14 +00001313// A6.2.5 Miscellaneous 16-bit instructions encoding.
Johnny Chen466231a2009-12-16 02:32:54 +00001314class T1Misc<bits<7> opcode> : Encoding16 {
Johnny Chenc28e6292009-12-15 17:24:14 +00001315 let Inst{15-12} = 0b1011;
1316 let Inst{11-5} = opcode;
1317}
1318
Evan Chengd76f0be2009-06-25 02:08:06 +00001319// Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001320class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001321 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001322 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001323 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001324 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001325 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001326 let AsmString = !strconcat(opc, "${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001327 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001328 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001329 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001330}
1331
Bill Wendlingb70dc872010-08-31 07:50:46 +00001332// Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1333// input operand since by default it's a zero register. It will become an
1334// implicit def once it's "flipped".
Jim Grosbachb9386552010-10-13 23:12:26 +00001335//
Evan Chengd76f0be2009-06-25 02:08:06 +00001336// FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1337// more consistent.
Owen Anderson651b2302011-07-13 23:22:26 +00001338class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001339 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001340 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001341 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Owen Andersoncf096a42010-12-07 20:50:15 +00001342 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1343 let Inst{20} = s;
1344
Evan Chengd76f0be2009-06-25 02:08:06 +00001345 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001346 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
Chris Lattner04c342e2010-10-06 00:05:18 +00001347 let AsmString = !strconcat(opc, "${s}${p}", asm);
Evan Chengd76f0be2009-06-25 02:08:06 +00001348 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001349 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001350 let DecoderNamespace = "Thumb2";
Evan Chengd76f0be2009-06-25 02:08:06 +00001351}
1352
1353// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001354class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001355 InstrItinClass itin,
Evan Chengd76f0be2009-06-25 02:08:06 +00001356 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001357 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
Evan Chengd76f0be2009-06-25 02:08:06 +00001358 let OutOperandList = oops;
1359 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001360 let AsmString = asm;
Evan Cheng431cf562009-06-23 17:48:47 +00001361 let Pattern = pattern;
Evan Cheng2c450d32009-07-02 06:38:40 +00001362 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001363 let DecoderNamespace = "Thumb2";
Evan Cheng431cf562009-06-23 17:48:47 +00001364}
1365
Owen Anderson651b2302011-07-13 23:22:26 +00001366class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001367 InstrItinClass itin,
1368 string asm, string cstr, list<dag> pattern>
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001369 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1370 let OutOperandList = oops;
1371 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001372 let AsmString = asm;
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001373 let Pattern = pattern;
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001374 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001375 let DecoderNamespace = "Thumb";
Jim Grosbach36d4dec2009-12-01 18:10:36 +00001376}
1377
David Goodwinb062c232009-08-06 16:52:47 +00001378class T2I<dag oops, dag iops, InstrItinClass itin,
1379 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001380 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001381class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1382 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001383 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001384class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1385 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001386 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001387class T2Iso<dag oops, dag iops, InstrItinClass itin,
1388 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001389 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001390class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1391 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001392 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001393class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
Jim Grosbach7db8d692011-09-08 22:07:06 +00001394 string opc, string asm, string cstr, list<dag> pattern>
1395 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Johnny Chenc28e6292009-12-15 17:24:14 +00001396 pattern> {
Owen Anderson943fb602010-12-01 19:18:46 +00001397 bits<4> Rt;
1398 bits<4> Rt2;
1399 bits<13> addr;
Jim Grosbach95bd6b72010-12-10 20:51:35 +00001400 let Inst{31-25} = 0b1110100;
1401 let Inst{24} = P;
1402 let Inst{23} = addr{8};
1403 let Inst{22} = 1;
1404 let Inst{21} = W;
1405 let Inst{20} = isLoad;
1406 let Inst{19-16} = addr{12-9};
Owen Anderson943fb602010-12-01 19:18:46 +00001407 let Inst{15-12} = Rt{3-0};
1408 let Inst{11-8} = Rt2{3-0};
Owen Anderson943fb602010-12-01 19:18:46 +00001409 let Inst{7-0} = addr{7-0};
Johnny Chenc28e6292009-12-15 17:24:14 +00001410}
Jim Grosbach7db8d692011-09-08 22:07:06 +00001411class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1412 InstrItinClass itin, string opc, string asm, string cstr,
1413 list<dag> pattern>
1414 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
Owen Anderson08d4bb02011-08-04 23:18:05 +00001415 pattern> {
1416 bits<4> Rt;
1417 bits<4> Rt2;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001418 bits<4> addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001419 bits<9> imm;
1420 let Inst{31-25} = 0b1110100;
1421 let Inst{24} = P;
1422 let Inst{23} = imm{8};
1423 let Inst{22} = 1;
1424 let Inst{21} = W;
1425 let Inst{20} = isLoad;
Jim Grosbach7db8d692011-09-08 22:07:06 +00001426 let Inst{19-16} = addr;
Owen Anderson08d4bb02011-08-04 23:18:05 +00001427 let Inst{15-12} = Rt{3-0};
1428 let Inst{11-8} = Rt2{3-0};
1429 let Inst{7-0} = imm{7-0};
1430}
1431
David Goodwinb062c232009-08-06 16:52:47 +00001432class T2sI<dag oops, dag iops, InstrItinClass itin,
1433 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001434 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
Evan Chengd76f0be2009-06-25 02:08:06 +00001435
David Goodwinb062c232009-08-06 16:52:47 +00001436class T2XI<dag oops, dag iops, InstrItinClass itin,
1437 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001438 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
David Goodwinb062c232009-08-06 16:52:47 +00001439class T2JTI<dag oops, dag iops, InstrItinClass itin,
1440 string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001441 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
Evan Cheng431cf562009-06-23 17:48:47 +00001442
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001443// Move to/from coprocessor instructions
Tim Northover2c45a382013-06-26 16:52:40 +00001444class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1445 list<dag> pattern>
1446 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
Jim Grosbachcabb48d2011-07-13 21:17:59 +00001447 let Inst{31-28} = opc;
Bruno Cardoso Lopes4d4b4902011-01-20 16:58:48 +00001448}
1449
Bob Wilson947f04b2010-03-13 01:08:20 +00001450// Two-address instructions
1451class T2XIt<dag oops, dag iops, InstrItinClass itin,
1452 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001453 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
Evan Cheng83e0d482009-09-28 09:14:39 +00001454
Jim Grosbachc086f682011-09-08 00:39:19 +00001455// T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1456class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
Johnny Chenc28e6292009-12-15 17:24:14 +00001457 dag oops, dag iops,
1458 AddrMode am, IndexMode im, InstrItinClass itin,
Evan Cheng84c6cda2009-07-02 07:28:31 +00001459 string opc, string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001460 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
Evan Cheng84c6cda2009-07-02 07:28:31 +00001461 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001462 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001463 let AsmString = !strconcat(opc, "${p}", asm);
Evan Cheng84c6cda2009-07-02 07:28:31 +00001464 let Pattern = pattern;
1465 list<Predicate> Predicates = [IsThumb2];
Owen Andersonc78e03c2011-07-19 21:06:00 +00001466 let DecoderNamespace = "Thumb2";
Jim Grosbachc086f682011-09-08 00:39:19 +00001467
1468 bits<4> Rt;
1469 bits<13> addr;
Johnny Chenc28e6292009-12-15 17:24:14 +00001470 let Inst{31-27} = 0b11111;
1471 let Inst{26-25} = 0b00;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001472 let Inst{24} = signed;
1473 let Inst{23} = 0;
Johnny Chenc28e6292009-12-15 17:24:14 +00001474 let Inst{22-21} = opcod;
Bill Wendlingb70dc872010-08-31 07:50:46 +00001475 let Inst{20} = load;
Jim Grosbachc086f682011-09-08 00:39:19 +00001476 let Inst{19-16} = addr{12-9};
1477 let Inst{15-12} = Rt{3-0};
Bill Wendlingb70dc872010-08-31 07:50:46 +00001478 let Inst{11} = 1;
Johnny Chenc28e6292009-12-15 17:24:14 +00001479 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
Bill Wendlingb70dc872010-08-31 07:50:46 +00001480 let Inst{10} = pre; // The P bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001481 let Inst{9} = addr{8}; // Sign bit
Bill Wendlingb70dc872010-08-31 07:50:46 +00001482 let Inst{8} = 1; // The W bit.
Jim Grosbachc086f682011-09-08 00:39:19 +00001483 let Inst{7-0} = addr{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001484
1485 let DecoderMethod = "DecodeT2LdStPre";
Jim Grosbachc086f682011-09-08 00:39:19 +00001486}
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001487
Jim Grosbachc086f682011-09-08 00:39:19 +00001488// T2Ipostldst - Thumb2 post-indexed load / store instructions.
1489class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1490 dag oops, dag iops,
1491 AddrMode am, IndexMode im, InstrItinClass itin,
1492 string opc, string asm, string cstr, list<dag> pattern>
1493 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1494 let OutOperandList = oops;
1495 let InOperandList = !con(iops, (ins pred:$p));
1496 let AsmString = !strconcat(opc, "${p}", asm);
1497 let Pattern = pattern;
1498 list<Predicate> Predicates = [IsThumb2];
1499 let DecoderNamespace = "Thumb2";
Jim Grosbachc4669ed2010-12-10 20:47:29 +00001500
Owen Andersone22c7322010-11-30 00:14:31 +00001501 bits<4> Rt;
1502 bits<4> Rn;
Jim Grosbach3343da52011-09-08 01:01:32 +00001503 bits<9> offset;
Jim Grosbachc086f682011-09-08 00:39:19 +00001504 let Inst{31-27} = 0b11111;
1505 let Inst{26-25} = 0b00;
1506 let Inst{24} = signed;
1507 let Inst{23} = 0;
1508 let Inst{22-21} = opcod;
1509 let Inst{20} = load;
1510 let Inst{19-16} = Rn;
Owen Andersone22c7322010-11-30 00:14:31 +00001511 let Inst{15-12} = Rt{3-0};
Jim Grosbachc086f682011-09-08 00:39:19 +00001512 let Inst{11} = 1;
1513 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1514 let Inst{10} = pre; // The P bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001515 let Inst{9} = offset{8}; // Sign bit
Jim Grosbachc086f682011-09-08 00:39:19 +00001516 let Inst{8} = 1; // The W bit.
Jim Grosbach3343da52011-09-08 01:01:32 +00001517 let Inst{7-0} = offset{7-0};
Owen Andersona9ebf6f2011-09-12 18:56:30 +00001518
1519 let DecoderMethod = "DecodeT2LdStPre";
Evan Cheng84c6cda2009-07-02 07:28:31 +00001520}
1521
David Goodwine5b969f2009-07-27 19:59:26 +00001522// T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1523class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
Jim Grosbachfddf36d2010-11-01 17:08:58 +00001524 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
David Goodwine5b969f2009-07-27 19:59:26 +00001525}
Evan Cheng84c6cda2009-07-02 07:28:31 +00001526
Bruno Cardoso Lopes168c9002011-05-03 17:29:22 +00001527// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1528class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1529 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1530}
1531
Evan Chengeab9ca72009-06-27 02:26:13 +00001532// T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1533class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
Evan Cheng2c450d32009-07-02 06:38:40 +00001534 list<Predicate> Predicates = [IsThumb2];
Evan Cheng431cf562009-06-23 17:48:47 +00001535}
1536
Evan Chengee98fa92008-08-29 06:41:12 +00001537//===----------------------------------------------------------------------===//
1538
Evan Chengac2af2f2008-11-11 02:11:05 +00001539//===----------------------------------------------------------------------===//
1540// ARM VFP Instruction templates.
1541//
1542
David Goodwin81cdd212009-07-10 17:03:29 +00001543// Almost all VFP instructions are predicable.
Owen Anderson651b2302011-07-13 23:22:26 +00001544class VFPI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001545 IndexMode im, Format f, InstrItinClass itin,
1546 string opc, string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001547 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Jim Grosbach576640f2010-10-12 21:22:40 +00001548 bits<4> p;
1549 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001550 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00001551 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00001552 let AsmString = !strconcat(opc, "${p}", asm);
David Goodwin81cdd212009-07-10 17:03:29 +00001553 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001554 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001555 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001556 list<Predicate> Predicates = [HasVFP2];
1557}
1558
1559// Special cases
Owen Anderson651b2302011-07-13 23:22:26 +00001560class VFPXI<dag oops, dag iops, AddrMode am, int sz,
David Goodwinb062c232009-08-06 16:52:47 +00001561 IndexMode im, Format f, InstrItinClass itin,
1562 string asm, string cstr, list<dag> pattern>
Anton Korobeynikov14635da2009-11-02 00:10:38 +00001563 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001564 bits<4> p;
1565 let Inst{31-28} = p;
David Goodwin81cdd212009-07-10 17:03:29 +00001566 let OutOperandList = oops;
1567 let InOperandList = iops;
Bob Wilson722bff22010-05-24 20:08:34 +00001568 let AsmString = asm;
David Goodwin81cdd212009-07-10 17:03:29 +00001569 let Pattern = pattern;
Bill Wendling87240d42010-12-01 21:54:50 +00001570 let PostEncoderMethod = "VFPThumb2PostEncoder";
Owen Andersone0152a72011-08-09 20:55:18 +00001571 let DecoderNamespace = "VFP";
David Goodwin81cdd212009-07-10 17:03:29 +00001572 list<Predicate> Predicates = [HasVFP2];
1573}
1574
David Goodwinb062c232009-08-06 16:52:47 +00001575class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1576 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001577 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
Bill Wendling87240d42010-12-01 21:54:50 +00001578 opc, asm, "", pattern> {
1579 let PostEncoderMethod = "VFPThumb2PostEncoder";
1580}
David Goodwin81cdd212009-07-10 17:03:29 +00001581
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001582// ARM VFP addrmode5 loads and stores
1583class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001584 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001585 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001586 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001587 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001588 // Instruction operands.
1589 bits<5> Dd;
1590 bits<13> addr;
1591
1592 // Encode instruction operands.
1593 let Inst{23} = addr{8}; // U (add = (U == '1'))
1594 let Inst{22} = Dd{4};
1595 let Inst{19-16} = addr{12-9}; // Rn
1596 let Inst{15-12} = Dd{3-0};
1597 let Inst{7-0} = addr{7-0}; // imm8
1598
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001599 let Inst{27-24} = opcod1;
1600 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001601 let Inst{11-9} = 0b101;
1602 let Inst{8} = 1; // Double precision
Anton Korobeynikov8cce1eb2009-11-02 00:11:06 +00001603
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001604 // Loads & stores operate on both NEON and VFP pipelines.
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +00001605 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001606}
1607
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001608class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00001609 InstrItinClass itin,
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001610 string opc, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001611 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001612 VFPLdStFrm, itin, opc, asm, "", pattern> {
Bill Wendlingc0024632010-11-04 00:59:42 +00001613 // Instruction operands.
1614 bits<5> Sd;
1615 bits<13> addr;
1616
1617 // Encode instruction operands.
1618 let Inst{23} = addr{8}; // U (add = (U == '1'))
1619 let Inst{22} = Sd{0};
1620 let Inst{19-16} = addr{12-9}; // Rn
1621 let Inst{15-12} = Sd{4-1};
1622 let Inst{7-0} = addr{7-0}; // imm8
1623
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001624 let Inst{27-24} = opcod1;
1625 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001626 let Inst{11-9} = 0b101;
1627 let Inst{8} = 0; // Single precision
Evan Cheng4a8c43f2011-02-16 00:35:02 +00001628
1629 // Loads & stores operate on both NEON and VFP pipelines.
1630 let D = VFPNeonDomain;
Evan Chengac2af2f2008-11-11 02:11:05 +00001631}
1632
Oliver Stannard65b85382016-01-25 10:26:26 +00001633class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1634 InstrItinClass itin,
1635 string opc, string asm, list<dag> pattern>
Sjoerd Meijer011de9c2018-01-26 09:26:40 +00001636 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
Oliver Stannard65b85382016-01-25 10:26:26 +00001637 VFPLdStFrm, itin, opc, asm, "", pattern> {
1638 list<Predicate> Predicates = [HasFullFP16];
1639
1640 // Instruction operands.
1641 bits<5> Sd;
1642 bits<13> addr;
1643
1644 // Encode instruction operands.
1645 let Inst{23} = addr{8}; // U (add = (U == '1'))
1646 let Inst{22} = Sd{0};
1647 let Inst{19-16} = addr{12-9}; // Rn
1648 let Inst{15-12} = Sd{4-1};
1649 let Inst{7-0} = addr{7-0}; // imm8
1650
1651 let Inst{27-24} = opcod1;
1652 let Inst{21-20} = opcod2;
1653 let Inst{11-8} = 0b1001; // Half precision
1654
1655 // Loads & stores operate on both NEON and VFP pipelines.
1656 let D = VFPNeonDomain;
Simon Tathamb70fc0c2019-02-25 10:39:53 +00001657
1658 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
Oliver Stannard65b85382016-01-25 10:26:26 +00001659}
1660
Bob Wilson6b853c32010-09-16 00:31:02 +00001661// VFP Load / store multiple pseudo instructions.
1662class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1663 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001664 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
Bob Wilson6b853c32010-09-16 00:31:02 +00001665 cstr, itin> {
1666 let OutOperandList = oops;
1667 let InOperandList = !con(iops, (ins pred:$p));
1668 let Pattern = pattern;
1669 list<Predicate> Predicates = [HasVFP2];
1670}
1671
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001672// Load / store multiple
Tim Northover4173e292013-05-31 15:55:51 +00001673
1674// Unknown precision
1675class AXXI4<dag oops, dag iops, IndexMode im,
1676 string asm, string cstr, list<dag> pattern>
1677 : VFPXI<oops, iops, AddrMode4, 4, im,
1678 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1679 // Instruction operands.
1680 bits<4> Rn;
1681 bits<13> regs;
1682
1683 // Encode instruction operands.
1684 let Inst{19-16} = Rn;
1685 let Inst{22} = 0;
1686 let Inst{15-12} = regs{11-8};
1687 let Inst{7-1} = regs{7-1};
1688
1689 let Inst{27-25} = 0b110;
1690 let Inst{11-8} = 0b1011;
1691 let Inst{0} = 1;
1692}
1693
1694// Double precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001695class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001696 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001697 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001698 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001699 // Instruction operands.
1700 bits<4> Rn;
1701 bits<13> regs;
1702
1703 // Encode instruction operands.
1704 let Inst{19-16} = Rn;
1705 let Inst{22} = regs{12};
1706 let Inst{15-12} = regs{11-8};
Tim Northover4173e292013-05-31 15:55:51 +00001707 let Inst{7-1} = regs{7-1};
Bill Wendling345b48f2010-11-17 00:45:23 +00001708
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001709 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001710 let Inst{11-9} = 0b101;
1711 let Inst{8} = 1; // Double precision
Tim Northover4173e292013-05-31 15:55:51 +00001712 let Inst{0} = 0;
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001713}
1714
Tim Northover4173e292013-05-31 15:55:51 +00001715// Single Precision
Jim Grosbachabcbe242010-09-08 00:25:50 +00001716class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
Bob Wilson947f04b2010-03-13 01:08:20 +00001717 string asm, string cstr, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00001718 : VFPXI<oops, iops, AddrMode4, 4, im,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001719 VFPLdStMulFrm, itin, asm, cstr, pattern> {
Bill Wendling345b48f2010-11-17 00:45:23 +00001720 // Instruction operands.
1721 bits<4> Rn;
1722 bits<13> regs;
1723
1724 // Encode instruction operands.
1725 let Inst{19-16} = Rn;
1726 let Inst{22} = regs{8};
1727 let Inst{15-12} = regs{12-9};
1728 let Inst{7-0} = regs{7-0};
1729
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001730 let Inst{27-25} = 0b110;
Bill Wendling98c29d72010-10-12 22:03:19 +00001731 let Inst{11-9} = 0b101;
1732 let Inst{8} = 0; // Single precision
Evan Cheng8cbbcb12008-11-11 21:48:44 +00001733}
1734
Evan Chengac2af2f2008-11-11 02:11:05 +00001735// Double precision, unary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001736class ADuI<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>
David Goodwinb062c232009-08-06 16:52:47 +00001739 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001740 // Instruction operands.
1741 bits<5> Dd;
1742 bits<5> Dm;
1743
1744 // Encode instruction operands.
1745 let Inst{3-0} = Dm{3-0};
1746 let Inst{5} = Dm{4};
1747 let Inst{15-12} = Dd{3-0};
1748 let Inst{22} = Dd{4};
1749
Johnny Chen34a6afc2010-01-29 23:21:10 +00001750 let Inst{27-23} = opcod1;
1751 let Inst{21-20} = opcod2;
1752 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001753 let Inst{11-9} = 0b101;
1754 let Inst{8} = 1; // Double precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001755 let Inst{7-6} = opcod4;
1756 let Inst{4} = opcod5;
Tim Northover5620faf2013-10-24 15:49:39 +00001757
1758 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001759}
1760
Joey Gouly0f12aa22013-07-09 11:26:18 +00001761// Double precision, unary, not-predicated
1762class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1763 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1764 string asm, list<dag> pattern>
1765 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1766 // Instruction operands.
1767 bits<5> Dd;
1768 bits<5> Dm;
1769
1770 let Inst{31-28} = 0b1111;
1771
1772 // Encode instruction operands.
1773 let Inst{3-0} = Dm{3-0};
1774 let Inst{5} = Dm{4};
1775 let Inst{15-12} = Dd{3-0};
1776 let Inst{22} = Dd{4};
1777
1778 let Inst{27-23} = opcod1;
1779 let Inst{21-20} = opcod2;
1780 let Inst{19-16} = opcod3;
1781 let Inst{11-9} = 0b101;
1782 let Inst{8} = 1; // Double precision
1783 let Inst{7-6} = opcod4;
1784 let Inst{4} = opcod5;
1785}
1786
Evan Chengac2af2f2008-11-11 02:11:05 +00001787// Double precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001788class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001789 dag iops, InstrItinClass itin, string opc, string asm,
1790 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001791 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001792 // Instruction operands.
1793 bits<5> Dd;
1794 bits<5> Dn;
1795 bits<5> Dm;
1796
1797 // Encode instruction operands.
1798 let Inst{3-0} = Dm{3-0};
1799 let Inst{5} = Dm{4};
1800 let Inst{19-16} = Dn{3-0};
1801 let Inst{7} = Dn{4};
1802 let Inst{15-12} = Dd{3-0};
1803 let Inst{22} = Dd{4};
1804
Johnny Chen34a6afc2010-01-29 23:21:10 +00001805 let Inst{27-23} = opcod1;
1806 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001807 let Inst{11-9} = 0b101;
1808 let Inst{8} = 1; // Double precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001809 let Inst{6} = op6;
1810 let Inst{4} = op4;
Tim Northover5620faf2013-10-24 15:49:39 +00001811
1812 let Predicates = [HasVFP2, HasDPVFP];
Evan Chengac2af2f2008-11-11 02:11:05 +00001813}
1814
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001815// FP, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001816class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001817 InstrItinClass itin, string asm, list<dag> pattern>
Joey Gouly2d0175e2013-07-09 09:59:04 +00001818 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1819 asm, "", pattern>
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001820{
1821 // Instruction operands.
1822 bits<5> Dd;
1823 bits<5> Dn;
1824 bits<5> Dm;
1825
1826 let Inst{31-28} = 0b1111;
1827
1828 // Encode instruction operands.
1829 let Inst{3-0} = Dm{3-0};
1830 let Inst{5} = Dm{4};
1831 let Inst{19-16} = Dn{3-0};
1832 let Inst{7} = Dn{4};
1833 let Inst{15-12} = Dd{3-0};
1834 let Inst{22} = Dd{4};
1835
1836 let Inst{27-23} = opcod1;
1837 let Inst{21-20} = opcod2;
1838 let Inst{11-9} = 0b101;
1839 let Inst{8} = 1; // double precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001840 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001841 let Inst{4} = 0;
Tim Northover5620faf2013-10-24 15:49:39 +00001842
1843 let Predicates = [HasVFP2, HasDPVFP];
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001844}
1845
Joey Gouly2d0175e2013-07-09 09:59:04 +00001846// Single precision, unary, predicated
Johnny Chen34a6afc2010-01-29 23:21:10 +00001847class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1848 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1849 string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001850 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001851 // Instruction operands.
1852 bits<5> Sd;
1853 bits<5> Sm;
1854
1855 // Encode instruction operands.
1856 let Inst{3-0} = Sm{4-1};
1857 let Inst{5} = Sm{0};
1858 let Inst{15-12} = Sd{4-1};
1859 let Inst{22} = Sd{0};
1860
Johnny Chen34a6afc2010-01-29 23:21:10 +00001861 let Inst{27-23} = opcod1;
1862 let Inst{21-20} = opcod2;
1863 let Inst{19-16} = opcod3;
Bill Wendling98c29d72010-10-12 22:03:19 +00001864 let Inst{11-9} = 0b101;
1865 let Inst{8} = 0; // Single precision
Johnny Chen34a6afc2010-01-29 23:21:10 +00001866 let Inst{7-6} = opcod4;
1867 let Inst{4} = opcod5;
Evan Chengac2af2f2008-11-11 02:11:05 +00001868}
1869
Joey Gouly2d0175e2013-07-09 09:59:04 +00001870// Single precision, unary, non-predicated
1871class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1872 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1873 string asm, list<dag> pattern>
1874 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1875 VFPUnaryFrm, itin, asm, "", pattern> {
1876 // Instruction operands.
1877 bits<5> Sd;
1878 bits<5> Sm;
1879
1880 let Inst{31-28} = 0b1111;
1881
1882 // Encode instruction operands.
1883 let Inst{3-0} = Sm{4-1};
1884 let Inst{5} = Sm{0};
1885 let Inst{15-12} = Sd{4-1};
1886 let Inst{22} = Sd{0};
1887
1888 let Inst{27-23} = opcod1;
1889 let Inst{21-20} = opcod2;
1890 let Inst{19-16} = opcod3;
1891 let Inst{11-9} = 0b101;
1892 let Inst{8} = 0; // Single precision
1893 let Inst{7-6} = opcod4;
1894 let Inst{4} = opcod5;
1895}
1896
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001897// Single precision unary, if no NEON. Same as ASuI except not available if
1898// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001899class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1900 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1901 string asm, list<dag> pattern>
1902 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1903 pattern> {
David Goodwin30bf6252009-08-04 20:39:05 +00001904 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1905}
1906
Evan Chengac2af2f2008-11-11 02:11:05 +00001907// Single precision, binary
Johnny Chen34a6afc2010-01-29 23:21:10 +00001908class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1909 InstrItinClass itin, string opc, string asm, list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00001910 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
Bill Wendling26233432010-11-01 06:00:39 +00001911 // Instruction operands.
1912 bits<5> Sd;
1913 bits<5> Sn;
1914 bits<5> Sm;
1915
1916 // Encode instruction operands.
1917 let Inst{3-0} = Sm{4-1};
1918 let Inst{5} = Sm{0};
1919 let Inst{19-16} = Sn{4-1};
1920 let Inst{7} = Sn{0};
1921 let Inst{15-12} = Sd{4-1};
1922 let Inst{22} = Sd{0};
1923
Johnny Chen34a6afc2010-01-29 23:21:10 +00001924 let Inst{27-23} = opcod1;
1925 let Inst{21-20} = opcod2;
Bill Wendling98c29d72010-10-12 22:03:19 +00001926 let Inst{11-9} = 0b101;
1927 let Inst{8} = 0; // Single precision
Bill Wendlingb70dc872010-08-31 07:50:46 +00001928 let Inst{6} = op6;
1929 let Inst{4} = op4;
Evan Chengac2af2f2008-11-11 02:11:05 +00001930}
1931
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001932// Single precision, binary, not predicated
Joey Gouly2efaa732013-07-06 20:50:18 +00001933class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001934 InstrItinClass itin, string asm, list<dag> pattern>
1935 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1936 VFPBinaryFrm, itin, asm, "", pattern>
1937{
1938 // Instruction operands.
1939 bits<5> Sd;
1940 bits<5> Sn;
1941 bits<5> Sm;
1942
1943 let Inst{31-28} = 0b1111;
1944
1945 // Encode instruction operands.
1946 let Inst{3-0} = Sm{4-1};
1947 let Inst{5} = Sm{0};
1948 let Inst{19-16} = Sn{4-1};
1949 let Inst{7} = Sn{0};
1950 let Inst{15-12} = Sd{4-1};
1951 let Inst{22} = Sd{0};
1952
1953 let Inst{27-23} = opcod1;
1954 let Inst{21-20} = opcod2;
1955 let Inst{11-9} = 0b101;
1956 let Inst{8} = 0; // Single precision
Joey Gouly2efaa732013-07-06 20:50:18 +00001957 let Inst{6} = opcod3;
Joey Goulycc4ff9e2013-07-04 14:57:20 +00001958 let Inst{4} = 0;
1959}
1960
Bill Wendlingcbb08ca2010-12-01 02:42:55 +00001961// Single precision binary, if no NEON. Same as ASbI except not available if
1962// NEON is enabled.
Johnny Chen34a6afc2010-01-29 23:21:10 +00001963class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
Bob Wilson3968c6a2010-03-23 17:23:59 +00001964 dag iops, InstrItinClass itin, string opc, string asm,
1965 list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00001966 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
David Goodwin3b9c52c2009-08-04 17:53:06 +00001967 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
Bill Wendling26233432010-11-01 06:00:39 +00001968
1969 // Instruction operands.
1970 bits<5> Sd;
1971 bits<5> Sn;
1972 bits<5> Sm;
1973
1974 // Encode instruction operands.
1975 let Inst{3-0} = Sm{4-1};
1976 let Inst{5} = Sm{0};
1977 let Inst{19-16} = Sn{4-1};
1978 let Inst{7} = Sn{0};
1979 let Inst{15-12} = Sd{4-1};
1980 let Inst{22} = Sd{0};
David Goodwin3b9c52c2009-08-04 17:53:06 +00001981}
1982
Oliver Stannard65b85382016-01-25 10:26:26 +00001983// Half precision, unary, predicated
1984class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1985 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1986 string asm, list<dag> pattern>
1987 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1988 list<Predicate> Predicates = [HasFullFP16];
1989
1990 // Instruction operands.
1991 bits<5> Sd;
1992 bits<5> Sm;
1993
1994 // Encode instruction operands.
1995 let Inst{3-0} = Sm{4-1};
1996 let Inst{5} = Sm{0};
1997 let Inst{15-12} = Sd{4-1};
1998 let Inst{22} = Sd{0};
1999
2000 let Inst{27-23} = opcod1;
2001 let Inst{21-20} = opcod2;
2002 let Inst{19-16} = opcod3;
2003 let Inst{11-8} = 0b1001; // Half precision
2004 let Inst{7-6} = opcod4;
2005 let Inst{4} = opcod5;
Simon Tathamb70fc0c2019-02-25 10:39:53 +00002006
2007 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
Oliver Stannard65b85382016-01-25 10:26:26 +00002008}
2009
2010// Half precision, unary, non-predicated
2011class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2012 bit opcod5, dag oops, dag iops, InstrItinClass itin,
2013 string asm, list<dag> pattern>
2014 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2015 VFPUnaryFrm, itin, asm, "", pattern> {
2016 list<Predicate> Predicates = [HasFullFP16];
2017
2018 // Instruction operands.
2019 bits<5> Sd;
2020 bits<5> Sm;
2021
2022 let Inst{31-28} = 0b1111;
2023
2024 // Encode instruction operands.
2025 let Inst{3-0} = Sm{4-1};
2026 let Inst{5} = Sm{0};
2027 let Inst{15-12} = Sd{4-1};
2028 let Inst{22} = Sd{0};
2029
2030 let Inst{27-23} = opcod1;
2031 let Inst{21-20} = opcod2;
2032 let Inst{19-16} = opcod3;
2033 let Inst{11-8} = 0b1001; // Half precision
2034 let Inst{7-6} = opcod4;
2035 let Inst{4} = opcod5;
Simon Tathamb70fc0c2019-02-25 10:39:53 +00002036
2037 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
Oliver Stannard65b85382016-01-25 10:26:26 +00002038}
2039
2040// Half precision, binary
2041class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
2042 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2043 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
2044 list<Predicate> Predicates = [HasFullFP16];
2045
2046 // Instruction operands.
2047 bits<5> Sd;
2048 bits<5> Sn;
2049 bits<5> Sm;
2050
2051 // Encode instruction operands.
2052 let Inst{3-0} = Sm{4-1};
2053 let Inst{5} = Sm{0};
2054 let Inst{19-16} = Sn{4-1};
2055 let Inst{7} = Sn{0};
2056 let Inst{15-12} = Sd{4-1};
2057 let Inst{22} = Sd{0};
2058
2059 let Inst{27-23} = opcod1;
2060 let Inst{21-20} = opcod2;
2061 let Inst{11-8} = 0b1001; // Half precision
2062 let Inst{6} = op6;
2063 let Inst{4} = op4;
Simon Tathamb70fc0c2019-02-25 10:39:53 +00002064
2065 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
Oliver Stannard65b85382016-01-25 10:26:26 +00002066}
2067
2068// Half precision, binary, not predicated
2069class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
2070 InstrItinClass itin, string asm, list<dag> pattern>
2071 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2072 VFPBinaryFrm, itin, asm, "", pattern> {
2073 list<Predicate> Predicates = [HasFullFP16];
2074
2075 // Instruction operands.
2076 bits<5> Sd;
2077 bits<5> Sn;
2078 bits<5> Sm;
2079
2080 let Inst{31-28} = 0b1111;
2081
2082 // Encode instruction operands.
2083 let Inst{3-0} = Sm{4-1};
2084 let Inst{5} = Sm{0};
2085 let Inst{19-16} = Sn{4-1};
2086 let Inst{7} = Sn{0};
2087 let Inst{15-12} = Sd{4-1};
2088 let Inst{22} = Sd{0};
2089
2090 let Inst{27-23} = opcod1;
2091 let Inst{21-20} = opcod2;
2092 let Inst{11-8} = 0b1001; // Half precision
2093 let Inst{6} = opcod3;
2094 let Inst{4} = 0;
Simon Tathamb70fc0c2019-02-25 10:39:53 +00002095
2096 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
Oliver Stannard65b85382016-01-25 10:26:26 +00002097}
2098
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002099// VFP conversion instructions
Johnny Chen34a6afc2010-01-29 23:21:10 +00002100class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2101 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2102 list<dag> pattern>
David Goodwinb062c232009-08-06 16:52:47 +00002103 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
Johnny Chen34a6afc2010-01-29 23:21:10 +00002104 let Inst{27-23} = opcod1;
2105 let Inst{21-20} = opcod2;
2106 let Inst{19-16} = opcod3;
2107 let Inst{11-8} = opcod4;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002108 let Inst{6} = 1;
Johnny Chen34a6afc2010-01-29 23:21:10 +00002109 let Inst{4} = 0;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002110}
2111
Johnny Chen39640592010-02-11 18:47:03 +00002112// VFP conversion between floating-point and fixed-point
2113class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002114 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2115 list<dag> pattern>
Johnny Chen39640592010-02-11 18:47:03 +00002116 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
Jim Grosbachf0d25112011-12-22 19:55:21 +00002117 bits<5> fbits;
Johnny Chen39640592010-02-11 18:47:03 +00002118 // size (fixed-point number): sx == 0 ? 16 : 32
2119 let Inst{7} = op5; // sx
Jim Grosbachf0d25112011-12-22 19:55:21 +00002120 let Inst{5} = fbits{0};
2121 let Inst{3-0} = fbits{4-1};
Johnny Chen39640592010-02-11 18:47:03 +00002122}
2123
David Goodwin85b5b022009-08-10 22:17:39 +00002124// VFP conversion instructions, if no NEON
Johnny Chen34a6afc2010-01-29 23:21:10 +00002125class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
David Goodwin85b5b022009-08-10 22:17:39 +00002126 dag oops, dag iops, InstrItinClass itin,
2127 string opc, string asm, list<dag> pattern>
Johnny Chen34a6afc2010-01-29 23:21:10 +00002128 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2129 pattern> {
David Goodwin85b5b022009-08-10 22:17:39 +00002130 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2131}
2132
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002133class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
David Goodwinb062c232009-08-06 16:52:47 +00002134 InstrItinClass itin,
2135 string opc, string asm, list<dag> pattern>
2136 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002137 let Inst{27-20} = opcod1;
Evan Cheng38c9a142008-11-11 19:40:26 +00002138 let Inst{11-8} = opcod2;
2139 let Inst{4} = 1;
2140}
2141
David Goodwinb062c232009-08-06 16:52:47 +00002142class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2143 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2144 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
Evan Cheng97ccab82008-11-11 22:46:12 +00002145
Bob Wilson3968c6a2010-03-23 17:23:59 +00002146class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
David Goodwinb062c232009-08-06 16:52:47 +00002147 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2148 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002149
David Goodwinb062c232009-08-06 16:52:47 +00002150class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2151 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2152 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
Evan Cheng4b6c7ef2008-11-12 06:41:41 +00002153
David Goodwinb062c232009-08-06 16:52:47 +00002154class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2155 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2156 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
Evan Cheng38c9a142008-11-11 19:40:26 +00002157
Evan Chengac2af2f2008-11-11 02:11:05 +00002158//===----------------------------------------------------------------------===//
2159
Bob Wilson2e076c42009-06-22 23:27:02 +00002160//===----------------------------------------------------------------------===//
2161// ARM NEON Instruction templates.
2162//
Evan Chengee98fa92008-08-29 06:41:12 +00002163
Johnny Chenf833fad2010-03-20 00:17:00 +00002164class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2165 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2166 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002167 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002168 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002169 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002170 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002171 let Pattern = pattern;
2172 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00002173 let DecoderNamespace = "NEON";
Evan Cheng738a97a2009-11-23 21:57:23 +00002174}
2175
2176// Same as NeonI except it does not have a "data type" specifier.
Johnny Chen020023a2010-03-23 20:40:44 +00002177class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2178 InstrItinClass itin, string opc, string asm, string cstr,
2179 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002180 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002181 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002182 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002183 let AsmString = !strconcat(opc, "${p}", "\t", asm);
Bob Wilson2e076c42009-06-22 23:27:02 +00002184 let Pattern = pattern;
2185 list<Predicate> Predicates = [HasNEON];
Owen Andersona6201f02011-08-15 23:38:54 +00002186 let DecoderNamespace = "NEON";
Evan Chengee98fa92008-08-29 06:41:12 +00002187}
2188
Joey Goulydf686002013-07-17 13:59:38 +00002189// Same as NeonI except it is not predicated
2190class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2191 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2192 list<dag> pattern>
2193 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2194 let OutOperandList = oops;
2195 let InOperandList = iops;
2196 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2197 let Pattern = pattern;
2198 list<Predicate> Predicates = [HasNEON];
2199 let DecoderNamespace = "NEON";
2200
2201 let Inst{31-28} = 0b1111;
2202}
2203
Bob Wilson50820a22009-10-07 21:53:04 +00002204class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2205 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002206 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenf833fad2010-03-20 00:17:00 +00002207 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2208 cstr, pattern> {
Bob Wilsonf731a2d2009-07-08 18:11:30 +00002209 let Inst{31-24} = 0b11110100;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002210 let Inst{23} = op23;
Jim Grosbach68f495c2009-10-20 00:19:08 +00002211 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002212 let Inst{11-8} = op11_8;
2213 let Inst{7-4} = op7_4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002214
Chris Lattner63274cb2010-11-15 05:19:05 +00002215 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002216 let DecoderNamespace = "NEONLoadStore";
Jim Grosbach5876e412010-11-19 22:42:55 +00002217
Owen Andersonad402342010-11-02 00:05:05 +00002218 bits<5> Vd;
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00002219 bits<6> Rn;
2220 bits<4> Rm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002221
Owen Andersonad402342010-11-02 00:05:05 +00002222 let Inst{22} = Vd{4};
2223 let Inst{15-12} = Vd{3-0};
Owen Anderson0ebd1fd2010-11-02 23:47:29 +00002224 let Inst{19-16} = Rn{3-0};
2225 let Inst{3-0} = Rm{3-0};
Bob Wilsonf731a2d2009-07-08 18:11:30 +00002226}
2227
Owen Anderson9f20daf2010-11-02 20:47:39 +00002228class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2229 dag oops, dag iops, InstrItinClass itin,
2230 string opc, string dt, string asm, string cstr, list<dag> pattern>
2231 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2232 dt, asm, cstr, pattern> {
2233 bits<3> lane;
2234}
2235
Bob Wilson9392b0e2010-08-25 23:27:42 +00002236class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
Owen Anderson651b2302011-07-13 23:22:26 +00002237 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilson9392b0e2010-08-25 23:27:42 +00002238 itin> {
2239 let OutOperandList = oops;
2240 let InOperandList = !con(iops, (ins pred:$p));
2241 list<Predicate> Predicates = [HasNEON];
2242}
2243
Jim Grosbach233b3a22010-10-06 20:36:55 +00002244class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2245 list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002246 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00002247 itin> {
2248 let OutOperandList = oops;
2249 let InOperandList = !con(iops, (ins pred:$p));
Jim Grosbach233b3a22010-10-06 20:36:55 +00002250 let Pattern = pattern;
Bob Wilsonc597fd3b2010-09-13 23:55:10 +00002251 list<Predicate> Predicates = [HasNEON];
2252}
2253
Johnny Chenac5024b2010-03-23 16:43:47 +00002254class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002255 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chenac5024b2010-03-23 16:43:47 +00002256 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2257 pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002258 let Inst{31-25} = 0b1111001;
Chris Lattner63274cb2010-11-15 05:19:05 +00002259 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00002260 let DecoderNamespace = "NEONData";
Evan Cheng738a97a2009-11-23 21:57:23 +00002261}
2262
Johnny Chen020023a2010-03-23 20:40:44 +00002263class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002264 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen020023a2010-03-23 20:40:44 +00002265 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002266 cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002267 let Inst{31-25} = 0b1111001;
Owen Andersonb538a222010-12-10 22:32:08 +00002268 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
Owen Andersona6201f02011-08-15 23:38:54 +00002269 let DecoderNamespace = "NEONData";
Bob Wilson2e076c42009-06-22 23:27:02 +00002270}
2271
2272// NEON "one register and a modified immediate" format.
2273class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2274 bit op5, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00002275 dag oops, dag iops, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002276 string opc, string dt, string asm, string cstr,
2277 list<dag> pattern>
Johnny Chen6a643202010-03-23 23:09:14 +00002278 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002279 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002280 let Inst{21-19} = op21_19;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002281 let Inst{11-8} = op11_8;
2282 let Inst{7} = op7;
2283 let Inst{6} = op6;
2284 let Inst{5} = op5;
2285 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002286
Owen Anderson284cb362010-10-26 17:40:54 +00002287 // Instruction operands.
2288 bits<5> Vd;
2289 bits<13> SIMM;
Jim Grosbach5876e412010-11-19 22:42:55 +00002290
Owen Anderson284cb362010-10-26 17:40:54 +00002291 let Inst{15-12} = Vd{3-0};
2292 let Inst{22} = Vd{4};
2293 let Inst{24} = SIMM{7};
2294 let Inst{18-16} = SIMM{6-4};
2295 let Inst{3-0} = SIMM{3-0};
David Greenfdedf242019-07-23 09:19:24 +00002296 let DecoderMethod = "DecodeVMOVModImmInstruction";
Bob Wilson2e076c42009-06-22 23:27:02 +00002297}
2298
2299// NEON 2 vector register format.
2300class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2301 bits<5> op11_7, bit op6, bit op4,
David Goodwinb062c232009-08-06 16:52:47 +00002302 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002303 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002304 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
Evan Cheng738a97a2009-11-23 21:57:23 +00002305 let Inst{24-23} = op24_23;
2306 let Inst{21-20} = op21_20;
2307 let Inst{19-18} = op19_18;
2308 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002309 let Inst{11-7} = op11_7;
2310 let Inst{6} = op6;
2311 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002312
Owen Anderson24774462010-10-25 18:43:52 +00002313 // Instruction operands.
2314 bits<5> Vd;
2315 bits<5> Vm;
2316
2317 let Inst{15-12} = Vd{3-0};
2318 let Inst{22} = Vd{4};
2319 let Inst{3-0} = Vm{3-0};
2320 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002321}
2322
Joey Gouly943dd592013-07-18 11:53:22 +00002323// Same as N2V but not predicated.
Amara Emerson33089092013-09-19 11:59:01 +00002324class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
Joey Gouly943dd592013-07-18 11:53:22 +00002325 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
Tim Northover6ad1f5c2014-04-28 13:53:00 +00002326 string Dt, list<dag> pattern>
Joey Gouly943dd592013-07-18 11:53:22 +00002327 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2328 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2329 bits<5> Vd;
2330 bits<5> Vm;
2331
2332 // Encode instruction operands
2333 let Inst{22} = Vd{4};
2334 let Inst{15-12} = Vd{3-0};
2335 let Inst{5} = Vm{4};
2336 let Inst{3-0} = Vm{3-0};
2337
2338 // Encode constant bits
2339 let Inst{27-23} = 0b00111;
2340 let Inst{21-20} = 0b11;
Amara Emerson33089092013-09-19 11:59:01 +00002341 let Inst{19-18} = op19_18;
Joey Gouly943dd592013-07-18 11:53:22 +00002342 let Inst{17-16} = op17_16;
2343 let Inst{11} = 0;
2344 let Inst{10-8} = op10_8;
2345 let Inst{7} = op7;
2346 let Inst{6} = op6;
2347 let Inst{4} = 0;
2348
2349 let DecoderNamespace = "NEON";
2350}
2351
Evan Cheng738a97a2009-11-23 21:57:23 +00002352// Same as N2V except it doesn't have a datatype suffix.
2353class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002354 bits<5> op11_7, bit op6, bit op4,
2355 dag oops, dag iops, InstrItinClass itin,
2356 string opc, string asm, string cstr, list<dag> pattern>
Johnny Chen9b1f60a2010-03-24 00:57:50 +00002357 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002358 let Inst{24-23} = op24_23;
2359 let Inst{21-20} = op21_20;
2360 let Inst{19-18} = op19_18;
2361 let Inst{17-16} = op17_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002362 let Inst{11-7} = op11_7;
2363 let Inst{6} = op6;
2364 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002365
Owen Anderson24774462010-10-25 18:43:52 +00002366 // Instruction operands.
2367 bits<5> Vd;
2368 bits<5> Vm;
2369
2370 let Inst{15-12} = Vd{3-0};
2371 let Inst{22} = Vd{4};
2372 let Inst{3-0} = Vm{3-0};
2373 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002374}
2375
2376// NEON 2 vector register with immediate.
Bob Wilsonbd3650c2009-10-21 02:15:46 +00002377class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
Johnny Chend82f9002010-03-25 20:39:04 +00002378 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002379 string opc, string dt, string asm, string cstr, list<dag> pattern>
Johnny Chend82f9002010-03-25 20:39:04 +00002380 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002381 let Inst{24} = op24;
2382 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002383 let Inst{11-8} = op11_8;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002384 let Inst{7} = op7;
2385 let Inst{6} = op6;
2386 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002387
Owen Anderson3665fee2010-10-26 20:56:57 +00002388 // Instruction operands.
2389 bits<5> Vd;
2390 bits<5> Vm;
2391 bits<6> SIMM;
2392
2393 let Inst{15-12} = Vd{3-0};
2394 let Inst{22} = Vd{4};
2395 let Inst{3-0} = Vm{3-0};
2396 let Inst{5} = Vm{4};
2397 let Inst{21-16} = SIMM{5-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002398}
2399
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002400// NEON 3 vector register format.
Owen Andersonabda3ca2011-03-30 23:45:29 +00002401
Jim Grosbacheca54e42011-05-19 17:34:53 +00002402class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2403 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2404 string opc, string dt, string asm, string cstr,
2405 list<dag> pattern>
Johnny Chen2cf04952010-03-26 21:26:28 +00002406 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002407 let Inst{24} = op24;
2408 let Inst{23} = op23;
Evan Cheng738a97a2009-11-23 21:57:23 +00002409 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002410 let Inst{11-8} = op11_8;
2411 let Inst{6} = op6;
2412 let Inst{4} = op4;
Owen Andersonabda3ca2011-03-30 23:45:29 +00002413}
2414
2415class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2416 dag oops, dag iops, Format f, InstrItinClass itin,
2417 string opc, string dt, string asm, string cstr, list<dag> pattern>
2418 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2419 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
Owen Anderson9e44cf22010-10-21 20:21:49 +00002420 // Instruction operands.
2421 bits<5> Vd;
2422 bits<5> Vn;
2423 bits<5> Vm;
2424
2425 let Inst{15-12} = Vd{3-0};
2426 let Inst{22} = Vd{4};
2427 let Inst{19-16} = Vn{3-0};
2428 let Inst{7} = Vn{4};
2429 let Inst{3-0} = Vm{3-0};
2430 let Inst{5} = Vm{4};
Evan Cheng738a97a2009-11-23 21:57:23 +00002431}
2432
Joey Goulydf686002013-07-17 13:59:38 +00002433class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2434 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
Tim Northover6ad1f5c2014-04-28 13:53:00 +00002435 string OpcodeStr, string Dt, list<dag> pattern>
Joey Goulydf686002013-07-17 13:59:38 +00002436 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2437 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2438 bits<5> Vd;
2439 bits<5> Vn;
2440 bits<5> Vm;
2441
2442 // Encode instruction operands
2443 let Inst{22} = Vd{4};
2444 let Inst{15-12} = Vd{3-0};
2445 let Inst{19-16} = Vn{3-0};
2446 let Inst{7} = Vn{4};
2447 let Inst{5} = Vm{4};
2448 let Inst{3-0} = Vm{3-0};
2449
2450 // Encode constant bits
2451 let Inst{27-23} = op27_23;
2452 let Inst{21-20} = op21_20;
2453 let Inst{11-8} = op11_8;
2454 let Inst{6} = op6;
2455 let Inst{4} = op4;
2456}
2457
Jim Grosbacheca54e42011-05-19 17:34:53 +00002458class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2459 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2460 string opc, string dt, string asm, string cstr,
2461 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002462 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2463 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2464
2465 // Instruction operands.
2466 bits<5> Vd;
2467 bits<5> Vn;
2468 bits<5> Vm;
2469 bit lane;
2470
2471 let Inst{15-12} = Vd{3-0};
2472 let Inst{22} = Vd{4};
2473 let Inst{19-16} = Vn{3-0};
2474 let Inst{7} = Vn{4};
2475 let Inst{3-0} = Vm{3-0};
2476 let Inst{5} = lane;
2477}
2478
Jim Grosbacheca54e42011-05-19 17:34:53 +00002479class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2480 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2481 string opc, string dt, string asm, string cstr,
2482 list<dag> pattern>
Owen Andersonabda3ca2011-03-30 23:45:29 +00002483 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2484 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2485
2486 // Instruction operands.
2487 bits<5> Vd;
2488 bits<5> Vn;
2489 bits<5> Vm;
2490 bits<2> lane;
2491
2492 let Inst{15-12} = Vd{3-0};
2493 let Inst{22} = Vd{4};
2494 let Inst{19-16} = Vn{3-0};
2495 let Inst{7} = Vn{4};
2496 let Inst{2-0} = Vm{2-0};
2497 let Inst{5} = lane{1};
2498 let Inst{3} = lane{0};
2499}
2500
Johnny Chen8a687232010-03-23 21:35:03 +00002501// Same as N3V except it doesn't have a data type suffix.
Bob Wilson3968c6a2010-03-23 17:23:59 +00002502class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2503 bit op4,
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002504 dag oops, dag iops, Format f, InstrItinClass itin,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002505 string opc, string asm, string cstr, list<dag> pattern>
Bob Wilsoncf603fb2010-03-27 03:56:52 +00002506 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
Bill Wendlingb70dc872010-08-31 07:50:46 +00002507 let Inst{24} = op24;
2508 let Inst{23} = op23;
Bob Wilson2e076c42009-06-22 23:27:02 +00002509 let Inst{21-20} = op21_20;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002510 let Inst{11-8} = op11_8;
2511 let Inst{6} = op6;
2512 let Inst{4} = op4;
Jim Grosbach5876e412010-11-19 22:42:55 +00002513
Owen Andersondff239c2010-10-25 18:28:30 +00002514 // Instruction operands.
2515 bits<5> Vd;
2516 bits<5> Vn;
2517 bits<5> Vm;
2518
2519 let Inst{15-12} = Vd{3-0};
2520 let Inst{22} = Vd{4};
2521 let Inst{19-16} = Vn{3-0};
2522 let Inst{7} = Vn{4};
2523 let Inst{3-0} = Vm{3-0};
2524 let Inst{5} = Vm{4};
Bob Wilson2e076c42009-06-22 23:27:02 +00002525}
2526
2527// NEON VMOVs between scalar and core registers.
2528class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002529 dag oops, dag iops, Format f, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002530 string opc, string dt, string asm, list<dag> pattern>
Owen Anderson651b2302011-07-13 23:22:26 +00002531 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
Bob Wilson3968c6a2010-03-23 17:23:59 +00002532 "", itin> {
Bob Wilson2e076c42009-06-22 23:27:02 +00002533 let Inst{27-20} = opcod1;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002534 let Inst{11-8} = opcod2;
2535 let Inst{6-5} = opcod3;
2536 let Inst{4} = 1;
Johnny Chen8bca1742011-04-06 18:27:46 +00002537 // A8.6.303, A8.6.328, A8.6.329
2538 let Inst{3-0} = 0b0000;
Evan Cheng738a97a2009-11-23 21:57:23 +00002539
2540 let OutOperandList = oops;
Chris Lattnerfb2ceed2010-03-18 21:06:54 +00002541 let InOperandList = !con(iops, (ins pred:$p));
Chris Lattner04c342e2010-10-06 00:05:18 +00002542 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
Evan Cheng738a97a2009-11-23 21:57:23 +00002543 let Pattern = pattern;
Bob Wilson2e076c42009-06-22 23:27:02 +00002544 list<Predicate> Predicates = [HasNEON];
Jim Grosbach5876e412010-11-19 22:42:55 +00002545
Chris Lattner63274cb2010-11-15 05:19:05 +00002546 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
Owen Andersonc86a5bd2011-08-10 19:01:10 +00002547 let DecoderNamespace = "NEONDup";
Jim Grosbach5876e412010-11-19 22:42:55 +00002548
Owen Andersoned9652f2010-10-27 21:28:09 +00002549 bits<5> V;
2550 bits<4> R;
Owen Anderson40d24a42010-10-27 19:25:54 +00002551 bits<4> p;
Owen Andersoned9652f2010-10-27 21:28:09 +00002552 bits<4> lane;
Jim Grosbach5876e412010-11-19 22:42:55 +00002553
Owen Anderson40d24a42010-10-27 19:25:54 +00002554 let Inst{31-28} = p{3-0};
Owen Andersoned9652f2010-10-27 21:28:09 +00002555 let Inst{7} = V{4};
2556 let Inst{19-16} = V{3-0};
2557 let Inst{15-12} = R{3-0};
Bob Wilson2e076c42009-06-22 23:27:02 +00002558}
2559class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002560 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002561 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002562 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002563 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002564class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002565 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002566 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002567 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002568 opc, dt, asm, pattern>;
Bob Wilson2e076c42009-06-22 23:27:02 +00002569class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
David Goodwinb062c232009-08-06 16:52:47 +00002570 dag oops, dag iops, InstrItinClass itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002571 string opc, string dt, string asm, list<dag> pattern>
Bob Wilsoncc386fb2010-06-25 23:56:05 +00002572 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
Evan Cheng738a97a2009-11-23 21:57:23 +00002573 opc, dt, asm, pattern>;
David Goodwin3b9c52c2009-08-04 17:53:06 +00002574
Johnny Chen45ab3f32010-03-25 17:01:27 +00002575// Vector Duplicate Lane (from scalar to all elements)
2576class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2577 InstrItinClass itin, string opc, string dt, string asm,
2578 list<dag> pattern>
Johnny Chen91d27742010-03-25 21:49:12 +00002579 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
Johnny Chen45ab3f32010-03-25 17:01:27 +00002580 let Inst{24-23} = 0b11;
2581 let Inst{21-20} = 0b11;
2582 let Inst{19-16} = op19_16;
Bill Wendlingb70dc872010-08-31 07:50:46 +00002583 let Inst{11-7} = 0b11000;
2584 let Inst{6} = op6;
2585 let Inst{4} = 0;
Jim Grosbach5876e412010-11-19 22:42:55 +00002586
Owen Anderson40d24a42010-10-27 19:25:54 +00002587 bits<5> Vd;
2588 bits<5> Vm;
Jim Grosbach5876e412010-11-19 22:42:55 +00002589
Owen Anderson40d24a42010-10-27 19:25:54 +00002590 let Inst{22} = Vd{4};
2591 let Inst{15-12} = Vd{3-0};
2592 let Inst{5} = Vm{4};
2593 let Inst{3-0} = Vm{3-0};
Johnny Chen45ab3f32010-03-25 17:01:27 +00002594}
2595
David Goodwin3b9c52c2009-08-04 17:53:06 +00002596// NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2597// for single-precision FP.
2598class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2599 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2600}
Jim Grosbach7996b152011-11-14 22:28:39 +00002601
2602// VFP/NEON Instruction aliases for type suffices.
Sjoerd Meijer9da258d2016-06-03 13:19:43 +00002603// Note: When EmitPriority == 1, the alias will be used for printing
2604class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
Mikhail Maltseved143c52019-07-10 08:59:17 +00002605 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002606
Sjoerd Meijer9da258d2016-06-03 13:19:43 +00002607// Note: When EmitPriority == 1, the alias will be used for printing
2608multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2609 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2610 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2611 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2612 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002613}
2614
Sjoerd Meijer9da258d2016-06-03 13:19:43 +00002615// Note: When EmitPriority == 1, the alias will be used for printing
2616multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
Jim Grosbach681db342012-01-24 17:23:29 +00002617 let Predicates = [HasNEON] in {
Sjoerd Meijer9da258d2016-06-03 13:19:43 +00002618 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2619 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2620 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2621 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
Jim Grosbach681db342012-01-24 17:23:29 +00002622}
2623}
2624
Jim Grosbache7dcbc82011-12-02 18:52:30 +00002625// The same alias classes using AsmPseudo instead, for the more complex
2626// stuff in NEON that InstAlias can't quite handle.
2627// Note that we can't use anonymous defm references here like we can
2628// above, as we care about the ultimate instruction enum names generated, unlike
2629// for instalias defs.
2630class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
Jim Grosbachdda976b2011-12-02 22:01:52 +00002631 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
Jim Grosbach585ce302011-12-07 01:17:58 +00002632
Sam Parker963da5b2017-09-29 13:11:33 +00002633// Extension of NEON 3-vector data processing instructions in coprocessor 8
2634// encoding space, introduced in ARMv8.3-A.
2635class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2636 dag oops, dag iops, InstrItinClass itin,
2637 string opc, string dt, string asm, string cstr, list<dag> pattern>
2638 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2639 dt, asm, cstr, pattern> {
2640 bits<5> Vd;
2641 bits<5> Vn;
2642 bits<5> Vm;
2643
2644 let DecoderNamespace = "VFPV8";
2645 // These have the same encodings in ARM and Thumb2
2646 let PostEncoderMethod = "";
2647
2648 let Inst{31-25} = 0b1111110;
2649 let Inst{24-23} = op24_23;
2650 let Inst{22} = Vd{4};
2651 let Inst{21-20} = op21_20;
2652 let Inst{19-16} = Vn{3-0};
2653 let Inst{15-12} = Vd{3-0};
2654 let Inst{11-8} = 0b1000;
2655 let Inst{7} = Vn{4};
2656 let Inst{6} = op6;
2657 let Inst{5} = Vm{4};
2658 let Inst{4} = op4;
2659 let Inst{3-0} = Vm{3-0};
2660}
2661
2662// Extension of NEON 2-vector-and-scalar data processing instructions in
2663// coprocessor 8 encoding space, introduced in ARMv8.3-A.
2664class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2665 dag oops, dag iops, InstrItinClass itin,
2666 string opc, string dt, string asm, string cstr, list<dag> pattern>
2667 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2668 dt, asm, cstr, pattern> {
2669 bits<5> Vd;
2670 bits<5> Vn;
2671 bits<5> Vm;
2672
2673 let DecoderNamespace = "VFPV8";
2674 // These have the same encodings in ARM and Thumb2
2675 let PostEncoderMethod = "";
2676
2677 let Inst{31-24} = 0b11111110;
2678 let Inst{23} = op23;
2679 let Inst{22} = Vd{4};
2680 let Inst{21-20} = op21_20;
2681 let Inst{19-16} = Vn{3-0};
2682 let Inst{15-12} = Vd{3-0};
2683 let Inst{11-8} = 0b1000;
2684 let Inst{7} = Vn{4};
2685 let Inst{6} = op6;
2686 // Bit 5 set by sub-classes
2687 let Inst{4} = op4;
2688 let Inst{3-0} = Vm{3-0};
2689}
2690
Bernard Ogdenb828bb22018-08-17 11:29:49 +00002691// In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
2692// differently:
2693// if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
2694// if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
2695// Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
2696class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2697 dag oops, dag iops, InstrItinClass itin,
2698 string opc, string dt, string asm, string cstr, list<dag> pattern>
2699 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
2700 bits<5> Vd;
2701 bits<5> Vn;
2702 bits<5> Vm;
2703
2704 let DecoderNamespace = "VFPV8";
2705 // These have the same encodings in ARM and Thumb2
2706 let PostEncoderMethod = "";
2707
2708 let Inst{31-25} = 0b1111110;
2709 let Inst{24-23} = op24_23;
2710 let Inst{22} = Vd{4};
2711 let Inst{21-20} = op21_20;
2712 let Inst{19-16} = Vn{4-1};
2713 let Inst{15-12} = Vd{3-0};
2714 let Inst{11-8} = 0b1000;
2715 let Inst{7} = Vn{0};
2716 let Inst{6} = op6;
2717 let Inst{5} = Vm{0};
2718 let Inst{4} = op4;
2719 let Inst{3-0} = Vm{4-1};
2720}
2721
Sam Parker963da5b2017-09-29 13:11:33 +00002722// Operand types for complex instructions
Oliver Stannard0d5c7922017-10-03 14:38:52 +00002723class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
Sam Parker963da5b2017-09-29 13:11:33 +00002724 : AsmOperandClass {
2725 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
Oliver Stannard0d5c7922017-10-03 14:38:52 +00002726 let DiagnosticString = "complex rotation must be " # Diag;
Sam Parker963da5b2017-09-29 13:11:33 +00002727 let Name = "ComplexRotation" # Type;
2728}
2729def complexrotateop : Operand<i32> {
Oliver Stannard0d5c7922017-10-03 14:38:52 +00002730 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
Sam Parker963da5b2017-09-29 13:11:33 +00002731 let PrintMethod = "printComplexRotationOp<90, 0>";
2732}
2733def complexrotateopodd : Operand<i32> {
Oliver Stannard0d5c7922017-10-03 14:38:52 +00002734 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
Sam Parker963da5b2017-09-29 13:11:33 +00002735 let PrintMethod = "printComplexRotationOp<180, 90>";
2736}
2737
Mikhail Maltsev0b001f92019-07-19 09:46:28 +00002738def MveSaturateOperand : AsmOperandClass {
2739 let PredicateMethod = "isMveSaturateOp";
2740 let DiagnosticString = "saturate operand must be 48 or 64";
2741 let Name = "MveSaturate";
2742}
2743def saturateop : Operand<i32> {
2744 let ParserMatchClass = MveSaturateOperand;
2745 let PrintMethod = "printMveSaturateOp";
2746}
2747
Jim Grosbach585ce302011-12-07 01:17:58 +00002748// Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2749def : TokenAlias<".s8", ".i8">;
2750def : TokenAlias<".u8", ".i8">;
2751def : TokenAlias<".s16", ".i16">;
2752def : TokenAlias<".u16", ".i16">;
2753def : TokenAlias<".s32", ".i32">;
2754def : TokenAlias<".u32", ".i32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002755def : TokenAlias<".s64", ".i64">;
2756def : TokenAlias<".u64", ".i64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002757
2758def : TokenAlias<".i8", ".8">;
2759def : TokenAlias<".i16", ".16">;
2760def : TokenAlias<".i32", ".32">;
Jim Grosbach2cf294a2011-12-07 01:50:36 +00002761def : TokenAlias<".i64", ".64">;
Jim Grosbach585ce302011-12-07 01:17:58 +00002762
2763def : TokenAlias<".p8", ".8">;
2764def : TokenAlias<".p16", ".16">;
2765
2766def : TokenAlias<".f32", ".32">;
2767def : TokenAlias<".f64", ".64">;
2768def : TokenAlias<".f", ".f32">;
2769def : TokenAlias<".d", ".f64">;