1 //===- ARMInstrFormats.td - ARM Instruction Formats --*- tablegen -*---------=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 // ARM Instruction Format Definitions.
15 // Format specifies the encoding used by the instruction. This is part of the
16 // ad-hoc solution used to emit machine instruction encodings by our machine
18 class Format<bits<6> val> {
22 def Pseudo : Format<0>;
23 def MulFrm : Format<1>;
24 def BrFrm : Format<2>;
25 def BrMiscFrm : Format<3>;
27 def DPFrm : Format<4>;
28 def DPSoRegFrm : Format<5>;
30 def LdFrm : Format<6>;
31 def StFrm : Format<7>;
32 def LdMiscFrm : Format<8>;
33 def StMiscFrm : Format<9>;
34 def LdStMulFrm : Format<10>;
36 def LdStExFrm : Format<11>;
38 def ArithMiscFrm : Format<12>;
39 def SatFrm : Format<13>;
40 def ExtFrm : Format<14>;
42 def VFPUnaryFrm : Format<15>;
43 def VFPBinaryFrm : Format<16>;
44 def VFPConv1Frm : Format<17>;
45 def VFPConv2Frm : Format<18>;
46 def VFPConv3Frm : Format<19>;
47 def VFPConv4Frm : Format<20>;
48 def VFPConv5Frm : Format<21>;
49 def VFPLdStFrm : Format<22>;
50 def VFPLdStMulFrm : Format<23>;
51 def VFPMiscFrm : Format<24>;
53 def ThumbFrm : Format<25>;
54 def MiscFrm : Format<26>;
56 def NGetLnFrm : Format<27>;
57 def NSetLnFrm : Format<28>;
58 def NDupFrm : Format<29>;
59 def NLdStFrm : Format<30>;
60 def N1RegModImmFrm: Format<31>;
61 def N2RegFrm : Format<32>;
62 def NVCVTFrm : Format<33>;
63 def NVDupLnFrm : Format<34>;
64 def N2RegVShLFrm : Format<35>;
65 def N2RegVShRFrm : Format<36>;
66 def N3RegFrm : Format<37>;
67 def N3RegVShFrm : Format<38>;
68 def NVExtFrm : Format<39>;
69 def NVMulSLFrm : Format<40>;
70 def NVTBLFrm : Format<41>;
74 // the instruction has a Rn register operand.
75 // UnaryDP - Indicates this is a unary data processing instruction, i.e.
76 // it doesn't have a Rn operand.
77 class UnaryDP { bit isUnaryDataProc = 1; }
79 // Xform16Bit - Indicates this Thumb2 instruction may be transformed into
80 // a 16-bit Thumb instruction if certain conditions are met.
81 class Xform16Bit { bit canXformTo16Bit = 1; }
83 //===----------------------------------------------------------------------===//
84 // ARM Instruction flags. These need to match ARMBaseInstrInfo.h.
88 class AddrMode<bits<5> val> {
91 def AddrModeNone : AddrMode<0>;
92 def AddrMode1 : AddrMode<1>;
93 def AddrMode2 : AddrMode<2>;
94 def AddrMode3 : AddrMode<3>;
95 def AddrMode4 : AddrMode<4>;
96 def AddrMode5 : AddrMode<5>;
97 def AddrMode6 : AddrMode<6>;
98 def AddrModeT1_1 : AddrMode<7>;
99 def AddrModeT1_2 : AddrMode<8>;
100 def AddrModeT1_4 : AddrMode<9>;
101 def AddrModeT1_s : AddrMode<10>;
102 def AddrModeT2_i12 : AddrMode<11>;
103 def AddrModeT2_i8 : AddrMode<12>;
104 def AddrModeT2_so : AddrMode<13>;
105 def AddrModeT2_pc : AddrMode<14>;
106 def AddrModeT2_i8s4 : AddrMode<15>;
107 def AddrMode_i12 : AddrMode<16>;
110 class SizeFlagVal<bits<3> val> {
113 def SizeInvalid : SizeFlagVal<0>; // Unset.
114 def SizeSpecial : SizeFlagVal<1>; // Pseudo or special.
115 def Size8Bytes : SizeFlagVal<2>;
116 def Size4Bytes : SizeFlagVal<3>;
117 def Size2Bytes : SizeFlagVal<4>;
119 // Load / store index mode.
120 class IndexMode<bits<2> val> {
123 def IndexModeNone : IndexMode<0>;
124 def IndexModePre : IndexMode<1>;
125 def IndexModePost : IndexMode<2>;
126 def IndexModeUpd : IndexMode<3>;
128 // Instruction execution domain.
129 class Domain<bits<2> val> {
132 def GenericDomain : Domain<0>;
133 def VFPDomain : Domain<1>; // Instructions in VFP domain only
134 def NeonDomain : Domain<2>; // Instructions in Neon domain only
135 def VFPNeonDomain : Domain<3>; // Instructions in both VFP & Neon domains
137 //===----------------------------------------------------------------------===//
139 // ARM special operands.
142 def CondCodeOperand : AsmOperandClass {
143 let Name = "CondCode";
144 let SuperClasses = [];
147 // ARM Predicate operand. Default to 14 = always (AL). Second part is CC
148 // register whose default is 0 (no register).
149 def pred : PredicateOperand<OtherVT, (ops i32imm, CCR),
150 (ops (i32 14), (i32 zero_reg))> {
151 let PrintMethod = "printPredicateOperand";
152 let ParserMatchClass = CondCodeOperand;
155 // Conditional code result for instructions whose 's' bit is set, e.g. subs.
156 def cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 zero_reg))> {
157 let EncoderMethod = "getCCOutOpValue";
158 let PrintMethod = "printSBitModifierOperand";
161 // Same as cc_out except it defaults to setting CPSR.
162 def s_cc_out : OptionalDefOperand<OtherVT, (ops CCR), (ops (i32 CPSR))> {
163 let EncoderMethod = "getCCOutOpValue";
164 let PrintMethod = "printSBitModifierOperand";
167 // ARM special operands for disassembly only.
169 def setend_op : Operand<i32> {
170 let PrintMethod = "printSetendOperand";
173 def cps_opt : Operand<i32> {
174 let PrintMethod = "printCPSOptionOperand";
177 def msr_mask : Operand<i32> {
178 let PrintMethod = "printMSRMaskOperand";
181 // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0.
182 // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc.
183 def neg_zero : Operand<i32> {
184 let PrintMethod = "printNegZeroOperand";
187 //===----------------------------------------------------------------------===//
189 // ARM Instruction templates.
192 class InstTemplate<AddrMode am, SizeFlagVal sz, IndexMode im,
193 Format f, Domain d, string cstr, InstrItinClass itin>
195 let Namespace = "ARM";
200 bits<2> IndexModeBits = IM.Value;
202 bits<6> Form = F.Value;
204 bit isUnaryDataProc = 0;
205 bit canXformTo16Bit = 0;
207 // If this is a pseudo instruction, mark it isCodeGenOnly.
208 let isCodeGenOnly = !eq(!cast<string>(f), "Pseudo");
210 // The layout of TSFlags should be kept in sync with ARMBaseInstrInfo.h.
211 let TSFlags{4-0} = AM.Value;
212 let TSFlags{7-5} = SZ.Value;
213 let TSFlags{9-8} = IndexModeBits;
214 let TSFlags{15-10} = Form;
215 let TSFlags{16} = isUnaryDataProc;
216 let TSFlags{17} = canXformTo16Bit;
217 let TSFlags{19-18} = D.Value;
219 let Constraints = cstr;
220 let Itinerary = itin;
227 class InstARM<AddrMode am, SizeFlagVal sz, IndexMode im,
228 Format f, Domain d, string cstr, InstrItinClass itin>
229 : InstTemplate<am, sz, im, f, d, cstr, itin>, Encoding;
231 // This Encoding-less class is used by Thumb1 to specify the encoding bits later
232 // on by adding flavors to specific instructions.
233 class InstThumb<AddrMode am, SizeFlagVal sz, IndexMode im,
234 Format f, Domain d, string cstr, InstrItinClass itin>
235 : InstTemplate<am, sz, im, f, d, cstr, itin>;
237 class PseudoInst<dag oops, dag iops, InstrItinClass itin, list<dag> pattern>
238 // FIXME: This really should derive from InstTemplate instead, as pseudos
239 // don't need encoding information. TableGen doesn't like that
240 // currently. Need to figure out why and fix it.
241 : InstARM<AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, GenericDomain,
243 let OutOperandList = oops;
244 let InOperandList = iops;
245 let Pattern = pattern;
248 // PseudoInst that's ARM-mode only.
249 class ARMPseudoInst<dag oops, dag iops, InstrItinClass itin,
251 : PseudoInst<oops, iops, itin, pattern> {
252 // Default these to 4byte size, as they're almost always expanded to a
253 // single instruction. Any exceptions can override the SZ field value.
255 list<Predicate> Predicates = [IsARM];
259 // Almost all ARM instructions are predicable.
260 class I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
261 IndexMode im, Format f, InstrItinClass itin,
262 string opc, string asm, string cstr,
264 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
267 let OutOperandList = oops;
268 let InOperandList = !con(iops, (ins pred:$p));
269 let AsmString = !strconcat(opc, "${p}", asm);
270 let Pattern = pattern;
271 list<Predicate> Predicates = [IsARM];
274 // A few are not predicable
275 class InoP<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
276 IndexMode im, Format f, InstrItinClass itin,
277 string opc, string asm, string cstr,
279 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
280 let OutOperandList = oops;
281 let InOperandList = iops;
282 let AsmString = !strconcat(opc, asm);
283 let Pattern = pattern;
284 let isPredicable = 0;
285 list<Predicate> Predicates = [IsARM];
288 // Same as I except it can optionally modify CPSR. Note it's modeled as an input
289 // operand since by default it's a zero register. It will become an implicit def
290 // once it's "flipped".
291 class sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
292 IndexMode im, Format f, InstrItinClass itin,
293 string opc, string asm, string cstr,
295 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
296 bits<4> p; // Predicate operand
297 bits<1> s; // condition-code set flag ('1' if the insn should set the flags)
301 let OutOperandList = oops;
302 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
303 let AsmString = !strconcat(opc, "${s}${p}", asm);
304 let Pattern = pattern;
305 list<Predicate> Predicates = [IsARM];
309 class XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
310 IndexMode im, Format f, InstrItinClass itin,
311 string asm, string cstr, list<dag> pattern>
312 : InstARM<am, sz, im, f, GenericDomain, cstr, itin> {
313 let OutOperandList = oops;
314 let InOperandList = iops;
316 let Pattern = pattern;
317 list<Predicate> Predicates = [IsARM];
320 class AI<dag oops, dag iops, Format f, InstrItinClass itin,
321 string opc, string asm, list<dag> pattern>
322 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
323 opc, asm, "", pattern>;
324 class AsI<dag oops, dag iops, Format f, InstrItinClass itin,
325 string opc, string asm, list<dag> pattern>
326 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
327 opc, asm, "", pattern>;
328 class AXI<dag oops, dag iops, Format f, InstrItinClass itin,
329 string asm, list<dag> pattern>
330 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
332 class AInoP<dag oops, dag iops, Format f, InstrItinClass itin,
333 string opc, string asm, list<dag> pattern>
334 : InoP<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
335 opc, asm, "", pattern>;
337 // Ctrl flow instructions
338 class ABI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
339 string opc, string asm, list<dag> pattern>
340 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
341 opc, asm, "", pattern> {
342 let Inst{27-24} = opcod;
344 class ABXI<bits<4> opcod, dag oops, dag iops, InstrItinClass itin,
345 string asm, list<dag> pattern>
346 : XI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, itin,
348 let Inst{27-24} = opcod;
350 class ABXIx2<dag oops, dag iops, InstrItinClass itin,
351 string asm, list<dag> pattern>
352 : XI<oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, Pseudo, itin,
355 // BR_JT instructions
356 class JTI<dag oops, dag iops, InstrItinClass itin,
357 string asm, list<dag> pattern>
358 : XI<oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BrMiscFrm, itin,
361 // Atomic load/store instructions
362 class AIldrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
363 string opc, string asm, list<dag> pattern>
364 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
365 opc, asm, "", pattern> {
368 let Inst{27-23} = 0b00011;
369 let Inst{22-21} = opcod;
371 let Inst{19-16} = Rn;
372 let Inst{15-12} = Rt;
373 let Inst{11-0} = 0b111110011111;
375 class AIstrex<bits<2> opcod, dag oops, dag iops, InstrItinClass itin,
376 string opc, string asm, list<dag> pattern>
377 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, LdStExFrm, itin,
378 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} = Rd;
387 let Inst{11-4} = 0b11111001;
390 class AIswp<bit b, dag oops, dag iops, string opc, list<dag> pattern>
391 : AI<oops, iops, MiscFrm, NoItinerary, opc, "\t$Rt, $Rt2, [$Rn]", pattern> {
395 let Inst{27-23} = 0b00010;
397 let Inst{21-20} = 0b00;
398 let Inst{19-16} = Rn;
399 let Inst{15-12} = Rt;
400 let Inst{11-4} = 0b00001001;
404 // addrmode1 instructions
405 class AI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
406 string opc, string asm, list<dag> pattern>
407 : I<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
408 opc, asm, "", pattern> {
409 let Inst{24-21} = opcod;
410 let Inst{27-26} = 0b00;
412 class AsI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
413 string opc, string asm, list<dag> pattern>
414 : sI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
415 opc, asm, "", pattern> {
416 let Inst{24-21} = opcod;
417 let Inst{27-26} = 0b00;
419 class AXI1<bits<4> opcod, dag oops, dag iops, Format f, InstrItinClass itin,
420 string asm, list<dag> pattern>
421 : XI<oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, itin,
423 let Inst{24-21} = opcod;
424 let Inst{27-26} = 0b00;
426 class AI1x2<dag oops, dag iops, Format f, InstrItinClass itin,
427 string opc, string asm, list<dag> pattern>
428 : I<oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, itin,
429 opc, asm, "", pattern>;
434 // LDR/LDRB/STR/STRB/...
435 class AI2ldst<bits<3> op, bit isLd, bit isByte, dag oops, dag iops, AddrMode am,
436 Format f, InstrItinClass itin, string opc, string asm,
438 : I<oops, iops, am, Size4Bytes, IndexModeNone, f, itin, opc, asm,
440 let Inst{27-25} = op;
441 let Inst{24} = 1; // 24 == P
443 let Inst{22} = isByte;
444 let Inst{21} = 0; // 21 == W
447 // Indexed load/stores
448 class AI2ldstidx<bit isLd, bit isByte, bit isPre, dag oops, dag iops,
449 IndexMode im, Format f, InstrItinClass itin, string opc,
450 string asm, string cstr, list<dag> pattern>
451 : I<oops, iops, AddrMode2, Size4Bytes, im, f, itin,
452 opc, asm, cstr, pattern> {
454 let Inst{27-26} = 0b01;
455 let Inst{24} = isPre; // P bit
456 let Inst{22} = isByte; // B bit
457 let Inst{21} = isPre; // W bit
458 let Inst{20} = isLd; // L bit
459 let Inst{15-12} = Rt;
461 class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
462 IndexMode im, Format f, InstrItinClass itin, string opc,
463 string asm, string cstr, list<dag> pattern>
464 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
466 // AM2 store w/ two operands: (GPR, am2offset)
467 // {13} 1 == Rm, 0 == imm12
472 let Inst{25} = offset{13};
473 let Inst{23} = offset{12};
474 let Inst{19-16} = Rn;
475 let Inst{11-0} = offset{11-0};
478 // addrmode3 instructions
479 class AI3ld<bits<4> op, bit op20, dag oops, dag iops, Format f,
480 InstrItinClass itin, string opc, string asm, list<dag> pattern>
481 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
482 opc, asm, "", pattern> {
485 let Inst{27-25} = 0b000;
486 let Inst{24} = 1; // P bit
487 let Inst{23} = addr{8}; // U bit
488 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
489 let Inst{21} = 0; // W bit
490 let Inst{20} = op20; // L bit
491 let Inst{19-16} = addr{12-9}; // Rn
492 let Inst{15-12} = Rt; // Rt
493 let Inst{11-8} = addr{7-4}; // imm7_4/zero
495 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
498 class AI3ldstidx<bits<4> op, bit op20, bit isLd, bit isPre, dag oops, dag iops,
499 IndexMode im, Format f, InstrItinClass itin, string opc,
500 string asm, string cstr, list<dag> pattern>
501 : I<oops, iops, AddrMode3, Size4Bytes, im, f, itin,
502 opc, asm, cstr, pattern> {
504 let Inst{27-25} = 0b000;
505 let Inst{24} = isPre; // P bit
506 let Inst{21} = isPre; // W bit
507 let Inst{20} = op20; // L bit
508 let Inst{15-12} = Rt; // Rt
511 class AI3stridx<bits<4> op, bit isByte, bit isPre, dag oops, dag iops,
512 IndexMode im, Format f, InstrItinClass itin, string opc,
513 string asm, string cstr, list<dag> pattern>
514 : AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
516 // AM3 store w/ two operands: (GPR, am3offset)
520 let Inst{27-25} = 0b000;
521 let Inst{23} = offset{8};
522 let Inst{22} = offset{9};
523 let Inst{19-16} = Rn;
524 let Inst{15-12} = Rt; // Rt
525 let Inst{11-8} = offset{7-4}; // imm7_4/zero
527 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
531 class AI3str<bits<4> op, dag oops, dag iops, Format f, InstrItinClass itin,
532 string opc, string asm, list<dag> pattern>
533 : I<oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, itin,
534 opc, asm, "", pattern> {
537 let Inst{27-25} = 0b000;
538 let Inst{24} = 1; // P bit
539 let Inst{23} = addr{8}; // U bit
540 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
541 let Inst{21} = 0; // W bit
542 let Inst{20} = 0; // L bit
543 let Inst{19-16} = addr{12-9}; // Rn
544 let Inst{15-12} = Rt; // Rt
545 let Inst{11-8} = addr{7-4}; // imm7_4/zero
547 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
550 // Pre-indexed stores
551 class AI3sthpr<dag oops, dag iops, Format f, InstrItinClass itin,
552 string opc, string asm, string cstr, list<dag> pattern>
553 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
554 opc, asm, cstr, pattern> {
556 let Inst{5} = 1; // H bit
557 let Inst{6} = 0; // S bit
559 let Inst{20} = 0; // L bit
560 let Inst{21} = 1; // W bit
561 let Inst{24} = 1; // P bit
562 let Inst{27-25} = 0b000;
564 class AI3stdpr<dag oops, dag iops, Format f, InstrItinClass itin,
565 string opc, string asm, string cstr, list<dag> pattern>
566 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, itin,
567 opc, asm, cstr, pattern> {
569 let Inst{5} = 1; // H bit
570 let Inst{6} = 1; // S bit
572 let Inst{20} = 0; // L bit
573 let Inst{21} = 1; // W bit
574 let Inst{24} = 1; // P bit
575 let Inst{27-25} = 0b000;
578 // Post-indexed stores
579 class AI3sthpo<dag oops, dag iops, Format f, InstrItinClass itin,
580 string opc, string asm, string cstr, list<dag> pattern>
581 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
582 opc, asm, cstr,pattern> {
584 let Inst{5} = 1; // H bit
585 let Inst{6} = 0; // S bit
587 let Inst{20} = 0; // L bit
588 let Inst{21} = 0; // W bit
589 let Inst{24} = 0; // P bit
590 let Inst{27-25} = 0b000;
592 class AI3stdpo<dag oops, dag iops, Format f, InstrItinClass itin,
593 string opc, string asm, string cstr, list<dag> pattern>
594 : I<oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, itin,
595 opc, asm, cstr, pattern> {
597 let Inst{5} = 1; // H bit
598 let Inst{6} = 1; // S bit
600 let Inst{20} = 0; // L bit
601 let Inst{21} = 0; // W bit
602 let Inst{24} = 0; // P bit
603 let Inst{27-25} = 0b000;
606 // addrmode4 instructions
607 class AXI4<dag oops, dag iops, IndexMode im, Format f, InstrItinClass itin,
608 string asm, string cstr, list<dag> pattern>
609 : XI<oops, iops, AddrMode4, Size4Bytes, im, f, itin, asm, cstr, pattern> {
614 let Inst{27-25} = 0b100;
615 let Inst{22} = 0; // S bit
616 let Inst{19-16} = Rn;
617 let Inst{15-0} = regs;
620 // Unsigned multiply, multiply-accumulate instructions.
621 class AMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
622 string opc, string asm, list<dag> pattern>
623 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
624 opc, asm, "", pattern> {
625 let Inst{7-4} = 0b1001;
626 let Inst{20} = 0; // S bit
627 let Inst{27-21} = opcod;
629 class AsMul1I<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
630 string opc, string asm, list<dag> pattern>
631 : sI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
632 opc, asm, "", pattern> {
633 let Inst{7-4} = 0b1001;
634 let Inst{27-21} = opcod;
637 // Most significant word multiply
638 class AMul2I<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
639 InstrItinClass itin, string opc, string asm, list<dag> pattern>
640 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
641 opc, asm, "", pattern> {
645 let Inst{7-4} = opc7_4;
647 let Inst{27-21} = opcod;
648 let Inst{19-16} = Rd;
652 // MSW multiple w/ Ra operand
653 class AMul2Ia<bits<7> opcod, bits<4> opc7_4, dag oops, dag iops,
654 InstrItinClass itin, string opc, string asm, list<dag> pattern>
655 : AMul2I<opcod, opc7_4, oops, iops, itin, opc, asm, pattern> {
657 let Inst{15-12} = Ra;
660 // SMUL<x><y> / SMULW<y> / SMLA<x><y> / SMLAW<x><y>
661 class AMulxyIbase<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
662 InstrItinClass itin, string opc, string asm, list<dag> pattern>
663 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, MulFrm, itin,
664 opc, asm, "", pattern> {
670 let Inst{27-21} = opcod;
671 let Inst{6-5} = bit6_5;
675 class AMulxyI<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
676 InstrItinClass itin, string opc, string asm, list<dag> pattern>
677 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
679 let Inst{19-16} = Rd;
682 // AMulxyI with Ra operand
683 class AMulxyIa<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
684 InstrItinClass itin, string opc, string asm, list<dag> pattern>
685 : AMulxyI<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
687 let Inst{15-12} = Ra;
690 class AMulxyI64<bits<7> opcod, bits<2> bit6_5, dag oops, dag iops,
691 InstrItinClass itin, string opc, string asm, list<dag> pattern>
692 : AMulxyIbase<opcod, bit6_5, oops, iops, itin, opc, asm, pattern> {
695 let Inst{19-16} = RdHi;
696 let Inst{15-12} = RdLo;
699 // Extend instructions.
700 class AExtI<bits<8> opcod, dag oops, dag iops, InstrItinClass itin,
701 string opc, string asm, list<dag> pattern>
702 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ExtFrm, itin,
703 opc, asm, "", pattern> {
704 // All AExtI instructions have Rd and Rm register operands.
707 let Inst{15-12} = Rd;
709 let Inst{7-4} = 0b0111;
710 let Inst{9-8} = 0b00;
711 let Inst{27-20} = opcod;
714 // Misc Arithmetic instructions.
715 class AMiscA1I<bits<8> opcod, bits<4> opc7_4, dag oops, dag iops,
716 InstrItinClass itin, string opc, string asm, list<dag> pattern>
717 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
718 opc, asm, "", pattern> {
721 let Inst{27-20} = opcod;
722 let Inst{19-16} = 0b1111;
723 let Inst{15-12} = Rd;
724 let Inst{11-8} = 0b1111;
725 let Inst{7-4} = opc7_4;
730 class APKHI<bits<8> opcod, bit tb, dag oops, dag iops, InstrItinClass itin,
731 string opc, string asm, list<dag> pattern>
732 : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, ArithMiscFrm, itin,
733 opc, asm, "", pattern> {
738 let Inst{27-20} = opcod;
739 let Inst{19-16} = Rn;
740 let Inst{15-12} = Rd;
741 let Inst{11-7} = sh{7-3};
743 let Inst{5-4} = 0b01;
747 //===----------------------------------------------------------------------===//
749 // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode.
750 class ARMPat<dag pattern, dag result> : Pat<pattern, result> {
751 list<Predicate> Predicates = [IsARM];
753 class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> {
754 list<Predicate> Predicates = [IsARM, HasV5TE];
756 class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> {
757 list<Predicate> Predicates = [IsARM, HasV6];
760 //===----------------------------------------------------------------------===//
762 // Thumb Instruction Format Definitions.
765 // TI - Thumb instruction.
767 class ThumbI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
768 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
769 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
770 let OutOperandList = oops;
771 let InOperandList = iops;
773 let Pattern = pattern;
774 list<Predicate> Predicates = [IsThumb];
777 class TI<dag oops, dag iops, InstrItinClass itin, string asm, list<dag> pattern>
778 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
780 // Two-address instructions
781 class TIt<dag oops, dag iops, InstrItinClass itin, string asm,
783 : ThumbI<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "$lhs = $dst",
786 // tBL, tBX 32-bit instructions
787 class TIx2<bits<5> opcod1, bits<2> opcod2, bit opcod3,
788 dag oops, dag iops, InstrItinClass itin, string asm,
790 : ThumbI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>,
792 let Inst{31-27} = opcod1;
793 let Inst{15-14} = opcod2;
794 let Inst{12} = opcod3;
797 // BR_JT instructions
798 class TJTI<dag oops, dag iops, InstrItinClass itin, string asm,
800 : ThumbI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
803 class Thumb1I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
804 InstrItinClass itin, string asm, string cstr, list<dag> pattern>
805 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
806 let OutOperandList = oops;
807 let InOperandList = iops;
809 let Pattern = pattern;
810 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
813 class T1I<dag oops, dag iops, InstrItinClass itin,
814 string asm, list<dag> pattern>
815 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin, asm, "", pattern>;
816 class T1Ix2<dag oops, dag iops, InstrItinClass itin,
817 string asm, list<dag> pattern>
818 : Thumb1I<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
819 class T1JTI<dag oops, dag iops, InstrItinClass itin,
820 string asm, list<dag> pattern>
821 : Thumb1I<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
823 // Two-address instructions
824 class T1It<dag oops, dag iops, InstrItinClass itin,
825 string asm, string cstr, list<dag> pattern>
826 : Thumb1I<oops, iops, AddrModeNone, Size2Bytes, itin,
829 // Thumb1 instruction that can either be predicated or set CPSR.
830 class Thumb1sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
832 string opc, string asm, string cstr, list<dag> pattern>
833 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
834 let OutOperandList = !con(oops, (outs s_cc_out:$s));
835 let InOperandList = !con(iops, (ins pred:$p));
836 let AsmString = !strconcat(opc, "${s}${p}", asm);
837 let Pattern = pattern;
838 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
841 class T1sI<dag oops, dag iops, InstrItinClass itin,
842 string opc, string asm, list<dag> pattern>
843 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
845 // Two-address instructions
846 class T1sIt<dag oops, dag iops, InstrItinClass itin,
847 string opc, string asm, list<dag> pattern>
848 : Thumb1sI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
849 "$lhs = $dst", pattern>;
851 // Thumb1 instruction that can be predicated.
852 class Thumb1pI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
854 string opc, string asm, string cstr, list<dag> pattern>
855 : InstThumb<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
856 let OutOperandList = oops;
857 let InOperandList = !con(iops, (ins pred:$p));
858 let AsmString = !strconcat(opc, "${p}", asm);
859 let Pattern = pattern;
860 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
863 class T1pI<dag oops, dag iops, InstrItinClass itin,
864 string opc, string asm, list<dag> pattern>
865 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm, "", pattern>;
867 // Two-address instructions
868 class T1pIt<dag oops, dag iops, InstrItinClass itin,
869 string opc, string asm, list<dag> pattern>
870 : Thumb1pI<oops, iops, AddrModeNone, Size2Bytes, itin, opc, asm,
871 "$lhs = $dst", pattern>;
873 class T1pI1<dag oops, dag iops, InstrItinClass itin,
874 string opc, string asm, list<dag> pattern>
875 : Thumb1pI<oops, iops, AddrModeT1_1, Size2Bytes, itin, opc, asm, "", pattern>;
876 class T1pI2<dag oops, dag iops, InstrItinClass itin,
877 string opc, string asm, list<dag> pattern>
878 : Thumb1pI<oops, iops, AddrModeT1_2, Size2Bytes, itin, opc, asm, "", pattern>;
879 class T1pI4<dag oops, dag iops, InstrItinClass itin,
880 string opc, string asm, list<dag> pattern>
881 : Thumb1pI<oops, iops, AddrModeT1_4, Size2Bytes, itin, opc, asm, "", pattern>;
882 class T1pIs<dag oops, dag iops,
883 InstrItinClass itin, string opc, string asm, list<dag> pattern>
884 : Thumb1pI<oops, iops, AddrModeT1_s, Size2Bytes, itin, opc, asm, "", pattern>;
886 class Encoding16 : Encoding {
887 let Inst{31-16} = 0x0000;
890 // A6.2 16-bit Thumb instruction encoding
891 class T1Encoding<bits<6> opcode> : Encoding16 {
892 let Inst{15-10} = opcode;
895 // A6.2.1 Shift (immediate), add, subtract, move, and compare encoding.
896 class T1General<bits<5> opcode> : Encoding16 {
897 let Inst{15-14} = 0b00;
898 let Inst{13-9} = opcode;
901 // A6.2.2 Data-processing encoding.
902 class T1DataProcessing<bits<4> opcode> : Encoding16 {
903 let Inst{15-10} = 0b010000;
904 let Inst{9-6} = opcode;
907 // A6.2.3 Special data instructions and branch and exchange encoding.
908 class T1Special<bits<4> opcode> : Encoding16 {
909 let Inst{15-10} = 0b010001;
910 let Inst{9-6} = opcode;
913 // A6.2.4 Load/store single data item encoding.
914 class T1LoadStore<bits<4> opA, bits<3> opB> : Encoding16 {
915 let Inst{15-12} = opA;
916 let Inst{11-9} = opB;
918 class T1LdSt<bits<3> opB> : T1LoadStore<0b0101, opB>;
919 class T1LdSt4Imm<bits<3> opB> : T1LoadStore<0b0110, opB>; // Immediate, 4 bytes
920 class T1LdSt1Imm<bits<3> opB> : T1LoadStore<0b0111, opB>; // Immediate, 1 byte
921 class T1LdSt2Imm<bits<3> opB> : T1LoadStore<0b1000, opB>; // Immediate, 2 bytes
922 class T1LdStSP<bits<3> opB> : T1LoadStore<0b1001, opB>; // SP relative
924 // A6.2.5 Miscellaneous 16-bit instructions encoding.
925 class T1Misc<bits<7> opcode> : Encoding16 {
926 let Inst{15-12} = 0b1011;
927 let Inst{11-5} = opcode;
930 // Thumb2I - Thumb2 instruction. Almost all Thumb2 instructions are predicable.
931 class Thumb2I<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
933 string opc, string asm, string cstr, list<dag> pattern>
934 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
935 let OutOperandList = oops;
936 let InOperandList = !con(iops, (ins pred:$p));
937 let AsmString = !strconcat(opc, "${p}", asm);
938 let Pattern = pattern;
939 list<Predicate> Predicates = [IsThumb2];
942 // Same as Thumb2I except it can optionally modify CPSR. Note it's modeled as an
943 // input operand since by default it's a zero register. It will become an
944 // implicit def once it's "flipped".
946 // FIXME: This uses unified syntax so {s} comes before {p}. We should make it
948 class Thumb2sI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
950 string opc, string asm, string cstr, list<dag> pattern>
951 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
952 let OutOperandList = oops;
953 let InOperandList = !con(iops, (ins pred:$p, cc_out:$s));
954 let AsmString = !strconcat(opc, "${s}${p}", asm);
955 let Pattern = pattern;
956 list<Predicate> Predicates = [IsThumb2];
960 class Thumb2XI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
962 string asm, string cstr, list<dag> pattern>
963 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
964 let OutOperandList = oops;
965 let InOperandList = iops;
967 let Pattern = pattern;
968 list<Predicate> Predicates = [IsThumb2];
971 class ThumbXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
973 string asm, string cstr, list<dag> pattern>
974 : InstARM<am, sz, IndexModeNone, ThumbFrm, GenericDomain, cstr, itin> {
975 let OutOperandList = oops;
976 let InOperandList = iops;
978 let Pattern = pattern;
979 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
982 class T2I<dag oops, dag iops, InstrItinClass itin,
983 string opc, string asm, list<dag> pattern>
984 : Thumb2I<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
985 class T2Ii12<dag oops, dag iops, InstrItinClass itin,
986 string opc, string asm, list<dag> pattern>
987 : Thumb2I<oops, iops, AddrModeT2_i12, Size4Bytes, itin, opc, asm, "",pattern>;
988 class T2Ii8<dag oops, dag iops, InstrItinClass itin,
989 string opc, string asm, list<dag> pattern>
990 : Thumb2I<oops, iops, AddrModeT2_i8, Size4Bytes, itin, opc, asm, "", pattern>;
991 class T2Iso<dag oops, dag iops, InstrItinClass itin,
992 string opc, string asm, list<dag> pattern>
993 : Thumb2I<oops, iops, AddrModeT2_so, Size4Bytes, itin, opc, asm, "", pattern>;
994 class T2Ipc<dag oops, dag iops, InstrItinClass itin,
995 string opc, string asm, list<dag> pattern>
996 : Thumb2I<oops, iops, AddrModeT2_pc, Size4Bytes, itin, opc, asm, "", pattern>;
997 class T2Ii8s4<bit P, bit W, bit load, dag oops, dag iops, InstrItinClass itin,
998 string opc, string asm, list<dag> pattern>
999 : Thumb2I<oops, iops, AddrModeT2_i8s4, Size4Bytes, itin, opc, asm, "",
1001 let Inst{31-27} = 0b11101;
1002 let Inst{26-25} = 0b00;
1004 let Inst{23} = ?; // The U bit.
1007 let Inst{20} = load;
1010 class T2sI<dag oops, dag iops, InstrItinClass itin,
1011 string opc, string asm, list<dag> pattern>
1012 : Thumb2sI<oops, iops, AddrModeNone, Size4Bytes, itin, opc, asm, "", pattern>;
1014 class T2XI<dag oops, dag iops, InstrItinClass itin,
1015 string asm, list<dag> pattern>
1016 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, "", pattern>;
1017 class T2JTI<dag oops, dag iops, InstrItinClass itin,
1018 string asm, list<dag> pattern>
1019 : Thumb2XI<oops, iops, AddrModeNone, SizeSpecial, itin, asm, "", pattern>;
1021 class T2Ix2<dag oops, dag iops, InstrItinClass itin,
1022 string opc, string asm, list<dag> pattern>
1023 : Thumb2I<oops, iops, AddrModeNone, Size8Bytes, itin, opc, asm, "", pattern>;
1025 // Two-address instructions
1026 class T2XIt<dag oops, dag iops, InstrItinClass itin,
1027 string asm, string cstr, list<dag> pattern>
1028 : Thumb2XI<oops, iops, AddrModeNone, Size4Bytes, itin, asm, cstr, pattern>;
1030 // T2Iidxldst - Thumb2 indexed load / store instructions.
1031 class T2Iidxldst<bit signed, bits<2> opcod, bit load, bit pre,
1033 AddrMode am, IndexMode im, InstrItinClass itin,
1034 string opc, string asm, string cstr, list<dag> pattern>
1035 : InstARM<am, Size4Bytes, im, ThumbFrm, GenericDomain, cstr, itin> {
1036 let OutOperandList = oops;
1037 let InOperandList = !con(iops, (ins pred:$p));
1038 let AsmString = !strconcat(opc, "${p}", asm);
1039 let Pattern = pattern;
1040 list<Predicate> Predicates = [IsThumb2];
1041 let Inst{31-27} = 0b11111;
1042 let Inst{26-25} = 0b00;
1043 let Inst{24} = signed;
1045 let Inst{22-21} = opcod;
1046 let Inst{20} = load;
1048 // (P, W) = (1, 1) Pre-indexed or (0, 1) Post-indexed
1049 let Inst{10} = pre; // The P bit.
1050 let Inst{8} = 1; // The W bit.
1053 // Tv5Pat - Same as Pat<>, but requires V5T Thumb mode.
1054 class Tv5Pat<dag pattern, dag result> : Pat<pattern, result> {
1055 list<Predicate> Predicates = [IsThumb, IsThumb1Only, HasV5T];
1058 // T1Pat - Same as Pat<>, but requires that the compiler be in Thumb1 mode.
1059 class T1Pat<dag pattern, dag result> : Pat<pattern, result> {
1060 list<Predicate> Predicates = [IsThumb, IsThumb1Only];
1063 // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode.
1064 class T2Pat<dag pattern, dag result> : Pat<pattern, result> {
1065 list<Predicate> Predicates = [IsThumb2];
1068 //===----------------------------------------------------------------------===//
1070 //===----------------------------------------------------------------------===//
1071 // ARM VFP Instruction templates.
1074 // Almost all VFP instructions are predicable.
1075 class VFPI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1076 IndexMode im, Format f, InstrItinClass itin,
1077 string opc, string asm, string cstr, list<dag> pattern>
1078 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1080 let Inst{31-28} = p;
1081 let OutOperandList = oops;
1082 let InOperandList = !con(iops, (ins pred:$p));
1083 let AsmString = !strconcat(opc, "${p}", asm);
1084 let Pattern = pattern;
1085 list<Predicate> Predicates = [HasVFP2];
1089 class VFPXI<dag oops, dag iops, AddrMode am, SizeFlagVal sz,
1090 IndexMode im, Format f, InstrItinClass itin,
1091 string asm, string cstr, list<dag> pattern>
1092 : InstARM<am, sz, im, f, VFPDomain, cstr, itin> {
1094 let Inst{31-28} = p;
1095 let OutOperandList = oops;
1096 let InOperandList = iops;
1097 let AsmString = asm;
1098 let Pattern = pattern;
1099 list<Predicate> Predicates = [HasVFP2];
1102 class VFPAI<dag oops, dag iops, Format f, InstrItinClass itin,
1103 string opc, string asm, list<dag> pattern>
1104 : VFPI<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, itin,
1105 opc, asm, "", pattern>;
1107 // ARM VFP addrmode5 loads and stores
1108 class ADI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1109 InstrItinClass itin,
1110 string opc, string asm, list<dag> pattern>
1111 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1112 VFPLdStFrm, itin, opc, asm, "", pattern> {
1113 // Instruction operands.
1117 // Encode instruction operands.
1118 let Inst{23} = addr{8}; // U (add = (U == '1'))
1119 let Inst{22} = Dd{4};
1120 let Inst{19-16} = addr{12-9}; // Rn
1121 let Inst{15-12} = Dd{3-0};
1122 let Inst{7-0} = addr{7-0}; // imm8
1124 // TODO: Mark the instructions with the appropriate subtarget info.
1125 let Inst{27-24} = opcod1;
1126 let Inst{21-20} = opcod2;
1127 let Inst{11-9} = 0b101;
1128 let Inst{8} = 1; // Double precision
1130 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1131 let D = VFPNeonDomain;
1134 class ASI5<bits<4> opcod1, bits<2> opcod2, dag oops, dag iops,
1135 InstrItinClass itin,
1136 string opc, string asm, list<dag> pattern>
1137 : VFPI<oops, iops, AddrMode5, Size4Bytes, IndexModeNone,
1138 VFPLdStFrm, itin, opc, asm, "", pattern> {
1139 // Instruction operands.
1143 // Encode instruction operands.
1144 let Inst{23} = addr{8}; // U (add = (U == '1'))
1145 let Inst{22} = Sd{0};
1146 let Inst{19-16} = addr{12-9}; // Rn
1147 let Inst{15-12} = Sd{4-1};
1148 let Inst{7-0} = addr{7-0}; // imm8
1150 // TODO: Mark the instructions with the appropriate subtarget info.
1151 let Inst{27-24} = opcod1;
1152 let Inst{21-20} = opcod2;
1153 let Inst{11-9} = 0b101;
1154 let Inst{8} = 0; // Single precision
1157 // VFP Load / store multiple pseudo instructions.
1158 class PseudoVFPLdStM<dag oops, dag iops, InstrItinClass itin, string cstr,
1160 : InstARM<AddrMode4, Size4Bytes, IndexModeNone, Pseudo, VFPNeonDomain,
1162 let OutOperandList = oops;
1163 let InOperandList = !con(iops, (ins pred:$p));
1164 let Pattern = pattern;
1165 list<Predicate> Predicates = [HasVFP2];
1168 // Load / store multiple
1169 class AXDI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1170 string asm, string cstr, list<dag> pattern>
1171 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1172 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1173 // Instruction operands.
1177 // Encode instruction operands.
1178 let Inst{19-16} = Rn;
1179 let Inst{22} = regs{12};
1180 let Inst{15-12} = regs{11-8};
1181 let Inst{7-0} = regs{7-0};
1183 // TODO: Mark the instructions with the appropriate subtarget info.
1184 let Inst{27-25} = 0b110;
1185 let Inst{11-9} = 0b101;
1186 let Inst{8} = 1; // Double precision
1188 // 64-bit loads & stores operate on both NEON and VFP pipelines.
1189 let D = VFPNeonDomain;
1192 class AXSI4<dag oops, dag iops, IndexMode im, InstrItinClass itin,
1193 string asm, string cstr, list<dag> pattern>
1194 : VFPXI<oops, iops, AddrMode4, Size4Bytes, im,
1195 VFPLdStMulFrm, itin, asm, cstr, pattern> {
1196 // Instruction operands.
1200 // Encode instruction operands.
1201 let Inst{19-16} = Rn;
1202 let Inst{22} = regs{8};
1203 let Inst{15-12} = regs{12-9};
1204 let Inst{7-0} = regs{7-0};
1206 // TODO: Mark the instructions with the appropriate subtarget info.
1207 let Inst{27-25} = 0b110;
1208 let Inst{11-9} = 0b101;
1209 let Inst{8} = 0; // Single precision
1212 // Double precision, unary
1213 class ADuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1214 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1215 string asm, list<dag> pattern>
1216 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1217 // Instruction operands.
1221 // Encode instruction operands.
1222 let Inst{3-0} = Dm{3-0};
1223 let Inst{5} = Dm{4};
1224 let Inst{15-12} = Dd{3-0};
1225 let Inst{22} = Dd{4};
1227 let Inst{27-23} = opcod1;
1228 let Inst{21-20} = opcod2;
1229 let Inst{19-16} = opcod3;
1230 let Inst{11-9} = 0b101;
1231 let Inst{8} = 1; // Double precision
1232 let Inst{7-6} = opcod4;
1233 let Inst{4} = opcod5;
1236 // Double precision, binary
1237 class ADbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1238 dag iops, InstrItinClass itin, string opc, string asm,
1240 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1241 // Instruction operands.
1246 // Encode instruction operands.
1247 let Inst{3-0} = Dm{3-0};
1248 let Inst{5} = Dm{4};
1249 let Inst{19-16} = Dn{3-0};
1250 let Inst{7} = Dn{4};
1251 let Inst{15-12} = Dd{3-0};
1252 let Inst{22} = Dd{4};
1254 let Inst{27-23} = opcod1;
1255 let Inst{21-20} = opcod2;
1256 let Inst{11-9} = 0b101;
1257 let Inst{8} = 1; // Double precision
1262 // Single precision, unary
1263 class ASuI<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1264 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1265 string asm, list<dag> pattern>
1266 : VFPAI<oops, iops, VFPUnaryFrm, itin, opc, asm, pattern> {
1267 // Instruction operands.
1271 // Encode instruction operands.
1272 let Inst{3-0} = Sm{4-1};
1273 let Inst{5} = Sm{0};
1274 let Inst{15-12} = Sd{4-1};
1275 let Inst{22} = Sd{0};
1277 let Inst{27-23} = opcod1;
1278 let Inst{21-20} = opcod2;
1279 let Inst{19-16} = opcod3;
1280 let Inst{11-9} = 0b101;
1281 let Inst{8} = 0; // Single precision
1282 let Inst{7-6} = opcod4;
1283 let Inst{4} = opcod5;
1286 // Single precision unary, if no NEON
1287 // Same as ASuI except not available if NEON is enabled
1288 class ASuIn<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<2> opcod4,
1289 bit opcod5, dag oops, dag iops, InstrItinClass itin, string opc,
1290 string asm, list<dag> pattern>
1291 : ASuI<opcod1, opcod2, opcod3, opcod4, opcod5, oops, iops, itin, opc, asm,
1293 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1296 // Single precision, binary
1297 class ASbI<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops, dag iops,
1298 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1299 : VFPAI<oops, iops, VFPBinaryFrm, itin, opc, asm, pattern> {
1300 // Instruction operands.
1305 // Encode instruction operands.
1306 let Inst{3-0} = Sm{4-1};
1307 let Inst{5} = Sm{0};
1308 let Inst{19-16} = Sn{4-1};
1309 let Inst{7} = Sn{0};
1310 let Inst{15-12} = Sd{4-1};
1311 let Inst{22} = Sd{0};
1313 let Inst{27-23} = opcod1;
1314 let Inst{21-20} = opcod2;
1315 let Inst{11-9} = 0b101;
1316 let Inst{8} = 0; // Single precision
1321 // Single precision binary, if no NEON
1322 // Same as ASbI except not available if NEON is enabled
1323 class ASbIn<bits<5> opcod1, bits<2> opcod2, bit op6, bit op4, dag oops,
1324 dag iops, InstrItinClass itin, string opc, string asm,
1326 : ASbI<opcod1, opcod2, op6, op4, oops, iops, itin, opc, asm, pattern> {
1327 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1329 // Instruction operands.
1334 // Encode instruction operands.
1335 let Inst{3-0} = Sm{4-1};
1336 let Inst{5} = Sm{0};
1337 let Inst{19-16} = Sn{4-1};
1338 let Inst{7} = Sn{0};
1339 let Inst{15-12} = Sd{4-1};
1340 let Inst{22} = Sd{0};
1343 // VFP conversion instructions
1344 class AVConv1I<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1345 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1347 : VFPAI<oops, iops, VFPConv1Frm, itin, opc, asm, pattern> {
1348 let Inst{27-23} = opcod1;
1349 let Inst{21-20} = opcod2;
1350 let Inst{19-16} = opcod3;
1351 let Inst{11-8} = opcod4;
1356 // VFP conversion between floating-point and fixed-point
1357 class AVConv1XI<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, bit op5,
1358 dag oops, dag iops, InstrItinClass itin, string opc, string asm,
1360 : AVConv1I<op1, op2, op3, op4, oops, iops, itin, opc, asm, pattern> {
1361 // size (fixed-point number): sx == 0 ? 16 : 32
1362 let Inst{7} = op5; // sx
1365 // VFP conversion instructions, if no NEON
1366 class AVConv1In<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, bits<4> opcod4,
1367 dag oops, dag iops, InstrItinClass itin,
1368 string opc, string asm, list<dag> pattern>
1369 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm,
1371 list<Predicate> Predicates = [HasVFP2,DontUseNEONForFP];
1374 class AVConvXI<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops, Format f,
1375 InstrItinClass itin,
1376 string opc, string asm, list<dag> pattern>
1377 : VFPAI<oops, iops, f, itin, opc, asm, pattern> {
1378 let Inst{27-20} = opcod1;
1379 let Inst{11-8} = opcod2;
1383 class AVConv2I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1384 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1385 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv2Frm, itin, opc, asm, pattern>;
1387 class AVConv3I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1388 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1389 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv3Frm, itin, opc, asm, pattern>;
1391 class AVConv4I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1392 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1393 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv4Frm, itin, opc, asm, pattern>;
1395 class AVConv5I<bits<8> opcod1, bits<4> opcod2, dag oops, dag iops,
1396 InstrItinClass itin, string opc, string asm, list<dag> pattern>
1397 : AVConvXI<opcod1, opcod2, oops, iops, VFPConv5Frm, itin, opc, asm, pattern>;
1399 //===----------------------------------------------------------------------===//
1401 //===----------------------------------------------------------------------===//
1402 // ARM NEON Instruction templates.
1405 class NeonI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1406 InstrItinClass itin, string opc, string dt, string asm, string cstr,
1408 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1409 let OutOperandList = oops;
1410 let InOperandList = !con(iops, (ins pred:$p));
1411 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1412 let Pattern = pattern;
1413 list<Predicate> Predicates = [HasNEON];
1416 // Same as NeonI except it does not have a "data type" specifier.
1417 class NeonXI<dag oops, dag iops, AddrMode am, IndexMode im, Format f,
1418 InstrItinClass itin, string opc, string asm, string cstr,
1420 : InstARM<am, Size4Bytes, im, f, NeonDomain, cstr, itin> {
1421 let OutOperandList = oops;
1422 let InOperandList = !con(iops, (ins pred:$p));
1423 let AsmString = !strconcat(opc, "${p}", "\t", asm);
1424 let Pattern = pattern;
1425 list<Predicate> Predicates = [HasNEON];
1428 class NLdSt<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1429 dag oops, dag iops, InstrItinClass itin,
1430 string opc, string dt, string asm, string cstr, list<dag> pattern>
1431 : NeonI<oops, iops, AddrMode6, IndexModeNone, NLdStFrm, itin, opc, dt, asm,
1433 let Inst{31-24} = 0b11110100;
1434 let Inst{23} = op23;
1435 let Inst{21-20} = op21_20;
1436 let Inst{11-8} = op11_8;
1437 let Inst{7-4} = op7_4;
1439 let PostEncoderMethod = "NEONThumb2LoadStorePostEncoder";
1445 let Inst{22} = Vd{4};
1446 let Inst{15-12} = Vd{3-0};
1447 let Inst{19-16} = Rn{3-0};
1448 let Inst{3-0} = Rm{3-0};
1451 class NLdStLn<bit op23, bits<2> op21_20, bits<4> op11_8, bits<4> op7_4,
1452 dag oops, dag iops, InstrItinClass itin,
1453 string opc, string dt, string asm, string cstr, list<dag> pattern>
1454 : NLdSt<op23, op21_20, op11_8, op7_4, oops, iops, itin, opc,
1455 dt, asm, cstr, pattern> {
1459 class PseudoNLdSt<dag oops, dag iops, InstrItinClass itin, string cstr>
1460 : InstARM<AddrMode6, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1462 let OutOperandList = oops;
1463 let InOperandList = !con(iops, (ins pred:$p));
1464 list<Predicate> Predicates = [HasNEON];
1467 class PseudoNeonI<dag oops, dag iops, InstrItinClass itin, string cstr,
1469 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, Pseudo, NeonDomain, cstr,
1471 let OutOperandList = oops;
1472 let InOperandList = !con(iops, (ins pred:$p));
1473 let Pattern = pattern;
1474 list<Predicate> Predicates = [HasNEON];
1477 class NDataI<dag oops, dag iops, Format f, InstrItinClass itin,
1478 string opc, string dt, string asm, string cstr, list<dag> pattern>
1479 : NeonI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, dt, asm, cstr,
1481 let Inst{31-25} = 0b1111001;
1482 let PostEncoderMethod = "NEONThumb2DataIPostEncoder";
1485 class NDataXI<dag oops, dag iops, Format f, InstrItinClass itin,
1486 string opc, string asm, string cstr, list<dag> pattern>
1487 : NeonXI<oops, iops, AddrModeNone, IndexModeNone, f, itin, opc, asm,
1489 let Inst{31-25} = 0b1111001;
1492 // NEON "one register and a modified immediate" format.
1493 class N1ModImm<bit op23, bits<3> op21_19, bits<4> op11_8, bit op7, bit op6,
1495 dag oops, dag iops, InstrItinClass itin,
1496 string opc, string dt, string asm, string cstr,
1498 : NDataI<oops, iops, N1RegModImmFrm, itin, opc, dt, asm, cstr, pattern> {
1499 let Inst{23} = op23;
1500 let Inst{21-19} = op21_19;
1501 let Inst{11-8} = op11_8;
1507 // Instruction operands.
1511 let Inst{15-12} = Vd{3-0};
1512 let Inst{22} = Vd{4};
1513 let Inst{24} = SIMM{7};
1514 let Inst{18-16} = SIMM{6-4};
1515 let Inst{3-0} = SIMM{3-0};
1518 // NEON 2 vector register format.
1519 class N2V<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1520 bits<5> op11_7, bit op6, bit op4,
1521 dag oops, dag iops, InstrItinClass itin,
1522 string opc, string dt, string asm, string cstr, list<dag> pattern>
1523 : NDataI<oops, iops, N2RegFrm, itin, opc, dt, asm, cstr, pattern> {
1524 let Inst{24-23} = op24_23;
1525 let Inst{21-20} = op21_20;
1526 let Inst{19-18} = op19_18;
1527 let Inst{17-16} = op17_16;
1528 let Inst{11-7} = op11_7;
1532 // Instruction operands.
1536 let Inst{15-12} = Vd{3-0};
1537 let Inst{22} = Vd{4};
1538 let Inst{3-0} = Vm{3-0};
1539 let Inst{5} = Vm{4};
1542 // Same as N2V except it doesn't have a datatype suffix.
1543 class N2VX<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18, bits<2> op17_16,
1544 bits<5> op11_7, bit op6, bit op4,
1545 dag oops, dag iops, InstrItinClass itin,
1546 string opc, string asm, string cstr, list<dag> pattern>
1547 : NDataXI<oops, iops, N2RegFrm, itin, opc, asm, cstr, pattern> {
1548 let Inst{24-23} = op24_23;
1549 let Inst{21-20} = op21_20;
1550 let Inst{19-18} = op19_18;
1551 let Inst{17-16} = op17_16;
1552 let Inst{11-7} = op11_7;
1556 // Instruction operands.
1560 let Inst{15-12} = Vd{3-0};
1561 let Inst{22} = Vd{4};
1562 let Inst{3-0} = Vm{3-0};
1563 let Inst{5} = Vm{4};
1566 // NEON 2 vector register with immediate.
1567 class N2VImm<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
1568 dag oops, dag iops, Format f, InstrItinClass itin,
1569 string opc, string dt, string asm, string cstr, list<dag> pattern>
1570 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1571 let Inst{24} = op24;
1572 let Inst{23} = op23;
1573 let Inst{11-8} = op11_8;
1578 // Instruction operands.
1583 let Inst{15-12} = Vd{3-0};
1584 let Inst{22} = Vd{4};
1585 let Inst{3-0} = Vm{3-0};
1586 let Inst{5} = Vm{4};
1587 let Inst{21-16} = SIMM{5-0};
1590 // NEON 3 vector register format.
1591 class N3V<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6, bit op4,
1592 dag oops, dag iops, Format f, InstrItinClass itin,
1593 string opc, string dt, string asm, string cstr, list<dag> pattern>
1594 : NDataI<oops, iops, f, itin, opc, dt, asm, cstr, pattern> {
1595 let Inst{24} = op24;
1596 let Inst{23} = op23;
1597 let Inst{21-20} = op21_20;
1598 let Inst{11-8} = op11_8;
1602 // Instruction operands.
1607 let Inst{15-12} = Vd{3-0};
1608 let Inst{22} = Vd{4};
1609 let Inst{19-16} = Vn{3-0};
1610 let Inst{7} = Vn{4};
1611 let Inst{3-0} = Vm{3-0};
1612 let Inst{5} = Vm{4};
1615 // Same as N3V except it doesn't have a data type suffix.
1616 class N3VX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op6,
1618 dag oops, dag iops, Format f, InstrItinClass itin,
1619 string opc, string asm, string cstr, list<dag> pattern>
1620 : NDataXI<oops, iops, f, itin, opc, asm, cstr, pattern> {
1621 let Inst{24} = op24;
1622 let Inst{23} = op23;
1623 let Inst{21-20} = op21_20;
1624 let Inst{11-8} = op11_8;
1628 // Instruction operands.
1633 let Inst{15-12} = Vd{3-0};
1634 let Inst{22} = Vd{4};
1635 let Inst{19-16} = Vn{3-0};
1636 let Inst{7} = Vn{4};
1637 let Inst{3-0} = Vm{3-0};
1638 let Inst{5} = Vm{4};
1641 // NEON VMOVs between scalar and core registers.
1642 class NVLaneOp<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1643 dag oops, dag iops, Format f, InstrItinClass itin,
1644 string opc, string dt, string asm, list<dag> pattern>
1645 : InstARM<AddrModeNone, Size4Bytes, IndexModeNone, f, NeonDomain,
1647 let Inst{27-20} = opcod1;
1648 let Inst{11-8} = opcod2;
1649 let Inst{6-5} = opcod3;
1652 let OutOperandList = oops;
1653 let InOperandList = !con(iops, (ins pred:$p));
1654 let AsmString = !strconcat(opc, "${p}", ".", dt, "\t", asm);
1655 let Pattern = pattern;
1656 list<Predicate> Predicates = [HasNEON];
1658 let PostEncoderMethod = "NEONThumb2DupPostEncoder";
1665 let Inst{31-28} = p{3-0};
1667 let Inst{19-16} = V{3-0};
1668 let Inst{15-12} = R{3-0};
1670 class NVGetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1671 dag oops, dag iops, InstrItinClass itin,
1672 string opc, string dt, string asm, list<dag> pattern>
1673 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NGetLnFrm, itin,
1674 opc, dt, asm, pattern>;
1675 class NVSetLane<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1676 dag oops, dag iops, InstrItinClass itin,
1677 string opc, string dt, string asm, list<dag> pattern>
1678 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NSetLnFrm, itin,
1679 opc, dt, asm, pattern>;
1680 class NVDup<bits<8> opcod1, bits<4> opcod2, bits<2> opcod3,
1681 dag oops, dag iops, InstrItinClass itin,
1682 string opc, string dt, string asm, list<dag> pattern>
1683 : NVLaneOp<opcod1, opcod2, opcod3, oops, iops, NDupFrm, itin,
1684 opc, dt, asm, pattern>;
1686 // Vector Duplicate Lane (from scalar to all elements)
1687 class NVDupLane<bits<4> op19_16, bit op6, dag oops, dag iops,
1688 InstrItinClass itin, string opc, string dt, string asm,
1690 : NDataI<oops, iops, NVDupLnFrm, itin, opc, dt, asm, "", pattern> {
1691 let Inst{24-23} = 0b11;
1692 let Inst{21-20} = 0b11;
1693 let Inst{19-16} = op19_16;
1694 let Inst{11-7} = 0b11000;
1702 let Inst{22} = Vd{4};
1703 let Inst{15-12} = Vd{3-0};
1704 let Inst{5} = Vm{4};
1705 let Inst{3-0} = Vm{3-0};
1708 // NEONFPPat - Same as Pat<>, but requires that the compiler be using NEON
1709 // for single-precision FP.
1710 class NEONFPPat<dag pattern, dag result> : Pat<pattern, result> {
1711 list<Predicate> Predicates = [HasNEON,UseNEONForFP];