AArch64: error when both positional & named operands are used.
[oota-llvm.git] / lib / Target / AArch64 / AArch64InstrFormats.td
1 //===- AArch64InstrFormats.td - AArch64 Instruction Formats --*- tablegen -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // This file describes AArch64 instruction formats, down to the level of the
10 // instruction's overall class.
11 //===----------------------------------------------------------------------===//
12
13
14 //===----------------------------------------------------------------------===//
15 // A64 Instruction Format Definitions.
16 //===----------------------------------------------------------------------===//
17
18 // A64 is currently the only instruction set supported by the AArch64
19 // architecture.
20 class A64Inst<dag outs, dag ins, string asmstr, list<dag> patterns,
21               InstrItinClass itin>
22     : Instruction {
23   // All A64 instructions are 32-bit. This field will be filled in
24   // gradually going down the hierarchy.
25   field bits<32> Inst;
26
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;
31
32   // LLVM-level model of the AArch64/A64 distinction.
33   let Namespace = "AArch64";
34   let DecoderNamespace = "A64";
35   let Size = 4;
36
37   // Set the templated fields
38   let OutOperandList = outs;
39   let InOperandList = ins;
40   let AsmString = asmstr;
41   let Pattern = patterns;
42   let Itinerary = itin;
43 }
44
45 class PseudoInst<dag outs, dag ins, list<dag> patterns> : Instruction {
46   let Namespace = "AArch64";
47
48   let OutOperandList = outs;
49   let InOperandList= ins;
50   let Pattern = patterns;
51   let isCodeGenOnly = 1;
52   let isPseudo = 1;
53 }
54
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> {
59   let Size = 4;
60 }
61
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>;
67
68
69 // First, some common cross-hierarchy register formats.
70
71 class A64InstRd<dag outs, dag ins, string asmstr,
72                 list<dag> patterns, InstrItinClass itin>
73   : A64Inst<outs, ins, asmstr, patterns, itin> {
74   bits<5> Rd;
75
76   let Inst{4-0} = Rd;
77 }
78
79 class A64InstRt<dag outs, dag ins, string asmstr,
80                 list<dag> patterns, InstrItinClass itin>
81   : A64Inst<outs, ins, asmstr, patterns, itin> {
82   bits<5> Rt;
83
84   let Inst{4-0} = Rt;
85 }
86
87
88 class A64InstRdn<dag outs, dag ins, string asmstr,
89                  list<dag> patterns, InstrItinClass itin>
90     : A64InstRd<outs, ins, asmstr, patterns, itin> {
91   // Inherit rdt
92   bits<5> Rn;
93
94   let Inst{9-5} = Rn;
95 }
96
97 class A64InstRtn<dag outs, dag ins, string asmstr,
98                 list<dag> patterns, InstrItinClass itin>
99     : A64InstRt<outs, ins, asmstr, patterns, itin> {
100   // Inherit rdt
101   bits<5> Rn;
102
103   let Inst{9-5} = Rn;
104 }
105
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> {
110   bits<5> Rt2;
111
112   let Inst{14-10} = Rt2;
113 }
114
115 class A64InstRdnm<dag outs, dag ins, string asmstr,
116                   list<dag> patterns, InstrItinClass itin>
117   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
118   bits<5> Rm;
119
120   let Inst{20-16} = Rm;
121 }
122
123 class A64InstRtnm<dag outs, dag ins, string asmstr,
124                   list<dag> patterns, InstrItinClass itin>
125   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
126   bits<5> Rm;
127
128   let Inst{20-16} = Rm;
129 }
130
131 //===----------------------------------------------------------------------===//
132 //
133 // Actual A64 Instruction Formats
134 //
135
136 // Format for Add-subtract (extended register) instructions.
137 class A64I_addsubext<bit sf, bit op, bit S, bits<2> opt, bits<3> option,
138                      dag outs, dag ins, string asmstr, list<dag> patterns,
139                      InstrItinClass itin>
140     : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
141     bits<3> Imm3;
142
143     let Inst{31} = sf;
144     let Inst{30} = op;
145     let Inst{29} = S;
146     let Inst{28-24} = 0b01011;
147     let Inst{23-22} = opt;
148     let Inst{21} = 0b1;
149     // Rm inherited in 20-16
150     let Inst{15-13} = option;
151     let Inst{12-10} = Imm3;
152     // Rn inherited in 9-5
153     // Rd inherited in 4-0
154 }
155
156 // Format for Add-subtract (immediate) instructions.
157 class A64I_addsubimm<bit sf, bit op, bit S, bits<2> shift,
158                      dag outs, dag ins, string asmstr,
159                      list<dag> patterns, InstrItinClass itin>
160   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
161   bits<12> Imm12;
162
163   let Inst{31} = sf;
164   let Inst{30} = op;
165   let Inst{29} = S;
166   let Inst{28-24} = 0b10001;
167   let Inst{23-22} = shift;
168   let Inst{21-10} = Imm12;
169 }
170
171 // Format for Add-subtract (shifted register) instructions.
172 class A64I_addsubshift<bit sf, bit op, bit S, bits<2> shift,
173                        dag outs, dag ins, string asmstr, list<dag> patterns,
174                        InstrItinClass itin>
175     : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
176     bits<6> Imm6;
177
178     let Inst{31} = sf;
179     let Inst{30} = op;
180     let Inst{29} = S;
181     let Inst{28-24} = 0b01011;
182     let Inst{23-22} = shift;
183     let Inst{21} = 0b0;
184     // Rm inherited in 20-16
185     let Inst{15-10} = Imm6;
186     // Rn inherited in 9-5
187     // Rd inherited in 4-0
188 }
189
190 // Format for Add-subtract (with carry) instructions.
191 class A64I_addsubcarry<bit sf, bit op, bit S, bits<6> opcode2,
192                        dag outs, dag ins, string asmstr, list<dag> patterns,
193                        InstrItinClass itin>
194     : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
195     let Inst{31} = sf;
196     let Inst{30} = op;
197     let Inst{29} = S;
198     let Inst{28-21} = 0b11010000;
199     // Rm inherited in 20-16
200     let Inst{15-10} = opcode2;
201     // Rn inherited in 9-5
202     // Rd inherited in 4-0
203 }
204
205
206 // Format for Bitfield instructions
207 class A64I_bitfield<bit sf, bits<2> opc, bit n,
208                     dag outs, dag ins, string asmstr,
209                     list<dag> patterns, InstrItinClass itin>
210   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
211   bits<6> ImmR;
212   bits<6> ImmS;
213
214   let Inst{31} = sf;
215   let Inst{30-29} = opc;
216   let Inst{28-23} = 0b100110;
217   let Inst{22} = n;
218   let Inst{21-16} = ImmR;
219   let Inst{15-10} = ImmS;
220   // Inherit Rn in 9-5
221   // Inherit Rd in 4-0
222 }
223
224 // Format for compare and branch (immediate) instructions.
225 class A64I_cmpbr<bit sf, bit op,
226                   dag outs, dag ins, string asmstr,
227                   list<dag> patterns, InstrItinClass itin>
228   : A64InstRt<outs, ins, asmstr, patterns, itin> {
229   bits<19> Label;
230
231   let Inst{31} = sf;
232   let Inst{30-25} = 0b011010;
233   let Inst{24} = op;
234   let Inst{23-5} = Label;
235   // Inherit Rt in 4-0
236 }
237
238 // Format for conditional branch (immediate) instructions.
239 class A64I_condbr<bit o1, bit o0,
240                   dag outs, dag ins, string asmstr,
241                   list<dag> patterns, InstrItinClass itin>
242   : A64Inst<outs, ins, asmstr, patterns, itin> {
243   bits<19> Label;
244   bits<4> Cond;
245
246   let Inst{31-25} = 0b0101010;
247   let Inst{24} = o1;
248   let Inst{23-5} = Label;
249   let Inst{4} = o0;
250   let Inst{3-0} = Cond;
251 }
252
253 // Format for conditional compare (immediate) instructions.
254 class A64I_condcmpimm<bit sf, bit op, bit o2, bit o3, bit s,
255                       dag outs, dag ins, string asmstr,
256                       list<dag> patterns, InstrItinClass itin>
257   : A64Inst<outs, ins, asmstr, patterns, itin> {
258   bits<5> Rn;
259   bits<5> UImm5;
260   bits<4> NZCVImm;
261   bits<4> Cond;
262
263   let Inst{31} = sf;
264   let Inst{30} = op;
265   let Inst{29} = s;
266   let Inst{28-21} = 0b11010010;
267   let Inst{20-16} = UImm5;
268   let Inst{15-12} = Cond;
269   let Inst{11} = 0b1;
270   let Inst{10} = o2;
271   let Inst{9-5} = Rn;
272   let Inst{4} = o3;
273   let Inst{3-0} = NZCVImm;
274 }
275
276 // Format for conditional compare (register) instructions.
277 class A64I_condcmpreg<bit sf, bit op, bit o2, bit o3, bit s,
278                       dag outs, dag ins, string asmstr,
279                       list<dag> patterns, InstrItinClass itin>
280   : A64Inst<outs, ins, asmstr, patterns, itin> {
281   bits<5> Rn;
282   bits<5> Rm;
283   bits<4> NZCVImm;
284   bits<4> Cond;
285
286
287   let Inst{31} = sf;
288   let Inst{30} = op;
289   let Inst{29} = s;
290   let Inst{28-21} = 0b11010010;
291   let Inst{20-16} = Rm;
292   let Inst{15-12} = Cond;
293   let Inst{11} = 0b0;
294   let Inst{10} = o2;
295   let Inst{9-5} = Rn;
296   let Inst{4} = o3;
297   let Inst{3-0} = NZCVImm;
298 }
299
300 // Format for conditional select instructions.
301 class A64I_condsel<bit sf, bit op, bit s, bits<2> op2,
302                    dag outs, dag ins, string asmstr,
303                    list<dag> patterns, InstrItinClass itin>
304   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
305   bits<4> Cond;
306
307   let Inst{31} = sf;
308   let Inst{30} = op;
309   let Inst{29} = s;
310   let Inst{28-21} = 0b11010100;
311   // Inherit Rm in 20-16
312   let Inst{15-12} = Cond;
313   let Inst{11-10} = op2;
314   // Inherit Rn in 9-5
315   // Inherit Rd in 4-0
316 }
317
318 // Format for data processing (1 source) instructions
319 class A64I_dp_1src<bit sf, bit S, bits<5> opcode2, bits<6> opcode,
320                 string asmstr, dag outs, dag ins,
321                 list<dag> patterns, InstrItinClass itin>
322   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
323   let Inst{31} = sf;
324   let Inst{30} = 0b1;
325   let Inst{29} = S;
326   let Inst{28-21} = 0b11010110;
327   let Inst{20-16} = opcode2;
328   let Inst{15-10} = opcode;
329 }
330
331 // Format for data processing (2 source) instructions
332 class A64I_dp_2src<bit sf, bits<6> opcode, bit S,
333                 string asmstr, dag outs, dag ins,
334                 list<dag> patterns, InstrItinClass itin>
335   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
336   let Inst{31} = sf;
337   let Inst{30} = 0b0;
338   let Inst{29} = S;
339   let Inst{28-21} = 0b11010110;
340   let Inst{15-10} = opcode;
341 }
342
343 // Format for data-processing (3 source) instructions
344
345 class A64I_dp3<bit sf, bits<6> opcode,
346                dag outs, dag ins, string asmstr,
347                list<dag> patterns, InstrItinClass itin>
348   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
349   let Inst{31} = sf;
350   let Inst{30-29} = opcode{5-4};
351   let Inst{28-24} = 0b11011;
352   let Inst{23-21} = opcode{3-1};
353   // Inherits Rm in 20-16
354   let Inst{15} = opcode{0};
355   // {14-10} mostly Ra, but unspecified for SMULH/UMULH
356   // Inherits Rn in 9-5
357   // Inherits Rd in 4-0
358 }
359
360 // Format for exception generation instructions
361 class A64I_exception<bits<3> opc, bits<3> op2, bits<2> ll,
362                      dag outs, dag ins, string asmstr,
363                      list<dag> patterns, InstrItinClass itin>
364   : A64Inst<outs, ins, asmstr, patterns, itin> {
365   bits<16> UImm16;
366
367   let Inst{31-24} = 0b11010100;
368   let Inst{23-21} = opc;
369   let Inst{20-5} = UImm16;
370   let Inst{4-2} = op2;
371   let Inst{1-0} = ll;
372 }
373
374 // Format for extract (immediate) instructions
375 class A64I_extract<bit sf, bits<3> op, bit n,
376                    dag outs, dag ins, string asmstr,
377                    list<dag> patterns, InstrItinClass itin>
378   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
379   bits<6> LSB;
380
381   let Inst{31} = sf;
382   let Inst{30-29} = op{2-1};
383   let Inst{28-23} = 0b100111;
384   let Inst{22} = n;
385   let Inst{21} = op{0};
386   // Inherits Rm in bits 20-16
387   let Inst{15-10} = LSB;
388   // Inherits Rn in 9-5
389   // Inherits Rd in 4-0
390 }
391
392 let Predicates = [HasFPARMv8] in {
393
394 // Format for floating-point compare instructions.
395 class A64I_fpcmp<bit m, bit s, bits<2> type, bits<2> op, bits<5> opcode2,
396                 dag outs, dag ins, string asmstr,
397                 list<dag> patterns, InstrItinClass itin>
398   : A64Inst<outs, ins, asmstr, patterns, itin> {
399   bits<5> Rn;
400   bits<5> Rm;
401
402   let Inst{31} = m;
403   let Inst{30} = 0b0;
404   let Inst{29} = s;
405   let Inst{28-24} = 0b11110;
406   let Inst{23-22} = type;
407   let Inst{21} = 0b1;
408   let Inst{20-16} = Rm;
409   let Inst{15-14} = op;
410   let Inst{13-10} = 0b1000;
411   let Inst{9-5} = Rn;
412   let Inst{4-0} = opcode2;
413 }
414
415 // Format for floating-point conditional compare instructions.
416 class A64I_fpccmp<bit m, bit s, bits<2> type, bit op,
417                  dag outs, dag ins, string asmstr,
418                  list<dag> patterns, InstrItinClass itin>
419   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
420   bits<5> Rn;
421   bits<5> Rm;
422   bits<4> NZCVImm;
423   bits<4> Cond;
424
425   let Inst{31} = m;
426   let Inst{30} = 0b0;
427   let Inst{29} = s;
428   let Inst{28-24} = 0b11110;
429   let Inst{23-22} = type;
430   let Inst{21} = 0b1;
431   let Inst{20-16} = Rm;
432   let Inst{15-12} = Cond;
433   let Inst{11-10} = 0b01;
434   let Inst{9-5} = Rn;
435   let Inst{4} = op;
436   let Inst{3-0} = NZCVImm;
437 }
438
439 // Format for floating-point conditional select instructions.
440 class A64I_fpcondsel<bit m, bit s, bits<2> type,
441                      dag outs, dag ins, string asmstr,
442                      list<dag> patterns, InstrItinClass itin>
443   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
444   bits<4> Cond;
445
446   let Inst{31} = m;
447   let Inst{30} = 0b0;
448   let Inst{29} = s;
449   let Inst{28-24} = 0b11110;
450   let Inst{23-22} = type;
451   let Inst{21} = 0b1;
452   // Inherit Rm in 20-16
453   let Inst{15-12} = Cond;
454   let Inst{11-10} = 0b11;
455   // Inherit Rn in 9-5
456   // Inherit Rd in 4-0
457 }
458
459
460 // Format for floating-point data-processing (1 source) instructions.
461 class A64I_fpdp1<bit m, bit s, bits<2> type, bits<6> opcode,
462                  dag outs, dag ins, string asmstr,
463                  list<dag> patterns, InstrItinClass itin>
464   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
465   let Inst{31} = m;
466   let Inst{30} = 0b0;
467   let Inst{29} = s;
468   let Inst{28-24} = 0b11110;
469   let Inst{23-22} = type;
470   let Inst{21} = 0b1;
471   let Inst{20-15} = opcode;
472   let Inst{14-10} = 0b10000;
473   // Inherit Rn in 9-5
474   // Inherit Rd in 4-0
475 }
476
477 // Format for floating-point data-processing (2 sources) instructions.
478 class A64I_fpdp2<bit m, bit s, bits<2> type, bits<4> opcode,
479                  dag outs, dag ins, string asmstr,
480                  list<dag> patterns, InstrItinClass itin>
481   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
482   let Inst{31} = m;
483   let Inst{30} = 0b0;
484   let Inst{29} = s;
485   let Inst{28-24} = 0b11110;
486   let Inst{23-22} = type;
487   let Inst{21} = 0b1;
488   // Inherit Rm in 20-16
489   let Inst{15-12} = opcode;
490   let Inst{11-10} = 0b10;
491   // Inherit Rn in 9-5
492   // Inherit Rd in 4-0
493 }
494
495 // Format for floating-point data-processing (3 sources) instructions.
496 class A64I_fpdp3<bit m, bit s, bits<2> type, bit o1, bit o0,
497                  dag outs, dag ins, string asmstr,
498                  list<dag> patterns, InstrItinClass itin>
499   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
500   bits<5> Ra;
501
502   let Inst{31} = m;
503   let Inst{30} = 0b0;
504   let Inst{29} = s;
505   let Inst{28-24} = 0b11111;
506   let Inst{23-22} = type;
507   let Inst{21} = o1;
508   // Inherit Rm in 20-16
509   let Inst{15} = o0;
510   let Inst{14-10} = Ra;
511   // Inherit Rn in 9-5
512   // Inherit Rd in 4-0
513 }
514
515 // Format for floating-point <-> fixed-point conversion instructions.
516 class A64I_fpfixed<bit sf, bit s, bits<2> type, bits<2> mode, bits<3> opcode,
517                  dag outs, dag ins, string asmstr,
518                  list<dag> patterns, InstrItinClass itin>
519   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
520   bits<6> Scale;
521
522   let Inst{31} = sf;
523   let Inst{30} = 0b0;
524   let Inst{29} = s;
525   let Inst{28-24} = 0b11110;
526   let Inst{23-22} = type;
527   let Inst{21} = 0b0;
528   let Inst{20-19} = mode;
529   let Inst{18-16} = opcode;
530   let Inst{15-10} = Scale;
531   // Inherit Rn in 9-5
532   // Inherit Rd in 4-0
533 }
534
535 // Format for floating-point <-> integer conversion instructions.
536 class A64I_fpint<bit sf, bit s, bits<2> type, bits<2> rmode, bits<3> opcode,
537                  dag outs, dag ins, string asmstr,
538                  list<dag> patterns, InstrItinClass itin>
539   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
540   let Inst{31} = sf;
541   let Inst{30} = 0b0;
542   let Inst{29} = s;
543   let Inst{28-24} = 0b11110;
544   let Inst{23-22} = type;
545   let Inst{21} = 0b1;
546   let Inst{20-19} = rmode;
547   let Inst{18-16} = opcode;
548   let Inst{15-10} = 0b000000;
549   // Inherit Rn in 9-5
550   // Inherit Rd in 4-0
551 }
552
553
554 // Format for floating-point immediate instructions.
555 class A64I_fpimm<bit m, bit s, bits<2> type, bits<5> imm5,
556                  dag outs, dag ins, string asmstr,
557                  list<dag> patterns, InstrItinClass itin>
558   : A64InstRd<outs, ins, asmstr, patterns, itin> {
559   bits<8> Imm8;
560
561   let Inst{31} = m;
562   let Inst{30} = 0b0;
563   let Inst{29} = s;
564   let Inst{28-24} = 0b11110;
565   let Inst{23-22} = type;
566   let Inst{21} = 0b1;
567   let Inst{20-13} = Imm8;
568   let Inst{12-10} = 0b100;
569   let Inst{9-5} = imm5;
570   // Inherit Rd in 4-0
571 }
572
573 }
574
575 // Format for load-register (literal) instructions.
576 class A64I_LDRlit<bits<2> opc, bit v,
577                   dag outs, dag ins, string asmstr,
578                   list<dag> patterns, InstrItinClass itin>
579   : A64InstRt<outs, ins, asmstr, patterns, itin> {
580   bits<19> Imm19;
581
582   let Inst{31-30} = opc;
583   let Inst{29-27} = 0b011;
584   let Inst{26} = v;
585   let Inst{25-24} = 0b00;
586   let Inst{23-5} = Imm19;
587   // Inherit Rt in 4-0
588 }
589
590 // Format for load-store exclusive instructions.
591 class A64I_LDSTex_tn<bits<2> size, bit o2, bit L, bit o1, bit o0,
592                  dag outs, dag ins, string asmstr,
593                  list <dag> patterns, InstrItinClass itin>
594   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
595   let Inst{31-30} = size;
596   let Inst{29-24} = 0b001000;
597   let Inst{23} = o2;
598   let Inst{22} = L;
599   let Inst{21} = o1;
600   let Inst{15} = o0;
601 }
602
603 class A64I_LDSTex_tt2n<bits<2> size, bit o2, bit L, bit o1, bit o0,
604                      dag outs, dag ins, string asmstr,
605                      list <dag> patterns, InstrItinClass itin>:
606       A64I_LDSTex_tn<size, o2, L, o1, o0, outs, ins, asmstr, patterns, itin>{
607    bits<5> Rt2;
608    let Inst{14-10} = Rt2;
609 }
610
611 class A64I_LDSTex_stn<bits<2> size, bit o2, bit L, bit o1, bit o0,
612                      dag outs, dag ins, string asmstr,
613                      list <dag> patterns, InstrItinClass itin>:
614       A64I_LDSTex_tn<size, o2, L, o1, o0, outs, ins, asmstr, patterns, itin>{
615    bits<5> Rs;
616    let Inst{20-16} = Rs;
617 }
618
619 class A64I_LDSTex_stt2n<bits<2> size, bit o2, bit L, bit o1, bit o0,
620                      dag outs, dag ins, string asmstr,
621                      list <dag> patterns, InstrItinClass itin>:
622       A64I_LDSTex_stn<size, o2, L, o1, o0, outs, ins, asmstr, patterns, itin>{
623    bits<5> Rt2;
624    let Inst{14-10} = Rt2;
625 }
626
627 // Format for load-store register (immediate post-indexed) instructions
628 class A64I_LSpostind<bits<2> size, bit v, bits<2> opc,
629                      dag outs, dag ins, string asmstr,
630                      list<dag> patterns, InstrItinClass itin>
631   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
632   bits<9> SImm9;
633
634   let Inst{31-30} = size;
635   let Inst{29-27} = 0b111;
636   let Inst{26} = v;
637   let Inst{25-24} = 0b00;
638   let Inst{23-22} = opc;
639   let Inst{21} = 0b0;
640   let Inst{20-12} = SImm9;
641   let Inst{11-10} = 0b01;
642   // Inherit Rn in 9-5
643   // Inherit Rt in 4-0
644 }
645
646 // Format for load-store register (immediate pre-indexed) instructions
647 class A64I_LSpreind<bits<2> size, bit v, bits<2> opc,
648                     dag outs, dag ins, string asmstr,
649                     list<dag> patterns, InstrItinClass itin>
650   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
651   bits<9> SImm9;
652
653
654   let Inst{31-30} = size;
655   let Inst{29-27} = 0b111;
656   let Inst{26} = v;
657   let Inst{25-24} = 0b00;
658   let Inst{23-22} = opc;
659   let Inst{21} = 0b0;
660   let Inst{20-12} = SImm9;
661   let Inst{11-10} = 0b11;
662   // Inherit Rn in 9-5
663   // Inherit Rt in 4-0
664 }
665
666 // Format for load-store register (unprivileged) instructions
667 class A64I_LSunpriv<bits<2> size, bit v, bits<2> opc,
668                     dag outs, dag ins, string asmstr,
669                     list<dag> patterns, InstrItinClass itin>
670   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
671   bits<9> SImm9;
672
673
674   let Inst{31-30} = size;
675   let Inst{29-27} = 0b111;
676   let Inst{26} = v;
677   let Inst{25-24} = 0b00;
678   let Inst{23-22} = opc;
679   let Inst{21} = 0b0;
680   let Inst{20-12} = SImm9;
681   let Inst{11-10} = 0b10;
682   // Inherit Rn in 9-5
683   // Inherit Rt in 4-0
684 }
685
686 // Format for load-store (unscaled immediate) instructions.
687 class A64I_LSunalimm<bits<2> size, bit v, bits<2> opc,
688                      dag outs, dag ins, string asmstr,
689                      list<dag> patterns, InstrItinClass itin>
690   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
691   bits<9> SImm9;
692
693   let Inst{31-30} = size;
694   let Inst{29-27} = 0b111;
695   let Inst{26} = v;
696   let Inst{25-24} = 0b00;
697   let Inst{23-22} = opc;
698   let Inst{21} = 0b0;
699   let Inst{20-12} = SImm9;
700   let Inst{11-10} = 0b00;
701   // Inherit Rn in 9-5
702   // Inherit Rt in 4-0
703 }
704
705
706 // Format for load-store (unsigned immediate) instructions.
707 class A64I_LSunsigimm<bits<2> size, bit v, bits<2> opc,
708                       dag outs, dag ins, string asmstr,
709                       list<dag> patterns, InstrItinClass itin>
710   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
711   bits<12> UImm12;
712
713   let Inst{31-30} = size;
714   let Inst{29-27} = 0b111;
715   let Inst{26} = v;
716   let Inst{25-24} = 0b01;
717   let Inst{23-22} = opc;
718   let Inst{21-10} = UImm12;
719 }
720
721 // Format for load-store register (register offset) instructions.
722 class A64I_LSregoff<bits<2> size, bit v, bits<2> opc, bit optionlo,
723                     dag outs, dag ins, string asmstr,
724                     list<dag> patterns, InstrItinClass itin>
725   : A64InstRtn<outs, ins, asmstr, patterns, itin> {
726   bits<5> Rm;
727
728   // Complex operand selection needed for these instructions, so they
729   // need an "addr" field for encoding/decoding to be generated.
730   bits<3> Ext;
731   // OptionHi = Ext{2-1}
732   // S = Ext{0}
733
734   let Inst{31-30} = size;
735   let Inst{29-27} = 0b111;
736   let Inst{26} = v;
737   let Inst{25-24} = 0b00;
738   let Inst{23-22} = opc;
739   let Inst{21} = 0b1;
740   let Inst{20-16} = Rm;
741   let Inst{15-14} = Ext{2-1};
742   let Inst{13} = optionlo;
743   let Inst{12} = Ext{0};
744   let Inst{11-10} = 0b10;
745   // Inherits Rn in 9-5
746   // Inherits Rt in 4-0
747
748   let AddedComplexity = 50;
749 }
750
751 // Format for Load-store register pair (offset) instructions
752 class A64I_LSPoffset<bits<2> opc, bit v, bit l,
753                       dag outs, dag ins, string asmstr,
754                       list<dag> patterns, InstrItinClass itin>
755   : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
756   bits<7> SImm7;
757
758   let Inst{31-30} = opc;
759   let Inst{29-27} = 0b101;
760   let Inst{26} = v;
761   let Inst{25-23} = 0b010;
762   let Inst{22} = l;
763   let Inst{21-15} = SImm7;
764   // Inherit Rt2 in 14-10
765   // Inherit Rn in 9-5
766   // Inherit Rt in 4-0
767 }
768
769 // Format for Load-store register pair (post-indexed) instructions
770 class A64I_LSPpostind<bits<2> opc, bit v, bit l,
771                       dag outs, dag ins, string asmstr,
772                       list<dag> patterns, InstrItinClass itin>
773   : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
774   bits<7> SImm7;
775
776   let Inst{31-30} = opc;
777   let Inst{29-27} = 0b101;
778   let Inst{26} = v;
779   let Inst{25-23} = 0b001;
780   let Inst{22} = l;
781   let Inst{21-15} = SImm7;
782   // Inherit Rt2 in 14-10
783   // Inherit Rn in 9-5
784   // Inherit Rt in 4-0
785 }
786
787 // Format for Load-store register pair (pre-indexed) instructions
788 class A64I_LSPpreind<bits<2> opc, bit v, bit l,
789                       dag outs, dag ins, string asmstr,
790                       list<dag> patterns, InstrItinClass itin>
791   : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
792   bits<7> SImm7;
793
794   let Inst{31-30} = opc;
795   let Inst{29-27} = 0b101;
796   let Inst{26} = v;
797   let Inst{25-23} = 0b011;
798   let Inst{22} = l;
799   let Inst{21-15} = SImm7;
800   // Inherit Rt2 in 14-10
801   // Inherit Rn in 9-5
802   // Inherit Rt in 4-0
803 }
804
805 // Format for Load-store non-temporal register pair (offset) instructions
806 class A64I_LSPnontemp<bits<2> opc, bit v, bit l,
807                       dag outs, dag ins, string asmstr,
808                       list<dag> patterns, InstrItinClass itin>
809   : A64InstRtt2n<outs, ins, asmstr, patterns, itin> {
810   bits<7> SImm7;
811
812   let Inst{31-30} = opc;
813   let Inst{29-27} = 0b101;
814   let Inst{26} = v;
815   let Inst{25-23} = 0b000;
816   let Inst{22} = l;
817   let Inst{21-15} = SImm7;
818   // Inherit Rt2 in 14-10
819   // Inherit Rn in 9-5
820   // Inherit Rt in 4-0
821 }
822
823 // Format for Logical (immediate) instructions
824 class A64I_logicalimm<bit sf, bits<2> opc,
825                       dag outs, dag ins, string asmstr,
826                       list<dag> patterns, InstrItinClass itin>
827   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
828   bit N;
829   bits<6> ImmR;
830   bits<6> ImmS;
831
832   // N, ImmR and ImmS have no separate existence in any assembly syntax (or for
833   // selection), so we'll combine them into a single field here.
834   bits<13> Imm;
835   // N = Imm{12};
836   // ImmR = Imm{11-6};
837   // ImmS = Imm{5-0};
838
839   let Inst{31} = sf;
840   let Inst{30-29} = opc;
841   let Inst{28-23} = 0b100100;
842   let Inst{22} = Imm{12};
843   let Inst{21-16} = Imm{11-6};
844   let Inst{15-10} = Imm{5-0};
845   // Rn inherited in 9-5
846   // Rd inherited in 4-0
847 }
848
849 // Format for Logical (shifted register) instructions
850 class A64I_logicalshift<bit sf, bits<2> opc, bits<2> shift, bit N,
851                         dag outs, dag ins, string asmstr,
852                         list<dag> patterns, InstrItinClass itin>
853   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
854   bits<6> Imm6;
855
856   let Inst{31} = sf;
857   let Inst{30-29} = opc;
858   let Inst{28-24} = 0b01010;
859   let Inst{23-22} = shift;
860   let Inst{21} = N;
861   // Rm inherited
862   let Inst{15-10} = Imm6;
863   // Rn inherited
864   // Rd inherited
865 }
866
867 // Format for Move wide (immediate)
868 class A64I_movw<bit sf, bits<2> opc,
869                 dag outs, dag ins, string asmstr,
870                 list<dag> patterns, InstrItinClass itin>
871   : A64InstRd<outs, ins, asmstr, patterns, itin> {
872   bits<16> UImm16;
873   bits<2> Shift; // Called "hw" officially
874
875   let Inst{31} = sf;
876   let Inst{30-29} = opc;
877   let Inst{28-23} = 0b100101;
878   let Inst{22-21} = Shift;
879   let Inst{20-5} = UImm16;
880   // Inherits Rd in 4-0
881 }
882
883 // Format for PC-relative addressing instructions, ADR and ADRP.
884 class A64I_PCADR<bit op,
885                  dag outs, dag ins, string asmstr,
886                  list<dag> patterns, InstrItinClass itin>
887   : A64InstRd<outs, ins, asmstr, patterns, itin> {
888   bits<21> Label;
889
890   let Inst{31} = op;
891   let Inst{30-29} = Label{1-0};
892   let Inst{28-24} = 0b10000;
893   let Inst{23-5} = Label{20-2};
894 }
895
896 // Format for system instructions
897 class A64I_system<bit l,
898                   dag outs, dag ins, string asmstr,
899                   list<dag> patterns, InstrItinClass itin>
900   : A64Inst<outs, ins, asmstr, patterns, itin> {
901   bits<2> Op0;
902   bits<3> Op1;
903   bits<4> CRn;
904   bits<4> CRm;
905   bits<3> Op2;
906   bits<5> Rt;
907
908   let Inst{31-22} = 0b1101010100;
909   let Inst{21} = l;
910   let Inst{20-19} = Op0;
911   let Inst{18-16} = Op1;
912   let Inst{15-12} = CRn;
913   let Inst{11-8} = CRm;
914   let Inst{7-5} = Op2;
915   let Inst{4-0} = Rt;
916
917   // These instructions can do horrible things.
918   let hasSideEffects = 1;
919 }
920
921 // Format for unconditional branch (immediate) instructions
922 class A64I_Bimm<bit op,
923                 dag outs, dag ins, string asmstr,
924                 list<dag> patterns, InstrItinClass itin>
925   : A64Inst<outs, ins, asmstr, patterns, itin> {
926   // Doubly special in not even sharing register fields with other
927   // instructions, so we create our own Rn here.
928   bits<26> Label;
929
930   let Inst{31} = op;
931   let Inst{30-26} = 0b00101;
932   let Inst{25-0} = Label;
933 }
934
935 // Format for Test & branch (immediate) instructions
936 class A64I_TBimm<bit op,
937                 dag outs, dag ins, string asmstr,
938                 list<dag> patterns, InstrItinClass itin>
939   : A64InstRt<outs, ins, asmstr, patterns, itin> {
940   // Doubly special in not even sharing register fields with other
941   // instructions, so we create our own Rn here.
942   bits<6> Imm;
943   bits<14> Label;
944
945   let Inst{31} = Imm{5};
946   let Inst{30-25} = 0b011011;
947   let Inst{24} = op;
948   let Inst{23-19} = Imm{4-0};
949   let Inst{18-5} = Label;
950   // Inherit Rt in 4-0
951 }
952
953 // Format for Unconditional branch (register) instructions, including
954 // RET.  Shares no fields with instructions further up the hierarchy
955 // so top-level.
956 class A64I_Breg<bits<4> opc, bits<5> op2, bits<6> op3, bits<5> op4,
957                 dag outs, dag ins, string asmstr,
958                 list<dag> patterns, InstrItinClass itin>
959   : A64Inst<outs, ins, asmstr, patterns, itin> {
960   // Doubly special in not even sharing register fields with other
961   // instructions, so we create our own Rn here.
962   bits<5> Rn;
963
964   let Inst{31-25} = 0b1101011;
965   let Inst{24-21} = opc;
966   let Inst{20-16} = op2;
967   let Inst{15-10} = op3;
968   let Inst{9-5}   = Rn;
969   let Inst{4-0}   = op4;
970 }
971
972
973 //===----------------------------------------------------------------------===//
974 //
975 // Neon Instruction Format Definitions.
976 //
977
978 let Predicates = [HasNEON] in {
979
980 class NeonInstAlias<string Asm, dag Result, bit Emit = 0b1>
981   : InstAlias<Asm, Result, Emit> {
982 }
983
984 // Format AdvSIMD bitwise extract
985 class NeonI_BitExtract<bit q, bits<2> op2,
986                        dag outs, dag ins, string asmstr,
987                        list<dag> patterns, InstrItinClass itin>
988   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
989   let Inst{31} = 0b0;
990   let Inst{30} = q;
991   let Inst{29-24} = 0b101110;
992   let Inst{23-22} = op2;
993   let Inst{21} = 0b0;
994   // Inherit Rm in 20-16
995   let Inst{15} = 0b0;
996   // imm4 in 14-11
997   let Inst{10} = 0b0;
998   // Inherit Rn in 9-5
999   // Inherit Rd in 4-0
1000 }
1001
1002 // Format AdvSIMD perm
1003 class NeonI_Perm<bit q, bits<2> size, bits<3> opcode,
1004                  dag outs, dag ins, string asmstr,
1005                  list<dag> patterns, InstrItinClass itin>
1006   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1007   let Inst{31} = 0b0;
1008   let Inst{30} = q;
1009   let Inst{29-24} = 0b001110;
1010   let Inst{23-22} = size;
1011   let Inst{21} = 0b0;
1012   // Inherit Rm in 20-16
1013   let Inst{15} = 0b0;
1014   let Inst{14-12} = opcode;
1015   let Inst{11-10} = 0b10;
1016   // Inherit Rn in 9-5
1017   // Inherit Rd in 4-0
1018 }
1019
1020 // Format AdvSIMD table lookup
1021 class NeonI_TBL<bit q, bits<2> op2, bits<2> len, bit op,
1022                 dag outs, dag ins, string asmstr,
1023                 list<dag> patterns, InstrItinClass itin>
1024   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1025   let Inst{31} = 0b0;
1026   let Inst{30} = q;
1027   let Inst{29-24} = 0b001110;
1028   let Inst{23-22} = op2;
1029   let Inst{21} = 0b0;
1030   // Inherit Rm in 20-16
1031   let Inst{15} = 0b0;
1032   let Inst{14-13} = len;
1033   let Inst{12} = op;
1034   let Inst{11-10} = 0b00;
1035   // Inherit Rn in 9-5
1036   // Inherit Rd in 4-0
1037 }
1038
1039 // Format AdvSIMD 3 vector registers with same vector type
1040 class NeonI_3VSame<bit q, bit u, bits<2> size, bits<5> opcode,
1041                    dag outs, dag ins, string asmstr,
1042                    list<dag> patterns, InstrItinClass itin>
1043   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1044   let Inst{31} = 0b0;
1045   let Inst{30} = q;
1046   let Inst{29} = u;
1047   let Inst{28-24} = 0b01110;
1048   let Inst{23-22} = size;
1049   let Inst{21} = 0b1;
1050   // Inherit Rm in 20-16
1051   let Inst{15-11} = opcode;
1052   let Inst{10} = 0b1;
1053   // Inherit Rn in 9-5
1054   // Inherit Rd in 4-0
1055 }
1056
1057 // Format AdvSIMD 3 vector registers with different vector type
1058 class NeonI_3VDiff<bit q, bit u, bits<2> size, bits<4> opcode,
1059                    dag outs, dag ins, string asmstr,
1060                    list<dag> patterns, InstrItinClass itin>
1061   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1062   let Inst{31} = 0b0;
1063   let Inst{30} = q;
1064   let Inst{29} = u;
1065   let Inst{28-24} = 0b01110;
1066   let Inst{23-22} = size;
1067   let Inst{21} = 0b1;
1068   // Inherit Rm in 20-16
1069   let Inst{15-12} = opcode;
1070   let Inst{11} = 0b0;
1071   let Inst{10} = 0b0;
1072   // Inherit Rn in 9-5
1073   // Inherit Rd in 4-0
1074 }
1075
1076 // Format AdvSIMD two registers and an element
1077 class NeonI_2VElem<bit q, bit u, bits<2> size, bits<4> opcode,
1078                    dag outs, dag ins, string asmstr,
1079                    list<dag> patterns, InstrItinClass itin>
1080   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1081   let Inst{31} = 0b0;
1082   let Inst{30} = q;
1083   let Inst{29} = u;
1084   let Inst{28-24} = 0b01111;
1085   let Inst{23-22} = size;
1086   // l in Inst{21}
1087   // m in Inst{20}
1088   // Inherit Rm in 19-16
1089   let Inst{15-12} = opcode;
1090   // h in Inst{11}
1091   let Inst{10} = 0b0;
1092   // Inherit Rn in 9-5
1093   // Inherit Rd in 4-0
1094 }
1095
1096 // Format AdvSIMD 1 vector register with modified immediate
1097 class NeonI_1VModImm<bit q, bit op,
1098                      dag outs, dag ins, string asmstr,
1099                      list<dag> patterns, InstrItinClass itin>
1100   : A64InstRd<outs,ins, asmstr, patterns, itin> {
1101   bits<8> Imm;
1102   bits<4> cmode;
1103   let Inst{31} = 0b0;
1104   let Inst{30} = q;
1105   let Inst{29} = op;
1106   let Inst{28-19} = 0b0111100000;
1107   let Inst{15-12} = cmode;
1108   let Inst{11} = 0b0; // o2
1109   let Inst{10} = 1;
1110   // Inherit Rd in 4-0
1111   let Inst{18-16} = Imm{7-5}; // imm a:b:c
1112   let Inst{9-5} = Imm{4-0};   // imm d:e:f:g:h
1113 }
1114
1115 // Format AdvSIMD 3 scalar registers with same type
1116
1117 class NeonI_Scalar3Same<bit u, bits<2> size, bits<5> opcode,
1118                           dag outs, dag ins, string asmstr,
1119                           list<dag> patterns, InstrItinClass itin>
1120   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1121   let Inst{31} = 0b0;
1122   let Inst{30} = 0b1;
1123   let Inst{29} = u;
1124   let Inst{28-24} = 0b11110;
1125   let Inst{23-22} = size;
1126   let Inst{21} = 0b1;
1127   // Inherit Rm in 20-16
1128   let Inst{15-11} = opcode;
1129   let Inst{10} = 0b1;
1130   // Inherit Rn in 9-5
1131   // Inherit Rd in 4-0
1132 }
1133
1134
1135 // Format AdvSIMD 2 vector registers miscellaneous
1136 class NeonI_2VMisc<bit q, bit u, bits<2> size, bits<5> opcode,
1137                    dag outs, dag ins, string asmstr,
1138                    list<dag> patterns, InstrItinClass itin>
1139   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1140   let Inst{31} = 0b0;
1141   let Inst{30} = q;
1142   let Inst{29} = u;
1143   let Inst{28-24} = 0b01110;
1144   let Inst{23-22} = size;
1145   let Inst{21-17} = 0b10000;
1146   let Inst{16-12} = opcode;
1147   let Inst{11-10} = 0b10;
1148
1149   // Inherit Rn in 9-5
1150   // Inherit Rd in 4-0
1151 }
1152
1153 // Format AdvSIMD 2 vector 1 immediate shift
1154 class NeonI_2VShiftImm<bit q, bit u, bits<5> opcode,
1155                        dag outs, dag ins, string asmstr,
1156                        list<dag> patterns, InstrItinClass itin>
1157   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1158   bits<7> Imm;
1159   let Inst{31} = 0b0;
1160   let Inst{30} = q;
1161   let Inst{29} = u;
1162   let Inst{28-23} = 0b011110;
1163   let Inst{22-16} = Imm;
1164   let Inst{15-11} = opcode;
1165   let Inst{10} = 0b1;
1166   
1167   // Inherit Rn in 9-5
1168   // Inherit Rd in 4-0
1169 }
1170
1171 // Format AdvSIMD duplicate and insert
1172 class NeonI_copy<bit q, bit op, bits<4> imm4,
1173                  dag outs, dag ins, string asmstr,
1174                  list<dag> patterns, InstrItinClass itin>
1175   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1176   bits<5> Imm5;
1177   let Inst{31} = 0b0;
1178   let Inst{30} = q;
1179   let Inst{29} = op;
1180   let Inst{28-21} = 0b01110000;
1181   let Inst{20-16} = Imm5;
1182   let Inst{15} = 0b0;
1183   let Inst{14-11} = imm4;
1184   let Inst{10} = 0b1;
1185   
1186   // Inherit Rn in 9-5
1187   // Inherit Rd in 4-0
1188 }
1189 // Format AdvSIMD insert from element to vector
1190 class NeonI_insert<bit q, bit op,
1191                   dag outs, dag ins, string asmstr,
1192                   list<dag> patterns, InstrItinClass itin>
1193   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1194   bits<5> Imm5;
1195   bits<4> Imm4;
1196   let Inst{31} = 0b0;
1197   let Inst{30} = q;
1198   let Inst{29} = op;
1199   let Inst{28-21} = 0b01110000;
1200   let Inst{20-16} = Imm5;
1201   let Inst{15} = 0b0;
1202   let Inst{14-11} = Imm4;
1203   let Inst{10} = 0b1;
1204   
1205   // Inherit Rn in 9-5
1206   // Inherit Rd in 4-0
1207 }
1208
1209 // Format AdvSIMD scalar pairwise
1210 class NeonI_ScalarPair<bit u, bits<2> size, bits<5> opcode,
1211                           dag outs, dag ins, string asmstr,
1212                           list<dag> patterns, InstrItinClass itin>
1213   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1214   let Inst{31} = 0b0;
1215   let Inst{30} = 0b1;
1216   let Inst{29} = u;
1217   let Inst{28-24} = 0b11110;
1218   let Inst{23-22} = size;
1219   let Inst{21-17} = 0b11000;
1220   let Inst{16-12} = opcode;
1221   let Inst{11-10} = 0b10;
1222
1223   // Inherit Rn in 9-5
1224   // Inherit Rd in 4-0
1225 }
1226
1227 // Format AdvSIMD 2 vector across lanes
1228 class NeonI_2VAcross<bit q, bit u, bits<2> size, bits<5> opcode,
1229                      dag outs, dag ins, string asmstr,
1230                      list<dag> patterns, InstrItinClass itin>
1231   : A64InstRdn<outs, ins, asmstr, patterns, itin>
1232 {
1233   let Inst{31} = 0b0;
1234   let Inst{30} = q;
1235   let Inst{29} = u;
1236   let Inst{28-24} = 0b01110;
1237   let Inst{23-22} = size;
1238   let Inst{21-17} = 0b11000;
1239   let Inst{16-12} = opcode;
1240   let Inst{11-10} = 0b10;
1241
1242   // Inherit Rn in 9-5
1243   // Inherit Rd in 4-0
1244 }
1245
1246 // Format AdvSIMD scalar two registers miscellaneous
1247 class NeonI_Scalar2SameMisc<bit u, bits<2> size, bits<5> opcode, dag outs, dag ins,
1248                             string asmstr, list<dag> patterns, InstrItinClass itin>
1249   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1250   let Inst{31} = 0b0;
1251   let Inst{30} = 0b1;
1252   let Inst{29} = u;
1253   let Inst{28-24} = 0b11110;
1254   let Inst{23-22} = size;
1255   let Inst{21-17} = 0b10000;
1256   let Inst{16-12} = opcode;
1257   let Inst{11-10} = 0b10;
1258   // Inherit Rn in 9-5
1259   // Inherit Rd in 4-0
1260 }
1261
1262 // Format AdvSIMD vector load/store multiple N-element structure
1263 class NeonI_LdStMult<bit q, bit l, bits<4> opcode, bits<2> size,
1264                     dag outs, dag ins, string asmstr,
1265                     list<dag> patterns, InstrItinClass itin>
1266   : A64InstRtn<outs, ins, asmstr, patterns, itin>
1267 {
1268   let Inst{31} = 0b0;
1269   let Inst{30} = q;
1270   let Inst{29-23} = 0b0011000;
1271   let Inst{22} = l;
1272   let Inst{21-16} = 0b000000;
1273   let Inst{15-12} = opcode;
1274   let Inst{11-10} = size;
1275   
1276   // Inherit Rn in 9-5
1277   // Inherit Rt in 4-0
1278 }
1279
1280 // Format AdvSIMD vector load/store multiple N-element structure (post-index)
1281 class NeonI_LdStMult_Post<bit q, bit l, bits<4> opcode, bits<2> size,
1282                          dag outs, dag ins, string asmstr,
1283                          list<dag> patterns, InstrItinClass itin>
1284   : A64InstRtnm<outs, ins, asmstr, patterns, itin>
1285 {
1286   let Inst{31} = 0b0;
1287   let Inst{30} = q;
1288   let Inst{29-23} = 0b0011001;
1289   let Inst{22} = l;
1290   let Inst{21} = 0b0;
1291   // Inherit Rm in 20-16
1292   let Inst{15-12} = opcode;
1293   let Inst{11-10} = size;
1294   // Inherit Rn in 9-5
1295   // Inherit Rt in 4-0
1296 }
1297
1298 // Format AdvSIMD vector load Single N-element structure to all lanes
1299 class NeonI_LdOne_Dup<bit q, bit r, bits<3> opcode, bits<2> size, dag outs,
1300                       dag ins, string asmstr, list<dag> patterns,
1301                       InstrItinClass itin>
1302   : A64InstRtn<outs, ins, asmstr, patterns, itin>
1303 {
1304   let Inst{31} = 0b0;
1305   let Inst{30} = q;
1306   let Inst{29-23} = 0b0011010;
1307   let Inst{22} = 0b1;
1308   let Inst{21} = r;
1309   let Inst{20-16} = 0b00000;
1310   let Inst{15-13} = opcode;
1311   let Inst{12} = 0b0;
1312   let Inst{11-10} = size;
1313
1314   // Inherit Rn in 9-5
1315   // Inherit Rt in 4-0
1316 }
1317
1318 // Format AdvSIMD vector load/store Single N-element structure to/from one lane
1319 class NeonI_LdStOne_Lane<bit l, bit r, bits<2> op2_1, bit op0, dag outs,
1320                          dag ins, string asmstr,
1321                          list<dag> patterns, InstrItinClass itin>
1322   : A64InstRtn<outs, ins, asmstr, patterns, itin>
1323 {
1324   bits<4> lane;
1325   let Inst{31} = 0b0;
1326   let Inst{29-23} = 0b0011010;
1327   let Inst{22} = l;
1328   let Inst{21} = r;
1329   let Inst{20-16} = 0b00000;
1330   let Inst{15-14} = op2_1;
1331   let Inst{13} = op0;
1332   
1333   // Inherit Rn in 9-5
1334   // Inherit Rt in 4-0
1335 }
1336
1337 // Format AdvSIMD post-index vector load Single N-element structure to all lanes
1338 class NeonI_LdOne_Dup_Post<bit q, bit r, bits<3> opcode, bits<2> size, dag outs,
1339                            dag ins, string asmstr, list<dag> patterns,
1340                            InstrItinClass itin>
1341   : A64InstRtnm<outs, ins, asmstr, patterns, itin>
1342 {
1343   let Inst{31} = 0b0;
1344   let Inst{30} = q;
1345   let Inst{29-23} = 0b0011011;
1346   let Inst{22} = 0b1;
1347   let Inst{21} = r;
1348   // Inherit Rm in 20-16
1349   let Inst{15-13} = opcode;
1350   let Inst{12} = 0b0;
1351   let Inst{11-10} = size;
1352
1353   // Inherit Rn in 9-5
1354   // Inherit Rt in 4-0
1355 }
1356
1357 // Format AdvSIMD post-index vector load/store Single N-element structure
1358 // to/from one lane
1359 class NeonI_LdStOne_Lane_Post<bit l, bit r, bits<2> op2_1, bit op0, dag outs,
1360                          dag ins, string asmstr,
1361                          list<dag> patterns, InstrItinClass itin>
1362   : A64InstRtnm<outs, ins, asmstr, patterns, itin>
1363 {
1364   bits<4> lane;
1365   let Inst{31} = 0b0;
1366   let Inst{29-23} = 0b0011011;
1367   let Inst{22} = l;
1368   let Inst{21} = r;
1369   // Inherit Rm in 20-16
1370   let Inst{15-14} = op2_1;
1371   let Inst{13} = op0;
1372   
1373   // Inherit Rn in 9-5
1374   // Inherit Rt in 4-0
1375 }
1376
1377 // Format AdvSIMD 3 scalar registers with different type
1378
1379 class NeonI_Scalar3Diff<bit u, bits<2> size, bits<4> opcode,
1380                           dag outs, dag ins, string asmstr,
1381                           list<dag> patterns, InstrItinClass itin>
1382   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1383   let Inst{31-30} = 0b01;
1384   let Inst{29} = u;
1385   let Inst{28-24} = 0b11110;
1386   let Inst{23-22} = size;
1387   let Inst{21} = 0b1;
1388   // Inherit Rm in 20-16
1389   let Inst{15-12} = opcode;
1390   let Inst{11-10} = 0b00;
1391   // Inherit Rn in 9-5
1392   // Inherit Rd in 4-0
1393 }
1394
1395 // Format AdvSIMD scalar shift by immediate
1396
1397 class NeonI_ScalarShiftImm<bit u, bits<5> opcode,
1398                            dag outs, dag ins, string asmstr,
1399                            list<dag> patterns, InstrItinClass itin>
1400   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1401   bits<4> Imm4;
1402   bits<3> Imm3;
1403   let Inst{31-30} = 0b01;
1404   let Inst{29} = u;
1405   let Inst{28-23} = 0b111110;
1406   let Inst{22-19} = Imm4;
1407   let Inst{18-16} = Imm3;
1408   let Inst{15-11} = opcode;
1409   let Inst{10} = 0b1;
1410   // Inherit Rn in 9-5
1411   // Inherit Rd in 4-0
1412 }
1413
1414 // Format AdvSIMD crypto AES
1415 class NeonI_Crypto_AES<bits<2> size, bits<5> opcode,
1416                        dag outs, dag ins, string asmstr,
1417                        list<dag> patterns, InstrItinClass itin>
1418   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1419   let Inst{31-24} = 0b01001110;
1420   let Inst{23-22} = size;
1421   let Inst{21-17} = 0b10100;
1422   let Inst{16-12} = opcode;
1423   let Inst{11-10} = 0b10;
1424   // Inherit Rn in 9-5
1425   // Inherit Rd in 4-0
1426 }
1427
1428 // Format AdvSIMD crypto SHA
1429 class NeonI_Crypto_SHA<bits<2> size, bits<5> opcode,
1430                        dag outs, dag ins, string asmstr,
1431                        list<dag> patterns, InstrItinClass itin>
1432   : A64InstRdn<outs, ins, asmstr, patterns, itin> {
1433   let Inst{31-24} = 0b01011110;
1434   let Inst{23-22} = size;
1435   let Inst{21-17} = 0b10100;
1436   let Inst{16-12} = opcode;
1437   let Inst{11-10} = 0b10;
1438   // Inherit Rn in 9-5
1439   // Inherit Rd in 4-0
1440 }
1441
1442 // Format AdvSIMD crypto 3V SHA
1443 class NeonI_Crypto_3VSHA<bits<2> size, bits<3> opcode,
1444                          dag outs, dag ins, string asmstr,
1445                          list<dag> patterns, InstrItinClass itin>
1446   : A64InstRdnm<outs, ins, asmstr, patterns, itin> {
1447   let Inst{31-24} = 0b01011110;
1448   let Inst{23-22} = size;
1449   let Inst{21} = 0b0;
1450   // Inherit Rm in 20-16
1451   let Inst{15} = 0b0;
1452   let Inst{14-12} = opcode;
1453   let Inst{11-10} = 0b00;
1454   // Inherit Rn in 9-5
1455   // Inherit Rd in 4-0
1456 }
1457
1458 // Format AdvSIMD scalar x indexed element
1459 class NeonI_ScalarXIndexedElem<bit u, bit szhi, bit szlo,
1460                                bits<4> opcode, dag outs, dag ins,
1461                                string asmstr, list<dag> patterns,
1462                                InstrItinClass itin>
1463   : A64InstRdnm<outs, ins, asmstr, patterns, itin>
1464 {
1465   let Inst{31} = 0b0;
1466   let Inst{30} = 0b1;
1467   let Inst{29} = u;
1468   let Inst{28-24} = 0b11111;
1469   let Inst{23} = szhi;
1470   let Inst{22} = szlo;
1471   // l in Inst{21}
1472   // m in Instr{20}
1473   // Inherit Rm in 19-16
1474   let Inst{15-12} = opcode;
1475   // h in Inst{11}
1476   let Inst{10} = 0b0;
1477   // Inherit Rn in 9-5
1478   // Inherit Rd in 4-0
1479 }
1480 // Format AdvSIMD scalar copy - insert from element to scalar
1481 class NeonI_ScalarCopy<dag outs, dag ins, string asmstr,
1482                        list<dag> patterns, InstrItinClass itin>
1483   : NeonI_copy<0b1, 0b0, 0b0000, outs, ins, asmstr, patterns, itin> {
1484   let Inst{28} = 0b1;
1485 }
1486 }
1487