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