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_i8pos : AddrMode<13>;
107 def AddrModeT2_i8neg : AddrMode<14>;
108 def AddrModeT2_so : AddrMode<15>;
109 def AddrModeT2_pc : AddrMode<16>;
110 def AddrModeT2_i8s4 : AddrMode<17>;
111 def AddrMode_i12 : AddrMode<18>;
112 def AddrMode5FP16 : AddrMode<19>;
113 def AddrModeT2_ldrex : AddrMode<20>;
114 def AddrModeT2_i7s4 : AddrMode<21>;
115 def AddrModeT2_i7s2 : AddrMode<22>;
116 def AddrModeT2_i7 : AddrMode<23>;
118 // Load / store index mode.
119 class IndexMode<bits<2> val> {
122 def IndexModeNone : IndexMode<0>;
123 def IndexModePre : IndexMode<1>;
124 def IndexModePost : IndexMode<2>;
125 def IndexModeUpd : IndexMode<3>;
127 // Instruction execution domain.
128 class Domain<bits<4> val> {
131 def GenericDomain : Domain<0>;
132 def VFPDomain : Domain<1>; // Instructions in VFP domain only
133 def NeonDomain : Domain<2>; // Instructions in Neon domain only
134 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
135 def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
136 def MVEDomain : Domain<8>; // Instructions in MVE and ARMv8.1m
138 //===----------------------------------------------------------------------===//
139 // ARM special operands.
142 // ARM imod and iflag operands, used only by the CPS instruction.
143 def imod_op : Operand<i32> {
144 let PrintMethod = "printCPSIMod";
147 def ProcIFlagsOperand : AsmOperandClass {
148 let Name = "ProcIFlags";
149 let ParserMethod = "parseProcIFlagsOperand";
151 def iflags_op : Operand<i32> {
152 let PrintMethod = "printCPSIFlag";
153 let ParserMatchClass = ProcIFlagsOperand;
156 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
157 // register whose default is 0 (no register).
158 def CondCodeOperand : AsmOperandClass {
159 let Name = "CondCode";
160 let DefaultMethod = "defaultCondCodeOp";
161 let IsOptional = true;
163 def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
164 (ops (i32 14), (i32 zero_reg))> {
165 let PrintMethod = "printPredicateOperand";
166 let ParserMatchClass = CondCodeOperand;
167 let DecoderMethod = "DecodePredicateOperand";
170 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
171 def CCOutOperand : AsmOperandClass {
173 let DefaultMethod = "defaultCCOutOp";
174 let IsOptional = true;
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";
203 let DefaultMethod = "defaultVPTPredOp";
204 let IsOptional = true;
206 def VPTPredROperand : AsmOperandClass {
207 let Name = "VPTPredR";
208 let PredicateMethod = "isVPTPred";
209 let DefaultMethod = "defaultVPTPredOp";
210 let IsOptional = true;
213 // Operand classes for the cluster of MC operands describing a
214 // VPT-predicated MVE instruction.
216 // There are two of these classes. Both of them have the same first
219 // $cond (an integer) indicates the instruction's predication status:
220 // * ARMVCC::None means it's unpredicated
221 // * ARMVCC::Then means it's in a VPT block and appears with the T suffix
222 // * ARMVCC::Else means it's in a VPT block and appears with the E suffix.
223 // During code generation, unpredicated and predicated instructions
224 // are indicated by setting this parameter to 'None' or to 'Then'; the
225 // third value 'Else' is only used for assembly and disassembly.
227 // $cond_reg (type VCCR) gives the input predicate register. This is
228 // always either zero_reg or VPR, but needs to be modelled as an
229 // explicit operand so that it can be register-allocated and spilled
230 // when these operands are used in code generation).
232 // For 'vpred_r', there's an extra operand $inactive, which specifies
233 // the vector register which will supply any lanes of the output
234 // register that the predication mask prevents from being written by
235 // this instruction. It's always tied to the actual output register
236 // (i.e. must be allocated into the same physical reg), but again,
237 // code generation will need to model it as a separate input value.
239 // 'vpred_n' doesn't have that extra operand: it only has $cond and
240 // $cond_reg. This variant is used for any instruction that can't, or
241 // doesn't want to, tie $inactive to the output register. Sometimes
242 // that's because another input parameter is already tied to it (e.g.
243 // instructions that both read and write their Qd register even when
244 // unpredicated, either because they only partially overwrite it like
245 // a narrowing integer conversion, or simply because the instruction
246 // encoding doesn't have enough register fields to make the output
247 // independent of all inputs). It can also be because the instruction
248 // is defined to set disabled output lanes to zero rather than leaving
249 // them unchanged (vector loads), or because it doesn't output a
250 // vector register at all (stores, compares). In any of these
251 // situations it's unnecessary to have an extra operand tied to the
252 // output, and inconvenient to leave it there unused.
254 // Base class for both kinds of vpred.
255 class vpred_ops<dag extra_op, dag extra_mi> : OperandWithDefaultOps<OtherVT,
256 !con((ops (i32 0), (i32 zero_reg), (i32 zero_reg)), extra_op)> {
257 let PrintMethod = "printVPTPredicateOperand";
258 let OperandNamespace = "ARM";
259 let MIOperandInfo = !con((ops i32imm:$cond, VCCR:$cond_reg, GPRlr:$tp_reg), extra_mi);
261 // For convenience, we provide a string value that can be appended
262 // to the constraints string. It's empty for vpred_n, and for
263 // vpred_r it ties the $inactive operand to the output q-register
264 // (which by convention will be called $Qd).
265 string vpred_constraint;
268 def vpred_r : vpred_ops<(ops (v4i32 undef_tied_input)), (ops MQPR:$inactive)> {
269 let ParserMatchClass = VPTPredROperand;
270 let OperandType = "OPERAND_VPRED_R";
271 let DecoderMethod = "DecodeVpredROperand";
272 let vpred_constraint = ",$Qd = $vp.inactive";
275 def vpred_n : vpred_ops<(ops), (ops)> {
276 let ParserMatchClass = VPTPredNOperand;
277 let OperandType = "OPERAND_VPRED_N";
278 let DecoderMethod = "DecodeVpredNOperand";
279 let vpred_constraint = "";
282 // ARM special operands for disassembly only.
284 def SetEndAsmOperand : ImmAsmOperand<0,1> {
285 let Name = "SetEndImm";
286 let ParserMethod = "parseSetEndImm";
288 def setend_op : Operand<i32> {
289 let PrintMethod = "printSetendOperand";
290 let ParserMatchClass = SetEndAsmOperand;
293 def MSRMaskOperand : AsmOperandClass {
294 let Name = "MSRMask";
295 let ParserMethod = "parseMSRMaskOperand";
297 def msr_mask : Operand<i32> {
298 let PrintMethod = "printMSRMaskOperand";
299 let DecoderMethod = "DecodeMSRMask";
300 let ParserMatchClass = MSRMaskOperand;
303 def BankedRegOperand : AsmOperandClass {
304 let Name = "BankedReg";
305 let ParserMethod = "parseBankedRegOperand";
307 def banked_reg : Operand<i32> {
308 let PrintMethod = "printBankedRegOperand";
309 let DecoderMethod = "DecodeBankedReg";
310 let ParserMatchClass = BankedRegOperand;
313 // Shift Right Immediate - A shift right immediate is encoded differently from
314 // other shift immediates. The imm6 field is encoded like so:
317 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
318 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
319 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
320 // 64 64 - <imm> is encoded in imm6<5:0>
321 def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
322 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
323 let EncoderMethod = "getShiftRight8Imm";
324 let DecoderMethod = "DecodeShiftRight8Imm";
325 let ParserMatchClass = shr_imm8_asm_operand;
327 def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
328 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
329 let EncoderMethod = "getShiftRight16Imm";
330 let DecoderMethod = "DecodeShiftRight16Imm";
331 let ParserMatchClass = shr_imm16_asm_operand;
333 def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
334 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
335 let EncoderMethod = "getShiftRight32Imm";
336 let DecoderMethod = "DecodeShiftRight32Imm";
337 let ParserMatchClass = shr_imm32_asm_operand;
339 def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
340 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
341 let EncoderMethod = "getShiftRight64Imm";
342 let DecoderMethod = "DecodeShiftRight64Imm";
343 let ParserMatchClass = shr_imm64_asm_operand;
347 // ARM Assembler operand for ldr Rd, =expression which generates an offset
348 // to a constant pool entry or a MOV depending on the value of expression
349 def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
350 def const_pool_asm_imm : Operand<i32> {
351 let ParserMatchClass = const_pool_asm_operand;
355 //===----------------------------------------------------------------------===//
356 // ARM Assembler alias templates.
358 // Note: When EmitPriority == 1, the alias will be used for printing
359 class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
360 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
361 class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
362 : InstAlias<Asm, Result, EmitPriority>,
363 Requires<[IsARM,UseNegativeImmediates]>;
364 class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
365 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
366 class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
367 : InstAlias<Asm, Result, EmitPriority>,
368 Requires<[IsThumb,UseNegativeImmediates]>;
369 class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
370 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
371 class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
372 : InstAlias<Asm, Result, EmitPriority>,
373 Requires<[IsThumb2,UseNegativeImmediates]>;
374 class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
375 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
376 class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
377 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
378 class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
379 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
380 class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
381 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
382 class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
383 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
386 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
388 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
391 //===----------------------------------------------------------------------===//
392 // ARM Instruction templates.
396 class InstTemplate<AddrMode am, int sz, IndexMode im,
397 Format f, Domain d, string cstr, InstrItinClass itin>
399 let Namespace = "ARM";
404 bits<2> IndexModeBits = IM.Value;
406 bits<6> Form = F.Value;
408 bit isUnaryDataProc = 0;
409 bit canXformTo16Bit = 0;
410 // The instruction is a 16-bit flag setting Thumb instruction. Used
411 // by the parser and if-converter to determine whether to require the 'S'
412 // suffix on the mnemonic (when not in an IT block) or preclude it (when
414 bit thumbArithFlagSetting = 0;
417 bit validForTailPredication = 0;
418 bit retainsPreviousHalfElement = 0;
419 bit horizontalReduction = 0;
420 bit doubleWidthResult = 0;
422 // If this is a pseudo instruction, mark it isCodeGenOnly.
423 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
425 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
426 let TSFlags{4-0} = AM.Value;
427 let TSFlags{6-5} = IndexModeBits;
428 let TSFlags{12-7} = Form;
429 let TSFlags{13} = isUnaryDataProc;
430 let TSFlags{14} = canXformTo16Bit;
431 let TSFlags{18-15} = D.Value;
432 let TSFlags{19} = thumbArithFlagSetting;
433 let TSFlags{20} = validForTailPredication;
434 let TSFlags{21} = retainsPreviousHalfElement;
435 let TSFlags{22} = horizontalReduction;
436 let TSFlags{23} = doubleWidthResult;
437 let TSFlags{25-24} = VecSize;
439 let Constraints = cstr;
440 let Itinerary = itin;
445 // Mask of bits that cause an encoding to be UNPREDICTABLE.
446 // If a bit is set, then if the corresponding bit in the
447 // target encoding differs from its value in the "Inst" field,
448 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
449 field bits<32> Unpredictable = 0;
450 // SoftFail is the generic name for this field, but we alias it so
451 // as to make it more obvious what it means in ARM-land.
452 field bits<32> SoftFail = Unpredictable;
455 class InstARM<AddrMode am, int sz, IndexMode im,
456 Format f, Domain d, string cstr, InstrItinClass itin>
457 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
458 let DecoderNamespace = "ARM";
461 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
462 // on by adding flavors to specific instructions.
463 class InstThumb<AddrMode am, int sz, IndexMode im,
464 Format f, Domain d, string cstr, InstrItinClass itin>
465 : InstTemplate<am, sz, im, f, d, cstr, itin> {
466 let DecoderNamespace = "Thumb";
469 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
470 // These are aliases that require C++ handling to convert to the target
471 // instruction, while InstAliases can be handled directly by tblgen.
472 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
473 : InstTemplate<AddrModeNone, 4, IndexModeNone, Pseudo, GenericDomain,
475 let OutOperandList = oops;
476 let InOperandList = iops;
478 let isCodeGenOnly = 0; // So we get asm matcher for it.
481 let hasNoSchedulingInfo = 1;
484 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
485 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
486 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
487 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
488 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
489 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
490 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
491 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
492 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
493 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
494 class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
495 : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
497 // Pseudo instructions for the code generator.
498 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
499 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
500 GenericDomain, "", itin> {
501 let OutOperandList = oops;
502 let InOperandList = iops;
503 let Pattern = pattern;
504 let isCodeGenOnly = 1;
508 // PseudoInst that's ARM-mode only.
509 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
511 : PseudoInst<oops, iops, itin, pattern> {
513 list<Predicate> Predicates = [IsARM];
516 // PseudoInst that's Thumb-mode only.
517 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
519 : PseudoInst<oops, iops, itin, pattern> {
521 list<Predicate> Predicates = [IsThumb];
524 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
525 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
527 : PseudoInst<oops, iops, itin, pattern> {
529 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
532 // PseudoInst that's Thumb2-mode only.
533 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
535 : PseudoInst<oops, iops, itin, pattern> {
537 list<Predicate> Predicates = [IsThumb2];
540 class ARMPseudoExpand<dag oops, dag iops, int sz,
541 InstrItinClass itin, list<dag> pattern,
543 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
544 PseudoInstExpansion<Result>;
546 class tPseudoExpand<dag oops, dag iops, int sz,
547 InstrItinClass itin, list<dag> pattern,
549 : tPseudoInst<oops, iops, sz, itin, pattern>,
550 PseudoInstExpansion<Result>;
552 class t2PseudoExpand<dag oops, dag iops, int sz,
553 InstrItinClass itin, list<dag> pattern,
555 : t2PseudoInst<oops, iops, sz, itin, pattern>,
556 PseudoInstExpansion<Result>;
558 // Almost all ARM instructions are predicable.
559 class I<dag oops, dag iops, AddrMode am, int sz,
560 IndexMode im, Format f, InstrItinClass itin,
561 string opc, string asm, string cstr,
563 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
566 let OutOperandList = oops;
567 let InOperandList = !con(iops, (ins pred:$p));
568 let AsmString = !strconcat(opc, "${p}", asm);
569 let Pattern = pattern;
570 list<Predicate> Predicates = [IsARM];
573 // A few are not predicable
574 class InoP<dag oops, dag iops, AddrMode am, int sz,
575 IndexMode im, Format f, InstrItinClass itin,
576 string opc, string asm, string cstr,
578 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
579 let OutOperandList = oops;
580 let InOperandList = iops;
581 let AsmString = !strconcat(opc, asm);
582 let Pattern = pattern;
583 let isPredicable = 0;
584 list<Predicate> Predicates = [IsARM];
587 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
588 // operand since by default it's a zero register. It will become an implicit def
589 // once it's "flipped".
590 class sI<dag oops, dag iops, AddrMode am, int sz,
591 IndexMode im, Format f, InstrItinClass itin,
592 string opc, string asm, string cstr,
594 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
595 bits<4> p; // Predicate operand
596 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
600 let OutOperandList = oops;
601 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
602 let AsmString = !strconcat(opc, "${s}${p}", asm);
603 let Pattern = pattern;
604 list<Predicate> Predicates = [IsARM];
608 class XI<dag oops, dag iops, AddrMode am, int sz,
609 IndexMode im, Format f, InstrItinClass itin,
610 string asm, string cstr, list<dag> pattern>
611 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
612 let OutOperandList = oops;
613 let InOperandList = iops;
615 let Pattern = pattern;
616 list<Predicate> Predicates = [IsARM];
619 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
620 string opc, string asm, list<dag> pattern>
621 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
622 opc, asm, "", pattern>;
623 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
624 string opc, string asm, list<dag> pattern>
625 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
626 opc, asm, "", pattern>;
627 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
628 string asm, list<dag> pattern>
629 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
631 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
632 string asm, list<dag> pattern>
633 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
635 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
636 string opc, string asm, list<dag> pattern>
637 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
638 opc, asm, "", pattern>;
640 // Ctrl flow instructions
641 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
642 string opc, string asm, list<dag> pattern>
643 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
644 opc, asm, "", pattern> {
645 let Inst{27-24} = opcod;
647 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
648 string asm, list<dag> pattern>
649 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
651 let Inst{27-24} = opcod;
654 // BR_JT instructions
655 class JTI<dag oops, dag iops, InstrItinClass itin,
656 string asm, list<dag> pattern>
657 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
660 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
661 string opc, string asm, list<dag> pattern>
662 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
663 opc, asm, "", pattern> {
666 let Inst{27-23} = 0b00011;
667 let Inst{22-21} = opcod;
669 let Inst{19-16} = addr;
670 let Inst{15-12} = Rt;
671 let Inst{11-10} = 0b11;
672 let Inst{9-8} = opcod2;
673 let Inst{7-0} = 0b10011111;
675 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
676 string opc, string asm, list<dag> pattern>
677 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
678 opc, asm, "", pattern> {
681 let Inst{27-23} = 0b00011;
682 let Inst{22-21} = opcod;
684 let Inst{19-16} = addr;
685 let Inst{11-10} = 0b11;
686 let Inst{9-8} = opcod2;
687 let Inst{7-4} = 0b1001;
690 // Atomic load/store instructions
691 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
692 string opc, string asm, list<dag> pattern>
693 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
695 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
696 string opc, string asm, list<dag> pattern>
697 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
699 let Inst{15-12} = Rd;
702 // Exclusive load/store instructions
704 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
705 string opc, string asm, list<dag> pattern>
706 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
707 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
709 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
710 string opc, string asm, list<dag> pattern>
711 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
712 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
714 let Inst{15-12} = Rd;
717 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
718 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
722 let Inst{27-23} = 0b00010;
724 let Inst{21-20} = 0b00;
725 let Inst{19-16} = addr;
726 let Inst{15-12} = Rt;
727 let Inst{11-4} = 0b00001001;
730 let Unpredictable{11-8} = 0b1111;
731 let DecoderMethod = "DecodeSwap";
733 // Acquire/Release load/store instructions
734 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
735 string opc, string asm, list<dag> pattern>
736 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
737 Requires<[IsARM, HasAcquireRelease]>;
739 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
740 string opc, string asm, list<dag> pattern>
741 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
742 Requires<[IsARM, HasAcquireRelease]> {
743 let Inst{15-12} = 0b1111;
746 // addrmode1 instructions
747 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
748 string opc, string asm, list<dag> pattern>
749 : I<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 AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
755 string opc, string asm, list<dag> pattern>
756 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
757 opc, asm, "", pattern> {
758 let Inst{24-21} = opcod;
759 let Inst{27-26} = 0b00;
761 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
762 string asm, list<dag> pattern>
763 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
765 let Inst{24-21} = opcod;
766 let Inst{27-26} = 0b00;
771 // LDR/LDRB/STR/STRB/...
772 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
773 Format f, InstrItinClass itin, string opc, string asm,
775 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
777 let Inst{27-25} = op;
778 let Inst{24} = 1; // 24 == P
780 let Inst{22} = isByte;
781 let Inst{21} = 0; // 21 == W
784 // Indexed load/stores
785 class AI2ldstidx<bit isLd, 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 : I<oops, iops, AddrMode2, 4, im, f, itin,
789 opc, asm, cstr, pattern> {
791 let Inst{27-26} = 0b01;
792 let Inst{24} = isPre; // P bit
793 let Inst{22} = isByte; // B bit
794 let Inst{21} = isPre; // W bit
795 let Inst{20} = isLd; // L bit
796 let Inst{15-12} = Rt;
798 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
799 IndexMode im, Format f, InstrItinClass itin, string opc,
800 string asm, string cstr, list<dag> pattern>
801 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
803 // AM2 store w/ two operands: (GPR, am2offset)
809 let Inst{23} = offset{12};
810 let Inst{19-16} = Rn;
811 let Inst{11-5} = offset{11-5};
813 let Inst{3-0} = offset{3-0};
816 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
817 IndexMode im, Format f, InstrItinClass itin, string opc,
818 string asm, string cstr, list<dag> pattern>
819 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
821 // AM2 store w/ two operands: (GPR, am2offset)
827 let Inst{23} = offset{12};
828 let Inst{19-16} = Rn;
829 let Inst{11-0} = offset{11-0};
833 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
834 // but for now use this class for STRT and STRBT.
835 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
836 IndexMode im, Format f, InstrItinClass itin, string opc,
837 string asm, string cstr, list<dag> pattern>
838 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
840 // AM2 store w/ two operands: (GPR, am2offset)
842 // {13} 1 == Rm, 0 == imm12
846 let Inst{25} = addr{13};
847 let Inst{23} = addr{12};
848 let Inst{19-16} = addr{17-14};
849 let Inst{11-0} = addr{11-0};
852 // addrmode3 instructions
853 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
854 InstrItinClass itin, string opc, string asm, list<dag> pattern>
855 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
856 opc, asm, "", pattern> {
859 let Inst{27-25} = 0b000;
860 let Inst{24} = 1; // P bit
861 let Inst{23} = addr{8}; // U bit
862 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
863 let Inst{21} = 0; // W bit
864 let Inst{20} = op20; // L bit
865 let Inst{19-16} = addr{12-9}; // Rn
866 let Inst{15-12} = Rt; // Rt
867 let Inst{11-8} = addr{7-4}; // imm7_4/zero
869 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
871 let DecoderMethod = "DecodeAddrMode3Instruction";
874 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
875 IndexMode im, Format f, InstrItinClass itin, string opc,
876 string asm, string cstr, list<dag> pattern>
877 : I<oops, iops, AddrMode3, 4, im, f, itin,
878 opc, asm, cstr, pattern> {
880 let Inst{27-25} = 0b000;
881 let Inst{24} = isPre; // P bit
882 let Inst{21} = isPre; // W bit
883 let Inst{20} = op20; // L bit
884 let Inst{15-12} = Rt; // Rt
888 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
889 // but for now use this class for LDRSBT, LDRHT, LDSHT.
890 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
891 IndexMode im, Format f, InstrItinClass itin, string opc,
892 string asm, string cstr, list<dag> pattern>
893 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
894 // {13} 1 == imm8, 0 == Rm
901 let Inst{27-25} = 0b000;
902 let Inst{24} = 0; // P bit
904 let Inst{20} = isLoad; // L bit
905 let Inst{19-16} = addr; // Rn
906 let Inst{15-12} = Rt; // Rt
911 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
912 string opc, string asm, list<dag> pattern>
913 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
914 opc, asm, "", pattern> {
917 let Inst{27-25} = 0b000;
918 let Inst{24} = 1; // P bit
919 let Inst{23} = addr{8}; // U bit
920 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
921 let Inst{21} = 0; // W bit
922 let Inst{20} = 0; // L bit
923 let Inst{19-16} = addr{12-9}; // Rn
924 let Inst{15-12} = Rt; // Rt
925 let Inst{11-8} = addr{7-4}; // imm7_4/zero
927 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
928 let DecoderMethod = "DecodeAddrMode3Instruction";
931 // addrmode4 instructions
932 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
933 string asm, string cstr, list<dag> pattern>
934 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
939 let Inst{27-25} = 0b100;
940 let Inst{22} = 0; // S bit
941 let Inst{19-16} = Rn;
942 let Inst{15-0} = regs;
945 // Unsigned multiply, multiply-accumulate instructions.
946 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
947 string opc, string asm, list<dag> pattern>
948 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
949 opc, asm, "", pattern> {
950 let Inst{7-4} = 0b1001;
951 let Inst{20} = 0; // S bit
952 let Inst{27-21} = opcod;
954 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
955 string opc, string asm, list<dag> pattern>
956 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
957 opc, asm, "", pattern> {
958 let Inst{7-4} = 0b1001;
959 let Inst{27-21} = opcod;
962 // Most significant word multiply
963 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
964 InstrItinClass itin, string opc, string asm, list<dag> pattern>
965 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
966 opc, asm, "", pattern> {
970 let Inst{7-4} = opc7_4;
972 let Inst{27-21} = opcod;
973 let Inst{19-16} = Rd;
977 // MSW multiple w/ Ra operand
978 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
979 InstrItinClass itin, string opc, string asm, list<dag> pattern>
980 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
982 let Inst{15-12} = Ra;
985 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
986 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
987 InstrItinClass itin, string opc, string asm, list<dag> pattern>
988 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
989 opc, asm, "", pattern> {
995 let Inst{27-21} = opcod;
996 let Inst{6-5} = bit6_5;
1000 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1001 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1002 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1004 let Inst{19-16} = Rd;
1007 // AMulxyI with Ra operand
1008 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1009 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1010 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1012 let Inst{15-12} = Ra;
1015 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1016 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1017 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1020 let Inst{19-16} = RdHi;
1021 let Inst{15-12} = RdLo;
1024 // Extend instructions.
1025 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1026 string opc, string asm, list<dag> pattern>
1027 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
1028 opc, asm, "", pattern> {
1029 // All AExtI instructions have Rd and Rm register operands.
1032 let Inst{15-12} = Rd;
1034 let Inst{7-4} = 0b0111;
1035 let Inst{9-8} = 0b00;
1036 let Inst{27-20} = opcod;
1038 let Unpredictable{9-8} = 0b11;
1041 // Misc Arithmetic instructions.
1042 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1043 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1044 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1045 opc, asm, "", pattern> {
1048 let Inst{27-20} = opcod;
1049 let Inst{19-16} = 0b1111;
1050 let Inst{15-12} = Rd;
1051 let Inst{11-8} = 0b1111;
1052 let Inst{7-4} = opc7_4;
1056 // Division instructions.
1057 class ADivA1I<bits<3> opcod, dag oops, dag iops,
1058 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1059 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1060 opc, asm, "", pattern> {
1064 let Inst{27-23} = 0b01110;
1065 let Inst{22-20} = opcod;
1066 let Inst{19-16} = Rd;
1067 let Inst{15-12} = 0b1111;
1068 let Inst{11-8} = Rm;
1069 let Inst{7-4} = 0b0001;
1074 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
1075 let Name = "PKHLSLImm";
1076 let ParserMethod = "parsePKHLSLImm";
1078 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1079 let PrintMethod = "printPKHLSLShiftImm";
1080 let ParserMatchClass = PKHLSLAsmOperand;
1082 def PKHASRAsmOperand : AsmOperandClass {
1083 let Name = "PKHASRImm";
1084 let ParserMethod = "parsePKHASRImm";
1086 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1087 let PrintMethod = "printPKHASRShiftImm";
1088 let ParserMatchClass = PKHASRAsmOperand;
1091 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1092 string opc, string asm, list<dag> pattern>
1093 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1094 opc, asm, "", pattern> {
1099 let Inst{27-20} = opcod;
1100 let Inst{19-16} = Rn;
1101 let Inst{15-12} = Rd;
1102 let Inst{11-7} = sh;
1104 let Inst{5-4} = 0b01;
1108 //===----------------------------------------------------------------------===//
1110 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1111 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1112 list<Predicate> Predicates = [IsARM];
1114 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1115 list<Predicate> Predicates = [IsARM, HasV5T];
1117 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1118 list<Predicate> Predicates = [IsARM, HasV5TE];
1120 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1121 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1122 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1124 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1125 list<Predicate> Predicates = [IsARM, HasV6];
1127 class ARMV6T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1128 list<Predicate> Predicates = [IsARM, HasV6T2];
1130 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1131 list<Predicate> Predicates = [HasVFP2];
1133 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1134 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1136 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1137 list<Predicate> Predicates = [IsThumb2, HasDSP];
1139 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1140 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1142 class FPRegs16Pat<dag pattern, dag result> : Pat<pattern, result> {
1143 list<Predicate> Predicates = [HasFPRegs16];
1145 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1146 list<Predicate> Predicates = [HasFP16];
1148 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1149 list<Predicate> Predicates = [HasFullFP16];
1151 //===----------------------------------------------------------------------===//
1152 // Thumb Instruction Format Definitions.
1155 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1156 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1157 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1158 let OutOperandList = oops;
1159 let InOperandList = iops;
1160 let AsmString = asm;
1161 let Pattern = pattern;
1162 list<Predicate> Predicates = [IsThumb];
1165 // TI - Thumb instruction.
1166 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1167 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1169 // Two-address instructions
1170 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1172 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1175 // tBL, tBX 32-bit instructions
1176 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1177 dag oops, dag iops, InstrItinClass itin, string asm,
1179 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1181 let Inst{31-27} = opcod1;
1182 let Inst{15-14} = opcod2;
1183 let Inst{12} = opcod3;
1186 // BR_JT instructions
1187 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1189 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1192 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1193 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1194 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1195 let OutOperandList = oops;
1196 let InOperandList = iops;
1197 let AsmString = asm;
1198 let Pattern = pattern;
1199 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1202 class T1I<dag oops, dag iops, InstrItinClass itin,
1203 string asm, list<dag> pattern>
1204 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1205 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1206 string asm, list<dag> pattern>
1207 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1209 // Two-address instructions
1210 class T1It<dag oops, dag iops, InstrItinClass itin,
1211 string asm, string cstr, list<dag> pattern>
1212 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1213 asm, cstr, pattern>;
1215 // Thumb1 instruction that can either be predicated or set CPSR.
1216 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1217 InstrItinClass itin,
1218 string opc, string asm, string cstr, list<dag> pattern>
1219 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1220 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1221 let InOperandList = !con(iops, (ins pred:$p));
1222 let AsmString = !strconcat(opc, "${s}${p}", asm);
1223 let Pattern = pattern;
1224 let thumbArithFlagSetting = 1;
1225 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1226 let DecoderNamespace = "ThumbSBit";
1229 class T1sI<dag oops, dag iops, InstrItinClass itin,
1230 string opc, string asm, list<dag> pattern>
1231 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1233 // Two-address instructions
1234 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1235 string opc, string asm, list<dag> pattern>
1236 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1237 "$Rn = $Rdn", pattern>;
1239 // Thumb1 instruction that can be predicated.
1240 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1241 InstrItinClass itin,
1242 string opc, string asm, string cstr, list<dag> pattern>
1243 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1244 let OutOperandList = oops;
1245 let InOperandList = !con(iops, (ins pred:$p));
1246 let AsmString = !strconcat(opc, "${p}", asm);
1247 let Pattern = pattern;
1248 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1251 class T1pI<dag oops, dag iops, InstrItinClass itin,
1252 string opc, string asm, list<dag> pattern>
1253 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1255 // Two-address instructions
1256 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1257 string opc, string asm, list<dag> pattern>
1258 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1259 "$Rn = $Rdn", pattern>;
1261 class T1pIs<dag oops, dag iops,
1262 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1263 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1265 class Encoding16 : Encoding {
1266 let Inst{31-16} = 0x0000;
1269 // A6.2 16-bit Thumb instruction encoding
1270 class T1Encoding<bits<6> opcode> : Encoding16 {
1271 let Inst{15-10} = opcode;
1274 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1275 class T1General<bits<5> opcode> : Encoding16 {
1276 let Inst{15-14} = 0b00;
1277 let Inst{13-9} = opcode;
1280 // A6.2.2 Data-processing encoding.
1281 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1282 let Inst{15-10} = 0b010000;
1283 let Inst{9-6} = opcode;
1286 // A6.2.3 Special data instructions and branch and exchange encoding.
1287 class T1Special<bits<4> opcode> : Encoding16 {
1288 let Inst{15-10} = 0b010001;
1289 let Inst{9-6} = opcode;
1292 // A6.2.4 Load/store single data item encoding.
1293 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1294 let Inst{15-12} = opA;
1295 let Inst{11-9} = opB;
1297 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1299 class T1BranchCond<bits<4> opcode> : Encoding16 {
1300 let Inst{15-12} = opcode;
1303 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1304 // following bits are used for "opA" (see A6.2.4):
1306 // 0b0110 => Immediate, 4 bytes
1307 // 0b1000 => Immediate, 2 bytes
1308 // 0b0111 => Immediate, 1 byte
1309 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1310 InstrItinClass itin, string opc, string asm,
1312 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1313 T1LoadStore<0b0101, opcode> {
1316 let Inst{8-6} = addr{5-3}; // Rm
1317 let Inst{5-3} = addr{2-0}; // Rn
1320 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1321 InstrItinClass itin, string opc, string asm,
1323 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1324 T1LoadStore<opA, {opB,?,?}> {
1327 let Inst{10-6} = addr{7-3}; // imm5
1328 let Inst{5-3} = addr{2-0}; // Rn
1332 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1333 class T1Misc<bits<7> opcode> : Encoding16 {
1334 let Inst{15-12} = 0b1011;
1335 let Inst{11-5} = opcode;
1338 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1339 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1340 InstrItinClass itin,
1341 string opc, string asm, string cstr, list<dag> pattern>
1342 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1343 let OutOperandList = oops;
1344 let InOperandList = !con(iops, (ins pred:$p));
1345 let AsmString = !strconcat(opc, "${p}", asm);
1346 let Pattern = pattern;
1347 list<Predicate> Predicates = [IsThumb2];
1348 let DecoderNamespace = "Thumb2";
1351 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1352 // input operand since by default it's a zero register. It will become an
1353 // implicit def once it's "flipped".
1355 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1357 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1358 InstrItinClass itin,
1359 string opc, string asm, string cstr, list<dag> pattern>
1360 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1361 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1364 let OutOperandList = oops;
1365 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1366 let AsmString = !strconcat(opc, "${s}${p}", asm);
1367 let Pattern = pattern;
1368 list<Predicate> Predicates = [IsThumb2];
1369 let DecoderNamespace = "Thumb2";
1373 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1374 InstrItinClass itin,
1375 string asm, string cstr, list<dag> pattern>
1376 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1377 let OutOperandList = oops;
1378 let InOperandList = iops;
1379 let AsmString = asm;
1380 let Pattern = pattern;
1381 list<Predicate> Predicates = [IsThumb2];
1382 let DecoderNamespace = "Thumb2";
1385 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1386 InstrItinClass itin,
1387 string asm, string cstr, list<dag> pattern>
1388 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1389 let OutOperandList = oops;
1390 let InOperandList = iops;
1391 let AsmString = asm;
1392 let Pattern = pattern;
1393 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1394 let DecoderNamespace = "Thumb";
1397 class T2I<dag oops, dag iops, InstrItinClass itin,
1398 string opc, string asm, list<dag> pattern, AddrMode am = AddrModeNone>
1399 : Thumb2I<oops, iops, am, 4, itin, opc, asm, "", pattern>;
1400 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1401 string opc, string asm, list<dag> pattern>
1402 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1403 class T2Ii8p<dag oops, dag iops, InstrItinClass itin,
1404 string opc, string asm, list<dag> pattern>
1405 : Thumb2I<oops, iops, AddrModeT2_i8pos, 4, itin, opc, asm, "", pattern>;
1406 class T2Ii8n<dag oops, dag iops, InstrItinClass itin,
1407 string opc, string asm, list<dag> pattern>
1408 : Thumb2I<oops, iops, AddrModeT2_i8neg, 4, itin, opc, asm, "", pattern>;
1409 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1410 string opc, string asm, list<dag> pattern>
1411 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1412 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1413 string opc, string asm, list<dag> pattern>
1414 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1415 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1416 string opc, string asm, string cstr, list<dag> pattern>
1417 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1422 let Inst{31-25} = 0b1110100;
1424 let Inst{23} = addr{8};
1427 let Inst{20} = isLoad;
1428 let Inst{19-16} = addr{12-9};
1429 let Inst{15-12} = Rt{3-0};
1430 let Inst{11-8} = Rt2{3-0};
1431 let Inst{7-0} = addr{7-0};
1433 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1434 InstrItinClass itin, string opc, string asm, string cstr,
1436 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1442 let Inst{31-25} = 0b1110100;
1444 let Inst{23} = imm{8};
1447 let Inst{20} = isLoad;
1448 let Inst{19-16} = addr;
1449 let Inst{15-12} = Rt{3-0};
1450 let Inst{11-8} = Rt2{3-0};
1451 let Inst{7-0} = imm{7-0};
1454 class T2sI<dag oops, dag iops, InstrItinClass itin,
1455 string opc, string asm, list<dag> pattern>
1456 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1458 class T2XI<dag oops, dag iops, InstrItinClass itin,
1459 string asm, list<dag> pattern>
1460 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1461 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1462 string asm, list<dag> pattern>
1463 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1465 // Move to/from coprocessor instructions
1466 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1468 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1469 let Inst{31-28} = opc;
1472 // Two-address instructions
1473 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1474 string asm, string cstr, list<dag> pattern>
1475 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1477 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1478 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1480 AddrMode am, IndexMode im, InstrItinClass itin,
1481 string opc, string asm, string cstr, list<dag> pattern>
1482 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1483 let OutOperandList = oops;
1484 let InOperandList = !con(iops, (ins pred:$p));
1485 let AsmString = !strconcat(opc, "${p}", asm);
1486 let Pattern = pattern;
1487 list<Predicate> Predicates = [IsThumb2];
1488 let DecoderNamespace = "Thumb2";
1492 let Inst{31-27} = 0b11111;
1493 let Inst{26-25} = 0b00;
1494 let Inst{24} = signed;
1496 let Inst{22-21} = opcod;
1497 let Inst{20} = load;
1498 let Inst{19-16} = addr{12-9};
1499 let Inst{15-12} = Rt{3-0};
1501 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1502 let Inst{10} = pre; // The P bit.
1503 let Inst{9} = addr{8}; // Sign bit
1504 let Inst{8} = 1; // The W bit.
1505 let Inst{7-0} = addr{7-0};
1507 let DecoderMethod = "DecodeT2LdStPre";
1510 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1511 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1513 AddrMode am, IndexMode im, InstrItinClass itin,
1514 string opc, string asm, string cstr, list<dag> pattern>
1515 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1516 let OutOperandList = oops;
1517 let InOperandList = !con(iops, (ins pred:$p));
1518 let AsmString = !strconcat(opc, "${p}", asm);
1519 let Pattern = pattern;
1520 list<Predicate> Predicates = [IsThumb2];
1521 let DecoderNamespace = "Thumb2";
1526 let Inst{31-27} = 0b11111;
1527 let Inst{26-25} = 0b00;
1528 let Inst{24} = signed;
1530 let Inst{22-21} = opcod;
1531 let Inst{20} = load;
1532 let Inst{19-16} = Rn;
1533 let Inst{15-12} = Rt{3-0};
1535 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1536 let Inst{10} = pre; // The P bit.
1537 let Inst{9} = offset{8}; // Sign bit
1538 let Inst{8} = 1; // The W bit.
1539 let Inst{7-0} = offset{7-0};
1541 let DecoderMethod = "DecodeT2LdStPre";
1544 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1545 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1546 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1549 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1550 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1551 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1554 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1555 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1556 list<Predicate> Predicates = [IsThumb2];
1559 //===----------------------------------------------------------------------===//
1561 //===----------------------------------------------------------------------===//
1562 // ARM VFP Instruction templates.
1565 // Almost all VFP instructions are predicable.
1566 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1567 IndexMode im, Format f, InstrItinClass itin,
1568 string opc, string asm, string cstr, list<dag> pattern>
1569 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1571 let Inst{31-28} = p;
1572 let OutOperandList = oops;
1573 let InOperandList = !con(iops, (ins pred:$p));
1574 let AsmString = !strconcat(opc, "${p}", asm);
1575 let Pattern = pattern;
1576 let PostEncoderMethod = "VFPThumb2PostEncoder";
1577 let DecoderNamespace = "VFP";
1578 list<Predicate> Predicates = [HasVFP2];
1582 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1583 IndexMode im, Format f, InstrItinClass itin,
1584 string asm, string cstr, list<dag> pattern>
1585 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1587 let Inst{31-28} = p;
1588 let OutOperandList = oops;
1589 let InOperandList = iops;
1590 let AsmString = asm;
1591 let Pattern = pattern;
1592 let PostEncoderMethod = "VFPThumb2PostEncoder";
1593 let DecoderNamespace = "VFP";
1594 list<Predicate> Predicates = [HasVFP2];
1597 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1598 string opc, string asm, string cstr, list<dag> pattern>
1599 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1600 opc, asm, cstr, pattern> {
1601 let PostEncoderMethod = "VFPThumb2PostEncoder";
1604 // ARM VFP addrmode5 loads and stores
1605 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1606 InstrItinClass itin,
1607 string opc, string asm, list<dag> pattern>
1608 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1609 VFPLdStFrm, itin, opc, asm, "", pattern> {
1610 // Instruction operands.
1614 // Encode instruction operands.
1615 let Inst{23} = addr{8}; // U (add = (U == '1'))
1616 let Inst{22} = Dd{4};
1617 let Inst{19-16} = addr{12-9}; // Rn
1618 let Inst{15-12} = Dd{3-0};
1619 let Inst{7-0} = addr{7-0}; // imm8
1621 let Inst{27-24} = opcod1;
1622 let Inst{21-20} = opcod2;
1623 let Inst{11-9} = 0b101;
1624 let Inst{8} = 1; // Double precision
1626 // Loads & stores operate on both NEON and VFP pipelines.
1627 let D = VFPNeonDomain;
1630 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1631 InstrItinClass itin,
1632 string opc, string asm, list<dag> pattern>
1633 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1634 VFPLdStFrm, itin, opc, asm, "", pattern> {
1635 // Instruction operands.
1639 // Encode instruction operands.
1640 let Inst{23} = addr{8}; // U (add = (U == '1'))
1641 let Inst{22} = Sd{0};
1642 let Inst{19-16} = addr{12-9}; // Rn
1643 let Inst{15-12} = Sd{4-1};
1644 let Inst{7-0} = addr{7-0}; // imm8
1646 let Inst{27-24} = opcod1;
1647 let Inst{21-20} = opcod2;
1648 let Inst{11-9} = 0b101;
1649 let Inst{8} = 0; // Single precision
1651 // Loads & stores operate on both NEON and VFP pipelines.
1652 let D = VFPNeonDomain;
1655 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1656 InstrItinClass itin,
1657 string opc, string asm, list<dag> pattern>
1658 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1659 VFPLdStFrm, itin, opc, asm, "", pattern> {
1660 list<Predicate> Predicates = [HasFullFP16];
1662 // Instruction operands.
1666 // Encode instruction operands.
1667 let Inst{23} = addr{8}; // U (add = (U == '1'))
1668 let Inst{22} = Sd{0};
1669 let Inst{19-16} = addr{12-9}; // Rn
1670 let Inst{15-12} = Sd{4-1};
1671 let Inst{7-0} = addr{7-0}; // imm8
1673 let Inst{27-24} = opcod1;
1674 let Inst{21-20} = opcod2;
1675 let Inst{11-8} = 0b1001; // Half precision
1677 // Loads & stores operate on both NEON and VFP pipelines.
1678 let D = VFPNeonDomain;
1680 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1683 // VFP Load / store multiple pseudo instructions.
1684 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1686 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1688 let OutOperandList = oops;
1689 let InOperandList = !con(iops, (ins pred:$p));
1690 let Pattern = pattern;
1691 list<Predicate> Predicates = [HasVFP2];
1694 // Load / store multiple
1696 // Unknown precision
1697 class AXXI4<dag oops, dag iops, IndexMode im,
1698 string asm, string cstr, list<dag> pattern>
1699 : VFPXI<oops, iops, AddrMode4, 4, im,
1700 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1701 // Instruction operands.
1705 // Encode instruction operands.
1706 let Inst{19-16} = Rn;
1708 let Inst{15-12} = regs{11-8};
1709 let Inst{7-1} = regs{7-1};
1711 let Inst{27-25} = 0b110;
1712 let Inst{11-8} = 0b1011;
1717 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1718 string asm, string cstr, list<dag> pattern>
1719 : VFPXI<oops, iops, AddrMode4, 4, im,
1720 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1721 // Instruction operands.
1725 // Encode instruction operands.
1726 let Inst{19-16} = Rn;
1727 let Inst{22} = regs{12};
1728 let Inst{15-12} = regs{11-8};
1729 let Inst{7-1} = regs{7-1};
1731 let Inst{27-25} = 0b110;
1732 let Inst{11-9} = 0b101;
1733 let Inst{8} = 1; // Double precision
1738 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1739 string asm, string cstr, list<dag> pattern>
1740 : VFPXI<oops, iops, AddrMode4, 4, im,
1741 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1742 // Instruction operands.
1746 // Encode instruction operands.
1747 let Inst{19-16} = Rn;
1748 let Inst{22} = regs{8};
1749 let Inst{15-12} = regs{12-9};
1750 let Inst{7-0} = regs{7-0};
1752 let Inst{27-25} = 0b110;
1753 let Inst{11-9} = 0b101;
1754 let Inst{8} = 0; // Single precision
1757 // Single Precision with fixed registers.
1758 // For when the registers-to-be-stored/loaded are fixed, e.g. VLLDM and VLSTM
1759 class AXSI4FR<string asm, bit et, bit load>
1760 : InstARM<AddrMode4, 4, IndexModeNone, VFPLdStMulFrm, VFPDomain, "", NoItinerary> {
1761 // Instruction operands.
1763 bits<13> regs; // Does not affect encoding, for assembly/disassembly only.
1764 list<Predicate> Predicates = [HasVFP2];
1765 let OutOperandList = (outs);
1766 let InOperandList = (ins GPRnopc:$Rn, pred:$p, dpr_reglist:$regs);
1767 let AsmString = asm;
1769 let DecoderNamespace = "VFP";
1770 // Encode instruction operands.
1771 let Inst{19-16} = Rn;
1772 let Inst{31-28} = 0b1110;
1773 let Inst{27-25} = 0b110;
1778 let Inst{20} = load; // Distinguishes vlldm from vlstm
1779 let Inst{15-12} = 0b0000;
1780 let Inst{11-9} = 0b101;
1781 let Inst{8} = 0; // Single precision
1782 let Inst{7} = et; // encoding type, 0 for T1 and 1 for T2.
1783 let Inst{6-0} = 0b0000000;
1785 let mayStore = !eq(load, 0);
1788 // Double precision, unary
1789 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1790 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1791 string asm, string cstr, list<dag> pattern>
1792 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, cstr, pattern> {
1793 // Instruction operands.
1797 // Encode instruction operands.
1798 let Inst{3-0} = Dm{3-0};
1799 let Inst{5} = Dm{4};
1800 let Inst{15-12} = Dd{3-0};
1801 let Inst{22} = Dd{4};
1803 let Inst{27-23} = opcod1;
1804 let Inst{21-20} = opcod2;
1805 let Inst{19-16} = opcod3;
1806 let Inst{11-9} = 0b101;
1807 let Inst{8} = 1; // Double precision
1808 let Inst{7-6} = opcod4;
1809 let Inst{4} = opcod5;
1811 let Predicates = [HasVFP2, HasDPVFP];
1814 // Double precision, unary, not-predicated
1815 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1816 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1817 string asm, list<dag> pattern>
1818 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1819 // Instruction operands.
1823 let Inst{31-28} = 0b1111;
1825 // Encode instruction operands.
1826 let Inst{3-0} = Dm{3-0};
1827 let Inst{5} = Dm{4};
1828 let Inst{15-12} = Dd{3-0};
1829 let Inst{22} = Dd{4};
1831 let Inst{27-23} = opcod1;
1832 let Inst{21-20} = opcod2;
1833 let Inst{19-16} = opcod3;
1834 let Inst{11-9} = 0b101;
1835 let Inst{8} = 1; // Double precision
1836 let Inst{7-6} = opcod4;
1837 let Inst{4} = opcod5;
1840 // Double precision, binary
1841 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1842 dag iops, InstrItinClass itin, string opc, string asm,
1844 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, "", pattern> {
1845 // Instruction operands.
1850 // Encode instruction operands.
1851 let Inst{3-0} = Dm{3-0};
1852 let Inst{5} = Dm{4};
1853 let Inst{19-16} = Dn{3-0};
1854 let Inst{7} = Dn{4};
1855 let Inst{15-12} = Dd{3-0};
1856 let Inst{22} = Dd{4};
1858 let Inst{27-23} = opcod1;
1859 let Inst{21-20} = opcod2;
1860 let Inst{11-9} = 0b101;
1861 let Inst{8} = 1; // Double precision
1865 let Predicates = [HasVFP2, HasDPVFP];
1868 // FP, binary, not predicated
1869 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1870 InstrItinClass itin, string asm, list<dag> pattern>
1871 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1874 // Instruction operands.
1879 let Inst{31-28} = 0b1111;
1881 // Encode instruction operands.
1882 let Inst{3-0} = Dm{3-0};
1883 let Inst{5} = Dm{4};
1884 let Inst{19-16} = Dn{3-0};
1885 let Inst{7} = Dn{4};
1886 let Inst{15-12} = Dd{3-0};
1887 let Inst{22} = Dd{4};
1889 let Inst{27-23} = opcod1;
1890 let Inst{21-20} = opcod2;
1891 let Inst{11-9} = 0b101;
1892 let Inst{8} = 1; // double precision
1893 let Inst{6} = opcod3;
1896 let Predicates = [HasVFP2, HasDPVFP];
1899 // Single precision, unary, predicated
1900 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1901 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1902 string asm, string cstr, list<dag> pattern>
1903 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, cstr, pattern> {
1904 // Instruction operands.
1908 // Encode instruction operands.
1909 let Inst{3-0} = Sm{4-1};
1910 let Inst{5} = Sm{0};
1911 let Inst{15-12} = Sd{4-1};
1912 let Inst{22} = Sd{0};
1914 let Inst{27-23} = opcod1;
1915 let Inst{21-20} = opcod2;
1916 let Inst{19-16} = opcod3;
1917 let Inst{11-9} = 0b101;
1918 let Inst{8} = 0; // Single precision
1919 let Inst{7-6} = opcod4;
1920 let Inst{4} = opcod5;
1923 // Single precision, unary, non-predicated
1924 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1925 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1926 string asm, list<dag> pattern>
1927 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1928 VFPUnaryFrm, itin, asm, "", pattern> {
1929 // Instruction operands.
1933 let Inst{31-28} = 0b1111;
1935 // Encode instruction operands.
1936 let Inst{3-0} = Sm{4-1};
1937 let Inst{5} = Sm{0};
1938 let Inst{15-12} = Sd{4-1};
1939 let Inst{22} = Sd{0};
1941 let Inst{27-23} = opcod1;
1942 let Inst{21-20} = opcod2;
1943 let Inst{19-16} = opcod3;
1944 let Inst{11-9} = 0b101;
1945 let Inst{8} = 0; // Single precision
1946 let Inst{7-6} = opcod4;
1947 let Inst{4} = opcod5;
1950 // Single precision unary, if no NEON. Same as ASuI except not available if
1952 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1953 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1954 string asm, list<dag> pattern>
1955 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1957 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1960 // Single precision, binary
1961 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1962 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1963 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, "", pattern> {
1964 // Instruction operands.
1969 // Encode instruction operands.
1970 let Inst{3-0} = Sm{4-1};
1971 let Inst{5} = Sm{0};
1972 let Inst{19-16} = Sn{4-1};
1973 let Inst{7} = Sn{0};
1974 let Inst{15-12} = Sd{4-1};
1975 let Inst{22} = Sd{0};
1977 let Inst{27-23} = opcod1;
1978 let Inst{21-20} = opcod2;
1979 let Inst{11-9} = 0b101;
1980 let Inst{8} = 0; // Single precision
1985 // Single precision, binary, not predicated
1986 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1987 InstrItinClass itin, string asm, list<dag> pattern>
1988 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1989 VFPBinaryFrm, itin, asm, "", pattern>
1991 // Instruction operands.
1996 let Inst{31-28} = 0b1111;
1998 // Encode instruction operands.
1999 let Inst{3-0} = Sm{4-1};
2000 let Inst{5} = Sm{0};
2001 let Inst{19-16} = Sn{4-1};
2002 let Inst{7} = Sn{0};
2003 let Inst{15-12} = Sd{4-1};
2004 let Inst{22} = Sd{0};
2006 let Inst{27-23} = opcod1;
2007 let Inst{21-20} = opcod2;
2008 let Inst{11-9} = 0b101;
2009 let Inst{8} = 0; // Single precision
2010 let Inst{6} = opcod3;
2014 // Single precision binary, if no NEON. Same as ASbI except not available if
2016 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
2017 dag iops, InstrItinClass itin, string opc, string asm,
2019 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
2020 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2022 // Instruction operands.
2027 // Encode instruction operands.
2028 let Inst{3-0} = Sm{4-1};
2029 let Inst{5} = Sm{0};
2030 let Inst{19-16} = Sn{4-1};
2031 let Inst{7} = Sn{0};
2032 let Inst{15-12} = Sd{4-1};
2033 let Inst{22} = Sd{0};
2036 // Half precision, unary, predicated
2037 class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2038 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
2039 string asm, list<dag> pattern>
2040 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, "", pattern> {
2041 list<Predicate> Predicates = [HasFullFP16];
2043 // Instruction operands.
2047 // Encode instruction operands.
2048 let Inst{3-0} = Sm{4-1};
2049 let Inst{5} = Sm{0};
2050 let Inst{15-12} = Sd{4-1};
2051 let Inst{22} = Sd{0};
2053 let Inst{27-23} = opcod1;
2054 let Inst{21-20} = opcod2;
2055 let Inst{19-16} = opcod3;
2056 let Inst{11-8} = 0b1001; // Half precision
2057 let Inst{7-6} = opcod4;
2058 let Inst{4} = opcod5;
2060 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2063 // Half precision, unary, non-predicated
2064 class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2065 bit opcod5, dag oops, dag iops, InstrItinClass itin,
2066 string asm, list<dag> pattern>
2067 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2068 VFPUnaryFrm, itin, asm, "", pattern> {
2069 list<Predicate> Predicates = [HasFullFP16];
2071 // Instruction operands.
2075 let Inst{31-28} = 0b1111;
2077 // Encode instruction operands.
2078 let Inst{3-0} = Sm{4-1};
2079 let Inst{5} = Sm{0};
2080 let Inst{15-12} = Sd{4-1};
2081 let Inst{22} = Sd{0};
2083 let Inst{27-23} = opcod1;
2084 let Inst{21-20} = opcod2;
2085 let Inst{19-16} = opcod3;
2086 let Inst{11-8} = 0b1001; // Half precision
2087 let Inst{7-6} = opcod4;
2088 let Inst{4} = opcod5;
2090 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2093 // Half precision, binary
2094 class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
2095 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2096 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, "", pattern> {
2097 list<Predicate> Predicates = [HasFullFP16];
2099 // Instruction operands.
2104 // Encode instruction operands.
2105 let Inst{3-0} = Sm{4-1};
2106 let Inst{5} = Sm{0};
2107 let Inst{19-16} = Sn{4-1};
2108 let Inst{7} = Sn{0};
2109 let Inst{15-12} = Sd{4-1};
2110 let Inst{22} = Sd{0};
2112 let Inst{27-23} = opcod1;
2113 let Inst{21-20} = opcod2;
2114 let Inst{11-8} = 0b1001; // Half precision
2118 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2121 // Half precision, binary, not predicated
2122 class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
2123 InstrItinClass itin, string asm, list<dag> pattern>
2124 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2125 VFPBinaryFrm, itin, asm, "", pattern> {
2126 list<Predicate> Predicates = [HasFullFP16];
2128 // Instruction operands.
2133 let Inst{31-28} = 0b1111;
2135 // Encode instruction operands.
2136 let Inst{3-0} = Sm{4-1};
2137 let Inst{5} = Sm{0};
2138 let Inst{19-16} = Sn{4-1};
2139 let Inst{7} = Sn{0};
2140 let Inst{15-12} = Sd{4-1};
2141 let Inst{22} = Sd{0};
2143 let Inst{27-23} = opcod1;
2144 let Inst{21-20} = opcod2;
2145 let Inst{11-8} = 0b1001; // Half precision
2146 let Inst{6} = opcod3;
2149 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2152 // VFP conversion instructions
2153 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2154 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2156 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, "", pattern> {
2157 let Inst{27-23} = opcod1;
2158 let Inst{21-20} = opcod2;
2159 let Inst{19-16} = opcod3;
2160 let Inst{11-8} = opcod4;
2165 // VFP conversion between floating-point and fixed-point
2166 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2167 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2169 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2171 // size (fixed-point number): sx == 0 ? 16 : 32
2172 let Inst{7} = op5; // sx
2173 let Inst{5} = fbits{0};
2174 let Inst{3-0} = fbits{4-1};
2177 // VFP conversion instructions, if no NEON
2178 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2179 dag oops, dag iops, InstrItinClass itin,
2180 string opc, string asm, list<dag> pattern>
2181 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2183 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2186 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2187 InstrItinClass itin,
2188 string opc, string asm, list<dag> pattern>
2189 : VFPAI<oops, iops, f, itin, opc, asm, "", pattern> {
2190 let Inst{27-20} = opcod1;
2191 let Inst{11-8} = opcod2;
2195 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2196 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2197 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
2199 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2200 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2201 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2203 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2204 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2205 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
2207 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2208 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2209 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
2211 //===----------------------------------------------------------------------===//
2213 //===----------------------------------------------------------------------===//
2214 // ARM NEON Instruction templates.
2217 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2218 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2220 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2221 let OutOperandList = oops;
2222 let InOperandList = !con(iops, (ins pred:$p));
2223 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2224 let Pattern = pattern;
2225 list<Predicate> Predicates = [HasNEON];
2226 let DecoderNamespace = "NEON";
2229 // Same as NeonI except it does not have a "data type" specifier.
2230 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2231 InstrItinClass itin, string opc, string asm, string cstr,
2233 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2234 let OutOperandList = oops;
2235 let InOperandList = !con(iops, (ins pred:$p));
2236 let AsmString = !strconcat(opc, "${p}", "\t", asm);
2237 let Pattern = pattern;
2238 list<Predicate> Predicates = [HasNEON];
2239 let DecoderNamespace = "NEON";
2242 // Same as NeonI except it is not predicated
2243 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2244 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2246 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2247 let OutOperandList = oops;
2248 let InOperandList = iops;
2249 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2250 let Pattern = pattern;
2251 list<Predicate> Predicates = [HasNEON];
2252 let DecoderNamespace = "NEON";
2254 let Inst{31-28} = 0b1111;
2257 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2258 dag oops, dag iops, InstrItinClass itin,
2259 string opc, string dt, string asm, string cstr, list<dag> pattern>
2260 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2262 let Inst{31-24} = 0b11110100;
2263 let Inst{23} = op23;
2264 let Inst{21-20} = op21_20;
2265 let Inst{11-8} = op11_8;
2266 let Inst{7-4} = op7_4;
2268 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2269 let DecoderNamespace = "NEONLoadStore";
2275 let Inst{22} = Vd{4};
2276 let Inst{15-12} = Vd{3-0};
2277 let Inst{19-16} = Rn{3-0};
2278 let Inst{3-0} = Rm{3-0};
2281 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2282 dag oops, dag iops, InstrItinClass itin,
2283 string opc, string dt, string asm, string cstr, list<dag> pattern>
2284 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2285 dt, asm, cstr, pattern> {
2289 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2290 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2292 let OutOperandList = oops;
2293 let InOperandList = !con(iops, (ins pred:$p));
2294 list<Predicate> Predicates = [HasNEON];
2297 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2299 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2301 let OutOperandList = oops;
2302 let InOperandList = !con(iops, (ins pred:$p));
2303 let Pattern = pattern;
2304 list<Predicate> Predicates = [HasNEON];
2307 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2308 string opc, string dt, string asm, string cstr, list<dag> pattern>
2309 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2311 let Inst{31-25} = 0b1111001;
2312 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2313 let DecoderNamespace = "NEONData";
2316 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2317 string opc, string asm, string cstr, list<dag> pattern>
2318 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2320 let Inst{31-25} = 0b1111001;
2321 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2322 let DecoderNamespace = "NEONData";
2325 // NEON "one register and a modified immediate" format.
2326 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2328 dag oops, dag iops, InstrItinClass itin,
2329 string opc, string dt, string asm, string cstr,
2331 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2332 let Inst{23} = op23;
2333 let Inst{21-19} = op21_19;
2334 let Inst{11-8} = op11_8;
2340 // Instruction operands.
2344 let Inst{15-12} = Vd{3-0};
2345 let Inst{22} = Vd{4};
2346 let Inst{24} = SIMM{7};
2347 let Inst{18-16} = SIMM{6-4};
2348 let Inst{3-0} = SIMM{3-0};
2349 let DecoderMethod = "DecodeVMOVModImmInstruction";
2352 // NEON 2 vector register format.
2353 class N2V<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 dt, string asm, string cstr, list<dag> pattern>
2357 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, 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 // Same as N2V but not predicated.
2377 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2378 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2379 string Dt, list<dag> pattern>
2380 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2381 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2385 // Encode instruction operands
2386 let Inst{22} = Vd{4};
2387 let Inst{15-12} = Vd{3-0};
2388 let Inst{5} = Vm{4};
2389 let Inst{3-0} = Vm{3-0};
2391 // Encode constant bits
2392 let Inst{27-23} = 0b00111;
2393 let Inst{21-20} = 0b11;
2394 let Inst{19-18} = op19_18;
2395 let Inst{17-16} = op17_16;
2397 let Inst{10-8} = op10_8;
2402 let DecoderNamespace = "NEON";
2405 // Same as N2V except it doesn't have a datatype suffix.
2406 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2407 bits<5> op11_7, bit op6, bit op4,
2408 dag oops, dag iops, InstrItinClass itin,
2409 string opc, string asm, string cstr, list<dag> pattern>
2410 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2411 let Inst{24-23} = op24_23;
2412 let Inst{21-20} = op21_20;
2413 let Inst{19-18} = op19_18;
2414 let Inst{17-16} = op17_16;
2415 let Inst{11-7} = op11_7;
2419 // Instruction operands.
2423 let Inst{15-12} = Vd{3-0};
2424 let Inst{22} = Vd{4};
2425 let Inst{3-0} = Vm{3-0};
2426 let Inst{5} = Vm{4};
2429 // NEON 2 vector register with immediate.
2430 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2431 dag oops, dag iops, Format f, InstrItinClass itin,
2432 string opc, string dt, string asm, string cstr, list<dag> pattern>
2433 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2434 let Inst{24} = op24;
2435 let Inst{23} = op23;
2436 let Inst{11-8} = op11_8;
2441 // Instruction operands.
2446 let Inst{15-12} = Vd{3-0};
2447 let Inst{22} = Vd{4};
2448 let Inst{3-0} = Vm{3-0};
2449 let Inst{5} = Vm{4};
2450 let Inst{21-16} = SIMM{5-0};
2453 // NEON 3 vector register format.
2455 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2456 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2457 string opc, string dt, string asm, string cstr,
2459 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2460 let Inst{24} = op24;
2461 let Inst{23} = op23;
2462 let Inst{21-20} = op21_20;
2463 let Inst{11-8} = op11_8;
2468 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2469 dag oops, dag iops, Format f, InstrItinClass itin,
2470 string opc, string dt, string asm, string cstr, list<dag> pattern>
2471 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2472 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2473 // Instruction operands.
2478 let Inst{15-12} = Vd{3-0};
2479 let Inst{22} = Vd{4};
2480 let Inst{19-16} = Vn{3-0};
2481 let Inst{7} = Vn{4};
2482 let Inst{3-0} = Vm{3-0};
2483 let Inst{5} = Vm{4};
2486 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2487 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2488 string OpcodeStr, string Dt, list<dag> pattern>
2489 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2490 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2495 // Encode instruction operands
2496 let Inst{22} = Vd{4};
2497 let Inst{15-12} = Vd{3-0};
2498 let Inst{19-16} = Vn{3-0};
2499 let Inst{7} = Vn{4};
2500 let Inst{5} = Vm{4};
2501 let Inst{3-0} = Vm{3-0};
2503 // Encode constant bits
2504 let Inst{27-23} = op27_23;
2505 let Inst{21-20} = op21_20;
2506 let Inst{11-8} = op11_8;
2511 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2512 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2513 string opc, string dt, string asm, string cstr,
2515 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2516 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2518 // Instruction operands.
2524 let Inst{15-12} = Vd{3-0};
2525 let Inst{22} = Vd{4};
2526 let Inst{19-16} = Vn{3-0};
2527 let Inst{7} = Vn{4};
2528 let Inst{3-0} = Vm{3-0};
2532 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2533 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2534 string opc, string dt, string asm, string cstr,
2536 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2537 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2539 // Instruction operands.
2545 let Inst{15-12} = Vd{3-0};
2546 let Inst{22} = Vd{4};
2547 let Inst{19-16} = Vn{3-0};
2548 let Inst{7} = Vn{4};
2549 let Inst{2-0} = Vm{2-0};
2550 let Inst{5} = lane{1};
2551 let Inst{3} = lane{0};
2554 // Same as N3V except it doesn't have a data type suffix.
2555 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2557 dag oops, dag iops, Format f, InstrItinClass itin,
2558 string opc, string asm, string cstr, list<dag> pattern>
2559 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2560 let Inst{24} = op24;
2561 let Inst{23} = op23;
2562 let Inst{21-20} = op21_20;
2563 let Inst{11-8} = op11_8;
2567 // Instruction operands.
2572 let Inst{15-12} = Vd{3-0};
2573 let Inst{22} = Vd{4};
2574 let Inst{19-16} = Vn{3-0};
2575 let Inst{7} = Vn{4};
2576 let Inst{3-0} = Vm{3-0};
2577 let Inst{5} = Vm{4};
2580 // NEON VMOVs between scalar and core registers.
2581 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2582 dag oops, dag iops, Format f, InstrItinClass itin,
2583 string opc, string dt, string asm, list<dag> pattern>
2584 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2586 let Inst{27-20} = opcod1;
2587 let Inst{11-8} = opcod2;
2588 let Inst{6-5} = opcod3;
2590 // A8.6.303, A8.6.328, A8.6.329
2591 let Inst{3-0} = 0b0000;
2593 let OutOperandList = oops;
2594 let InOperandList = !con(iops, (ins pred:$p));
2595 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2596 let Pattern = pattern;
2597 list<Predicate> Predicates = [HasNEON];
2599 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2600 let DecoderNamespace = "NEONDup";
2607 let Inst{31-28} = p{3-0};
2609 let Inst{19-16} = V{3-0};
2610 let Inst{15-12} = R{3-0};
2612 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2613 dag oops, dag iops, InstrItinClass itin,
2614 string opc, string dt, string asm, list<dag> pattern>
2615 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2616 opc, dt, asm, pattern>;
2617 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2618 dag oops, dag iops, InstrItinClass itin,
2619 string opc, string dt, string asm, list<dag> pattern>
2620 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2621 opc, dt, asm, pattern>;
2622 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2623 dag oops, dag iops, InstrItinClass itin,
2624 string opc, string dt, string asm, list<dag> pattern>
2625 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2626 opc, dt, asm, pattern>;
2628 // Vector Duplicate Lane (from scalar to all elements)
2629 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2630 InstrItinClass itin, string opc, string dt, string asm,
2632 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2633 let Inst{24-23} = 0b11;
2634 let Inst{21-20} = 0b11;
2635 let Inst{19-16} = op19_16;
2636 let Inst{11-7} = 0b11000;
2643 let Inst{22} = Vd{4};
2644 let Inst{15-12} = Vd{3-0};
2645 let Inst{5} = Vm{4};
2646 let Inst{3-0} = Vm{3-0};
2649 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2650 // for single-precision FP.
2651 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2652 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2655 // VFP/NEON Instruction aliases for type suffices.
2656 // Note: When EmitPriority == 1, the alias will be used for printing
2657 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2658 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
2660 // Note: When EmitPriority == 1, the alias will be used for printing
2661 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2662 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2663 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2664 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2665 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2668 // Note: When EmitPriority == 1, the alias will be used for printing
2669 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2670 let Predicates = [HasNEON] in {
2671 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2672 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2673 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2674 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2678 // The same alias classes using AsmPseudo instead, for the more complex
2679 // stuff in NEON that InstAlias can't quite handle.
2680 // Note that we can't use anonymous defm references here like we can
2681 // above, as we care about the ultimate instruction enum names generated, unlike
2682 // for instalias defs.
2683 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2684 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2686 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2687 // encoding space, introduced in ARMv8.3-A.
2688 class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2689 dag oops, dag iops, InstrItinClass itin,
2690 string opc, string dt, string asm, string cstr, list<dag> pattern>
2691 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2692 dt, asm, cstr, pattern> {
2697 let DecoderNamespace = "VFPV8";
2698 // These have the same encodings in ARM and Thumb2
2699 let PostEncoderMethod = "";
2701 let Inst{31-25} = 0b1111110;
2702 let Inst{24-23} = op24_23;
2703 let Inst{22} = Vd{4};
2704 let Inst{21-20} = op21_20;
2705 let Inst{19-16} = Vn{3-0};
2706 let Inst{15-12} = Vd{3-0};
2707 let Inst{11-8} = 0b1000;
2708 let Inst{7} = Vn{4};
2710 let Inst{5} = Vm{4};
2712 let Inst{3-0} = Vm{3-0};
2715 // Extension of NEON 2-vector-and-scalar data processing instructions in
2716 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2717 class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2718 dag oops, dag iops, InstrItinClass itin,
2719 string opc, string dt, string asm, string cstr, list<dag> pattern>
2720 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2721 dt, asm, cstr, pattern> {
2726 let DecoderNamespace = "VFPV8";
2727 // These have the same encodings in ARM and Thumb2
2728 let PostEncoderMethod = "";
2730 let Inst{31-24} = 0b11111110;
2731 let Inst{23} = op23;
2732 let Inst{22} = Vd{4};
2733 let Inst{21-20} = op21_20;
2734 let Inst{19-16} = Vn{3-0};
2735 let Inst{15-12} = Vd{3-0};
2736 let Inst{11-8} = 0b1000;
2737 let Inst{7} = Vn{4};
2739 // Bit 5 set by sub-classes
2741 let Inst{3-0} = Vm{3-0};
2744 // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
2746 // if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
2747 // if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
2748 // Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
2749 class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2750 dag oops, dag iops, InstrItinClass itin,
2751 string opc, string dt, string asm, string cstr, list<dag> pattern>
2752 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
2757 let DecoderNamespace = "VFPV8";
2758 // These have the same encodings in ARM and Thumb2
2759 let PostEncoderMethod = "";
2761 let Inst{31-25} = 0b1111110;
2762 let Inst{24-23} = op24_23;
2763 let Inst{22} = Vd{4};
2764 let Inst{21-20} = op21_20;
2765 let Inst{19-16} = Vn{4-1};
2766 let Inst{15-12} = Vd{3-0};
2767 let Inst{11-8} = 0b1000;
2768 let Inst{7} = Vn{0};
2770 let Inst{5} = Vm{0};
2772 let Inst{3-0} = Vm{4-1};
2775 // Operand types for complex instructions
2776 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2778 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2779 let DiagnosticString = "complex rotation must be " # Diag;
2780 let Name = "ComplexRotation" # Type;
2782 def complexrotateop : Operand<i32> {
2783 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2784 let PrintMethod = "printComplexRotationOp<90, 0>";
2786 def complexrotateopodd : Operand<i32> {
2787 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2788 let PrintMethod = "printComplexRotationOp<180, 90>";
2791 def MveSaturateOperand : AsmOperandClass {
2792 let PredicateMethod = "isMveSaturateOp";
2793 let DiagnosticString = "saturate operand must be 48 or 64";
2794 let Name = "MveSaturate";
2796 def saturateop : Operand<i32> {
2797 let ParserMatchClass = MveSaturateOperand;
2798 let PrintMethod = "printMveSaturateOp";
2801 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2802 def : TokenAlias<".s8", ".i8">;
2803 def : TokenAlias<".u8", ".i8">;
2804 def : TokenAlias<".s16", ".i16">;
2805 def : TokenAlias<".u16", ".i16">;
2806 def : TokenAlias<".s32", ".i32">;
2807 def : TokenAlias<".u32", ".i32">;
2808 def : TokenAlias<".s64", ".i64">;
2809 def : TokenAlias<".u64", ".i64">;
2811 def : TokenAlias<".i8", ".8">;
2812 def : TokenAlias<".i16", ".16">;
2813 def : TokenAlias<".i32", ".32">;
2814 def : TokenAlias<".i64", ".64">;
2816 def : TokenAlias<".p8", ".8">;
2817 def : TokenAlias<".p16", ".16">;
2819 def : TokenAlias<".f32", ".32">;
2820 def : TokenAlias<".f64", ".64">;
2821 def : TokenAlias<".f", ".f32">;
2822 def : TokenAlias<".d", ".f64">;