1 //===-- ARMInstrFormats.td - ARM Instruction Formats -------*- tablegen -*-===//
3 // 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
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 // ARM Instruction Format Definitions.
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
17 class Format<bits<6> val> {
21 def Pseudo : Format<0>;
22 def MulFrm : Format<1>;
23 def BrFrm : Format<2>;
24 def BrMiscFrm : Format<3>;
26 def DPFrm : Format<4>;
27 def DPSoRegRegFrm : Format<5>;
29 def LdFrm : Format<6>;
30 def StFrm : Format<7>;
31 def LdMiscFrm : Format<8>;
32 def StMiscFrm : Format<9>;
33 def LdStMulFrm : Format<10>;
35 def LdStExFrm : Format<11>;
37 def ArithMiscFrm : Format<12>;
38 def SatFrm : Format<13>;
39 def ExtFrm : Format<14>;
41 def VFPUnaryFrm : Format<15>;
42 def VFPBinaryFrm : Format<16>;
43 def VFPConv1Frm : Format<17>;
44 def VFPConv2Frm : Format<18>;
45 def VFPConv3Frm : Format<19>;
46 def VFPConv4Frm : Format<20>;
47 def VFPConv5Frm : Format<21>;
48 def VFPLdStFrm : Format<22>;
49 def VFPLdStMulFrm : Format<23>;
50 def VFPMiscFrm : Format<24>;
52 def ThumbFrm : Format<25>;
53 def MiscFrm : Format<26>;
55 def NGetLnFrm : Format<27>;
56 def NSetLnFrm : Format<28>;
57 def NDupFrm : Format<29>;
58 def NLdStFrm : Format<30>;
59 def N1RegModImmFrm: Format<31>;
60 def N2RegFrm : Format<32>;
61 def NVCVTFrm : Format<33>;
62 def NVDupLnFrm : Format<34>;
63 def N2RegVShLFrm : Format<35>;
64 def N2RegVShRFrm : Format<36>;
65 def N3RegFrm : Format<37>;
66 def N3RegVShFrm : Format<38>;
67 def NVExtFrm : Format<39>;
68 def NVMulSLFrm : Format<40>;
69 def NVTBLFrm : Format<41>;
70 def DPSoRegImmFrm : Format<42>;
71 def N3RegCplxFrm : Format<43>;
75 // The instruction has an Rn register operand.
76 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
77 // it doesn't have a Rn operand.
78 class UnaryDP { bit isUnaryDataProc = 1; }
80 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
81 // a 16-bit Thumb instruction if certain conditions are met.
82 class Xform16Bit { bit canXformTo16Bit = 1; }
84 //===----------------------------------------------------------------------===//
85 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
88 // FIXME: Once the JIT is MC-ized, these can go away.
90 class AddrMode<bits<5> val> {
93 def AddrModeNone : AddrMode<0>;
94 def AddrMode1 : AddrMode<1>;
95 def AddrMode2 : AddrMode<2>;
96 def AddrMode3 : AddrMode<3>;
97 def AddrMode4 : AddrMode<4>;
98 def AddrMode5 : AddrMode<5>;
99 def AddrMode6 : AddrMode<6>;
100 def AddrModeT1_1 : AddrMode<7>;
101 def AddrModeT1_2 : AddrMode<8>;
102 def AddrModeT1_4 : AddrMode<9>;
103 def AddrModeT1_s : AddrMode<10>;
104 def AddrModeT2_i12 : AddrMode<11>;
105 def AddrModeT2_i8 : AddrMode<12>;
106 def AddrModeT2_so : AddrMode<13>;
107 def AddrModeT2_pc : AddrMode<14>;
108 def AddrModeT2_i8s4 : AddrMode<15>;
109 def AddrMode_i12 : AddrMode<16>;
110 def AddrMode5FP16 : AddrMode<17>;
111 def AddrModeT2_ldrex : AddrMode<18>;
112 def AddrModeT2_i7s4 : AddrMode<19>;
113 def AddrModeT2_i7s2 : AddrMode<20>;
114 def AddrModeT2_i7 : AddrMode<21>;
116 // Load / store index mode.
117 class IndexMode<bits<2> val> {
120 def IndexModeNone : IndexMode<0>;
121 def IndexModePre : IndexMode<1>;
122 def IndexModePost : IndexMode<2>;
123 def IndexModeUpd : IndexMode<3>;
125 // Instruction execution domain.
126 class Domain<bits<4> val> {
129 def GenericDomain : Domain<0>;
130 def VFPDomain : Domain<1>; // Instructions in VFP domain only
131 def NeonDomain : Domain<2>; // Instructions in Neon domain only
132 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
133 def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
134 def MVEDomain : Domain<8>; // Instructions in MVE and ARMv8.1m
136 //===----------------------------------------------------------------------===//
137 // ARM special operands.
140 // ARM imod and iflag operands, used only by the CPS instruction.
141 def imod_op : Operand<i32> {
142 let PrintMethod = "printCPSIMod";
145 def ProcIFlagsOperand : AsmOperandClass {
146 let Name = "ProcIFlags";
147 let ParserMethod = "parseProcIFlagsOperand";
149 def iflags_op : Operand<i32> {
150 let PrintMethod = "printCPSIFlag";
151 let ParserMatchClass = ProcIFlagsOperand;
154 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
155 // register whose default is 0 (no register).
156 def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
157 def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
158 (ops (i32 14), (i32 zero_reg))> {
159 let PrintMethod = "printPredicateOperand";
160 let ParserMatchClass = CondCodeOperand;
161 let DecoderMethod = "DecodePredicateOperand";
164 // 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.
168 def cmovpred : Operand<i32>, PredicateOp,
169 ComplexPattern<i32, 2, "SelectCMOVPred"> {
170 let MIOperandInfo = (ops i32imm, i32imm);
171 let PrintMethod = "printPredicateOperand";
174 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
175 def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
176 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
177 let EncoderMethod = "getCCOutOpValue";
178 let PrintMethod = "printSBitModifierOperand";
179 let ParserMatchClass = CCOutOperand;
180 let DecoderMethod = "DecodeCCOutOperand";
183 // Same as cc_out except it defaults to setting CPSR.
184 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
185 let EncoderMethod = "getCCOutOpValue";
186 let PrintMethod = "printSBitModifierOperand";
187 let ParserMatchClass = CCOutOperand;
188 let DecoderMethod = "DecodeCCOutOperand";
191 // Transform to generate the inverse of a condition code during ISel
192 def inv_cond_XFORM : SDNodeXForm<imm, [{
193 ARMCC::CondCodes CC = static_cast<ARMCC::CondCodes>(N->getZExtValue());
194 return CurDAG->getTargetConstant(ARMCC::getOppositeCondition(CC), SDLoc(N),
200 def VPTPredNOperand : AsmOperandClass {
201 let Name = "VPTPredN";
202 let PredicateMethod = "isVPTPred";
204 def VPTPredROperand : AsmOperandClass {
205 let Name = "VPTPredR";
206 let PredicateMethod = "isVPTPred";
208 def undef_tied_input;
210 // Operand classes for the cluster of MC operands describing a
211 // VPT-predicated MVE instruction.
213 // There are two of these classes. Both of them have the same first
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.
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).
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.
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.
251 // Base class for both kinds of vpred.
252 class 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);
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;
265 def 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";
272 def vpred_n : vpred_ops<(ops), (ops)> {
273 let ParserMatchClass = VPTPredNOperand;
274 let OperandType = "OPERAND_VPRED_N";
275 let vpred_constraint = "";
278 // ARM special operands for disassembly only.
280 def SetEndAsmOperand : ImmAsmOperand<0,1> {
281 let Name = "SetEndImm";
282 let ParserMethod = "parseSetEndImm";
284 def setend_op : Operand<i32> {
285 let PrintMethod = "printSetendOperand";
286 let ParserMatchClass = SetEndAsmOperand;
289 def MSRMaskOperand : AsmOperandClass {
290 let Name = "MSRMask";
291 let ParserMethod = "parseMSRMaskOperand";
293 def msr_mask : Operand<i32> {
294 let PrintMethod = "printMSRMaskOperand";
295 let DecoderMethod = "DecodeMSRMask";
296 let ParserMatchClass = MSRMaskOperand;
299 def BankedRegOperand : AsmOperandClass {
300 let Name = "BankedReg";
301 let ParserMethod = "parseBankedRegOperand";
303 def banked_reg : Operand<i32> {
304 let PrintMethod = "printBankedRegOperand";
305 let DecoderMethod = "DecodeBankedReg";
306 let ParserMatchClass = BankedRegOperand;
309 // Shift Right Immediate - A shift right immediate is encoded differently from
310 // other shift immediates. The imm6 field is encoded like so:
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>
317 def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
318 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
319 let EncoderMethod = "getShiftRight8Imm";
320 let DecoderMethod = "DecodeShiftRight8Imm";
321 let ParserMatchClass = shr_imm8_asm_operand;
323 def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
324 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
325 let EncoderMethod = "getShiftRight16Imm";
326 let DecoderMethod = "DecodeShiftRight16Imm";
327 let ParserMatchClass = shr_imm16_asm_operand;
329 def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
330 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
331 let EncoderMethod = "getShiftRight32Imm";
332 let DecoderMethod = "DecodeShiftRight32Imm";
333 let ParserMatchClass = shr_imm32_asm_operand;
335 def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
336 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
337 let EncoderMethod = "getShiftRight64Imm";
338 let DecoderMethod = "DecodeShiftRight64Imm";
339 let ParserMatchClass = shr_imm64_asm_operand;
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
345 def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
346 def const_pool_asm_imm : Operand<i32> {
347 let ParserMatchClass = const_pool_asm_operand;
351 //===----------------------------------------------------------------------===//
352 // ARM Assembler alias templates.
354 // Note: When EmitPriority == 1, the alias will be used for printing
355 class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
356 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
357 class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
358 : InstAlias<Asm, Result, EmitPriority>,
359 Requires<[IsARM,UseNegativeImmediates]>;
360 class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
361 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
362 class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
363 : InstAlias<Asm, Result, EmitPriority>,
364 Requires<[IsThumb,UseNegativeImmediates]>;
365 class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
366 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
367 class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
368 : InstAlias<Asm, Result, EmitPriority>,
369 Requires<[IsThumb2,UseNegativeImmediates]>;
370 class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
371 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
372 class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
373 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
374 class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
375 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
376 class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
377 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
378 class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
379 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
382 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
384 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
387 //===----------------------------------------------------------------------===//
388 // ARM Instruction templates.
392 class InstTemplate<AddrMode am, int sz, IndexMode im,
393 Format f, Domain d, string cstr, InstrItinClass itin>
395 let Namespace = "ARM";
400 bits<2> IndexModeBits = IM.Value;
402 bits<6> Form = F.Value;
404 bit isUnaryDataProc = 0;
405 bit canXformTo16Bit = 0;
406 // 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;
411 bit validForTailPredication = 0;
413 // If this is a pseudo instruction, mark it isCodeGenOnly.
414 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
416 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
417 let TSFlags{4-0} = AM.Value;
418 let TSFlags{6-5} = IndexModeBits;
419 let TSFlags{12-7} = Form;
420 let TSFlags{13} = isUnaryDataProc;
421 let TSFlags{14} = canXformTo16Bit;
422 let TSFlags{18-15} = D.Value;
423 let TSFlags{19} = thumbArithFlagSetting;
424 let TSFlags{20} = validForTailPredication;
426 let Constraints = cstr;
427 let Itinerary = itin;
432 // 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;
442 class InstARM<AddrMode am, int sz, IndexMode im,
443 Format f, Domain d, string cstr, InstrItinClass itin>
444 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
445 let DecoderNamespace = "ARM";
448 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
449 // on by adding flavors to specific instructions.
450 class InstThumb<AddrMode am, int sz, IndexMode im,
451 Format f, Domain d, string cstr, InstrItinClass itin>
452 : InstTemplate<am, sz, im, f, d, cstr, itin> {
453 let DecoderNamespace = "Thumb";
456 // 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.
459 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
460 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
462 let OutOperandList = oops;
463 let InOperandList = iops;
465 let isCodeGenOnly = 0; // So we get asm matcher for it.
468 let hasNoSchedulingInfo = 1;
471 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
472 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
473 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
474 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
475 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
476 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
477 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
478 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
479 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
480 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
481 class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
482 : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
484 // Pseudo instructions for the code generator.
485 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
486 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
487 GenericDomain, "", itin> {
488 let OutOperandList = oops;
489 let InOperandList = iops;
490 let Pattern = pattern;
491 let isCodeGenOnly = 1;
495 // PseudoInst that's ARM-mode only.
496 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
498 : PseudoInst<oops, iops, itin, pattern> {
500 list<Predicate> Predicates = [IsARM];
503 // PseudoInst that's Thumb-mode only.
504 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
506 : PseudoInst<oops, iops, itin, pattern> {
508 list<Predicate> Predicates = [IsThumb];
511 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
512 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
514 : PseudoInst<oops, iops, itin, pattern> {
516 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
519 // PseudoInst that's Thumb2-mode only.
520 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
522 : PseudoInst<oops, iops, itin, pattern> {
524 list<Predicate> Predicates = [IsThumb2];
527 class ARMPseudoExpand<dag oops, dag iops, int sz,
528 InstrItinClass itin, list<dag> pattern,
530 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
531 PseudoInstExpansion<Result>;
533 class tPseudoExpand<dag oops, dag iops, int sz,
534 InstrItinClass itin, list<dag> pattern,
536 : tPseudoInst<oops, iops, sz, itin, pattern>,
537 PseudoInstExpansion<Result>;
539 class t2PseudoExpand<dag oops, dag iops, int sz,
540 InstrItinClass itin, list<dag> pattern,
542 : t2PseudoInst<oops, iops, sz, itin, pattern>,
543 PseudoInstExpansion<Result>;
545 // Almost all ARM instructions are predicable.
546 class I<dag oops, dag iops, AddrMode am, int sz,
547 IndexMode im, Format f, InstrItinClass itin,
548 string opc, string asm, string cstr,
550 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
553 let OutOperandList = oops;
554 let InOperandList = !con(iops, (ins pred:$p));
555 let AsmString = !strconcat(opc, "${p}", asm);
556 let Pattern = pattern;
557 list<Predicate> Predicates = [IsARM];
560 // A few are not predicable
561 class InoP<dag oops, dag iops, AddrMode am, int sz,
562 IndexMode im, Format f, InstrItinClass itin,
563 string opc, string asm, string cstr,
565 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
566 let OutOperandList = oops;
567 let InOperandList = iops;
568 let AsmString = !strconcat(opc, asm);
569 let Pattern = pattern;
570 let isPredicable = 0;
571 list<Predicate> Predicates = [IsARM];
574 // 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".
577 class sI<dag oops, dag iops, AddrMode am, int sz,
578 IndexMode im, Format f, InstrItinClass itin,
579 string opc, string asm, string cstr,
581 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
582 bits<4> p; // Predicate operand
583 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
587 let OutOperandList = oops;
588 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
589 let AsmString = !strconcat(opc, "${s}${p}", asm);
590 let Pattern = pattern;
591 list<Predicate> Predicates = [IsARM];
595 class XI<dag oops, dag iops, AddrMode am, int sz,
596 IndexMode im, Format f, InstrItinClass itin,
597 string asm, string cstr, list<dag> pattern>
598 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
599 let OutOperandList = oops;
600 let InOperandList = iops;
602 let Pattern = pattern;
603 list<Predicate> Predicates = [IsARM];
606 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, list<dag> pattern>
608 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
609 opc, asm, "", pattern>;
610 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
611 string opc, string asm, list<dag> pattern>
612 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
613 opc, asm, "", pattern>;
614 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
615 string asm, list<dag> pattern>
616 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
618 class 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,
622 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
623 string opc, string asm, list<dag> pattern>
624 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
625 opc, asm, "", pattern>;
627 // Ctrl flow instructions
628 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
629 string opc, string asm, list<dag> pattern>
630 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
631 opc, asm, "", pattern> {
632 let Inst{27-24} = opcod;
634 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
635 string asm, list<dag> pattern>
636 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
638 let Inst{27-24} = opcod;
641 // BR_JT instructions
642 class JTI<dag oops, dag iops, InstrItinClass itin,
643 string asm, list<dag> pattern>
644 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
647 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
648 string opc, string asm, list<dag> pattern>
649 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
650 opc, asm, "", pattern> {
653 let Inst{27-23} = 0b00011;
654 let Inst{22-21} = opcod;
656 let Inst{19-16} = addr;
657 let Inst{15-12} = Rt;
658 let Inst{11-10} = 0b11;
659 let Inst{9-8} = opcod2;
660 let Inst{7-0} = 0b10011111;
662 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
663 string opc, string asm, list<dag> pattern>
664 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
665 opc, asm, "", pattern> {
668 let Inst{27-23} = 0b00011;
669 let Inst{22-21} = opcod;
671 let Inst{19-16} = addr;
672 let Inst{11-10} = 0b11;
673 let Inst{9-8} = opcod2;
674 let Inst{7-4} = 0b1001;
677 // Atomic load/store instructions
678 class 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>;
682 class 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> {
686 let Inst{15-12} = Rd;
689 // Exclusive load/store instructions
691 class 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>,
694 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
696 class 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>,
699 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
701 let Inst{15-12} = Rd;
704 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
705 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
709 let Inst{27-23} = 0b00010;
711 let Inst{21-20} = 0b00;
712 let Inst{19-16} = addr;
713 let Inst{15-12} = Rt;
714 let Inst{11-4} = 0b00001001;
717 let Unpredictable{11-8} = 0b1111;
718 let DecoderMethod = "DecodeSwap";
720 // Acquire/Release load/store instructions
721 class 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>,
724 Requires<[IsARM, HasAcquireRelease]>;
726 class 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>,
729 Requires<[IsARM, HasAcquireRelease]> {
730 let Inst{15-12} = 0b1111;
733 // addrmode1 instructions
734 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
735 string opc, string asm, list<dag> pattern>
736 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
737 opc, asm, "", pattern> {
738 let Inst{24-21} = opcod;
739 let Inst{27-26} = 0b00;
741 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
742 string opc, string asm, list<dag> pattern>
743 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
744 opc, asm, "", pattern> {
745 let Inst{24-21} = opcod;
746 let Inst{27-26} = 0b00;
748 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
749 string asm, list<dag> pattern>
750 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
752 let Inst{24-21} = opcod;
753 let Inst{27-26} = 0b00;
758 // LDR/LDRB/STR/STRB/...
759 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
760 Format f, InstrItinClass itin, string opc, string asm,
762 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
764 let Inst{27-25} = op;
765 let Inst{24} = 1; // 24 == P
767 let Inst{22} = isByte;
768 let Inst{21} = 0; // 21 == W
771 // Indexed load/stores
772 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
773 IndexMode im, Format f, InstrItinClass itin, string opc,
774 string asm, string cstr, list<dag> pattern>
775 : I<oops, iops, AddrMode2, 4, im, f, itin,
776 opc, asm, cstr, pattern> {
778 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
783 let Inst{15-12} = Rt;
785 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
786 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,
790 // AM2 store w/ two operands: (GPR, am2offset)
796 let Inst{23} = offset{12};
797 let Inst{19-16} = Rn;
798 let Inst{11-5} = offset{11-5};
800 let Inst{3-0} = offset{3-0};
803 class 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,
808 // AM2 store w/ two operands: (GPR, am2offset)
814 let Inst{23} = offset{12};
815 let Inst{19-16} = Rn;
816 let Inst{11-0} = offset{11-0};
820 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
821 // but for now use this class for STRT and STRBT.
822 class 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,
827 // AM2 store w/ two operands: (GPR, am2offset)
829 // {13} 1 == Rm, 0 == imm12
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};
839 // addrmode3 instructions
840 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
841 InstrItinClass itin, string opc, string asm, list<dag> pattern>
842 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
843 opc, asm, "", pattern> {
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
851 let Inst{20} = op20; // L bit
852 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
856 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
858 let DecoderMethod = "DecodeAddrMode3Instruction";
861 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
862 IndexMode im, Format f, InstrItinClass itin, string opc,
863 string asm, string cstr, list<dag> pattern>
864 : I<oops, iops, AddrMode3, 4, im, f, itin,
865 opc, asm, cstr, pattern> {
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
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.
877 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
878 IndexMode im, Format f, InstrItinClass itin, string opc,
879 string asm, string cstr, list<dag> pattern>
880 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
881 // {13} 1 == imm8, 0 == Rm
888 let Inst{27-25} = 0b000;
889 let Inst{24} = 0; // P bit
891 let Inst{20} = isLoad; // L bit
892 let Inst{19-16} = addr; // Rn
893 let Inst{15-12} = Rt; // Rt
898 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
899 string opc, string asm, list<dag> pattern>
900 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
901 opc, asm, "", pattern> {
904 let Inst{27-25} = 0b000;
905 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
914 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
915 let DecoderMethod = "DecodeAddrMode3Instruction";
918 // addrmode4 instructions
919 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
920 string asm, string cstr, list<dag> pattern>
921 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
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;
932 // Unsigned multiply, multiply-accumulate instructions.
933 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
934 string opc, string asm, list<dag> pattern>
935 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
936 opc, asm, "", pattern> {
937 let Inst{7-4} = 0b1001;
938 let Inst{20} = 0; // S bit
939 let Inst{27-21} = opcod;
941 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
942 string opc, string asm, list<dag> pattern>
943 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
944 opc, asm, "", pattern> {
945 let Inst{7-4} = 0b1001;
946 let Inst{27-21} = opcod;
949 // Most significant word multiply
950 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
951 InstrItinClass itin, string opc, string asm, list<dag> pattern>
952 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
953 opc, asm, "", pattern> {
957 let Inst{7-4} = opc7_4;
959 let Inst{27-21} = opcod;
960 let Inst{19-16} = Rd;
964 // MSW multiple w/ Ra operand
965 class 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> {
969 let Inst{15-12} = Ra;
972 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
973 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
974 InstrItinClass itin, string opc, string asm, list<dag> pattern>
975 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
976 opc, asm, "", pattern> {
982 let Inst{27-21} = opcod;
983 let Inst{6-5} = bit6_5;
987 class 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> {
991 let Inst{19-16} = Rd;
994 // AMulxyI with Ra operand
995 class 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> {
999 let Inst{15-12} = Ra;
1002 class 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> {
1007 let Inst{19-16} = RdHi;
1008 let Inst{15-12} = RdLo;
1011 // Extend instructions.
1012 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1013 string opc, string asm, list<dag> pattern>
1014 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
1015 opc, asm, "", pattern> {
1016 // All AExtI instructions have Rd and Rm register operands.
1019 let Inst{15-12} = Rd;
1021 let Inst{7-4} = 0b0111;
1022 let Inst{9-8} = 0b00;
1023 let Inst{27-20} = opcod;
1025 let Unpredictable{9-8} = 0b11;
1028 // Misc Arithmetic instructions.
1029 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1030 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1031 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1032 opc, asm, "", pattern> {
1035 let Inst{27-20} = opcod;
1036 let Inst{19-16} = 0b1111;
1037 let Inst{15-12} = Rd;
1038 let Inst{11-8} = 0b1111;
1039 let Inst{7-4} = opc7_4;
1043 // Division instructions.
1044 class 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> {
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;
1061 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
1062 let Name = "PKHLSLImm";
1063 let ParserMethod = "parsePKHLSLImm";
1065 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1066 let PrintMethod = "printPKHLSLShiftImm";
1067 let ParserMatchClass = PKHLSLAsmOperand;
1069 def PKHASRAsmOperand : AsmOperandClass {
1070 let Name = "PKHASRImm";
1071 let ParserMethod = "parsePKHASRImm";
1073 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1074 let PrintMethod = "printPKHASRShiftImm";
1075 let ParserMatchClass = PKHASRAsmOperand;
1078 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1079 string opc, string asm, list<dag> pattern>
1080 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1081 opc, asm, "", pattern> {
1086 let Inst{27-20} = opcod;
1087 let Inst{19-16} = Rn;
1088 let Inst{15-12} = Rd;
1089 let Inst{11-7} = sh;
1091 let Inst{5-4} = 0b01;
1095 //===----------------------------------------------------------------------===//
1097 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1098 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1099 list<Predicate> Predicates = [IsARM];
1101 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1102 list<Predicate> Predicates = [IsARM, HasV5T];
1104 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1105 list<Predicate> Predicates = [IsARM, HasV5TE];
1107 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1108 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1109 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1111 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1112 list<Predicate> Predicates = [IsARM, HasV6];
1114 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1115 list<Predicate> Predicates = [HasVFP2];
1117 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1118 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1120 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1121 list<Predicate> Predicates = [IsThumb2, HasDSP];
1123 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1124 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1126 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1127 list<Predicate> Predicates = [HasFP16];
1129 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1130 list<Predicate> Predicates = [HasFullFP16];
1132 //===----------------------------------------------------------------------===//
1133 // Thumb Instruction Format Definitions.
1136 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1137 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1138 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1139 let OutOperandList = oops;
1140 let InOperandList = iops;
1141 let AsmString = asm;
1142 let Pattern = pattern;
1143 list<Predicate> Predicates = [IsThumb];
1146 // TI - Thumb instruction.
1147 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1148 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1150 // Two-address instructions
1151 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1153 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1156 // tBL, tBX 32-bit instructions
1157 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1158 dag oops, dag iops, InstrItinClass itin, string asm,
1160 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1162 let Inst{31-27} = opcod1;
1163 let Inst{15-14} = opcod2;
1164 let Inst{12} = opcod3;
1167 // BR_JT instructions
1168 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1170 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1173 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1174 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1175 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1176 let OutOperandList = oops;
1177 let InOperandList = iops;
1178 let AsmString = asm;
1179 let Pattern = pattern;
1180 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1183 class T1I<dag oops, dag iops, InstrItinClass itin,
1184 string asm, list<dag> pattern>
1185 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1186 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1187 string asm, list<dag> pattern>
1188 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1190 // Two-address instructions
1191 class T1It<dag oops, dag iops, InstrItinClass itin,
1192 string asm, string cstr, list<dag> pattern>
1193 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1194 asm, cstr, pattern>;
1196 // Thumb1 instruction that can either be predicated or set CPSR.
1197 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1198 InstrItinClass itin,
1199 string opc, string asm, string cstr, list<dag> pattern>
1200 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1201 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1202 let InOperandList = !con(iops, (ins pred:$p));
1203 let AsmString = !strconcat(opc, "${s}${p}", asm);
1204 let Pattern = pattern;
1205 let thumbArithFlagSetting = 1;
1206 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1207 let DecoderNamespace = "ThumbSBit";
1210 class T1sI<dag oops, dag iops, InstrItinClass itin,
1211 string opc, string asm, list<dag> pattern>
1212 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1214 // Two-address instructions
1215 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1216 string opc, string asm, list<dag> pattern>
1217 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1218 "$Rn = $Rdn", pattern>;
1220 // Thumb1 instruction that can be predicated.
1221 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1222 InstrItinClass itin,
1223 string opc, string asm, string cstr, list<dag> pattern>
1224 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1225 let OutOperandList = oops;
1226 let InOperandList = !con(iops, (ins pred:$p));
1227 let AsmString = !strconcat(opc, "${p}", asm);
1228 let Pattern = pattern;
1229 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1232 class T1pI<dag oops, dag iops, InstrItinClass itin,
1233 string opc, string asm, list<dag> pattern>
1234 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1236 // Two-address instructions
1237 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1238 string opc, string asm, list<dag> pattern>
1239 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1240 "$Rn = $Rdn", pattern>;
1242 class T1pIs<dag oops, dag iops,
1243 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1244 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1246 class Encoding16 : Encoding {
1247 let Inst{31-16} = 0x0000;
1250 // A6.2 16-bit Thumb instruction encoding
1251 class T1Encoding<bits<6> opcode> : Encoding16 {
1252 let Inst{15-10} = opcode;
1255 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1256 class T1General<bits<5> opcode> : Encoding16 {
1257 let Inst{15-14} = 0b00;
1258 let Inst{13-9} = opcode;
1261 // A6.2.2 Data-processing encoding.
1262 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1263 let Inst{15-10} = 0b010000;
1264 let Inst{9-6} = opcode;
1267 // A6.2.3 Special data instructions and branch and exchange encoding.
1268 class T1Special<bits<4> opcode> : Encoding16 {
1269 let Inst{15-10} = 0b010001;
1270 let Inst{9-6} = opcode;
1273 // A6.2.4 Load/store single data item encoding.
1274 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1275 let Inst{15-12} = opA;
1276 let Inst{11-9} = opB;
1278 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1280 class T1BranchCond<bits<4> opcode> : Encoding16 {
1281 let Inst{15-12} = opcode;
1284 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1285 // following bits are used for "opA" (see A6.2.4):
1287 // 0b0110 => Immediate, 4 bytes
1288 // 0b1000 => Immediate, 2 bytes
1289 // 0b0111 => Immediate, 1 byte
1290 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1291 InstrItinClass itin, string opc, string asm,
1293 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1294 T1LoadStore<0b0101, opcode> {
1297 let Inst{8-6} = addr{5-3}; // Rm
1298 let Inst{5-3} = addr{2-0}; // Rn
1301 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1302 InstrItinClass itin, string opc, string asm,
1304 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1305 T1LoadStore<opA, {opB,?,?}> {
1308 let Inst{10-6} = addr{7-3}; // imm5
1309 let Inst{5-3} = addr{2-0}; // Rn
1313 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1314 class T1Misc<bits<7> opcode> : Encoding16 {
1315 let Inst{15-12} = 0b1011;
1316 let Inst{11-5} = opcode;
1319 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1320 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1321 InstrItinClass itin,
1322 string opc, string asm, string cstr, list<dag> pattern>
1323 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1324 let OutOperandList = oops;
1325 let InOperandList = !con(iops, (ins pred:$p));
1326 let AsmString = !strconcat(opc, "${p}", asm);
1327 let Pattern = pattern;
1328 list<Predicate> Predicates = [IsThumb2];
1329 let DecoderNamespace = "Thumb2";
1332 // 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".
1336 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1338 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1339 InstrItinClass itin,
1340 string opc, string asm, string cstr, list<dag> pattern>
1341 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1342 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1345 let OutOperandList = oops;
1346 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1347 let AsmString = !strconcat(opc, "${s}${p}", asm);
1348 let Pattern = pattern;
1349 list<Predicate> Predicates = [IsThumb2];
1350 let DecoderNamespace = "Thumb2";
1354 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1355 InstrItinClass itin,
1356 string asm, string cstr, list<dag> pattern>
1357 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1358 let OutOperandList = oops;
1359 let InOperandList = iops;
1360 let AsmString = asm;
1361 let Pattern = pattern;
1362 list<Predicate> Predicates = [IsThumb2];
1363 let DecoderNamespace = "Thumb2";
1366 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1367 InstrItinClass itin,
1368 string asm, string cstr, list<dag> pattern>
1369 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1370 let OutOperandList = oops;
1371 let InOperandList = iops;
1372 let AsmString = asm;
1373 let Pattern = pattern;
1374 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1375 let DecoderNamespace = "Thumb";
1378 class T2I<dag oops, dag iops, InstrItinClass itin,
1379 string opc, string asm, list<dag> pattern>
1380 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1381 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1382 string opc, string asm, list<dag> pattern>
1383 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1384 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1385 string opc, string asm, list<dag> pattern>
1386 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1387 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1388 string opc, string asm, list<dag> pattern>
1389 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1390 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1391 string opc, string asm, list<dag> pattern>
1392 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1393 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1394 string opc, string asm, string cstr, list<dag> pattern>
1395 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1400 let Inst{31-25} = 0b1110100;
1402 let Inst{23} = addr{8};
1405 let Inst{20} = isLoad;
1406 let Inst{19-16} = addr{12-9};
1407 let Inst{15-12} = Rt{3-0};
1408 let Inst{11-8} = Rt2{3-0};
1409 let Inst{7-0} = addr{7-0};
1411 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1412 InstrItinClass itin, string opc, string asm, string cstr,
1414 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1420 let Inst{31-25} = 0b1110100;
1422 let Inst{23} = imm{8};
1425 let Inst{20} = isLoad;
1426 let Inst{19-16} = addr;
1427 let Inst{15-12} = Rt{3-0};
1428 let Inst{11-8} = Rt2{3-0};
1429 let Inst{7-0} = imm{7-0};
1432 class T2sI<dag oops, dag iops, InstrItinClass itin,
1433 string opc, string asm, list<dag> pattern>
1434 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1436 class T2XI<dag oops, dag iops, InstrItinClass itin,
1437 string asm, list<dag> pattern>
1438 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1439 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1440 string asm, list<dag> pattern>
1441 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1443 // Move to/from coprocessor instructions
1444 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1446 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1447 let Inst{31-28} = opc;
1450 // Two-address instructions
1451 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1452 string asm, string cstr, list<dag> pattern>
1453 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1455 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1456 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1458 AddrMode am, IndexMode im, InstrItinClass itin,
1459 string opc, string asm, string cstr, list<dag> pattern>
1460 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1461 let OutOperandList = oops;
1462 let InOperandList = !con(iops, (ins pred:$p));
1463 let AsmString = !strconcat(opc, "${p}", asm);
1464 let Pattern = pattern;
1465 list<Predicate> Predicates = [IsThumb2];
1466 let DecoderNamespace = "Thumb2";
1470 let Inst{31-27} = 0b11111;
1471 let Inst{26-25} = 0b00;
1472 let Inst{24} = signed;
1474 let Inst{22-21} = opcod;
1475 let Inst{20} = load;
1476 let Inst{19-16} = addr{12-9};
1477 let Inst{15-12} = Rt{3-0};
1479 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1480 let Inst{10} = pre; // The P bit.
1481 let Inst{9} = addr{8}; // Sign bit
1482 let Inst{8} = 1; // The W bit.
1483 let Inst{7-0} = addr{7-0};
1485 let DecoderMethod = "DecodeT2LdStPre";
1488 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1489 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
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";
1504 let Inst{31-27} = 0b11111;
1505 let Inst{26-25} = 0b00;
1506 let Inst{24} = signed;
1508 let Inst{22-21} = opcod;
1509 let Inst{20} = load;
1510 let Inst{19-16} = Rn;
1511 let Inst{15-12} = Rt{3-0};
1513 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1514 let Inst{10} = pre; // The P bit.
1515 let Inst{9} = offset{8}; // Sign bit
1516 let Inst{8} = 1; // The W bit.
1517 let Inst{7-0} = offset{7-0};
1519 let DecoderMethod = "DecodeT2LdStPre";
1522 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1523 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1524 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1527 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1528 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1529 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1532 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1533 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1534 list<Predicate> Predicates = [IsThumb2];
1537 //===----------------------------------------------------------------------===//
1539 //===----------------------------------------------------------------------===//
1540 // ARM VFP Instruction templates.
1543 // Almost all VFP instructions are predicable.
1544 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1545 IndexMode im, Format f, InstrItinClass itin,
1546 string opc, string asm, string cstr, list<dag> pattern>
1547 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1549 let Inst{31-28} = p;
1550 let OutOperandList = oops;
1551 let InOperandList = !con(iops, (ins pred:$p));
1552 let AsmString = !strconcat(opc, "${p}", asm);
1553 let Pattern = pattern;
1554 let PostEncoderMethod = "VFPThumb2PostEncoder";
1555 let DecoderNamespace = "VFP";
1556 list<Predicate> Predicates = [HasVFP2];
1560 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1561 IndexMode im, Format f, InstrItinClass itin,
1562 string asm, string cstr, list<dag> pattern>
1563 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1565 let Inst{31-28} = p;
1566 let OutOperandList = oops;
1567 let InOperandList = iops;
1568 let AsmString = asm;
1569 let Pattern = pattern;
1570 let PostEncoderMethod = "VFPThumb2PostEncoder";
1571 let DecoderNamespace = "VFP";
1572 list<Predicate> Predicates = [HasVFP2];
1575 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1576 string opc, string asm, list<dag> pattern>
1577 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1578 opc, asm, "", pattern> {
1579 let PostEncoderMethod = "VFPThumb2PostEncoder";
1582 // ARM VFP addrmode5 loads and stores
1583 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1584 InstrItinClass itin,
1585 string opc, string asm, list<dag> pattern>
1586 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1587 VFPLdStFrm, itin, opc, asm, "", pattern> {
1588 // Instruction operands.
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
1599 let Inst{27-24} = opcod1;
1600 let Inst{21-20} = opcod2;
1601 let Inst{11-9} = 0b101;
1602 let Inst{8} = 1; // Double precision
1604 // Loads & stores operate on both NEON and VFP pipelines.
1605 let D = VFPNeonDomain;
1608 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1609 InstrItinClass itin,
1610 string opc, string asm, list<dag> pattern>
1611 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1612 VFPLdStFrm, itin, opc, asm, "", pattern> {
1613 // Instruction operands.
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
1624 let Inst{27-24} = opcod1;
1625 let Inst{21-20} = opcod2;
1626 let Inst{11-9} = 0b101;
1627 let Inst{8} = 0; // Single precision
1629 // Loads & stores operate on both NEON and VFP pipelines.
1630 let D = VFPNeonDomain;
1633 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1634 InstrItinClass itin,
1635 string opc, string asm, list<dag> pattern>
1636 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1637 VFPLdStFrm, itin, opc, asm, "", pattern> {
1638 list<Predicate> Predicates = [HasFullFP16];
1640 // Instruction operands.
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
1651 let Inst{27-24} = opcod1;
1652 let Inst{21-20} = opcod2;
1653 let Inst{11-8} = 0b1001; // Half precision
1655 // Loads & stores operate on both NEON and VFP pipelines.
1656 let D = VFPNeonDomain;
1658 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1661 // VFP Load / store multiple pseudo instructions.
1662 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1664 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1666 let OutOperandList = oops;
1667 let InOperandList = !con(iops, (ins pred:$p));
1668 let Pattern = pattern;
1669 list<Predicate> Predicates = [HasVFP2];
1672 // Load / store multiple
1674 // Unknown precision
1675 class 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.
1683 // Encode instruction operands.
1684 let Inst{19-16} = Rn;
1686 let Inst{15-12} = regs{11-8};
1687 let Inst{7-1} = regs{7-1};
1689 let Inst{27-25} = 0b110;
1690 let Inst{11-8} = 0b1011;
1695 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1696 string asm, string cstr, list<dag> pattern>
1697 : VFPXI<oops, iops, AddrMode4, 4, im,
1698 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1699 // Instruction operands.
1703 // Encode instruction operands.
1704 let Inst{19-16} = Rn;
1705 let Inst{22} = regs{12};
1706 let Inst{15-12} = regs{11-8};
1707 let Inst{7-1} = regs{7-1};
1709 let Inst{27-25} = 0b110;
1710 let Inst{11-9} = 0b101;
1711 let Inst{8} = 1; // Double precision
1716 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1717 string asm, string cstr, list<dag> pattern>
1718 : VFPXI<oops, iops, AddrMode4, 4, im,
1719 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1720 // Instruction operands.
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};
1730 let Inst{27-25} = 0b110;
1731 let Inst{11-9} = 0b101;
1732 let Inst{8} = 0; // Single precision
1735 // Double precision, unary
1736 class 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>
1739 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1740 // Instruction operands.
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};
1750 let Inst{27-23} = opcod1;
1751 let Inst{21-20} = opcod2;
1752 let Inst{19-16} = opcod3;
1753 let Inst{11-9} = 0b101;
1754 let Inst{8} = 1; // Double precision
1755 let Inst{7-6} = opcod4;
1756 let Inst{4} = opcod5;
1758 let Predicates = [HasVFP2, HasDPVFP];
1761 // Double precision, unary, not-predicated
1762 class 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.
1770 let Inst{31-28} = 0b1111;
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};
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;
1787 // Double precision, binary
1788 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1789 dag iops, InstrItinClass itin, string opc, string asm,
1791 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1792 // Instruction operands.
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};
1805 let Inst{27-23} = opcod1;
1806 let Inst{21-20} = opcod2;
1807 let Inst{11-9} = 0b101;
1808 let Inst{8} = 1; // Double precision
1812 let Predicates = [HasVFP2, HasDPVFP];
1815 // FP, binary, not predicated
1816 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1817 InstrItinClass itin, string asm, list<dag> pattern>
1818 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1821 // Instruction operands.
1826 let Inst{31-28} = 0b1111;
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};
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
1840 let Inst{6} = opcod3;
1843 let Predicates = [HasVFP2, HasDPVFP];
1846 // Single precision, unary, predicated
1847 class 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>
1850 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1851 // Instruction operands.
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};
1861 let Inst{27-23} = opcod1;
1862 let Inst{21-20} = opcod2;
1863 let Inst{19-16} = opcod3;
1864 let Inst{11-9} = 0b101;
1865 let Inst{8} = 0; // Single precision
1866 let Inst{7-6} = opcod4;
1867 let Inst{4} = opcod5;
1870 // Single precision, unary, non-predicated
1871 class 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.
1880 let Inst{31-28} = 0b1111;
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};
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;
1897 // Single precision unary, if no NEON. Same as ASuI except not available if
1899 class 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,
1904 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1907 // Single precision, binary
1908 class 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>
1910 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1911 // Instruction operands.
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};
1924 let Inst{27-23} = opcod1;
1925 let Inst{21-20} = opcod2;
1926 let Inst{11-9} = 0b101;
1927 let Inst{8} = 0; // Single precision
1932 // Single precision, binary, not predicated
1933 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1934 InstrItinClass itin, string asm, list<dag> pattern>
1935 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1936 VFPBinaryFrm, itin, asm, "", pattern>
1938 // Instruction operands.
1943 let Inst{31-28} = 0b1111;
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};
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
1957 let Inst{6} = opcod3;
1961 // Single precision binary, if no NEON. Same as ASbI except not available if
1963 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1964 dag iops, InstrItinClass itin, string opc, string asm,
1966 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1967 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1969 // Instruction operands.
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};
1983 // Half precision, unary, predicated
1984 class 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];
1990 // Instruction operands.
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};
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;
2007 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2010 // Half precision, unary, non-predicated
2011 class 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];
2018 // Instruction operands.
2022 let Inst{31-28} = 0b1111;
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};
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;
2037 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2040 // Half precision, binary
2041 class 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];
2046 // Instruction operands.
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};
2059 let Inst{27-23} = opcod1;
2060 let Inst{21-20} = opcod2;
2061 let Inst{11-8} = 0b1001; // Half precision
2065 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2068 // Half precision, binary, not predicated
2069 class 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];
2075 // Instruction operands.
2080 let Inst{31-28} = 0b1111;
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};
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;
2096 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2099 // VFP conversion instructions
2100 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2101 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2103 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
2104 let Inst{27-23} = opcod1;
2105 let Inst{21-20} = opcod2;
2106 let Inst{19-16} = opcod3;
2107 let Inst{11-8} = opcod4;
2112 // VFP conversion between floating-point and fixed-point
2113 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2114 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2116 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2118 // size (fixed-point number): sx == 0 ? 16 : 32
2119 let Inst{7} = op5; // sx
2120 let Inst{5} = fbits{0};
2121 let Inst{3-0} = fbits{4-1};
2124 // VFP conversion instructions, if no NEON
2125 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2126 dag oops, dag iops, InstrItinClass itin,
2127 string opc, string asm, list<dag> pattern>
2128 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2130 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2133 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2134 InstrItinClass itin,
2135 string opc, string asm, list<dag> pattern>
2136 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
2137 let Inst{27-20} = opcod1;
2138 let Inst{11-8} = opcod2;
2142 class 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>;
2146 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2147 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2148 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2150 class 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>;
2154 class 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>;
2158 //===----------------------------------------------------------------------===//
2160 //===----------------------------------------------------------------------===//
2161 // ARM NEON Instruction templates.
2164 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2165 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2167 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2168 let OutOperandList = oops;
2169 let InOperandList = !con(iops, (ins pred:$p));
2170 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2171 let Pattern = pattern;
2172 list<Predicate> Predicates = [HasNEON];
2173 let DecoderNamespace = "NEON";
2176 // Same as NeonI except it does not have a "data type" specifier.
2177 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2178 InstrItinClass itin, string opc, string asm, string cstr,
2180 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2181 let OutOperandList = oops;
2182 let InOperandList = !con(iops, (ins pred:$p));
2183 let AsmString = !strconcat(opc, "${p}", "\t", asm);
2184 let Pattern = pattern;
2185 list<Predicate> Predicates = [HasNEON];
2186 let DecoderNamespace = "NEON";
2189 // Same as NeonI except it is not predicated
2190 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2191 InstrItinClass itin, string opc, string dt, string asm, string cstr,
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";
2201 let Inst{31-28} = 0b1111;
2204 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2205 dag oops, dag iops, InstrItinClass itin,
2206 string opc, string dt, string asm, string cstr, list<dag> pattern>
2207 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2209 let Inst{31-24} = 0b11110100;
2210 let Inst{23} = op23;
2211 let Inst{21-20} = op21_20;
2212 let Inst{11-8} = op11_8;
2213 let Inst{7-4} = op7_4;
2215 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2216 let DecoderNamespace = "NEONLoadStore";
2222 let Inst{22} = Vd{4};
2223 let Inst{15-12} = Vd{3-0};
2224 let Inst{19-16} = Rn{3-0};
2225 let Inst{3-0} = Rm{3-0};
2228 class 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> {
2236 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2237 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2239 let OutOperandList = oops;
2240 let InOperandList = !con(iops, (ins pred:$p));
2241 list<Predicate> Predicates = [HasNEON];
2244 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2246 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2248 let OutOperandList = oops;
2249 let InOperandList = !con(iops, (ins pred:$p));
2250 let Pattern = pattern;
2251 list<Predicate> Predicates = [HasNEON];
2254 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2255 string opc, string dt, string asm, string cstr, list<dag> pattern>
2256 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2258 let Inst{31-25} = 0b1111001;
2259 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2260 let DecoderNamespace = "NEONData";
2263 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2264 string opc, string asm, string cstr, list<dag> pattern>
2265 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2267 let Inst{31-25} = 0b1111001;
2268 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2269 let DecoderNamespace = "NEONData";
2272 // NEON "one register and a modified immediate" format.
2273 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2275 dag oops, dag iops, InstrItinClass itin,
2276 string opc, string dt, string asm, string cstr,
2278 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2279 let Inst{23} = op23;
2280 let Inst{21-19} = op21_19;
2281 let Inst{11-8} = op11_8;
2287 // Instruction operands.
2291 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};
2296 let DecoderMethod = "DecodeVMOVModImmInstruction";
2299 // NEON 2 vector register format.
2300 class 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,
2302 dag oops, dag iops, InstrItinClass itin,
2303 string opc, string dt, string asm, string cstr, list<dag> pattern>
2304 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2305 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;
2309 let Inst{11-7} = op11_7;
2313 // Instruction operands.
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};
2323 // Same as N2V but not predicated.
2324 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2325 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2326 string Dt, list<dag> pattern>
2327 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2328 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
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};
2338 // Encode constant bits
2339 let Inst{27-23} = 0b00111;
2340 let Inst{21-20} = 0b11;
2341 let Inst{19-18} = op19_18;
2342 let Inst{17-16} = op17_16;
2344 let Inst{10-8} = op10_8;
2349 let DecoderNamespace = "NEON";
2352 // Same as N2V except it doesn't have a datatype suffix.
2353 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2354 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>
2357 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2358 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;
2362 let Inst{11-7} = op11_7;
2366 // Instruction operands.
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};
2376 // NEON 2 vector register with immediate.
2377 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2378 dag oops, dag iops, Format f, InstrItinClass itin,
2379 string opc, string dt, string asm, string cstr, list<dag> pattern>
2380 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2381 let Inst{24} = op24;
2382 let Inst{23} = op23;
2383 let Inst{11-8} = op11_8;
2388 // Instruction operands.
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};
2400 // NEON 3 vector register format.
2402 class 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,
2406 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2407 let Inst{24} = op24;
2408 let Inst{23} = op23;
2409 let Inst{21-20} = op21_20;
2410 let Inst{11-8} = op11_8;
2415 class 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> {
2420 // Instruction operands.
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};
2433 class 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,
2435 string OpcodeStr, string Dt, list<dag> pattern>
2436 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2437 Dt, "$Vd, $Vn, $Vm", "", pattern> {
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};
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;
2458 class 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,
2462 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2463 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2465 // Instruction operands.
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};
2479 class 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,
2483 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2484 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2486 // Instruction operands.
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};
2501 // Same as N3V except it doesn't have a data type suffix.
2502 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2504 dag oops, dag iops, Format f, InstrItinClass itin,
2505 string opc, string asm, string cstr, list<dag> pattern>
2506 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2507 let Inst{24} = op24;
2508 let Inst{23} = op23;
2509 let Inst{21-20} = op21_20;
2510 let Inst{11-8} = op11_8;
2514 // Instruction operands.
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};
2527 // NEON VMOVs between scalar and core registers.
2528 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2529 dag oops, dag iops, Format f, InstrItinClass itin,
2530 string opc, string dt, string asm, list<dag> pattern>
2531 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2533 let Inst{27-20} = opcod1;
2534 let Inst{11-8} = opcod2;
2535 let Inst{6-5} = opcod3;
2537 // A8.6.303, A8.6.328, A8.6.329
2538 let Inst{3-0} = 0b0000;
2540 let OutOperandList = oops;
2541 let InOperandList = !con(iops, (ins pred:$p));
2542 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2543 let Pattern = pattern;
2544 list<Predicate> Predicates = [HasNEON];
2546 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2547 let DecoderNamespace = "NEONDup";
2554 let Inst{31-28} = p{3-0};
2556 let Inst{19-16} = V{3-0};
2557 let Inst{15-12} = R{3-0};
2559 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2560 dag oops, dag iops, InstrItinClass itin,
2561 string opc, string dt, string asm, list<dag> pattern>
2562 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2563 opc, dt, asm, pattern>;
2564 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2565 dag oops, dag iops, InstrItinClass itin,
2566 string opc, string dt, string asm, list<dag> pattern>
2567 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2568 opc, dt, asm, pattern>;
2569 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2570 dag oops, dag iops, InstrItinClass itin,
2571 string opc, string dt, string asm, list<dag> pattern>
2572 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2573 opc, dt, asm, pattern>;
2575 // Vector Duplicate Lane (from scalar to all elements)
2576 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2577 InstrItinClass itin, string opc, string dt, string asm,
2579 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2580 let Inst{24-23} = 0b11;
2581 let Inst{21-20} = 0b11;
2582 let Inst{19-16} = op19_16;
2583 let Inst{11-7} = 0b11000;
2590 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};
2596 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2597 // for single-precision FP.
2598 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2599 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2602 // VFP/NEON Instruction aliases for type suffices.
2603 // Note: When EmitPriority == 1, the alias will be used for printing
2604 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2605 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
2607 // Note: When EmitPriority == 1, the alias will be used for printing
2608 multiclass 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>;
2615 // Note: When EmitPriority == 1, the alias will be used for printing
2616 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2617 let Predicates = [HasNEON] in {
2618 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>;
2625 // 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.
2630 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2631 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2633 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2634 // encoding space, introduced in ARMv8.3-A.
2635 class 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> {
2644 let DecoderNamespace = "VFPV8";
2645 // These have the same encodings in ARM and Thumb2
2646 let PostEncoderMethod = "";
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};
2657 let Inst{5} = Vm{4};
2659 let Inst{3-0} = Vm{3-0};
2662 // Extension of NEON 2-vector-and-scalar data processing instructions in
2663 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2664 class 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> {
2673 let DecoderNamespace = "VFPV8";
2674 // These have the same encodings in ARM and Thumb2
2675 let PostEncoderMethod = "";
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};
2686 // Bit 5 set by sub-classes
2688 let Inst{3-0} = Vm{3-0};
2691 // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
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.
2696 class 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> {
2704 let DecoderNamespace = "VFPV8";
2705 // These have the same encodings in ARM and Thumb2
2706 let PostEncoderMethod = "";
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};
2717 let Inst{5} = Vm{0};
2719 let Inst{3-0} = Vm{4-1};
2722 // Operand types for complex instructions
2723 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2725 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2726 let DiagnosticString = "complex rotation must be " # Diag;
2727 let Name = "ComplexRotation" # Type;
2729 def complexrotateop : Operand<i32> {
2730 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2731 let PrintMethod = "printComplexRotationOp<90, 0>";
2733 def complexrotateopodd : Operand<i32> {
2734 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2735 let PrintMethod = "printComplexRotationOp<180, 90>";
2738 def MveSaturateOperand : AsmOperandClass {
2739 let PredicateMethod = "isMveSaturateOp";
2740 let DiagnosticString = "saturate operand must be 48 or 64";
2741 let Name = "MveSaturate";
2743 def saturateop : Operand<i32> {
2744 let ParserMatchClass = MveSaturateOperand;
2745 let PrintMethod = "printMveSaturateOp";
2748 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2749 def : TokenAlias<".s8", ".i8">;
2750 def : TokenAlias<".u8", ".i8">;
2751 def : TokenAlias<".s16", ".i16">;
2752 def : TokenAlias<".u16", ".i16">;
2753 def : TokenAlias<".s32", ".i32">;
2754 def : TokenAlias<".u32", ".i32">;
2755 def : TokenAlias<".s64", ".i64">;
2756 def : TokenAlias<".u64", ".i64">;
2758 def : TokenAlias<".i8", ".8">;
2759 def : TokenAlias<".i16", ".16">;
2760 def : TokenAlias<".i32", ".32">;
2761 def : TokenAlias<".i64", ".64">;
2763 def : TokenAlias<".p8", ".8">;
2764 def : TokenAlias<".p16", ".16">;
2766 def : TokenAlias<".f32", ".32">;
2767 def : TokenAlias<".f64", ".64">;
2768 def : TokenAlias<".f", ".f32">;
2769 def : TokenAlias<".d", ".f64">;