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