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.
88 class AddrMode<bits<5> val> {
91 def AddrModeNone : AddrMode<0>;
92 def AddrMode1 : AddrMode<1>;
93 def AddrMode2 : AddrMode<2>;
94 def AddrMode3 : AddrMode<3>;
95 def AddrMode4 : AddrMode<4>;
96 def AddrMode5 : AddrMode<5>;
97 def AddrMode6 : AddrMode<6>;
98 def AddrModeT1_1 : AddrMode<7>;
99 def AddrModeT1_2 : AddrMode<8>;
100 def AddrModeT1_4 : AddrMode<9>;
101 def AddrModeT1_s : AddrMode<10>;
102 def AddrModeT2_i12 : AddrMode<11>;
103 def AddrModeT2_i8 : AddrMode<12>;
104 def AddrModeT2_so : AddrMode<13>;
105 def AddrModeT2_pc : AddrMode<14>;
106 def AddrModeT2_i8s4 : AddrMode<15>;
107 def AddrMode_i12 : AddrMode<16>;
110 class SizeFlagVal<bits<3> val> {
113 def SizeInvalid : SizeFlagVal<0>; // Unset.
114 def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
115 def Size8Bytes : SizeFlagVal<2>;
116 def Size4Bytes : SizeFlagVal<3>;
117 def Size2Bytes : SizeFlagVal<4>;
119 // Load / store index mode.
120 class IndexMode<bits<2> val> {
123 def IndexModeNone : IndexMode<0>;
124 def IndexModePre : IndexMode<1>;
125 def IndexModePost : IndexMode<2>;
126 def IndexModeUpd : IndexMode<3>;
128 // Instruction execution domain.
129 class Domain<bits<2> val> {
132 def GenericDomain : Domain<0>;
133 def VFPDomain : Domain<1>; // Instructions in VFP domain only
134 def NeonDomain : Domain<2>; // Instructions in Neon domain only
135 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
137 //===----------------------------------------------------------------------===//
138 // ARM special operands.
141 def CondCodeOperand : AsmOperandClass {
142 let Name = "CondCode";
143 let SuperClasses = [];
146 def CCOutOperand : AsmOperandClass {
148 let SuperClasses = [];
151 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
152 // register whose default is 0 (no register).
153 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
154 (ops (i32 14), (i32 zero_reg))> {
155 let PrintMethod = "printPredicateOperand";
156 let ParserMatchClass = CondCodeOperand;
159 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
160 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
161 let EncoderMethod = "getCCOutOpValue";
162 let PrintMethod = "printSBitModifierOperand";
163 let ParserMatchClass = CCOutOperand;
166 // Same as cc_out except it defaults to setting CPSR.
167 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
168 let EncoderMethod = "getCCOutOpValue";
169 let PrintMethod = "printSBitModifierOperand";
170 let ParserMatchClass = CCOutOperand;
173 // ARM special operands for disassembly only.
175 def setend_op : Operand<i32> {
176 let PrintMethod = "printSetendOperand";
179 def cps_opt : Operand<i32> {
180 let PrintMethod = "printCPSOptionOperand";
183 def msr_mask : Operand<i32> {
184 let PrintMethod = "printMSRMaskOperand";
187 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
188 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
189 def neg_zero : Operand<i32> {
190 let PrintMethod = "printNegZeroOperand";
193 //===----------------------------------------------------------------------===//
194 // ARM Instruction templates.
197 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
198 Format f, Domain d, string cstr, InstrItinClass itin>
200 let Namespace = "ARM";
205 bits<2> IndexModeBits = IM.Value;
207 bits<6> Form = F.Value;
209 bit isUnaryDataProc = 0;
210 bit canXformTo16Bit = 0;
212 // If this is a pseudo instruction, mark it isCodeGenOnly.
213 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
215 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
216 let TSFlags{4-0} = AM.Value;
217 let TSFlags{7-5} = SZ.Value;
218 let TSFlags{9-8} = IndexModeBits;
219 let TSFlags{15-10} = Form;
220 let TSFlags{16} = isUnaryDataProc;
221 let TSFlags{17} = canXformTo16Bit;
222 let TSFlags{19-18} = D.Value;
224 let Constraints = cstr;
225 let Itinerary = itin;
232 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
233 Format f, Domain d, string cstr, InstrItinClass itin>
234 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
236 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
237 // on by adding flavors to specific instructions.
238 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
239 Format f, Domain d, string cstr, InstrItinClass itin>
240 : InstTemplate<am, sz, im, f, d, cstr, itin>;
242 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
243 // FIXME: This really should derive from InstTemplate instead, as pseudos
244 // don't need encoding information. TableGen doesn't like that
245 // currently. Need to figure out why and fix it.
246 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
248 let OutOperandList = oops;
249 let InOperandList = iops;
250 let Pattern = pattern;
253 // PseudoInst that's ARM-mode only.
254 class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
256 : PseudoInst<oops, iops, itin, pattern> {
258 list<Predicate> Predicates = [IsARM];
261 // PseudoInst that's Thumb-mode only.
262 class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
264 : PseudoInst<oops, iops, itin, pattern> {
266 list<Predicate> Predicates = [IsThumb];
269 // Almost all ARM instructions are predicable.
270 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
271 IndexMode im, Format f, InstrItinClass itin,
272 string opc, string asm, string cstr,
274 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
277 let OutOperandList = oops;
278 let InOperandList = !con(iops, (ins pred:$p));
279 let AsmString = !strconcat(opc, "${p}", asm);
280 let Pattern = pattern;
281 list<Predicate> Predicates = [IsARM];
284 // A few are not predicable
285 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
286 IndexMode im, Format f, InstrItinClass itin,
287 string opc, string asm, string cstr,
289 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
290 let OutOperandList = oops;
291 let InOperandList = iops;
292 let AsmString = !strconcat(opc, asm);
293 let Pattern = pattern;
294 let isPredicable = 0;
295 list<Predicate> Predicates = [IsARM];
298 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
299 // operand since by default it's a zero register. It will become an implicit def
300 // once it's "flipped".
301 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
302 IndexMode im, Format f, InstrItinClass itin,
303 string opc, string asm, string cstr,
305 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
306 bits<4> p; // Predicate operand
307 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
311 let OutOperandList = oops;
312 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
313 let AsmString = !strconcat(opc, "${s}${p}", asm);
314 let Pattern = pattern;
315 list<Predicate> Predicates = [IsARM];
319 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
320 IndexMode im, Format f, InstrItinClass itin,
321 string asm, string cstr, list<dag> pattern>
322 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
323 let OutOperandList = oops;
324 let InOperandList = iops;
326 let Pattern = pattern;
327 list<Predicate> Predicates = [IsARM];
330 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
331 string opc, string asm, list<dag> pattern>
332 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
333 opc, asm, "", pattern>;
334 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
335 string opc, string asm, list<dag> pattern>
336 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
337 opc, asm, "", pattern>;
338 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
339 string asm, list<dag> pattern>
340 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
342 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
343 string opc, string asm, list<dag> pattern>
344 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
345 opc, asm, "", pattern>;
347 // Ctrl flow instructions
348 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
349 string opc, string asm, list<dag> pattern>
350 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
351 opc, asm, "", pattern> {
352 let Inst{27-24} = opcod;
354 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
355 string asm, list<dag> pattern>
356 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
358 let Inst{27-24} = opcod;
361 // BR_JT instructions
362 class JTI<dag oops, dag iops, InstrItinClass itin,
363 string asm, list<dag> pattern>
364 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
367 // Atomic load/store instructions
368 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
369 string opc, string asm, list<dag> pattern>
370 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
371 opc, asm, "", pattern> {
374 let Inst{27-23} = 0b00011;
375 let Inst{22-21} = opcod;
377 let Inst{19-16} = Rn;
378 let Inst{15-12} = Rt;
379 let Inst{11-0} = 0b111110011111;
381 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
382 string opc, string asm, list<dag> pattern>
383 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
384 opc, asm, "", pattern> {
388 let Inst{27-23} = 0b00011;
389 let Inst{22-21} = opcod;
391 let Inst{19-16} = Rn;
392 let Inst{15-12} = Rd;
393 let Inst{11-4} = 0b11111001;
396 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
397 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
401 let Inst{27-23} = 0b00010;
403 let Inst{21-20} = 0b00;
404 let Inst{19-16} = Rn;
405 let Inst{15-12} = Rt;
406 let Inst{11-4} = 0b00001001;
410 // addrmode1 instructions
411 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
412 string opc, string asm, list<dag> pattern>
413 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
414 opc, asm, "", pattern> {
415 let Inst{24-21} = opcod;
416 let Inst{27-26} = 0b00;
418 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
419 string opc, string asm, list<dag> pattern>
420 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
421 opc, asm, "", pattern> {
422 let Inst{24-21} = opcod;
423 let Inst{27-26} = 0b00;
425 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
426 string asm, list<dag> pattern>
427 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
429 let Inst{24-21} = opcod;
430 let Inst{27-26} = 0b00;
435 // LDR/LDRB/STR/STRB/...
436 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
437 Format f, InstrItinClass itin, string opc, string asm,
439 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
441 let Inst{27-25} = op;
442 let Inst{24} = 1; // 24 == P
444 let Inst{22} = isByte;
445 let Inst{21} = 0; // 21 == W
448 // Indexed load/stores
449 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
450 IndexMode im, Format f, InstrItinClass itin, string opc,
451 string asm, string cstr, list<dag> pattern>
452 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
453 opc, asm, cstr, pattern> {
455 let Inst{27-26} = 0b01;
456 let Inst{24} = isPre; // P bit
457 let Inst{22} = isByte; // B bit
458 let Inst{21} = isPre; // W bit
459 let Inst{20} = isLd; // L bit
460 let Inst{15-12} = Rt;
462 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
463 IndexMode im, Format f, InstrItinClass itin, string opc,
464 string asm, string cstr, list<dag> pattern>
465 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
467 // AM2 store w/ two operands: (GPR, am2offset)
468 // {13} 1 == Rm, 0 == imm12
473 let Inst{25} = offset{13};
474 let Inst{23} = offset{12};
475 let Inst{19-16} = Rn;
476 let Inst{11-0} = offset{11-0};
479 // addrmode3 instructions
480 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
481 InstrItinClass itin, string opc, string asm, list<dag> pattern>
482 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
483 opc, asm, "", pattern> {
486 let Inst{27-25} = 0b000;
487 let Inst{24} = 1; // P bit
488 let Inst{23} = addr{8}; // U bit
489 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
490 let Inst{21} = 0; // W bit
491 let Inst{20} = op20; // L bit
492 let Inst{19-16} = addr{12-9}; // Rn
493 let Inst{15-12} = Rt; // Rt
494 let Inst{11-8} = addr{7-4}; // imm7_4/zero
496 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
499 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
500 IndexMode im, Format f, InstrItinClass itin, string opc,
501 string asm, string cstr, list<dag> pattern>
502 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
503 opc, asm, cstr, pattern> {
505 let Inst{27-25} = 0b000;
506 let Inst{24} = isPre; // P bit
507 let Inst{21} = isPre; // W bit
508 let Inst{20} = op20; // L bit
509 let Inst{15-12} = Rt; // Rt
512 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
513 IndexMode im, Format f, InstrItinClass itin, string opc,
514 string asm, string cstr, list<dag> pattern>
515 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
517 // AM3 store w/ two operands: (GPR, am3offset)
521 let Inst{27-25} = 0b000;
522 let Inst{23} = offset{8};
523 let Inst{22} = offset{9};
524 let Inst{19-16} = Rn;
525 let Inst{15-12} = Rt; // Rt
526 let Inst{11-8} = offset{7-4}; // imm7_4/zero
528 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
532 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
533 string opc, string asm, list<dag> pattern>
534 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
535 opc, asm, "", pattern> {
538 let Inst{27-25} = 0b000;
539 let Inst{24} = 1; // P bit
540 let Inst{23} = addr{8}; // U bit
541 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
542 let Inst{21} = 0; // W bit
543 let Inst{20} = 0; // L bit
544 let Inst{19-16} = addr{12-9}; // Rn
545 let Inst{15-12} = Rt; // Rt
546 let Inst{11-8} = addr{7-4}; // imm7_4/zero
548 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
551 // Pre-indexed stores
552 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
553 string opc, string asm, string cstr, list<dag> pattern>
554 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
555 opc, asm, cstr, pattern> {
557 let Inst{5} = 1; // H bit
558 let Inst{6} = 0; // S bit
560 let Inst{20} = 0; // L bit
561 let Inst{21} = 1; // W bit
562 let Inst{24} = 1; // P bit
563 let Inst{27-25} = 0b000;
565 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
566 string opc, string asm, string cstr, list<dag> pattern>
567 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
568 opc, asm, cstr, pattern> {
570 let Inst{5} = 1; // H bit
571 let Inst{6} = 1; // S bit
573 let Inst{20} = 0; // L bit
574 let Inst{21} = 1; // W bit
575 let Inst{24} = 1; // P bit
576 let Inst{27-25} = 0b000;
579 // Post-indexed stores
580 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
581 string opc, string asm, string cstr, list<dag> pattern>
582 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
583 opc, asm, cstr,pattern> {
585 let Inst{5} = 1; // H bit
586 let Inst{6} = 0; // S bit
588 let Inst{20} = 0; // L bit
589 let Inst{21} = 0; // W bit
590 let Inst{24} = 0; // P bit
591 let Inst{27-25} = 0b000;
593 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
594 string opc, string asm, string cstr, list<dag> pattern>
595 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
596 opc, asm, cstr, pattern> {
598 let Inst{5} = 1; // H bit
599 let Inst{6} = 1; // S bit
601 let Inst{20} = 0; // L bit
602 let Inst{21} = 0; // W bit
603 let Inst{24} = 0; // P bit
604 let Inst{27-25} = 0b000;
607 // addrmode4 instructions
608 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
609 string asm, string cstr, list<dag> pattern>
610 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
615 let Inst{27-25} = 0b100;
616 let Inst{22} = 0; // S bit
617 let Inst{19-16} = Rn;
618 let Inst{15-0} = regs;
621 // Unsigned multiply, multiply-accumulate instructions.
622 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
623 string opc, string asm, list<dag> pattern>
624 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
625 opc, asm, "", pattern> {
626 let Inst{7-4} = 0b1001;
627 let Inst{20} = 0; // S bit
628 let Inst{27-21} = opcod;
630 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
631 string opc, string asm, list<dag> pattern>
632 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
633 opc, asm, "", pattern> {
634 let Inst{7-4} = 0b1001;
635 let Inst{27-21} = opcod;
638 // Most significant word multiply
639 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
640 InstrItinClass itin, string opc, string asm, list<dag> pattern>
641 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
642 opc, asm, "", pattern> {
646 let Inst{7-4} = opc7_4;
648 let Inst{27-21} = opcod;
649 let Inst{19-16} = Rd;
653 // MSW multiple w/ Ra operand
654 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
655 InstrItinClass itin, string opc, string asm, list<dag> pattern>
656 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
658 let Inst{15-12} = Ra;
661 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
662 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
663 InstrItinClass itin, string opc, string asm, list<dag> pattern>
664 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
665 opc, asm, "", pattern> {
671 let Inst{27-21} = opcod;
672 let Inst{6-5} = bit6_5;
676 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
677 InstrItinClass itin, string opc, string asm, list<dag> pattern>
678 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
680 let Inst{19-16} = Rd;
683 // AMulxyI with Ra operand
684 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
685 InstrItinClass itin, string opc, string asm, list<dag> pattern>
686 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
688 let Inst{15-12} = Ra;
691 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
692 InstrItinClass itin, string opc, string asm, list<dag> pattern>
693 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
696 let Inst{19-16} = RdHi;
697 let Inst{15-12} = RdLo;
700 // Extend instructions.
701 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
702 string opc, string asm, list<dag> pattern>
703 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
704 opc, asm, "", pattern> {
705 // All AExtI instructions have Rd and Rm register operands.
708 let Inst{15-12} = Rd;
710 let Inst{7-4} = 0b0111;
711 let Inst{9-8} = 0b00;
712 let Inst{27-20} = opcod;
715 // Misc Arithmetic instructions.
716 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
717 InstrItinClass itin, string opc, string asm, list<dag> pattern>
718 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
719 opc, asm, "", pattern> {
722 let Inst{27-20} = opcod;
723 let Inst{19-16} = 0b1111;
724 let Inst{15-12} = Rd;
725 let Inst{11-8} = 0b1111;
726 let Inst{7-4} = opc7_4;
731 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
732 string opc, string asm, list<dag> pattern>
733 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
734 opc, asm, "", pattern> {
739 let Inst{27-20} = opcod;
740 let Inst{19-16} = Rn;
741 let Inst{15-12} = Rd;
742 let Inst{11-7} = sh{7-3};
744 let Inst{5-4} = 0b01;
748 //===----------------------------------------------------------------------===//
750 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
751 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
752 list<Predicate> Predicates = [IsARM];
754 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
755 list<Predicate> Predicates = [IsARM, HasV5TE];
757 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
758 list<Predicate> Predicates = [IsARM, HasV6];
761 //===----------------------------------------------------------------------===//
762 // Thumb Instruction Format Definitions.
765 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
766 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
767 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
768 let OutOperandList = oops;
769 let InOperandList = iops;
771 let Pattern = pattern;
772 list<Predicate> Predicates = [IsThumb];
775 // TI - Thumb instruction.
776 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
777 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
779 // Two-address instructions
780 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
782 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
785 // tBL, tBX 32-bit instructions
786 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
787 dag oops, dag iops, InstrItinClass itin, string asm,
789 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
791 let Inst{31-27} = opcod1;
792 let Inst{15-14} = opcod2;
793 let Inst{12} = opcod3;
796 // BR_JT instructions
797 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
799 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
802 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
803 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
804 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
805 let OutOperandList = oops;
806 let InOperandList = iops;
808 let Pattern = pattern;
809 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
812 class T1I<dag oops, dag iops, InstrItinClass itin,
813 string asm, list<dag> pattern>
814 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
815 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
816 string asm, list<dag> pattern>
817 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
819 // Two-address instructions
820 class T1It<dag oops, dag iops, InstrItinClass itin,
821 string asm, string cstr, list<dag> pattern>
822 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
825 // Thumb1 instruction that can either be predicated or set CPSR.
826 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
828 string opc, string asm, string cstr, list<dag> pattern>
829 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
830 let OutOperandList = !con(oops, (outs s_cc_out:$s));
831 let InOperandList = !con(iops, (ins pred:$p));
832 let AsmString = !strconcat(opc, "${s}${p}", asm);
833 let Pattern = pattern;
834 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
837 class T1sI<dag oops, dag iops, InstrItinClass itin,
838 string opc, string asm, list<dag> pattern>
839 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
841 // Two-address instructions
842 class T1sIt<dag oops, dag iops, InstrItinClass itin,
843 string opc, string asm, list<dag> pattern>
844 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
845 "$Rn = $Rdn", pattern>;
847 // Thumb1 instruction that can be predicated.
848 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
850 string opc, string asm, string cstr, list<dag> pattern>
851 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
852 let OutOperandList = oops;
853 let InOperandList = !con(iops, (ins pred:$p));
854 let AsmString = !strconcat(opc, "${p}", asm);
855 let Pattern = pattern;
856 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
859 class T1pI<dag oops, dag iops, InstrItinClass itin,
860 string opc, string asm, list<dag> pattern>
861 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
863 // Two-address instructions
864 class T1pIt<dag oops, dag iops, InstrItinClass itin,
865 string opc, string asm, list<dag> pattern>
866 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
867 "$Rn = $Rdn", pattern>;
869 class T1pIs<dag oops, dag iops,
870 InstrItinClass itin, string opc, string asm, list<dag> pattern>
871 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
873 class Encoding16 : Encoding {
874 let Inst{31-16} = 0x0000;
877 // A6.2 16-bit Thumb instruction encoding
878 class T1Encoding<bits<6> opcode> : Encoding16 {
879 let Inst{15-10} = opcode;
882 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
883 class T1General<bits<5> opcode> : Encoding16 {
884 let Inst{15-14} = 0b00;
885 let Inst{13-9} = opcode;
888 // A6.2.2 Data-processing encoding.
889 class T1DataProcessing<bits<4> opcode> : Encoding16 {
890 let Inst{15-10} = 0b010000;
891 let Inst{9-6} = opcode;
894 // A6.2.3 Special data instructions and branch and exchange encoding.
895 class T1Special<bits<4> opcode> : Encoding16 {
896 let Inst{15-10} = 0b010001;
897 let Inst{9-6} = opcode;
900 // A6.2.4 Load/store single data item encoding.
901 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
902 let Inst{15-12} = opA;
903 let Inst{11-9} = opB;
905 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
907 // Helper classes to encode Thumb1 loads and stores. For immediates, the
908 // following bits are used for "opA" (see A6.2.4):
910 // 0b0110 => Immediate, 4 bytes
911 // 0b1000 => Immediate, 2 bytes
912 // 0b0111 => Immediate, 1 byte
913 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
914 InstrItinClass itin, string opc, string asm,
916 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
917 T1LoadStore<0b0101, opcode> {
920 let Inst{8-6} = addr{5-3}; // Rm
921 let Inst{5-3} = addr{2-0}; // Rn
924 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
925 InstrItinClass itin, string opc, string asm,
927 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
928 T1LoadStore<opA, {opB,?,?}> {
931 let Inst{10-6} = addr{7-3}; // imm5
932 let Inst{5-3} = addr{2-0}; // Rn
936 // A6.2.5 Miscellaneous 16-bit instructions encoding.
937 class T1Misc<bits<7> opcode> : Encoding16 {
938 let Inst{15-12} = 0b1011;
939 let Inst{11-5} = opcode;
942 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
943 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
945 string opc, string asm, string cstr, list<dag> pattern>
946 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
947 let OutOperandList = oops;
948 let InOperandList = !con(iops, (ins pred:$p));
949 let AsmString = !strconcat(opc, "${p}", asm);
950 let Pattern = pattern;
951 list<Predicate> Predicates = [IsThumb2];
954 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
955 // input operand since by default it's a zero register. It will become an
956 // implicit def once it's "flipped".
958 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
960 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
962 string opc, string asm, string cstr, list<dag> pattern>
963 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
964 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
967 let OutOperandList = oops;
968 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
969 let AsmString = !strconcat(opc, "${s}${p}", asm);
970 let Pattern = pattern;
971 list<Predicate> Predicates = [IsThumb2];
975 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
977 string asm, string cstr, list<dag> pattern>
978 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
979 let OutOperandList = oops;
980 let InOperandList = iops;
982 let Pattern = pattern;
983 list<Predicate> Predicates = [IsThumb2];
986 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
988 string asm, string cstr, list<dag> pattern>
989 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
990 let OutOperandList = oops;
991 let InOperandList = iops;
993 let Pattern = pattern;
994 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
997 class T2I<dag oops, dag iops, InstrItinClass itin,
998 string opc, string asm, list<dag> pattern>
999 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1000 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1001 string opc, string asm, list<dag> pattern>
1002 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
1003 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1004 string opc, string asm, list<dag> pattern>
1005 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1006 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1007 string opc, string asm, list<dag> pattern>
1008 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1009 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1010 string opc, string asm, list<dag> pattern>
1011 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1012 class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
1013 string opc, string asm, list<dag> pattern>
1014 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1016 let Inst{31-27} = 0b11101;
1017 let Inst{26-25} = 0b00;
1019 let Inst{23} = ?; // The U bit.
1022 let Inst{20} = load;
1027 let Inst{15-12} = Rt{3-0};
1028 let Inst{11-8} = Rt2{3-0};
1029 let Inst{19-16} = addr{12-9};
1030 let Inst{23} = addr{8};
1031 let Inst{7-0} = addr{7-0};
1034 class T2sI<dag oops, dag iops, InstrItinClass itin,
1035 string opc, string asm, list<dag> pattern>
1036 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1038 class T2XI<dag oops, dag iops, InstrItinClass itin,
1039 string asm, list<dag> pattern>
1040 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1041 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1042 string asm, list<dag> pattern>
1043 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1045 // Two-address instructions
1046 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1047 string asm, string cstr, list<dag> pattern>
1048 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1050 // T2Iidxldst - Thumb2 indexed load / store instructions.
1051 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1053 AddrMode am, IndexMode im, InstrItinClass itin,
1054 string opc, string asm, string cstr, list<dag> pattern>
1055 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1056 let OutOperandList = oops;
1057 let InOperandList = !con(iops, (ins pred:$p));
1058 let AsmString = !strconcat(opc, "${p}", asm);
1059 let Pattern = pattern;
1060 list<Predicate> Predicates = [IsThumb2];
1061 let Inst{31-27} = 0b11111;
1062 let Inst{26-25} = 0b00;
1063 let Inst{24} = signed;
1065 let Inst{22-21} = opcod;
1066 let Inst{20} = load;
1068 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1069 let Inst{10} = pre; // The P bit.
1070 let Inst{8} = 1; // The W bit.
1073 let Inst{7-0} = addr{7-0};
1074 let Inst{9} = addr{8}; // Sign bit
1078 let Inst{15-12} = Rt{3-0};
1079 let Inst{19-16} = Rn{3-0};
1082 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1083 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1084 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1087 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1088 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1089 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1092 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1093 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1094 list<Predicate> Predicates = [IsThumb2];
1097 //===----------------------------------------------------------------------===//
1099 //===----------------------------------------------------------------------===//
1100 // ARM VFP Instruction templates.
1103 // Almost all VFP instructions are predicable.
1104 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1105 IndexMode im, Format f, InstrItinClass itin,
1106 string opc, string asm, string cstr, list<dag> pattern>
1107 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1109 let Inst{31-28} = p;
1110 let OutOperandList = oops;
1111 let InOperandList = !con(iops, (ins pred:$p));
1112 let AsmString = !strconcat(opc, "${p}", asm);
1113 let Pattern = pattern;
1114 let PostEncoderMethod = "VFPThumb2PostEncoder";
1115 list<Predicate> Predicates = [HasVFP2];
1119 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1120 IndexMode im, Format f, InstrItinClass itin,
1121 string asm, string cstr, list<dag> pattern>
1122 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1124 let Inst{31-28} = p;
1125 let OutOperandList = oops;
1126 let InOperandList = iops;
1127 let AsmString = asm;
1128 let Pattern = pattern;
1129 let PostEncoderMethod = "VFPThumb2PostEncoder";
1130 list<Predicate> Predicates = [HasVFP2];
1133 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1134 string opc, string asm, list<dag> pattern>
1135 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1136 opc, asm, "", pattern> {
1137 let PostEncoderMethod = "VFPThumb2PostEncoder";
1140 // ARM VFP addrmode5 loads and stores
1141 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1142 InstrItinClass itin,
1143 string opc, string asm, list<dag> pattern>
1144 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1145 VFPLdStFrm, itin, opc, asm, "", pattern> {
1146 // Instruction operands.
1150 // Encode instruction operands.
1151 let Inst{23} = addr{8}; // U (add = (U == '1'))
1152 let Inst{22} = Dd{4};
1153 let Inst{19-16} = addr{12-9}; // Rn
1154 let Inst{15-12} = Dd{3-0};
1155 let Inst{7-0} = addr{7-0}; // imm8
1157 // TODO: Mark the instructions with the appropriate subtarget info.
1158 let Inst{27-24} = opcod1;
1159 let Inst{21-20} = opcod2;
1160 let Inst{11-9} = 0b101;
1161 let Inst{8} = 1; // Double precision
1163 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1164 let D = VFPNeonDomain;
1167 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1168 InstrItinClass itin,
1169 string opc, string asm, list<dag> pattern>
1170 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1171 VFPLdStFrm, itin, opc, asm, "", pattern> {
1172 // Instruction operands.
1176 // Encode instruction operands.
1177 let Inst{23} = addr{8}; // U (add = (U == '1'))
1178 let Inst{22} = Sd{0};
1179 let Inst{19-16} = addr{12-9}; // Rn
1180 let Inst{15-12} = Sd{4-1};
1181 let Inst{7-0} = addr{7-0}; // imm8
1183 // TODO: Mark the instructions with the appropriate subtarget info.
1184 let Inst{27-24} = opcod1;
1185 let Inst{21-20} = opcod2;
1186 let Inst{11-9} = 0b101;
1187 let Inst{8} = 0; // Single precision
1190 // VFP Load / store multiple pseudo instructions.
1191 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1193 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1195 let OutOperandList = oops;
1196 let InOperandList = !con(iops, (ins pred:$p));
1197 let Pattern = pattern;
1198 list<Predicate> Predicates = [HasVFP2];
1201 // Load / store multiple
1202 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1203 string asm, string cstr, list<dag> pattern>
1204 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1205 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1206 // Instruction operands.
1210 // Encode instruction operands.
1211 let Inst{19-16} = Rn;
1212 let Inst{22} = regs{12};
1213 let Inst{15-12} = regs{11-8};
1214 let Inst{7-0} = regs{7-0};
1216 // TODO: Mark the instructions with the appropriate subtarget info.
1217 let Inst{27-25} = 0b110;
1218 let Inst{11-9} = 0b101;
1219 let Inst{8} = 1; // Double precision
1221 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1222 let D = VFPNeonDomain;
1225 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1226 string asm, string cstr, list<dag> pattern>
1227 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1228 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1229 // Instruction operands.
1233 // Encode instruction operands.
1234 let Inst{19-16} = Rn;
1235 let Inst{22} = regs{8};
1236 let Inst{15-12} = regs{12-9};
1237 let Inst{7-0} = regs{7-0};
1239 // TODO: Mark the instructions with the appropriate subtarget info.
1240 let Inst{27-25} = 0b110;
1241 let Inst{11-9} = 0b101;
1242 let Inst{8} = 0; // Single precision
1245 // Double precision, unary
1246 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1247 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1248 string asm, list<dag> pattern>
1249 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1250 // Instruction operands.
1254 // Encode instruction operands.
1255 let Inst{3-0} = Dm{3-0};
1256 let Inst{5} = Dm{4};
1257 let Inst{15-12} = Dd{3-0};
1258 let Inst{22} = Dd{4};
1260 let Inst{27-23} = opcod1;
1261 let Inst{21-20} = opcod2;
1262 let Inst{19-16} = opcod3;
1263 let Inst{11-9} = 0b101;
1264 let Inst{8} = 1; // Double precision
1265 let Inst{7-6} = opcod4;
1266 let Inst{4} = opcod5;
1269 // Double precision, binary
1270 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1271 dag iops, InstrItinClass itin, string opc, string asm,
1273 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1274 // Instruction operands.
1279 // Encode instruction operands.
1280 let Inst{3-0} = Dm{3-0};
1281 let Inst{5} = Dm{4};
1282 let Inst{19-16} = Dn{3-0};
1283 let Inst{7} = Dn{4};
1284 let Inst{15-12} = Dd{3-0};
1285 let Inst{22} = Dd{4};
1287 let Inst{27-23} = opcod1;
1288 let Inst{21-20} = opcod2;
1289 let Inst{11-9} = 0b101;
1290 let Inst{8} = 1; // Double precision
1295 // Single precision, unary
1296 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1297 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1298 string asm, list<dag> pattern>
1299 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1300 // Instruction operands.
1304 // Encode instruction operands.
1305 let Inst{3-0} = Sm{4-1};
1306 let Inst{5} = Sm{0};
1307 let Inst{15-12} = Sd{4-1};
1308 let Inst{22} = Sd{0};
1310 let Inst{27-23} = opcod1;
1311 let Inst{21-20} = opcod2;
1312 let Inst{19-16} = opcod3;
1313 let Inst{11-9} = 0b101;
1314 let Inst{8} = 0; // Single precision
1315 let Inst{7-6} = opcod4;
1316 let Inst{4} = opcod5;
1319 // Single precision unary, if no NEON. Same as ASuI except not available if
1321 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1322 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1323 string asm, list<dag> pattern>
1324 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1326 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1329 // Single precision, binary
1330 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1331 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1332 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1333 // Instruction operands.
1338 // Encode instruction operands.
1339 let Inst{3-0} = Sm{4-1};
1340 let Inst{5} = Sm{0};
1341 let Inst{19-16} = Sn{4-1};
1342 let Inst{7} = Sn{0};
1343 let Inst{15-12} = Sd{4-1};
1344 let Inst{22} = Sd{0};
1346 let Inst{27-23} = opcod1;
1347 let Inst{21-20} = opcod2;
1348 let Inst{11-9} = 0b101;
1349 let Inst{8} = 0; // Single precision
1354 // Single precision binary, if no NEON. Same as ASbI except not available if
1356 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1357 dag iops, InstrItinClass itin, string opc, string asm,
1359 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1360 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1362 // Instruction operands.
1367 // Encode instruction operands.
1368 let Inst{3-0} = Sm{4-1};
1369 let Inst{5} = Sm{0};
1370 let Inst{19-16} = Sn{4-1};
1371 let Inst{7} = Sn{0};
1372 let Inst{15-12} = Sd{4-1};
1373 let Inst{22} = Sd{0};
1376 // VFP conversion instructions
1377 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1378 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1380 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1381 let Inst{27-23} = opcod1;
1382 let Inst{21-20} = opcod2;
1383 let Inst{19-16} = opcod3;
1384 let Inst{11-8} = opcod4;
1389 // VFP conversion between floating-point and fixed-point
1390 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1391 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1393 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1394 // size (fixed-point number): sx == 0 ? 16 : 32
1395 let Inst{7} = op5; // sx
1398 // VFP conversion instructions, if no NEON
1399 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1400 dag oops, dag iops, InstrItinClass itin,
1401 string opc, string asm, list<dag> pattern>
1402 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1404 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1407 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1408 InstrItinClass itin,
1409 string opc, string asm, list<dag> pattern>
1410 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1411 let Inst{27-20} = opcod1;
1412 let Inst{11-8} = opcod2;
1416 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1417 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1418 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1420 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1421 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1422 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1424 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1425 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1426 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1428 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1429 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1430 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1432 //===----------------------------------------------------------------------===//
1434 //===----------------------------------------------------------------------===//
1435 // ARM NEON Instruction templates.
1438 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1439 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1441 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1442 let OutOperandList = oops;
1443 let InOperandList = !con(iops, (ins pred:$p));
1444 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1445 let Pattern = pattern;
1446 list<Predicate> Predicates = [HasNEON];
1449 // Same as NeonI except it does not have a "data type" specifier.
1450 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1451 InstrItinClass itin, string opc, string asm, string cstr,
1453 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1454 let OutOperandList = oops;
1455 let InOperandList = !con(iops, (ins pred:$p));
1456 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1457 let Pattern = pattern;
1458 list<Predicate> Predicates = [HasNEON];
1461 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1462 dag oops, dag iops, InstrItinClass itin,
1463 string opc, string dt, string asm, string cstr, list<dag> pattern>
1464 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1466 let Inst{31-24} = 0b11110100;
1467 let Inst{23} = op23;
1468 let Inst{21-20} = op21_20;
1469 let Inst{11-8} = op11_8;
1470 let Inst{7-4} = op7_4;
1472 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1478 let Inst{22} = Vd{4};
1479 let Inst{15-12} = Vd{3-0};
1480 let Inst{19-16} = Rn{3-0};
1481 let Inst{3-0} = Rm{3-0};
1484 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1485 dag oops, dag iops, InstrItinClass itin,
1486 string opc, string dt, string asm, string cstr, list<dag> pattern>
1487 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1488 dt, asm, cstr, pattern> {
1492 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1493 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1495 let OutOperandList = oops;
1496 let InOperandList = !con(iops, (ins pred:$p));
1497 list<Predicate> Predicates = [HasNEON];
1500 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1502 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1504 let OutOperandList = oops;
1505 let InOperandList = !con(iops, (ins pred:$p));
1506 let Pattern = pattern;
1507 list<Predicate> Predicates = [HasNEON];
1510 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1511 string opc, string dt, string asm, string cstr, list<dag> pattern>
1512 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1514 let Inst{31-25} = 0b1111001;
1515 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1518 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1519 string opc, string asm, string cstr, list<dag> pattern>
1520 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1522 let Inst{31-25} = 0b1111001;
1525 // NEON "one register and a modified immediate" format.
1526 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1528 dag oops, dag iops, InstrItinClass itin,
1529 string opc, string dt, string asm, string cstr,
1531 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1532 let Inst{23} = op23;
1533 let Inst{21-19} = op21_19;
1534 let Inst{11-8} = op11_8;
1540 // Instruction operands.
1544 let Inst{15-12} = Vd{3-0};
1545 let Inst{22} = Vd{4};
1546 let Inst{24} = SIMM{7};
1547 let Inst{18-16} = SIMM{6-4};
1548 let Inst{3-0} = SIMM{3-0};
1551 // NEON 2 vector register format.
1552 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1553 bits<5> op11_7, bit op6, bit op4,
1554 dag oops, dag iops, InstrItinClass itin,
1555 string opc, string dt, string asm, string cstr, list<dag> pattern>
1556 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1557 let Inst{24-23} = op24_23;
1558 let Inst{21-20} = op21_20;
1559 let Inst{19-18} = op19_18;
1560 let Inst{17-16} = op17_16;
1561 let Inst{11-7} = op11_7;
1565 // Instruction operands.
1569 let Inst{15-12} = Vd{3-0};
1570 let Inst{22} = Vd{4};
1571 let Inst{3-0} = Vm{3-0};
1572 let Inst{5} = Vm{4};
1575 // Same as N2V except it doesn't have a datatype suffix.
1576 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1577 bits<5> op11_7, bit op6, bit op4,
1578 dag oops, dag iops, InstrItinClass itin,
1579 string opc, string asm, string cstr, list<dag> pattern>
1580 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1581 let Inst{24-23} = op24_23;
1582 let Inst{21-20} = op21_20;
1583 let Inst{19-18} = op19_18;
1584 let Inst{17-16} = op17_16;
1585 let Inst{11-7} = op11_7;
1589 // Instruction operands.
1593 let Inst{15-12} = Vd{3-0};
1594 let Inst{22} = Vd{4};
1595 let Inst{3-0} = Vm{3-0};
1596 let Inst{5} = Vm{4};
1599 // NEON 2 vector register with immediate.
1600 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1601 dag oops, dag iops, Format f, InstrItinClass itin,
1602 string opc, string dt, string asm, string cstr, list<dag> pattern>
1603 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1604 let Inst{24} = op24;
1605 let Inst{23} = op23;
1606 let Inst{11-8} = op11_8;
1611 // Instruction operands.
1616 let Inst{15-12} = Vd{3-0};
1617 let Inst{22} = Vd{4};
1618 let Inst{3-0} = Vm{3-0};
1619 let Inst{5} = Vm{4};
1620 let Inst{21-16} = SIMM{5-0};
1623 // NEON 3 vector register format.
1624 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1625 dag oops, dag iops, Format f, InstrItinClass itin,
1626 string opc, string dt, string asm, string cstr, list<dag> pattern>
1627 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1628 let Inst{24} = op24;
1629 let Inst{23} = op23;
1630 let Inst{21-20} = op21_20;
1631 let Inst{11-8} = op11_8;
1635 // Instruction operands.
1640 let Inst{15-12} = Vd{3-0};
1641 let Inst{22} = Vd{4};
1642 let Inst{19-16} = Vn{3-0};
1643 let Inst{7} = Vn{4};
1644 let Inst{3-0} = Vm{3-0};
1645 let Inst{5} = Vm{4};
1648 // Same as N3V except it doesn't have a data type suffix.
1649 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1651 dag oops, dag iops, Format f, InstrItinClass itin,
1652 string opc, string asm, string cstr, list<dag> pattern>
1653 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1654 let Inst{24} = op24;
1655 let Inst{23} = op23;
1656 let Inst{21-20} = op21_20;
1657 let Inst{11-8} = op11_8;
1661 // Instruction operands.
1666 let Inst{15-12} = Vd{3-0};
1667 let Inst{22} = Vd{4};
1668 let Inst{19-16} = Vn{3-0};
1669 let Inst{7} = Vn{4};
1670 let Inst{3-0} = Vm{3-0};
1671 let Inst{5} = Vm{4};
1674 // NEON VMOVs between scalar and core registers.
1675 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1676 dag oops, dag iops, Format f, InstrItinClass itin,
1677 string opc, string dt, string asm, list<dag> pattern>
1678 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1680 let Inst{27-20} = opcod1;
1681 let Inst{11-8} = opcod2;
1682 let Inst{6-5} = opcod3;
1685 let OutOperandList = oops;
1686 let InOperandList = !con(iops, (ins pred:$p));
1687 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1688 let Pattern = pattern;
1689 list<Predicate> Predicates = [HasNEON];
1691 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1698 let Inst{31-28} = p{3-0};
1700 let Inst{19-16} = V{3-0};
1701 let Inst{15-12} = R{3-0};
1703 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1704 dag oops, dag iops, InstrItinClass itin,
1705 string opc, string dt, string asm, list<dag> pattern>
1706 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1707 opc, dt, asm, pattern>;
1708 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1709 dag oops, dag iops, InstrItinClass itin,
1710 string opc, string dt, string asm, list<dag> pattern>
1711 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1712 opc, dt, asm, pattern>;
1713 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1714 dag oops, dag iops, InstrItinClass itin,
1715 string opc, string dt, string asm, list<dag> pattern>
1716 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1717 opc, dt, asm, pattern>;
1719 // Vector Duplicate Lane (from scalar to all elements)
1720 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1721 InstrItinClass itin, string opc, string dt, string asm,
1723 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1724 let Inst{24-23} = 0b11;
1725 let Inst{21-20} = 0b11;
1726 let Inst{19-16} = op19_16;
1727 let Inst{11-7} = 0b11000;
1735 let Inst{22} = Vd{4};
1736 let Inst{15-12} = Vd{3-0};
1737 let Inst{5} = Vm{4};
1738 let Inst{3-0} = Vm{3-0};
1741 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1742 // for single-precision FP.
1743 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1744 list<Predicate> Predicates = [HasNEON,UseNEONForFP];