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";
193 def VPTPredNOperand : AsmOperandClass {
194 let Name = "VPTPredN";
195 let PredicateMethod = "isVPTPred";
197 def VPTPredROperand : AsmOperandClass {
198 let Name = "VPTPredR";
199 let PredicateMethod = "isVPTPred";
201 def undef_tied_input;
203 // Operand classes for the cluster of MC operands describing a
204 // VPT-predicated MVE instruction.
206 // There are two of these classes. Both of them have the same first
209 // $cond (an integer) indicates the instruction's predication status:
210 // * ARMVCC::None means it's unpredicated
211 // * ARMVCC::Then means it's in a VPT block and appears with the T suffix
212 // * ARMVCC::Else means it's in a VPT block and appears with the E suffix.
213 // During code generation, unpredicated and predicated instructions
214 // are indicated by setting this parameter to 'None' or to 'Then'; the
215 // third value 'Else' is only used for assembly and disassembly.
217 // $cond_reg (type VCCR) gives the input predicate register. This is
218 // always either zero_reg or VPR, but needs to be modelled as an
219 // explicit operand so that it can be register-allocated and spilled
220 // when these operands are used in code generation).
222 // For 'vpred_r', there's an extra operand $inactive, which specifies
223 // the vector register which will supply any lanes of the output
224 // register that the predication mask prevents from being written by
225 // this instruction. It's always tied to the actual output register
226 // (i.e. must be allocated into the same physical reg), but again,
227 // code generation will need to model it as a separate input value.
229 // 'vpred_n' doesn't have that extra operand: it only has $cond and
230 // $cond_reg. This variant is used for any instruction that can't, or
231 // doesn't want to, tie $inactive to the output register. Sometimes
232 // that's because another input parameter is already tied to it (e.g.
233 // instructions that both read and write their Qd register even when
234 // unpredicated, either because they only partially overwrite it like
235 // a narrowing integer conversion, or simply because the instruction
236 // encoding doesn't have enough register fields to make the output
237 // independent of all inputs). It can also be because the instruction
238 // is defined to set disabled output lanes to zero rather than leaving
239 // them unchanged (vector loads), or because it doesn't output a
240 // vector register at all (stores, compares). In any of these
241 // situations it's unnecessary to have an extra operand tied to the
242 // output, and inconvenient to leave it there unused.
244 // Base class for both kinds of vpred.
245 class vpred_ops<dag extra_op, dag extra_mi> : OperandWithDefaultOps<OtherVT,
246 !con((ops (i32 0), (i32 zero_reg)), extra_op)> {
247 let PrintMethod = "printVPTPredicateOperand";
248 let OperandNamespace = "ARM";
249 let MIOperandInfo = !con((ops i32imm:$cond, VCCR:$cond_reg), extra_mi);
251 // For convenience, we provide a string value that can be appended
252 // to the constraints string. It's empty for vpred_n, and for
253 // vpred_r it ties the $inactive operand to the output q-register
254 // (which by convention will be called $Qd).
255 string vpred_constraint;
258 def vpred_r : vpred_ops<(ops (v4i32 undef_tied_input)), (ops MQPR:$inactive)> {
259 let ParserMatchClass = VPTPredROperand;
260 let OperandType = "OPERAND_VPRED_R";
261 let DecoderMethod = "DecodeVpredROperand";
262 let vpred_constraint = ",$Qd = $vp.inactive";
265 def vpred_n : vpred_ops<(ops), (ops)> {
266 let ParserMatchClass = VPTPredNOperand;
267 let OperandType = "OPERAND_VPRED_N";
268 let vpred_constraint = "";
271 // ARM special operands for disassembly only.
273 def SetEndAsmOperand : ImmAsmOperand<0,1> {
274 let Name = "SetEndImm";
275 let ParserMethod = "parseSetEndImm";
277 def setend_op : Operand<i32> {
278 let PrintMethod = "printSetendOperand";
279 let ParserMatchClass = SetEndAsmOperand;
282 def MSRMaskOperand : AsmOperandClass {
283 let Name = "MSRMask";
284 let ParserMethod = "parseMSRMaskOperand";
286 def msr_mask : Operand<i32> {
287 let PrintMethod = "printMSRMaskOperand";
288 let DecoderMethod = "DecodeMSRMask";
289 let ParserMatchClass = MSRMaskOperand;
292 def BankedRegOperand : AsmOperandClass {
293 let Name = "BankedReg";
294 let ParserMethod = "parseBankedRegOperand";
296 def banked_reg : Operand<i32> {
297 let PrintMethod = "printBankedRegOperand";
298 let DecoderMethod = "DecodeBankedReg";
299 let ParserMatchClass = BankedRegOperand;
302 // Shift Right Immediate - A shift right immediate is encoded differently from
303 // other shift immediates. The imm6 field is encoded like so:
306 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
307 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
308 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
309 // 64 64 - <imm> is encoded in imm6<5:0>
310 def shr_imm8_asm_operand : ImmAsmOperand<1,8> { let Name = "ShrImm8"; }
311 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
312 let EncoderMethod = "getShiftRight8Imm";
313 let DecoderMethod = "DecodeShiftRight8Imm";
314 let ParserMatchClass = shr_imm8_asm_operand;
316 def shr_imm16_asm_operand : ImmAsmOperand<1,16> { let Name = "ShrImm16"; }
317 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
318 let EncoderMethod = "getShiftRight16Imm";
319 let DecoderMethod = "DecodeShiftRight16Imm";
320 let ParserMatchClass = shr_imm16_asm_operand;
322 def shr_imm32_asm_operand : ImmAsmOperand<1,32> { let Name = "ShrImm32"; }
323 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
324 let EncoderMethod = "getShiftRight32Imm";
325 let DecoderMethod = "DecodeShiftRight32Imm";
326 let ParserMatchClass = shr_imm32_asm_operand;
328 def shr_imm64_asm_operand : ImmAsmOperand<1,64> { let Name = "ShrImm64"; }
329 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
330 let EncoderMethod = "getShiftRight64Imm";
331 let DecoderMethod = "DecodeShiftRight64Imm";
332 let ParserMatchClass = shr_imm64_asm_operand;
336 // ARM Assembler operand for ldr Rd, =expression which generates an offset
337 // to a constant pool entry or a MOV depending on the value of expression
338 def const_pool_asm_operand : AsmOperandClass { let Name = "ConstPoolAsmImm"; }
339 def const_pool_asm_imm : Operand<i32> {
340 let ParserMatchClass = const_pool_asm_operand;
344 //===----------------------------------------------------------------------===//
345 // ARM Assembler alias templates.
347 // Note: When EmitPriority == 1, the alias will be used for printing
348 class ARMInstAlias<string Asm, dag Result, bit EmitPriority = 0>
349 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsARM]>;
350 class ARMInstSubst<string Asm, dag Result, bit EmitPriority = 0>
351 : InstAlias<Asm, Result, EmitPriority>,
352 Requires<[IsARM,UseNegativeImmediates]>;
353 class tInstAlias<string Asm, dag Result, bit EmitPriority = 0>
354 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb]>;
355 class tInstSubst<string Asm, dag Result, bit EmitPriority = 0>
356 : InstAlias<Asm, Result, EmitPriority>,
357 Requires<[IsThumb,UseNegativeImmediates]>;
358 class t2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
359 : InstAlias<Asm, Result, EmitPriority>, Requires<[IsThumb2]>;
360 class t2InstSubst<string Asm, dag Result, bit EmitPriority = 0>
361 : InstAlias<Asm, Result, EmitPriority>,
362 Requires<[IsThumb2,UseNegativeImmediates]>;
363 class VFP2InstAlias<string Asm, dag Result, bit EmitPriority = 0>
364 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2]>;
365 class VFP2DPInstAlias<string Asm, dag Result, bit EmitPriority = 0>
366 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP2,HasDPVFP]>;
367 class VFP3InstAlias<string Asm, dag Result, bit EmitPriority = 0>
368 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasVFP3]>;
369 class NEONInstAlias<string Asm, dag Result, bit EmitPriority = 0>
370 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasNEON]>;
371 class MVEInstAlias<string Asm, dag Result, bit EmitPriority = 1>
372 : InstAlias<Asm, Result, EmitPriority>, Requires<[HasMVEInt, IsThumb]>;
375 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
377 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
380 //===----------------------------------------------------------------------===//
381 // ARM Instruction templates.
385 class InstTemplate<AddrMode am, int sz, IndexMode im,
386 Format f, Domain d, string cstr, InstrItinClass itin>
388 let Namespace = "ARM";
393 bits<2> IndexModeBits = IM.Value;
395 bits<6> Form = F.Value;
397 bit isUnaryDataProc = 0;
398 bit canXformTo16Bit = 0;
399 // The instruction is a 16-bit flag setting Thumb instruction. Used
400 // by the parser to determine whether to require the 'S' suffix on the
401 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
402 bit thumbArithFlagSetting = 0;
404 // If this is a pseudo instruction, mark it isCodeGenOnly.
405 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
407 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
408 let TSFlags{4-0} = AM.Value;
409 let TSFlags{6-5} = IndexModeBits;
410 let TSFlags{12-7} = Form;
411 let TSFlags{13} = isUnaryDataProc;
412 let TSFlags{14} = canXformTo16Bit;
413 let TSFlags{18-15} = D.Value;
414 let TSFlags{19} = thumbArithFlagSetting;
416 let Constraints = cstr;
417 let Itinerary = itin;
422 // Mask of bits that cause an encoding to be UNPREDICTABLE.
423 // If a bit is set, then if the corresponding bit in the
424 // target encoding differs from its value in the "Inst" field,
425 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
426 field bits<32> Unpredictable = 0;
427 // SoftFail is the generic name for this field, but we alias it so
428 // as to make it more obvious what it means in ARM-land.
429 field bits<32> SoftFail = Unpredictable;
432 class InstARM<AddrMode am, int sz, IndexMode im,
433 Format f, Domain d, string cstr, InstrItinClass itin>
434 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
435 let DecoderNamespace = "ARM";
438 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
439 // on by adding flavors to specific instructions.
440 class InstThumb<AddrMode am, int sz, IndexMode im,
441 Format f, Domain d, string cstr, InstrItinClass itin>
442 : InstTemplate<am, sz, im, f, d, cstr, itin> {
443 let DecoderNamespace = "Thumb";
446 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
447 // These are aliases that require C++ handling to convert to the target
448 // instruction, while InstAliases can be handled directly by tblgen.
449 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
450 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
452 let OutOperandList = oops;
453 let InOperandList = iops;
455 let isCodeGenOnly = 0; // So we get asm matcher for it.
460 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
461 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
462 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
463 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
464 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
465 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
466 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
467 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
468 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
469 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
470 class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
471 : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
473 // Pseudo instructions for the code generator.
474 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
475 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
476 GenericDomain, "", itin> {
477 let OutOperandList = oops;
478 let InOperandList = iops;
479 let Pattern = pattern;
480 let isCodeGenOnly = 1;
484 // PseudoInst that's ARM-mode only.
485 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
487 : PseudoInst<oops, iops, itin, pattern> {
489 list<Predicate> Predicates = [IsARM];
492 // PseudoInst that's Thumb-mode only.
493 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
495 : PseudoInst<oops, iops, itin, pattern> {
497 list<Predicate> Predicates = [IsThumb];
500 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
501 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
503 : PseudoInst<oops, iops, itin, pattern> {
505 list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
508 // PseudoInst that's Thumb2-mode only.
509 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
511 : PseudoInst<oops, iops, itin, pattern> {
513 list<Predicate> Predicates = [IsThumb2];
516 class ARMPseudoExpand<dag oops, dag iops, int sz,
517 InstrItinClass itin, list<dag> pattern,
519 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
520 PseudoInstExpansion<Result>;
522 class tPseudoExpand<dag oops, dag iops, int sz,
523 InstrItinClass itin, list<dag> pattern,
525 : tPseudoInst<oops, iops, sz, itin, pattern>,
526 PseudoInstExpansion<Result>;
528 class t2PseudoExpand<dag oops, dag iops, int sz,
529 InstrItinClass itin, list<dag> pattern,
531 : t2PseudoInst<oops, iops, sz, itin, pattern>,
532 PseudoInstExpansion<Result>;
534 // Almost all ARM instructions are predicable.
535 class I<dag oops, dag iops, AddrMode am, int sz,
536 IndexMode im, Format f, InstrItinClass itin,
537 string opc, string asm, string cstr,
539 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
542 let OutOperandList = oops;
543 let InOperandList = !con(iops, (ins pred:$p));
544 let AsmString = !strconcat(opc, "${p}", asm);
545 let Pattern = pattern;
546 list<Predicate> Predicates = [IsARM];
549 // A few are not predicable
550 class InoP<dag oops, dag iops, AddrMode am, int sz,
551 IndexMode im, Format f, InstrItinClass itin,
552 string opc, string asm, string cstr,
554 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
555 let OutOperandList = oops;
556 let InOperandList = iops;
557 let AsmString = !strconcat(opc, asm);
558 let Pattern = pattern;
559 let isPredicable = 0;
560 list<Predicate> Predicates = [IsARM];
563 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
564 // operand since by default it's a zero register. It will become an implicit def
565 // once it's "flipped".
566 class sI<dag oops, dag iops, AddrMode am, int sz,
567 IndexMode im, Format f, InstrItinClass itin,
568 string opc, string asm, string cstr,
570 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
571 bits<4> p; // Predicate operand
572 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
576 let OutOperandList = oops;
577 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
578 let AsmString = !strconcat(opc, "${s}${p}", asm);
579 let Pattern = pattern;
580 list<Predicate> Predicates = [IsARM];
584 class XI<dag oops, dag iops, AddrMode am, int sz,
585 IndexMode im, Format f, InstrItinClass itin,
586 string asm, string cstr, list<dag> pattern>
587 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
588 let OutOperandList = oops;
589 let InOperandList = iops;
591 let Pattern = pattern;
592 list<Predicate> Predicates = [IsARM];
595 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
596 string opc, string asm, list<dag> pattern>
597 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
598 opc, asm, "", pattern>;
599 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
600 string opc, string asm, list<dag> pattern>
601 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
602 opc, asm, "", pattern>;
603 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
604 string asm, list<dag> pattern>
605 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
607 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
608 string asm, list<dag> pattern>
609 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
611 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
612 string opc, string asm, list<dag> pattern>
613 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
614 opc, asm, "", pattern>;
616 // Ctrl flow instructions
617 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
618 string opc, string asm, list<dag> pattern>
619 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
620 opc, asm, "", pattern> {
621 let Inst{27-24} = opcod;
623 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
624 string asm, list<dag> pattern>
625 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
627 let Inst{27-24} = opcod;
630 // BR_JT instructions
631 class JTI<dag oops, dag iops, InstrItinClass itin,
632 string asm, list<dag> pattern>
633 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
636 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
637 string opc, string asm, list<dag> pattern>
638 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
639 opc, asm, "", pattern> {
642 let Inst{27-23} = 0b00011;
643 let Inst{22-21} = opcod;
645 let Inst{19-16} = addr;
646 let Inst{15-12} = Rt;
647 let Inst{11-10} = 0b11;
648 let Inst{9-8} = opcod2;
649 let Inst{7-0} = 0b10011111;
651 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
652 string opc, string asm, list<dag> pattern>
653 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
654 opc, asm, "", pattern> {
657 let Inst{27-23} = 0b00011;
658 let Inst{22-21} = opcod;
660 let Inst{19-16} = addr;
661 let Inst{11-10} = 0b11;
662 let Inst{9-8} = opcod2;
663 let Inst{7-4} = 0b1001;
666 // Atomic load/store instructions
667 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
668 string opc, string asm, list<dag> pattern>
669 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
671 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
672 string opc, string asm, list<dag> pattern>
673 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
675 let Inst{15-12} = Rd;
678 // Exclusive load/store instructions
680 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
681 string opc, string asm, list<dag> pattern>
682 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
683 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
685 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
686 string opc, string asm, list<dag> pattern>
687 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
688 Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
690 let Inst{15-12} = Rd;
693 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
694 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
698 let Inst{27-23} = 0b00010;
700 let Inst{21-20} = 0b00;
701 let Inst{19-16} = addr;
702 let Inst{15-12} = Rt;
703 let Inst{11-4} = 0b00001001;
706 let Unpredictable{11-8} = 0b1111;
707 let DecoderMethod = "DecodeSwap";
709 // Acquire/Release load/store instructions
710 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
711 string opc, string asm, list<dag> pattern>
712 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
713 Requires<[IsARM, HasAcquireRelease]>;
715 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
716 string opc, string asm, list<dag> pattern>
717 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
718 Requires<[IsARM, HasAcquireRelease]> {
719 let Inst{15-12} = 0b1111;
722 // addrmode1 instructions
723 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
724 string opc, string asm, list<dag> pattern>
725 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
726 opc, asm, "", pattern> {
727 let Inst{24-21} = opcod;
728 let Inst{27-26} = 0b00;
730 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
731 string opc, string asm, list<dag> pattern>
732 : sI<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 AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
738 string asm, list<dag> pattern>
739 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
741 let Inst{24-21} = opcod;
742 let Inst{27-26} = 0b00;
747 // LDR/LDRB/STR/STRB/...
748 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
749 Format f, InstrItinClass itin, string opc, string asm,
751 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
753 let Inst{27-25} = op;
754 let Inst{24} = 1; // 24 == P
756 let Inst{22} = isByte;
757 let Inst{21} = 0; // 21 == W
760 // Indexed load/stores
761 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
762 IndexMode im, Format f, InstrItinClass itin, string opc,
763 string asm, string cstr, list<dag> pattern>
764 : I<oops, iops, AddrMode2, 4, im, f, itin,
765 opc, asm, cstr, pattern> {
767 let Inst{27-26} = 0b01;
768 let Inst{24} = isPre; // P bit
769 let Inst{22} = isByte; // B bit
770 let Inst{21} = isPre; // W bit
771 let Inst{20} = isLd; // L bit
772 let Inst{15-12} = Rt;
774 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
775 IndexMode im, Format f, InstrItinClass itin, string opc,
776 string asm, string cstr, list<dag> pattern>
777 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
779 // AM2 store w/ two operands: (GPR, am2offset)
785 let Inst{23} = offset{12};
786 let Inst{19-16} = Rn;
787 let Inst{11-5} = offset{11-5};
789 let Inst{3-0} = offset{3-0};
792 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
793 IndexMode im, Format f, InstrItinClass itin, string opc,
794 string asm, string cstr, list<dag> pattern>
795 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
797 // AM2 store w/ two operands: (GPR, am2offset)
803 let Inst{23} = offset{12};
804 let Inst{19-16} = Rn;
805 let Inst{11-0} = offset{11-0};
809 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
810 // but for now use this class for STRT and STRBT.
811 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
812 IndexMode im, Format f, InstrItinClass itin, string opc,
813 string asm, string cstr, list<dag> pattern>
814 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
816 // AM2 store w/ two operands: (GPR, am2offset)
818 // {13} 1 == Rm, 0 == imm12
822 let Inst{25} = addr{13};
823 let Inst{23} = addr{12};
824 let Inst{19-16} = addr{17-14};
825 let Inst{11-0} = addr{11-0};
828 // addrmode3 instructions
829 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
830 InstrItinClass itin, string opc, string asm, list<dag> pattern>
831 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
832 opc, asm, "", pattern> {
835 let Inst{27-25} = 0b000;
836 let Inst{24} = 1; // P bit
837 let Inst{23} = addr{8}; // U bit
838 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
839 let Inst{21} = 0; // W bit
840 let Inst{20} = op20; // L bit
841 let Inst{19-16} = addr{12-9}; // Rn
842 let Inst{15-12} = Rt; // Rt
843 let Inst{11-8} = addr{7-4}; // imm7_4/zero
845 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
847 let DecoderMethod = "DecodeAddrMode3Instruction";
850 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
851 IndexMode im, Format f, InstrItinClass itin, string opc,
852 string asm, string cstr, list<dag> pattern>
853 : I<oops, iops, AddrMode3, 4, im, f, itin,
854 opc, asm, cstr, pattern> {
856 let Inst{27-25} = 0b000;
857 let Inst{24} = isPre; // P bit
858 let Inst{21} = isPre; // W bit
859 let Inst{20} = op20; // L bit
860 let Inst{15-12} = Rt; // Rt
864 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
865 // but for now use this class for LDRSBT, LDRHT, LDSHT.
866 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
867 IndexMode im, Format f, InstrItinClass itin, string opc,
868 string asm, string cstr, list<dag> pattern>
869 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
870 // {13} 1 == imm8, 0 == Rm
877 let Inst{27-25} = 0b000;
878 let Inst{24} = 0; // P bit
880 let Inst{20} = isLoad; // L bit
881 let Inst{19-16} = addr; // Rn
882 let Inst{15-12} = Rt; // Rt
887 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
888 string opc, string asm, list<dag> pattern>
889 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
890 opc, asm, "", pattern> {
893 let Inst{27-25} = 0b000;
894 let Inst{24} = 1; // P bit
895 let Inst{23} = addr{8}; // U bit
896 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
897 let Inst{21} = 0; // W bit
898 let Inst{20} = 0; // L bit
899 let Inst{19-16} = addr{12-9}; // Rn
900 let Inst{15-12} = Rt; // Rt
901 let Inst{11-8} = addr{7-4}; // imm7_4/zero
903 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
904 let DecoderMethod = "DecodeAddrMode3Instruction";
907 // addrmode4 instructions
908 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
909 string asm, string cstr, list<dag> pattern>
910 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
915 let Inst{27-25} = 0b100;
916 let Inst{22} = 0; // S bit
917 let Inst{19-16} = Rn;
918 let Inst{15-0} = regs;
921 // Unsigned multiply, multiply-accumulate instructions.
922 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
923 string opc, string asm, list<dag> pattern>
924 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
925 opc, asm, "", pattern> {
926 let Inst{7-4} = 0b1001;
927 let Inst{20} = 0; // S bit
928 let Inst{27-21} = opcod;
930 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
931 string opc, string asm, list<dag> pattern>
932 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
933 opc, asm, "", pattern> {
934 let Inst{7-4} = 0b1001;
935 let Inst{27-21} = opcod;
938 // Most significant word multiply
939 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
940 InstrItinClass itin, string opc, string asm, list<dag> pattern>
941 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
942 opc, asm, "", pattern> {
946 let Inst{7-4} = opc7_4;
948 let Inst{27-21} = opcod;
949 let Inst{19-16} = Rd;
953 // MSW multiple w/ Ra operand
954 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
955 InstrItinClass itin, string opc, string asm, list<dag> pattern>
956 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
958 let Inst{15-12} = Ra;
961 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
962 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
963 InstrItinClass itin, string opc, string asm, list<dag> pattern>
964 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
965 opc, asm, "", pattern> {
971 let Inst{27-21} = opcod;
972 let Inst{6-5} = bit6_5;
976 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
977 InstrItinClass itin, string opc, string asm, list<dag> pattern>
978 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
980 let Inst{19-16} = Rd;
983 // AMulxyI with Ra operand
984 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
985 InstrItinClass itin, string opc, string asm, list<dag> pattern>
986 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
988 let Inst{15-12} = Ra;
991 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
992 InstrItinClass itin, string opc, string asm, list<dag> pattern>
993 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
996 let Inst{19-16} = RdHi;
997 let Inst{15-12} = RdLo;
1000 // Extend instructions.
1001 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1002 string opc, string asm, list<dag> pattern>
1003 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
1004 opc, asm, "", pattern> {
1005 // All AExtI instructions have Rd and Rm register operands.
1008 let Inst{15-12} = Rd;
1010 let Inst{7-4} = 0b0111;
1011 let Inst{9-8} = 0b00;
1012 let Inst{27-20} = opcod;
1014 let Unpredictable{9-8} = 0b11;
1017 // Misc Arithmetic instructions.
1018 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1019 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1020 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1021 opc, asm, "", pattern> {
1024 let Inst{27-20} = opcod;
1025 let Inst{19-16} = 0b1111;
1026 let Inst{15-12} = Rd;
1027 let Inst{11-8} = 0b1111;
1028 let Inst{7-4} = opc7_4;
1032 // Division instructions.
1033 class ADivA1I<bits<3> opcod, dag oops, dag iops,
1034 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1035 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1036 opc, asm, "", pattern> {
1040 let Inst{27-23} = 0b01110;
1041 let Inst{22-20} = opcod;
1042 let Inst{19-16} = Rd;
1043 let Inst{15-12} = 0b1111;
1044 let Inst{11-8} = Rm;
1045 let Inst{7-4} = 0b0001;
1050 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
1051 let Name = "PKHLSLImm";
1052 let ParserMethod = "parsePKHLSLImm";
1054 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1055 let PrintMethod = "printPKHLSLShiftImm";
1056 let ParserMatchClass = PKHLSLAsmOperand;
1058 def PKHASRAsmOperand : AsmOperandClass {
1059 let Name = "PKHASRImm";
1060 let ParserMethod = "parsePKHASRImm";
1062 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1063 let PrintMethod = "printPKHASRShiftImm";
1064 let ParserMatchClass = PKHASRAsmOperand;
1067 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1068 string opc, string asm, list<dag> pattern>
1069 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1070 opc, asm, "", pattern> {
1075 let Inst{27-20} = opcod;
1076 let Inst{19-16} = Rn;
1077 let Inst{15-12} = Rd;
1078 let Inst{11-7} = sh;
1080 let Inst{5-4} = 0b01;
1084 //===----------------------------------------------------------------------===//
1086 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1087 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1088 list<Predicate> Predicates = [IsARM];
1090 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1091 list<Predicate> Predicates = [IsARM, HasV5T];
1093 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1094 list<Predicate> Predicates = [IsARM, HasV5TE];
1096 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1097 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1098 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1100 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1101 list<Predicate> Predicates = [IsARM, HasV6];
1103 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1104 list<Predicate> Predicates = [HasVFP2];
1106 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1107 list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1109 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1110 list<Predicate> Predicates = [IsThumb2, HasDSP];
1112 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1113 list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1115 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1116 list<Predicate> Predicates = [HasFP16];
1118 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1119 list<Predicate> Predicates = [HasFullFP16];
1121 //===----------------------------------------------------------------------===//
1122 // Thumb Instruction Format Definitions.
1125 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1126 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1127 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1128 let OutOperandList = oops;
1129 let InOperandList = iops;
1130 let AsmString = asm;
1131 let Pattern = pattern;
1132 list<Predicate> Predicates = [IsThumb];
1135 // TI - Thumb instruction.
1136 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1137 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1139 // Two-address instructions
1140 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1142 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1145 // tBL, tBX 32-bit instructions
1146 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1147 dag oops, dag iops, InstrItinClass itin, string asm,
1149 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1151 let Inst{31-27} = opcod1;
1152 let Inst{15-14} = opcod2;
1153 let Inst{12} = opcod3;
1156 // BR_JT instructions
1157 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1159 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1162 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1163 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1164 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1165 let OutOperandList = oops;
1166 let InOperandList = iops;
1167 let AsmString = asm;
1168 let Pattern = pattern;
1169 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1172 class T1I<dag oops, dag iops, InstrItinClass itin,
1173 string asm, list<dag> pattern>
1174 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1175 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1176 string asm, list<dag> pattern>
1177 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1179 // Two-address instructions
1180 class T1It<dag oops, dag iops, InstrItinClass itin,
1181 string asm, string cstr, list<dag> pattern>
1182 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1183 asm, cstr, pattern>;
1185 // Thumb1 instruction that can either be predicated or set CPSR.
1186 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1187 InstrItinClass itin,
1188 string opc, string asm, string cstr, list<dag> pattern>
1189 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1190 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1191 let InOperandList = !con(iops, (ins pred:$p));
1192 let AsmString = !strconcat(opc, "${s}${p}", asm);
1193 let Pattern = pattern;
1194 let thumbArithFlagSetting = 1;
1195 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1196 let DecoderNamespace = "ThumbSBit";
1199 class T1sI<dag oops, dag iops, InstrItinClass itin,
1200 string opc, string asm, list<dag> pattern>
1201 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1203 // Two-address instructions
1204 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1205 string opc, string asm, list<dag> pattern>
1206 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1207 "$Rn = $Rdn", pattern>;
1209 // Thumb1 instruction that can be predicated.
1210 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1211 InstrItinClass itin,
1212 string opc, string asm, string cstr, list<dag> pattern>
1213 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1214 let OutOperandList = oops;
1215 let InOperandList = !con(iops, (ins pred:$p));
1216 let AsmString = !strconcat(opc, "${p}", asm);
1217 let Pattern = pattern;
1218 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1221 class T1pI<dag oops, dag iops, InstrItinClass itin,
1222 string opc, string asm, list<dag> pattern>
1223 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1225 // Two-address instructions
1226 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1227 string opc, string asm, list<dag> pattern>
1228 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1229 "$Rn = $Rdn", pattern>;
1231 class T1pIs<dag oops, dag iops,
1232 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1233 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1235 class Encoding16 : Encoding {
1236 let Inst{31-16} = 0x0000;
1239 // A6.2 16-bit Thumb instruction encoding
1240 class T1Encoding<bits<6> opcode> : Encoding16 {
1241 let Inst{15-10} = opcode;
1244 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1245 class T1General<bits<5> opcode> : Encoding16 {
1246 let Inst{15-14} = 0b00;
1247 let Inst{13-9} = opcode;
1250 // A6.2.2 Data-processing encoding.
1251 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1252 let Inst{15-10} = 0b010000;
1253 let Inst{9-6} = opcode;
1256 // A6.2.3 Special data instructions and branch and exchange encoding.
1257 class T1Special<bits<4> opcode> : Encoding16 {
1258 let Inst{15-10} = 0b010001;
1259 let Inst{9-6} = opcode;
1262 // A6.2.4 Load/store single data item encoding.
1263 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1264 let Inst{15-12} = opA;
1265 let Inst{11-9} = opB;
1267 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1269 class T1BranchCond<bits<4> opcode> : Encoding16 {
1270 let Inst{15-12} = opcode;
1273 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1274 // following bits are used for "opA" (see A6.2.4):
1276 // 0b0110 => Immediate, 4 bytes
1277 // 0b1000 => Immediate, 2 bytes
1278 // 0b0111 => Immediate, 1 byte
1279 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1280 InstrItinClass itin, string opc, string asm,
1282 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1283 T1LoadStore<0b0101, opcode> {
1286 let Inst{8-6} = addr{5-3}; // Rm
1287 let Inst{5-3} = addr{2-0}; // Rn
1290 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1291 InstrItinClass itin, string opc, string asm,
1293 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1294 T1LoadStore<opA, {opB,?,?}> {
1297 let Inst{10-6} = addr{7-3}; // imm5
1298 let Inst{5-3} = addr{2-0}; // Rn
1302 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1303 class T1Misc<bits<7> opcode> : Encoding16 {
1304 let Inst{15-12} = 0b1011;
1305 let Inst{11-5} = opcode;
1308 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1309 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1310 InstrItinClass itin,
1311 string opc, string asm, string cstr, list<dag> pattern>
1312 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1313 let OutOperandList = oops;
1314 let InOperandList = !con(iops, (ins pred:$p));
1315 let AsmString = !strconcat(opc, "${p}", asm);
1316 let Pattern = pattern;
1317 list<Predicate> Predicates = [IsThumb2];
1318 let DecoderNamespace = "Thumb2";
1321 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1322 // input operand since by default it's a zero register. It will become an
1323 // implicit def once it's "flipped".
1325 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1327 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1328 InstrItinClass itin,
1329 string opc, string asm, string cstr, list<dag> pattern>
1330 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1331 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1334 let OutOperandList = oops;
1335 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1336 let AsmString = !strconcat(opc, "${s}${p}", asm);
1337 let Pattern = pattern;
1338 list<Predicate> Predicates = [IsThumb2];
1339 let DecoderNamespace = "Thumb2";
1343 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1344 InstrItinClass itin,
1345 string asm, string cstr, list<dag> pattern>
1346 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1347 let OutOperandList = oops;
1348 let InOperandList = iops;
1349 let AsmString = asm;
1350 let Pattern = pattern;
1351 list<Predicate> Predicates = [IsThumb2];
1352 let DecoderNamespace = "Thumb2";
1355 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1356 InstrItinClass itin,
1357 string asm, string cstr, list<dag> pattern>
1358 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1359 let OutOperandList = oops;
1360 let InOperandList = iops;
1361 let AsmString = asm;
1362 let Pattern = pattern;
1363 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1364 let DecoderNamespace = "Thumb";
1367 class T2I<dag oops, dag iops, InstrItinClass itin,
1368 string opc, string asm, list<dag> pattern>
1369 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1370 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1371 string opc, string asm, list<dag> pattern>
1372 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1373 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1374 string opc, string asm, list<dag> pattern>
1375 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1376 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1377 string opc, string asm, list<dag> pattern>
1378 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1379 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1380 string opc, string asm, list<dag> pattern>
1381 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1382 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1383 string opc, string asm, string cstr, list<dag> pattern>
1384 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1389 let Inst{31-25} = 0b1110100;
1391 let Inst{23} = addr{8};
1394 let Inst{20} = isLoad;
1395 let Inst{19-16} = addr{12-9};
1396 let Inst{15-12} = Rt{3-0};
1397 let Inst{11-8} = Rt2{3-0};
1398 let Inst{7-0} = addr{7-0};
1400 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1401 InstrItinClass itin, string opc, string asm, string cstr,
1403 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1409 let Inst{31-25} = 0b1110100;
1411 let Inst{23} = imm{8};
1414 let Inst{20} = isLoad;
1415 let Inst{19-16} = addr;
1416 let Inst{15-12} = Rt{3-0};
1417 let Inst{11-8} = Rt2{3-0};
1418 let Inst{7-0} = imm{7-0};
1421 class T2sI<dag oops, dag iops, InstrItinClass itin,
1422 string opc, string asm, list<dag> pattern>
1423 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1425 class T2XI<dag oops, dag iops, InstrItinClass itin,
1426 string asm, list<dag> pattern>
1427 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1428 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1429 string asm, list<dag> pattern>
1430 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1432 // Move to/from coprocessor instructions
1433 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1435 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1436 let Inst{31-28} = opc;
1439 // Two-address instructions
1440 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1441 string asm, string cstr, list<dag> pattern>
1442 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1444 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1445 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1447 AddrMode am, IndexMode im, InstrItinClass itin,
1448 string opc, string asm, string cstr, list<dag> pattern>
1449 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1450 let OutOperandList = oops;
1451 let InOperandList = !con(iops, (ins pred:$p));
1452 let AsmString = !strconcat(opc, "${p}", asm);
1453 let Pattern = pattern;
1454 list<Predicate> Predicates = [IsThumb2];
1455 let DecoderNamespace = "Thumb2";
1459 let Inst{31-27} = 0b11111;
1460 let Inst{26-25} = 0b00;
1461 let Inst{24} = signed;
1463 let Inst{22-21} = opcod;
1464 let Inst{20} = load;
1465 let Inst{19-16} = addr{12-9};
1466 let Inst{15-12} = Rt{3-0};
1468 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1469 let Inst{10} = pre; // The P bit.
1470 let Inst{9} = addr{8}; // Sign bit
1471 let Inst{8} = 1; // The W bit.
1472 let Inst{7-0} = addr{7-0};
1474 let DecoderMethod = "DecodeT2LdStPre";
1477 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1478 class T2Ipostldst<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";
1493 let Inst{31-27} = 0b11111;
1494 let Inst{26-25} = 0b00;
1495 let Inst{24} = signed;
1497 let Inst{22-21} = opcod;
1498 let Inst{20} = load;
1499 let Inst{19-16} = Rn;
1500 let Inst{15-12} = Rt{3-0};
1502 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1503 let Inst{10} = pre; // The P bit.
1504 let Inst{9} = offset{8}; // Sign bit
1505 let Inst{8} = 1; // The W bit.
1506 let Inst{7-0} = offset{7-0};
1508 let DecoderMethod = "DecodeT2LdStPre";
1511 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1512 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1513 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1516 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1517 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1518 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1521 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1522 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1523 list<Predicate> Predicates = [IsThumb2];
1526 //===----------------------------------------------------------------------===//
1528 //===----------------------------------------------------------------------===//
1529 // ARM VFP Instruction templates.
1532 // Almost all VFP instructions are predicable.
1533 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1534 IndexMode im, Format f, InstrItinClass itin,
1535 string opc, string asm, string cstr, list<dag> pattern>
1536 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1538 let Inst{31-28} = p;
1539 let OutOperandList = oops;
1540 let InOperandList = !con(iops, (ins pred:$p));
1541 let AsmString = !strconcat(opc, "${p}", asm);
1542 let Pattern = pattern;
1543 let PostEncoderMethod = "VFPThumb2PostEncoder";
1544 let DecoderNamespace = "VFP";
1545 list<Predicate> Predicates = [HasVFP2];
1549 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1550 IndexMode im, Format f, InstrItinClass itin,
1551 string asm, string cstr, list<dag> pattern>
1552 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1554 let Inst{31-28} = p;
1555 let OutOperandList = oops;
1556 let InOperandList = iops;
1557 let AsmString = asm;
1558 let Pattern = pattern;
1559 let PostEncoderMethod = "VFPThumb2PostEncoder";
1560 let DecoderNamespace = "VFP";
1561 list<Predicate> Predicates = [HasVFP2];
1564 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1565 string opc, string asm, list<dag> pattern>
1566 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1567 opc, asm, "", pattern> {
1568 let PostEncoderMethod = "VFPThumb2PostEncoder";
1571 // ARM VFP addrmode5 loads and stores
1572 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1573 InstrItinClass itin,
1574 string opc, string asm, list<dag> pattern>
1575 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1576 VFPLdStFrm, itin, opc, asm, "", pattern> {
1577 // Instruction operands.
1581 // Encode instruction operands.
1582 let Inst{23} = addr{8}; // U (add = (U == '1'))
1583 let Inst{22} = Dd{4};
1584 let Inst{19-16} = addr{12-9}; // Rn
1585 let Inst{15-12} = Dd{3-0};
1586 let Inst{7-0} = addr{7-0}; // imm8
1588 let Inst{27-24} = opcod1;
1589 let Inst{21-20} = opcod2;
1590 let Inst{11-9} = 0b101;
1591 let Inst{8} = 1; // Double precision
1593 // Loads & stores operate on both NEON and VFP pipelines.
1594 let D = VFPNeonDomain;
1597 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1598 InstrItinClass itin,
1599 string opc, string asm, list<dag> pattern>
1600 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1601 VFPLdStFrm, itin, opc, asm, "", pattern> {
1602 // Instruction operands.
1606 // Encode instruction operands.
1607 let Inst{23} = addr{8}; // U (add = (U == '1'))
1608 let Inst{22} = Sd{0};
1609 let Inst{19-16} = addr{12-9}; // Rn
1610 let Inst{15-12} = Sd{4-1};
1611 let Inst{7-0} = addr{7-0}; // imm8
1613 let Inst{27-24} = opcod1;
1614 let Inst{21-20} = opcod2;
1615 let Inst{11-9} = 0b101;
1616 let Inst{8} = 0; // Single precision
1618 // Loads & stores operate on both NEON and VFP pipelines.
1619 let D = VFPNeonDomain;
1622 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1623 InstrItinClass itin,
1624 string opc, string asm, list<dag> pattern>
1625 : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1626 VFPLdStFrm, itin, opc, asm, "", pattern> {
1627 list<Predicate> Predicates = [HasFullFP16];
1629 // Instruction operands.
1633 // Encode instruction operands.
1634 let Inst{23} = addr{8}; // U (add = (U == '1'))
1635 let Inst{22} = Sd{0};
1636 let Inst{19-16} = addr{12-9}; // Rn
1637 let Inst{15-12} = Sd{4-1};
1638 let Inst{7-0} = addr{7-0}; // imm8
1640 let Inst{27-24} = opcod1;
1641 let Inst{21-20} = opcod2;
1642 let Inst{11-8} = 0b1001; // Half precision
1644 // Loads & stores operate on both NEON and VFP pipelines.
1645 let D = VFPNeonDomain;
1647 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1650 // VFP Load / store multiple pseudo instructions.
1651 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1653 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1655 let OutOperandList = oops;
1656 let InOperandList = !con(iops, (ins pred:$p));
1657 let Pattern = pattern;
1658 list<Predicate> Predicates = [HasVFP2];
1661 // Load / store multiple
1663 // Unknown precision
1664 class AXXI4<dag oops, dag iops, IndexMode im,
1665 string asm, string cstr, list<dag> pattern>
1666 : VFPXI<oops, iops, AddrMode4, 4, im,
1667 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1668 // Instruction operands.
1672 // Encode instruction operands.
1673 let Inst{19-16} = Rn;
1675 let Inst{15-12} = regs{11-8};
1676 let Inst{7-1} = regs{7-1};
1678 let Inst{27-25} = 0b110;
1679 let Inst{11-8} = 0b1011;
1684 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1685 string asm, string cstr, list<dag> pattern>
1686 : VFPXI<oops, iops, AddrMode4, 4, im,
1687 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1688 // Instruction operands.
1692 // Encode instruction operands.
1693 let Inst{19-16} = Rn;
1694 let Inst{22} = regs{12};
1695 let Inst{15-12} = regs{11-8};
1696 let Inst{7-1} = regs{7-1};
1698 let Inst{27-25} = 0b110;
1699 let Inst{11-9} = 0b101;
1700 let Inst{8} = 1; // Double precision
1705 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1706 string asm, string cstr, list<dag> pattern>
1707 : VFPXI<oops, iops, AddrMode4, 4, im,
1708 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1709 // Instruction operands.
1713 // Encode instruction operands.
1714 let Inst{19-16} = Rn;
1715 let Inst{22} = regs{8};
1716 let Inst{15-12} = regs{12-9};
1717 let Inst{7-0} = regs{7-0};
1719 let Inst{27-25} = 0b110;
1720 let Inst{11-9} = 0b101;
1721 let Inst{8} = 0; // Single precision
1724 // Double precision, unary
1725 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1726 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1727 string asm, list<dag> pattern>
1728 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1729 // Instruction operands.
1733 // Encode instruction operands.
1734 let Inst{3-0} = Dm{3-0};
1735 let Inst{5} = Dm{4};
1736 let Inst{15-12} = Dd{3-0};
1737 let Inst{22} = Dd{4};
1739 let Inst{27-23} = opcod1;
1740 let Inst{21-20} = opcod2;
1741 let Inst{19-16} = opcod3;
1742 let Inst{11-9} = 0b101;
1743 let Inst{8} = 1; // Double precision
1744 let Inst{7-6} = opcod4;
1745 let Inst{4} = opcod5;
1747 let Predicates = [HasVFP2, HasDPVFP];
1750 // Double precision, unary, not-predicated
1751 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1752 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1753 string asm, list<dag> pattern>
1754 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1755 // Instruction operands.
1759 let Inst{31-28} = 0b1111;
1761 // Encode instruction operands.
1762 let Inst{3-0} = Dm{3-0};
1763 let Inst{5} = Dm{4};
1764 let Inst{15-12} = Dd{3-0};
1765 let Inst{22} = Dd{4};
1767 let Inst{27-23} = opcod1;
1768 let Inst{21-20} = opcod2;
1769 let Inst{19-16} = opcod3;
1770 let Inst{11-9} = 0b101;
1771 let Inst{8} = 1; // Double precision
1772 let Inst{7-6} = opcod4;
1773 let Inst{4} = opcod5;
1776 // Double precision, binary
1777 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1778 dag iops, InstrItinClass itin, string opc, string asm,
1780 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1781 // Instruction operands.
1786 // Encode instruction operands.
1787 let Inst{3-0} = Dm{3-0};
1788 let Inst{5} = Dm{4};
1789 let Inst{19-16} = Dn{3-0};
1790 let Inst{7} = Dn{4};
1791 let Inst{15-12} = Dd{3-0};
1792 let Inst{22} = Dd{4};
1794 let Inst{27-23} = opcod1;
1795 let Inst{21-20} = opcod2;
1796 let Inst{11-9} = 0b101;
1797 let Inst{8} = 1; // Double precision
1801 let Predicates = [HasVFP2, HasDPVFP];
1804 // FP, binary, not predicated
1805 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1806 InstrItinClass itin, string asm, list<dag> pattern>
1807 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1810 // Instruction operands.
1815 let Inst{31-28} = 0b1111;
1817 // Encode instruction operands.
1818 let Inst{3-0} = Dm{3-0};
1819 let Inst{5} = Dm{4};
1820 let Inst{19-16} = Dn{3-0};
1821 let Inst{7} = Dn{4};
1822 let Inst{15-12} = Dd{3-0};
1823 let Inst{22} = Dd{4};
1825 let Inst{27-23} = opcod1;
1826 let Inst{21-20} = opcod2;
1827 let Inst{11-9} = 0b101;
1828 let Inst{8} = 1; // double precision
1829 let Inst{6} = opcod3;
1832 let Predicates = [HasVFP2, HasDPVFP];
1835 // Single precision, unary, predicated
1836 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1837 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1838 string asm, list<dag> pattern>
1839 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1840 // Instruction operands.
1844 // Encode instruction operands.
1845 let Inst{3-0} = Sm{4-1};
1846 let Inst{5} = Sm{0};
1847 let Inst{15-12} = Sd{4-1};
1848 let Inst{22} = Sd{0};
1850 let Inst{27-23} = opcod1;
1851 let Inst{21-20} = opcod2;
1852 let Inst{19-16} = opcod3;
1853 let Inst{11-9} = 0b101;
1854 let Inst{8} = 0; // Single precision
1855 let Inst{7-6} = opcod4;
1856 let Inst{4} = opcod5;
1859 // Single precision, unary, non-predicated
1860 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1861 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1862 string asm, list<dag> pattern>
1863 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1864 VFPUnaryFrm, itin, asm, "", pattern> {
1865 // Instruction operands.
1869 let Inst{31-28} = 0b1111;
1871 // Encode instruction operands.
1872 let Inst{3-0} = Sm{4-1};
1873 let Inst{5} = Sm{0};
1874 let Inst{15-12} = Sd{4-1};
1875 let Inst{22} = Sd{0};
1877 let Inst{27-23} = opcod1;
1878 let Inst{21-20} = opcod2;
1879 let Inst{19-16} = opcod3;
1880 let Inst{11-9} = 0b101;
1881 let Inst{8} = 0; // Single precision
1882 let Inst{7-6} = opcod4;
1883 let Inst{4} = opcod5;
1886 // Single precision unary, if no NEON. Same as ASuI except not available if
1888 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1889 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1890 string asm, list<dag> pattern>
1891 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1893 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1896 // Single precision, binary
1897 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1898 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1899 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1900 // Instruction operands.
1905 // Encode instruction operands.
1906 let Inst{3-0} = Sm{4-1};
1907 let Inst{5} = Sm{0};
1908 let Inst{19-16} = Sn{4-1};
1909 let Inst{7} = Sn{0};
1910 let Inst{15-12} = Sd{4-1};
1911 let Inst{22} = Sd{0};
1913 let Inst{27-23} = opcod1;
1914 let Inst{21-20} = opcod2;
1915 let Inst{11-9} = 0b101;
1916 let Inst{8} = 0; // Single precision
1921 // Single precision, binary, not predicated
1922 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1923 InstrItinClass itin, string asm, list<dag> pattern>
1924 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1925 VFPBinaryFrm, itin, asm, "", pattern>
1927 // Instruction operands.
1932 let Inst{31-28} = 0b1111;
1934 // Encode instruction operands.
1935 let Inst{3-0} = Sm{4-1};
1936 let Inst{5} = Sm{0};
1937 let Inst{19-16} = Sn{4-1};
1938 let Inst{7} = Sn{0};
1939 let Inst{15-12} = Sd{4-1};
1940 let Inst{22} = Sd{0};
1942 let Inst{27-23} = opcod1;
1943 let Inst{21-20} = opcod2;
1944 let Inst{11-9} = 0b101;
1945 let Inst{8} = 0; // Single precision
1946 let Inst{6} = opcod3;
1950 // Single precision binary, if no NEON. Same as ASbI except not available if
1952 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1953 dag iops, InstrItinClass itin, string opc, string asm,
1955 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1956 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1958 // Instruction operands.
1963 // Encode instruction operands.
1964 let Inst{3-0} = Sm{4-1};
1965 let Inst{5} = Sm{0};
1966 let Inst{19-16} = Sn{4-1};
1967 let Inst{7} = Sn{0};
1968 let Inst{15-12} = Sd{4-1};
1969 let Inst{22} = Sd{0};
1972 // Half precision, unary, predicated
1973 class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1974 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1975 string asm, list<dag> pattern>
1976 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1977 list<Predicate> Predicates = [HasFullFP16];
1979 // Instruction operands.
1983 // Encode instruction operands.
1984 let Inst{3-0} = Sm{4-1};
1985 let Inst{5} = Sm{0};
1986 let Inst{15-12} = Sd{4-1};
1987 let Inst{22} = Sd{0};
1989 let Inst{27-23} = opcod1;
1990 let Inst{21-20} = opcod2;
1991 let Inst{19-16} = opcod3;
1992 let Inst{11-8} = 0b1001; // Half precision
1993 let Inst{7-6} = opcod4;
1994 let Inst{4} = opcod5;
1996 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1999 // Half precision, unary, non-predicated
2000 class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2001 bit opcod5, dag oops, dag iops, InstrItinClass itin,
2002 string asm, list<dag> pattern>
2003 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2004 VFPUnaryFrm, itin, asm, "", pattern> {
2005 list<Predicate> Predicates = [HasFullFP16];
2007 // Instruction operands.
2011 let Inst{31-28} = 0b1111;
2013 // Encode instruction operands.
2014 let Inst{3-0} = Sm{4-1};
2015 let Inst{5} = Sm{0};
2016 let Inst{15-12} = Sd{4-1};
2017 let Inst{22} = Sd{0};
2019 let Inst{27-23} = opcod1;
2020 let Inst{21-20} = opcod2;
2021 let Inst{19-16} = opcod3;
2022 let Inst{11-8} = 0b1001; // Half precision
2023 let Inst{7-6} = opcod4;
2024 let Inst{4} = opcod5;
2026 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2029 // Half precision, binary
2030 class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
2031 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2032 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
2033 list<Predicate> Predicates = [HasFullFP16];
2035 // Instruction operands.
2040 // Encode instruction operands.
2041 let Inst{3-0} = Sm{4-1};
2042 let Inst{5} = Sm{0};
2043 let Inst{19-16} = Sn{4-1};
2044 let Inst{7} = Sn{0};
2045 let Inst{15-12} = Sd{4-1};
2046 let Inst{22} = Sd{0};
2048 let Inst{27-23} = opcod1;
2049 let Inst{21-20} = opcod2;
2050 let Inst{11-8} = 0b1001; // Half precision
2054 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2057 // Half precision, binary, not predicated
2058 class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
2059 InstrItinClass itin, string asm, list<dag> pattern>
2060 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2061 VFPBinaryFrm, itin, asm, "", pattern> {
2062 list<Predicate> Predicates = [HasFullFP16];
2064 // Instruction operands.
2069 let Inst{31-28} = 0b1111;
2071 // Encode instruction operands.
2072 let Inst{3-0} = Sm{4-1};
2073 let Inst{5} = Sm{0};
2074 let Inst{19-16} = Sn{4-1};
2075 let Inst{7} = Sn{0};
2076 let Inst{15-12} = Sd{4-1};
2077 let Inst{22} = Sd{0};
2079 let Inst{27-23} = opcod1;
2080 let Inst{21-20} = opcod2;
2081 let Inst{11-8} = 0b1001; // Half precision
2082 let Inst{6} = opcod3;
2085 let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2088 // VFP conversion instructions
2089 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2090 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2092 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
2093 let Inst{27-23} = opcod1;
2094 let Inst{21-20} = opcod2;
2095 let Inst{19-16} = opcod3;
2096 let Inst{11-8} = opcod4;
2101 // VFP conversion between floating-point and fixed-point
2102 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2103 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2105 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2107 // size (fixed-point number): sx == 0 ? 16 : 32
2108 let Inst{7} = op5; // sx
2109 let Inst{5} = fbits{0};
2110 let Inst{3-0} = fbits{4-1};
2113 // VFP conversion instructions, if no NEON
2114 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2115 dag oops, dag iops, InstrItinClass itin,
2116 string opc, string asm, list<dag> pattern>
2117 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2119 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2122 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2123 InstrItinClass itin,
2124 string opc, string asm, list<dag> pattern>
2125 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
2126 let Inst{27-20} = opcod1;
2127 let Inst{11-8} = opcod2;
2131 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2132 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2133 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
2135 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2136 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2137 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2139 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2140 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2141 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
2143 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2144 InstrItinClass itin, string opc, string asm, list<dag> pattern>
2145 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
2147 //===----------------------------------------------------------------------===//
2149 //===----------------------------------------------------------------------===//
2150 // ARM NEON Instruction templates.
2153 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2154 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2156 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2157 let OutOperandList = oops;
2158 let InOperandList = !con(iops, (ins pred:$p));
2159 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2160 let Pattern = pattern;
2161 list<Predicate> Predicates = [HasNEON];
2162 let DecoderNamespace = "NEON";
2165 // Same as NeonI except it does not have a "data type" specifier.
2166 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2167 InstrItinClass itin, string opc, string asm, string cstr,
2169 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2170 let OutOperandList = oops;
2171 let InOperandList = !con(iops, (ins pred:$p));
2172 let AsmString = !strconcat(opc, "${p}", "\t", asm);
2173 let Pattern = pattern;
2174 list<Predicate> Predicates = [HasNEON];
2175 let DecoderNamespace = "NEON";
2178 // Same as NeonI except it is not predicated
2179 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2180 InstrItinClass itin, string opc, string dt, string asm, string cstr,
2182 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2183 let OutOperandList = oops;
2184 let InOperandList = iops;
2185 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2186 let Pattern = pattern;
2187 list<Predicate> Predicates = [HasNEON];
2188 let DecoderNamespace = "NEON";
2190 let Inst{31-28} = 0b1111;
2193 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2194 dag oops, dag iops, InstrItinClass itin,
2195 string opc, string dt, string asm, string cstr, list<dag> pattern>
2196 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2198 let Inst{31-24} = 0b11110100;
2199 let Inst{23} = op23;
2200 let Inst{21-20} = op21_20;
2201 let Inst{11-8} = op11_8;
2202 let Inst{7-4} = op7_4;
2204 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2205 let DecoderNamespace = "NEONLoadStore";
2211 let Inst{22} = Vd{4};
2212 let Inst{15-12} = Vd{3-0};
2213 let Inst{19-16} = Rn{3-0};
2214 let Inst{3-0} = Rm{3-0};
2217 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2218 dag oops, dag iops, InstrItinClass itin,
2219 string opc, string dt, string asm, string cstr, list<dag> pattern>
2220 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2221 dt, asm, cstr, pattern> {
2225 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2226 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2228 let OutOperandList = oops;
2229 let InOperandList = !con(iops, (ins pred:$p));
2230 list<Predicate> Predicates = [HasNEON];
2233 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2235 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2237 let OutOperandList = oops;
2238 let InOperandList = !con(iops, (ins pred:$p));
2239 let Pattern = pattern;
2240 list<Predicate> Predicates = [HasNEON];
2243 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2244 string opc, string dt, string asm, string cstr, list<dag> pattern>
2245 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2247 let Inst{31-25} = 0b1111001;
2248 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2249 let DecoderNamespace = "NEONData";
2252 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2253 string opc, string asm, string cstr, list<dag> pattern>
2254 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2256 let Inst{31-25} = 0b1111001;
2257 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2258 let DecoderNamespace = "NEONData";
2261 // NEON "one register and a modified immediate" format.
2262 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2264 dag oops, dag iops, InstrItinClass itin,
2265 string opc, string dt, string asm, string cstr,
2267 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2268 let Inst{23} = op23;
2269 let Inst{21-19} = op21_19;
2270 let Inst{11-8} = op11_8;
2276 // Instruction operands.
2280 let Inst{15-12} = Vd{3-0};
2281 let Inst{22} = Vd{4};
2282 let Inst{24} = SIMM{7};
2283 let Inst{18-16} = SIMM{6-4};
2284 let Inst{3-0} = SIMM{3-0};
2285 let DecoderMethod = "DecodeVMOVModImmInstruction";
2288 // NEON 2 vector register format.
2289 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2290 bits<5> op11_7, bit op6, bit op4,
2291 dag oops, dag iops, InstrItinClass itin,
2292 string opc, string dt, string asm, string cstr, list<dag> pattern>
2293 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2294 let Inst{24-23} = op24_23;
2295 let Inst{21-20} = op21_20;
2296 let Inst{19-18} = op19_18;
2297 let Inst{17-16} = op17_16;
2298 let Inst{11-7} = op11_7;
2302 // Instruction operands.
2306 let Inst{15-12} = Vd{3-0};
2307 let Inst{22} = Vd{4};
2308 let Inst{3-0} = Vm{3-0};
2309 let Inst{5} = Vm{4};
2312 // Same as N2V but not predicated.
2313 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2314 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2315 string Dt, list<dag> pattern>
2316 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2317 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2321 // Encode instruction operands
2322 let Inst{22} = Vd{4};
2323 let Inst{15-12} = Vd{3-0};
2324 let Inst{5} = Vm{4};
2325 let Inst{3-0} = Vm{3-0};
2327 // Encode constant bits
2328 let Inst{27-23} = 0b00111;
2329 let Inst{21-20} = 0b11;
2330 let Inst{19-18} = op19_18;
2331 let Inst{17-16} = op17_16;
2333 let Inst{10-8} = op10_8;
2338 let DecoderNamespace = "NEON";
2341 // Same as N2V except it doesn't have a datatype suffix.
2342 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2343 bits<5> op11_7, bit op6, bit op4,
2344 dag oops, dag iops, InstrItinClass itin,
2345 string opc, string asm, string cstr, list<dag> pattern>
2346 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2347 let Inst{24-23} = op24_23;
2348 let Inst{21-20} = op21_20;
2349 let Inst{19-18} = op19_18;
2350 let Inst{17-16} = op17_16;
2351 let Inst{11-7} = op11_7;
2355 // Instruction operands.
2359 let Inst{15-12} = Vd{3-0};
2360 let Inst{22} = Vd{4};
2361 let Inst{3-0} = Vm{3-0};
2362 let Inst{5} = Vm{4};
2365 // NEON 2 vector register with immediate.
2366 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2367 dag oops, dag iops, Format f, InstrItinClass itin,
2368 string opc, string dt, string asm, string cstr, list<dag> pattern>
2369 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2370 let Inst{24} = op24;
2371 let Inst{23} = op23;
2372 let Inst{11-8} = op11_8;
2377 // Instruction operands.
2382 let Inst{15-12} = Vd{3-0};
2383 let Inst{22} = Vd{4};
2384 let Inst{3-0} = Vm{3-0};
2385 let Inst{5} = Vm{4};
2386 let Inst{21-16} = SIMM{5-0};
2389 // NEON 3 vector register format.
2391 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2392 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2393 string opc, string dt, string asm, string cstr,
2395 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2396 let Inst{24} = op24;
2397 let Inst{23} = op23;
2398 let Inst{21-20} = op21_20;
2399 let Inst{11-8} = op11_8;
2404 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2405 dag oops, dag iops, Format f, InstrItinClass itin,
2406 string opc, string dt, string asm, string cstr, list<dag> pattern>
2407 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2408 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2409 // Instruction operands.
2414 let Inst{15-12} = Vd{3-0};
2415 let Inst{22} = Vd{4};
2416 let Inst{19-16} = Vn{3-0};
2417 let Inst{7} = Vn{4};
2418 let Inst{3-0} = Vm{3-0};
2419 let Inst{5} = Vm{4};
2422 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2423 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2424 string OpcodeStr, string Dt, list<dag> pattern>
2425 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2426 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2431 // Encode instruction operands
2432 let Inst{22} = Vd{4};
2433 let Inst{15-12} = Vd{3-0};
2434 let Inst{19-16} = Vn{3-0};
2435 let Inst{7} = Vn{4};
2436 let Inst{5} = Vm{4};
2437 let Inst{3-0} = Vm{3-0};
2439 // Encode constant bits
2440 let Inst{27-23} = op27_23;
2441 let Inst{21-20} = op21_20;
2442 let Inst{11-8} = op11_8;
2447 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2448 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2449 string opc, string dt, string asm, string cstr,
2451 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2452 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2454 // Instruction operands.
2460 let Inst{15-12} = Vd{3-0};
2461 let Inst{22} = Vd{4};
2462 let Inst{19-16} = Vn{3-0};
2463 let Inst{7} = Vn{4};
2464 let Inst{3-0} = Vm{3-0};
2468 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2469 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2470 string opc, string dt, string asm, string cstr,
2472 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2473 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2475 // Instruction operands.
2481 let Inst{15-12} = Vd{3-0};
2482 let Inst{22} = Vd{4};
2483 let Inst{19-16} = Vn{3-0};
2484 let Inst{7} = Vn{4};
2485 let Inst{2-0} = Vm{2-0};
2486 let Inst{5} = lane{1};
2487 let Inst{3} = lane{0};
2490 // Same as N3V except it doesn't have a data type suffix.
2491 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2493 dag oops, dag iops, Format f, InstrItinClass itin,
2494 string opc, string asm, string cstr, list<dag> pattern>
2495 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2496 let Inst{24} = op24;
2497 let Inst{23} = op23;
2498 let Inst{21-20} = op21_20;
2499 let Inst{11-8} = op11_8;
2503 // Instruction operands.
2508 let Inst{15-12} = Vd{3-0};
2509 let Inst{22} = Vd{4};
2510 let Inst{19-16} = Vn{3-0};
2511 let Inst{7} = Vn{4};
2512 let Inst{3-0} = Vm{3-0};
2513 let Inst{5} = Vm{4};
2516 // NEON VMOVs between scalar and core registers.
2517 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2518 dag oops, dag iops, Format f, InstrItinClass itin,
2519 string opc, string dt, string asm, list<dag> pattern>
2520 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2522 let Inst{27-20} = opcod1;
2523 let Inst{11-8} = opcod2;
2524 let Inst{6-5} = opcod3;
2526 // A8.6.303, A8.6.328, A8.6.329
2527 let Inst{3-0} = 0b0000;
2529 let OutOperandList = oops;
2530 let InOperandList = !con(iops, (ins pred:$p));
2531 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2532 let Pattern = pattern;
2533 list<Predicate> Predicates = [HasNEON];
2535 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2536 let DecoderNamespace = "NEONDup";
2543 let Inst{31-28} = p{3-0};
2545 let Inst{19-16} = V{3-0};
2546 let Inst{15-12} = R{3-0};
2548 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2549 dag oops, dag iops, InstrItinClass itin,
2550 string opc, string dt, string asm, list<dag> pattern>
2551 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2552 opc, dt, asm, pattern>;
2553 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2554 dag oops, dag iops, InstrItinClass itin,
2555 string opc, string dt, string asm, list<dag> pattern>
2556 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2557 opc, dt, asm, pattern>;
2558 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2559 dag oops, dag iops, InstrItinClass itin,
2560 string opc, string dt, string asm, list<dag> pattern>
2561 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2562 opc, dt, asm, pattern>;
2564 // Vector Duplicate Lane (from scalar to all elements)
2565 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2566 InstrItinClass itin, string opc, string dt, string asm,
2568 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2569 let Inst{24-23} = 0b11;
2570 let Inst{21-20} = 0b11;
2571 let Inst{19-16} = op19_16;
2572 let Inst{11-7} = 0b11000;
2579 let Inst{22} = Vd{4};
2580 let Inst{15-12} = Vd{3-0};
2581 let Inst{5} = Vm{4};
2582 let Inst{3-0} = Vm{3-0};
2585 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2586 // for single-precision FP.
2587 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2588 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2591 // VFP/NEON Instruction aliases for type suffices.
2592 // Note: When EmitPriority == 1, the alias will be used for printing
2593 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2594 InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
2596 // Note: When EmitPriority == 1, the alias will be used for printing
2597 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2598 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2599 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2600 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2601 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2604 // Note: When EmitPriority == 1, the alias will be used for printing
2605 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2606 let Predicates = [HasNEON] in {
2607 def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2608 def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2609 def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2610 def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2614 // The same alias classes using AsmPseudo instead, for the more complex
2615 // stuff in NEON that InstAlias can't quite handle.
2616 // Note that we can't use anonymous defm references here like we can
2617 // above, as we care about the ultimate instruction enum names generated, unlike
2618 // for instalias defs.
2619 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2620 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2622 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2623 // encoding space, introduced in ARMv8.3-A.
2624 class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2625 dag oops, dag iops, InstrItinClass itin,
2626 string opc, string dt, string asm, string cstr, list<dag> pattern>
2627 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2628 dt, asm, cstr, pattern> {
2633 let DecoderNamespace = "VFPV8";
2634 // These have the same encodings in ARM and Thumb2
2635 let PostEncoderMethod = "";
2637 let Inst{31-25} = 0b1111110;
2638 let Inst{24-23} = op24_23;
2639 let Inst{22} = Vd{4};
2640 let Inst{21-20} = op21_20;
2641 let Inst{19-16} = Vn{3-0};
2642 let Inst{15-12} = Vd{3-0};
2643 let Inst{11-8} = 0b1000;
2644 let Inst{7} = Vn{4};
2646 let Inst{5} = Vm{4};
2648 let Inst{3-0} = Vm{3-0};
2651 // Extension of NEON 2-vector-and-scalar data processing instructions in
2652 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2653 class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2654 dag oops, dag iops, InstrItinClass itin,
2655 string opc, string dt, string asm, string cstr, list<dag> pattern>
2656 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2657 dt, asm, cstr, pattern> {
2662 let DecoderNamespace = "VFPV8";
2663 // These have the same encodings in ARM and Thumb2
2664 let PostEncoderMethod = "";
2666 let Inst{31-24} = 0b11111110;
2667 let Inst{23} = op23;
2668 let Inst{22} = Vd{4};
2669 let Inst{21-20} = op21_20;
2670 let Inst{19-16} = Vn{3-0};
2671 let Inst{15-12} = Vd{3-0};
2672 let Inst{11-8} = 0b1000;
2673 let Inst{7} = Vn{4};
2675 // Bit 5 set by sub-classes
2677 let Inst{3-0} = Vm{3-0};
2680 // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
2682 // if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
2683 // if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
2684 // Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
2685 class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2686 dag oops, dag iops, InstrItinClass itin,
2687 string opc, string dt, string asm, string cstr, list<dag> pattern>
2688 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
2693 let DecoderNamespace = "VFPV8";
2694 // These have the same encodings in ARM and Thumb2
2695 let PostEncoderMethod = "";
2697 let Inst{31-25} = 0b1111110;
2698 let Inst{24-23} = op24_23;
2699 let Inst{22} = Vd{4};
2700 let Inst{21-20} = op21_20;
2701 let Inst{19-16} = Vn{4-1};
2702 let Inst{15-12} = Vd{3-0};
2703 let Inst{11-8} = 0b1000;
2704 let Inst{7} = Vn{0};
2706 let Inst{5} = Vm{0};
2708 let Inst{3-0} = Vm{4-1};
2711 // Operand types for complex instructions
2712 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2714 let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2715 let DiagnosticString = "complex rotation must be " # Diag;
2716 let Name = "ComplexRotation" # Type;
2718 def complexrotateop : Operand<i32> {
2719 let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2720 let PrintMethod = "printComplexRotationOp<90, 0>";
2722 def complexrotateopodd : Operand<i32> {
2723 let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2724 let PrintMethod = "printComplexRotationOp<180, 90>";
2727 def MveSaturateOperand : AsmOperandClass {
2728 let PredicateMethod = "isMveSaturateOp";
2729 let DiagnosticString = "saturate operand must be 48 or 64";
2730 let Name = "MveSaturate";
2732 def saturateop : Operand<i32> {
2733 let ParserMatchClass = MveSaturateOperand;
2734 let PrintMethod = "printMveSaturateOp";
2737 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2738 def : TokenAlias<".s8", ".i8">;
2739 def : TokenAlias<".u8", ".i8">;
2740 def : TokenAlias<".s16", ".i16">;
2741 def : TokenAlias<".u16", ".i16">;
2742 def : TokenAlias<".s32", ".i32">;
2743 def : TokenAlias<".u32", ".i32">;
2744 def : TokenAlias<".s64", ".i64">;
2745 def : TokenAlias<".u64", ".i64">;
2747 def : TokenAlias<".i8", ".8">;
2748 def : TokenAlias<".i16", ".16">;
2749 def : TokenAlias<".i32", ".32">;
2750 def : TokenAlias<".i64", ".64">;
2752 def : TokenAlias<".p8", ".8">;
2753 def : TokenAlias<".p16", ".16">;
2755 def : TokenAlias<".f32", ".32">;
2756 def : TokenAlias<".f64", ".64">;
2757 def : TokenAlias<".f", ".f32">;
2758 def : TokenAlias<".d", ".f64">;