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 // Shift Right Immediate - A shift right immediate is encoded differently from
207 // other shift immediates. The imm6 field is encoded like so:
210 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
211 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
212 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
213 // 64 64 - <imm> is encoded in imm6<5:0>
214 def shr_imm8_asm_operand : ImmAsmOperand { let Name = "ShrImm8"; }
215 def shr_imm8 : Operand<i32> {
216 let EncoderMethod = "getShiftRight8Imm";
217 let DecoderMethod = "DecodeShiftRight8Imm";
218 let ParserMatchClass = shr_imm8_asm_operand;
220 def shr_imm16_asm_operand : ImmAsmOperand { let Name = "ShrImm16"; }
221 def shr_imm16 : Operand<i32> {
222 let EncoderMethod = "getShiftRight16Imm";
223 let DecoderMethod = "DecodeShiftRight16Imm";
224 let ParserMatchClass = shr_imm16_asm_operand;
226 def shr_imm32_asm_operand : ImmAsmOperand { let Name = "ShrImm32"; }
227 def shr_imm32 : Operand<i32> {
228 let EncoderMethod = "getShiftRight32Imm";
229 let DecoderMethod = "DecodeShiftRight32Imm";
230 let ParserMatchClass = shr_imm32_asm_operand;
232 def shr_imm64_asm_operand : ImmAsmOperand { let Name = "ShrImm64"; }
233 def shr_imm64 : Operand<i32> {
234 let EncoderMethod = "getShiftRight64Imm";
235 let DecoderMethod = "DecodeShiftRight64Imm";
236 let ParserMatchClass = shr_imm64_asm_operand;
239 //===----------------------------------------------------------------------===//
240 // ARM Assembler alias templates.
242 class ARMInstAlias<string Asm, dag Result, bit Emit = 0b1>
243 : InstAlias<Asm, Result, Emit>, Requires<[IsARM]>;
244 class tInstAlias<string Asm, dag Result, bit Emit = 0b1>
245 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb]>;
246 class t2InstAlias<string Asm, dag Result, bit Emit = 0b1>
247 : InstAlias<Asm, Result, Emit>, Requires<[IsThumb2]>;
248 class VFP2InstAlias<string Asm, dag Result, bit Emit = 0b1>
249 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP2]>;
250 class VFP3InstAlias<string Asm, dag Result, bit Emit = 0b1>
251 : InstAlias<Asm, Result, Emit>, Requires<[HasVFP3]>;
252 class NEONInstAlias<string Asm, dag Result, bit Emit = 0b1>
253 : InstAlias<Asm, Result, Emit>, Requires<[HasNEON]>;
256 class VFP2MnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
258 class NEONMnemonicAlias<string src, string dst> : MnemonicAlias<src, dst>,
261 //===----------------------------------------------------------------------===//
262 // ARM Instruction templates.
266 class InstTemplate<AddrMode am, int sz, IndexMode im,
267 Format f, Domain d, string cstr, InstrItinClass itin>
269 let Namespace = "ARM";
274 bits<2> IndexModeBits = IM.Value;
276 bits<6> Form = F.Value;
278 bit isUnaryDataProc = 0;
279 bit canXformTo16Bit = 0;
280 // The instruction is a 16-bit flag setting Thumb instruction. Used
281 // by the parser to determine whether to require the 'S' suffix on the
282 // mnemonic (when not in an IT block) or preclude it (when in an IT block).
283 bit thumbArithFlagSetting = 0;
285 // If this is a pseudo instruction, mark it isCodeGenOnly.
286 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
288 // The layout of TSFlags should be kept in sync with ARMBaseInfo.h.
289 let TSFlags{4-0} = AM.Value;
290 let TSFlags{6-5} = IndexModeBits;
291 let TSFlags{12-7} = Form;
292 let TSFlags{13} = isUnaryDataProc;
293 let TSFlags{14} = canXformTo16Bit;
294 let TSFlags{17-15} = D.Value;
295 let TSFlags{18} = thumbArithFlagSetting;
297 let Constraints = cstr;
298 let Itinerary = itin;
303 // Mask of bits that cause an encoding to be UNPREDICTABLE.
304 // If a bit is set, then if the corresponding bit in the
305 // target encoding differs from its value in the "Inst" field,
306 // the instruction is UNPREDICTABLE (SoftFail in abstract parlance).
307 field bits<32> Unpredictable = 0;
308 // SoftFail is the generic name for this field, but we alias it so
309 // as to make it more obvious what it means in ARM-land.
310 field bits<32> SoftFail = Unpredictable;
313 class InstARM<AddrMode am, int sz, IndexMode im,
314 Format f, Domain d, string cstr, InstrItinClass itin>
315 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding {
316 let DecoderNamespace = "ARM";
319 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
320 // on by adding flavors to specific instructions.
321 class InstThumb<AddrMode am, int sz, IndexMode im,
322 Format f, Domain d, string cstr, InstrItinClass itin>
323 : InstTemplate<am, sz, im, f, d, cstr, itin> {
324 let DecoderNamespace = "Thumb";
327 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
328 // These are aliases that require C++ handling to convert to the target
329 // instruction, while InstAliases can be handled directly by tblgen.
330 class AsmPseudoInst<string asm, dag iops>
331 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo, GenericDomain,
333 let OutOperandList = (outs);
334 let InOperandList = iops;
336 let isCodeGenOnly = 0; // So we get asm matcher for it.
341 class ARMAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
343 class tAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
345 class t2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
346 Requires<[IsThumb2]>;
347 class VFP2AsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
349 class NEONAsmPseudo<string asm, dag iops> : AsmPseudoInst<asm, iops>,
352 // Pseudo instructions for the code generator.
353 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
354 : InstTemplate<AddrModeNone, 0, IndexModeNone, Pseudo,
355 GenericDomain, "", itin> {
356 let OutOperandList = oops;
357 let InOperandList = iops;
358 let Pattern = pattern;
359 let isCodeGenOnly = 1;
363 // PseudoInst that's ARM-mode only.
364 class ARMPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
366 : PseudoInst<oops, iops, itin, pattern> {
368 list<Predicate> Predicates = [IsARM];
371 // PseudoInst that's Thumb-mode only.
372 class tPseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
374 : PseudoInst<oops, iops, itin, pattern> {
376 list<Predicate> Predicates = [IsThumb];
379 // PseudoInst that's Thumb2-mode only.
380 class t2PseudoInst<dag oops, dag iops, int sz, InstrItinClass itin,
382 : PseudoInst<oops, iops, itin, pattern> {
384 list<Predicate> Predicates = [IsThumb2];
387 class ARMPseudoExpand<dag oops, dag iops, int sz,
388 InstrItinClass itin, list<dag> pattern,
390 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
391 PseudoInstExpansion<Result>;
393 class tPseudoExpand<dag oops, dag iops, int sz,
394 InstrItinClass itin, list<dag> pattern,
396 : tPseudoInst<oops, iops, sz, itin, pattern>,
397 PseudoInstExpansion<Result>;
399 class t2PseudoExpand<dag oops, dag iops, int sz,
400 InstrItinClass itin, list<dag> pattern,
402 : t2PseudoInst<oops, iops, sz, itin, pattern>,
403 PseudoInstExpansion<Result>;
405 // Almost all ARM instructions are predicable.
406 class I<dag oops, dag iops, AddrMode am, int sz,
407 IndexMode im, Format f, InstrItinClass itin,
408 string opc, string asm, string cstr,
410 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
413 let OutOperandList = oops;
414 let InOperandList = !con(iops, (ins pred:$p));
415 let AsmString = !strconcat(opc, "${p}", asm);
416 let Pattern = pattern;
417 list<Predicate> Predicates = [IsARM];
420 // A few are not predicable
421 class InoP<dag oops, dag iops, AddrMode am, int sz,
422 IndexMode im, Format f, InstrItinClass itin,
423 string opc, string asm, string cstr,
425 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
426 let OutOperandList = oops;
427 let InOperandList = iops;
428 let AsmString = !strconcat(opc, asm);
429 let Pattern = pattern;
430 let isPredicable = 0;
431 list<Predicate> Predicates = [IsARM];
434 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
435 // operand since by default it's a zero register. It will become an implicit def
436 // once it's "flipped".
437 class sI<dag oops, dag iops, AddrMode am, int sz,
438 IndexMode im, Format f, InstrItinClass itin,
439 string opc, string asm, string cstr,
441 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
442 bits<4> p; // Predicate operand
443 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
447 let OutOperandList = oops;
448 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
449 let AsmString = !strconcat(opc, "${s}${p}", asm);
450 let Pattern = pattern;
451 list<Predicate> Predicates = [IsARM];
455 class XI<dag oops, dag iops, AddrMode am, int sz,
456 IndexMode im, Format f, InstrItinClass itin,
457 string asm, string cstr, list<dag> pattern>
458 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
459 let OutOperandList = oops;
460 let InOperandList = iops;
462 let Pattern = pattern;
463 list<Predicate> Predicates = [IsARM];
466 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
467 string opc, string asm, list<dag> pattern>
468 : I<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
469 opc, asm, "", pattern>;
470 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
471 string opc, string asm, list<dag> pattern>
472 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
473 opc, asm, "", pattern>;
474 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
475 string asm, list<dag> pattern>
476 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
478 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
480 : InoP<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
481 opc, asm, "", pattern>;
483 // Ctrl flow instructions
484 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
485 string opc, string asm, list<dag> pattern>
486 : I<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
487 opc, asm, "", pattern> {
488 let Inst{27-24} = opcod;
490 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
491 string asm, list<dag> pattern>
492 : XI<oops, iops, AddrModeNone, 4, IndexModeNone, BrFrm, itin,
494 let Inst{27-24} = opcod;
497 // BR_JT instructions
498 class JTI<dag oops, dag iops, InstrItinClass itin,
499 string asm, list<dag> pattern>
500 : XI<oops, iops, AddrModeNone, 0, IndexModeNone, BrMiscFrm, itin,
503 // Atomic load/store instructions
504 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
505 string opc, string asm, list<dag> pattern>
506 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
507 opc, asm, "", pattern> {
510 let Inst{27-23} = 0b00011;
511 let Inst{22-21} = opcod;
513 let Inst{19-16} = addr;
514 let Inst{15-12} = Rt;
515 let Inst{11-0} = 0b111110011111;
517 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
518 string opc, string asm, list<dag> pattern>
519 : I<oops, iops, AddrModeNone, 4, IndexModeNone, LdStExFrm, itin,
520 opc, asm, "", pattern> {
524 let Inst{27-23} = 0b00011;
525 let Inst{22-21} = opcod;
527 let Inst{19-16} = addr;
528 let Inst{15-12} = Rd;
529 let Inst{11-4} = 0b11111001;
532 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
533 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, $addr", pattern> {
537 let Inst{27-23} = 0b00010;
539 let Inst{21-20} = 0b00;
540 let Inst{19-16} = addr;
541 let Inst{15-12} = Rt;
542 let Inst{11-4} = 0b00001001;
545 let Unpredictable{11-8} = 0b1111;
546 let DecoderMethod = "DecodeSwap";
549 // addrmode1 instructions
550 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
551 string opc, string asm, list<dag> pattern>
552 : I<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
553 opc, asm, "", pattern> {
554 let Inst{24-21} = opcod;
555 let Inst{27-26} = 0b00;
557 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
558 string opc, string asm, list<dag> pattern>
559 : sI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
560 opc, asm, "", pattern> {
561 let Inst{24-21} = opcod;
562 let Inst{27-26} = 0b00;
564 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
565 string asm, list<dag> pattern>
566 : XI<oops, iops, AddrMode1, 4, IndexModeNone, f, itin,
568 let Inst{24-21} = opcod;
569 let Inst{27-26} = 0b00;
574 // LDR/LDRB/STR/STRB/...
575 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
576 Format f, InstrItinClass itin, string opc, string asm,
578 : I<oops, iops, am, 4, IndexModeNone, f, itin, opc, asm,
580 let Inst{27-25} = op;
581 let Inst{24} = 1; // 24 == P
583 let Inst{22} = isByte;
584 let Inst{21} = 0; // 21 == W
587 // Indexed load/stores
588 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
589 IndexMode im, Format f, InstrItinClass itin, string opc,
590 string asm, string cstr, list<dag> pattern>
591 : I<oops, iops, AddrMode2, 4, im, f, itin,
592 opc, asm, cstr, pattern> {
594 let Inst{27-26} = 0b01;
595 let Inst{24} = isPre; // P bit
596 let Inst{22} = isByte; // B bit
597 let Inst{21} = isPre; // W bit
598 let Inst{20} = isLd; // L bit
599 let Inst{15-12} = Rt;
601 class AI2stridx_reg<bit isByte, bit isPre, dag oops, dag iops,
602 IndexMode im, Format f, InstrItinClass itin, string opc,
603 string asm, string cstr, list<dag> pattern>
604 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
606 // AM2 store w/ two operands: (GPR, am2offset)
612 let Inst{23} = offset{12};
613 let Inst{19-16} = Rn;
614 let Inst{11-5} = offset{11-5};
616 let Inst{3-0} = offset{3-0};
619 class AI2stridx_imm<bit isByte, bit isPre, dag oops, dag iops,
620 IndexMode im, Format f, InstrItinClass itin, string opc,
621 string asm, string cstr, list<dag> pattern>
622 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
624 // AM2 store w/ two operands: (GPR, am2offset)
630 let Inst{23} = offset{12};
631 let Inst{19-16} = Rn;
632 let Inst{11-0} = offset{11-0};
636 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
637 // but for now use this class for STRT and STRBT.
638 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
639 IndexMode im, Format f, InstrItinClass itin, string opc,
640 string asm, string cstr, list<dag> pattern>
641 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
643 // AM2 store w/ two operands: (GPR, am2offset)
645 // {13} 1 == Rm, 0 == imm12
649 let Inst{25} = addr{13};
650 let Inst{23} = addr{12};
651 let Inst{19-16} = addr{17-14};
652 let Inst{11-0} = addr{11-0};
655 // addrmode3 instructions
656 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
657 InstrItinClass itin, string opc, string asm, list<dag> pattern>
658 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
659 opc, asm, "", pattern> {
662 let Inst{27-25} = 0b000;
663 let Inst{24} = 1; // P bit
664 let Inst{23} = addr{8}; // U bit
665 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
666 let Inst{21} = 0; // W bit
667 let Inst{20} = op20; // L bit
668 let Inst{19-16} = addr{12-9}; // Rn
669 let Inst{15-12} = Rt; // Rt
670 let Inst{11-8} = addr{7-4}; // imm7_4/zero
672 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
674 let DecoderMethod = "DecodeAddrMode3Instruction";
677 class AI3ldstidx<bits<4> op, bit op20, bit isPre, dag oops, dag iops,
678 IndexMode im, Format f, InstrItinClass itin, string opc,
679 string asm, string cstr, list<dag> pattern>
680 : I<oops, iops, AddrMode3, 4, im, f, itin,
681 opc, asm, cstr, pattern> {
683 let Inst{27-25} = 0b000;
684 let Inst{24} = isPre; // P bit
685 let Inst{21} = isPre; // W bit
686 let Inst{20} = op20; // L bit
687 let Inst{15-12} = Rt; // Rt
691 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
692 // but for now use this class for LDRSBT, LDRHT, LDSHT.
693 class AI3ldstidxT<bits<4> op, bit isLoad, dag oops, dag iops,
694 IndexMode im, Format f, InstrItinClass itin, string opc,
695 string asm, string cstr, list<dag> pattern>
696 : I<oops, iops, AddrMode3, 4, im, f, itin, opc, asm, cstr, pattern> {
697 // {13} 1 == imm8, 0 == Rm
704 let Inst{27-25} = 0b000;
705 let Inst{24} = 0; // P bit
707 let Inst{20} = isLoad; // L bit
708 let Inst{19-16} = addr; // Rn
709 let Inst{15-12} = Rt; // Rt
714 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
715 string opc, string asm, list<dag> pattern>
716 : I<oops, iops, AddrMode3, 4, IndexModeNone, f, itin,
717 opc, asm, "", pattern> {
720 let Inst{27-25} = 0b000;
721 let Inst{24} = 1; // P bit
722 let Inst{23} = addr{8}; // U bit
723 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
724 let Inst{21} = 0; // W bit
725 let Inst{20} = 0; // L bit
726 let Inst{19-16} = addr{12-9}; // Rn
727 let Inst{15-12} = Rt; // Rt
728 let Inst{11-8} = addr{7-4}; // imm7_4/zero
730 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
731 let DecoderMethod = "DecodeAddrMode3Instruction";
734 // addrmode4 instructions
735 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
736 string asm, string cstr, list<dag> pattern>
737 : XI<oops, iops, AddrMode4, 4, im, f, itin, asm, cstr, pattern> {
742 let Inst{27-25} = 0b100;
743 let Inst{22} = 0; // S bit
744 let Inst{19-16} = Rn;
745 let Inst{15-0} = regs;
748 // Unsigned multiply, multiply-accumulate instructions.
749 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
750 string opc, string asm, list<dag> pattern>
751 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
752 opc, asm, "", pattern> {
753 let Inst{7-4} = 0b1001;
754 let Inst{20} = 0; // S bit
755 let Inst{27-21} = opcod;
757 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
758 string opc, string asm, list<dag> pattern>
759 : sI<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
760 opc, asm, "", pattern> {
761 let Inst{7-4} = 0b1001;
762 let Inst{27-21} = opcod;
765 // Most significant word multiply
766 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
767 InstrItinClass itin, string opc, string asm, list<dag> pattern>
768 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
769 opc, asm, "", pattern> {
773 let Inst{7-4} = opc7_4;
775 let Inst{27-21} = opcod;
776 let Inst{19-16} = Rd;
780 // MSW multiple w/ Ra operand
781 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
782 InstrItinClass itin, string opc, string asm, list<dag> pattern>
783 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
785 let Inst{15-12} = Ra;
788 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
789 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
790 InstrItinClass itin, string opc, string asm, list<dag> pattern>
791 : I<oops, iops, AddrModeNone, 4, IndexModeNone, MulFrm, itin,
792 opc, asm, "", pattern> {
798 let Inst{27-21} = opcod;
799 let Inst{6-5} = bit6_5;
803 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
804 InstrItinClass itin, string opc, string asm, list<dag> pattern>
805 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
807 let Inst{19-16} = Rd;
810 // AMulxyI with Ra operand
811 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
812 InstrItinClass itin, string opc, string asm, list<dag> pattern>
813 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
815 let Inst{15-12} = Ra;
818 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
819 InstrItinClass itin, string opc, string asm, list<dag> pattern>
820 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
823 let Inst{19-16} = RdHi;
824 let Inst{15-12} = RdLo;
827 // Extend instructions.
828 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
829 string opc, string asm, list<dag> pattern>
830 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ExtFrm, itin,
831 opc, asm, "", pattern> {
832 // All AExtI instructions have Rd and Rm register operands.
835 let Inst{15-12} = Rd;
837 let Inst{7-4} = 0b0111;
838 let Inst{9-8} = 0b00;
839 let Inst{27-20} = opcod;
841 let Unpredictable{9-8} = 0b11;
844 // Misc Arithmetic instructions.
845 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
846 InstrItinClass itin, string opc, string asm, list<dag> pattern>
847 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
848 opc, asm, "", pattern> {
851 let Inst{27-20} = opcod;
852 let Inst{19-16} = 0b1111;
853 let Inst{15-12} = Rd;
854 let Inst{11-8} = 0b1111;
855 let Inst{7-4} = opc7_4;
859 // Division instructions.
860 class ADivA1I<bits<3> opcod, dag oops, dag iops,
861 InstrItinClass itin, string opc, string asm, list<dag> pattern>
862 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
863 opc, asm, "", pattern> {
867 let Inst{27-23} = 0b01110;
868 let Inst{22-20} = opcod;
869 let Inst{19-16} = Rd;
870 let Inst{15-12} = 0b1111;
872 let Inst{7-4} = 0b0001;
877 def PKHLSLAsmOperand : ImmAsmOperand {
878 let Name = "PKHLSLImm";
879 let ParserMethod = "parsePKHLSLImm";
881 def pkh_lsl_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 32; }]>{
882 let PrintMethod = "printPKHLSLShiftImm";
883 let ParserMatchClass = PKHLSLAsmOperand;
885 def PKHASRAsmOperand : AsmOperandClass {
886 let Name = "PKHASRImm";
887 let ParserMethod = "parsePKHASRImm";
889 def pkh_asr_amt: Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm <= 32; }]>{
890 let PrintMethod = "printPKHASRShiftImm";
891 let ParserMatchClass = PKHASRAsmOperand;
894 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
895 string opc, string asm, list<dag> pattern>
896 : I<oops, iops, AddrModeNone, 4, IndexModeNone, ArithMiscFrm, itin,
897 opc, asm, "", pattern> {
902 let Inst{27-20} = opcod;
903 let Inst{19-16} = Rn;
904 let Inst{15-12} = Rd;
907 let Inst{5-4} = 0b01;
911 //===----------------------------------------------------------------------===//
913 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
914 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
915 list<Predicate> Predicates = [IsARM];
917 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
918 list<Predicate> Predicates = [IsARM, HasV5T];
920 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
921 list<Predicate> Predicates = [IsARM, HasV5TE];
923 // ARMV5MOPat - Same as ARMV5TEPat with UseMulOps.
924 class ARMV5MOPat<dag pattern, dag result> : Pat<pattern, result> {
925 list<Predicate> Predicates = [IsARM, HasV5TE, UseMulOps];
927 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
928 list<Predicate> Predicates = [IsARM, HasV6];
931 //===----------------------------------------------------------------------===//
932 // Thumb Instruction Format Definitions.
935 class ThumbI<dag oops, dag iops, AddrMode am, int sz,
936 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
937 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
938 let OutOperandList = oops;
939 let InOperandList = iops;
941 let Pattern = pattern;
942 list<Predicate> Predicates = [IsThumb];
945 // TI - Thumb instruction.
946 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
947 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
949 // Two-address instructions
950 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
952 : ThumbI<oops, iops, AddrModeNone, 2, itin, asm, "$lhs = $dst",
955 // tBL, tBX 32-bit instructions
956 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
957 dag oops, dag iops, InstrItinClass itin, string asm,
959 : ThumbI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>,
961 let Inst{31-27} = opcod1;
962 let Inst{15-14} = opcod2;
963 let Inst{12} = opcod3;
966 // BR_JT instructions
967 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
969 : ThumbI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
972 class Thumb1I<dag oops, dag iops, AddrMode am, int sz,
973 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
974 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
975 let OutOperandList = oops;
976 let InOperandList = iops;
978 let Pattern = pattern;
979 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
982 class T1I<dag oops, dag iops, InstrItinClass itin,
983 string asm, list<dag> pattern>
984 : Thumb1I<oops, iops, AddrModeNone, 2, itin, asm, "", pattern>;
985 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
986 string asm, list<dag> pattern>
987 : Thumb1I<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
989 // Two-address instructions
990 class T1It<dag oops, dag iops, InstrItinClass itin,
991 string asm, string cstr, list<dag> pattern>
992 : Thumb1I<oops, iops, AddrModeNone, 2, itin,
995 // Thumb1 instruction that can either be predicated or set CPSR.
996 class Thumb1sI<dag oops, dag iops, AddrMode am, int sz,
998 string opc, string asm, string cstr, list<dag> pattern>
999 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1000 let OutOperandList = !con(oops, (outs s_cc_out:$s));
1001 let InOperandList = !con(iops, (ins pred:$p));
1002 let AsmString = !strconcat(opc, "${s}${p}", asm);
1003 let Pattern = pattern;
1004 let thumbArithFlagSetting = 1;
1005 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1006 let DecoderNamespace = "ThumbSBit";
1009 class T1sI<dag oops, dag iops, InstrItinClass itin,
1010 string opc, string asm, list<dag> pattern>
1011 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1013 // Two-address instructions
1014 class T1sIt<dag oops, dag iops, InstrItinClass itin,
1015 string opc, string asm, list<dag> pattern>
1016 : Thumb1sI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1017 "$Rn = $Rdn", pattern>;
1019 // Thumb1 instruction that can be predicated.
1020 class Thumb1pI<dag oops, dag iops, AddrMode am, int sz,
1021 InstrItinClass itin,
1022 string opc, string asm, string cstr, list<dag> pattern>
1023 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1024 let OutOperandList = oops;
1025 let InOperandList = !con(iops, (ins pred:$p));
1026 let AsmString = !strconcat(opc, "${p}", asm);
1027 let Pattern = pattern;
1028 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1031 class T1pI<dag oops, dag iops, InstrItinClass itin,
1032 string opc, string asm, list<dag> pattern>
1033 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm, "", pattern>;
1035 // Two-address instructions
1036 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1037 string opc, string asm, list<dag> pattern>
1038 : Thumb1pI<oops, iops, AddrModeNone, 2, itin, opc, asm,
1039 "$Rn = $Rdn", pattern>;
1041 class T1pIs<dag oops, dag iops,
1042 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1043 : Thumb1pI<oops, iops, AddrModeT1_s, 2, itin, opc, asm, "", pattern>;
1045 class Encoding16 : Encoding {
1046 let Inst{31-16} = 0x0000;
1049 // A6.2 16-bit Thumb instruction encoding
1050 class T1Encoding<bits<6> opcode> : Encoding16 {
1051 let Inst{15-10} = opcode;
1054 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1055 class T1General<bits<5> opcode> : Encoding16 {
1056 let Inst{15-14} = 0b00;
1057 let Inst{13-9} = opcode;
1060 // A6.2.2 Data-processing encoding.
1061 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1062 let Inst{15-10} = 0b010000;
1063 let Inst{9-6} = opcode;
1066 // A6.2.3 Special data instructions and branch and exchange encoding.
1067 class T1Special<bits<4> opcode> : Encoding16 {
1068 let Inst{15-10} = 0b010001;
1069 let Inst{9-6} = opcode;
1072 // A6.2.4 Load/store single data item encoding.
1073 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1074 let Inst{15-12} = opA;
1075 let Inst{11-9} = opB;
1077 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1079 class T1BranchCond<bits<4> opcode> : Encoding16 {
1080 let Inst{15-12} = opcode;
1083 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1084 // following bits are used for "opA" (see A6.2.4):
1086 // 0b0110 => Immediate, 4 bytes
1087 // 0b1000 => Immediate, 2 bytes
1088 // 0b0111 => Immediate, 1 byte
1089 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1090 InstrItinClass itin, string opc, string asm,
1092 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1093 T1LoadStore<0b0101, opcode> {
1096 let Inst{8-6} = addr{5-3}; // Rm
1097 let Inst{5-3} = addr{2-0}; // Rn
1100 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1101 InstrItinClass itin, string opc, string asm,
1103 : Thumb1pI<oops, iops, am, 2, itin, opc, asm, "", pattern>,
1104 T1LoadStore<opA, {opB,?,?}> {
1107 let Inst{10-6} = addr{7-3}; // imm5
1108 let Inst{5-3} = addr{2-0}; // Rn
1112 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1113 class T1Misc<bits<7> opcode> : Encoding16 {
1114 let Inst{15-12} = 0b1011;
1115 let Inst{11-5} = opcode;
1118 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1119 class Thumb2I<dag oops, dag iops, AddrMode am, int sz,
1120 InstrItinClass itin,
1121 string opc, string asm, string cstr, list<dag> pattern>
1122 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1123 let OutOperandList = oops;
1124 let InOperandList = !con(iops, (ins pred:$p));
1125 let AsmString = !strconcat(opc, "${p}", asm);
1126 let Pattern = pattern;
1127 list<Predicate> Predicates = [IsThumb2];
1128 let DecoderNamespace = "Thumb2";
1131 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1132 // input operand since by default it's a zero register. It will become an
1133 // implicit def once it's "flipped".
1135 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1137 class Thumb2sI<dag oops, dag iops, AddrMode am, int sz,
1138 InstrItinClass itin,
1139 string opc, string asm, string cstr, list<dag> pattern>
1140 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1141 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1144 let OutOperandList = oops;
1145 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1146 let AsmString = !strconcat(opc, "${s}${p}", asm);
1147 let Pattern = pattern;
1148 list<Predicate> Predicates = [IsThumb2];
1149 let DecoderNamespace = "Thumb2";
1153 class Thumb2XI<dag oops, dag iops, AddrMode am, int sz,
1154 InstrItinClass itin,
1155 string asm, string cstr, list<dag> pattern>
1156 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1157 let OutOperandList = oops;
1158 let InOperandList = iops;
1159 let AsmString = asm;
1160 let Pattern = pattern;
1161 list<Predicate> Predicates = [IsThumb2];
1162 let DecoderNamespace = "Thumb2";
1165 class ThumbXI<dag oops, dag iops, AddrMode am, int sz,
1166 InstrItinClass itin,
1167 string asm, string cstr, list<dag> pattern>
1168 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1169 let OutOperandList = oops;
1170 let InOperandList = iops;
1171 let AsmString = asm;
1172 let Pattern = pattern;
1173 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1174 let DecoderNamespace = "Thumb";
1177 class T2I<dag oops, dag iops, InstrItinClass itin,
1178 string opc, string asm, list<dag> pattern>
1179 : Thumb2I<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1180 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1181 string opc, string asm, list<dag> pattern>
1182 : Thumb2I<oops, iops, AddrModeT2_i12, 4, itin, opc, asm, "",pattern>;
1183 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1184 string opc, string asm, list<dag> pattern>
1185 : Thumb2I<oops, iops, AddrModeT2_i8, 4, itin, opc, asm, "", pattern>;
1186 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1187 string opc, string asm, list<dag> pattern>
1188 : Thumb2I<oops, iops, AddrModeT2_so, 4, itin, opc, asm, "", pattern>;
1189 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1190 string opc, string asm, list<dag> pattern>
1191 : Thumb2I<oops, iops, AddrModeT2_pc, 4, itin, opc, asm, "", pattern>;
1192 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1193 string opc, string asm, string cstr, list<dag> pattern>
1194 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1199 let Inst{31-25} = 0b1110100;
1201 let Inst{23} = addr{8};
1204 let Inst{20} = isLoad;
1205 let Inst{19-16} = addr{12-9};
1206 let Inst{15-12} = Rt{3-0};
1207 let Inst{11-8} = Rt2{3-0};
1208 let Inst{7-0} = addr{7-0};
1210 class T2Ii8s4post<bit P, bit W, bit isLoad, dag oops, dag iops,
1211 InstrItinClass itin, string opc, string asm, string cstr,
1213 : Thumb2I<oops, iops, AddrModeT2_i8s4, 4, itin, opc, asm, cstr,
1219 let Inst{31-25} = 0b1110100;
1221 let Inst{23} = imm{8};
1224 let Inst{20} = isLoad;
1225 let Inst{19-16} = addr;
1226 let Inst{15-12} = Rt{3-0};
1227 let Inst{11-8} = Rt2{3-0};
1228 let Inst{7-0} = imm{7-0};
1231 class T2sI<dag oops, dag iops, InstrItinClass itin,
1232 string opc, string asm, list<dag> pattern>
1233 : Thumb2sI<oops, iops, AddrModeNone, 4, itin, opc, asm, "", pattern>;
1235 class T2XI<dag oops, dag iops, InstrItinClass itin,
1236 string asm, list<dag> pattern>
1237 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, "", pattern>;
1238 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1239 string asm, list<dag> pattern>
1240 : Thumb2XI<oops, iops, AddrModeNone, 0, itin, asm, "", pattern>;
1242 // Move to/from coprocessor instructions
1243 class T2Cop<bits<4> opc, dag oops, dag iops, string opcstr, string asm,
1245 : T2I <oops, iops, NoItinerary, opcstr, asm, pattern>, Requires<[IsThumb2]> {
1246 let Inst{31-28} = opc;
1249 // Two-address instructions
1250 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1251 string asm, string cstr, list<dag> pattern>
1252 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, asm, cstr, pattern>;
1254 // T2Ipreldst - Thumb2 pre-indexed load / store instructions.
1255 class T2Ipreldst<bit signed, bits<2> opcod, bit load, bit pre,
1257 AddrMode am, IndexMode im, InstrItinClass itin,
1258 string opc, string asm, string cstr, list<dag> pattern>
1259 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1260 let OutOperandList = oops;
1261 let InOperandList = !con(iops, (ins pred:$p));
1262 let AsmString = !strconcat(opc, "${p}", asm);
1263 let Pattern = pattern;
1264 list<Predicate> Predicates = [IsThumb2];
1265 let DecoderNamespace = "Thumb2";
1269 let Inst{31-27} = 0b11111;
1270 let Inst{26-25} = 0b00;
1271 let Inst{24} = signed;
1273 let Inst{22-21} = opcod;
1274 let Inst{20} = load;
1275 let Inst{19-16} = addr{12-9};
1276 let Inst{15-12} = Rt{3-0};
1278 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1279 let Inst{10} = pre; // The P bit.
1280 let Inst{9} = addr{8}; // Sign bit
1281 let Inst{8} = 1; // The W bit.
1282 let Inst{7-0} = addr{7-0};
1284 let DecoderMethod = "DecodeT2LdStPre";
1287 // T2Ipostldst - Thumb2 post-indexed load / store instructions.
1288 class T2Ipostldst<bit signed, bits<2> opcod, bit load, bit pre,
1290 AddrMode am, IndexMode im, InstrItinClass itin,
1291 string opc, string asm, string cstr, list<dag> pattern>
1292 : InstARM<am, 4, im, ThumbFrm, GenericDomain, cstr, itin> {
1293 let OutOperandList = oops;
1294 let InOperandList = !con(iops, (ins pred:$p));
1295 let AsmString = !strconcat(opc, "${p}", asm);
1296 let Pattern = pattern;
1297 list<Predicate> Predicates = [IsThumb2];
1298 let DecoderNamespace = "Thumb2";
1303 let Inst{31-27} = 0b11111;
1304 let Inst{26-25} = 0b00;
1305 let Inst{24} = signed;
1307 let Inst{22-21} = opcod;
1308 let Inst{20} = load;
1309 let Inst{19-16} = Rn;
1310 let Inst{15-12} = Rt{3-0};
1312 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1313 let Inst{10} = pre; // The P bit.
1314 let Inst{9} = offset{8}; // Sign bit
1315 let Inst{8} = 1; // The W bit.
1316 let Inst{7-0} = offset{7-0};
1318 let DecoderMethod = "DecodeT2LdStPre";
1321 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1322 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1323 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1326 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1327 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1328 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1331 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1332 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1333 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1336 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1337 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1338 list<Predicate> Predicates = [IsThumb2];
1341 //===----------------------------------------------------------------------===//
1343 //===----------------------------------------------------------------------===//
1344 // ARM VFP Instruction templates.
1347 // Almost all VFP instructions are predicable.
1348 class VFPI<dag oops, dag iops, AddrMode am, int sz,
1349 IndexMode im, Format f, InstrItinClass itin,
1350 string opc, string asm, string cstr, list<dag> pattern>
1351 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1353 let Inst{31-28} = p;
1354 let OutOperandList = oops;
1355 let InOperandList = !con(iops, (ins pred:$p));
1356 let AsmString = !strconcat(opc, "${p}", asm);
1357 let Pattern = pattern;
1358 let PostEncoderMethod = "VFPThumb2PostEncoder";
1359 let DecoderNamespace = "VFP";
1360 list<Predicate> Predicates = [HasVFP2];
1364 class VFPXI<dag oops, dag iops, AddrMode am, int sz,
1365 IndexMode im, Format f, InstrItinClass itin,
1366 string asm, string cstr, list<dag> pattern>
1367 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1369 let Inst{31-28} = p;
1370 let OutOperandList = oops;
1371 let InOperandList = iops;
1372 let AsmString = asm;
1373 let Pattern = pattern;
1374 let PostEncoderMethod = "VFPThumb2PostEncoder";
1375 let DecoderNamespace = "VFP";
1376 list<Predicate> Predicates = [HasVFP2];
1379 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1380 string opc, string asm, list<dag> pattern>
1381 : VFPI<oops, iops, AddrModeNone, 4, IndexModeNone, f, itin,
1382 opc, asm, "", pattern> {
1383 let PostEncoderMethod = "VFPThumb2PostEncoder";
1386 // ARM VFP addrmode5 loads and stores
1387 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1388 InstrItinClass itin,
1389 string opc, string asm, list<dag> pattern>
1390 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1391 VFPLdStFrm, itin, opc, asm, "", pattern> {
1392 // Instruction operands.
1396 // Encode instruction operands.
1397 let Inst{23} = addr{8}; // U (add = (U == '1'))
1398 let Inst{22} = Dd{4};
1399 let Inst{19-16} = addr{12-9}; // Rn
1400 let Inst{15-12} = Dd{3-0};
1401 let Inst{7-0} = addr{7-0}; // imm8
1403 let Inst{27-24} = opcod1;
1404 let Inst{21-20} = opcod2;
1405 let Inst{11-9} = 0b101;
1406 let Inst{8} = 1; // Double precision
1408 // Loads & stores operate on both NEON and VFP pipelines.
1409 let D = VFPNeonDomain;
1412 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1413 InstrItinClass itin,
1414 string opc, string asm, list<dag> pattern>
1415 : VFPI<oops, iops, AddrMode5, 4, IndexModeNone,
1416 VFPLdStFrm, itin, opc, asm, "", pattern> {
1417 // Instruction operands.
1421 // Encode instruction operands.
1422 let Inst{23} = addr{8}; // U (add = (U == '1'))
1423 let Inst{22} = Sd{0};
1424 let Inst{19-16} = addr{12-9}; // Rn
1425 let Inst{15-12} = Sd{4-1};
1426 let Inst{7-0} = addr{7-0}; // imm8
1428 let Inst{27-24} = opcod1;
1429 let Inst{21-20} = opcod2;
1430 let Inst{11-9} = 0b101;
1431 let Inst{8} = 0; // Single precision
1433 // Loads & stores operate on both NEON and VFP pipelines.
1434 let D = VFPNeonDomain;
1437 // VFP Load / store multiple pseudo instructions.
1438 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1440 : InstARM<AddrMode4, 4, IndexModeNone, Pseudo, VFPNeonDomain,
1442 let OutOperandList = oops;
1443 let InOperandList = !con(iops, (ins pred:$p));
1444 let Pattern = pattern;
1445 list<Predicate> Predicates = [HasVFP2];
1448 // Load / store multiple
1450 // Unknown precision
1451 class AXXI4<dag oops, dag iops, IndexMode im,
1452 string asm, string cstr, list<dag> pattern>
1453 : VFPXI<oops, iops, AddrMode4, 4, im,
1454 VFPLdStFrm, NoItinerary, asm, cstr, pattern> {
1455 // Instruction operands.
1459 // Encode instruction operands.
1460 let Inst{19-16} = Rn;
1462 let Inst{15-12} = regs{11-8};
1463 let Inst{7-1} = regs{7-1};
1465 let Inst{27-25} = 0b110;
1466 let Inst{11-8} = 0b1011;
1471 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1472 string asm, string cstr, list<dag> pattern>
1473 : VFPXI<oops, iops, AddrMode4, 4, im,
1474 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1475 // Instruction operands.
1479 // Encode instruction operands.
1480 let Inst{19-16} = Rn;
1481 let Inst{22} = regs{12};
1482 let Inst{15-12} = regs{11-8};
1483 let Inst{7-1} = regs{7-1};
1485 let Inst{27-25} = 0b110;
1486 let Inst{11-9} = 0b101;
1487 let Inst{8} = 1; // Double precision
1492 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1493 string asm, string cstr, list<dag> pattern>
1494 : VFPXI<oops, iops, AddrMode4, 4, im,
1495 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1496 // Instruction operands.
1500 // Encode instruction operands.
1501 let Inst{19-16} = Rn;
1502 let Inst{22} = regs{8};
1503 let Inst{15-12} = regs{12-9};
1504 let Inst{7-0} = regs{7-0};
1506 let Inst{27-25} = 0b110;
1507 let Inst{11-9} = 0b101;
1508 let Inst{8} = 0; // Single precision
1511 // Double precision, unary
1512 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1513 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1514 string asm, list<dag> pattern>
1515 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1516 // Instruction operands.
1520 // Encode instruction operands.
1521 let Inst{3-0} = Dm{3-0};
1522 let Inst{5} = Dm{4};
1523 let Inst{15-12} = Dd{3-0};
1524 let Inst{22} = Dd{4};
1526 let Inst{27-23} = opcod1;
1527 let Inst{21-20} = opcod2;
1528 let Inst{19-16} = opcod3;
1529 let Inst{11-9} = 0b101;
1530 let Inst{8} = 1; // Double precision
1531 let Inst{7-6} = opcod4;
1532 let Inst{4} = opcod5;
1535 // Double precision, unary, not-predicated
1536 class ADuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1537 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1538 string asm, list<dag> pattern>
1539 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPUnaryFrm, itin, asm, "", pattern> {
1540 // Instruction operands.
1544 let Inst{31-28} = 0b1111;
1546 // Encode instruction operands.
1547 let Inst{3-0} = Dm{3-0};
1548 let Inst{5} = Dm{4};
1549 let Inst{15-12} = Dd{3-0};
1550 let Inst{22} = Dd{4};
1552 let Inst{27-23} = opcod1;
1553 let Inst{21-20} = opcod2;
1554 let Inst{19-16} = opcod3;
1555 let Inst{11-9} = 0b101;
1556 let Inst{8} = 1; // Double precision
1557 let Inst{7-6} = opcod4;
1558 let Inst{4} = opcod5;
1561 // Double precision, binary
1562 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1563 dag iops, InstrItinClass itin, string opc, string asm,
1565 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1566 // Instruction operands.
1571 // Encode instruction operands.
1572 let Inst{3-0} = Dm{3-0};
1573 let Inst{5} = Dm{4};
1574 let Inst{19-16} = Dn{3-0};
1575 let Inst{7} = Dn{4};
1576 let Inst{15-12} = Dd{3-0};
1577 let Inst{22} = Dd{4};
1579 let Inst{27-23} = opcod1;
1580 let Inst{21-20} = opcod2;
1581 let Inst{11-9} = 0b101;
1582 let Inst{8} = 1; // Double precision
1587 // FP, binary, not predicated
1588 class ADbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1589 InstrItinClass itin, string asm, list<dag> pattern>
1590 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone, VFPBinaryFrm, itin,
1593 // Instruction operands.
1598 let Inst{31-28} = 0b1111;
1600 // Encode instruction operands.
1601 let Inst{3-0} = Dm{3-0};
1602 let Inst{5} = Dm{4};
1603 let Inst{19-16} = Dn{3-0};
1604 let Inst{7} = Dn{4};
1605 let Inst{15-12} = Dd{3-0};
1606 let Inst{22} = Dd{4};
1608 let Inst{27-23} = opcod1;
1609 let Inst{21-20} = opcod2;
1610 let Inst{11-9} = 0b101;
1611 let Inst{8} = 1; // double precision
1612 let Inst{6} = opcod3;
1616 // Single precision, unary, predicated
1617 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1618 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1619 string asm, list<dag> pattern>
1620 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1621 // Instruction operands.
1625 // Encode instruction operands.
1626 let Inst{3-0} = Sm{4-1};
1627 let Inst{5} = Sm{0};
1628 let Inst{15-12} = Sd{4-1};
1629 let Inst{22} = Sd{0};
1631 let Inst{27-23} = opcod1;
1632 let Inst{21-20} = opcod2;
1633 let Inst{19-16} = opcod3;
1634 let Inst{11-9} = 0b101;
1635 let Inst{8} = 0; // Single precision
1636 let Inst{7-6} = opcod4;
1637 let Inst{4} = opcod5;
1640 // Single precision, unary, non-predicated
1641 class ASuInp<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1642 bit opcod5, dag oops, dag iops, InstrItinClass itin,
1643 string asm, list<dag> pattern>
1644 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1645 VFPUnaryFrm, itin, asm, "", pattern> {
1646 // Instruction operands.
1650 let Inst{31-28} = 0b1111;
1652 // Encode instruction operands.
1653 let Inst{3-0} = Sm{4-1};
1654 let Inst{5} = Sm{0};
1655 let Inst{15-12} = Sd{4-1};
1656 let Inst{22} = Sd{0};
1658 let Inst{27-23} = opcod1;
1659 let Inst{21-20} = opcod2;
1660 let Inst{19-16} = opcod3;
1661 let Inst{11-9} = 0b101;
1662 let Inst{8} = 0; // Single precision
1663 let Inst{7-6} = opcod4;
1664 let Inst{4} = opcod5;
1667 // Single precision unary, if no NEON. Same as ASuI except not available if
1669 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1670 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1671 string asm, list<dag> pattern>
1672 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1674 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1677 // Single precision, binary
1678 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1679 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1680 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1681 // Instruction operands.
1686 // Encode instruction operands.
1687 let Inst{3-0} = Sm{4-1};
1688 let Inst{5} = Sm{0};
1689 let Inst{19-16} = Sn{4-1};
1690 let Inst{7} = Sn{0};
1691 let Inst{15-12} = Sd{4-1};
1692 let Inst{22} = Sd{0};
1694 let Inst{27-23} = opcod1;
1695 let Inst{21-20} = opcod2;
1696 let Inst{11-9} = 0b101;
1697 let Inst{8} = 0; // Single precision
1702 // Single precision, binary, not predicated
1703 class ASbInp<bits<5> opcod1, bits<2> opcod2, bit opcod3, dag oops, dag iops,
1704 InstrItinClass itin, string asm, list<dag> pattern>
1705 : VFPXI<oops, iops, AddrModeNone, 4, IndexModeNone,
1706 VFPBinaryFrm, itin, asm, "", pattern>
1708 // Instruction operands.
1713 let Inst{31-28} = 0b1111;
1715 // Encode instruction operands.
1716 let Inst{3-0} = Sm{4-1};
1717 let Inst{5} = Sm{0};
1718 let Inst{19-16} = Sn{4-1};
1719 let Inst{7} = Sn{0};
1720 let Inst{15-12} = Sd{4-1};
1721 let Inst{22} = Sd{0};
1723 let Inst{27-23} = opcod1;
1724 let Inst{21-20} = opcod2;
1725 let Inst{11-9} = 0b101;
1726 let Inst{8} = 0; // Single precision
1727 let Inst{6} = opcod3;
1731 // Single precision binary, if no NEON. Same as ASbI except not available if
1733 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1734 dag iops, InstrItinClass itin, string opc, string asm,
1736 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1737 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1739 // Instruction operands.
1744 // Encode instruction operands.
1745 let Inst{3-0} = Sm{4-1};
1746 let Inst{5} = Sm{0};
1747 let Inst{19-16} = Sn{4-1};
1748 let Inst{7} = Sn{0};
1749 let Inst{15-12} = Sd{4-1};
1750 let Inst{22} = Sd{0};
1753 // VFP conversion instructions
1754 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1755 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1757 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1758 let Inst{27-23} = opcod1;
1759 let Inst{21-20} = opcod2;
1760 let Inst{19-16} = opcod3;
1761 let Inst{11-8} = opcod4;
1766 // VFP conversion between floating-point and fixed-point
1767 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1768 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1770 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1772 // size (fixed-point number): sx == 0 ? 16 : 32
1773 let Inst{7} = op5; // sx
1774 let Inst{5} = fbits{0};
1775 let Inst{3-0} = fbits{4-1};
1778 // VFP conversion instructions, if no NEON
1779 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1780 dag oops, dag iops, InstrItinClass itin,
1781 string opc, string asm, list<dag> pattern>
1782 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1784 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1787 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1788 InstrItinClass itin,
1789 string opc, string asm, list<dag> pattern>
1790 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1791 let Inst{27-20} = opcod1;
1792 let Inst{11-8} = opcod2;
1796 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1797 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1798 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1800 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1801 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1802 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1804 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1805 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1806 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1808 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1809 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1810 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1812 //===----------------------------------------------------------------------===//
1814 //===----------------------------------------------------------------------===//
1815 // ARM NEON Instruction templates.
1818 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1819 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1821 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1822 let OutOperandList = oops;
1823 let InOperandList = !con(iops, (ins pred:$p));
1824 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1825 let Pattern = pattern;
1826 list<Predicate> Predicates = [HasNEON];
1827 let DecoderNamespace = "NEON";
1830 // Same as NeonI except it does not have a "data type" specifier.
1831 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1832 InstrItinClass itin, string opc, string asm, string cstr,
1834 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1835 let OutOperandList = oops;
1836 let InOperandList = !con(iops, (ins pred:$p));
1837 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1838 let Pattern = pattern;
1839 list<Predicate> Predicates = [HasNEON];
1840 let DecoderNamespace = "NEON";
1843 // Same as NeonI except it is not predicated
1844 class NeonInp<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1845 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1847 : InstARM<am, 4, im, f, NeonDomain, cstr, itin> {
1848 let OutOperandList = oops;
1849 let InOperandList = iops;
1850 let AsmString = !strconcat(opc, ".", dt, "\t", asm);
1851 let Pattern = pattern;
1852 list<Predicate> Predicates = [HasNEON];
1853 let DecoderNamespace = "NEON";
1855 let Inst{31-28} = 0b1111;
1858 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1859 dag oops, dag iops, InstrItinClass itin,
1860 string opc, string dt, string asm, string cstr, list<dag> pattern>
1861 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1863 let Inst{31-24} = 0b11110100;
1864 let Inst{23} = op23;
1865 let Inst{21-20} = op21_20;
1866 let Inst{11-8} = op11_8;
1867 let Inst{7-4} = op7_4;
1869 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1870 let DecoderNamespace = "NEONLoadStore";
1876 let Inst{22} = Vd{4};
1877 let Inst{15-12} = Vd{3-0};
1878 let Inst{19-16} = Rn{3-0};
1879 let Inst{3-0} = Rm{3-0};
1882 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1883 dag oops, dag iops, InstrItinClass itin,
1884 string opc, string dt, string asm, string cstr, list<dag> pattern>
1885 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1886 dt, asm, cstr, pattern> {
1890 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1891 : InstARM<AddrMode6, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
1893 let OutOperandList = oops;
1894 let InOperandList = !con(iops, (ins pred:$p));
1895 list<Predicate> Predicates = [HasNEON];
1898 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1900 : InstARM<AddrModeNone, 4, IndexModeNone, Pseudo, NeonDomain, cstr,
1902 let OutOperandList = oops;
1903 let InOperandList = !con(iops, (ins pred:$p));
1904 let Pattern = pattern;
1905 list<Predicate> Predicates = [HasNEON];
1908 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1909 string opc, string dt, string asm, string cstr, list<dag> pattern>
1910 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1912 let Inst{31-25} = 0b1111001;
1913 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1914 let DecoderNamespace = "NEONData";
1917 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1918 string opc, string asm, string cstr, list<dag> pattern>
1919 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1921 let Inst{31-25} = 0b1111001;
1922 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1923 let DecoderNamespace = "NEONData";
1926 // NEON "one register and a modified immediate" format.
1927 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1929 dag oops, dag iops, InstrItinClass itin,
1930 string opc, string dt, string asm, string cstr,
1932 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1933 let Inst{23} = op23;
1934 let Inst{21-19} = op21_19;
1935 let Inst{11-8} = op11_8;
1941 // Instruction operands.
1945 let Inst{15-12} = Vd{3-0};
1946 let Inst{22} = Vd{4};
1947 let Inst{24} = SIMM{7};
1948 let Inst{18-16} = SIMM{6-4};
1949 let Inst{3-0} = SIMM{3-0};
1950 let DecoderMethod = "DecodeNEONModImmInstruction";
1953 // NEON 2 vector register format.
1954 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1955 bits<5> op11_7, bit op6, bit op4,
1956 dag oops, dag iops, InstrItinClass itin,
1957 string opc, string dt, string asm, string cstr, list<dag> pattern>
1958 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1959 let Inst{24-23} = op24_23;
1960 let Inst{21-20} = op21_20;
1961 let Inst{19-18} = op19_18;
1962 let Inst{17-16} = op17_16;
1963 let Inst{11-7} = op11_7;
1967 // Instruction operands.
1971 let Inst{15-12} = Vd{3-0};
1972 let Inst{22} = Vd{4};
1973 let Inst{3-0} = Vm{3-0};
1974 let Inst{5} = Vm{4};
1977 // Same as N2V but not predicated.
1978 class N2Vnp<bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
1979 dag oops, dag iops, InstrItinClass itin, string OpcodeStr,
1980 string Dt, ValueType ResTy, ValueType OpTy, list<dag> pattern>
1981 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, N2RegFrm, itin,
1982 OpcodeStr, Dt, "$Vd, $Vm", "", pattern> {
1986 // Encode instruction operands
1987 let Inst{22} = Vd{4};
1988 let Inst{15-12} = Vd{3-0};
1989 let Inst{5} = Vm{4};
1990 let Inst{3-0} = Vm{3-0};
1992 // Encode constant bits
1993 let Inst{27-23} = 0b00111;
1994 let Inst{21-20} = 0b11;
1995 let Inst{19-18} = 0b10;
1996 let Inst{17-16} = op17_16;
1998 let Inst{10-8} = op10_8;
2003 let DecoderNamespace = "NEON";
2006 // Same as N2V except it doesn't have a datatype suffix.
2007 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
2008 bits<5> op11_7, bit op6, bit op4,
2009 dag oops, dag iops, InstrItinClass itin,
2010 string opc, string asm, string cstr, list<dag> pattern>
2011 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
2012 let Inst{24-23} = op24_23;
2013 let Inst{21-20} = op21_20;
2014 let Inst{19-18} = op19_18;
2015 let Inst{17-16} = op17_16;
2016 let Inst{11-7} = op11_7;
2020 // Instruction operands.
2024 let Inst{15-12} = Vd{3-0};
2025 let Inst{22} = Vd{4};
2026 let Inst{3-0} = Vm{3-0};
2027 let Inst{5} = Vm{4};
2030 // NEON 2 vector register with immediate.
2031 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
2032 dag oops, dag iops, Format f, InstrItinClass itin,
2033 string opc, string dt, string asm, string cstr, list<dag> pattern>
2034 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2035 let Inst{24} = op24;
2036 let Inst{23} = op23;
2037 let Inst{11-8} = op11_8;
2042 // Instruction operands.
2047 let Inst{15-12} = Vd{3-0};
2048 let Inst{22} = Vd{4};
2049 let Inst{3-0} = Vm{3-0};
2050 let Inst{5} = Vm{4};
2051 let Inst{21-16} = SIMM{5-0};
2054 // NEON 3 vector register format.
2056 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2057 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2058 string opc, string dt, string asm, string cstr,
2060 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2061 let Inst{24} = op24;
2062 let Inst{23} = op23;
2063 let Inst{21-20} = op21_20;
2064 let Inst{11-8} = op11_8;
2069 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
2070 dag oops, dag iops, Format f, InstrItinClass itin,
2071 string opc, string dt, string asm, string cstr, list<dag> pattern>
2072 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2073 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2074 // Instruction operands.
2079 let Inst{15-12} = Vd{3-0};
2080 let Inst{22} = Vd{4};
2081 let Inst{19-16} = Vn{3-0};
2082 let Inst{7} = Vn{4};
2083 let Inst{3-0} = Vm{3-0};
2084 let Inst{5} = Vm{4};
2087 class N3Vnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2088 bit op4, dag oops, dag iops,Format f, InstrItinClass itin,
2089 string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy,
2090 SDPatternOperator IntOp, bit Commutable, list<dag> pattern>
2091 : NeonInp<oops, iops, AddrModeNone, IndexModeNone, f, itin, OpcodeStr,
2092 Dt, "$Vd, $Vn, $Vm", "", pattern> {
2097 // Encode instruction operands
2098 let Inst{22} = Vd{4};
2099 let Inst{15-12} = Vd{3-0};
2100 let Inst{19-16} = Vn{3-0};
2101 let Inst{7} = Vn{4};
2102 let Inst{5} = Vm{4};
2103 let Inst{3-0} = Vm{3-0};
2105 // Encode constant bits
2106 let Inst{27-23} = op27_23;
2107 let Inst{21-20} = op21_20;
2108 let Inst{11-8} = op11_8;
2113 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2114 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2115 string opc, string dt, string asm, string cstr,
2117 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2118 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2120 // Instruction operands.
2126 let Inst{15-12} = Vd{3-0};
2127 let Inst{22} = Vd{4};
2128 let Inst{19-16} = Vn{3-0};
2129 let Inst{7} = Vn{4};
2130 let Inst{3-0} = Vm{3-0};
2134 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2135 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
2136 string opc, string dt, string asm, string cstr,
2138 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
2139 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
2141 // Instruction operands.
2147 let Inst{15-12} = Vd{3-0};
2148 let Inst{22} = Vd{4};
2149 let Inst{19-16} = Vn{3-0};
2150 let Inst{7} = Vn{4};
2151 let Inst{2-0} = Vm{2-0};
2152 let Inst{5} = lane{1};
2153 let Inst{3} = lane{0};
2156 // Same as N3V except it doesn't have a data type suffix.
2157 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
2159 dag oops, dag iops, Format f, InstrItinClass itin,
2160 string opc, string asm, string cstr, list<dag> pattern>
2161 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
2162 let Inst{24} = op24;
2163 let Inst{23} = op23;
2164 let Inst{21-20} = op21_20;
2165 let Inst{11-8} = op11_8;
2169 // Instruction operands.
2174 let Inst{15-12} = Vd{3-0};
2175 let Inst{22} = Vd{4};
2176 let Inst{19-16} = Vn{3-0};
2177 let Inst{7} = Vn{4};
2178 let Inst{3-0} = Vm{3-0};
2179 let Inst{5} = Vm{4};
2182 // NEON VMOVs between scalar and core registers.
2183 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2184 dag oops, dag iops, Format f, InstrItinClass itin,
2185 string opc, string dt, string asm, list<dag> pattern>
2186 : InstARM<AddrModeNone, 4, IndexModeNone, f, NeonDomain,
2188 let Inst{27-20} = opcod1;
2189 let Inst{11-8} = opcod2;
2190 let Inst{6-5} = opcod3;
2192 // A8.6.303, A8.6.328, A8.6.329
2193 let Inst{3-0} = 0b0000;
2195 let OutOperandList = oops;
2196 let InOperandList = !con(iops, (ins pred:$p));
2197 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
2198 let Pattern = pattern;
2199 list<Predicate> Predicates = [HasNEON];
2201 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
2202 let DecoderNamespace = "NEONDup";
2209 let Inst{31-28} = p{3-0};
2211 let Inst{19-16} = V{3-0};
2212 let Inst{15-12} = R{3-0};
2214 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2215 dag oops, dag iops, InstrItinClass itin,
2216 string opc, string dt, string asm, list<dag> pattern>
2217 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
2218 opc, dt, asm, pattern>;
2219 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2220 dag oops, dag iops, InstrItinClass itin,
2221 string opc, string dt, string asm, list<dag> pattern>
2222 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
2223 opc, dt, asm, pattern>;
2224 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
2225 dag oops, dag iops, InstrItinClass itin,
2226 string opc, string dt, string asm, list<dag> pattern>
2227 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
2228 opc, dt, asm, pattern>;
2230 // Vector Duplicate Lane (from scalar to all elements)
2231 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
2232 InstrItinClass itin, string opc, string dt, string asm,
2234 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
2235 let Inst{24-23} = 0b11;
2236 let Inst{21-20} = 0b11;
2237 let Inst{19-16} = op19_16;
2238 let Inst{11-7} = 0b11000;
2245 let Inst{22} = Vd{4};
2246 let Inst{15-12} = Vd{3-0};
2247 let Inst{5} = Vm{4};
2248 let Inst{3-0} = Vm{3-0};
2251 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
2252 // for single-precision FP.
2253 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
2254 list<Predicate> Predicates = [HasNEON,UseNEONForFP];
2257 // VFP/NEON Instruction aliases for type suffices.
2258 class VFPDataTypeInstAlias<string opc, string dt, string asm, dag Result> :
2259 InstAlias<!strconcat(opc, dt, "\t", asm), Result>, Requires<[HasVFP2]>;
2261 multiclass VFPDTAnyInstAlias<string opc, string asm, dag Result> {
2262 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2263 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2264 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2265 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2268 multiclass NEONDTAnyInstAlias<string opc, string asm, dag Result> {
2269 let Predicates = [HasNEON] in {
2270 def : VFPDataTypeInstAlias<opc, ".8", asm, Result>;
2271 def : VFPDataTypeInstAlias<opc, ".16", asm, Result>;
2272 def : VFPDataTypeInstAlias<opc, ".32", asm, Result>;
2273 def : VFPDataTypeInstAlias<opc, ".64", asm, Result>;
2277 // The same alias classes using AsmPseudo instead, for the more complex
2278 // stuff in NEON that InstAlias can't quite handle.
2279 // Note that we can't use anonymous defm references here like we can
2280 // above, as we care about the ultimate instruction enum names generated, unlike
2281 // for instalias defs.
2282 class NEONDataTypeAsmPseudoInst<string opc, string dt, string asm, dag iops> :
2283 AsmPseudoInst<!strconcat(opc, dt, "\t", asm), iops>, Requires<[HasNEON]>;
2285 // Data type suffix token aliases. Implements Table A7-3 in the ARM ARM.
2286 def : TokenAlias<".s8", ".i8">;
2287 def : TokenAlias<".u8", ".i8">;
2288 def : TokenAlias<".s16", ".i16">;
2289 def : TokenAlias<".u16", ".i16">;
2290 def : TokenAlias<".s32", ".i32">;
2291 def : TokenAlias<".u32", ".i32">;
2292 def : TokenAlias<".s64", ".i64">;
2293 def : TokenAlias<".u64", ".i64">;
2295 def : TokenAlias<".i8", ".8">;
2296 def : TokenAlias<".i16", ".16">;
2297 def : TokenAlias<".i32", ".32">;
2298 def : TokenAlias<".i64", ".64">;
2300 def : TokenAlias<".p8", ".8">;
2301 def : TokenAlias<".p16", ".16">;
2303 def : TokenAlias<".f32", ".32">;
2304 def : TokenAlias<".f64", ".64">;
2305 def : TokenAlias<".f", ".f32">;
2306 def : TokenAlias<".d", ".f64">;