]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / SystemZ / SystemZInstrFormats.td
1 //==- SystemZInstrFormats.td - SystemZ 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
10 //===----------------------------------------------------------------------===//
11 // Basic SystemZ instruction definition
12 //===----------------------------------------------------------------------===//
13
14 class InstSystemZ<int size, dag outs, dag ins, string asmstr,
15                   list<dag> pattern> : Instruction {
16   let Namespace = "SystemZ";
17
18   dag OutOperandList = outs;
19   dag InOperandList = ins;
20   let Size = size;
21   let Pattern = pattern;
22   let AsmString = asmstr;
23
24   let hasSideEffects = 0;
25   let mayLoad = 0;
26   let mayStore = 0;
27
28   // Some instructions come in pairs, one having a 12-bit displacement
29   // and the other having a 20-bit displacement.  Both instructions in
30   // the pair have the same DispKey and their DispSizes are "12" and "20"
31   // respectively.
32   string DispKey = "";
33   string DispSize = "none";
34
35   // Many register-based <INSN>R instructions have a memory-based <INSN>
36   // counterpart.  OpKey uniquely identifies <INSN>R, while OpType is
37   // "reg" for <INSN>R and "mem" for <INSN>.
38   string OpKey = "";
39   string OpType = "none";
40
41   // Many distinct-operands instructions have older 2-operand equivalents.
42   // NumOpsKey uniquely identifies one of these 2-operand and 3-operand pairs,
43   // with NumOpsValue being "2" or "3" as appropriate.
44   string NumOpsKey = "";
45   string NumOpsValue = "none";
46
47   // True if this instruction is a simple D(X,B) load of a register
48   // (with no sign or zero extension).
49   bit SimpleBDXLoad = 0;
50
51   // True if this instruction is a simple D(X,B) store of a register
52   // (with no truncation).
53   bit SimpleBDXStore = 0;
54
55   // True if this instruction has a 20-bit displacement field.
56   bit Has20BitOffset = 0;
57
58   // True if addresses in this instruction have an index register.
59   bit HasIndex = 0;
60
61   // True if this is a 128-bit pseudo instruction that combines two 64-bit
62   // operations.
63   bit Is128Bit = 0;
64
65   // The access size of all memory operands in bytes, or 0 if not known.
66   bits<5> AccessBytes = 0;
67
68   // If the instruction sets CC to a useful value, this gives the mask
69   // of all possible CC results.  The mask has the same form as
70   // SystemZ::CCMASK_*.
71   bits<4> CCValues = 0;
72
73   // The subset of CCValues that have the same meaning as they would after
74   // a comparison of the first operand against zero.
75   bits<4> CompareZeroCCMask = 0;
76
77   // True if the instruction is conditional and if the CC mask operand
78   // comes first (as for BRC, etc.).
79   bit CCMaskFirst = 0;
80
81   // Similar, but true if the CC mask operand comes last (as for LOC, etc.).
82   bit CCMaskLast = 0;
83
84   // True if the instruction is the "logical" rather than "arithmetic" form,
85   // in cases where a distinction exists.
86   bit IsLogical = 0;
87
88   let TSFlags{0}     = SimpleBDXLoad;
89   let TSFlags{1}     = SimpleBDXStore;
90   let TSFlags{2}     = Has20BitOffset;
91   let TSFlags{3}     = HasIndex;
92   let TSFlags{4}     = Is128Bit;
93   let TSFlags{9-5}   = AccessBytes;
94   let TSFlags{13-10} = CCValues;
95   let TSFlags{17-14} = CompareZeroCCMask;
96   let TSFlags{18}    = CCMaskFirst;
97   let TSFlags{19}    = CCMaskLast;
98   let TSFlags{20}    = IsLogical;
99 }
100
101 //===----------------------------------------------------------------------===//
102 // Mappings between instructions
103 //===----------------------------------------------------------------------===//
104
105 // Return the version of an instruction that has an unsigned 12-bit
106 // displacement.
107 def getDisp12Opcode : InstrMapping {
108   let FilterClass = "InstSystemZ";
109   let RowFields = ["DispKey"];
110   let ColFields = ["DispSize"];
111   let KeyCol = ["20"];
112   let ValueCols = [["12"]];
113 }
114
115 // Return the version of an instruction that has a signed 20-bit displacement.
116 def getDisp20Opcode : InstrMapping {
117   let FilterClass = "InstSystemZ";
118   let RowFields = ["DispKey"];
119   let ColFields = ["DispSize"];
120   let KeyCol = ["12"];
121   let ValueCols = [["20"]];
122 }
123
124 // Return the memory form of a register instruction.
125 def getMemOpcode : InstrMapping {
126   let FilterClass = "InstSystemZ";
127   let RowFields = ["OpKey"];
128   let ColFields = ["OpType"];
129   let KeyCol = ["reg"];
130   let ValueCols = [["mem"]];
131 }
132
133 // Return the 3-operand form of a 2-operand instruction.
134 def getThreeOperandOpcode : InstrMapping {
135   let FilterClass = "InstSystemZ";
136   let RowFields = ["NumOpsKey"];
137   let ColFields = ["NumOpsValue"];
138   let KeyCol = ["2"];
139   let ValueCols = [["3"]];
140 }
141
142 //===----------------------------------------------------------------------===//
143 // Instruction formats
144 //===----------------------------------------------------------------------===//
145 //
146 // Formats are specified using operand field declarations of the form:
147 //
148 //   bits<4> Rn   : register input or output for operand n
149 //   bits<5> Vn   : vector register input or output for operand n
150 //   bits<m> In   : immediate value of width m for operand n
151 //   bits<4> BDn  : address operand n, which has a base and a displacement
152 //   bits<m> XBDn : address operand n, which has an index, a base and a
153 //                  displacement
154 //   bits<m> VBDn : address operand n, which has a vector index, a base and a
155 //                  displacement
156 //   bits<4> Xn   : index register for address operand n
157 //   bits<4> Mn   : mode value for operand n
158 //
159 // The operand numbers ("n" in the list above) follow the architecture manual.
160 // Assembly operands sometimes have a different order; in particular, R3 often
161 // is often written between operands 1 and 2.
162 //
163 //===----------------------------------------------------------------------===//
164
165 class InstE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
166   : InstSystemZ<2, outs, ins, asmstr, pattern> {
167   field bits<16> Inst;
168   field bits<16> SoftFail = 0;
169
170   let Inst = op;
171 }
172
173 class InstI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
174   : InstSystemZ<2, outs, ins, asmstr, pattern> {
175   field bits<16> Inst;
176   field bits<16> SoftFail = 0;
177
178   bits<8> I1;
179
180   let Inst{15-8} = op;
181   let Inst{7-0}  = I1;
182 }
183
184 class InstIE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
185   : InstSystemZ<4, outs, ins, asmstr, pattern> {
186   field bits<32> Inst;
187   field bits<32> SoftFail = 0;
188
189   bits<4> I1;
190   bits<4> I2;
191
192   let Inst{31-16} = op;
193   let Inst{15-8}  = 0;
194   let Inst{7-4}   = I1;
195   let Inst{3-0}   = I2;
196 }
197
198 class InstMII<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
199   : InstSystemZ<6, outs, ins, asmstr, pattern> {
200   field bits<48> Inst;
201   field bits<48> SoftFail = 0;
202
203   bits<4> M1;
204   bits<12> RI2;
205   bits<24> RI3;
206
207   let Inst{47-40} = op;
208   let Inst{39-36} = M1;
209   let Inst{35-24} = RI2;
210   let Inst{23-0}  = RI3;
211 }
212
213 class InstRIa<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
214   : InstSystemZ<4, outs, ins, asmstr, pattern> {
215   field bits<32> Inst;
216   field bits<32> SoftFail = 0;
217
218   bits<4> R1;
219   bits<16> I2;
220
221   let Inst{31-24} = op{11-4};
222   let Inst{23-20} = R1;
223   let Inst{19-16} = op{3-0};
224   let Inst{15-0}  = I2;
225 }
226
227 class InstRIb<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
228   : InstSystemZ<4, outs, ins, asmstr, pattern> {
229   field bits<32> Inst;
230   field bits<32> SoftFail = 0;
231
232   bits<4> R1;
233   bits<16> RI2;
234
235   let Inst{31-24} = op{11-4};
236   let Inst{23-20} = R1;
237   let Inst{19-16} = op{3-0};
238   let Inst{15-0}  = RI2;
239 }
240
241 class InstRIc<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
242   : InstSystemZ<4, outs, ins, asmstr, pattern> {
243   field bits<32> Inst;
244   field bits<32> SoftFail = 0;
245
246   bits<4> M1;
247   bits<16> RI2;
248
249   let Inst{31-24} = op{11-4};
250   let Inst{23-20} = M1;
251   let Inst{19-16} = op{3-0};
252   let Inst{15-0}  = RI2;
253 }
254
255 class InstRIEa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
256   : InstSystemZ<6, outs, ins, asmstr, pattern> {
257   field bits<48> Inst;
258   field bits<48> SoftFail = 0;
259
260   bits<4> R1;
261   bits<16> I2;
262   bits<4> M3;
263
264   let Inst{47-40} = op{15-8};
265   let Inst{39-36} = R1;
266   let Inst{35-32} = 0;
267   let Inst{31-16} = I2;
268   let Inst{15-12} = M3;
269   let Inst{11-8}  = 0;
270   let Inst{7-0}   = op{7-0};
271 }
272
273 class InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
274   : InstSystemZ<6, outs, ins, asmstr, pattern> {
275   field bits<48> Inst;
276   field bits<48> SoftFail = 0;
277
278   bits<4> R1;
279   bits<4> R2;
280   bits<4> M3;
281   bits<16> RI4;
282
283   let Inst{47-40} = op{15-8};
284   let Inst{39-36} = R1;
285   let Inst{35-32} = R2;
286   let Inst{31-16} = RI4;
287   let Inst{15-12} = M3;
288   let Inst{11-8}  = 0;
289   let Inst{7-0}   = op{7-0};
290 }
291
292 class InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
293   : InstSystemZ<6, outs, ins, asmstr, pattern> {
294   field bits<48> Inst;
295   field bits<48> SoftFail = 0;
296
297   bits<4> R1;
298   bits<8> I2;
299   bits<4> M3;
300   bits<16> RI4;
301
302   let Inst{47-40} = op{15-8};
303   let Inst{39-36} = R1;
304   let Inst{35-32} = M3;
305   let Inst{31-16} = RI4;
306   let Inst{15-8}  = I2;
307   let Inst{7-0}   = op{7-0};
308 }
309
310 class InstRIEd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
311   : InstSystemZ<6, outs, ins, asmstr, pattern> {
312   field bits<48> Inst;
313   field bits<48> SoftFail = 0;
314
315   bits<4> R1;
316   bits<4> R3;
317   bits<16> I2;
318
319   let Inst{47-40} = op{15-8};
320   let Inst{39-36} = R1;
321   let Inst{35-32} = R3;
322   let Inst{31-16} = I2;
323   let Inst{15-8}  = 0;
324   let Inst{7-0}   = op{7-0};
325 }
326
327 class InstRIEe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
328   : InstSystemZ<6, outs, ins, asmstr, pattern> {
329   field bits<48> Inst;
330   field bits<48> SoftFail = 0;
331
332   bits<4> R1;
333   bits<4> R3;
334   bits<16> RI2;
335
336   let Inst{47-40} = op{15-8};
337   let Inst{39-36} = R1;
338   let Inst{35-32} = R3;
339   let Inst{31-16} = RI2;
340   let Inst{15-8}  = 0;
341   let Inst{7-0}   = op{7-0};
342 }
343
344 class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
345   : InstSystemZ<6, outs, ins, asmstr, pattern> {
346   field bits<48> Inst;
347   field bits<48> SoftFail = 0;
348
349   bits<4> R1;
350   bits<4> R2;
351   bits<8> I3;
352   bits<8> I4;
353   bits<8> I5;
354
355   let Inst{47-40} = op{15-8};
356   let Inst{39-36} = R1;
357   let Inst{35-32} = R2;
358   let Inst{31-24} = I3;
359   let Inst{23-16} = I4;
360   let Inst{15-8}  = I5;
361   let Inst{7-0}   = op{7-0};
362 }
363
364 class InstRIEg<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
365   : InstSystemZ<6, outs, ins, asmstr, pattern> {
366   field bits<48> Inst;
367   field bits<48> SoftFail = 0;
368
369   bits<4> R1;
370   bits<4> M3;
371   bits<16> I2;
372
373   let Inst{47-40} = op{15-8};
374   let Inst{39-36} = R1;
375   let Inst{35-32} = M3;
376   let Inst{31-16} = I2;
377   let Inst{15-8}  = 0;
378   let Inst{7-0}   = op{7-0};
379 }
380
381 class InstRILa<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
382   : InstSystemZ<6, outs, ins, asmstr, pattern> {
383   field bits<48> Inst;
384   field bits<48> SoftFail = 0;
385
386   bits<4> R1;
387   bits<32> I2;
388
389   let Inst{47-40} = op{11-4};
390   let Inst{39-36} = R1;
391   let Inst{35-32} = op{3-0};
392   let Inst{31-0}  = I2;
393 }
394
395 class InstRILb<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
396   : InstSystemZ<6, outs, ins, asmstr, pattern> {
397   field bits<48> Inst;
398   field bits<48> SoftFail = 0;
399
400   bits<4> R1;
401   bits<32> RI2;
402
403   let Inst{47-40} = op{11-4};
404   let Inst{39-36} = R1;
405   let Inst{35-32} = op{3-0};
406   let Inst{31-0}  = RI2;
407 }
408
409 class InstRILc<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
410   : InstSystemZ<6, outs, ins, asmstr, pattern> {
411   field bits<48> Inst;
412   field bits<48> SoftFail = 0;
413
414   bits<4> M1;
415   bits<32> RI2;
416
417   let Inst{47-40} = op{11-4};
418   let Inst{39-36} = M1;
419   let Inst{35-32} = op{3-0};
420   let Inst{31-0}  = RI2;
421 }
422
423 class InstRIS<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
424   : InstSystemZ<6, outs, ins, asmstr, pattern> {
425   field bits<48> Inst;
426   field bits<48> SoftFail = 0;
427
428   bits<4> R1;
429   bits<8> I2;
430   bits<4> M3;
431   bits<16> BD4;
432
433   let Inst{47-40} = op{15-8};
434   let Inst{39-36} = R1;
435   let Inst{35-32} = M3;
436   let Inst{31-16} = BD4;
437   let Inst{15-8}  = I2;
438   let Inst{7-0}   = op{7-0};
439 }
440
441 class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
442   : InstSystemZ<2, outs, ins, asmstr, pattern> {
443   field bits<16> Inst;
444   field bits<16> SoftFail = 0;
445
446   bits<4> R1;
447   bits<4> R2;
448
449   let Inst{15-8} = op;
450   let Inst{7-4}  = R1;
451   let Inst{3-0}  = R2;
452 }
453
454 class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
455   : InstSystemZ<4, outs, ins, asmstr, pattern> {
456   field bits<32> Inst;
457   field bits<32> SoftFail = 0;
458
459   bits<4> R1;
460   bits<4> R3;
461   bits<4> R2;
462
463   let Inst{31-16} = op;
464   let Inst{15-12} = R1;
465   let Inst{11-8}  = 0;
466   let Inst{7-4}   = R3;
467   let Inst{3-0}   = R2;
468 }
469
470 class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
471   : InstSystemZ<4, outs, ins, asmstr, pattern> {
472   field bits<32> Inst;
473   field bits<32> SoftFail = 0;
474
475   bits<4> R1;
476   bits<4> R2;
477
478   let Inst{31-16} = op;
479   let Inst{15-8}  = 0;
480   let Inst{7-4}   = R1;
481   let Inst{3-0}   = R2;
482 }
483
484 class InstRRFa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
485   : InstSystemZ<4, outs, ins, asmstr, pattern> {
486   field bits<32> Inst;
487   field bits<32> SoftFail = 0;
488
489   bits<4> R1;
490   bits<4> R2;
491   bits<4> R3;
492   bits<4> M4;
493
494   let Inst{31-16} = op;
495   let Inst{15-12} = R3;
496   let Inst{11-8}  = M4;
497   let Inst{7-4}   = R1;
498   let Inst{3-0}   = R2;
499 }
500
501 class InstRRFb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
502   : InstSystemZ<4, outs, ins, asmstr, pattern> {
503   field bits<32> Inst;
504   field bits<32> SoftFail = 0;
505
506   bits<4> R1;
507   bits<4> R2;
508   bits<4> R3;
509   bits<4> M4;
510
511   let Inst{31-16} = op;
512   let Inst{15-12} = R3;
513   let Inst{11-8}  = M4;
514   let Inst{7-4}   = R1;
515   let Inst{3-0}   = R2;
516 }
517
518 class InstRRFc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
519   : InstSystemZ<4, outs, ins, asmstr, pattern> {
520   field bits<32> Inst;
521   field bits<32> SoftFail = 0;
522
523   bits<4> R1;
524   bits<4> R2;
525   bits<4> M3;
526
527   let Inst{31-16} = op;
528   let Inst{15-12} = M3;
529   let Inst{11-8}  = 0;
530   let Inst{7-4}   = R1;
531   let Inst{3-0}   = R2;
532 }
533
534 class InstRRFd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
535   : InstSystemZ<4, outs, ins, asmstr, pattern> {
536   field bits<32> Inst;
537   field bits<32> SoftFail = 0;
538
539   bits<4> R1;
540   bits<4> R2;
541   bits<4> M4;
542
543   let Inst{31-16} = op;
544   let Inst{15-12} = 0;
545   let Inst{11-8}  = M4;
546   let Inst{7-4}   = R1;
547   let Inst{3-0}   = R2;
548 }
549
550 class InstRRFe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
551   : InstSystemZ<4, outs, ins, asmstr, pattern> {
552   field bits<32> Inst;
553   field bits<32> SoftFail = 0;
554
555   bits<4> R1;
556   bits<4> R2;
557   bits<4> M3;
558   bits<4> M4;
559
560   let Inst{31-16} = op;
561   let Inst{15-12} = M3;
562   let Inst{11-8}  = M4;
563   let Inst{7-4}   = R1;
564   let Inst{3-0}   = R2;
565 }
566
567 class InstRRS<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
568   : InstSystemZ<6, outs, ins, asmstr, pattern> {
569   field bits<48> Inst;
570   field bits<48> SoftFail = 0;
571
572   bits<4> R1;
573   bits<4> R2;
574   bits<4> M3;
575   bits<16> BD4;
576
577   let Inst{47-40} = op{15-8};
578   let Inst{39-36} = R1;
579   let Inst{35-32} = R2;
580   let Inst{31-16} = BD4;
581   let Inst{15-12} = M3;
582   let Inst{11-8}  = 0;
583   let Inst{7-0}   = op{7-0};
584 }
585
586 class InstRXa<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
587   : InstSystemZ<4, outs, ins, asmstr, pattern> {
588   field bits<32> Inst;
589   field bits<32> SoftFail = 0;
590
591   bits<4> R1;
592   bits<20> XBD2;
593
594   let Inst{31-24} = op;
595   let Inst{23-20} = R1;
596   let Inst{19-0}  = XBD2;
597
598   let HasIndex = 1;
599 }
600
601 class InstRXb<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
602   : InstSystemZ<4, outs, ins, asmstr, pattern> {
603   field bits<32> Inst;
604   field bits<32> SoftFail = 0;
605
606   bits<4> M1;
607   bits<20> XBD2;
608
609   let Inst{31-24} = op;
610   let Inst{23-20} = M1;
611   let Inst{19-0}  = XBD2;
612
613   let HasIndex = 1;
614 }
615
616 class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
617   : InstSystemZ<6, outs, ins, asmstr, pattern> {
618   field bits<48> Inst;
619   field bits<48> SoftFail = 0;
620
621   bits<4> R1;
622   bits<20> XBD2;
623   bits<4> M3;
624
625   let Inst{47-40} = op{15-8};
626   let Inst{39-36} = R1;
627   let Inst{35-16} = XBD2;
628   let Inst{15-12} = M3;
629   let Inst{11-8}  = 0;
630   let Inst{7-0}   = op{7-0};
631
632   let HasIndex = 1;
633 }
634
635 class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
636   : InstSystemZ<6, outs, ins, asmstr, pattern> {
637   field bits<48> Inst;
638   field bits<48> SoftFail = 0;
639
640   bits<4> R1;
641   bits<4> R3;
642   bits<20> XBD2;
643
644   let Inst{47-40} = op{15-8};
645   let Inst{39-36} = R3;
646   let Inst{35-16} = XBD2;
647   let Inst{15-12} = R1;
648   let Inst{11-8}  = 0;
649   let Inst{7-0}   = op{7-0};
650
651   let HasIndex = 1;
652 }
653
654 class InstRXYa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
655   : InstSystemZ<6, outs, ins, asmstr, pattern> {
656   field bits<48> Inst;
657   field bits<48> SoftFail = 0;
658
659   bits<4> R1;
660   bits<28> XBD2;
661
662   let Inst{47-40} = op{15-8};
663   let Inst{39-36} = R1;
664   let Inst{35-8}  = XBD2;
665   let Inst{7-0}   = op{7-0};
666
667   let Has20BitOffset = 1;
668   let HasIndex = 1;
669 }
670
671 class InstRXYb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
672   : InstSystemZ<6, outs, ins, asmstr, pattern> {
673   field bits<48> Inst;
674   field bits<48> SoftFail = 0;
675
676   bits<4> M1;
677   bits<28> XBD2;
678
679   let Inst{47-40} = op{15-8};
680   let Inst{39-36} = M1;
681   let Inst{35-8}  = XBD2;
682   let Inst{7-0}   = op{7-0};
683
684   let Has20BitOffset = 1;
685   let HasIndex = 1;
686 }
687
688 class InstRSa<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
689   : InstSystemZ<4, outs, ins, asmstr, pattern> {
690   field bits<32> Inst;
691   field bits<32> SoftFail = 0;
692
693   bits<4> R1;
694   bits<4> R3;
695   bits<16> BD2;
696
697   let Inst{31-24} = op;
698   let Inst{23-20} = R1;
699   let Inst{19-16} = R3;
700   let Inst{15-0}  = BD2;
701 }
702
703 class InstRSb<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
704   : InstSystemZ<4, outs, ins, asmstr, pattern> {
705   field bits<32> Inst;
706   field bits<32> SoftFail = 0;
707
708   bits<4> R1;
709   bits<4> M3;
710   bits<16> BD2;
711
712   let Inst{31-24} = op;
713   let Inst{23-20} = R1;
714   let Inst{19-16} = M3;
715   let Inst{15-0}  = BD2;
716 }
717
718 class InstRSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
719   : InstSystemZ<4, outs, ins, asmstr, pattern> {
720   field bits<32> Inst;
721   field bits<32> SoftFail = 0;
722
723   bits<4> R1;
724   bits<4> R3;
725   bits<16> RI2;
726
727   let Inst{31-24} = op;
728   let Inst{23-20} = R1;
729   let Inst{19-16} = R3;
730   let Inst{15-0}  = RI2;
731 }
732
733 class InstRSLa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
734   : InstSystemZ<6, outs, ins, asmstr, pattern> {
735   field bits<48> Inst;
736   field bits<48> SoftFail = 0;
737
738   bits<20> BDL1;
739
740   let Inst{47-40} = op{15-8};
741   let Inst{39-36} = BDL1{19-16};
742   let Inst{35-32} = 0;
743   let Inst{31-16} = BDL1{15-0};
744   let Inst{15-8}  = 0;
745   let Inst{7-0}   = op{7-0};
746 }
747
748 class InstRSLb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
749   : InstSystemZ<6, outs, ins, asmstr, pattern> {
750   field bits<48> Inst;
751   field bits<48> SoftFail = 0;
752
753   bits<4> R1;
754   bits<24> BDL2;
755   bits<4> M3;
756
757   let Inst{47-40} = op{15-8};
758   let Inst{39-16} = BDL2;
759   let Inst{15-12} = R1;
760   let Inst{11-8}  = M3;
761   let Inst{7-0}   = op{7-0};
762 }
763
764 class InstRSYa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
765   : InstSystemZ<6, outs, ins, asmstr, pattern> {
766   field bits<48> Inst;
767   field bits<48> SoftFail = 0;
768
769   bits<4> R1;
770   bits<4> R3;
771   bits<24> BD2;
772
773   let Inst{47-40} = op{15-8};
774   let Inst{39-36} = R1;
775   let Inst{35-32} = R3;
776   let Inst{31-8}  = BD2;
777   let Inst{7-0}   = op{7-0};
778
779   let Has20BitOffset = 1;
780 }
781
782 class InstRSYb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
783   : InstSystemZ<6, outs, ins, asmstr, pattern> {
784   field bits<48> Inst;
785   field bits<48> SoftFail = 0;
786
787   bits<4> R1;
788   bits<4> M3;
789   bits<24> BD2;
790
791   let Inst{47-40} = op{15-8};
792   let Inst{39-36} = R1;
793   let Inst{35-32} = M3;
794   let Inst{31-8}  = BD2;
795   let Inst{7-0}   = op{7-0};
796
797   let Has20BitOffset = 1;
798 }
799
800 class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
801   : InstSystemZ<4, outs, ins, asmstr, pattern> {
802   field bits<32> Inst;
803   field bits<32> SoftFail = 0;
804
805   bits<16> BD1;
806   bits<8> I2;
807
808   let Inst{31-24} = op;
809   let Inst{23-16} = I2;
810   let Inst{15-0}  = BD1;
811 }
812
813 class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
814   : InstSystemZ<6, outs, ins, asmstr, pattern> {
815   field bits<48> Inst;
816   field bits<48> SoftFail = 0;
817
818   bits<16> BD1;
819   bits<16> I2;
820
821   let Inst{47-32} = op;
822   let Inst{31-16} = BD1;
823   let Inst{15-0}  = I2;
824 }
825
826 class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
827   : InstSystemZ<6, outs, ins, asmstr, pattern> {
828   field bits<48> Inst;
829   field bits<48> SoftFail = 0;
830
831   bits<24> BD1;
832   bits<8> I2;
833
834   let Inst{47-40} = op{15-8};
835   let Inst{39-32} = I2;
836   let Inst{31-8}  = BD1;
837   let Inst{7-0}   = op{7-0};
838
839   let Has20BitOffset = 1;
840 }
841
842 class InstSMI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
843   : InstSystemZ<6, outs, ins, asmstr, pattern> {
844   field bits<48> Inst;
845   field bits<48> SoftFail = 0;
846
847   bits<4> M1;
848   bits<16> RI2;
849   bits<16> BD3;
850
851   let Inst{47-40} = op;
852   let Inst{39-36} = M1;
853   let Inst{35-32} = 0;
854   let Inst{31-16} = BD3;
855   let Inst{15-0}  = RI2;
856 }
857
858 class InstSSa<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
859   : InstSystemZ<6, outs, ins, asmstr, pattern> {
860   field bits<48> Inst;
861   field bits<48> SoftFail = 0;
862
863   bits<24> BDL1;
864   bits<16> BD2;
865
866   let Inst{47-40} = op;
867   let Inst{39-16} = BDL1;
868   let Inst{15-0}  = BD2;
869 }
870
871 class InstSSb<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
872   : InstSystemZ<6, outs, ins, asmstr, pattern> {
873   field bits<48> Inst;
874   field bits<48> SoftFail = 0;
875
876   bits<20> BDL1;
877   bits<20> BDL2;
878
879   let Inst{47-40} = op;
880   let Inst{39-36} = BDL1{19-16};
881   let Inst{35-32} = BDL2{19-16};
882   let Inst{31-16} = BDL1{15-0};
883   let Inst{15-0}  = BDL2{15-0};
884 }
885
886 class InstSSc<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
887   : InstSystemZ<6, outs, ins, asmstr, pattern> {
888   field bits<48> Inst;
889   field bits<48> SoftFail = 0;
890
891   bits<20> BDL1;
892   bits<16> BD2;
893   bits<4> I3;
894
895   let Inst{47-40} = op;
896   let Inst{39-36} = BDL1{19-16};
897   let Inst{35-32} = I3;
898   let Inst{31-16} = BDL1{15-0};
899   let Inst{15-0}  = BD2;
900 }
901
902 class InstSSd<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
903   : InstSystemZ<6, outs, ins, asmstr, pattern> {
904   field bits<48> Inst;
905   field bits<48> SoftFail = 0;
906
907   bits<20> RBD1;
908   bits<16> BD2;
909   bits<4> R3;
910
911   let Inst{47-40} = op;
912   let Inst{39-36} = RBD1{19-16};
913   let Inst{35-32} = R3;
914   let Inst{31-16} = RBD1{15-0};
915   let Inst{15-0}  = BD2;
916 }
917
918 class InstSSe<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
919   : InstSystemZ<6, outs, ins, asmstr, pattern> {
920   field bits<48> Inst;
921   field bits<48> SoftFail = 0;
922
923   bits<4> R1;
924   bits<16> BD2;
925   bits<4> R3;
926   bits<16> BD4;
927
928   let Inst{47-40} = op;
929   let Inst{39-36} = R1;
930   let Inst{35-32} = R3;
931   let Inst{31-16} = BD2;
932   let Inst{15-0}  = BD4;
933 }
934
935 class InstSSf<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
936   : InstSystemZ<6, outs, ins, asmstr, pattern> {
937   field bits<48> Inst;
938   field bits<48> SoftFail = 0;
939
940   bits<16> BD1;
941   bits<24> BDL2;
942
943   let Inst{47-40} = op;
944   let Inst{39-32} = BDL2{23-16};
945   let Inst{31-16} = BD1;
946   let Inst{15-0}  = BDL2{15-0};
947 }
948
949 class InstSSE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
950   : InstSystemZ<6, outs, ins, asmstr, pattern> {
951   field bits<48> Inst;
952   field bits<48> SoftFail = 0;
953
954   bits<16> BD1;
955   bits<16> BD2;
956
957   let Inst{47-32} = op;
958   let Inst{31-16} = BD1;
959   let Inst{15-0}  = BD2;
960 }
961
962 class InstSSF<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
963   : InstSystemZ<6, outs, ins, asmstr, pattern> {
964   field bits<48> Inst;
965   field bits<48> SoftFail = 0;
966
967   bits<16> BD1;
968   bits<16> BD2;
969   bits<4>  R3;
970
971   let Inst{47-40} = op{11-4};
972   let Inst{39-36} = R3;
973   let Inst{35-32} = op{3-0};
974   let Inst{31-16} = BD1;
975   let Inst{15-0}  = BD2;
976 }
977
978 class InstS<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
979   : InstSystemZ<4, outs, ins, asmstr, pattern> {
980   field bits<32> Inst;
981   field bits<32> SoftFail = 0;
982
983   bits<16> BD2;
984
985   let Inst{31-16} = op;
986   let Inst{15-0}  = BD2;
987 }
988
989 class InstVRIa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
990   : InstSystemZ<6, outs, ins, asmstr, pattern> {
991   field bits<48> Inst;
992   field bits<48> SoftFail = 0;
993
994   bits<5> V1;
995   bits<16> I2;
996   bits<4> M3;
997
998   let Inst{47-40} = op{15-8};
999   let Inst{39-36} = V1{3-0};
1000   let Inst{35-32} = 0;
1001   let Inst{31-16} = I2;
1002   let Inst{15-12} = M3;
1003   let Inst{11}    = V1{4};
1004   let Inst{10-8}  = 0;
1005   let Inst{7-0}   = op{7-0};
1006 }
1007
1008 class InstVRIb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1009   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1010   field bits<48> Inst;
1011   field bits<48> SoftFail = 0;
1012
1013   bits<5> V1;
1014   bits<8> I2;
1015   bits<8> I3;
1016   bits<4> M4;
1017
1018   let Inst{47-40} = op{15-8};
1019   let Inst{39-36} = V1{3-0};
1020   let Inst{35-32} = 0;
1021   let Inst{31-24} = I2;
1022   let Inst{23-16} = I3;
1023   let Inst{15-12} = M4;
1024   let Inst{11}    = V1{4};
1025   let Inst{10-8}  = 0;
1026   let Inst{7-0}   = op{7-0};
1027 }
1028
1029 class InstVRIc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1030   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1031   field bits<48> Inst;
1032   field bits<48> SoftFail = 0;
1033
1034   bits<5> V1;
1035   bits<5> V3;
1036   bits<16> I2;
1037   bits<4> M4;
1038
1039   let Inst{47-40} = op{15-8};
1040   let Inst{39-36} = V1{3-0};
1041   let Inst{35-32} = V3{3-0};
1042   let Inst{31-16} = I2;
1043   let Inst{15-12} = M4;
1044   let Inst{11}    = V1{4};
1045   let Inst{10}    = V3{4};
1046   let Inst{9-8}   = 0;
1047   let Inst{7-0}   = op{7-0};
1048 }
1049
1050 class InstVRId<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1051   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1052   field bits<48> Inst;
1053   field bits<48> SoftFail = 0;
1054
1055   bits<5> V1;
1056   bits<5> V2;
1057   bits<5> V3;
1058   bits<8> I4;
1059   bits<4> M5;
1060
1061   let Inst{47-40} = op{15-8};
1062   let Inst{39-36} = V1{3-0};
1063   let Inst{35-32} = V2{3-0};
1064   let Inst{31-28} = V3{3-0};
1065   let Inst{27-24} = 0;
1066   let Inst{23-16} = I4;
1067   let Inst{15-12} = M5;
1068   let Inst{11}    = V1{4};
1069   let Inst{10}    = V2{4};
1070   let Inst{9}     = V3{4};
1071   let Inst{8}     = 0;
1072   let Inst{7-0}   = op{7-0};
1073 }
1074
1075 class InstVRIe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1076   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1077   field bits<48> Inst;
1078   field bits<48> SoftFail = 0;
1079
1080   bits<5> V1;
1081   bits<5> V2;
1082   bits<12> I3;
1083   bits<4> M4;
1084   bits<4> M5;
1085
1086   let Inst{47-40} = op{15-8};
1087   let Inst{39-36} = V1{3-0};
1088   let Inst{35-32} = V2{3-0};
1089   let Inst{31-20} = I3;
1090   let Inst{19-16} = M5;
1091   let Inst{15-12} = M4;
1092   let Inst{11}    = V1{4};
1093   let Inst{10}    = V2{4};
1094   let Inst{9-8}   = 0;
1095   let Inst{7-0}   = op{7-0};
1096 }
1097
1098 class InstVRIf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1099   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1100   field bits<48> Inst;
1101   field bits<48> SoftFail = 0;
1102
1103   bits<5> V1;
1104   bits<5> V2;
1105   bits<5> V3;
1106   bits<8> I4;
1107   bits<4> M5;
1108
1109   let Inst{47-40} = op{15-8};
1110   let Inst{39-36} = V1{3-0};
1111   let Inst{35-32} = V2{3-0};
1112   let Inst{31-28} = V3{3-0};
1113   let Inst{27-24} = 0;
1114   let Inst{23-20} = M5;
1115   let Inst{19-12} = I4;
1116   let Inst{11}    = V1{4};
1117   let Inst{10}    = V2{4};
1118   let Inst{9}     = V3{4};
1119   let Inst{8}     = 0;
1120   let Inst{7-0}   = op{7-0};
1121 }
1122
1123 class InstVRIg<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1124   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1125   field bits<48> Inst;
1126   field bits<48> SoftFail = 0;
1127
1128   bits<5> V1;
1129   bits<5> V2;
1130   bits<8> I3;
1131   bits<8> I4;
1132   bits<4> M5;
1133
1134   let Inst{47-40} = op{15-8};
1135   let Inst{39-36} = V1{3-0};
1136   let Inst{35-32} = V2{3-0};
1137   let Inst{31-24} = I4;
1138   let Inst{23-20} = M5;
1139   let Inst{19-12} = I3;
1140   let Inst{11}    = V1{4};
1141   let Inst{10}    = V2{4};
1142   let Inst{9-8}   = 0;
1143   let Inst{7-0}   = op{7-0};
1144 }
1145
1146 class InstVRIh<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1147   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1148   field bits<48> Inst;
1149   field bits<48> SoftFail = 0;
1150
1151   bits<5> V1;
1152   bits<16> I2;
1153   bits<4> I3;
1154
1155   let Inst{47-40} = op{15-8};
1156   let Inst{39-36} = V1{3-0};
1157   let Inst{35-32} = 0;
1158   let Inst{31-16} = I2;
1159   let Inst{15-12} = I3;
1160   let Inst{11}    = V1{4};
1161   let Inst{10-8}  = 0;
1162   let Inst{7-0}   = op{7-0};
1163 }
1164
1165 class InstVRIi<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1166   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1167   field bits<48> Inst;
1168   field bits<48> SoftFail = 0;
1169
1170   bits<5> V1;
1171   bits<4> R2;
1172   bits<8> I3;
1173   bits<4> M4;
1174
1175   let Inst{47-40} = op{15-8};
1176   let Inst{39-36} = V1{3-0};
1177   let Inst{35-32} = R2;
1178   let Inst{31-24} = 0;
1179   let Inst{23-20} = M4;
1180   let Inst{19-12} = I3;
1181   let Inst{11}    = V1{4};
1182   let Inst{10-8}  = 0;
1183   let Inst{7-0}   = op{7-0};
1184 }
1185
1186 // Depending on the instruction mnemonic, certain bits may be or-ed into
1187 // the M4 value provided as explicit operand.  These are passed as m4or.
1188 class InstVRRa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
1189                bits<4> m4or = 0>
1190   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1191   field bits<48> Inst;
1192   field bits<48> SoftFail = 0;
1193
1194   bits<5> V1;
1195   bits<5> V2;
1196   bits<4> M3;
1197   bits<4> M4;
1198   bits<4> M5;
1199
1200   let Inst{47-40} = op{15-8};
1201   let Inst{39-36} = V1{3-0};
1202   let Inst{35-32} = V2{3-0};
1203   let Inst{31-24} = 0;
1204   let Inst{23-20} = M5;
1205   let Inst{19}    = !if (!eq (m4or{3}, 1), 1, M4{3});
1206   let Inst{18}    = !if (!eq (m4or{2}, 1), 1, M4{2});
1207   let Inst{17}    = !if (!eq (m4or{1}, 1), 1, M4{1});
1208   let Inst{16}    = !if (!eq (m4or{0}, 1), 1, M4{0});
1209   let Inst{15-12} = M3;
1210   let Inst{11}    = V1{4};
1211   let Inst{10}    = V2{4};
1212   let Inst{9-8}   = 0;
1213   let Inst{7-0}   = op{7-0};
1214 }
1215
1216 // Depending on the instruction mnemonic, certain bits may be or-ed into
1217 // the M5 value provided as explicit operand.  These are passed as m5or.
1218 class InstVRRb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
1219                bits<4> m5or = 0>
1220   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1221   field bits<48> Inst;
1222   field bits<48> SoftFail = 0;
1223
1224   bits<5> V1;
1225   bits<5> V2;
1226   bits<5> V3;
1227   bits<4> M4;
1228   bits<4> M5;
1229
1230   let Inst{47-40} = op{15-8};
1231   let Inst{39-36} = V1{3-0};
1232   let Inst{35-32} = V2{3-0};
1233   let Inst{31-28} = V3{3-0};
1234   let Inst{27-24} = 0;
1235   let Inst{23}    = !if (!eq (m5or{3}, 1), 1, M5{3});
1236   let Inst{22}    = !if (!eq (m5or{2}, 1), 1, M5{2});
1237   let Inst{21}    = !if (!eq (m5or{1}, 1), 1, M5{1});
1238   let Inst{20}    = !if (!eq (m5or{0}, 1), 1, M5{0});
1239   let Inst{19-16} = 0;
1240   let Inst{15-12} = M4;
1241   let Inst{11}    = V1{4};
1242   let Inst{10}    = V2{4};
1243   let Inst{9}     = V3{4};
1244   let Inst{8}     = 0;
1245   let Inst{7-0}   = op{7-0};
1246 }
1247
1248 class InstVRRc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1249   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1250   field bits<48> Inst;
1251   field bits<48> SoftFail = 0;
1252
1253   bits<5> V1;
1254   bits<5> V2;
1255   bits<5> V3;
1256   bits<4> M4;
1257   bits<4> M5;
1258   bits<4> M6;
1259
1260   let Inst{47-40} = op{15-8};
1261   let Inst{39-36} = V1{3-0};
1262   let Inst{35-32} = V2{3-0};
1263   let Inst{31-28} = V3{3-0};
1264   let Inst{27-24} = 0;
1265   let Inst{23-20} = M6;
1266   let Inst{19-16} = M5;
1267   let Inst{15-12} = M4;
1268   let Inst{11}    = V1{4};
1269   let Inst{10}    = V2{4};
1270   let Inst{9}     = V3{4};
1271   let Inst{8}     = 0;
1272   let Inst{7-0}   = op{7-0};
1273 }
1274
1275 // Depending on the instruction mnemonic, certain bits may be or-ed into
1276 // the M6 value provided as explicit operand.  These are passed as m6or.
1277 class InstVRRd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern,
1278                bits<4> m6or = 0>
1279   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1280   field bits<48> Inst;
1281   field bits<48> SoftFail = 0;
1282
1283   bits<5> V1;
1284   bits<5> V2;
1285   bits<5> V3;
1286   bits<5> V4;
1287   bits<4> M5;
1288   bits<4> M6;
1289
1290   let Inst{47-40} = op{15-8};
1291   let Inst{39-36} = V1{3-0};
1292   let Inst{35-32} = V2{3-0};
1293   let Inst{31-28} = V3{3-0};
1294   let Inst{27-24} = M5;
1295   let Inst{23}    = !if (!eq (m6or{3}, 1), 1, M6{3});
1296   let Inst{22}    = !if (!eq (m6or{2}, 1), 1, M6{2});
1297   let Inst{21}    = !if (!eq (m6or{1}, 1), 1, M6{1});
1298   let Inst{20}    = !if (!eq (m6or{0}, 1), 1, M6{0});
1299   let Inst{19-16} = 0;
1300   let Inst{15-12} = V4{3-0};
1301   let Inst{11}    = V1{4};
1302   let Inst{10}    = V2{4};
1303   let Inst{9}     = V3{4};
1304   let Inst{8}     = V4{4};
1305   let Inst{7-0}   = op{7-0};
1306 }
1307
1308 class InstVRRe<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1309   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1310   field bits<48> Inst;
1311   field bits<48> SoftFail = 0;
1312
1313   bits<5> V1;
1314   bits<5> V2;
1315   bits<5> V3;
1316   bits<5> V4;
1317   bits<4> M5;
1318   bits<4> M6;
1319
1320   let Inst{47-40} = op{15-8};
1321   let Inst{39-36} = V1{3-0};
1322   let Inst{35-32} = V2{3-0};
1323   let Inst{31-28} = V3{3-0};
1324   let Inst{27-24} = M6;
1325   let Inst{23-20} = 0;
1326   let Inst{19-16} = M5;
1327   let Inst{15-12} = V4{3-0};
1328   let Inst{11}    = V1{4};
1329   let Inst{10}    = V2{4};
1330   let Inst{9}     = V3{4};
1331   let Inst{8}     = V4{4};
1332   let Inst{7-0}   = op{7-0};
1333 }
1334
1335 class InstVRRf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1336   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1337   field bits<48> Inst;
1338   field bits<48> SoftFail = 0;
1339
1340   bits<5> V1;
1341   bits<4> R2;
1342   bits<4> R3;
1343
1344   let Inst{47-40} = op{15-8};
1345   let Inst{39-36} = V1{3-0};
1346   let Inst{35-32} = R2;
1347   let Inst{31-28} = R3;
1348   let Inst{27-12} = 0;
1349   let Inst{11}    = V1{4};
1350   let Inst{10-8}  = 0;
1351   let Inst{7-0}   = op{7-0};
1352 }
1353
1354 class InstVRRg<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1355   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1356   field bits<48> Inst;
1357   field bits<48> SoftFail = 0;
1358
1359   bits<5> V1;
1360
1361   let Inst{47-40} = op{15-8};
1362   let Inst{39-36} = 0;
1363   let Inst{35-32} = V1{3-0};
1364   let Inst{31-12} = 0;
1365   let Inst{11}    = 0;
1366   let Inst{10}    = V1{4};
1367   let Inst{9-8}   = 0;
1368   let Inst{7-0}   = op{7-0};
1369 }
1370
1371 class InstVRRh<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1372   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1373   field bits<48> Inst;
1374   field bits<48> SoftFail = 0;
1375
1376   bits<5> V1;
1377   bits<5> V2;
1378   bits<4> M3;
1379
1380   let Inst{47-40} = op{15-8};
1381   let Inst{39-36} = 0;
1382   let Inst{35-32} = V1{3-0};
1383   let Inst{31-28} = V2{3-0};
1384   let Inst{27-24} = 0;
1385   let Inst{23-20} = M3;
1386   let Inst{19-12} = 0;
1387   let Inst{11}    = 0;
1388   let Inst{10}    = V1{4};
1389   let Inst{9}     = V2{4};
1390   let Inst{8}     = 0;
1391   let Inst{7-0}   = op{7-0};
1392 }
1393
1394 class InstVRRi<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1395   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1396   field bits<48> Inst;
1397   field bits<48> SoftFail = 0;
1398
1399   bits<4> R1;
1400   bits<5> V2;
1401   bits<4> M3;
1402
1403   let Inst{47-40} = op{15-8};
1404   let Inst{39-36} = R1;
1405   let Inst{35-32} = V2{3-0};
1406   let Inst{31-24} = 0;
1407   let Inst{23-20} = M3;
1408   let Inst{19-12} = 0;
1409   let Inst{11}    = 0;
1410   let Inst{10}    = V2{4};
1411   let Inst{9-8}   = 0;
1412   let Inst{7-0}   = op{7-0};
1413 }
1414
1415 class InstVRSa<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1416   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1417   field bits<48> Inst;
1418   field bits<48> SoftFail = 0;
1419
1420   bits<5> V1;
1421   bits<16> BD2;
1422   bits<5> V3;
1423   bits<4> M4;
1424
1425   let Inst{47-40} = op{15-8};
1426   let Inst{39-36} = V1{3-0};
1427   let Inst{35-32} = V3{3-0};
1428   let Inst{31-16} = BD2;
1429   let Inst{15-12} = M4;
1430   let Inst{11}    = V1{4};
1431   let Inst{10}    = V3{4};
1432   let Inst{9-8}   = 0;
1433   let Inst{7-0}   = op{7-0};
1434 }
1435
1436 class InstVRSb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1437   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1438   field bits<48> Inst;
1439   field bits<48> SoftFail = 0;
1440
1441   bits<5> V1;
1442   bits<16> BD2;
1443   bits<4> R3;
1444   bits<4> M4;
1445
1446   let Inst{47-40} = op{15-8};
1447   let Inst{39-36} = V1{3-0};
1448   let Inst{35-32} = R3;
1449   let Inst{31-16} = BD2;
1450   let Inst{15-12} = M4;
1451   let Inst{11}    = V1{4};
1452   let Inst{10-8}  = 0;
1453   let Inst{7-0}   = op{7-0};
1454 }
1455
1456 class InstVRSc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1457   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1458   field bits<48> Inst;
1459   field bits<48> SoftFail = 0;
1460
1461   bits<4> R1;
1462   bits<16> BD2;
1463   bits<5> V3;
1464   bits<4> M4;
1465
1466   let Inst{47-40} = op{15-8};
1467   let Inst{39-36} = R1;
1468   let Inst{35-32} = V3{3-0};
1469   let Inst{31-16} = BD2;
1470   let Inst{15-12} = M4;
1471   let Inst{11}    = 0;
1472   let Inst{10}    = V3{4};
1473   let Inst{9-8}   = 0;
1474   let Inst{7-0}   = op{7-0};
1475 }
1476
1477 class InstVRSd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1478   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1479   field bits<48> Inst;
1480   field bits<48> SoftFail = 0;
1481
1482   bits<5> V1;
1483   bits<16> BD2;
1484   bits<4> R3;
1485
1486   let Inst{47-40} = op{15-8};
1487   let Inst{39-36} = 0;
1488   let Inst{35-32} = R3;
1489   let Inst{31-16} = BD2;
1490   let Inst{15-12} = V1{3-0};
1491   let Inst{11-9}  = 0;
1492   let Inst{8}     = V1{4};
1493   let Inst{7-0}   = op{7-0};
1494 }
1495
1496 class InstVRV<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1497   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1498   field bits<48> Inst;
1499   field bits<48> SoftFail = 0;
1500
1501   bits<5> V1;
1502   bits<21> VBD2;
1503   bits<4> M3;
1504
1505   let Inst{47-40} = op{15-8};
1506   let Inst{39-36} = V1{3-0};
1507   let Inst{35-16} = VBD2{19-0};
1508   let Inst{15-12} = M3;
1509   let Inst{11}    = V1{4};
1510   let Inst{10}    = VBD2{20};
1511   let Inst{9-8}   = 0;
1512   let Inst{7-0}   = op{7-0};
1513 }
1514
1515 class InstVRX<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1516   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1517   field bits<48> Inst;
1518   field bits<48> SoftFail = 0;
1519
1520   bits<5> V1;
1521   bits<20> XBD2;
1522   bits<4> M3;
1523
1524   let Inst{47-40} = op{15-8};
1525   let Inst{39-36} = V1{3-0};
1526   let Inst{35-16} = XBD2;
1527   let Inst{15-12} = M3;
1528   let Inst{11}    = V1{4};
1529   let Inst{10-8}  = 0;
1530   let Inst{7-0}   = op{7-0};
1531 }
1532
1533 class InstVSI<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
1534   : InstSystemZ<6, outs, ins, asmstr, pattern> {
1535   field bits<48> Inst;
1536   field bits<48> SoftFail = 0;
1537
1538   bits<5> V1;
1539   bits<16> BD2;
1540   bits<8> I3;
1541
1542   let Inst{47-40} = op{15-8};
1543   let Inst{39-32} = I3;
1544   let Inst{31-16} = BD2;
1545   let Inst{15-12} = V1{3-0};
1546   let Inst{11-9}  = 0;
1547   let Inst{8}     = V1{4};
1548   let Inst{7-0}   = op{7-0};
1549 }
1550
1551 //===----------------------------------------------------------------------===//
1552 // Instruction classes for .insn directives
1553 //===----------------------------------------------------------------------===//
1554
1555 class DirectiveInsnE<dag outs, dag ins, string asmstr, list<dag> pattern>
1556   : InstE<0, outs, ins, asmstr, pattern> {
1557   bits<16> enc;
1558
1559   let Inst = enc;
1560 }
1561
1562 class DirectiveInsnRI<dag outs, dag ins, string asmstr, list<dag> pattern>
1563   : InstRIa<0, outs, ins, asmstr, pattern> {
1564   bits<32> enc;
1565
1566   let Inst{31-24} = enc{31-24};
1567   let Inst{19-16} = enc{19-16};
1568 }
1569
1570 class DirectiveInsnRIE<dag outs, dag ins, string asmstr, list<dag> pattern>
1571   : InstRIEd<0, outs, ins, asmstr, pattern> {
1572   bits<48> enc;
1573
1574   let Inst{47-40} = enc{47-40};
1575   let Inst{7-0}   = enc{7-0};
1576 }
1577
1578 class DirectiveInsnRIL<dag outs, dag ins, string asmstr, list<dag> pattern>
1579   : InstRILa<0, outs, ins, asmstr, pattern> {
1580   bits<48> enc;
1581   string type;
1582
1583   let Inst{47-40} = enc{47-40};
1584   let Inst{35-32} = enc{35-32};
1585 }
1586
1587 class DirectiveInsnRIS<dag outs, dag ins, string asmstr, list<dag> pattern>
1588   : InstRIS<0, outs, ins, asmstr, pattern> {
1589   bits<48> enc;
1590
1591   let Inst{47-40} = enc{47-40};
1592   let Inst{7-0}   = enc{7-0};
1593 }
1594
1595 class DirectiveInsnRR<dag outs, dag ins, string asmstr, list<dag> pattern>
1596   : InstRR<0, outs, ins, asmstr, pattern> {
1597   bits<16> enc;
1598
1599   let Inst{15-8} = enc{15-8};
1600 }
1601
1602 class DirectiveInsnRRE<dag outs, dag ins, string asmstr, list<dag> pattern>
1603   : InstRRE<0, outs, ins, asmstr, pattern> {
1604   bits<32> enc;
1605
1606   let Inst{31-16} = enc{31-16};
1607 }
1608
1609 class DirectiveInsnRRF<dag outs, dag ins, string asmstr, list<dag> pattern>
1610   : InstRRFa<0, outs, ins, asmstr, pattern> {
1611   bits<32> enc;
1612
1613   let Inst{31-16} = enc{31-16};
1614 }
1615
1616 class DirectiveInsnRRS<dag outs, dag ins, string asmstr, list<dag> pattern>
1617   : InstRRS<0, outs, ins, asmstr, pattern> {
1618   bits<48> enc;
1619
1620   let Inst{47-40} = enc{47-40};
1621   let Inst{7-0}   = enc{7-0};
1622 }
1623
1624 class DirectiveInsnRS<dag outs, dag ins, string asmstr, list<dag> pattern>
1625   : InstRSa<0, outs, ins, asmstr, pattern> {
1626   bits<32> enc;
1627
1628   let Inst{31-24} = enc{31-24};
1629 }
1630
1631 // RSE is like RSY except with a 12 bit displacement (instead of 20).
1632 class DirectiveInsnRSE<dag outs, dag ins, string asmstr, list<dag> pattern>
1633   : InstRSYa<6, outs, ins, asmstr, pattern> {
1634   bits <48> enc;
1635
1636   let Inst{47-40} = enc{47-40};
1637   let Inst{31-16} = BD2{15-0};
1638   let Inst{15-8}  = 0;
1639   let Inst{7-0}   = enc{7-0};
1640 }
1641
1642 class DirectiveInsnRSI<dag outs, dag ins, string asmstr, list<dag> pattern>
1643   : InstRSI<0, outs, ins, asmstr, pattern> {
1644   bits<32> enc;
1645
1646   let Inst{31-24} = enc{31-24};
1647 }
1648
1649 class DirectiveInsnRSY<dag outs, dag ins, string asmstr, list<dag> pattern>
1650   : InstRSYa<0, outs, ins, asmstr, pattern> {
1651   bits<48> enc;
1652
1653   let Inst{47-40} = enc{47-40};
1654   let Inst{7-0}   = enc{7-0};
1655 }
1656
1657 class DirectiveInsnRX<dag outs, dag ins, string asmstr, list<dag> pattern>
1658   : InstRXa<0, outs, ins, asmstr, pattern> {
1659   bits<32> enc;
1660
1661   let Inst{31-24} = enc{31-24};
1662 }
1663
1664 class DirectiveInsnRXE<dag outs, dag ins, string asmstr, list<dag> pattern>
1665   : InstRXE<0, outs, ins, asmstr, pattern> {
1666   bits<48> enc;
1667
1668   let M3 = 0;
1669
1670   let Inst{47-40} = enc{47-40};
1671   let Inst{7-0}   = enc{7-0};
1672 }
1673
1674 class DirectiveInsnRXF<dag outs, dag ins, string asmstr, list<dag> pattern>
1675   : InstRXF<0, outs, ins, asmstr, pattern> {
1676   bits<48> enc;
1677
1678   let Inst{47-40} = enc{47-40};
1679   let Inst{7-0}   = enc{7-0};
1680 }
1681
1682 class DirectiveInsnRXY<dag outs, dag ins, string asmstr, list<dag> pattern>
1683   : InstRXYa<0, outs, ins, asmstr, pattern> {
1684   bits<48> enc;
1685
1686   let Inst{47-40} = enc{47-40};
1687   let Inst{7-0}   = enc{7-0};
1688 }
1689
1690 class DirectiveInsnS<dag outs, dag ins, string asmstr, list<dag> pattern>
1691   : InstS<0, outs, ins, asmstr, pattern> {
1692   bits<32> enc;
1693
1694   let Inst{31-16} = enc{31-16};
1695 }
1696
1697 class DirectiveInsnSI<dag outs, dag ins, string asmstr, list<dag> pattern>
1698   : InstSI<0, outs, ins, asmstr, pattern> {
1699   bits<32> enc;
1700
1701   let Inst{31-24} = enc{31-24};
1702 }
1703
1704 class DirectiveInsnSIY<dag outs, dag ins, string asmstr, list<dag> pattern>
1705   : InstSIY<0, outs, ins, asmstr, pattern> {
1706   bits<48> enc;
1707
1708   let Inst{47-40} = enc{47-40};
1709   let Inst{7-0}   = enc{7-0};
1710 }
1711
1712 class DirectiveInsnSIL<dag outs, dag ins, string asmstr, list<dag> pattern>
1713   : InstSIL<0, outs, ins, asmstr, pattern> {
1714   bits<48> enc;
1715
1716   let Inst{47-32} = enc{47-32};
1717 }
1718
1719 class DirectiveInsnSS<dag outs, dag ins, string asmstr, list<dag> pattern>
1720   : InstSSd<0, outs, ins, asmstr, pattern> {
1721   bits<48> enc;
1722
1723   let Inst{47-40} = enc{47-40};
1724 }
1725
1726 class DirectiveInsnSSE<dag outs, dag ins, string asmstr, list<dag> pattern>
1727   : InstSSE<0, outs, ins, asmstr, pattern> {
1728   bits<48> enc;
1729
1730   let Inst{47-32} = enc{47-32};
1731 }
1732
1733 class DirectiveInsnSSF<dag outs, dag ins, string asmstr, list<dag> pattern>
1734   : InstSSF<0, outs, ins, asmstr, pattern> {
1735   bits<48> enc;
1736
1737   let Inst{47-40} = enc{47-40};
1738   let Inst{35-32} = enc{35-32};
1739 }
1740
1741 //===----------------------------------------------------------------------===//
1742 // Variants of instructions with condition mask
1743 //===----------------------------------------------------------------------===//
1744 //
1745 // For instructions using a condition mask (e.g. conditional branches,
1746 // compare-and-branch instructions, or conditional move instructions),
1747 // we generally need to create multiple instruction patterns:
1748 //
1749 // - One used for code generation, which encodes the condition mask as an
1750 //   MI operand, but writes out an extended mnemonic for better readability.
1751 // - One pattern for the base form of the instruction with an explicit
1752 //   condition mask (encoded as a plain integer MI operand).
1753 // - Specific patterns for each extended mnemonic, where the condition mask
1754 //   is implied by the pattern name and not otherwise encoded at all.
1755 //
1756 // We need the latter primarily for the assembler and disassembler, since the
1757 // assembler parser is not able to decode part of an instruction mnemonic
1758 // into an operand.  Thus we provide separate patterns for each mnemonic.
1759 //
1760 // Note that in some cases there are two different mnemonics for the same
1761 // condition mask.  In this case we cannot have both instructions available
1762 // to the disassembler at the same time since the encodings are not distinct.
1763 // Therefore the alternate forms are marked isAsmParserOnly.
1764 //
1765 // We don't make one of the two names an alias of the other because
1766 // we need the custom parsing routines to select the correct register class.
1767 //
1768 // This section provides helpers for generating the specific forms.
1769 //
1770 //===----------------------------------------------------------------------===//
1771
1772 // A class to describe a variant of an instruction with condition mask.
1773 class CondVariant<bits<4> ccmaskin, string suffixin, bit alternatein> {
1774   // The fixed condition mask to use.
1775   bits<4> ccmask = ccmaskin;
1776
1777   // The suffix to use for the extended assembler mnemonic.
1778   string suffix = suffixin;
1779
1780   // Whether this is an alternate that needs to be marked isAsmParserOnly.
1781   bit alternate = alternatein;
1782 }
1783
1784 // Condition mask 15 means "always true", which is used to define
1785 // unconditional branches as a variant of conditional branches.
1786 def CondAlways : CondVariant<15, "", 0>;
1787
1788 // Condition masks for general instructions that can set all 4 bits.
1789 def CondVariantO   : CondVariant<1,  "o",   0>;
1790 def CondVariantH   : CondVariant<2,  "h",   0>;
1791 def CondVariantP   : CondVariant<2,  "p",   1>;
1792 def CondVariantNLE : CondVariant<3,  "nle", 0>;
1793 def CondVariantL   : CondVariant<4,  "l",   0>;
1794 def CondVariantM   : CondVariant<4,  "m",   1>;
1795 def CondVariantNHE : CondVariant<5,  "nhe", 0>;
1796 def CondVariantLH  : CondVariant<6,  "lh",  0>;
1797 def CondVariantNE  : CondVariant<7,  "ne",  0>;
1798 def CondVariantNZ  : CondVariant<7,  "nz",  1>;
1799 def CondVariantE   : CondVariant<8,  "e",   0>;
1800 def CondVariantZ   : CondVariant<8,  "z",   1>;
1801 def CondVariantNLH : CondVariant<9,  "nlh", 0>;
1802 def CondVariantHE  : CondVariant<10, "he",  0>;
1803 def CondVariantNL  : CondVariant<11, "nl",  0>;
1804 def CondVariantNM  : CondVariant<11, "nm",  1>;
1805 def CondVariantLE  : CondVariant<12, "le",  0>;
1806 def CondVariantNH  : CondVariant<13, "nh",  0>;
1807 def CondVariantNP  : CondVariant<13, "np",  1>;
1808 def CondVariantNO  : CondVariant<14, "no",  0>;
1809
1810 // A helper class to look up one of the above by name.
1811 class CV<string name>
1812   : CondVariant<!cast<CondVariant>("CondVariant"#name).ccmask,
1813                 !cast<CondVariant>("CondVariant"#name).suffix,
1814                 !cast<CondVariant>("CondVariant"#name).alternate>;
1815
1816 // Condition masks for integer instructions (e.g. compare-and-branch).
1817 // This is like the list above, except that condition 3 is not possible
1818 // and that the low bit of the mask is therefore always 0.  This means
1819 // that each condition has two names.  Conditions "o" and "no" are not used.
1820 def IntCondVariantH   : CondVariant<2,  "h",   0>;
1821 def IntCondVariantNLE : CondVariant<2,  "nle", 1>;
1822 def IntCondVariantL   : CondVariant<4,  "l",   0>;
1823 def IntCondVariantNHE : CondVariant<4,  "nhe", 1>;
1824 def IntCondVariantLH  : CondVariant<6,  "lh",  0>;
1825 def IntCondVariantNE  : CondVariant<6,  "ne",  1>;
1826 def IntCondVariantE   : CondVariant<8,  "e",   0>;
1827 def IntCondVariantNLH : CondVariant<8,  "nlh", 1>;
1828 def IntCondVariantHE  : CondVariant<10, "he",  0>;
1829 def IntCondVariantNL  : CondVariant<10, "nl",  1>;
1830 def IntCondVariantLE  : CondVariant<12, "le",  0>;
1831 def IntCondVariantNH  : CondVariant<12, "nh",  1>;
1832
1833 // A helper class to look up one of the above by name.
1834 class ICV<string name>
1835   : CondVariant<!cast<CondVariant>("IntCondVariant"#name).ccmask,
1836                 !cast<CondVariant>("IntCondVariant"#name).suffix,
1837                 !cast<CondVariant>("IntCondVariant"#name).alternate>;
1838
1839 //===----------------------------------------------------------------------===//
1840 // Instruction definitions with semantics
1841 //===----------------------------------------------------------------------===//
1842 //
1843 // These classes have the form [Cond]<Category><Format>, where <Format> is one
1844 // of the formats defined above and where <Category> describes the inputs
1845 // and outputs.  "Cond" is used if the instruction is conditional,
1846 // in which case the 4-bit condition-code mask is added as a final operand.
1847 // <Category> can be one of:
1848 //
1849 //   Inherent:
1850 //     One register output operand and no input operands.
1851 //
1852 //   InherentDual:
1853 //     Two register output operands and no input operands.
1854 //
1855 //   StoreInherent:
1856 //     One address operand.  The instruction stores to the address.
1857 //
1858 //   SideEffectInherent:
1859 //     No input or output operands, but causes some side effect.
1860 //
1861 //   Branch:
1862 //     One branch target.  The instruction branches to the target.
1863 //
1864 //   Call:
1865 //     One output operand and one branch target.  The instruction stores
1866 //     the return address to the output operand and branches to the target.
1867 //
1868 //   CmpBranch:
1869 //     Two input operands and one optional branch target.  The instruction
1870 //     compares the two input operands and branches or traps on the result.
1871 //
1872 //   BranchUnary:
1873 //     One register output operand, one register input operand and one branch
1874 //     target.  The instructions stores a modified form of the source register
1875 //     in the destination register and branches on the result.
1876 //
1877 //   BranchBinary:
1878 //     One register output operand, two register input operands and one branch
1879 //     target. The instructions stores a modified form of one of the source
1880 //     registers in the destination register and branches on the result.
1881 //
1882 //   LoadMultiple:
1883 //     One address input operand and two explicit output operands.
1884 //     The instruction loads a range of registers from the address,
1885 //     with the explicit operands giving the first and last register
1886 //     to load.  Other loaded registers are added as implicit definitions.
1887 //
1888 //   StoreMultiple:
1889 //     Two explicit input register operands and an address operand.
1890 //     The instruction stores a range of registers to the address,
1891 //     with the explicit operands giving the first and last register
1892 //     to store.  Other stored registers are added as implicit uses.
1893 //
1894 //   StoreLength:
1895 //     One value operand, one length operand and one address operand.
1896 //     The instruction stores the value operand to the address but
1897 //     doesn't write more than the number of bytes specified by the
1898 //     length operand.
1899 //
1900 //   LoadAddress:
1901 //     One register output operand and one address operand.
1902 //
1903 //   SideEffectAddress:
1904 //     One address operand.  No output operands, but causes some side effect.
1905 //
1906 //   Unary:
1907 //     One register output operand and one input operand.
1908 //
1909 //   Store:
1910 //     One address operand and one other input operand.  The instruction
1911 //     stores to the address.
1912 //
1913 //   SideEffectUnary:
1914 //     One input operand.  No output operands, but causes some side effect.
1915 //
1916 //   Binary:
1917 //     One register output operand and two input operands.
1918 //
1919 //   StoreBinary:
1920 //     One address operand and two other input operands.  The instruction
1921 //     stores to the address.
1922 //
1923 //   SideEffectBinary:
1924 //     Two input operands.  No output operands, but causes some side effect.
1925 //
1926 //   Compare:
1927 //     Two input operands and an implicit CC output operand.
1928 //
1929 //   Test:
1930 //     One or two input operands and an implicit CC output operand.  If
1931 //     present, the second input operand is an "address" operand used as
1932 //     a test class mask.
1933 //
1934 //   Ternary:
1935 //     One register output operand and three input operands.
1936 //
1937 //   SideEffectTernary:
1938 //     Three input operands.  No output operands, but causes some side effect.
1939 //
1940 //   Quaternary:
1941 //     One register output operand and four input operands.
1942 //
1943 //   LoadAndOp:
1944 //     One output operand and two input operands, one of which is an address.
1945 //     The instruction both reads from and writes to the address.
1946 //
1947 //   CmpSwap:
1948 //     One output operand and three input operands, one of which is an address.
1949 //     The instruction both reads from and writes to the address.
1950 //
1951 //   RotateSelect:
1952 //     One output operand and five input operands.  The first two operands
1953 //     are registers and the other three are immediates.
1954 //
1955 //   Prefetch:
1956 //     One 4-bit immediate operand and one address operand.  The immediate
1957 //     operand is 1 for a load prefetch and 2 for a store prefetch.
1958 //
1959 //   BranchPreload:
1960 //     One 4-bit immediate operand and two address operands.
1961 //
1962 // The format determines which input operands are tied to output operands,
1963 // and also determines the shape of any address operand.
1964 //
1965 // Multiclasses of the form <Category><Format>Pair define two instructions,
1966 // one with <Category><Format> and one with <Category><Format>Y.  The name
1967 // of the first instruction has no suffix, the name of the second has
1968 // an extra "y".
1969 //
1970 //===----------------------------------------------------------------------===//
1971
1972 class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
1973                   SDPatternOperator operator>
1974   : InstRRE<opcode, (outs cls:$R1), (ins),
1975             mnemonic#"\t$R1",
1976             [(set cls:$R1, (operator))]> {
1977   let R2 = 0;
1978 }
1979
1980 class InherentDualRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
1981   : InstRRE<opcode, (outs cls:$R1, cls:$R2), (ins),
1982             mnemonic#"\t$R1, $R2", []>;
1983
1984 class InherentVRIa<string mnemonic, bits<16> opcode, bits<16> value>
1985   : InstVRIa<opcode, (outs VR128:$V1), (ins), mnemonic#"\t$V1", []> {
1986   let I2 = value;
1987   let M3 = 0;
1988 }
1989
1990 class StoreInherentS<string mnemonic, bits<16> opcode,
1991                      SDPatternOperator operator, bits<5> bytes>
1992   : InstS<opcode, (outs), (ins bdaddr12only:$BD2),
1993           mnemonic#"\t$BD2", [(operator bdaddr12only:$BD2)]> {
1994   let mayStore = 1;
1995   let AccessBytes = bytes;
1996 }
1997
1998 class SideEffectInherentE<string mnemonic, bits<16>opcode>
1999   : InstE<opcode, (outs), (ins), mnemonic, []>;
2000
2001 class SideEffectInherentS<string mnemonic, bits<16> opcode,
2002                           SDPatternOperator operator>
2003   : InstS<opcode, (outs), (ins), mnemonic, [(operator)]> {
2004   let BD2 = 0;
2005 }
2006
2007 class SideEffectInherentRRE<string mnemonic, bits<16> opcode>
2008   : InstRRE<opcode, (outs), (ins), mnemonic, []> {
2009   let R1 = 0;
2010   let R2 = 0;
2011 }
2012
2013 // Allow an optional TLS marker symbol to generate TLS call relocations.
2014 class CallRI<string mnemonic, bits<12> opcode>
2015   : InstRIb<opcode, (outs), (ins GR64:$R1, brtarget16tls:$RI2),
2016             mnemonic#"\t$R1, $RI2", []>;
2017
2018 // Allow an optional TLS marker symbol to generate TLS call relocations.
2019 class CallRIL<string mnemonic, bits<12> opcode>
2020   : InstRILb<opcode, (outs), (ins GR64:$R1, brtarget32tls:$RI2),
2021              mnemonic#"\t$R1, $RI2", []>;
2022
2023 class CallRR<string mnemonic, bits<8> opcode>
2024   : InstRR<opcode, (outs), (ins GR64:$R1, ADDR64:$R2),
2025            mnemonic#"\t$R1, $R2", []>;
2026
2027 class CallRX<string mnemonic, bits<8> opcode>
2028   : InstRXa<opcode, (outs), (ins GR64:$R1, bdxaddr12only:$XBD2),
2029             mnemonic#"\t$R1, $XBD2", []>;
2030
2031 class CondBranchRI<string mnemonic, bits<12> opcode,
2032                    SDPatternOperator operator = null_frag>
2033   : InstRIc<opcode, (outs), (ins cond4:$valid, cond4:$M1, brtarget16:$RI2),
2034             !subst("#", "${M1}", mnemonic)#"\t$RI2",
2035             [(operator cond4:$valid, cond4:$M1, bb:$RI2)]> {
2036   let CCMaskFirst = 1;
2037 }
2038
2039 class AsmCondBranchRI<string mnemonic, bits<12> opcode>
2040   : InstRIc<opcode, (outs), (ins imm32zx4:$M1, brtarget16:$RI2),
2041             mnemonic#"\t$M1, $RI2", []>;
2042
2043 class FixedCondBranchRI<CondVariant V, string mnemonic, bits<12> opcode,
2044                         SDPatternOperator operator = null_frag>
2045   : InstRIc<opcode, (outs), (ins brtarget16:$RI2),
2046             !subst("#", V.suffix, mnemonic)#"\t$RI2", [(operator bb:$RI2)]> {
2047   let isAsmParserOnly = V.alternate;
2048   let M1 = V.ccmask;
2049 }
2050
2051 class CondBranchRIL<string mnemonic, bits<12> opcode>
2052   : InstRILc<opcode, (outs), (ins cond4:$valid, cond4:$M1, brtarget32:$RI2),
2053              !subst("#", "${M1}", mnemonic)#"\t$RI2", []> {
2054   let CCMaskFirst = 1;
2055 }
2056
2057 class AsmCondBranchRIL<string mnemonic, bits<12> opcode>
2058   : InstRILc<opcode, (outs), (ins imm32zx4:$M1, brtarget32:$RI2),
2059              mnemonic#"\t$M1, $RI2", []>;
2060
2061 class FixedCondBranchRIL<CondVariant V, string mnemonic, bits<12> opcode>
2062   : InstRILc<opcode, (outs), (ins brtarget32:$RI2),
2063              !subst("#", V.suffix, mnemonic)#"\t$RI2", []> {
2064   let isAsmParserOnly = V.alternate;
2065   let M1 = V.ccmask;
2066 }
2067
2068 class CondBranchRR<string mnemonic, bits<8> opcode>
2069   : InstRR<opcode, (outs), (ins cond4:$valid, cond4:$R1, GR64:$R2),
2070            !subst("#", "${R1}", mnemonic)#"\t$R2", []> {
2071   let CCMaskFirst = 1;
2072 }
2073
2074 class AsmCondBranchRR<string mnemonic, bits<8> opcode>
2075   : InstRR<opcode, (outs), (ins imm32zx4:$R1, GR64:$R2),
2076            mnemonic#"\t$R1, $R2", []>;
2077
2078 class FixedCondBranchRR<CondVariant V, string mnemonic, bits<8> opcode,
2079                       SDPatternOperator operator = null_frag>
2080   : InstRR<opcode, (outs), (ins ADDR64:$R2),
2081            !subst("#", V.suffix, mnemonic)#"\t$R2", [(operator ADDR64:$R2)]> {
2082   let isAsmParserOnly = V.alternate;
2083   let R1 = V.ccmask;
2084 }
2085
2086 class CondBranchRX<string mnemonic, bits<8> opcode>
2087   : InstRXb<opcode, (outs), (ins cond4:$valid, cond4:$M1, bdxaddr12only:$XBD2),
2088             !subst("#", "${M1}", mnemonic)#"\t$XBD2", []> {
2089   let CCMaskFirst = 1;
2090 }
2091
2092 class AsmCondBranchRX<string mnemonic, bits<8> opcode>
2093   : InstRXb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr12only:$XBD2),
2094             mnemonic#"\t$M1, $XBD2", []>;
2095
2096 class FixedCondBranchRX<CondVariant V, string mnemonic, bits<8> opcode>
2097   : InstRXb<opcode, (outs), (ins bdxaddr12only:$XBD2),
2098             !subst("#", V.suffix, mnemonic)#"\t$XBD2", []> {
2099   let isAsmParserOnly = V.alternate;
2100   let M1 = V.ccmask;
2101 }
2102
2103 class CondBranchRXY<string mnemonic, bits<16> opcode>
2104   : InstRXYb<opcode, (outs), (ins cond4:$valid, cond4:$M1, bdxaddr20only:$XBD2),
2105              !subst("#", "${M1}", mnemonic)#"\t$XBD2", []> {
2106   let CCMaskFirst = 1;
2107   let mayLoad = 1;
2108 }
2109
2110 class AsmCondBranchRXY<string mnemonic, bits<16> opcode>
2111   : InstRXYb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr20only:$XBD2),
2112              mnemonic#"\t$M1, $XBD2", []> {
2113   let mayLoad = 1;
2114 }
2115
2116 class FixedCondBranchRXY<CondVariant V, string mnemonic, bits<16> opcode,
2117                          SDPatternOperator operator = null_frag>
2118   : InstRXYb<opcode, (outs), (ins bdxaddr20only:$XBD2),
2119              !subst("#", V.suffix, mnemonic)#"\t$XBD2",
2120              [(operator (load bdxaddr20only:$XBD2))]> {
2121   let isAsmParserOnly = V.alternate;
2122   let M1 = V.ccmask;
2123   let mayLoad = 1;
2124 }
2125
2126 class CmpBranchRIEa<string mnemonic, bits<16> opcode,
2127                     RegisterOperand cls, Immediate imm>
2128   : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2, cond4:$M3),
2129              mnemonic#"$M3\t$R1, $I2", []>;
2130
2131 class AsmCmpBranchRIEa<string mnemonic, bits<16> opcode,
2132                        RegisterOperand cls, Immediate imm>
2133   : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2, imm32zx4:$M3),
2134              mnemonic#"\t$R1, $I2, $M3", []>;
2135
2136 class FixedCmpBranchRIEa<CondVariant V, string mnemonic, bits<16> opcode,
2137                           RegisterOperand cls, Immediate imm>
2138   : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2),
2139              mnemonic#V.suffix#"\t$R1, $I2", []> {
2140   let isAsmParserOnly = V.alternate;
2141   let M3 = V.ccmask;
2142 }
2143
2144 multiclass CmpBranchRIEaPair<string mnemonic, bits<16> opcode,
2145                              RegisterOperand cls, Immediate imm> {
2146   let isCodeGenOnly = 1 in
2147     def "" : CmpBranchRIEa<mnemonic, opcode, cls, imm>;
2148   def Asm : AsmCmpBranchRIEa<mnemonic, opcode, cls, imm>;
2149 }
2150
2151 class CmpBranchRIEb<string mnemonic, bits<16> opcode,
2152                     RegisterOperand cls>
2153   : InstRIEb<opcode, (outs),
2154              (ins cls:$R1, cls:$R2, cond4:$M3, brtarget16:$RI4),
2155              mnemonic#"$M3\t$R1, $R2, $RI4", []>;
2156
2157 class AsmCmpBranchRIEb<string mnemonic, bits<16> opcode,
2158                        RegisterOperand cls>
2159   : InstRIEb<opcode, (outs),
2160              (ins cls:$R1, cls:$R2, imm32zx4:$M3, brtarget16:$RI4),
2161              mnemonic#"\t$R1, $R2, $M3, $RI4", []>;
2162
2163 class FixedCmpBranchRIEb<CondVariant V, string mnemonic, bits<16> opcode,
2164                          RegisterOperand cls>
2165   : InstRIEb<opcode, (outs), (ins cls:$R1, cls:$R2, brtarget16:$RI4),
2166              mnemonic#V.suffix#"\t$R1, $R2, $RI4", []> {
2167   let isAsmParserOnly = V.alternate;
2168   let M3 = V.ccmask;
2169 }
2170
2171 multiclass CmpBranchRIEbPair<string mnemonic, bits<16> opcode,
2172                              RegisterOperand cls> {
2173   let isCodeGenOnly = 1 in
2174     def "" : CmpBranchRIEb<mnemonic, opcode, cls>;
2175   def Asm : AsmCmpBranchRIEb<mnemonic, opcode, cls>;
2176 }
2177
2178 class CmpBranchRIEc<string mnemonic, bits<16> opcode,
2179                     RegisterOperand cls, Immediate imm>
2180   : InstRIEc<opcode, (outs),
2181              (ins cls:$R1, imm:$I2, cond4:$M3, brtarget16:$RI4),
2182              mnemonic#"$M3\t$R1, $I2, $RI4", []>;
2183
2184 class AsmCmpBranchRIEc<string mnemonic, bits<16> opcode,
2185                        RegisterOperand cls, Immediate imm>
2186   : InstRIEc<opcode, (outs),
2187              (ins cls:$R1, imm:$I2, imm32zx4:$M3, brtarget16:$RI4),
2188              mnemonic#"\t$R1, $I2, $M3, $RI4", []>;
2189
2190 class FixedCmpBranchRIEc<CondVariant V, string mnemonic, bits<16> opcode,
2191                          RegisterOperand cls, Immediate imm>
2192   : InstRIEc<opcode, (outs), (ins cls:$R1, imm:$I2, brtarget16:$RI4),
2193              mnemonic#V.suffix#"\t$R1, $I2, $RI4", []> {
2194   let isAsmParserOnly = V.alternate;
2195   let M3 = V.ccmask;
2196 }
2197
2198 multiclass CmpBranchRIEcPair<string mnemonic, bits<16> opcode,
2199                             RegisterOperand cls, Immediate imm> {
2200   let isCodeGenOnly = 1 in
2201     def "" : CmpBranchRIEc<mnemonic, opcode, cls, imm>;
2202   def Asm : AsmCmpBranchRIEc<mnemonic, opcode, cls, imm>;
2203 }
2204
2205 class CmpBranchRRFc<string mnemonic, bits<16> opcode,
2206                     RegisterOperand cls>
2207   : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2, cond4:$M3),
2208              mnemonic#"$M3\t$R1, $R2", []>;
2209
2210 class AsmCmpBranchRRFc<string mnemonic, bits<16> opcode,
2211                        RegisterOperand cls>
2212   : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2, imm32zx4:$M3),
2213              mnemonic#"\t$R1, $R2, $M3", []>;
2214
2215 multiclass CmpBranchRRFcPair<string mnemonic, bits<16> opcode,
2216                              RegisterOperand cls> {
2217   let isCodeGenOnly = 1 in
2218     def "" : CmpBranchRRFc<mnemonic, opcode, cls>;
2219   def Asm : AsmCmpBranchRRFc<mnemonic, opcode, cls>;
2220 }
2221
2222 class FixedCmpBranchRRFc<CondVariant V, string mnemonic, bits<16> opcode,
2223                           RegisterOperand cls>
2224   : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2),
2225              mnemonic#V.suffix#"\t$R1, $R2", []> {
2226   let isAsmParserOnly = V.alternate;
2227   let M3 = V.ccmask;
2228 }
2229
2230 class CmpBranchRRS<string mnemonic, bits<16> opcode,
2231                    RegisterOperand cls>
2232   : InstRRS<opcode, (outs),
2233             (ins cls:$R1, cls:$R2, cond4:$M3, bdaddr12only:$BD4),
2234             mnemonic#"$M3\t$R1, $R2, $BD4", []>;
2235
2236 class AsmCmpBranchRRS<string mnemonic, bits<16> opcode,
2237                       RegisterOperand cls>
2238   : InstRRS<opcode, (outs),
2239             (ins cls:$R1, cls:$R2, imm32zx4:$M3, bdaddr12only:$BD4),
2240             mnemonic#"\t$R1, $R2, $M3, $BD4", []>;
2241
2242 class FixedCmpBranchRRS<CondVariant V, string mnemonic, bits<16> opcode,
2243                         RegisterOperand cls>
2244   : InstRRS<opcode, (outs), (ins cls:$R1, cls:$R2, bdaddr12only:$BD4),
2245             mnemonic#V.suffix#"\t$R1, $R2, $BD4", []> {
2246   let isAsmParserOnly = V.alternate;
2247   let M3 = V.ccmask;
2248 }
2249
2250 multiclass CmpBranchRRSPair<string mnemonic, bits<16> opcode,
2251                             RegisterOperand cls> {
2252   let isCodeGenOnly = 1 in
2253     def "" : CmpBranchRRS<mnemonic, opcode, cls>;
2254   def Asm : AsmCmpBranchRRS<mnemonic, opcode, cls>;
2255 }
2256
2257 class CmpBranchRIS<string mnemonic, bits<16> opcode,
2258                    RegisterOperand cls, Immediate imm>
2259   : InstRIS<opcode, (outs),
2260             (ins cls:$R1, imm:$I2, cond4:$M3, bdaddr12only:$BD4),
2261             mnemonic#"$M3\t$R1, $I2, $BD4", []>;
2262
2263 class AsmCmpBranchRIS<string mnemonic, bits<16> opcode,
2264                       RegisterOperand cls, Immediate imm>
2265   : InstRIS<opcode, (outs),
2266             (ins cls:$R1, imm:$I2, imm32zx4:$M3, bdaddr12only:$BD4),
2267             mnemonic#"\t$R1, $I2, $M3, $BD4", []>;
2268
2269 class FixedCmpBranchRIS<CondVariant V, string mnemonic, bits<16> opcode,
2270                         RegisterOperand cls, Immediate imm>
2271   : InstRIS<opcode, (outs), (ins cls:$R1, imm:$I2, bdaddr12only:$BD4),
2272             mnemonic#V.suffix#"\t$R1, $I2, $BD4", []> {
2273   let isAsmParserOnly = V.alternate;
2274   let M3 = V.ccmask;
2275 }
2276
2277 multiclass CmpBranchRISPair<string mnemonic, bits<16> opcode,
2278                             RegisterOperand cls, Immediate imm> {
2279   let isCodeGenOnly = 1 in
2280     def "" : CmpBranchRIS<mnemonic, opcode, cls, imm>;
2281   def Asm : AsmCmpBranchRIS<mnemonic, opcode, cls, imm>;
2282 }
2283
2284 class CmpBranchRSYb<string mnemonic, bits<16> opcode,
2285                     RegisterOperand cls>
2286   : InstRSYb<opcode, (outs), (ins cls:$R1, bdaddr20only:$BD2, cond4:$M3),
2287              mnemonic#"$M3\t$R1, $BD2", []>;
2288
2289 class AsmCmpBranchRSYb<string mnemonic, bits<16> opcode,
2290                        RegisterOperand cls>
2291   : InstRSYb<opcode, (outs), (ins cls:$R1, bdaddr20only:$BD2, imm32zx4:$M3),
2292              mnemonic#"\t$R1, $M3, $BD2", []>;
2293
2294 multiclass CmpBranchRSYbPair<string mnemonic, bits<16> opcode,
2295                              RegisterOperand cls> {
2296   let isCodeGenOnly = 1 in
2297     def "" : CmpBranchRSYb<mnemonic, opcode, cls>;
2298   def Asm : AsmCmpBranchRSYb<mnemonic, opcode, cls>;
2299 }
2300
2301 class FixedCmpBranchRSYb<CondVariant V, string mnemonic, bits<16> opcode,
2302                           RegisterOperand cls>
2303   : InstRSYb<opcode, (outs), (ins cls:$R1, bdaddr20only:$BD2),
2304              mnemonic#V.suffix#"\t$R1, $BD2", []> {
2305   let isAsmParserOnly = V.alternate;
2306   let M3 = V.ccmask;
2307 }
2308
2309 class BranchUnaryRI<string mnemonic, bits<12> opcode, RegisterOperand cls>
2310   : InstRIb<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget16:$RI2),
2311             mnemonic##"\t$R1, $RI2", []> {
2312   let Constraints = "$R1 = $R1src";
2313   let DisableEncoding = "$R1src";
2314 }
2315
2316 class BranchUnaryRIL<string mnemonic, bits<12> opcode, RegisterOperand cls>
2317   : InstRILb<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget32:$RI2),
2318              mnemonic##"\t$R1, $RI2", []> {
2319   let Constraints = "$R1 = $R1src";
2320   let DisableEncoding = "$R1src";
2321 }
2322
2323 class BranchUnaryRR<string mnemonic, bits<8> opcode, RegisterOperand cls>
2324   : InstRR<opcode, (outs cls:$R1), (ins cls:$R1src, GR64:$R2),
2325            mnemonic##"\t$R1, $R2", []> {
2326   let Constraints = "$R1 = $R1src";
2327   let DisableEncoding = "$R1src";
2328 }
2329
2330 class BranchUnaryRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
2331   : InstRRE<opcode, (outs cls:$R1), (ins cls:$R1src, GR64:$R2),
2332             mnemonic##"\t$R1, $R2", []> {
2333   let Constraints = "$R1 = $R1src";
2334   let DisableEncoding = "$R1src";
2335 }
2336
2337 class BranchUnaryRX<string mnemonic, bits<8> opcode, RegisterOperand cls>
2338   : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
2339             mnemonic##"\t$R1, $XBD2", []> {
2340   let Constraints = "$R1 = $R1src";
2341   let DisableEncoding = "$R1src";
2342 }
2343
2344 class BranchUnaryRXY<string mnemonic, bits<16> opcode, RegisterOperand cls>
2345   : InstRXYa<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr20only:$XBD2),
2346              mnemonic##"\t$R1, $XBD2", []> {
2347   let Constraints = "$R1 = $R1src";
2348   let DisableEncoding = "$R1src";
2349 }
2350
2351 class BranchBinaryRSI<string mnemonic, bits<8> opcode, RegisterOperand cls>
2352   : InstRSI<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, brtarget16:$RI2),
2353             mnemonic##"\t$R1, $R3, $RI2", []> {
2354   let Constraints = "$R1 = $R1src";
2355   let DisableEncoding = "$R1src";
2356 }
2357
2358 class BranchBinaryRIEe<string mnemonic, bits<16> opcode, RegisterOperand cls>
2359   : InstRIEe<opcode, (outs cls:$R1),
2360              (ins cls:$R1src, cls:$R3, brtarget16:$RI2),
2361              mnemonic##"\t$R1, $R3, $RI2", []> {
2362   let Constraints = "$R1 = $R1src";
2363   let DisableEncoding = "$R1src";
2364 }
2365
2366 class BranchBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls>
2367   : InstRSa<opcode, (outs cls:$R1),
2368             (ins cls:$R1src, cls:$R3, bdaddr12only:$BD2),
2369             mnemonic##"\t$R1, $R3, $BD2", []> {
2370   let Constraints = "$R1 = $R1src";
2371   let DisableEncoding = "$R1src";
2372 }
2373
2374 class BranchBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
2375   : InstRSYa<opcode,
2376              (outs cls:$R1), (ins cls:$R1src, cls:$R3, bdaddr20only:$BD2),
2377              mnemonic##"\t$R1, $R3, $BD2", []> {
2378   let Constraints = "$R1 = $R1src";
2379   let DisableEncoding = "$R1src";
2380 }
2381
2382 class LoadMultipleRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
2383                      AddressingMode mode = bdaddr12only>
2384   : InstRSa<opcode, (outs cls:$R1, cls:$R3), (ins mode:$BD2),
2385             mnemonic#"\t$R1, $R3, $BD2", []> {
2386   let mayLoad = 1;
2387 }
2388
2389 class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
2390                       AddressingMode mode = bdaddr20only>
2391   : InstRSYa<opcode, (outs cls:$R1, cls:$R3), (ins mode:$BD2),
2392              mnemonic#"\t$R1, $R3, $BD2", []> {
2393   let mayLoad = 1;
2394 }
2395
2396 multiclass LoadMultipleRSPair<string mnemonic, bits<8> rsOpcode,
2397                               bits<16> rsyOpcode, RegisterOperand cls> {
2398   let DispKey = mnemonic ## #cls in {
2399     let DispSize = "12" in
2400       def "" : LoadMultipleRS<mnemonic, rsOpcode, cls, bdaddr12pair>;
2401     let DispSize = "20" in
2402       def Y  : LoadMultipleRSY<mnemonic#"y", rsyOpcode, cls, bdaddr20pair>;
2403   }
2404 }
2405
2406 class LoadMultipleSSe<string mnemonic, bits<8> opcode, RegisterOperand cls>
2407   : InstSSe<opcode, (outs cls:$R1, cls:$R3),
2408             (ins bdaddr12only:$BD2, bdaddr12only:$BD4),
2409             mnemonic#"\t$R1, $R3, $BD2, $BD4", []> {
2410   let mayLoad = 1;
2411 }
2412
2413 class LoadMultipleVRSa<string mnemonic, bits<16> opcode>
2414   : InstVRSa<opcode, (outs VR128:$V1, VR128:$V3), (ins bdaddr12only:$BD2),
2415              mnemonic#"\t$V1, $V3, $BD2", []> {
2416   let M4 = 0;
2417   let mayLoad = 1;
2418 }
2419
2420 class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2421                  RegisterOperand cls>
2422   : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
2423              mnemonic#"\t$R1, $RI2",
2424              [(operator cls:$R1, pcrel32:$RI2)]> {
2425   let mayStore = 1;
2426   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
2427   // However, BDXs have two extra operands and are therefore 6 units more
2428   // complex.
2429   let AddedComplexity = 7;
2430 }
2431
2432 class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2433               RegisterOperand cls, bits<5> bytes,
2434               AddressingMode mode = bdxaddr12only>
2435   : InstRXa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
2436             mnemonic#"\t$R1, $XBD2",
2437             [(operator cls:$R1, mode:$XBD2)]> {
2438   let OpKey = mnemonic#"r"#cls;
2439   let OpType = "mem";
2440   let mayStore = 1;
2441   let AccessBytes = bytes;
2442 }
2443
2444 class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2445                RegisterOperand cls, bits<5> bytes,
2446                AddressingMode mode = bdxaddr20only>
2447   : InstRXYa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
2448              mnemonic#"\t$R1, $XBD2",
2449              [(operator cls:$R1, mode:$XBD2)]> {
2450   let OpKey = mnemonic#"r"#cls;
2451   let OpType = "mem";
2452   let mayStore = 1;
2453   let AccessBytes = bytes;
2454 }
2455
2456 multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
2457                        SDPatternOperator operator, RegisterOperand cls,
2458                        bits<5> bytes> {
2459   let DispKey = mnemonic ## #cls in {
2460     let DispSize = "12" in
2461       def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
2462     let DispSize = "20" in
2463       def Y  : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
2464                         bdxaddr20pair>;
2465   }
2466 }
2467
2468 class StoreVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2469                TypedReg tr, bits<5> bytes, bits<4> type = 0>
2470   : InstVRX<opcode, (outs), (ins tr.op:$V1, bdxaddr12only:$XBD2),
2471             mnemonic#"\t$V1, $XBD2",
2472             [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2))]> {
2473   let M3 = type;
2474   let mayStore = 1;
2475   let AccessBytes = bytes;
2476 }
2477
2478 class StoreLengthVRSb<string mnemonic, bits<16> opcode,
2479                       SDPatternOperator operator, bits<5> bytes>
2480   : InstVRSb<opcode, (outs), (ins VR128:$V1, GR32:$R3, bdaddr12only:$BD2),
2481              mnemonic#"\t$V1, $R3, $BD2",
2482              [(operator VR128:$V1, GR32:$R3, bdaddr12only:$BD2)]> {
2483   let M4 = 0;
2484   let mayStore = 1;
2485   let AccessBytes = bytes;
2486 }
2487
2488 class StoreLengthVRSd<string mnemonic, bits<16> opcode,
2489                       SDPatternOperator operator, bits<5> bytes>
2490   : InstVRSd<opcode, (outs), (ins VR128:$V1, GR32:$R3, bdaddr12only:$BD2),
2491              mnemonic#"\t$V1, $R3, $BD2",
2492              [(operator VR128:$V1, GR32:$R3, bdaddr12only:$BD2)]> {
2493   let mayStore = 1;
2494   let AccessBytes = bytes;
2495 }
2496
2497 class StoreLengthVSI<string mnemonic, bits<16> opcode,
2498                      SDPatternOperator operator, bits<5> bytes>
2499   : InstVSI<opcode, (outs), (ins VR128:$V1, bdaddr12only:$BD2, imm32zx8:$I3),
2500             mnemonic#"\t$V1, $BD2, $I3",
2501             [(operator VR128:$V1, imm32zx8:$I3, bdaddr12only:$BD2)]> {
2502   let mayStore = 1;
2503   let AccessBytes = bytes;
2504 }
2505
2506 class StoreMultipleRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
2507                       AddressingMode mode = bdaddr12only>
2508   : InstRSa<opcode, (outs), (ins cls:$R1, cls:$R3, mode:$BD2),
2509             mnemonic#"\t$R1, $R3, $BD2", []> {
2510   let mayStore = 1;
2511 }
2512
2513 class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
2514                        AddressingMode mode = bdaddr20only>
2515   : InstRSYa<opcode, (outs), (ins cls:$R1, cls:$R3, mode:$BD2),
2516              mnemonic#"\t$R1, $R3, $BD2", []> {
2517   let mayStore = 1;
2518 }
2519
2520 multiclass StoreMultipleRSPair<string mnemonic, bits<8> rsOpcode,
2521                                bits<16> rsyOpcode, RegisterOperand cls> {
2522   let DispKey = mnemonic ## #cls in {
2523     let DispSize = "12" in
2524       def "" : StoreMultipleRS<mnemonic, rsOpcode, cls, bdaddr12pair>;
2525     let DispSize = "20" in
2526       def Y  : StoreMultipleRSY<mnemonic#"y", rsyOpcode, cls, bdaddr20pair>;
2527   }
2528 }
2529
2530 class StoreMultipleVRSa<string mnemonic, bits<16> opcode>
2531   : InstVRSa<opcode, (outs), (ins VR128:$V1, VR128:$V3, bdaddr12only:$BD2),
2532              mnemonic#"\t$V1, $V3, $BD2", []> {
2533   let M4 = 0;
2534   let mayStore = 1;
2535 }
2536
2537 // StoreSI* instructions are used to store an integer to memory, but the
2538 // addresses are more restricted than for normal stores.  If we are in the
2539 // situation of having to force either the address into a register or the
2540 // constant into a register, it's usually better to do the latter.
2541 // We therefore match the address in the same way as a normal store and
2542 // only use the StoreSI* instruction if the matched address is suitable.
2543 class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2544               Immediate imm>
2545   : InstSI<opcode, (outs), (ins mviaddr12pair:$BD1, imm:$I2),
2546            mnemonic#"\t$BD1, $I2",
2547            [(operator imm:$I2, mviaddr12pair:$BD1)]> {
2548   let mayStore = 1;
2549 }
2550
2551 class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2552                Immediate imm>
2553   : InstSIY<opcode, (outs), (ins mviaddr20pair:$BD1, imm:$I2),
2554             mnemonic#"\t$BD1, $I2",
2555             [(operator imm:$I2, mviaddr20pair:$BD1)]> {
2556   let mayStore = 1;
2557 }
2558
2559 class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2560                Immediate imm>
2561   : InstSIL<opcode, (outs), (ins mviaddr12pair:$BD1, imm:$I2),
2562             mnemonic#"\t$BD1, $I2",
2563             [(operator imm:$I2, mviaddr12pair:$BD1)]> {
2564   let mayStore = 1;
2565 }
2566
2567 multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
2568                        SDPatternOperator operator, Immediate imm> {
2569   let DispKey = mnemonic in {
2570     let DispSize = "12" in
2571       def "" : StoreSI<mnemonic, siOpcode, operator, imm>;
2572     let DispSize = "20" in
2573       def Y  : StoreSIY<mnemonic#"y", siyOpcode, operator, imm>;
2574   }
2575 }
2576
2577 class StoreSSE<string mnemonic, bits<16> opcode>
2578   : InstSSE<opcode, (outs), (ins bdaddr12only:$BD1, bdaddr12only:$BD2),
2579             mnemonic#"\t$BD1, $BD2", []> {
2580   let mayStore = 1;
2581 }
2582
2583 class CondStoreRSY<string mnemonic, bits<16> opcode,
2584                    RegisterOperand cls, bits<5> bytes,
2585                    AddressingMode mode = bdaddr20only>
2586   : InstRSYb<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$M3),
2587             mnemonic#"$M3\t$R1, $BD2", []> {
2588   let mayStore = 1;
2589   let AccessBytes = bytes;
2590   let CCMaskLast = 1;
2591 }
2592
2593 // Like CondStoreRSY, but used for the raw assembly form.  The condition-code
2594 // mask is the third operand rather than being part of the mnemonic.
2595 class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
2596                       RegisterOperand cls, bits<5> bytes,
2597                       AddressingMode mode = bdaddr20only>
2598   : InstRSYb<opcode, (outs), (ins cls:$R1, mode:$BD2, imm32zx4:$M3),
2599              mnemonic#"\t$R1, $BD2, $M3", []> {
2600   let mayStore = 1;
2601   let AccessBytes = bytes;
2602 }
2603
2604 // Like CondStoreRSY, but with a fixed CC mask.
2605 class FixedCondStoreRSY<CondVariant V, string mnemonic, bits<16> opcode,
2606                         RegisterOperand cls, bits<5> bytes,
2607                         AddressingMode mode = bdaddr20only>
2608   : InstRSYb<opcode, (outs), (ins cls:$R1, mode:$BD2),
2609              mnemonic#V.suffix#"\t$R1, $BD2", []> {
2610   let mayStore = 1;
2611   let AccessBytes = bytes;
2612   let isAsmParserOnly = V.alternate;
2613   let M3 = V.ccmask;
2614 }
2615
2616 multiclass CondStoreRSYPair<string mnemonic, bits<16> opcode,
2617                             RegisterOperand cls, bits<5> bytes,
2618                             AddressingMode mode = bdaddr20only> {
2619   let isCodeGenOnly = 1 in
2620     def "" : CondStoreRSY<mnemonic, opcode, cls, bytes, mode>;
2621   def Asm : AsmCondStoreRSY<mnemonic, opcode, cls, bytes, mode>;
2622 }
2623
2624 class SideEffectUnaryI<string mnemonic, bits<8> opcode, Immediate imm>
2625   : InstI<opcode, (outs), (ins imm:$I1),
2626           mnemonic#"\t$I1", []>;
2627
2628 class SideEffectUnaryRR<string mnemonic, bits<8>opcode, RegisterOperand cls>
2629   : InstRR<opcode, (outs), (ins cls:$R1),
2630            mnemonic#"\t$R1", []> {
2631   let R2 = 0;
2632 }
2633
2634 class SideEffectUnaryRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
2635                          SDPatternOperator operator>
2636   : InstRRE<opcode, (outs), (ins cls:$R1),
2637             mnemonic#"\t$R1", [(operator cls:$R1)]> {
2638   let R2 = 0;
2639 }
2640
2641 class SideEffectUnaryS<string mnemonic, bits<16> opcode,
2642                        SDPatternOperator operator, bits<5> bytes,
2643                        AddressingMode mode = bdaddr12only>
2644   : InstS<opcode, (outs), (ins mode:$BD2),
2645           mnemonic#"\t$BD2", [(operator mode:$BD2)]> {
2646   let mayLoad = 1;
2647   let AccessBytes = bytes;
2648 }
2649
2650 class SideEffectAddressS<string mnemonic, bits<16> opcode,
2651                         SDPatternOperator operator,
2652                         AddressingMode mode = bdaddr12only>
2653   : InstS<opcode, (outs), (ins mode:$BD2),
2654           mnemonic#"\t$BD2", [(operator mode:$BD2)]>;
2655
2656 class LoadAddressRX<string mnemonic, bits<8> opcode,
2657                     SDPatternOperator operator, AddressingMode mode>
2658   : InstRXa<opcode, (outs GR64:$R1), (ins mode:$XBD2),
2659             mnemonic#"\t$R1, $XBD2",
2660             [(set GR64:$R1, (operator mode:$XBD2))]>;
2661
2662 class LoadAddressRXY<string mnemonic, bits<16> opcode,
2663                      SDPatternOperator operator, AddressingMode mode>
2664   : InstRXYa<opcode, (outs GR64:$R1), (ins mode:$XBD2),
2665              mnemonic#"\t$R1, $XBD2",
2666              [(set GR64:$R1, (operator mode:$XBD2))]>;
2667
2668 multiclass LoadAddressRXPair<string mnemonic, bits<8> rxOpcode,
2669                              bits<16> rxyOpcode, SDPatternOperator operator> {
2670   let DispKey = mnemonic in {
2671     let DispSize = "12" in
2672       def "" : LoadAddressRX<mnemonic, rxOpcode, operator, laaddr12pair>;
2673     let DispSize = "20" in
2674       def Y  : LoadAddressRXY<mnemonic#"y", rxyOpcode, operator, laaddr20pair>;
2675   }
2676 }
2677
2678 class LoadAddressRIL<string mnemonic, bits<12> opcode,
2679                      SDPatternOperator operator>
2680   : InstRILb<opcode, (outs GR64:$R1), (ins pcrel32:$RI2),
2681              mnemonic#"\t$R1, $RI2",
2682              [(set GR64:$R1, (operator pcrel32:$RI2))]>;
2683
2684 class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2685               RegisterOperand cls1, RegisterOperand cls2>
2686   : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
2687            mnemonic#"\t$R1, $R2",
2688            [(set cls1:$R1, (operator cls2:$R2))]> {
2689   let OpKey = mnemonic#cls1;
2690   let OpType = "reg";
2691 }
2692
2693 class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2694                RegisterOperand cls1, RegisterOperand cls2>
2695   : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
2696             mnemonic#"\t$R1, $R2",
2697             [(set cls1:$R1, (operator cls2:$R2))]> {
2698   let OpKey = mnemonic#cls1;
2699   let OpType = "reg";
2700 }
2701
2702 class UnaryTiedRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
2703   : InstRRE<opcode, (outs cls:$R1), (ins cls:$R1src),
2704             mnemonic#"\t$R1", []> {
2705   let Constraints = "$R1 = $R1src";
2706   let DisableEncoding = "$R1src";
2707   let R2 = 0;
2708 }
2709
2710 class UnaryMemRRFc<string mnemonic, bits<16> opcode,
2711                    RegisterOperand cls1, RegisterOperand cls2>
2712   : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src),
2713             mnemonic#"\t$R1, $R2", []> {
2714   let Constraints = "$R1 = $R1src";
2715   let DisableEncoding = "$R1src";
2716   let M3 = 0;
2717 }
2718
2719 class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2720               RegisterOperand cls, Immediate imm>
2721   : InstRIa<opcode, (outs cls:$R1), (ins imm:$I2),
2722             mnemonic#"\t$R1, $I2",
2723             [(set cls:$R1, (operator imm:$I2))]>;
2724
2725 class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2726                RegisterOperand cls, Immediate imm>
2727   : InstRILa<opcode, (outs cls:$R1), (ins imm:$I2),
2728              mnemonic#"\t$R1, $I2",
2729              [(set cls:$R1, (operator imm:$I2))]>;
2730
2731 class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2732                  RegisterOperand cls>
2733   : InstRILb<opcode, (outs cls:$R1), (ins pcrel32:$RI2),
2734              mnemonic#"\t$R1, $RI2",
2735              [(set cls:$R1, (operator pcrel32:$RI2))]> {
2736   let mayLoad = 1;
2737   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
2738   // However, BDXs have two extra operands and are therefore 6 units more
2739   // complex.
2740   let AddedComplexity = 7;
2741 }
2742
2743 class CondUnaryRSY<string mnemonic, bits<16> opcode,
2744                    SDPatternOperator operator, RegisterOperand cls,
2745                    bits<5> bytes, AddressingMode mode = bdaddr20only>
2746   : InstRSYb<opcode, (outs cls:$R1),
2747              (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$M3),
2748              mnemonic#"$M3\t$R1, $BD2",
2749              [(set cls:$R1,
2750                    (z_select_ccmask (operator bdaddr20only:$BD2), cls:$R1src,
2751                                     cond4:$valid, cond4:$M3))]> {
2752   let Constraints = "$R1 = $R1src";
2753   let DisableEncoding = "$R1src";
2754   let mayLoad = 1;
2755   let AccessBytes = bytes;
2756   let CCMaskLast = 1;
2757 }
2758
2759 // Like CondUnaryRSY, but used for the raw assembly form.  The condition-code
2760 // mask is the third operand rather than being part of the mnemonic.
2761 class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
2762                       RegisterOperand cls, bits<5> bytes,
2763                       AddressingMode mode = bdaddr20only>
2764   : InstRSYb<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, imm32zx4:$M3),
2765              mnemonic#"\t$R1, $BD2, $M3", []> {
2766   let mayLoad = 1;
2767   let AccessBytes = bytes;
2768   let Constraints = "$R1 = $R1src";
2769   let DisableEncoding = "$R1src";
2770 }
2771
2772 // Like CondUnaryRSY, but with a fixed CC mask.
2773 class FixedCondUnaryRSY<CondVariant V, string mnemonic, bits<16> opcode,
2774                         RegisterOperand cls, bits<5> bytes,
2775                         AddressingMode mode = bdaddr20only>
2776   : InstRSYb<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
2777              mnemonic#V.suffix#"\t$R1, $BD2", []> {
2778   let Constraints = "$R1 = $R1src";
2779   let DisableEncoding = "$R1src";
2780   let mayLoad = 1;
2781   let AccessBytes = bytes;
2782   let isAsmParserOnly = V.alternate;
2783   let M3 = V.ccmask;
2784 }
2785
2786 multiclass CondUnaryRSYPair<string mnemonic, bits<16> opcode,
2787                             SDPatternOperator operator,
2788                             RegisterOperand cls, bits<5> bytes,
2789                             AddressingMode mode = bdaddr20only> {
2790   let isCodeGenOnly = 1 in
2791     def "" : CondUnaryRSY<mnemonic, opcode, operator, cls, bytes, mode>;
2792   def Asm : AsmCondUnaryRSY<mnemonic, opcode, cls, bytes, mode>;
2793 }
2794
2795 class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2796               RegisterOperand cls, bits<5> bytes,
2797               AddressingMode mode = bdxaddr12only>
2798   : InstRXa<opcode, (outs cls:$R1), (ins mode:$XBD2),
2799             mnemonic#"\t$R1, $XBD2",
2800             [(set cls:$R1, (operator mode:$XBD2))]> {
2801   let OpKey = mnemonic#"r"#cls;
2802   let OpType = "mem";
2803   let mayLoad = 1;
2804   let AccessBytes = bytes;
2805 }
2806
2807 class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2808                RegisterOperand cls, bits<5> bytes>
2809   : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
2810             mnemonic#"\t$R1, $XBD2",
2811             [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
2812   let OpKey = mnemonic#"r"#cls;
2813   let OpType = "mem";
2814   let mayLoad = 1;
2815   let AccessBytes = bytes;
2816   let M3 = 0;
2817 }
2818
2819 class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2820                RegisterOperand cls, bits<5> bytes,
2821                AddressingMode mode = bdxaddr20only>
2822   : InstRXYa<opcode, (outs cls:$R1), (ins mode:$XBD2),
2823              mnemonic#"\t$R1, $XBD2",
2824              [(set cls:$R1, (operator mode:$XBD2))]> {
2825   let OpKey = mnemonic#"r"#cls;
2826   let OpType = "mem";
2827   let mayLoad = 1;
2828   let AccessBytes = bytes;
2829 }
2830
2831 multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
2832                        SDPatternOperator operator, RegisterOperand cls,
2833                        bits<5> bytes> {
2834   let DispKey = mnemonic ## #cls in {
2835     let DispSize = "12" in
2836       def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
2837     let DispSize = "20" in
2838       def Y  : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
2839                         bdxaddr20pair>;
2840   }
2841 }
2842
2843 class UnaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2844                 TypedReg tr, Immediate imm, bits<4> type = 0>
2845   : InstVRIa<opcode, (outs tr.op:$V1), (ins imm:$I2),
2846              mnemonic#"\t$V1, $I2",
2847              [(set (tr.vt tr.op:$V1), (operator imm:$I2))]> {
2848   let M3 = type;
2849 }
2850
2851 class UnaryVRIaGeneric<string mnemonic, bits<16> opcode, Immediate imm>
2852   : InstVRIa<opcode, (outs VR128:$V1), (ins imm:$I2, imm32zx4:$M3),
2853              mnemonic#"\t$V1, $I2, $M3", []>;
2854
2855 class UnaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2856                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0,
2857                 bits<4> m5 = 0>
2858   : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2),
2859              mnemonic#"\t$V1, $V2",
2860              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]> {
2861   let M3 = type;
2862   let M4 = m4;
2863   let M5 = m5;
2864 }
2865
2866 class UnaryVRRaGeneric<string mnemonic, bits<16> opcode, bits<4> m4 = 0,
2867                        bits<4> m5 = 0>
2868   : InstVRRa<opcode, (outs VR128:$V1), (ins VR128:$V2, imm32zx4:$M3),
2869              mnemonic#"\t$V1, $V2, $M3", []> {
2870   let M4 = m4;
2871   let M5 = m5;
2872 }
2873
2874 class UnaryVRRaFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0>
2875   : InstVRRa<opcode, (outs VR128:$V1),
2876              (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4),
2877              mnemonic#"\t$V1, $V2, $M3, $M4", []> {
2878   let M5 = m5;
2879 }
2880
2881 // Declare a pair of instructions, one which sets CC and one which doesn't.
2882 // The CC-setting form ends with "S" and sets the low bit of M5.
2883 // The form that does not set CC has an extra operand to optionally allow
2884 // specifying arbitrary M5 values in assembler.
2885 multiclass UnaryExtraVRRaSPair<string mnemonic, bits<16> opcode,
2886                                SDPatternOperator operator,
2887                                SDPatternOperator operator_cc,
2888                                TypedReg tr1, TypedReg tr2, bits<4> type> {
2889   let M3 = type, M4 = 0 in
2890     def "" : InstVRRa<opcode, (outs tr1.op:$V1),
2891                       (ins tr2.op:$V2, imm32zx4:$M5),
2892                       mnemonic#"\t$V1, $V2, $M5", []>;
2893   def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2))),
2894             (!cast<Instruction>(NAME) tr2.op:$V2, 0)>;
2895   def : InstAlias<mnemonic#"\t$V1, $V2",
2896                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2, 0)>;
2897   let Defs = [CC] in
2898     def S : UnaryVRRa<mnemonic##"s", opcode, operator_cc, tr1, tr2,
2899                       type, 0, 1>;
2900 }
2901
2902 multiclass UnaryExtraVRRaSPairGeneric<string mnemonic, bits<16> opcode> {
2903   let M4 = 0, Defs = [CC] in
2904     def "" : InstVRRa<opcode, (outs VR128:$V1),
2905                      (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M5),
2906                      mnemonic#"\t$V1, $V2, $M3, $M5", []>;
2907   def : InstAlias<mnemonic#"\t$V1, $V2, $M3",
2908                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2,
2909                                             imm32zx4:$M3, 0)>;
2910 }
2911
2912 class UnaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2913                TypedReg tr, bits<5> bytes, bits<4> type = 0>
2914   : InstVRX<opcode, (outs tr.op:$V1), (ins bdxaddr12only:$XBD2),
2915             mnemonic#"\t$V1, $XBD2",
2916             [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2))]> {
2917   let M3 = type;
2918   let mayLoad = 1;
2919   let AccessBytes = bytes;
2920 }
2921
2922 class UnaryVRXGeneric<string mnemonic, bits<16> opcode>
2923   : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
2924             mnemonic#"\t$V1, $XBD2, $M3", []> {
2925   let mayLoad = 1;
2926 }
2927
2928 class SideEffectBinaryRX<string mnemonic, bits<8> opcode,
2929                          RegisterOperand cls>
2930   : InstRXa<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
2931             mnemonic##"\t$R1, $XBD2", []>;
2932
2933 class SideEffectBinaryRXY<string mnemonic, bits<16> opcode,
2934                           RegisterOperand cls>
2935   : InstRXYa<opcode, (outs), (ins cls:$R1, bdxaddr20only:$XBD2),
2936              mnemonic##"\t$R1, $XBD2", []>;
2937
2938 class SideEffectBinaryRILPC<string mnemonic, bits<12> opcode,
2939                             RegisterOperand cls>
2940   : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
2941              mnemonic##"\t$R1, $RI2", []> {
2942   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
2943   // However, BDXs have two extra operands and are therefore 6 units more
2944   // complex.
2945   let AddedComplexity = 7;
2946 }
2947
2948 class SideEffectBinaryRRE<string mnemonic, bits<16> opcode,
2949                           RegisterOperand cls1, RegisterOperand cls2>
2950   : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
2951             mnemonic#"\t$R1, $R2", []>;
2952
2953 class SideEffectBinaryRRFa<string mnemonic, bits<16> opcode,
2954                            RegisterOperand cls1, RegisterOperand cls2>
2955   : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2),
2956              mnemonic#"\t$R1, $R2", []> {
2957   let R3 = 0;
2958   let M4 = 0;
2959 }
2960
2961 class SideEffectBinaryRRFc<string mnemonic, bits<16> opcode,
2962                            RegisterOperand cls1, RegisterOperand cls2>
2963   : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2),
2964              mnemonic#"\t$R1, $R2", []> {
2965   let M3 = 0;
2966 }
2967
2968 class SideEffectBinaryIE<string mnemonic, bits<16> opcode,
2969                          Immediate imm1, Immediate imm2>
2970   : InstIE<opcode, (outs), (ins imm1:$I1, imm2:$I2),
2971            mnemonic#"\t$I1, $I2", []>;
2972
2973 class SideEffectBinarySI<string mnemonic, bits<8> opcode, Operand imm>
2974   : InstSI<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
2975            mnemonic#"\t$BD1, $I2", []>;
2976
2977 class SideEffectBinarySIL<string mnemonic, bits<16> opcode,
2978                           SDPatternOperator operator, Immediate imm>
2979   : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
2980             mnemonic#"\t$BD1, $I2", [(operator bdaddr12only:$BD1, imm:$I2)]>;
2981
2982 class SideEffectBinarySSa<string mnemonic, bits<8> opcode>
2983   : InstSSa<opcode, (outs), (ins bdladdr12onlylen8:$BDL1, bdaddr12only:$BD2),
2984             mnemonic##"\t$BDL1, $BD2", []>;
2985
2986 class SideEffectBinarySSb<string mnemonic, bits<8> opcode>
2987   : InstSSb<opcode,
2988             (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
2989             mnemonic##"\t$BDL1, $BDL2", []>;
2990
2991 class SideEffectBinarySSf<string mnemonic, bits<8> opcode>
2992   : InstSSf<opcode, (outs), (ins bdaddr12only:$BD1, bdladdr12onlylen8:$BDL2),
2993             mnemonic##"\t$BD1, $BDL2", []>;
2994
2995 class SideEffectBinarySSE<string mnemonic, bits<16> opcode>
2996   : InstSSE<opcode, (outs), (ins bdaddr12only:$BD1, bdaddr12only:$BD2),
2997             mnemonic#"\t$BD1, $BD2", []>;
2998
2999 class SideEffectBinaryMemMemRR<string mnemonic, bits<8> opcode,
3000                                RegisterOperand cls1, RegisterOperand cls2>
3001   : InstRR<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3002            mnemonic#"\t$R1, $R2", []> {
3003     let Constraints = "$R1 = $R1src, $R2 = $R2src";
3004     let DisableEncoding = "$R1src, $R2src";
3005 }
3006
3007 class SideEffectBinaryMemRRE<string mnemonic, bits<16> opcode,
3008                              RegisterOperand cls1, RegisterOperand cls2>
3009   : InstRRE<opcode, (outs cls2:$R2), (ins cls1:$R1, cls2:$R2src),
3010             mnemonic#"\t$R1, $R2", []> {
3011   let Constraints = "$R2 = $R2src";
3012   let DisableEncoding = "$R2src";
3013 }
3014
3015 class SideEffectBinaryMemMemRRE<string mnemonic, bits<16> opcode,
3016                                 RegisterOperand cls1, RegisterOperand cls2>
3017   : InstRRE<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3018             mnemonic#"\t$R1, $R2", []> {
3019     let Constraints = "$R1 = $R1src, $R2 = $R2src";
3020     let DisableEncoding = "$R1src, $R2src";
3021 }
3022
3023 class SideEffectBinaryMemMemRRFc<string mnemonic, bits<16> opcode,
3024                                  RegisterOperand cls1, RegisterOperand cls2>
3025   : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3026              mnemonic#"\t$R1, $R2", []> {
3027   let Constraints = "$R1 = $R1src, $R2 = $R2src";
3028   let DisableEncoding = "$R1src, $R2src";
3029   let M3 = 0;
3030 }
3031
3032 class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3033                RegisterOperand cls1, RegisterOperand cls2>
3034   : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3035            mnemonic#"\t$R1, $R2",
3036            [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
3037   let OpKey = mnemonic#cls1;
3038   let OpType = "reg";
3039   let Constraints = "$R1 = $R1src";
3040   let DisableEncoding = "$R1src";
3041 }
3042
3043 class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3044                 RegisterOperand cls1, RegisterOperand cls2>
3045   : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3046             mnemonic#"\t$R1, $R2",
3047             [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
3048   let OpKey = mnemonic#cls1;
3049   let OpType = "reg";
3050   let Constraints = "$R1 = $R1src";
3051   let DisableEncoding = "$R1src";
3052 }
3053
3054 class BinaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3055                 RegisterOperand cls1, RegisterOperand cls2>
3056   : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R3, cls2:$R2),
3057             mnemonic#"\t$R1, $R3, $R2",
3058             [(set cls1:$R1, (operator cls2:$R3, cls2:$R2))]> {
3059   let OpKey = mnemonic#cls;
3060   let OpType = "reg";
3061 }
3062
3063 class BinaryRRFa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3064                  RegisterOperand cls1, RegisterOperand cls2,
3065                  RegisterOperand cls3>
3066   : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
3067              mnemonic#"\t$R1, $R2, $R3",
3068              [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
3069   let M4 = 0;
3070 }
3071
3072 multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3073                         SDPatternOperator operator, RegisterOperand cls1,
3074                         RegisterOperand cls2> {
3075   let NumOpsKey = mnemonic in {
3076     let NumOpsValue = "3" in
3077       def K : BinaryRRFa<mnemonic#"k", opcode2, null_frag, cls1, cls1, cls2>,
3078               Requires<[FeatureDistinctOps]>;
3079     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
3080       def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
3081   }
3082 }
3083
3084 multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
3085                          SDPatternOperator operator, RegisterOperand cls1,
3086                          RegisterOperand cls2> {
3087   let NumOpsKey = mnemonic in {
3088     let NumOpsValue = "3" in
3089       def K : BinaryRRFa<mnemonic#"k", opcode2, null_frag, cls1, cls1, cls2>,
3090               Requires<[FeatureDistinctOps]>;
3091     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
3092       def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
3093   }
3094 }
3095
3096 class BinaryRRFb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3097                  RegisterOperand cls1, RegisterOperand cls2,
3098                  RegisterOperand cls3>
3099   : InstRRFb<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
3100              mnemonic#"\t$R1, $R3, $R2",
3101              [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
3102   let M4 = 0;
3103 }
3104
3105 class BinaryMemRRFc<string mnemonic, bits<16> opcode,
3106                     RegisterOperand cls1, RegisterOperand cls2, Immediate imm>
3107   : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src, imm:$M3),
3108             mnemonic#"\t$R1, $R2, $M3", []> {
3109   let Constraints = "$R1 = $R1src";
3110   let DisableEncoding = "$R1src";
3111 }
3112
3113 multiclass BinaryMemRRFcOpt<string mnemonic, bits<16> opcode,
3114                             RegisterOperand cls1, RegisterOperand cls2> {
3115   def "" : BinaryMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3116   def Opt : UnaryMemRRFc<mnemonic, opcode, cls1, cls2>;
3117 }
3118
3119 class BinaryRRFd<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3120                 RegisterOperand cls2>
3121   : InstRRFd<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M4),
3122              mnemonic#"\t$R1, $R2, $M4", []>;
3123
3124 class BinaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3125                 RegisterOperand cls2>
3126   : InstRRFe<opcode, (outs cls1:$R1), (ins imm32zx4:$M3, cls2:$R2),
3127              mnemonic#"\t$R1, $M3, $R2", []> {
3128   let M4 = 0;
3129 }
3130
3131 class CondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3132                    RegisterOperand cls2>
3133   : InstRRFc<opcode, (outs cls1:$R1),
3134              (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
3135              mnemonic#"$M3\t$R1, $R2",
3136              [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
3137                                               cond4:$valid, cond4:$M3))]> {
3138   let Constraints = "$R1 = $R1src";
3139   let DisableEncoding = "$R1src";
3140   let CCMaskLast = 1;
3141 }
3142
3143 // Like CondBinaryRRF, but used for the raw assembly form.  The condition-code
3144 // mask is the third operand rather than being part of the mnemonic.
3145 class AsmCondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3146                        RegisterOperand cls2>
3147   : InstRRFc<opcode, (outs cls1:$R1),
3148              (ins cls1:$R1src, cls2:$R2, imm32zx4:$M3),
3149              mnemonic#"\t$R1, $R2, $M3", []> {
3150   let Constraints = "$R1 = $R1src";
3151   let DisableEncoding = "$R1src";
3152 }
3153
3154 // Like CondBinaryRRF, but with a fixed CC mask.
3155 class FixedCondBinaryRRF<CondVariant V, string mnemonic, bits<16> opcode,
3156                          RegisterOperand cls1, RegisterOperand cls2>
3157   : InstRRFc<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3158              mnemonic#V.suffix#"\t$R1, $R2", []> {
3159   let Constraints = "$R1 = $R1src";
3160   let DisableEncoding = "$R1src";
3161   let isAsmParserOnly = V.alternate;
3162   let M3 = V.ccmask;
3163 }
3164
3165 multiclass CondBinaryRRFPair<string mnemonic, bits<16> opcode,
3166                              RegisterOperand cls1, RegisterOperand cls2> {
3167   let isCodeGenOnly = 1 in
3168     def "" : CondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3169   def Asm : AsmCondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3170 }
3171
3172 class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3173                RegisterOperand cls, Immediate imm>
3174   : InstRIa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3175             mnemonic#"\t$R1, $I2",
3176             [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3177   let Constraints = "$R1 = $R1src";
3178   let DisableEncoding = "$R1src";
3179 }
3180
3181 class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3182                 RegisterOperand cls, Immediate imm>
3183   : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
3184              mnemonic#"\t$R1, $R3, $I2",
3185              [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
3186
3187 multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
3188                         SDPatternOperator operator, RegisterOperand cls,
3189                         Immediate imm> {
3190   let NumOpsKey = mnemonic in {
3191     let NumOpsValue = "3" in
3192       def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
3193               Requires<[FeatureDistinctOps]>;
3194     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
3195       def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
3196   }
3197 }
3198
3199 class CondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3200                     Immediate imm>
3201   : InstRIEg<opcode, (outs cls:$R1),
3202              (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
3203              mnemonic#"$M3\t$R1, $I2",
3204              [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
3205                                              cond4:$valid, cond4:$M3))]> {
3206   let Constraints = "$R1 = $R1src";
3207   let DisableEncoding = "$R1src";
3208   let CCMaskLast = 1;
3209 }
3210
3211 // Like CondBinaryRIE, but used for the raw assembly form.  The condition-code
3212 // mask is the third operand rather than being part of the mnemonic.
3213 class AsmCondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3214                        Immediate imm>
3215   : InstRIEg<opcode, (outs cls:$R1),
3216              (ins cls:$R1src, imm:$I2, imm32zx4:$M3),
3217              mnemonic#"\t$R1, $I2, $M3", []> {
3218   let Constraints = "$R1 = $R1src";
3219   let DisableEncoding = "$R1src";
3220 }
3221
3222 // Like CondBinaryRIE, but with a fixed CC mask.
3223 class FixedCondBinaryRIE<CondVariant V, string mnemonic, bits<16> opcode,
3224                          RegisterOperand cls, Immediate imm>
3225   : InstRIEg<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3226              mnemonic#V.suffix#"\t$R1, $I2", []> {
3227   let Constraints = "$R1 = $R1src";
3228   let DisableEncoding = "$R1src";
3229   let isAsmParserOnly = V.alternate;
3230   let M3 = V.ccmask;
3231 }
3232
3233 multiclass CondBinaryRIEPair<string mnemonic, bits<16> opcode,
3234                              RegisterOperand cls, Immediate imm> {
3235   let isCodeGenOnly = 1 in
3236     def "" : CondBinaryRIE<mnemonic, opcode, cls, imm>;
3237   def Asm : AsmCondBinaryRIE<mnemonic, opcode, cls, imm>;
3238 }
3239
3240 class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3241                 RegisterOperand cls, Immediate imm>
3242   : InstRILa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3243              mnemonic#"\t$R1, $I2",
3244              [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3245   let Constraints = "$R1 = $R1src";
3246   let DisableEncoding = "$R1src";
3247 }
3248
3249 class BinaryRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3250                RegisterOperand cls>
3251   : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
3252             mnemonic#"\t$R1, $BD2",
3253             [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
3254   let R3 = 0;
3255   let Constraints = "$R1 = $R1src";
3256   let DisableEncoding = "$R1src";
3257 }
3258
3259 class BinaryRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3260                 RegisterOperand cls>
3261   : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
3262              mnemonic#"\t$R1, $R3, $BD2",
3263              [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
3264
3265 multiclass BinaryRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3266                         SDPatternOperator operator, RegisterOperand cls> {
3267   let NumOpsKey = mnemonic in {
3268     let NumOpsValue = "3" in
3269       def K  : BinaryRSY<mnemonic##"k", opcode2, null_frag, cls>,
3270                Requires<[FeatureDistinctOps]>;
3271     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
3272       def "" : BinaryRS<mnemonic, opcode1, operator, cls>;
3273   }
3274 }
3275
3276 class BinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3277   : InstRSLb<opcode, (outs cls:$R1),
3278              (ins bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3279              mnemonic#"\t$R1, $BDL2, $M3", []> {
3280   let mayLoad = 1;
3281 }
3282
3283 class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3284                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3285                AddressingMode mode = bdxaddr12only>
3286   : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3287             mnemonic#"\t$R1, $XBD2",
3288             [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3289   let OpKey = mnemonic#"r"#cls;
3290   let OpType = "mem";
3291   let Constraints = "$R1 = $R1src";
3292   let DisableEncoding = "$R1src";
3293   let mayLoad = 1;
3294   let AccessBytes = bytes;
3295 }
3296
3297 class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3298                   RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3299   : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
3300             mnemonic#"\t$R1, $XBD2",
3301             [(set cls:$R1, (operator cls:$R1src,
3302                                      (load bdxaddr12only:$XBD2)))]> {
3303   let OpKey = mnemonic#"r"#cls;
3304   let OpType = "mem";
3305   let Constraints = "$R1 = $R1src";
3306   let DisableEncoding = "$R1src";
3307   let mayLoad = 1;
3308   let AccessBytes = bytes;
3309   let M3 = 0;
3310 }
3311
3312 class BinaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3313                 RegisterOperand cls1, RegisterOperand cls2,
3314                 SDPatternOperator load, bits<5> bytes>
3315   : InstRXF<opcode, (outs cls1:$R1), (ins cls2:$R3, bdxaddr12only:$XBD2),
3316             mnemonic#"\t$R1, $R3, $XBD2",
3317             [(set cls1:$R1, (operator cls2:$R3, (load bdxaddr12only:$XBD2)))]> {
3318   let OpKey = mnemonic#"r"#cls;
3319   let OpType = "mem";
3320   let mayLoad = 1;
3321   let AccessBytes = bytes;
3322 }
3323
3324 class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3325                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3326                 AddressingMode mode = bdxaddr20only>
3327   : InstRXYa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3328              mnemonic#"\t$R1, $XBD2",
3329              [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3330   let OpKey = mnemonic#"r"#cls;
3331   let OpType = "mem";
3332   let Constraints = "$R1 = $R1src";
3333   let DisableEncoding = "$R1src";
3334   let mayLoad = 1;
3335   let AccessBytes = bytes;
3336 }
3337
3338 multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3339                         SDPatternOperator operator, RegisterOperand cls,
3340                         SDPatternOperator load, bits<5> bytes> {
3341   let DispKey = mnemonic ## #cls in {
3342     let DispSize = "12" in
3343       def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
3344                         bdxaddr12pair>;
3345     let DispSize = "20" in
3346       def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
3347                          bdxaddr20pair>;
3348   }
3349 }
3350
3351 class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3352                Operand imm, AddressingMode mode = bdaddr12only>
3353   : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3354            mnemonic#"\t$BD1, $I2",
3355            [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3356   let mayLoad = 1;
3357   let mayStore = 1;
3358 }
3359
3360 class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3361                 Operand imm, AddressingMode mode = bdaddr20only>
3362   : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3363             mnemonic#"\t$BD1, $I2",
3364             [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3365   let mayLoad = 1;
3366   let mayStore = 1;
3367 }
3368
3369 multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
3370                         bits<16> siyOpcode, SDPatternOperator operator,
3371                         Operand imm> {
3372   let DispKey = mnemonic ## #cls in {
3373     let DispSize = "12" in
3374       def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
3375     let DispSize = "20" in
3376       def Y  : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
3377   }
3378 }
3379
3380 class BinarySSF<string mnemonic, bits<12> opcode, RegisterOperand cls>
3381   : InstSSF<opcode, (outs cls:$R3), (ins bdaddr12pair:$BD1, bdaddr12pair:$BD2),
3382             mnemonic#"\t$R3, $BD1, $BD2", []> {
3383   let mayLoad = 1;
3384 }
3385
3386 class BinaryVRIb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3387                  TypedReg tr, bits<4> type>
3388   : InstVRIb<opcode, (outs tr.op:$V1), (ins imm32zx8:$I2, imm32zx8:$I3),
3389              mnemonic#"\t$V1, $I2, $I3",
3390              [(set (tr.vt tr.op:$V1), (operator imm32zx8:$I2, imm32zx8:$I3))]> {
3391   let M4 = type;
3392 }
3393
3394 class BinaryVRIbGeneric<string mnemonic, bits<16> opcode>
3395   : InstVRIb<opcode, (outs VR128:$V1),
3396              (ins imm32zx8:$I2, imm32zx8:$I3, imm32zx4:$M4),
3397              mnemonic#"\t$V1, $I2, $I3, $M4", []>;
3398
3399 class BinaryVRIc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3400                  TypedReg tr1, TypedReg tr2, bits<4> type>
3401   : InstVRIc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, imm32zx16:$I2),
3402              mnemonic#"\t$V1, $V3, $I2",
3403              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
3404                                                   imm32zx16:$I2))]> {
3405   let M4 = type;
3406 }
3407
3408 class BinaryVRIcGeneric<string mnemonic, bits<16> opcode>
3409   : InstVRIc<opcode, (outs VR128:$V1),
3410              (ins VR128:$V3, imm32zx16:$I2, imm32zx4:$M4),
3411              mnemonic#"\t$V1, $V3, $I2, $M4", []>;
3412
3413 class BinaryVRIe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3414                  TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m5>
3415   : InstVRIe<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx12:$I3),
3416              mnemonic#"\t$V1, $V2, $I3",
3417              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3418                                                   imm32zx12:$I3))]> {
3419   let M4 = type;
3420   let M5 = m5;
3421 }
3422
3423 class BinaryVRIeFloatGeneric<string mnemonic, bits<16> opcode>
3424   : InstVRIe<opcode, (outs VR128:$V1),
3425              (ins VR128:$V2, imm32zx12:$I3, imm32zx4:$M4, imm32zx4:$M5),
3426              mnemonic#"\t$V1, $V2, $I3, $M4, $M5", []>;
3427
3428 class BinaryVRIh<string mnemonic, bits<16> opcode>
3429   : InstVRIh<opcode, (outs VR128:$V1),
3430              (ins imm32zx16:$I2, imm32zx4:$I3),
3431              mnemonic#"\t$V1, $I2, $I3", []>;
3432
3433 class BinaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3434                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0>
3435   : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx4:$M5),
3436              mnemonic#"\t$V1, $V2, $M5",
3437              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3438                                                   imm32zx12:$M5))]> {
3439   let M3 = type;
3440   let M4 = m4;
3441 }
3442
3443 class BinaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
3444   : InstVRRa<opcode, (outs VR128:$V1),
3445              (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
3446              mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
3447
3448 class BinaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3449                  TypedReg tr1, TypedReg tr2, bits<4> type = 0,
3450                  bits<4> modifier = 0>
3451   : InstVRRb<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3452              mnemonic#"\t$V1, $V2, $V3",
3453              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3454                                                   (tr2.vt tr2.op:$V3)))]> {
3455   let M4 = type;
3456   let M5 = modifier;
3457 }
3458
3459 // Declare a pair of instructions, one which sets CC and one which doesn't.
3460 // The CC-setting form ends with "S" and sets the low bit of M5.
3461 multiclass BinaryVRRbSPair<string mnemonic, bits<16> opcode,
3462                            SDPatternOperator operator,
3463                            SDPatternOperator operator_cc, TypedReg tr1,
3464                            TypedReg tr2, bits<4> type, bits<4> modifier = 0> {
3465   def "" : BinaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
3466                       !and (modifier, 14)>;
3467   let Defs = [CC] in
3468     def S : BinaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
3469                        !add (!and (modifier, 14), 1)>;
3470 }
3471
3472 class BinaryVRRbSPairGeneric<string mnemonic, bits<16> opcode>
3473   : InstVRRb<opcode, (outs VR128:$V1),
3474              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3475              mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3476   let Defs = [CC];
3477 }
3478
3479 // Declare a pair of instructions, one which sets CC and one which doesn't.
3480 // The CC-setting form ends with "S" and sets the low bit of M5.
3481 // The form that does not set CC has an extra operand to optionally allow
3482 // specifying arbitrary M5 values in assembler.
3483 multiclass BinaryExtraVRRbSPair<string mnemonic, bits<16> opcode,
3484                                 SDPatternOperator operator,
3485                                 SDPatternOperator operator_cc,
3486                                 TypedReg tr1, TypedReg tr2, bits<4> type> {
3487   let M4 = type in
3488     def "" : InstVRRb<opcode, (outs tr1.op:$V1),
3489                       (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M5),
3490                       mnemonic#"\t$V1, $V2, $V3, $M5", []>;
3491   def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3))),
3492             (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, 0)>;
3493   def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
3494                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
3495                                             tr2.op:$V3, 0)>;
3496   let Defs = [CC] in
3497     def S : BinaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type, 1>;
3498 }
3499
3500 multiclass BinaryExtraVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
3501   let Defs = [CC] in
3502     def "" : InstVRRb<opcode, (outs VR128:$V1),
3503                      (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3504                      mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
3505   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
3506                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
3507                                             imm32zx4:$M4, 0)>;
3508 }
3509
3510 class BinaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3511                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m5 = 0,
3512                  bits<4> m6 = 0>
3513   : InstVRRc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3514              mnemonic#"\t$V1, $V2, $V3",
3515              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3516                                                   (tr2.vt tr2.op:$V3)))]> {
3517   let M4 = type;
3518   let M5 = m5;
3519   let M6 = m6;
3520 }
3521
3522 class BinaryVRRcGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0,
3523                         bits<4> m6 = 0>
3524   : InstVRRc<opcode, (outs VR128:$V1),
3525              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4),
3526              mnemonic#"\t$V1, $V2, $V3, $M4", []> {
3527   let M5 = m5;
3528   let M6 = m6;
3529 }
3530
3531 class BinaryVRRcFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m6 = 0>
3532   : InstVRRc<opcode, (outs VR128:$V1),
3533              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3534              mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3535   let M6 = m6;
3536 }
3537
3538 // Declare a pair of instructions, one which sets CC and one which doesn't.
3539 // The CC-setting form ends with "S" and sets the low bit of M5.
3540 multiclass BinaryVRRcSPair<string mnemonic, bits<16> opcode,
3541                            SDPatternOperator operator,
3542                            SDPatternOperator operator_cc, TypedReg tr1,
3543                            TypedReg tr2, bits<4> type, bits<4> m5,
3544                            bits<4> modifier = 0> {
3545   def "" : BinaryVRRc<mnemonic, opcode, operator, tr1, tr2, type,
3546                       m5, !and (modifier, 14)>;
3547   let Defs = [CC] in
3548     def S : BinaryVRRc<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
3549                        m5, !add (!and (modifier, 14), 1)>;
3550 }
3551
3552 class BinaryVRRcSPairFloatGeneric<string mnemonic, bits<16> opcode>
3553   : InstVRRc<opcode, (outs VR128:$V1),
3554              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
3555                   imm32zx4:$M6),
3556              mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
3557
3558 class BinaryVRRf<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3559                  TypedReg tr>
3560   : InstVRRf<opcode, (outs tr.op:$V1), (ins GR64:$R2, GR64:$R3),
3561              mnemonic#"\t$V1, $R2, $R3",
3562              [(set (tr.vt tr.op:$V1), (operator GR64:$R2, GR64:$R3))]>;
3563
3564 class BinaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
3565   : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2, imm32zx4:$M3),
3566              mnemonic#"\t$R1, $V2, $M3", []>;
3567
3568 class BinaryVRSa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3569                  TypedReg tr1, TypedReg tr2, bits<4> type>
3570   : InstVRSa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, shift12only:$BD2),
3571              mnemonic#"\t$V1, $V3, $BD2",
3572              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
3573                                                   shift12only:$BD2))]> {
3574   let M4 = type;
3575 }
3576
3577 class BinaryVRSaGeneric<string mnemonic, bits<16> opcode>
3578   : InstVRSa<opcode, (outs VR128:$V1),
3579              (ins VR128:$V3, shift12only:$BD2, imm32zx4:$M4),
3580              mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
3581
3582 class BinaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3583                  bits<5> bytes>
3584   : InstVRSb<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3585              mnemonic#"\t$V1, $R3, $BD2",
3586              [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3587   let M4 = 0;
3588   let mayLoad = 1;
3589   let AccessBytes = bytes;
3590 }
3591
3592 class BinaryVRSc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3593                  TypedReg tr, bits<4> type>
3594   : InstVRSc<opcode, (outs GR64:$R1), (ins tr.op:$V3, shift12only:$BD2),
3595            mnemonic#"\t$R1, $V3, $BD2",
3596            [(set GR64:$R1, (operator (tr.vt tr.op:$V3), shift12only:$BD2))]> {
3597   let M4 = type;
3598 }
3599
3600 class BinaryVRScGeneric<string mnemonic, bits<16> opcode>
3601   : InstVRSc<opcode, (outs GR64:$R1),
3602              (ins VR128:$V3, shift12only:$BD2, imm32zx4: $M4),
3603              mnemonic#"\t$R1, $V3, $BD2, $M4", []>;
3604
3605 class BinaryVRSd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3606                  bits<5> bytes>
3607   : InstVRSd<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3608              mnemonic#"\t$V1, $R3, $BD2",
3609              [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3610   let mayLoad = 1;
3611   let AccessBytes = bytes;
3612 }
3613
3614 class BinaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3615                 TypedReg tr, bits<5> bytes>
3616   : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
3617             mnemonic#"\t$V1, $XBD2, $M3",
3618             [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2,
3619                                                imm32zx4:$M3))]> {
3620   let mayLoad = 1;
3621   let AccessBytes = bytes;
3622 }
3623
3624 class StoreBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3625                     bits<5> bytes, AddressingMode mode = bdaddr12only>
3626   : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3627             mnemonic#"\t$R1, $M3, $BD2", []> {
3628   let mayStore = 1;
3629   let AccessBytes = bytes;
3630 }
3631
3632 class StoreBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3633                      bits<5> bytes, AddressingMode mode = bdaddr20only>
3634   : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3635              mnemonic#"\t$R1, $M3, $BD2", []> {
3636   let mayStore = 1;
3637   let AccessBytes = bytes;
3638 }
3639
3640 multiclass StoreBinaryRSPair<string mnemonic, bits<8> rsOpcode,
3641                              bits<16> rsyOpcode, RegisterOperand cls,
3642                              bits<5> bytes> {
3643   let DispKey = mnemonic ## #cls in {
3644     let DispSize = "12" in
3645       def "" : StoreBinaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3646     let DispSize = "20" in
3647       def Y  : StoreBinaryRSY<mnemonic#"y", rsyOpcode, cls, bytes,
3648                               bdaddr20pair>;
3649   }
3650 }
3651
3652 class StoreBinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3653   : InstRSLb<opcode, (outs),
3654              (ins cls:$R1, bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3655              mnemonic#"\t$R1, $BDL2, $M3", []> {
3656   let mayStore = 1;
3657 }
3658
3659 class BinaryVSI<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3660                 bits<5> bytes>
3661   : InstVSI<opcode, (outs VR128:$V1), (ins bdaddr12only:$BD2, imm32zx8:$I3),
3662             mnemonic#"\t$V1, $BD2, $I3",
3663             [(set VR128:$V1, (operator imm32zx8:$I3, bdaddr12only:$BD2))]> {
3664   let mayLoad = 1;
3665   let AccessBytes = bytes;
3666 }
3667
3668 class StoreBinaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
3669                      Immediate index>
3670   : InstVRV<opcode, (outs), (ins VR128:$V1, bdvaddr12only:$VBD2, index:$M3),
3671             mnemonic#"\t$V1, $VBD2, $M3", []> {
3672   let mayStore = 1;
3673   let AccessBytes = bytes;
3674 }
3675
3676 class StoreBinaryVRX<string mnemonic, bits<16> opcode,
3677                      SDPatternOperator operator, TypedReg tr, bits<5> bytes,
3678                      Immediate index>
3679   : InstVRX<opcode, (outs), (ins tr.op:$V1, bdxaddr12only:$XBD2, index:$M3),
3680             mnemonic#"\t$V1, $XBD2, $M3",
3681             [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2, index:$M3)]> {
3682   let mayStore = 1;
3683   let AccessBytes = bytes;
3684 }
3685
3686 class MemoryBinarySSd<string mnemonic, bits<8> opcode,
3687                       RegisterOperand cls>
3688   : InstSSd<opcode, (outs),
3689             (ins bdraddr12only:$RBD1, bdaddr12only:$BD2, cls:$R3),
3690             mnemonic#"\t$RBD1, $BD2, $R3", []>;
3691
3692 class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3693                 RegisterOperand cls1, RegisterOperand cls2>
3694   : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3695            mnemonic#"\t$R1, $R2",
3696            [(set CC, (operator cls1:$R1, cls2:$R2))]> {
3697   let OpKey = mnemonic#cls1;
3698   let OpType = "reg";
3699   let isCompare = 1;
3700 }
3701
3702 class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3703                  RegisterOperand cls1, RegisterOperand cls2>
3704   : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3705             mnemonic#"\t$R1, $R2",
3706             [(set CC, (operator cls1:$R1, cls2:$R2))]> {
3707   let OpKey = mnemonic#cls1;
3708   let OpType = "reg";
3709   let isCompare = 1;
3710 }
3711
3712 class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3713                 RegisterOperand cls, Immediate imm>
3714   : InstRIa<opcode, (outs), (ins cls:$R1, imm:$I2),
3715             mnemonic#"\t$R1, $I2",
3716             [(set CC, (operator cls:$R1, imm:$I2))]> {
3717   let isCompare = 1;
3718 }
3719
3720 class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3721                  RegisterOperand cls, Immediate imm>
3722   : InstRILa<opcode, (outs), (ins cls:$R1, imm:$I2),
3723              mnemonic#"\t$R1, $I2",
3724              [(set CC, (operator cls:$R1, imm:$I2))]> {
3725   let isCompare = 1;
3726 }
3727
3728 class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3729                    RegisterOperand cls, SDPatternOperator load>
3730   : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
3731              mnemonic#"\t$R1, $RI2",
3732              [(set CC, (operator cls:$R1, (load pcrel32:$RI2)))]> {
3733   let isCompare = 1;
3734   let mayLoad = 1;
3735   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
3736   // However, BDXs have two extra operands and are therefore 6 units more
3737   // complex.
3738   let AddedComplexity = 7;
3739 }
3740
3741 class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3742                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3743                 AddressingMode mode = bdxaddr12only>
3744   : InstRXa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3745             mnemonic#"\t$R1, $XBD2",
3746             [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
3747   let OpKey = mnemonic#"r"#cls;
3748   let OpType = "mem";
3749   let isCompare = 1;
3750   let mayLoad = 1;
3751   let AccessBytes = bytes;
3752 }
3753
3754 class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3755                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3756   : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3757             mnemonic#"\t$R1, $XBD2",
3758             [(set CC, (operator cls:$R1, (load bdxaddr12only:$XBD2)))]> {
3759   let OpKey = mnemonic#"r"#cls;
3760   let OpType = "mem";
3761   let isCompare = 1;
3762   let mayLoad = 1;
3763   let AccessBytes = bytes;
3764   let M3 = 0;
3765 }
3766
3767 class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3768                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3769                  AddressingMode mode = bdxaddr20only>
3770   : InstRXYa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3771              mnemonic#"\t$R1, $XBD2",
3772              [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
3773   let OpKey = mnemonic#"r"#cls;
3774   let OpType = "mem";
3775   let isCompare = 1;
3776   let mayLoad = 1;
3777   let AccessBytes = bytes;
3778 }
3779
3780 multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3781                          SDPatternOperator operator, RegisterOperand cls,
3782                          SDPatternOperator load, bits<5> bytes> {
3783   let DispKey = mnemonic ## #cls in {
3784     let DispSize = "12" in
3785       def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
3786                          load, bytes, bdxaddr12pair>;
3787     let DispSize = "20" in
3788       def Y  : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
3789                           load, bytes, bdxaddr20pair>;
3790   }
3791 }
3792
3793 class CompareRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3794                 bits<5> bytes, AddressingMode mode = bdaddr12only>
3795   : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3796             mnemonic#"\t$R1, $M3, $BD2", []> {
3797   let mayLoad = 1;
3798   let AccessBytes = bytes;
3799 }
3800
3801 class CompareRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3802                  bits<5> bytes, AddressingMode mode = bdaddr20only>
3803   : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3804              mnemonic#"\t$R1, $M3, $BD2", []> {
3805   let mayLoad = 1;
3806   let AccessBytes = bytes;
3807 }
3808
3809 multiclass CompareRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
3810                          RegisterOperand cls, bits<5> bytes> {
3811   let DispKey = mnemonic ## #cls in {
3812     let DispSize = "12" in
3813       def "" : CompareRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3814     let DispSize = "20" in
3815       def Y  : CompareRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
3816   }
3817 }
3818
3819 class CompareSSb<string mnemonic, bits<8> opcode>
3820   : InstSSb<opcode,
3821             (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
3822             mnemonic##"\t$BDL1, $BDL2", []> {
3823   let isCompare = 1;
3824   let mayLoad = 1;
3825 }
3826
3827 class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3828                 SDPatternOperator load, Immediate imm,
3829                 AddressingMode mode = bdaddr12only>
3830   : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3831            mnemonic#"\t$BD1, $I2",
3832            [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
3833   let isCompare = 1;
3834   let mayLoad = 1;
3835 }
3836
3837 class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3838                  SDPatternOperator load, Immediate imm>
3839   : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3840             mnemonic#"\t$BD1, $I2",
3841             [(set CC, (operator (load bdaddr12only:$BD1), imm:$I2))]> {
3842   let isCompare = 1;
3843   let mayLoad = 1;
3844 }
3845
3846 class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3847                  SDPatternOperator load, Immediate imm,
3848                  AddressingMode mode = bdaddr20only>
3849   : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3850             mnemonic#"\t$BD1, $I2",
3851             [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
3852   let isCompare = 1;
3853   let mayLoad = 1;
3854 }
3855
3856 multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
3857                          SDPatternOperator operator, SDPatternOperator load,
3858                          Immediate imm> {
3859   let DispKey = mnemonic in {
3860     let DispSize = "12" in
3861       def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
3862     let DispSize = "20" in
3863       def Y  : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
3864                           bdaddr20pair>;
3865   }
3866 }
3867
3868 class CompareVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3869                   TypedReg tr, bits<4> type>
3870   : InstVRRa<opcode, (outs), (ins tr.op:$V1, tr.op:$V2),
3871              mnemonic#"\t$V1, $V2",
3872              [(set CC, (operator (tr.vt tr.op:$V1), (tr.vt tr.op:$V2)))]> {
3873   let isCompare = 1;
3874   let M3 = type;
3875   let M4 = 0;
3876   let M5 = 0;
3877 }
3878
3879 class CompareVRRaGeneric<string mnemonic, bits<16> opcode>
3880   : InstVRRa<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
3881              mnemonic#"\t$V1, $V2, $M3", []> {
3882   let isCompare = 1;
3883   let M4 = 0;
3884   let M5 = 0;
3885 }
3886
3887 class CompareVRRaFloatGeneric<string mnemonic, bits<16> opcode>
3888   : InstVRRa<opcode, (outs),
3889              (ins VR64:$V1, VR64:$V2, imm32zx4:$M3, imm32zx4:$M4),
3890              mnemonic#"\t$V1, $V2, $M3, $M4", []> {
3891   let isCompare = 1;
3892   let M5 = 0;
3893 }
3894
3895 class CompareVRRh<string mnemonic, bits<16> opcode>
3896   : InstVRRh<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
3897              mnemonic#"\t$V1, $V2, $M3", []> {
3898   let isCompare = 1;
3899 }
3900
3901 class TestInherentS<string mnemonic, bits<16> opcode,
3902                     SDPatternOperator operator>
3903   : InstS<opcode, (outs), (ins), mnemonic, [(set CC, (operator))]> {
3904   let BD2 = 0;
3905 }
3906
3907 class TestRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3908               RegisterOperand cls>
3909   : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3910             mnemonic#"\t$R1, $XBD2",
3911             [(set CC, (operator cls:$R1, bdxaddr12only:$XBD2))]> {
3912   let M3 = 0;
3913 }
3914
3915 class TestBinarySIL<string mnemonic, bits<16> opcode,
3916                     SDPatternOperator operator, Immediate imm>
3917   : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3918             mnemonic#"\t$BD1, $I2",
3919             [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
3920
3921 class TestRSL<string mnemonic, bits<16> opcode>
3922   : InstRSLa<opcode, (outs), (ins bdladdr12onlylen4:$BDL1),
3923              mnemonic#"\t$BDL1", []> {
3924   let mayLoad = 1;
3925 }
3926
3927 class TestVRRg<string mnemonic, bits<16> opcode>
3928   : InstVRRg<opcode, (outs), (ins VR128:$V1),
3929              mnemonic#"\t$V1", []>;
3930
3931 class SideEffectTernarySSc<string mnemonic, bits<8> opcode>
3932   : InstSSc<opcode, (outs), (ins bdladdr12onlylen4:$BDL1,
3933                                  shift12only:$BD2, imm32zx4:$I3),
3934             mnemonic##"\t$BDL1, $BD2, $I3", []>;
3935
3936 class SideEffectTernaryRRFa<string mnemonic, bits<16> opcode,
3937                             RegisterOperand cls1, RegisterOperand cls2,
3938                             RegisterOperand cls3>
3939   : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
3940              mnemonic#"\t$R1, $R2, $R3", []> {
3941   let M4 = 0;
3942 }
3943
3944 class SideEffectTernaryRRFb<string mnemonic, bits<16> opcode,
3945                             RegisterOperand cls1, RegisterOperand cls2,
3946                             RegisterOperand cls3>
3947   : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
3948              mnemonic#"\t$R1, $R3, $R2", []> {
3949   let M4 = 0;
3950 }
3951
3952 class SideEffectTernaryMemMemMemRRFb<string mnemonic, bits<16> opcode,
3953                                      RegisterOperand cls1,
3954                                      RegisterOperand cls2,
3955                                      RegisterOperand cls3>
3956   : InstRRFb<opcode, (outs cls1:$R1, cls2:$R2, cls3:$R3),
3957              (ins cls1:$R1src, cls2:$R2src, cls3:$R3src),
3958              mnemonic#"\t$R1, $R3, $R2", []> {
3959   let Constraints = "$R1 = $R1src, $R2 = $R2src, $R3 = $R3src";
3960   let DisableEncoding = "$R1src, $R2src, $R3src";
3961   let M4 = 0;
3962 }
3963
3964 class SideEffectTernaryRRFc<string mnemonic, bits<16> opcode,
3965                             RegisterOperand cls1, RegisterOperand cls2,
3966                             Immediate imm>
3967   : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2, imm:$M3),
3968              mnemonic#"\t$R1, $R2, $M3", []>;
3969
3970 multiclass SideEffectTernaryRRFcOpt<string mnemonic, bits<16> opcode,
3971                                     RegisterOperand cls1,
3972                                     RegisterOperand cls2> {
3973   def "" : SideEffectTernaryRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3974   def Opt : SideEffectBinaryRRFc<mnemonic, opcode, cls1, cls2>;
3975 }
3976
3977 class SideEffectTernaryMemMemRRFc<string mnemonic, bits<16> opcode,
3978                                   RegisterOperand cls1, RegisterOperand cls2,
3979                                   Immediate imm>
3980   : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2),
3981              (ins cls1:$R1src, cls2:$R2src, imm:$M3),
3982              mnemonic#"\t$R1, $R2, $M3", []> {
3983   let Constraints = "$R1 = $R1src, $R2 = $R2src";
3984   let DisableEncoding = "$R1src, $R2src";
3985 }
3986
3987 multiclass SideEffectTernaryMemMemRRFcOpt<string mnemonic, bits<16> opcode,
3988                                           RegisterOperand cls1,
3989                                           RegisterOperand cls2> {
3990   def "" : SideEffectTernaryMemMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3991   def Opt : SideEffectBinaryMemMemRRFc<mnemonic, opcode, cls1, cls2>;
3992 }
3993
3994 class SideEffectTernarySSF<string mnemonic, bits<12> opcode,
3995                            RegisterOperand cls>
3996   : InstSSF<opcode, (outs),
3997             (ins bdaddr12only:$BD1, bdaddr12only:$BD2, cls:$R3),
3998             mnemonic#"\t$BD1, $BD2, $R3", []>;
3999
4000 class TernaryRRFa<string mnemonic, bits<16> opcode,
4001                  RegisterOperand cls1, RegisterOperand cls2,
4002                  RegisterOperand cls3>
4003   : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3, imm32zx4:$M4),
4004              mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4005
4006 class TernaryRRFb<string mnemonic, bits<16> opcode,
4007                   RegisterOperand cls1, RegisterOperand cls2,
4008                   RegisterOperand cls3>
4009   : InstRRFb<opcode, (outs cls1:$R1, cls3:$R3),
4010              (ins cls1:$R1src, cls2:$R2, imm32zx4:$M4),
4011              mnemonic#"\t$R1, $R3, $R2, $M4", []> {
4012   let Constraints = "$R1 = $R1src";
4013   let DisableEncoding = "$R1src";
4014 }
4015
4016 class TernaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4017                   RegisterOperand cls2>
4018   : InstRRFe<opcode, (outs cls1:$R1),
4019              (ins imm32zx4:$M3, cls2:$R2, imm32zx4:$M4),
4020              mnemonic#"\t$R1, $M3, $R2, $M4", []>;
4021
4022 class TernaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4023                  RegisterOperand cls1, RegisterOperand cls2>
4024   : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R1src, cls2:$R3, cls2:$R2),
4025             mnemonic#"\t$R1, $R3, $R2",
4026             [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3, cls2:$R2))]> {
4027   let OpKey = mnemonic#cls;
4028   let OpType = "reg";
4029   let Constraints = "$R1 = $R1src";
4030   let DisableEncoding = "$R1src";
4031 }
4032
4033 class TernaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
4034                 bits<5> bytes, AddressingMode mode = bdaddr12only>
4035   : InstRSb<opcode, (outs cls:$R1),
4036             (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4037             mnemonic#"\t$R1, $M3, $BD2", []> {
4038
4039   let Constraints = "$R1 = $R1src";
4040   let DisableEncoding = "$R1src";
4041   let mayLoad = 1;
4042   let AccessBytes = bytes;
4043 }
4044
4045 class TernaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
4046                 bits<5> bytes, AddressingMode mode = bdaddr20only>
4047   : InstRSYb<opcode, (outs cls:$R1),
4048              (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4049              mnemonic#"\t$R1, $M3, $BD2", []> {
4050
4051   let Constraints = "$R1 = $R1src";
4052   let DisableEncoding = "$R1src";
4053   let mayLoad = 1;
4054   let AccessBytes = bytes;
4055 }
4056
4057 multiclass TernaryRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4058                          RegisterOperand cls, bits<5> bytes> {
4059   let DispKey = mnemonic ## #cls in {
4060     let DispSize = "12" in
4061       def "" : TernaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
4062     let DispSize = "20" in
4063       def Y  : TernaryRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
4064   }
4065 }
4066
4067 class SideEffectTernaryRS<string mnemonic, bits<8> opcode,
4068                           RegisterOperand cls1, RegisterOperand cls2>
4069   : InstRSa<opcode, (outs),
4070             (ins cls1:$R1, cls2:$R3, bdaddr12only:$BD2),
4071             mnemonic#"\t$R1, $R3, $BD2", []>;
4072
4073 class SideEffectTernaryRSY<string mnemonic, bits<16> opcode,
4074                            RegisterOperand cls1, RegisterOperand cls2>
4075   : InstRSYa<opcode, (outs),
4076              (ins cls1:$R1, cls2:$R3, bdaddr20only:$BD2),
4077              mnemonic#"\t$R1, $R3, $BD2", []>;
4078
4079 class SideEffectTernaryMemMemRS<string mnemonic, bits<8> opcode,
4080                                 RegisterOperand cls1, RegisterOperand cls2>
4081   : InstRSa<opcode, (outs cls1:$R1, cls2:$R3),
4082             (ins cls1:$R1src, cls2:$R3src, shift12only:$BD2),
4083             mnemonic#"\t$R1, $R3, $BD2", []> {
4084     let Constraints = "$R1 = $R1src, $R3 = $R3src";
4085     let DisableEncoding = "$R1src, $R3src";
4086 }
4087
4088 class SideEffectTernaryMemMemRSY<string mnemonic, bits<16> opcode,
4089                                  RegisterOperand cls1, RegisterOperand cls2>
4090   : InstRSYa<opcode, (outs cls1:$R1, cls2:$R3),
4091              (ins cls1:$R1src, cls2:$R3src, shift20only:$BD2),
4092              mnemonic#"\t$R1, $R3, $BD2", []> {
4093     let Constraints = "$R1 = $R1src, $R3 = $R3src";
4094     let DisableEncoding = "$R1src, $R3src";
4095 }
4096
4097 class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4098                  RegisterOperand cls1, RegisterOperand cls2,
4099                  SDPatternOperator load, bits<5> bytes>
4100   : InstRXF<opcode, (outs cls1:$R1),
4101             (ins cls2:$R1src, cls2:$R3, bdxaddr12only:$XBD2),
4102             mnemonic#"\t$R1, $R3, $XBD2",
4103             [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3,
4104                                       (load bdxaddr12only:$XBD2)))]> {
4105   let OpKey = mnemonic#"r"#cls;
4106   let OpType = "mem";
4107   let Constraints = "$R1 = $R1src";
4108   let DisableEncoding = "$R1src";
4109   let mayLoad = 1;
4110   let AccessBytes = bytes;
4111 }
4112
4113 class TernaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4114                   TypedReg tr1, TypedReg tr2, Immediate imm, Immediate index>
4115   : InstVRIa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V1src, imm:$I2, index:$M3),
4116              mnemonic#"\t$V1, $I2, $M3",
4117              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4118                                                   imm:$I2, index:$M3))]> {
4119   let Constraints = "$V1 = $V1src";
4120   let DisableEncoding = "$V1src";
4121 }
4122
4123 class TernaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4124                   TypedReg tr1, TypedReg tr2, bits<4> type>
4125   : InstVRId<opcode, (outs tr1.op:$V1),
4126              (ins tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4127              mnemonic#"\t$V1, $V2, $V3, $I4",
4128              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4129                                                   (tr2.vt tr2.op:$V3),
4130                                                   imm32zx8:$I4))]> {
4131   let M5 = type;
4132 }
4133
4134 class TernaryVRIi<string mnemonic, bits<16> opcode, RegisterOperand cls>
4135   : InstVRIi<opcode, (outs VR128:$V1),
4136              (ins cls:$R2, imm32zx8:$I3, imm32zx4:$M4),
4137              mnemonic#"\t$V1, $R2, $I3, $M4", []>;
4138
4139 class TernaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4140                   TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m4or>
4141   : InstVRRa<opcode, (outs tr1.op:$V1),
4142              (ins tr2.op:$V2, imm32zx4:$M4, imm32zx4:$M5),
4143              mnemonic#"\t$V1, $V2, $M4, $M5",
4144              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4145                                                   imm32zx4:$M4,
4146                                                   imm32zx4:$M5))],
4147              m4or> {
4148   let M3 = type;
4149 }
4150
4151 class TernaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
4152   : InstVRRa<opcode, (outs VR128:$V1),
4153              (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
4154              mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
4155
4156 class TernaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4157                   TypedReg tr1, TypedReg tr2, bits<4> type,
4158                   SDPatternOperator m5mask, bits<4> m5or>
4159   : InstVRRb<opcode, (outs tr1.op:$V1),
4160              (ins tr2.op:$V2, tr2.op:$V3, m5mask:$M5),
4161              mnemonic#"\t$V1, $V2, $V3, $M5",
4162              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4163                                                   (tr2.vt tr2.op:$V3),
4164                                                   m5mask:$M5))],
4165              m5or> {
4166   let M4 = type;
4167 }
4168
4169 // Declare a pair of instructions, one which sets CC and one which doesn't.
4170 // The CC-setting form ends with "S" and sets the low bit of M5.
4171 // Also create aliases to make use of M5 operand optional in assembler.
4172 multiclass TernaryOptVRRbSPair<string mnemonic, bits<16> opcode,
4173                                SDPatternOperator operator,
4174                                SDPatternOperator operator_cc,
4175                                TypedReg tr1, TypedReg tr2, bits<4> type,
4176                                bits<4> modifier = 0> {
4177   def "" : TernaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
4178                        imm32zx4even, !and (modifier, 14)>;
4179   def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
4180                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4181                                             tr2.op:$V3, 0)>;
4182   let Defs = [CC] in
4183     def S : TernaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
4184                         imm32zx4even, !add(!and (modifier, 14), 1)>;
4185   def : InstAlias<mnemonic#"s\t$V1, $V2, $V3",
4186                   (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4187                                                 tr2.op:$V3, 0)>;
4188 }
4189
4190 multiclass TernaryOptVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
4191   let Defs = [CC] in
4192     def "" : InstVRRb<opcode, (outs VR128:$V1),
4193                      (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
4194                      mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
4195   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
4196                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4197                                             imm32zx4:$M4, 0)>;
4198 }
4199
4200 class TernaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4201                   TypedReg tr1, TypedReg tr2>
4202   : InstVRRc<opcode, (outs tr1.op:$V1),
4203              (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M4),
4204              mnemonic#"\t$V1, $V2, $V3, $M4",
4205              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4206                                                   (tr2.vt tr2.op:$V3),
4207                                                   imm32zx4:$M4))]> {
4208   let M5 = 0;
4209   let M6 = 0;
4210 }
4211
4212 class TernaryVRRcFloat<string mnemonic, bits<16> opcode,
4213                        SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4214                        bits<4> type = 0, bits<4> m5 = 0>
4215   : InstVRRc<opcode, (outs tr1.op:$V1),
4216              (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M6),
4217              mnemonic#"\t$V1, $V2, $V3, $M6",
4218              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4219                                                   (tr2.vt tr2.op:$V3),
4220                                                   imm32zx4:$M6))]> {
4221   let M4 = type;
4222   let M5 = m5;
4223 }
4224
4225 class TernaryVRRcFloatGeneric<string mnemonic, bits<16> opcode>
4226   : InstVRRc<opcode, (outs VR128:$V1),
4227              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
4228                   imm32zx4:$M6),
4229              mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
4230
4231 class TernaryVRRd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4232                   TypedReg tr1, TypedReg tr2, bits<4> type = 0>
4233   : InstVRRd<opcode, (outs tr1.op:$V1),
4234              (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4235              mnemonic#"\t$V1, $V2, $V3, $V4",
4236              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4237                                                   (tr2.vt tr2.op:$V3),
4238                                                   (tr1.vt tr1.op:$V4)))]> {
4239   let M5 = type;
4240   let M6 = 0;
4241 }
4242
4243 class TernaryVRRdGeneric<string mnemonic, bits<16> opcode>
4244   : InstVRRd<opcode, (outs VR128:$V1),
4245              (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5),
4246              mnemonic#"\t$V1, $V2, $V3, $V4, $M5", []> {
4247   let M6 = 0;
4248 }
4249
4250 class TernaryVRRe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4251                   TypedReg tr1, TypedReg tr2, bits<4> m5 = 0, bits<4> type = 0>
4252   : InstVRRe<opcode, (outs tr1.op:$V1),
4253              (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4254              mnemonic#"\t$V1, $V2, $V3, $V4",
4255              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4256                                                   (tr2.vt tr2.op:$V3),
4257                                                   (tr1.vt tr1.op:$V4)))]> {
4258   let M5 = m5;
4259   let M6 = type;
4260 }
4261
4262 class TernaryVRReFloatGeneric<string mnemonic, bits<16> opcode>
4263   : InstVRRe<opcode, (outs VR128:$V1),
4264              (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4265              mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4266
4267 class TernaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4268                   TypedReg tr1, TypedReg tr2, RegisterOperand cls, bits<4> type>
4269   : InstVRSb<opcode, (outs tr1.op:$V1),
4270              (ins tr2.op:$V1src, cls:$R3, shift12only:$BD2),
4271              mnemonic#"\t$V1, $R3, $BD2",
4272              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4273                                                   cls:$R3,
4274                                                   shift12only:$BD2))]> {
4275   let Constraints = "$V1 = $V1src";
4276   let DisableEncoding = "$V1src";
4277   let M4 = type;
4278 }
4279
4280 class TernaryVRSbGeneric<string mnemonic, bits<16> opcode>
4281   : InstVRSb<opcode, (outs VR128:$V1),
4282              (ins VR128:$V1src, GR64:$R3, shift12only:$BD2, imm32zx4:$M4),
4283              mnemonic#"\t$V1, $R3, $BD2, $M4", []> {
4284   let Constraints = "$V1 = $V1src";
4285   let DisableEncoding = "$V1src";
4286 }
4287
4288 class TernaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
4289                  Immediate index>
4290   : InstVRV<opcode, (outs VR128:$V1),
4291            (ins VR128:$V1src, bdvaddr12only:$VBD2, index:$M3),
4292            mnemonic#"\t$V1, $VBD2, $M3", []> {
4293   let Constraints = "$V1 = $V1src";
4294   let DisableEncoding = "$V1src";
4295   let mayLoad = 1;
4296   let AccessBytes = bytes;
4297 }
4298
4299 class TernaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4300                  TypedReg tr1, TypedReg tr2, bits<5> bytes, Immediate index>
4301   : InstVRX<opcode, (outs tr1.op:$V1),
4302            (ins tr2.op:$V1src, bdxaddr12only:$XBD2, index:$M3),
4303            mnemonic#"\t$V1, $XBD2, $M3",
4304            [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4305                                                 bdxaddr12only:$XBD2,
4306                                                 index:$M3))]> {
4307   let Constraints = "$V1 = $V1src";
4308   let DisableEncoding = "$V1src";
4309   let mayLoad = 1;
4310   let AccessBytes = bytes;
4311 }
4312
4313 class QuaternaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4314                      TypedReg tr1, TypedReg tr2, bits<4> type>
4315   : InstVRId<opcode, (outs tr1.op:$V1),
4316              (ins tr2.op:$V1src, tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4317              mnemonic#"\t$V1, $V2, $V3, $I4",
4318              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4319                                                   (tr2.vt tr2.op:$V2),
4320                                                   (tr2.vt tr2.op:$V3),
4321                                                   imm32zx8:$I4))]> {
4322   let Constraints = "$V1 = $V1src";
4323   let DisableEncoding = "$V1src";
4324   let M5 = type;
4325 }
4326
4327 class QuaternaryVRIdGeneric<string mnemonic, bits<16> opcode>
4328   : InstVRId<opcode, (outs VR128:$V1),
4329              (ins VR128:$V1src, VR128:$V2, VR128:$V3,
4330                   imm32zx8:$I4, imm32zx4:$M5),
4331              mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []> {
4332   let Constraints = "$V1 = $V1src";
4333   let DisableEncoding = "$V1src";
4334 }
4335
4336 class QuaternaryVRIf<string mnemonic, bits<16> opcode>
4337   : InstVRIf<opcode, (outs VR128:$V1),
4338              (ins VR128:$V2, VR128:$V3,
4339                   imm32zx8:$I4, imm32zx4:$M5),
4340              mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []>;
4341
4342 class QuaternaryVRIg<string mnemonic, bits<16> opcode>
4343   : InstVRIg<opcode, (outs VR128:$V1),
4344              (ins VR128:$V2, imm32zx8:$I3,
4345                   imm32zx8:$I4, imm32zx4:$M5),
4346              mnemonic#"\t$V1, $V2, $I3, $I4, $M5", []>;
4347
4348 class QuaternaryVRRd<string mnemonic, bits<16> opcode,
4349                      SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4350                      TypedReg tr3, TypedReg tr4, bits<4> type,
4351                      SDPatternOperator m6mask = imm32zx4, bits<4> m6or = 0>
4352   : InstVRRd<opcode, (outs tr1.op:$V1),
4353              (ins tr2.op:$V2, tr3.op:$V3, tr4.op:$V4, m6mask:$M6),
4354              mnemonic#"\t$V1, $V2, $V3, $V4, $M6",
4355              [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4356                                                   (tr3.vt tr3.op:$V3),
4357                                                   (tr4.vt tr4.op:$V4),
4358                                                   m6mask:$M6))],
4359              m6or> {
4360   let M5 = type;
4361 }
4362
4363 class QuaternaryVRRdGeneric<string mnemonic, bits<16> opcode>
4364   : InstVRRd<opcode, (outs VR128:$V1),
4365              (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4366              mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4367
4368 // Declare a pair of instructions, one which sets CC and one which doesn't.
4369 // The CC-setting form ends with "S" and sets the low bit of M6.
4370 // Also create aliases to make use of M6 operand optional in assembler.
4371 multiclass QuaternaryOptVRRdSPair<string mnemonic, bits<16> opcode,
4372                                   SDPatternOperator operator,
4373                                 SDPatternOperator operator_cc,
4374                                 TypedReg tr1, TypedReg tr2, bits<4> type,
4375                                 bits<4> modifier = 0> {
4376   def "" : QuaternaryVRRd<mnemonic, opcode, operator,
4377                           tr1, tr2, tr2, tr2, type,
4378                           imm32zx4even, !and (modifier, 14)>;
4379   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
4380                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4381                                             tr2.op:$V3, tr2.op:$V4, 0)>;
4382   let Defs = [CC] in
4383     def S : QuaternaryVRRd<mnemonic##"s", opcode, operator_cc,
4384                            tr1, tr2, tr2, tr2, type,
4385                            imm32zx4even, !add (!and (modifier, 14), 1)>;
4386   def : InstAlias<mnemonic#"s\t$V1, $V2, $V3, $V4",
4387                   (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4388                                                 tr2.op:$V3, tr2.op:$V4, 0)>;
4389 }
4390
4391 multiclass QuaternaryOptVRRdSPairGeneric<string mnemonic, bits<16> opcode> {
4392   let Defs = [CC] in
4393     def "" : QuaternaryVRRdGeneric<mnemonic, opcode>;
4394   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
4395                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4396                                             VR128:$V4, imm32zx4:$M5, 0)>;
4397 }
4398
4399 class SideEffectQuaternaryRRFa<string mnemonic, bits<16> opcode,
4400                                RegisterOperand cls1, RegisterOperand cls2,
4401                                RegisterOperand cls3>
4402   : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4403              mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4404
4405 multiclass SideEffectQuaternaryRRFaOptOpt<string mnemonic, bits<16> opcode,
4406                                           RegisterOperand cls1,
4407                                           RegisterOperand cls2,
4408                                           RegisterOperand cls3> {
4409   def "" : SideEffectQuaternaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4410   def Opt : SideEffectTernaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4411   def OptOpt : SideEffectBinaryRRFa<mnemonic, opcode, cls1, cls2>;
4412 }
4413
4414 class SideEffectQuaternaryRRFb<string mnemonic, bits<16> opcode,
4415                                RegisterOperand cls1, RegisterOperand cls2,
4416                                RegisterOperand cls3>
4417   : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4418              mnemonic#"\t$R1, $R3, $R2, $M4", []>;
4419
4420 multiclass SideEffectQuaternaryRRFbOpt<string mnemonic, bits<16> opcode,
4421                                        RegisterOperand cls1,
4422                                        RegisterOperand cls2,
4423                                        RegisterOperand cls3> {
4424   def "" : SideEffectQuaternaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4425   def Opt : SideEffectTernaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4426 }
4427
4428 class SideEffectQuaternarySSe<string mnemonic, bits<8> opcode,
4429                               RegisterOperand cls>
4430   : InstSSe<opcode, (outs),
4431             (ins cls:$R1, bdaddr12only:$BD2, cls:$R3, bdaddr12only:$BD4),
4432             mnemonic#"\t$R1, $BD2, $R3, $BD4", []>;
4433
4434 class LoadAndOpRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4435                   RegisterOperand cls, AddressingMode mode = bdaddr20only>
4436   : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
4437              mnemonic#"\t$R1, $R3, $BD2",
4438              [(set cls:$R1, (operator mode:$BD2, cls:$R3))]> {
4439   let mayLoad = 1;
4440   let mayStore = 1;
4441 }
4442
4443 class CmpSwapRRE<string mnemonic, bits<16> opcode,
4444                  RegisterOperand cls1, RegisterOperand cls2>
4445   : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
4446             mnemonic#"\t$R1, $R2", []> {
4447   let Constraints = "$R1 = $R1src";
4448   let DisableEncoding = "$R1src";
4449   let mayLoad = 1;
4450   let mayStore = 1;
4451 }
4452
4453 class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
4454                 RegisterOperand cls, AddressingMode mode = bdaddr12only>
4455   : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4456             mnemonic#"\t$R1, $R3, $BD2",
4457             [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4458   let Constraints = "$R1 = $R1src";
4459   let DisableEncoding = "$R1src";
4460   let mayLoad = 1;
4461   let mayStore = 1;
4462 }
4463
4464 class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4465                  RegisterOperand cls, AddressingMode mode = bdaddr20only>
4466   : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4467              mnemonic#"\t$R1, $R3, $BD2",
4468              [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4469   let Constraints = "$R1 = $R1src";
4470   let DisableEncoding = "$R1src";
4471   let mayLoad = 1;
4472   let mayStore = 1;
4473 }
4474
4475 multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4476                          SDPatternOperator operator, RegisterOperand cls> {
4477   let DispKey = mnemonic ## #cls in {
4478     let DispSize = "12" in
4479       def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
4480     let DispSize = "20" in
4481       def Y  : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
4482   }
4483 }
4484
4485 class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4486                        RegisterOperand cls2>
4487   : InstRIEf<opcode, (outs cls1:$R1),
4488              (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4489                   imm32zx6:$I5),
4490              mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
4491   let Constraints = "$R1 = $R1src";
4492   let DisableEncoding = "$R1src";
4493 }
4494
4495 class PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator>
4496   : InstRXYb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr20only:$XBD2),
4497              mnemonic##"\t$M1, $XBD2",
4498              [(operator imm32zx4:$M1, bdxaddr20only:$XBD2)]>;
4499
4500 class PrefetchRILPC<string mnemonic, bits<12> opcode,
4501                     SDPatternOperator operator>
4502   : InstRILc<opcode, (outs), (ins imm32zx4:$M1, pcrel32:$RI2),
4503              mnemonic##"\t$M1, $RI2",
4504              [(operator imm32zx4:$M1, pcrel32:$RI2)]> {
4505   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
4506   // However, BDXs have two extra operands and are therefore 6 units more
4507   // complex.
4508   let AddedComplexity = 7;
4509 }
4510
4511 class BranchPreloadSMI<string mnemonic, bits<8> opcode>
4512   : InstSMI<opcode, (outs),
4513             (ins imm32zx4:$M1, brtarget16bpp:$RI2, bdxaddr12only:$BD3),
4514             mnemonic#"\t$M1, $RI2, $BD3", []>;
4515
4516 class BranchPreloadMII<string mnemonic, bits<8> opcode>
4517   : InstMII<opcode, (outs),
4518             (ins imm32zx4:$M1, brtarget12bpp:$RI2, brtarget24bpp:$RI3),
4519             mnemonic#"\t$M1, $RI2, $RI3", []>;
4520
4521 // A floating-point load-and test operation.  Create both a normal unary
4522 // operation and one that acts as a comparison against zero.
4523 // Note that the comparison against zero operation is not available if we
4524 // have vector support, since load-and-test instructions will partially
4525 // clobber the target (vector) register.
4526 multiclass LoadAndTestRRE<string mnemonic, bits<16> opcode,
4527                           RegisterOperand cls> {
4528   def "" : UnaryRRE<mnemonic, opcode, null_frag, cls, cls>;
4529   let isCodeGenOnly = 1, Predicates = [FeatureNoVector] in
4530     def Compare : CompareRRE<mnemonic, opcode, null_frag, cls, cls>;
4531 }
4532
4533 //===----------------------------------------------------------------------===//
4534 // Pseudo instructions
4535 //===----------------------------------------------------------------------===//
4536 //
4537 // Convenience instructions that get lowered to real instructions
4538 // by either SystemZTargetLowering::EmitInstrWithCustomInserter()
4539 // or SystemZInstrInfo::expandPostRAPseudo().
4540 //
4541 //===----------------------------------------------------------------------===//
4542
4543 class Pseudo<dag outs, dag ins, list<dag> pattern>
4544   : InstSystemZ<0, outs, ins, "", pattern> {
4545   let isPseudo = 1;
4546   let isCodeGenOnly = 1;
4547 }
4548
4549 // Like UnaryRI, but expanded after RA depending on the choice of register.
4550 class UnaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4551                     Immediate imm>
4552   : Pseudo<(outs cls:$R1), (ins imm:$I2),
4553            [(set cls:$R1, (operator imm:$I2))]>;
4554
4555 // Like UnaryRXY, but expanded after RA depending on the choice of register.
4556 class UnaryRXYPseudo<string key, SDPatternOperator operator,
4557                      RegisterOperand cls, bits<5> bytes,
4558                      AddressingMode mode = bdxaddr20only>
4559   : Pseudo<(outs cls:$R1), (ins mode:$XBD2),
4560            [(set cls:$R1, (operator mode:$XBD2))]> {
4561   let OpKey = key#"r"#cls;
4562   let OpType = "mem";
4563   let mayLoad = 1;
4564   let Has20BitOffset = 1;
4565   let HasIndex = 1;
4566   let AccessBytes = bytes;
4567 }
4568
4569 // Like UnaryRR, but expanded after RA depending on the choice of registers.
4570 class UnaryRRPseudo<string key, SDPatternOperator operator,
4571                     RegisterOperand cls1, RegisterOperand cls2>
4572   : Pseudo<(outs cls1:$R1), (ins cls2:$R2),
4573            [(set cls1:$R1, (operator cls2:$R2))]> {
4574   let OpKey = key#cls1;
4575   let OpType = "reg";
4576 }
4577
4578 // Like BinaryRI, but expanded after RA depending on the choice of register.
4579 class BinaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4580                      Immediate imm>
4581   : Pseudo<(outs cls:$R1), (ins cls:$R1src, imm:$I2),
4582            [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4583   let Constraints = "$R1 = $R1src";
4584 }
4585
4586 // Like BinaryRIE, but expanded after RA depending on the choice of register.
4587 class BinaryRIEPseudo<SDPatternOperator operator, RegisterOperand cls,
4588                       Immediate imm>
4589   : Pseudo<(outs cls:$R1), (ins cls:$R3, imm:$I2),
4590            [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
4591
4592 // Like BinaryRIAndK, but expanded after RA depending on the choice of register.
4593 multiclass BinaryRIAndKPseudo<string key, SDPatternOperator operator,
4594                               RegisterOperand cls, Immediate imm> {
4595   let NumOpsKey = key in {
4596     let NumOpsValue = "3" in
4597       def K : BinaryRIEPseudo<null_frag, cls, imm>,
4598               Requires<[FeatureHighWord, FeatureDistinctOps]>;
4599     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
4600       def "" : BinaryRIPseudo<operator, cls, imm>,
4601                Requires<[FeatureHighWord]>;
4602   }
4603 }
4604
4605 // Like CompareRI, but expanded after RA depending on the choice of register.
4606 class CompareRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4607                       Immediate imm>
4608   : Pseudo<(outs), (ins cls:$R1, imm:$I2),
4609            [(set CC, (operator cls:$R1, imm:$I2))]> {
4610   let isCompare = 1;
4611 }
4612
4613 // Like CompareRXY, but expanded after RA depending on the choice of register.
4614 class CompareRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4615                        SDPatternOperator load, bits<5> bytes,
4616                        AddressingMode mode = bdxaddr20only>
4617   : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4618            [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
4619   let mayLoad = 1;
4620   let Has20BitOffset = 1;
4621   let HasIndex = 1;
4622   let AccessBytes = bytes;
4623 }
4624
4625 // Like TestBinarySIL, but expanded later.
4626 class TestBinarySILPseudo<SDPatternOperator operator, Immediate imm>
4627   : Pseudo<(outs), (ins bdaddr12only:$BD1, imm:$I2),
4628            [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
4629
4630 // Like CondBinaryRRF, but expanded after RA depending on the choice of
4631 // register.
4632 class CondBinaryRRFPseudo<RegisterOperand cls1, RegisterOperand cls2>
4633   : Pseudo<(outs cls1:$R1),
4634            (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
4635            [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
4636                                             cond4:$valid, cond4:$M3))]> {
4637   let Constraints = "$R1 = $R1src";
4638   let DisableEncoding = "$R1src";
4639   let CCMaskLast = 1;
4640 }
4641
4642 // Like CondBinaryRIE, but expanded after RA depending on the choice of
4643 // register.
4644 class CondBinaryRIEPseudo<RegisterOperand cls, Immediate imm>
4645   : Pseudo<(outs cls:$R1),
4646            (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
4647            [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
4648                                            cond4:$valid, cond4:$M3))]> {
4649   let Constraints = "$R1 = $R1src";
4650   let DisableEncoding = "$R1src";
4651   let CCMaskLast = 1;
4652 }
4653
4654 // Like CondUnaryRSY, but expanded after RA depending on the choice of
4655 // register.
4656 class CondUnaryRSYPseudo<SDPatternOperator operator, RegisterOperand cls,
4657                          bits<5> bytes, AddressingMode mode = bdaddr20only>
4658   : Pseudo<(outs cls:$R1),
4659            (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
4660            [(set cls:$R1,
4661                  (z_select_ccmask (operator mode:$BD2), cls:$R1src,
4662                                   cond4:$valid, cond4:$R3))]> {
4663   let Constraints = "$R1 = $R1src";
4664   let DisableEncoding = "$R1src";
4665   let mayLoad = 1;
4666   let AccessBytes = bytes;
4667   let CCMaskLast = 1;
4668 }
4669
4670 // Like CondStoreRSY, but expanded after RA depending on the choice of
4671 // register.
4672 class CondStoreRSYPseudo<RegisterOperand cls, bits<5> bytes,
4673                          AddressingMode mode = bdaddr20only>
4674   : Pseudo<(outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3), []> {
4675   let mayStore = 1;
4676   let AccessBytes = bytes;
4677   let CCMaskLast = 1;
4678 }
4679
4680 // Like StoreRXY, but expanded after RA depending on the choice of register.
4681 class StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4682                      bits<5> bytes, AddressingMode mode = bdxaddr20only>
4683   : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4684            [(operator cls:$R1, mode:$XBD2)]> {
4685   let mayStore = 1;
4686   let Has20BitOffset = 1;
4687   let HasIndex = 1;
4688   let AccessBytes = bytes;
4689 }
4690
4691 // Like RotateSelectRIEf, but expanded after RA depending on the choice
4692 // of registers.
4693 class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>
4694   : Pseudo<(outs cls1:$R1),
4695            (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4696                 imm32zx6:$I5),
4697            []> {
4698   let Constraints = "$R1 = $R1src";
4699   let DisableEncoding = "$R1src";
4700 }
4701
4702 // Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
4703 // the value of the PSW's 2-bit condition code field.
4704 class SelectWrapper<ValueType vt, RegisterOperand cls>
4705   : Pseudo<(outs cls:$dst),
4706            (ins cls:$src1, cls:$src2, imm32zx4:$valid, imm32zx4:$cc),
4707            [(set (vt cls:$dst), (z_select_ccmask cls:$src1, cls:$src2,
4708                                             imm32zx4:$valid, imm32zx4:$cc))]> {
4709   let usesCustomInserter = 1;
4710   let hasNoSchedulingInfo = 1;
4711   let Uses = [CC];
4712 }
4713
4714 // Stores $new to $addr if $cc is true ("" case) or false (Inv case).
4715 multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
4716                       SDPatternOperator load, AddressingMode mode> {
4717   let Uses = [CC], usesCustomInserter = 1, hasNoSchedulingInfo = 1,
4718       mayLoad = 1, mayStore = 1 in {
4719     def "" : Pseudo<(outs),
4720                     (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4721                     [(store (z_select_ccmask cls:$new, (load mode:$addr),
4722                                              imm32zx4:$valid, imm32zx4:$cc),
4723                             mode:$addr)]>;
4724     def Inv : Pseudo<(outs),
4725                      (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4726                      [(store (z_select_ccmask (load mode:$addr), cls:$new,
4727                                               imm32zx4:$valid, imm32zx4:$cc),
4728                               mode:$addr)]>;
4729   }
4730 }
4731
4732 // OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation.  PAT and OPERAND
4733 // describe the second (non-memory) operand.
4734 class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
4735                        dag pat, DAGOperand operand>
4736   : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
4737            [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
4738   let Defs = [CC];
4739   let Has20BitOffset = 1;
4740   let mayLoad = 1;
4741   let mayStore = 1;
4742   let usesCustomInserter = 1;
4743   let hasNoSchedulingInfo = 1;
4744 }
4745
4746 // Specializations of AtomicLoadWBinary.
4747 class AtomicLoadBinaryReg32<SDPatternOperator operator>
4748   : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
4749 class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
4750   : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
4751 class AtomicLoadBinaryReg64<SDPatternOperator operator>
4752   : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
4753 class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
4754   : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
4755
4756 // OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation.  PAT and OPERAND
4757 // describe the second (non-memory) operand.
4758 class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
4759                         DAGOperand operand>
4760   : Pseudo<(outs GR32:$dst),
4761            (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
4762                 ADDR32:$negbitshift, uimm32:$bitsize),
4763            [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
4764                                       ADDR32:$negbitshift, uimm32:$bitsize))]> {
4765   let Defs = [CC];
4766   let Has20BitOffset = 1;
4767   let mayLoad = 1;
4768   let mayStore = 1;
4769   let usesCustomInserter = 1;
4770   let hasNoSchedulingInfo = 1;
4771 }
4772
4773 // Specializations of AtomicLoadWBinary.
4774 class AtomicLoadWBinaryReg<SDPatternOperator operator>
4775   : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
4776 class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
4777   : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;
4778
4779 // Define an instruction that operates on two fixed-length blocks of memory,
4780 // and associated pseudo instructions for operating on blocks of any size.
4781 // The Sequence form uses a straight-line sequence of instructions and
4782 // the Loop form uses a loop of length-256 instructions followed by
4783 // another instruction to handle the excess.
4784 multiclass MemorySS<string mnemonic, bits<8> opcode,
4785                     SDPatternOperator sequence, SDPatternOperator loop> {
4786   def "" : SideEffectBinarySSa<mnemonic, opcode>;
4787   let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CC] in {
4788     def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
4789                                        imm64:$length),
4790                            [(sequence bdaddr12only:$dest, bdaddr12only:$src,
4791                                       imm64:$length)]>;
4792     def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
4793                                    imm64:$length, GR64:$count256),
4794                       [(loop bdaddr12only:$dest, bdaddr12only:$src,
4795                              imm64:$length, GR64:$count256)]>;
4796   }
4797 }
4798
4799 // The same, but setting a CC result as comparion operator.
4800 multiclass CompareMemorySS<string mnemonic, bits<8> opcode,
4801                           SDPatternOperator sequence, SDPatternOperator loop> {
4802   def "" : SideEffectBinarySSa<mnemonic, opcode>;
4803   let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
4804     def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
4805                                        imm64:$length),
4806                            [(set CC, (sequence bdaddr12only:$dest, bdaddr12only:$src,
4807                                                imm64:$length))]>;
4808     def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
4809                                    imm64:$length, GR64:$count256),
4810                       [(set CC, (loop bdaddr12only:$dest, bdaddr12only:$src,
4811                                       imm64:$length, GR64:$count256))]>;
4812   }
4813 }
4814
4815 // Define an instruction that operates on two strings, both terminated
4816 // by the character in R0.  The instruction processes a CPU-determinated
4817 // number of bytes at a time and sets CC to 3 if the instruction needs
4818 // to be repeated.  Also define a pseudo instruction that represents
4819 // the full loop (the main instruction plus the branch on CC==3).
4820 multiclass StringRRE<string mnemonic, bits<16> opcode,
4821                      SDPatternOperator operator> {
4822   let Uses = [R0L] in
4823     def "" : SideEffectBinaryMemMemRRE<mnemonic, opcode, GR64, GR64>;
4824   let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
4825     def Loop : Pseudo<(outs GR64:$end),
4826                       (ins GR64:$start1, GR64:$start2, GR32:$char),
4827                       [(set GR64:$end, (operator GR64:$start1, GR64:$start2,
4828                                                  GR32:$char))]>;
4829 }
4830
4831 // A pseudo instruction that is a direct alias of a real instruction.
4832 // These aliases are used in cases where a particular register operand is
4833 // fixed or where the same instruction is used with different register sizes.
4834 // The size parameter is the size in bytes of the associated real instruction.
4835 class Alias<int size, dag outs, dag ins, list<dag> pattern>
4836   : InstSystemZ<size, outs, ins, "", pattern> {
4837   let isPseudo = 1;
4838   let isCodeGenOnly = 1;
4839 }
4840
4841 class UnaryAliasVRS<RegisterOperand cls1, RegisterOperand cls2>
4842  : Alias<6, (outs cls1:$src1), (ins cls2:$src2), []>;
4843
4844 // An alias of a UnaryVRR*, but with different register sizes.
4845 class UnaryAliasVRR<SDPatternOperator operator, TypedReg tr1, TypedReg tr2>
4846   : Alias<6, (outs tr1.op:$V1), (ins tr2.op:$V2),
4847           [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]>;
4848
4849 // An alias of a UnaryVRX, but with different register sizes.
4850 class UnaryAliasVRX<SDPatternOperator operator, TypedReg tr,
4851                     AddressingMode mode = bdxaddr12only>
4852   : Alias<6, (outs tr.op:$V1), (ins mode:$XBD2),
4853           [(set (tr.vt tr.op:$V1), (operator mode:$XBD2))]>;
4854
4855 // An alias of a StoreVRX, but with different register sizes.
4856 class StoreAliasVRX<SDPatternOperator operator, TypedReg tr,
4857                     AddressingMode mode = bdxaddr12only>
4858   : Alias<6, (outs), (ins tr.op:$V1, mode:$XBD2),
4859           [(operator (tr.vt tr.op:$V1), mode:$XBD2)]>;
4860
4861 // An alias of a BinaryRI, but with different register sizes.
4862 class BinaryAliasRI<SDPatternOperator operator, RegisterOperand cls,
4863                     Immediate imm>
4864   : Alias<4, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
4865           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4866   let Constraints = "$R1 = $R1src";
4867 }
4868
4869 // An alias of a BinaryRIL, but with different register sizes.
4870 class BinaryAliasRIL<SDPatternOperator operator, RegisterOperand cls,
4871                      Immediate imm>
4872   : Alias<6, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
4873           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4874   let Constraints = "$R1 = $R1src";
4875 }
4876
4877 // An alias of a BinaryVRRf, but with different register sizes.
4878 class BinaryAliasVRRf<RegisterOperand cls>
4879   : Alias<6, (outs VR128:$V1), (ins cls:$R2, cls:$R3), []>;
4880
4881 // An alias of a CompareRI, but with different register sizes.
4882 class CompareAliasRI<SDPatternOperator operator, RegisterOperand cls,
4883                      Immediate imm>
4884   : Alias<4, (outs), (ins cls:$R1, imm:$I2),
4885           [(set CC, (operator cls:$R1, imm:$I2))]> {
4886   let isCompare = 1;
4887 }
4888
4889 // An alias of a RotateSelectRIEf, but with different register sizes.
4890 class RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>
4891   : Alias<6, (outs cls1:$R1),
4892           (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4893                imm32zx6:$I5), []> {
4894   let Constraints = "$R1 = $R1src";
4895 }