1 //===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 // ARM Instruction Format Definitions.
15 // Format specifies the encoding used by the instruction. This is part of the
16 // ad-hoc solution used to emit machine instruction encodings by our machine
18 class Format<bits<6> val> {
22 def Pseudo : Format<0>;
23 def MulFrm : Format<1>;
24 def BrFrm : Format<2>;
25 def BrMiscFrm : Format<3>;
27 def DPFrm : Format<4>;
28 def DPSoRegFrm : Format<5>;
30 def LdFrm : Format<6>;
31 def StFrm : Format<7>;
32 def LdMiscFrm : Format<8>;
33 def StMiscFrm : Format<9>;
34 def LdStMulFrm : Format<10>;
36 def LdStExFrm : Format<11>;
38 def ArithMiscFrm : Format<12>;
39 def SatFrm : Format<13>;
40 def ExtFrm : Format<14>;
42 def VFPUnaryFrm : Format<15>;
43 def VFPBinaryFrm : Format<16>;
44 def VFPConv1Frm : Format<17>;
45 def VFPConv2Frm : Format<18>;
46 def VFPConv3Frm : Format<19>;
47 def VFPConv4Frm : Format<20>;
48 def VFPConv5Frm : Format<21>;
49 def VFPLdStFrm : Format<22>;
50 def VFPLdStMulFrm : Format<23>;
51 def VFPMiscFrm : Format<24>;
53 def ThumbFrm : Format<25>;
54 def MiscFrm : Format<26>;
56 def NGetLnFrm : Format<27>;
57 def NSetLnFrm : Format<28>;
58 def NDupFrm : Format<29>;
59 def NLdStFrm : Format<30>;
60 def N1RegModImmFrm: Format<31>;
61 def N2RegFrm : Format<32>;
62 def NVCVTFrm : Format<33>;
63 def NVDupLnFrm : Format<34>;
64 def N2RegVShLFrm : Format<35>;
65 def N2RegVShRFrm : Format<36>;
66 def N3RegFrm : Format<37>;
67 def N3RegVShFrm : Format<38>;
68 def NVExtFrm : Format<39>;
69 def NVMulSLFrm : Format<40>;
70 def NVTBLFrm : Format<41>;
74 // The instruction has an Rn register operand.
75 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
76 // it doesn't have a Rn operand.
77 class UnaryDP { bit isUnaryDataProc = 1; }
79 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80 // a 16-bit Thumb instruction if certain conditions are met.
81 class Xform16Bit { bit canXformTo16Bit = 1; }
83 //===----------------------------------------------------------------------===//
84 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
88 class AddrMode<bits<5> val> {
91 def AddrModeNone : AddrMode<0>;
92 def AddrMode1 : AddrMode<1>;
93 def AddrMode2 : AddrMode<2>;
94 def AddrMode3 : AddrMode<3>;
95 def AddrMode4 : AddrMode<4>;
96 def AddrMode5 : AddrMode<5>;
97 def AddrMode6 : AddrMode<6>;
98 def AddrModeT1_1 : AddrMode<7>;
99 def AddrModeT1_2 : AddrMode<8>;
100 def AddrModeT1_4 : AddrMode<9>;
101 def AddrModeT1_s : AddrMode<10>;
102 def AddrModeT2_i12 : AddrMode<11>;
103 def AddrModeT2_i8 : AddrMode<12>;
104 def AddrModeT2_so : AddrMode<13>;
105 def AddrModeT2_pc : AddrMode<14>;
106 def AddrModeT2_i8s4 : AddrMode<15>;
107 def AddrMode_i12 : AddrMode<16>;
110 class SizeFlagVal<bits<3> val> {
113 def SizeInvalid : SizeFlagVal<0>; // Unset.
114 def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
115 def Size8Bytes : SizeFlagVal<2>;
116 def Size4Bytes : SizeFlagVal<3>;
117 def Size2Bytes : SizeFlagVal<4>;
119 // Load / store index mode.
120 class IndexMode<bits<2> val> {
123 def IndexModeNone : IndexMode<0>;
124 def IndexModePre : IndexMode<1>;
125 def IndexModePost : IndexMode<2>;
126 def IndexModeUpd : IndexMode<3>;
128 // Instruction execution domain.
129 class Domain<bits<2> val> {
132 def GenericDomain : Domain<0>;
133 def VFPDomain : Domain<1>; // Instructions in VFP domain only
134 def NeonDomain : Domain<2>; // Instructions in Neon domain only
135 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
137 //===----------------------------------------------------------------------===//
138 // ARM special operands.
141 def CondCodeOperand : AsmOperandClass {
142 let Name = "CondCode";
143 let SuperClasses = [];
146 def CCOutOperand : AsmOperandClass {
148 let SuperClasses = [];
151 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
152 // register whose default is 0 (no register).
153 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
154 (ops (i32 14), (i32 zero_reg))> {
155 let PrintMethod = "printPredicateOperand";
156 let ParserMatchClass = CondCodeOperand;
159 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
160 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
161 let EncoderMethod = "getCCOutOpValue";
162 let PrintMethod = "printSBitModifierOperand";
163 let ParserMatchClass = CCOutOperand;
166 // Same as cc_out except it defaults to setting CPSR.
167 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
168 let EncoderMethod = "getCCOutOpValue";
169 let PrintMethod = "printSBitModifierOperand";
170 let ParserMatchClass = CCOutOperand;
173 // ARM special operands for disassembly only.
175 def setend_op : Operand<i32> {
176 let PrintMethod = "printSetendOperand";
179 def cps_opt : Operand<i32> {
180 let PrintMethod = "printCPSOptionOperand";
183 def msr_mask : Operand<i32> {
184 let PrintMethod = "printMSRMaskOperand";
187 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
188 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
189 def neg_zero : Operand<i32> {
190 let PrintMethod = "printNegZeroOperand";
193 //===----------------------------------------------------------------------===//
194 // ARM Instruction templates.
197 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
198 Format f, Domain d, string cstr, InstrItinClass itin>
200 let Namespace = "ARM";
205 bits<2> IndexModeBits = IM.Value;
207 bits<6> Form = F.Value;
209 bit isUnaryDataProc = 0;
210 bit canXformTo16Bit = 0;
212 // If this is a pseudo instruction, mark it isCodeGenOnly.
213 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
215 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
216 let TSFlags{4-0} = AM.Value;
217 let TSFlags{7-5} = SZ.Value;
218 let TSFlags{9-8} = IndexModeBits;
219 let TSFlags{15-10} = Form;
220 let TSFlags{16} = isUnaryDataProc;
221 let TSFlags{17} = canXformTo16Bit;
222 let TSFlags{19-18} = D.Value;
224 let Constraints = cstr;
225 let Itinerary = itin;
232 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
233 Format f, Domain d, string cstr, InstrItinClass itin>
234 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
236 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
237 // on by adding flavors to specific instructions.
238 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
239 Format f, Domain d, string cstr, InstrItinClass itin>
240 : InstTemplate<am, sz, im, f, d, cstr, itin>;
242 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
243 // FIXME: This really should derive from InstTemplate instead, as pseudos
244 // don't need encoding information. TableGen doesn't like that
245 // currently. Need to figure out why and fix it.
246 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
248 let OutOperandList = oops;
249 let InOperandList = iops;
250 let Pattern = pattern;
253 // PseudoInst that's ARM-mode only.
254 class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
256 : PseudoInst<oops, iops, itin, pattern> {
258 list<Predicate> Predicates = [IsARM];
261 // PseudoInst that's Thumb-mode only.
262 class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
264 : PseudoInst<oops, iops, itin, pattern> {
266 list<Predicate> Predicates = [IsThumb];
269 // Almost all ARM instructions are predicable.
270 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
271 IndexMode im, Format f, InstrItinClass itin,
272 string opc, string asm, string cstr,
274 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
277 let OutOperandList = oops;
278 let InOperandList = !con(iops, (ins pred:$p));
279 let AsmString = !strconcat(opc, "${p}", asm);
280 let Pattern = pattern;
281 list<Predicate> Predicates = [IsARM];
284 // A few are not predicable
285 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
286 IndexMode im, Format f, InstrItinClass itin,
287 string opc, string asm, string cstr,
289 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
290 let OutOperandList = oops;
291 let InOperandList = iops;
292 let AsmString = !strconcat(opc, asm);
293 let Pattern = pattern;
294 let isPredicable = 0;
295 list<Predicate> Predicates = [IsARM];
298 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
299 // operand since by default it's a zero register. It will become an implicit def
300 // once it's "flipped".
301 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
302 IndexMode im, Format f, InstrItinClass itin,
303 string opc, string asm, string cstr,
305 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
306 bits<4> p; // Predicate operand
307 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
311 let OutOperandList = oops;
312 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
313 let AsmString = !strconcat(opc, "${s}${p}", asm);
314 let Pattern = pattern;
315 list<Predicate> Predicates = [IsARM];
319 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
320 IndexMode im, Format f, InstrItinClass itin,
321 string asm, string cstr, list<dag> pattern>
322 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
323 let OutOperandList = oops;
324 let InOperandList = iops;
326 let Pattern = pattern;
327 list<Predicate> Predicates = [IsARM];
330 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
331 string opc, string asm, list<dag> pattern>
332 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
333 opc, asm, "", pattern>;
334 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
335 string opc, string asm, list<dag> pattern>
336 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
337 opc, asm, "", pattern>;
338 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
339 string asm, list<dag> pattern>
340 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
342 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
343 string opc, string asm, list<dag> pattern>
344 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
345 opc, asm, "", pattern>;
347 // Ctrl flow instructions
348 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
349 string opc, string asm, list<dag> pattern>
350 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
351 opc, asm, "", pattern> {
352 let Inst{27-24} = opcod;
354 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
355 string asm, list<dag> pattern>
356 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
358 let Inst{27-24} = opcod;
361 // BR_JT instructions
362 class JTI<dag oops, dag iops, InstrItinClass itin,
363 string asm, list<dag> pattern>
364 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
367 // Atomic load/store instructions
368 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
369 string opc, string asm, list<dag> pattern>
370 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
371 opc, asm, "", pattern> {
374 let Inst{27-23} = 0b00011;
375 let Inst{22-21} = opcod;
377 let Inst{19-16} = Rn;
378 let Inst{15-12} = Rt;
379 let Inst{11-0} = 0b111110011111;
381 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
382 string opc, string asm, list<dag> pattern>
383 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
384 opc, asm, "", pattern> {
388 let Inst{27-23} = 0b00011;
389 let Inst{22-21} = opcod;
391 let Inst{19-16} = Rn;
392 let Inst{15-12} = Rd;
393 let Inst{11-4} = 0b11111001;
396 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
397 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
401 let Inst{27-23} = 0b00010;
403 let Inst{21-20} = 0b00;
404 let Inst{19-16} = Rn;
405 let Inst{15-12} = Rt;
406 let Inst{11-4} = 0b00001001;
410 // addrmode1 instructions
411 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
412 string opc, string asm, list<dag> pattern>
413 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
414 opc, asm, "", pattern> {
415 let Inst{24-21} = opcod;
416 let Inst{27-26} = 0b00;
418 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
419 string opc, string asm, list<dag> pattern>
420 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
421 opc, asm, "", pattern> {
422 let Inst{24-21} = opcod;
423 let Inst{27-26} = 0b00;
425 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
426 string asm, list<dag> pattern>
427 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
429 let Inst{24-21} = opcod;
430 let Inst{27-26} = 0b00;
435 // LDR/LDRB/STR/STRB/...
436 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
437 Format f, InstrItinClass itin, string opc, string asm,
439 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
441 let Inst{27-25} = op;
442 let Inst{24} = 1; // 24 == P
444 let Inst{22} = isByte;
445 let Inst{21} = 0; // 21 == W
448 // Indexed load/stores
449 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
450 IndexMode im, Format f, InstrItinClass itin, string opc,
451 string asm, string cstr, list<dag> pattern>
452 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
453 opc, asm, cstr, pattern> {
455 let Inst{27-26} = 0b01;
456 let Inst{24} = isPre; // P bit
457 let Inst{22} = isByte; // B bit
458 let Inst{21} = isPre; // W bit
459 let Inst{20} = isLd; // L bit
460 let Inst{15-12} = Rt;
462 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
463 IndexMode im, Format f, InstrItinClass itin, string opc,
464 string asm, string cstr, list<dag> pattern>
465 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
467 // AM2 store w/ two operands: (GPR, am2offset)
468 // {13} 1 == Rm, 0 == imm12
473 let Inst{25} = offset{13};
474 let Inst{23} = offset{12};
475 let Inst{19-16} = Rn;
476 let Inst{11-0} = offset{11-0};
479 // addrmode3 instructions
480 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
481 InstrItinClass itin, string opc, string asm, list<dag> pattern>
482 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
483 opc, asm, "", pattern> {
486 let Inst{27-25} = 0b000;
487 let Inst{24} = 1; // P bit
488 let Inst{23} = addr{8}; // U bit
489 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
490 let Inst{21} = 0; // W bit
491 let Inst{20} = op20; // L bit
492 let Inst{19-16} = addr{12-9}; // Rn
493 let Inst{15-12} = Rt; // Rt
494 let Inst{11-8} = addr{7-4}; // imm7_4/zero
496 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
499 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
500 IndexMode im, Format f, InstrItinClass itin, string opc,
501 string asm, string cstr, list<dag> pattern>
502 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
503 opc, asm, cstr, pattern> {
505 let Inst{27-25} = 0b000;
506 let Inst{24} = isPre; // P bit
507 let Inst{21} = isPre; // W bit
508 let Inst{20} = op20; // L bit
509 let Inst{15-12} = Rt; // Rt
512 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
513 IndexMode im, Format f, InstrItinClass itin, string opc,
514 string asm, string cstr, list<dag> pattern>
515 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
517 // AM3 store w/ two operands: (GPR, am3offset)
521 let Inst{27-25} = 0b000;
522 let Inst{23} = offset{8};
523 let Inst{22} = offset{9};
524 let Inst{19-16} = Rn;
525 let Inst{15-12} = Rt; // Rt
526 let Inst{11-8} = offset{7-4}; // imm7_4/zero
528 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
532 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
533 string opc, string asm, list<dag> pattern>
534 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
535 opc, asm, "", pattern> {
538 let Inst{27-25} = 0b000;
539 let Inst{24} = 1; // P bit
540 let Inst{23} = addr{8}; // U bit
541 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
542 let Inst{21} = 0; // W bit
543 let Inst{20} = 0; // L bit
544 let Inst{19-16} = addr{12-9}; // Rn
545 let Inst{15-12} = Rt; // Rt
546 let Inst{11-8} = addr{7-4}; // imm7_4/zero
548 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
551 // Pre-indexed stores
552 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
553 string opc, string asm, string cstr, list<dag> pattern>
554 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
555 opc, asm, cstr, pattern> {
557 let Inst{5} = 1; // H bit
558 let Inst{6} = 0; // S bit
560 let Inst{20} = 0; // L bit
561 let Inst{21} = 1; // W bit
562 let Inst{24} = 1; // P bit
563 let Inst{27-25} = 0b000;
565 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
566 string opc, string asm, string cstr, list<dag> pattern>
567 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
568 opc, asm, cstr, pattern> {
570 let Inst{5} = 1; // H bit
571 let Inst{6} = 1; // S bit
573 let Inst{20} = 0; // L bit
574 let Inst{21} = 1; // W bit
575 let Inst{24} = 1; // P bit
576 let Inst{27-25} = 0b000;
579 // Post-indexed stores
580 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
581 string opc, string asm, string cstr, list<dag> pattern>
582 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
583 opc, asm, cstr,pattern> {
585 let Inst{5} = 1; // H bit
586 let Inst{6} = 0; // S bit
588 let Inst{20} = 0; // L bit
589 let Inst{21} = 0; // W bit
590 let Inst{24} = 0; // P bit
591 let Inst{27-25} = 0b000;
593 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
594 string opc, string asm, string cstr, list<dag> pattern>
595 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
596 opc, asm, cstr, pattern> {
598 let Inst{5} = 1; // H bit
599 let Inst{6} = 1; // S bit
601 let Inst{20} = 0; // L bit
602 let Inst{21} = 0; // W bit
603 let Inst{24} = 0; // P bit
604 let Inst{27-25} = 0b000;
607 // addrmode4 instructions
608 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
609 string asm, string cstr, list<dag> pattern>
610 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
615 let Inst{27-25} = 0b100;
616 let Inst{22} = 0; // S bit
617 let Inst{19-16} = Rn;
618 let Inst{15-0} = regs;
621 // Unsigned multiply, multiply-accumulate instructions.
622 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
623 string opc, string asm, list<dag> pattern>
624 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
625 opc, asm, "", pattern> {
626 let Inst{7-4} = 0b1001;
627 let Inst{20} = 0; // S bit
628 let Inst{27-21} = opcod;
630 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
631 string opc, string asm, list<dag> pattern>
632 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
633 opc, asm, "", pattern> {
634 let Inst{7-4} = 0b1001;
635 let Inst{27-21} = opcod;
638 // Most significant word multiply
639 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
640 InstrItinClass itin, string opc, string asm, list<dag> pattern>
641 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
642 opc, asm, "", pattern> {
646 let Inst{7-4} = opc7_4;
648 let Inst{27-21} = opcod;
649 let Inst{19-16} = Rd;
653 // MSW multiple w/ Ra operand
654 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
655 InstrItinClass itin, string opc, string asm, list<dag> pattern>
656 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
658 let Inst{15-12} = Ra;
661 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
662 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
663 InstrItinClass itin, string opc, string asm, list<dag> pattern>
664 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
665 opc, asm, "", pattern> {
671 let Inst{27-21} = opcod;
672 let Inst{6-5} = bit6_5;
676 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
677 InstrItinClass itin, string opc, string asm, list<dag> pattern>
678 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
680 let Inst{19-16} = Rd;
683 // AMulxyI with Ra operand
684 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
685 InstrItinClass itin, string opc, string asm, list<dag> pattern>
686 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
688 let Inst{15-12} = Ra;
691 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
692 InstrItinClass itin, string opc, string asm, list<dag> pattern>
693 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
696 let Inst{19-16} = RdHi;
697 let Inst{15-12} = RdLo;
700 // Extend instructions.
701 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
702 string opc, string asm, list<dag> pattern>
703 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
704 opc, asm, "", pattern> {
705 // All AExtI instructions have Rd and Rm register operands.
708 let Inst{15-12} = Rd;
710 let Inst{7-4} = 0b0111;
711 let Inst{9-8} = 0b00;
712 let Inst{27-20} = opcod;
715 // Misc Arithmetic instructions.
716 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
717 InstrItinClass itin, string opc, string asm, list<dag> pattern>
718 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
719 opc, asm, "", pattern> {
722 let Inst{27-20} = opcod;
723 let Inst{19-16} = 0b1111;
724 let Inst{15-12} = Rd;
725 let Inst{11-8} = 0b1111;
726 let Inst{7-4} = opc7_4;
731 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
732 string opc, string asm, list<dag> pattern>
733 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
734 opc, asm, "", pattern> {
739 let Inst{27-20} = opcod;
740 let Inst{19-16} = Rn;
741 let Inst{15-12} = Rd;
742 let Inst{11-7} = sh{7-3};
744 let Inst{5-4} = 0b01;
748 //===----------------------------------------------------------------------===//
750 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
751 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
752 list<Predicate> Predicates = [IsARM];
754 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
755 list<Predicate> Predicates = [IsARM, HasV5TE];
757 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
758 list<Predicate> Predicates = [IsARM, HasV6];
761 //===----------------------------------------------------------------------===//
762 // Thumb Instruction Format Definitions.
765 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
766 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
767 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
768 let OutOperandList = oops;
769 let InOperandList = iops;
771 let Pattern = pattern;
772 list<Predicate> Predicates = [IsThumb];
775 // TI - Thumb instruction.
776 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
777 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
779 // Two-address instructions
780 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
782 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
785 // tBL, tBX 32-bit instructions
786 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
787 dag oops, dag iops, InstrItinClass itin, string asm,
789 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
791 let Inst{31-27} = opcod1;
792 let Inst{15-14} = opcod2;
793 let Inst{12} = opcod3;
796 // BR_JT instructions
797 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
799 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
802 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
803 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
804 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
805 let OutOperandList = oops;
806 let InOperandList = iops;
808 let Pattern = pattern;
809 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
812 class T1I<dag oops, dag iops, InstrItinClass itin,
813 string asm, list<dag> pattern>
814 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
815 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
816 string asm, list<dag> pattern>
817 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
819 // Two-address instructions
820 class T1It<dag oops, dag iops, InstrItinClass itin,
821 string asm, string cstr, list<dag> pattern>
822 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
825 // Thumb1 instruction that can either be predicated or set CPSR.
826 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
828 string opc, string asm, string cstr, list<dag> pattern>
829 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
830 let OutOperandList = !con(oops, (outs s_cc_out:$s));
831 let InOperandList = !con(iops, (ins pred:$p));
832 let AsmString = !strconcat(opc, "${s}${p}", asm);
833 let Pattern = pattern;
834 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
837 class T1sI<dag oops, dag iops, InstrItinClass itin,
838 string opc, string asm, list<dag> pattern>
839 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
841 // Two-address instructions
842 class T1sIt<dag oops, dag iops, InstrItinClass itin,
843 string opc, string asm, list<dag> pattern>
844 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
845 "$Rn = $Rdn", pattern>;
847 // Thumb1 instruction that can be predicated.
848 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
850 string opc, string asm, string cstr, list<dag> pattern>
851 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
852 let OutOperandList = oops;
853 let InOperandList = !con(iops, (ins pred:$p));
854 let AsmString = !strconcat(opc, "${p}", asm);
855 let Pattern = pattern;
856 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
859 class T1pI<dag oops, dag iops, InstrItinClass itin,
860 string opc, string asm, list<dag> pattern>
861 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
863 // Two-address instructions
864 class T1pIt<dag oops, dag iops, InstrItinClass itin,
865 string opc, string asm, list<dag> pattern>
866 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
867 "$Rn = $Rdn", pattern>;
869 class T1pIs<dag oops, dag iops,
870 InstrItinClass itin, string opc, string asm, list<dag> pattern>
871 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
873 class Encoding16 : Encoding {
874 let Inst{31-16} = 0x0000;
877 // A6.2 16-bit Thumb instruction encoding
878 class T1Encoding<bits<6> opcode> : Encoding16 {
879 let Inst{15-10} = opcode;
882 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
883 class T1General<bits<5> opcode> : Encoding16 {
884 let Inst{15-14} = 0b00;
885 let Inst{13-9} = opcode;
888 // A6.2.2 Data-processing encoding.
889 class T1DataProcessing<bits<4> opcode> : Encoding16 {
890 let Inst{15-10} = 0b010000;
891 let Inst{9-6} = opcode;
894 // A6.2.3 Special data instructions and branch and exchange encoding.
895 class T1Special<bits<4> opcode> : Encoding16 {
896 let Inst{15-10} = 0b010001;
897 let Inst{9-6} = opcode;
900 // A6.2.4 Load/store single data item encoding.
901 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
902 let Inst{15-12} = opA;
903 let Inst{11-9} = opB;
905 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
907 // Helper classes to encode Thumb1 loads and stores. For immediates, the
908 // following bits are used for "opA" (see A6.2.4):
910 // 0b0110 => Immediate, 4 bytes
911 // 0b1000 => Immediate, 2 bytes
912 // 0b0111 => Immediate, 1 byte
913 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
914 InstrItinClass itin, string opc, string asm,
916 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
917 T1LoadStore<0b0101, opcode> {
920 let Inst{8-6} = addr{5-3}; // Rm
921 let Inst{5-3} = addr{2-0}; // Rn
924 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
925 InstrItinClass itin, string opc, string asm,
927 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
928 T1LoadStore<opA, {opB,?,?}> {
931 let Inst{10-6} = addr{7-3}; // imm5
932 let Inst{5-3} = addr{2-0}; // Rn
936 // A6.2.5 Miscellaneous 16-bit instructions encoding.
937 class T1Misc<bits<7> opcode> : Encoding16 {
938 let Inst{15-12} = 0b1011;
939 let Inst{11-5} = opcode;
942 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
943 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
945 string opc, string asm, string cstr, list<dag> pattern>
946 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
947 let OutOperandList = oops;
948 let InOperandList = !con(iops, (ins pred:$p));
949 let AsmString = !strconcat(opc, "${p}", asm);
950 let Pattern = pattern;
951 list<Predicate> Predicates = [IsThumb2];
954 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
955 // input operand since by default it's a zero register. It will become an
956 // implicit def once it's "flipped".
958 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
960 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
962 string opc, string asm, string cstr, list<dag> pattern>
963 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
964 let OutOperandList = oops;
965 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
966 let AsmString = !strconcat(opc, "${s}${p}", asm);
967 let Pattern = pattern;
968 list<Predicate> Predicates = [IsThumb2];
972 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
974 string asm, string cstr, list<dag> pattern>
975 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
976 let OutOperandList = oops;
977 let InOperandList = iops;
979 let Pattern = pattern;
980 list<Predicate> Predicates = [IsThumb2];
983 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
985 string asm, string cstr, list<dag> pattern>
986 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
987 let OutOperandList = oops;
988 let InOperandList = iops;
990 let Pattern = pattern;
991 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
994 class T2I<dag oops, dag iops, InstrItinClass itin,
995 string opc, string asm, list<dag> pattern>
996 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
997 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
998 string opc, string asm, list<dag> pattern>
999 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
1000 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1001 string opc, string asm, list<dag> pattern>
1002 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1003 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1004 string opc, string asm, list<dag> pattern>
1005 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1006 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1007 string opc, string asm, list<dag> pattern>
1008 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1009 class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
1010 string opc, string asm, list<dag> pattern>
1011 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1013 let Inst{31-27} = 0b11101;
1014 let Inst{26-25} = 0b00;
1016 let Inst{23} = ?; // The U bit.
1019 let Inst{20} = load;
1024 let Inst{15-12} = Rt{3-0};
1025 let Inst{11-8} = Rt2{3-0};
1026 let Inst{19-16} = addr{12-9};
1027 let Inst{23} = addr{8};
1028 let Inst{7-0} = addr{7-0};
1031 class T2sI<dag oops, dag iops, InstrItinClass itin,
1032 string opc, string asm, list<dag> pattern>
1033 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1035 class T2XI<dag oops, dag iops, InstrItinClass itin,
1036 string asm, list<dag> pattern>
1037 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1038 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1039 string asm, list<dag> pattern>
1040 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1042 // Two-address instructions
1043 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1044 string asm, string cstr, list<dag> pattern>
1045 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1047 // T2Iidxldst - Thumb2 indexed load / store instructions.
1048 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1050 AddrMode am, IndexMode im, InstrItinClass itin,
1051 string opc, string asm, string cstr, list<dag> pattern>
1052 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1053 let OutOperandList = oops;
1054 let InOperandList = !con(iops, (ins pred:$p));
1055 let AsmString = !strconcat(opc, "${p}", asm);
1056 let Pattern = pattern;
1057 list<Predicate> Predicates = [IsThumb2];
1058 let Inst{31-27} = 0b11111;
1059 let Inst{26-25} = 0b00;
1060 let Inst{24} = signed;
1062 let Inst{22-21} = opcod;
1063 let Inst{20} = load;
1065 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1066 let Inst{10} = pre; // The P bit.
1067 let Inst{8} = 1; // The W bit.
1070 let Inst{7-0} = addr{7-0};
1071 let Inst{9} = addr{8}; // Sign bit
1075 let Inst{15-12} = Rt{3-0};
1076 let Inst{19-16} = Rn{3-0};
1079 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1080 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1081 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1084 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1085 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1086 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1089 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1090 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1091 list<Predicate> Predicates = [IsThumb2];
1094 //===----------------------------------------------------------------------===//
1096 //===----------------------------------------------------------------------===//
1097 // ARM VFP Instruction templates.
1100 // Almost all VFP instructions are predicable.
1101 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1102 IndexMode im, Format f, InstrItinClass itin,
1103 string opc, string asm, string cstr, list<dag> pattern>
1104 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1106 let Inst{31-28} = p;
1107 let OutOperandList = oops;
1108 let InOperandList = !con(iops, (ins pred:$p));
1109 let AsmString = !strconcat(opc, "${p}", asm);
1110 let Pattern = pattern;
1111 let PostEncoderMethod = "VFPThumb2PostEncoder";
1112 list<Predicate> Predicates = [HasVFP2];
1116 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1117 IndexMode im, Format f, InstrItinClass itin,
1118 string asm, string cstr, list<dag> pattern>
1119 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1121 let Inst{31-28} = p;
1122 let OutOperandList = oops;
1123 let InOperandList = iops;
1124 let AsmString = asm;
1125 let Pattern = pattern;
1126 let PostEncoderMethod = "VFPThumb2PostEncoder";
1127 list<Predicate> Predicates = [HasVFP2];
1130 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1131 string opc, string asm, list<dag> pattern>
1132 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1133 opc, asm, "", pattern> {
1134 let PostEncoderMethod = "VFPThumb2PostEncoder";
1137 // ARM VFP addrmode5 loads and stores
1138 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1139 InstrItinClass itin,
1140 string opc, string asm, list<dag> pattern>
1141 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1142 VFPLdStFrm, itin, opc, asm, "", pattern> {
1143 // Instruction operands.
1147 // Encode instruction operands.
1148 let Inst{23} = addr{8}; // U (add = (U == '1'))
1149 let Inst{22} = Dd{4};
1150 let Inst{19-16} = addr{12-9}; // Rn
1151 let Inst{15-12} = Dd{3-0};
1152 let Inst{7-0} = addr{7-0}; // imm8
1154 // TODO: Mark the instructions with the appropriate subtarget info.
1155 let Inst{27-24} = opcod1;
1156 let Inst{21-20} = opcod2;
1157 let Inst{11-9} = 0b101;
1158 let Inst{8} = 1; // Double precision
1160 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1161 let D = VFPNeonDomain;
1164 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1165 InstrItinClass itin,
1166 string opc, string asm, list<dag> pattern>
1167 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1168 VFPLdStFrm, itin, opc, asm, "", pattern> {
1169 // Instruction operands.
1173 // Encode instruction operands.
1174 let Inst{23} = addr{8}; // U (add = (U == '1'))
1175 let Inst{22} = Sd{0};
1176 let Inst{19-16} = addr{12-9}; // Rn
1177 let Inst{15-12} = Sd{4-1};
1178 let Inst{7-0} = addr{7-0}; // imm8
1180 // TODO: Mark the instructions with the appropriate subtarget info.
1181 let Inst{27-24} = opcod1;
1182 let Inst{21-20} = opcod2;
1183 let Inst{11-9} = 0b101;
1184 let Inst{8} = 0; // Single precision
1187 // VFP Load / store multiple pseudo instructions.
1188 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1190 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1192 let OutOperandList = oops;
1193 let InOperandList = !con(iops, (ins pred:$p));
1194 let Pattern = pattern;
1195 list<Predicate> Predicates = [HasVFP2];
1198 // Load / store multiple
1199 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1200 string asm, string cstr, list<dag> pattern>
1201 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1202 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1203 // Instruction operands.
1207 // Encode instruction operands.
1208 let Inst{19-16} = Rn;
1209 let Inst{22} = regs{12};
1210 let Inst{15-12} = regs{11-8};
1211 let Inst{7-0} = regs{7-0};
1213 // TODO: Mark the instructions with the appropriate subtarget info.
1214 let Inst{27-25} = 0b110;
1215 let Inst{11-9} = 0b101;
1216 let Inst{8} = 1; // Double precision
1218 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1219 let D = VFPNeonDomain;
1222 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1223 string asm, string cstr, list<dag> pattern>
1224 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1225 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1226 // Instruction operands.
1230 // Encode instruction operands.
1231 let Inst{19-16} = Rn;
1232 let Inst{22} = regs{8};
1233 let Inst{15-12} = regs{12-9};
1234 let Inst{7-0} = regs{7-0};
1236 // TODO: Mark the instructions with the appropriate subtarget info.
1237 let Inst{27-25} = 0b110;
1238 let Inst{11-9} = 0b101;
1239 let Inst{8} = 0; // Single precision
1242 // Double precision, unary
1243 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1244 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1245 string asm, list<dag> pattern>
1246 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1247 // Instruction operands.
1251 // Encode instruction operands.
1252 let Inst{3-0} = Dm{3-0};
1253 let Inst{5} = Dm{4};
1254 let Inst{15-12} = Dd{3-0};
1255 let Inst{22} = Dd{4};
1257 let Inst{27-23} = opcod1;
1258 let Inst{21-20} = opcod2;
1259 let Inst{19-16} = opcod3;
1260 let Inst{11-9} = 0b101;
1261 let Inst{8} = 1; // Double precision
1262 let Inst{7-6} = opcod4;
1263 let Inst{4} = opcod5;
1266 // Double precision, binary
1267 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1268 dag iops, InstrItinClass itin, string opc, string asm,
1270 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1271 // Instruction operands.
1276 // Encode instruction operands.
1277 let Inst{3-0} = Dm{3-0};
1278 let Inst{5} = Dm{4};
1279 let Inst{19-16} = Dn{3-0};
1280 let Inst{7} = Dn{4};
1281 let Inst{15-12} = Dd{3-0};
1282 let Inst{22} = Dd{4};
1284 let Inst{27-23} = opcod1;
1285 let Inst{21-20} = opcod2;
1286 let Inst{11-9} = 0b101;
1287 let Inst{8} = 1; // Double precision
1292 // Single precision, unary
1293 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1294 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1295 string asm, list<dag> pattern>
1296 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1297 // Instruction operands.
1301 // Encode instruction operands.
1302 let Inst{3-0} = Sm{4-1};
1303 let Inst{5} = Sm{0};
1304 let Inst{15-12} = Sd{4-1};
1305 let Inst{22} = Sd{0};
1307 let Inst{27-23} = opcod1;
1308 let Inst{21-20} = opcod2;
1309 let Inst{19-16} = opcod3;
1310 let Inst{11-9} = 0b101;
1311 let Inst{8} = 0; // Single precision
1312 let Inst{7-6} = opcod4;
1313 let Inst{4} = opcod5;
1316 // Single precision unary, if no NEON. Same as ASuI except not available if
1318 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1319 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1320 string asm, list<dag> pattern>
1321 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1323 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1326 // Single precision, binary
1327 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1328 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1329 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1330 // Instruction operands.
1335 // Encode instruction operands.
1336 let Inst{3-0} = Sm{4-1};
1337 let Inst{5} = Sm{0};
1338 let Inst{19-16} = Sn{4-1};
1339 let Inst{7} = Sn{0};
1340 let Inst{15-12} = Sd{4-1};
1341 let Inst{22} = Sd{0};
1343 let Inst{27-23} = opcod1;
1344 let Inst{21-20} = opcod2;
1345 let Inst{11-9} = 0b101;
1346 let Inst{8} = 0; // Single precision
1351 // Single precision binary, if no NEON. Same as ASbI except not available if
1353 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1354 dag iops, InstrItinClass itin, string opc, string asm,
1356 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1357 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1359 // Instruction operands.
1364 // Encode instruction operands.
1365 let Inst{3-0} = Sm{4-1};
1366 let Inst{5} = Sm{0};
1367 let Inst{19-16} = Sn{4-1};
1368 let Inst{7} = Sn{0};
1369 let Inst{15-12} = Sd{4-1};
1370 let Inst{22} = Sd{0};
1373 // VFP conversion instructions
1374 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1375 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1377 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1378 let Inst{27-23} = opcod1;
1379 let Inst{21-20} = opcod2;
1380 let Inst{19-16} = opcod3;
1381 let Inst{11-8} = opcod4;
1386 // VFP conversion between floating-point and fixed-point
1387 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1388 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1390 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1391 // size (fixed-point number): sx == 0 ? 16 : 32
1392 let Inst{7} = op5; // sx
1395 // VFP conversion instructions, if no NEON
1396 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1397 dag oops, dag iops, InstrItinClass itin,
1398 string opc, string asm, list<dag> pattern>
1399 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1401 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1404 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1405 InstrItinClass itin,
1406 string opc, string asm, list<dag> pattern>
1407 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1408 let Inst{27-20} = opcod1;
1409 let Inst{11-8} = opcod2;
1413 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1414 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1415 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1417 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1418 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1419 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1421 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1422 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1423 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1425 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1426 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1427 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1429 //===----------------------------------------------------------------------===//
1431 //===----------------------------------------------------------------------===//
1432 // ARM NEON Instruction templates.
1435 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1436 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1438 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1439 let OutOperandList = oops;
1440 let InOperandList = !con(iops, (ins pred:$p));
1441 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1442 let Pattern = pattern;
1443 list<Predicate> Predicates = [HasNEON];
1446 // Same as NeonI except it does not have a "data type" specifier.
1447 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1448 InstrItinClass itin, string opc, string asm, string cstr,
1450 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1451 let OutOperandList = oops;
1452 let InOperandList = !con(iops, (ins pred:$p));
1453 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1454 let Pattern = pattern;
1455 list<Predicate> Predicates = [HasNEON];
1458 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1459 dag oops, dag iops, InstrItinClass itin,
1460 string opc, string dt, string asm, string cstr, list<dag> pattern>
1461 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1463 let Inst{31-24} = 0b11110100;
1464 let Inst{23} = op23;
1465 let Inst{21-20} = op21_20;
1466 let Inst{11-8} = op11_8;
1467 let Inst{7-4} = op7_4;
1469 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1475 let Inst{22} = Vd{4};
1476 let Inst{15-12} = Vd{3-0};
1477 let Inst{19-16} = Rn{3-0};
1478 let Inst{3-0} = Rm{3-0};
1481 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1482 dag oops, dag iops, InstrItinClass itin,
1483 string opc, string dt, string asm, string cstr, list<dag> pattern>
1484 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1485 dt, asm, cstr, pattern> {
1489 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1490 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1492 let OutOperandList = oops;
1493 let InOperandList = !con(iops, (ins pred:$p));
1494 list<Predicate> Predicates = [HasNEON];
1497 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1499 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1501 let OutOperandList = oops;
1502 let InOperandList = !con(iops, (ins pred:$p));
1503 let Pattern = pattern;
1504 list<Predicate> Predicates = [HasNEON];
1507 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1508 string opc, string dt, string asm, string cstr, list<dag> pattern>
1509 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1511 let Inst{31-25} = 0b1111001;
1512 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1515 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1516 string opc, string asm, string cstr, list<dag> pattern>
1517 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1519 let Inst{31-25} = 0b1111001;
1522 // NEON "one register and a modified immediate" format.
1523 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1525 dag oops, dag iops, InstrItinClass itin,
1526 string opc, string dt, string asm, string cstr,
1528 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1529 let Inst{23} = op23;
1530 let Inst{21-19} = op21_19;
1531 let Inst{11-8} = op11_8;
1537 // Instruction operands.
1541 let Inst{15-12} = Vd{3-0};
1542 let Inst{22} = Vd{4};
1543 let Inst{24} = SIMM{7};
1544 let Inst{18-16} = SIMM{6-4};
1545 let Inst{3-0} = SIMM{3-0};
1548 // NEON 2 vector register format.
1549 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1550 bits<5> op11_7, bit op6, bit op4,
1551 dag oops, dag iops, InstrItinClass itin,
1552 string opc, string dt, string asm, string cstr, list<dag> pattern>
1553 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1554 let Inst{24-23} = op24_23;
1555 let Inst{21-20} = op21_20;
1556 let Inst{19-18} = op19_18;
1557 let Inst{17-16} = op17_16;
1558 let Inst{11-7} = op11_7;
1562 // Instruction operands.
1566 let Inst{15-12} = Vd{3-0};
1567 let Inst{22} = Vd{4};
1568 let Inst{3-0} = Vm{3-0};
1569 let Inst{5} = Vm{4};
1572 // Same as N2V except it doesn't have a datatype suffix.
1573 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1574 bits<5> op11_7, bit op6, bit op4,
1575 dag oops, dag iops, InstrItinClass itin,
1576 string opc, string asm, string cstr, list<dag> pattern>
1577 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1578 let Inst{24-23} = op24_23;
1579 let Inst{21-20} = op21_20;
1580 let Inst{19-18} = op19_18;
1581 let Inst{17-16} = op17_16;
1582 let Inst{11-7} = op11_7;
1586 // Instruction operands.
1590 let Inst{15-12} = Vd{3-0};
1591 let Inst{22} = Vd{4};
1592 let Inst{3-0} = Vm{3-0};
1593 let Inst{5} = Vm{4};
1596 // NEON 2 vector register with immediate.
1597 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1598 dag oops, dag iops, Format f, InstrItinClass itin,
1599 string opc, string dt, string asm, string cstr, list<dag> pattern>
1600 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1601 let Inst{24} = op24;
1602 let Inst{23} = op23;
1603 let Inst{11-8} = op11_8;
1608 // Instruction operands.
1613 let Inst{15-12} = Vd{3-0};
1614 let Inst{22} = Vd{4};
1615 let Inst{3-0} = Vm{3-0};
1616 let Inst{5} = Vm{4};
1617 let Inst{21-16} = SIMM{5-0};
1620 // NEON 3 vector register format.
1621 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1622 dag oops, dag iops, Format f, InstrItinClass itin,
1623 string opc, string dt, string asm, string cstr, list<dag> pattern>
1624 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1625 let Inst{24} = op24;
1626 let Inst{23} = op23;
1627 let Inst{21-20} = op21_20;
1628 let Inst{11-8} = op11_8;
1632 // Instruction operands.
1637 let Inst{15-12} = Vd{3-0};
1638 let Inst{22} = Vd{4};
1639 let Inst{19-16} = Vn{3-0};
1640 let Inst{7} = Vn{4};
1641 let Inst{3-0} = Vm{3-0};
1642 let Inst{5} = Vm{4};
1645 // Same as N3V except it doesn't have a data type suffix.
1646 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1648 dag oops, dag iops, Format f, InstrItinClass itin,
1649 string opc, string asm, string cstr, list<dag> pattern>
1650 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1651 let Inst{24} = op24;
1652 let Inst{23} = op23;
1653 let Inst{21-20} = op21_20;
1654 let Inst{11-8} = op11_8;
1658 // Instruction operands.
1663 let Inst{15-12} = Vd{3-0};
1664 let Inst{22} = Vd{4};
1665 let Inst{19-16} = Vn{3-0};
1666 let Inst{7} = Vn{4};
1667 let Inst{3-0} = Vm{3-0};
1668 let Inst{5} = Vm{4};
1671 // NEON VMOVs between scalar and core registers.
1672 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1673 dag oops, dag iops, Format f, InstrItinClass itin,
1674 string opc, string dt, string asm, list<dag> pattern>
1675 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1677 let Inst{27-20} = opcod1;
1678 let Inst{11-8} = opcod2;
1679 let Inst{6-5} = opcod3;
1682 let OutOperandList = oops;
1683 let InOperandList = !con(iops, (ins pred:$p));
1684 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1685 let Pattern = pattern;
1686 list<Predicate> Predicates = [HasNEON];
1688 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1695 let Inst{31-28} = p{3-0};
1697 let Inst{19-16} = V{3-0};
1698 let Inst{15-12} = R{3-0};
1700 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1701 dag oops, dag iops, InstrItinClass itin,
1702 string opc, string dt, string asm, list<dag> pattern>
1703 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1704 opc, dt, asm, pattern>;
1705 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1706 dag oops, dag iops, InstrItinClass itin,
1707 string opc, string dt, string asm, list<dag> pattern>
1708 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1709 opc, dt, asm, pattern>;
1710 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1711 dag oops, dag iops, InstrItinClass itin,
1712 string opc, string dt, string asm, list<dag> pattern>
1713 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1714 opc, dt, asm, pattern>;
1716 // Vector Duplicate Lane (from scalar to all elements)
1717 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1718 InstrItinClass itin, string opc, string dt, string asm,
1720 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1721 let Inst{24-23} = 0b11;
1722 let Inst{21-20} = 0b11;
1723 let Inst{19-16} = op19_16;
1724 let Inst{11-7} = 0b11000;
1732 let Inst{22} = Vd{4};
1733 let Inst{15-12} = Vd{3-0};
1734 let Inst{5} = Vm{4};
1735 let Inst{3-0} = Vm{3-0};
1738 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1739 // for single-precision FP.
1740 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1741 list<Predicate> Predicates = [HasNEON,UseNEONForFP];