]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/SystemZ/SystemZInstrFormats.td
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
[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.op:$V1, (tr.vt (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.op:$V1, (tr.vt (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.op:$V1, (tr1.vt (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 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.op:$V1, (tr.vt (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   let Constraints = "$R1 = $R1src";
3137   let DisableEncoding = "$R1src";
3138   let CCMaskLast = 1;
3139 }
3140
3141 // Like CondBinaryRRF, but used for the raw assembly form.  The condition-code
3142 // mask is the third operand rather than being part of the mnemonic.
3143 class AsmCondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3144                        RegisterOperand cls2>
3145   : InstRRFc<opcode, (outs cls1:$R1),
3146              (ins cls1:$R1src, cls2:$R2, imm32zx4:$M3),
3147              mnemonic#"\t$R1, $R2, $M3", []> {
3148   let Constraints = "$R1 = $R1src";
3149   let DisableEncoding = "$R1src";
3150 }
3151
3152 // Like CondBinaryRRF, but with a fixed CC mask.
3153 class FixedCondBinaryRRF<CondVariant V, string mnemonic, bits<16> opcode,
3154                          RegisterOperand cls1, RegisterOperand cls2>
3155   : InstRRFc<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3156              mnemonic#V.suffix#"\t$R1, $R2", []> {
3157   let Constraints = "$R1 = $R1src";
3158   let DisableEncoding = "$R1src";
3159   let isAsmParserOnly = V.alternate;
3160   let M3 = V.ccmask;
3161 }
3162
3163 multiclass CondBinaryRRFPair<string mnemonic, bits<16> opcode,
3164                              RegisterOperand cls1, RegisterOperand cls2> {
3165   let isCodeGenOnly = 1 in
3166     def "" : CondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3167   def Asm : AsmCondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3168 }
3169
3170 class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3171                RegisterOperand cls, Immediate imm>
3172   : InstRIa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3173             mnemonic#"\t$R1, $I2",
3174             [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3175   let Constraints = "$R1 = $R1src";
3176   let DisableEncoding = "$R1src";
3177 }
3178
3179 class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3180                 RegisterOperand cls, Immediate imm>
3181   : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
3182              mnemonic#"\t$R1, $R3, $I2",
3183              [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
3184
3185 multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
3186                         SDPatternOperator operator, RegisterOperand cls,
3187                         Immediate imm> {
3188   let NumOpsKey = mnemonic in {
3189     let NumOpsValue = "3" in
3190       def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
3191               Requires<[FeatureDistinctOps]>;
3192     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
3193       def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
3194   }
3195 }
3196
3197 class CondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3198                     Immediate imm>
3199   : InstRIEg<opcode, (outs cls:$R1),
3200              (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
3201              mnemonic#"$M3\t$R1, $I2",
3202              [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
3203                                              cond4:$valid, cond4:$M3))]> {
3204   let Constraints = "$R1 = $R1src";
3205   let DisableEncoding = "$R1src";
3206   let CCMaskLast = 1;
3207 }
3208
3209 // Like CondBinaryRIE, but used for the raw assembly form.  The condition-code
3210 // mask is the third operand rather than being part of the mnemonic.
3211 class AsmCondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3212                        Immediate imm>
3213   : InstRIEg<opcode, (outs cls:$R1),
3214              (ins cls:$R1src, imm:$I2, imm32zx4:$M3),
3215              mnemonic#"\t$R1, $I2, $M3", []> {
3216   let Constraints = "$R1 = $R1src";
3217   let DisableEncoding = "$R1src";
3218 }
3219
3220 // Like CondBinaryRIE, but with a fixed CC mask.
3221 class FixedCondBinaryRIE<CondVariant V, string mnemonic, bits<16> opcode,
3222                          RegisterOperand cls, Immediate imm>
3223   : InstRIEg<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3224              mnemonic#V.suffix#"\t$R1, $I2", []> {
3225   let Constraints = "$R1 = $R1src";
3226   let DisableEncoding = "$R1src";
3227   let isAsmParserOnly = V.alternate;
3228   let M3 = V.ccmask;
3229 }
3230
3231 multiclass CondBinaryRIEPair<string mnemonic, bits<16> opcode,
3232                              RegisterOperand cls, Immediate imm> {
3233   let isCodeGenOnly = 1 in
3234     def "" : CondBinaryRIE<mnemonic, opcode, cls, imm>;
3235   def Asm : AsmCondBinaryRIE<mnemonic, opcode, cls, imm>;
3236 }
3237
3238 class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3239                 RegisterOperand cls, Immediate imm>
3240   : InstRILa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3241              mnemonic#"\t$R1, $I2",
3242              [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3243   let Constraints = "$R1 = $R1src";
3244   let DisableEncoding = "$R1src";
3245 }
3246
3247 class BinaryRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3248                RegisterOperand cls>
3249   : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
3250             mnemonic#"\t$R1, $BD2",
3251             [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
3252   let R3 = 0;
3253   let Constraints = "$R1 = $R1src";
3254   let DisableEncoding = "$R1src";
3255 }
3256
3257 class BinaryRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3258                 RegisterOperand cls>
3259   : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
3260              mnemonic#"\t$R1, $R3, $BD2",
3261              [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
3262
3263 multiclass BinaryRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3264                         SDPatternOperator operator, RegisterOperand cls> {
3265   let NumOpsKey = mnemonic in {
3266     let NumOpsValue = "3" in
3267       def K  : BinaryRSY<mnemonic##"k", opcode2, null_frag, cls>,
3268                Requires<[FeatureDistinctOps]>;
3269     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
3270       def "" : BinaryRS<mnemonic, opcode1, operator, cls>;
3271   }
3272 }
3273
3274 class BinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3275   : InstRSLb<opcode, (outs cls:$R1),
3276              (ins bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3277              mnemonic#"\t$R1, $BDL2, $M3", []> {
3278   let mayLoad = 1;
3279 }
3280
3281 class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3282                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3283                AddressingMode mode = bdxaddr12only>
3284   : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3285             mnemonic#"\t$R1, $XBD2",
3286             [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3287   let OpKey = mnemonic#"r"#cls;
3288   let OpType = "mem";
3289   let Constraints = "$R1 = $R1src";
3290   let DisableEncoding = "$R1src";
3291   let mayLoad = 1;
3292   let AccessBytes = bytes;
3293 }
3294
3295 class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3296                   RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3297   : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
3298             mnemonic#"\t$R1, $XBD2",
3299             [(set cls:$R1, (operator cls:$R1src,
3300                                      (load bdxaddr12only:$XBD2)))]> {
3301   let OpKey = mnemonic#"r"#cls;
3302   let OpType = "mem";
3303   let Constraints = "$R1 = $R1src";
3304   let DisableEncoding = "$R1src";
3305   let mayLoad = 1;
3306   let AccessBytes = bytes;
3307   let M3 = 0;
3308 }
3309
3310 class BinaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3311                 RegisterOperand cls1, RegisterOperand cls2,
3312                 SDPatternOperator load, bits<5> bytes>
3313   : InstRXF<opcode, (outs cls1:$R1), (ins cls2:$R3, bdxaddr12only:$XBD2),
3314             mnemonic#"\t$R1, $R3, $XBD2",
3315             [(set cls1:$R1, (operator cls2:$R3, (load bdxaddr12only:$XBD2)))]> {
3316   let OpKey = mnemonic#"r"#cls;
3317   let OpType = "mem";
3318   let mayLoad = 1;
3319   let AccessBytes = bytes;
3320 }
3321
3322 class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3323                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3324                 AddressingMode mode = bdxaddr20only>
3325   : InstRXYa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3326              mnemonic#"\t$R1, $XBD2",
3327              [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3328   let OpKey = mnemonic#"r"#cls;
3329   let OpType = "mem";
3330   let Constraints = "$R1 = $R1src";
3331   let DisableEncoding = "$R1src";
3332   let mayLoad = 1;
3333   let AccessBytes = bytes;
3334 }
3335
3336 multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3337                         SDPatternOperator operator, RegisterOperand cls,
3338                         SDPatternOperator load, bits<5> bytes> {
3339   let DispKey = mnemonic ## #cls in {
3340     let DispSize = "12" in
3341       def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
3342                         bdxaddr12pair>;
3343     let DispSize = "20" in
3344       def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
3345                          bdxaddr20pair>;
3346   }
3347 }
3348
3349 class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3350                Operand imm, AddressingMode mode = bdaddr12only>
3351   : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3352            mnemonic#"\t$BD1, $I2",
3353            [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3354   let mayLoad = 1;
3355   let mayStore = 1;
3356 }
3357
3358 class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3359                 Operand imm, AddressingMode mode = bdaddr20only>
3360   : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3361             mnemonic#"\t$BD1, $I2",
3362             [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3363   let mayLoad = 1;
3364   let mayStore = 1;
3365 }
3366
3367 multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
3368                         bits<16> siyOpcode, SDPatternOperator operator,
3369                         Operand imm> {
3370   let DispKey = mnemonic ## #cls in {
3371     let DispSize = "12" in
3372       def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
3373     let DispSize = "20" in
3374       def Y  : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
3375   }
3376 }
3377
3378 class BinarySSF<string mnemonic, bits<12> opcode, RegisterOperand cls>
3379   : InstSSF<opcode, (outs cls:$R3), (ins bdaddr12pair:$BD1, bdaddr12pair:$BD2),
3380             mnemonic#"\t$R3, $BD1, $BD2", []> {
3381   let mayLoad = 1;
3382 }
3383
3384 class BinaryVRIb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3385                  TypedReg tr, bits<4> type>
3386   : InstVRIb<opcode, (outs tr.op:$V1), (ins imm32zx8:$I2, imm32zx8:$I3),
3387              mnemonic#"\t$V1, $I2, $I3",
3388              [(set tr.op:$V1, (tr.vt (operator imm32zx8:$I2, imm32zx8:$I3)))]> {
3389   let M4 = type;
3390 }
3391
3392 class BinaryVRIbGeneric<string mnemonic, bits<16> opcode>
3393   : InstVRIb<opcode, (outs VR128:$V1),
3394              (ins imm32zx8:$I2, imm32zx8:$I3, imm32zx4:$M4),
3395              mnemonic#"\t$V1, $I2, $I3, $M4", []>;
3396
3397 class BinaryVRIc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3398                  TypedReg tr1, TypedReg tr2, bits<4> type>
3399   : InstVRIc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, imm32zx16:$I2),
3400              mnemonic#"\t$V1, $V3, $I2",
3401              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V3),
3402                                                  imm32zx16:$I2)))]> {
3403   let M4 = type;
3404 }
3405
3406 class BinaryVRIcGeneric<string mnemonic, bits<16> opcode>
3407   : InstVRIc<opcode, (outs VR128:$V1),
3408              (ins VR128:$V3, imm32zx16:$I2, imm32zx4:$M4),
3409              mnemonic#"\t$V1, $V3, $I2, $M4", []>;
3410
3411 class BinaryVRIe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3412                  TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m5>
3413   : InstVRIe<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx12:$I3),
3414              mnemonic#"\t$V1, $V2, $I3",
3415              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
3416                                                  imm32zx12:$I3)))]> {
3417   let M4 = type;
3418   let M5 = m5;
3419 }
3420
3421 class BinaryVRIeFloatGeneric<string mnemonic, bits<16> opcode>
3422   : InstVRIe<opcode, (outs VR128:$V1),
3423              (ins VR128:$V2, imm32zx12:$I3, imm32zx4:$M4, imm32zx4:$M5),
3424              mnemonic#"\t$V1, $V2, $I3, $M4, $M5", []>;
3425
3426 class BinaryVRIh<string mnemonic, bits<16> opcode>
3427   : InstVRIh<opcode, (outs VR128:$V1),
3428              (ins imm32zx16:$I2, imm32zx4:$I3),
3429              mnemonic#"\t$V1, $I2, $I3", []>;
3430
3431 class BinaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3432                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0>
3433   : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx4:$M5),
3434              mnemonic#"\t$V1, $V2, $M5",
3435              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
3436                                                  imm32zx12:$M5)))]> {
3437   let M3 = type;
3438   let M4 = m4;
3439 }
3440
3441 class BinaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
3442   : InstVRRa<opcode, (outs VR128:$V1),
3443              (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
3444              mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
3445
3446 class BinaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3447                  TypedReg tr1, TypedReg tr2, bits<4> type = 0,
3448                  bits<4> modifier = 0>
3449   : InstVRRb<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3450              mnemonic#"\t$V1, $V2, $V3",
3451              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
3452                                                  (tr2.vt tr2.op:$V3))))]> {
3453   let M4 = type;
3454   let M5 = modifier;
3455 }
3456
3457 // Declare a pair of instructions, one which sets CC and one which doesn't.
3458 // The CC-setting form ends with "S" and sets the low bit of M5.
3459 multiclass BinaryVRRbSPair<string mnemonic, bits<16> opcode,
3460                            SDPatternOperator operator,
3461                            SDPatternOperator operator_cc, TypedReg tr1,
3462                            TypedReg tr2, bits<4> type, bits<4> modifier = 0> {
3463   def "" : BinaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
3464                       !and (modifier, 14)>;
3465   let Defs = [CC] in
3466     def S : BinaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
3467                        !add (!and (modifier, 14), 1)>;
3468 }
3469
3470 class BinaryVRRbSPairGeneric<string mnemonic, bits<16> opcode>
3471   : InstVRRb<opcode, (outs VR128:$V1),
3472              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3473              mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
3474
3475 // Declare a pair of instructions, one which sets CC and one which doesn't.
3476 // The CC-setting form ends with "S" and sets the low bit of M5.
3477 // The form that does not set CC has an extra operand to optionally allow
3478 // specifying arbitrary M5 values in assembler.
3479 multiclass BinaryExtraVRRbSPair<string mnemonic, bits<16> opcode,
3480                                 SDPatternOperator operator,
3481                                 SDPatternOperator operator_cc,
3482                                 TypedReg tr1, TypedReg tr2, bits<4> type> {
3483   let M4 = type in
3484     def "" : InstVRRb<opcode, (outs tr1.op:$V1),
3485                       (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M5),
3486                       mnemonic#"\t$V1, $V2, $V3, $M5", []>;
3487   def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3))),
3488             (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, 0)>;
3489   def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
3490                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
3491                                             tr2.op:$V3, 0)>;
3492   let Defs = [CC] in
3493     def S : BinaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type, 1>;
3494 }
3495
3496 multiclass BinaryExtraVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
3497   def "" : InstVRRb<opcode, (outs VR128:$V1),
3498                    (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3499                    mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
3500   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
3501                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
3502                                             imm32zx4:$M4, 0)>;
3503 }
3504
3505 class BinaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3506                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m5 = 0,
3507                  bits<4> m6 = 0>
3508   : InstVRRc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3509              mnemonic#"\t$V1, $V2, $V3",
3510              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
3511                                                  (tr2.vt tr2.op:$V3))))]> {
3512   let M4 = type;
3513   let M5 = m5;
3514   let M6 = m6;
3515 }
3516
3517 class BinaryVRRcGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0,
3518                         bits<4> m6 = 0>
3519   : InstVRRc<opcode, (outs VR128:$V1),
3520              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4),
3521              mnemonic#"\t$V1, $V2, $V3, $M4", []> {
3522   let M5 = m5;
3523   let M6 = m6;
3524 }
3525
3526 class BinaryVRRcFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m6 = 0>
3527   : InstVRRc<opcode, (outs VR128:$V1),
3528              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3529              mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3530   let M6 = m6;
3531 }
3532
3533 // Declare a pair of instructions, one which sets CC and one which doesn't.
3534 // The CC-setting form ends with "S" and sets the low bit of M5.
3535 multiclass BinaryVRRcSPair<string mnemonic, bits<16> opcode,
3536                            SDPatternOperator operator,
3537                            SDPatternOperator operator_cc, TypedReg tr1,
3538                            TypedReg tr2, bits<4> type, bits<4> m5,
3539                            bits<4> modifier = 0> {
3540   def "" : BinaryVRRc<mnemonic, opcode, operator, tr1, tr2, type,
3541                       m5, !and (modifier, 14)>;
3542   let Defs = [CC] in
3543     def S : BinaryVRRc<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
3544                        m5, !add (!and (modifier, 14), 1)>;
3545 }
3546
3547 class BinaryVRRcSPairFloatGeneric<string mnemonic, bits<16> opcode>
3548   : InstVRRc<opcode, (outs VR128:$V1),
3549              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
3550                   imm32zx4:$M6),
3551              mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
3552
3553 class BinaryVRRf<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3554                  TypedReg tr>
3555   : InstVRRf<opcode, (outs tr.op:$V1), (ins GR64:$R2, GR64:$R3),
3556              mnemonic#"\t$V1, $R2, $R3",
3557              [(set tr.op:$V1, (tr.vt (operator GR64:$R2, GR64:$R3)))]>;
3558
3559 class BinaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
3560   : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2, imm32zx4:$M3),
3561              mnemonic#"\t$R1, $V2, $M3", []>;
3562
3563 class BinaryVRSa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3564                  TypedReg tr1, TypedReg tr2, bits<4> type>
3565   : InstVRSa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, shift12only:$BD2),
3566              mnemonic#"\t$V1, $V3, $BD2",
3567              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V3),
3568                                                  shift12only:$BD2)))]> {
3569   let M4 = type;
3570 }
3571
3572 class BinaryVRSaGeneric<string mnemonic, bits<16> opcode>
3573   : InstVRSa<opcode, (outs VR128:$V1),
3574              (ins VR128:$V3, shift12only:$BD2, imm32zx4:$M4),
3575              mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
3576
3577 class BinaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3578                  bits<5> bytes>
3579   : InstVRSb<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3580              mnemonic#"\t$V1, $R3, $BD2",
3581              [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3582   let M4 = 0;
3583   let mayLoad = 1;
3584   let AccessBytes = bytes;
3585 }
3586
3587 class BinaryVRSc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3588                  TypedReg tr, bits<4> type>
3589   : InstVRSc<opcode, (outs GR64:$R1), (ins tr.op:$V3, shift12only:$BD2),
3590            mnemonic#"\t$R1, $V3, $BD2",
3591            [(set GR64:$R1, (operator (tr.vt tr.op:$V3), shift12only:$BD2))]> {
3592   let M4 = type;
3593 }
3594
3595 class BinaryVRScGeneric<string mnemonic, bits<16> opcode>
3596   : InstVRSc<opcode, (outs GR64:$R1),
3597              (ins VR128:$V3, shift12only:$BD2, imm32zx4: $M4),
3598              mnemonic#"\t$R1, $V3, $BD2, $M4", []>;
3599
3600 class BinaryVRSd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3601                  bits<5> bytes>
3602   : InstVRSd<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3603              mnemonic#"\t$V1, $R3, $BD2",
3604              [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3605   let mayLoad = 1;
3606   let AccessBytes = bytes;
3607 }
3608
3609 class BinaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3610                 TypedReg tr, bits<5> bytes>
3611   : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
3612             mnemonic#"\t$V1, $XBD2, $M3",
3613             [(set tr.op:$V1, (tr.vt (operator bdxaddr12only:$XBD2,
3614                                               imm32zx4:$M3)))]> {
3615   let mayLoad = 1;
3616   let AccessBytes = bytes;
3617 }
3618
3619 class StoreBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3620                     bits<5> bytes, AddressingMode mode = bdaddr12only>
3621   : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3622             mnemonic#"\t$R1, $M3, $BD2", []> {
3623   let mayStore = 1;
3624   let AccessBytes = bytes;
3625 }
3626
3627 class StoreBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3628                      bits<5> bytes, AddressingMode mode = bdaddr20only>
3629   : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3630              mnemonic#"\t$R1, $M3, $BD2", []> {
3631   let mayStore = 1;
3632   let AccessBytes = bytes;
3633 }
3634
3635 multiclass StoreBinaryRSPair<string mnemonic, bits<8> rsOpcode,
3636                              bits<16> rsyOpcode, RegisterOperand cls,
3637                              bits<5> bytes> {
3638   let DispKey = mnemonic ## #cls in {
3639     let DispSize = "12" in
3640       def "" : StoreBinaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3641     let DispSize = "20" in
3642       def Y  : StoreBinaryRSY<mnemonic#"y", rsyOpcode, cls, bytes,
3643                               bdaddr20pair>;
3644   }
3645 }
3646
3647 class StoreBinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3648   : InstRSLb<opcode, (outs),
3649              (ins cls:$R1, bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3650              mnemonic#"\t$R1, $BDL2, $M3", []> {
3651   let mayStore = 1;
3652 }
3653
3654 class BinaryVSI<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3655                 bits<5> bytes>
3656   : InstVSI<opcode, (outs VR128:$V1), (ins bdaddr12only:$BD2, imm32zx8:$I3),
3657             mnemonic#"\t$V1, $BD2, $I3",
3658             [(set VR128:$V1, (operator imm32zx8:$I3, bdaddr12only:$BD2))]> {
3659   let mayLoad = 1;
3660   let AccessBytes = bytes;
3661 }
3662
3663 class StoreBinaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
3664                      Immediate index>
3665   : InstVRV<opcode, (outs), (ins VR128:$V1, bdvaddr12only:$VBD2, index:$M3),
3666             mnemonic#"\t$V1, $VBD2, $M3", []> {
3667   let mayStore = 1;
3668   let AccessBytes = bytes;
3669 }
3670
3671 class StoreBinaryVRX<string mnemonic, bits<16> opcode,
3672                      SDPatternOperator operator, TypedReg tr, bits<5> bytes,
3673                      Immediate index>
3674   : InstVRX<opcode, (outs), (ins tr.op:$V1, bdxaddr12only:$XBD2, index:$M3),
3675             mnemonic#"\t$V1, $XBD2, $M3",
3676             [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2, index:$M3)]> {
3677   let mayStore = 1;
3678   let AccessBytes = bytes;
3679 }
3680
3681 class MemoryBinarySSd<string mnemonic, bits<8> opcode,
3682                       RegisterOperand cls>
3683   : InstSSd<opcode, (outs),
3684             (ins bdraddr12only:$RBD1, bdaddr12only:$BD2, cls:$R3),
3685             mnemonic#"\t$RBD1, $BD2, $R3", []>;
3686
3687 class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3688                 RegisterOperand cls1, RegisterOperand cls2>
3689   : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3690            mnemonic#"\t$R1, $R2",
3691            [(operator cls1:$R1, cls2:$R2)]> {
3692   let OpKey = mnemonic#cls1;
3693   let OpType = "reg";
3694   let isCompare = 1;
3695 }
3696
3697 class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3698                  RegisterOperand cls1, RegisterOperand cls2>
3699   : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3700             mnemonic#"\t$R1, $R2",
3701             [(operator cls1:$R1, cls2:$R2)]> {
3702   let OpKey = mnemonic#cls1;
3703   let OpType = "reg";
3704   let isCompare = 1;
3705 }
3706
3707 class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3708                 RegisterOperand cls, Immediate imm>
3709   : InstRIa<opcode, (outs), (ins cls:$R1, imm:$I2),
3710             mnemonic#"\t$R1, $I2",
3711             [(operator cls:$R1, imm:$I2)]> {
3712   let isCompare = 1;
3713 }
3714
3715 class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3716                  RegisterOperand cls, Immediate imm>
3717   : InstRILa<opcode, (outs), (ins cls:$R1, imm:$I2),
3718              mnemonic#"\t$R1, $I2",
3719              [(operator cls:$R1, imm:$I2)]> {
3720   let isCompare = 1;
3721 }
3722
3723 class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3724                    RegisterOperand cls, SDPatternOperator load>
3725   : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
3726              mnemonic#"\t$R1, $RI2",
3727              [(operator cls:$R1, (load pcrel32:$RI2))]> {
3728   let isCompare = 1;
3729   let mayLoad = 1;
3730   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
3731   // However, BDXs have two extra operands and are therefore 6 units more
3732   // complex.
3733   let AddedComplexity = 7;
3734 }
3735
3736 class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3737                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3738                 AddressingMode mode = bdxaddr12only>
3739   : InstRXa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3740             mnemonic#"\t$R1, $XBD2",
3741             [(operator cls:$R1, (load mode:$XBD2))]> {
3742   let OpKey = mnemonic#"r"#cls;
3743   let OpType = "mem";
3744   let isCompare = 1;
3745   let mayLoad = 1;
3746   let AccessBytes = bytes;
3747 }
3748
3749 class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3750                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3751   : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3752             mnemonic#"\t$R1, $XBD2",
3753             [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
3754   let OpKey = mnemonic#"r"#cls;
3755   let OpType = "mem";
3756   let isCompare = 1;
3757   let mayLoad = 1;
3758   let AccessBytes = bytes;
3759   let M3 = 0;
3760 }
3761
3762 class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3763                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3764                  AddressingMode mode = bdxaddr20only>
3765   : InstRXYa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3766              mnemonic#"\t$R1, $XBD2",
3767              [(operator cls:$R1, (load mode:$XBD2))]> {
3768   let OpKey = mnemonic#"r"#cls;
3769   let OpType = "mem";
3770   let isCompare = 1;
3771   let mayLoad = 1;
3772   let AccessBytes = bytes;
3773 }
3774
3775 multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3776                          SDPatternOperator operator, RegisterOperand cls,
3777                          SDPatternOperator load, bits<5> bytes> {
3778   let DispKey = mnemonic ## #cls in {
3779     let DispSize = "12" in
3780       def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
3781                          load, bytes, bdxaddr12pair>;
3782     let DispSize = "20" in
3783       def Y  : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
3784                           load, bytes, bdxaddr20pair>;
3785   }
3786 }
3787
3788 class CompareRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3789                 bits<5> bytes, AddressingMode mode = bdaddr12only>
3790   : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3791             mnemonic#"\t$R1, $M3, $BD2", []> {
3792   let mayLoad = 1;
3793   let AccessBytes = bytes;
3794 }
3795
3796 class CompareRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3797                  bits<5> bytes, AddressingMode mode = bdaddr20only>
3798   : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3799              mnemonic#"\t$R1, $M3, $BD2", []> {
3800   let mayLoad = 1;
3801   let AccessBytes = bytes;
3802 }
3803
3804 multiclass CompareRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
3805                          RegisterOperand cls, bits<5> bytes> {
3806   let DispKey = mnemonic ## #cls in {
3807     let DispSize = "12" in
3808       def "" : CompareRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3809     let DispSize = "20" in
3810       def Y  : CompareRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
3811   }
3812 }
3813
3814 class CompareSSb<string mnemonic, bits<8> opcode>
3815   : InstSSb<opcode,
3816             (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
3817             mnemonic##"\t$BDL1, $BDL2", []> {
3818   let isCompare = 1;
3819   let mayLoad = 1;
3820 }
3821
3822 class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3823                 SDPatternOperator load, Immediate imm,
3824                 AddressingMode mode = bdaddr12only>
3825   : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3826            mnemonic#"\t$BD1, $I2",
3827            [(operator (load mode:$BD1), imm:$I2)]> {
3828   let isCompare = 1;
3829   let mayLoad = 1;
3830 }
3831
3832 class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3833                  SDPatternOperator load, Immediate imm>
3834   : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3835             mnemonic#"\t$BD1, $I2",
3836             [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
3837   let isCompare = 1;
3838   let mayLoad = 1;
3839 }
3840
3841 class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3842                  SDPatternOperator load, Immediate imm,
3843                  AddressingMode mode = bdaddr20only>
3844   : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3845             mnemonic#"\t$BD1, $I2",
3846             [(operator (load mode:$BD1), imm:$I2)]> {
3847   let isCompare = 1;
3848   let mayLoad = 1;
3849 }
3850
3851 multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
3852                          SDPatternOperator operator, SDPatternOperator load,
3853                          Immediate imm> {
3854   let DispKey = mnemonic in {
3855     let DispSize = "12" in
3856       def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
3857     let DispSize = "20" in
3858       def Y  : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
3859                           bdaddr20pair>;
3860   }
3861 }
3862
3863 class CompareVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3864                   TypedReg tr, bits<4> type>
3865   : InstVRRa<opcode, (outs), (ins tr.op:$V1, tr.op:$V2),
3866              mnemonic#"\t$V1, $V2",
3867              [(operator (tr.vt tr.op:$V1), (tr.vt tr.op:$V2))]> {
3868   let isCompare = 1;
3869   let M3 = type;
3870   let M4 = 0;
3871   let M5 = 0;
3872 }
3873
3874 class CompareVRRaGeneric<string mnemonic, bits<16> opcode>
3875   : InstVRRa<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
3876              mnemonic#"\t$V1, $V2, $M3", []> {
3877   let isCompare = 1;
3878   let M4 = 0;
3879   let M5 = 0;
3880 }
3881
3882 class CompareVRRaFloatGeneric<string mnemonic, bits<16> opcode>
3883   : InstVRRa<opcode, (outs),
3884              (ins VR64:$V1, VR64:$V2, imm32zx4:$M3, imm32zx4:$M4),
3885              mnemonic#"\t$V1, $V2, $M3, $M4", []> {
3886   let isCompare = 1;
3887   let M5 = 0;
3888 }
3889
3890 class CompareVRRh<string mnemonic, bits<16> opcode>
3891   : InstVRRh<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
3892              mnemonic#"\t$V1, $V2, $M3", []> {
3893   let isCompare = 1;
3894 }
3895
3896 class TestRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3897               RegisterOperand cls>
3898   : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3899             mnemonic#"\t$R1, $XBD2",
3900             [(operator cls:$R1, bdxaddr12only:$XBD2)]> {
3901   let M3 = 0;
3902 }
3903
3904 class TestRSL<string mnemonic, bits<16> opcode>
3905   : InstRSLa<opcode, (outs), (ins bdladdr12onlylen4:$BDL1),
3906              mnemonic#"\t$BDL1", []> {
3907   let mayLoad = 1;
3908 }
3909
3910 class TestVRRg<string mnemonic, bits<16> opcode>
3911   : InstVRRg<opcode, (outs), (ins VR128:$V1),
3912              mnemonic#"\t$V1", []>;
3913
3914 class SideEffectTernarySSc<string mnemonic, bits<8> opcode>
3915   : InstSSc<opcode, (outs), (ins bdladdr12onlylen4:$BDL1,
3916                                  shift12only:$BD2, imm32zx4:$I3),
3917             mnemonic##"\t$BDL1, $BD2, $I3", []>;
3918
3919 class SideEffectTernaryRRFa<string mnemonic, bits<16> opcode,
3920                             RegisterOperand cls1, RegisterOperand cls2,
3921                             RegisterOperand cls3>
3922   : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
3923              mnemonic#"\t$R1, $R2, $R3", []> {
3924   let M4 = 0;
3925 }
3926
3927 class SideEffectTernaryRRFb<string mnemonic, bits<16> opcode,
3928                             RegisterOperand cls1, RegisterOperand cls2,
3929                             RegisterOperand cls3>
3930   : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
3931              mnemonic#"\t$R1, $R3, $R2", []> {
3932   let M4 = 0;
3933 }
3934
3935 class SideEffectTernaryMemMemMemRRFb<string mnemonic, bits<16> opcode,
3936                                      RegisterOperand cls1,
3937                                      RegisterOperand cls2,
3938                                      RegisterOperand cls3>
3939   : InstRRFb<opcode, (outs cls1:$R1, cls2:$R2, cls3:$R3),
3940              (ins cls1:$R1src, cls2:$R2src, cls3:$R3src),
3941              mnemonic#"\t$R1, $R3, $R2", []> {
3942   let Constraints = "$R1 = $R1src, $R2 = $R2src, $R3 = $R3src";
3943   let DisableEncoding = "$R1src, $R2src, $R3src";
3944   let M4 = 0;
3945 }
3946
3947 class SideEffectTernaryRRFc<string mnemonic, bits<16> opcode,
3948                             RegisterOperand cls1, RegisterOperand cls2,
3949                             Immediate imm>
3950   : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2, imm:$M3),
3951              mnemonic#"\t$R1, $R2, $M3", []>;
3952
3953 multiclass SideEffectTernaryRRFcOpt<string mnemonic, bits<16> opcode,
3954                                     RegisterOperand cls1,
3955                                     RegisterOperand cls2> {
3956   def "" : SideEffectTernaryRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3957   def Opt : SideEffectBinaryRRFc<mnemonic, opcode, cls1, cls2>;
3958 }
3959
3960 class SideEffectTernaryMemMemRRFc<string mnemonic, bits<16> opcode,
3961                                   RegisterOperand cls1, RegisterOperand cls2,
3962                                   Immediate imm>
3963   : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2),
3964              (ins cls1:$R1src, cls2:$R2src, imm:$M3),
3965              mnemonic#"\t$R1, $R2, $M3", []> {
3966   let Constraints = "$R1 = $R1src, $R2 = $R2src";
3967   let DisableEncoding = "$R1src, $R2src";
3968 }
3969
3970 multiclass SideEffectTernaryMemMemRRFcOpt<string mnemonic, bits<16> opcode,
3971                                           RegisterOperand cls1,
3972                                           RegisterOperand cls2> {
3973   def "" : SideEffectTernaryMemMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3974   def Opt : SideEffectBinaryMemMemRRFc<mnemonic, opcode, cls1, cls2>;
3975 }
3976
3977 class SideEffectTernarySSF<string mnemonic, bits<12> opcode,
3978                            RegisterOperand cls>
3979   : InstSSF<opcode, (outs),
3980             (ins bdaddr12only:$BD1, bdaddr12only:$BD2, cls:$R3),
3981             mnemonic#"\t$BD1, $BD2, $R3", []>;
3982
3983 class TernaryRRFa<string mnemonic, bits<16> opcode,
3984                  RegisterOperand cls1, RegisterOperand cls2,
3985                  RegisterOperand cls3>
3986   : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3, imm32zx4:$M4),
3987              mnemonic#"\t$R1, $R2, $R3, $M4", []>;
3988
3989 class TernaryRRFb<string mnemonic, bits<16> opcode,
3990                   RegisterOperand cls1, RegisterOperand cls2,
3991                   RegisterOperand cls3>
3992   : InstRRFb<opcode, (outs cls1:$R1, cls3:$R3),
3993              (ins cls1:$R1src, cls2:$R2, imm32zx4:$M4),
3994              mnemonic#"\t$R1, $R3, $R2, $M4", []> {
3995   let Constraints = "$R1 = $R1src";
3996   let DisableEncoding = "$R1src";
3997 }
3998
3999 class TernaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4000                   RegisterOperand cls2>
4001   : InstRRFe<opcode, (outs cls1:$R1),
4002              (ins imm32zx4:$M3, cls2:$R2, imm32zx4:$M4),
4003              mnemonic#"\t$R1, $M3, $R2, $M4", []>;
4004
4005 class TernaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4006                  RegisterOperand cls1, RegisterOperand cls2>
4007   : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R1src, cls2:$R3, cls2:$R2),
4008             mnemonic#"\t$R1, $R3, $R2",
4009             [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3, cls2:$R2))]> {
4010   let OpKey = mnemonic#cls;
4011   let OpType = "reg";
4012   let Constraints = "$R1 = $R1src";
4013   let DisableEncoding = "$R1src";
4014 }
4015
4016 class TernaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
4017                 bits<5> bytes, AddressingMode mode = bdaddr12only>
4018   : InstRSb<opcode, (outs cls:$R1),
4019             (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4020             mnemonic#"\t$R1, $M3, $BD2", []> {
4021
4022   let Constraints = "$R1 = $R1src";
4023   let DisableEncoding = "$R1src";
4024   let mayLoad = 1;
4025   let AccessBytes = bytes;
4026 }
4027
4028 class TernaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
4029                 bits<5> bytes, AddressingMode mode = bdaddr20only>
4030   : InstRSYb<opcode, (outs cls:$R1),
4031              (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4032              mnemonic#"\t$R1, $M3, $BD2", []> {
4033
4034   let Constraints = "$R1 = $R1src";
4035   let DisableEncoding = "$R1src";
4036   let mayLoad = 1;
4037   let AccessBytes = bytes;
4038 }
4039
4040 multiclass TernaryRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4041                          RegisterOperand cls, bits<5> bytes> {
4042   let DispKey = mnemonic ## #cls in {
4043     let DispSize = "12" in
4044       def "" : TernaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
4045     let DispSize = "20" in
4046       def Y  : TernaryRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
4047   }
4048 }
4049
4050 class SideEffectTernaryRS<string mnemonic, bits<8> opcode,
4051                           RegisterOperand cls1, RegisterOperand cls2>
4052   : InstRSa<opcode, (outs),
4053             (ins cls1:$R1, cls2:$R3, bdaddr12only:$BD2),
4054             mnemonic#"\t$R1, $R3, $BD2", []>;
4055
4056 class SideEffectTernaryRSY<string mnemonic, bits<16> opcode,
4057                            RegisterOperand cls1, RegisterOperand cls2>
4058   : InstRSYa<opcode, (outs),
4059              (ins cls1:$R1, cls2:$R3, bdaddr20only:$BD2),
4060              mnemonic#"\t$R1, $R3, $BD2", []>;
4061
4062 class SideEffectTernaryMemMemRS<string mnemonic, bits<8> opcode,
4063                                 RegisterOperand cls1, RegisterOperand cls2>
4064   : InstRSa<opcode, (outs cls1:$R1, cls2:$R3),
4065             (ins cls1:$R1src, cls2:$R3src, shift12only:$BD2),
4066             mnemonic#"\t$R1, $R3, $BD2", []> {
4067     let Constraints = "$R1 = $R1src, $R3 = $R3src";
4068     let DisableEncoding = "$R1src, $R3src";
4069 }
4070
4071 class SideEffectTernaryMemMemRSY<string mnemonic, bits<16> opcode,
4072                                  RegisterOperand cls1, RegisterOperand cls2>
4073   : InstRSYa<opcode, (outs cls1:$R1, cls2:$R3),
4074              (ins cls1:$R1src, cls2:$R3src, shift20only:$BD2),
4075              mnemonic#"\t$R1, $R3, $BD2", []> {
4076     let Constraints = "$R1 = $R1src, $R3 = $R3src";
4077     let DisableEncoding = "$R1src, $R3src";
4078 }
4079
4080 class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4081                  RegisterOperand cls1, RegisterOperand cls2,
4082                  SDPatternOperator load, bits<5> bytes>
4083   : InstRXF<opcode, (outs cls1:$R1),
4084             (ins cls2:$R1src, cls2:$R3, bdxaddr12only:$XBD2),
4085             mnemonic#"\t$R1, $R3, $XBD2",
4086             [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3,
4087                                       (load bdxaddr12only:$XBD2)))]> {
4088   let OpKey = mnemonic#"r"#cls;
4089   let OpType = "mem";
4090   let Constraints = "$R1 = $R1src";
4091   let DisableEncoding = "$R1src";
4092   let mayLoad = 1;
4093   let AccessBytes = bytes;
4094 }
4095
4096 class TernaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4097                   TypedReg tr1, TypedReg tr2, Immediate imm, Immediate index>
4098   : InstVRIa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V1src, imm:$I2, index:$M3),
4099              mnemonic#"\t$V1, $I2, $M3",
4100              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V1src),
4101                                                  imm:$I2, index:$M3)))]> {
4102   let Constraints = "$V1 = $V1src";
4103   let DisableEncoding = "$V1src";
4104 }
4105
4106 class TernaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4107                   TypedReg tr1, TypedReg tr2, bits<4> type>
4108   : InstVRId<opcode, (outs tr1.op:$V1),
4109              (ins tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4110              mnemonic#"\t$V1, $V2, $V3, $I4",
4111              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4112                                                  (tr2.vt tr2.op:$V3),
4113                                                  imm32zx8:$I4)))]> {
4114   let M5 = type;
4115 }
4116
4117 class TernaryVRIi<string mnemonic, bits<16> opcode, RegisterOperand cls>
4118   : InstVRIi<opcode, (outs VR128:$V1),
4119              (ins cls:$R2, imm32zx8:$I3, imm32zx4:$M4),
4120              mnemonic#"\t$V1, $R2, $I3, $M4", []>;
4121
4122 class TernaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4123                   TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m4or>
4124   : InstVRRa<opcode, (outs tr1.op:$V1),
4125              (ins tr2.op:$V2, imm32zx4:$M4, imm32zx4:$M5),
4126              mnemonic#"\t$V1, $V2, $M4, $M5",
4127              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4128                                                  imm32zx4:$M4,
4129                                                  imm32zx4:$M5)))],
4130              m4or> {
4131   let M3 = type;
4132 }
4133
4134 class TernaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
4135   : InstVRRa<opcode, (outs VR128:$V1),
4136              (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
4137              mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
4138
4139 class TernaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4140                   TypedReg tr1, TypedReg tr2, bits<4> type,
4141                   SDPatternOperator m5mask, bits<4> m5or>
4142   : InstVRRb<opcode, (outs tr1.op:$V1),
4143              (ins tr2.op:$V2, tr2.op:$V3, m5mask:$M5),
4144              mnemonic#"\t$V1, $V2, $V3, $M5",
4145              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4146                                                  (tr2.vt tr2.op:$V3),
4147                                                  m5mask:$M5)))],
4148              m5or> {
4149   let M4 = type;
4150 }
4151
4152 // Declare a pair of instructions, one which sets CC and one which doesn't.
4153 // The CC-setting form ends with "S" and sets the low bit of M5.
4154 // Also create aliases to make use of M5 operand optional in assembler.
4155 multiclass TernaryOptVRRbSPair<string mnemonic, bits<16> opcode,
4156                                SDPatternOperator operator,
4157                                SDPatternOperator operator_cc,
4158                                TypedReg tr1, TypedReg tr2, bits<4> type,
4159                                bits<4> modifier = 0> {
4160   def "" : TernaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
4161                        imm32zx4even, !and (modifier, 14)>;
4162   def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
4163                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4164                                             tr2.op:$V3, 0)>;
4165   let Defs = [CC] in
4166     def S : TernaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
4167                         imm32zx4even, !add(!and (modifier, 14), 1)>;
4168   def : InstAlias<mnemonic#"s\t$V1, $V2, $V3",
4169                   (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4170                                                 tr2.op:$V3, 0)>;
4171 }
4172
4173 multiclass TernaryOptVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
4174   def "" : InstVRRb<opcode, (outs VR128:$V1),
4175                    (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
4176                    mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
4177   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
4178                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4179                                             imm32zx4:$M4, 0)>;
4180 }
4181
4182 class TernaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4183                   TypedReg tr1, TypedReg tr2>
4184   : InstVRRc<opcode, (outs tr1.op:$V1),
4185              (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M4),
4186              mnemonic#"\t$V1, $V2, $V3, $M4",
4187              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4188                                                  (tr2.vt tr2.op:$V3),
4189                                                  imm32zx4:$M4)))]> {
4190   let M5 = 0;
4191   let M6 = 0;
4192 }
4193
4194 class TernaryVRRcFloat<string mnemonic, bits<16> opcode,
4195                        SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4196                        bits<4> type = 0, bits<4> m5 = 0>
4197   : InstVRRc<opcode, (outs tr1.op:$V1),
4198              (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M6),
4199              mnemonic#"\t$V1, $V2, $V3, $M6",
4200              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4201                                                  (tr2.vt tr2.op:$V3),
4202                                                  imm32zx4:$M6)))]> {
4203   let M4 = type;
4204   let M5 = m5;
4205 }
4206
4207 class TernaryVRRcFloatGeneric<string mnemonic, bits<16> opcode>
4208   : InstVRRc<opcode, (outs VR128:$V1),
4209              (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
4210                   imm32zx4:$M6),
4211              mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
4212
4213 class TernaryVRRd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4214                   TypedReg tr1, TypedReg tr2, bits<4> type = 0>
4215   : InstVRRd<opcode, (outs tr1.op:$V1),
4216              (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4217              mnemonic#"\t$V1, $V2, $V3, $V4",
4218              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4219                                                  (tr2.vt tr2.op:$V3),
4220                                                  (tr1.vt tr1.op:$V4))))]> {
4221   let M5 = type;
4222   let M6 = 0;
4223 }
4224
4225 class TernaryVRRdGeneric<string mnemonic, bits<16> opcode>
4226   : InstVRRd<opcode, (outs VR128:$V1),
4227              (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5),
4228              mnemonic#"\t$V1, $V2, $V3, $V4, $M5", []> {
4229   let M6 = 0;
4230 }
4231
4232 class TernaryVRRe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4233                   TypedReg tr1, TypedReg tr2, bits<4> m5 = 0, bits<4> type = 0>
4234   : InstVRRe<opcode, (outs tr1.op:$V1),
4235              (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4236              mnemonic#"\t$V1, $V2, $V3, $V4",
4237              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4238                                                  (tr2.vt tr2.op:$V3),
4239                                                  (tr1.vt tr1.op:$V4))))]> {
4240   let M5 = m5;
4241   let M6 = type;
4242 }
4243
4244 class TernaryVRReFloatGeneric<string mnemonic, bits<16> opcode>
4245   : InstVRRe<opcode, (outs VR128:$V1),
4246              (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4247              mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4248
4249 class TernaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4250                   TypedReg tr1, TypedReg tr2, RegisterOperand cls, bits<4> type>
4251   : InstVRSb<opcode, (outs tr1.op:$V1),
4252              (ins tr2.op:$V1src, cls:$R3, shift12only:$BD2),
4253              mnemonic#"\t$V1, $R3, $BD2",
4254              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V1src),
4255                                                  cls:$R3,
4256                                                  shift12only:$BD2)))]> {
4257   let Constraints = "$V1 = $V1src";
4258   let DisableEncoding = "$V1src";
4259   let M4 = type;
4260 }
4261
4262 class TernaryVRSbGeneric<string mnemonic, bits<16> opcode>
4263   : InstVRSb<opcode, (outs VR128:$V1),
4264              (ins VR128:$V1src, GR64:$R3, shift12only:$BD2, imm32zx4:$M4),
4265              mnemonic#"\t$V1, $R3, $BD2, $M4", []> {
4266   let Constraints = "$V1 = $V1src";
4267   let DisableEncoding = "$V1src";
4268 }
4269
4270 class TernaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
4271                  Immediate index>
4272   : InstVRV<opcode, (outs VR128:$V1),
4273            (ins VR128:$V1src, bdvaddr12only:$VBD2, index:$M3),
4274            mnemonic#"\t$V1, $VBD2, $M3", []> {
4275   let Constraints = "$V1 = $V1src";
4276   let DisableEncoding = "$V1src";
4277   let mayLoad = 1;
4278   let AccessBytes = bytes;
4279 }
4280
4281 class TernaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4282                  TypedReg tr1, TypedReg tr2, bits<5> bytes, Immediate index>
4283   : InstVRX<opcode, (outs tr1.op:$V1),
4284            (ins tr2.op:$V1src, bdxaddr12only:$XBD2, index:$M3),
4285            mnemonic#"\t$V1, $XBD2, $M3",
4286            [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V1src),
4287                                                bdxaddr12only:$XBD2,
4288                                                index:$M3)))]> {
4289   let Constraints = "$V1 = $V1src";
4290   let DisableEncoding = "$V1src";
4291   let mayLoad = 1;
4292   let AccessBytes = bytes;
4293 }
4294
4295 class QuaternaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4296                      TypedReg tr1, TypedReg tr2, bits<4> type>
4297   : InstVRId<opcode, (outs tr1.op:$V1),
4298              (ins tr2.op:$V1src, tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4299              mnemonic#"\t$V1, $V2, $V3, $I4",
4300              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V1src),
4301                                                  (tr2.vt tr2.op:$V2),
4302                                                  (tr2.vt tr2.op:$V3),
4303                                                  imm32zx8:$I4)))]> {
4304   let Constraints = "$V1 = $V1src";
4305   let DisableEncoding = "$V1src";
4306   let M5 = type;
4307 }
4308
4309 class QuaternaryVRIdGeneric<string mnemonic, bits<16> opcode>
4310   : InstVRId<opcode, (outs VR128:$V1),
4311              (ins VR128:$V1src, VR128:$V2, VR128:$V3,
4312                   imm32zx8:$I4, imm32zx4:$M5),
4313              mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []> {
4314   let Constraints = "$V1 = $V1src";
4315   let DisableEncoding = "$V1src";
4316 }
4317
4318 class QuaternaryVRIf<string mnemonic, bits<16> opcode>
4319   : InstVRIf<opcode, (outs VR128:$V1),
4320              (ins VR128:$V2, VR128:$V3,
4321                   imm32zx8:$I4, imm32zx4:$M5),
4322              mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []>;
4323
4324 class QuaternaryVRIg<string mnemonic, bits<16> opcode>
4325   : InstVRIg<opcode, (outs VR128:$V1),
4326              (ins VR128:$V2, imm32zx8:$I3,
4327                   imm32zx8:$I4, imm32zx4:$M5),
4328              mnemonic#"\t$V1, $V2, $I3, $I4, $M5", []>;
4329
4330 class QuaternaryVRRd<string mnemonic, bits<16> opcode,
4331                      SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4332                      TypedReg tr3, TypedReg tr4, bits<4> type,
4333                      SDPatternOperator m6mask = imm32zx4, bits<4> m6or = 0>
4334   : InstVRRd<opcode, (outs tr1.op:$V1),
4335              (ins tr2.op:$V2, tr3.op:$V3, tr4.op:$V4, m6mask:$M6),
4336              mnemonic#"\t$V1, $V2, $V3, $V4, $M6",
4337              [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2),
4338                                                  (tr3.vt tr3.op:$V3),
4339                                                  (tr4.vt tr4.op:$V4),
4340                                                  m6mask:$M6)))],
4341              m6or> {
4342   let M5 = type;
4343 }
4344
4345 class QuaternaryVRRdGeneric<string mnemonic, bits<16> opcode>
4346   : InstVRRd<opcode, (outs VR128:$V1),
4347              (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4348              mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4349
4350 // Declare a pair of instructions, one which sets CC and one which doesn't.
4351 // The CC-setting form ends with "S" and sets the low bit of M6.
4352 // Also create aliases to make use of M6 operand optional in assembler.
4353 multiclass QuaternaryOptVRRdSPair<string mnemonic, bits<16> opcode,
4354                                   SDPatternOperator operator,
4355                                 SDPatternOperator operator_cc,
4356                                 TypedReg tr1, TypedReg tr2, bits<4> type,
4357                                 bits<4> modifier = 0> {
4358   def "" : QuaternaryVRRd<mnemonic, opcode, operator,
4359                           tr1, tr2, tr2, tr2, type,
4360                           imm32zx4even, !and (modifier, 14)>;
4361   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
4362                   (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4363                                             tr2.op:$V3, tr2.op:$V4, 0)>;
4364   let Defs = [CC] in
4365     def S : QuaternaryVRRd<mnemonic##"s", opcode, operator_cc,
4366                            tr1, tr2, tr2, tr2, type,
4367                            imm32zx4even, !add (!and (modifier, 14), 1)>;
4368   def : InstAlias<mnemonic#"s\t$V1, $V2, $V3, $V4",
4369                   (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4370                                                 tr2.op:$V3, tr2.op:$V4, 0)>;
4371 }
4372
4373 multiclass QuaternaryOptVRRdSPairGeneric<string mnemonic, bits<16> opcode> {
4374   def "" : QuaternaryVRRdGeneric<mnemonic, opcode>;
4375   def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
4376                   (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4377                                             VR128:$V4, imm32zx4:$M5, 0)>;
4378 }
4379
4380 class SideEffectQuaternaryRRFa<string mnemonic, bits<16> opcode,
4381                                RegisterOperand cls1, RegisterOperand cls2,
4382                                RegisterOperand cls3>
4383   : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4384              mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4385
4386 multiclass SideEffectQuaternaryRRFaOptOpt<string mnemonic, bits<16> opcode,
4387                                           RegisterOperand cls1,
4388                                           RegisterOperand cls2,
4389                                           RegisterOperand cls3> {
4390   def "" : SideEffectQuaternaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4391   def Opt : SideEffectTernaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4392   def OptOpt : SideEffectBinaryRRFa<mnemonic, opcode, cls1, cls2>;
4393 }
4394
4395 class SideEffectQuaternaryRRFb<string mnemonic, bits<16> opcode,
4396                                RegisterOperand cls1, RegisterOperand cls2,
4397                                RegisterOperand cls3>
4398   : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4399              mnemonic#"\t$R1, $R3, $R2, $M4", []>;
4400
4401 multiclass SideEffectQuaternaryRRFbOpt<string mnemonic, bits<16> opcode,
4402                                        RegisterOperand cls1,
4403                                        RegisterOperand cls2,
4404                                        RegisterOperand cls3> {
4405   def "" : SideEffectQuaternaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4406   def Opt : SideEffectTernaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4407 }
4408
4409 class SideEffectQuaternarySSe<string mnemonic, bits<8> opcode,
4410                               RegisterOperand cls>
4411   : InstSSe<opcode, (outs),
4412             (ins cls:$R1, bdaddr12only:$BD2, cls:$R3, bdaddr12only:$BD4),
4413             mnemonic#"\t$R1, $BD2, $R3, $BD4", []>;
4414
4415 class LoadAndOpRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4416                   RegisterOperand cls, AddressingMode mode = bdaddr20only>
4417   : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
4418              mnemonic#"\t$R1, $R3, $BD2",
4419              [(set cls:$R1, (operator mode:$BD2, cls:$R3))]> {
4420   let mayLoad = 1;
4421   let mayStore = 1;
4422 }
4423
4424 class CmpSwapRRE<string mnemonic, bits<16> opcode,
4425                  RegisterOperand cls1, RegisterOperand cls2>
4426   : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
4427             mnemonic#"\t$R1, $R2", []> {
4428   let Constraints = "$R1 = $R1src";
4429   let DisableEncoding = "$R1src";
4430   let mayLoad = 1;
4431   let mayStore = 1;
4432 }
4433
4434 class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
4435                 RegisterOperand cls, AddressingMode mode = bdaddr12only>
4436   : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4437             mnemonic#"\t$R1, $R3, $BD2",
4438             [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4439   let Constraints = "$R1 = $R1src";
4440   let DisableEncoding = "$R1src";
4441   let mayLoad = 1;
4442   let mayStore = 1;
4443 }
4444
4445 class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4446                  RegisterOperand cls, AddressingMode mode = bdaddr20only>
4447   : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4448              mnemonic#"\t$R1, $R3, $BD2",
4449              [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4450   let Constraints = "$R1 = $R1src";
4451   let DisableEncoding = "$R1src";
4452   let mayLoad = 1;
4453   let mayStore = 1;
4454 }
4455
4456 multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4457                          SDPatternOperator operator, RegisterOperand cls> {
4458   let DispKey = mnemonic ## #cls in {
4459     let DispSize = "12" in
4460       def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
4461     let DispSize = "20" in
4462       def Y  : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
4463   }
4464 }
4465
4466 class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4467                        RegisterOperand cls2>
4468   : InstRIEf<opcode, (outs cls1:$R1),
4469              (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4470                   imm32zx6:$I5),
4471              mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
4472   let Constraints = "$R1 = $R1src";
4473   let DisableEncoding = "$R1src";
4474 }
4475
4476 class PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator>
4477   : InstRXYb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr20only:$XBD2),
4478              mnemonic##"\t$M1, $XBD2",
4479              [(operator imm32zx4:$M1, bdxaddr20only:$XBD2)]>;
4480
4481 class PrefetchRILPC<string mnemonic, bits<12> opcode,
4482                     SDPatternOperator operator>
4483   : InstRILc<opcode, (outs), (ins imm32zx4:$M1, pcrel32:$RI2),
4484              mnemonic##"\t$M1, $RI2",
4485              [(operator imm32zx4:$M1, pcrel32:$RI2)]> {
4486   // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
4487   // However, BDXs have two extra operands and are therefore 6 units more
4488   // complex.
4489   let AddedComplexity = 7;
4490 }
4491
4492 class BranchPreloadSMI<string mnemonic, bits<8> opcode>
4493   : InstSMI<opcode, (outs),
4494             (ins imm32zx4:$M1, brtarget16bpp:$RI2, bdxaddr12only:$BD3),
4495             mnemonic#"\t$M1, $RI2, $BD3", []>;
4496
4497 class BranchPreloadMII<string mnemonic, bits<8> opcode>
4498   : InstMII<opcode, (outs),
4499             (ins imm32zx4:$M1, brtarget12bpp:$RI2, brtarget24bpp:$RI3),
4500             mnemonic#"\t$M1, $RI2, $RI3", []>;
4501
4502 // A floating-point load-and test operation.  Create both a normal unary
4503 // operation and one that acts as a comparison against zero.
4504 // Note that the comparison against zero operation is not available if we
4505 // have vector support, since load-and-test instructions will partially
4506 // clobber the target (vector) register.
4507 multiclass LoadAndTestRRE<string mnemonic, bits<16> opcode,
4508                           RegisterOperand cls> {
4509   def "" : UnaryRRE<mnemonic, opcode, null_frag, cls, cls>;
4510   let isCodeGenOnly = 1, Predicates = [FeatureNoVector] in
4511     def Compare : CompareRRE<mnemonic, opcode, null_frag, cls, cls>;
4512 }
4513
4514 //===----------------------------------------------------------------------===//
4515 // Pseudo instructions
4516 //===----------------------------------------------------------------------===//
4517 //
4518 // Convenience instructions that get lowered to real instructions
4519 // by either SystemZTargetLowering::EmitInstrWithCustomInserter()
4520 // or SystemZInstrInfo::expandPostRAPseudo().
4521 //
4522 //===----------------------------------------------------------------------===//
4523
4524 class Pseudo<dag outs, dag ins, list<dag> pattern>
4525   : InstSystemZ<0, outs, ins, "", pattern> {
4526   let isPseudo = 1;
4527   let isCodeGenOnly = 1;
4528 }
4529
4530 // Like SideEffectBinarySIL, but expanded later.
4531 class SideEffectBinarySILPseudo<SDPatternOperator operator, Immediate imm>
4532   : Pseudo<(outs), (ins bdaddr12only:$BD1, imm:$I2),
4533            [(operator bdaddr12only:$BD1, imm:$I2)]>;
4534
4535 // Like UnaryRI, but expanded after RA depending on the choice of register.
4536 class UnaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4537                     Immediate imm>
4538   : Pseudo<(outs cls:$R1), (ins imm:$I2),
4539            [(set cls:$R1, (operator imm:$I2))]>;
4540
4541 // Like UnaryRXY, but expanded after RA depending on the choice of register.
4542 class UnaryRXYPseudo<string key, SDPatternOperator operator,
4543                      RegisterOperand cls, bits<5> bytes,
4544                      AddressingMode mode = bdxaddr20only>
4545   : Pseudo<(outs cls:$R1), (ins mode:$XBD2),
4546            [(set cls:$R1, (operator mode:$XBD2))]> {
4547   let OpKey = key#"r"#cls;
4548   let OpType = "mem";
4549   let mayLoad = 1;
4550   let Has20BitOffset = 1;
4551   let HasIndex = 1;
4552   let AccessBytes = bytes;
4553 }
4554
4555 // Like UnaryRR, but expanded after RA depending on the choice of registers.
4556 class UnaryRRPseudo<string key, SDPatternOperator operator,
4557                     RegisterOperand cls1, RegisterOperand cls2>
4558   : Pseudo<(outs cls1:$R1), (ins cls2:$R2),
4559            [(set cls1:$R1, (operator cls2:$R2))]> {
4560   let OpKey = key#cls1;
4561   let OpType = "reg";
4562 }
4563
4564 // Like BinaryRI, but expanded after RA depending on the choice of register.
4565 class BinaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4566                      Immediate imm>
4567   : Pseudo<(outs cls:$R1), (ins cls:$R1src, imm:$I2),
4568            [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4569   let Constraints = "$R1 = $R1src";
4570 }
4571
4572 // Like BinaryRIE, but expanded after RA depending on the choice of register.
4573 class BinaryRIEPseudo<SDPatternOperator operator, RegisterOperand cls,
4574                       Immediate imm>
4575   : Pseudo<(outs cls:$R1), (ins cls:$R3, imm:$I2),
4576            [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
4577
4578 // Like BinaryRIAndK, but expanded after RA depending on the choice of register.
4579 multiclass BinaryRIAndKPseudo<string key, SDPatternOperator operator,
4580                               RegisterOperand cls, Immediate imm> {
4581   let NumOpsKey = key in {
4582     let NumOpsValue = "3" in
4583       def K : BinaryRIEPseudo<null_frag, cls, imm>,
4584               Requires<[FeatureHighWord, FeatureDistinctOps]>;
4585     let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
4586       def "" : BinaryRIPseudo<operator, cls, imm>,
4587                Requires<[FeatureHighWord]>;
4588   }
4589 }
4590
4591 // Like CompareRI, but expanded after RA depending on the choice of register.
4592 class CompareRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4593                       Immediate imm>
4594   : Pseudo<(outs), (ins cls:$R1, imm:$I2), [(operator cls:$R1, imm:$I2)]> {
4595   let isCompare = 1;
4596 }
4597
4598 // Like CompareRXY, but expanded after RA depending on the choice of register.
4599 class CompareRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4600                        SDPatternOperator load, bits<5> bytes,
4601                        AddressingMode mode = bdxaddr20only>
4602   : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4603            [(operator cls:$R1, (load mode:$XBD2))]> {
4604   let mayLoad = 1;
4605   let Has20BitOffset = 1;
4606   let HasIndex = 1;
4607   let AccessBytes = bytes;
4608 }
4609
4610 // Like CondBinaryRRF, but expanded after RA depending on the choice of
4611 // register.
4612 class CondBinaryRRFPseudo<RegisterOperand cls1, RegisterOperand cls2>
4613   : Pseudo<(outs cls1:$R1),
4614            (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3), []> {
4615   let Constraints = "$R1 = $R1src";
4616   let DisableEncoding = "$R1src";
4617   let CCMaskLast = 1;
4618 }
4619
4620 // Like CondBinaryRIE, but expanded after RA depending on the choice of
4621 // register.
4622 class CondBinaryRIEPseudo<RegisterOperand cls, Immediate imm>
4623   : Pseudo<(outs cls:$R1),
4624            (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
4625            [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
4626                                            cond4:$valid, cond4:$M3))]> {
4627   let Constraints = "$R1 = $R1src";
4628   let DisableEncoding = "$R1src";
4629   let CCMaskLast = 1;
4630 }
4631
4632 // Like CondUnaryRSY, but expanded after RA depending on the choice of
4633 // register.
4634 class CondUnaryRSYPseudo<SDPatternOperator operator, RegisterOperand cls,
4635                          bits<5> bytes, AddressingMode mode = bdaddr20only>
4636   : Pseudo<(outs cls:$R1),
4637            (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
4638            [(set cls:$R1,
4639                  (z_select_ccmask (operator mode:$BD2), cls:$R1src,
4640                                   cond4:$valid, cond4:$R3))]> {
4641   let Constraints = "$R1 = $R1src";
4642   let DisableEncoding = "$R1src";
4643   let mayLoad = 1;
4644   let AccessBytes = bytes;
4645   let CCMaskLast = 1;
4646 }
4647
4648 // Like CondStoreRSY, but expanded after RA depending on the choice of
4649 // register.
4650 class CondStoreRSYPseudo<RegisterOperand cls, bits<5> bytes,
4651                          AddressingMode mode = bdaddr20only>
4652   : Pseudo<(outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3), []> {
4653   let mayStore = 1;
4654   let AccessBytes = bytes;
4655   let CCMaskLast = 1;
4656 }
4657
4658 // Like StoreRXY, but expanded after RA depending on the choice of register.
4659 class StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4660                      bits<5> bytes, AddressingMode mode = bdxaddr20only>
4661   : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4662            [(operator cls:$R1, mode:$XBD2)]> {
4663   let mayStore = 1;
4664   let Has20BitOffset = 1;
4665   let HasIndex = 1;
4666   let AccessBytes = bytes;
4667 }
4668
4669 // Like RotateSelectRIEf, but expanded after RA depending on the choice
4670 // of registers.
4671 class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>
4672   : Pseudo<(outs cls1:$R1),
4673            (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4674                 imm32zx6:$I5),
4675            []> {
4676   let Constraints = "$R1 = $R1src";
4677   let DisableEncoding = "$R1src";
4678 }
4679
4680 // Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
4681 // the value of the PSW's 2-bit condition code field.
4682 class SelectWrapper<ValueType vt, RegisterOperand cls>
4683   : Pseudo<(outs cls:$dst),
4684            (ins cls:$src1, cls:$src2, imm32zx4:$valid, imm32zx4:$cc),
4685            [(set (vt cls:$dst), (z_select_ccmask cls:$src1, cls:$src2,
4686                                             imm32zx4:$valid, imm32zx4:$cc))]> {
4687   let usesCustomInserter = 1;
4688   // Although the instructions used by these nodes do not in themselves
4689   // change CC, the insertion requires new blocks, and CC cannot be live
4690   // across them.
4691   let Defs = [CC];
4692   let Uses = [CC];
4693 }
4694
4695 // Stores $new to $addr if $cc is true ("" case) or false (Inv case).
4696 multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
4697                       SDPatternOperator load, AddressingMode mode> {
4698   let Defs = [CC], Uses = [CC], usesCustomInserter = 1,
4699       mayLoad = 1, mayStore = 1 in {
4700     def "" : Pseudo<(outs),
4701                     (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4702                     [(store (z_select_ccmask cls:$new, (load mode:$addr),
4703                                              imm32zx4:$valid, imm32zx4:$cc),
4704                             mode:$addr)]>;
4705     def Inv : Pseudo<(outs),
4706                      (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4707                      [(store (z_select_ccmask (load mode:$addr), cls:$new,
4708                                               imm32zx4:$valid, imm32zx4:$cc),
4709                               mode:$addr)]>;
4710   }
4711 }
4712
4713 // OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation.  PAT and OPERAND
4714 // describe the second (non-memory) operand.
4715 class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
4716                        dag pat, DAGOperand operand>
4717   : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
4718            [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
4719   let Defs = [CC];
4720   let Has20BitOffset = 1;
4721   let mayLoad = 1;
4722   let mayStore = 1;
4723   let usesCustomInserter = 1;
4724   let hasNoSchedulingInfo = 1;
4725 }
4726
4727 // Specializations of AtomicLoadWBinary.
4728 class AtomicLoadBinaryReg32<SDPatternOperator operator>
4729   : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
4730 class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
4731   : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
4732 class AtomicLoadBinaryReg64<SDPatternOperator operator>
4733   : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
4734 class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
4735   : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
4736
4737 // OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation.  PAT and OPERAND
4738 // describe the second (non-memory) operand.
4739 class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
4740                         DAGOperand operand>
4741   : Pseudo<(outs GR32:$dst),
4742            (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
4743                 ADDR32:$negbitshift, uimm32:$bitsize),
4744            [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
4745                                       ADDR32:$negbitshift, uimm32:$bitsize))]> {
4746   let Defs = [CC];
4747   let Has20BitOffset = 1;
4748   let mayLoad = 1;
4749   let mayStore = 1;
4750   let usesCustomInserter = 1;
4751   let hasNoSchedulingInfo = 1;
4752 }
4753
4754 // Specializations of AtomicLoadWBinary.
4755 class AtomicLoadWBinaryReg<SDPatternOperator operator>
4756   : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
4757 class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
4758   : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;
4759
4760 // Define an instruction that operates on two fixed-length blocks of memory,
4761 // and associated pseudo instructions for operating on blocks of any size.
4762 // The Sequence form uses a straight-line sequence of instructions and
4763 // the Loop form uses a loop of length-256 instructions followed by
4764 // another instruction to handle the excess.
4765 multiclass MemorySS<string mnemonic, bits<8> opcode,
4766                     SDPatternOperator sequence, SDPatternOperator loop> {
4767   def "" : SideEffectBinarySSa<mnemonic, opcode>;
4768   let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
4769     def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
4770                                        imm64:$length),
4771                            [(sequence bdaddr12only:$dest, bdaddr12only:$src,
4772                                       imm64:$length)]>;
4773     def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
4774                                    imm64:$length, GR64:$count256),
4775                       [(loop bdaddr12only:$dest, bdaddr12only:$src,
4776                              imm64:$length, GR64:$count256)]>;
4777   }
4778 }
4779
4780 // Define an instruction that operates on two strings, both terminated
4781 // by the character in R0.  The instruction processes a CPU-determinated
4782 // number of bytes at a time and sets CC to 3 if the instruction needs
4783 // to be repeated.  Also define a pseudo instruction that represents
4784 // the full loop (the main instruction plus the branch on CC==3).
4785 multiclass StringRRE<string mnemonic, bits<16> opcode,
4786                      SDPatternOperator operator> {
4787   let Uses = [R0L] in
4788     def "" : SideEffectBinaryMemMemRRE<mnemonic, opcode, GR64, GR64>;
4789   let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
4790     def Loop : Pseudo<(outs GR64:$end),
4791                       (ins GR64:$start1, GR64:$start2, GR32:$char),
4792                       [(set GR64:$end, (operator GR64:$start1, GR64:$start2,
4793                                                  GR32:$char))]>;
4794 }
4795
4796 // A pseudo instruction that is a direct alias of a real instruction.
4797 // These aliases are used in cases where a particular register operand is
4798 // fixed or where the same instruction is used with different register sizes.
4799 // The size parameter is the size in bytes of the associated real instruction.
4800 class Alias<int size, dag outs, dag ins, list<dag> pattern>
4801   : InstSystemZ<size, outs, ins, "", pattern> {
4802   let isPseudo = 1;
4803   let isCodeGenOnly = 1;
4804 }
4805
4806 class UnaryAliasVRS<RegisterOperand cls1, RegisterOperand cls2>
4807  : Alias<6, (outs cls1:$src1), (ins cls2:$src2), []>;
4808
4809 // An alias of a UnaryVRR*, but with different register sizes.
4810 class UnaryAliasVRR<SDPatternOperator operator, TypedReg tr1, TypedReg tr2>
4811   : Alias<6, (outs tr1.op:$V1), (ins tr2.op:$V2),
4812           [(set tr1.op:$V1, (tr1.vt (operator (tr2.vt tr2.op:$V2))))]>;
4813
4814 // An alias of a UnaryVRX, but with different register sizes.
4815 class UnaryAliasVRX<SDPatternOperator operator, TypedReg tr,
4816                     AddressingMode mode = bdxaddr12only>
4817   : Alias<6, (outs tr.op:$V1), (ins mode:$XBD2),
4818           [(set tr.op:$V1, (tr.vt (operator mode:$XBD2)))]>;
4819
4820 // An alias of a StoreVRX, but with different register sizes.
4821 class StoreAliasVRX<SDPatternOperator operator, TypedReg tr,
4822                     AddressingMode mode = bdxaddr12only>
4823   : Alias<6, (outs), (ins tr.op:$V1, mode:$XBD2),
4824           [(operator (tr.vt tr.op:$V1), mode:$XBD2)]>;
4825
4826 // An alias of a BinaryRI, but with different register sizes.
4827 class BinaryAliasRI<SDPatternOperator operator, RegisterOperand cls,
4828                     Immediate imm>
4829   : Alias<4, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
4830           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4831   let Constraints = "$R1 = $R1src";
4832 }
4833
4834 // An alias of a BinaryRIL, but with different register sizes.
4835 class BinaryAliasRIL<SDPatternOperator operator, RegisterOperand cls,
4836                      Immediate imm>
4837   : Alias<6, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
4838           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4839   let Constraints = "$R1 = $R1src";
4840 }
4841
4842 // An alias of a BinaryVRRf, but with different register sizes.
4843 class BinaryAliasVRRf<RegisterOperand cls>
4844   : Alias<6, (outs VR128:$V1), (ins cls:$R2, cls:$R3), []>;
4845
4846 // An alias of a CompareRI, but with different register sizes.
4847 class CompareAliasRI<SDPatternOperator operator, RegisterOperand cls,
4848                      Immediate imm>
4849   : Alias<4, (outs), (ins cls:$R1, imm:$I2), [(operator cls:$R1, imm:$I2)]> {
4850   let isCompare = 1;
4851 }
4852
4853 // An alias of a RotateSelectRIEf, but with different register sizes.
4854 class RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>
4855   : Alias<6, (outs cls1:$R1),
4856           (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4857                imm32zx6:$I5), []> {
4858   let Constraints = "$R1 = $R1src";
4859 }