1 //===-- ARMInstrFormats.td - ARM Instruction Formats -------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 // ARM Instruction Format Definitions.
15 // Format specifies the encoding used by the instruction. This is part of the
16 // ad-hoc solution used to emit machine instruction encodings by our machine
18 class Format<bits<6> val> {
22 def Pseudo : Format<0>;
23 def MulFrm : Format<1>;
24 def BrFrm : Format<2>;
25 def BrMiscFrm : Format<3>;
27 def DPFrm : Format<4>;
28 def DPSoRegRegFrm : Format<5>;
30 def LdFrm : Format<6>;
31 def StFrm : Format<7>;
32 def LdMiscFrm : Format<8>;
33 def StMiscFrm : Format<9>;
34 def LdStMulFrm : Format<10>;
36 def LdStExFrm : Format<11>;
38 def ArithMiscFrm : Format<12>;
39 def SatFrm : Format<13>;
40 def ExtFrm : Format<14>;
42 def VFPUnaryFrm : Format<15>;
43 def VFPBinaryFrm : Format<16>;
44 def VFPConv1Frm : Format<17>;
45 def VFPConv2Frm : Format<18>;
46 def VFPConv3Frm : Format<19>;
47 def VFPConv4Frm : Format<20>;
48 def VFPConv5Frm : Format<21>;
49 def VFPLdStFrm : Format<22>;
50 def VFPLdStMulFrm : Format<23>;
51 def VFPMiscFrm : Format<24>;
53 def ThumbFrm : Format<25>;
54 def MiscFrm : Format<26>;
56 def NGetLnFrm : Format<27>;
57 def NSetLnFrm : Format<28>;
58 def NDupFrm : Format<29>;
59 def NLdStFrm : Format<30>;
60 def N1RegModImmFrm: Format<31>;
61 def N2RegFrm : Format<32>;
62 def NVCVTFrm : Format<33>;
63 def NVDupLnFrm : Format<34>;
64 def N2RegVShLFrm : Format<35>;
65 def N2RegVShRFrm : Format<36>;
66 def N3RegFrm : Format<37>;
67 def N3RegVShFrm : Format<38>;
68 def NVExtFrm : Format<39>;
69 def NVMulSLFrm : Format<40>;
70 def NVTBLFrm : Format<41>;
71 def DPSoRegImmFrm : Format<42>;
75 // The instruction has an Rn register operand.
76 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
77 // it doesn't have a Rn operand.
78 class UnaryDP { bit isUnaryDataProc = 1; }
80 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
81 // a 16-bit Thumb instruction if certain conditions are met.
82 class Xform16Bit { bit canXformTo16Bit = 1; }
84 //===----------------------------------------------------------------------===//
85 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
88 // FIXME: Once the JIT is MC-ized, these can go away.
90 class AddrMode<bits<5> val> {
93 def AddrModeNone : AddrMode<0>;
94 def AddrMode1 : AddrMode<1>;
95 def AddrMode2 : AddrMode<2>;
96 def AddrMode3 : AddrMode<3>;
97 def AddrMode4 : AddrMode<4>;
98 def AddrMode5 : AddrMode<5>;
99 def AddrMode6 : AddrMode<6>;
100 def AddrModeT1_1 : AddrMode<7>;
101 def AddrModeT1_2 : AddrMode<8>;
102 def AddrModeT1_4 : AddrMode<9>;
103 def AddrModeT1_s : AddrMode<10>;
104 def AddrModeT2_i12 : AddrMode<11>;
105 def AddrModeT2_i8 : AddrMode<12>;
106 def AddrModeT2_so : AddrMode<13>;
107 def AddrModeT2_pc : AddrMode<14>;
108 def AddrModeT2_i8s4 : AddrMode<15>;
109 def AddrMode_i12 : AddrMode<16>;
111 // Load / store index mode.
112 class IndexMode<bits<2> val> {
115 def IndexModeNone : IndexMode<0>;
116 def IndexModePre : IndexMode<1>;
117 def IndexModePost : IndexMode<2>;
118 def IndexModeUpd : IndexMode<3>;
120 // Instruction execution domain.
121 class Domain<bits<3> val> {
124 def GenericDomain : Domain<0>;
125 def VFPDomain : Domain<1>; // Instructions in VFP domain only
126 def NeonDomain : Domain<2>; // Instructions in Neon domain only
127 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
128 def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
130 //===----------------------------------------------------------------------===//
131 // ARM special operands.
134 // ARM imod and iflag operands, used only by the CPS instruction.
135 def imod_op : Operand<i32> {
136 let PrintMethod = "printCPSIMod";
139 def ProcIFlagsOperand : AsmOperandClass {
140 let Name = "ProcIFlags";
141 let ParserMethod = "parseProcIFlagsOperand";
143 def iflags_op : Operand<i32> {
144 let PrintMethod = "printCPSIFlag";
145 let ParserMatchClass = ProcIFlagsOperand;
148 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
149 // register whose default is 0 (no register).
150 def CondCodeOperand : AsmOperandClass { let Name = "CondCode"; }
151 def pred : PredicateOperand<OtherVT, (ops i32imm, i32imm),
152 (ops (i32 14), (i32 zero_reg))> {
153 let PrintMethod = "printPredicateOperand";
154 let ParserMatchClass = CondCodeOperand;
155 let DecoderMethod = "DecodePredicateOperand";
158 // Selectable predicate operand for CMOV instructions. We can't use a normal
159 // predicate because the default values interfere with instruction selection. In
160 // all other respects it is identical though: pseudo-instruction expansion
161 // relies on the MachineOperands being compatible.
162 def cmovpred : Operand<i32>, PredicateOp,
163 ComplexPattern<i32, 2, "SelectCMOVPred"> {
164 let MIOperandInfo = (ops i32imm, i32imm);
165 let PrintMethod = "printPredicateOperand";
168 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
169 def CCOutOperand : AsmOperandClass { let Name = "CCOut"; }
170 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
171 let EncoderMethod = "getCCOutOpValue";
172 let PrintMethod = "printSBitModifierOperand";
173 let ParserMatchClass = CCOutOperand;
174 let DecoderMethod = "DecodeCCOutOperand";
177 // Same as cc_out except it defaults to setting CPSR.
178 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
179 let EncoderMethod = "getCCOutOpValue";
180 let PrintMethod = "printSBitModifierOperand";
181 let ParserMatchClass = CCOutOperand;
182 let DecoderMethod = "DecodeCCOutOperand";
185 // ARM special operands for disassembly only.
187 def SetEndAsmOperand : ImmAsmOperand {
188 let Name = "SetEndImm";
189 let ParserMethod = "parseSetEndImm";
191 def setend_op : Operand<i32> {
192 let PrintMethod = "printSetendOperand";
193 let ParserMatchClass = SetEndAsmOperand;
196 def MSRMaskOperand : AsmOperandClass {
197 let Name = "MSRMask";
198 let ParserMethod = "parseMSRMaskOperand";
200 def msr_mask : Operand<i32> {
201 let PrintMethod = "printMSRMaskOperand";
202 let DecoderMethod = "DecodeMSRMask";
203 let ParserMatchClass = MSRMaskOperand;
206 def BankedRegOperand : AsmOperandClass {
207 let Name = "BankedReg";
208 let ParserMethod = "parseBankedRegOperand";
210 def banked_reg : Operand<i32> {
211 let PrintMethod = "printBankedRegOperand";
212 let DecoderMethod = "DecodeBankedReg";
213 let ParserMatchClass = BankedRegOperand;
216 // Shift Right Immediate - A shift right immediate is encoded differently from
217 // other shift immediates. The imm6 field is encoded like so:
220 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
221 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
222 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
223 // 64 64 - <imm> is encoded in imm6<5:0>
224 def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; }
225 def shr_imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 8; }]> {
226 let EncoderMethod = "getShiftRight8Imm";
227 let DecoderMethod = "DecodeShiftRight8Imm";
228 let ParserMatchClass = shr_imm8_asm_operand;
230 def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; }
231 def shr_imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 16; }]> {
232 let EncoderMethod = "getShiftRight16Imm";
233 let DecoderMethod = "DecodeShiftRight16Imm";
234 let ParserMatchClass = shr_imm16_asm_operand;
236 def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; }
237 def shr_imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]> {
238 let EncoderMethod = "getShiftRight32Imm";
239 let DecoderMethod = "DecodeShiftRight32Imm";
240 let ParserMatchClass = shr_imm32_asm_operand;
242 def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; }
243 def shr_imm64 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 64; }]> {
244 let EncoderMethod = "getShiftRight64Imm";
245 let DecoderMethod = "DecodeShiftRight64Imm";
246 let ParserMatchClass = shr_imm64_asm_operand;
249 //===----------------------------------------------------------------------===//
250 // ARM Assembler alias templates.
252 class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
253 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
254 class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
255 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
256 class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
257 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
258 class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
259 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
260 class VFP2DPInstAlias<string Asm, dag Result, bit Emit = 0b1>
261 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2,HasDPVFP]>;
262 class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
263 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
264 class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
265 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
268 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
270 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
273 //===----------------------------------------------------------------------===//
274 // ARM Instruction templates.
278 class InstTemplate<AddrMode am, int sz, IndexMode im,
279 Format f, Domain d, string cstr, InstrItinClass itin>
281 let Namespace = "ARM";
286 bits<2> IndexModeBits = IM.Value;
288 bits<6> Form = F.Value;
290 bit isUnaryDataProc = 0;
291 bit canXformTo16Bit = 0;
292 // The instruction is a 16-bit flag setting Thumb instruction. Used
293 // by the parser to determine whether to require the 'S' suffix on the
294 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
295 bit thumbArithFlagSetting = 0;
297 // If this is a pseudo instruction, mark it isCodeGenOnly.
298 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
300 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
301 let TSFlags{4-0} = AM.Value;
302 let TSFlags{6-5} = IndexModeBits;
303 let TSFlags{12-7} = Form;
304 let TSFlags{13} = isUnaryDataProc;
305 let TSFlags{14} = canXformTo16Bit;
306 let TSFlags{17-15} = D.Value;
307 let TSFlags{18} = thumbArithFlagSetting;
309 let Constraints = cstr;
310 let Itinerary = itin;
315 // Mask of bits that cause an encoding to be UNPREDICTABLE.
316 // If a bit is set, then if the corresponding bit in the
317 // target encoding differs from its value in the "Inst" field,
318 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
319 field bits<32> Unpredictable = 0;
320 // SoftFail is the generic name for this field, but we alias it so
321 // as to make it more obvious what it means in ARM-land.
322 field bits<32> SoftFail = Unpredictable;
325 class InstARM<AddrMode am, int sz, IndexMode im,
326 Format f, Domain d, string cstr, InstrItinClass itin>
327 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
328 let DecoderNamespace = "ARM";
331 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
332 // on by adding flavors to specific instructions.
333 class InstThumb<AddrMode am, int sz, IndexMode im,
334 Format f, Domain d, string cstr, InstrItinClass itin>
335 : InstTemplate<am, sz, im, f, d, cstr, itin> {
336 let DecoderNamespace = "Thumb";
339 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
340 // These are aliases that require C++ handling to convert to the target
341 // instruction, while InstAliases can be handled directly by tblgen.
342 class AsmPseudoInst<string asm, dag iops, dag oops = (outs)>
343 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
345 let OutOperandList = oops;
346 let InOperandList = iops;
348 let isCodeGenOnly = 0; // So we get asm matcher for it.
353 class ARMAsmPseudo<string asm, dag iops, dag oops = (outs)>
354 : AsmPseudoInst<asm, iops, oops>, Requires<[IsARM]>;
355 class tAsmPseudo<string asm, dag iops, dag oops = (outs)>
356 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb]>;
357 class t2AsmPseudo<string asm, dag iops, dag oops = (outs)>
358 : AsmPseudoInst<asm, iops, oops>, Requires<[IsThumb2]>;
359 class VFP2AsmPseudo<string asm, dag iops, dag oops = (outs)>
360 : AsmPseudoInst<asm, iops, oops>, Requires<[HasVFP2]>;
361 class NEONAsmPseudo<string asm, dag iops, dag oops = (outs)>
362 : AsmPseudoInst<asm, iops, oops>, Requires<[HasNEON]>;
364 // Pseudo instructions for the code generator.
365 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
366 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
367 GenericDomain, "", itin> {
368 let OutOperandList = oops;
369 let InOperandList = iops;
370 let Pattern = pattern;
371 let isCodeGenOnly = 1;
375 // PseudoInst that's ARM-mode only.
376 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
378 : PseudoInst<oops, iops, itin, pattern> {
380 list<Predicate> Predicates = [IsARM];
383 // PseudoInst that's Thumb-mode only.
384 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
386 : PseudoInst<oops, iops, itin, pattern> {
388 list<Predicate> Predicates = [IsThumb];
391 // PseudoInst that's Thumb2-mode only.
392 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
394 : PseudoInst<oops, iops, itin, pattern> {
396 list<Predicate> Predicates = [IsThumb2];
399 class ARMPseudoExpand<dag oops, dag iops, int sz,
400 InstrItinClass itin, list<dag> pattern,
402 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
403 PseudoInstExpansion<Result>;
405 class tPseudoExpand<dag oops, dag iops, int sz,
406 InstrItinClass itin, list<dag> pattern,
408 : tPseudoInst<oops, iops, sz, itin, pattern>,
409 PseudoInstExpansion<Result>;
411 class t2PseudoExpand<dag oops, dag iops, int sz,
412 InstrItinClass itin, list<dag> pattern,
414 : t2PseudoInst<oops, iops, sz, itin, pattern>,
415 PseudoInstExpansion<Result>;
417 // Almost all ARM instructions are predicable.
418 class I<dag oops, dag iops, AddrMode am, int sz,
419 IndexMode im, Format f, InstrItinClass itin,
420 string opc, string asm, string cstr,
422 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
425 let OutOperandList = oops;
426 let InOperandList = !con(iops, (ins pred:$p));
427 let AsmString = !strconcat(opc, "${p}", asm);
428 let Pattern = pattern;
429 list<Predicate> Predicates = [IsARM];
432 // A few are not predicable
433 class InoP<dag oops, dag iops, AddrMode am, int sz,
434 IndexMode im, Format f, InstrItinClass itin,
435 string opc, string asm, string cstr,
437 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
438 let OutOperandList = oops;
439 let InOperandList = iops;
440 let AsmString = !strconcat(opc, asm);
441 let Pattern = pattern;
442 let isPredicable = 0;
443 list<Predicate> Predicates = [IsARM];
446 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
447 // operand since by default it's a zero register. It will become an implicit def
448 // once it's "flipped".
449 class sI<dag oops, dag iops, AddrMode am, int sz,
450 IndexMode im, Format f, InstrItinClass itin,
451 string opc, string asm, string cstr,
453 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
454 bits<4> p; // Predicate operand
455 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
459 let OutOperandList = oops;
460 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
461 let AsmString = !strconcat(opc, "${s}${p}", asm);
462 let Pattern = pattern;
463 list<Predicate> Predicates = [IsARM];
467 class XI<dag oops, dag iops, AddrMode am, int sz,
468 IndexMode im, Format f, InstrItinClass itin,
469 string asm, string cstr, list<dag> pattern>
470 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
471 let OutOperandList = oops;
472 let InOperandList = iops;
474 let Pattern = pattern;
475 list<Predicate> Predicates = [IsARM];
478 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
480 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
481 opc, asm, "", pattern>;
482 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
483 string opc, string asm, list<dag> pattern>
484 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
485 opc, asm, "", pattern>;
486 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
487 string asm, list<dag> pattern>
488 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
490 class AXIM<dag oops, dag iops, AddrMode am, Format f, InstrItinClass itin,
491 string asm, list<dag> pattern>
492 : XI<oops, iops, am, 4, IndexModeNone, f, itin,
494 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
495 string opc, string asm, list<dag> pattern>
496 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
497 opc, asm, "", pattern>;
499 // Ctrl flow instructions
500 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
501 string opc, string asm, list<dag> pattern>
502 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
503 opc, asm, "", pattern> {
504 let Inst{27-24} = opcod;
506 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
507 string asm, list<dag> pattern>
508 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
510 let Inst{27-24} = opcod;
513 // BR_JT instructions
514 class JTI<dag oops, dag iops, InstrItinClass itin,
515 string asm, list<dag> pattern>
516 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
519 class AIldr_ex_or_acq<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
520 string opc, string asm, list<dag> pattern>
521 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
522 opc, asm, "", pattern> {
525 let Inst{27-23} = 0b00011;
526 let Inst{22-21} = opcod;
528 let Inst{19-16} = addr;
529 let Inst{15-12} = Rt;
530 let Inst{11-10} = 0b11;
531 let Inst{9-8} = opcod2;
532 let Inst{7-0} = 0b10011111;
534 class AIstr_ex_or_rel<bits<2> opcod, bits<2> opcod2, dag oops, dag iops, InstrItinClass itin,
535 string opc, string asm, list<dag> pattern>
536 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
537 opc, asm, "", pattern> {
540 let Inst{27-23} = 0b00011;
541 let Inst{22-21} = opcod;
543 let Inst{19-16} = addr;
544 let Inst{11-10} = 0b11;
545 let Inst{9-8} = opcod2;
546 let Inst{7-4} = 0b1001;
549 // Atomic load/store instructions
550 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
551 string opc, string asm, list<dag> pattern>
552 : AIldr_ex_or_acq<opcod, 0b11, oops, iops, itin, opc, asm, pattern>;
554 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
555 string opc, string asm, list<dag> pattern>
556 : AIstr_ex_or_rel<opcod, 0b11, oops, iops, itin, opc, asm, pattern> {
558 let Inst{15-12} = Rd;
561 // Exclusive load/store instructions
563 class AIldaex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
564 string opc, string asm, list<dag> pattern>
565 : AIldr_ex_or_acq<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
566 Requires<[IsARM, HasV8]>;
568 class AIstlex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
569 string opc, string asm, list<dag> pattern>
570 : AIstr_ex_or_rel<opcod, 0b10, oops, iops, itin, opc, asm, pattern>,
571 Requires<[IsARM, HasV8]> {
573 let Inst{15-12} = Rd;
576 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
577 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
581 let Inst{27-23} = 0b00010;
583 let Inst{21-20} = 0b00;
584 let Inst{19-16} = addr;
585 let Inst{15-12} = Rt;
586 let Inst{11-4} = 0b00001001;
589 let Unpredictable{11-8} = 0b1111;
590 let DecoderMethod = "DecodeSwap";
592 // Acquire/Release load/store instructions
593 class AIldracq<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
594 string opc, string asm, list<dag> pattern>
595 : AIldr_ex_or_acq<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
596 Requires<[IsARM, HasV8]>;
598 class AIstrrel<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
599 string opc, string asm, list<dag> pattern>
600 : AIstr_ex_or_rel<opcod, 0b00, oops, iops, itin, opc, asm, pattern>,
601 Requires<[IsARM, HasV8]> {
602 let Inst{15-12} = 0b1111;
605 // addrmode1 instructions
606 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
607 string opc, string asm, list<dag> pattern>
608 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
609 opc, asm, "", pattern> {
610 let Inst{24-21} = opcod;
611 let Inst{27-26} = 0b00;
613 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
614 string opc, string asm, list<dag> pattern>
615 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
616 opc, asm, "", pattern> {
617 let Inst{24-21} = opcod;
618 let Inst{27-26} = 0b00;
620 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
621 string asm, list<dag> pattern>
622 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
624 let Inst{24-21} = opcod;
625 let Inst{27-26} = 0b00;
630 // LDR/LDRB/STR/STRB/...
631 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
632 Format f, InstrItinClass itin, string opc, string asm,
634 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
636 let Inst{27-25} = op;
637 let Inst{24} = 1; // 24 == P
639 let Inst{22} = isByte;
640 let Inst{21} = 0; // 21 == W
643 // Indexed load/stores
644 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
645 IndexMode im, Format f, InstrItinClass itin, string opc,
646 string asm, string cstr, list<dag> pattern>
647 : I<oops, iops, AddrMode2, 4, im, f, itin,
648 opc, asm, cstr, pattern> {
650 let Inst{27-26} = 0b01;
651 let Inst{24} = isPre; // P bit
652 let Inst{22} = isByte; // B bit
653 let Inst{21} = isPre; // W bit
654 let Inst{20} = isLd; // L bit
655 let Inst{15-12} = Rt;
657 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
658 IndexMode im, Format f, InstrItinClass itin, string opc,
659 string asm, string cstr, list<dag> pattern>
660 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
662 // AM2 store w/ two operands: (GPR, am2offset)
668 let Inst{23} = offset{12};
669 let Inst{19-16} = Rn;
670 let Inst{11-5} = offset{11-5};
672 let Inst{3-0} = offset{3-0};
675 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
676 IndexMode im, Format f, InstrItinClass itin, string opc,
677 string asm, string cstr, list<dag> pattern>
678 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
680 // AM2 store w/ two operands: (GPR, am2offset)
686 let Inst{23} = offset{12};
687 let Inst{19-16} = Rn;
688 let Inst{11-0} = offset{11-0};
692 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
693 // but for now use this class for STRT and STRBT.
694 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
695 IndexMode im, Format f, InstrItinClass itin, string opc,
696 string asm, string cstr, list<dag> pattern>
697 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
699 // AM2 store w/ two operands: (GPR, am2offset)
701 // {13} 1 == Rm, 0 == imm12
705 let Inst{25} = addr{13};
706 let Inst{23} = addr{12};
707 let Inst{19-16} = addr{17-14};
708 let Inst{11-0} = addr{11-0};
711 // addrmode3 instructions
712 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
713 InstrItinClass itin, string opc, string asm, list<dag> pattern>
714 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
715 opc, asm, "", pattern> {
718 let Inst{27-25} = 0b000;
719 let Inst{24} = 1; // P bit
720 let Inst{23} = addr{8}; // U bit
721 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
722 let Inst{21} = 0; // W bit
723 let Inst{20} = op20; // L bit
724 let Inst{19-16} = addr{12-9}; // Rn
725 let Inst{15-12} = Rt; // Rt
726 let Inst{11-8} = addr{7-4}; // imm7_4/zero
728 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
730 let DecoderMethod = "DecodeAddrMode3Instruction";
733 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
734 IndexMode im, Format f, InstrItinClass itin, string opc,
735 string asm, string cstr, list<dag> pattern>
736 : I<oops, iops, AddrMode3, 4, im, f, itin,
737 opc, asm, cstr, pattern> {
739 let Inst{27-25} = 0b000;
740 let Inst{24} = isPre; // P bit
741 let Inst{21} = isPre; // W bit
742 let Inst{20} = op20; // L bit
743 let Inst{15-12} = Rt; // Rt
747 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
748 // but for now use this class for LDRSBT, LDRHT, LDSHT.
749 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
750 IndexMode im, Format f, InstrItinClass itin, string opc,
751 string asm, string cstr, list<dag> pattern>
752 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
753 // {13} 1 == imm8, 0 == Rm
760 let Inst{27-25} = 0b000;
761 let Inst{24} = 0; // P bit
763 let Inst{20} = isLoad; // L bit
764 let Inst{19-16} = addr; // Rn
765 let Inst{15-12} = Rt; // Rt
770 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
771 string opc, string asm, list<dag> pattern>
772 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
773 opc, asm, "", pattern> {
776 let Inst{27-25} = 0b000;
777 let Inst{24} = 1; // P bit
778 let Inst{23} = addr{8}; // U bit
779 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
780 let Inst{21} = 0; // W bit
781 let Inst{20} = 0; // L bit
782 let Inst{19-16} = addr{12-9}; // Rn
783 let Inst{15-12} = Rt; // Rt
784 let Inst{11-8} = addr{7-4}; // imm7_4/zero
786 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
787 let DecoderMethod = "DecodeAddrMode3Instruction";
790 // addrmode4 instructions
791 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
792 string asm, string cstr, list<dag> pattern>
793 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
798 let Inst{27-25} = 0b100;
799 let Inst{22} = 0; // S bit
800 let Inst{19-16} = Rn;
801 let Inst{15-0} = regs;
804 // Unsigned multiply, multiply-accumulate instructions.
805 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
806 string opc, string asm, list<dag> pattern>
807 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
808 opc, asm, "", pattern> {
809 let Inst{7-4} = 0b1001;
810 let Inst{20} = 0; // S bit
811 let Inst{27-21} = opcod;
813 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
814 string opc, string asm, list<dag> pattern>
815 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
816 opc, asm, "", pattern> {
817 let Inst{7-4} = 0b1001;
818 let Inst{27-21} = opcod;
821 // Most significant word multiply
822 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
823 InstrItinClass itin, string opc, string asm, list<dag> pattern>
824 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
825 opc, asm, "", pattern> {
829 let Inst{7-4} = opc7_4;
831 let Inst{27-21} = opcod;
832 let Inst{19-16} = Rd;
836 // MSW multiple w/ Ra operand
837 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
838 InstrItinClass itin, string opc, string asm, list<dag> pattern>
839 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
841 let Inst{15-12} = Ra;
844 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
845 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
846 InstrItinClass itin, string opc, string asm, list<dag> pattern>
847 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
848 opc, asm, "", pattern> {
854 let Inst{27-21} = opcod;
855 let Inst{6-5} = bit6_5;
859 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
860 InstrItinClass itin, string opc, string asm, list<dag> pattern>
861 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
863 let Inst{19-16} = Rd;
866 // AMulxyI with Ra operand
867 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
868 InstrItinClass itin, string opc, string asm, list<dag> pattern>
869 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
871 let Inst{15-12} = Ra;
874 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
875 InstrItinClass itin, string opc, string asm, list<dag> pattern>
876 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
879 let Inst{19-16} = RdHi;
880 let Inst{15-12} = RdLo;
883 // Extend instructions.
884 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
885 string opc, string asm, list<dag> pattern>
886 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
887 opc, asm, "", pattern> {
888 // All AExtI instructions have Rd and Rm register operands.
891 let Inst{15-12} = Rd;
893 let Inst{7-4} = 0b0111;
894 let Inst{9-8} = 0b00;
895 let Inst{27-20} = opcod;
897 let Unpredictable{9-8} = 0b11;
900 // Misc Arithmetic instructions.
901 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
902 InstrItinClass itin, string opc, string asm, list<dag> pattern>
903 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
904 opc, asm, "", pattern> {
907 let Inst{27-20} = opcod;
908 let Inst{19-16} = 0b1111;
909 let Inst{15-12} = Rd;
910 let Inst{11-8} = 0b1111;
911 let Inst{7-4} = opc7_4;
915 // Division instructions.
916 class ADivA1I<bits<3> opcod, dag oops, dag iops,
917 InstrItinClass itin, string opc, string asm, list<dag> pattern>
918 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
919 opc, asm, "", pattern> {
923 let Inst{27-23} = 0b01110;
924 let Inst{22-20} = opcod;
925 let Inst{19-16} = Rd;
926 let Inst{15-12} = 0b1111;
928 let Inst{7-4} = 0b0001;
933 def PKHLSLAsmOperand : ImmAsmOperand {
934 let Name = "PKHLSLImm";
935 let ParserMethod = "parsePKHLSLImm";
937 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
938 let PrintMethod = "printPKHLSLShiftImm";
939 let ParserMatchClass = PKHLSLAsmOperand;
941 def PKHASRAsmOperand : AsmOperandClass {
942 let Name = "PKHASRImm";
943 let ParserMethod = "parsePKHASRImm";
945 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
946 let PrintMethod = "printPKHASRShiftImm";
947 let ParserMatchClass = PKHASRAsmOperand;
950 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
951 string opc, string asm, list<dag> pattern>
952 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
953 opc, asm, "", pattern> {
958 let Inst{27-20} = opcod;
959 let Inst{19-16} = Rn;
960 let Inst{15-12} = Rd;
963 let Inst{5-4} = 0b01;
967 //===----------------------------------------------------------------------===//
969 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
970 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
971 list<Predicate> Predicates = [IsARM];
973 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
974 list<Predicate> Predicates = [IsARM, HasV5T];
976 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
977 list<Predicate> Predicates = [IsARM, HasV5TE];
979 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
980 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
981 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
983 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
984 list<Predicate> Predicates = [IsARM, HasV6];
987 //===----------------------------------------------------------------------===//
988 // Thumb Instruction Format Definitions.
991 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
992 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
993 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
994 let OutOperandList = oops;
995 let InOperandList = iops;
997 let Pattern = pattern;
998 list<Predicate> Predicates = [IsThumb];
1001 // TI - Thumb instruction.
1002 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
1003 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1005 // Two-address instructions
1006 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
1008 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
1011 // tBL, tBX 32-bit instructions
1012 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
1013 dag oops, dag iops, InstrItinClass itin, string asm,
1015 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
1017 let Inst{31-27} = opcod1;
1018 let Inst{15-14} = opcod2;
1019 let Inst{12} = opcod3;
1022 // BR_JT instructions
1023 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
1025 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1028 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
1029 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
1030 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1031 let OutOperandList = oops;
1032 let InOperandList = iops;
1033 let AsmString = asm;
1034 let Pattern = pattern;
1035 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1038 class T1I<dag oops, dag iops, InstrItinClass itin,
1039 string asm, list<dag> pattern>
1040 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
1041 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
1042 string asm, list<dag> pattern>
1043 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1045 // Two-address instructions
1046 class T1It<dag oops, dag iops, InstrItinClass itin,
1047 string asm, string cstr, list<dag> pattern>
1048 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
1049 asm, cstr, pattern>;
1051 // Thumb1 instruction that can either be predicated or set CPSR.
1052 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
1053 InstrItinClass itin,
1054 string opc, string asm, string cstr, list<dag> pattern>
1055 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1056 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1057 let InOperandList = !con(iops, (ins pred:$p));
1058 let AsmString = !strconcat(opc, "${s}${p}", asm);
1059 let Pattern = pattern;
1060 let thumbArithFlagSetting = 1;
1061 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1062 let DecoderNamespace = "ThumbSBit";
1065 class T1sI<dag oops, dag iops, InstrItinClass itin,
1066 string opc, string asm, list<dag> pattern>
1067 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1069 // Two-address instructions
1070 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1071 string opc, string asm, list<dag> pattern>
1072 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1073 "$Rn = $Rdn", pattern>;
1075 // Thumb1 instruction that can be predicated.
1076 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1077 InstrItinClass itin,
1078 string opc, string asm, string cstr, list<dag> pattern>
1079 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1080 let OutOperandList = oops;
1081 let InOperandList = !con(iops, (ins pred:$p));
1082 let AsmString = !strconcat(opc, "${p}", asm);
1083 let Pattern = pattern;
1084 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1087 class T1pI<dag oops, dag iops, InstrItinClass itin,
1088 string opc, string asm, list<dag> pattern>
1089 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1091 // Two-address instructions
1092 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1093 string opc, string asm, list<dag> pattern>
1094 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1095 "$Rn = $Rdn", pattern>;
1097 class T1pIs<dag oops, dag iops,
1098 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1099 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1101 class Encoding16 : Encoding {
1102 let Inst{31-16} = 0x0000;
1105 // A6.2 16-bit Thumb instruction encoding
1106 class T1Encoding<bits<6> opcode> : Encoding16 {
1107 let Inst{15-10} = opcode;
1110 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1111 class T1General<bits<5> opcode> : Encoding16 {
1112 let Inst{15-14} = 0b00;
1113 let Inst{13-9} = opcode;
1116 // A6.2.2 Data-processing encoding.
1117 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1118 let Inst{15-10} = 0b010000;
1119 let Inst{9-6} = opcode;
1122 // A6.2.3 Special data instructions and branch and exchange encoding.
1123 class T1Special<bits<4> opcode> : Encoding16 {
1124 let Inst{15-10} = 0b010001;
1125 let Inst{9-6} = opcode;
1128 // A6.2.4 Load/store single data item encoding.
1129 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1130 let Inst{15-12} = opA;
1131 let Inst{11-9} = opB;
1133 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1135 class T1BranchCond<bits<4> opcode> : Encoding16 {
1136 let Inst{15-12} = opcode;
1139 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1140 // following bits are used for "opA" (see A6.2.4):
1142 // 0b0110 => Immediate, 4 bytes
1143 // 0b1000 => Immediate, 2 bytes
1144 // 0b0111 => Immediate, 1 byte
1145 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1146 InstrItinClass itin, string opc, string asm,
1148 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1149 T1LoadStore<0b0101, opcode> {
1152 let Inst{8-6} = addr{5-3}; // Rm
1153 let Inst{5-3} = addr{2-0}; // Rn
1156 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1157 InstrItinClass itin, string opc, string asm,
1159 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1160 T1LoadStore<opA, {opB,?,?}> {
1163 let Inst{10-6} = addr{7-3}; // imm5
1164 let Inst{5-3} = addr{2-0}; // Rn
1168 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1169 class T1Misc<bits<7> opcode> : Encoding16 {
1170 let Inst{15-12} = 0b1011;
1171 let Inst{11-5} = opcode;
1174 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1175 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1176 InstrItinClass itin,
1177 string opc, string asm, string cstr, list<dag> pattern>
1178 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1179 let OutOperandList = oops;
1180 let InOperandList = !con(iops, (ins pred:$p));
1181 let AsmString = !strconcat(opc, "${p}", asm);
1182 let Pattern = pattern;
1183 list<Predicate> Predicates = [IsThumb2];
1184 let DecoderNamespace = "Thumb2";
1187 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1188 // input operand since by default it's a zero register. It will become an
1189 // implicit def once it's "flipped".
1191 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1193 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1194 InstrItinClass itin,
1195 string opc, string asm, string cstr, list<dag> pattern>
1196 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1197 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1200 let OutOperandList = oops;
1201 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1202 let AsmString = !strconcat(opc, "${s}${p}", asm);
1203 let Pattern = pattern;
1204 list<Predicate> Predicates = [IsThumb2];
1205 let DecoderNamespace = "Thumb2";
1209 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1210 InstrItinClass itin,
1211 string asm, string cstr, list<dag> pattern>
1212 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1213 let OutOperandList = oops;
1214 let InOperandList = iops;
1215 let AsmString = asm;
1216 let Pattern = pattern;
1217 list<Predicate> Predicates = [IsThumb2];
1218 let DecoderNamespace = "Thumb2";
1221 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1222 InstrItinClass itin,
1223 string asm, string cstr, list<dag> pattern>
1224 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1225 let OutOperandList = oops;
1226 let InOperandList = iops;
1227 let AsmString = asm;
1228 let Pattern = pattern;
1229 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1230 let DecoderNamespace = "Thumb";
1233 class T2I<dag oops, dag iops, InstrItinClass itin,
1234 string opc, string asm, list<dag> pattern>
1235 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1236 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1237 string opc, string asm, list<dag> pattern>
1238 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1239 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1240 string opc, string asm, list<dag> pattern>
1241 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1242 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1243 string opc, string asm, list<dag> pattern>
1244 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1245 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1246 string opc, string asm, list<dag> pattern>
1247 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1248 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1249 string opc, string asm, string cstr, list<dag> pattern>
1250 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1255 let Inst{31-25} = 0b1110100;
1257 let Inst{23} = addr{8};
1260 let Inst{20} = isLoad;
1261 let Inst{19-16} = addr{12-9};
1262 let Inst{15-12} = Rt{3-0};
1263 let Inst{11-8} = Rt2{3-0};
1264 let Inst{7-0} = addr{7-0};
1266 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1267 InstrItinClass itin, string opc, string asm, string cstr,
1269 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1275 let Inst{31-25} = 0b1110100;
1277 let Inst{23} = imm{8};
1280 let Inst{20} = isLoad;
1281 let Inst{19-16} = addr;
1282 let Inst{15-12} = Rt{3-0};
1283 let Inst{11-8} = Rt2{3-0};
1284 let Inst{7-0} = imm{7-0};
1287 class T2sI<dag oops, dag iops, InstrItinClass itin,
1288 string opc, string asm, list<dag> pattern>
1289 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1291 class T2XI<dag oops, dag iops, InstrItinClass itin,
1292 string asm, list<dag> pattern>
1293 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1294 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1295 string asm, list<dag> pattern>
1296 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1298 // Move to/from coprocessor instructions
1299 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1301 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1302 let Inst{31-28} = opc;
1305 // Two-address instructions
1306 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1307 string asm, string cstr, list<dag> pattern>
1308 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1310 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1311 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1313 AddrMode am, IndexMode im, InstrItinClass itin,
1314 string opc, string asm, string cstr, list<dag> pattern>
1315 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1316 let OutOperandList = oops;
1317 let InOperandList = !con(iops, (ins pred:$p));
1318 let AsmString = !strconcat(opc, "${p}", asm);
1319 let Pattern = pattern;
1320 list<Predicate> Predicates = [IsThumb2];
1321 let DecoderNamespace = "Thumb2";
1325 let Inst{31-27} = 0b11111;
1326 let Inst{26-25} = 0b00;
1327 let Inst{24} = signed;
1329 let Inst{22-21} = opcod;
1330 let Inst{20} = load;
1331 let Inst{19-16} = addr{12-9};
1332 let Inst{15-12} = Rt{3-0};
1334 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1335 let Inst{10} = pre; // The P bit.
1336 let Inst{9} = addr{8}; // Sign bit
1337 let Inst{8} = 1; // The W bit.
1338 let Inst{7-0} = addr{7-0};
1340 let DecoderMethod = "DecodeT2LdStPre";
1343 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1344 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1346 AddrMode am, IndexMode im, InstrItinClass itin,
1347 string opc, string asm, string cstr, list<dag> pattern>
1348 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1349 let OutOperandList = oops;
1350 let InOperandList = !con(iops, (ins pred:$p));
1351 let AsmString = !strconcat(opc, "${p}", asm);
1352 let Pattern = pattern;
1353 list<Predicate> Predicates = [IsThumb2];
1354 let DecoderNamespace = "Thumb2";
1359 let Inst{31-27} = 0b11111;
1360 let Inst{26-25} = 0b00;
1361 let Inst{24} = signed;
1363 let Inst{22-21} = opcod;
1364 let Inst{20} = load;
1365 let Inst{19-16} = Rn;
1366 let Inst{15-12} = Rt{3-0};
1368 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1369 let Inst{10} = pre; // The P bit.
1370 let Inst{9} = offset{8}; // Sign bit
1371 let Inst{8} = 1; // The W bit.
1372 let Inst{7-0} = offset{7-0};
1374 let DecoderMethod = "DecodeT2LdStPre";
1377 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1378 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1379 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1382 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1383 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1384 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1387 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1388 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1389 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1392 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1393 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1394 list<Predicate> Predicates = [IsThumb2];
1397 //===----------------------------------------------------------------------===//
1399 //===----------------------------------------------------------------------===//
1400 // ARM VFP Instruction templates.
1403 // Almost all VFP instructions are predicable.
1404 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1405 IndexMode im, Format f, InstrItinClass itin,
1406 string opc, string asm, string cstr, list<dag> pattern>
1407 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1409 let Inst{31-28} = p;
1410 let OutOperandList = oops;
1411 let InOperandList = !con(iops, (ins pred:$p));
1412 let AsmString = !strconcat(opc, "${p}", asm);
1413 let Pattern = pattern;
1414 let PostEncoderMethod = "VFPThumb2PostEncoder";
1415 let DecoderNamespace = "VFP";
1416 list<Predicate> Predicates = [HasVFP2];
1420 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1421 IndexMode im, Format f, InstrItinClass itin,
1422 string asm, string cstr, list<dag> pattern>
1423 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1425 let Inst{31-28} = p;
1426 let OutOperandList = oops;
1427 let InOperandList = iops;
1428 let AsmString = asm;
1429 let Pattern = pattern;
1430 let PostEncoderMethod = "VFPThumb2PostEncoder";
1431 let DecoderNamespace = "VFP";
1432 list<Predicate> Predicates = [HasVFP2];
1435 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1436 string opc, string asm, list<dag> pattern>
1437 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1438 opc, asm, "", pattern> {
1439 let PostEncoderMethod = "VFPThumb2PostEncoder";
1442 // ARM VFP addrmode5 loads and stores
1443 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1444 InstrItinClass itin,
1445 string opc, string asm, list<dag> pattern>
1446 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1447 VFPLdStFrm, itin, opc, asm, "", pattern> {
1448 // Instruction operands.
1452 // Encode instruction operands.
1453 let Inst{23} = addr{8}; // U (add = (U == '1'))
1454 let Inst{22} = Dd{4};
1455 let Inst{19-16} = addr{12-9}; // Rn
1456 let Inst{15-12} = Dd{3-0};
1457 let Inst{7-0} = addr{7-0}; // imm8
1459 let Inst{27-24} = opcod1;
1460 let Inst{21-20} = opcod2;
1461 let Inst{11-9} = 0b101;
1462 let Inst{8} = 1; // Double precision
1464 // Loads & stores operate on both NEON and VFP pipelines.
1465 let D = VFPNeonDomain;
1468 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1469 InstrItinClass itin,
1470 string opc, string asm, list<dag> pattern>
1471 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1472 VFPLdStFrm, itin, opc, asm, "", pattern> {
1473 // Instruction operands.
1477 // Encode instruction operands.
1478 let Inst{23} = addr{8}; // U (add = (U == '1'))
1479 let Inst{22} = Sd{0};
1480 let Inst{19-16} = addr{12-9}; // Rn
1481 let Inst{15-12} = Sd{4-1};
1482 let Inst{7-0} = addr{7-0}; // imm8
1484 let Inst{27-24} = opcod1;
1485 let Inst{21-20} = opcod2;
1486 let Inst{11-9} = 0b101;
1487 let Inst{8} = 0; // Single precision
1489 // Loads & stores operate on both NEON and VFP pipelines.
1490 let D = VFPNeonDomain;
1493 // VFP Load / store multiple pseudo instructions.
1494 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1496 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1498 let OutOperandList = oops;
1499 let InOperandList = !con(iops, (ins pred:$p));
1500 let Pattern = pattern;
1501 list<Predicate> Predicates = [HasVFP2];
1504 // Load / store multiple
1506 // Unknown precision
1507 class AXXI4<dag oops, dag iops, IndexMode im,
1508 string asm, string cstr, list<dag> pattern>
1509 : VFPXI<oops, iops, AddrMode4, 4, im,
1510 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1511 // Instruction operands.
1515 // Encode instruction operands.
1516 let Inst{19-16} = Rn;
1518 let Inst{15-12} = regs{11-8};
1519 let Inst{7-1} = regs{7-1};
1521 let Inst{27-25} = 0b110;
1522 let Inst{11-8} = 0b1011;
1527 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1528 string asm, string cstr, list<dag> pattern>
1529 : VFPXI<oops, iops, AddrMode4, 4, im,
1530 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1531 // Instruction operands.
1535 // Encode instruction operands.
1536 let Inst{19-16} = Rn;
1537 let Inst{22} = regs{12};
1538 let Inst{15-12} = regs{11-8};
1539 let Inst{7-1} = regs{7-1};
1541 let Inst{27-25} = 0b110;
1542 let Inst{11-9} = 0b101;
1543 let Inst{8} = 1; // Double precision
1548 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1549 string asm, string cstr, list<dag> pattern>
1550 : VFPXI<oops, iops, AddrMode4, 4, im,
1551 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1552 // Instruction operands.
1556 // Encode instruction operands.
1557 let Inst{19-16} = Rn;
1558 let Inst{22} = regs{8};
1559 let Inst{15-12} = regs{12-9};
1560 let Inst{7-0} = regs{7-0};
1562 let Inst{27-25} = 0b110;
1563 let Inst{11-9} = 0b101;
1564 let Inst{8} = 0; // Single precision
1567 // Double precision, unary
1568 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1569 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1570 string asm, list<dag> pattern>
1571 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1572 // Instruction operands.
1576 // Encode instruction operands.
1577 let Inst{3-0} = Dm{3-0};
1578 let Inst{5} = Dm{4};
1579 let Inst{15-12} = Dd{3-0};
1580 let Inst{22} = Dd{4};
1582 let Inst{27-23} = opcod1;
1583 let Inst{21-20} = opcod2;
1584 let Inst{19-16} = opcod3;
1585 let Inst{11-9} = 0b101;
1586 let Inst{8} = 1; // Double precision
1587 let Inst{7-6} = opcod4;
1588 let Inst{4} = opcod5;
1590 let Predicates = [HasVFP2, HasDPVFP];
1593 // Double precision, unary, not-predicated
1594 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1595 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1596 string asm, list<dag> pattern>
1597 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1598 // Instruction operands.
1602 let Inst{31-28} = 0b1111;
1604 // Encode instruction operands.
1605 let Inst{3-0} = Dm{3-0};
1606 let Inst{5} = Dm{4};
1607 let Inst{15-12} = Dd{3-0};
1608 let Inst{22} = Dd{4};
1610 let Inst{27-23} = opcod1;
1611 let Inst{21-20} = opcod2;
1612 let Inst{19-16} = opcod3;
1613 let Inst{11-9} = 0b101;
1614 let Inst{8} = 1; // Double precision
1615 let Inst{7-6} = opcod4;
1616 let Inst{4} = opcod5;
1619 // Double precision, binary
1620 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1621 dag iops, InstrItinClass itin, string opc, string asm,
1623 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1624 // Instruction operands.
1629 // Encode instruction operands.
1630 let Inst{3-0} = Dm{3-0};
1631 let Inst{5} = Dm{4};
1632 let Inst{19-16} = Dn{3-0};
1633 let Inst{7} = Dn{4};
1634 let Inst{15-12} = Dd{3-0};
1635 let Inst{22} = Dd{4};
1637 let Inst{27-23} = opcod1;
1638 let Inst{21-20} = opcod2;
1639 let Inst{11-9} = 0b101;
1640 let Inst{8} = 1; // Double precision
1644 let Predicates = [HasVFP2, HasDPVFP];
1647 // FP, binary, not predicated
1648 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1649 InstrItinClass itin, string asm, list<dag> pattern>
1650 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1653 // Instruction operands.
1658 let Inst{31-28} = 0b1111;
1660 // Encode instruction operands.
1661 let Inst{3-0} = Dm{3-0};
1662 let Inst{5} = Dm{4};
1663 let Inst{19-16} = Dn{3-0};
1664 let Inst{7} = Dn{4};
1665 let Inst{15-12} = Dd{3-0};
1666 let Inst{22} = Dd{4};
1668 let Inst{27-23} = opcod1;
1669 let Inst{21-20} = opcod2;
1670 let Inst{11-9} = 0b101;
1671 let Inst{8} = 1; // double precision
1672 let Inst{6} = opcod3;
1675 let Predicates = [HasVFP2, HasDPVFP];
1678 // Single precision, unary, predicated
1679 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1680 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1681 string asm, list<dag> pattern>
1682 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1683 // Instruction operands.
1687 // Encode instruction operands.
1688 let Inst{3-0} = Sm{4-1};
1689 let Inst{5} = Sm{0};
1690 let Inst{15-12} = Sd{4-1};
1691 let Inst{22} = Sd{0};
1693 let Inst{27-23} = opcod1;
1694 let Inst{21-20} = opcod2;
1695 let Inst{19-16} = opcod3;
1696 let Inst{11-9} = 0b101;
1697 let Inst{8} = 0; // Single precision
1698 let Inst{7-6} = opcod4;
1699 let Inst{4} = opcod5;
1702 // Single precision, unary, non-predicated
1703 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1704 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1705 string asm, list<dag> pattern>
1706 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1707 VFPUnaryFrm, itin, asm, "", pattern> {
1708 // Instruction operands.
1712 let Inst{31-28} = 0b1111;
1714 // Encode instruction operands.
1715 let Inst{3-0} = Sm{4-1};
1716 let Inst{5} = Sm{0};
1717 let Inst{15-12} = Sd{4-1};
1718 let Inst{22} = Sd{0};
1720 let Inst{27-23} = opcod1;
1721 let Inst{21-20} = opcod2;
1722 let Inst{19-16} = opcod3;
1723 let Inst{11-9} = 0b101;
1724 let Inst{8} = 0; // Single precision
1725 let Inst{7-6} = opcod4;
1726 let Inst{4} = opcod5;
1729 // Single precision unary, if no NEON. Same as ASuI except not available if
1731 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1732 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1733 string asm, list<dag> pattern>
1734 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1736 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1739 // Single precision, binary
1740 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1741 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1742 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1743 // Instruction operands.
1748 // Encode instruction operands.
1749 let Inst{3-0} = Sm{4-1};
1750 let Inst{5} = Sm{0};
1751 let Inst{19-16} = Sn{4-1};
1752 let Inst{7} = Sn{0};
1753 let Inst{15-12} = Sd{4-1};
1754 let Inst{22} = Sd{0};
1756 let Inst{27-23} = opcod1;
1757 let Inst{21-20} = opcod2;
1758 let Inst{11-9} = 0b101;
1759 let Inst{8} = 0; // Single precision
1764 // Single precision, binary, not predicated
1765 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1766 InstrItinClass itin, string asm, list<dag> pattern>
1767 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1768 VFPBinaryFrm, itin, asm, "", pattern>
1770 // Instruction operands.
1775 let Inst{31-28} = 0b1111;
1777 // Encode instruction operands.
1778 let Inst{3-0} = Sm{4-1};
1779 let Inst{5} = Sm{0};
1780 let Inst{19-16} = Sn{4-1};
1781 let Inst{7} = Sn{0};
1782 let Inst{15-12} = Sd{4-1};
1783 let Inst{22} = Sd{0};
1785 let Inst{27-23} = opcod1;
1786 let Inst{21-20} = opcod2;
1787 let Inst{11-9} = 0b101;
1788 let Inst{8} = 0; // Single precision
1789 let Inst{6} = opcod3;
1793 // Single precision binary, if no NEON. Same as ASbI except not available if
1795 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1796 dag iops, InstrItinClass itin, string opc, string asm,
1798 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1799 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1801 // Instruction operands.
1806 // Encode instruction operands.
1807 let Inst{3-0} = Sm{4-1};
1808 let Inst{5} = Sm{0};
1809 let Inst{19-16} = Sn{4-1};
1810 let Inst{7} = Sn{0};
1811 let Inst{15-12} = Sd{4-1};
1812 let Inst{22} = Sd{0};
1815 // VFP conversion instructions
1816 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1817 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1819 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1820 let Inst{27-23} = opcod1;
1821 let Inst{21-20} = opcod2;
1822 let Inst{19-16} = opcod3;
1823 let Inst{11-8} = opcod4;
1828 // VFP conversion between floating-point and fixed-point
1829 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1830 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1832 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1834 // size (fixed-point number): sx == 0 ? 16 : 32
1835 let Inst{7} = op5; // sx
1836 let Inst{5} = fbits{0};
1837 let Inst{3-0} = fbits{4-1};
1840 // VFP conversion instructions, if no NEON
1841 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1842 dag oops, dag iops, InstrItinClass itin,
1843 string opc, string asm, list<dag> pattern>
1844 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1846 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1849 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1850 InstrItinClass itin,
1851 string opc, string asm, list<dag> pattern>
1852 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1853 let Inst{27-20} = opcod1;
1854 let Inst{11-8} = opcod2;
1858 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1859 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1860 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1862 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1863 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1864 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1866 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1867 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1868 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1870 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1871 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1872 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1874 //===----------------------------------------------------------------------===//
1876 //===----------------------------------------------------------------------===//
1877 // ARM NEON Instruction templates.
1880 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1881 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1883 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1884 let OutOperandList = oops;
1885 let InOperandList = !con(iops, (ins pred:$p));
1886 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1887 let Pattern = pattern;
1888 list<Predicate> Predicates = [HasNEON];
1889 let DecoderNamespace = "NEON";
1892 // Same as NeonI except it does not have a "data type" specifier.
1893 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1894 InstrItinClass itin, string opc, string asm, string cstr,
1896 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1897 let OutOperandList = oops;
1898 let InOperandList = !con(iops, (ins pred:$p));
1899 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1900 let Pattern = pattern;
1901 list<Predicate> Predicates = [HasNEON];
1902 let DecoderNamespace = "NEON";
1905 // Same as NeonI except it is not predicated
1906 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1907 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1909 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1910 let OutOperandList = oops;
1911 let InOperandList = iops;
1912 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
1913 let Pattern = pattern;
1914 list<Predicate> Predicates = [HasNEON];
1915 let DecoderNamespace = "NEON";
1917 let Inst{31-28} = 0b1111;
1920 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1921 dag oops, dag iops, InstrItinClass itin,
1922 string opc, string dt, string asm, string cstr, list<dag> pattern>
1923 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1925 let Inst{31-24} = 0b11110100;
1926 let Inst{23} = op23;
1927 let Inst{21-20} = op21_20;
1928 let Inst{11-8} = op11_8;
1929 let Inst{7-4} = op7_4;
1931 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1932 let DecoderNamespace = "NEONLoadStore";
1938 let Inst{22} = Vd{4};
1939 let Inst{15-12} = Vd{3-0};
1940 let Inst{19-16} = Rn{3-0};
1941 let Inst{3-0} = Rm{3-0};
1944 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1945 dag oops, dag iops, InstrItinClass itin,
1946 string opc, string dt, string asm, string cstr, list<dag> pattern>
1947 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1948 dt, asm, cstr, pattern> {
1952 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1953 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
1955 let OutOperandList = oops;
1956 let InOperandList = !con(iops, (ins pred:$p));
1957 list<Predicate> Predicates = [HasNEON];
1960 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1962 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
1964 let OutOperandList = oops;
1965 let InOperandList = !con(iops, (ins pred:$p));
1966 let Pattern = pattern;
1967 list<Predicate> Predicates = [HasNEON];
1970 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1971 string opc, string dt, string asm, string cstr, list<dag> pattern>
1972 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1974 let Inst{31-25} = 0b1111001;
1975 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1976 let DecoderNamespace = "NEONData";
1979 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1980 string opc, string asm, string cstr, list<dag> pattern>
1981 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1983 let Inst{31-25} = 0b1111001;
1984 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1985 let DecoderNamespace = "NEONData";
1988 // NEON "one register and a modified immediate" format.
1989 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1991 dag oops, dag iops, InstrItinClass itin,
1992 string opc, string dt, string asm, string cstr,
1994 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1995 let Inst{23} = op23;
1996 let Inst{21-19} = op21_19;
1997 let Inst{11-8} = op11_8;
2003 // Instruction operands.
2007 let Inst{15-12} = Vd{3-0};
2008 let Inst{22} = Vd{4};
2009 let Inst{24} = SIMM{7};
2010 let Inst{18-16} = SIMM{6-4};
2011 let Inst{3-0} = SIMM{3-0};
2012 let DecoderMethod = "DecodeNEONModImmInstruction";
2015 // NEON 2 vector register format.
2016 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2017 bits<5> op11_7, bit op6, bit op4,
2018 dag oops, dag iops, InstrItinClass itin,
2019 string opc, string dt, string asm, string cstr, list<dag> pattern>
2020 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
2021 let Inst{24-23} = op24_23;
2022 let Inst{21-20} = op21_20;
2023 let Inst{19-18} = op19_18;
2024 let Inst{17-16} = op17_16;
2025 let Inst{11-7} = op11_7;
2029 // Instruction operands.
2033 let Inst{15-12} = Vd{3-0};
2034 let Inst{22} = Vd{4};
2035 let Inst{3-0} = Vm{3-0};
2036 let Inst{5} = Vm{4};
2039 // Same as N2V but not predicated.
2040 class N2Vnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
2041 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
2042 string Dt, list<dag> pattern>
2043 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
2044 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
2048 // Encode instruction operands
2049 let Inst{22} = Vd{4};
2050 let Inst{15-12} = Vd{3-0};
2051 let Inst{5} = Vm{4};
2052 let Inst{3-0} = Vm{3-0};
2054 // Encode constant bits
2055 let Inst{27-23} = 0b00111;
2056 let Inst{21-20} = 0b11;
2057 let Inst{19-18} = op19_18;
2058 let Inst{17-16} = op17_16;
2060 let Inst{10-8} = op10_8;
2065 let DecoderNamespace = "NEON";
2068 // Same as N2V except it doesn't have a datatype suffix.
2069 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2070 bits<5> op11_7, bit op6, bit op4,
2071 dag oops, dag iops, InstrItinClass itin,
2072 string opc, string asm, string cstr, list<dag> pattern>
2073 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2074 let Inst{24-23} = op24_23;
2075 let Inst{21-20} = op21_20;
2076 let Inst{19-18} = op19_18;
2077 let Inst{17-16} = op17_16;
2078 let Inst{11-7} = op11_7;
2082 // Instruction operands.
2086 let Inst{15-12} = Vd{3-0};
2087 let Inst{22} = Vd{4};
2088 let Inst{3-0} = Vm{3-0};
2089 let Inst{5} = Vm{4};
2092 // NEON 2 vector register with immediate.
2093 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2094 dag oops, dag iops, Format f, InstrItinClass itin,
2095 string opc, string dt, string asm, string cstr, list<dag> pattern>
2096 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2097 let Inst{24} = op24;
2098 let Inst{23} = op23;
2099 let Inst{11-8} = op11_8;
2104 // Instruction operands.
2109 let Inst{15-12} = Vd{3-0};
2110 let Inst{22} = Vd{4};
2111 let Inst{3-0} = Vm{3-0};
2112 let Inst{5} = Vm{4};
2113 let Inst{21-16} = SIMM{5-0};
2116 // NEON 3 vector register format.
2118 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2119 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2120 string opc, string dt, string asm, string cstr,
2122 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2123 let Inst{24} = op24;
2124 let Inst{23} = op23;
2125 let Inst{21-20} = op21_20;
2126 let Inst{11-8} = op11_8;
2131 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2132 dag oops, dag iops, Format f, InstrItinClass itin,
2133 string opc, string dt, string asm, string cstr, list<dag> pattern>
2134 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2135 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2136 // Instruction operands.
2141 let Inst{15-12} = Vd{3-0};
2142 let Inst{22} = Vd{4};
2143 let Inst{19-16} = Vn{3-0};
2144 let Inst{7} = Vn{4};
2145 let Inst{3-0} = Vm{3-0};
2146 let Inst{5} = Vm{4};
2149 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2150 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2151 string OpcodeStr, string Dt, list<dag> pattern>
2152 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2153 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2158 // Encode instruction operands
2159 let Inst{22} = Vd{4};
2160 let Inst{15-12} = Vd{3-0};
2161 let Inst{19-16} = Vn{3-0};
2162 let Inst{7} = Vn{4};
2163 let Inst{5} = Vm{4};
2164 let Inst{3-0} = Vm{3-0};
2166 // Encode constant bits
2167 let Inst{27-23} = op27_23;
2168 let Inst{21-20} = op21_20;
2169 let Inst{11-8} = op11_8;
2174 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2175 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2176 string opc, string dt, string asm, string cstr,
2178 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2179 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2181 // Instruction operands.
2187 let Inst{15-12} = Vd{3-0};
2188 let Inst{22} = Vd{4};
2189 let Inst{19-16} = Vn{3-0};
2190 let Inst{7} = Vn{4};
2191 let Inst{3-0} = Vm{3-0};
2195 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2196 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2197 string opc, string dt, string asm, string cstr,
2199 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2200 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2202 // Instruction operands.
2208 let Inst{15-12} = Vd{3-0};
2209 let Inst{22} = Vd{4};
2210 let Inst{19-16} = Vn{3-0};
2211 let Inst{7} = Vn{4};
2212 let Inst{2-0} = Vm{2-0};
2213 let Inst{5} = lane{1};
2214 let Inst{3} = lane{0};
2217 // Same as N3V except it doesn't have a data type suffix.
2218 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2220 dag oops, dag iops, Format f, InstrItinClass itin,
2221 string opc, string asm, string cstr, list<dag> pattern>
2222 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2223 let Inst{24} = op24;
2224 let Inst{23} = op23;
2225 let Inst{21-20} = op21_20;
2226 let Inst{11-8} = op11_8;
2230 // Instruction operands.
2235 let Inst{15-12} = Vd{3-0};
2236 let Inst{22} = Vd{4};
2237 let Inst{19-16} = Vn{3-0};
2238 let Inst{7} = Vn{4};
2239 let Inst{3-0} = Vm{3-0};
2240 let Inst{5} = Vm{4};
2243 // NEON VMOVs between scalar and core registers.
2244 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2245 dag oops, dag iops, Format f, InstrItinClass itin,
2246 string opc, string dt, string asm, list<dag> pattern>
2247 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2249 let Inst{27-20} = opcod1;
2250 let Inst{11-8} = opcod2;
2251 let Inst{6-5} = opcod3;
2253 // A8.6.303, A8.6.328, A8.6.329
2254 let Inst{3-0} = 0b0000;
2256 let OutOperandList = oops;
2257 let InOperandList = !con(iops, (ins pred:$p));
2258 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2259 let Pattern = pattern;
2260 list<Predicate> Predicates = [HasNEON];
2262 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2263 let DecoderNamespace = "NEONDup";
2270 let Inst{31-28} = p{3-0};
2272 let Inst{19-16} = V{3-0};
2273 let Inst{15-12} = R{3-0};
2275 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2276 dag oops, dag iops, InstrItinClass itin,
2277 string opc, string dt, string asm, list<dag> pattern>
2278 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2279 opc, dt, asm, pattern>;
2280 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2281 dag oops, dag iops, InstrItinClass itin,
2282 string opc, string dt, string asm, list<dag> pattern>
2283 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2284 opc, dt, asm, pattern>;
2285 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2286 dag oops, dag iops, InstrItinClass itin,
2287 string opc, string dt, string asm, list<dag> pattern>
2288 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2289 opc, dt, asm, pattern>;
2291 // Vector Duplicate Lane (from scalar to all elements)
2292 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2293 InstrItinClass itin, string opc, string dt, string asm,
2295 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2296 let Inst{24-23} = 0b11;
2297 let Inst{21-20} = 0b11;
2298 let Inst{19-16} = op19_16;
2299 let Inst{11-7} = 0b11000;
2306 let Inst{22} = Vd{4};
2307 let Inst{15-12} = Vd{3-0};
2308 let Inst{5} = Vm{4};
2309 let Inst{3-0} = Vm{3-0};
2312 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2313 // for single-precision FP.
2314 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2315 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2318 // VFP/NEON Instruction aliases for type suffices.
2319 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
2320 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
2322 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
2323 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2324 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2325 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2326 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2329 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2330 let Predicates = [HasNEON] in {
2331 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2332 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2333 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2334 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2338 // The same alias classes using AsmPseudo instead, for the more complex
2339 // stuff in NEON that InstAlias can't quite handle.
2340 // Note that we can't use anonymous defm references here like we can
2341 // above, as we care about the ultimate instruction enum names generated, unlike
2342 // for instalias defs.
2343 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2344 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2346 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2347 def : TokenAlias<".s8", ".i8">;
2348 def : TokenAlias<".u8", ".i8">;
2349 def : TokenAlias<".s16", ".i16">;
2350 def : TokenAlias<".u16", ".i16">;
2351 def : TokenAlias<".s32", ".i32">;
2352 def : TokenAlias<".u32", ".i32">;
2353 def : TokenAlias<".s64", ".i64">;
2354 def : TokenAlias<".u64", ".i64">;
2356 def : TokenAlias<".i8", ".8">;
2357 def : TokenAlias<".i16", ".16">;
2358 def : TokenAlias<".i32", ".32">;
2359 def : TokenAlias<".i64", ".64">;
2361 def : TokenAlias<".p8", ".8">;
2362 def : TokenAlias<".p16", ".16">;
2364 def : TokenAlias<".f32", ".32">;
2365 def : TokenAlias<".f64", ".64">;
2366 def : TokenAlias<".f", ".f32">;
2367 def : TokenAlias<".d", ".f64">;