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 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
147 // register whose default is 0 (no register).
148 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
149 (ops (i32 14), (i32 zero_reg))> {
150 let PrintMethod = "printPredicateOperand";
151 let ParserMatchClass = CondCodeOperand;
154 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
155 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
156 let EncoderMethod = "getCCOutOpValue";
157 let PrintMethod = "printSBitModifierOperand";
160 // Same as cc_out except it defaults to setting CPSR.
161 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
162 let EncoderMethod = "getCCOutOpValue";
163 let PrintMethod = "printSBitModifierOperand";
166 // ARM special operands for disassembly only.
168 def setend_op : Operand<i32> {
169 let PrintMethod = "printSetendOperand";
172 def cps_opt : Operand<i32> {
173 let PrintMethod = "printCPSOptionOperand";
176 def msr_mask : Operand<i32> {
177 let PrintMethod = "printMSRMaskOperand";
180 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
181 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
182 def neg_zero : Operand<i32> {
183 let PrintMethod = "printNegZeroOperand";
186 //===----------------------------------------------------------------------===//
187 // ARM Instruction templates.
190 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
191 Format f, Domain d, string cstr, InstrItinClass itin>
193 let Namespace = "ARM";
198 bits<2> IndexModeBits = IM.Value;
200 bits<6> Form = F.Value;
202 bit isUnaryDataProc = 0;
203 bit canXformTo16Bit = 0;
205 // If this is a pseudo instruction, mark it isCodeGenOnly.
206 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
208 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
209 let TSFlags{4-0} = AM.Value;
210 let TSFlags{7-5} = SZ.Value;
211 let TSFlags{9-8} = IndexModeBits;
212 let TSFlags{15-10} = Form;
213 let TSFlags{16} = isUnaryDataProc;
214 let TSFlags{17} = canXformTo16Bit;
215 let TSFlags{19-18} = D.Value;
217 let Constraints = cstr;
218 let Itinerary = itin;
225 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
226 Format f, Domain d, string cstr, InstrItinClass itin>
227 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
229 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
230 // on by adding flavors to specific instructions.
231 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
232 Format f, Domain d, string cstr, InstrItinClass itin>
233 : InstTemplate<am, sz, im, f, d, cstr, itin>;
235 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
236 // FIXME: This really should derive from InstTemplate instead, as pseudos
237 // don't need encoding information. TableGen doesn't like that
238 // currently. Need to figure out why and fix it.
239 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
241 let OutOperandList = oops;
242 let InOperandList = iops;
243 let Pattern = pattern;
246 // PseudoInst that's ARM-mode only.
247 class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
249 : PseudoInst<oops, iops, itin, pattern> {
251 list<Predicate> Predicates = [IsARM];
254 // PseudoInst that's Thumb-mode only.
255 class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
257 : PseudoInst<oops, iops, itin, pattern> {
259 list<Predicate> Predicates = [IsThumb];
262 // Almost all ARM instructions are predicable.
263 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
264 IndexMode im, Format f, InstrItinClass itin,
265 string opc, string asm, string cstr,
267 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
270 let OutOperandList = oops;
271 let InOperandList = !con(iops, (ins pred:$p));
272 let AsmString = !strconcat(opc, "${p}", asm);
273 let Pattern = pattern;
274 list<Predicate> Predicates = [IsARM];
277 // A few are not predicable
278 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
279 IndexMode im, Format f, InstrItinClass itin,
280 string opc, string asm, string cstr,
282 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
283 let OutOperandList = oops;
284 let InOperandList = iops;
285 let AsmString = !strconcat(opc, asm);
286 let Pattern = pattern;
287 let isPredicable = 0;
288 list<Predicate> Predicates = [IsARM];
291 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
292 // operand since by default it's a zero register. It will become an implicit def
293 // once it's "flipped".
294 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
295 IndexMode im, Format f, InstrItinClass itin,
296 string opc, string asm, string cstr,
298 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
299 bits<4> p; // Predicate operand
300 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
304 let OutOperandList = oops;
305 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
306 let AsmString = !strconcat(opc, "${s}${p}", asm);
307 let Pattern = pattern;
308 list<Predicate> Predicates = [IsARM];
312 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
313 IndexMode im, Format f, InstrItinClass itin,
314 string asm, string cstr, list<dag> pattern>
315 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
316 let OutOperandList = oops;
317 let InOperandList = iops;
319 let Pattern = pattern;
320 list<Predicate> Predicates = [IsARM];
323 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
324 string opc, string asm, list<dag> pattern>
325 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
326 opc, asm, "", pattern>;
327 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
328 string opc, string asm, list<dag> pattern>
329 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
330 opc, asm, "", pattern>;
331 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
332 string asm, list<dag> pattern>
333 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
335 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
336 string opc, string asm, list<dag> pattern>
337 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
338 opc, asm, "", pattern>;
340 // Ctrl flow instructions
341 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
342 string opc, string asm, list<dag> pattern>
343 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
344 opc, asm, "", pattern> {
345 let Inst{27-24} = opcod;
347 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
348 string asm, list<dag> pattern>
349 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
351 let Inst{27-24} = opcod;
354 // BR_JT instructions
355 class JTI<dag oops, dag iops, InstrItinClass itin,
356 string asm, list<dag> pattern>
357 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
360 // Atomic load/store instructions
361 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
362 string opc, string asm, list<dag> pattern>
363 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
364 opc, asm, "", pattern> {
367 let Inst{27-23} = 0b00011;
368 let Inst{22-21} = opcod;
370 let Inst{19-16} = Rn;
371 let Inst{15-12} = Rt;
372 let Inst{11-0} = 0b111110011111;
374 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
375 string opc, string asm, list<dag> pattern>
376 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
377 opc, asm, "", pattern> {
381 let Inst{27-23} = 0b00011;
382 let Inst{22-21} = opcod;
384 let Inst{19-16} = Rn;
385 let Inst{15-12} = Rd;
386 let Inst{11-4} = 0b11111001;
389 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
390 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
394 let Inst{27-23} = 0b00010;
396 let Inst{21-20} = 0b00;
397 let Inst{19-16} = Rn;
398 let Inst{15-12} = Rt;
399 let Inst{11-4} = 0b00001001;
403 // addrmode1 instructions
404 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
405 string opc, string asm, list<dag> pattern>
406 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
407 opc, asm, "", pattern> {
408 let Inst{24-21} = opcod;
409 let Inst{27-26} = 0b00;
411 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
412 string opc, string asm, list<dag> pattern>
413 : sI<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 AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
419 string asm, list<dag> pattern>
420 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
422 let Inst{24-21} = opcod;
423 let Inst{27-26} = 0b00;
428 // LDR/LDRB/STR/STRB/...
429 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
430 Format f, InstrItinClass itin, string opc, string asm,
432 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
434 let Inst{27-25} = op;
435 let Inst{24} = 1; // 24 == P
437 let Inst{22} = isByte;
438 let Inst{21} = 0; // 21 == W
441 // Indexed load/stores
442 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
443 IndexMode im, Format f, InstrItinClass itin, string opc,
444 string asm, string cstr, list<dag> pattern>
445 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
446 opc, asm, cstr, pattern> {
448 let Inst{27-26} = 0b01;
449 let Inst{24} = isPre; // P bit
450 let Inst{22} = isByte; // B bit
451 let Inst{21} = isPre; // W bit
452 let Inst{20} = isLd; // L bit
453 let Inst{15-12} = Rt;
455 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
456 IndexMode im, Format f, InstrItinClass itin, string opc,
457 string asm, string cstr, list<dag> pattern>
458 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
460 // AM2 store w/ two operands: (GPR, am2offset)
461 // {13} 1 == Rm, 0 == imm12
466 let Inst{25} = offset{13};
467 let Inst{23} = offset{12};
468 let Inst{19-16} = Rn;
469 let Inst{11-0} = offset{11-0};
472 // addrmode3 instructions
473 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
474 InstrItinClass itin, string opc, string asm, list<dag> pattern>
475 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
476 opc, asm, "", pattern> {
479 let Inst{27-25} = 0b000;
480 let Inst{24} = 1; // P bit
481 let Inst{23} = addr{8}; // U bit
482 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
483 let Inst{21} = 0; // W bit
484 let Inst{20} = op20; // L bit
485 let Inst{19-16} = addr{12-9}; // Rn
486 let Inst{15-12} = Rt; // Rt
487 let Inst{11-8} = addr{7-4}; // imm7_4/zero
489 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
492 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
493 IndexMode im, Format f, InstrItinClass itin, string opc,
494 string asm, string cstr, list<dag> pattern>
495 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
496 opc, asm, cstr, pattern> {
498 let Inst{27-25} = 0b000;
499 let Inst{24} = isPre; // P bit
500 let Inst{21} = isPre; // W bit
501 let Inst{20} = op20; // L bit
502 let Inst{15-12} = Rt; // Rt
505 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
506 IndexMode im, Format f, InstrItinClass itin, string opc,
507 string asm, string cstr, list<dag> pattern>
508 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
510 // AM3 store w/ two operands: (GPR, am3offset)
514 let Inst{27-25} = 0b000;
515 let Inst{23} = offset{8};
516 let Inst{22} = offset{9};
517 let Inst{19-16} = Rn;
518 let Inst{15-12} = Rt; // Rt
519 let Inst{11-8} = offset{7-4}; // imm7_4/zero
521 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
525 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
526 string opc, string asm, list<dag> pattern>
527 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
528 opc, asm, "", pattern> {
531 let Inst{27-25} = 0b000;
532 let Inst{24} = 1; // P bit
533 let Inst{23} = addr{8}; // U bit
534 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
535 let Inst{21} = 0; // W bit
536 let Inst{20} = 0; // L bit
537 let Inst{19-16} = addr{12-9}; // Rn
538 let Inst{15-12} = Rt; // Rt
539 let Inst{11-8} = addr{7-4}; // imm7_4/zero
541 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
544 // Pre-indexed stores
545 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
546 string opc, string asm, string cstr, list<dag> pattern>
547 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
548 opc, asm, cstr, pattern> {
550 let Inst{5} = 1; // H bit
551 let Inst{6} = 0; // S bit
553 let Inst{20} = 0; // L bit
554 let Inst{21} = 1; // W bit
555 let Inst{24} = 1; // P bit
556 let Inst{27-25} = 0b000;
558 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
559 string opc, string asm, string cstr, list<dag> pattern>
560 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
561 opc, asm, cstr, pattern> {
563 let Inst{5} = 1; // H bit
564 let Inst{6} = 1; // S bit
566 let Inst{20} = 0; // L bit
567 let Inst{21} = 1; // W bit
568 let Inst{24} = 1; // P bit
569 let Inst{27-25} = 0b000;
572 // Post-indexed stores
573 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
574 string opc, string asm, string cstr, list<dag> pattern>
575 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
576 opc, asm, cstr,pattern> {
578 let Inst{5} = 1; // H bit
579 let Inst{6} = 0; // S bit
581 let Inst{20} = 0; // L bit
582 let Inst{21} = 0; // W bit
583 let Inst{24} = 0; // P bit
584 let Inst{27-25} = 0b000;
586 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
587 string opc, string asm, string cstr, list<dag> pattern>
588 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
589 opc, asm, cstr, pattern> {
591 let Inst{5} = 1; // H bit
592 let Inst{6} = 1; // S bit
594 let Inst{20} = 0; // L bit
595 let Inst{21} = 0; // W bit
596 let Inst{24} = 0; // P bit
597 let Inst{27-25} = 0b000;
600 // addrmode4 instructions
601 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
602 string asm, string cstr, list<dag> pattern>
603 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
608 let Inst{27-25} = 0b100;
609 let Inst{22} = 0; // S bit
610 let Inst{19-16} = Rn;
611 let Inst{15-0} = regs;
614 // Unsigned multiply, multiply-accumulate instructions.
615 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
616 string opc, string asm, list<dag> pattern>
617 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
618 opc, asm, "", pattern> {
619 let Inst{7-4} = 0b1001;
620 let Inst{20} = 0; // S bit
621 let Inst{27-21} = opcod;
623 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
624 string opc, string asm, list<dag> pattern>
625 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
626 opc, asm, "", pattern> {
627 let Inst{7-4} = 0b1001;
628 let Inst{27-21} = opcod;
631 // Most significant word multiply
632 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
633 InstrItinClass itin, string opc, string asm, list<dag> pattern>
634 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
635 opc, asm, "", pattern> {
639 let Inst{7-4} = opc7_4;
641 let Inst{27-21} = opcod;
642 let Inst{19-16} = Rd;
646 // MSW multiple w/ Ra operand
647 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
648 InstrItinClass itin, string opc, string asm, list<dag> pattern>
649 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
651 let Inst{15-12} = Ra;
654 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
655 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
656 InstrItinClass itin, string opc, string asm, list<dag> pattern>
657 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
658 opc, asm, "", pattern> {
664 let Inst{27-21} = opcod;
665 let Inst{6-5} = bit6_5;
669 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
670 InstrItinClass itin, string opc, string asm, list<dag> pattern>
671 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
673 let Inst{19-16} = Rd;
676 // AMulxyI with Ra operand
677 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
678 InstrItinClass itin, string opc, string asm, list<dag> pattern>
679 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
681 let Inst{15-12} = Ra;
684 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
685 InstrItinClass itin, string opc, string asm, list<dag> pattern>
686 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
689 let Inst{19-16} = RdHi;
690 let Inst{15-12} = RdLo;
693 // Extend instructions.
694 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
695 string opc, string asm, list<dag> pattern>
696 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
697 opc, asm, "", pattern> {
698 // All AExtI instructions have Rd and Rm register operands.
701 let Inst{15-12} = Rd;
703 let Inst{7-4} = 0b0111;
704 let Inst{9-8} = 0b00;
705 let Inst{27-20} = opcod;
708 // Misc Arithmetic instructions.
709 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
710 InstrItinClass itin, string opc, string asm, list<dag> pattern>
711 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
712 opc, asm, "", pattern> {
715 let Inst{27-20} = opcod;
716 let Inst{19-16} = 0b1111;
717 let Inst{15-12} = Rd;
718 let Inst{11-8} = 0b1111;
719 let Inst{7-4} = opc7_4;
724 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
725 string opc, string asm, list<dag> pattern>
726 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
727 opc, asm, "", pattern> {
732 let Inst{27-20} = opcod;
733 let Inst{19-16} = Rn;
734 let Inst{15-12} = Rd;
735 let Inst{11-7} = sh{7-3};
737 let Inst{5-4} = 0b01;
741 //===----------------------------------------------------------------------===//
743 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
744 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
745 list<Predicate> Predicates = [IsARM];
747 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
748 list<Predicate> Predicates = [IsARM, HasV5TE];
750 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
751 list<Predicate> Predicates = [IsARM, HasV6];
754 //===----------------------------------------------------------------------===//
755 // Thumb Instruction Format Definitions.
758 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
759 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
760 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
761 let OutOperandList = oops;
762 let InOperandList = iops;
764 let Pattern = pattern;
765 list<Predicate> Predicates = [IsThumb];
768 // TI - Thumb instruction.
769 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
770 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
772 // Two-address instructions
773 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
775 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
778 // tBL, tBX 32-bit instructions
779 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
780 dag oops, dag iops, InstrItinClass itin, string asm,
782 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
784 let Inst{31-27} = opcod1;
785 let Inst{15-14} = opcod2;
786 let Inst{12} = opcod3;
789 // BR_JT instructions
790 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
792 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
795 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
796 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
797 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
798 let OutOperandList = oops;
799 let InOperandList = iops;
801 let Pattern = pattern;
802 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
805 class T1I<dag oops, dag iops, InstrItinClass itin,
806 string asm, list<dag> pattern>
807 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
808 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
809 string asm, list<dag> pattern>
810 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
812 // Two-address instructions
813 class T1It<dag oops, dag iops, InstrItinClass itin,
814 string asm, string cstr, list<dag> pattern>
815 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
818 // Thumb1 instruction that can either be predicated or set CPSR.
819 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
821 string opc, string asm, string cstr, list<dag> pattern>
822 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
823 let OutOperandList = !con(oops, (outs s_cc_out:$s));
824 let InOperandList = !con(iops, (ins pred:$p));
825 let AsmString = !strconcat(opc, "${s}${p}", asm);
826 let Pattern = pattern;
827 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
830 class T1sI<dag oops, dag iops, InstrItinClass itin,
831 string opc, string asm, list<dag> pattern>
832 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
834 // Two-address instructions
835 class T1sIt<dag oops, dag iops, InstrItinClass itin,
836 string opc, string asm, list<dag> pattern>
837 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
838 "$Rn = $Rdn", pattern>;
840 // Thumb1 instruction that can be predicated.
841 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
843 string opc, string asm, string cstr, list<dag> pattern>
844 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
845 let OutOperandList = oops;
846 let InOperandList = !con(iops, (ins pred:$p));
847 let AsmString = !strconcat(opc, "${p}", asm);
848 let Pattern = pattern;
849 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
852 class T1pI<dag oops, dag iops, InstrItinClass itin,
853 string opc, string asm, list<dag> pattern>
854 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
856 // Two-address instructions
857 class T1pIt<dag oops, dag iops, InstrItinClass itin,
858 string opc, string asm, list<dag> pattern>
859 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
860 "$Rn = $Rdn", pattern>;
862 class T1pIs<dag oops, dag iops,
863 InstrItinClass itin, string opc, string asm, list<dag> pattern>
864 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
866 class Encoding16 : Encoding {
867 let Inst{31-16} = 0x0000;
870 // A6.2 16-bit Thumb instruction encoding
871 class T1Encoding<bits<6> opcode> : Encoding16 {
872 let Inst{15-10} = opcode;
875 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
876 class T1General<bits<5> opcode> : Encoding16 {
877 let Inst{15-14} = 0b00;
878 let Inst{13-9} = opcode;
881 // A6.2.2 Data-processing encoding.
882 class T1DataProcessing<bits<4> opcode> : Encoding16 {
883 let Inst{15-10} = 0b010000;
884 let Inst{9-6} = opcode;
887 // A6.2.3 Special data instructions and branch and exchange encoding.
888 class T1Special<bits<4> opcode> : Encoding16 {
889 let Inst{15-10} = 0b010001;
890 let Inst{9-6} = opcode;
893 // A6.2.4 Load/store single data item encoding.
894 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
895 let Inst{15-12} = opA;
896 let Inst{11-9} = opB;
898 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
900 // Helper classes to encode Thumb1 loads and stores. For immediates, the
901 // following bits are used for "opA" (see A6.2.4):
903 // 0b0110 => Immediate, 4 bytes
904 // 0b1000 => Immediate, 2 bytes
905 // 0b0111 => Immediate, 1 byte
906 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
907 InstrItinClass itin, string opc, string asm,
909 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
910 T1LoadStore<0b0101, opcode> {
913 let Inst{8-6} = addr{5-3}; // Rm
914 let Inst{5-3} = addr{2-0}; // Rn
917 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
918 InstrItinClass itin, string opc, string asm,
920 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
921 T1LoadStore<opA, {opB,?,?}> {
924 let Inst{10-6} = addr{7-3}; // imm5
925 let Inst{5-3} = addr{2-0}; // Rn
929 // A6.2.5 Miscellaneous 16-bit instructions encoding.
930 class T1Misc<bits<7> opcode> : Encoding16 {
931 let Inst{15-12} = 0b1011;
932 let Inst{11-5} = opcode;
935 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
936 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
938 string opc, string asm, string cstr, list<dag> pattern>
939 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
940 let OutOperandList = oops;
941 let InOperandList = !con(iops, (ins pred:$p));
942 let AsmString = !strconcat(opc, "${p}", asm);
943 let Pattern = pattern;
944 list<Predicate> Predicates = [IsThumb2];
947 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
948 // input operand since by default it's a zero register. It will become an
949 // implicit def once it's "flipped".
951 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
953 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
955 string opc, string asm, string cstr, list<dag> pattern>
956 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
957 let OutOperandList = oops;
958 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
959 let AsmString = !strconcat(opc, "${s}${p}", asm);
960 let Pattern = pattern;
961 list<Predicate> Predicates = [IsThumb2];
965 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
967 string asm, string cstr, list<dag> pattern>
968 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
969 let OutOperandList = oops;
970 let InOperandList = iops;
972 let Pattern = pattern;
973 list<Predicate> Predicates = [IsThumb2];
976 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
978 string asm, string cstr, list<dag> pattern>
979 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
980 let OutOperandList = oops;
981 let InOperandList = iops;
983 let Pattern = pattern;
984 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
987 class T2I<dag oops, dag iops, InstrItinClass itin,
988 string opc, string asm, list<dag> pattern>
989 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
990 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
991 string opc, string asm, list<dag> pattern>
992 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
993 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
994 string opc, string asm, list<dag> pattern>
995 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
996 class T2Iso<dag oops, dag iops, InstrItinClass itin,
997 string opc, string asm, list<dag> pattern>
998 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
999 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1000 string opc, string asm, list<dag> pattern>
1001 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1002 class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
1003 string opc, string asm, list<dag> pattern>
1004 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1006 let Inst{31-27} = 0b11101;
1007 let Inst{26-25} = 0b00;
1009 let Inst{23} = ?; // The U bit.
1012 let Inst{20} = load;
1017 let Inst{15-12} = Rt{3-0};
1018 let Inst{11-8} = Rt2{3-0};
1019 let Inst{19-16} = addr{12-9};
1020 let Inst{23} = addr{8};
1021 let Inst{7-0} = addr{7-0};
1024 class T2sI<dag oops, dag iops, InstrItinClass itin,
1025 string opc, string asm, list<dag> pattern>
1026 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1028 class T2XI<dag oops, dag iops, InstrItinClass itin,
1029 string asm, list<dag> pattern>
1030 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1031 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1032 string asm, list<dag> pattern>
1033 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1035 // Two-address instructions
1036 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1037 string asm, string cstr, list<dag> pattern>
1038 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1040 // T2Iidxldst - Thumb2 indexed load / store instructions.
1041 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1043 AddrMode am, IndexMode im, InstrItinClass itin,
1044 string opc, string asm, string cstr, list<dag> pattern>
1045 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1046 let OutOperandList = oops;
1047 let InOperandList = !con(iops, (ins pred:$p));
1048 let AsmString = !strconcat(opc, "${p}", asm);
1049 let Pattern = pattern;
1050 list<Predicate> Predicates = [IsThumb2];
1051 let Inst{31-27} = 0b11111;
1052 let Inst{26-25} = 0b00;
1053 let Inst{24} = signed;
1055 let Inst{22-21} = opcod;
1056 let Inst{20} = load;
1058 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1059 let Inst{10} = pre; // The P bit.
1060 let Inst{8} = 1; // The W bit.
1063 let Inst{7-0} = addr{7-0};
1064 let Inst{9} = addr{8}; // Sign bit
1068 let Inst{15-12} = Rt{3-0};
1069 let Inst{19-16} = Rn{3-0};
1072 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1073 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1074 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1077 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1078 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1079 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1082 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1083 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1084 list<Predicate> Predicates = [IsThumb2];
1087 //===----------------------------------------------------------------------===//
1089 //===----------------------------------------------------------------------===//
1090 // ARM VFP Instruction templates.
1093 // Almost all VFP instructions are predicable.
1094 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1095 IndexMode im, Format f, InstrItinClass itin,
1096 string opc, string asm, string cstr, list<dag> pattern>
1097 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1099 let Inst{31-28} = p;
1100 let OutOperandList = oops;
1101 let InOperandList = !con(iops, (ins pred:$p));
1102 let AsmString = !strconcat(opc, "${p}", asm);
1103 let Pattern = pattern;
1104 let PostEncoderMethod = "VFPThumb2PostEncoder";
1105 list<Predicate> Predicates = [HasVFP2];
1109 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1110 IndexMode im, Format f, InstrItinClass itin,
1111 string asm, string cstr, list<dag> pattern>
1112 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1114 let Inst{31-28} = p;
1115 let OutOperandList = oops;
1116 let InOperandList = iops;
1117 let AsmString = asm;
1118 let Pattern = pattern;
1119 let PostEncoderMethod = "VFPThumb2PostEncoder";
1120 list<Predicate> Predicates = [HasVFP2];
1123 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1124 string opc, string asm, list<dag> pattern>
1125 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1126 opc, asm, "", pattern> {
1127 let PostEncoderMethod = "VFPThumb2PostEncoder";
1130 // ARM VFP addrmode5 loads and stores
1131 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1132 InstrItinClass itin,
1133 string opc, string asm, list<dag> pattern>
1134 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1135 VFPLdStFrm, itin, opc, asm, "", pattern> {
1136 // Instruction operands.
1140 // Encode instruction operands.
1141 let Inst{23} = addr{8}; // U (add = (U == '1'))
1142 let Inst{22} = Dd{4};
1143 let Inst{19-16} = addr{12-9}; // Rn
1144 let Inst{15-12} = Dd{3-0};
1145 let Inst{7-0} = addr{7-0}; // imm8
1147 // TODO: Mark the instructions with the appropriate subtarget info.
1148 let Inst{27-24} = opcod1;
1149 let Inst{21-20} = opcod2;
1150 let Inst{11-9} = 0b101;
1151 let Inst{8} = 1; // Double precision
1153 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1154 let D = VFPNeonDomain;
1157 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1158 InstrItinClass itin,
1159 string opc, string asm, list<dag> pattern>
1160 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1161 VFPLdStFrm, itin, opc, asm, "", pattern> {
1162 // Instruction operands.
1166 // Encode instruction operands.
1167 let Inst{23} = addr{8}; // U (add = (U == '1'))
1168 let Inst{22} = Sd{0};
1169 let Inst{19-16} = addr{12-9}; // Rn
1170 let Inst{15-12} = Sd{4-1};
1171 let Inst{7-0} = addr{7-0}; // imm8
1173 // TODO: Mark the instructions with the appropriate subtarget info.
1174 let Inst{27-24} = opcod1;
1175 let Inst{21-20} = opcod2;
1176 let Inst{11-9} = 0b101;
1177 let Inst{8} = 0; // Single precision
1180 // VFP Load / store multiple pseudo instructions.
1181 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1183 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1185 let OutOperandList = oops;
1186 let InOperandList = !con(iops, (ins pred:$p));
1187 let Pattern = pattern;
1188 list<Predicate> Predicates = [HasVFP2];
1191 // Load / store multiple
1192 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1193 string asm, string cstr, list<dag> pattern>
1194 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1195 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1196 // Instruction operands.
1200 // Encode instruction operands.
1201 let Inst{19-16} = Rn;
1202 let Inst{22} = regs{12};
1203 let Inst{15-12} = regs{11-8};
1204 let Inst{7-0} = regs{7-0};
1206 // TODO: Mark the instructions with the appropriate subtarget info.
1207 let Inst{27-25} = 0b110;
1208 let Inst{11-9} = 0b101;
1209 let Inst{8} = 1; // Double precision
1211 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1212 let D = VFPNeonDomain;
1215 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1216 string asm, string cstr, list<dag> pattern>
1217 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1218 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1219 // Instruction operands.
1223 // Encode instruction operands.
1224 let Inst{19-16} = Rn;
1225 let Inst{22} = regs{8};
1226 let Inst{15-12} = regs{12-9};
1227 let Inst{7-0} = regs{7-0};
1229 // TODO: Mark the instructions with the appropriate subtarget info.
1230 let Inst{27-25} = 0b110;
1231 let Inst{11-9} = 0b101;
1232 let Inst{8} = 0; // Single precision
1235 // Double precision, unary
1236 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1237 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1238 string asm, list<dag> pattern>
1239 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1240 // Instruction operands.
1244 // Encode instruction operands.
1245 let Inst{3-0} = Dm{3-0};
1246 let Inst{5} = Dm{4};
1247 let Inst{15-12} = Dd{3-0};
1248 let Inst{22} = Dd{4};
1250 let Inst{27-23} = opcod1;
1251 let Inst{21-20} = opcod2;
1252 let Inst{19-16} = opcod3;
1253 let Inst{11-9} = 0b101;
1254 let Inst{8} = 1; // Double precision
1255 let Inst{7-6} = opcod4;
1256 let Inst{4} = opcod5;
1259 // Double precision, binary
1260 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1261 dag iops, InstrItinClass itin, string opc, string asm,
1263 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1264 // Instruction operands.
1269 // Encode instruction operands.
1270 let Inst{3-0} = Dm{3-0};
1271 let Inst{5} = Dm{4};
1272 let Inst{19-16} = Dn{3-0};
1273 let Inst{7} = Dn{4};
1274 let Inst{15-12} = Dd{3-0};
1275 let Inst{22} = Dd{4};
1277 let Inst{27-23} = opcod1;
1278 let Inst{21-20} = opcod2;
1279 let Inst{11-9} = 0b101;
1280 let Inst{8} = 1; // Double precision
1285 // Single precision, unary
1286 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1287 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1288 string asm, list<dag> pattern>
1289 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1290 // Instruction operands.
1294 // Encode instruction operands.
1295 let Inst{3-0} = Sm{4-1};
1296 let Inst{5} = Sm{0};
1297 let Inst{15-12} = Sd{4-1};
1298 let Inst{22} = Sd{0};
1300 let Inst{27-23} = opcod1;
1301 let Inst{21-20} = opcod2;
1302 let Inst{19-16} = opcod3;
1303 let Inst{11-9} = 0b101;
1304 let Inst{8} = 0; // Single precision
1305 let Inst{7-6} = opcod4;
1306 let Inst{4} = opcod5;
1309 // Single precision unary, if no NEON. Same as ASuI except not available if
1311 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1312 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1313 string asm, list<dag> pattern>
1314 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1316 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1319 // Single precision, binary
1320 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1321 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1322 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1323 // Instruction operands.
1328 // Encode instruction operands.
1329 let Inst{3-0} = Sm{4-1};
1330 let Inst{5} = Sm{0};
1331 let Inst{19-16} = Sn{4-1};
1332 let Inst{7} = Sn{0};
1333 let Inst{15-12} = Sd{4-1};
1334 let Inst{22} = Sd{0};
1336 let Inst{27-23} = opcod1;
1337 let Inst{21-20} = opcod2;
1338 let Inst{11-9} = 0b101;
1339 let Inst{8} = 0; // Single precision
1344 // Single precision binary, if no NEON. Same as ASbI except not available if
1346 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1347 dag iops, InstrItinClass itin, string opc, string asm,
1349 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1350 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1352 // Instruction operands.
1357 // Encode instruction operands.
1358 let Inst{3-0} = Sm{4-1};
1359 let Inst{5} = Sm{0};
1360 let Inst{19-16} = Sn{4-1};
1361 let Inst{7} = Sn{0};
1362 let Inst{15-12} = Sd{4-1};
1363 let Inst{22} = Sd{0};
1366 // VFP conversion instructions
1367 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1368 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1370 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1371 let Inst{27-23} = opcod1;
1372 let Inst{21-20} = opcod2;
1373 let Inst{19-16} = opcod3;
1374 let Inst{11-8} = opcod4;
1379 // VFP conversion between floating-point and fixed-point
1380 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1381 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1383 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1384 // size (fixed-point number): sx == 0 ? 16 : 32
1385 let Inst{7} = op5; // sx
1388 // VFP conversion instructions, if no NEON
1389 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1390 dag oops, dag iops, InstrItinClass itin,
1391 string opc, string asm, list<dag> pattern>
1392 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1394 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1397 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1398 InstrItinClass itin,
1399 string opc, string asm, list<dag> pattern>
1400 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1401 let Inst{27-20} = opcod1;
1402 let Inst{11-8} = opcod2;
1406 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1407 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1408 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1410 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1411 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1412 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1414 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1415 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1416 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1418 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1419 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1420 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1422 //===----------------------------------------------------------------------===//
1424 //===----------------------------------------------------------------------===//
1425 // ARM NEON Instruction templates.
1428 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1429 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1431 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1432 let OutOperandList = oops;
1433 let InOperandList = !con(iops, (ins pred:$p));
1434 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1435 let Pattern = pattern;
1436 list<Predicate> Predicates = [HasNEON];
1439 // Same as NeonI except it does not have a "data type" specifier.
1440 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1441 InstrItinClass itin, string opc, string asm, string cstr,
1443 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1444 let OutOperandList = oops;
1445 let InOperandList = !con(iops, (ins pred:$p));
1446 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1447 let Pattern = pattern;
1448 list<Predicate> Predicates = [HasNEON];
1451 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1452 dag oops, dag iops, InstrItinClass itin,
1453 string opc, string dt, string asm, string cstr, list<dag> pattern>
1454 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1456 let Inst{31-24} = 0b11110100;
1457 let Inst{23} = op23;
1458 let Inst{21-20} = op21_20;
1459 let Inst{11-8} = op11_8;
1460 let Inst{7-4} = op7_4;
1462 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1468 let Inst{22} = Vd{4};
1469 let Inst{15-12} = Vd{3-0};
1470 let Inst{19-16} = Rn{3-0};
1471 let Inst{3-0} = Rm{3-0};
1474 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1475 dag oops, dag iops, InstrItinClass itin,
1476 string opc, string dt, string asm, string cstr, list<dag> pattern>
1477 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1478 dt, asm, cstr, pattern> {
1482 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1483 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1485 let OutOperandList = oops;
1486 let InOperandList = !con(iops, (ins pred:$p));
1487 list<Predicate> Predicates = [HasNEON];
1490 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1492 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1494 let OutOperandList = oops;
1495 let InOperandList = !con(iops, (ins pred:$p));
1496 let Pattern = pattern;
1497 list<Predicate> Predicates = [HasNEON];
1500 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1501 string opc, string dt, string asm, string cstr, list<dag> pattern>
1502 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1504 let Inst{31-25} = 0b1111001;
1505 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1508 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1509 string opc, string asm, string cstr, list<dag> pattern>
1510 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1512 let Inst{31-25} = 0b1111001;
1515 // NEON "one register and a modified immediate" format.
1516 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1518 dag oops, dag iops, InstrItinClass itin,
1519 string opc, string dt, string asm, string cstr,
1521 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1522 let Inst{23} = op23;
1523 let Inst{21-19} = op21_19;
1524 let Inst{11-8} = op11_8;
1530 // Instruction operands.
1534 let Inst{15-12} = Vd{3-0};
1535 let Inst{22} = Vd{4};
1536 let Inst{24} = SIMM{7};
1537 let Inst{18-16} = SIMM{6-4};
1538 let Inst{3-0} = SIMM{3-0};
1541 // NEON 2 vector register format.
1542 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1543 bits<5> op11_7, bit op6, bit op4,
1544 dag oops, dag iops, InstrItinClass itin,
1545 string opc, string dt, string asm, string cstr, list<dag> pattern>
1546 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1547 let Inst{24-23} = op24_23;
1548 let Inst{21-20} = op21_20;
1549 let Inst{19-18} = op19_18;
1550 let Inst{17-16} = op17_16;
1551 let Inst{11-7} = op11_7;
1555 // Instruction operands.
1559 let Inst{15-12} = Vd{3-0};
1560 let Inst{22} = Vd{4};
1561 let Inst{3-0} = Vm{3-0};
1562 let Inst{5} = Vm{4};
1565 // Same as N2V except it doesn't have a datatype suffix.
1566 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1567 bits<5> op11_7, bit op6, bit op4,
1568 dag oops, dag iops, InstrItinClass itin,
1569 string opc, string asm, string cstr, list<dag> pattern>
1570 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1571 let Inst{24-23} = op24_23;
1572 let Inst{21-20} = op21_20;
1573 let Inst{19-18} = op19_18;
1574 let Inst{17-16} = op17_16;
1575 let Inst{11-7} = op11_7;
1579 // Instruction operands.
1583 let Inst{15-12} = Vd{3-0};
1584 let Inst{22} = Vd{4};
1585 let Inst{3-0} = Vm{3-0};
1586 let Inst{5} = Vm{4};
1589 // NEON 2 vector register with immediate.
1590 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1591 dag oops, dag iops, Format f, InstrItinClass itin,
1592 string opc, string dt, string asm, string cstr, list<dag> pattern>
1593 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1594 let Inst{24} = op24;
1595 let Inst{23} = op23;
1596 let Inst{11-8} = op11_8;
1601 // Instruction operands.
1606 let Inst{15-12} = Vd{3-0};
1607 let Inst{22} = Vd{4};
1608 let Inst{3-0} = Vm{3-0};
1609 let Inst{5} = Vm{4};
1610 let Inst{21-16} = SIMM{5-0};
1613 // NEON 3 vector register format.
1614 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1615 dag oops, dag iops, Format f, InstrItinClass itin,
1616 string opc, string dt, string asm, string cstr, list<dag> pattern>
1617 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1618 let Inst{24} = op24;
1619 let Inst{23} = op23;
1620 let Inst{21-20} = op21_20;
1621 let Inst{11-8} = op11_8;
1625 // Instruction operands.
1630 let Inst{15-12} = Vd{3-0};
1631 let Inst{22} = Vd{4};
1632 let Inst{19-16} = Vn{3-0};
1633 let Inst{7} = Vn{4};
1634 let Inst{3-0} = Vm{3-0};
1635 let Inst{5} = Vm{4};
1638 // Same as N3V except it doesn't have a data type suffix.
1639 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1641 dag oops, dag iops, Format f, InstrItinClass itin,
1642 string opc, string asm, string cstr, list<dag> pattern>
1643 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1644 let Inst{24} = op24;
1645 let Inst{23} = op23;
1646 let Inst{21-20} = op21_20;
1647 let Inst{11-8} = op11_8;
1651 // Instruction operands.
1656 let Inst{15-12} = Vd{3-0};
1657 let Inst{22} = Vd{4};
1658 let Inst{19-16} = Vn{3-0};
1659 let Inst{7} = Vn{4};
1660 let Inst{3-0} = Vm{3-0};
1661 let Inst{5} = Vm{4};
1664 // NEON VMOVs between scalar and core registers.
1665 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1666 dag oops, dag iops, Format f, InstrItinClass itin,
1667 string opc, string dt, string asm, list<dag> pattern>
1668 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1670 let Inst{27-20} = opcod1;
1671 let Inst{11-8} = opcod2;
1672 let Inst{6-5} = opcod3;
1675 let OutOperandList = oops;
1676 let InOperandList = !con(iops, (ins pred:$p));
1677 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1678 let Pattern = pattern;
1679 list<Predicate> Predicates = [HasNEON];
1681 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1688 let Inst{31-28} = p{3-0};
1690 let Inst{19-16} = V{3-0};
1691 let Inst{15-12} = R{3-0};
1693 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1694 dag oops, dag iops, InstrItinClass itin,
1695 string opc, string dt, string asm, list<dag> pattern>
1696 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1697 opc, dt, asm, pattern>;
1698 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1699 dag oops, dag iops, InstrItinClass itin,
1700 string opc, string dt, string asm, list<dag> pattern>
1701 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1702 opc, dt, asm, pattern>;
1703 class NVDup<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, NDupFrm, itin,
1707 opc, dt, asm, pattern>;
1709 // Vector Duplicate Lane (from scalar to all elements)
1710 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1711 InstrItinClass itin, string opc, string dt, string asm,
1713 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1714 let Inst{24-23} = 0b11;
1715 let Inst{21-20} = 0b11;
1716 let Inst{19-16} = op19_16;
1717 let Inst{11-7} = 0b11000;
1725 let Inst{22} = Vd{4};
1726 let Inst{15-12} = Vd{3-0};
1727 let Inst{5} = Vm{4};
1728 let Inst{3-0} = Vm{3-0};
1731 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1732 // for single-precision FP.
1733 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1734 list<Predicate> Predicates = [HasNEON,UseNEONForFP];