[x86] fix assert with horizontal math + broadcast of vector (PR43402)
[llvm-core.git] / lib / Target / ARM / ARMInstrFormats.td
blob53af05cf5f42460582489d5789f18c5134615bae
1 //===-- ARMInstrFormats.td - ARM Instruction Formats -------*- tablegen -*-===//
2 //
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
6 //
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
16 // code emitter.
17 class Format<bits<6> val> {
18   bits<6> Value = 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>;
73 // Misc flags.
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.
89 // Addressing mode.
90 class AddrMode<bits<5> val> {
91   bits<5> Value = 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> {
118   bits<2> Value = 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> {
127   bits<4> Value = 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),
195                                    MVT::i32);
196 }]>;
198 // VPT predicate
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
214 // two options:
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:
312 //    Offset    Encoding
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>,
383           Requires<[HasVFP2]>;
384 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
385           Requires<[HasNEON]>;
387 //===----------------------------------------------------------------------===//
388 // ARM Instruction templates.
392 class InstTemplate<AddrMode am, int sz, IndexMode im,
393                    Format f, Domain d, string cstr, InstrItinClass itin>
394   : Instruction {
395   let Namespace = "ARM";
397   AddrMode AM = am;
398   int Size = sz;
399   IndexMode IM = im;
400   bits<2> IndexModeBits = IM.Value;
401   Format F = f;
402   bits<6> Form = F.Value;
403   Domain D = d;
404   bit isUnaryDataProc = 0;
405   bit canXformTo16Bit = 0;
406   // The instruction is a 16-bit flag setting Thumb instruction. Used
407   // by the parser to determine whether to require the 'S' suffix on the
408   // mnemonic (when not in an IT block) or preclude it (when in an IT block).
409   bit thumbArithFlagSetting = 0;
411   bit invalidForTailPredication = 0;
413   // If this is a pseudo instruction, mark it isCodeGenOnly.
414   let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
416   // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
417   let TSFlags{4-0}   = AM.Value;
418   let TSFlags{6-5}   = IndexModeBits;
419   let TSFlags{12-7} = Form;
420   let TSFlags{13}    = isUnaryDataProc;
421   let TSFlags{14}    = canXformTo16Bit;
422   let TSFlags{18-15} = D.Value;
423   let TSFlags{19}    = thumbArithFlagSetting;
424   let TSFlags{20}    = invalidForTailPredication;
426   let Constraints = cstr;
427   let Itinerary = itin;
430 class Encoding {
431   field bits<32> Inst;
432   // Mask of bits that cause an encoding to be UNPREDICTABLE.
433   // If a bit is set, then if the corresponding bit in the
434   // target encoding differs from its value in the "Inst" field,
435   // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
436   field bits<32> Unpredictable = 0;
437   // SoftFail is the generic name for this field, but we alias it so
438   // as to make it more obvious what it means in ARM-land.
439   field bits<32> SoftFail = Unpredictable;
442 class InstARM<AddrMode am, int sz, IndexMode im,
443               Format f, Domain d, string cstr, InstrItinClass itin>
444   : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
445   let DecoderNamespace = "ARM";
448 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
449 // on by adding flavors to specific instructions.
450 class InstThumb<AddrMode am, int sz, IndexMode im,
451                 Format f, Domain d, string cstr, InstrItinClass itin>
452   : InstTemplate<am, sz, im, f, d, cstr, itin> {
453   let DecoderNamespace = "Thumb";
456 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
457 // These are aliases that require C++ handling to convert to the target
458 // instruction, while InstAliases can be handled directly by tblgen.
459 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
460   : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
461                  "", NoItinerary> {
462   let OutOperandList = oops;
463   let InOperandList = iops;
464   let Pattern = [];
465   let isCodeGenOnly = 0; // So we get asm matcher for it.
466   let AsmString = asm;
467   let isPseudo = 1;
470 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
471   : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
472 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
473   : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
474 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
475   : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
476 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
477   : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
478 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
479   : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
480 class MVEAsmPseudo<string asm, dag iops, dag oops = (outs)>
481   : AsmPseudoInst<asm, iops, oops>, Requires<[HasMVEInt]>;
483 // Pseudo instructions for the code generator.
484 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
485   : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
486                  GenericDomain, "", itin> {
487   let OutOperandList = oops;
488   let InOperandList = iops;
489   let Pattern = pattern;
490   let isCodeGenOnly = 1;
491   let isPseudo = 1;
494 // PseudoInst that's ARM-mode only.
495 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
496                     list<dag> pattern>
497   : PseudoInst<oops, iops, itin, pattern> {
498   let Size = sz;
499   list<Predicate> Predicates = [IsARM];
502 // PseudoInst that's Thumb-mode only.
503 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
504                     list<dag> pattern>
505   : PseudoInst<oops, iops, itin, pattern> {
506   let Size = sz;
507   list<Predicate> Predicates = [IsThumb];
510 // PseudoInst that's in ARMv8-M baseline (Somewhere between Thumb and Thumb2)
511 class t2basePseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
512                     list<dag> pattern>
513   : PseudoInst<oops, iops, itin, pattern> {
514   let Size = sz;
515   list<Predicate> Predicates = [IsThumb,HasV8MBaseline];
518 // PseudoInst that's Thumb2-mode only.
519 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
520                     list<dag> pattern>
521   : PseudoInst<oops, iops, itin, pattern> {
522   let Size = sz;
523   list<Predicate> Predicates = [IsThumb2];
526 class ARMPseudoExpand<dag oops, dag iops, int sz,
527                       InstrItinClass itin, list<dag> pattern,
528                       dag Result>
529   : ARMPseudoInst<oops, iops, sz, itin, pattern>,
530     PseudoInstExpansion<Result>;
532 class tPseudoExpand<dag oops, dag iops, int sz,
533                     InstrItinClass itin, list<dag> pattern,
534                     dag Result>
535   : tPseudoInst<oops, iops, sz, itin, pattern>,
536     PseudoInstExpansion<Result>;
538 class t2PseudoExpand<dag oops, dag iops, int sz,
539                     InstrItinClass itin, list<dag> pattern,
540                     dag Result>
541   : t2PseudoInst<oops, iops, sz, itin, pattern>,
542     PseudoInstExpansion<Result>;
544 // Almost all ARM instructions are predicable.
545 class I<dag oops, dag iops, AddrMode am, int sz,
546         IndexMode im, Format f, InstrItinClass itin,
547         string opc, string asm, string cstr,
548         list<dag> pattern>
549   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
550   bits<4> p;
551   let Inst{31-28} = p;
552   let OutOperandList = oops;
553   let InOperandList = !con(iops, (ins pred:$p));
554   let AsmString = !strconcat(opc, "${p}", asm);
555   let Pattern = pattern;
556   list<Predicate> Predicates = [IsARM];
559 // A few are not predicable
560 class InoP<dag oops, dag iops, AddrMode am, int sz,
561            IndexMode im, Format f, InstrItinClass itin,
562            string opc, string asm, string cstr,
563            list<dag> pattern>
564   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
565   let OutOperandList = oops;
566   let InOperandList = iops;
567   let AsmString = !strconcat(opc, asm);
568   let Pattern = pattern;
569   let isPredicable = 0;
570   list<Predicate> Predicates = [IsARM];
573 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
574 // operand since by default it's a zero register. It will become an implicit def
575 // once it's "flipped".
576 class sI<dag oops, dag iops, AddrMode am, int sz,
577          IndexMode im, Format f, InstrItinClass itin,
578          string opc, string asm, string cstr,
579          list<dag> pattern>
580   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
581   bits<4> p; // Predicate operand
582   bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
583   let Inst{31-28} = p;
584   let Inst{20} = s;
586   let OutOperandList = oops;
587   let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
588   let AsmString = !strconcat(opc, "${s}${p}", asm);
589   let Pattern = pattern;
590   list<Predicate> Predicates = [IsARM];
593 // Special cases
594 class XI<dag oops, dag iops, AddrMode am, int sz,
595          IndexMode im, Format f, InstrItinClass itin,
596          string asm, string cstr, list<dag> pattern>
597   : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
598   let OutOperandList = oops;
599   let InOperandList = iops;
600   let AsmString = asm;
601   let Pattern = pattern;
602   list<Predicate> Predicates = [IsARM];
605 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
606          string opc, string asm, list<dag> pattern>
607   : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
608       opc, asm, "", pattern>;
609 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
610           string opc, string asm, list<dag> pattern>
611   : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
612        opc, asm, "", pattern>;
613 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
614           string asm, list<dag> pattern>
615   : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
616        asm, "", pattern>;
617 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
618           string asm, list<dag> pattern>
619   : XI<oops, iops, am, 4, IndexModeNone, f, itin,
620        asm, "", pattern>;
621 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
622             string opc, string asm, list<dag> pattern>
623   : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
624          opc, asm, "", pattern>;
626 // Ctrl flow instructions
627 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
628           string opc, string asm, list<dag> pattern>
629   : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
630       opc, asm, "", pattern> {
631   let Inst{27-24} = opcod;
633 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
634            string asm, list<dag> pattern>
635   : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
636        asm, "", pattern> {
637   let Inst{27-24} = opcod;
640 // BR_JT instructions
641 class JTI<dag oops, dag iops, InstrItinClass itin,
642           string asm, list<dag> pattern>
643   : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
644        asm, "", pattern>;
646 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
647               string opc, string asm, list<dag> pattern>
648   : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
649       opc, asm, "", pattern> {
650   bits<4> Rt;
651   bits<4> addr;
652   let Inst{27-23} = 0b00011;
653   let Inst{22-21} = opcod;
654   let Inst{20}    = 1;
655   let Inst{19-16} = addr;
656   let Inst{15-12} = Rt;
657   let Inst{11-10} = 0b11;
658   let Inst{9-8}   = opcod2;
659   let Inst{7-0}   = 0b10011111;
661 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
662               string opc, string asm, list<dag> pattern>
663   : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
664       opc, asm, "", pattern> {
665   bits<4> Rt;
666   bits<4> addr;
667   let Inst{27-23} = 0b00011;
668   let Inst{22-21} = opcod;
669   let Inst{20}    = 0;
670   let Inst{19-16} = addr;
671   let Inst{11-10} = 0b11;
672   let Inst{9-8}   = opcod2;
673   let Inst{7-4}   = 0b1001;
674   let Inst{3-0}   = Rt;
676 // Atomic load/store instructions
677 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
678               string opc, string asm, list<dag> pattern>
679   : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
681 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
682               string opc, string asm, list<dag> pattern>
683   : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
684   bits<4> Rd;
685   let Inst{15-12} = Rd;
688 // Exclusive load/store instructions
690 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
691               string opc, string asm, list<dag> pattern>
692   : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
693     Requires<[IsARM, HasAcquireRelease, HasV7Clrex]>;
695 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
696               string opc, string asm, list<dag> pattern>
697   : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
698     Requires<[IsARM, HasAcquireRelease, HasV7Clrex]> {
699   bits<4> Rd;
700   let Inst{15-12} = Rd;
703 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
704   : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
705   bits<4> Rt;
706   bits<4> Rt2;
707   bits<4> addr;
708   let Inst{27-23} = 0b00010;
709   let Inst{22} = b;
710   let Inst{21-20} = 0b00;
711   let Inst{19-16} = addr;
712   let Inst{15-12} = Rt;
713   let Inst{11-4} = 0b00001001;
714   let Inst{3-0} = Rt2;
716   let Unpredictable{11-8} = 0b1111;
717   let DecoderMethod = "DecodeSwap";
719 // Acquire/Release load/store instructions
720 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
721               string opc, string asm, list<dag> pattern>
722   : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
723     Requires<[IsARM, HasAcquireRelease]>;
725 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
726               string opc, string asm, list<dag> pattern>
727   : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
728     Requires<[IsARM, HasAcquireRelease]> {
729   let Inst{15-12}   = 0b1111;
732 // addrmode1 instructions
733 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
734           string opc, string asm, list<dag> pattern>
735   : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
736       opc, asm, "", pattern> {
737   let Inst{24-21} = opcod;
738   let Inst{27-26} = 0b00;
740 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
741            string opc, string asm, list<dag> pattern>
742   : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
743        opc, asm, "", pattern> {
744   let Inst{24-21} = opcod;
745   let Inst{27-26} = 0b00;
747 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
748            string asm, list<dag> pattern>
749   : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
750        asm, "", pattern> {
751   let Inst{24-21} = opcod;
752   let Inst{27-26} = 0b00;
755 // loads
757 // LDR/LDRB/STR/STRB/...
758 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
759              Format f, InstrItinClass itin, string opc, string asm,
760              list<dag> pattern>
761   : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
762       "", pattern> {
763   let Inst{27-25} = op;
764   let Inst{24} = 1;  // 24 == P
765   // 23 == U
766   let Inst{22} = isByte;
767   let Inst{21} = 0;  // 21 == W
768   let Inst{20} = isLd;
770 // Indexed load/stores
771 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
772                 IndexMode im, Format f, InstrItinClass itin, string opc,
773                 string asm, string cstr, list<dag> pattern>
774   : I<oops, iops, AddrMode2, 4, im, f, itin,
775       opc, asm, cstr, pattern> {
776   bits<4> Rt;
777   let Inst{27-26} = 0b01;
778   let Inst{24}    = isPre; // P bit
779   let Inst{22}    = isByte; // B bit
780   let Inst{21}    = isPre; // W bit
781   let Inst{20}    = isLd; // L bit
782   let Inst{15-12} = Rt;
784 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
785                 IndexMode im, Format f, InstrItinClass itin, string opc,
786                 string asm, string cstr, list<dag> pattern>
787   : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
788                pattern> {
789   // AM2 store w/ two operands: (GPR, am2offset)
790   // {12}     isAdd
791   // {11-0}   imm12/Rm
792   bits<14> offset;
793   bits<4> Rn;
794   let Inst{25} = 1;
795   let Inst{23} = offset{12};
796   let Inst{19-16} = Rn;
797   let Inst{11-5} = offset{11-5};
798   let Inst{4} = 0;
799   let Inst{3-0} = offset{3-0};
802 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
803                 IndexMode im, Format f, InstrItinClass itin, string opc,
804                 string asm, string cstr, list<dag> pattern>
805   : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
806                pattern> {
807   // AM2 store w/ two operands: (GPR, am2offset)
808   // {12}     isAdd
809   // {11-0}   imm12/Rm
810   bits<14> offset;
811   bits<4> Rn;
812   let Inst{25} = 0;
813   let Inst{23} = offset{12};
814   let Inst{19-16} = Rn;
815   let Inst{11-0} = offset{11-0};
819 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
820 // but for now use this class for STRT and STRBT.
821 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
822                 IndexMode im, Format f, InstrItinClass itin, string opc,
823                 string asm, string cstr, list<dag> pattern>
824   : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
825                pattern> {
826   // AM2 store w/ two operands: (GPR, am2offset)
827   // {17-14}  Rn
828   // {13}     1 == Rm, 0 == imm12
829   // {12}     isAdd
830   // {11-0}   imm12/Rm
831   bits<18> addr;
832   let Inst{25} = addr{13};
833   let Inst{23} = addr{12};
834   let Inst{19-16} = addr{17-14};
835   let Inst{11-0} = addr{11-0};
838 // addrmode3 instructions
839 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
840             InstrItinClass itin, string opc, string asm, list<dag> pattern>
841   : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
842       opc, asm, "", pattern> {
843   bits<14> addr;
844   bits<4> Rt;
845   let Inst{27-25} = 0b000;
846   let Inst{24}    = 1;            // P bit
847   let Inst{23}    = addr{8};      // U bit
848   let Inst{22}    = addr{13};     // 1 == imm8, 0 == Rm
849   let Inst{21}    = 0;            // W bit
850   let Inst{20}    = op20;         // L bit
851   let Inst{19-16} = addr{12-9};   // Rn
852   let Inst{15-12} = Rt;           // Rt
853   let Inst{11-8}  = addr{7-4};    // imm7_4/zero
854   let Inst{7-4}   = op;
855   let Inst{3-0}   = addr{3-0};    // imm3_0/Rm
857   let DecoderMethod = "DecodeAddrMode3Instruction";
860 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
861                 IndexMode im, Format f, InstrItinClass itin, string opc,
862                 string asm, string cstr, list<dag> pattern>
863   : I<oops, iops, AddrMode3, 4, im, f, itin,
864       opc, asm, cstr, pattern> {
865   bits<4> Rt;
866   let Inst{27-25} = 0b000;
867   let Inst{24}    = isPre;        // P bit
868   let Inst{21}    = isPre;        // W bit
869   let Inst{20}    = op20;         // L bit
870   let Inst{15-12} = Rt;           // Rt
871   let Inst{7-4}   = op;
874 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
875 // but for now use this class for LDRSBT, LDRHT, LDSHT.
876 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
877                   IndexMode im, Format f, InstrItinClass itin, string opc,
878                   string asm, string cstr, list<dag> pattern>
879   : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
880   // {13}     1 == imm8, 0 == Rm
881   // {12-9}   Rn
882   // {8}      isAdd
883   // {7-4}    imm7_4/zero
884   // {3-0}    imm3_0/Rm
885   bits<4> addr;
886   bits<4> Rt;
887   let Inst{27-25} = 0b000;
888   let Inst{24}    = 0;            // P bit
889   let Inst{21}    = 1;
890   let Inst{20}    = isLoad;       // L bit
891   let Inst{19-16} = addr;         // Rn
892   let Inst{15-12} = Rt;           // Rt
893   let Inst{7-4}   = op;
896 // stores
897 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
898              string opc, string asm, list<dag> pattern>
899   : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
900       opc, asm, "", pattern> {
901   bits<14> addr;
902   bits<4> Rt;
903   let Inst{27-25} = 0b000;
904   let Inst{24}    = 1;            // P bit
905   let Inst{23}    = addr{8};      // U bit
906   let Inst{22}    = addr{13};     // 1 == imm8, 0 == Rm
907   let Inst{21}    = 0;            // W bit
908   let Inst{20}    = 0;            // L bit
909   let Inst{19-16} = addr{12-9};   // Rn
910   let Inst{15-12} = Rt;           // Rt
911   let Inst{11-8}  = addr{7-4};    // imm7_4/zero
912   let Inst{7-4}   = op;
913   let Inst{3-0}   = addr{3-0};    // imm3_0/Rm
914   let DecoderMethod = "DecodeAddrMode3Instruction";
917 // addrmode4 instructions
918 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
919            string asm, string cstr, list<dag> pattern>
920   : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
921   bits<4>  p;
922   bits<16> regs;
923   bits<4>  Rn;
924   let Inst{31-28} = p;
925   let Inst{27-25} = 0b100;
926   let Inst{22}    = 0; // S bit
927   let Inst{19-16} = Rn;
928   let Inst{15-0}  = regs;
931 // Unsigned multiply, multiply-accumulate instructions.
932 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
933              string opc, string asm, list<dag> pattern>
934   : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
935       opc, asm, "", pattern> {
936   let Inst{7-4}   = 0b1001;
937   let Inst{20}    = 0; // S bit
938   let Inst{27-21} = opcod;
940 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
941               string opc, string asm, list<dag> pattern>
942   : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
943        opc, asm, "", pattern> {
944   let Inst{7-4}   = 0b1001;
945   let Inst{27-21} = opcod;
948 // Most significant word multiply
949 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
950              InstrItinClass itin, string opc, string asm, list<dag> pattern>
951   : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
952       opc, asm, "", pattern> {
953   bits<4> Rd;
954   bits<4> Rn;
955   bits<4> Rm;
956   let Inst{7-4}   = opc7_4;
957   let Inst{20}    = 1;
958   let Inst{27-21} = opcod;
959   let Inst{19-16} = Rd;
960   let Inst{11-8}  = Rm;
961   let Inst{3-0}   = Rn;
963 // MSW multiple w/ Ra operand
964 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
965               InstrItinClass itin, string opc, string asm, list<dag> pattern>
966   : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
967   bits<4> Ra;
968   let Inst{15-12} = Ra;
971 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
972 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
973               InstrItinClass itin, string opc, string asm, list<dag> pattern>
974   : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
975       opc, asm, "", pattern> {
976   bits<4> Rn;
977   bits<4> Rm;
978   let Inst{4}     = 0;
979   let Inst{7}     = 1;
980   let Inst{20}    = 0;
981   let Inst{27-21} = opcod;
982   let Inst{6-5}   = bit6_5;
983   let Inst{11-8}  = Rm;
984   let Inst{3-0}   = Rn;
986 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
987               InstrItinClass itin, string opc, string asm, list<dag> pattern>
988   : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
989   bits<4> Rd;
990   let Inst{19-16} = Rd;
993 // AMulxyI with Ra operand
994 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
995               InstrItinClass itin, string opc, string asm, list<dag> pattern>
996   : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
997   bits<4> Ra;
998   let Inst{15-12} = Ra;
1000 // SMLAL*
1001 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
1002               InstrItinClass itin, string opc, string asm, list<dag> pattern>
1003   : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
1004   bits<4> RdLo;
1005   bits<4> RdHi;
1006   let Inst{19-16} = RdHi;
1007   let Inst{15-12} = RdLo;
1010 // Extend instructions.
1011 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
1012             string opc, string asm, list<dag> pattern>
1013   : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
1014       opc, asm, "", pattern> {
1015   // All AExtI instructions have Rd and Rm register operands.
1016   bits<4> Rd;
1017   bits<4> Rm;
1018   let Inst{15-12} = Rd;
1019   let Inst{3-0}   = Rm;
1020   let Inst{7-4}   = 0b0111;
1021   let Inst{9-8}   = 0b00;
1022   let Inst{27-20} = opcod;
1024   let Unpredictable{9-8} = 0b11;
1027 // Misc Arithmetic instructions.
1028 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
1029                InstrItinClass itin, string opc, string asm, list<dag> pattern>
1030   : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1031       opc, asm, "", pattern> {
1032   bits<4> Rd;
1033   bits<4> Rm;
1034   let Inst{27-20} = opcod;
1035   let Inst{19-16} = 0b1111;
1036   let Inst{15-12} = Rd;
1037   let Inst{11-8}  = 0b1111;
1038   let Inst{7-4}   = opc7_4;
1039   let Inst{3-0}   = Rm;
1042 // Division instructions.
1043 class ADivA1I<bits<3> opcod, dag oops, dag iops,
1044               InstrItinClass itin, string opc, string asm, list<dag> pattern>
1045   : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1046       opc, asm, "", pattern> {
1047   bits<4> Rd;
1048   bits<4> Rn;
1049   bits<4> Rm;
1050   let Inst{27-23} = 0b01110;
1051   let Inst{22-20} = opcod;
1052   let Inst{19-16} = Rd;
1053   let Inst{15-12} = 0b1111;
1054   let Inst{11-8}  = Rm;
1055   let Inst{7-4}   = 0b0001;
1056   let Inst{3-0}   = Rn;
1059 // PKH instructions
1060 def PKHLSLAsmOperand : ImmAsmOperand<0,31> {
1061   let Name = "PKHLSLImm";
1062   let ParserMethod = "parsePKHLSLImm";
1064 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
1065   let PrintMethod = "printPKHLSLShiftImm";
1066   let ParserMatchClass = PKHLSLAsmOperand;
1068 def PKHASRAsmOperand : AsmOperandClass {
1069   let Name = "PKHASRImm";
1070   let ParserMethod = "parsePKHASRImm";
1072 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
1073   let PrintMethod = "printPKHASRShiftImm";
1074   let ParserMatchClass = PKHASRAsmOperand;
1077 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
1078             string opc, string asm, list<dag> pattern>
1079   : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
1080       opc, asm, "", pattern> {
1081   bits<4> Rd;
1082   bits<4> Rn;
1083   bits<4> Rm;
1084   bits<5> sh;
1085   let Inst{27-20} = opcod;
1086   let Inst{19-16} = Rn;
1087   let Inst{15-12} = Rd;
1088   let Inst{11-7}  = sh;
1089   let Inst{6}     = tb;
1090   let Inst{5-4}   = 0b01;
1091   let Inst{3-0}   = Rm;
1094 //===----------------------------------------------------------------------===//
1096 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
1097 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
1098   list<Predicate> Predicates = [IsARM];
1100 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
1101   list<Predicate> Predicates = [IsARM, HasV5T];
1103 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
1104   list<Predicate> Predicates = [IsARM, HasV5TE];
1106 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
1107 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
1108   list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
1110 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
1111   list<Predicate> Predicates = [IsARM, HasV6];
1113 class VFPPat<dag pattern, dag result> : Pat<pattern, result> {
1114   list<Predicate> Predicates = [HasVFP2];
1116 class VFPNoNEONPat<dag pattern, dag result> : Pat<pattern, result> {
1117   list<Predicate> Predicates = [HasVFP2, DontUseNEONForFP];
1119 class Thumb2DSPPat<dag pattern, dag result> : Pat<pattern, result> {
1120   list<Predicate> Predicates = [IsThumb2, HasDSP];
1122 class Thumb2DSPMulPat<dag pattern, dag result> : Pat<pattern, result> {
1123   list<Predicate> Predicates = [IsThumb2, UseMulOps, HasDSP];
1125 class FP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1126   list<Predicate> Predicates = [HasFP16];
1128 class FullFP16Pat<dag pattern, dag result> : Pat<pattern, result> {
1129   list<Predicate> Predicates = [HasFullFP16];
1131 //===----------------------------------------------------------------------===//
1132 // Thumb Instruction Format Definitions.
1135 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
1136              InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1137   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1138   let OutOperandList = oops;
1139   let InOperandList = iops;
1140   let AsmString = asm;
1141   let Pattern = pattern;
1142   list<Predicate> Predicates = [IsThumb];
1145 // TI - Thumb instruction.
1146 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1147   : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1149 // Two-address instructions
1150 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1151           list<dag> pattern>
1152   : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1153            pattern>;
1155 // tBL, tBX 32-bit instructions
1156 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1157            dag oops, dag iops, InstrItinClass itin, string asm,
1158            list<dag> pattern>
1159     : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1160       Encoding {
1161   let Inst{31-27} = opcod1;
1162   let Inst{15-14} = opcod2;
1163   let Inst{12}    = opcod3;
1166 // BR_JT instructions
1167 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1168            list<dag> pattern>
1169   : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1171 // Thumb1 only
1172 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1173               InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1174   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1175   let OutOperandList = oops;
1176   let InOperandList = iops;
1177   let AsmString = asm;
1178   let Pattern = pattern;
1179   list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1182 class T1I<dag oops, dag iops, InstrItinClass itin,
1183           string asm, list<dag> pattern>
1184   : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1185 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1186             string asm, list<dag> pattern>
1187   : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1189 // Two-address instructions
1190 class T1It<dag oops, dag iops, InstrItinClass itin,
1191            string asm, string cstr, list<dag> pattern>
1192   : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1193             asm, cstr, pattern>;
1195 // Thumb1 instruction that can either be predicated or set CPSR.
1196 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1197                InstrItinClass itin,
1198                string opc, string asm, string cstr, list<dag> pattern>
1199   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1200   let OutOperandList = !con(oops, (outs s_cc_out:$s));
1201   let InOperandList = !con(iops, (ins pred:$p));
1202   let AsmString = !strconcat(opc, "${s}${p}", asm);
1203   let Pattern = pattern;
1204   let thumbArithFlagSetting = 1;
1205   list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1206   let DecoderNamespace = "ThumbSBit";
1209 class T1sI<dag oops, dag iops, InstrItinClass itin,
1210            string opc, string asm, list<dag> pattern>
1211   : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1213 // Two-address instructions
1214 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1215             string opc, string asm, list<dag> pattern>
1216   : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1217              "$Rn = $Rdn", pattern>;
1219 // Thumb1 instruction that can be predicated.
1220 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1221                InstrItinClass itin,
1222                string opc, string asm, string cstr, list<dag> pattern>
1223   : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1224   let OutOperandList = oops;
1225   let InOperandList = !con(iops, (ins pred:$p));
1226   let AsmString = !strconcat(opc, "${p}", asm);
1227   let Pattern = pattern;
1228   list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1231 class T1pI<dag oops, dag iops, InstrItinClass itin,
1232            string opc, string asm, list<dag> pattern>
1233   : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1235 // Two-address instructions
1236 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1237             string opc, string asm, list<dag> pattern>
1238   : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1239              "$Rn = $Rdn", pattern>;
1241 class T1pIs<dag oops, dag iops,
1242             InstrItinClass itin, string opc, string asm, list<dag> pattern>
1243   : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1245 class Encoding16 : Encoding {
1246   let Inst{31-16} = 0x0000;
1249 // A6.2 16-bit Thumb instruction encoding
1250 class T1Encoding<bits<6> opcode> : Encoding16 {
1251   let Inst{15-10} = opcode;
1254 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1255 class T1General<bits<5> opcode> : Encoding16 {
1256   let Inst{15-14} = 0b00;
1257   let Inst{13-9} = opcode;
1260 // A6.2.2 Data-processing encoding.
1261 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1262   let Inst{15-10} = 0b010000;
1263   let Inst{9-6} = opcode;
1266 // A6.2.3 Special data instructions and branch and exchange encoding.
1267 class T1Special<bits<4> opcode> : Encoding16 {
1268   let Inst{15-10} = 0b010001;
1269   let Inst{9-6}   = opcode;
1272 // A6.2.4 Load/store single data item encoding.
1273 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1274   let Inst{15-12} = opA;
1275   let Inst{11-9}  = opB;
1277 class T1LdStSP<bits<3> opB>   : T1LoadStore<0b1001, opB>; // SP relative
1279 class T1BranchCond<bits<4> opcode> : Encoding16 {
1280   let Inst{15-12} = opcode;
1283 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1284 // following bits are used for "opA" (see A6.2.4):
1286 //   0b0110 => Immediate, 4 bytes
1287 //   0b1000 => Immediate, 2 bytes
1288 //   0b0111 => Immediate, 1 byte
1289 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1290                      InstrItinClass itin, string opc, string asm,
1291                      list<dag> pattern>
1292   : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1293     T1LoadStore<0b0101, opcode> {
1294   bits<3> Rt;
1295   bits<8> addr;
1296   let Inst{8-6} = addr{5-3};    // Rm
1297   let Inst{5-3} = addr{2-0};    // Rn
1298   let Inst{2-0} = Rt;
1300 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1301                         InstrItinClass itin, string opc, string asm,
1302                         list<dag> pattern>
1303   : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1304     T1LoadStore<opA, {opB,?,?}> {
1305   bits<3> Rt;
1306   bits<8> addr;
1307   let Inst{10-6} = addr{7-3};   // imm5
1308   let Inst{5-3}  = addr{2-0};   // Rn
1309   let Inst{2-0}  = Rt;
1312 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1313 class T1Misc<bits<7> opcode> : Encoding16 {
1314   let Inst{15-12} = 0b1011;
1315   let Inst{11-5} = opcode;
1318 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1319 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1320               InstrItinClass itin,
1321               string opc, string asm, string cstr, list<dag> pattern>
1322   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1323   let OutOperandList = oops;
1324   let InOperandList = !con(iops, (ins pred:$p));
1325   let AsmString = !strconcat(opc, "${p}", asm);
1326   let Pattern = pattern;
1327   list<Predicate> Predicates = [IsThumb2];
1328   let DecoderNamespace = "Thumb2";
1331 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1332 // input operand since by default it's a zero register. It will become an
1333 // implicit def once it's "flipped".
1335 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1336 // more consistent.
1337 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1338                InstrItinClass itin,
1339                string opc, string asm, string cstr, list<dag> pattern>
1340   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1341   bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1342   let Inst{20} = s;
1344   let OutOperandList = oops;
1345   let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1346   let AsmString = !strconcat(opc, "${s}${p}", asm);
1347   let Pattern = pattern;
1348   list<Predicate> Predicates = [IsThumb2];
1349   let DecoderNamespace = "Thumb2";
1352 // Special cases
1353 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1354                InstrItinClass itin,
1355                string asm, string cstr, list<dag> pattern>
1356   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1357   let OutOperandList = oops;
1358   let InOperandList = iops;
1359   let AsmString = asm;
1360   let Pattern = pattern;
1361   list<Predicate> Predicates = [IsThumb2];
1362   let DecoderNamespace = "Thumb2";
1365 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1366               InstrItinClass itin,
1367               string asm, string cstr, list<dag> pattern>
1368   : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1369   let OutOperandList = oops;
1370   let InOperandList = iops;
1371   let AsmString = asm;
1372   let Pattern = pattern;
1373   list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1374   let DecoderNamespace = "Thumb";
1377 class T2I<dag oops, dag iops, InstrItinClass itin,
1378           string opc, string asm, list<dag> pattern>
1379   : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1380 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1381              string opc, string asm, list<dag> pattern>
1382   : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1383 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1384             string opc, string asm, list<dag> pattern>
1385   : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1386 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1387             string opc, string asm, list<dag> pattern>
1388   : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1389 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1390             string opc, string asm, list<dag> pattern>
1391   : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1392 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1393               string opc, string asm, string cstr, list<dag> pattern>
1394   : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1395             pattern> {
1396   bits<4> Rt;
1397   bits<4> Rt2;
1398   bits<13> addr;
1399   let Inst{31-25} = 0b1110100;
1400   let Inst{24}    = P;
1401   let Inst{23}    = addr{8};
1402   let Inst{22}    = 1;
1403   let Inst{21}    = W;
1404   let Inst{20}    = isLoad;
1405   let Inst{19-16} = addr{12-9};
1406   let Inst{15-12} = Rt{3-0};
1407   let Inst{11-8}  = Rt2{3-0};
1408   let Inst{7-0}   = addr{7-0};
1410 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1411                   InstrItinClass itin, string opc, string asm, string cstr,
1412                   list<dag> pattern>
1413   : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1414             pattern> {
1415   bits<4> Rt;
1416   bits<4> Rt2;
1417   bits<4> addr;
1418   bits<9> imm;
1419   let Inst{31-25} = 0b1110100;
1420   let Inst{24}    = P;
1421   let Inst{23}    = imm{8};
1422   let Inst{22}    = 1;
1423   let Inst{21}    = W;
1424   let Inst{20}    = isLoad;
1425   let Inst{19-16} = addr;
1426   let Inst{15-12} = Rt{3-0};
1427   let Inst{11-8}  = Rt2{3-0};
1428   let Inst{7-0}   = imm{7-0};
1431 class T2sI<dag oops, dag iops, InstrItinClass itin,
1432            string opc, string asm, list<dag> pattern>
1433   : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1435 class T2XI<dag oops, dag iops, InstrItinClass itin,
1436            string asm, list<dag> pattern>
1437   : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1438 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1439             string asm, list<dag> pattern>
1440   : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1442 // Move to/from coprocessor instructions
1443 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1444             list<dag> pattern>
1445   : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1446   let Inst{31-28} = opc;
1449 // Two-address instructions
1450 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1451             string asm, string cstr, list<dag> pattern>
1452   : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1454 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1455 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1456                  dag oops, dag iops,
1457                  AddrMode am, IndexMode im, InstrItinClass itin,
1458                  string opc, string asm, string cstr, list<dag> pattern>
1459   : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1460   let OutOperandList = oops;
1461   let InOperandList = !con(iops, (ins pred:$p));
1462   let AsmString = !strconcat(opc, "${p}", asm);
1463   let Pattern = pattern;
1464   list<Predicate> Predicates = [IsThumb2];
1465   let DecoderNamespace = "Thumb2";
1467   bits<4> Rt;
1468   bits<13> addr;
1469   let Inst{31-27} = 0b11111;
1470   let Inst{26-25} = 0b00;
1471   let Inst{24}    = signed;
1472   let Inst{23}    = 0;
1473   let Inst{22-21} = opcod;
1474   let Inst{20}    = load;
1475   let Inst{19-16} = addr{12-9};
1476   let Inst{15-12} = Rt{3-0};
1477   let Inst{11}    = 1;
1478   // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1479   let Inst{10}    = pre; // The P bit.
1480   let Inst{9}     = addr{8}; // Sign bit
1481   let Inst{8}     = 1; // The W bit.
1482   let Inst{7-0}   = addr{7-0};
1484   let DecoderMethod = "DecodeT2LdStPre";
1487 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1488 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1489                  dag oops, dag iops,
1490                  AddrMode am, IndexMode im, InstrItinClass itin,
1491                  string opc, string asm, string cstr, list<dag> pattern>
1492   : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1493   let OutOperandList = oops;
1494   let InOperandList = !con(iops, (ins pred:$p));
1495   let AsmString = !strconcat(opc, "${p}", asm);
1496   let Pattern = pattern;
1497   list<Predicate> Predicates = [IsThumb2];
1498   let DecoderNamespace = "Thumb2";
1500   bits<4> Rt;
1501   bits<4> Rn;
1502   bits<9> offset;
1503   let Inst{31-27} = 0b11111;
1504   let Inst{26-25} = 0b00;
1505   let Inst{24}    = signed;
1506   let Inst{23}    = 0;
1507   let Inst{22-21} = opcod;
1508   let Inst{20}    = load;
1509   let Inst{19-16} = Rn;
1510   let Inst{15-12} = Rt{3-0};
1511   let Inst{11}    = 1;
1512   // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1513   let Inst{10}    = pre; // The P bit.
1514   let Inst{9}     = offset{8}; // Sign bit
1515   let Inst{8}     = 1; // The W bit.
1516   let Inst{7-0}   = offset{7-0};
1518   let DecoderMethod = "DecodeT2LdStPre";
1521 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1522 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1523   list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1526 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1527 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1528   list<Predicate> Predicates = [IsThumb2, HasV6T2];
1531 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1532 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1533   list<Predicate> Predicates = [IsThumb2];
1536 //===----------------------------------------------------------------------===//
1538 //===----------------------------------------------------------------------===//
1539 // ARM VFP Instruction templates.
1542 // Almost all VFP instructions are predicable.
1543 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1544            IndexMode im, Format f, InstrItinClass itin,
1545            string opc, string asm, string cstr, list<dag> pattern>
1546   : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1547   bits<4> p;
1548   let Inst{31-28} = p;
1549   let OutOperandList = oops;
1550   let InOperandList = !con(iops, (ins pred:$p));
1551   let AsmString = !strconcat(opc, "${p}", asm);
1552   let Pattern = pattern;
1553   let PostEncoderMethod = "VFPThumb2PostEncoder";
1554   let DecoderNamespace = "VFP";
1555   list<Predicate> Predicates = [HasVFP2];
1558 // Special cases
1559 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1560             IndexMode im, Format f, InstrItinClass itin,
1561             string asm, string cstr, list<dag> pattern>
1562   : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1563   bits<4> p;
1564   let Inst{31-28} = p;
1565   let OutOperandList = oops;
1566   let InOperandList = iops;
1567   let AsmString = asm;
1568   let Pattern = pattern;
1569   let PostEncoderMethod = "VFPThumb2PostEncoder";
1570   let DecoderNamespace = "VFP";
1571   list<Predicate> Predicates = [HasVFP2];
1574 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1575             string opc, string asm, list<dag> pattern>
1576   : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1577          opc, asm, "", pattern> {
1578   let PostEncoderMethod = "VFPThumb2PostEncoder";
1581 // ARM VFP addrmode5 loads and stores
1582 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1583            InstrItinClass itin,
1584            string opc, string asm, list<dag> pattern>
1585   : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1586          VFPLdStFrm, itin, opc, asm, "", pattern> {
1587   // Instruction operands.
1588   bits<5>  Dd;
1589   bits<13> addr;
1591   // Encode instruction operands.
1592   let Inst{23}    = addr{8};      // U (add = (U == '1'))
1593   let Inst{22}    = Dd{4};
1594   let Inst{19-16} = addr{12-9};   // Rn
1595   let Inst{15-12} = Dd{3-0};
1596   let Inst{7-0}   = addr{7-0};    // imm8
1598   let Inst{27-24} = opcod1;
1599   let Inst{21-20} = opcod2;
1600   let Inst{11-9}  = 0b101;
1601   let Inst{8}     = 1;          // Double precision
1603   // Loads & stores operate on both NEON and VFP pipelines.
1604   let D = VFPNeonDomain;
1607 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1608            InstrItinClass itin,
1609            string opc, string asm, list<dag> pattern>
1610   : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1611          VFPLdStFrm, itin, opc, asm, "", pattern> {
1612   // Instruction operands.
1613   bits<5>  Sd;
1614   bits<13> addr;
1616   // Encode instruction operands.
1617   let Inst{23}    = addr{8};      // U (add = (U == '1'))
1618   let Inst{22}    = Sd{0};
1619   let Inst{19-16} = addr{12-9};   // Rn
1620   let Inst{15-12} = Sd{4-1};
1621   let Inst{7-0}   = addr{7-0};    // imm8
1623   let Inst{27-24} = opcod1;
1624   let Inst{21-20} = opcod2;
1625   let Inst{11-9}  = 0b101;
1626   let Inst{8}     = 0;          // Single precision
1628   // Loads & stores operate on both NEON and VFP pipelines.
1629   let D = VFPNeonDomain;
1632 class AHI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1633            InstrItinClass itin,
1634            string opc, string asm, list<dag> pattern>
1635   : VFPI<oops, iops, AddrMode5FP16, 4, IndexModeNone,
1636          VFPLdStFrm, itin, opc, asm, "", pattern> {
1637   list<Predicate> Predicates = [HasFullFP16];
1639   // Instruction operands.
1640   bits<5>  Sd;
1641   bits<13> addr;
1643   // Encode instruction operands.
1644   let Inst{23}    = addr{8};      // U (add = (U == '1'))
1645   let Inst{22}    = Sd{0};
1646   let Inst{19-16} = addr{12-9};   // Rn
1647   let Inst{15-12} = Sd{4-1};
1648   let Inst{7-0}   = addr{7-0};    // imm8
1650   let Inst{27-24} = opcod1;
1651   let Inst{21-20} = opcod2;
1652   let Inst{11-8}  = 0b1001;     // Half precision
1654   // Loads & stores operate on both NEON and VFP pipelines.
1655   let D = VFPNeonDomain;
1657   let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
1660 // VFP Load / store multiple pseudo instructions.
1661 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1662                      list<dag> pattern>
1663   : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1664             cstr, itin> {
1665   let OutOperandList = oops;
1666   let InOperandList = !con(iops, (ins pred:$p));
1667   let Pattern = pattern;
1668   list<Predicate> Predicates = [HasVFP2];
1671 // Load / store multiple
1673 // Unknown precision
1674 class AXXI4<dag oops, dag iops, IndexMode im,
1675             string asm, string cstr, list<dag> pattern>
1676   : VFPXI<oops, iops, AddrMode4, 4, im,
1677           VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1678   // Instruction operands.
1679   bits<4>  Rn;
1680   bits<13> regs;
1682   // Encode instruction operands.
1683   let Inst{19-16} = Rn;
1684   let Inst{22}    = 0;
1685   let Inst{15-12} = regs{11-8};
1686   let Inst{7-1}   = regs{7-1};
1688   let Inst{27-25} = 0b110;
1689   let Inst{11-8}  = 0b1011;
1690   let Inst{0}     = 1;
1693 // Double precision
1694 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1695             string asm, string cstr, list<dag> pattern>
1696   : VFPXI<oops, iops, AddrMode4, 4, im,
1697           VFPLdStMulFrm, itin, asm, cstr, pattern> {
1698   // Instruction operands.
1699   bits<4>  Rn;
1700   bits<13> regs;
1702   // Encode instruction operands.
1703   let Inst{19-16} = Rn;
1704   let Inst{22}    = regs{12};
1705   let Inst{15-12} = regs{11-8};
1706   let Inst{7-1}   = regs{7-1};
1708   let Inst{27-25} = 0b110;
1709   let Inst{11-9}  = 0b101;
1710   let Inst{8}     = 1;          // Double precision
1711   let Inst{0}     = 0;
1714 // Single Precision
1715 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1716             string asm, string cstr, list<dag> pattern>
1717   : VFPXI<oops, iops, AddrMode4, 4, im,
1718           VFPLdStMulFrm, itin, asm, cstr, pattern> {
1719   // Instruction operands.
1720   bits<4> Rn;
1721   bits<13> regs;
1723   // Encode instruction operands.
1724   let Inst{19-16} = Rn;
1725   let Inst{22}    = regs{8};
1726   let Inst{15-12} = regs{12-9};
1727   let Inst{7-0}   = regs{7-0};
1729   let Inst{27-25} = 0b110;
1730   let Inst{11-9}  = 0b101;
1731   let Inst{8}     = 0;          // Single precision
1734 // Double precision, unary
1735 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1736            bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1737            string asm, list<dag> pattern>
1738   : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1739   // Instruction operands.
1740   bits<5> Dd;
1741   bits<5> Dm;
1743   // Encode instruction operands.
1744   let Inst{3-0}   = Dm{3-0};
1745   let Inst{5}     = Dm{4};
1746   let Inst{15-12} = Dd{3-0};
1747   let Inst{22}    = Dd{4};
1749   let Inst{27-23} = opcod1;
1750   let Inst{21-20} = opcod2;
1751   let Inst{19-16} = opcod3;
1752   let Inst{11-9}  = 0b101;
1753   let Inst{8}     = 1;          // Double precision
1754   let Inst{7-6}   = opcod4;
1755   let Inst{4}     = opcod5;
1757   let Predicates = [HasVFP2, HasDPVFP];
1760 // Double precision, unary, not-predicated
1761 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1762            bit opcod5, dag oops, dag iops, InstrItinClass itin,
1763            string asm, list<dag> pattern>
1764   : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1765   // Instruction operands.
1766   bits<5> Dd;
1767   bits<5> Dm;
1769   let Inst{31-28} = 0b1111;
1771   // Encode instruction operands.
1772   let Inst{3-0}   = Dm{3-0};
1773   let Inst{5}     = Dm{4};
1774   let Inst{15-12} = Dd{3-0};
1775   let Inst{22}    = Dd{4};
1777   let Inst{27-23} = opcod1;
1778   let Inst{21-20} = opcod2;
1779   let Inst{19-16} = opcod3;
1780   let Inst{11-9}  = 0b101;
1781   let Inst{8}     = 1;          // Double precision
1782   let Inst{7-6}   = opcod4;
1783   let Inst{4}     = opcod5;
1786 // Double precision, binary
1787 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1788            dag iops, InstrItinClass itin, string opc, string asm,
1789            list<dag> pattern>
1790   : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1791   // Instruction operands.
1792   bits<5> Dd;
1793   bits<5> Dn;
1794   bits<5> Dm;
1796   // Encode instruction operands.
1797   let Inst{3-0}   = Dm{3-0};
1798   let Inst{5}     = Dm{4};
1799   let Inst{19-16} = Dn{3-0};
1800   let Inst{7}     = Dn{4};
1801   let Inst{15-12} = Dd{3-0};
1802   let Inst{22}    = Dd{4};
1804   let Inst{27-23} = opcod1;
1805   let Inst{21-20} = opcod2;
1806   let Inst{11-9}  = 0b101;
1807   let Inst{8}     = 1;          // Double precision
1808   let Inst{6}     = op6;
1809   let Inst{4}     = op4;
1811   let Predicates = [HasVFP2, HasDPVFP];
1814 // FP, binary, not predicated
1815 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1816            InstrItinClass itin, string asm, list<dag> pattern>
1817   : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1818           asm, "", pattern>
1820   // Instruction operands.
1821   bits<5> Dd;
1822   bits<5> Dn;
1823   bits<5> Dm;
1825   let Inst{31-28} = 0b1111;
1827   // Encode instruction operands.
1828   let Inst{3-0}   = Dm{3-0};
1829   let Inst{5}     = Dm{4};
1830   let Inst{19-16} = Dn{3-0};
1831   let Inst{7}     = Dn{4};
1832   let Inst{15-12} = Dd{3-0};
1833   let Inst{22}    = Dd{4};
1835   let Inst{27-23} = opcod1;
1836   let Inst{21-20} = opcod2;
1837   let Inst{11-9}  = 0b101;
1838   let Inst{8}     = 1; // double precision
1839   let Inst{6}     = opcod3;
1840   let Inst{4}     = 0;
1842   let Predicates = [HasVFP2, HasDPVFP];
1845 // Single precision, unary, predicated
1846 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1847            bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1848            string asm, list<dag> pattern>
1849   : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1850   // Instruction operands.
1851   bits<5> Sd;
1852   bits<5> Sm;
1854   // Encode instruction operands.
1855   let Inst{3-0}   = Sm{4-1};
1856   let Inst{5}     = Sm{0};
1857   let Inst{15-12} = Sd{4-1};
1858   let Inst{22}    = Sd{0};
1860   let Inst{27-23} = opcod1;
1861   let Inst{21-20} = opcod2;
1862   let Inst{19-16} = opcod3;
1863   let Inst{11-9}  = 0b101;
1864   let Inst{8}     = 0;          // Single precision
1865   let Inst{7-6}   = opcod4;
1866   let Inst{4}     = opcod5;
1869 // Single precision, unary, non-predicated
1870 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1871              bit opcod5, dag oops, dag iops, InstrItinClass itin,
1872              string asm, list<dag> pattern>
1873   : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1874           VFPUnaryFrm, itin, asm, "", pattern> {
1875   // Instruction operands.
1876   bits<5> Sd;
1877   bits<5> Sm;
1879   let Inst{31-28} = 0b1111;
1881   // Encode instruction operands.
1882   let Inst{3-0}   = Sm{4-1};
1883   let Inst{5}     = Sm{0};
1884   let Inst{15-12} = Sd{4-1};
1885   let Inst{22}    = Sd{0};
1887   let Inst{27-23} = opcod1;
1888   let Inst{21-20} = opcod2;
1889   let Inst{19-16} = opcod3;
1890   let Inst{11-9}  = 0b101;
1891   let Inst{8}     = 0;          // Single precision
1892   let Inst{7-6}   = opcod4;
1893   let Inst{4}     = opcod5;
1896 // Single precision unary, if no NEON. Same as ASuI except not available if
1897 // NEON is enabled.
1898 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1899             bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1900             string asm, list<dag> pattern>
1901   : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1902          pattern> {
1903   list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1906 // Single precision, binary
1907 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1908            InstrItinClass itin, string opc, string asm, list<dag> pattern>
1909   : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1910   // Instruction operands.
1911   bits<5> Sd;
1912   bits<5> Sn;
1913   bits<5> Sm;
1915   // Encode instruction operands.
1916   let Inst{3-0}   = Sm{4-1};
1917   let Inst{5}     = Sm{0};
1918   let Inst{19-16} = Sn{4-1};
1919   let Inst{7}     = Sn{0};
1920   let Inst{15-12} = Sd{4-1};
1921   let Inst{22}    = Sd{0};
1923   let Inst{27-23} = opcod1;
1924   let Inst{21-20} = opcod2;
1925   let Inst{11-9}  = 0b101;
1926   let Inst{8}     = 0;          // Single precision
1927   let Inst{6}     = op6;
1928   let Inst{4}     = op4;
1931 // Single precision, binary, not predicated
1932 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1933            InstrItinClass itin, string asm, list<dag> pattern>
1934   : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1935           VFPBinaryFrm, itin, asm, "", pattern>
1937   // Instruction operands.
1938   bits<5> Sd;
1939   bits<5> Sn;
1940   bits<5> Sm;
1942   let Inst{31-28} = 0b1111;
1944   // Encode instruction operands.
1945   let Inst{3-0}   = Sm{4-1};
1946   let Inst{5}     = Sm{0};
1947   let Inst{19-16} = Sn{4-1};
1948   let Inst{7}     = Sn{0};
1949   let Inst{15-12} = Sd{4-1};
1950   let Inst{22}    = Sd{0};
1952   let Inst{27-23} = opcod1;
1953   let Inst{21-20} = opcod2;
1954   let Inst{11-9}  = 0b101;
1955   let Inst{8}     = 0; // Single precision
1956   let Inst{6}     = opcod3;
1957   let Inst{4}     = 0;
1960 // Single precision binary, if no NEON. Same as ASbI except not available if
1961 // NEON is enabled.
1962 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1963             dag iops, InstrItinClass itin, string opc, string asm,
1964             list<dag> pattern>
1965   : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1966   list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1968   // Instruction operands.
1969   bits<5> Sd;
1970   bits<5> Sn;
1971   bits<5> Sm;
1973   // Encode instruction operands.
1974   let Inst{3-0}   = Sm{4-1};
1975   let Inst{5}     = Sm{0};
1976   let Inst{19-16} = Sn{4-1};
1977   let Inst{7}     = Sn{0};
1978   let Inst{15-12} = Sd{4-1};
1979   let Inst{22}    = Sd{0};
1982 // Half precision, unary, predicated
1983 class AHuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1984            bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1985            string asm, list<dag> pattern>
1986   : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1987   list<Predicate> Predicates = [HasFullFP16];
1989   // Instruction operands.
1990   bits<5> Sd;
1991   bits<5> Sm;
1993   // Encode instruction operands.
1994   let Inst{3-0}   = Sm{4-1};
1995   let Inst{5}     = Sm{0};
1996   let Inst{15-12} = Sd{4-1};
1997   let Inst{22}    = Sd{0};
1999   let Inst{27-23} = opcod1;
2000   let Inst{21-20} = opcod2;
2001   let Inst{19-16} = opcod3;
2002   let Inst{11-8}  = 0b1001;   // Half precision
2003   let Inst{7-6}   = opcod4;
2004   let Inst{4}     = opcod5;
2006   let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2009 // Half precision, unary, non-predicated
2010 class AHuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
2011              bit opcod5, dag oops, dag iops, InstrItinClass itin,
2012              string asm, list<dag> pattern>
2013   : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2014           VFPUnaryFrm, itin, asm, "", pattern> {
2015   list<Predicate> Predicates = [HasFullFP16];
2017   // Instruction operands.
2018   bits<5> Sd;
2019   bits<5> Sm;
2021   let Inst{31-28} = 0b1111;
2023   // Encode instruction operands.
2024   let Inst{3-0}   = Sm{4-1};
2025   let Inst{5}     = Sm{0};
2026   let Inst{15-12} = Sd{4-1};
2027   let Inst{22}    = Sd{0};
2029   let Inst{27-23} = opcod1;
2030   let Inst{21-20} = opcod2;
2031   let Inst{19-16} = opcod3;
2032   let Inst{11-8}  = 0b1001;   // Half precision
2033   let Inst{7-6}   = opcod4;
2034   let Inst{4}     = opcod5;
2036   let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2039 // Half precision, binary
2040 class AHbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
2041            InstrItinClass itin, string opc, string asm, list<dag> pattern>
2042   : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
2043   list<Predicate> Predicates = [HasFullFP16];
2045   // Instruction operands.
2046   bits<5> Sd;
2047   bits<5> Sn;
2048   bits<5> Sm;
2050   // Encode instruction operands.
2051   let Inst{3-0}   = Sm{4-1};
2052   let Inst{5}     = Sm{0};
2053   let Inst{19-16} = Sn{4-1};
2054   let Inst{7}     = Sn{0};
2055   let Inst{15-12} = Sd{4-1};
2056   let Inst{22}    = Sd{0};
2058   let Inst{27-23} = opcod1;
2059   let Inst{21-20} = opcod2;
2060   let Inst{11-8}  = 0b1001;   // Half precision
2061   let Inst{6}     = op6;
2062   let Inst{4}     = op4;
2064   let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2067 // Half precision, binary, not predicated
2068 class AHbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
2069            InstrItinClass itin, string asm, list<dag> pattern>
2070   : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
2071           VFPBinaryFrm, itin, asm, "", pattern> {
2072   list<Predicate> Predicates = [HasFullFP16];
2074   // Instruction operands.
2075   bits<5> Sd;
2076   bits<5> Sn;
2077   bits<5> Sm;
2079   let Inst{31-28} = 0b1111;
2081   // Encode instruction operands.
2082   let Inst{3-0}   = Sm{4-1};
2083   let Inst{5}     = Sm{0};
2084   let Inst{19-16} = Sn{4-1};
2085   let Inst{7}     = Sn{0};
2086   let Inst{15-12} = Sd{4-1};
2087   let Inst{22}    = Sd{0};
2089   let Inst{27-23} = opcod1;
2090   let Inst{21-20} = opcod2;
2091   let Inst{11-8}  = 0b1001;   // Half precision
2092   let Inst{6}     = opcod3;
2093   let Inst{4}     = 0;
2095   let isUnpredicable = 1; // FP16 instructions cannot in general be conditional
2098 // VFP conversion instructions
2099 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2100                dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2101                list<dag> pattern>
2102   : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
2103   let Inst{27-23} = opcod1;
2104   let Inst{21-20} = opcod2;
2105   let Inst{19-16} = opcod3;
2106   let Inst{11-8}  = opcod4;
2107   let Inst{6}     = 1;
2108   let Inst{4}     = 0;
2111 // VFP conversion between floating-point and fixed-point
2112 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
2113                 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
2114                 list<dag> pattern>
2115   : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
2116   bits<5> fbits;
2117   // size (fixed-point number): sx == 0 ? 16 : 32
2118   let Inst{7} = op5; // sx
2119   let Inst{5} = fbits{0};
2120   let Inst{3-0} = fbits{4-1};
2123 // VFP conversion instructions, if no NEON
2124 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
2125                 dag oops, dag iops, InstrItinClass itin,
2126                 string opc, string asm, list<dag> pattern>
2127   : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
2128              pattern> {
2129   list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
2132 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
2133                InstrItinClass itin,
2134                string opc, string asm, list<dag> pattern>
2135   : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
2136   let Inst{27-20} = opcod1;
2137   let Inst{11-8}  = opcod2;
2138   let Inst{4}     = 1;
2141 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2142                InstrItinClass itin, string opc, string asm, list<dag> pattern>
2143   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
2145 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2146                InstrItinClass itin, string opc, string asm, list<dag> pattern>
2147   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
2149 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2150                InstrItinClass itin, string opc, string asm, list<dag> pattern>
2151   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
2153 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
2154                InstrItinClass itin, string opc, string asm, list<dag> pattern>
2155   : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
2157 //===----------------------------------------------------------------------===//
2159 //===----------------------------------------------------------------------===//
2160 // ARM NEON Instruction templates.
2163 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2164             InstrItinClass itin, string opc, string dt, string asm, string cstr,
2165             list<dag> pattern>
2166   : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2167   let OutOperandList = oops;
2168   let InOperandList = !con(iops, (ins pred:$p));
2169   let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2170   let Pattern = pattern;
2171   list<Predicate> Predicates = [HasNEON];
2172   let DecoderNamespace = "NEON";
2175 // Same as NeonI except it does not have a "data type" specifier.
2176 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2177              InstrItinClass itin, string opc, string asm, string cstr,
2178              list<dag> pattern>
2179   : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2180   let OutOperandList = oops;
2181   let InOperandList = !con(iops, (ins pred:$p));
2182   let AsmString = !strconcat(opc, "${p}", "\t", asm);
2183   let Pattern = pattern;
2184   list<Predicate> Predicates = [HasNEON];
2185   let DecoderNamespace = "NEON";
2188 // Same as NeonI except it is not predicated
2189 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
2190             InstrItinClass itin, string opc, string dt, string asm, string cstr,
2191             list<dag> pattern>
2192   : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
2193   let OutOperandList = oops;
2194   let InOperandList = iops;
2195   let AsmString = !strconcat(opc, ".", dt, "\t", asm);
2196   let Pattern = pattern;
2197   list<Predicate> Predicates = [HasNEON];
2198   let DecoderNamespace = "NEON";
2200   let Inst{31-28} = 0b1111;
2203 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2204             dag oops, dag iops, InstrItinClass itin,
2205             string opc, string dt, string asm, string cstr, list<dag> pattern>
2206   : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
2207           cstr, pattern> {
2208   let Inst{31-24} = 0b11110100;
2209   let Inst{23}    = op23;
2210   let Inst{21-20} = op21_20;
2211   let Inst{11-8}  = op11_8;
2212   let Inst{7-4}   = op7_4;
2214   let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
2215   let DecoderNamespace = "NEONLoadStore";
2217   bits<5> Vd;
2218   bits<6> Rn;
2219   bits<4> Rm;
2221   let Inst{22}    = Vd{4};
2222   let Inst{15-12} = Vd{3-0};
2223   let Inst{19-16} = Rn{3-0};
2224   let Inst{3-0}   = Rm{3-0};
2227 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
2228             dag oops, dag iops, InstrItinClass itin,
2229             string opc, string dt, string asm, string cstr, list<dag> pattern>
2230   : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
2231           dt, asm, cstr, pattern> {
2232   bits<3> lane;
2235 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
2236   : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2237             itin> {
2238   let OutOperandList = oops;
2239   let InOperandList = !con(iops, (ins pred:$p));
2240   list<Predicate> Predicates = [HasNEON];
2243 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
2244                   list<dag> pattern>
2245   : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
2246             itin> {
2247   let OutOperandList = oops;
2248   let InOperandList = !con(iops, (ins pred:$p));
2249   let Pattern = pattern;
2250   list<Predicate> Predicates = [HasNEON];
2253 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
2254              string opc, string dt, string asm, string cstr, list<dag> pattern>
2255   : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
2256           pattern> {
2257   let Inst{31-25} = 0b1111001;
2258   let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2259   let DecoderNamespace = "NEONData";
2262 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
2263               string opc, string asm, string cstr, list<dag> pattern>
2264   : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
2265            cstr, pattern> {
2266   let Inst{31-25} = 0b1111001;
2267   let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
2268   let DecoderNamespace = "NEONData";
2271 // NEON "one register and a modified immediate" format.
2272 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
2273                bit op5, bit op4,
2274                dag oops, dag iops, InstrItinClass itin,
2275                string opc, string dt, string asm, string cstr,
2276                list<dag> pattern>
2277   : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
2278   let Inst{23}    = op23;
2279   let Inst{21-19} = op21_19;
2280   let Inst{11-8}  = op11_8;
2281   let Inst{7}     = op7;
2282   let Inst{6}     = op6;
2283   let Inst{5}     = op5;
2284   let Inst{4}     = op4;
2286   // Instruction operands.
2287   bits<5> Vd;
2288   bits<13> SIMM;
2290   let Inst{15-12} = Vd{3-0};
2291   let Inst{22}    = Vd{4};
2292   let Inst{24}    = SIMM{7};
2293   let Inst{18-16} = SIMM{6-4};
2294   let Inst{3-0}   = SIMM{3-0};
2295   let DecoderMethod = "DecodeVMOVModImmInstruction";
2298 // NEON 2 vector register format.
2299 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2300           bits<5> op11_7, bit op6, bit op4,
2301           dag oops, dag iops, InstrItinClass itin,
2302           string opc, string dt, string asm, string cstr, list<dag> pattern>
2303   : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2304   let Inst{24-23} = op24_23;
2305   let Inst{21-20} = op21_20;
2306   let Inst{19-18} = op19_18;
2307   let Inst{17-16} = op17_16;
2308   let Inst{11-7}  = op11_7;
2309   let Inst{6}     = op6;
2310   let Inst{4}     = op4;
2312   // Instruction operands.
2313   bits<5> Vd;
2314   bits<5> Vm;
2316   let Inst{15-12} = Vd{3-0};
2317   let Inst{22}    = Vd{4};
2318   let Inst{3-0}   = Vm{3-0};
2319   let Inst{5}     = Vm{4};
2322 // Same as N2V but not predicated.
2323 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2324             dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2325             string Dt, list<dag> pattern>
2326    : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2327              OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2328   bits<5> Vd;
2329   bits<5> Vm;
2331   // Encode instruction operands
2332   let Inst{22}    = Vd{4};
2333   let Inst{15-12} = Vd{3-0};
2334   let Inst{5}     = Vm{4};
2335   let Inst{3-0}   = Vm{3-0};
2337   // Encode constant bits
2338   let Inst{27-23} = 0b00111;
2339   let Inst{21-20} = 0b11;
2340   let Inst{19-18} = op19_18;
2341   let Inst{17-16} = op17_16;
2342   let Inst{11} = 0;
2343   let Inst{10-8} = op10_8;
2344   let Inst{7} = op7;
2345   let Inst{6} = op6;
2346   let Inst{4} = 0;
2348   let DecoderNamespace = "NEON";
2351 // Same as N2V except it doesn't have a datatype suffix.
2352 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2353            bits<5> op11_7, bit op6, bit op4,
2354            dag oops, dag iops, InstrItinClass itin,
2355            string opc, string asm, string cstr, list<dag> pattern>
2356   : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2357   let Inst{24-23} = op24_23;
2358   let Inst{21-20} = op21_20;
2359   let Inst{19-18} = op19_18;
2360   let Inst{17-16} = op17_16;
2361   let Inst{11-7}  = op11_7;
2362   let Inst{6}     = op6;
2363   let Inst{4}     = op4;
2365   // Instruction operands.
2366   bits<5> Vd;
2367   bits<5> Vm;
2369   let Inst{15-12} = Vd{3-0};
2370   let Inst{22}    = Vd{4};
2371   let Inst{3-0}   = Vm{3-0};
2372   let Inst{5}     = Vm{4};
2375 // NEON 2 vector register with immediate.
2376 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2377              dag oops, dag iops, Format f, InstrItinClass itin,
2378              string opc, string dt, string asm, string cstr, list<dag> pattern>
2379   : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2380   let Inst{24}   = op24;
2381   let Inst{23}   = op23;
2382   let Inst{11-8} = op11_8;
2383   let Inst{7}    = op7;
2384   let Inst{6}    = op6;
2385   let Inst{4}    = op4;
2387   // Instruction operands.
2388   bits<5> Vd;
2389   bits<5> Vm;
2390   bits<6> SIMM;
2392   let Inst{15-12} = Vd{3-0};
2393   let Inst{22}    = Vd{4};
2394   let Inst{3-0}   = Vm{3-0};
2395   let Inst{5}     = Vm{4};
2396   let Inst{21-16} = SIMM{5-0};
2399 // NEON 3 vector register format.
2401 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2402                 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2403                 string opc, string dt, string asm, string cstr,
2404                 list<dag> pattern>
2405   : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2406   let Inst{24}    = op24;
2407   let Inst{23}    = op23;
2408   let Inst{21-20} = op21_20;
2409   let Inst{11-8}  = op11_8;
2410   let Inst{6}     = op6;
2411   let Inst{4}     = op4;
2414 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2415           dag oops, dag iops, Format f, InstrItinClass itin,
2416           string opc, string dt, string asm, string cstr, list<dag> pattern>
2417   : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2418               oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2419   // Instruction operands.
2420   bits<5> Vd;
2421   bits<5> Vn;
2422   bits<5> Vm;
2424   let Inst{15-12} = Vd{3-0};
2425   let Inst{22}    = Vd{4};
2426   let Inst{19-16} = Vn{3-0};
2427   let Inst{7}     = Vn{4};
2428   let Inst{3-0}   = Vm{3-0};
2429   let Inst{5}     = Vm{4};
2432 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2433                 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2434                 string OpcodeStr, string Dt, list<dag> pattern>
2435   : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2436             Dt, "$Vd, $Vn, $Vm", "", pattern> {
2437   bits<5> Vd;
2438   bits<5> Vn;
2439   bits<5> Vm;
2441   // Encode instruction operands
2442   let Inst{22} = Vd{4};
2443   let Inst{15-12} = Vd{3-0};
2444   let Inst{19-16} = Vn{3-0};
2445   let Inst{7} = Vn{4};
2446   let Inst{5} = Vm{4};
2447   let Inst{3-0} = Vm{3-0};
2449   // Encode constant bits
2450   let Inst{27-23} = op27_23;
2451   let Inst{21-20} = op21_20;
2452   let Inst{11-8}  = op11_8;
2453   let Inst{6}     = op6;
2454   let Inst{4}     = op4;
2457 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2458                 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2459                 string opc, string dt, string asm, string cstr,
2460                 list<dag> pattern>
2461   : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2462               oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2464   // Instruction operands.
2465   bits<5> Vd;
2466   bits<5> Vn;
2467   bits<5> Vm;
2468   bit lane;
2470   let Inst{15-12} = Vd{3-0};
2471   let Inst{22}    = Vd{4};
2472   let Inst{19-16} = Vn{3-0};
2473   let Inst{7}     = Vn{4};
2474   let Inst{3-0}   = Vm{3-0};
2475   let Inst{5}     = lane;
2478 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2479                 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2480                 string opc, string dt, string asm, string cstr,
2481                 list<dag> pattern>
2482   : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2483               oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2485   // Instruction operands.
2486   bits<5> Vd;
2487   bits<5> Vn;
2488   bits<5> Vm;
2489   bits<2> lane;
2491   let Inst{15-12} = Vd{3-0};
2492   let Inst{22}    = Vd{4};
2493   let Inst{19-16} = Vn{3-0};
2494   let Inst{7}     = Vn{4};
2495   let Inst{2-0}   = Vm{2-0};
2496   let Inst{5}     = lane{1};
2497   let Inst{3}     = lane{0};
2500 // Same as N3V except it doesn't have a data type suffix.
2501 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2502            bit op4,
2503            dag oops, dag iops, Format f, InstrItinClass itin,
2504            string opc, string asm, string cstr, list<dag> pattern>
2505   : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2506   let Inst{24}    = op24;
2507   let Inst{23}    = op23;
2508   let Inst{21-20} = op21_20;
2509   let Inst{11-8}  = op11_8;
2510   let Inst{6}     = op6;
2511   let Inst{4}     = op4;
2513   // Instruction operands.
2514   bits<5> Vd;
2515   bits<5> Vn;
2516   bits<5> Vm;
2518   let Inst{15-12} = Vd{3-0};
2519   let Inst{22}    = Vd{4};
2520   let Inst{19-16} = Vn{3-0};
2521   let Inst{7}     = Vn{4};
2522   let Inst{3-0}   = Vm{3-0};
2523   let Inst{5}     = Vm{4};
2526 // NEON VMOVs between scalar and core registers.
2527 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2528                dag oops, dag iops, Format f, InstrItinClass itin,
2529                string opc, string dt, string asm, list<dag> pattern>
2530   : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2531             "", itin> {
2532   let Inst{27-20} = opcod1;
2533   let Inst{11-8}  = opcod2;
2534   let Inst{6-5}   = opcod3;
2535   let Inst{4}     = 1;
2536   // A8.6.303, A8.6.328, A8.6.329
2537   let Inst{3-0}   = 0b0000;
2539   let OutOperandList = oops;
2540   let InOperandList = !con(iops, (ins pred:$p));
2541   let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2542   let Pattern = pattern;
2543   list<Predicate> Predicates = [HasNEON];
2545   let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2546   let DecoderNamespace = "NEONDup";
2548   bits<5> V;
2549   bits<4> R;
2550   bits<4> p;
2551   bits<4> lane;
2553   let Inst{31-28} = p{3-0};
2554   let Inst{7}     = V{4};
2555   let Inst{19-16} = V{3-0};
2556   let Inst{15-12} = R{3-0};
2558 class NVGetLane<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, NGetLnFrm, itin,
2562              opc, dt, asm, pattern>;
2563 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2564                 dag oops, dag iops, InstrItinClass itin,
2565                 string opc, string dt, string asm, list<dag> pattern>
2566   : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2567              opc, dt, asm, pattern>;
2568 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2569             dag oops, dag iops, InstrItinClass itin,
2570             string opc, string dt, string asm, list<dag> pattern>
2571   : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2572              opc, dt, asm, pattern>;
2574 // Vector Duplicate Lane (from scalar to all elements)
2575 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2576                 InstrItinClass itin, string opc, string dt, string asm,
2577                 list<dag> pattern>
2578   : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2579   let Inst{24-23} = 0b11;
2580   let Inst{21-20} = 0b11;
2581   let Inst{19-16} = op19_16;
2582   let Inst{11-7}  = 0b11000;
2583   let Inst{6}     = op6;
2584   let Inst{4}     = 0;
2586   bits<5> Vd;
2587   bits<5> Vm;
2589   let Inst{22}     = Vd{4};
2590   let Inst{15-12} = Vd{3-0};
2591   let Inst{5}     = Vm{4};
2592   let Inst{3-0} = Vm{3-0};
2595 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2596 // for single-precision FP.
2597 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2598   list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2601 // VFP/NEON Instruction aliases for type suffices.
2602 // Note: When EmitPriority == 1, the alias will be used for printing
2603 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result, bit EmitPriority = 0> :
2604   InstAlias<!strconcat(opc, dt, "\t", asm), Result, EmitPriority>, Requires<[HasFPRegs]>;
2606 // Note: When EmitPriority == 1, the alias will be used for printing
2607 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2608   def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2609   def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2610   def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2611   def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2614 // Note: When EmitPriority == 1, the alias will be used for printing
2615 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result, bit EmitPriority = 0> {
2616   let Predicates = [HasNEON] in {
2617   def : VFPDataTypeInstAlias<opc, ".8", asm, Result, EmitPriority>;
2618   def : VFPDataTypeInstAlias<opc, ".16", asm, Result, EmitPriority>;
2619   def : VFPDataTypeInstAlias<opc, ".32", asm, Result, EmitPriority>;
2620   def : VFPDataTypeInstAlias<opc, ".64", asm, Result, EmitPriority>;
2624 // The same alias classes using AsmPseudo instead, for the more complex
2625 // stuff in NEON that InstAlias can't quite handle.
2626 // Note that we can't use anonymous defm references here like we can
2627 // above, as we care about the ultimate instruction enum names generated, unlike
2628 // for instalias defs.
2629 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2630   AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2632 // Extension of NEON 3-vector data processing instructions in coprocessor 8
2633 // encoding space, introduced in ARMv8.3-A.
2634 class N3VCP8<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2635              dag oops, dag iops, InstrItinClass itin,
2636              string opc, string dt, string asm, string cstr, list<dag> pattern>
2637   : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2638             dt, asm, cstr, pattern> {
2639   bits<5> Vd;
2640   bits<5> Vn;
2641   bits<5> Vm;
2643   let DecoderNamespace = "VFPV8";
2644   // These have the same encodings in ARM and Thumb2
2645   let PostEncoderMethod = "";
2647   let Inst{31-25} = 0b1111110;
2648   let Inst{24-23} = op24_23;
2649   let Inst{22}    = Vd{4};
2650   let Inst{21-20} = op21_20;
2651   let Inst{19-16} = Vn{3-0};
2652   let Inst{15-12} = Vd{3-0};
2653   let Inst{11-8}  = 0b1000;
2654   let Inst{7}     = Vn{4};
2655   let Inst{6}     = op6;
2656   let Inst{5}     = Vm{4};
2657   let Inst{4}     = op4;
2658   let Inst{3-0}   = Vm{3-0};
2661 // Extension of NEON 2-vector-and-scalar data processing instructions in
2662 // coprocessor 8 encoding space, introduced in ARMv8.3-A.
2663 class N3VLaneCP8<bit op23, bits<2> op21_20, bit op6, bit op4,
2664              dag oops, dag iops, InstrItinClass itin,
2665              string opc, string dt, string asm, string cstr, list<dag> pattern>
2666   : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc,
2667             dt, asm, cstr, pattern> {
2668   bits<5> Vd;
2669   bits<5> Vn;
2670   bits<5> Vm;
2672   let DecoderNamespace = "VFPV8";
2673   // These have the same encodings in ARM and Thumb2
2674   let PostEncoderMethod = "";
2676   let Inst{31-24} = 0b11111110;
2677   let Inst{23}    = op23;
2678   let Inst{22}    = Vd{4};
2679   let Inst{21-20} = op21_20;
2680   let Inst{19-16} = Vn{3-0};
2681   let Inst{15-12} = Vd{3-0};
2682   let Inst{11-8}  = 0b1000;
2683   let Inst{7}     = Vn{4};
2684   let Inst{6}     = op6;
2685   // Bit 5 set by sub-classes
2686   let Inst{4}     = op4;
2687   let Inst{3-0}   = Vm{3-0};
2690 // In Armv8.2-A, some NEON instructions are added that encode Vn and Vm
2691 // differently:
2692 //    if Q == ‘1’ then UInt(N:Vn) else UInt(Vn:N);
2693 //    if Q == ‘1’ then UInt(M:Vm) else UInt(Vm:M);
2694 // Class N3VCP8 above describes the Q=1 case, and this class the Q=0 case.
2695 class N3VCP8Q0<bits<2> op24_23, bits<2> op21_20, bit op6, bit op4,
2696              dag oops, dag iops, InstrItinClass itin,
2697              string opc, string dt, string asm, string cstr, list<dag> pattern>
2698   : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N3RegCplxFrm, itin, opc, dt, asm, cstr, pattern> {
2699   bits<5> Vd;
2700   bits<5> Vn;
2701   bits<5> Vm;
2703   let DecoderNamespace = "VFPV8";
2704   // These have the same encodings in ARM and Thumb2
2705   let PostEncoderMethod = "";
2707   let Inst{31-25} = 0b1111110;
2708   let Inst{24-23} = op24_23;
2709   let Inst{22}    = Vd{4};
2710   let Inst{21-20} = op21_20;
2711   let Inst{19-16} = Vn{4-1};
2712   let Inst{15-12} = Vd{3-0};
2713   let Inst{11-8}  = 0b1000;
2714   let Inst{7}     = Vn{0};
2715   let Inst{6}     = op6;
2716   let Inst{5}     = Vm{0};
2717   let Inst{4}     = op4;
2718   let Inst{3-0}   = Vm{4-1};
2721 // Operand types for complex instructions
2722 class ComplexRotationOperand<int Angle, int Remainder, string Type, string Diag>
2723   : AsmOperandClass {
2724   let PredicateMethod = "isComplexRotation<" # Angle # ", " # Remainder # ">";
2725   let DiagnosticString = "complex rotation must be " # Diag;
2726   let Name = "ComplexRotation" # Type;
2728 def complexrotateop : Operand<i32> {
2729   let ParserMatchClass = ComplexRotationOperand<90, 0, "Even", "0, 90, 180 or 270">;
2730   let PrintMethod = "printComplexRotationOp<90, 0>";
2732 def complexrotateopodd : Operand<i32> {
2733   let ParserMatchClass = ComplexRotationOperand<180, 90, "Odd", "90 or 270">;
2734   let PrintMethod = "printComplexRotationOp<180, 90>";
2737 def MveSaturateOperand : AsmOperandClass {
2738   let PredicateMethod = "isMveSaturateOp";
2739   let DiagnosticString = "saturate operand must be 48 or 64";
2740   let Name = "MveSaturate";
2742 def saturateop : Operand<i32> {
2743   let ParserMatchClass = MveSaturateOperand;
2744   let PrintMethod = "printMveSaturateOp";
2747 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2748 def : TokenAlias<".s8", ".i8">;
2749 def : TokenAlias<".u8", ".i8">;
2750 def : TokenAlias<".s16", ".i16">;
2751 def : TokenAlias<".u16", ".i16">;
2752 def : TokenAlias<".s32", ".i32">;
2753 def : TokenAlias<".u32", ".i32">;
2754 def : TokenAlias<".s64", ".i64">;
2755 def : TokenAlias<".u64", ".i64">;
2757 def : TokenAlias<".i8", ".8">;
2758 def : TokenAlias<".i16", ".16">;
2759 def : TokenAlias<".i32", ".32">;
2760 def : TokenAlias<".i64", ".64">;
2762 def : TokenAlias<".p8", ".8">;
2763 def : TokenAlias<".p16", ".16">;
2765 def : TokenAlias<".f32", ".32">;
2766 def : TokenAlias<".f64", ".64">;
2767 def : TokenAlias<".f", ".f32">;
2768 def : TokenAlias<".d", ".f64">;