1 //===- AArch64InstrFormats.td - AArch64 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 //===----------------------------------------------------------------------===//
9 // This file describes AArch64 instruction formats, down to the level of the
10 // instruction's overall class.
11 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // A64 Instruction Format Definitions.
16 //===----------------------------------------------------------------------===//
18 // A64 is currently the only instruction set supported by the AArch64
20 class A64Inst<dag outs, dag ins, string asmstr, list<dag> patterns,
23 // All A64 instructions are 32-bit. This field will be filled in
24 // gradually going down the hierarchy.
27 field bits<32> Unpredictable = 0;
28 // SoftFail is the generic name for this field, but we alias it so
29 // as to make it more obvious what it means in ARM-land.
30 field bits<32> SoftFail = Unpredictable;
32 // LLVM-level model of the AArch64/A64 distinction.
33 let Namespace = "AArch64";
34 let DecoderNamespace = "A64";
37 // Set the templated fields
38 let OutOperandList = outs;
39 let InOperandList = ins;
40 let AsmString = asmstr;
41 let Pattern = patterns;
45 class PseudoInst<dag outs, dag ins, list<dag> patterns> : Instruction {
46 let Namespace = "AArch64";
48 let OutOperandList = outs;
49 let InOperandList= ins;
50 let Pattern = patterns;
51 let isCodeGenOnly = 1;
55 // Represents a pseudo-instruction that represents a single A64 instruction for
56 // whatever reason, the eventual result will be a 32-bit real instruction.
57 class A64PseudoInst<dag outs, dag ins, list<dag> patterns>
58 : PseudoInst<outs, ins, patterns> {
62 // As above, this will be a single A64 instruction, but we can actually give the
63 // expansion in TableGen.
64 class A64PseudoExpand<dag outs, dag ins, list<dag> patterns, dag Result>
65 : A64PseudoInst<outs, ins, patterns>,
66 PseudoInstExpansion<Result>;
69 // First, some common cross-hierarchy register formats.
71 class A64InstRd<dag outs, dag ins, string asmstr,
72 list<dag> patterns, InstrItinClass itin>
73 : A64Inst<outs, ins, asmstr, patterns, itin> {
79 class A64InstRt<dag outs, dag ins, string asmstr,
80 list<dag> patterns, InstrItinClass itin>
81 : A64Inst<outs, ins, asmstr, patterns, itin> {
88 class A64InstRdn<dag outs, dag ins, string asmstr,
89 list<dag> patterns, InstrItinClass itin>
90 : A64InstRd<outs, ins, asmstr, patterns, itin> {
97 class A64InstRtn<dag outs, dag ins, string asmstr,
98 list<dag> patterns, InstrItinClass itin>
99 : A64InstRt<outs, ins, asmstr, patterns, itin> {
106 // Instructions taking Rt,Rt2,Rn
107 class A64InstRtt2n<dag outs, dag ins, string asmstr,
108 list<dag> patterns, InstrItinClass itin>
109 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
112 let Inst{14-10} = Rt2;
115 class A64InstRdnm<dag outs, dag ins, string asmstr,
116 list<dag> patterns, InstrItinClass itin>
117 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
120 let Inst{20-16} = Rm;
123 //===----------------------------------------------------------------------===//
125 // Actual A64 Instruction Formats
128 // Format for Add-subtract (extended register) instructions.
129 class A64I_addsubext<bit sf, bit op, bit S, bits<2> opt, bits<3> option,
130 dag outs, dag ins, string asmstr, list<dag> patterns,
132 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
138 let Inst{28-24} = 0b01011;
139 let Inst{23-22} = opt;
141 // Rm inherited in 20-16
142 let Inst{15-13} = option;
143 let Inst{12-10} = Imm3;
144 // Rn inherited in 9-5
145 // Rd inherited in 4-0
148 // Format for Add-subtract (immediate) instructions.
149 class A64I_addsubimm<bit sf, bit op, bit S, bits<2> shift,
150 dag outs, dag ins, string asmstr,
151 list<dag> patterns, InstrItinClass itin>
152 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
158 let Inst{28-24} = 0b10001;
159 let Inst{23-22} = shift;
160 let Inst{21-10} = Imm12;
163 // Format for Add-subtract (shifted register) instructions.
164 class A64I_addsubshift<bit sf, bit op, bit S, bits<2> shift,
165 dag outs, dag ins, string asmstr, list<dag> patterns,
167 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
173 let Inst{28-24} = 0b01011;
174 let Inst{23-22} = shift;
176 // Rm inherited in 20-16
177 let Inst{15-10} = Imm6;
178 // Rn inherited in 9-5
179 // Rd inherited in 4-0
182 // Format for Add-subtract (with carry) instructions.
183 class A64I_addsubcarry<bit sf, bit op, bit S, bits<6> opcode2,
184 dag outs, dag ins, string asmstr, list<dag> patterns,
186 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
190 let Inst{28-21} = 0b11010000;
191 // Rm inherited in 20-16
192 let Inst{15-10} = opcode2;
193 // Rn inherited in 9-5
194 // Rd inherited in 4-0
198 // Format for Bitfield instructions
199 class A64I_bitfield<bit sf, bits<2> opc, bit n,
200 dag outs, dag ins, string asmstr,
201 list<dag> patterns, InstrItinClass itin>
202 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
207 let Inst{30-29} = opc;
208 let Inst{28-23} = 0b100110;
210 let Inst{21-16} = ImmR;
211 let Inst{15-10} = ImmS;
216 // Format for compare and branch (immediate) instructions.
217 class A64I_cmpbr<bit sf, bit op,
218 dag outs, dag ins, string asmstr,
219 list<dag> patterns, InstrItinClass itin>
220 : A64InstRt<outs, ins, asmstr, patterns, itin> {
224 let Inst{30-25} = 0b011010;
226 let Inst{23-5} = Label;
230 // Format for conditional branch (immediate) instructions.
231 class A64I_condbr<bit o1, bit o0,
232 dag outs, dag ins, string asmstr,
233 list<dag> patterns, InstrItinClass itin>
234 : A64Inst<outs, ins, asmstr, patterns, itin> {
238 let Inst{31-25} = 0b0101010;
240 let Inst{23-5} = Label;
242 let Inst{3-0} = Cond;
245 // Format for conditional compare (immediate) instructions.
246 class A64I_condcmpimm<bit sf, bit op, bit o2, bit o3, bit s,
247 dag outs, dag ins, string asmstr,
248 list<dag> patterns, InstrItinClass itin>
249 : A64Inst<outs, ins, asmstr, patterns, itin> {
258 let Inst{28-21} = 0b11010010;
259 let Inst{20-16} = UImm5;
260 let Inst{15-12} = Cond;
265 let Inst{3-0} = NZCVImm;
268 // Format for conditional compare (register) instructions.
269 class A64I_condcmpreg<bit sf, bit op, bit o2, bit o3, bit s,
270 dag outs, dag ins, string asmstr,
271 list<dag> patterns, InstrItinClass itin>
272 : A64Inst<outs, ins, asmstr, patterns, itin> {
282 let Inst{28-21} = 0b11010010;
283 let Inst{20-16} = Rm;
284 let Inst{15-12} = Cond;
289 let Inst{3-0} = NZCVImm;
292 // Format for conditional select instructions.
293 class A64I_condsel<bit sf, bit op, bit s, bits<2> op2,
294 dag outs, dag ins, string asmstr,
295 list<dag> patterns, InstrItinClass itin>
296 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
302 let Inst{28-21} = 0b11010100;
303 // Inherit Rm in 20-16
304 let Inst{15-12} = Cond;
305 let Inst{11-10} = op2;
310 // Format for data processing (1 source) instructions
311 class A64I_dp_1src<bit sf, bit S, bits<5> opcode2, bits<6> opcode,
312 string asmstr, dag outs, dag ins,
313 list<dag> patterns, InstrItinClass itin>
314 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
318 let Inst{28-21} = 0b11010110;
319 let Inst{20-16} = opcode2;
320 let Inst{15-10} = opcode;
323 // Format for data processing (2 source) instructions
324 class A64I_dp_2src<bit sf, bits<6> opcode, bit S,
325 string asmstr, dag outs, dag ins,
326 list<dag> patterns, InstrItinClass itin>
327 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
331 let Inst{28-21} = 0b11010110;
332 let Inst{15-10} = opcode;
335 // Format for data-processing (3 source) instructions
337 class A64I_dp3<bit sf, bits<6> opcode,
338 dag outs, dag ins, string asmstr,
339 list<dag> patterns, InstrItinClass itin>
340 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
344 let Inst{30-29} = opcode{5-4};
345 let Inst{28-24} = 0b11011;
346 let Inst{23-21} = opcode{3-1};
347 // Inherits Rm in 20-16
348 let Inst{15} = opcode{0};
349 let Inst{14-10} = Ra;
350 // Inherits Rn in 9-5
351 // Inherits Rd in 4-0
354 // Format for exception generation instructions
355 class A64I_exception<bits<3> opc, bits<3> op2, bits<2> ll,
356 dag outs, dag ins, string asmstr,
357 list<dag> patterns, InstrItinClass itin>
358 : A64Inst<outs, ins, asmstr, patterns, itin> {
361 let Inst{31-24} = 0b11010100;
362 let Inst{23-21} = opc;
363 let Inst{20-5} = UImm16;
368 // Format for extract (immediate) instructions
369 class A64I_extract<bit sf, bits<3> op, bit n,
370 dag outs, dag ins, string asmstr,
371 list<dag> patterns, InstrItinClass itin>
372 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
376 let Inst{30-29} = op{2-1};
377 let Inst{28-23} = 0b100111;
379 let Inst{21} = op{0};
380 // Inherits Rm in bits 20-16
381 let Inst{15-10} = LSB;
382 // Inherits Rn in 9-5
383 // Inherits Rd in 4-0
386 // Format for floating-point compare instructions.
387 class A64I_fpcmp<bit m, bit s, bits<2> type, bits<2> op, bits<5> opcode2,
388 dag outs, dag ins, string asmstr,
389 list<dag> patterns, InstrItinClass itin>
390 : A64Inst<outs, ins, asmstr, patterns, itin> {
397 let Inst{28-24} = 0b11110;
398 let Inst{23-22} = type;
400 let Inst{20-16} = Rm;
401 let Inst{15-14} = op;
402 let Inst{13-10} = 0b1000;
404 let Inst{4-0} = opcode2;
407 // Format for floating-point conditional compare instructions.
408 class A64I_fpccmp<bit m, bit s, bits<2> type, bit op,
409 dag outs, dag ins, string asmstr,
410 list<dag> patterns, InstrItinClass itin>
411 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
420 let Inst{28-24} = 0b11110;
421 let Inst{23-22} = type;
423 let Inst{20-16} = Rm;
424 let Inst{15-12} = Cond;
425 let Inst{11-10} = 0b01;
428 let Inst{3-0} = NZCVImm;
431 // Format for floating-point conditional select instructions.
432 class A64I_fpcondsel<bit m, bit s, bits<2> type,
433 dag outs, dag ins, string asmstr,
434 list<dag> patterns, InstrItinClass itin>
435 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
441 let Inst{28-24} = 0b11110;
442 let Inst{23-22} = type;
444 // Inherit Rm in 20-16
445 let Inst{15-12} = Cond;
446 let Inst{11-10} = 0b11;
452 // Format for floating-point data-processing (1 source) instructions.
453 class A64I_fpdp1<bit m, bit s, bits<2> type, bits<6> opcode,
454 dag outs, dag ins, string asmstr,
455 list<dag> patterns, InstrItinClass itin>
456 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
460 let Inst{28-24} = 0b11110;
461 let Inst{23-22} = type;
463 let Inst{20-15} = opcode;
464 let Inst{14-10} = 0b10000;
469 // Format for floating-point data-processing (2 sources) instructions.
470 class A64I_fpdp2<bit m, bit s, bits<2> type, bits<4> opcode,
471 dag outs, dag ins, string asmstr,
472 list<dag> patterns, InstrItinClass itin>
473 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
477 let Inst{28-24} = 0b11110;
478 let Inst{23-22} = type;
480 // Inherit Rm in 20-16
481 let Inst{15-12} = opcode;
482 let Inst{11-10} = 0b10;
487 // Format for floating-point data-processing (3 sources) instructions.
488 class A64I_fpdp3<bit m, bit s, bits<2> type, bit o1, bit o0,
489 dag outs, dag ins, string asmstr,
490 list<dag> patterns, InstrItinClass itin>
491 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
497 let Inst{28-24} = 0b11111;
498 let Inst{23-22} = type;
500 // Inherit Rm in 20-16
502 let Inst{14-10} = Ra;
507 // Format for floating-point <-> fixed-point conversion instructions.
508 class A64I_fpfixed<bit sf, bit s, bits<2> type, bits<2> mode, bits<3> opcode,
509 dag outs, dag ins, string asmstr,
510 list<dag> patterns, InstrItinClass itin>
511 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
517 let Inst{28-24} = 0b11110;
518 let Inst{23-22} = type;
520 let Inst{20-19} = mode;
521 let Inst{18-16} = opcode;
522 let Inst{15-10} = Scale;
527 // Format for floating-point <-> integer conversion instructions.
528 class A64I_fpint<bit sf, bit s, bits<2> type, bits<2> rmode, bits<3> opcode,
529 dag outs, dag ins, string asmstr,
530 list<dag> patterns, InstrItinClass itin>
531 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
535 let Inst{28-24} = 0b11110;
536 let Inst{23-22} = type;
538 let Inst{20-19} = rmode;
539 let Inst{18-16} = opcode;
540 let Inst{15-10} = 0b000000;
546 // Format for floating-point immediate instructions.
547 class A64I_fpimm<bit m, bit s, bits<2> type, bits<5> imm5,
548 dag outs, dag ins, string asmstr,
549 list<dag> patterns, InstrItinClass itin>
550 : A64InstRd<outs, ins, asmstr, patterns, itin> {
556 let Inst{28-24} = 0b11110;
557 let Inst{23-22} = type;
559 let Inst{20-13} = Imm8;
560 let Inst{12-10} = 0b100;
561 let Inst{9-5} = imm5;
565 // Format for load-register (literal) instructions.
566 class A64I_LDRlit<bits<2> opc, bit v,
567 dag outs, dag ins, string asmstr,
568 list<dag> patterns, InstrItinClass itin>
569 : A64InstRt<outs, ins, asmstr, patterns, itin> {
572 let Inst{31-30} = opc;
573 let Inst{29-27} = 0b011;
575 let Inst{25-24} = 0b00;
576 let Inst{23-5} = Imm19;
580 // Format for load-store exclusive instructions.
581 class A64I_LDSTex_tn<bits<2> size, bit o2, bit L, bit o1, bit o0,
582 dag outs, dag ins, string asmstr,
583 list <dag> patterns, InstrItinClass itin>
584 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
585 let Inst{31-30} = size;
586 let Inst{29-24} = 0b001000;
593 class A64I_LDSTex_tt2n<bits<2> size, bit o2, bit L, bit o1, bit o0,
594 dag outs, dag ins, string asmstr,
595 list <dag> patterns, InstrItinClass itin>:
596 A64I_LDSTex_tn<size, o2, L, o1, o0, outs, ins, asmstr, patterns, itin>{
598 let Inst{14-10} = Rt2;
601 class A64I_LDSTex_stn<bits<2> size, bit o2, bit L, bit o1, bit o0,
602 dag outs, dag ins, string asmstr,
603 list <dag> patterns, InstrItinClass itin>:
604 A64I_LDSTex_tn<size, o2, L, o1, o0, outs, ins, asmstr, patterns, itin>{
606 let Inst{20-16} = Rs;
609 class A64I_LDSTex_stt2n<bits<2> size, bit o2, bit L, bit o1, bit o0,
610 dag outs, dag ins, string asmstr,
611 list <dag> patterns, InstrItinClass itin>:
612 A64I_LDSTex_stn<size, o2, L, o1, o0, outs, ins, asmstr, patterns, itin>{
614 let Inst{14-10} = Rt2;
617 // Format for load-store register (immediate post-indexed) instructions
618 class A64I_LSpostind<bits<2> size, bit v, bits<2> opc,
619 dag outs, dag ins, string asmstr,
620 list<dag> patterns, InstrItinClass itin>
621 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
624 let Inst{31-30} = size;
625 let Inst{29-27} = 0b111;
627 let Inst{25-24} = 0b00;
628 let Inst{23-22} = opc;
630 let Inst{20-12} = SImm9;
631 let Inst{11-10} = 0b01;
636 // Format for load-store register (immediate pre-indexed) instructions
637 class A64I_LSpreind<bits<2> size, bit v, bits<2> opc,
638 dag outs, dag ins, string asmstr,
639 list<dag> patterns, InstrItinClass itin>
640 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
644 let Inst{31-30} = size;
645 let Inst{29-27} = 0b111;
647 let Inst{25-24} = 0b00;
648 let Inst{23-22} = opc;
650 let Inst{20-12} = SImm9;
651 let Inst{11-10} = 0b11;
656 // Format for load-store register (unprivileged) instructions
657 class A64I_LSunpriv<bits<2> size, bit v, bits<2> opc,
658 dag outs, dag ins, string asmstr,
659 list<dag> patterns, InstrItinClass itin>
660 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
664 let Inst{31-30} = size;
665 let Inst{29-27} = 0b111;
667 let Inst{25-24} = 0b00;
668 let Inst{23-22} = opc;
670 let Inst{20-12} = SImm9;
671 let Inst{11-10} = 0b10;
676 // Format for load-store (unscaled immediate) instructions.
677 class A64I_LSunalimm<bits<2> size, bit v, bits<2> opc,
678 dag outs, dag ins, string asmstr,
679 list<dag> patterns, InstrItinClass itin>
680 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
683 let Inst{31-30} = size;
684 let Inst{29-27} = 0b111;
686 let Inst{25-24} = 0b00;
687 let Inst{23-22} = opc;
689 let Inst{20-12} = SImm9;
690 let Inst{11-10} = 0b00;
696 // Format for load-store (unsigned immediate) instructions.
697 class A64I_LSunsigimm<bits<2> size, bit v, bits<2> opc,
698 dag outs, dag ins, string asmstr,
699 list<dag> patterns, InstrItinClass itin>
700 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
703 let Inst{31-30} = size;
704 let Inst{29-27} = 0b111;
706 let Inst{25-24} = 0b01;
707 let Inst{23-22} = opc;
708 let Inst{21-10} = UImm12;
711 // Format for load-store register (register offset) instructions.
712 class A64I_LSregoff<bits<2> size, bit v, bits<2> opc, bit optionlo,
713 dag outs, dag ins, string asmstr,
714 list<dag> patterns, InstrItinClass itin>
715 : A64InstRtn<outs, ins, asmstr, patterns, itin> {
718 // Complex operand selection needed for these instructions, so they
719 // need an "addr" field for encoding/decoding to be generated.
721 // OptionHi = Ext{2-1}
724 let Inst{31-30} = size;
725 let Inst{29-27} = 0b111;
727 let Inst{25-24} = 0b00;
728 let Inst{23-22} = opc;
730 let Inst{20-16} = Rm;
731 let Inst{15-14} = Ext{2-1};
732 let Inst{13} = optionlo;
733 let Inst{12} = Ext{0};
734 let Inst{11-10} = 0b10;
735 // Inherits Rn in 9-5
736 // Inherits Rt in 4-0
738 let AddedComplexity = 50;
741 // Format for Load-store register pair (offset) instructions
742 class A64I_LSPoffset<bits<2> opc, bit v, bit l,
743 dag outs, dag ins, string asmstr,
744 list<dag> patterns, InstrItinClass itin>
745 : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
748 let Inst{31-30} = opc;
749 let Inst{29-27} = 0b101;
751 let Inst{25-23} = 0b010;
753 let Inst{21-15} = SImm7;
754 // Inherit Rt2 in 14-10
759 // Format for Load-store register pair (post-indexed) instructions
760 class A64I_LSPpostind<bits<2> opc, bit v, bit l,
761 dag outs, dag ins, string asmstr,
762 list<dag> patterns, InstrItinClass itin>
763 : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
766 let Inst{31-30} = opc;
767 let Inst{29-27} = 0b101;
769 let Inst{25-23} = 0b001;
771 let Inst{21-15} = SImm7;
772 // Inherit Rt2 in 14-10
777 // Format for Load-store register pair (pre-indexed) instructions
778 class A64I_LSPpreind<bits<2> opc, bit v, bit l,
779 dag outs, dag ins, string asmstr,
780 list<dag> patterns, InstrItinClass itin>
781 : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
784 let Inst{31-30} = opc;
785 let Inst{29-27} = 0b101;
787 let Inst{25-23} = 0b011;
789 let Inst{21-15} = SImm7;
790 // Inherit Rt2 in 14-10
795 // Format for Load-store non-temporal register pair (offset) instructions
796 class A64I_LSPnontemp<bits<2> opc, bit v, bit l,
797 dag outs, dag ins, string asmstr,
798 list<dag> patterns, InstrItinClass itin>
799 : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
802 let Inst{31-30} = opc;
803 let Inst{29-27} = 0b101;
805 let Inst{25-23} = 0b000;
807 let Inst{21-15} = SImm7;
808 // Inherit Rt2 in 14-10
813 // Format for Logical (immediate) instructions
814 class A64I_logicalimm<bit sf, bits<2> opc,
815 dag outs, dag ins, string asmstr,
816 list<dag> patterns, InstrItinClass itin>
817 : A64InstRdn<outs, ins, asmstr, patterns, itin> {
822 // N, ImmR and ImmS have no separate existence in any assembly syntax (or for
823 // selection), so we'll combine them into a single field here.
830 let Inst{30-29} = opc;
831 let Inst{28-23} = 0b100100;
832 let Inst{22} = Imm{12};
833 let Inst{21-16} = Imm{11-6};
834 let Inst{15-10} = Imm{5-0};
835 // Rn inherited in 9-5
836 // Rd inherited in 4-0
839 // Format for Logical (shifted register) instructions
840 class A64I_logicalshift<bit sf, bits<2> opc, bits<2> shift, bit N,
841 dag outs, dag ins, string asmstr,
842 list<dag> patterns, InstrItinClass itin>
843 : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
847 let Inst{30-29} = opc;
848 let Inst{28-24} = 0b01010;
849 let Inst{23-22} = shift;
852 let Inst{15-10} = Imm6;
857 // Format for Move wide (immediate)
858 class A64I_movw<bit sf, bits<2> opc,
859 dag outs, dag ins, string asmstr,
860 list<dag> patterns, InstrItinClass itin>
861 : A64InstRd<outs, ins, asmstr, patterns, itin> {
863 bits<2> Shift; // Called "hw" officially
866 let Inst{30-29} = opc;
867 let Inst{28-23} = 0b100101;
868 let Inst{22-21} = Shift;
869 let Inst{20-5} = UImm16;
870 // Inherits Rd in 4-0
873 // Format for PC-relative addressing instructions, ADR and ADRP.
874 class A64I_PCADR<bit op,
875 dag outs, dag ins, string asmstr,
876 list<dag> patterns, InstrItinClass itin>
877 : A64InstRd<outs, ins, asmstr, patterns, itin> {
881 let Inst{30-29} = Label{1-0};
882 let Inst{28-24} = 0b10000;
883 let Inst{23-5} = Label{20-2};
886 // Format for system instructions
887 class A64I_system<bit l,
888 dag outs, dag ins, string asmstr,
889 list<dag> patterns, InstrItinClass itin>
890 : A64Inst<outs, ins, asmstr, patterns, itin> {
898 let Inst{31-22} = 0b1101010100;
900 let Inst{20-19} = Op0;
901 let Inst{18-16} = Op1;
902 let Inst{15-12} = CRn;
903 let Inst{11-8} = CRm;
907 // These instructions can do horrible things.
908 let hasSideEffects = 1;
911 // Format for unconditional branch (immediate) instructions
912 class A64I_Bimm<bit op,
913 dag outs, dag ins, string asmstr,
914 list<dag> patterns, InstrItinClass itin>
915 : A64Inst<outs, ins, asmstr, patterns, itin> {
916 // Doubly special in not even sharing register fields with other
917 // instructions, so we create our own Rn here.
921 let Inst{30-26} = 0b00101;
922 let Inst{25-0} = Label;
925 // Format for Test & branch (immediate) instructions
926 class A64I_TBimm<bit op,
927 dag outs, dag ins, string asmstr,
928 list<dag> patterns, InstrItinClass itin>
929 : A64InstRt<outs, ins, asmstr, patterns, itin> {
930 // Doubly special in not even sharing register fields with other
931 // instructions, so we create our own Rn here.
935 let Inst{31} = Imm{5};
936 let Inst{30-25} = 0b011011;
938 let Inst{23-19} = Imm{4-0};
939 let Inst{18-5} = Label;
943 // Format for Unconditional branch (register) instructions, including
944 // RET. Shares no fields with instructions further up the hierarchy
946 class A64I_Breg<bits<4> opc, bits<5> op2, bits<6> op3, bits<5> op4,
947 dag outs, dag ins, string asmstr,
948 list<dag> patterns, InstrItinClass itin>
949 : A64Inst<outs, ins, asmstr, patterns, itin> {
950 // Doubly special in not even sharing register fields with other
951 // instructions, so we create our own Rn here.
954 let Inst{31-25} = 0b1101011;
955 let Inst{24-21} = opc;
956 let Inst{20-16} = op2;
957 let Inst{15-10} = op3;
963 //===----------------------------------------------------------------------===//
965 // Neon Instruction Format Definitions.
968 let Predicates = [HasNEON] in {
970 class NeonInstAlias<string Asm, dag Result, bit Emit = 0b1>
971 : InstAlias<Asm, Result, Emit> {
974 // Format AdvSIMD 3 vector registers with same vector type
975 class NeonI_3VSame<bit q, bit u, bits<2> size, bits<5> opcode,
976 dag outs, dag ins, string asmstr,
977 list<dag> patterns, InstrItinClass itin>
978 : A64InstRdnm<outs, ins, asmstr, patterns, itin>
983 let Inst{28-24} = 0b01110;
984 let Inst{23-22} = size;
986 // Inherit Rm in 20-16
987 let Inst{15-11} = opcode;
993 // Format AdvSIMD 3 vector registers with different vector type
994 class NeonI_3VDiff<bit q, bit u, bits<2> size, bits<4> opcode,
995 dag outs, dag ins, string asmstr,
996 list<dag> patterns, InstrItinClass itin>
997 : A64InstRdnm<outs, ins, asmstr, patterns, itin>
1002 let Inst{28-24} = 0b01110;
1003 let Inst{23-22} = size;
1005 // Inherit Rm in 20-16
1006 let Inst{15-12} = opcode;
1009 // Inherit Rn in 9-5
1010 // Inherit Rd in 4-0
1013 // Format AdvSIMD 1 vector register with modified immediate
1014 class NeonI_1VModImm<bit q, bit op,
1015 dag outs, dag ins, string asmstr,
1016 list<dag> patterns, InstrItinClass itin>
1017 : A64InstRd<outs,ins, asmstr, patterns, itin>
1024 let Inst{28-19} = 0b0111100000;
1025 let Inst{15-12} = cmode;
1026 let Inst{11} = 0b0; // o2
1028 // Inherit Rd in 4-0
1029 let Inst{18-16} = Imm{7-5}; // imm a:b:c
1030 let Inst{9-5} = Imm{4-0}; // imm d:e:f:g:h
1033 // Format AdvSIMD 3 scalar registers with same type
1035 class NeonI_Scalar3Same<bit u, bits<2> size, bits<5> opcode,
1036 dag outs, dag ins, string asmstr,
1037 list<dag> patterns, InstrItinClass itin>
1038 : A64InstRdnm<outs, ins, asmstr, patterns, itin>
1043 let Inst{28-24} = 0b11110;
1044 let Inst{23-22} = size;
1046 // Inherit Rm in 20-16
1047 let Inst{15-11} = opcode;
1049 // Inherit Rn in 9-5
1050 // Inherit Rd in 4-0
1054 // Format AdvSIMD 2 vector registers miscellaneous
1055 class NeonI_2VMisc<bit q, bit u, bits<2> size, bits<5> opcode,
1056 dag outs, dag ins, string asmstr,
1057 list<dag> patterns, InstrItinClass itin>
1058 : A64InstRdn<outs, ins, asmstr, patterns, itin>
1063 let Inst{28-24} = 0b01110;
1064 let Inst{23-22} = size;
1065 let Inst{21-17} = 0b10000;
1066 let Inst{16-12} = opcode;
1067 let Inst{11-10} = 0b10;
1069 // Inherit Rn in 9-5
1070 // Inherit Rd in 4-0
1073 // Format AdvSIMD 2 vector 1 immediate shift
1074 class NeonI_2VShiftImm<bit q, bit u, bits<5> opcode,
1075 dag outs, dag ins, string asmstr,
1076 list<dag> patterns, InstrItinClass itin>
1077 : A64InstRdn<outs, ins, asmstr, patterns, itin>
1083 let Inst{28-23} = 0b011110;
1084 let Inst{22-16} = Imm;
1085 let Inst{15-11} = opcode;
1088 // Inherit Rn in 9-5
1089 // Inherit Rd in 4-0
1092 // Format AdvSIMD duplicate and insert
1093 class NeonI_copy<bit q, bit op, bits<4> imm4,
1094 dag outs, dag ins, string asmstr,
1095 list<dag> patterns, InstrItinClass itin>
1096 : A64InstRdn<outs, ins, asmstr, patterns, itin>
1102 let Inst{28-21} = 0b01110000;
1103 let Inst{20-16} = Imm5;
1105 let Inst{14-11} = imm4;
1108 // Inherit Rn in 9-5
1109 // Inherit Rd in 4-0
1111 // Format AdvSIMD insert from element to vector
1112 class NeonI_insert<bit q, bit op,
1113 dag outs, dag ins, string asmstr,
1114 list<dag> patterns, InstrItinClass itin>
1115 : A64InstRdn<outs, ins, asmstr, patterns, itin>
1122 let Inst{28-21} = 0b01110000;
1123 let Inst{20-16} = Imm5;
1125 let Inst{14-11} = Imm4;
1128 // Inherit Rn in 9-5
1129 // Inherit Rd in 4-0