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 DPSoRegFrm : 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>;
74 // The instruction has an Rn register operand.
75 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
76 // it doesn't have a Rn operand.
77 class UnaryDP { bit isUnaryDataProc = 1; }
79 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80 // a 16-bit Thumb instruction if certain conditions are met.
81 class Xform16Bit { bit canXformTo16Bit = 1; }
83 //===----------------------------------------------------------------------===//
84 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
87 // FIXME: Once the JIT is MC-ized, these can go away.
89 class AddrMode<bits<5> val> {
92 def AddrModeNone : AddrMode<0>;
93 def AddrMode1 : AddrMode<1>;
94 def AddrMode2 : AddrMode<2>;
95 def AddrMode3 : AddrMode<3>;
96 def AddrMode4 : AddrMode<4>;
97 def AddrMode5 : AddrMode<5>;
98 def AddrMode6 : AddrMode<6>;
99 def AddrModeT1_1 : AddrMode<7>;
100 def AddrModeT1_2 : AddrMode<8>;
101 def AddrModeT1_4 : AddrMode<9>;
102 def AddrModeT1_s : AddrMode<10>;
103 def AddrModeT2_i12 : AddrMode<11>;
104 def AddrModeT2_i8 : AddrMode<12>;
105 def AddrModeT2_so : AddrMode<13>;
106 def AddrModeT2_pc : AddrMode<14>;
107 def AddrModeT2_i8s4 : AddrMode<15>;
108 def AddrMode_i12 : AddrMode<16>;
111 class SizeFlagVal<bits<3> val> {
114 def SizeInvalid : SizeFlagVal<0>; // Unset.
115 def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
116 def Size8Bytes : SizeFlagVal<2>;
117 def Size4Bytes : SizeFlagVal<3>;
118 def Size2Bytes : SizeFlagVal<4>;
120 // Load / store index mode.
121 class IndexMode<bits<2> val> {
124 def IndexModeNone : IndexMode<0>;
125 def IndexModePre : IndexMode<1>;
126 def IndexModePost : IndexMode<2>;
127 def IndexModeUpd : IndexMode<3>;
129 // Instruction execution domain.
130 class Domain<bits<3> val> {
133 def GenericDomain : Domain<0>;
134 def VFPDomain : Domain<1>; // Instructions in VFP domain only
135 def NeonDomain : Domain<2>; // Instructions in Neon domain only
136 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
137 def VFPNeonA8Domain : Domain<5>; // Instructions in VFP & Neon under A8
139 //===----------------------------------------------------------------------===//
140 // ARM special operands.
143 def CondCodeOperand : AsmOperandClass {
144 let Name = "CondCode";
145 let SuperClasses = [];
148 def CCOutOperand : AsmOperandClass {
150 let SuperClasses = [];
153 def MemBarrierOptOperand : AsmOperandClass {
154 let Name = "MemBarrierOpt";
155 let SuperClasses = [];
156 let ParserMethod = "tryParseMemBarrierOptOperand";
159 def ProcIFlagsOperand : AsmOperandClass {
160 let Name = "ProcIFlags";
161 let SuperClasses = [];
162 let ParserMethod = "tryParseProcIFlagsOperand";
165 def MSRMaskOperand : AsmOperandClass {
166 let Name = "MSRMask";
167 let SuperClasses = [];
168 let ParserMethod = "tryParseMSRMaskOperand";
171 // ARM imod and iflag operands, used only by the CPS instruction.
172 def imod_op : Operand<i32> {
173 let PrintMethod = "printCPSIMod";
176 def iflags_op : Operand<i32> {
177 let PrintMethod = "printCPSIFlag";
178 let ParserMatchClass = ProcIFlagsOperand;
181 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
182 // register whose default is 0 (no register).
183 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
184 (ops (i32 14), (i32 zero_reg))> {
185 let PrintMethod = "printPredicateOperand";
186 let ParserMatchClass = CondCodeOperand;
189 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
190 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
191 let EncoderMethod = "getCCOutOpValue";
192 let PrintMethod = "printSBitModifierOperand";
193 let ParserMatchClass = CCOutOperand;
196 // Same as cc_out except it defaults to setting CPSR.
197 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
198 let EncoderMethod = "getCCOutOpValue";
199 let PrintMethod = "printSBitModifierOperand";
200 let ParserMatchClass = CCOutOperand;
203 // ARM special operands for disassembly only.
205 def setend_op : Operand<i32> {
206 let PrintMethod = "printSetendOperand";
209 def msr_mask : Operand<i32> {
210 let PrintMethod = "printMSRMaskOperand";
211 let ParserMatchClass = MSRMaskOperand;
214 // Shift Right Immediate - A shift right immediate is encoded differently from
215 // other shift immediates. The imm6 field is encoded like so:
218 // 8 imm6<5:3> = '001', 8 - <imm> is encoded in imm6<2:0>
219 // 16 imm6<5:4> = '01', 16 - <imm> is encoded in imm6<3:0>
220 // 32 imm6<5> = '1', 32 - <imm> is encoded in imm6<4:0>
221 // 64 64 - <imm> is encoded in imm6<5:0>
222 def shr_imm8 : Operand<i32> {
223 let EncoderMethod = "getShiftRight8Imm";
225 def shr_imm16 : Operand<i32> {
226 let EncoderMethod = "getShiftRight16Imm";
228 def shr_imm32 : Operand<i32> {
229 let EncoderMethod = "getShiftRight32Imm";
231 def shr_imm64 : Operand<i32> {
232 let EncoderMethod = "getShiftRight64Imm";
235 //===----------------------------------------------------------------------===//
236 // ARM Instruction templates.
239 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
240 Format f, Domain d, string cstr, InstrItinClass itin>
242 let Namespace = "ARM";
247 bits<2> IndexModeBits = IM.Value;
249 bits<6> Form = F.Value;
251 bit isUnaryDataProc = 0;
252 bit canXformTo16Bit = 0;
254 // If this is a pseudo instruction, mark it isCodeGenOnly.
255 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
257 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
258 let TSFlags{4-0} = AM.Value;
259 let TSFlags{7-5} = SZ.Value;
260 let TSFlags{9-8} = IndexModeBits;
261 let TSFlags{15-10} = Form;
262 let TSFlags{16} = isUnaryDataProc;
263 let TSFlags{17} = canXformTo16Bit;
264 let TSFlags{20-18} = D.Value;
266 let Constraints = cstr;
267 let Itinerary = itin;
274 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
275 Format f, Domain d, string cstr, InstrItinClass itin>
276 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
278 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
279 // on by adding flavors to specific instructions.
280 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
281 Format f, Domain d, string cstr, InstrItinClass itin>
282 : InstTemplate<am, sz, im, f, d, cstr, itin>;
284 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
285 : InstTemplate<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo,
286 GenericDomain, "", itin> {
287 let OutOperandList = oops;
288 let InOperandList = iops;
289 let Pattern = pattern;
290 let isCodeGenOnly = 1;
294 // PseudoInst that's ARM-mode only.
295 class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
297 : PseudoInst<oops, iops, itin, pattern> {
299 list<Predicate> Predicates = [IsARM];
302 // PseudoInst that's Thumb-mode only.
303 class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
305 : PseudoInst<oops, iops, itin, pattern> {
307 list<Predicate> Predicates = [IsThumb];
310 // PseudoInst that's Thumb2-mode only.
311 class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
313 : PseudoInst<oops, iops, itin, pattern> {
315 list<Predicate> Predicates = [IsThumb2];
318 class ARMPseudoExpand<dag oops, dag iops, SizeFlagVal sz,
319 InstrItinClass itin, list<dag> pattern,
321 : ARMPseudoInst<oops, iops, sz, itin, pattern>,
322 PseudoInstExpansion<Result>;
324 class tPseudoExpand<dag oops, dag iops, SizeFlagVal sz,
325 InstrItinClass itin, list<dag> pattern,
327 : tPseudoInst<oops, iops, sz, itin, pattern>,
328 PseudoInstExpansion<Result>;
330 class t2PseudoExpand<dag oops, dag iops, SizeFlagVal sz,
331 InstrItinClass itin, list<dag> pattern,
333 : t2PseudoInst<oops, iops, sz, itin, pattern>,
334 PseudoInstExpansion<Result>;
336 // Almost all ARM instructions are predicable.
337 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
338 IndexMode im, Format f, InstrItinClass itin,
339 string opc, string asm, string cstr,
341 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
344 let OutOperandList = oops;
345 let InOperandList = !con(iops, (ins pred:$p));
346 let AsmString = !strconcat(opc, "${p}", asm);
347 let Pattern = pattern;
348 list<Predicate> Predicates = [IsARM];
351 // A few are not predicable
352 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
353 IndexMode im, Format f, InstrItinClass itin,
354 string opc, string asm, string cstr,
356 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
357 let OutOperandList = oops;
358 let InOperandList = iops;
359 let AsmString = !strconcat(opc, asm);
360 let Pattern = pattern;
361 let isPredicable = 0;
362 list<Predicate> Predicates = [IsARM];
365 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
366 // operand since by default it's a zero register. It will become an implicit def
367 // once it's "flipped".
368 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
369 IndexMode im, Format f, InstrItinClass itin,
370 string opc, string asm, string cstr,
372 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
373 bits<4> p; // Predicate operand
374 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
378 let OutOperandList = oops;
379 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
380 let AsmString = !strconcat(opc, "${s}${p}", asm);
381 let Pattern = pattern;
382 list<Predicate> Predicates = [IsARM];
386 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
387 IndexMode im, Format f, InstrItinClass itin,
388 string asm, string cstr, list<dag> pattern>
389 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
390 let OutOperandList = oops;
391 let InOperandList = iops;
393 let Pattern = pattern;
394 list<Predicate> Predicates = [IsARM];
397 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
398 string opc, string asm, list<dag> pattern>
399 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
400 opc, asm, "", pattern>;
401 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
402 string opc, string asm, list<dag> pattern>
403 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
404 opc, asm, "", pattern>;
405 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
406 string asm, list<dag> pattern>
407 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
409 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
410 string opc, string asm, list<dag> pattern>
411 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
412 opc, asm, "", pattern>;
414 // Ctrl flow instructions
415 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
416 string opc, string asm, list<dag> pattern>
417 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
418 opc, asm, "", pattern> {
419 let Inst{27-24} = opcod;
421 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
422 string asm, list<dag> pattern>
423 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
425 let Inst{27-24} = opcod;
428 // BR_JT instructions
429 class JTI<dag oops, dag iops, InstrItinClass itin,
430 string asm, list<dag> pattern>
431 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
434 // Atomic load/store instructions
435 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
436 string opc, string asm, list<dag> pattern>
437 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
438 opc, asm, "", pattern> {
441 let Inst{27-23} = 0b00011;
442 let Inst{22-21} = opcod;
444 let Inst{19-16} = Rn;
445 let Inst{15-12} = Rt;
446 let Inst{11-0} = 0b111110011111;
448 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
449 string opc, string asm, list<dag> pattern>
450 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
451 opc, asm, "", pattern> {
455 let Inst{27-23} = 0b00011;
456 let Inst{22-21} = opcod;
458 let Inst{19-16} = addr;
459 let Inst{15-12} = Rd;
460 let Inst{11-4} = 0b11111001;
463 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
464 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
468 let Inst{27-23} = 0b00010;
470 let Inst{21-20} = 0b00;
471 let Inst{19-16} = Rn;
472 let Inst{15-12} = Rt;
473 let Inst{11-4} = 0b00001001;
477 // addrmode1 instructions
478 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
479 string opc, string asm, list<dag> pattern>
480 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
481 opc, asm, "", pattern> {
482 let Inst{24-21} = opcod;
483 let Inst{27-26} = 0b00;
485 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
486 string opc, string asm, list<dag> pattern>
487 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
488 opc, asm, "", pattern> {
489 let Inst{24-21} = opcod;
490 let Inst{27-26} = 0b00;
492 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
493 string asm, list<dag> pattern>
494 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
496 let Inst{24-21} = opcod;
497 let Inst{27-26} = 0b00;
502 // LDR/LDRB/STR/STRB/...
503 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
504 Format f, InstrItinClass itin, string opc, string asm,
506 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
508 let Inst{27-25} = op;
509 let Inst{24} = 1; // 24 == P
511 let Inst{22} = isByte;
512 let Inst{21} = 0; // 21 == W
515 // Indexed load/stores
516 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
517 IndexMode im, Format f, InstrItinClass itin, string opc,
518 string asm, string cstr, list<dag> pattern>
519 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
520 opc, asm, cstr, pattern> {
522 let Inst{27-26} = 0b01;
523 let Inst{24} = isPre; // P bit
524 let Inst{22} = isByte; // B bit
525 let Inst{21} = isPre; // W bit
526 let Inst{20} = isLd; // L bit
527 let Inst{15-12} = Rt;
529 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
530 IndexMode im, Format f, InstrItinClass itin, string opc,
531 string asm, string cstr, list<dag> pattern>
532 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
534 // AM2 store w/ two operands: (GPR, am2offset)
535 // {13} 1 == Rm, 0 == imm12
540 let Inst{25} = offset{13};
541 let Inst{23} = offset{12};
542 let Inst{19-16} = Rn;
543 let Inst{11-0} = offset{11-0};
545 // FIXME: Merge with the above class when addrmode2 gets used for STR, STRB
546 // but for now use this class for STRT and STRBT.
547 class AI2stridxT<bit isByte, bit isPre, dag oops, dag iops,
548 IndexMode im, Format f, InstrItinClass itin, string opc,
549 string asm, string cstr, list<dag> pattern>
550 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
552 // AM2 store w/ two operands: (GPR, am2offset)
554 // {13} 1 == Rm, 0 == imm12
558 let Inst{25} = addr{13};
559 let Inst{23} = addr{12};
560 let Inst{19-16} = addr{17-14};
561 let Inst{11-0} = addr{11-0};
564 // addrmode3 instructions
565 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
566 InstrItinClass itin, string opc, string asm, list<dag> pattern>
567 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
568 opc, asm, "", pattern> {
571 let Inst{27-25} = 0b000;
572 let Inst{24} = 1; // P bit
573 let Inst{23} = addr{8}; // U bit
574 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
575 let Inst{21} = 0; // W bit
576 let Inst{20} = op20; // L bit
577 let Inst{19-16} = addr{12-9}; // Rn
578 let Inst{15-12} = Rt; // Rt
579 let Inst{11-8} = addr{7-4}; // imm7_4/zero
581 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
584 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
585 IndexMode im, Format f, InstrItinClass itin, string opc,
586 string asm, string cstr, list<dag> pattern>
587 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
588 opc, asm, cstr, pattern> {
590 let Inst{27-25} = 0b000;
591 let Inst{24} = isPre; // P bit
592 let Inst{21} = isPre; // W bit
593 let Inst{20} = op20; // L bit
594 let Inst{15-12} = Rt; // Rt
598 // FIXME: Merge with the above class when addrmode2 gets used for LDR, LDRB
599 // but for now use this class for LDRSBT, LDRHT, LDSHT.
600 class AI3ldstidxT<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
601 IndexMode im, Format f, InstrItinClass itin, string opc,
602 string asm, string cstr, list<dag> pattern>
603 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
604 opc, asm, cstr, pattern> {
605 // {13} 1 == imm8, 0 == Rm
612 let Inst{27-25} = 0b000;
613 let Inst{24} = isPre; // P bit
614 let Inst{23} = addr{8}; // U bit
615 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
616 let Inst{20} = op20; // L bit
617 let Inst{19-16} = addr{12-9}; // Rn
618 let Inst{15-12} = Rt; // Rt
619 let Inst{11-8} = addr{7-4}; // imm7_4/zero
621 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
622 let AsmMatchConverter = "CvtLdWriteBackRegAddrMode3";
625 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
626 IndexMode im, Format f, InstrItinClass itin, string opc,
627 string asm, string cstr, list<dag> pattern>
628 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
630 // AM3 store w/ two operands: (GPR, am3offset)
634 let Inst{27-25} = 0b000;
635 let Inst{23} = offset{8};
636 let Inst{22} = offset{9};
637 let Inst{19-16} = Rn;
638 let Inst{15-12} = Rt; // Rt
639 let Inst{11-8} = offset{7-4}; // imm7_4/zero
641 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
645 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
646 string opc, string asm, list<dag> pattern>
647 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
648 opc, asm, "", pattern> {
651 let Inst{27-25} = 0b000;
652 let Inst{24} = 1; // P bit
653 let Inst{23} = addr{8}; // U bit
654 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
655 let Inst{21} = 0; // W bit
656 let Inst{20} = 0; // L bit
657 let Inst{19-16} = addr{12-9}; // Rn
658 let Inst{15-12} = Rt; // Rt
659 let Inst{11-8} = addr{7-4}; // imm7_4/zero
661 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
664 // Pre-indexed stores
665 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
666 string opc, string asm, string cstr, list<dag> pattern>
667 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
668 opc, asm, cstr, pattern> {
670 let Inst{5} = 1; // H bit
671 let Inst{6} = 0; // S bit
673 let Inst{20} = 0; // L bit
674 let Inst{21} = 1; // W bit
675 let Inst{24} = 1; // P bit
676 let Inst{27-25} = 0b000;
678 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
679 string opc, string asm, string cstr, list<dag> pattern>
680 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
681 opc, asm, cstr, pattern> {
683 let Inst{5} = 1; // H bit
684 let Inst{6} = 1; // S bit
686 let Inst{20} = 0; // L bit
687 let Inst{21} = 1; // W bit
688 let Inst{24} = 1; // P bit
689 let Inst{27-25} = 0b000;
692 // Post-indexed stores
693 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
694 string opc, string asm, string cstr, list<dag> pattern>
695 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
696 opc, asm, cstr,pattern> {
697 // {13} 1 == imm8, 0 == Rm
704 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
706 let Inst{5} = 1; // H bit
707 let Inst{6} = 0; // S bit
709 let Inst{11-8} = addr{7-4}; // imm7_4/zero
710 let Inst{15-12} = Rt; // Rt
711 let Inst{19-16} = addr{12-9}; // Rn
712 let Inst{20} = 0; // L bit
713 let Inst{21} = 0; // W bit
714 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
715 let Inst{23} = addr{8}; // U bit
716 let Inst{24} = 0; // P bit
717 let Inst{27-25} = 0b000;
719 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
720 string opc, string asm, string cstr, list<dag> pattern>
721 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
722 opc, asm, cstr, pattern> {
724 let Inst{5} = 1; // H bit
725 let Inst{6} = 1; // S bit
727 let Inst{20} = 0; // L bit
728 let Inst{21} = 0; // W bit
729 let Inst{24} = 0; // P bit
730 let Inst{27-25} = 0b000;
733 // addrmode4 instructions
734 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
735 string asm, string cstr, list<dag> pattern>
736 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
741 let Inst{27-25} = 0b100;
742 let Inst{22} = 0; // S bit
743 let Inst{19-16} = Rn;
744 let Inst{15-0} = regs;
747 // Unsigned multiply, multiply-accumulate instructions.
748 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
749 string opc, string asm, list<dag> pattern>
750 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
751 opc, asm, "", pattern> {
752 let Inst{7-4} = 0b1001;
753 let Inst{20} = 0; // S bit
754 let Inst{27-21} = opcod;
756 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
757 string opc, string asm, list<dag> pattern>
758 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
759 opc, asm, "", pattern> {
760 let Inst{7-4} = 0b1001;
761 let Inst{27-21} = opcod;
764 // Most significant word multiply
765 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
766 InstrItinClass itin, string opc, string asm, list<dag> pattern>
767 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
768 opc, asm, "", pattern> {
772 let Inst{7-4} = opc7_4;
774 let Inst{27-21} = opcod;
775 let Inst{19-16} = Rd;
779 // MSW multiple w/ Ra operand
780 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
781 InstrItinClass itin, string opc, string asm, list<dag> pattern>
782 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
784 let Inst{15-12} = Ra;
787 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
788 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
789 InstrItinClass itin, string opc, string asm, list<dag> pattern>
790 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
791 opc, asm, "", pattern> {
797 let Inst{27-21} = opcod;
798 let Inst{6-5} = bit6_5;
802 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
803 InstrItinClass itin, string opc, string asm, list<dag> pattern>
804 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
806 let Inst{19-16} = Rd;
809 // AMulxyI with Ra operand
810 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
811 InstrItinClass itin, string opc, string asm, list<dag> pattern>
812 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
814 let Inst{15-12} = Ra;
817 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
818 InstrItinClass itin, string opc, string asm, list<dag> pattern>
819 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
822 let Inst{19-16} = RdHi;
823 let Inst{15-12} = RdLo;
826 // Extend instructions.
827 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
828 string opc, string asm, list<dag> pattern>
829 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
830 opc, asm, "", pattern> {
831 // All AExtI instructions have Rd and Rm register operands.
834 let Inst{15-12} = Rd;
836 let Inst{7-4} = 0b0111;
837 let Inst{9-8} = 0b00;
838 let Inst{27-20} = opcod;
841 // Misc Arithmetic instructions.
842 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
843 InstrItinClass itin, string opc, string asm, list<dag> pattern>
844 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
845 opc, asm, "", pattern> {
848 let Inst{27-20} = opcod;
849 let Inst{19-16} = 0b1111;
850 let Inst{15-12} = Rd;
851 let Inst{11-8} = 0b1111;
852 let Inst{7-4} = opc7_4;
857 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
858 string opc, string asm, list<dag> pattern>
859 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
860 opc, asm, "", pattern> {
865 let Inst{27-20} = opcod;
866 let Inst{19-16} = Rn;
867 let Inst{15-12} = Rd;
868 let Inst{11-7} = sh{7-3};
870 let Inst{5-4} = 0b01;
874 //===----------------------------------------------------------------------===//
876 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
877 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
878 list<Predicate> Predicates = [IsARM];
880 class ARMV5TPat<dag pattern, dag result> : Pat<pattern, result> {
881 list<Predicate> Predicates = [IsARM, HasV5T];
883 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
884 list<Predicate> Predicates = [IsARM, HasV5TE];
886 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
887 list<Predicate> Predicates = [IsARM, HasV6];
890 //===----------------------------------------------------------------------===//
891 // Thumb Instruction Format Definitions.
894 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
895 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
896 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
897 let OutOperandList = oops;
898 let InOperandList = iops;
900 let Pattern = pattern;
901 list<Predicate> Predicates = [IsThumb];
904 // TI - Thumb instruction.
905 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
906 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
908 // Two-address instructions
909 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
911 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
914 // tBL, tBX 32-bit instructions
915 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
916 dag oops, dag iops, InstrItinClass itin, string asm,
918 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
920 let Inst{31-27} = opcod1;
921 let Inst{15-14} = opcod2;
922 let Inst{12} = opcod3;
925 // Move to/from coprocessor instructions
926 class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
927 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
928 Encoding, Requires<[IsThumb, HasV6]> {
929 let Inst{31-28} = 0b1110;
932 // BR_JT instructions
933 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
935 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
938 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
939 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
940 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
941 let OutOperandList = oops;
942 let InOperandList = iops;
944 let Pattern = pattern;
945 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
948 class T1I<dag oops, dag iops, InstrItinClass itin,
949 string asm, list<dag> pattern>
950 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
951 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
952 string asm, list<dag> pattern>
953 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
955 // Two-address instructions
956 class T1It<dag oops, dag iops, InstrItinClass itin,
957 string asm, string cstr, list<dag> pattern>
958 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
961 // Thumb1 instruction that can either be predicated or set CPSR.
962 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
964 string opc, string asm, string cstr, list<dag> pattern>
965 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
966 let OutOperandList = !con(oops, (outs s_cc_out:$s));
967 let InOperandList = !con(iops, (ins pred:$p));
968 let AsmString = !strconcat(opc, "${s}${p}", asm);
969 let Pattern = pattern;
970 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
973 class T1sI<dag oops, dag iops, InstrItinClass itin,
974 string opc, string asm, list<dag> pattern>
975 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
977 // Two-address instructions
978 class T1sIt<dag oops, dag iops, InstrItinClass itin,
979 string opc, string asm, list<dag> pattern>
980 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
981 "$Rn = $Rdn", pattern>;
983 // Thumb1 instruction that can be predicated.
984 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
986 string opc, string asm, string cstr, list<dag> pattern>
987 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
988 let OutOperandList = oops;
989 let InOperandList = !con(iops, (ins pred:$p));
990 let AsmString = !strconcat(opc, "${p}", asm);
991 let Pattern = pattern;
992 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
995 class T1pI<dag oops, dag iops, InstrItinClass itin,
996 string opc, string asm, list<dag> pattern>
997 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
999 // Two-address instructions
1000 class T1pIt<dag oops, dag iops, InstrItinClass itin,
1001 string opc, string asm, list<dag> pattern>
1002 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
1003 "$Rn = $Rdn", pattern>;
1005 class T1pIs<dag oops, dag iops,
1006 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1007 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
1009 class Encoding16 : Encoding {
1010 let Inst{31-16} = 0x0000;
1013 // A6.2 16-bit Thumb instruction encoding
1014 class T1Encoding<bits<6> opcode> : Encoding16 {
1015 let Inst{15-10} = opcode;
1018 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
1019 class T1General<bits<5> opcode> : Encoding16 {
1020 let Inst{15-14} = 0b00;
1021 let Inst{13-9} = opcode;
1024 // A6.2.2 Data-processing encoding.
1025 class T1DataProcessing<bits<4> opcode> : Encoding16 {
1026 let Inst{15-10} = 0b010000;
1027 let Inst{9-6} = opcode;
1030 // A6.2.3 Special data instructions and branch and exchange encoding.
1031 class T1Special<bits<4> opcode> : Encoding16 {
1032 let Inst{15-10} = 0b010001;
1033 let Inst{9-6} = opcode;
1036 // A6.2.4 Load/store single data item encoding.
1037 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
1038 let Inst{15-12} = opA;
1039 let Inst{11-9} = opB;
1041 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
1043 class T1BranchCond<bits<4> opcode> : Encoding16 {
1044 let Inst{15-12} = opcode;
1047 // Helper classes to encode Thumb1 loads and stores. For immediates, the
1048 // following bits are used for "opA" (see A6.2.4):
1050 // 0b0110 => Immediate, 4 bytes
1051 // 0b1000 => Immediate, 2 bytes
1052 // 0b0111 => Immediate, 1 byte
1053 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
1054 InstrItinClass itin, string opc, string asm,
1056 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
1057 T1LoadStore<0b0101, opcode> {
1060 let Inst{8-6} = addr{5-3}; // Rm
1061 let Inst{5-3} = addr{2-0}; // Rn
1064 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
1065 InstrItinClass itin, string opc, string asm,
1067 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
1068 T1LoadStore<opA, {opB,?,?}> {
1071 let Inst{10-6} = addr{7-3}; // imm5
1072 let Inst{5-3} = addr{2-0}; // Rn
1076 // A6.2.5 Miscellaneous 16-bit instructions encoding.
1077 class T1Misc<bits<7> opcode> : Encoding16 {
1078 let Inst{15-12} = 0b1011;
1079 let Inst{11-5} = opcode;
1082 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
1083 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1084 InstrItinClass itin,
1085 string opc, string asm, string cstr, list<dag> pattern>
1086 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1087 let OutOperandList = oops;
1088 let InOperandList = !con(iops, (ins pred:$p));
1089 let AsmString = !strconcat(opc, "${p}", asm);
1090 let Pattern = pattern;
1091 list<Predicate> Predicates = [IsThumb2];
1094 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
1095 // input operand since by default it's a zero register. It will become an
1096 // implicit def once it's "flipped".
1098 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
1100 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1101 InstrItinClass itin,
1102 string opc, string asm, string cstr, list<dag> pattern>
1103 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1104 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
1107 let OutOperandList = oops;
1108 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
1109 let AsmString = !strconcat(opc, "${s}${p}", asm);
1110 let Pattern = pattern;
1111 list<Predicate> Predicates = [IsThumb2];
1115 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1116 InstrItinClass itin,
1117 string asm, string cstr, list<dag> pattern>
1118 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1119 let OutOperandList = oops;
1120 let InOperandList = iops;
1121 let AsmString = asm;
1122 let Pattern = pattern;
1123 list<Predicate> Predicates = [IsThumb2];
1126 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1127 InstrItinClass itin,
1128 string asm, string cstr, list<dag> pattern>
1129 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1130 let OutOperandList = oops;
1131 let InOperandList = iops;
1132 let AsmString = asm;
1133 let Pattern = pattern;
1134 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1137 class T2I<dag oops, dag iops, InstrItinClass itin,
1138 string opc, string asm, list<dag> pattern>
1139 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1140 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1141 string opc, string asm, list<dag> pattern>
1142 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
1143 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1144 string opc, string asm, list<dag> pattern>
1145 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1146 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1147 string opc, string asm, list<dag> pattern>
1148 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1149 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1150 string opc, string asm, list<dag> pattern>
1151 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1152 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1153 string opc, string asm, list<dag> pattern>
1154 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1159 let Inst{31-25} = 0b1110100;
1161 let Inst{23} = addr{8};
1164 let Inst{20} = isLoad;
1165 let Inst{19-16} = addr{12-9};
1166 let Inst{15-12} = Rt{3-0};
1167 let Inst{11-8} = Rt2{3-0};
1168 let Inst{7-0} = addr{7-0};
1171 class T2sI<dag oops, dag iops, InstrItinClass itin,
1172 string opc, string asm, list<dag> pattern>
1173 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1175 class T2XI<dag oops, dag iops, InstrItinClass itin,
1176 string asm, list<dag> pattern>
1177 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1178 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1179 string asm, list<dag> pattern>
1180 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1182 // Move to/from coprocessor instructions
1183 class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1184 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1185 let Inst{31-28} = 0b1111;
1188 // Two-address instructions
1189 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1190 string asm, string cstr, list<dag> pattern>
1191 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1193 // T2Iidxldst - Thumb2 indexed load / store instructions.
1194 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1196 AddrMode am, IndexMode im, InstrItinClass itin,
1197 string opc, string asm, string cstr, list<dag> pattern>
1198 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1199 let OutOperandList = oops;
1200 let InOperandList = !con(iops, (ins pred:$p));
1201 let AsmString = !strconcat(opc, "${p}", asm);
1202 let Pattern = pattern;
1203 list<Predicate> Predicates = [IsThumb2];
1204 let Inst{31-27} = 0b11111;
1205 let Inst{26-25} = 0b00;
1206 let Inst{24} = signed;
1208 let Inst{22-21} = opcod;
1209 let Inst{20} = load;
1211 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1212 let Inst{10} = pre; // The P bit.
1213 let Inst{8} = 1; // The W bit.
1216 let Inst{7-0} = addr{7-0};
1217 let Inst{9} = addr{8}; // Sign bit
1221 let Inst{15-12} = Rt{3-0};
1222 let Inst{19-16} = Rn{3-0};
1225 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1226 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1227 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1230 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1231 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1232 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1235 // T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode.
1236 class T2v6Pat<dag pattern, dag result> : Pat<pattern, result> {
1237 list<Predicate> Predicates = [IsThumb2, HasV6T2];
1240 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1241 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1242 list<Predicate> Predicates = [IsThumb2];
1245 //===----------------------------------------------------------------------===//
1247 //===----------------------------------------------------------------------===//
1248 // ARM VFP Instruction templates.
1251 // Almost all VFP instructions are predicable.
1252 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1253 IndexMode im, Format f, InstrItinClass itin,
1254 string opc, string asm, string cstr, list<dag> pattern>
1255 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1257 let Inst{31-28} = p;
1258 let OutOperandList = oops;
1259 let InOperandList = !con(iops, (ins pred:$p));
1260 let AsmString = !strconcat(opc, "${p}", asm);
1261 let Pattern = pattern;
1262 let PostEncoderMethod = "VFPThumb2PostEncoder";
1263 list<Predicate> Predicates = [HasVFP2];
1267 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1268 IndexMode im, Format f, InstrItinClass itin,
1269 string asm, string cstr, list<dag> pattern>
1270 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1272 let Inst{31-28} = p;
1273 let OutOperandList = oops;
1274 let InOperandList = iops;
1275 let AsmString = asm;
1276 let Pattern = pattern;
1277 let PostEncoderMethod = "VFPThumb2PostEncoder";
1278 list<Predicate> Predicates = [HasVFP2];
1281 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1282 string opc, string asm, list<dag> pattern>
1283 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1284 opc, asm, "", pattern> {
1285 let PostEncoderMethod = "VFPThumb2PostEncoder";
1288 // ARM VFP addrmode5 loads and stores
1289 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1290 InstrItinClass itin,
1291 string opc, string asm, list<dag> pattern>
1292 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1293 VFPLdStFrm, itin, opc, asm, "", pattern> {
1294 // Instruction operands.
1298 // Encode instruction operands.
1299 let Inst{23} = addr{8}; // U (add = (U == '1'))
1300 let Inst{22} = Dd{4};
1301 let Inst{19-16} = addr{12-9}; // Rn
1302 let Inst{15-12} = Dd{3-0};
1303 let Inst{7-0} = addr{7-0}; // imm8
1305 // TODO: Mark the instructions with the appropriate subtarget info.
1306 let Inst{27-24} = opcod1;
1307 let Inst{21-20} = opcod2;
1308 let Inst{11-9} = 0b101;
1309 let Inst{8} = 1; // Double precision
1311 // Loads & stores operate on both NEON and VFP pipelines.
1312 let D = VFPNeonDomain;
1315 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1316 InstrItinClass itin,
1317 string opc, string asm, list<dag> pattern>
1318 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1319 VFPLdStFrm, itin, opc, asm, "", pattern> {
1320 // Instruction operands.
1324 // Encode instruction operands.
1325 let Inst{23} = addr{8}; // U (add = (U == '1'))
1326 let Inst{22} = Sd{0};
1327 let Inst{19-16} = addr{12-9}; // Rn
1328 let Inst{15-12} = Sd{4-1};
1329 let Inst{7-0} = addr{7-0}; // imm8
1331 // TODO: Mark the instructions with the appropriate subtarget info.
1332 let Inst{27-24} = opcod1;
1333 let Inst{21-20} = opcod2;
1334 let Inst{11-9} = 0b101;
1335 let Inst{8} = 0; // Single precision
1337 // Loads & stores operate on both NEON and VFP pipelines.
1338 let D = VFPNeonDomain;
1341 // VFP Load / store multiple pseudo instructions.
1342 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1344 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1346 let OutOperandList = oops;
1347 let InOperandList = !con(iops, (ins pred:$p));
1348 let Pattern = pattern;
1349 list<Predicate> Predicates = [HasVFP2];
1352 // Load / store multiple
1353 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1354 string asm, string cstr, list<dag> pattern>
1355 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1356 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1357 // Instruction operands.
1361 // Encode instruction operands.
1362 let Inst{19-16} = Rn;
1363 let Inst{22} = regs{12};
1364 let Inst{15-12} = regs{11-8};
1365 let Inst{7-0} = regs{7-0};
1367 // TODO: Mark the instructions with the appropriate subtarget info.
1368 let Inst{27-25} = 0b110;
1369 let Inst{11-9} = 0b101;
1370 let Inst{8} = 1; // Double precision
1373 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1374 string asm, string cstr, list<dag> pattern>
1375 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1376 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1377 // Instruction operands.
1381 // Encode instruction operands.
1382 let Inst{19-16} = Rn;
1383 let Inst{22} = regs{8};
1384 let Inst{15-12} = regs{12-9};
1385 let Inst{7-0} = regs{7-0};
1387 // TODO: Mark the instructions with the appropriate subtarget info.
1388 let Inst{27-25} = 0b110;
1389 let Inst{11-9} = 0b101;
1390 let Inst{8} = 0; // Single precision
1393 // Double precision, unary
1394 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1395 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1396 string asm, list<dag> pattern>
1397 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1398 // Instruction operands.
1402 // Encode instruction operands.
1403 let Inst{3-0} = Dm{3-0};
1404 let Inst{5} = Dm{4};
1405 let Inst{15-12} = Dd{3-0};
1406 let Inst{22} = Dd{4};
1408 let Inst{27-23} = opcod1;
1409 let Inst{21-20} = opcod2;
1410 let Inst{19-16} = opcod3;
1411 let Inst{11-9} = 0b101;
1412 let Inst{8} = 1; // Double precision
1413 let Inst{7-6} = opcod4;
1414 let Inst{4} = opcod5;
1417 // Double precision, binary
1418 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1419 dag iops, InstrItinClass itin, string opc, string asm,
1421 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1422 // Instruction operands.
1427 // Encode instruction operands.
1428 let Inst{3-0} = Dm{3-0};
1429 let Inst{5} = Dm{4};
1430 let Inst{19-16} = Dn{3-0};
1431 let Inst{7} = Dn{4};
1432 let Inst{15-12} = Dd{3-0};
1433 let Inst{22} = Dd{4};
1435 let Inst{27-23} = opcod1;
1436 let Inst{21-20} = opcod2;
1437 let Inst{11-9} = 0b101;
1438 let Inst{8} = 1; // Double precision
1443 // Single precision, unary
1444 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1445 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1446 string asm, list<dag> pattern>
1447 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1448 // Instruction operands.
1452 // Encode instruction operands.
1453 let Inst{3-0} = Sm{4-1};
1454 let Inst{5} = Sm{0};
1455 let Inst{15-12} = Sd{4-1};
1456 let Inst{22} = Sd{0};
1458 let Inst{27-23} = opcod1;
1459 let Inst{21-20} = opcod2;
1460 let Inst{19-16} = opcod3;
1461 let Inst{11-9} = 0b101;
1462 let Inst{8} = 0; // Single precision
1463 let Inst{7-6} = opcod4;
1464 let Inst{4} = opcod5;
1467 // Single precision unary, if no NEON. Same as ASuI except not available if
1469 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1470 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1471 string asm, list<dag> pattern>
1472 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1474 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1477 // Single precision, binary
1478 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1479 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1480 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1481 // Instruction operands.
1486 // Encode instruction operands.
1487 let Inst{3-0} = Sm{4-1};
1488 let Inst{5} = Sm{0};
1489 let Inst{19-16} = Sn{4-1};
1490 let Inst{7} = Sn{0};
1491 let Inst{15-12} = Sd{4-1};
1492 let Inst{22} = Sd{0};
1494 let Inst{27-23} = opcod1;
1495 let Inst{21-20} = opcod2;
1496 let Inst{11-9} = 0b101;
1497 let Inst{8} = 0; // Single precision
1502 // Single precision binary, if no NEON. Same as ASbI except not available if
1504 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1505 dag iops, InstrItinClass itin, string opc, string asm,
1507 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1508 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1510 // Instruction operands.
1515 // Encode instruction operands.
1516 let Inst{3-0} = Sm{4-1};
1517 let Inst{5} = Sm{0};
1518 let Inst{19-16} = Sn{4-1};
1519 let Inst{7} = Sn{0};
1520 let Inst{15-12} = Sd{4-1};
1521 let Inst{22} = Sd{0};
1524 // VFP conversion instructions
1525 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1526 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1528 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1529 let Inst{27-23} = opcod1;
1530 let Inst{21-20} = opcod2;
1531 let Inst{19-16} = opcod3;
1532 let Inst{11-8} = opcod4;
1537 // VFP conversion between floating-point and fixed-point
1538 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1539 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1541 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1542 // size (fixed-point number): sx == 0 ? 16 : 32
1543 let Inst{7} = op5; // sx
1546 // VFP conversion instructions, if no NEON
1547 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1548 dag oops, dag iops, InstrItinClass itin,
1549 string opc, string asm, list<dag> pattern>
1550 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1552 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1555 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1556 InstrItinClass itin,
1557 string opc, string asm, list<dag> pattern>
1558 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1559 let Inst{27-20} = opcod1;
1560 let Inst{11-8} = opcod2;
1564 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1565 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1566 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1568 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1569 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1570 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1572 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1573 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1574 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1576 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1577 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1578 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1580 //===----------------------------------------------------------------------===//
1582 //===----------------------------------------------------------------------===//
1583 // ARM NEON Instruction templates.
1586 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1587 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1589 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1590 let OutOperandList = oops;
1591 let InOperandList = !con(iops, (ins pred:$p));
1592 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1593 let Pattern = pattern;
1594 list<Predicate> Predicates = [HasNEON];
1597 // Same as NeonI except it does not have a "data type" specifier.
1598 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1599 InstrItinClass itin, string opc, string asm, string cstr,
1601 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1602 let OutOperandList = oops;
1603 let InOperandList = !con(iops, (ins pred:$p));
1604 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1605 let Pattern = pattern;
1606 list<Predicate> Predicates = [HasNEON];
1609 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1610 dag oops, dag iops, InstrItinClass itin,
1611 string opc, string dt, string asm, string cstr, list<dag> pattern>
1612 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1614 let Inst{31-24} = 0b11110100;
1615 let Inst{23} = op23;
1616 let Inst{21-20} = op21_20;
1617 let Inst{11-8} = op11_8;
1618 let Inst{7-4} = op7_4;
1620 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1626 let Inst{22} = Vd{4};
1627 let Inst{15-12} = Vd{3-0};
1628 let Inst{19-16} = Rn{3-0};
1629 let Inst{3-0} = Rm{3-0};
1632 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1633 dag oops, dag iops, InstrItinClass itin,
1634 string opc, string dt, string asm, string cstr, list<dag> pattern>
1635 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1636 dt, asm, cstr, pattern> {
1640 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1641 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1643 let OutOperandList = oops;
1644 let InOperandList = !con(iops, (ins pred:$p));
1645 list<Predicate> Predicates = [HasNEON];
1648 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1650 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1652 let OutOperandList = oops;
1653 let InOperandList = !con(iops, (ins pred:$p));
1654 let Pattern = pattern;
1655 list<Predicate> Predicates = [HasNEON];
1658 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1659 string opc, string dt, string asm, string cstr, list<dag> pattern>
1660 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1662 let Inst{31-25} = 0b1111001;
1663 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1666 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1667 string opc, string asm, string cstr, list<dag> pattern>
1668 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1670 let Inst{31-25} = 0b1111001;
1671 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1674 // NEON "one register and a modified immediate" format.
1675 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1677 dag oops, dag iops, InstrItinClass itin,
1678 string opc, string dt, string asm, string cstr,
1680 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1681 let Inst{23} = op23;
1682 let Inst{21-19} = op21_19;
1683 let Inst{11-8} = op11_8;
1689 // Instruction operands.
1693 let Inst{15-12} = Vd{3-0};
1694 let Inst{22} = Vd{4};
1695 let Inst{24} = SIMM{7};
1696 let Inst{18-16} = SIMM{6-4};
1697 let Inst{3-0} = SIMM{3-0};
1700 // NEON 2 vector register format.
1701 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1702 bits<5> op11_7, bit op6, bit op4,
1703 dag oops, dag iops, InstrItinClass itin,
1704 string opc, string dt, string asm, string cstr, list<dag> pattern>
1705 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1706 let Inst{24-23} = op24_23;
1707 let Inst{21-20} = op21_20;
1708 let Inst{19-18} = op19_18;
1709 let Inst{17-16} = op17_16;
1710 let Inst{11-7} = op11_7;
1714 // Instruction operands.
1718 let Inst{15-12} = Vd{3-0};
1719 let Inst{22} = Vd{4};
1720 let Inst{3-0} = Vm{3-0};
1721 let Inst{5} = Vm{4};
1724 // Same as N2V except it doesn't have a datatype suffix.
1725 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1726 bits<5> op11_7, bit op6, bit op4,
1727 dag oops, dag iops, InstrItinClass itin,
1728 string opc, string asm, string cstr, list<dag> pattern>
1729 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1730 let Inst{24-23} = op24_23;
1731 let Inst{21-20} = op21_20;
1732 let Inst{19-18} = op19_18;
1733 let Inst{17-16} = op17_16;
1734 let Inst{11-7} = op11_7;
1738 // Instruction operands.
1742 let Inst{15-12} = Vd{3-0};
1743 let Inst{22} = Vd{4};
1744 let Inst{3-0} = Vm{3-0};
1745 let Inst{5} = Vm{4};
1748 // NEON 2 vector register with immediate.
1749 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1750 dag oops, dag iops, Format f, InstrItinClass itin,
1751 string opc, string dt, string asm, string cstr, list<dag> pattern>
1752 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1753 let Inst{24} = op24;
1754 let Inst{23} = op23;
1755 let Inst{11-8} = op11_8;
1760 // Instruction operands.
1765 let Inst{15-12} = Vd{3-0};
1766 let Inst{22} = Vd{4};
1767 let Inst{3-0} = Vm{3-0};
1768 let Inst{5} = Vm{4};
1769 let Inst{21-16} = SIMM{5-0};
1772 // NEON 3 vector register format.
1774 class N3VCommon<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1775 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1776 string opc, string dt, string asm, string cstr,
1778 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1779 let Inst{24} = op24;
1780 let Inst{23} = op23;
1781 let Inst{21-20} = op21_20;
1782 let Inst{11-8} = op11_8;
1787 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1788 dag oops, dag iops, Format f, InstrItinClass itin,
1789 string opc, string dt, string asm, string cstr, list<dag> pattern>
1790 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1791 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1793 // Instruction operands.
1798 let Inst{15-12} = Vd{3-0};
1799 let Inst{22} = Vd{4};
1800 let Inst{19-16} = Vn{3-0};
1801 let Inst{7} = Vn{4};
1802 let Inst{3-0} = Vm{3-0};
1803 let Inst{5} = Vm{4};
1806 class N3VLane32<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1807 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1808 string opc, string dt, string asm, string cstr,
1810 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1811 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1813 // Instruction operands.
1819 let Inst{15-12} = Vd{3-0};
1820 let Inst{22} = Vd{4};
1821 let Inst{19-16} = Vn{3-0};
1822 let Inst{7} = Vn{4};
1823 let Inst{3-0} = Vm{3-0};
1827 class N3VLane16<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1828 bit op4, dag oops, dag iops, Format f, InstrItinClass itin,
1829 string opc, string dt, string asm, string cstr,
1831 : N3VCommon<op24, op23, op21_20, op11_8, op6, op4,
1832 oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1834 // Instruction operands.
1840 let Inst{15-12} = Vd{3-0};
1841 let Inst{22} = Vd{4};
1842 let Inst{19-16} = Vn{3-0};
1843 let Inst{7} = Vn{4};
1844 let Inst{2-0} = Vm{2-0};
1845 let Inst{5} = lane{1};
1846 let Inst{3} = lane{0};
1849 // Same as N3V except it doesn't have a data type suffix.
1850 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1852 dag oops, dag iops, Format f, InstrItinClass itin,
1853 string opc, string asm, string cstr, list<dag> pattern>
1854 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1855 let Inst{24} = op24;
1856 let Inst{23} = op23;
1857 let Inst{21-20} = op21_20;
1858 let Inst{11-8} = op11_8;
1862 // Instruction operands.
1867 let Inst{15-12} = Vd{3-0};
1868 let Inst{22} = Vd{4};
1869 let Inst{19-16} = Vn{3-0};
1870 let Inst{7} = Vn{4};
1871 let Inst{3-0} = Vm{3-0};
1872 let Inst{5} = Vm{4};
1875 // NEON VMOVs between scalar and core registers.
1876 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1877 dag oops, dag iops, Format f, InstrItinClass itin,
1878 string opc, string dt, string asm, list<dag> pattern>
1879 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1881 let Inst{27-20} = opcod1;
1882 let Inst{11-8} = opcod2;
1883 let Inst{6-5} = opcod3;
1885 // A8.6.303, A8.6.328, A8.6.329
1886 let Inst{3-0} = 0b0000;
1888 let OutOperandList = oops;
1889 let InOperandList = !con(iops, (ins pred:$p));
1890 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1891 let Pattern = pattern;
1892 list<Predicate> Predicates = [HasNEON];
1894 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1901 let Inst{31-28} = p{3-0};
1903 let Inst{19-16} = V{3-0};
1904 let Inst{15-12} = R{3-0};
1906 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1907 dag oops, dag iops, InstrItinClass itin,
1908 string opc, string dt, string asm, list<dag> pattern>
1909 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1910 opc, dt, asm, pattern>;
1911 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1912 dag oops, dag iops, InstrItinClass itin,
1913 string opc, string dt, string asm, list<dag> pattern>
1914 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1915 opc, dt, asm, pattern>;
1916 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1917 dag oops, dag iops, InstrItinClass itin,
1918 string opc, string dt, string asm, list<dag> pattern>
1919 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1920 opc, dt, asm, pattern>;
1922 // Vector Duplicate Lane (from scalar to all elements)
1923 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1924 InstrItinClass itin, string opc, string dt, string asm,
1926 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1927 let Inst{24-23} = 0b11;
1928 let Inst{21-20} = 0b11;
1929 let Inst{19-16} = op19_16;
1930 let Inst{11-7} = 0b11000;
1938 let Inst{22} = Vd{4};
1939 let Inst{15-12} = Vd{3-0};
1940 let Inst{5} = Vm{4};
1941 let Inst{3-0} = Vm{3-0};
1944 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1945 // for single-precision FP.
1946 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1947 list<Predicate> Predicates = [HasNEON,UseNEONForFP];