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";
209 // Operand classes for the cluster of MC operands describing a
210 // VPT-predicated MVE instruction.
212 // There are two of these classes. Both of them have the same first
215 // $cond (an integer) indicates the instruction's predication status:
216 // * ARMVCC::None means it's unpredicated
217 // * ARMVCC::Then means it's in a VPT block and appears with the T suffix
218 // * ARMVCC::Else means it's in a VPT block and appears with the E suffix.
219 // During code generation, unpredicated and predicated instructions
220 // are indicated by setting this parameter to 'None' or to 'Then'; the
221 // third value 'Else' is only used for assembly and disassembly.
223 // $cond_reg (type VCCR) gives the input predicate register. This is
224 // always either zero_reg or VPR, but needs to be modelled as an
225 // explicit operand so that it can be register-allocated and spilled
226 // when these operands are used in code generation).
228 // For 'vpred_r', there's an extra operand $inactive, which specifies
229 // the vector register which will supply any lanes of the output
230 // register that the predication mask prevents from being written by
231 // this instruction. It's always tied to the actual output register
232 // (i.e. must be allocated into the same physical reg), but again,
233 // code generation will need to model it as a separate input value.
235 // 'vpred_n' doesn't have that extra operand: it only has $cond and
236 // $cond_reg. This variant is used for any instruction that can't, or
237 // doesn't want to, tie $inactive to the output register. Sometimes
238 // that's because another input parameter is already tied to it (e.g.
239 // instructions that both read and write their Qd register even when
240 // unpredicated, either because they only partially overwrite it like
241 // a narrowing integer conversion, or simply because the instruction
242 // encoding doesn't have enough register fields to make the output
243 // independent of all inputs). It can also be because the instruction
244 // is defined to set disabled output lanes to zero rather than leaving
245 // them unchanged (vector loads), or because it doesn't output a
246 // vector register at all (stores, compares). In any of these
247 // situations it's unnecessary to have an extra operand tied to the
248 // output, and inconvenient to leave it there unused.
250 // Base class for both kinds of vpred.
251 class vpred_ops<dag extra_op, dag extra_mi> : OperandWithDefaultOps<OtherVT,
252 !con((ops (i32 0), (i32 zero_reg)), extra_op)> {
253 let PrintMethod = "printVPTPredicateOperand";
254 let OperandNamespace = "ARM";
255 let MIOperandInfo = !con((ops i32imm:$cond, VCCR:$cond_reg), extra_mi);
257 // For convenience, we provide a string value that can be appended
258 // to the constraints string. It's empty for vpred_n, and for
259 // vpred_r it ties the $inactive operand to the output q-register
260 // (which by convention will be called $Qd).
261 string vpred_constraint;
264 def vpred_r : vpred_ops<(ops (v4i32 undef_tied_input)), (ops MQPR:$inactive)> {
265 let ParserMatchClass = VPTPredROperand;
266 let OperandType = "OPERAND_VPRED_R";
267 let DecoderMethod = "DecodeVpredROperand";
268 let vpred_constraint = ",$Qd = $vp.inactive";
271 def vpred_n : vpred_ops<(ops), (ops)> {
272 let ParserMatchClass = VPTPredNOperand;
273 let OperandType = "OPERAND_VPRED_N";
274 let vpred_constraint = "";
277 // ARM special operands for disassembly only.
279 def SetEndAsmOperand : ImmAsmOperand<0,1> {
280 let Name = "SetEndImm";
281 let ParserMethod = "parseSetEndImm";
283 def setend_op : Operand<i32> {
284 let PrintMethod = "printSetendOperand";
285 let ParserMatchClass = SetEndAsmOperand;
288 def MSRMaskOperand : AsmOperandClass {
289 let Name = "MSRMask";
290 let ParserMethod = "parseMSRMaskOperand";
292 def msr_mask : Operand<i32> {
293 let PrintMethod = "printMSRMaskOperand";
294 let DecoderMethod = "DecodeMSRMask";
295 let ParserMatchClass = MSRMaskOperand;
298 def BankedRegOperand : AsmOperandClass {
299 let Name = "BankedReg";
300 let ParserMethod = "parseBankedRegOperand";
302 def banked_reg : Operand<i32> {
303 let PrintMethod = "printBankedRegOperand";
304 let DecoderMethod = "DecodeBankedReg";
305 let ParserMatchClass = BankedRegOperand;
308 // Shift Right Immediate - A shift right immediate is encoded differently from
309 // other shift immediates. The imm6 field is encoded like so:
312 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
313 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
314 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
315 // 64 64 - <imm> is encoded in imm6<5:0>
316 def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
317 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
318 let EncoderMethod = "getShiftRight8Imm";
319 let DecoderMethod = "DecodeShiftRight8Imm";
320 let ParserMatchClass = shr_imm8_asm_operand;
322 def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
323 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
324 let EncoderMethod = "getShiftRight16Imm";
325 let DecoderMethod = "DecodeShiftRight16Imm";
326 let ParserMatchClass = shr_imm16_asm_operand;
328 def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
329 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
330 let EncoderMethod = "getShiftRight32Imm";
331 let DecoderMethod = "DecodeShiftRight32Imm";
332 let ParserMatchClass = shr_imm32_asm_operand;
334 def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
335 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
336 let EncoderMethod = "getShiftRight64Imm";
337 let DecoderMethod = "DecodeShiftRight64Imm";
338 let ParserMatchClass = shr_imm64_asm_operand;
342 // ARM Assembler operand for ldr Rd, =expression which generates an offset
343 // to a constant pool entry or a MOV depending on the value of expression
344 def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
345 def const_pool_asm_imm : Operand<i32> {
346 let ParserMatchClass = const_pool_asm_operand;
350 //===----------------------------------------------------------------------===//
351 // ARM Assembler alias templates.
353 // Note: When EmitPriority == 1, the alias will be used for printing
354 class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
355 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
356 class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
357 : InstAlias<Asm, Result, EmitPriority>,
358 Requires<[IsARM,UseNegativeImmediates]>;
359 class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
360 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
361 class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
362 : InstAlias<Asm, Result, EmitPriority>,
363 Requires<[IsThumb,UseNegativeImmediates]>;
364 class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
365 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
366 class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
367 : InstAlias<Asm, Result, EmitPriority>,
368 Requires<[IsThumb2,UseNegativeImmediates]>;
369 class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
370 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
371 class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
372 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
373 class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
374 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
375 class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
376 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
377 class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
378 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
381 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
383 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
386 //===----------------------------------------------------------------------===//
387 // ARM Instruction templates.
391 class InstTemplate<AddrMode am, int sz, IndexMode im,
392 Format f, Domain d, string cstr, InstrItinClass itin>
394 let Namespace = "ARM";
399 bits<2> IndexModeBits = IM.Value;
401 bits<6> Form = F.Value;
403 bit isUnaryDataProc = 0;
404 bit canXformTo16Bit = 0;
405 // The instruction is a 16-bit flag setting Thumb instruction. Used
406 // by the parser and if-converter to determine whether to require the 'S'
407 // suffix on the mnemonic (when not in an IT block) or preclude it (when
409 bit thumbArithFlagSetting = 0;
411 bit validForTailPredication = 0;
412 bit retainsPreviousHalfElement = 0;
413 bit horizontalReduction = 0;
414 bit doubleWidthResult = 0;
416 // If this is a pseudo instruction, mark it isCodeGenOnly.
417 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
419 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
420 let TSFlags{4-0} = AM.Value;
421 let TSFlags{6-5} = IndexModeBits;
422 let TSFlags{12-7} = Form;
423 let TSFlags{13} = isUnaryDataProc;
424 let TSFlags{14} = canXformTo16Bit;
425 let TSFlags{18-15} = D.Value;
426 let TSFlags{19} = thumbArithFlagSetting;
427 let TSFlags{20} = validForTailPredication;
428 let TSFlags{21} = retainsPreviousHalfElement;
429 let TSFlags{22} = horizontalReduction;
430 let TSFlags{23} = doubleWidthResult;
432 let Constraints = cstr;
433 let Itinerary = itin;
438 // Mask of bits that cause an encoding to be UNPREDICTABLE.
439 // If a bit is set, then if the corresponding bit in the
440 // target encoding differs from its value in the "Inst" field,
441 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
442 field bits<32> Unpredictable = 0;
443 // SoftFail is the generic name for this field, but we alias it so
444 // as to make it more obvious what it means in ARM-land.
445 field bits<32> SoftFail = Unpredictable;
448 class InstARM<AddrMode am, int sz, IndexMode im,
449 Format f, Domain d, string cstr, InstrItinClass itin>
450 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
451 let DecoderNamespace = "ARM";
454 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
455 // on by adding flavors to specific instructions.
456 class InstThumb<AddrMode am, int sz, IndexMode im,
457 Format f, Domain d, string cstr, InstrItinClass itin>
458 : InstTemplate<am, sz, im, f, d, cstr, itin> {
459 let DecoderNamespace = "Thumb";
462 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
463 // These are aliases that require C++ handling to convert to the target
464 // instruction, while InstAliases can be handled directly by tblgen.
465 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
466 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
468 let OutOperandList = oops;
469 let InOperandList = iops;
471 let isCodeGenOnly = 0; // So we get asm matcher for it.
474 let hasNoSchedulingInfo = 1;
477 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
478 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
479 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
480 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
481 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
482 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
483 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
484 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
485 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
486 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
487 class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
488 : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
490 // Pseudo instructions for the code generator.
491 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
492 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
493 GenericDomain, "", itin> {
494 let OutOperandList = oops;
495 let InOperandList = iops;
496 let Pattern = pattern;
497 let isCodeGenOnly = 1;
501 // PseudoInst that's ARM-mode only.
502 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
504 : PseudoInst<oops, iops, itin, pattern> {
506 list<Predicate> Predicates = [IsARM];
509 // PseudoInst that's Thumb-mode only.
510 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
512 : PseudoInst<oops, iops, itin, pattern> {
514 list<Predicate> Predicates = [IsThumb];
517 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
518 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
520 : PseudoInst<oops, iops, itin, pattern> {
522 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
525 // PseudoInst that's Thumb2-mode only.
526 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
528 : PseudoInst<oops, iops, itin, pattern> {
530 list<Predicate> Predicates = [IsThumb2];
533 class ARMPseudoExpand<dag oops, dag iops, int sz,
534 InstrItinClass itin, list<dag> pattern,
536 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
537 PseudoInstExpansion<Result>;
539 class tPseudoExpand<dag oops, dag iops, int sz,
540 InstrItinClass itin, list<dag> pattern,
542 : tPseudoInst<oops, iops, sz, itin, pattern>,
543 PseudoInstExpansion<Result>;
545 class t2PseudoExpand<dag oops, dag iops, int sz,
546 InstrItinClass itin, list<dag> pattern,
548 : t2PseudoInst<oops, iops, sz, itin, pattern>,
549 PseudoInstExpansion<Result>;
551 // Almost all ARM instructions are predicable.
552 class I<dag oops, dag iops, AddrMode am, int sz,
553 IndexMode im, Format f, InstrItinClass itin,
554 string opc, string asm, string cstr,
556 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
559 let OutOperandList = oops;
560 let InOperandList = !con(iops, (ins pred:$p));
561 let AsmString = !strconcat(opc, "${p}", asm);
562 let Pattern = pattern;
563 list<Predicate> Predicates = [IsARM];
566 // A few are not predicable
567 class InoP<dag oops, dag iops, AddrMode am, int sz,
568 IndexMode im, Format f, InstrItinClass itin,
569 string opc, string asm, string cstr,
571 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
572 let OutOperandList = oops;
573 let InOperandList = iops;
574 let AsmString = !strconcat(opc, asm);
575 let Pattern = pattern;
576 let isPredicable = 0;
577 list<Predicate> Predicates = [IsARM];
580 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
581 // operand since by default it's a zero register. It will become an implicit def
582 // once it's "flipped".
583 class sI<dag oops, dag iops, AddrMode am, int sz,
584 IndexMode im, Format f, InstrItinClass itin,
585 string opc, string asm, string cstr,
587 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
588 bits<4> p; // Predicate operand
589 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
593 let OutOperandList = oops;
594 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
595 let AsmString = !strconcat(opc, "${s}${p}", asm);
596 let Pattern = pattern;
597 list<Predicate> Predicates = [IsARM];
601 class XI<dag oops, dag iops, AddrMode am, int sz,
602 IndexMode im, Format f, InstrItinClass itin,
603 string asm, string cstr, list<dag> pattern>
604 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
605 let OutOperandList = oops;
606 let InOperandList = iops;
608 let Pattern = pattern;
609 list<Predicate> Predicates = [IsARM];
612 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
613 string opc, string asm, list<dag> pattern>
614 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
615 opc, asm, "", pattern>;
616 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
617 string opc, string asm, list<dag> pattern>
618 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
619 opc, asm, "", pattern>;
620 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
621 string asm, list<dag> pattern>
622 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
624 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
625 string asm, list<dag> pattern>
626 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
628 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
629 string opc, string asm, list<dag> pattern>
630 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
631 opc, asm, "", pattern>;
633 // Ctrl flow instructions
634 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
635 string opc, string asm, list<dag> pattern>
636 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
637 opc, asm, "", pattern> {
638 let Inst{27-24} = opcod;
640 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
641 string asm, list<dag> pattern>
642 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
644 let Inst{27-24} = opcod;
647 // BR_JT instructions
648 class JTI<dag oops, dag iops, InstrItinClass itin,
649 string asm, list<dag> pattern>
650 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
653 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
654 string opc, string asm, list<dag> pattern>
655 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
656 opc, asm, "", pattern> {
659 let Inst{27-23} = 0b00011;
660 let Inst{22-21} = opcod;
662 let Inst{19-16} = addr;
663 let Inst{15-12} = Rt;
664 let Inst{11-10} = 0b11;
665 let Inst{9-8} = opcod2;
666 let Inst{7-0} = 0b10011111;
668 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
669 string opc, string asm, list<dag> pattern>
670 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
671 opc, asm, "", pattern> {
674 let Inst{27-23} = 0b00011;
675 let Inst{22-21} = opcod;
677 let Inst{19-16} = addr;
678 let Inst{11-10} = 0b11;
679 let Inst{9-8} = opcod2;
680 let Inst{7-4} = 0b1001;
683 // Atomic load/store instructions
684 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
685 string opc, string asm, list<dag> pattern>
686 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
688 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
689 string opc, string asm, list<dag> pattern>
690 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
692 let Inst{15-12} = Rd;
695 // Exclusive load/store instructions
697 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
698 string opc, string asm, list<dag> pattern>
699 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
700 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
702 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
703 string opc, string asm, list<dag> pattern>
704 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
705 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
707 let Inst{15-12} = Rd;
710 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
711 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
715 let Inst{27-23} = 0b00010;
717 let Inst{21-20} = 0b00;
718 let Inst{19-16} = addr;
719 let Inst{15-12} = Rt;
720 let Inst{11-4} = 0b00001001;
723 let Unpredictable{11-8} = 0b1111;
724 let DecoderMethod = "DecodeSwap";
726 // Acquire/Release load/store instructions
727 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
728 string opc, string asm, list<dag> pattern>
729 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
730 Requires<[IsARM, HasAcquireRelease]>;
732 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
733 string opc, string asm, list<dag> pattern>
734 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
735 Requires<[IsARM, HasAcquireRelease]> {
736 let Inst{15-12} = 0b1111;
739 // addrmode1 instructions
740 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
741 string opc, string asm, list<dag> pattern>
742 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
743 opc, asm, "", pattern> {
744 let Inst{24-21} = opcod;
745 let Inst{27-26} = 0b00;
747 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
748 string opc, string asm, list<dag> pattern>
749 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
750 opc, asm, "", pattern> {
751 let Inst{24-21} = opcod;
752 let Inst{27-26} = 0b00;
754 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
755 string asm, list<dag> pattern>
756 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
758 let Inst{24-21} = opcod;
759 let Inst{27-26} = 0b00;
764 // LDR/LDRB/STR/STRB/...
765 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
766 Format f, InstrItinClass itin, string opc, string asm,
768 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
770 let Inst{27-25} = op;
771 let Inst{24} = 1; // 24 == P
773 let Inst{22} = isByte;
774 let Inst{21} = 0; // 21 == W
777 // Indexed load/stores
778 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
779 IndexMode im, Format f, InstrItinClass itin, string opc,
780 string asm, string cstr, list<dag> pattern>
781 : I<oops, iops, AddrMode2, 4, im, f, itin,
782 opc, asm, cstr, pattern> {
784 let Inst{27-26} = 0b01;
785 let Inst{24} = isPre; // P bit
786 let Inst{22} = isByte; // B bit
787 let Inst{21} = isPre; // W bit
788 let Inst{20} = isLd; // L bit
789 let Inst{15-12} = Rt;
791 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
792 IndexMode im, Format f, InstrItinClass itin, string opc,
793 string asm, string cstr, list<dag> pattern>
794 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
796 // AM2 store w/ two operands: (GPR, am2offset)
802 let Inst{23} = offset{12};
803 let Inst{19-16} = Rn;
804 let Inst{11-5} = offset{11-5};
806 let Inst{3-0} = offset{3-0};
809 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
810 IndexMode im, Format f, InstrItinClass itin, string opc,
811 string asm, string cstr, list<dag> pattern>
812 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
814 // AM2 store w/ two operands: (GPR, am2offset)
820 let Inst{23} = offset{12};
821 let Inst{19-16} = Rn;
822 let Inst{11-0} = offset{11-0};
826 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
827 // but for now use this class for STRT and STRBT.
828 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
829 IndexMode im, Format f, InstrItinClass itin, string opc,
830 string asm, string cstr, list<dag> pattern>
831 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
833 // AM2 store w/ two operands: (GPR, am2offset)
835 // {13} 1 == Rm, 0 == imm12
839 let Inst{25} = addr{13};
840 let Inst{23} = addr{12};
841 let Inst{19-16} = addr{17-14};
842 let Inst{11-0} = addr{11-0};
845 // addrmode3 instructions
846 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
847 InstrItinClass itin, string opc, string asm, list<dag> pattern>
848 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
849 opc, asm, "", pattern> {
852 let Inst{27-25} = 0b000;
853 let Inst{24} = 1; // P bit
854 let Inst{23} = addr{8}; // U bit
855 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
856 let Inst{21} = 0; // W bit
857 let Inst{20} = op20; // L bit
858 let Inst{19-16} = addr{12-9}; // Rn
859 let Inst{15-12} = Rt; // Rt
860 let Inst{11-8} = addr{7-4}; // imm7_4/zero
862 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
864 let DecoderMethod = "DecodeAddrMode3Instruction";
867 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
868 IndexMode im, Format f, InstrItinClass itin, string opc,
869 string asm, string cstr, list<dag> pattern>
870 : I<oops, iops, AddrMode3, 4, im, f, itin,
871 opc, asm, cstr, pattern> {
873 let Inst{27-25} = 0b000;
874 let Inst{24} = isPre; // P bit
875 let Inst{21} = isPre; // W bit
876 let Inst{20} = op20; // L bit
877 let Inst{15-12} = Rt; // Rt
881 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
882 // but for now use this class for LDRSBT, LDRHT, LDSHT.
883 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
884 IndexMode im, Format f, InstrItinClass itin, string opc,
885 string asm, string cstr, list<dag> pattern>
886 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
887 // {13} 1 == imm8, 0 == Rm
894 let Inst{27-25} = 0b000;
895 let Inst{24} = 0; // P bit
897 let Inst{20} = isLoad; // L bit
898 let Inst{19-16} = addr; // Rn
899 let Inst{15-12} = Rt; // Rt
904 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
905 string opc, string asm, list<dag> pattern>
906 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
907 opc, asm, "", pattern> {
910 let Inst{27-25} = 0b000;
911 let Inst{24} = 1; // P bit
912 let Inst{23} = addr{8}; // U bit
913 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
914 let Inst{21} = 0; // W bit
915 let Inst{20} = 0; // L bit
916 let Inst{19-16} = addr{12-9}; // Rn
917 let Inst{15-12} = Rt; // Rt
918 let Inst{11-8} = addr{7-4}; // imm7_4/zero
920 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
921 let DecoderMethod = "DecodeAddrMode3Instruction";
924 // addrmode4 instructions
925 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
926 string asm, string cstr, list<dag> pattern>
927 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
932 let Inst{27-25} = 0b100;
933 let Inst{22} = 0; // S bit
934 let Inst{19-16} = Rn;
935 let Inst{15-0} = regs;
938 // Unsigned multiply, multiply-accumulate instructions.
939 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
940 string opc, string asm, list<dag> pattern>
941 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
942 opc, asm, "", pattern> {
943 let Inst{7-4} = 0b1001;
944 let Inst{20} = 0; // S bit
945 let Inst{27-21} = opcod;
947 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
948 string opc, string asm, list<dag> pattern>
949 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
950 opc, asm, "", pattern> {
951 let Inst{7-4} = 0b1001;
952 let Inst{27-21} = opcod;
955 // Most significant word multiply
956 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
957 InstrItinClass itin, string opc, string asm, list<dag> pattern>
958 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
959 opc, asm, "", pattern> {
963 let Inst{7-4} = opc7_4;
965 let Inst{27-21} = opcod;
966 let Inst{19-16} = Rd;
970 // MSW multiple w/ Ra operand
971 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
972 InstrItinClass itin, string opc, string asm, list<dag> pattern>
973 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
975 let Inst{15-12} = Ra;
978 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
979 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
980 InstrItinClass itin, string opc, string asm, list<dag> pattern>
981 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
982 opc, asm, "", pattern> {
988 let Inst{27-21} = opcod;
989 let Inst{6-5} = bit6_5;
993 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
994 InstrItinClass itin, string opc, string asm, list<dag> pattern>
995 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
997 let Inst{19-16} = Rd;
1000 // AMulxyI with Ra operand
1001 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1002 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1003 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1005 let Inst{15-12} = Ra;
1008 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1009 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1010 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1013 let Inst{19-16} = RdHi;
1014 let Inst{15-12} = RdLo;
1017 // Extend instructions.
1018 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1019 string opc, string asm, list<dag> pattern>
1020 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
1021 opc, asm, "", pattern> {
1022 // All AExtI instructions have Rd and Rm register operands.
1025 let Inst{15-12} = Rd;
1027 let Inst{7-4} = 0b0111;
1028 let Inst{9-8} = 0b00;
1029 let Inst{27-20} = opcod;
1031 let Unpredictable{9-8} = 0b11;
1034 // Misc Arithmetic instructions.
1035 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1036 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1037 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1038 opc, asm, "", pattern> {
1041 let Inst{27-20} = opcod;
1042 let Inst{19-16} = 0b1111;
1043 let Inst{15-12} = Rd;
1044 let Inst{11-8} = 0b1111;
1045 let Inst{7-4} = opc7_4;
1049 // Division instructions.
1050 class ADivA1I<bits<3> opcod, dag oops, dag iops,
1051 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1052 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1053 opc, asm, "", pattern> {
1057 let Inst{27-23} = 0b01110;
1058 let Inst{22-20} = opcod;
1059 let Inst{19-16} = Rd;
1060 let Inst{15-12} = 0b1111;
1061 let Inst{11-8} = Rm;
1062 let Inst{7-4} = 0b0001;
1067 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
1068 let Name = "PKHLSLImm";
1069 let ParserMethod = "parsePKHLSLImm";
1071 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1072 let PrintMethod = "printPKHLSLShiftImm";
1073 let ParserMatchClass = PKHLSLAsmOperand;
1075 def PKHASRAsmOperand : AsmOperandClass {
1076 let Name = "PKHASRImm";
1077 let ParserMethod = "parsePKHASRImm";
1079 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1080 let PrintMethod = "printPKHASRShiftImm";
1081 let ParserMatchClass = PKHASRAsmOperand;
1084 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1085 string opc, string asm, list<dag> pattern>
1086 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1087 opc, asm, "", pattern> {
1092 let Inst{27-20} = opcod;
1093 let Inst{19-16} = Rn;
1094 let Inst{15-12} = Rd;
1095 let Inst{11-7} = sh;
1097 let Inst{5-4} = 0b01;
1101 //===----------------------------------------------------------------------===//
1103 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1104 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1105 list<Predicate> Predicates = [IsARM];
1107 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1108 list<Predicate> Predicates = [IsARM, HasV5T];
1110 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1111 list<Predicate> Predicates = [IsARM, HasV5TE];
1113 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1114 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1115 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1117 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1118 list<Predicate> Predicates = [IsARM, HasV6];
1120 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1121 list<Predicate> Predicates = [HasVFP2];
1123 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1124 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1126 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1127 list<Predicate> Predicates = [IsThumb2, HasDSP];
1129 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1130 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1132 class FPRegs16Pat<dag pattern, dag result> : Pat<pattern, result> {
1133 list<Predicate> Predicates = [HasFPRegs16];
1135 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1136 list<Predicate> Predicates = [HasFP16];
1138 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1139 list<Predicate> Predicates = [HasFullFP16];
1141 //===----------------------------------------------------------------------===//
1142 // Thumb Instruction Format Definitions.
1145 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1146 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1147 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1148 let OutOperandList = oops;
1149 let InOperandList = iops;
1150 let AsmString = asm;
1151 let Pattern = pattern;
1152 list<Predicate> Predicates = [IsThumb];
1155 // TI - Thumb instruction.
1156 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1157 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1159 // Two-address instructions
1160 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1162 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1165 // tBL, tBX 32-bit instructions
1166 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1167 dag oops, dag iops, InstrItinClass itin, string asm,
1169 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1171 let Inst{31-27} = opcod1;
1172 let Inst{15-14} = opcod2;
1173 let Inst{12} = opcod3;
1176 // BR_JT instructions
1177 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1179 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1182 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1183 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1184 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1185 let OutOperandList = oops;
1186 let InOperandList = iops;
1187 let AsmString = asm;
1188 let Pattern = pattern;
1189 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1192 class T1I<dag oops, dag iops, InstrItinClass itin,
1193 string asm, list<dag> pattern>
1194 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1195 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1196 string asm, list<dag> pattern>
1197 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1199 // Two-address instructions
1200 class T1It<dag oops, dag iops, InstrItinClass itin,
1201 string asm, string cstr, list<dag> pattern>
1202 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1203 asm, cstr, pattern>;
1205 // Thumb1 instruction that can either be predicated or set CPSR.
1206 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1207 InstrItinClass itin,
1208 string opc, string asm, string cstr, list<dag> pattern>
1209 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1210 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1211 let InOperandList = !con(iops, (ins pred:$p));
1212 let AsmString = !strconcat(opc, "${s}${p}", asm);
1213 let Pattern = pattern;
1214 let thumbArithFlagSetting = 1;
1215 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1216 let DecoderNamespace = "ThumbSBit";
1219 class T1sI<dag oops, dag iops, InstrItinClass itin,
1220 string opc, string asm, list<dag> pattern>
1221 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1223 // Two-address instructions
1224 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1225 string opc, string asm, list<dag> pattern>
1226 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1227 "$Rn = $Rdn", pattern>;
1229 // Thumb1 instruction that can be predicated.
1230 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1231 InstrItinClass itin,
1232 string opc, string asm, string cstr, list<dag> pattern>
1233 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1234 let OutOperandList = oops;
1235 let InOperandList = !con(iops, (ins pred:$p));
1236 let AsmString = !strconcat(opc, "${p}", asm);
1237 let Pattern = pattern;
1238 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1241 class T1pI<dag oops, dag iops, InstrItinClass itin,
1242 string opc, string asm, list<dag> pattern>
1243 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1245 // Two-address instructions
1246 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1247 string opc, string asm, list<dag> pattern>
1248 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1249 "$Rn = $Rdn", pattern>;
1251 class T1pIs<dag oops, dag iops,
1252 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1253 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1255 class Encoding16 : Encoding {
1256 let Inst{31-16} = 0x0000;
1259 // A6.2 16-bit Thumb instruction encoding
1260 class T1Encoding<bits<6> opcode> : Encoding16 {
1261 let Inst{15-10} = opcode;
1264 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1265 class T1General<bits<5> opcode> : Encoding16 {
1266 let Inst{15-14} = 0b00;
1267 let Inst{13-9} = opcode;
1270 // A6.2.2 Data-processing encoding.
1271 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1272 let Inst{15-10} = 0b010000;
1273 let Inst{9-6} = opcode;
1276 // A6.2.3 Special data instructions and branch and exchange encoding.
1277 class T1Special<bits<4> opcode> : Encoding16 {
1278 let Inst{15-10} = 0b010001;
1279 let Inst{9-6} = opcode;
1282 // A6.2.4 Load/store single data item encoding.
1283 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1284 let Inst{15-12} = opA;
1285 let Inst{11-9} = opB;
1287 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1289 class T1BranchCond<bits<4> opcode> : Encoding16 {
1290 let Inst{15-12} = opcode;
1293 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1294 // following bits are used for "opA" (see A6.2.4):
1296 // 0b0110 => Immediate, 4 bytes
1297 // 0b1000 => Immediate, 2 bytes
1298 // 0b0111 => Immediate, 1 byte
1299 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1300 InstrItinClass itin, string opc, string asm,
1302 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1303 T1LoadStore<0b0101, opcode> {
1306 let Inst{8-6} = addr{5-3}; // Rm
1307 let Inst{5-3} = addr{2-0}; // Rn
1310 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1311 InstrItinClass itin, string opc, string asm,
1313 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1314 T1LoadStore<opA, {opB,?,?}> {
1317 let Inst{10-6} = addr{7-3}; // imm5
1318 let Inst{5-3} = addr{2-0}; // Rn
1322 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1323 class T1Misc<bits<7> opcode> : Encoding16 {
1324 let Inst{15-12} = 0b1011;
1325 let Inst{11-5} = opcode;
1328 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1329 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1330 InstrItinClass itin,
1331 string opc, string asm, string cstr, list<dag> pattern>
1332 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1333 let OutOperandList = oops;
1334 let InOperandList = !con(iops, (ins pred:$p));
1335 let AsmString = !strconcat(opc, "${p}", asm);
1336 let Pattern = pattern;
1337 list<Predicate> Predicates = [IsThumb2];
1338 let DecoderNamespace = "Thumb2";
1341 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1342 // input operand since by default it's a zero register. It will become an
1343 // implicit def once it's "flipped".
1345 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1347 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1348 InstrItinClass itin,
1349 string opc, string asm, string cstr, list<dag> pattern>
1350 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1351 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1354 let OutOperandList = oops;
1355 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1356 let AsmString = !strconcat(opc, "${s}${p}", asm);
1357 let Pattern = pattern;
1358 list<Predicate> Predicates = [IsThumb2];
1359 let DecoderNamespace = "Thumb2";
1363 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1364 InstrItinClass itin,
1365 string asm, string cstr, list<dag> pattern>
1366 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1367 let OutOperandList = oops;
1368 let InOperandList = iops;
1369 let AsmString = asm;
1370 let Pattern = pattern;
1371 list<Predicate> Predicates = [IsThumb2];
1372 let DecoderNamespace = "Thumb2";
1375 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1376 InstrItinClass itin,
1377 string asm, string cstr, list<dag> pattern>
1378 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1379 let OutOperandList = oops;
1380 let InOperandList = iops;
1381 let AsmString = asm;
1382 let Pattern = pattern;
1383 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1384 let DecoderNamespace = "Thumb";
1387 class T2I<dag oops, dag iops, InstrItinClass itin,
1388 string opc, string asm, list<dag> pattern, AddrMode am = AddrModeNone>
1389 : Thumb2I<oops, iops, am, 4, itin, opc, asm, "", pattern>;
1390 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1391 string opc, string asm, list<dag> pattern>
1392 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1393 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1394 string opc, string asm, list<dag> pattern>
1395 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1396 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1397 string opc, string asm, list<dag> pattern>
1398 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1399 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1400 string opc, string asm, list<dag> pattern>
1401 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1402 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1403 string opc, string asm, string cstr, list<dag> pattern>
1404 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1409 let Inst{31-25} = 0b1110100;
1411 let Inst{23} = addr{8};
1414 let Inst{20} = isLoad;
1415 let Inst{19-16} = addr{12-9};
1416 let Inst{15-12} = Rt{3-0};
1417 let Inst{11-8} = Rt2{3-0};
1418 let Inst{7-0} = addr{7-0};
1420 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1421 InstrItinClass itin, string opc, string asm, string cstr,
1423 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1429 let Inst{31-25} = 0b1110100;
1431 let Inst{23} = imm{8};
1434 let Inst{20} = isLoad;
1435 let Inst{19-16} = addr;
1436 let Inst{15-12} = Rt{3-0};
1437 let Inst{11-8} = Rt2{3-0};
1438 let Inst{7-0} = imm{7-0};
1441 class T2sI<dag oops, dag iops, InstrItinClass itin,
1442 string opc, string asm, list<dag> pattern>
1443 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1445 class T2XI<dag oops, dag iops, InstrItinClass itin,
1446 string asm, list<dag> pattern>
1447 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1448 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1449 string asm, list<dag> pattern>
1450 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1452 // Move to/from coprocessor instructions
1453 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1455 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1456 let Inst{31-28} = opc;
1459 // Two-address instructions
1460 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1461 string asm, string cstr, list<dag> pattern>
1462 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1464 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1465 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1467 AddrMode am, IndexMode im, InstrItinClass itin,
1468 string opc, string asm, string cstr, list<dag> pattern>
1469 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1470 let OutOperandList = oops;
1471 let InOperandList = !con(iops, (ins pred:$p));
1472 let AsmString = !strconcat(opc, "${p}", asm);
1473 let Pattern = pattern;
1474 list<Predicate> Predicates = [IsThumb2];
1475 let DecoderNamespace = "Thumb2";
1479 let Inst{31-27} = 0b11111;
1480 let Inst{26-25} = 0b00;
1481 let Inst{24} = signed;
1483 let Inst{22-21} = opcod;
1484 let Inst{20} = load;
1485 let Inst{19-16} = addr{12-9};
1486 let Inst{15-12} = Rt{3-0};
1488 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1489 let Inst{10} = pre; // The P bit.
1490 let Inst{9} = addr{8}; // Sign bit
1491 let Inst{8} = 1; // The W bit.
1492 let Inst{7-0} = addr{7-0};
1494 let DecoderMethod = "DecodeT2LdStPre";
1497 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1498 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1500 AddrMode am, IndexMode im, InstrItinClass itin,
1501 string opc, string asm, string cstr, list<dag> pattern>
1502 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1503 let OutOperandList = oops;
1504 let InOperandList = !con(iops, (ins pred:$p));
1505 let AsmString = !strconcat(opc, "${p}", asm);
1506 let Pattern = pattern;
1507 list<Predicate> Predicates = [IsThumb2];
1508 let DecoderNamespace = "Thumb2";
1513 let Inst{31-27} = 0b11111;
1514 let Inst{26-25} = 0b00;
1515 let Inst{24} = signed;
1517 let Inst{22-21} = opcod;
1518 let Inst{20} = load;
1519 let Inst{19-16} = Rn;
1520 let Inst{15-12} = Rt{3-0};
1522 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1523 let Inst{10} = pre; // The P bit.
1524 let Inst{9} = offset{8}; // Sign bit
1525 let Inst{8} = 1; // The W bit.
1526 let Inst{7-0} = offset{7-0};
1528 let DecoderMethod = "DecodeT2LdStPre";
1531 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1532 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1533 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1536 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1537 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1538 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1541 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1542 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1543 list<Predicate> Predicates = [IsThumb2];
1546 //===----------------------------------------------------------------------===//
1548 //===----------------------------------------------------------------------===//
1549 // ARM VFP Instruction templates.
1552 // Almost all VFP instructions are predicable.
1553 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1554 IndexMode im, Format f, InstrItinClass itin,
1555 string opc, string asm, string cstr, list<dag> pattern>
1556 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1558 let Inst{31-28} = p;
1559 let OutOperandList = oops;
1560 let InOperandList = !con(iops, (ins pred:$p));
1561 let AsmString = !strconcat(opc, "${p}", asm);
1562 let Pattern = pattern;
1563 let PostEncoderMethod = "VFPThumb2PostEncoder";
1564 let DecoderNamespace = "VFP";
1565 list<Predicate> Predicates = [HasVFP2];
1569 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1570 IndexMode im, Format f, InstrItinClass itin,
1571 string asm, string cstr, list<dag> pattern>
1572 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1574 let Inst{31-28} = p;
1575 let OutOperandList = oops;
1576 let InOperandList = iops;
1577 let AsmString = asm;
1578 let Pattern = pattern;
1579 let PostEncoderMethod = "VFPThumb2PostEncoder";
1580 let DecoderNamespace = "VFP";
1581 list<Predicate> Predicates = [HasVFP2];
1584 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1585 string opc, string asm, list<dag> pattern>
1586 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1587 opc, asm, "", pattern> {
1588 let PostEncoderMethod = "VFPThumb2PostEncoder";
1591 // ARM VFP addrmode5 loads and stores
1592 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1593 InstrItinClass itin,
1594 string opc, string asm, list<dag> pattern>
1595 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1596 VFPLdStFrm, itin, opc, asm, "", pattern> {
1597 // Instruction operands.
1601 // Encode instruction operands.
1602 let Inst{23} = addr{8}; // U (add = (U == '1'))
1603 let Inst{22} = Dd{4};
1604 let Inst{19-16} = addr{12-9}; // Rn
1605 let Inst{15-12} = Dd{3-0};
1606 let Inst{7-0} = addr{7-0}; // imm8
1608 let Inst{27-24} = opcod1;
1609 let Inst{21-20} = opcod2;
1610 let Inst{11-9} = 0b101;
1611 let Inst{8} = 1; // Double precision
1613 // Loads & stores operate on both NEON and VFP pipelines.
1614 let D = VFPNeonDomain;
1617 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1618 InstrItinClass itin,
1619 string opc, string asm, list<dag> pattern>
1620 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1621 VFPLdStFrm, itin, opc, asm, "", pattern> {
1622 // Instruction operands.
1626 // Encode instruction operands.
1627 let Inst{23} = addr{8}; // U (add = (U == '1'))
1628 let Inst{22} = Sd{0};
1629 let Inst{19-16} = addr{12-9}; // Rn
1630 let Inst{15-12} = Sd{4-1};
1631 let Inst{7-0} = addr{7-0}; // imm8
1633 let Inst{27-24} = opcod1;
1634 let Inst{21-20} = opcod2;
1635 let Inst{11-9} = 0b101;
1636 let Inst{8} = 0; // Single precision
1638 // Loads & stores operate on both NEON and VFP pipelines.
1639 let D = VFPNeonDomain;
1642 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1643 InstrItinClass itin,
1644 string opc, string asm, list<dag> pattern>
1645 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1646 VFPLdStFrm, itin, opc, asm, "", pattern> {
1647 list<Predicate> Predicates = [HasFullFP16];
1649 // Instruction operands.
1653 // Encode instruction operands.
1654 let Inst{23} = addr{8}; // U (add = (U == '1'))
1655 let Inst{22} = Sd{0};
1656 let Inst{19-16} = addr{12-9}; // Rn
1657 let Inst{15-12} = Sd{4-1};
1658 let Inst{7-0} = addr{7-0}; // imm8
1660 let Inst{27-24} = opcod1;
1661 let Inst{21-20} = opcod2;
1662 let Inst{11-8} = 0b1001; // Half precision
1664 // Loads & stores operate on both NEON and VFP pipelines.
1665 let D = VFPNeonDomain;
1667 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1670 // VFP Load / store multiple pseudo instructions.
1671 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1673 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1675 let OutOperandList = oops;
1676 let InOperandList = !con(iops, (ins pred:$p));
1677 let Pattern = pattern;
1678 list<Predicate> Predicates = [HasVFP2];
1681 // Load / store multiple
1683 // Unknown precision
1684 class AXXI4<dag oops, dag iops, IndexMode im,
1685 string asm, string cstr, list<dag> pattern>
1686 : VFPXI<oops, iops, AddrMode4, 4, im,
1687 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1688 // Instruction operands.
1692 // Encode instruction operands.
1693 let Inst{19-16} = Rn;
1695 let Inst{15-12} = regs{11-8};
1696 let Inst{7-1} = regs{7-1};
1698 let Inst{27-25} = 0b110;
1699 let Inst{11-8} = 0b1011;
1704 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1705 string asm, string cstr, list<dag> pattern>
1706 : VFPXI<oops, iops, AddrMode4, 4, im,
1707 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1708 // Instruction operands.
1712 // Encode instruction operands.
1713 let Inst{19-16} = Rn;
1714 let Inst{22} = regs{12};
1715 let Inst{15-12} = regs{11-8};
1716 let Inst{7-1} = regs{7-1};
1718 let Inst{27-25} = 0b110;
1719 let Inst{11-9} = 0b101;
1720 let Inst{8} = 1; // Double precision
1725 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1726 string asm, string cstr, list<dag> pattern>
1727 : VFPXI<oops, iops, AddrMode4, 4, im,
1728 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1729 // Instruction operands.
1733 // Encode instruction operands.
1734 let Inst{19-16} = Rn;
1735 let Inst{22} = regs{8};
1736 let Inst{15-12} = regs{12-9};
1737 let Inst{7-0} = regs{7-0};
1739 let Inst{27-25} = 0b110;
1740 let Inst{11-9} = 0b101;
1741 let Inst{8} = 0; // Single precision
1744 // Double precision, unary
1745 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1746 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1747 string asm, list<dag> pattern>
1748 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1749 // Instruction operands.
1753 // Encode instruction operands.
1754 let Inst{3-0} = Dm{3-0};
1755 let Inst{5} = Dm{4};
1756 let Inst{15-12} = Dd{3-0};
1757 let Inst{22} = Dd{4};
1759 let Inst{27-23} = opcod1;
1760 let Inst{21-20} = opcod2;
1761 let Inst{19-16} = opcod3;
1762 let Inst{11-9} = 0b101;
1763 let Inst{8} = 1; // Double precision
1764 let Inst{7-6} = opcod4;
1765 let Inst{4} = opcod5;
1767 let Predicates = [HasVFP2, HasDPVFP];
1770 // Double precision, unary, not-predicated
1771 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1772 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1773 string asm, list<dag> pattern>
1774 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1775 // Instruction operands.
1779 let Inst{31-28} = 0b1111;
1781 // Encode instruction operands.
1782 let Inst{3-0} = Dm{3-0};
1783 let Inst{5} = Dm{4};
1784 let Inst{15-12} = Dd{3-0};
1785 let Inst{22} = Dd{4};
1787 let Inst{27-23} = opcod1;
1788 let Inst{21-20} = opcod2;
1789 let Inst{19-16} = opcod3;
1790 let Inst{11-9} = 0b101;
1791 let Inst{8} = 1; // Double precision
1792 let Inst{7-6} = opcod4;
1793 let Inst{4} = opcod5;
1796 // Double precision, binary
1797 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1798 dag iops, InstrItinClass itin, string opc, string asm,
1800 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1801 // Instruction operands.
1806 // Encode instruction operands.
1807 let Inst{3-0} = Dm{3-0};
1808 let Inst{5} = Dm{4};
1809 let Inst{19-16} = Dn{3-0};
1810 let Inst{7} = Dn{4};
1811 let Inst{15-12} = Dd{3-0};
1812 let Inst{22} = Dd{4};
1814 let Inst{27-23} = opcod1;
1815 let Inst{21-20} = opcod2;
1816 let Inst{11-9} = 0b101;
1817 let Inst{8} = 1; // Double precision
1821 let Predicates = [HasVFP2, HasDPVFP];
1824 // FP, binary, not predicated
1825 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1826 InstrItinClass itin, string asm, list<dag> pattern>
1827 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1830 // Instruction operands.
1835 let Inst{31-28} = 0b1111;
1837 // Encode instruction operands.
1838 let Inst{3-0} = Dm{3-0};
1839 let Inst{5} = Dm{4};
1840 let Inst{19-16} = Dn{3-0};
1841 let Inst{7} = Dn{4};
1842 let Inst{15-12} = Dd{3-0};
1843 let Inst{22} = Dd{4};
1845 let Inst{27-23} = opcod1;
1846 let Inst{21-20} = opcod2;
1847 let Inst{11-9} = 0b101;
1848 let Inst{8} = 1; // double precision
1849 let Inst{6} = opcod3;
1852 let Predicates = [HasVFP2, HasDPVFP];
1855 // Single precision, unary, predicated
1856 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1857 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1858 string asm, list<dag> pattern>
1859 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1860 // Instruction operands.
1864 // Encode instruction operands.
1865 let Inst{3-0} = Sm{4-1};
1866 let Inst{5} = Sm{0};
1867 let Inst{15-12} = Sd{4-1};
1868 let Inst{22} = Sd{0};
1870 let Inst{27-23} = opcod1;
1871 let Inst{21-20} = opcod2;
1872 let Inst{19-16} = opcod3;
1873 let Inst{11-9} = 0b101;
1874 let Inst{8} = 0; // Single precision
1875 let Inst{7-6} = opcod4;
1876 let Inst{4} = opcod5;
1879 // Single precision, unary, non-predicated
1880 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1881 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1882 string asm, list<dag> pattern>
1883 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1884 VFPUnaryFrm, itin, asm, "", pattern> {
1885 // Instruction operands.
1889 let Inst{31-28} = 0b1111;
1891 // Encode instruction operands.
1892 let Inst{3-0} = Sm{4-1};
1893 let Inst{5} = Sm{0};
1894 let Inst{15-12} = Sd{4-1};
1895 let Inst{22} = Sd{0};
1897 let Inst{27-23} = opcod1;
1898 let Inst{21-20} = opcod2;
1899 let Inst{19-16} = opcod3;
1900 let Inst{11-9} = 0b101;
1901 let Inst{8} = 0; // Single precision
1902 let Inst{7-6} = opcod4;
1903 let Inst{4} = opcod5;
1906 // Single precision unary, if no NEON. Same as ASuI except not available if
1908 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1909 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1910 string asm, list<dag> pattern>
1911 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1913 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1916 // Single precision, binary
1917 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1918 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1919 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1920 // Instruction operands.
1925 // Encode instruction operands.
1926 let Inst{3-0} = Sm{4-1};
1927 let Inst{5} = Sm{0};
1928 let Inst{19-16} = Sn{4-1};
1929 let Inst{7} = Sn{0};
1930 let Inst{15-12} = Sd{4-1};
1931 let Inst{22} = Sd{0};
1933 let Inst{27-23} = opcod1;
1934 let Inst{21-20} = opcod2;
1935 let Inst{11-9} = 0b101;
1936 let Inst{8} = 0; // Single precision
1941 // Single precision, binary, not predicated
1942 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1943 InstrItinClass itin, string asm, list<dag> pattern>
1944 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1945 VFPBinaryFrm, itin, asm, "", pattern>
1947 // Instruction operands.
1952 let Inst{31-28} = 0b1111;
1954 // Encode instruction operands.
1955 let Inst{3-0} = Sm{4-1};
1956 let Inst{5} = Sm{0};
1957 let Inst{19-16} = Sn{4-1};
1958 let Inst{7} = Sn{0};
1959 let Inst{15-12} = Sd{4-1};
1960 let Inst{22} = Sd{0};
1962 let Inst{27-23} = opcod1;
1963 let Inst{21-20} = opcod2;
1964 let Inst{11-9} = 0b101;
1965 let Inst{8} = 0; // Single precision
1966 let Inst{6} = opcod3;
1970 // Single precision binary, if no NEON. Same as ASbI except not available if
1972 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1973 dag iops, InstrItinClass itin, string opc, string asm,
1975 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1976 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1978 // Instruction operands.
1983 // Encode instruction operands.
1984 let Inst{3-0} = Sm{4-1};
1985 let Inst{5} = Sm{0};
1986 let Inst{19-16} = Sn{4-1};
1987 let Inst{7} = Sn{0};
1988 let Inst{15-12} = Sd{4-1};
1989 let Inst{22} = Sd{0};
1992 // Half precision, unary, predicated
1993 class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1994 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1995 string asm, list<dag> pattern>
1996 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1997 list<Predicate> Predicates = [HasFullFP16];
1999 // Instruction operands.
2003 // Encode instruction operands.
2004 let Inst{3-0} = Sm{4-1};
2005 let Inst{5} = Sm{0};
2006 let Inst{15-12} = Sd{4-1};
2007 let Inst{22} = Sd{0};
2009 let Inst{27-23} = opcod1;
2010 let Inst{21-20} = opcod2;
2011 let Inst{19-16} = opcod3;
2012 let Inst{11-8} = 0b1001; // Half precision
2013 let Inst{7-6} = opcod4;
2014 let Inst{4} = opcod5;
2016 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2019 // Half precision, unary, non-predicated
2020 class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2021 bit opcod5, dag oops, dag iops, InstrItinClass itin,
2022 string asm, list<dag> pattern>
2023 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2024 VFPUnaryFrm, itin, asm, "", pattern> {
2025 list<Predicate> Predicates = [HasFullFP16];
2027 // Instruction operands.
2031 let Inst{31-28} = 0b1111;
2033 // Encode instruction operands.
2034 let Inst{3-0} = Sm{4-1};
2035 let Inst{5} = Sm{0};
2036 let Inst{15-12} = Sd{4-1};
2037 let Inst{22} = Sd{0};
2039 let Inst{27-23} = opcod1;
2040 let Inst{21-20} = opcod2;
2041 let Inst{19-16} = opcod3;
2042 let Inst{11-8} = 0b1001; // Half precision
2043 let Inst{7-6} = opcod4;
2044 let Inst{4} = opcod5;
2046 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2049 // Half precision, binary
2050 class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
2051 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2052 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
2053 list<Predicate> Predicates = [HasFullFP16];
2055 // Instruction operands.
2060 // Encode instruction operands.
2061 let Inst{3-0} = Sm{4-1};
2062 let Inst{5} = Sm{0};
2063 let Inst{19-16} = Sn{4-1};
2064 let Inst{7} = Sn{0};
2065 let Inst{15-12} = Sd{4-1};
2066 let Inst{22} = Sd{0};
2068 let Inst{27-23} = opcod1;
2069 let Inst{21-20} = opcod2;
2070 let Inst{11-8} = 0b1001; // Half precision
2074 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2077 // Half precision, binary, not predicated
2078 class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
2079 InstrItinClass itin, string asm, list<dag> pattern>
2080 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2081 VFPBinaryFrm, itin, asm, "", pattern> {
2082 list<Predicate> Predicates = [HasFullFP16];
2084 // Instruction operands.
2089 let Inst{31-28} = 0b1111;
2091 // Encode instruction operands.
2092 let Inst{3-0} = Sm{4-1};
2093 let Inst{5} = Sm{0};
2094 let Inst{19-16} = Sn{4-1};
2095 let Inst{7} = Sn{0};
2096 let Inst{15-12} = Sd{4-1};
2097 let Inst{22} = Sd{0};
2099 let Inst{27-23} = opcod1;
2100 let Inst{21-20} = opcod2;
2101 let Inst{11-8} = 0b1001; // Half precision
2102 let Inst{6} = opcod3;
2105 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2108 // VFP conversion instructions
2109 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2110 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2112 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
2113 let Inst{27-23} = opcod1;
2114 let Inst{21-20} = opcod2;
2115 let Inst{19-16} = opcod3;
2116 let Inst{11-8} = opcod4;
2121 // VFP conversion between floating-point and fixed-point
2122 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2123 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2125 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2127 // size (fixed-point number): sx == 0 ? 16 : 32
2128 let Inst{7} = op5; // sx
2129 let Inst{5} = fbits{0};
2130 let Inst{3-0} = fbits{4-1};
2133 // VFP conversion instructions, if no NEON
2134 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2135 dag oops, dag iops, InstrItinClass itin,
2136 string opc, string asm, list<dag> pattern>
2137 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2139 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2142 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2143 InstrItinClass itin,
2144 string opc, string asm, list<dag> pattern>
2145 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
2146 let Inst{27-20} = opcod1;
2147 let Inst{11-8} = opcod2;
2151 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2152 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2153 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
2155 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2156 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2157 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2159 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2160 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2161 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
2163 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2164 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2165 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
2167 //===----------------------------------------------------------------------===//
2169 //===----------------------------------------------------------------------===//
2170 // ARM NEON Instruction templates.
2173 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2174 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2176 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2177 let OutOperandList = oops;
2178 let InOperandList = !con(iops, (ins pred:$p));
2179 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2180 let Pattern = pattern;
2181 list<Predicate> Predicates = [HasNEON];
2182 let DecoderNamespace = "NEON";
2185 // Same as NeonI except it does not have a "data type" specifier.
2186 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2187 InstrItinClass itin, string opc, string asm, string cstr,
2189 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2190 let OutOperandList = oops;
2191 let InOperandList = !con(iops, (ins pred:$p));
2192 let AsmString = !strconcat(opc, "${p}", "\t", asm);
2193 let Pattern = pattern;
2194 list<Predicate> Predicates = [HasNEON];
2195 let DecoderNamespace = "NEON";
2198 // Same as NeonI except it is not predicated
2199 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2200 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2202 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2203 let OutOperandList = oops;
2204 let InOperandList = iops;
2205 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2206 let Pattern = pattern;
2207 list<Predicate> Predicates = [HasNEON];
2208 let DecoderNamespace = "NEON";
2210 let Inst{31-28} = 0b1111;
2213 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2214 dag oops, dag iops, InstrItinClass itin,
2215 string opc, string dt, string asm, string cstr, list<dag> pattern>
2216 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2218 let Inst{31-24} = 0b11110100;
2219 let Inst{23} = op23;
2220 let Inst{21-20} = op21_20;
2221 let Inst{11-8} = op11_8;
2222 let Inst{7-4} = op7_4;
2224 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2225 let DecoderNamespace = "NEONLoadStore";
2231 let Inst{22} = Vd{4};
2232 let Inst{15-12} = Vd{3-0};
2233 let Inst{19-16} = Rn{3-0};
2234 let Inst{3-0} = Rm{3-0};
2237 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2238 dag oops, dag iops, InstrItinClass itin,
2239 string opc, string dt, string asm, string cstr, list<dag> pattern>
2240 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2241 dt, asm, cstr, pattern> {
2245 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2246 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2248 let OutOperandList = oops;
2249 let InOperandList = !con(iops, (ins pred:$p));
2250 list<Predicate> Predicates = [HasNEON];
2253 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2255 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2257 let OutOperandList = oops;
2258 let InOperandList = !con(iops, (ins pred:$p));
2259 let Pattern = pattern;
2260 list<Predicate> Predicates = [HasNEON];
2263 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2264 string opc, string dt, string asm, string cstr, list<dag> pattern>
2265 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2267 let Inst{31-25} = 0b1111001;
2268 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2269 let DecoderNamespace = "NEONData";
2272 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2273 string opc, string asm, string cstr, list<dag> pattern>
2274 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2276 let Inst{31-25} = 0b1111001;
2277 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2278 let DecoderNamespace = "NEONData";
2281 // NEON "one register and a modified immediate" format.
2282 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2284 dag oops, dag iops, InstrItinClass itin,
2285 string opc, string dt, string asm, string cstr,
2287 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2288 let Inst{23} = op23;
2289 let Inst{21-19} = op21_19;
2290 let Inst{11-8} = op11_8;
2296 // Instruction operands.
2300 let Inst{15-12} = Vd{3-0};
2301 let Inst{22} = Vd{4};
2302 let Inst{24} = SIMM{7};
2303 let Inst{18-16} = SIMM{6-4};
2304 let Inst{3-0} = SIMM{3-0};
2305 let DecoderMethod = "DecodeVMOVModImmInstruction";
2308 // NEON 2 vector register format.
2309 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2310 bits<5> op11_7, bit op6, bit op4,
2311 dag oops, dag iops, InstrItinClass itin,
2312 string opc, string dt, string asm, string cstr, list<dag> pattern>
2313 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2314 let Inst{24-23} = op24_23;
2315 let Inst{21-20} = op21_20;
2316 let Inst{19-18} = op19_18;
2317 let Inst{17-16} = op17_16;
2318 let Inst{11-7} = op11_7;
2322 // Instruction operands.
2326 let Inst{15-12} = Vd{3-0};
2327 let Inst{22} = Vd{4};
2328 let Inst{3-0} = Vm{3-0};
2329 let Inst{5} = Vm{4};
2332 // Same as N2V but not predicated.
2333 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2334 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2335 string Dt, list<dag> pattern>
2336 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2337 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2341 // Encode instruction operands
2342 let Inst{22} = Vd{4};
2343 let Inst{15-12} = Vd{3-0};
2344 let Inst{5} = Vm{4};
2345 let Inst{3-0} = Vm{3-0};
2347 // Encode constant bits
2348 let Inst{27-23} = 0b00111;
2349 let Inst{21-20} = 0b11;
2350 let Inst{19-18} = op19_18;
2351 let Inst{17-16} = op17_16;
2353 let Inst{10-8} = op10_8;
2358 let DecoderNamespace = "NEON";
2361 // Same as N2V except it doesn't have a datatype suffix.
2362 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2363 bits<5> op11_7, bit op6, bit op4,
2364 dag oops, dag iops, InstrItinClass itin,
2365 string opc, string asm, string cstr, list<dag> pattern>
2366 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2367 let Inst{24-23} = op24_23;
2368 let Inst{21-20} = op21_20;
2369 let Inst{19-18} = op19_18;
2370 let Inst{17-16} = op17_16;
2371 let Inst{11-7} = op11_7;
2375 // Instruction operands.
2379 let Inst{15-12} = Vd{3-0};
2380 let Inst{22} = Vd{4};
2381 let Inst{3-0} = Vm{3-0};
2382 let Inst{5} = Vm{4};
2385 // NEON 2 vector register with immediate.
2386 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2387 dag oops, dag iops, Format f, InstrItinClass itin,
2388 string opc, string dt, string asm, string cstr, list<dag> pattern>
2389 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2390 let Inst{24} = op24;
2391 let Inst{23} = op23;
2392 let Inst{11-8} = op11_8;
2397 // Instruction operands.
2402 let Inst{15-12} = Vd{3-0};
2403 let Inst{22} = Vd{4};
2404 let Inst{3-0} = Vm{3-0};
2405 let Inst{5} = Vm{4};
2406 let Inst{21-16} = SIMM{5-0};
2409 // NEON 3 vector register format.
2411 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2412 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2413 string opc, string dt, string asm, string cstr,
2415 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2416 let Inst{24} = op24;
2417 let Inst{23} = op23;
2418 let Inst{21-20} = op21_20;
2419 let Inst{11-8} = op11_8;
2424 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2425 dag oops, dag iops, Format f, InstrItinClass itin,
2426 string opc, string dt, string asm, string cstr, list<dag> pattern>
2427 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2428 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2429 // Instruction operands.
2434 let Inst{15-12} = Vd{3-0};
2435 let Inst{22} = Vd{4};
2436 let Inst{19-16} = Vn{3-0};
2437 let Inst{7} = Vn{4};
2438 let Inst{3-0} = Vm{3-0};
2439 let Inst{5} = Vm{4};
2442 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2443 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2444 string OpcodeStr, string Dt, list<dag> pattern>
2445 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2446 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2451 // Encode instruction operands
2452 let Inst{22} = Vd{4};
2453 let Inst{15-12} = Vd{3-0};
2454 let Inst{19-16} = Vn{3-0};
2455 let Inst{7} = Vn{4};
2456 let Inst{5} = Vm{4};
2457 let Inst{3-0} = Vm{3-0};
2459 // Encode constant bits
2460 let Inst{27-23} = op27_23;
2461 let Inst{21-20} = op21_20;
2462 let Inst{11-8} = op11_8;
2467 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2468 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2469 string opc, string dt, string asm, string cstr,
2471 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2472 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2474 // Instruction operands.
2480 let Inst{15-12} = Vd{3-0};
2481 let Inst{22} = Vd{4};
2482 let Inst{19-16} = Vn{3-0};
2483 let Inst{7} = Vn{4};
2484 let Inst{3-0} = Vm{3-0};
2488 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2489 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2490 string opc, string dt, string asm, string cstr,
2492 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2493 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2495 // Instruction operands.
2501 let Inst{15-12} = Vd{3-0};
2502 let Inst{22} = Vd{4};
2503 let Inst{19-16} = Vn{3-0};
2504 let Inst{7} = Vn{4};
2505 let Inst{2-0} = Vm{2-0};
2506 let Inst{5} = lane{1};
2507 let Inst{3} = lane{0};
2510 // Same as N3V except it doesn't have a data type suffix.
2511 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2513 dag oops, dag iops, Format f, InstrItinClass itin,
2514 string opc, string asm, string cstr, list<dag> pattern>
2515 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2516 let Inst{24} = op24;
2517 let Inst{23} = op23;
2518 let Inst{21-20} = op21_20;
2519 let Inst{11-8} = op11_8;
2523 // Instruction operands.
2528 let Inst{15-12} = Vd{3-0};
2529 let Inst{22} = Vd{4};
2530 let Inst{19-16} = Vn{3-0};
2531 let Inst{7} = Vn{4};
2532 let Inst{3-0} = Vm{3-0};
2533 let Inst{5} = Vm{4};
2536 // NEON VMOVs between scalar and core registers.
2537 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2538 dag oops, dag iops, Format f, InstrItinClass itin,
2539 string opc, string dt, string asm, list<dag> pattern>
2540 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2542 let Inst{27-20} = opcod1;
2543 let Inst{11-8} = opcod2;
2544 let Inst{6-5} = opcod3;
2546 // A8.6.303, A8.6.328, A8.6.329
2547 let Inst{3-0} = 0b0000;
2549 let OutOperandList = oops;
2550 let InOperandList = !con(iops, (ins pred:$p));
2551 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2552 let Pattern = pattern;
2553 list<Predicate> Predicates = [HasNEON];
2555 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2556 let DecoderNamespace = "NEONDup";
2563 let Inst{31-28} = p{3-0};
2565 let Inst{19-16} = V{3-0};
2566 let Inst{15-12} = R{3-0};
2568 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2569 dag oops, dag iops, InstrItinClass itin,
2570 string opc, string dt, string asm, list<dag> pattern>
2571 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2572 opc, dt, asm, pattern>;
2573 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2574 dag oops, dag iops, InstrItinClass itin,
2575 string opc, string dt, string asm, list<dag> pattern>
2576 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2577 opc, dt, asm, pattern>;
2578 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2579 dag oops, dag iops, InstrItinClass itin,
2580 string opc, string dt, string asm, list<dag> pattern>
2581 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2582 opc, dt, asm, pattern>;
2584 // Vector Duplicate Lane (from scalar to all elements)
2585 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2586 InstrItinClass itin, string opc, string dt, string asm,
2588 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2589 let Inst{24-23} = 0b11;
2590 let Inst{21-20} = 0b11;
2591 let Inst{19-16} = op19_16;
2592 let Inst{11-7} = 0b11000;
2599 let Inst{22} = Vd{4};
2600 let Inst{15-12} = Vd{3-0};
2601 let Inst{5} = Vm{4};
2602 let Inst{3-0} = Vm{3-0};
2605 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2606 // for single-precision FP.
2607 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2608 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2611 // VFP/NEON Instruction aliases for type suffices.
2612 // Note: When EmitPriority == 1, the alias will be used for printing
2613 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2614 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
2616 // Note: When EmitPriority == 1, the alias will be used for printing
2617 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
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>;
2624 // Note: When EmitPriority == 1, the alias will be used for printing
2625 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2626 let Predicates = [HasNEON] in {
2627 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2628 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2629 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2630 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2634 // The same alias classes using AsmPseudo instead, for the more complex
2635 // stuff in NEON that InstAlias can't quite handle.
2636 // Note that we can't use anonymous defm references here like we can
2637 // above, as we care about the ultimate instruction enum names generated, unlike
2638 // for instalias defs.
2639 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2640 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2642 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2643 // encoding space, introduced in ARMv8.3-A.
2644 class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2645 dag oops, dag iops, InstrItinClass itin,
2646 string opc, string dt, string asm, string cstr, list<dag> pattern>
2647 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2648 dt, asm, cstr, pattern> {
2653 let DecoderNamespace = "VFPV8";
2654 // These have the same encodings in ARM and Thumb2
2655 let PostEncoderMethod = "";
2657 let Inst{31-25} = 0b1111110;
2658 let Inst{24-23} = op24_23;
2659 let Inst{22} = Vd{4};
2660 let Inst{21-20} = op21_20;
2661 let Inst{19-16} = Vn{3-0};
2662 let Inst{15-12} = Vd{3-0};
2663 let Inst{11-8} = 0b1000;
2664 let Inst{7} = Vn{4};
2666 let Inst{5} = Vm{4};
2668 let Inst{3-0} = Vm{3-0};
2671 // Extension of NEON 2-vector-and-scalar data processing instructions in
2672 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2673 class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2674 dag oops, dag iops, InstrItinClass itin,
2675 string opc, string dt, string asm, string cstr, list<dag> pattern>
2676 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2677 dt, asm, cstr, pattern> {
2682 let DecoderNamespace = "VFPV8";
2683 // These have the same encodings in ARM and Thumb2
2684 let PostEncoderMethod = "";
2686 let Inst{31-24} = 0b11111110;
2687 let Inst{23} = op23;
2688 let Inst{22} = Vd{4};
2689 let Inst{21-20} = op21_20;
2690 let Inst{19-16} = Vn{3-0};
2691 let Inst{15-12} = Vd{3-0};
2692 let Inst{11-8} = 0b1000;
2693 let Inst{7} = Vn{4};
2695 // Bit 5 set by sub-classes
2697 let Inst{3-0} = Vm{3-0};
2700 // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
2702 // if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
2703 // if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
2704 // Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
2705 class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2706 dag oops, dag iops, InstrItinClass itin,
2707 string opc, string dt, string asm, string cstr, list<dag> pattern>
2708 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
2713 let DecoderNamespace = "VFPV8";
2714 // These have the same encodings in ARM and Thumb2
2715 let PostEncoderMethod = "";
2717 let Inst{31-25} = 0b1111110;
2718 let Inst{24-23} = op24_23;
2719 let Inst{22} = Vd{4};
2720 let Inst{21-20} = op21_20;
2721 let Inst{19-16} = Vn{4-1};
2722 let Inst{15-12} = Vd{3-0};
2723 let Inst{11-8} = 0b1000;
2724 let Inst{7} = Vn{0};
2726 let Inst{5} = Vm{0};
2728 let Inst{3-0} = Vm{4-1};
2731 // Operand types for complex instructions
2732 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2734 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2735 let DiagnosticString = "complex rotation must be " # Diag;
2736 let Name = "ComplexRotation" # Type;
2738 def complexrotateop : Operand<i32> {
2739 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2740 let PrintMethod = "printComplexRotationOp<90, 0>";
2742 def complexrotateopodd : Operand<i32> {
2743 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2744 let PrintMethod = "printComplexRotationOp<180, 90>";
2747 def MveSaturateOperand : AsmOperandClass {
2748 let PredicateMethod = "isMveSaturateOp";
2749 let DiagnosticString = "saturate operand must be 48 or 64";
2750 let Name = "MveSaturate";
2752 def saturateop : Operand<i32> {
2753 let ParserMatchClass = MveSaturateOperand;
2754 let PrintMethod = "printMveSaturateOp";
2757 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2758 def : TokenAlias<".s8", ".i8">;
2759 def : TokenAlias<".u8", ".i8">;
2760 def : TokenAlias<".s16", ".i16">;
2761 def : TokenAlias<".u16", ".i16">;
2762 def : TokenAlias<".s32", ".i32">;
2763 def : TokenAlias<".u32", ".i32">;
2764 def : TokenAlias<".s64", ".i64">;
2765 def : TokenAlias<".u64", ".i64">;
2767 def : TokenAlias<".i8", ".8">;
2768 def : TokenAlias<".i16", ".16">;
2769 def : TokenAlias<".i32", ".32">;
2770 def : TokenAlias<".i64", ".64">;
2772 def : TokenAlias<".p8", ".8">;
2773 def : TokenAlias<".p16", ".16">;
2775 def : TokenAlias<".f32", ".32">;
2776 def : TokenAlias<".f64", ".64">;
2777 def : TokenAlias<".f", ".f32">;
2778 def : TokenAlias<".d", ".f64">;