1 //===-- ARMInstrFormats.td - ARM Instruction Formats -------*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 //===----------------------------------------------------------------------===//
11 // ARM Instruction Format Definitions.
14 // Format specifies the encoding used by the instruction. This is part of the
15 // ad-hoc solution used to emit machine instruction encodings by our machine
17 class Format<bits<6> val> {
21 def Pseudo : Format<0>;
22 def MulFrm : Format<1>;
23 def BrFrm : Format<2>;
24 def BrMiscFrm : Format<3>;
26 def DPFrm : Format<4>;
27 def DPSoRegRegFrm : Format<5>;
29 def LdFrm : Format<6>;
30 def StFrm : Format<7>;
31 def LdMiscFrm : Format<8>;
32 def StMiscFrm : Format<9>;
33 def LdStMulFrm : Format<10>;
35 def LdStExFrm : Format<11>;
37 def ArithMiscFrm : Format<12>;
38 def SatFrm : Format<13>;
39 def ExtFrm : Format<14>;
41 def VFPUnaryFrm : Format<15>;
42 def VFPBinaryFrm : Format<16>;
43 def VFPConv1Frm : Format<17>;
44 def VFPConv2Frm : Format<18>;
45 def VFPConv3Frm : Format<19>;
46 def VFPConv4Frm : Format<20>;
47 def VFPConv5Frm : Format<21>;
48 def VFPLdStFrm : Format<22>;
49 def VFPLdStMulFrm : Format<23>;
50 def VFPMiscFrm : Format<24>;
52 def ThumbFrm : Format<25>;
53 def MiscFrm : Format<26>;
55 def NGetLnFrm : Format<27>;
56 def NSetLnFrm : Format<28>;
57 def NDupFrm : Format<29>;
58 def NLdStFrm : Format<30>;
59 def N1RegModImmFrm: Format<31>;
60 def N2RegFrm : Format<32>;
61 def NVCVTFrm : Format<33>;
62 def NVDupLnFrm : Format<34>;
63 def N2RegVShLFrm : Format<35>;
64 def N2RegVShRFrm : Format<36>;
65 def N3RegFrm : Format<37>;
66 def N3RegVShFrm : Format<38>;
67 def NVExtFrm : Format<39>;
68 def NVMulSLFrm : Format<40>;
69 def NVTBLFrm : Format<41>;
70 def DPSoRegImmFrm : Format<42>;
71 def N3RegCplxFrm : Format<43>;
75 // The instruction has an Rn register operand.
76 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
77 // it doesn't have a Rn operand.
78 class UnaryDP { bit isUnaryDataProc = 1; }
80 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
81 // a 16-bit Thumb instruction if certain conditions are met.
82 class Xform16Bit { bit canXformTo16Bit = 1; }
84 //===----------------------------------------------------------------------===//
85 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
88 // FIXME: Once the JIT is MC-ized, these can go away.
90 class AddrMode<bits<5> val> {
93 def AddrModeNone : AddrMode<0>;
94 def AddrMode1 : AddrMode<1>;
95 def AddrMode2 : AddrMode<2>;
96 def AddrMode3 : AddrMode<3>;
97 def AddrMode4 : AddrMode<4>;
98 def AddrMode5 : AddrMode<5>;
99 def AddrMode6 : AddrMode<6>;
100 def AddrModeT1_1 : AddrMode<7>;
101 def AddrModeT1_2 : AddrMode<8>;
102 def AddrModeT1_4 : AddrMode<9>;
103 def AddrModeT1_s : AddrMode<10>;
104 def AddrModeT2_i12 : AddrMode<11>;
105 def AddrModeT2_i8 : AddrMode<12>;
106 def AddrModeT2_so : AddrMode<13>;
107 def AddrModeT2_pc : AddrMode<14>;
108 def AddrModeT2_i8s4 : AddrMode<15>;
109 def AddrMode_i12 : AddrMode<16>;
110 def AddrMode5FP16 : AddrMode<17>;
111 def AddrModeT2_ldrex : AddrMode<18>;
112 def AddrModeT2_i7s4 : AddrMode<19>;
113 def AddrModeT2_i7s2 : AddrMode<20>;
114 def AddrModeT2_i7 : AddrMode<21>;
116 // Load / store index mode.
117 class IndexMode<bits<2> val> {
120 def IndexModeNone : IndexMode<0>;
121 def IndexModePre : IndexMode<1>;
122 def IndexModePost : IndexMode<2>;
123 def IndexModeUpd : IndexMode<3>;
125 // Instruction execution domain.
126 class Domain<bits<4> val> {
129 def GenericDomain : Domain<0>;
130 def VFPDomain : Domain<1>; // Instructions in VFP domain only
131 def NeonDomain : Domain<2>; // Instructions in Neon domain only
132 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
133 def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
134 def MVEDomain : Domain<8>; // Instructions in MVE and ARMv8.1m
136 //===----------------------------------------------------------------------===//
137 // ARM special operands.
140 // ARM imod and iflag operands, used only by the CPS instruction.
141 def imod_op : Operand<i32> {
142 let PrintMethod = "printCPSIMod";
145 def ProcIFlagsOperand : AsmOperandClass {
146 let Name = "ProcIFlags";
147 let ParserMethod = "parseProcIFlagsOperand";
149 def iflags_op : Operand<i32> {
150 let PrintMethod = "printCPSIFlag";
151 let ParserMatchClass = ProcIFlagsOperand;
154 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
155 // register whose default is 0 (no register).
156 def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
157 def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
158 (ops (i32 14), (i32 zero_reg))> {
159 let PrintMethod = "printPredicateOperand";
160 let ParserMatchClass = CondCodeOperand;
161 let DecoderMethod = "DecodePredicateOperand";
164 // Selectable predicate operand for CMOV instructions. We can't use a normal
165 // predicate because the default values interfere with instruction selection. In
166 // all other respects it is identical though: pseudo-instruction expansion
167 // relies on the MachineOperands being compatible.
168 def cmovpred : Operand<i32>, PredicateOp,
169 ComplexPattern<i32, 2, "SelectCMOVPred"> {
170 let MIOperandInfo = (ops i32imm, i32imm);
171 let PrintMethod = "printPredicateOperand";
174 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
175 def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
176 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
177 let EncoderMethod = "getCCOutOpValue";
178 let PrintMethod = "printSBitModifierOperand";
179 let ParserMatchClass = CCOutOperand;
180 let DecoderMethod = "DecodeCCOutOperand";
183 // Same as cc_out except it defaults to setting CPSR.
184 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
185 let EncoderMethod = "getCCOutOpValue";
186 let PrintMethod = "printSBitModifierOperand";
187 let ParserMatchClass = CCOutOperand;
188 let DecoderMethod = "DecodeCCOutOperand";
191 // Transform to generate the inverse of a condition code during ISel
192 def inv_cond_XFORM : SDNodeXForm<imm, [{
193 ARMCC::CondCodes CC = static_cast<ARMCC::CondCodes>(N->getZExtValue());
194 return CurDAG->getTargetConstant(ARMCC::getOppositeCondition(CC), SDLoc(N),
200 def VPTPredNOperand : AsmOperandClass {
201 let Name = "VPTPredN";
202 let PredicateMethod = "isVPTPred";
204 def VPTPredROperand : AsmOperandClass {
205 let Name = "VPTPredR";
206 let PredicateMethod = "isVPTPred";
208 def undef_tied_input;
210 // Operand classes for the cluster of MC operands describing a
211 // VPT-predicated MVE instruction.
213 // There are two of these classes. Both of them have the same first
216 // $cond (an integer) indicates the instruction's predication status:
217 // * ARMVCC::None means it's unpredicated
218 // * ARMVCC::Then means it's in a VPT block and appears with the T suffix
219 // * ARMVCC::Else means it's in a VPT block and appears with the E suffix.
220 // During code generation, unpredicated and predicated instructions
221 // are indicated by setting this parameter to 'None' or to 'Then'; the
222 // third value 'Else' is only used for assembly and disassembly.
224 // $cond_reg (type VCCR) gives the input predicate register. This is
225 // always either zero_reg or VPR, but needs to be modelled as an
226 // explicit operand so that it can be register-allocated and spilled
227 // when these operands are used in code generation).
229 // For 'vpred_r', there's an extra operand $inactive, which specifies
230 // the vector register which will supply any lanes of the output
231 // register that the predication mask prevents from being written by
232 // this instruction. It's always tied to the actual output register
233 // (i.e. must be allocated into the same physical reg), but again,
234 // code generation will need to model it as a separate input value.
236 // 'vpred_n' doesn't have that extra operand: it only has $cond and
237 // $cond_reg. This variant is used for any instruction that can't, or
238 // doesn't want to, tie $inactive to the output register. Sometimes
239 // that's because another input parameter is already tied to it (e.g.
240 // instructions that both read and write their Qd register even when
241 // unpredicated, either because they only partially overwrite it like
242 // a narrowing integer conversion, or simply because the instruction
243 // encoding doesn't have enough register fields to make the output
244 // independent of all inputs). It can also be because the instruction
245 // is defined to set disabled output lanes to zero rather than leaving
246 // them unchanged (vector loads), or because it doesn't output a
247 // vector register at all (stores, compares). In any of these
248 // situations it's unnecessary to have an extra operand tied to the
249 // output, and inconvenient to leave it there unused.
251 // Base class for both kinds of vpred.
252 class vpred_ops<dag extra_op, dag extra_mi> : OperandWithDefaultOps<OtherVT,
253 !con((ops (i32 0), (i32 zero_reg)), extra_op)> {
254 let PrintMethod = "printVPTPredicateOperand";
255 let OperandNamespace = "ARM";
256 let MIOperandInfo = !con((ops i32imm:$cond, VCCR:$cond_reg), extra_mi);
258 // For convenience, we provide a string value that can be appended
259 // to the constraints string. It's empty for vpred_n, and for
260 // vpred_r it ties the $inactive operand to the output q-register
261 // (which by convention will be called $Qd).
262 string vpred_constraint;
265 def vpred_r : vpred_ops<(ops (v4i32 undef_tied_input)), (ops MQPR:$inactive)> {
266 let ParserMatchClass = VPTPredROperand;
267 let OperandType = "OPERAND_VPRED_R";
268 let DecoderMethod = "DecodeVpredROperand";
269 let vpred_constraint = ",$Qd = $vp.inactive";
272 def vpred_n : vpred_ops<(ops), (ops)> {
273 let ParserMatchClass = VPTPredNOperand;
274 let OperandType = "OPERAND_VPRED_N";
275 let vpred_constraint = "";
278 // ARM special operands for disassembly only.
280 def SetEndAsmOperand : ImmAsmOperand<0,1> {
281 let Name = "SetEndImm";
282 let ParserMethod = "parseSetEndImm";
284 def setend_op : Operand<i32> {
285 let PrintMethod = "printSetendOperand";
286 let ParserMatchClass = SetEndAsmOperand;
289 def MSRMaskOperand : AsmOperandClass {
290 let Name = "MSRMask";
291 let ParserMethod = "parseMSRMaskOperand";
293 def msr_mask : Operand<i32> {
294 let PrintMethod = "printMSRMaskOperand";
295 let DecoderMethod = "DecodeMSRMask";
296 let ParserMatchClass = MSRMaskOperand;
299 def BankedRegOperand : AsmOperandClass {
300 let Name = "BankedReg";
301 let ParserMethod = "parseBankedRegOperand";
303 def banked_reg : Operand<i32> {
304 let PrintMethod = "printBankedRegOperand";
305 let DecoderMethod = "DecodeBankedReg";
306 let ParserMatchClass = BankedRegOperand;
309 // Shift Right Immediate - A shift right immediate is encoded differently from
310 // other shift immediates. The imm6 field is encoded like so:
313 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
314 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
315 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
316 // 64 64 - <imm> is encoded in imm6<5:0>
317 def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
318 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
319 let EncoderMethod = "getShiftRight8Imm";
320 let DecoderMethod = "DecodeShiftRight8Imm";
321 let ParserMatchClass = shr_imm8_asm_operand;
323 def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
324 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
325 let EncoderMethod = "getShiftRight16Imm";
326 let DecoderMethod = "DecodeShiftRight16Imm";
327 let ParserMatchClass = shr_imm16_asm_operand;
329 def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
330 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
331 let EncoderMethod = "getShiftRight32Imm";
332 let DecoderMethod = "DecodeShiftRight32Imm";
333 let ParserMatchClass = shr_imm32_asm_operand;
335 def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
336 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
337 let EncoderMethod = "getShiftRight64Imm";
338 let DecoderMethod = "DecodeShiftRight64Imm";
339 let ParserMatchClass = shr_imm64_asm_operand;
343 // ARM Assembler operand for ldr Rd, =expression which generates an offset
344 // to a constant pool entry or a MOV depending on the value of expression
345 def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
346 def const_pool_asm_imm : Operand<i32> {
347 let ParserMatchClass = const_pool_asm_operand;
351 //===----------------------------------------------------------------------===//
352 // ARM Assembler alias templates.
354 // Note: When EmitPriority == 1, the alias will be used for printing
355 class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
356 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
357 class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
358 : InstAlias<Asm, Result, EmitPriority>,
359 Requires<[IsARM,UseNegativeImmediates]>;
360 class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
361 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
362 class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
363 : InstAlias<Asm, Result, EmitPriority>,
364 Requires<[IsThumb,UseNegativeImmediates]>;
365 class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
366 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
367 class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
368 : InstAlias<Asm, Result, EmitPriority>,
369 Requires<[IsThumb2,UseNegativeImmediates]>;
370 class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
371 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
372 class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
373 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
374 class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
375 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
376 class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
377 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
378 class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
379 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
382 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
384 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
387 //===----------------------------------------------------------------------===//
388 // ARM Instruction templates.
392 class InstTemplate<AddrMode am, int sz, IndexMode im,
393 Format f, Domain d, string cstr, InstrItinClass itin>
395 let Namespace = "ARM";
400 bits<2> IndexModeBits = IM.Value;
402 bits<6> Form = F.Value;
404 bit isUnaryDataProc = 0;
405 bit canXformTo16Bit = 0;
406 // The instruction is a 16-bit flag setting Thumb instruction. Used
407 // by the parser to determine whether to require the 'S' suffix on the
408 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
409 bit thumbArithFlagSetting = 0;
411 // If this is a pseudo instruction, mark it isCodeGenOnly.
412 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
414 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
415 let TSFlags{4-0} = AM.Value;
416 let TSFlags{6-5} = IndexModeBits;
417 let TSFlags{12-7} = Form;
418 let TSFlags{13} = isUnaryDataProc;
419 let TSFlags{14} = canXformTo16Bit;
420 let TSFlags{18-15} = D.Value;
421 let TSFlags{19} = thumbArithFlagSetting;
423 let Constraints = cstr;
424 let Itinerary = itin;
429 // Mask of bits that cause an encoding to be UNPREDICTABLE.
430 // If a bit is set, then if the corresponding bit in the
431 // target encoding differs from its value in the "Inst" field,
432 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
433 field bits<32> Unpredictable = 0;
434 // SoftFail is the generic name for this field, but we alias it so
435 // as to make it more obvious what it means in ARM-land.
436 field bits<32> SoftFail = Unpredictable;
439 class InstARM<AddrMode am, int sz, IndexMode im,
440 Format f, Domain d, string cstr, InstrItinClass itin>
441 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
442 let DecoderNamespace = "ARM";
445 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
446 // on by adding flavors to specific instructions.
447 class InstThumb<AddrMode am, int sz, IndexMode im,
448 Format f, Domain d, string cstr, InstrItinClass itin>
449 : InstTemplate<am, sz, im, f, d, cstr, itin> {
450 let DecoderNamespace = "Thumb";
453 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
454 // These are aliases that require C++ handling to convert to the target
455 // instruction, while InstAliases can be handled directly by tblgen.
456 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
457 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
459 let OutOperandList = oops;
460 let InOperandList = iops;
462 let isCodeGenOnly = 0; // So we get asm matcher for it.
467 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
468 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
469 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
470 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
471 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
472 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
473 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
474 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
475 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
476 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
477 class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
478 : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
480 // Pseudo instructions for the code generator.
481 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
482 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
483 GenericDomain, "", itin> {
484 let OutOperandList = oops;
485 let InOperandList = iops;
486 let Pattern = pattern;
487 let isCodeGenOnly = 1;
491 // PseudoInst that's ARM-mode only.
492 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
494 : PseudoInst<oops, iops, itin, pattern> {
496 list<Predicate> Predicates = [IsARM];
499 // PseudoInst that's Thumb-mode only.
500 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
502 : PseudoInst<oops, iops, itin, pattern> {
504 list<Predicate> Predicates = [IsThumb];
507 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
508 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
510 : PseudoInst<oops, iops, itin, pattern> {
512 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
515 // PseudoInst that's Thumb2-mode only.
516 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
518 : PseudoInst<oops, iops, itin, pattern> {
520 list<Predicate> Predicates = [IsThumb2];
523 class ARMPseudoExpand<dag oops, dag iops, int sz,
524 InstrItinClass itin, list<dag> pattern,
526 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
527 PseudoInstExpansion<Result>;
529 class tPseudoExpand<dag oops, dag iops, int sz,
530 InstrItinClass itin, list<dag> pattern,
532 : tPseudoInst<oops, iops, sz, itin, pattern>,
533 PseudoInstExpansion<Result>;
535 class t2PseudoExpand<dag oops, dag iops, int sz,
536 InstrItinClass itin, list<dag> pattern,
538 : t2PseudoInst<oops, iops, sz, itin, pattern>,
539 PseudoInstExpansion<Result>;
541 // Almost all ARM instructions are predicable.
542 class I<dag oops, dag iops, AddrMode am, int sz,
543 IndexMode im, Format f, InstrItinClass itin,
544 string opc, string asm, string cstr,
546 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
549 let OutOperandList = oops;
550 let InOperandList = !con(iops, (ins pred:$p));
551 let AsmString = !strconcat(opc, "${p}", asm);
552 let Pattern = pattern;
553 list<Predicate> Predicates = [IsARM];
556 // A few are not predicable
557 class InoP<dag oops, dag iops, AddrMode am, int sz,
558 IndexMode im, Format f, InstrItinClass itin,
559 string opc, string asm, string cstr,
561 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
562 let OutOperandList = oops;
563 let InOperandList = iops;
564 let AsmString = !strconcat(opc, asm);
565 let Pattern = pattern;
566 let isPredicable = 0;
567 list<Predicate> Predicates = [IsARM];
570 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
571 // operand since by default it's a zero register. It will become an implicit def
572 // once it's "flipped".
573 class sI<dag oops, dag iops, AddrMode am, int sz,
574 IndexMode im, Format f, InstrItinClass itin,
575 string opc, string asm, string cstr,
577 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
578 bits<4> p; // Predicate operand
579 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
583 let OutOperandList = oops;
584 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
585 let AsmString = !strconcat(opc, "${s}${p}", asm);
586 let Pattern = pattern;
587 list<Predicate> Predicates = [IsARM];
591 class XI<dag oops, dag iops, AddrMode am, int sz,
592 IndexMode im, Format f, InstrItinClass itin,
593 string asm, string cstr, list<dag> pattern>
594 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
595 let OutOperandList = oops;
596 let InOperandList = iops;
598 let Pattern = pattern;
599 list<Predicate> Predicates = [IsARM];
602 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
603 string opc, string asm, list<dag> pattern>
604 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
605 opc, asm, "", pattern>;
606 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, list<dag> pattern>
608 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
609 opc, asm, "", pattern>;
610 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
611 string asm, list<dag> pattern>
612 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
614 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
615 string asm, list<dag> pattern>
616 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
618 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
619 string opc, string asm, list<dag> pattern>
620 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
621 opc, asm, "", pattern>;
623 // Ctrl flow instructions
624 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
625 string opc, string asm, list<dag> pattern>
626 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
627 opc, asm, "", pattern> {
628 let Inst{27-24} = opcod;
630 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
631 string asm, list<dag> pattern>
632 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
634 let Inst{27-24} = opcod;
637 // BR_JT instructions
638 class JTI<dag oops, dag iops, InstrItinClass itin,
639 string asm, list<dag> pattern>
640 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
643 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
644 string opc, string asm, list<dag> pattern>
645 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
646 opc, asm, "", pattern> {
649 let Inst{27-23} = 0b00011;
650 let Inst{22-21} = opcod;
652 let Inst{19-16} = addr;
653 let Inst{15-12} = Rt;
654 let Inst{11-10} = 0b11;
655 let Inst{9-8} = opcod2;
656 let Inst{7-0} = 0b10011111;
658 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
659 string opc, string asm, list<dag> pattern>
660 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
661 opc, asm, "", pattern> {
664 let Inst{27-23} = 0b00011;
665 let Inst{22-21} = opcod;
667 let Inst{19-16} = addr;
668 let Inst{11-10} = 0b11;
669 let Inst{9-8} = opcod2;
670 let Inst{7-4} = 0b1001;
673 // Atomic load/store instructions
674 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
675 string opc, string asm, list<dag> pattern>
676 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
678 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
679 string opc, string asm, list<dag> pattern>
680 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
682 let Inst{15-12} = Rd;
685 // Exclusive load/store instructions
687 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
688 string opc, string asm, list<dag> pattern>
689 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
690 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
692 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
693 string opc, string asm, list<dag> pattern>
694 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
695 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
697 let Inst{15-12} = Rd;
700 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
701 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
705 let Inst{27-23} = 0b00010;
707 let Inst{21-20} = 0b00;
708 let Inst{19-16} = addr;
709 let Inst{15-12} = Rt;
710 let Inst{11-4} = 0b00001001;
713 let Unpredictable{11-8} = 0b1111;
714 let DecoderMethod = "DecodeSwap";
716 // Acquire/Release load/store instructions
717 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
718 string opc, string asm, list<dag> pattern>
719 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
720 Requires<[IsARM, HasAcquireRelease]>;
722 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
723 string opc, string asm, list<dag> pattern>
724 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
725 Requires<[IsARM, HasAcquireRelease]> {
726 let Inst{15-12} = 0b1111;
729 // addrmode1 instructions
730 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
731 string opc, string asm, list<dag> pattern>
732 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
733 opc, asm, "", pattern> {
734 let Inst{24-21} = opcod;
735 let Inst{27-26} = 0b00;
737 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
738 string opc, string asm, list<dag> pattern>
739 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
740 opc, asm, "", pattern> {
741 let Inst{24-21} = opcod;
742 let Inst{27-26} = 0b00;
744 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
745 string asm, list<dag> pattern>
746 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
748 let Inst{24-21} = opcod;
749 let Inst{27-26} = 0b00;
754 // LDR/LDRB/STR/STRB/...
755 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
756 Format f, InstrItinClass itin, string opc, string asm,
758 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
760 let Inst{27-25} = op;
761 let Inst{24} = 1; // 24 == P
763 let Inst{22} = isByte;
764 let Inst{21} = 0; // 21 == W
767 // Indexed load/stores
768 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
769 IndexMode im, Format f, InstrItinClass itin, string opc,
770 string asm, string cstr, list<dag> pattern>
771 : I<oops, iops, AddrMode2, 4, im, f, itin,
772 opc, asm, cstr, pattern> {
774 let Inst{27-26} = 0b01;
775 let Inst{24} = isPre; // P bit
776 let Inst{22} = isByte; // B bit
777 let Inst{21} = isPre; // W bit
778 let Inst{20} = isLd; // L bit
779 let Inst{15-12} = Rt;
781 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
782 IndexMode im, Format f, InstrItinClass itin, string opc,
783 string asm, string cstr, list<dag> pattern>
784 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
786 // AM2 store w/ two operands: (GPR, am2offset)
792 let Inst{23} = offset{12};
793 let Inst{19-16} = Rn;
794 let Inst{11-5} = offset{11-5};
796 let Inst{3-0} = offset{3-0};
799 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
800 IndexMode im, Format f, InstrItinClass itin, string opc,
801 string asm, string cstr, list<dag> pattern>
802 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
804 // AM2 store w/ two operands: (GPR, am2offset)
810 let Inst{23} = offset{12};
811 let Inst{19-16} = Rn;
812 let Inst{11-0} = offset{11-0};
816 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
817 // but for now use this class for STRT and STRBT.
818 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
819 IndexMode im, Format f, InstrItinClass itin, string opc,
820 string asm, string cstr, list<dag> pattern>
821 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
823 // AM2 store w/ two operands: (GPR, am2offset)
825 // {13} 1 == Rm, 0 == imm12
829 let Inst{25} = addr{13};
830 let Inst{23} = addr{12};
831 let Inst{19-16} = addr{17-14};
832 let Inst{11-0} = addr{11-0};
835 // addrmode3 instructions
836 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
837 InstrItinClass itin, string opc, string asm, list<dag> pattern>
838 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
839 opc, asm, "", pattern> {
842 let Inst{27-25} = 0b000;
843 let Inst{24} = 1; // P bit
844 let Inst{23} = addr{8}; // U bit
845 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
846 let Inst{21} = 0; // W bit
847 let Inst{20} = op20; // L bit
848 let Inst{19-16} = addr{12-9}; // Rn
849 let Inst{15-12} = Rt; // Rt
850 let Inst{11-8} = addr{7-4}; // imm7_4/zero
852 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
854 let DecoderMethod = "DecodeAddrMode3Instruction";
857 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
858 IndexMode im, Format f, InstrItinClass itin, string opc,
859 string asm, string cstr, list<dag> pattern>
860 : I<oops, iops, AddrMode3, 4, im, f, itin,
861 opc, asm, cstr, pattern> {
863 let Inst{27-25} = 0b000;
864 let Inst{24} = isPre; // P bit
865 let Inst{21} = isPre; // W bit
866 let Inst{20} = op20; // L bit
867 let Inst{15-12} = Rt; // Rt
871 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
872 // but for now use this class for LDRSBT, LDRHT, LDSHT.
873 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
874 IndexMode im, Format f, InstrItinClass itin, string opc,
875 string asm, string cstr, list<dag> pattern>
876 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
877 // {13} 1 == imm8, 0 == Rm
884 let Inst{27-25} = 0b000;
885 let Inst{24} = 0; // P bit
887 let Inst{20} = isLoad; // L bit
888 let Inst{19-16} = addr; // Rn
889 let Inst{15-12} = Rt; // Rt
894 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
895 string opc, string asm, list<dag> pattern>
896 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
897 opc, asm, "", pattern> {
900 let Inst{27-25} = 0b000;
901 let Inst{24} = 1; // P bit
902 let Inst{23} = addr{8}; // U bit
903 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
904 let Inst{21} = 0; // W bit
905 let Inst{20} = 0; // L bit
906 let Inst{19-16} = addr{12-9}; // Rn
907 let Inst{15-12} = Rt; // Rt
908 let Inst{11-8} = addr{7-4}; // imm7_4/zero
910 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
911 let DecoderMethod = "DecodeAddrMode3Instruction";
914 // addrmode4 instructions
915 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
916 string asm, string cstr, list<dag> pattern>
917 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
922 let Inst{27-25} = 0b100;
923 let Inst{22} = 0; // S bit
924 let Inst{19-16} = Rn;
925 let Inst{15-0} = regs;
928 // Unsigned multiply, multiply-accumulate instructions.
929 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
930 string opc, string asm, list<dag> pattern>
931 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
932 opc, asm, "", pattern> {
933 let Inst{7-4} = 0b1001;
934 let Inst{20} = 0; // S bit
935 let Inst{27-21} = opcod;
937 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
938 string opc, string asm, list<dag> pattern>
939 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
940 opc, asm, "", pattern> {
941 let Inst{7-4} = 0b1001;
942 let Inst{27-21} = opcod;
945 // Most significant word multiply
946 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
947 InstrItinClass itin, string opc, string asm, list<dag> pattern>
948 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
949 opc, asm, "", pattern> {
953 let Inst{7-4} = opc7_4;
955 let Inst{27-21} = opcod;
956 let Inst{19-16} = Rd;
960 // MSW multiple w/ Ra operand
961 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
962 InstrItinClass itin, string opc, string asm, list<dag> pattern>
963 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
965 let Inst{15-12} = Ra;
968 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
969 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
970 InstrItinClass itin, string opc, string asm, list<dag> pattern>
971 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
972 opc, asm, "", pattern> {
978 let Inst{27-21} = opcod;
979 let Inst{6-5} = bit6_5;
983 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
984 InstrItinClass itin, string opc, string asm, list<dag> pattern>
985 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
987 let Inst{19-16} = Rd;
990 // AMulxyI with Ra operand
991 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
992 InstrItinClass itin, string opc, string asm, list<dag> pattern>
993 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
995 let Inst{15-12} = Ra;
998 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
999 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1000 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1003 let Inst{19-16} = RdHi;
1004 let Inst{15-12} = RdLo;
1007 // Extend instructions.
1008 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1009 string opc, string asm, list<dag> pattern>
1010 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
1011 opc, asm, "", pattern> {
1012 // All AExtI instructions have Rd and Rm register operands.
1015 let Inst{15-12} = Rd;
1017 let Inst{7-4} = 0b0111;
1018 let Inst{9-8} = 0b00;
1019 let Inst{27-20} = opcod;
1021 let Unpredictable{9-8} = 0b11;
1024 // Misc Arithmetic instructions.
1025 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1026 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1027 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1028 opc, asm, "", pattern> {
1031 let Inst{27-20} = opcod;
1032 let Inst{19-16} = 0b1111;
1033 let Inst{15-12} = Rd;
1034 let Inst{11-8} = 0b1111;
1035 let Inst{7-4} = opc7_4;
1039 // Division instructions.
1040 class ADivA1I<bits<3> opcod, dag oops, dag iops,
1041 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1042 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1043 opc, asm, "", pattern> {
1047 let Inst{27-23} = 0b01110;
1048 let Inst{22-20} = opcod;
1049 let Inst{19-16} = Rd;
1050 let Inst{15-12} = 0b1111;
1051 let Inst{11-8} = Rm;
1052 let Inst{7-4} = 0b0001;
1057 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
1058 let Name = "PKHLSLImm";
1059 let ParserMethod = "parsePKHLSLImm";
1061 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1062 let PrintMethod = "printPKHLSLShiftImm";
1063 let ParserMatchClass = PKHLSLAsmOperand;
1065 def PKHASRAsmOperand : AsmOperandClass {
1066 let Name = "PKHASRImm";
1067 let ParserMethod = "parsePKHASRImm";
1069 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1070 let PrintMethod = "printPKHASRShiftImm";
1071 let ParserMatchClass = PKHASRAsmOperand;
1074 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1075 string opc, string asm, list<dag> pattern>
1076 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1077 opc, asm, "", pattern> {
1082 let Inst{27-20} = opcod;
1083 let Inst{19-16} = Rn;
1084 let Inst{15-12} = Rd;
1085 let Inst{11-7} = sh;
1087 let Inst{5-4} = 0b01;
1091 //===----------------------------------------------------------------------===//
1093 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1094 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1095 list<Predicate> Predicates = [IsARM];
1097 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1098 list<Predicate> Predicates = [IsARM, HasV5T];
1100 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1101 list<Predicate> Predicates = [IsARM, HasV5TE];
1103 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1104 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1105 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1107 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1108 list<Predicate> Predicates = [IsARM, HasV6];
1110 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1111 list<Predicate> Predicates = [HasVFP2];
1113 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1114 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1116 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1117 list<Predicate> Predicates = [IsThumb2, HasDSP];
1119 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1120 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1122 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1123 list<Predicate> Predicates = [HasFP16];
1125 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1126 list<Predicate> Predicates = [HasFullFP16];
1128 //===----------------------------------------------------------------------===//
1129 // Thumb Instruction Format Definitions.
1132 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1133 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1134 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1135 let OutOperandList = oops;
1136 let InOperandList = iops;
1137 let AsmString = asm;
1138 let Pattern = pattern;
1139 list<Predicate> Predicates = [IsThumb];
1142 // TI - Thumb instruction.
1143 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1144 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1146 // Two-address instructions
1147 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1149 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1152 // tBL, tBX 32-bit instructions
1153 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1154 dag oops, dag iops, InstrItinClass itin, string asm,
1156 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1158 let Inst{31-27} = opcod1;
1159 let Inst{15-14} = opcod2;
1160 let Inst{12} = opcod3;
1163 // BR_JT instructions
1164 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1166 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1169 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1170 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1171 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1172 let OutOperandList = oops;
1173 let InOperandList = iops;
1174 let AsmString = asm;
1175 let Pattern = pattern;
1176 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1179 class T1I<dag oops, dag iops, InstrItinClass itin,
1180 string asm, list<dag> pattern>
1181 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1182 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1183 string asm, list<dag> pattern>
1184 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1186 // Two-address instructions
1187 class T1It<dag oops, dag iops, InstrItinClass itin,
1188 string asm, string cstr, list<dag> pattern>
1189 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1190 asm, cstr, pattern>;
1192 // Thumb1 instruction that can either be predicated or set CPSR.
1193 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1194 InstrItinClass itin,
1195 string opc, string asm, string cstr, list<dag> pattern>
1196 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1197 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1198 let InOperandList = !con(iops, (ins pred:$p));
1199 let AsmString = !strconcat(opc, "${s}${p}", asm);
1200 let Pattern = pattern;
1201 let thumbArithFlagSetting = 1;
1202 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1203 let DecoderNamespace = "ThumbSBit";
1206 class T1sI<dag oops, dag iops, InstrItinClass itin,
1207 string opc, string asm, list<dag> pattern>
1208 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1210 // Two-address instructions
1211 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1212 string opc, string asm, list<dag> pattern>
1213 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1214 "$Rn = $Rdn", pattern>;
1216 // Thumb1 instruction that can be predicated.
1217 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1218 InstrItinClass itin,
1219 string opc, string asm, string cstr, list<dag> pattern>
1220 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1221 let OutOperandList = oops;
1222 let InOperandList = !con(iops, (ins pred:$p));
1223 let AsmString = !strconcat(opc, "${p}", asm);
1224 let Pattern = pattern;
1225 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1228 class T1pI<dag oops, dag iops, InstrItinClass itin,
1229 string opc, string asm, list<dag> pattern>
1230 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1232 // Two-address instructions
1233 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1234 string opc, string asm, list<dag> pattern>
1235 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1236 "$Rn = $Rdn", pattern>;
1238 class T1pIs<dag oops, dag iops,
1239 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1240 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1242 class Encoding16 : Encoding {
1243 let Inst{31-16} = 0x0000;
1246 // A6.2 16-bit Thumb instruction encoding
1247 class T1Encoding<bits<6> opcode> : Encoding16 {
1248 let Inst{15-10} = opcode;
1251 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1252 class T1General<bits<5> opcode> : Encoding16 {
1253 let Inst{15-14} = 0b00;
1254 let Inst{13-9} = opcode;
1257 // A6.2.2 Data-processing encoding.
1258 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1259 let Inst{15-10} = 0b010000;
1260 let Inst{9-6} = opcode;
1263 // A6.2.3 Special data instructions and branch and exchange encoding.
1264 class T1Special<bits<4> opcode> : Encoding16 {
1265 let Inst{15-10} = 0b010001;
1266 let Inst{9-6} = opcode;
1269 // A6.2.4 Load/store single data item encoding.
1270 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1271 let Inst{15-12} = opA;
1272 let Inst{11-9} = opB;
1274 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1276 class T1BranchCond<bits<4> opcode> : Encoding16 {
1277 let Inst{15-12} = opcode;
1280 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1281 // following bits are used for "opA" (see A6.2.4):
1283 // 0b0110 => Immediate, 4 bytes
1284 // 0b1000 => Immediate, 2 bytes
1285 // 0b0111 => Immediate, 1 byte
1286 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1287 InstrItinClass itin, string opc, string asm,
1289 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1290 T1LoadStore<0b0101, opcode> {
1293 let Inst{8-6} = addr{5-3}; // Rm
1294 let Inst{5-3} = addr{2-0}; // Rn
1297 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1298 InstrItinClass itin, string opc, string asm,
1300 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1301 T1LoadStore<opA, {opB,?,?}> {
1304 let Inst{10-6} = addr{7-3}; // imm5
1305 let Inst{5-3} = addr{2-0}; // Rn
1309 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1310 class T1Misc<bits<7> opcode> : Encoding16 {
1311 let Inst{15-12} = 0b1011;
1312 let Inst{11-5} = opcode;
1315 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1316 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1317 InstrItinClass itin,
1318 string opc, string asm, string cstr, list<dag> pattern>
1319 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1320 let OutOperandList = oops;
1321 let InOperandList = !con(iops, (ins pred:$p));
1322 let AsmString = !strconcat(opc, "${p}", asm);
1323 let Pattern = pattern;
1324 list<Predicate> Predicates = [IsThumb2];
1325 let DecoderNamespace = "Thumb2";
1328 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1329 // input operand since by default it's a zero register. It will become an
1330 // implicit def once it's "flipped".
1332 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1334 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1335 InstrItinClass itin,
1336 string opc, string asm, string cstr, list<dag> pattern>
1337 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1338 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1341 let OutOperandList = oops;
1342 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1343 let AsmString = !strconcat(opc, "${s}${p}", asm);
1344 let Pattern = pattern;
1345 list<Predicate> Predicates = [IsThumb2];
1346 let DecoderNamespace = "Thumb2";
1350 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1351 InstrItinClass itin,
1352 string asm, string cstr, list<dag> pattern>
1353 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1354 let OutOperandList = oops;
1355 let InOperandList = iops;
1356 let AsmString = asm;
1357 let Pattern = pattern;
1358 list<Predicate> Predicates = [IsThumb2];
1359 let DecoderNamespace = "Thumb2";
1362 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1363 InstrItinClass itin,
1364 string asm, string cstr, list<dag> pattern>
1365 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1366 let OutOperandList = oops;
1367 let InOperandList = iops;
1368 let AsmString = asm;
1369 let Pattern = pattern;
1370 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1371 let DecoderNamespace = "Thumb";
1374 class T2I<dag oops, dag iops, InstrItinClass itin,
1375 string opc, string asm, list<dag> pattern>
1376 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1377 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1378 string opc, string asm, list<dag> pattern>
1379 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1380 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1381 string opc, string asm, list<dag> pattern>
1382 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1383 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1384 string opc, string asm, list<dag> pattern>
1385 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1386 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1387 string opc, string asm, list<dag> pattern>
1388 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1389 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1390 string opc, string asm, string cstr, list<dag> pattern>
1391 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1396 let Inst{31-25} = 0b1110100;
1398 let Inst{23} = addr{8};
1401 let Inst{20} = isLoad;
1402 let Inst{19-16} = addr{12-9};
1403 let Inst{15-12} = Rt{3-0};
1404 let Inst{11-8} = Rt2{3-0};
1405 let Inst{7-0} = addr{7-0};
1407 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1408 InstrItinClass itin, string opc, string asm, string cstr,
1410 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1416 let Inst{31-25} = 0b1110100;
1418 let Inst{23} = imm{8};
1421 let Inst{20} = isLoad;
1422 let Inst{19-16} = addr;
1423 let Inst{15-12} = Rt{3-0};
1424 let Inst{11-8} = Rt2{3-0};
1425 let Inst{7-0} = imm{7-0};
1428 class T2sI<dag oops, dag iops, InstrItinClass itin,
1429 string opc, string asm, list<dag> pattern>
1430 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1432 class T2XI<dag oops, dag iops, InstrItinClass itin,
1433 string asm, list<dag> pattern>
1434 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1435 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1436 string asm, list<dag> pattern>
1437 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1439 // Move to/from coprocessor instructions
1440 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1442 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1443 let Inst{31-28} = opc;
1446 // Two-address instructions
1447 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1448 string asm, string cstr, list<dag> pattern>
1449 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1451 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1452 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1454 AddrMode am, IndexMode im, InstrItinClass itin,
1455 string opc, string asm, string cstr, list<dag> pattern>
1456 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1457 let OutOperandList = oops;
1458 let InOperandList = !con(iops, (ins pred:$p));
1459 let AsmString = !strconcat(opc, "${p}", asm);
1460 let Pattern = pattern;
1461 list<Predicate> Predicates = [IsThumb2];
1462 let DecoderNamespace = "Thumb2";
1466 let Inst{31-27} = 0b11111;
1467 let Inst{26-25} = 0b00;
1468 let Inst{24} = signed;
1470 let Inst{22-21} = opcod;
1471 let Inst{20} = load;
1472 let Inst{19-16} = addr{12-9};
1473 let Inst{15-12} = Rt{3-0};
1475 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1476 let Inst{10} = pre; // The P bit.
1477 let Inst{9} = addr{8}; // Sign bit
1478 let Inst{8} = 1; // The W bit.
1479 let Inst{7-0} = addr{7-0};
1481 let DecoderMethod = "DecodeT2LdStPre";
1484 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1485 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1487 AddrMode am, IndexMode im, InstrItinClass itin,
1488 string opc, string asm, string cstr, list<dag> pattern>
1489 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1490 let OutOperandList = oops;
1491 let InOperandList = !con(iops, (ins pred:$p));
1492 let AsmString = !strconcat(opc, "${p}", asm);
1493 let Pattern = pattern;
1494 list<Predicate> Predicates = [IsThumb2];
1495 let DecoderNamespace = "Thumb2";
1500 let Inst{31-27} = 0b11111;
1501 let Inst{26-25} = 0b00;
1502 let Inst{24} = signed;
1504 let Inst{22-21} = opcod;
1505 let Inst{20} = load;
1506 let Inst{19-16} = Rn;
1507 let Inst{15-12} = Rt{3-0};
1509 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1510 let Inst{10} = pre; // The P bit.
1511 let Inst{9} = offset{8}; // Sign bit
1512 let Inst{8} = 1; // The W bit.
1513 let Inst{7-0} = offset{7-0};
1515 let DecoderMethod = "DecodeT2LdStPre";
1518 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1519 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1520 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1523 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1524 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1525 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1528 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1529 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1530 list<Predicate> Predicates = [IsThumb2];
1533 //===----------------------------------------------------------------------===//
1535 //===----------------------------------------------------------------------===//
1536 // ARM VFP Instruction templates.
1539 // Almost all VFP instructions are predicable.
1540 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1541 IndexMode im, Format f, InstrItinClass itin,
1542 string opc, string asm, string cstr, list<dag> pattern>
1543 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1545 let Inst{31-28} = p;
1546 let OutOperandList = oops;
1547 let InOperandList = !con(iops, (ins pred:$p));
1548 let AsmString = !strconcat(opc, "${p}", asm);
1549 let Pattern = pattern;
1550 let PostEncoderMethod = "VFPThumb2PostEncoder";
1551 let DecoderNamespace = "VFP";
1552 list<Predicate> Predicates = [HasVFP2];
1556 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1557 IndexMode im, Format f, InstrItinClass itin,
1558 string asm, string cstr, list<dag> pattern>
1559 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1561 let Inst{31-28} = p;
1562 let OutOperandList = oops;
1563 let InOperandList = iops;
1564 let AsmString = asm;
1565 let Pattern = pattern;
1566 let PostEncoderMethod = "VFPThumb2PostEncoder";
1567 let DecoderNamespace = "VFP";
1568 list<Predicate> Predicates = [HasVFP2];
1571 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1572 string opc, string asm, list<dag> pattern>
1573 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1574 opc, asm, "", pattern> {
1575 let PostEncoderMethod = "VFPThumb2PostEncoder";
1578 // ARM VFP addrmode5 loads and stores
1579 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1580 InstrItinClass itin,
1581 string opc, string asm, list<dag> pattern>
1582 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1583 VFPLdStFrm, itin, opc, asm, "", pattern> {
1584 // Instruction operands.
1588 // Encode instruction operands.
1589 let Inst{23} = addr{8}; // U (add = (U == '1'))
1590 let Inst{22} = Dd{4};
1591 let Inst{19-16} = addr{12-9}; // Rn
1592 let Inst{15-12} = Dd{3-0};
1593 let Inst{7-0} = addr{7-0}; // imm8
1595 let Inst{27-24} = opcod1;
1596 let Inst{21-20} = opcod2;
1597 let Inst{11-9} = 0b101;
1598 let Inst{8} = 1; // Double precision
1600 // Loads & stores operate on both NEON and VFP pipelines.
1601 let D = VFPNeonDomain;
1604 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1605 InstrItinClass itin,
1606 string opc, string asm, list<dag> pattern>
1607 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1608 VFPLdStFrm, itin, opc, asm, "", pattern> {
1609 // Instruction operands.
1613 // Encode instruction operands.
1614 let Inst{23} = addr{8}; // U (add = (U == '1'))
1615 let Inst{22} = Sd{0};
1616 let Inst{19-16} = addr{12-9}; // Rn
1617 let Inst{15-12} = Sd{4-1};
1618 let Inst{7-0} = addr{7-0}; // imm8
1620 let Inst{27-24} = opcod1;
1621 let Inst{21-20} = opcod2;
1622 let Inst{11-9} = 0b101;
1623 let Inst{8} = 0; // Single precision
1625 // Loads & stores operate on both NEON and VFP pipelines.
1626 let D = VFPNeonDomain;
1629 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1630 InstrItinClass itin,
1631 string opc, string asm, list<dag> pattern>
1632 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1633 VFPLdStFrm, itin, opc, asm, "", pattern> {
1634 list<Predicate> Predicates = [HasFullFP16];
1636 // Instruction operands.
1640 // Encode instruction operands.
1641 let Inst{23} = addr{8}; // U (add = (U == '1'))
1642 let Inst{22} = Sd{0};
1643 let Inst{19-16} = addr{12-9}; // Rn
1644 let Inst{15-12} = Sd{4-1};
1645 let Inst{7-0} = addr{7-0}; // imm8
1647 let Inst{27-24} = opcod1;
1648 let Inst{21-20} = opcod2;
1649 let Inst{11-8} = 0b1001; // Half precision
1651 // Loads & stores operate on both NEON and VFP pipelines.
1652 let D = VFPNeonDomain;
1654 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1657 // VFP Load / store multiple pseudo instructions.
1658 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1660 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1662 let OutOperandList = oops;
1663 let InOperandList = !con(iops, (ins pred:$p));
1664 let Pattern = pattern;
1665 list<Predicate> Predicates = [HasVFP2];
1668 // Load / store multiple
1670 // Unknown precision
1671 class AXXI4<dag oops, dag iops, IndexMode im,
1672 string asm, string cstr, list<dag> pattern>
1673 : VFPXI<oops, iops, AddrMode4, 4, im,
1674 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1675 // Instruction operands.
1679 // Encode instruction operands.
1680 let Inst{19-16} = Rn;
1682 let Inst{15-12} = regs{11-8};
1683 let Inst{7-1} = regs{7-1};
1685 let Inst{27-25} = 0b110;
1686 let Inst{11-8} = 0b1011;
1691 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1692 string asm, string cstr, list<dag> pattern>
1693 : VFPXI<oops, iops, AddrMode4, 4, im,
1694 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1695 // Instruction operands.
1699 // Encode instruction operands.
1700 let Inst{19-16} = Rn;
1701 let Inst{22} = regs{12};
1702 let Inst{15-12} = regs{11-8};
1703 let Inst{7-1} = regs{7-1};
1705 let Inst{27-25} = 0b110;
1706 let Inst{11-9} = 0b101;
1707 let Inst{8} = 1; // Double precision
1712 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1713 string asm, string cstr, list<dag> pattern>
1714 : VFPXI<oops, iops, AddrMode4, 4, im,
1715 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1716 // Instruction operands.
1720 // Encode instruction operands.
1721 let Inst{19-16} = Rn;
1722 let Inst{22} = regs{8};
1723 let Inst{15-12} = regs{12-9};
1724 let Inst{7-0} = regs{7-0};
1726 let Inst{27-25} = 0b110;
1727 let Inst{11-9} = 0b101;
1728 let Inst{8} = 0; // Single precision
1731 // Double precision, unary
1732 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1733 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1734 string asm, list<dag> pattern>
1735 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1736 // Instruction operands.
1740 // Encode instruction operands.
1741 let Inst{3-0} = Dm{3-0};
1742 let Inst{5} = Dm{4};
1743 let Inst{15-12} = Dd{3-0};
1744 let Inst{22} = Dd{4};
1746 let Inst{27-23} = opcod1;
1747 let Inst{21-20} = opcod2;
1748 let Inst{19-16} = opcod3;
1749 let Inst{11-9} = 0b101;
1750 let Inst{8} = 1; // Double precision
1751 let Inst{7-6} = opcod4;
1752 let Inst{4} = opcod5;
1754 let Predicates = [HasVFP2, HasDPVFP];
1757 // Double precision, unary, not-predicated
1758 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1759 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1760 string asm, list<dag> pattern>
1761 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1762 // Instruction operands.
1766 let Inst{31-28} = 0b1111;
1768 // Encode instruction operands.
1769 let Inst{3-0} = Dm{3-0};
1770 let Inst{5} = Dm{4};
1771 let Inst{15-12} = Dd{3-0};
1772 let Inst{22} = Dd{4};
1774 let Inst{27-23} = opcod1;
1775 let Inst{21-20} = opcod2;
1776 let Inst{19-16} = opcod3;
1777 let Inst{11-9} = 0b101;
1778 let Inst{8} = 1; // Double precision
1779 let Inst{7-6} = opcod4;
1780 let Inst{4} = opcod5;
1783 // Double precision, binary
1784 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1785 dag iops, InstrItinClass itin, string opc, string asm,
1787 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1788 // Instruction operands.
1793 // Encode instruction operands.
1794 let Inst{3-0} = Dm{3-0};
1795 let Inst{5} = Dm{4};
1796 let Inst{19-16} = Dn{3-0};
1797 let Inst{7} = Dn{4};
1798 let Inst{15-12} = Dd{3-0};
1799 let Inst{22} = Dd{4};
1801 let Inst{27-23} = opcod1;
1802 let Inst{21-20} = opcod2;
1803 let Inst{11-9} = 0b101;
1804 let Inst{8} = 1; // Double precision
1808 let Predicates = [HasVFP2, HasDPVFP];
1811 // FP, binary, not predicated
1812 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1813 InstrItinClass itin, string asm, list<dag> pattern>
1814 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1817 // Instruction operands.
1822 let Inst{31-28} = 0b1111;
1824 // Encode instruction operands.
1825 let Inst{3-0} = Dm{3-0};
1826 let Inst{5} = Dm{4};
1827 let Inst{19-16} = Dn{3-0};
1828 let Inst{7} = Dn{4};
1829 let Inst{15-12} = Dd{3-0};
1830 let Inst{22} = Dd{4};
1832 let Inst{27-23} = opcod1;
1833 let Inst{21-20} = opcod2;
1834 let Inst{11-9} = 0b101;
1835 let Inst{8} = 1; // double precision
1836 let Inst{6} = opcod3;
1839 let Predicates = [HasVFP2, HasDPVFP];
1842 // Single precision, unary, predicated
1843 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1844 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1845 string asm, list<dag> pattern>
1846 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1847 // Instruction operands.
1851 // Encode instruction operands.
1852 let Inst{3-0} = Sm{4-1};
1853 let Inst{5} = Sm{0};
1854 let Inst{15-12} = Sd{4-1};
1855 let Inst{22} = Sd{0};
1857 let Inst{27-23} = opcod1;
1858 let Inst{21-20} = opcod2;
1859 let Inst{19-16} = opcod3;
1860 let Inst{11-9} = 0b101;
1861 let Inst{8} = 0; // Single precision
1862 let Inst{7-6} = opcod4;
1863 let Inst{4} = opcod5;
1866 // Single precision, unary, non-predicated
1867 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1868 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1869 string asm, list<dag> pattern>
1870 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1871 VFPUnaryFrm, itin, asm, "", pattern> {
1872 // Instruction operands.
1876 let Inst{31-28} = 0b1111;
1878 // Encode instruction operands.
1879 let Inst{3-0} = Sm{4-1};
1880 let Inst{5} = Sm{0};
1881 let Inst{15-12} = Sd{4-1};
1882 let Inst{22} = Sd{0};
1884 let Inst{27-23} = opcod1;
1885 let Inst{21-20} = opcod2;
1886 let Inst{19-16} = opcod3;
1887 let Inst{11-9} = 0b101;
1888 let Inst{8} = 0; // Single precision
1889 let Inst{7-6} = opcod4;
1890 let Inst{4} = opcod5;
1893 // Single precision unary, if no NEON. Same as ASuI except not available if
1895 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1896 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1897 string asm, list<dag> pattern>
1898 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1900 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1903 // Single precision, binary
1904 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1905 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1906 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1907 // Instruction operands.
1912 // Encode instruction operands.
1913 let Inst{3-0} = Sm{4-1};
1914 let Inst{5} = Sm{0};
1915 let Inst{19-16} = Sn{4-1};
1916 let Inst{7} = Sn{0};
1917 let Inst{15-12} = Sd{4-1};
1918 let Inst{22} = Sd{0};
1920 let Inst{27-23} = opcod1;
1921 let Inst{21-20} = opcod2;
1922 let Inst{11-9} = 0b101;
1923 let Inst{8} = 0; // Single precision
1928 // Single precision, binary, not predicated
1929 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1930 InstrItinClass itin, string asm, list<dag> pattern>
1931 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1932 VFPBinaryFrm, itin, asm, "", pattern>
1934 // Instruction operands.
1939 let Inst{31-28} = 0b1111;
1941 // Encode instruction operands.
1942 let Inst{3-0} = Sm{4-1};
1943 let Inst{5} = Sm{0};
1944 let Inst{19-16} = Sn{4-1};
1945 let Inst{7} = Sn{0};
1946 let Inst{15-12} = Sd{4-1};
1947 let Inst{22} = Sd{0};
1949 let Inst{27-23} = opcod1;
1950 let Inst{21-20} = opcod2;
1951 let Inst{11-9} = 0b101;
1952 let Inst{8} = 0; // Single precision
1953 let Inst{6} = opcod3;
1957 // Single precision binary, if no NEON. Same as ASbI except not available if
1959 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1960 dag iops, InstrItinClass itin, string opc, string asm,
1962 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1963 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1965 // Instruction operands.
1970 // Encode instruction operands.
1971 let Inst{3-0} = Sm{4-1};
1972 let Inst{5} = Sm{0};
1973 let Inst{19-16} = Sn{4-1};
1974 let Inst{7} = Sn{0};
1975 let Inst{15-12} = Sd{4-1};
1976 let Inst{22} = Sd{0};
1979 // Half precision, unary, predicated
1980 class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1981 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1982 string asm, list<dag> pattern>
1983 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1984 list<Predicate> Predicates = [HasFullFP16];
1986 // Instruction operands.
1990 // Encode instruction operands.
1991 let Inst{3-0} = Sm{4-1};
1992 let Inst{5} = Sm{0};
1993 let Inst{15-12} = Sd{4-1};
1994 let Inst{22} = Sd{0};
1996 let Inst{27-23} = opcod1;
1997 let Inst{21-20} = opcod2;
1998 let Inst{19-16} = opcod3;
1999 let Inst{11-8} = 0b1001; // Half precision
2000 let Inst{7-6} = opcod4;
2001 let Inst{4} = opcod5;
2003 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2006 // Half precision, unary, non-predicated
2007 class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2008 bit opcod5, dag oops, dag iops, InstrItinClass itin,
2009 string asm, list<dag> pattern>
2010 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2011 VFPUnaryFrm, itin, asm, "", pattern> {
2012 list<Predicate> Predicates = [HasFullFP16];
2014 // Instruction operands.
2018 let Inst{31-28} = 0b1111;
2020 // Encode instruction operands.
2021 let Inst{3-0} = Sm{4-1};
2022 let Inst{5} = Sm{0};
2023 let Inst{15-12} = Sd{4-1};
2024 let Inst{22} = Sd{0};
2026 let Inst{27-23} = opcod1;
2027 let Inst{21-20} = opcod2;
2028 let Inst{19-16} = opcod3;
2029 let Inst{11-8} = 0b1001; // Half precision
2030 let Inst{7-6} = opcod4;
2031 let Inst{4} = opcod5;
2033 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2036 // Half precision, binary
2037 class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
2038 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2039 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
2040 list<Predicate> Predicates = [HasFullFP16];
2042 // Instruction operands.
2047 // Encode instruction operands.
2048 let Inst{3-0} = Sm{4-1};
2049 let Inst{5} = Sm{0};
2050 let Inst{19-16} = Sn{4-1};
2051 let Inst{7} = Sn{0};
2052 let Inst{15-12} = Sd{4-1};
2053 let Inst{22} = Sd{0};
2055 let Inst{27-23} = opcod1;
2056 let Inst{21-20} = opcod2;
2057 let Inst{11-8} = 0b1001; // Half precision
2061 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2064 // Half precision, binary, not predicated
2065 class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
2066 InstrItinClass itin, string asm, list<dag> pattern>
2067 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2068 VFPBinaryFrm, itin, asm, "", pattern> {
2069 list<Predicate> Predicates = [HasFullFP16];
2071 // Instruction operands.
2076 let Inst{31-28} = 0b1111;
2078 // Encode instruction operands.
2079 let Inst{3-0} = Sm{4-1};
2080 let Inst{5} = Sm{0};
2081 let Inst{19-16} = Sn{4-1};
2082 let Inst{7} = Sn{0};
2083 let Inst{15-12} = Sd{4-1};
2084 let Inst{22} = Sd{0};
2086 let Inst{27-23} = opcod1;
2087 let Inst{21-20} = opcod2;
2088 let Inst{11-8} = 0b1001; // Half precision
2089 let Inst{6} = opcod3;
2092 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2095 // VFP conversion instructions
2096 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2097 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2099 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
2100 let Inst{27-23} = opcod1;
2101 let Inst{21-20} = opcod2;
2102 let Inst{19-16} = opcod3;
2103 let Inst{11-8} = opcod4;
2108 // VFP conversion between floating-point and fixed-point
2109 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2110 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2112 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2114 // size (fixed-point number): sx == 0 ? 16 : 32
2115 let Inst{7} = op5; // sx
2116 let Inst{5} = fbits{0};
2117 let Inst{3-0} = fbits{4-1};
2120 // VFP conversion instructions, if no NEON
2121 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2122 dag oops, dag iops, InstrItinClass itin,
2123 string opc, string asm, list<dag> pattern>
2124 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2126 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2129 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2130 InstrItinClass itin,
2131 string opc, string asm, list<dag> pattern>
2132 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
2133 let Inst{27-20} = opcod1;
2134 let Inst{11-8} = opcod2;
2138 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2139 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2140 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
2142 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2143 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2144 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2146 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2147 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2148 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
2150 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2151 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2152 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
2154 //===----------------------------------------------------------------------===//
2156 //===----------------------------------------------------------------------===//
2157 // ARM NEON Instruction templates.
2160 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2161 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2163 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2164 let OutOperandList = oops;
2165 let InOperandList = !con(iops, (ins pred:$p));
2166 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2167 let Pattern = pattern;
2168 list<Predicate> Predicates = [HasNEON];
2169 let DecoderNamespace = "NEON";
2172 // Same as NeonI except it does not have a "data type" specifier.
2173 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2174 InstrItinClass itin, string opc, 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}", "\t", asm);
2180 let Pattern = pattern;
2181 list<Predicate> Predicates = [HasNEON];
2182 let DecoderNamespace = "NEON";
2185 // Same as NeonI except it is not predicated
2186 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2187 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2189 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2190 let OutOperandList = oops;
2191 let InOperandList = iops;
2192 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2193 let Pattern = pattern;
2194 list<Predicate> Predicates = [HasNEON];
2195 let DecoderNamespace = "NEON";
2197 let Inst{31-28} = 0b1111;
2200 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2201 dag oops, dag iops, InstrItinClass itin,
2202 string opc, string dt, string asm, string cstr, list<dag> pattern>
2203 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2205 let Inst{31-24} = 0b11110100;
2206 let Inst{23} = op23;
2207 let Inst{21-20} = op21_20;
2208 let Inst{11-8} = op11_8;
2209 let Inst{7-4} = op7_4;
2211 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2212 let DecoderNamespace = "NEONLoadStore";
2218 let Inst{22} = Vd{4};
2219 let Inst{15-12} = Vd{3-0};
2220 let Inst{19-16} = Rn{3-0};
2221 let Inst{3-0} = Rm{3-0};
2224 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2225 dag oops, dag iops, InstrItinClass itin,
2226 string opc, string dt, string asm, string cstr, list<dag> pattern>
2227 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2228 dt, asm, cstr, pattern> {
2232 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2233 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2235 let OutOperandList = oops;
2236 let InOperandList = !con(iops, (ins pred:$p));
2237 list<Predicate> Predicates = [HasNEON];
2240 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2242 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2244 let OutOperandList = oops;
2245 let InOperandList = !con(iops, (ins pred:$p));
2246 let Pattern = pattern;
2247 list<Predicate> Predicates = [HasNEON];
2250 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2251 string opc, string dt, string asm, string cstr, list<dag> pattern>
2252 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2254 let Inst{31-25} = 0b1111001;
2255 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2256 let DecoderNamespace = "NEONData";
2259 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2260 string opc, string asm, string cstr, list<dag> pattern>
2261 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2263 let Inst{31-25} = 0b1111001;
2264 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2265 let DecoderNamespace = "NEONData";
2268 // NEON "one register and a modified immediate" format.
2269 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2271 dag oops, dag iops, InstrItinClass itin,
2272 string opc, string dt, string asm, string cstr,
2274 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2275 let Inst{23} = op23;
2276 let Inst{21-19} = op21_19;
2277 let Inst{11-8} = op11_8;
2283 // Instruction operands.
2287 let Inst{15-12} = Vd{3-0};
2288 let Inst{22} = Vd{4};
2289 let Inst{24} = SIMM{7};
2290 let Inst{18-16} = SIMM{6-4};
2291 let Inst{3-0} = SIMM{3-0};
2292 let DecoderMethod = "DecodeVMOVModImmInstruction";
2295 // NEON 2 vector register format.
2296 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2297 bits<5> op11_7, bit op6, bit op4,
2298 dag oops, dag iops, InstrItinClass itin,
2299 string opc, string dt, string asm, string cstr, list<dag> pattern>
2300 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2301 let Inst{24-23} = op24_23;
2302 let Inst{21-20} = op21_20;
2303 let Inst{19-18} = op19_18;
2304 let Inst{17-16} = op17_16;
2305 let Inst{11-7} = op11_7;
2309 // Instruction operands.
2313 let Inst{15-12} = Vd{3-0};
2314 let Inst{22} = Vd{4};
2315 let Inst{3-0} = Vm{3-0};
2316 let Inst{5} = Vm{4};
2319 // Same as N2V but not predicated.
2320 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2321 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2322 string Dt, list<dag> pattern>
2323 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2324 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2328 // Encode instruction operands
2329 let Inst{22} = Vd{4};
2330 let Inst{15-12} = Vd{3-0};
2331 let Inst{5} = Vm{4};
2332 let Inst{3-0} = Vm{3-0};
2334 // Encode constant bits
2335 let Inst{27-23} = 0b00111;
2336 let Inst{21-20} = 0b11;
2337 let Inst{19-18} = op19_18;
2338 let Inst{17-16} = op17_16;
2340 let Inst{10-8} = op10_8;
2345 let DecoderNamespace = "NEON";
2348 // Same as N2V except it doesn't have a datatype suffix.
2349 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2350 bits<5> op11_7, bit op6, bit op4,
2351 dag oops, dag iops, InstrItinClass itin,
2352 string opc, string asm, string cstr, list<dag> pattern>
2353 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2354 let Inst{24-23} = op24_23;
2355 let Inst{21-20} = op21_20;
2356 let Inst{19-18} = op19_18;
2357 let Inst{17-16} = op17_16;
2358 let Inst{11-7} = op11_7;
2362 // Instruction operands.
2366 let Inst{15-12} = Vd{3-0};
2367 let Inst{22} = Vd{4};
2368 let Inst{3-0} = Vm{3-0};
2369 let Inst{5} = Vm{4};
2372 // NEON 2 vector register with immediate.
2373 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2374 dag oops, dag iops, Format f, InstrItinClass itin,
2375 string opc, string dt, string asm, string cstr, list<dag> pattern>
2376 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2377 let Inst{24} = op24;
2378 let Inst{23} = op23;
2379 let Inst{11-8} = op11_8;
2384 // Instruction operands.
2389 let Inst{15-12} = Vd{3-0};
2390 let Inst{22} = Vd{4};
2391 let Inst{3-0} = Vm{3-0};
2392 let Inst{5} = Vm{4};
2393 let Inst{21-16} = SIMM{5-0};
2396 // NEON 3 vector register format.
2398 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2399 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2400 string opc, string dt, string asm, string cstr,
2402 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2403 let Inst{24} = op24;
2404 let Inst{23} = op23;
2405 let Inst{21-20} = op21_20;
2406 let Inst{11-8} = op11_8;
2411 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2412 dag oops, dag iops, Format f, InstrItinClass itin,
2413 string opc, string dt, string asm, string cstr, list<dag> pattern>
2414 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2415 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2416 // Instruction operands.
2421 let Inst{15-12} = Vd{3-0};
2422 let Inst{22} = Vd{4};
2423 let Inst{19-16} = Vn{3-0};
2424 let Inst{7} = Vn{4};
2425 let Inst{3-0} = Vm{3-0};
2426 let Inst{5} = Vm{4};
2429 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2430 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2431 string OpcodeStr, string Dt, list<dag> pattern>
2432 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2433 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2438 // Encode instruction operands
2439 let Inst{22} = Vd{4};
2440 let Inst{15-12} = Vd{3-0};
2441 let Inst{19-16} = Vn{3-0};
2442 let Inst{7} = Vn{4};
2443 let Inst{5} = Vm{4};
2444 let Inst{3-0} = Vm{3-0};
2446 // Encode constant bits
2447 let Inst{27-23} = op27_23;
2448 let Inst{21-20} = op21_20;
2449 let Inst{11-8} = op11_8;
2454 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2455 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2456 string opc, string dt, string asm, string cstr,
2458 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2459 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2461 // Instruction operands.
2467 let Inst{15-12} = Vd{3-0};
2468 let Inst{22} = Vd{4};
2469 let Inst{19-16} = Vn{3-0};
2470 let Inst{7} = Vn{4};
2471 let Inst{3-0} = Vm{3-0};
2475 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2476 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2477 string opc, string dt, string asm, string cstr,
2479 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2480 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2482 // Instruction operands.
2488 let Inst{15-12} = Vd{3-0};
2489 let Inst{22} = Vd{4};
2490 let Inst{19-16} = Vn{3-0};
2491 let Inst{7} = Vn{4};
2492 let Inst{2-0} = Vm{2-0};
2493 let Inst{5} = lane{1};
2494 let Inst{3} = lane{0};
2497 // Same as N3V except it doesn't have a data type suffix.
2498 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2500 dag oops, dag iops, Format f, InstrItinClass itin,
2501 string opc, string asm, string cstr, list<dag> pattern>
2502 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2503 let Inst{24} = op24;
2504 let Inst{23} = op23;
2505 let Inst{21-20} = op21_20;
2506 let Inst{11-8} = op11_8;
2510 // Instruction operands.
2515 let Inst{15-12} = Vd{3-0};
2516 let Inst{22} = Vd{4};
2517 let Inst{19-16} = Vn{3-0};
2518 let Inst{7} = Vn{4};
2519 let Inst{3-0} = Vm{3-0};
2520 let Inst{5} = Vm{4};
2523 // NEON VMOVs between scalar and core registers.
2524 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2525 dag oops, dag iops, Format f, InstrItinClass itin,
2526 string opc, string dt, string asm, list<dag> pattern>
2527 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2529 let Inst{27-20} = opcod1;
2530 let Inst{11-8} = opcod2;
2531 let Inst{6-5} = opcod3;
2533 // A8.6.303, A8.6.328, A8.6.329
2534 let Inst{3-0} = 0b0000;
2536 let OutOperandList = oops;
2537 let InOperandList = !con(iops, (ins pred:$p));
2538 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2539 let Pattern = pattern;
2540 list<Predicate> Predicates = [HasNEON];
2542 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2543 let DecoderNamespace = "NEONDup";
2550 let Inst{31-28} = p{3-0};
2552 let Inst{19-16} = V{3-0};
2553 let Inst{15-12} = R{3-0};
2555 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2556 dag oops, dag iops, InstrItinClass itin,
2557 string opc, string dt, string asm, list<dag> pattern>
2558 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2559 opc, dt, asm, pattern>;
2560 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2561 dag oops, dag iops, InstrItinClass itin,
2562 string opc, string dt, string asm, list<dag> pattern>
2563 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2564 opc, dt, asm, pattern>;
2565 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2566 dag oops, dag iops, InstrItinClass itin,
2567 string opc, string dt, string asm, list<dag> pattern>
2568 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2569 opc, dt, asm, pattern>;
2571 // Vector Duplicate Lane (from scalar to all elements)
2572 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2573 InstrItinClass itin, string opc, string dt, string asm,
2575 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2576 let Inst{24-23} = 0b11;
2577 let Inst{21-20} = 0b11;
2578 let Inst{19-16} = op19_16;
2579 let Inst{11-7} = 0b11000;
2586 let Inst{22} = Vd{4};
2587 let Inst{15-12} = Vd{3-0};
2588 let Inst{5} = Vm{4};
2589 let Inst{3-0} = Vm{3-0};
2592 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2593 // for single-precision FP.
2594 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2595 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2598 // VFP/NEON Instruction aliases for type suffices.
2599 // Note: When EmitPriority == 1, the alias will be used for printing
2600 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2601 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
2603 // Note: When EmitPriority == 1, the alias will be used for printing
2604 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2605 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2606 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2607 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2608 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2611 // Note: When EmitPriority == 1, the alias will be used for printing
2612 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2613 let Predicates = [HasNEON] in {
2614 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2615 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2616 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2617 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2621 // The same alias classes using AsmPseudo instead, for the more complex
2622 // stuff in NEON that InstAlias can't quite handle.
2623 // Note that we can't use anonymous defm references here like we can
2624 // above, as we care about the ultimate instruction enum names generated, unlike
2625 // for instalias defs.
2626 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2627 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2629 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2630 // encoding space, introduced in ARMv8.3-A.
2631 class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2632 dag oops, dag iops, InstrItinClass itin,
2633 string opc, string dt, string asm, string cstr, list<dag> pattern>
2634 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2635 dt, asm, cstr, pattern> {
2640 let DecoderNamespace = "VFPV8";
2641 // These have the same encodings in ARM and Thumb2
2642 let PostEncoderMethod = "";
2644 let Inst{31-25} = 0b1111110;
2645 let Inst{24-23} = op24_23;
2646 let Inst{22} = Vd{4};
2647 let Inst{21-20} = op21_20;
2648 let Inst{19-16} = Vn{3-0};
2649 let Inst{15-12} = Vd{3-0};
2650 let Inst{11-8} = 0b1000;
2651 let Inst{7} = Vn{4};
2653 let Inst{5} = Vm{4};
2655 let Inst{3-0} = Vm{3-0};
2658 // Extension of NEON 2-vector-and-scalar data processing instructions in
2659 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2660 class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2661 dag oops, dag iops, InstrItinClass itin,
2662 string opc, string dt, string asm, string cstr, list<dag> pattern>
2663 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2664 dt, asm, cstr, pattern> {
2669 let DecoderNamespace = "VFPV8";
2670 // These have the same encodings in ARM and Thumb2
2671 let PostEncoderMethod = "";
2673 let Inst{31-24} = 0b11111110;
2674 let Inst{23} = op23;
2675 let Inst{22} = Vd{4};
2676 let Inst{21-20} = op21_20;
2677 let Inst{19-16} = Vn{3-0};
2678 let Inst{15-12} = Vd{3-0};
2679 let Inst{11-8} = 0b1000;
2680 let Inst{7} = Vn{4};
2682 // Bit 5 set by sub-classes
2684 let Inst{3-0} = Vm{3-0};
2687 // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
2689 // if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
2690 // if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
2691 // Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
2692 class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2693 dag oops, dag iops, InstrItinClass itin,
2694 string opc, string dt, string asm, string cstr, list<dag> pattern>
2695 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
2700 let DecoderNamespace = "VFPV8";
2701 // These have the same encodings in ARM and Thumb2
2702 let PostEncoderMethod = "";
2704 let Inst{31-25} = 0b1111110;
2705 let Inst{24-23} = op24_23;
2706 let Inst{22} = Vd{4};
2707 let Inst{21-20} = op21_20;
2708 let Inst{19-16} = Vn{4-1};
2709 let Inst{15-12} = Vd{3-0};
2710 let Inst{11-8} = 0b1000;
2711 let Inst{7} = Vn{0};
2713 let Inst{5} = Vm{0};
2715 let Inst{3-0} = Vm{4-1};
2718 // Operand types for complex instructions
2719 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2721 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2722 let DiagnosticString = "complex rotation must be " # Diag;
2723 let Name = "ComplexRotation" # Type;
2725 def complexrotateop : Operand<i32> {
2726 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2727 let PrintMethod = "printComplexRotationOp<90, 0>";
2729 def complexrotateopodd : Operand<i32> {
2730 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2731 let PrintMethod = "printComplexRotationOp<180, 90>";
2734 def MveSaturateOperand : AsmOperandClass {
2735 let PredicateMethod = "isMveSaturateOp";
2736 let DiagnosticString = "saturate operand must be 48 or 64";
2737 let Name = "MveSaturate";
2739 def saturateop : Operand<i32> {
2740 let ParserMatchClass = MveSaturateOperand;
2741 let PrintMethod = "printMveSaturateOp";
2744 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2745 def : TokenAlias<".s8", ".i8">;
2746 def : TokenAlias<".u8", ".i8">;
2747 def : TokenAlias<".s16", ".i16">;
2748 def : TokenAlias<".u16", ".i16">;
2749 def : TokenAlias<".s32", ".i32">;
2750 def : TokenAlias<".u32", ".i32">;
2751 def : TokenAlias<".s64", ".i64">;
2752 def : TokenAlias<".u64", ".i64">;
2754 def : TokenAlias<".i8", ".8">;
2755 def : TokenAlias<".i16", ".16">;
2756 def : TokenAlias<".i32", ".32">;
2757 def : TokenAlias<".i64", ".64">;
2759 def : TokenAlias<".p8", ".8">;
2760 def : TokenAlias<".p16", ".16">;
2762 def : TokenAlias<".f32", ".32">;
2763 def : TokenAlias<".f64", ".64">;
2764 def : TokenAlias<".f", ".f32">;
2765 def : TokenAlias<".d", ".f64">;