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 a 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 //===----------------------------------------------------------------------===//
139 // ARM special operands.
142 def CondCodeOperand : AsmOperandClass {
143 let Name = "CondCode";
144 let SuperClasses = [];
147 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
148 // register whose default is 0 (no register).
149 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
150 (ops (i32 14), (i32 zero_reg))> {
151 let PrintMethod = "printPredicateOperand";
152 let ParserMatchClass = CondCodeOperand;
155 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
156 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
157 let EncoderMethod = "getCCOutOpValue";
158 let PrintMethod = "printSBitModifierOperand";
161 // Same as cc_out except it defaults to setting CPSR.
162 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
163 let EncoderMethod = "getCCOutOpValue";
164 let PrintMethod = "printSBitModifierOperand";
167 // ARM special operands for disassembly only.
169 def setend_op : Operand<i32> {
170 let PrintMethod = "printSetendOperand";
173 def cps_opt : Operand<i32> {
174 let PrintMethod = "printCPSOptionOperand";
177 def msr_mask : Operand<i32> {
178 let PrintMethod = "printMSRMaskOperand";
181 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
182 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
183 def neg_zero : Operand<i32> {
184 let PrintMethod = "printNegZeroOperand";
187 //===----------------------------------------------------------------------===//
189 // ARM Instruction templates.
192 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
193 Format f, Domain d, string cstr, InstrItinClass itin>
195 let Namespace = "ARM";
200 bits<2> IndexModeBits = IM.Value;
202 bits<6> Form = F.Value;
204 bit isUnaryDataProc = 0;
205 bit canXformTo16Bit = 0;
207 // If this is a pseudo instruction, mark it isCodeGenOnly.
208 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
210 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
211 let TSFlags{4-0} = AM.Value;
212 let TSFlags{7-5} = SZ.Value;
213 let TSFlags{9-8} = IndexModeBits;
214 let TSFlags{15-10} = Form;
215 let TSFlags{16} = isUnaryDataProc;
216 let TSFlags{17} = canXformTo16Bit;
217 let TSFlags{19-18} = D.Value;
219 let Constraints = cstr;
220 let Itinerary = itin;
227 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
228 Format f, Domain d, string cstr, InstrItinClass itin>
229 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
231 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
232 // on by adding flavors to specific instructions.
233 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
234 Format f, Domain d, string cstr, InstrItinClass itin>
235 : InstTemplate<am, sz, im, f, d, cstr, itin>;
237 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
238 // FIXME: This really should derive from InstTemplate instead, as pseudos
239 // don't need encoding information. TableGen doesn't like that
240 // currently. Need to figure out why and fix it.
241 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
243 let OutOperandList = oops;
244 let InOperandList = iops;
245 let Pattern = pattern;
248 // PseudoInst that's ARM-mode only.
249 class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
251 : PseudoInst<oops, iops, itin, pattern> {
253 list<Predicate> Predicates = [IsARM];
256 // PseudoInst that's Thumb-mode only.
257 class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
259 : PseudoInst<oops, iops, itin, pattern> {
261 list<Predicate> Predicates = [IsThumb];
264 // Almost all ARM instructions are predicable.
265 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
266 IndexMode im, Format f, InstrItinClass itin,
267 string opc, string asm, string cstr,
269 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
272 let OutOperandList = oops;
273 let InOperandList = !con(iops, (ins pred:$p));
274 let AsmString = !strconcat(opc, "${p}", asm);
275 let Pattern = pattern;
276 list<Predicate> Predicates = [IsARM];
279 // A few are not predicable
280 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
281 IndexMode im, Format f, InstrItinClass itin,
282 string opc, string asm, string cstr,
284 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
285 let OutOperandList = oops;
286 let InOperandList = iops;
287 let AsmString = !strconcat(opc, asm);
288 let Pattern = pattern;
289 let isPredicable = 0;
290 list<Predicate> Predicates = [IsARM];
293 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
294 // operand since by default it's a zero register. It will become an implicit def
295 // once it's "flipped".
296 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
297 IndexMode im, Format f, InstrItinClass itin,
298 string opc, string asm, string cstr,
300 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
301 bits<4> p; // Predicate operand
302 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
306 let OutOperandList = oops;
307 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
308 let AsmString = !strconcat(opc, "${s}${p}", asm);
309 let Pattern = pattern;
310 list<Predicate> Predicates = [IsARM];
314 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
315 IndexMode im, Format f, InstrItinClass itin,
316 string asm, string cstr, list<dag> pattern>
317 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
318 let OutOperandList = oops;
319 let InOperandList = iops;
321 let Pattern = pattern;
322 list<Predicate> Predicates = [IsARM];
325 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
326 string opc, string asm, list<dag> pattern>
327 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
328 opc, asm, "", pattern>;
329 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
330 string opc, string asm, list<dag> pattern>
331 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
332 opc, asm, "", pattern>;
333 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
334 string asm, list<dag> pattern>
335 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
337 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
338 string opc, string asm, list<dag> pattern>
339 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
340 opc, asm, "", pattern>;
342 // Ctrl flow instructions
343 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
344 string opc, string asm, list<dag> pattern>
345 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
346 opc, asm, "", pattern> {
347 let Inst{27-24} = opcod;
349 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
350 string asm, list<dag> pattern>
351 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
353 let Inst{27-24} = opcod;
356 // BR_JT instructions
357 class JTI<dag oops, dag iops, InstrItinClass itin,
358 string asm, list<dag> pattern>
359 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
362 // Atomic load/store instructions
363 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
364 string opc, string asm, list<dag> pattern>
365 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
366 opc, asm, "", pattern> {
369 let Inst{27-23} = 0b00011;
370 let Inst{22-21} = opcod;
372 let Inst{19-16} = Rn;
373 let Inst{15-12} = Rt;
374 let Inst{11-0} = 0b111110011111;
376 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
377 string opc, string asm, list<dag> pattern>
378 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
379 opc, asm, "", pattern> {
383 let Inst{27-23} = 0b00011;
384 let Inst{22-21} = opcod;
386 let Inst{19-16} = Rn;
387 let Inst{15-12} = Rd;
388 let Inst{11-4} = 0b11111001;
391 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
392 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
396 let Inst{27-23} = 0b00010;
398 let Inst{21-20} = 0b00;
399 let Inst{19-16} = Rn;
400 let Inst{15-12} = Rt;
401 let Inst{11-4} = 0b00001001;
405 // addrmode1 instructions
406 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
407 string opc, string asm, list<dag> pattern>
408 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
409 opc, asm, "", pattern> {
410 let Inst{24-21} = opcod;
411 let Inst{27-26} = 0b00;
413 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
414 string opc, string asm, list<dag> pattern>
415 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
416 opc, asm, "", pattern> {
417 let Inst{24-21} = opcod;
418 let Inst{27-26} = 0b00;
420 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
421 string asm, list<dag> pattern>
422 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
424 let Inst{24-21} = opcod;
425 let Inst{27-26} = 0b00;
430 // LDR/LDRB/STR/STRB/...
431 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
432 Format f, InstrItinClass itin, string opc, string asm,
434 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
436 let Inst{27-25} = op;
437 let Inst{24} = 1; // 24 == P
439 let Inst{22} = isByte;
440 let Inst{21} = 0; // 21 == W
443 // Indexed load/stores
444 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
445 IndexMode im, Format f, InstrItinClass itin, string opc,
446 string asm, string cstr, list<dag> pattern>
447 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
448 opc, asm, cstr, pattern> {
450 let Inst{27-26} = 0b01;
451 let Inst{24} = isPre; // P bit
452 let Inst{22} = isByte; // B bit
453 let Inst{21} = isPre; // W bit
454 let Inst{20} = isLd; // L bit
455 let Inst{15-12} = Rt;
457 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
458 IndexMode im, Format f, InstrItinClass itin, string opc,
459 string asm, string cstr, list<dag> pattern>
460 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
462 // AM2 store w/ two operands: (GPR, am2offset)
463 // {13} 1 == Rm, 0 == imm12
468 let Inst{25} = offset{13};
469 let Inst{23} = offset{12};
470 let Inst{19-16} = Rn;
471 let Inst{11-0} = offset{11-0};
474 // addrmode3 instructions
475 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
476 InstrItinClass itin, string opc, string asm, list<dag> pattern>
477 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
478 opc, asm, "", pattern> {
481 let Inst{27-25} = 0b000;
482 let Inst{24} = 1; // P bit
483 let Inst{23} = addr{8}; // U bit
484 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
485 let Inst{21} = 0; // W bit
486 let Inst{20} = op20; // L bit
487 let Inst{19-16} = addr{12-9}; // Rn
488 let Inst{15-12} = Rt; // Rt
489 let Inst{11-8} = addr{7-4}; // imm7_4/zero
491 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
494 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
495 IndexMode im, Format f, InstrItinClass itin, string opc,
496 string asm, string cstr, list<dag> pattern>
497 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
498 opc, asm, cstr, pattern> {
500 let Inst{27-25} = 0b000;
501 let Inst{24} = isPre; // P bit
502 let Inst{21} = isPre; // W bit
503 let Inst{20} = op20; // L bit
504 let Inst{15-12} = Rt; // Rt
507 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
508 IndexMode im, Format f, InstrItinClass itin, string opc,
509 string asm, string cstr, list<dag> pattern>
510 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
512 // AM3 store w/ two operands: (GPR, am3offset)
516 let Inst{27-25} = 0b000;
517 let Inst{23} = offset{8};
518 let Inst{22} = offset{9};
519 let Inst{19-16} = Rn;
520 let Inst{15-12} = Rt; // Rt
521 let Inst{11-8} = offset{7-4}; // imm7_4/zero
523 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
527 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
528 string opc, string asm, list<dag> pattern>
529 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
530 opc, asm, "", pattern> {
533 let Inst{27-25} = 0b000;
534 let Inst{24} = 1; // P bit
535 let Inst{23} = addr{8}; // U bit
536 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
537 let Inst{21} = 0; // W bit
538 let Inst{20} = 0; // L bit
539 let Inst{19-16} = addr{12-9}; // Rn
540 let Inst{15-12} = Rt; // Rt
541 let Inst{11-8} = addr{7-4}; // imm7_4/zero
543 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
546 // Pre-indexed stores
547 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
548 string opc, string asm, string cstr, list<dag> pattern>
549 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
550 opc, asm, cstr, pattern> {
552 let Inst{5} = 1; // H bit
553 let Inst{6} = 0; // S bit
555 let Inst{20} = 0; // L bit
556 let Inst{21} = 1; // W bit
557 let Inst{24} = 1; // P bit
558 let Inst{27-25} = 0b000;
560 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
561 string opc, string asm, string cstr, list<dag> pattern>
562 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
563 opc, asm, cstr, pattern> {
565 let Inst{5} = 1; // H bit
566 let Inst{6} = 1; // S bit
568 let Inst{20} = 0; // L bit
569 let Inst{21} = 1; // W bit
570 let Inst{24} = 1; // P bit
571 let Inst{27-25} = 0b000;
574 // Post-indexed stores
575 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
576 string opc, string asm, string cstr, list<dag> pattern>
577 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
578 opc, asm, cstr,pattern> {
580 let Inst{5} = 1; // H bit
581 let Inst{6} = 0; // S bit
583 let Inst{20} = 0; // L bit
584 let Inst{21} = 0; // W bit
585 let Inst{24} = 0; // P bit
586 let Inst{27-25} = 0b000;
588 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
589 string opc, string asm, string cstr, list<dag> pattern>
590 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
591 opc, asm, cstr, pattern> {
593 let Inst{5} = 1; // H bit
594 let Inst{6} = 1; // S bit
596 let Inst{20} = 0; // L bit
597 let Inst{21} = 0; // W bit
598 let Inst{24} = 0; // P bit
599 let Inst{27-25} = 0b000;
602 // addrmode4 instructions
603 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
604 string asm, string cstr, list<dag> pattern>
605 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
610 let Inst{27-25} = 0b100;
611 let Inst{22} = 0; // S bit
612 let Inst{19-16} = Rn;
613 let Inst{15-0} = regs;
616 // Unsigned multiply, multiply-accumulate instructions.
617 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
618 string opc, string asm, list<dag> pattern>
619 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
620 opc, asm, "", pattern> {
621 let Inst{7-4} = 0b1001;
622 let Inst{20} = 0; // S bit
623 let Inst{27-21} = opcod;
625 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
626 string opc, string asm, list<dag> pattern>
627 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
628 opc, asm, "", pattern> {
629 let Inst{7-4} = 0b1001;
630 let Inst{27-21} = opcod;
633 // Most significant word multiply
634 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
635 InstrItinClass itin, string opc, string asm, list<dag> pattern>
636 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
637 opc, asm, "", pattern> {
641 let Inst{7-4} = opc7_4;
643 let Inst{27-21} = opcod;
644 let Inst{19-16} = Rd;
648 // MSW multiple w/ Ra operand
649 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
650 InstrItinClass itin, string opc, string asm, list<dag> pattern>
651 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
653 let Inst{15-12} = Ra;
656 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
657 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
658 InstrItinClass itin, string opc, string asm, list<dag> pattern>
659 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
660 opc, asm, "", pattern> {
666 let Inst{27-21} = opcod;
667 let Inst{6-5} = bit6_5;
671 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
672 InstrItinClass itin, string opc, string asm, list<dag> pattern>
673 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
675 let Inst{19-16} = Rd;
678 // AMulxyI with Ra operand
679 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
680 InstrItinClass itin, string opc, string asm, list<dag> pattern>
681 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
683 let Inst{15-12} = Ra;
686 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
687 InstrItinClass itin, string opc, string asm, list<dag> pattern>
688 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
691 let Inst{19-16} = RdHi;
692 let Inst{15-12} = RdLo;
695 // Extend instructions.
696 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
697 string opc, string asm, list<dag> pattern>
698 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
699 opc, asm, "", pattern> {
700 // All AExtI instructions have Rd and Rm register operands.
703 let Inst{15-12} = Rd;
705 let Inst{7-4} = 0b0111;
706 let Inst{9-8} = 0b00;
707 let Inst{27-20} = opcod;
710 // Misc Arithmetic instructions.
711 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
712 InstrItinClass itin, string opc, string asm, list<dag> pattern>
713 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
714 opc, asm, "", pattern> {
717 let Inst{27-20} = opcod;
718 let Inst{19-16} = 0b1111;
719 let Inst{15-12} = Rd;
720 let Inst{11-8} = 0b1111;
721 let Inst{7-4} = opc7_4;
726 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
727 string opc, string asm, list<dag> pattern>
728 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
729 opc, asm, "", pattern> {
734 let Inst{27-20} = opcod;
735 let Inst{19-16} = Rn;
736 let Inst{15-12} = Rd;
737 let Inst{11-7} = sh{7-3};
739 let Inst{5-4} = 0b01;
743 //===----------------------------------------------------------------------===//
745 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
746 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
747 list<Predicate> Predicates = [IsARM];
749 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
750 list<Predicate> Predicates = [IsARM, HasV5TE];
752 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
753 list<Predicate> Predicates = [IsARM, HasV6];
756 //===----------------------------------------------------------------------===//
758 // Thumb Instruction Format Definitions.
761 // TI - Thumb instruction.
763 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
764 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
765 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
766 let OutOperandList = oops;
767 let InOperandList = iops;
769 let Pattern = pattern;
770 list<Predicate> Predicates = [IsThumb];
773 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
774 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
776 // Two-address instructions
777 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
779 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
782 // tBL, tBX 32-bit instructions
783 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
784 dag oops, dag iops, InstrItinClass itin, string asm,
786 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
788 let Inst{31-27} = opcod1;
789 let Inst{15-14} = opcod2;
790 let Inst{12} = opcod3;
793 // BR_JT instructions
794 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
796 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
799 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
800 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
801 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
802 let OutOperandList = oops;
803 let InOperandList = iops;
805 let Pattern = pattern;
806 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
809 class T1I<dag oops, dag iops, InstrItinClass itin,
810 string asm, list<dag> pattern>
811 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
812 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
813 string asm, list<dag> pattern>
814 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
816 // Two-address instructions
817 class T1It<dag oops, dag iops, InstrItinClass itin,
818 string asm, string cstr, list<dag> pattern>
819 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
822 // Thumb1 instruction that can either be predicated or set CPSR.
823 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
825 string opc, string asm, string cstr, list<dag> pattern>
826 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
827 let OutOperandList = !con(oops, (outs s_cc_out:$s));
828 let InOperandList = !con(iops, (ins pred:$p));
829 let AsmString = !strconcat(opc, "${s}${p}", asm);
830 let Pattern = pattern;
831 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
834 class T1sI<dag oops, dag iops, InstrItinClass itin,
835 string opc, string asm, list<dag> pattern>
836 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
838 // Two-address instructions
839 class T1sIt<dag oops, dag iops, InstrItinClass itin,
840 string opc, string asm, list<dag> pattern>
841 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
842 "$Rn = $Rdn", pattern>;
844 // Thumb1 instruction that can be predicated.
845 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
847 string opc, string asm, string cstr, list<dag> pattern>
848 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
849 let OutOperandList = oops;
850 let InOperandList = !con(iops, (ins pred:$p));
851 let AsmString = !strconcat(opc, "${p}", asm);
852 let Pattern = pattern;
853 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
856 class T1pI<dag oops, dag iops, InstrItinClass itin,
857 string opc, string asm, list<dag> pattern>
858 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
860 // Two-address instructions
861 class T1pIt<dag oops, dag iops, InstrItinClass itin,
862 string opc, string asm, list<dag> pattern>
863 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
864 "$Rn = $Rdn", pattern>;
866 class T1pIs<dag oops, dag iops,
867 InstrItinClass itin, string opc, string asm, list<dag> pattern>
868 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
870 class Encoding16 : Encoding {
871 let Inst{31-16} = 0x0000;
874 // A6.2 16-bit Thumb instruction encoding
875 class T1Encoding<bits<6> opcode> : Encoding16 {
876 let Inst{15-10} = opcode;
879 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
880 class T1General<bits<5> opcode> : Encoding16 {
881 let Inst{15-14} = 0b00;
882 let Inst{13-9} = opcode;
885 // A6.2.2 Data-processing encoding.
886 class T1DataProcessing<bits<4> opcode> : Encoding16 {
887 let Inst{15-10} = 0b010000;
888 let Inst{9-6} = opcode;
891 // A6.2.3 Special data instructions and branch and exchange encoding.
892 class T1Special<bits<4> opcode> : Encoding16 {
893 let Inst{15-10} = 0b010001;
894 let Inst{9-6} = opcode;
897 // A6.2.4 Load/store single data item encoding.
898 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
899 let Inst{15-12} = opA;
900 let Inst{11-9} = opB;
902 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
904 // Helper classes to encode Thumb1 loads and stores. For immediates, the
905 // following bits are used for "opA" (see A6.2.4):
907 // 0b0110 => Immediate, 4 bytes
908 // 0b1000 => Immediate, 2 bytes
909 // 0b0111 => Immediate, 1 byte
910 class T1pIEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
911 InstrItinClass itin, string opc, string asm,
913 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
914 T1LoadStore<0b0101, opcode> {
917 let Inst{8-6} = addr{5-3}; // Rm
918 let Inst{5-3} = addr{2-0}; // Rn
921 class T1pIEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
922 InstrItinClass itin, string opc, string asm,
924 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
925 T1LoadStore<opA, {opB,?,?}> {
928 let Inst{10-6} = addr{7-3}; // imm5
929 let Inst{5-3} = addr{2-0}; // Rn
933 // A6.2.5 Miscellaneous 16-bit instructions encoding.
934 class T1Misc<bits<7> opcode> : Encoding16 {
935 let Inst{15-12} = 0b1011;
936 let Inst{11-5} = opcode;
939 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
940 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
942 string opc, string asm, string cstr, list<dag> pattern>
943 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
944 let OutOperandList = oops;
945 let InOperandList = !con(iops, (ins pred:$p));
946 let AsmString = !strconcat(opc, "${p}", asm);
947 let Pattern = pattern;
948 list<Predicate> Predicates = [IsThumb2];
951 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
952 // input operand since by default it's a zero register. It will become an
953 // implicit def once it's "flipped".
955 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
957 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
959 string opc, string asm, string cstr, list<dag> pattern>
960 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
961 let OutOperandList = oops;
962 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
963 let AsmString = !strconcat(opc, "${s}${p}", asm);
964 let Pattern = pattern;
965 list<Predicate> Predicates = [IsThumb2];
969 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
971 string asm, string cstr, list<dag> pattern>
972 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
973 let OutOperandList = oops;
974 let InOperandList = iops;
976 let Pattern = pattern;
977 list<Predicate> Predicates = [IsThumb2];
980 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
982 string asm, string cstr, list<dag> pattern>
983 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
984 let OutOperandList = oops;
985 let InOperandList = iops;
987 let Pattern = pattern;
988 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
991 class T2I<dag oops, dag iops, InstrItinClass itin,
992 string opc, string asm, list<dag> pattern>
993 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
994 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
995 string opc, string asm, list<dag> pattern>
996 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
997 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
998 string opc, string asm, list<dag> pattern>
999 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1000 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1001 string opc, string asm, list<dag> pattern>
1002 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1003 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1004 string opc, string asm, list<dag> pattern>
1005 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1006 class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
1007 string opc, string asm, list<dag> pattern>
1008 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1010 let Inst{31-27} = 0b11101;
1011 let Inst{26-25} = 0b00;
1013 let Inst{23} = ?; // The U bit.
1016 let Inst{20} = load;
1019 class T2sI<dag oops, dag iops, InstrItinClass itin,
1020 string opc, string asm, list<dag> pattern>
1021 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1023 class T2XI<dag oops, dag iops, InstrItinClass itin,
1024 string asm, list<dag> pattern>
1025 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1026 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1027 string asm, list<dag> pattern>
1028 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1030 // Two-address instructions
1031 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1032 string asm, string cstr, list<dag> pattern>
1033 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1035 // T2Iidxldst - Thumb2 indexed load / store instructions.
1036 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1038 AddrMode am, IndexMode im, InstrItinClass itin,
1039 string opc, string asm, string cstr, list<dag> pattern>
1040 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1041 let OutOperandList = oops;
1042 let InOperandList = !con(iops, (ins pred:$p));
1043 let AsmString = !strconcat(opc, "${p}", asm);
1044 let Pattern = pattern;
1045 list<Predicate> Predicates = [IsThumb2];
1046 let Inst{31-27} = 0b11111;
1047 let Inst{26-25} = 0b00;
1048 let Inst{24} = signed;
1050 let Inst{22-21} = opcod;
1051 let Inst{20} = load;
1053 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1054 let Inst{10} = pre; // The P bit.
1055 let Inst{8} = 1; // The W bit.
1058 let Inst{7-0} = addr{7-0};
1059 let Inst{9} = addr{8}; // Sign bit
1063 let Inst{15-12} = Rt{3-0};
1064 let Inst{19-16} = Rn{3-0};
1067 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1068 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1069 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1072 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1073 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1074 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1077 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1078 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1079 list<Predicate> Predicates = [IsThumb2];
1082 //===----------------------------------------------------------------------===//
1084 //===----------------------------------------------------------------------===//
1085 // ARM VFP Instruction templates.
1088 // Almost all VFP instructions are predicable.
1089 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1090 IndexMode im, Format f, InstrItinClass itin,
1091 string opc, string asm, string cstr, list<dag> pattern>
1092 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1094 let Inst{31-28} = p;
1095 let OutOperandList = oops;
1096 let InOperandList = !con(iops, (ins pred:$p));
1097 let AsmString = !strconcat(opc, "${p}", asm);
1098 let Pattern = pattern;
1099 list<Predicate> Predicates = [HasVFP2];
1103 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1104 IndexMode im, Format f, InstrItinClass itin,
1105 string asm, string cstr, list<dag> pattern>
1106 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1108 let Inst{31-28} = p;
1109 let OutOperandList = oops;
1110 let InOperandList = iops;
1111 let AsmString = asm;
1112 let Pattern = pattern;
1113 list<Predicate> Predicates = [HasVFP2];
1116 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1117 string opc, string asm, list<dag> pattern>
1118 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1119 opc, asm, "", pattern>;
1121 // ARM VFP addrmode5 loads and stores
1122 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1123 InstrItinClass itin,
1124 string opc, string asm, list<dag> pattern>
1125 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1126 VFPLdStFrm, itin, opc, asm, "", pattern> {
1127 // Instruction operands.
1131 // Encode instruction operands.
1132 let Inst{23} = addr{8}; // U (add = (U == '1'))
1133 let Inst{22} = Dd{4};
1134 let Inst{19-16} = addr{12-9}; // Rn
1135 let Inst{15-12} = Dd{3-0};
1136 let Inst{7-0} = addr{7-0}; // imm8
1138 // TODO: Mark the instructions with the appropriate subtarget info.
1139 let Inst{27-24} = opcod1;
1140 let Inst{21-20} = opcod2;
1141 let Inst{11-9} = 0b101;
1142 let Inst{8} = 1; // Double precision
1144 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1145 let D = VFPNeonDomain;
1148 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1149 InstrItinClass itin,
1150 string opc, string asm, list<dag> pattern>
1151 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1152 VFPLdStFrm, itin, opc, asm, "", pattern> {
1153 // Instruction operands.
1157 // Encode instruction operands.
1158 let Inst{23} = addr{8}; // U (add = (U == '1'))
1159 let Inst{22} = Sd{0};
1160 let Inst{19-16} = addr{12-9}; // Rn
1161 let Inst{15-12} = Sd{4-1};
1162 let Inst{7-0} = addr{7-0}; // imm8
1164 // TODO: Mark the instructions with the appropriate subtarget info.
1165 let Inst{27-24} = opcod1;
1166 let Inst{21-20} = opcod2;
1167 let Inst{11-9} = 0b101;
1168 let Inst{8} = 0; // Single precision
1171 // VFP Load / store multiple pseudo instructions.
1172 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1174 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1176 let OutOperandList = oops;
1177 let InOperandList = !con(iops, (ins pred:$p));
1178 let Pattern = pattern;
1179 list<Predicate> Predicates = [HasVFP2];
1182 // Load / store multiple
1183 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1184 string asm, string cstr, list<dag> pattern>
1185 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1186 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1187 // Instruction operands.
1191 // Encode instruction operands.
1192 let Inst{19-16} = Rn;
1193 let Inst{22} = regs{12};
1194 let Inst{15-12} = regs{11-8};
1195 let Inst{7-0} = regs{7-0};
1197 // TODO: Mark the instructions with the appropriate subtarget info.
1198 let Inst{27-25} = 0b110;
1199 let Inst{11-9} = 0b101;
1200 let Inst{8} = 1; // Double precision
1202 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1203 let D = VFPNeonDomain;
1206 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1207 string asm, string cstr, list<dag> pattern>
1208 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1209 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1210 // Instruction operands.
1214 // Encode instruction operands.
1215 let Inst{19-16} = Rn;
1216 let Inst{22} = regs{8};
1217 let Inst{15-12} = regs{12-9};
1218 let Inst{7-0} = regs{7-0};
1220 // TODO: Mark the instructions with the appropriate subtarget info.
1221 let Inst{27-25} = 0b110;
1222 let Inst{11-9} = 0b101;
1223 let Inst{8} = 0; // Single precision
1226 // Double precision, unary
1227 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1228 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1229 string asm, list<dag> pattern>
1230 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1231 // Instruction operands.
1235 // Encode instruction operands.
1236 let Inst{3-0} = Dm{3-0};
1237 let Inst{5} = Dm{4};
1238 let Inst{15-12} = Dd{3-0};
1239 let Inst{22} = Dd{4};
1241 let Inst{27-23} = opcod1;
1242 let Inst{21-20} = opcod2;
1243 let Inst{19-16} = opcod3;
1244 let Inst{11-9} = 0b101;
1245 let Inst{8} = 1; // Double precision
1246 let Inst{7-6} = opcod4;
1247 let Inst{4} = opcod5;
1250 // Double precision, binary
1251 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1252 dag iops, InstrItinClass itin, string opc, string asm,
1254 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1255 // Instruction operands.
1260 // Encode instruction operands.
1261 let Inst{3-0} = Dm{3-0};
1262 let Inst{5} = Dm{4};
1263 let Inst{19-16} = Dn{3-0};
1264 let Inst{7} = Dn{4};
1265 let Inst{15-12} = Dd{3-0};
1266 let Inst{22} = Dd{4};
1268 let Inst{27-23} = opcod1;
1269 let Inst{21-20} = opcod2;
1270 let Inst{11-9} = 0b101;
1271 let Inst{8} = 1; // Double precision
1276 // Single precision, unary
1277 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1278 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1279 string asm, list<dag> pattern>
1280 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1281 // Instruction operands.
1285 // Encode instruction operands.
1286 let Inst{3-0} = Sm{4-1};
1287 let Inst{5} = Sm{0};
1288 let Inst{15-12} = Sd{4-1};
1289 let Inst{22} = Sd{0};
1291 let Inst{27-23} = opcod1;
1292 let Inst{21-20} = opcod2;
1293 let Inst{19-16} = opcod3;
1294 let Inst{11-9} = 0b101;
1295 let Inst{8} = 0; // Single precision
1296 let Inst{7-6} = opcod4;
1297 let Inst{4} = opcod5;
1300 // Single precision unary, if no NEON
1301 // Same as ASuI except not available if NEON is enabled
1302 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1303 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1304 string asm, list<dag> pattern>
1305 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1307 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1310 // Single precision, binary
1311 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1312 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1313 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1314 // Instruction operands.
1319 // Encode instruction operands.
1320 let Inst{3-0} = Sm{4-1};
1321 let Inst{5} = Sm{0};
1322 let Inst{19-16} = Sn{4-1};
1323 let Inst{7} = Sn{0};
1324 let Inst{15-12} = Sd{4-1};
1325 let Inst{22} = Sd{0};
1327 let Inst{27-23} = opcod1;
1328 let Inst{21-20} = opcod2;
1329 let Inst{11-9} = 0b101;
1330 let Inst{8} = 0; // Single precision
1335 // Single precision binary, if no NEON
1336 // Same as ASbI except not available if NEON is enabled
1337 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1338 dag iops, InstrItinClass itin, string opc, string asm,
1340 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1341 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1343 // Instruction operands.
1348 // Encode instruction operands.
1349 let Inst{3-0} = Sm{4-1};
1350 let Inst{5} = Sm{0};
1351 let Inst{19-16} = Sn{4-1};
1352 let Inst{7} = Sn{0};
1353 let Inst{15-12} = Sd{4-1};
1354 let Inst{22} = Sd{0};
1357 // VFP conversion instructions
1358 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1359 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1361 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1362 let Inst{27-23} = opcod1;
1363 let Inst{21-20} = opcod2;
1364 let Inst{19-16} = opcod3;
1365 let Inst{11-8} = opcod4;
1370 // VFP conversion between floating-point and fixed-point
1371 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1372 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1374 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1375 // size (fixed-point number): sx == 0 ? 16 : 32
1376 let Inst{7} = op5; // sx
1379 // VFP conversion instructions, if no NEON
1380 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1381 dag oops, dag iops, InstrItinClass itin,
1382 string opc, string asm, list<dag> pattern>
1383 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1385 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1388 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1389 InstrItinClass itin,
1390 string opc, string asm, list<dag> pattern>
1391 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1392 let Inst{27-20} = opcod1;
1393 let Inst{11-8} = opcod2;
1397 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1398 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1399 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1401 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1402 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1403 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1405 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1406 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1407 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1409 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1410 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1411 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1413 //===----------------------------------------------------------------------===//
1415 //===----------------------------------------------------------------------===//
1416 // ARM NEON Instruction templates.
1419 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1420 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1422 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1423 let OutOperandList = oops;
1424 let InOperandList = !con(iops, (ins pred:$p));
1425 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1426 let Pattern = pattern;
1427 list<Predicate> Predicates = [HasNEON];
1430 // Same as NeonI except it does not have a "data type" specifier.
1431 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1432 InstrItinClass itin, string opc, string asm, string cstr,
1434 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1435 let OutOperandList = oops;
1436 let InOperandList = !con(iops, (ins pred:$p));
1437 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1438 let Pattern = pattern;
1439 list<Predicate> Predicates = [HasNEON];
1442 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1443 dag oops, dag iops, InstrItinClass itin,
1444 string opc, string dt, string asm, string cstr, list<dag> pattern>
1445 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1447 let Inst{31-24} = 0b11110100;
1448 let Inst{23} = op23;
1449 let Inst{21-20} = op21_20;
1450 let Inst{11-8} = op11_8;
1451 let Inst{7-4} = op7_4;
1453 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1459 let Inst{22} = Vd{4};
1460 let Inst{15-12} = Vd{3-0};
1461 let Inst{19-16} = Rn{3-0};
1462 let Inst{3-0} = Rm{3-0};
1465 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1466 dag oops, dag iops, InstrItinClass itin,
1467 string opc, string dt, string asm, string cstr, list<dag> pattern>
1468 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1469 dt, asm, cstr, pattern> {
1473 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1474 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1476 let OutOperandList = oops;
1477 let InOperandList = !con(iops, (ins pred:$p));
1478 list<Predicate> Predicates = [HasNEON];
1481 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1483 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1485 let OutOperandList = oops;
1486 let InOperandList = !con(iops, (ins pred:$p));
1487 let Pattern = pattern;
1488 list<Predicate> Predicates = [HasNEON];
1491 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1492 string opc, string dt, string asm, string cstr, list<dag> pattern>
1493 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1495 let Inst{31-25} = 0b1111001;
1496 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1499 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1500 string opc, string asm, string cstr, list<dag> pattern>
1501 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1503 let Inst{31-25} = 0b1111001;
1506 // NEON "one register and a modified immediate" format.
1507 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1509 dag oops, dag iops, InstrItinClass itin,
1510 string opc, string dt, string asm, string cstr,
1512 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1513 let Inst{23} = op23;
1514 let Inst{21-19} = op21_19;
1515 let Inst{11-8} = op11_8;
1521 // Instruction operands.
1525 let Inst{15-12} = Vd{3-0};
1526 let Inst{22} = Vd{4};
1527 let Inst{24} = SIMM{7};
1528 let Inst{18-16} = SIMM{6-4};
1529 let Inst{3-0} = SIMM{3-0};
1532 // NEON 2 vector register format.
1533 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1534 bits<5> op11_7, bit op6, bit op4,
1535 dag oops, dag iops, InstrItinClass itin,
1536 string opc, string dt, string asm, string cstr, list<dag> pattern>
1537 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1538 let Inst{24-23} = op24_23;
1539 let Inst{21-20} = op21_20;
1540 let Inst{19-18} = op19_18;
1541 let Inst{17-16} = op17_16;
1542 let Inst{11-7} = op11_7;
1546 // Instruction operands.
1550 let Inst{15-12} = Vd{3-0};
1551 let Inst{22} = Vd{4};
1552 let Inst{3-0} = Vm{3-0};
1553 let Inst{5} = Vm{4};
1556 // Same as N2V except it doesn't have a datatype suffix.
1557 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1558 bits<5> op11_7, bit op6, bit op4,
1559 dag oops, dag iops, InstrItinClass itin,
1560 string opc, string asm, string cstr, list<dag> pattern>
1561 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1562 let Inst{24-23} = op24_23;
1563 let Inst{21-20} = op21_20;
1564 let Inst{19-18} = op19_18;
1565 let Inst{17-16} = op17_16;
1566 let Inst{11-7} = op11_7;
1570 // Instruction operands.
1574 let Inst{15-12} = Vd{3-0};
1575 let Inst{22} = Vd{4};
1576 let Inst{3-0} = Vm{3-0};
1577 let Inst{5} = Vm{4};
1580 // NEON 2 vector register with immediate.
1581 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1582 dag oops, dag iops, Format f, InstrItinClass itin,
1583 string opc, string dt, string asm, string cstr, list<dag> pattern>
1584 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1585 let Inst{24} = op24;
1586 let Inst{23} = op23;
1587 let Inst{11-8} = op11_8;
1592 // Instruction operands.
1597 let Inst{15-12} = Vd{3-0};
1598 let Inst{22} = Vd{4};
1599 let Inst{3-0} = Vm{3-0};
1600 let Inst{5} = Vm{4};
1601 let Inst{21-16} = SIMM{5-0};
1604 // NEON 3 vector register format.
1605 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1606 dag oops, dag iops, Format f, InstrItinClass itin,
1607 string opc, string dt, string asm, string cstr, list<dag> pattern>
1608 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1609 let Inst{24} = op24;
1610 let Inst{23} = op23;
1611 let Inst{21-20} = op21_20;
1612 let Inst{11-8} = op11_8;
1616 // Instruction operands.
1621 let Inst{15-12} = Vd{3-0};
1622 let Inst{22} = Vd{4};
1623 let Inst{19-16} = Vn{3-0};
1624 let Inst{7} = Vn{4};
1625 let Inst{3-0} = Vm{3-0};
1626 let Inst{5} = Vm{4};
1629 // Same as N3V except it doesn't have a data type suffix.
1630 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1632 dag oops, dag iops, Format f, InstrItinClass itin,
1633 string opc, string asm, string cstr, list<dag> pattern>
1634 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1635 let Inst{24} = op24;
1636 let Inst{23} = op23;
1637 let Inst{21-20} = op21_20;
1638 let Inst{11-8} = op11_8;
1642 // Instruction operands.
1647 let Inst{15-12} = Vd{3-0};
1648 let Inst{22} = Vd{4};
1649 let Inst{19-16} = Vn{3-0};
1650 let Inst{7} = Vn{4};
1651 let Inst{3-0} = Vm{3-0};
1652 let Inst{5} = Vm{4};
1655 // NEON VMOVs between scalar and core registers.
1656 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1657 dag oops, dag iops, Format f, InstrItinClass itin,
1658 string opc, string dt, string asm, list<dag> pattern>
1659 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1661 let Inst{27-20} = opcod1;
1662 let Inst{11-8} = opcod2;
1663 let Inst{6-5} = opcod3;
1666 let OutOperandList = oops;
1667 let InOperandList = !con(iops, (ins pred:$p));
1668 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1669 let Pattern = pattern;
1670 list<Predicate> Predicates = [HasNEON];
1672 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1679 let Inst{31-28} = p{3-0};
1681 let Inst{19-16} = V{3-0};
1682 let Inst{15-12} = R{3-0};
1684 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1685 dag oops, dag iops, InstrItinClass itin,
1686 string opc, string dt, string asm, list<dag> pattern>
1687 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1688 opc, dt, asm, pattern>;
1689 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1690 dag oops, dag iops, InstrItinClass itin,
1691 string opc, string dt, string asm, list<dag> pattern>
1692 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1693 opc, dt, asm, pattern>;
1694 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1695 dag oops, dag iops, InstrItinClass itin,
1696 string opc, string dt, string asm, list<dag> pattern>
1697 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1698 opc, dt, asm, pattern>;
1700 // Vector Duplicate Lane (from scalar to all elements)
1701 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1702 InstrItinClass itin, string opc, string dt, string asm,
1704 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1705 let Inst{24-23} = 0b11;
1706 let Inst{21-20} = 0b11;
1707 let Inst{19-16} = op19_16;
1708 let Inst{11-7} = 0b11000;
1716 let Inst{22} = Vd{4};
1717 let Inst{15-12} = Vd{3-0};
1718 let Inst{5} = Vm{4};
1719 let Inst{3-0} = Vm{3-0};
1722 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1723 // for single-precision FP.
1724 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1725 list<Predicate> Predicates = [HasNEON,UseNEONForFP];