1 //===- ARMInstrFormats.td - ARM Instruction Formats ----------*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 // ARM Instruction Format Definitions.
15 // Format specifies the encoding used by the instruction. This is part of the
16 // ad-hoc solution used to emit machine instruction encodings by our machine
18 class Format<bits<6> val> {
22 def Pseudo : Format<0>;
23 def MulFrm : Format<1>;
24 def BrFrm : Format<2>;
25 def BrMiscFrm : Format<3>;
27 def DPFrm : Format<4>;
28 def DPSoRegFrm : Format<5>;
30 def LdFrm : Format<6>;
31 def StFrm : Format<7>;
32 def LdMiscFrm : Format<8>;
33 def StMiscFrm : Format<9>;
34 def LdStMulFrm : Format<10>;
36 def LdStExFrm : Format<11>;
38 def ArithMiscFrm : Format<12>;
39 def SatFrm : Format<13>;
40 def ExtFrm : Format<14>;
42 def VFPUnaryFrm : Format<15>;
43 def VFPBinaryFrm : Format<16>;
44 def VFPConv1Frm : Format<17>;
45 def VFPConv2Frm : Format<18>;
46 def VFPConv3Frm : Format<19>;
47 def VFPConv4Frm : Format<20>;
48 def VFPConv5Frm : Format<21>;
49 def VFPLdStFrm : Format<22>;
50 def VFPLdStMulFrm : Format<23>;
51 def VFPMiscFrm : Format<24>;
53 def ThumbFrm : Format<25>;
54 def MiscFrm : Format<26>;
56 def NGetLnFrm : Format<27>;
57 def NSetLnFrm : Format<28>;
58 def NDupFrm : Format<29>;
59 def NLdStFrm : Format<30>;
60 def N1RegModImmFrm: Format<31>;
61 def N2RegFrm : Format<32>;
62 def NVCVTFrm : Format<33>;
63 def NVDupLnFrm : Format<34>;
64 def N2RegVShLFrm : Format<35>;
65 def N2RegVShRFrm : Format<36>;
66 def N3RegFrm : Format<37>;
67 def N3RegVShFrm : Format<38>;
68 def NVExtFrm : Format<39>;
69 def NVMulSLFrm : Format<40>;
70 def NVTBLFrm : Format<41>;
74 // The instruction has an Rn register operand.
75 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
76 // it doesn't have a Rn operand.
77 class UnaryDP { bit isUnaryDataProc = 1; }
79 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80 // a 16-bit Thumb instruction if certain conditions are met.
81 class Xform16Bit { bit canXformTo16Bit = 1; }
83 //===----------------------------------------------------------------------===//
84 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
87 // FIXME: Once the JIT is MC-ized, these can go away.
89 class AddrMode<bits<5> val> {
92 def AddrModeNone : AddrMode<0>;
93 def AddrMode1 : AddrMode<1>;
94 def AddrMode2 : AddrMode<2>;
95 def AddrMode3 : AddrMode<3>;
96 def AddrMode4 : AddrMode<4>;
97 def AddrMode5 : AddrMode<5>;
98 def AddrMode6 : AddrMode<6>;
99 def AddrModeT1_1 : AddrMode<7>;
100 def AddrModeT1_2 : AddrMode<8>;
101 def AddrModeT1_4 : AddrMode<9>;
102 def AddrModeT1_s : AddrMode<10>;
103 def AddrModeT2_i12 : AddrMode<11>;
104 def AddrModeT2_i8 : AddrMode<12>;
105 def AddrModeT2_so : AddrMode<13>;
106 def AddrModeT2_pc : AddrMode<14>;
107 def AddrModeT2_i8s4 : AddrMode<15>;
108 def AddrMode_i12 : AddrMode<16>;
111 class SizeFlagVal<bits<3> val> {
114 def SizeInvalid : SizeFlagVal<0>; // Unset.
115 def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
116 def Size8Bytes : SizeFlagVal<2>;
117 def Size4Bytes : SizeFlagVal<3>;
118 def Size2Bytes : SizeFlagVal<4>;
120 // Load / store index mode.
121 class IndexMode<bits<2> val> {
124 def IndexModeNone : IndexMode<0>;
125 def IndexModePre : IndexMode<1>;
126 def IndexModePost : IndexMode<2>;
127 def IndexModeUpd : IndexMode<3>;
129 // Instruction execution domain.
130 class Domain<bits<2> val> {
133 def GenericDomain : Domain<0>;
134 def VFPDomain : Domain<1>; // Instructions in VFP domain only
135 def NeonDomain : Domain<2>; // Instructions in Neon domain only
136 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
138 //===----------------------------------------------------------------------===//
139 // ARM special operands.
142 def CondCodeOperand : AsmOperandClass {
143 let Name = "CondCode";
144 let SuperClasses = [];
147 def CCOutOperand : AsmOperandClass {
149 let SuperClasses = [];
152 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
153 // register whose default is 0 (no register).
154 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
155 (ops (i32 14), (i32 zero_reg))> {
156 let PrintMethod = "printPredicateOperand";
157 let ParserMatchClass = CondCodeOperand;
160 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
161 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
162 let EncoderMethod = "getCCOutOpValue";
163 let PrintMethod = "printSBitModifierOperand";
164 let ParserMatchClass = CCOutOperand;
167 // Same as cc_out except it defaults to setting CPSR.
168 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
169 let EncoderMethod = "getCCOutOpValue";
170 let PrintMethod = "printSBitModifierOperand";
171 let ParserMatchClass = CCOutOperand;
174 // ARM special operands for disassembly only.
176 def setend_op : Operand<i32> {
177 let PrintMethod = "printSetendOperand";
180 def cps_opt : Operand<i32> {
181 let PrintMethod = "printCPSOptionOperand";
184 def msr_mask : Operand<i32> {
185 let PrintMethod = "printMSRMaskOperand";
188 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
189 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
190 def neg_zero : Operand<i32> {
191 let PrintMethod = "printNegZeroOperand";
194 //===----------------------------------------------------------------------===//
195 // ARM Instruction templates.
198 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
199 Format f, Domain d, string cstr, InstrItinClass itin>
201 let Namespace = "ARM";
206 bits<2> IndexModeBits = IM.Value;
208 bits<6> Form = F.Value;
210 bit isUnaryDataProc = 0;
211 bit canXformTo16Bit = 0;
213 // If this is a pseudo instruction, mark it isCodeGenOnly.
214 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
216 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
217 let TSFlags{4-0} = AM.Value;
218 let TSFlags{7-5} = SZ.Value;
219 let TSFlags{9-8} = IndexModeBits;
220 let TSFlags{15-10} = Form;
221 let TSFlags{16} = isUnaryDataProc;
222 let TSFlags{17} = canXformTo16Bit;
223 let TSFlags{19-18} = D.Value;
225 let Constraints = cstr;
226 let Itinerary = itin;
233 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
234 Format f, Domain d, string cstr, InstrItinClass itin>
235 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
237 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
238 // on by adding flavors to specific instructions.
239 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
240 Format f, Domain d, string cstr, InstrItinClass itin>
241 : InstTemplate<am, sz, im, f, d, cstr, itin>;
243 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
244 // FIXME: This really should derive from InstTemplate instead, as pseudos
245 // don't need encoding information. TableGen doesn't like that
246 // currently. Need to figure out why and fix it.
247 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
249 let OutOperandList = oops;
250 let InOperandList = iops;
251 let Pattern = pattern;
254 // PseudoInst that's ARM-mode only.
255 class ARMPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
257 : PseudoInst<oops, iops, itin, pattern> {
259 list<Predicate> Predicates = [IsARM];
262 // PseudoInst that's Thumb-mode only.
263 class tPseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
265 : PseudoInst<oops, iops, itin, pattern> {
267 list<Predicate> Predicates = [IsThumb];
270 // PseudoInst that's Thumb2-mode only.
271 class t2PseudoInst<dag oops, dag iops, SizeFlagVal sz, InstrItinClass itin,
273 : PseudoInst<oops, iops, itin, pattern> {
275 list<Predicate> Predicates = [IsThumb2];
277 // Almost all ARM instructions are predicable.
278 class I<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> {
285 let OutOperandList = oops;
286 let InOperandList = !con(iops, (ins pred:$p));
287 let AsmString = !strconcat(opc, "${p}", asm);
288 let Pattern = pattern;
289 list<Predicate> Predicates = [IsARM];
292 // A few are not predicable
293 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
294 IndexMode im, Format f, InstrItinClass itin,
295 string opc, string asm, string cstr,
297 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
298 let OutOperandList = oops;
299 let InOperandList = iops;
300 let AsmString = !strconcat(opc, asm);
301 let Pattern = pattern;
302 let isPredicable = 0;
303 list<Predicate> Predicates = [IsARM];
306 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
307 // operand since by default it's a zero register. It will become an implicit def
308 // once it's "flipped".
309 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
310 IndexMode im, Format f, InstrItinClass itin,
311 string opc, string asm, string cstr,
313 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
314 bits<4> p; // Predicate operand
315 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
319 let OutOperandList = oops;
320 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
321 let AsmString = !strconcat(opc, "${s}${p}", asm);
322 let Pattern = pattern;
323 list<Predicate> Predicates = [IsARM];
327 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
328 IndexMode im, Format f, InstrItinClass itin,
329 string asm, string cstr, list<dag> pattern>
330 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
331 let OutOperandList = oops;
332 let InOperandList = iops;
334 let Pattern = pattern;
335 list<Predicate> Predicates = [IsARM];
338 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
339 string opc, string asm, list<dag> pattern>
340 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
341 opc, asm, "", pattern>;
342 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
343 string opc, string asm, list<dag> pattern>
344 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
345 opc, asm, "", pattern>;
346 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
347 string asm, list<dag> pattern>
348 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
350 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
351 string opc, string asm, list<dag> pattern>
352 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
353 opc, asm, "", pattern>;
355 // Ctrl flow instructions
356 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
357 string opc, string asm, list<dag> pattern>
358 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
359 opc, asm, "", pattern> {
360 let Inst{27-24} = opcod;
362 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
363 string asm, list<dag> pattern>
364 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
366 let Inst{27-24} = opcod;
369 // BR_JT instructions
370 class JTI<dag oops, dag iops, InstrItinClass itin,
371 string asm, list<dag> pattern>
372 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
375 // Atomic load/store instructions
376 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
377 string opc, string asm, list<dag> pattern>
378 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
379 opc, asm, "", pattern> {
382 let Inst{27-23} = 0b00011;
383 let Inst{22-21} = opcod;
385 let Inst{19-16} = Rn;
386 let Inst{15-12} = Rt;
387 let Inst{11-0} = 0b111110011111;
389 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
390 string opc, string asm, list<dag> pattern>
391 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
392 opc, asm, "", pattern> {
396 let Inst{27-23} = 0b00011;
397 let Inst{22-21} = opcod;
399 let Inst{19-16} = Rn;
400 let Inst{15-12} = Rd;
401 let Inst{11-4} = 0b11111001;
404 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
405 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
409 let Inst{27-23} = 0b00010;
411 let Inst{21-20} = 0b00;
412 let Inst{19-16} = Rn;
413 let Inst{15-12} = Rt;
414 let Inst{11-4} = 0b00001001;
418 // addrmode1 instructions
419 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
420 string opc, string asm, list<dag> pattern>
421 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
422 opc, asm, "", pattern> {
423 let Inst{24-21} = opcod;
424 let Inst{27-26} = 0b00;
426 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
427 string opc, string asm, list<dag> pattern>
428 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
429 opc, asm, "", pattern> {
430 let Inst{24-21} = opcod;
431 let Inst{27-26} = 0b00;
433 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
434 string asm, list<dag> pattern>
435 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
437 let Inst{24-21} = opcod;
438 let Inst{27-26} = 0b00;
443 // LDR/LDRB/STR/STRB/...
444 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
445 Format f, InstrItinClass itin, string opc, string asm,
447 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
449 let Inst{27-25} = op;
450 let Inst{24} = 1; // 24 == P
452 let Inst{22} = isByte;
453 let Inst{21} = 0; // 21 == W
456 // Indexed load/stores
457 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
458 IndexMode im, Format f, InstrItinClass itin, string opc,
459 string asm, string cstr, list<dag> pattern>
460 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
461 opc, asm, cstr, pattern> {
463 let Inst{27-26} = 0b01;
464 let Inst{24} = isPre; // P bit
465 let Inst{22} = isByte; // B bit
466 let Inst{21} = isPre; // W bit
467 let Inst{20} = isLd; // L bit
468 let Inst{15-12} = Rt;
470 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
471 IndexMode im, Format f, InstrItinClass itin, string opc,
472 string asm, string cstr, list<dag> pattern>
473 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
475 // AM2 store w/ two operands: (GPR, am2offset)
476 // {13} 1 == Rm, 0 == imm12
481 let Inst{25} = offset{13};
482 let Inst{23} = offset{12};
483 let Inst{19-16} = Rn;
484 let Inst{11-0} = offset{11-0};
487 // addrmode3 instructions
488 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
489 InstrItinClass itin, string opc, string asm, list<dag> pattern>
490 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
491 opc, asm, "", pattern> {
494 let Inst{27-25} = 0b000;
495 let Inst{24} = 1; // P bit
496 let Inst{23} = addr{8}; // U bit
497 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
498 let Inst{21} = 0; // W bit
499 let Inst{20} = op20; // L bit
500 let Inst{19-16} = addr{12-9}; // Rn
501 let Inst{15-12} = Rt; // Rt
502 let Inst{11-8} = addr{7-4}; // imm7_4/zero
504 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
507 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
508 IndexMode im, Format f, InstrItinClass itin, string opc,
509 string asm, string cstr, list<dag> pattern>
510 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
511 opc, asm, cstr, pattern> {
513 let Inst{27-25} = 0b000;
514 let Inst{24} = isPre; // P bit
515 let Inst{21} = isPre; // W bit
516 let Inst{20} = op20; // L bit
517 let Inst{15-12} = Rt; // Rt
520 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
521 IndexMode im, Format f, InstrItinClass itin, string opc,
522 string asm, string cstr, list<dag> pattern>
523 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
525 // AM3 store w/ two operands: (GPR, am3offset)
529 let Inst{27-25} = 0b000;
530 let Inst{23} = offset{8};
531 let Inst{22} = offset{9};
532 let Inst{19-16} = Rn;
533 let Inst{15-12} = Rt; // Rt
534 let Inst{11-8} = offset{7-4}; // imm7_4/zero
536 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
540 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
541 string opc, string asm, list<dag> pattern>
542 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
543 opc, asm, "", pattern> {
546 let Inst{27-25} = 0b000;
547 let Inst{24} = 1; // P bit
548 let Inst{23} = addr{8}; // U bit
549 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
550 let Inst{21} = 0; // W bit
551 let Inst{20} = 0; // L bit
552 let Inst{19-16} = addr{12-9}; // Rn
553 let Inst{15-12} = Rt; // Rt
554 let Inst{11-8} = addr{7-4}; // imm7_4/zero
556 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
559 // Pre-indexed stores
560 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
561 string opc, string asm, string cstr, list<dag> pattern>
562 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
563 opc, asm, cstr, pattern> {
565 let Inst{5} = 1; // H bit
566 let Inst{6} = 0; // S bit
568 let Inst{20} = 0; // L bit
569 let Inst{21} = 1; // W bit
570 let Inst{24} = 1; // P bit
571 let Inst{27-25} = 0b000;
573 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
574 string opc, string asm, string cstr, list<dag> pattern>
575 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
576 opc, asm, cstr, pattern> {
578 let Inst{5} = 1; // H bit
579 let Inst{6} = 1; // S bit
581 let Inst{20} = 0; // L bit
582 let Inst{21} = 1; // W bit
583 let Inst{24} = 1; // P bit
584 let Inst{27-25} = 0b000;
587 // Post-indexed stores
588 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
589 string opc, string asm, string cstr, list<dag> pattern>
590 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
591 opc, asm, cstr,pattern> {
593 let Inst{5} = 1; // H bit
594 let Inst{6} = 0; // S bit
596 let Inst{20} = 0; // L bit
597 let Inst{21} = 0; // W bit
598 let Inst{24} = 0; // P bit
599 let Inst{27-25} = 0b000;
601 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
602 string opc, string asm, string cstr, list<dag> pattern>
603 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
604 opc, asm, cstr, pattern> {
606 let Inst{5} = 1; // H bit
607 let Inst{6} = 1; // S bit
609 let Inst{20} = 0; // L bit
610 let Inst{21} = 0; // W bit
611 let Inst{24} = 0; // P bit
612 let Inst{27-25} = 0b000;
615 // addrmode4 instructions
616 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
617 string asm, string cstr, list<dag> pattern>
618 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
623 let Inst{27-25} = 0b100;
624 let Inst{22} = 0; // S bit
625 let Inst{19-16} = Rn;
626 let Inst{15-0} = regs;
629 // Unsigned multiply, multiply-accumulate instructions.
630 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
631 string opc, string asm, list<dag> pattern>
632 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
633 opc, asm, "", pattern> {
634 let Inst{7-4} = 0b1001;
635 let Inst{20} = 0; // S bit
636 let Inst{27-21} = opcod;
638 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
639 string opc, string asm, list<dag> pattern>
640 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
641 opc, asm, "", pattern> {
642 let Inst{7-4} = 0b1001;
643 let Inst{27-21} = opcod;
646 // Most significant word multiply
647 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
648 InstrItinClass itin, string opc, string asm, list<dag> pattern>
649 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
650 opc, asm, "", pattern> {
654 let Inst{7-4} = opc7_4;
656 let Inst{27-21} = opcod;
657 let Inst{19-16} = Rd;
661 // MSW multiple w/ Ra operand
662 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
663 InstrItinClass itin, string opc, string asm, list<dag> pattern>
664 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
666 let Inst{15-12} = Ra;
669 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
670 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
671 InstrItinClass itin, string opc, string asm, list<dag> pattern>
672 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
673 opc, asm, "", pattern> {
679 let Inst{27-21} = opcod;
680 let Inst{6-5} = bit6_5;
684 class AMulxyI<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> {
688 let Inst{19-16} = Rd;
691 // AMulxyI with Ra operand
692 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
693 InstrItinClass itin, string opc, string asm, list<dag> pattern>
694 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
696 let Inst{15-12} = Ra;
699 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
700 InstrItinClass itin, string opc, string asm, list<dag> pattern>
701 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
704 let Inst{19-16} = RdHi;
705 let Inst{15-12} = RdLo;
708 // Extend instructions.
709 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
710 string opc, string asm, list<dag> pattern>
711 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
712 opc, asm, "", pattern> {
713 // All AExtI instructions have Rd and Rm register operands.
716 let Inst{15-12} = Rd;
718 let Inst{7-4} = 0b0111;
719 let Inst{9-8} = 0b00;
720 let Inst{27-20} = opcod;
723 // Misc Arithmetic instructions.
724 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
725 InstrItinClass itin, string opc, string asm, list<dag> pattern>
726 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
727 opc, asm, "", pattern> {
730 let Inst{27-20} = opcod;
731 let Inst{19-16} = 0b1111;
732 let Inst{15-12} = Rd;
733 let Inst{11-8} = 0b1111;
734 let Inst{7-4} = opc7_4;
739 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
740 string opc, string asm, list<dag> pattern>
741 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
742 opc, asm, "", pattern> {
747 let Inst{27-20} = opcod;
748 let Inst{19-16} = Rn;
749 let Inst{15-12} = Rd;
750 let Inst{11-7} = sh{7-3};
752 let Inst{5-4} = 0b01;
756 //===----------------------------------------------------------------------===//
758 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
759 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
760 list<Predicate> Predicates = [IsARM];
762 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
763 list<Predicate> Predicates = [IsARM, HasV5TE];
765 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
766 list<Predicate> Predicates = [IsARM, HasV6];
769 //===----------------------------------------------------------------------===//
770 // Thumb Instruction Format Definitions.
773 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
774 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
775 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
776 let OutOperandList = oops;
777 let InOperandList = iops;
779 let Pattern = pattern;
780 list<Predicate> Predicates = [IsThumb];
783 // TI - Thumb instruction.
784 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
785 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
787 // Two-address instructions
788 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
790 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
793 // tBL, tBX 32-bit instructions
794 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
795 dag oops, dag iops, InstrItinClass itin, string asm,
797 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
799 let Inst{31-27} = opcod1;
800 let Inst{15-14} = opcod2;
801 let Inst{12} = opcod3;
804 // Move to/from coprocessor instructions
805 class T1Cop<dag oops, dag iops, string asm, list<dag> pattern>
806 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, NoItinerary, asm, "", pattern>,
807 Encoding, Requires<[IsThumb, HasV6]> {
808 let Inst{31-28} = 0b1110;
811 // BR_JT instructions
812 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
814 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
817 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
818 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
819 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
820 let OutOperandList = oops;
821 let InOperandList = iops;
823 let Pattern = pattern;
824 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
827 class T1I<dag oops, dag iops, InstrItinClass itin,
828 string asm, list<dag> pattern>
829 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
830 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
831 string asm, list<dag> pattern>
832 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
834 // Two-address instructions
835 class T1It<dag oops, dag iops, InstrItinClass itin,
836 string asm, string cstr, list<dag> pattern>
837 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
840 // Thumb1 instruction that can either be predicated or set CPSR.
841 class Thumb1sI<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 = !con(oops, (outs s_cc_out:$s));
846 let InOperandList = !con(iops, (ins pred:$p));
847 let AsmString = !strconcat(opc, "${s}${p}", asm);
848 let Pattern = pattern;
849 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
852 class T1sI<dag oops, dag iops, InstrItinClass itin,
853 string opc, string asm, list<dag> pattern>
854 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
856 // Two-address instructions
857 class T1sIt<dag oops, dag iops, InstrItinClass itin,
858 string opc, string asm, list<dag> pattern>
859 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
860 "$Rn = $Rdn", pattern>;
862 // Thumb1 instruction that can be predicated.
863 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
865 string opc, string asm, string cstr, list<dag> pattern>
866 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
867 let OutOperandList = oops;
868 let InOperandList = !con(iops, (ins pred:$p));
869 let AsmString = !strconcat(opc, "${p}", asm);
870 let Pattern = pattern;
871 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
874 class T1pI<dag oops, dag iops, InstrItinClass itin,
875 string opc, string asm, list<dag> pattern>
876 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
878 // Two-address instructions
879 class T1pIt<dag oops, dag iops, InstrItinClass itin,
880 string opc, string asm, list<dag> pattern>
881 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
882 "$Rn = $Rdn", pattern>;
884 class T1pIs<dag oops, dag iops,
885 InstrItinClass itin, string opc, string asm, list<dag> pattern>
886 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
888 class Encoding16 : Encoding {
889 let Inst{31-16} = 0x0000;
892 // A6.2 16-bit Thumb instruction encoding
893 class T1Encoding<bits<6> opcode> : Encoding16 {
894 let Inst{15-10} = opcode;
897 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
898 class T1General<bits<5> opcode> : Encoding16 {
899 let Inst{15-14} = 0b00;
900 let Inst{13-9} = opcode;
903 // A6.2.2 Data-processing encoding.
904 class T1DataProcessing<bits<4> opcode> : Encoding16 {
905 let Inst{15-10} = 0b010000;
906 let Inst{9-6} = opcode;
909 // A6.2.3 Special data instructions and branch and exchange encoding.
910 class T1Special<bits<4> opcode> : Encoding16 {
911 let Inst{15-10} = 0b010001;
912 let Inst{9-6} = opcode;
915 // A6.2.4 Load/store single data item encoding.
916 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
917 let Inst{15-12} = opA;
918 let Inst{11-9} = opB;
920 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
922 // Helper classes to encode Thumb1 loads and stores. For immediates, the
923 // following bits are used for "opA" (see A6.2.4):
925 // 0b0110 => Immediate, 4 bytes
926 // 0b1000 => Immediate, 2 bytes
927 // 0b0111 => Immediate, 1 byte
928 class T1pILdStEncode<bits<3> opcode, dag oops, dag iops, AddrMode am,
929 InstrItinClass itin, string opc, string asm,
931 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
932 T1LoadStore<0b0101, opcode> {
935 let Inst{8-6} = addr{5-3}; // Rm
936 let Inst{5-3} = addr{2-0}; // Rn
939 class T1pILdStEncodeImm<bits<4> opA, bit opB, dag oops, dag iops, AddrMode am,
940 InstrItinClass itin, string opc, string asm,
942 : Thumb1pI<oops, iops, am, Size2Bytes, itin, opc, asm, "", pattern>,
943 T1LoadStore<opA, {opB,?,?}> {
946 let Inst{10-6} = addr{7-3}; // imm5
947 let Inst{5-3} = addr{2-0}; // Rn
951 // A6.2.5 Miscellaneous 16-bit instructions encoding.
952 class T1Misc<bits<7> opcode> : Encoding16 {
953 let Inst{15-12} = 0b1011;
954 let Inst{11-5} = opcode;
957 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
958 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
960 string opc, string asm, string cstr, list<dag> pattern>
961 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
962 let OutOperandList = oops;
963 let InOperandList = !con(iops, (ins pred:$p));
964 let AsmString = !strconcat(opc, "${p}", asm);
965 let Pattern = pattern;
966 list<Predicate> Predicates = [IsThumb2];
969 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
970 // input operand since by default it's a zero register. It will become an
971 // implicit def once it's "flipped".
973 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
975 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
977 string opc, string asm, string cstr, list<dag> pattern>
978 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
979 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
982 let OutOperandList = oops;
983 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
984 let AsmString = !strconcat(opc, "${s}${p}", asm);
985 let Pattern = pattern;
986 list<Predicate> Predicates = [IsThumb2];
990 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
992 string asm, string cstr, list<dag> pattern>
993 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
994 let OutOperandList = oops;
995 let InOperandList = iops;
997 let Pattern = pattern;
998 list<Predicate> Predicates = [IsThumb2];
1001 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1002 InstrItinClass itin,
1003 string asm, string cstr, list<dag> pattern>
1004 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
1005 let OutOperandList = oops;
1006 let InOperandList = iops;
1007 let AsmString = asm;
1008 let Pattern = pattern;
1009 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1012 class T2I<dag oops, dag iops, InstrItinClass itin,
1013 string opc, string asm, list<dag> pattern>
1014 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1015 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
1016 string opc, string asm, list<dag> pattern>
1017 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
1018 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
1019 string opc, string asm, list<dag> pattern>
1020 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
1021 class T2Iso<dag oops, dag iops, InstrItinClass itin,
1022 string opc, string asm, list<dag> pattern>
1023 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
1024 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
1025 string opc, string asm, list<dag> pattern>
1026 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
1027 class T2Ii8s4<bit P, bit W, bit isLoad, dag oops, dag iops, InstrItinClass itin,
1028 string opc, string asm, list<dag> pattern>
1029 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1034 let Inst{31-25} = 0b1110100;
1036 let Inst{23} = addr{8};
1039 let Inst{20} = isLoad;
1040 let Inst{19-16} = addr{12-9};
1041 let Inst{15-12} = Rt{3-0};
1042 let Inst{11-8} = Rt2{3-0};
1043 let Inst{7-0} = addr{7-0};
1046 class T2sI<dag oops, dag iops, InstrItinClass itin,
1047 string opc, string asm, list<dag> pattern>
1048 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1050 class T2XI<dag oops, dag iops, InstrItinClass itin,
1051 string asm, list<dag> pattern>
1052 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1053 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1054 string asm, list<dag> pattern>
1055 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1057 // Move to/from coprocessor instructions
1058 class T2Cop<dag oops, dag iops, string asm, list<dag> pattern>
1059 : T2XI<oops, iops, NoItinerary, asm, pattern>, Requires<[IsThumb2, HasV6]> {
1060 let Inst{31-28} = 0b1111;
1063 // Two-address instructions
1064 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1065 string asm, string cstr, list<dag> pattern>
1066 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1068 // T2Iidxldst - Thumb2 indexed load / store instructions.
1069 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1071 AddrMode am, IndexMode im, InstrItinClass itin,
1072 string opc, string asm, string cstr, list<dag> pattern>
1073 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1074 let OutOperandList = oops;
1075 let InOperandList = !con(iops, (ins pred:$p));
1076 let AsmString = !strconcat(opc, "${p}", asm);
1077 let Pattern = pattern;
1078 list<Predicate> Predicates = [IsThumb2];
1079 let Inst{31-27} = 0b11111;
1080 let Inst{26-25} = 0b00;
1081 let Inst{24} = signed;
1083 let Inst{22-21} = opcod;
1084 let Inst{20} = load;
1086 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1087 let Inst{10} = pre; // The P bit.
1088 let Inst{8} = 1; // The W bit.
1091 let Inst{7-0} = addr{7-0};
1092 let Inst{9} = addr{8}; // Sign bit
1096 let Inst{15-12} = Rt{3-0};
1097 let Inst{19-16} = Rn{3-0};
1100 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1101 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1102 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1105 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1106 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1107 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1110 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1111 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1112 list<Predicate> Predicates = [IsThumb2];
1115 //===----------------------------------------------------------------------===//
1117 //===----------------------------------------------------------------------===//
1118 // ARM VFP Instruction templates.
1121 // Almost all VFP instructions are predicable.
1122 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1123 IndexMode im, Format f, InstrItinClass itin,
1124 string opc, string asm, string cstr, list<dag> pattern>
1125 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1127 let Inst{31-28} = p;
1128 let OutOperandList = oops;
1129 let InOperandList = !con(iops, (ins pred:$p));
1130 let AsmString = !strconcat(opc, "${p}", asm);
1131 let Pattern = pattern;
1132 let PostEncoderMethod = "VFPThumb2PostEncoder";
1133 list<Predicate> Predicates = [HasVFP2];
1137 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1138 IndexMode im, Format f, InstrItinClass itin,
1139 string asm, string cstr, list<dag> pattern>
1140 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1142 let Inst{31-28} = p;
1143 let OutOperandList = oops;
1144 let InOperandList = iops;
1145 let AsmString = asm;
1146 let Pattern = pattern;
1147 let PostEncoderMethod = "VFPThumb2PostEncoder";
1148 list<Predicate> Predicates = [HasVFP2];
1151 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1152 string opc, string asm, list<dag> pattern>
1153 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1154 opc, asm, "", pattern> {
1155 let PostEncoderMethod = "VFPThumb2PostEncoder";
1158 // ARM VFP addrmode5 loads and stores
1159 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1160 InstrItinClass itin,
1161 string opc, string asm, list<dag> pattern>
1162 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1163 VFPLdStFrm, itin, opc, asm, "", pattern> {
1164 // Instruction operands.
1168 // Encode instruction operands.
1169 let Inst{23} = addr{8}; // U (add = (U == '1'))
1170 let Inst{22} = Dd{4};
1171 let Inst{19-16} = addr{12-9}; // Rn
1172 let Inst{15-12} = Dd{3-0};
1173 let Inst{7-0} = addr{7-0}; // imm8
1175 // TODO: Mark the instructions with the appropriate subtarget info.
1176 let Inst{27-24} = opcod1;
1177 let Inst{21-20} = opcod2;
1178 let Inst{11-9} = 0b101;
1179 let Inst{8} = 1; // Double precision
1181 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1182 let D = VFPNeonDomain;
1185 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1186 InstrItinClass itin,
1187 string opc, string asm, list<dag> pattern>
1188 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1189 VFPLdStFrm, itin, opc, asm, "", pattern> {
1190 // Instruction operands.
1194 // Encode instruction operands.
1195 let Inst{23} = addr{8}; // U (add = (U == '1'))
1196 let Inst{22} = Sd{0};
1197 let Inst{19-16} = addr{12-9}; // Rn
1198 let Inst{15-12} = Sd{4-1};
1199 let Inst{7-0} = addr{7-0}; // imm8
1201 // TODO: Mark the instructions with the appropriate subtarget info.
1202 let Inst{27-24} = opcod1;
1203 let Inst{21-20} = opcod2;
1204 let Inst{11-9} = 0b101;
1205 let Inst{8} = 0; // Single precision
1208 // VFP Load / store multiple pseudo instructions.
1209 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1211 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1213 let OutOperandList = oops;
1214 let InOperandList = !con(iops, (ins pred:$p));
1215 let Pattern = pattern;
1216 list<Predicate> Predicates = [HasVFP2];
1219 // Load / store multiple
1220 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1221 string asm, string cstr, list<dag> pattern>
1222 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1223 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1224 // Instruction operands.
1228 // Encode instruction operands.
1229 let Inst{19-16} = Rn;
1230 let Inst{22} = regs{12};
1231 let Inst{15-12} = regs{11-8};
1232 let Inst{7-0} = regs{7-0};
1234 // TODO: Mark the instructions with the appropriate subtarget info.
1235 let Inst{27-25} = 0b110;
1236 let Inst{11-9} = 0b101;
1237 let Inst{8} = 1; // Double precision
1239 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1240 let D = VFPNeonDomain;
1243 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1244 string asm, string cstr, list<dag> pattern>
1245 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1246 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1247 // Instruction operands.
1251 // Encode instruction operands.
1252 let Inst{19-16} = Rn;
1253 let Inst{22} = regs{8};
1254 let Inst{15-12} = regs{12-9};
1255 let Inst{7-0} = regs{7-0};
1257 // TODO: Mark the instructions with the appropriate subtarget info.
1258 let Inst{27-25} = 0b110;
1259 let Inst{11-9} = 0b101;
1260 let Inst{8} = 0; // Single precision
1263 // Double precision, unary
1264 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1265 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1266 string asm, list<dag> pattern>
1267 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1268 // Instruction operands.
1272 // Encode instruction operands.
1273 let Inst{3-0} = Dm{3-0};
1274 let Inst{5} = Dm{4};
1275 let Inst{15-12} = Dd{3-0};
1276 let Inst{22} = Dd{4};
1278 let Inst{27-23} = opcod1;
1279 let Inst{21-20} = opcod2;
1280 let Inst{19-16} = opcod3;
1281 let Inst{11-9} = 0b101;
1282 let Inst{8} = 1; // Double precision
1283 let Inst{7-6} = opcod4;
1284 let Inst{4} = opcod5;
1287 // Double precision, binary
1288 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1289 dag iops, InstrItinClass itin, string opc, string asm,
1291 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1292 // Instruction operands.
1297 // Encode instruction operands.
1298 let Inst{3-0} = Dm{3-0};
1299 let Inst{5} = Dm{4};
1300 let Inst{19-16} = Dn{3-0};
1301 let Inst{7} = Dn{4};
1302 let Inst{15-12} = Dd{3-0};
1303 let Inst{22} = Dd{4};
1305 let Inst{27-23} = opcod1;
1306 let Inst{21-20} = opcod2;
1307 let Inst{11-9} = 0b101;
1308 let Inst{8} = 1; // Double precision
1313 // Single precision, unary
1314 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1315 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1316 string asm, list<dag> pattern>
1317 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1318 // Instruction operands.
1322 // Encode instruction operands.
1323 let Inst{3-0} = Sm{4-1};
1324 let Inst{5} = Sm{0};
1325 let Inst{15-12} = Sd{4-1};
1326 let Inst{22} = Sd{0};
1328 let Inst{27-23} = opcod1;
1329 let Inst{21-20} = opcod2;
1330 let Inst{19-16} = opcod3;
1331 let Inst{11-9} = 0b101;
1332 let Inst{8} = 0; // Single precision
1333 let Inst{7-6} = opcod4;
1334 let Inst{4} = opcod5;
1337 // Single precision unary, if no NEON. Same as ASuI except not available if
1339 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1340 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1341 string asm, list<dag> pattern>
1342 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1344 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1347 // Single precision, binary
1348 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1349 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1350 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1351 // Instruction operands.
1356 // Encode instruction operands.
1357 let Inst{3-0} = Sm{4-1};
1358 let Inst{5} = Sm{0};
1359 let Inst{19-16} = Sn{4-1};
1360 let Inst{7} = Sn{0};
1361 let Inst{15-12} = Sd{4-1};
1362 let Inst{22} = Sd{0};
1364 let Inst{27-23} = opcod1;
1365 let Inst{21-20} = opcod2;
1366 let Inst{11-9} = 0b101;
1367 let Inst{8} = 0; // Single precision
1372 // Single precision binary, if no NEON. Same as ASbI except not available if
1374 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1375 dag iops, InstrItinClass itin, string opc, string asm,
1377 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1378 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1380 // Instruction operands.
1385 // Encode instruction operands.
1386 let Inst{3-0} = Sm{4-1};
1387 let Inst{5} = Sm{0};
1388 let Inst{19-16} = Sn{4-1};
1389 let Inst{7} = Sn{0};
1390 let Inst{15-12} = Sd{4-1};
1391 let Inst{22} = Sd{0};
1394 // VFP conversion instructions
1395 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1396 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1398 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1399 let Inst{27-23} = opcod1;
1400 let Inst{21-20} = opcod2;
1401 let Inst{19-16} = opcod3;
1402 let Inst{11-8} = opcod4;
1407 // VFP conversion between floating-point and fixed-point
1408 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1409 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1411 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1412 // size (fixed-point number): sx == 0 ? 16 : 32
1413 let Inst{7} = op5; // sx
1416 // VFP conversion instructions, if no NEON
1417 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1418 dag oops, dag iops, InstrItinClass itin,
1419 string opc, string asm, list<dag> pattern>
1420 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1422 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1425 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1426 InstrItinClass itin,
1427 string opc, string asm, list<dag> pattern>
1428 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1429 let Inst{27-20} = opcod1;
1430 let Inst{11-8} = opcod2;
1434 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1435 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1436 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1438 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1439 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1440 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1442 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1443 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1444 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1446 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1447 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1448 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1450 //===----------------------------------------------------------------------===//
1452 //===----------------------------------------------------------------------===//
1453 // ARM NEON Instruction templates.
1456 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1457 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1459 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1460 let OutOperandList = oops;
1461 let InOperandList = !con(iops, (ins pred:$p));
1462 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1463 let Pattern = pattern;
1464 list<Predicate> Predicates = [HasNEON];
1467 // Same as NeonI except it does not have a "data type" specifier.
1468 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1469 InstrItinClass itin, string opc, string asm, string cstr,
1471 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1472 let OutOperandList = oops;
1473 let InOperandList = !con(iops, (ins pred:$p));
1474 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1475 let Pattern = pattern;
1476 list<Predicate> Predicates = [HasNEON];
1479 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1480 dag oops, dag iops, InstrItinClass itin,
1481 string opc, string dt, string asm, string cstr, list<dag> pattern>
1482 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1484 let Inst{31-24} = 0b11110100;
1485 let Inst{23} = op23;
1486 let Inst{21-20} = op21_20;
1487 let Inst{11-8} = op11_8;
1488 let Inst{7-4} = op7_4;
1490 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1496 let Inst{22} = Vd{4};
1497 let Inst{15-12} = Vd{3-0};
1498 let Inst{19-16} = Rn{3-0};
1499 let Inst{3-0} = Rm{3-0};
1502 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1503 dag oops, dag iops, InstrItinClass itin,
1504 string opc, string dt, string asm, string cstr, list<dag> pattern>
1505 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1506 dt, asm, cstr, pattern> {
1510 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1511 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1513 let OutOperandList = oops;
1514 let InOperandList = !con(iops, (ins pred:$p));
1515 list<Predicate> Predicates = [HasNEON];
1518 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1520 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1522 let OutOperandList = oops;
1523 let InOperandList = !con(iops, (ins pred:$p));
1524 let Pattern = pattern;
1525 list<Predicate> Predicates = [HasNEON];
1528 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1529 string opc, string dt, string asm, string cstr, list<dag> pattern>
1530 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1532 let Inst{31-25} = 0b1111001;
1533 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1536 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1537 string opc, string asm, string cstr, list<dag> pattern>
1538 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1540 let Inst{31-25} = 0b1111001;
1541 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1544 // NEON "one register and a modified immediate" format.
1545 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1547 dag oops, dag iops, InstrItinClass itin,
1548 string opc, string dt, string asm, string cstr,
1550 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1551 let Inst{23} = op23;
1552 let Inst{21-19} = op21_19;
1553 let Inst{11-8} = op11_8;
1559 // Instruction operands.
1563 let Inst{15-12} = Vd{3-0};
1564 let Inst{22} = Vd{4};
1565 let Inst{24} = SIMM{7};
1566 let Inst{18-16} = SIMM{6-4};
1567 let Inst{3-0} = SIMM{3-0};
1570 // NEON 2 vector register format.
1571 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1572 bits<5> op11_7, bit op6, bit op4,
1573 dag oops, dag iops, InstrItinClass itin,
1574 string opc, string dt, string asm, string cstr, list<dag> pattern>
1575 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1576 let Inst{24-23} = op24_23;
1577 let Inst{21-20} = op21_20;
1578 let Inst{19-18} = op19_18;
1579 let Inst{17-16} = op17_16;
1580 let Inst{11-7} = op11_7;
1584 // Instruction operands.
1588 let Inst{15-12} = Vd{3-0};
1589 let Inst{22} = Vd{4};
1590 let Inst{3-0} = Vm{3-0};
1591 let Inst{5} = Vm{4};
1594 // Same as N2V except it doesn't have a datatype suffix.
1595 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1596 bits<5> op11_7, bit op6, bit op4,
1597 dag oops, dag iops, InstrItinClass itin,
1598 string opc, string asm, string cstr, list<dag> pattern>
1599 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1600 let Inst{24-23} = op24_23;
1601 let Inst{21-20} = op21_20;
1602 let Inst{19-18} = op19_18;
1603 let Inst{17-16} = op17_16;
1604 let Inst{11-7} = op11_7;
1608 // Instruction operands.
1612 let Inst{15-12} = Vd{3-0};
1613 let Inst{22} = Vd{4};
1614 let Inst{3-0} = Vm{3-0};
1615 let Inst{5} = Vm{4};
1618 // NEON 2 vector register with immediate.
1619 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1620 dag oops, dag iops, Format f, InstrItinClass itin,
1621 string opc, string dt, string asm, string cstr, list<dag> pattern>
1622 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1623 let Inst{24} = op24;
1624 let Inst{23} = op23;
1625 let Inst{11-8} = op11_8;
1630 // Instruction operands.
1635 let Inst{15-12} = Vd{3-0};
1636 let Inst{22} = Vd{4};
1637 let Inst{3-0} = Vm{3-0};
1638 let Inst{5} = Vm{4};
1639 let Inst{21-16} = SIMM{5-0};
1642 // NEON 3 vector register format.
1643 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1644 dag oops, dag iops, Format f, InstrItinClass itin,
1645 string opc, string dt, string asm, string cstr, list<dag> pattern>
1646 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1647 let Inst{24} = op24;
1648 let Inst{23} = op23;
1649 let Inst{21-20} = op21_20;
1650 let Inst{11-8} = op11_8;
1654 // Instruction operands.
1659 let Inst{15-12} = Vd{3-0};
1660 let Inst{22} = Vd{4};
1661 let Inst{19-16} = Vn{3-0};
1662 let Inst{7} = Vn{4};
1663 let Inst{3-0} = Vm{3-0};
1664 let Inst{5} = Vm{4};
1667 // Same as N3V except it doesn't have a data type suffix.
1668 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1670 dag oops, dag iops, Format f, InstrItinClass itin,
1671 string opc, string asm, string cstr, list<dag> pattern>
1672 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1673 let Inst{24} = op24;
1674 let Inst{23} = op23;
1675 let Inst{21-20} = op21_20;
1676 let Inst{11-8} = op11_8;
1680 // Instruction operands.
1685 let Inst{15-12} = Vd{3-0};
1686 let Inst{22} = Vd{4};
1687 let Inst{19-16} = Vn{3-0};
1688 let Inst{7} = Vn{4};
1689 let Inst{3-0} = Vm{3-0};
1690 let Inst{5} = Vm{4};
1693 // NEON VMOVs between scalar and core registers.
1694 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1695 dag oops, dag iops, Format f, InstrItinClass itin,
1696 string opc, string dt, string asm, list<dag> pattern>
1697 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1699 let Inst{27-20} = opcod1;
1700 let Inst{11-8} = opcod2;
1701 let Inst{6-5} = opcod3;
1704 let OutOperandList = oops;
1705 let InOperandList = !con(iops, (ins pred:$p));
1706 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1707 let Pattern = pattern;
1708 list<Predicate> Predicates = [HasNEON];
1710 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1717 let Inst{31-28} = p{3-0};
1719 let Inst{19-16} = V{3-0};
1720 let Inst{15-12} = R{3-0};
1722 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1723 dag oops, dag iops, InstrItinClass itin,
1724 string opc, string dt, string asm, list<dag> pattern>
1725 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1726 opc, dt, asm, pattern>;
1727 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1728 dag oops, dag iops, InstrItinClass itin,
1729 string opc, string dt, string asm, list<dag> pattern>
1730 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1731 opc, dt, asm, pattern>;
1732 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1733 dag oops, dag iops, InstrItinClass itin,
1734 string opc, string dt, string asm, list<dag> pattern>
1735 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1736 opc, dt, asm, pattern>;
1738 // Vector Duplicate Lane (from scalar to all elements)
1739 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1740 InstrItinClass itin, string opc, string dt, string asm,
1742 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1743 let Inst{24-23} = 0b11;
1744 let Inst{21-20} = 0b11;
1745 let Inst{19-16} = op19_16;
1746 let Inst{11-7} = 0b11000;
1754 let Inst{22} = Vd{4};
1755 let Inst{15-12} = Vd{3-0};
1756 let Inst{5} = Vm{4};
1757 let Inst{3-0} = Vm{3-0};
1760 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1761 // for single-precision FP.
1762 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1763 list<Predicate> Predicates = [HasNEON,UseNEONForFP];