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
1767//===----------------------------------------------------------------------===//
1768// Variants of instructions with condition mask
1769//===----------------------------------------------------------------------===//
1770//
1771// For instructions using a condition mask (e.g. conditional branches,
1772// compare-and-branch instructions, or conditional move instructions),
1773// we generally need to create multiple instruction patterns:
1774//
1775// - One used for code generation, which encodes the condition mask as an
1776//   MI operand, but writes out an extended mnemonic for better readability.
1777// - One pattern for the base form of the instruction with an explicit
1778//   condition mask (encoded as a plain integer MI operand).
1779// - Specific patterns for each extended mnemonic, where the condition mask
1780//   is implied by the pattern name and not otherwise encoded at all.
1781//
1782// We need the latter primarily for the assembler and disassembler, since the
1783// assembler parser is not able to decode part of an instruction mnemonic
1784// into an operand.  Thus we provide separate patterns for each mnemonic.
1785//
1786// Note that in some cases there are two different mnemonics for the same
1787// condition mask.  In this case we cannot have both instructions available
1788// to the disassembler at the same time since the encodings are not distinct.
1789// Therefore the alternate forms are marked isAsmParserOnly.
1790//
1791// We don't make one of the two names an alias of the other because
1792// we need the custom parsing routines to select the correct register class.
1793//
1794// This section provides helpers for generating the specific forms.
1795//
1796//===----------------------------------------------------------------------===//
1797
1798// A class to describe a variant of an instruction with condition mask.
1799class CondVariant<bits<4> ccmaskin, string suffixin, bit alternatein> {
1800  // The fixed condition mask to use.
1801  bits<4> ccmask = ccmaskin;
1802
1803  // The suffix to use for the extended assembler mnemonic.
1804  string suffix = suffixin;
1805
1806  // Whether this is an alternate that needs to be marked isAsmParserOnly.
1807  bit alternate = alternatein;
1808}
1809
1810// Condition mask 15 means "always true", which is used to define
1811// unconditional branches as a variant of conditional branches.
1812def CondAlways : CondVariant<15, "", 0>;
1813
1814// Condition masks for general instructions that can set all 4 bits.
1815def CondVariantO   : CondVariant<1,  "o",   0>;
1816def CondVariantH   : CondVariant<2,  "h",   0>;
1817def CondVariantP   : CondVariant<2,  "p",   1>;
1818def CondVariantNLE : CondVariant<3,  "nle", 0>;
1819def CondVariantL   : CondVariant<4,  "l",   0>;
1820def CondVariantM   : CondVariant<4,  "m",   1>;
1821def CondVariantNHE : CondVariant<5,  "nhe", 0>;
1822def CondVariantLH  : CondVariant<6,  "lh",  0>;
1823def CondVariantNE  : CondVariant<7,  "ne",  0>;
1824def CondVariantNZ  : CondVariant<7,  "nz",  1>;
1825def CondVariantE   : CondVariant<8,  "e",   0>;
1826def CondVariantZ   : CondVariant<8,  "z",   1>;
1827def CondVariantNLH : CondVariant<9,  "nlh", 0>;
1828def CondVariantHE  : CondVariant<10, "he",  0>;
1829def CondVariantNL  : CondVariant<11, "nl",  0>;
1830def CondVariantNM  : CondVariant<11, "nm",  1>;
1831def CondVariantLE  : CondVariant<12, "le",  0>;
1832def CondVariantNH  : CondVariant<13, "nh",  0>;
1833def CondVariantNP  : CondVariant<13, "np",  1>;
1834def CondVariantNO  : CondVariant<14, "no",  0>;
1835
1836// A helper class to look up one of the above by name.
1837class CV<string name>
1838  : CondVariant<!cast<CondVariant>("CondVariant"#name).ccmask,
1839                !cast<CondVariant>("CondVariant"#name).suffix,
1840                !cast<CondVariant>("CondVariant"#name).alternate>;
1841
1842// Condition masks for integer instructions (e.g. compare-and-branch).
1843// This is like the list above, except that condition 3 is not possible
1844// and that the low bit of the mask is therefore always 0.  This means
1845// that each condition has two names.  Conditions "o" and "no" are not used.
1846def IntCondVariantH   : CondVariant<2,  "h",   0>;
1847def IntCondVariantNLE : CondVariant<2,  "nle", 1>;
1848def IntCondVariantL   : CondVariant<4,  "l",   0>;
1849def IntCondVariantNHE : CondVariant<4,  "nhe", 1>;
1850def IntCondVariantLH  : CondVariant<6,  "lh",  0>;
1851def IntCondVariantNE  : CondVariant<6,  "ne",  1>;
1852def IntCondVariantE   : CondVariant<8,  "e",   0>;
1853def IntCondVariantNLH : CondVariant<8,  "nlh", 1>;
1854def IntCondVariantHE  : CondVariant<10, "he",  0>;
1855def IntCondVariantNL  : CondVariant<10, "nl",  1>;
1856def IntCondVariantLE  : CondVariant<12, "le",  0>;
1857def IntCondVariantNH  : CondVariant<12, "nh",  1>;
1858
1859// A helper class to look up one of the above by name.
1860class ICV<string name>
1861  : CondVariant<!cast<CondVariant>("IntCondVariant"#name).ccmask,
1862                !cast<CondVariant>("IntCondVariant"#name).suffix,
1863                !cast<CondVariant>("IntCondVariant"#name).alternate>;
1864
1865//===----------------------------------------------------------------------===//
1866// Instruction definitions with semantics
1867//===----------------------------------------------------------------------===//
1868//
1869// These classes have the form [Cond]<Category><Format>, where <Format> is one
1870// of the formats defined above and where <Category> describes the inputs
1871// and outputs.  "Cond" is used if the instruction is conditional,
1872// in which case the 4-bit condition-code mask is added as a final operand.
1873// <Category> can be one of:
1874//
1875//   Inherent:
1876//     One register output operand and no input operands.
1877//
1878//   InherentDual:
1879//     Two register output operands and no input operands.
1880//
1881//   StoreInherent:
1882//     One address operand.  The instruction stores to the address.
1883//
1884//   SideEffectInherent:
1885//     No input or output operands, but causes some side effect.
1886//
1887//   Branch:
1888//     One branch target.  The instruction branches to the target.
1889//
1890//   Call:
1891//     One output operand and one branch target.  The instruction stores
1892//     the return address to the output operand and branches to the target.
1893//
1894//   CmpBranch:
1895//     Two input operands and one optional branch target.  The instruction
1896//     compares the two input operands and branches or traps on the result.
1897//
1898//   BranchUnary:
1899//     One register output operand, one register input operand and one branch
1900//     target.  The instructions stores a modified form of the source register
1901//     in the destination register and branches on the result.
1902//
1903//   BranchBinary:
1904//     One register output operand, two register input operands and one branch
1905//     target. The instructions stores a modified form of one of the source
1906//     registers in the destination register and branches on the result.
1907//
1908//   LoadMultiple:
1909//     One address input operand and two explicit output operands.
1910//     The instruction loads a range of registers from the address,
1911//     with the explicit operands giving the first and last register
1912//     to load.  Other loaded registers are added as implicit definitions.
1913//
1914//   StoreMultiple:
1915//     Two explicit input register operands and an address operand.
1916//     The instruction stores a range of registers to the address,
1917//     with the explicit operands giving the first and last register
1918//     to store.  Other stored registers are added as implicit uses.
1919//
1920//   StoreLength:
1921//     One value operand, one length operand and one address operand.
1922//     The instruction stores the value operand to the address but
1923//     doesn't write more than the number of bytes specified by the
1924//     length operand.
1925//
1926//   LoadAddress:
1927//     One register output operand and one address operand.
1928//
1929//   SideEffectAddress:
1930//     One address operand.  No output operands, but causes some side effect.
1931//
1932//   Unary:
1933//     One register output operand and one input operand.
1934//
1935//   Store:
1936//     One address operand and one other input operand.  The instruction
1937//     stores to the address.
1938//
1939//   SideEffectUnary:
1940//     One input operand.  No output operands, but causes some side effect.
1941//
1942//   Binary:
1943//     One register output operand and two input operands.
1944//
1945//   StoreBinary:
1946//     One address operand and two other input operands.  The instruction
1947//     stores to the address.
1948//
1949//   SideEffectBinary:
1950//     Two input operands.  No output operands, but causes some side effect.
1951//
1952//   Compare:
1953//     Two input operands and an implicit CC output operand.
1954//
1955//   Test:
1956//     One or two input operands and an implicit CC output operand.  If
1957//     present, the second input operand is an "address" operand used as
1958//     a test class mask.
1959//
1960//   Ternary:
1961//     One register output operand and three input operands.
1962//
1963//   SideEffectTernary:
1964//     Three input operands.  No output operands, but causes some side effect.
1965//
1966//   Quaternary:
1967//     One register output operand and four input operands.
1968//
1969//   LoadAndOp:
1970//     One output operand and two input operands, one of which is an address.
1971//     The instruction both reads from and writes to the address.
1972//
1973//   CmpSwap:
1974//     One output operand and three input operands, one of which is an address.
1975//     The instruction both reads from and writes to the address.
1976//
1977//   RotateSelect:
1978//     One output operand and five input operands.  The first two operands
1979//     are registers and the other three are immediates.
1980//
1981//   Prefetch:
1982//     One 4-bit immediate operand and one address operand.  The immediate
1983//     operand is 1 for a load prefetch and 2 for a store prefetch.
1984//
1985//   BranchPreload:
1986//     One 4-bit immediate operand and two address operands.
1987//
1988// The format determines which input operands are tied to output operands,
1989// and also determines the shape of any address operand.
1990//
1991// Multiclasses of the form <Category><Format>Pair define two instructions,
1992// one with <Category><Format> and one with <Category><Format>Y.  The name
1993// of the first instruction has no suffix, the name of the second has
1994// an extra "y".
1995//
1996//===----------------------------------------------------------------------===//
1997
1998class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
1999                  SDPatternOperator operator>
2000  : InstRRE<opcode, (outs cls:$R1), (ins),
2001            mnemonic#"\t$R1",
2002            [(set cls:$R1, (operator))]> {
2003  let R2 = 0;
2004}
2005
2006class InherentDualRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
2007  : InstRRE<opcode, (outs cls:$R1, cls:$R2), (ins),
2008            mnemonic#"\t$R1, $R2", []>;
2009
2010class InherentVRIa<string mnemonic, bits<16> opcode, bits<16> value>
2011  : InstVRIa<opcode, (outs VR128:$V1), (ins), mnemonic#"\t$V1", []> {
2012  let I2 = value;
2013  let M3 = 0;
2014}
2015
2016class StoreInherentS<string mnemonic, bits<16> opcode,
2017                     SDPatternOperator operator, bits<5> bytes>
2018  : InstS<opcode, (outs), (ins bdaddr12only:$BD2),
2019          mnemonic#"\t$BD2", [(operator bdaddr12only:$BD2)]> {
2020  let mayStore = 1;
2021  let AccessBytes = bytes;
2022}
2023
2024class SideEffectInherentE<string mnemonic, bits<16>opcode>
2025  : InstE<opcode, (outs), (ins), mnemonic, []>;
2026
2027class SideEffectInherentS<string mnemonic, bits<16> opcode,
2028                          SDPatternOperator operator>
2029  : InstS<opcode, (outs), (ins), mnemonic, [(operator)]> {
2030  let BD2 = 0;
2031}
2032
2033class SideEffectInherentRRE<string mnemonic, bits<16> opcode>
2034  : InstRRE<opcode, (outs), (ins), mnemonic, []> {
2035  let R1 = 0;
2036  let R2 = 0;
2037}
2038
2039// Allow an optional TLS marker symbol to generate TLS call relocations.
2040class CallRI<string mnemonic, bits<12> opcode>
2041  : InstRIb<opcode, (outs), (ins GR64:$R1, brtarget16tls:$RI2),
2042            mnemonic#"\t$R1, $RI2", []>;
2043
2044// Allow an optional TLS marker symbol to generate TLS call relocations.
2045class CallRIL<string mnemonic, bits<12> opcode>
2046  : InstRILb<opcode, (outs), (ins GR64:$R1, brtarget32tls:$RI2),
2047             mnemonic#"\t$R1, $RI2", []>;
2048
2049class CallRR<string mnemonic, bits<8> opcode>
2050  : InstRR<opcode, (outs), (ins GR64:$R1, ADDR64:$R2),
2051           mnemonic#"\t$R1, $R2", []>;
2052
2053class CallRX<string mnemonic, bits<8> opcode>
2054  : InstRXa<opcode, (outs), (ins GR64:$R1, bdxaddr12only:$XBD2),
2055            mnemonic#"\t$R1, $XBD2", []>;
2056
2057class CondBranchRI<string mnemonic, bits<12> opcode,
2058                   SDPatternOperator operator = null_frag>
2059  : InstRIc<opcode, (outs), (ins cond4:$valid, cond4:$M1, brtarget16:$RI2),
2060            !subst("#", "${M1}", mnemonic)#"\t$RI2",
2061            [(operator cond4:$valid, cond4:$M1, bb:$RI2)]> {
2062  let CCMaskFirst = 1;
2063}
2064
2065class AsmCondBranchRI<string mnemonic, bits<12> opcode>
2066  : InstRIc<opcode, (outs), (ins imm32zx4:$M1, brtarget16:$RI2),
2067            mnemonic#"\t$M1, $RI2", []>;
2068
2069class FixedCondBranchRI<CondVariant V, string mnemonic, bits<12> opcode,
2070                        SDPatternOperator operator = null_frag>
2071  : InstRIc<opcode, (outs), (ins brtarget16:$RI2),
2072            !subst("#", V.suffix, mnemonic)#"\t$RI2", [(operator bb:$RI2)]> {
2073  let isAsmParserOnly = V.alternate;
2074  let M1 = V.ccmask;
2075}
2076
2077class CondBranchRIL<string mnemonic, bits<12> opcode>
2078  : InstRILc<opcode, (outs), (ins cond4:$valid, cond4:$M1, brtarget32:$RI2),
2079             !subst("#", "${M1}", mnemonic)#"\t$RI2", []> {
2080  let CCMaskFirst = 1;
2081}
2082
2083class AsmCondBranchRIL<string mnemonic, bits<12> opcode>
2084  : InstRILc<opcode, (outs), (ins imm32zx4:$M1, brtarget32:$RI2),
2085             mnemonic#"\t$M1, $RI2", []>;
2086
2087class FixedCondBranchRIL<CondVariant V, string mnemonic, bits<12> opcode>
2088  : InstRILc<opcode, (outs), (ins brtarget32:$RI2),
2089             !subst("#", V.suffix, mnemonic)#"\t$RI2", []> {
2090  let isAsmParserOnly = V.alternate;
2091  let M1 = V.ccmask;
2092}
2093
2094class CondBranchRR<string mnemonic, bits<8> opcode>
2095  : InstRR<opcode, (outs), (ins cond4:$valid, cond4:$R1, GR64:$R2),
2096           !subst("#", "${R1}", mnemonic)#"\t$R2", []> {
2097  let CCMaskFirst = 1;
2098}
2099
2100class AsmCondBranchRR<string mnemonic, bits<8> opcode>
2101  : InstRR<opcode, (outs), (ins imm32zx4:$R1, GR64:$R2),
2102           mnemonic#"\t$R1, $R2", []>;
2103
2104class FixedCondBranchRR<CondVariant V, string mnemonic, bits<8> opcode,
2105                      SDPatternOperator operator = null_frag>
2106  : InstRR<opcode, (outs), (ins ADDR64:$R2),
2107           !subst("#", V.suffix, mnemonic)#"\t$R2", [(operator ADDR64:$R2)]> {
2108  let isAsmParserOnly = V.alternate;
2109  let R1 = V.ccmask;
2110}
2111
2112class CondBranchRX<string mnemonic, bits<8> opcode>
2113  : InstRXb<opcode, (outs), (ins cond4:$valid, cond4:$M1, bdxaddr12only:$XBD2),
2114            !subst("#", "${M1}", mnemonic)#"\t$XBD2", []> {
2115  let CCMaskFirst = 1;
2116}
2117
2118class AsmCondBranchRX<string mnemonic, bits<8> opcode>
2119  : InstRXb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr12only:$XBD2),
2120            mnemonic#"\t$M1, $XBD2", []>;
2121
2122class FixedCondBranchRX<CondVariant V, string mnemonic, bits<8> opcode>
2123  : InstRXb<opcode, (outs), (ins bdxaddr12only:$XBD2),
2124            !subst("#", V.suffix, mnemonic)#"\t$XBD2", []> {
2125  let isAsmParserOnly = V.alternate;
2126  let M1 = V.ccmask;
2127}
2128
2129class CondBranchRXY<string mnemonic, bits<16> opcode>
2130  : InstRXYb<opcode, (outs), (ins cond4:$valid, cond4:$M1, bdxaddr20only:$XBD2),
2131             !subst("#", "${M1}", mnemonic)#"\t$XBD2", []> {
2132  let CCMaskFirst = 1;
2133  let mayLoad = 1;
2134}
2135
2136class AsmCondBranchRXY<string mnemonic, bits<16> opcode>
2137  : InstRXYb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr20only:$XBD2),
2138             mnemonic#"\t$M1, $XBD2", []> {
2139  let mayLoad = 1;
2140}
2141
2142class FixedCondBranchRXY<CondVariant V, string mnemonic, bits<16> opcode,
2143                         SDPatternOperator operator = null_frag>
2144  : InstRXYb<opcode, (outs), (ins bdxaddr20only:$XBD2),
2145             !subst("#", V.suffix, mnemonic)#"\t$XBD2",
2146             [(operator (load bdxaddr20only:$XBD2))]> {
2147  let isAsmParserOnly = V.alternate;
2148  let M1 = V.ccmask;
2149  let mayLoad = 1;
2150}
2151
2152class CmpBranchRIEa<string mnemonic, bits<16> opcode,
2153                    RegisterOperand cls, ImmOpWithPattern imm>
2154  : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2, cond4:$M3),
2155             mnemonic#"$M3\t$R1, $I2", []>;
2156
2157class AsmCmpBranchRIEa<string mnemonic, bits<16> opcode,
2158                       RegisterOperand cls, ImmOpWithPattern imm>
2159  : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2, imm32zx4:$M3),
2160             mnemonic#"\t$R1, $I2, $M3", []>;
2161
2162class FixedCmpBranchRIEa<CondVariant V, string mnemonic, bits<16> opcode,
2163                          RegisterOperand cls, ImmOpWithPattern imm>
2164  : InstRIEa<opcode, (outs), (ins cls:$R1, imm:$I2),
2165             mnemonic#V.suffix#"\t$R1, $I2", []> {
2166  let isAsmParserOnly = V.alternate;
2167  let M3 = V.ccmask;
2168}
2169
2170multiclass CmpBranchRIEaPair<string mnemonic, bits<16> opcode,
2171                             RegisterOperand cls, ImmOpWithPattern imm> {
2172  let isCodeGenOnly = 1 in
2173    def "" : CmpBranchRIEa<mnemonic, opcode, cls, imm>;
2174  def Asm : AsmCmpBranchRIEa<mnemonic, opcode, cls, imm>;
2175}
2176
2177class CmpBranchRIEb<string mnemonic, bits<16> opcode,
2178                    RegisterOperand cls>
2179  : InstRIEb<opcode, (outs),
2180             (ins cls:$R1, cls:$R2, cond4:$M3, brtarget16:$RI4),
2181             mnemonic#"$M3\t$R1, $R2, $RI4", []>;
2182
2183class AsmCmpBranchRIEb<string mnemonic, bits<16> opcode,
2184                       RegisterOperand cls>
2185  : InstRIEb<opcode, (outs),
2186             (ins cls:$R1, cls:$R2, imm32zx4:$M3, brtarget16:$RI4),
2187             mnemonic#"\t$R1, $R2, $M3, $RI4", []>;
2188
2189class FixedCmpBranchRIEb<CondVariant V, string mnemonic, bits<16> opcode,
2190                         RegisterOperand cls>
2191  : InstRIEb<opcode, (outs), (ins cls:$R1, cls:$R2, brtarget16:$RI4),
2192             mnemonic#V.suffix#"\t$R1, $R2, $RI4", []> {
2193  let isAsmParserOnly = V.alternate;
2194  let M3 = V.ccmask;
2195}
2196
2197multiclass CmpBranchRIEbPair<string mnemonic, bits<16> opcode,
2198                             RegisterOperand cls> {
2199  let isCodeGenOnly = 1 in
2200    def "" : CmpBranchRIEb<mnemonic, opcode, cls>;
2201  def Asm : AsmCmpBranchRIEb<mnemonic, opcode, cls>;
2202}
2203
2204class CmpBranchRIEc<string mnemonic, bits<16> opcode,
2205                    RegisterOperand cls, ImmOpWithPattern imm>
2206  : InstRIEc<opcode, (outs),
2207             (ins cls:$R1, imm:$I2, cond4:$M3, brtarget16:$RI4),
2208             mnemonic#"$M3\t$R1, $I2, $RI4", []>;
2209
2210class AsmCmpBranchRIEc<string mnemonic, bits<16> opcode,
2211                       RegisterOperand cls, ImmOpWithPattern imm>
2212  : InstRIEc<opcode, (outs),
2213             (ins cls:$R1, imm:$I2, imm32zx4:$M3, brtarget16:$RI4),
2214             mnemonic#"\t$R1, $I2, $M3, $RI4", []>;
2215
2216class FixedCmpBranchRIEc<CondVariant V, string mnemonic, bits<16> opcode,
2217                         RegisterOperand cls, ImmOpWithPattern imm>
2218  : InstRIEc<opcode, (outs), (ins cls:$R1, imm:$I2, brtarget16:$RI4),
2219             mnemonic#V.suffix#"\t$R1, $I2, $RI4", []> {
2220  let isAsmParserOnly = V.alternate;
2221  let M3 = V.ccmask;
2222}
2223
2224multiclass CmpBranchRIEcPair<string mnemonic, bits<16> opcode,
2225                            RegisterOperand cls, ImmOpWithPattern imm> {
2226  let isCodeGenOnly = 1 in
2227    def "" : CmpBranchRIEc<mnemonic, opcode, cls, imm>;
2228  def Asm : AsmCmpBranchRIEc<mnemonic, opcode, cls, imm>;
2229}
2230
2231class CmpBranchRRFc<string mnemonic, bits<16> opcode,
2232                    RegisterOperand cls>
2233  : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2, cond4:$M3),
2234             mnemonic#"$M3\t$R1, $R2", []>;
2235
2236class AsmCmpBranchRRFc<string mnemonic, bits<16> opcode,
2237                       RegisterOperand cls>
2238  : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2, imm32zx4:$M3),
2239             mnemonic#"\t$R1, $R2, $M3", []>;
2240
2241multiclass CmpBranchRRFcPair<string mnemonic, bits<16> opcode,
2242                             RegisterOperand cls> {
2243  let isCodeGenOnly = 1 in
2244    def "" : CmpBranchRRFc<mnemonic, opcode, cls>;
2245  def Asm : AsmCmpBranchRRFc<mnemonic, opcode, cls>;
2246}
2247
2248class FixedCmpBranchRRFc<CondVariant V, string mnemonic, bits<16> opcode,
2249                          RegisterOperand cls>
2250  : InstRRFc<opcode, (outs), (ins cls:$R1, cls:$R2),
2251             mnemonic#V.suffix#"\t$R1, $R2", []> {
2252  let isAsmParserOnly = V.alternate;
2253  let M3 = V.ccmask;
2254}
2255
2256class CmpBranchRRS<string mnemonic, bits<16> opcode,
2257                   RegisterOperand cls>
2258  : InstRRS<opcode, (outs),
2259            (ins cls:$R1, cls:$R2, cond4:$M3, bdaddr12only:$BD4),
2260            mnemonic#"$M3\t$R1, $R2, $BD4", []>;
2261
2262class AsmCmpBranchRRS<string mnemonic, bits<16> opcode,
2263                      RegisterOperand cls>
2264  : InstRRS<opcode, (outs),
2265            (ins cls:$R1, cls:$R2, imm32zx4:$M3, bdaddr12only:$BD4),
2266            mnemonic#"\t$R1, $R2, $M3, $BD4", []>;
2267
2268class FixedCmpBranchRRS<CondVariant V, string mnemonic, bits<16> opcode,
2269                        RegisterOperand cls>
2270  : InstRRS<opcode, (outs), (ins cls:$R1, cls:$R2, bdaddr12only:$BD4),
2271            mnemonic#V.suffix#"\t$R1, $R2, $BD4", []> {
2272  let isAsmParserOnly = V.alternate;
2273  let M3 = V.ccmask;
2274}
2275
2276multiclass CmpBranchRRSPair<string mnemonic, bits<16> opcode,
2277                            RegisterOperand cls> {
2278  let isCodeGenOnly = 1 in
2279    def "" : CmpBranchRRS<mnemonic, opcode, cls>;
2280  def Asm : AsmCmpBranchRRS<mnemonic, opcode, cls>;
2281}
2282
2283class CmpBranchRIS<string mnemonic, bits<16> opcode,
2284                   RegisterOperand cls, ImmOpWithPattern imm>
2285  : InstRIS<opcode, (outs),
2286            (ins cls:$R1, imm:$I2, cond4:$M3, bdaddr12only:$BD4),
2287            mnemonic#"$M3\t$R1, $I2, $BD4", []>;
2288
2289class AsmCmpBranchRIS<string mnemonic, bits<16> opcode,
2290                      RegisterOperand cls, ImmOpWithPattern imm>
2291  : InstRIS<opcode, (outs),
2292            (ins cls:$R1, imm:$I2, imm32zx4:$M3, bdaddr12only:$BD4),
2293            mnemonic#"\t$R1, $I2, $M3, $BD4", []>;
2294
2295class FixedCmpBranchRIS<CondVariant V, string mnemonic, bits<16> opcode,
2296                        RegisterOperand cls, ImmOpWithPattern imm>
2297  : InstRIS<opcode, (outs), (ins cls:$R1, imm:$I2, bdaddr12only:$BD4),
2298            mnemonic#V.suffix#"\t$R1, $I2, $BD4", []> {
2299  let isAsmParserOnly = V.alternate;
2300  let M3 = V.ccmask;
2301}
2302
2303multiclass CmpBranchRISPair<string mnemonic, bits<16> opcode,
2304                            RegisterOperand cls, ImmOpWithPattern imm> {
2305  let isCodeGenOnly = 1 in
2306    def "" : CmpBranchRIS<mnemonic, opcode, cls, imm>;
2307  def Asm : AsmCmpBranchRIS<mnemonic, opcode, cls, imm>;
2308}
2309
2310class CmpBranchRSYb<string mnemonic, bits<16> opcode,
2311                    RegisterOperand cls>
2312  : InstRSYb<opcode, (outs), (ins cls:$R1, bdaddr20only:$BD2, cond4:$M3),
2313             mnemonic#"$M3\t$R1, $BD2", []>;
2314
2315class AsmCmpBranchRSYb<string mnemonic, bits<16> opcode,
2316                       RegisterOperand cls>
2317  : InstRSYb<opcode, (outs), (ins cls:$R1, bdaddr20only:$BD2, imm32zx4:$M3),
2318             mnemonic#"\t$R1, $M3, $BD2", []>;
2319
2320multiclass CmpBranchRSYbPair<string mnemonic, bits<16> opcode,
2321                             RegisterOperand cls> {
2322  let isCodeGenOnly = 1 in
2323    def "" : CmpBranchRSYb<mnemonic, opcode, cls>;
2324  def Asm : AsmCmpBranchRSYb<mnemonic, opcode, cls>;
2325}
2326
2327class FixedCmpBranchRSYb<CondVariant V, string mnemonic, bits<16> opcode,
2328                          RegisterOperand cls>
2329  : InstRSYb<opcode, (outs), (ins cls:$R1, bdaddr20only:$BD2),
2330             mnemonic#V.suffix#"\t$R1, $BD2", []> {
2331  let isAsmParserOnly = V.alternate;
2332  let M3 = V.ccmask;
2333}
2334
2335class BranchUnaryRI<string mnemonic, bits<12> opcode, RegisterOperand cls>
2336  : InstRIb<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget16:$RI2),
2337            mnemonic##"\t$R1, $RI2", []> {
2338  let Constraints = "$R1 = $R1src";
2339  let DisableEncoding = "$R1src";
2340}
2341
2342class BranchUnaryRIL<string mnemonic, bits<12> opcode, RegisterOperand cls>
2343  : InstRILb<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget32:$RI2),
2344             mnemonic##"\t$R1, $RI2", []> {
2345  let Constraints = "$R1 = $R1src";
2346  let DisableEncoding = "$R1src";
2347}
2348
2349class BranchUnaryRR<string mnemonic, bits<8> opcode, RegisterOperand cls>
2350  : InstRR<opcode, (outs cls:$R1), (ins cls:$R1src, GR64:$R2),
2351           mnemonic##"\t$R1, $R2", []> {
2352  let Constraints = "$R1 = $R1src";
2353  let DisableEncoding = "$R1src";
2354}
2355
2356class BranchUnaryRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
2357  : InstRRE<opcode, (outs cls:$R1), (ins cls:$R1src, GR64:$R2),
2358            mnemonic##"\t$R1, $R2", []> {
2359  let Constraints = "$R1 = $R1src";
2360  let DisableEncoding = "$R1src";
2361}
2362
2363class BranchUnaryRX<string mnemonic, bits<8> opcode, RegisterOperand cls>
2364  : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
2365            mnemonic##"\t$R1, $XBD2", []> {
2366  let Constraints = "$R1 = $R1src";
2367  let DisableEncoding = "$R1src";
2368}
2369
2370class BranchUnaryRXY<string mnemonic, bits<16> opcode, RegisterOperand cls>
2371  : InstRXYa<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr20only:$XBD2),
2372             mnemonic##"\t$R1, $XBD2", []> {
2373  let Constraints = "$R1 = $R1src";
2374  let DisableEncoding = "$R1src";
2375}
2376
2377class BranchBinaryRSI<string mnemonic, bits<8> opcode, RegisterOperand cls>
2378  : InstRSI<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, brtarget16:$RI2),
2379            mnemonic##"\t$R1, $R3, $RI2", []> {
2380  let Constraints = "$R1 = $R1src";
2381  let DisableEncoding = "$R1src";
2382}
2383
2384class BranchBinaryRIEe<string mnemonic, bits<16> opcode, RegisterOperand cls>
2385  : InstRIEe<opcode, (outs cls:$R1),
2386             (ins cls:$R1src, cls:$R3, brtarget16:$RI2),
2387             mnemonic##"\t$R1, $R3, $RI2", []> {
2388  let Constraints = "$R1 = $R1src";
2389  let DisableEncoding = "$R1src";
2390}
2391
2392class BranchBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls>
2393  : InstRSa<opcode, (outs cls:$R1),
2394            (ins cls:$R1src, cls:$R3, bdaddr12only:$BD2),
2395            mnemonic##"\t$R1, $R3, $BD2", []> {
2396  let Constraints = "$R1 = $R1src";
2397  let DisableEncoding = "$R1src";
2398}
2399
2400class BranchBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
2401  : InstRSYa<opcode,
2402             (outs cls:$R1), (ins cls:$R1src, cls:$R3, bdaddr20only:$BD2),
2403             mnemonic##"\t$R1, $R3, $BD2", []> {
2404  let Constraints = "$R1 = $R1src";
2405  let DisableEncoding = "$R1src";
2406}
2407
2408class LoadMultipleRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
2409                     AddressingMode mode = bdaddr12only>
2410  : InstRSa<opcode, (outs cls:$R1, cls:$R3), (ins mode:$BD2),
2411            mnemonic#"\t$R1, $R3, $BD2", []> {
2412  let mayLoad = 1;
2413}
2414
2415class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
2416                      AddressingMode mode = bdaddr20only>
2417  : InstRSYa<opcode, (outs cls:$R1, cls:$R3), (ins mode:$BD2),
2418             mnemonic#"\t$R1, $R3, $BD2", []> {
2419  let mayLoad = 1;
2420}
2421
2422multiclass LoadMultipleRSPair<string mnemonic, bits<8> rsOpcode,
2423                              bits<16> rsyOpcode, RegisterOperand cls> {
2424  let DispKey = mnemonic ## #cls in {
2425    let DispSize = "12" in
2426      def "" : LoadMultipleRS<mnemonic, rsOpcode, cls, bdaddr12pair>;
2427    let DispSize = "20" in
2428      def Y  : LoadMultipleRSY<mnemonic#"y", rsyOpcode, cls, bdaddr20pair>;
2429  }
2430}
2431
2432class LoadMultipleSSe<string mnemonic, bits<8> opcode, RegisterOperand cls>
2433  : InstSSe<opcode, (outs cls:$R1, cls:$R3),
2434            (ins bdaddr12only:$BD2, bdaddr12only:$BD4),
2435            mnemonic#"\t$R1, $R3, $BD2, $BD4", []> {
2436  let mayLoad = 1;
2437}
2438
2439multiclass LoadMultipleVRSaAlign<string mnemonic, bits<16> opcode> {
2440  let mayLoad = 1 in {
2441    def Align : InstVRSa<opcode, (outs VR128:$V1, VR128:$V3),
2442                        (ins bdaddr12only:$BD2, imm32zx4:$M4),
2443                        mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
2444    let M4 = 0 in
2445      def "" : InstVRSa<opcode, (outs VR128:$V1, VR128:$V3),
2446                        (ins bdaddr12only:$BD2),
2447                        mnemonic#"\t$V1, $V3, $BD2", []>;
2448  }
2449}
2450
2451class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2452                 RegisterOperand cls>
2453  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
2454             mnemonic#"\t$R1, $RI2",
2455             [(operator cls:$R1, pcrel32:$RI2)]> {
2456  let mayStore = 1;
2457  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
2458  // However, BDXs have two extra operands and are therefore 6 units more
2459  // complex.
2460  let AddedComplexity = 7;
2461}
2462
2463class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2464              RegisterOperand cls, bits<5> bytes,
2465              AddressingMode mode = bdxaddr12only>
2466  : InstRXa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
2467            mnemonic#"\t$R1, $XBD2",
2468            [(operator cls:$R1, mode:$XBD2)]> {
2469  let OpKey = mnemonic#"r"#cls;
2470  let OpType = "mem";
2471  let mayStore = 1;
2472  let AccessBytes = bytes;
2473}
2474
2475class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2476               RegisterOperand cls, bits<5> bytes,
2477               AddressingMode mode = bdxaddr20only>
2478  : InstRXYa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
2479             mnemonic#"\t$R1, $XBD2",
2480             [(operator cls:$R1, mode:$XBD2)]> {
2481  let OpKey = mnemonic#"r"#cls;
2482  let OpType = "mem";
2483  let mayStore = 1;
2484  let AccessBytes = bytes;
2485}
2486
2487multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
2488                       SDPatternOperator operator, RegisterOperand cls,
2489                       bits<5> bytes> {
2490  let DispKey = mnemonic ## #cls in {
2491    let DispSize = "12" in
2492      def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
2493    let DispSize = "20" in
2494      def Y  : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
2495                        bdxaddr20pair>;
2496  }
2497}
2498
2499class StoreVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2500               TypedReg tr, bits<5> bytes, bits<4> type = 0>
2501  : InstVRX<opcode, (outs), (ins tr.op:$V1, bdxaddr12only:$XBD2),
2502            mnemonic#"\t$V1, $XBD2",
2503            [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2)]> {
2504  let M3 = type;
2505  let mayStore = 1;
2506  let AccessBytes = bytes;
2507}
2508
2509class StoreVRXGeneric<string mnemonic, bits<16> opcode>
2510  : InstVRX<opcode, (outs), (ins VR128:$V1, bdxaddr12only:$XBD2, imm32zx4:$M3),
2511            mnemonic#"\t$V1, $XBD2, $M3", []> {
2512  let mayStore = 1;
2513}
2514
2515multiclass StoreVRXAlign<string mnemonic, bits<16> opcode> {
2516  let mayStore = 1, AccessBytes = 16 in {
2517    def Align : InstVRX<opcode, (outs),
2518                        (ins VR128:$V1, bdxaddr12only:$XBD2, imm32zx4:$M3),
2519                        mnemonic#"\t$V1, $XBD2, $M3", []>;
2520    let M3 = 0 in
2521      def "" : InstVRX<opcode, (outs), (ins VR128:$V1, bdxaddr12only:$XBD2),
2522                       mnemonic#"\t$V1, $XBD2", []>;
2523  }
2524}
2525
2526class StoreLengthVRSb<string mnemonic, bits<16> opcode,
2527                      SDPatternOperator operator, bits<5> bytes>
2528  : InstVRSb<opcode, (outs), (ins VR128:$V1, GR32:$R3, bdaddr12only:$BD2),
2529             mnemonic#"\t$V1, $R3, $BD2",
2530             [(operator VR128:$V1, GR32:$R3, bdaddr12only:$BD2)]> {
2531  let M4 = 0;
2532  let mayStore = 1;
2533  let AccessBytes = bytes;
2534}
2535
2536class StoreLengthVRSd<string mnemonic, bits<16> opcode,
2537                      SDPatternOperator operator, bits<5> bytes>
2538  : InstVRSd<opcode, (outs), (ins VR128:$V1, GR32:$R3, bdaddr12only:$BD2),
2539             mnemonic#"\t$V1, $R3, $BD2",
2540             [(operator VR128:$V1, GR32:$R3, bdaddr12only:$BD2)]> {
2541  let mayStore = 1;
2542  let AccessBytes = bytes;
2543}
2544
2545class StoreLengthVSI<string mnemonic, bits<16> opcode,
2546                     SDPatternOperator operator, bits<5> bytes>
2547  : InstVSI<opcode, (outs), (ins VR128:$V1, bdaddr12only:$BD2, imm32zx8:$I3),
2548            mnemonic#"\t$V1, $BD2, $I3",
2549            [(operator VR128:$V1, imm32zx8:$I3, bdaddr12only:$BD2)]> {
2550  let mayStore = 1;
2551  let AccessBytes = bytes;
2552}
2553
2554class StoreMultipleRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
2555                      AddressingMode mode = bdaddr12only>
2556  : InstRSa<opcode, (outs), (ins cls:$R1, cls:$R3, mode:$BD2),
2557            mnemonic#"\t$R1, $R3, $BD2", []> {
2558  let mayStore = 1;
2559}
2560
2561class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
2562                       AddressingMode mode = bdaddr20only>
2563  : InstRSYa<opcode, (outs), (ins cls:$R1, cls:$R3, mode:$BD2),
2564             mnemonic#"\t$R1, $R3, $BD2", []> {
2565  let mayStore = 1;
2566}
2567
2568multiclass StoreMultipleRSPair<string mnemonic, bits<8> rsOpcode,
2569                               bits<16> rsyOpcode, RegisterOperand cls> {
2570  let DispKey = mnemonic ## #cls in {
2571    let DispSize = "12" in
2572      def "" : StoreMultipleRS<mnemonic, rsOpcode, cls, bdaddr12pair>;
2573    let DispSize = "20" in
2574      def Y  : StoreMultipleRSY<mnemonic#"y", rsyOpcode, cls, bdaddr20pair>;
2575  }
2576}
2577
2578multiclass StoreMultipleVRSaAlign<string mnemonic, bits<16> opcode> {
2579  let mayStore = 1 in {
2580    def Align : InstVRSa<opcode, (outs), (ins VR128:$V1, VR128:$V3,
2581                                              bdaddr12only:$BD2, imm32zx4:$M4),
2582                         mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
2583    let M4 = 0 in
2584      def "" : InstVRSa<opcode, (outs), (ins VR128:$V1, VR128:$V3,
2585                                             bdaddr12only:$BD2),
2586                        mnemonic#"\t$V1, $V3, $BD2", []>;
2587  }
2588}
2589
2590// StoreSI* instructions are used to store an integer to memory, but the
2591// addresses are more restricted than for normal stores.  If we are in the
2592// situation of having to force either the address into a register or the
2593// constant into a register, it's usually better to do the latter.
2594// We therefore match the address in the same way as a normal store and
2595// only use the StoreSI* instruction if the matched address is suitable.
2596class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2597              ImmOpWithPattern imm>
2598  : InstSI<opcode, (outs), (ins mviaddr12pair:$BD1, imm:$I2),
2599           mnemonic#"\t$BD1, $I2",
2600           [(operator imm:$I2, mviaddr12pair:$BD1)]> {
2601  let mayStore = 1;
2602}
2603
2604class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2605               ImmOpWithPattern imm>
2606  : InstSIY<opcode, (outs), (ins mviaddr20pair:$BD1, imm:$I2),
2607            mnemonic#"\t$BD1, $I2",
2608            [(operator imm:$I2, mviaddr20pair:$BD1)]> {
2609  let mayStore = 1;
2610}
2611
2612class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2613               ImmOpWithPattern imm>
2614  : InstSIL<opcode, (outs), (ins mviaddr12pair:$BD1, imm:$I2),
2615            mnemonic#"\t$BD1, $I2",
2616            [(operator imm:$I2, mviaddr12pair:$BD1)]> {
2617  let mayStore = 1;
2618}
2619
2620multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
2621                       SDPatternOperator operator, ImmOpWithPattern imm> {
2622  let DispKey = mnemonic in {
2623    let DispSize = "12" in
2624      def "" : StoreSI<mnemonic, siOpcode, operator, imm>;
2625    let DispSize = "20" in
2626      def Y  : StoreSIY<mnemonic#"y", siyOpcode, operator, imm>;
2627  }
2628}
2629
2630class StoreSSE<string mnemonic, bits<16> opcode>
2631  : InstSSE<opcode, (outs), (ins bdaddr12only:$BD1, bdaddr12only:$BD2),
2632            mnemonic#"\t$BD1, $BD2", []> {
2633  let mayStore = 1;
2634}
2635
2636class CondStoreRSY<string mnemonic, bits<16> opcode,
2637                   RegisterOperand cls, bits<5> bytes,
2638                   AddressingMode mode = bdaddr20only>
2639  : InstRSYb<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$M3),
2640            mnemonic#"$M3\t$R1, $BD2", []> {
2641  let mayStore = 1;
2642  let AccessBytes = bytes;
2643  let CCMaskLast = 1;
2644}
2645
2646// Like CondStoreRSY, but used for the raw assembly form.  The condition-code
2647// mask is the third operand rather than being part of the mnemonic.
2648class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
2649                      RegisterOperand cls, bits<5> bytes,
2650                      AddressingMode mode = bdaddr20only>
2651  : InstRSYb<opcode, (outs), (ins cls:$R1, mode:$BD2, imm32zx4:$M3),
2652             mnemonic#"\t$R1, $BD2, $M3", []> {
2653  let mayStore = 1;
2654  let AccessBytes = bytes;
2655}
2656
2657// Like CondStoreRSY, but with a fixed CC mask.
2658class FixedCondStoreRSY<CondVariant V, string mnemonic, bits<16> opcode,
2659                        RegisterOperand cls, bits<5> bytes,
2660                        AddressingMode mode = bdaddr20only>
2661  : InstRSYb<opcode, (outs), (ins cls:$R1, mode:$BD2),
2662             mnemonic#V.suffix#"\t$R1, $BD2", []> {
2663  let mayStore = 1;
2664  let AccessBytes = bytes;
2665  let isAsmParserOnly = V.alternate;
2666  let M3 = V.ccmask;
2667}
2668
2669multiclass CondStoreRSYPair<string mnemonic, bits<16> opcode,
2670                            RegisterOperand cls, bits<5> bytes,
2671                            AddressingMode mode = bdaddr20only> {
2672  let isCodeGenOnly = 1 in
2673    def "" : CondStoreRSY<mnemonic, opcode, cls, bytes, mode>;
2674  def Asm : AsmCondStoreRSY<mnemonic, opcode, cls, bytes, mode>;
2675}
2676
2677class SideEffectUnaryI<string mnemonic, bits<8> opcode, ImmOpWithPattern imm>
2678  : InstI<opcode, (outs), (ins imm:$I1),
2679          mnemonic#"\t$I1", []>;
2680
2681class SideEffectUnaryRR<string mnemonic, bits<8>opcode, RegisterOperand cls>
2682  : InstRR<opcode, (outs), (ins cls:$R1),
2683           mnemonic#"\t$R1", []> {
2684  let R2 = 0;
2685}
2686
2687class SideEffectUnaryRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
2688                         SDPatternOperator operator>
2689  : InstRRE<opcode, (outs), (ins cls:$R1),
2690            mnemonic#"\t$R1", [(operator cls:$R1)]> {
2691  let R2 = 0;
2692}
2693
2694class SideEffectUnaryS<string mnemonic, bits<16> opcode,
2695                       SDPatternOperator operator, bits<5> bytes,
2696                       AddressingMode mode = bdaddr12only>
2697  : InstS<opcode, (outs), (ins mode:$BD2),
2698          mnemonic#"\t$BD2", [(operator mode:$BD2)]> {
2699  let mayLoad = 1;
2700  let AccessBytes = bytes;
2701}
2702
2703class SideEffectAddressS<string mnemonic, bits<16> opcode,
2704                        SDPatternOperator operator,
2705                        AddressingMode mode = bdaddr12only>
2706  : InstS<opcode, (outs), (ins mode:$BD2),
2707          mnemonic#"\t$BD2", [(operator mode:$BD2)]>;
2708
2709class LoadAddressRX<string mnemonic, bits<8> opcode,
2710                    SDPatternOperator operator, AddressingMode mode>
2711  : InstRXa<opcode, (outs GR64:$R1), (ins mode:$XBD2),
2712            mnemonic#"\t$R1, $XBD2",
2713            [(set GR64:$R1, (operator mode:$XBD2))]>;
2714
2715class LoadAddressRXY<string mnemonic, bits<16> opcode,
2716                     SDPatternOperator operator, AddressingMode mode>
2717  : InstRXYa<opcode, (outs GR64:$R1), (ins mode:$XBD2),
2718             mnemonic#"\t$R1, $XBD2",
2719             [(set GR64:$R1, (operator mode:$XBD2))]>;
2720
2721multiclass LoadAddressRXPair<string mnemonic, bits<8> rxOpcode,
2722                             bits<16> rxyOpcode, SDPatternOperator operator> {
2723  let DispKey = mnemonic in {
2724    let DispSize = "12" in
2725      def "" : LoadAddressRX<mnemonic, rxOpcode, operator, laaddr12pair>;
2726    let DispSize = "20" in
2727      def Y  : LoadAddressRXY<mnemonic#"y", rxyOpcode, operator, laaddr20pair>;
2728  }
2729}
2730
2731class LoadAddressRIL<string mnemonic, bits<12> opcode,
2732                     SDPatternOperator operator>
2733  : InstRILb<opcode, (outs GR64:$R1), (ins pcrel32:$RI2),
2734             mnemonic#"\t$R1, $RI2",
2735             [(set GR64:$R1, (operator pcrel32:$RI2))]>;
2736
2737class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2738              RegisterOperand cls1, RegisterOperand cls2>
2739  : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
2740           mnemonic#"\t$R1, $R2",
2741           [(set cls1:$R1, (operator cls2:$R2))]> {
2742  let OpKey = mnemonic#cls1;
2743  let OpType = "reg";
2744}
2745
2746class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2747               RegisterOperand cls1, RegisterOperand cls2>
2748  : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
2749            mnemonic#"\t$R1, $R2",
2750            [(set cls1:$R1, (operator cls2:$R2))]> {
2751  let OpKey = mnemonic#cls1;
2752  let OpType = "reg";
2753}
2754
2755class UnaryTiedRRE<string mnemonic, bits<16> opcode, RegisterOperand cls>
2756  : InstRRE<opcode, (outs cls:$R1), (ins cls:$R1src),
2757            mnemonic#"\t$R1", []> {
2758  let Constraints = "$R1 = $R1src";
2759  let DisableEncoding = "$R1src";
2760  let R2 = 0;
2761}
2762
2763class UnaryMemRRFc<string mnemonic, bits<16> opcode,
2764                   RegisterOperand cls1, RegisterOperand cls2>
2765  : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src),
2766            mnemonic#"\t$R1, $R2", []> {
2767  let Constraints = "$R1 = $R1src";
2768  let DisableEncoding = "$R1src";
2769  let M3 = 0;
2770}
2771
2772class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2773              RegisterOperand cls, ImmOpWithPattern imm>
2774  : InstRIa<opcode, (outs cls:$R1), (ins imm:$I2),
2775            mnemonic#"\t$R1, $I2",
2776            [(set cls:$R1, (operator imm:$I2))]>;
2777
2778class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2779               RegisterOperand cls, ImmOpWithPattern imm>
2780  : InstRILa<opcode, (outs cls:$R1), (ins imm:$I2),
2781             mnemonic#"\t$R1, $I2",
2782             [(set cls:$R1, (operator imm:$I2))]>;
2783
2784class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
2785                 RegisterOperand cls>
2786  : InstRILb<opcode, (outs cls:$R1), (ins pcrel32:$RI2),
2787             mnemonic#"\t$R1, $RI2",
2788             [(set cls:$R1, (operator pcrel32:$RI2))]> {
2789  let mayLoad = 1;
2790  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
2791  // However, BDXs have two extra operands and are therefore 6 units more
2792  // complex.
2793  let AddedComplexity = 7;
2794}
2795
2796class CondUnaryRSY<string mnemonic, bits<16> opcode,
2797                   SDPatternOperator operator, RegisterOperand cls,
2798                   bits<5> bytes, AddressingMode mode = bdaddr20only>
2799  : InstRSYb<opcode, (outs cls:$R1),
2800             (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$M3),
2801             mnemonic#"$M3\t$R1, $BD2",
2802             [(set cls:$R1,
2803                   (z_select_ccmask (operator bdaddr20only:$BD2), cls:$R1src,
2804                                    cond4:$valid, cond4:$M3))]> {
2805  let Constraints = "$R1 = $R1src";
2806  let DisableEncoding = "$R1src";
2807  let mayLoad = 1;
2808  let AccessBytes = bytes;
2809  let CCMaskLast = 1;
2810  let OpKey = mnemonic#"r"#cls;
2811  let OpType = "mem";
2812  let MemKey = mnemonic#cls;
2813  let MemType = "target";
2814}
2815
2816// Like CondUnaryRSY, but used for the raw assembly form.  The condition-code
2817// mask is the third operand rather than being part of the mnemonic.
2818class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
2819                      RegisterOperand cls, bits<5> bytes,
2820                      AddressingMode mode = bdaddr20only>
2821  : InstRSYb<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, imm32zx4:$M3),
2822             mnemonic#"\t$R1, $BD2, $M3", []> {
2823  let mayLoad = 1;
2824  let AccessBytes = bytes;
2825  let Constraints = "$R1 = $R1src";
2826  let DisableEncoding = "$R1src";
2827}
2828
2829// Like CondUnaryRSY, but with a fixed CC mask.
2830class FixedCondUnaryRSY<CondVariant V, string mnemonic, bits<16> opcode,
2831                        RegisterOperand cls, bits<5> bytes,
2832                        AddressingMode mode = bdaddr20only>
2833  : InstRSYb<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
2834             mnemonic#V.suffix#"\t$R1, $BD2", []> {
2835  let Constraints = "$R1 = $R1src";
2836  let DisableEncoding = "$R1src";
2837  let mayLoad = 1;
2838  let AccessBytes = bytes;
2839  let isAsmParserOnly = V.alternate;
2840  let M3 = V.ccmask;
2841}
2842
2843multiclass CondUnaryRSYPair<string mnemonic, bits<16> opcode,
2844                            SDPatternOperator operator,
2845                            RegisterOperand cls, bits<5> bytes,
2846                            AddressingMode mode = bdaddr20only> {
2847  let isCodeGenOnly = 1 in
2848    def "" : CondUnaryRSY<mnemonic, opcode, operator, cls, bytes, mode>;
2849  def Asm : AsmCondUnaryRSY<mnemonic, opcode, cls, bytes, mode>;
2850}
2851
2852class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
2853              RegisterOperand cls, bits<5> bytes,
2854              AddressingMode mode = bdxaddr12only>
2855  : InstRXa<opcode, (outs cls:$R1), (ins mode:$XBD2),
2856            mnemonic#"\t$R1, $XBD2",
2857            [(set cls:$R1, (operator mode:$XBD2))]> {
2858  let OpKey = mnemonic#"r"#cls;
2859  let OpType = "mem";
2860  let mayLoad = 1;
2861  let AccessBytes = bytes;
2862}
2863
2864class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2865               RegisterOperand cls, bits<5> bytes>
2866  : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
2867            mnemonic#"\t$R1, $XBD2",
2868            [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
2869  let OpKey = mnemonic#"r"#cls;
2870  let OpType = "mem";
2871  let mayLoad = 1;
2872  let AccessBytes = bytes;
2873  let M3 = 0;
2874}
2875
2876class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2877               RegisterOperand cls, bits<5> bytes,
2878               AddressingMode mode = bdxaddr20only>
2879  : InstRXYa<opcode, (outs cls:$R1), (ins mode:$XBD2),
2880             mnemonic#"\t$R1, $XBD2",
2881             [(set cls:$R1, (operator mode:$XBD2))]> {
2882  let OpKey = mnemonic#"r"#cls;
2883  let OpType = "mem";
2884  let mayLoad = 1;
2885  let AccessBytes = bytes;
2886}
2887
2888multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
2889                       SDPatternOperator operator, RegisterOperand cls,
2890                       bits<5> bytes> {
2891  let DispKey = mnemonic ## #cls in {
2892    let DispSize = "12" in
2893      def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
2894    let DispSize = "20" in
2895      def Y  : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
2896                        bdxaddr20pair>;
2897  }
2898}
2899
2900class UnaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2901                TypedReg tr, ImmOpWithPattern imm, bits<4> type = 0>
2902  : InstVRIa<opcode, (outs tr.op:$V1), (ins imm:$I2),
2903             mnemonic#"\t$V1, $I2",
2904             [(set (tr.vt tr.op:$V1), (operator (i32 timm:$I2)))]> {
2905  let M3 = type;
2906}
2907
2908class UnaryVRIaGeneric<string mnemonic, bits<16> opcode, ImmOpWithPattern imm>
2909  : InstVRIa<opcode, (outs VR128:$V1), (ins imm:$I2, imm32zx4:$M3),
2910             mnemonic#"\t$V1, $I2, $M3", []>;
2911
2912class UnaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2913                TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0,
2914                bits<4> m5 = 0>
2915  : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2),
2916             mnemonic#"\t$V1, $V2",
2917             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]> {
2918  let M3 = type;
2919  let M4 = m4;
2920  let M5 = m5;
2921}
2922
2923class UnaryVRRaGeneric<string mnemonic, bits<16> opcode, bits<4> m4 = 0,
2924                       bits<4> m5 = 0>
2925  : InstVRRa<opcode, (outs VR128:$V1), (ins VR128:$V2, imm32zx4:$M3),
2926             mnemonic#"\t$V1, $V2, $M3", []> {
2927  let M4 = m4;
2928  let M5 = m5;
2929}
2930
2931class UnaryVRRaFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0>
2932  : InstVRRa<opcode, (outs VR128:$V1),
2933             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4),
2934             mnemonic#"\t$V1, $V2, $M3, $M4", []> {
2935  let M5 = m5;
2936}
2937
2938// Declare a pair of instructions, one which sets CC and one which doesn't.
2939// The CC-setting form ends with "S" and sets the low bit of M5.
2940// The form that does not set CC has an extra operand to optionally allow
2941// specifying arbitrary M5 values in assembler.
2942multiclass UnaryExtraVRRaSPair<string mnemonic, bits<16> opcode,
2943                               SDPatternOperator operator,
2944                               SDPatternOperator operator_cc,
2945                               TypedReg tr1, TypedReg tr2, bits<4> type> {
2946  let M3 = type, M4 = 0 in
2947    def "" : InstVRRa<opcode, (outs tr1.op:$V1),
2948                      (ins tr2.op:$V2, imm32zx4:$M5),
2949                      mnemonic#"\t$V1, $V2, $M5", []>;
2950  def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2))),
2951            (!cast<Instruction>(NAME) tr2.op:$V2, 0)>;
2952  def : InstAlias<mnemonic#"\t$V1, $V2",
2953                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2, 0)>;
2954  let Defs = [CC] in
2955    def S : UnaryVRRa<mnemonic##"s", opcode, operator_cc, tr1, tr2,
2956                      type, 0, 1>;
2957}
2958
2959multiclass UnaryExtraVRRaSPairGeneric<string mnemonic, bits<16> opcode> {
2960  let M4 = 0, Defs = [CC] in
2961    def "" : InstVRRa<opcode, (outs VR128:$V1),
2962                     (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M5),
2963                     mnemonic#"\t$V1, $V2, $M3, $M5", []>;
2964  def : InstAlias<mnemonic#"\t$V1, $V2, $M3",
2965                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2,
2966                                            imm32zx4:$M3, 0)>;
2967}
2968
2969class UnaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2970               TypedReg tr, bits<5> bytes, bits<4> type = 0>
2971  : InstVRX<opcode, (outs tr.op:$V1), (ins bdxaddr12only:$XBD2),
2972            mnemonic#"\t$V1, $XBD2",
2973            [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2))]> {
2974  let M3 = type;
2975  let mayLoad = 1;
2976  let AccessBytes = bytes;
2977}
2978
2979class UnaryVRXGeneric<string mnemonic, bits<16> opcode>
2980  : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
2981            mnemonic#"\t$V1, $XBD2, $M3", []> {
2982  let mayLoad = 1;
2983}
2984
2985multiclass UnaryVRXAlign<string mnemonic, bits<16> opcode> {
2986  let mayLoad = 1, AccessBytes = 16 in {
2987    def Align : InstVRX<opcode, (outs VR128:$V1),
2988                        (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
2989                        mnemonic#"\t$V1, $XBD2, $M3", []>;
2990    let M3 = 0 in
2991      def "" : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2),
2992                       mnemonic#"\t$V1, $XBD2", []>;
2993  }
2994}
2995
2996class SideEffectBinaryRX<string mnemonic, bits<8> opcode,
2997                         RegisterOperand cls>
2998  : InstRXa<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
2999            mnemonic##"\t$R1, $XBD2", []>;
3000
3001class SideEffectBinaryRXY<string mnemonic, bits<16> opcode,
3002                          RegisterOperand cls>
3003  : InstRXYa<opcode, (outs), (ins cls:$R1, bdxaddr20only:$XBD2),
3004             mnemonic##"\t$R1, $XBD2", []>;
3005
3006class SideEffectBinaryRILPC<string mnemonic, bits<12> opcode,
3007                            RegisterOperand cls>
3008  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
3009             mnemonic##"\t$R1, $RI2", []> {
3010  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
3011  // However, BDXs have two extra operands and are therefore 6 units more
3012  // complex.
3013  let AddedComplexity = 7;
3014}
3015
3016class SideEffectBinaryRRE<string mnemonic, bits<16> opcode,
3017                          RegisterOperand cls1, RegisterOperand cls2>
3018  : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3019            mnemonic#"\t$R1, $R2", []>;
3020
3021class SideEffectBinaryRRFa<string mnemonic, bits<16> opcode,
3022                           RegisterOperand cls1, RegisterOperand cls2>
3023  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3024             mnemonic#"\t$R1, $R2", []> {
3025  let R3 = 0;
3026  let M4 = 0;
3027}
3028
3029class SideEffectBinaryRRFc<string mnemonic, bits<16> opcode,
3030                           RegisterOperand cls1, RegisterOperand cls2>
3031  : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3032             mnemonic#"\t$R1, $R2", []> {
3033  let M3 = 0;
3034}
3035
3036class SideEffectBinaryIE<string mnemonic, bits<16> opcode,
3037                         ImmOpWithPattern imm1, ImmOpWithPattern imm2>
3038  : InstIE<opcode, (outs), (ins imm1:$I1, imm2:$I2),
3039           mnemonic#"\t$I1, $I2", []>;
3040
3041class SideEffectBinarySI<string mnemonic, bits<8> opcode, Operand imm>
3042  : InstSI<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3043           mnemonic#"\t$BD1, $I2", []>;
3044
3045class SideEffectBinarySIL<string mnemonic, bits<16> opcode,
3046                          SDPatternOperator operator, ImmOpWithPattern imm>
3047  : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3048            mnemonic#"\t$BD1, $I2", [(operator bdaddr12only:$BD1, imm:$I2)]>;
3049
3050class SideEffectBinarySSa<string mnemonic, bits<8> opcode>
3051  : InstSSa<opcode, (outs), (ins bdladdr12onlylen8:$BDL1, bdaddr12only:$BD2),
3052            mnemonic##"\t$BDL1, $BD2", []>;
3053
3054class SideEffectBinarySSb<string mnemonic, bits<8> opcode>
3055  : InstSSb<opcode,
3056            (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
3057            mnemonic##"\t$BDL1, $BDL2", []>;
3058
3059class SideEffectBinarySSf<string mnemonic, bits<8> opcode>
3060  : InstSSf<opcode, (outs), (ins bdaddr12only:$BD1, bdladdr12onlylen8:$BDL2),
3061            mnemonic##"\t$BD1, $BDL2", []>;
3062
3063class SideEffectBinarySSE<string mnemonic, bits<16> opcode>
3064  : InstSSE<opcode, (outs), (ins bdaddr12only:$BD1, bdaddr12only:$BD2),
3065            mnemonic#"\t$BD1, $BD2", []>;
3066
3067class SideEffectBinaryMemMemRR<string mnemonic, bits<8> opcode,
3068                               RegisterOperand cls1, RegisterOperand cls2>
3069  : InstRR<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3070           mnemonic#"\t$R1, $R2", []> {
3071    let Constraints = "$R1 = $R1src, $R2 = $R2src";
3072    let DisableEncoding = "$R1src, $R2src";
3073}
3074
3075class SideEffectBinaryMemRRE<string mnemonic, bits<16> opcode,
3076                             RegisterOperand cls1, RegisterOperand cls2>
3077  : InstRRE<opcode, (outs cls2:$R2), (ins cls1:$R1, cls2:$R2src),
3078            mnemonic#"\t$R1, $R2", []> {
3079  let Constraints = "$R2 = $R2src";
3080  let DisableEncoding = "$R2src";
3081}
3082
3083class SideEffectBinaryMemMemRRE<string mnemonic, bits<16> opcode,
3084                                RegisterOperand cls1, RegisterOperand cls2>
3085  : InstRRE<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3086            mnemonic#"\t$R1, $R2", []> {
3087    let Constraints = "$R1 = $R1src, $R2 = $R2src";
3088    let DisableEncoding = "$R1src, $R2src";
3089}
3090
3091class SideEffectBinaryMemMemRRFc<string mnemonic, bits<16> opcode,
3092                                 RegisterOperand cls1, RegisterOperand cls2>
3093  : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3094             mnemonic#"\t$R1, $R2", []> {
3095  let Constraints = "$R1 = $R1src, $R2 = $R2src";
3096  let DisableEncoding = "$R1src, $R2src";
3097  let M3 = 0;
3098}
3099
3100class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3101               RegisterOperand cls1, RegisterOperand cls2>
3102  : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3103           mnemonic#"\t$R1, $R2",
3104           [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
3105  let OpKey = mnemonic#cls1;
3106  let OpType = "reg";
3107  let Constraints = "$R1 = $R1src";
3108  let DisableEncoding = "$R1src";
3109}
3110
3111class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3112                RegisterOperand cls1, RegisterOperand cls2>
3113  : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3114            mnemonic#"\t$R1, $R2",
3115            [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
3116  let OpKey = mnemonic#cls1;
3117  let OpType = "reg";
3118  let Constraints = "$R1 = $R1src";
3119  let DisableEncoding = "$R1src";
3120}
3121
3122class BinaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3123                RegisterOperand cls1, RegisterOperand cls2>
3124  : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R3, cls2:$R2),
3125            mnemonic#"\t$R1, $R3, $R2",
3126            [(set cls1:$R1, (operator cls2:$R3, cls2:$R2))]> {
3127  let OpKey = mnemonic#cls;
3128  let OpType = "reg";
3129}
3130
3131class BinaryRRFa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3132                 RegisterOperand cls1, RegisterOperand cls2,
3133                 RegisterOperand cls3>
3134  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
3135             mnemonic#"\t$R1, $R2, $R3",
3136             [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
3137  let M4 = 0;
3138  let OpKey = mnemonic#cls1;
3139  let OpType = "reg";
3140}
3141
3142multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3143                        SDPatternOperator operator, RegisterOperand cls1,
3144                        RegisterOperand cls2> {
3145  let NumOpsKey = mnemonic in {
3146    let NumOpsValue = "3" in
3147      def K : BinaryRRFa<mnemonic#"k", opcode2, operator, cls1, cls1, cls2>,
3148              Requires<[FeatureDistinctOps]>;
3149    let NumOpsValue = "2" in
3150      def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
3151  }
3152}
3153
3154multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
3155                         SDPatternOperator operator, RegisterOperand cls1,
3156                         RegisterOperand cls2> {
3157  let NumOpsKey = mnemonic in {
3158    let NumOpsValue = "3" in
3159      def K : BinaryRRFa<mnemonic#"k", opcode2, operator, cls1, cls1, cls2>,
3160              Requires<[FeatureDistinctOps]>;
3161    let NumOpsValue = "2" in
3162      def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
3163  }
3164}
3165
3166class BinaryRRFb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3167                 RegisterOperand cls1, RegisterOperand cls2,
3168                 RegisterOperand cls3>
3169  : InstRRFb<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
3170             mnemonic#"\t$R1, $R3, $R2",
3171             [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
3172  let M4 = 0;
3173}
3174
3175class BinaryRRFc<string mnemonic, bits<16> opcode,
3176                 RegisterOperand cls1, RegisterOperand cls2>
3177  : InstRRFc<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M3),
3178             mnemonic#"\t$R1, $R2, $M3", []>;
3179
3180class BinaryMemRRFc<string mnemonic, bits<16> opcode,
3181                    RegisterOperand cls1, RegisterOperand cls2, ImmOpWithPattern imm>
3182  : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src, imm:$M3),
3183            mnemonic#"\t$R1, $R2, $M3", []> {
3184  let Constraints = "$R1 = $R1src";
3185  let DisableEncoding = "$R1src";
3186}
3187
3188multiclass BinaryMemRRFcOpt<string mnemonic, bits<16> opcode,
3189                            RegisterOperand cls1, RegisterOperand cls2> {
3190  def "" : BinaryMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3191  def Opt : UnaryMemRRFc<mnemonic, opcode, cls1, cls2>;
3192}
3193
3194class BinaryRRFd<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3195                RegisterOperand cls2>
3196  : InstRRFd<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M4),
3197             mnemonic#"\t$R1, $R2, $M4", []>;
3198
3199class BinaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3200                RegisterOperand cls2>
3201  : InstRRFe<opcode, (outs cls1:$R1), (ins imm32zx4:$M3, cls2:$R2),
3202             mnemonic#"\t$R1, $M3, $R2", []> {
3203  let M4 = 0;
3204}
3205
3206class CondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3207                   RegisterOperand cls2>
3208  : InstRRFc<opcode, (outs cls1:$R1),
3209             (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
3210             mnemonic#"$M3\t$R1, $R2",
3211             [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
3212                                              cond4:$valid, cond4:$M3))]> {
3213  let Constraints = "$R1 = $R1src";
3214  let DisableEncoding = "$R1src";
3215  let CCMaskLast = 1;
3216  let NumOpsKey = !subst("loc", "sel", mnemonic);
3217  let NumOpsValue = "2";
3218  let OpKey = mnemonic#cls1;
3219  let OpType = "reg";
3220}
3221
3222// Like CondBinaryRRF, but used for the raw assembly form.  The condition-code
3223// mask is the third operand rather than being part of the mnemonic.
3224class AsmCondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3225                       RegisterOperand cls2>
3226  : InstRRFc<opcode, (outs cls1:$R1),
3227             (ins cls1:$R1src, cls2:$R2, imm32zx4:$M3),
3228             mnemonic#"\t$R1, $R2, $M3", []> {
3229  let Constraints = "$R1 = $R1src";
3230  let DisableEncoding = "$R1src";
3231}
3232
3233// Like CondBinaryRRF, but with a fixed CC mask.
3234class FixedCondBinaryRRF<CondVariant V, string mnemonic, bits<16> opcode,
3235                         RegisterOperand cls1, RegisterOperand cls2>
3236  : InstRRFc<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3237             mnemonic#V.suffix#"\t$R1, $R2", []> {
3238  let Constraints = "$R1 = $R1src";
3239  let DisableEncoding = "$R1src";
3240  let isAsmParserOnly = V.alternate;
3241  let M3 = V.ccmask;
3242}
3243
3244multiclass CondBinaryRRFPair<string mnemonic, bits<16> opcode,
3245                             RegisterOperand cls1, RegisterOperand cls2> {
3246  let isCodeGenOnly = 1 in
3247    def "" : CondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3248  def Asm : AsmCondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3249}
3250
3251class CondBinaryRRFa<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3252                    RegisterOperand cls2, RegisterOperand cls3>
3253  : InstRRFa<opcode, (outs cls1:$R1),
3254             (ins cls3:$R3, cls2:$R2, cond4:$valid, cond4:$M4),
3255             mnemonic#"$M4\t$R1, $R2, $R3",
3256             [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls3:$R3,
3257                                              cond4:$valid, cond4:$M4))]> {
3258  let CCMaskLast = 1;
3259  let NumOpsKey = mnemonic;
3260  let NumOpsValue = "3";
3261  let OpKey = mnemonic#cls1;
3262  let OpType = "reg";
3263}
3264
3265// Like CondBinaryRRFa, but used for the raw assembly form.  The condition-code
3266// mask is the third operand rather than being part of the mnemonic.
3267class AsmCondBinaryRRFa<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3268                        RegisterOperand cls2, RegisterOperand cls3>
3269  : InstRRFa<opcode, (outs cls1:$R1), (ins cls3:$R3, cls2:$R2, imm32zx4:$M4),
3270             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
3271
3272// Like CondBinaryRRFa, but with a fixed CC mask.
3273class FixedCondBinaryRRFa<CondVariant V, string mnemonic, bits<16> opcode,
3274                         RegisterOperand cls1, RegisterOperand cls2,
3275                         RegisterOperand cls3>
3276  : InstRRFa<opcode, (outs cls1:$R1), (ins cls3:$R3, cls2:$R2),
3277             mnemonic#V.suffix#"\t$R1, $R2, $R3", []> {
3278  let isAsmParserOnly = V.alternate;
3279  let M4 = V.ccmask;
3280}
3281
3282multiclass CondBinaryRRFaPair<string mnemonic, bits<16> opcode,
3283                             RegisterOperand cls1, RegisterOperand cls2,
3284                             RegisterOperand cls3> {
3285  let isCodeGenOnly = 1 in
3286    def "" : CondBinaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
3287  def Asm : AsmCondBinaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
3288}
3289
3290class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3291               RegisterOperand cls, ImmOpWithPattern imm>
3292  : InstRIa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3293            mnemonic#"\t$R1, $I2",
3294            [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3295  let Constraints = "$R1 = $R1src";
3296  let DisableEncoding = "$R1src";
3297}
3298
3299class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3300                RegisterOperand cls, ImmOpWithPattern imm>
3301  : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
3302             mnemonic#"\t$R1, $R3, $I2",
3303             [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
3304
3305multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
3306                        SDPatternOperator operator, RegisterOperand cls,
3307                        ImmOpWithPattern imm> {
3308  let NumOpsKey = mnemonic in {
3309    let NumOpsValue = "3" in
3310      def K : BinaryRIE<mnemonic##"k", opcode2, operator, cls, imm>,
3311              Requires<[FeatureDistinctOps]>;
3312    let NumOpsValue = "2" in
3313      def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
3314  }
3315}
3316
3317class CondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3318                    ImmOpWithPattern imm>
3319  : InstRIEg<opcode, (outs cls:$R1),
3320             (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
3321             mnemonic#"$M3\t$R1, $I2",
3322             [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
3323                                             cond4:$valid, cond4:$M3))]> {
3324  let Constraints = "$R1 = $R1src";
3325  let DisableEncoding = "$R1src";
3326  let CCMaskLast = 1;
3327}
3328
3329// Like CondBinaryRIE, but used for the raw assembly form.  The condition-code
3330// mask is the third operand rather than being part of the mnemonic.
3331class AsmCondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3332                       ImmOpWithPattern imm>
3333  : InstRIEg<opcode, (outs cls:$R1),
3334             (ins cls:$R1src, imm:$I2, imm32zx4:$M3),
3335             mnemonic#"\t$R1, $I2, $M3", []> {
3336  let Constraints = "$R1 = $R1src";
3337  let DisableEncoding = "$R1src";
3338}
3339
3340// Like CondBinaryRIE, but with a fixed CC mask.
3341class FixedCondBinaryRIE<CondVariant V, string mnemonic, bits<16> opcode,
3342                         RegisterOperand cls, ImmOpWithPattern imm>
3343  : InstRIEg<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3344             mnemonic#V.suffix#"\t$R1, $I2", []> {
3345  let Constraints = "$R1 = $R1src";
3346  let DisableEncoding = "$R1src";
3347  let isAsmParserOnly = V.alternate;
3348  let M3 = V.ccmask;
3349}
3350
3351multiclass CondBinaryRIEPair<string mnemonic, bits<16> opcode,
3352                             RegisterOperand cls, ImmOpWithPattern imm> {
3353  let isCodeGenOnly = 1 in
3354    def "" : CondBinaryRIE<mnemonic, opcode, cls, imm>;
3355  def Asm : AsmCondBinaryRIE<mnemonic, opcode, cls, imm>;
3356}
3357
3358class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3359                RegisterOperand cls, ImmOpWithPattern imm>
3360  : InstRILa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3361             mnemonic#"\t$R1, $I2",
3362             [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3363  let Constraints = "$R1 = $R1src";
3364  let DisableEncoding = "$R1src";
3365}
3366
3367class BinaryRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3368               RegisterOperand cls>
3369  : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
3370            mnemonic#"\t$R1, $BD2",
3371            [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
3372  let R3 = 0;
3373  let Constraints = "$R1 = $R1src";
3374  let DisableEncoding = "$R1src";
3375}
3376
3377class BinaryRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3378                RegisterOperand cls>
3379  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
3380             mnemonic#"\t$R1, $R3, $BD2",
3381             [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
3382
3383multiclass BinaryRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3384                        SDPatternOperator operator, RegisterOperand cls> {
3385  let NumOpsKey = mnemonic in {
3386    let NumOpsValue = "3" in
3387      def K  : BinaryRSY<mnemonic##"k", opcode2, operator, cls>,
3388               Requires<[FeatureDistinctOps]>;
3389    let NumOpsValue = "2" in
3390      def "" : BinaryRS<mnemonic, opcode1, operator, cls>;
3391  }
3392}
3393
3394class BinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3395  : InstRSLb<opcode, (outs cls:$R1),
3396             (ins bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3397             mnemonic#"\t$R1, $BDL2, $M3", []> {
3398  let mayLoad = 1;
3399}
3400
3401class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3402               RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3403               AddressingMode mode = bdxaddr12only>
3404  : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3405            mnemonic#"\t$R1, $XBD2",
3406            [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3407  let OpKey = mnemonic#"r"#cls;
3408  let OpType = "mem";
3409  let Constraints = "$R1 = $R1src";
3410  let DisableEncoding = "$R1src";
3411  let mayLoad = 1;
3412  let AccessBytes = bytes;
3413}
3414
3415class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3416                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3417  : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
3418            mnemonic#"\t$R1, $XBD2",
3419            [(set cls:$R1, (operator cls:$R1src,
3420                                     (load bdxaddr12only:$XBD2)))]> {
3421  let OpKey = mnemonic#"r"#cls;
3422  let OpType = "mem";
3423  let Constraints = "$R1 = $R1src";
3424  let DisableEncoding = "$R1src";
3425  let mayLoad = 1;
3426  let AccessBytes = bytes;
3427  let M3 = 0;
3428}
3429
3430class BinaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3431                RegisterOperand cls1, RegisterOperand cls2,
3432                SDPatternOperator load, bits<5> bytes>
3433  : InstRXF<opcode, (outs cls1:$R1), (ins cls2:$R3, bdxaddr12only:$XBD2),
3434            mnemonic#"\t$R1, $R3, $XBD2",
3435            [(set cls1:$R1, (operator cls2:$R3, (load bdxaddr12only:$XBD2)))]> {
3436  let OpKey = mnemonic#"r"#cls;
3437  let OpType = "mem";
3438  let mayLoad = 1;
3439  let AccessBytes = bytes;
3440}
3441
3442class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3443                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3444                AddressingMode mode = bdxaddr20only>
3445  : InstRXYa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3446             mnemonic#"\t$R1, $XBD2",
3447             [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3448  let OpKey = mnemonic#"r"#cls;
3449  let OpType = "mem";
3450  let Constraints = "$R1 = $R1src";
3451  let DisableEncoding = "$R1src";
3452  let mayLoad = 1;
3453  let AccessBytes = bytes;
3454}
3455
3456multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3457                        SDPatternOperator operator, RegisterOperand cls,
3458                        SDPatternOperator load, bits<5> bytes> {
3459  let DispKey = mnemonic ## #cls in {
3460    let DispSize = "12" in
3461      def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
3462                        bdxaddr12pair>;
3463    let DispSize = "20" in
3464      def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
3465                         bdxaddr20pair>;
3466  }
3467}
3468
3469class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3470               Operand imm, AddressingMode mode = bdaddr12only>
3471  : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3472           mnemonic#"\t$BD1, $I2",
3473           [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3474  let mayLoad = 1;
3475  let mayStore = 1;
3476}
3477
3478class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3479                Operand imm, AddressingMode mode = bdaddr20only>
3480  : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3481            mnemonic#"\t$BD1, $I2",
3482            [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3483  let mayLoad = 1;
3484  let mayStore = 1;
3485}
3486
3487multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
3488                        bits<16> siyOpcode, SDPatternOperator operator,
3489                        Operand imm> {
3490  let DispKey = mnemonic ## #cls in {
3491    let DispSize = "12" in
3492      def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
3493    let DispSize = "20" in
3494      def Y  : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
3495  }
3496}
3497
3498class BinarySSF<string mnemonic, bits<12> opcode, RegisterOperand cls>
3499  : InstSSF<opcode, (outs cls:$R3), (ins bdaddr12pair:$BD1, bdaddr12pair:$BD2),
3500            mnemonic#"\t$R3, $BD1, $BD2", []> {
3501  let mayLoad = 1;
3502}
3503
3504class BinaryVRIb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3505                 TypedReg tr, bits<4> type>
3506  : InstVRIb<opcode, (outs tr.op:$V1), (ins imm32zx8:$I2, imm32zx8:$I3),
3507             mnemonic#"\t$V1, $I2, $I3",
3508             [(set (tr.vt tr.op:$V1), (operator imm32zx8_timm:$I2, imm32zx8_timm:$I3))]> {
3509  let M4 = type;
3510}
3511
3512class BinaryVRIbGeneric<string mnemonic, bits<16> opcode>
3513  : InstVRIb<opcode, (outs VR128:$V1),
3514             (ins imm32zx8:$I2, imm32zx8:$I3, imm32zx4:$M4),
3515             mnemonic#"\t$V1, $I2, $I3, $M4", []>;
3516
3517class BinaryVRIc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3518                 TypedReg tr1, TypedReg tr2, bits<4> type>
3519  : InstVRIc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, imm32zx16:$I2),
3520             mnemonic#"\t$V1, $V3, $I2",
3521             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
3522                                                  imm32zx16_timm:$I2))]> {
3523  let M4 = type;
3524}
3525
3526class BinaryVRIcGeneric<string mnemonic, bits<16> opcode>
3527  : InstVRIc<opcode, (outs VR128:$V1),
3528             (ins VR128:$V3, imm32zx16:$I2, imm32zx4:$M4),
3529             mnemonic#"\t$V1, $V3, $I2, $M4", []>;
3530
3531class BinaryVRIe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3532                 TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m5>
3533  : InstVRIe<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx12:$I3),
3534             mnemonic#"\t$V1, $V2, $I3",
3535             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3536                                                  imm32zx12_timm:$I3))]> {
3537  let M4 = type;
3538  let M5 = m5;
3539}
3540
3541class BinaryVRIeFloatGeneric<string mnemonic, bits<16> opcode>
3542  : InstVRIe<opcode, (outs VR128:$V1),
3543             (ins VR128:$V2, imm32zx12:$I3, imm32zx4:$M4, imm32zx4:$M5),
3544             mnemonic#"\t$V1, $V2, $I3, $M4, $M5", []>;
3545
3546class BinaryVRIh<string mnemonic, bits<16> opcode>
3547  : InstVRIh<opcode, (outs VR128:$V1),
3548             (ins imm32zx16:$I2, imm32zx4:$I3),
3549             mnemonic#"\t$V1, $I2, $I3", []>;
3550
3551class BinaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3552                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0>
3553  : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx4:$M5),
3554             mnemonic#"\t$V1, $V2, $M5",
3555             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3556                                                  imm32zx12:$M5))]> {
3557  let M3 = type;
3558  let M4 = m4;
3559}
3560
3561class BinaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
3562  : InstVRRa<opcode, (outs VR128:$V1),
3563             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
3564             mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
3565
3566class BinaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3567                 TypedReg tr1, TypedReg tr2, bits<4> type = 0,
3568                 bits<4> modifier = 0>
3569  : InstVRRb<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3570             mnemonic#"\t$V1, $V2, $V3",
3571             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3572                                                  (tr2.vt tr2.op:$V3)))]> {
3573  let M4 = type;
3574  let M5 = modifier;
3575}
3576
3577// Declare a pair of instructions, one which sets CC and one which doesn't.
3578// The CC-setting form ends with "S" and sets the low bit of M5.
3579multiclass BinaryVRRbSPair<string mnemonic, bits<16> opcode,
3580                           SDPatternOperator operator,
3581                           SDPatternOperator operator_cc, TypedReg tr1,
3582                           TypedReg tr2, bits<4> type, bits<4> modifier = 0> {
3583  def "" : BinaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
3584                      !and (modifier, 14)>;
3585  let Defs = [CC] in
3586    def S : BinaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
3587                       !add (!and (modifier, 14), 1)>;
3588}
3589
3590class BinaryVRRbSPairGeneric<string mnemonic, bits<16> opcode>
3591  : InstVRRb<opcode, (outs VR128:$V1),
3592             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3593             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3594  let Defs = [CC];
3595}
3596
3597// Declare a pair of instructions, one which sets CC and one which doesn't.
3598// The CC-setting form ends with "S" and sets the low bit of M5.
3599// The form that does not set CC has an extra operand to optionally allow
3600// specifying arbitrary M5 values in assembler.
3601multiclass BinaryExtraVRRbSPair<string mnemonic, bits<16> opcode,
3602                                SDPatternOperator operator,
3603                                SDPatternOperator operator_cc,
3604                                TypedReg tr1, TypedReg tr2, bits<4> type> {
3605  let M4 = type in
3606    def "" : InstVRRb<opcode, (outs tr1.op:$V1),
3607                      (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M5),
3608                      mnemonic#"\t$V1, $V2, $V3, $M5", []>;
3609  def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3))),
3610            (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, 0)>;
3611  def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
3612                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
3613                                            tr2.op:$V3, 0)>;
3614  let Defs = [CC] in
3615    def S : BinaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type, 1>;
3616}
3617
3618multiclass BinaryExtraVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
3619  let Defs = [CC] in
3620    def "" : InstVRRb<opcode, (outs VR128:$V1),
3621                     (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3622                     mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
3623  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
3624                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
3625                                            imm32zx4:$M4, 0)>;
3626}
3627
3628class BinaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3629                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m5 = 0,
3630                 bits<4> m6 = 0>
3631  : InstVRRc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3632             mnemonic#"\t$V1, $V2, $V3",
3633             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3634                                                  (tr2.vt tr2.op:$V3)))]> {
3635  let M4 = type;
3636  let M5 = m5;
3637  let M6 = m6;
3638}
3639
3640class BinaryVRRcGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0,
3641                        bits<4> m6 = 0>
3642  : InstVRRc<opcode, (outs VR128:$V1),
3643             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4),
3644             mnemonic#"\t$V1, $V2, $V3, $M4", []> {
3645  let M5 = m5;
3646  let M6 = m6;
3647}
3648
3649class BinaryVRRcFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m6 = 0>
3650  : InstVRRc<opcode, (outs VR128:$V1),
3651             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3652             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3653  let M6 = m6;
3654}
3655
3656// Declare a pair of instructions, one which sets CC and one which doesn't.
3657// The CC-setting form ends with "S" and sets the low bit of M5.
3658multiclass BinaryVRRcSPair<string mnemonic, bits<16> opcode,
3659                           SDPatternOperator operator,
3660                           SDPatternOperator operator_cc, TypedReg tr1,
3661                           TypedReg tr2, bits<4> type, bits<4> m5,
3662                           bits<4> modifier = 0> {
3663  def "" : BinaryVRRc<mnemonic, opcode, operator, tr1, tr2, type,
3664                      m5, !and (modifier, 14)>;
3665  let Defs = [CC] in
3666    def S : BinaryVRRc<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
3667                       m5, !add (!and (modifier, 14), 1)>;
3668}
3669
3670class BinaryVRRcSPairFloatGeneric<string mnemonic, bits<16> opcode>
3671  : InstVRRc<opcode, (outs VR128:$V1),
3672             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
3673                  imm32zx4:$M6),
3674             mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
3675
3676class BinaryVRRf<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3677                 TypedReg tr>
3678  : InstVRRf<opcode, (outs tr.op:$V1), (ins GR64:$R2, GR64:$R3),
3679             mnemonic#"\t$V1, $R2, $R3",
3680             [(set (tr.vt tr.op:$V1), (operator GR64:$R2, GR64:$R3))]>;
3681
3682class BinaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
3683  : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2, imm32zx4:$M3),
3684             mnemonic#"\t$R1, $V2, $M3", []> {
3685  let M4 = 0;
3686}
3687
3688class BinaryVRSa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3689                 TypedReg tr1, TypedReg tr2, bits<4> type>
3690  : InstVRSa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, shift12only:$BD2),
3691             mnemonic#"\t$V1, $V3, $BD2",
3692             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
3693                                                  shift12only:$BD2))]> {
3694  let M4 = type;
3695}
3696
3697class BinaryVRSaGeneric<string mnemonic, bits<16> opcode>
3698  : InstVRSa<opcode, (outs VR128:$V1),
3699             (ins VR128:$V3, shift12only:$BD2, imm32zx4:$M4),
3700             mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
3701
3702class BinaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3703                 bits<5> bytes>
3704  : InstVRSb<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3705             mnemonic#"\t$V1, $R3, $BD2",
3706             [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3707  let M4 = 0;
3708  let mayLoad = 1;
3709  let AccessBytes = bytes;
3710}
3711
3712class BinaryVRSc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3713                 TypedReg tr, bits<4> type>
3714  : InstVRSc<opcode, (outs GR64:$R1), (ins tr.op:$V3, shift12only:$BD2),
3715           mnemonic#"\t$R1, $V3, $BD2",
3716           [(set GR64:$R1, (operator (tr.vt tr.op:$V3), shift12only:$BD2))]> {
3717  let M4 = type;
3718}
3719
3720class BinaryVRScGeneric<string mnemonic, bits<16> opcode>
3721  : InstVRSc<opcode, (outs GR64:$R1),
3722             (ins VR128:$V3, shift12only:$BD2, imm32zx4: $M4),
3723             mnemonic#"\t$R1, $V3, $BD2, $M4", []>;
3724
3725class BinaryVRSd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3726                 bits<5> bytes>
3727  : InstVRSd<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3728             mnemonic#"\t$V1, $R3, $BD2",
3729             [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3730  let mayLoad = 1;
3731  let AccessBytes = bytes;
3732}
3733
3734class BinaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3735                TypedReg tr, bits<5> bytes>
3736  : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
3737            mnemonic#"\t$V1, $XBD2, $M3",
3738            [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2,
3739                                               imm32zx4_timm:$M3))]> {
3740  let mayLoad = 1;
3741  let AccessBytes = bytes;
3742}
3743
3744class StoreBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3745                    bits<5> bytes, AddressingMode mode = bdaddr12only>
3746  : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3747            mnemonic#"\t$R1, $M3, $BD2", []> {
3748  let mayStore = 1;
3749  let AccessBytes = bytes;
3750}
3751
3752class StoreBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3753                     bits<5> bytes, AddressingMode mode = bdaddr20only>
3754  : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3755             mnemonic#"\t$R1, $M3, $BD2", []> {
3756  let mayStore = 1;
3757  let AccessBytes = bytes;
3758}
3759
3760multiclass StoreBinaryRSPair<string mnemonic, bits<8> rsOpcode,
3761                             bits<16> rsyOpcode, RegisterOperand cls,
3762                             bits<5> bytes> {
3763  let DispKey = mnemonic ## #cls in {
3764    let DispSize = "12" in
3765      def "" : StoreBinaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3766    let DispSize = "20" in
3767      def Y  : StoreBinaryRSY<mnemonic#"y", rsyOpcode, cls, bytes,
3768                              bdaddr20pair>;
3769  }
3770}
3771
3772class StoreBinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3773  : InstRSLb<opcode, (outs),
3774             (ins cls:$R1, bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3775             mnemonic#"\t$R1, $BDL2, $M3", []> {
3776  let mayStore = 1;
3777}
3778
3779class BinaryVSI<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3780                bits<5> bytes>
3781  : InstVSI<opcode, (outs VR128:$V1), (ins bdaddr12only:$BD2, imm32zx8:$I3),
3782            mnemonic#"\t$V1, $BD2, $I3",
3783            [(set VR128:$V1, (operator imm32zx8:$I3, bdaddr12only:$BD2))]> {
3784  let mayLoad = 1;
3785  let AccessBytes = bytes;
3786}
3787
3788class StoreBinaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
3789                     ImmOpWithPattern index>
3790  : InstVRV<opcode, (outs), (ins VR128:$V1, bdvaddr12only:$VBD2, index:$M3),
3791            mnemonic#"\t$V1, $VBD2, $M3", []> {
3792  let mayStore = 1;
3793  let AccessBytes = bytes;
3794}
3795
3796class StoreBinaryVRX<string mnemonic, bits<16> opcode,
3797                     SDPatternOperator operator, TypedReg tr, bits<5> bytes,
3798                     ImmOpWithPattern index>
3799  : InstVRX<opcode, (outs), (ins tr.op:$V1, bdxaddr12only:$XBD2, index:$M3),
3800            mnemonic#"\t$V1, $XBD2, $M3",
3801            [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2, index:$M3)]> {
3802  let mayStore = 1;
3803  let AccessBytes = bytes;
3804}
3805
3806class MemoryBinarySSd<string mnemonic, bits<8> opcode,
3807                      RegisterOperand cls>
3808  : InstSSd<opcode, (outs),
3809            (ins bdraddr12only:$RBD1, bdaddr12only:$BD2, cls:$R3),
3810            mnemonic#"\t$RBD1, $BD2, $R3", []>;
3811
3812class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3813                RegisterOperand cls1, RegisterOperand cls2>
3814  : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3815           mnemonic#"\t$R1, $R2",
3816           [(set CC, (operator cls1:$R1, cls2:$R2))]> {
3817  let OpKey = mnemonic#cls1;
3818  let OpType = "reg";
3819  let isCompare = 1;
3820}
3821
3822class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3823                 RegisterOperand cls1, RegisterOperand cls2>
3824  : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3825            mnemonic#"\t$R1, $R2",
3826            [(set CC, (operator cls1:$R1, cls2:$R2))]> {
3827  let OpKey = mnemonic#cls1;
3828  let OpType = "reg";
3829  let isCompare = 1;
3830}
3831
3832class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3833                RegisterOperand cls, ImmOpWithPattern imm>
3834  : InstRIa<opcode, (outs), (ins cls:$R1, imm:$I2),
3835            mnemonic#"\t$R1, $I2",
3836            [(set CC, (operator cls:$R1, imm:$I2))]> {
3837  let isCompare = 1;
3838}
3839
3840class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3841                 RegisterOperand cls, ImmOpWithPattern imm>
3842  : InstRILa<opcode, (outs), (ins cls:$R1, imm:$I2),
3843             mnemonic#"\t$R1, $I2",
3844             [(set CC, (operator cls:$R1, imm:$I2))]> {
3845  let isCompare = 1;
3846}
3847
3848class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3849                   RegisterOperand cls, SDPatternOperator load>
3850  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
3851             mnemonic#"\t$R1, $RI2",
3852             [(set CC, (operator cls:$R1, (load pcrel32:$RI2)))]> {
3853  let isCompare = 1;
3854  let mayLoad = 1;
3855  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
3856  // However, BDXs have two extra operands and are therefore 6 units more
3857  // complex.
3858  let AddedComplexity = 7;
3859}
3860
3861class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3862                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3863                AddressingMode mode = bdxaddr12only>
3864  : InstRXa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3865            mnemonic#"\t$R1, $XBD2",
3866            [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
3867  let OpKey = mnemonic#"r"#cls;
3868  let OpType = "mem";
3869  let isCompare = 1;
3870  let mayLoad = 1;
3871  let AccessBytes = bytes;
3872}
3873
3874class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3875                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3876  : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3877            mnemonic#"\t$R1, $XBD2",
3878            [(set CC, (operator cls:$R1, (load bdxaddr12only:$XBD2)))]> {
3879  let OpKey = mnemonic#"r"#cls;
3880  let OpType = "mem";
3881  let isCompare = 1;
3882  let mayLoad = 1;
3883  let AccessBytes = bytes;
3884  let M3 = 0;
3885}
3886
3887class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3888                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3889                 AddressingMode mode = bdxaddr20only>
3890  : InstRXYa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3891             mnemonic#"\t$R1, $XBD2",
3892             [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
3893  let OpKey = mnemonic#"r"#cls;
3894  let OpType = "mem";
3895  let isCompare = 1;
3896  let mayLoad = 1;
3897  let AccessBytes = bytes;
3898}
3899
3900multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3901                         SDPatternOperator operator, RegisterOperand cls,
3902                         SDPatternOperator load, bits<5> bytes> {
3903  let DispKey = mnemonic ## #cls in {
3904    let DispSize = "12" in
3905      def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
3906                         load, bytes, bdxaddr12pair>;
3907    let DispSize = "20" in
3908      def Y  : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
3909                          load, bytes, bdxaddr20pair>;
3910  }
3911}
3912
3913class CompareRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3914                bits<5> bytes, AddressingMode mode = bdaddr12only>
3915  : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3916            mnemonic#"\t$R1, $M3, $BD2", []> {
3917  let mayLoad = 1;
3918  let AccessBytes = bytes;
3919}
3920
3921class CompareRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3922                 bits<5> bytes, AddressingMode mode = bdaddr20only>
3923  : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3924             mnemonic#"\t$R1, $M3, $BD2", []> {
3925  let mayLoad = 1;
3926  let AccessBytes = bytes;
3927}
3928
3929multiclass CompareRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
3930                         RegisterOperand cls, bits<5> bytes> {
3931  let DispKey = mnemonic ## #cls in {
3932    let DispSize = "12" in
3933      def "" : CompareRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3934    let DispSize = "20" in
3935      def Y  : CompareRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
3936  }
3937}
3938
3939class CompareSSb<string mnemonic, bits<8> opcode>
3940  : InstSSb<opcode,
3941            (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
3942            mnemonic##"\t$BDL1, $BDL2", []> {
3943  let isCompare = 1;
3944  let mayLoad = 1;
3945}
3946
3947class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3948                SDPatternOperator load, ImmOpWithPattern imm,
3949                AddressingMode mode = bdaddr12only>
3950  : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3951           mnemonic#"\t$BD1, $I2",
3952           [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
3953  let isCompare = 1;
3954  let mayLoad = 1;
3955}
3956
3957class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3958                 SDPatternOperator load, ImmOpWithPattern imm>
3959  : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3960            mnemonic#"\t$BD1, $I2",
3961            [(set CC, (operator (load bdaddr12only:$BD1), imm:$I2))]> {
3962  let isCompare = 1;
3963  let mayLoad = 1;
3964}
3965
3966class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3967                 SDPatternOperator load, ImmOpWithPattern imm,
3968                 AddressingMode mode = bdaddr20only>
3969  : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3970            mnemonic#"\t$BD1, $I2",
3971            [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
3972  let isCompare = 1;
3973  let mayLoad = 1;
3974}
3975
3976multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
3977                         SDPatternOperator operator, SDPatternOperator load,
3978                         ImmOpWithPattern imm> {
3979  let DispKey = mnemonic in {
3980    let DispSize = "12" in
3981      def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
3982    let DispSize = "20" in
3983      def Y  : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
3984                          bdaddr20pair>;
3985  }
3986}
3987
3988class CompareVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3989                  TypedReg tr, bits<4> type>
3990  : InstVRRa<opcode, (outs), (ins tr.op:$V1, tr.op:$V2),
3991             mnemonic#"\t$V1, $V2",
3992             [(set CC, (operator (tr.vt tr.op:$V1), (tr.vt tr.op:$V2)))]> {
3993  let isCompare = 1;
3994  let M3 = type;
3995  let M4 = 0;
3996  let M5 = 0;
3997}
3998
3999class CompareVRRaGeneric<string mnemonic, bits<16> opcode>
4000  : InstVRRa<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
4001             mnemonic#"\t$V1, $V2, $M3", []> {
4002  let isCompare = 1;
4003  let M4 = 0;
4004  let M5 = 0;
4005}
4006
4007class CompareVRRaFloatGeneric<string mnemonic, bits<16> opcode>
4008  : InstVRRa<opcode, (outs),
4009             (ins VR64:$V1, VR64:$V2, imm32zx4:$M3, imm32zx4:$M4),
4010             mnemonic#"\t$V1, $V2, $M3, $M4", []> {
4011  let isCompare = 1;
4012  let M5 = 0;
4013}
4014
4015class CompareVRRh<string mnemonic, bits<16> opcode>
4016  : InstVRRh<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
4017             mnemonic#"\t$V1, $V2, $M3", []> {
4018  let isCompare = 1;
4019}
4020
4021class TestInherentS<string mnemonic, bits<16> opcode,
4022                    SDPatternOperator operator>
4023  : InstS<opcode, (outs), (ins), mnemonic, [(set CC, (operator))]> {
4024  let BD2 = 0;
4025}
4026
4027class TestRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4028              RegisterOperand cls>
4029  : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
4030            mnemonic#"\t$R1, $XBD2",
4031            [(set CC, (operator cls:$R1, bdxaddr12only:$XBD2))]> {
4032  let M3 = 0;
4033}
4034
4035class TestBinarySIL<string mnemonic, bits<16> opcode,
4036                    SDPatternOperator operator, ImmOpWithPattern imm>
4037  : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
4038            mnemonic#"\t$BD1, $I2",
4039            [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
4040
4041class TestRSL<string mnemonic, bits<16> opcode>
4042  : InstRSLa<opcode, (outs), (ins bdladdr12onlylen4:$BDL1),
4043             mnemonic#"\t$BDL1", []> {
4044  let mayLoad = 1;
4045}
4046
4047class TestVRRg<string mnemonic, bits<16> opcode>
4048  : InstVRRg<opcode, (outs), (ins VR128:$V1),
4049             mnemonic#"\t$V1", []>;
4050
4051class SideEffectTernarySSc<string mnemonic, bits<8> opcode>
4052  : InstSSc<opcode, (outs), (ins bdladdr12onlylen4:$BDL1,
4053                                 shift12only:$BD2, imm32zx4:$I3),
4054            mnemonic##"\t$BDL1, $BD2, $I3", []>;
4055
4056class SideEffectTernaryRRFa<string mnemonic, bits<16> opcode,
4057                            RegisterOperand cls1, RegisterOperand cls2,
4058                            RegisterOperand cls3>
4059  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
4060             mnemonic#"\t$R1, $R2, $R3", []> {
4061  let M4 = 0;
4062}
4063
4064class SideEffectTernaryMemMemRRFa<string mnemonic, bits<16> opcode,
4065                                  RegisterOperand cls1, RegisterOperand cls2,
4066                                  RegisterOperand cls3>
4067  : InstRRFa<opcode, (outs cls1:$R1, cls2:$R2),
4068             (ins cls1:$R1src, cls2:$R2src, cls3:$R3),
4069             mnemonic#"\t$R1, $R2, $R3", []> {
4070  let Constraints = "$R1 = $R1src, $R2 = $R2src";
4071  let DisableEncoding = "$R1src, $R2src";
4072  let M4 = 0;
4073}
4074
4075class SideEffectTernaryRRFb<string mnemonic, bits<16> opcode,
4076                            RegisterOperand cls1, RegisterOperand cls2,
4077                            RegisterOperand cls3>
4078  : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
4079             mnemonic#"\t$R1, $R3, $R2", []> {
4080  let M4 = 0;
4081}
4082
4083class SideEffectTernaryMemMemMemRRFb<string mnemonic, bits<16> opcode,
4084                                     RegisterOperand cls1,
4085                                     RegisterOperand cls2,
4086                                     RegisterOperand cls3>
4087  : InstRRFb<opcode, (outs cls1:$R1, cls2:$R2, cls3:$R3),
4088             (ins cls1:$R1src, cls2:$R2src, cls3:$R3src),
4089             mnemonic#"\t$R1, $R3, $R2", []> {
4090  let Constraints = "$R1 = $R1src, $R2 = $R2src, $R3 = $R3src";
4091  let DisableEncoding = "$R1src, $R2src, $R3src";
4092  let M4 = 0;
4093}
4094
4095class SideEffectTernaryRRFc<string mnemonic, bits<16> opcode,
4096                            RegisterOperand cls1, RegisterOperand cls2,
4097                            ImmOpWithPattern imm>
4098  : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2, imm:$M3),
4099             mnemonic#"\t$R1, $R2, $M3", []>;
4100
4101multiclass SideEffectTernaryRRFcOpt<string mnemonic, bits<16> opcode,
4102                                    RegisterOperand cls1,
4103                                    RegisterOperand cls2> {
4104  def "" : SideEffectTernaryRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
4105  def Opt : SideEffectBinaryRRFc<mnemonic, opcode, cls1, cls2>;
4106}
4107
4108class SideEffectTernaryMemMemRRFc<string mnemonic, bits<16> opcode,
4109                                  RegisterOperand cls1, RegisterOperand cls2,
4110                                  ImmOpWithPattern imm>
4111  : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2),
4112             (ins cls1:$R1src, cls2:$R2src, imm:$M3),
4113             mnemonic#"\t$R1, $R2, $M3", []> {
4114  let Constraints = "$R1 = $R1src, $R2 = $R2src";
4115  let DisableEncoding = "$R1src, $R2src";
4116}
4117
4118multiclass SideEffectTernaryMemMemRRFcOpt<string mnemonic, bits<16> opcode,
4119                                          RegisterOperand cls1,
4120                                          RegisterOperand cls2> {
4121  def "" : SideEffectTernaryMemMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
4122  def Opt : SideEffectBinaryMemMemRRFc<mnemonic, opcode, cls1, cls2>;
4123}
4124
4125class SideEffectTernarySSF<string mnemonic, bits<12> opcode,
4126                           RegisterOperand cls>
4127  : InstSSF<opcode, (outs),
4128            (ins bdaddr12only:$BD1, bdaddr12only:$BD2, cls:$R3),
4129            mnemonic#"\t$BD1, $BD2, $R3", []>;
4130
4131class TernaryRRFa<string mnemonic, bits<16> opcode,
4132                 RegisterOperand cls1, RegisterOperand cls2,
4133                 RegisterOperand cls3>
4134  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3, imm32zx4:$M4),
4135             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4136
4137class TernaryRRFb<string mnemonic, bits<16> opcode,
4138                  RegisterOperand cls1, RegisterOperand cls2,
4139                  RegisterOperand cls3>
4140  : InstRRFb<opcode, (outs cls1:$R1, cls3:$R3),
4141             (ins cls1:$R1src, cls2:$R2, imm32zx4:$M4),
4142             mnemonic#"\t$R1, $R3, $R2, $M4", []> {
4143  let Constraints = "$R1 = $R1src";
4144  let DisableEncoding = "$R1src";
4145}
4146
4147class TernaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4148                  RegisterOperand cls2>
4149  : InstRRFe<opcode, (outs cls1:$R1),
4150             (ins imm32zx4:$M3, cls2:$R2, imm32zx4:$M4),
4151             mnemonic#"\t$R1, $M3, $R2, $M4", []>;
4152
4153class TernaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4154                 RegisterOperand cls1, RegisterOperand cls2>
4155  : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R1src, cls2:$R3, cls2:$R2),
4156            mnemonic#"\t$R1, $R3, $R2",
4157            [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3, cls2:$R2))]> {
4158  let OpKey = mnemonic#cls;
4159  let OpType = "reg";
4160  let Constraints = "$R1 = $R1src";
4161  let DisableEncoding = "$R1src";
4162}
4163
4164class TernaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
4165                bits<5> bytes, AddressingMode mode = bdaddr12only>
4166  : InstRSb<opcode, (outs cls:$R1),
4167            (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4168            mnemonic#"\t$R1, $M3, $BD2", []> {
4169
4170  let Constraints = "$R1 = $R1src";
4171  let DisableEncoding = "$R1src";
4172  let mayLoad = 1;
4173  let AccessBytes = bytes;
4174}
4175
4176class TernaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
4177                bits<5> bytes, AddressingMode mode = bdaddr20only>
4178  : InstRSYb<opcode, (outs cls:$R1),
4179             (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4180             mnemonic#"\t$R1, $M3, $BD2", []> {
4181
4182  let Constraints = "$R1 = $R1src";
4183  let DisableEncoding = "$R1src";
4184  let mayLoad = 1;
4185  let AccessBytes = bytes;
4186}
4187
4188multiclass TernaryRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4189                         RegisterOperand cls, bits<5> bytes> {
4190  let DispKey = mnemonic ## #cls in {
4191    let DispSize = "12" in
4192      def "" : TernaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
4193    let DispSize = "20" in
4194      def Y  : TernaryRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
4195  }
4196}
4197
4198class SideEffectTernaryRS<string mnemonic, bits<8> opcode,
4199                          RegisterOperand cls1, RegisterOperand cls2>
4200  : InstRSa<opcode, (outs),
4201            (ins cls1:$R1, cls2:$R3, bdaddr12only:$BD2),
4202            mnemonic#"\t$R1, $R3, $BD2", []>;
4203
4204class SideEffectTernaryRSY<string mnemonic, bits<16> opcode,
4205                           RegisterOperand cls1, RegisterOperand cls2>
4206  : InstRSYa<opcode, (outs),
4207             (ins cls1:$R1, cls2:$R3, bdaddr20only:$BD2),
4208             mnemonic#"\t$R1, $R3, $BD2", []>;
4209
4210class SideEffectTernaryMemMemRS<string mnemonic, bits<8> opcode,
4211                                RegisterOperand cls1, RegisterOperand cls2>
4212  : InstRSa<opcode, (outs cls1:$R1, cls2:$R3),
4213            (ins cls1:$R1src, cls2:$R3src, shift12only:$BD2),
4214            mnemonic#"\t$R1, $R3, $BD2", []> {
4215    let Constraints = "$R1 = $R1src, $R3 = $R3src";
4216    let DisableEncoding = "$R1src, $R3src";
4217}
4218
4219class SideEffectTernaryMemMemRSY<string mnemonic, bits<16> opcode,
4220                                 RegisterOperand cls1, RegisterOperand cls2>
4221  : InstRSYa<opcode, (outs cls1:$R1, cls2:$R3),
4222             (ins cls1:$R1src, cls2:$R3src, shift20only:$BD2),
4223             mnemonic#"\t$R1, $R3, $BD2", []> {
4224    let Constraints = "$R1 = $R1src, $R3 = $R3src";
4225    let DisableEncoding = "$R1src, $R3src";
4226}
4227
4228class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4229                 RegisterOperand cls1, RegisterOperand cls2,
4230                 SDPatternOperator load, bits<5> bytes>
4231  : InstRXF<opcode, (outs cls1:$R1),
4232            (ins cls2:$R1src, cls2:$R3, bdxaddr12only:$XBD2),
4233            mnemonic#"\t$R1, $R3, $XBD2",
4234            [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3,
4235                                      (load bdxaddr12only:$XBD2)))]> {
4236  let OpKey = mnemonic#"r"#cls;
4237  let OpType = "mem";
4238  let Constraints = "$R1 = $R1src";
4239  let DisableEncoding = "$R1src";
4240  let mayLoad = 1;
4241  let AccessBytes = bytes;
4242}
4243
4244class TernaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4245                  TypedReg tr1, TypedReg tr2, ImmOpWithPattern imm, ImmOpWithPattern index>
4246  : InstVRIa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V1src, imm:$I2, index:$M3),
4247             mnemonic#"\t$V1, $I2, $M3",
4248             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4249                                                  imm:$I2, index:$M3))]> {
4250  let Constraints = "$V1 = $V1src";
4251  let DisableEncoding = "$V1src";
4252}
4253
4254class TernaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4255                  TypedReg tr1, TypedReg tr2, bits<4> type>
4256  : InstVRId<opcode, (outs tr1.op:$V1),
4257             (ins tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4258             mnemonic#"\t$V1, $V2, $V3, $I4",
4259             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4260                                                  (tr2.vt tr2.op:$V3),
4261                                                  imm32zx8_timm:$I4))]> {
4262  let M5 = type;
4263}
4264
4265class TernaryVRIi<string mnemonic, bits<16> opcode, RegisterOperand cls>
4266  : InstVRIi<opcode, (outs VR128:$V1),
4267             (ins cls:$R2, imm32zx8:$I3, imm32zx4:$M4),
4268             mnemonic#"\t$V1, $R2, $I3, $M4", []>;
4269
4270class TernaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4271                  TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m4or>
4272  : InstVRRa<opcode, (outs tr1.op:$V1),
4273             (ins tr2.op:$V2, imm32zx4:$M4, imm32zx4:$M5),
4274             mnemonic#"\t$V1, $V2, $M4, $M5",
4275             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4276                                                  imm32zx4_timm:$M4,
4277                                                  imm32zx4_timm:$M5))],
4278             m4or> {
4279  let M3 = type;
4280}
4281
4282class TernaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
4283  : InstVRRa<opcode, (outs VR128:$V1),
4284             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
4285             mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
4286
4287class TernaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4288                  TypedReg tr1, TypedReg tr2, bits<4> type,
4289                  SDPatternOperator m5mask, bits<4> m5or>
4290  : InstVRRb<opcode, (outs tr1.op:$V1),
4291             (ins tr2.op:$V2, tr2.op:$V3, m5mask:$M5),
4292             mnemonic#"\t$V1, $V2, $V3, $M5",
4293             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4294                                                  (tr2.vt tr2.op:$V3),
4295                                                  m5mask:$M5))],
4296             m5or> {
4297  let M4 = type;
4298}
4299
4300// Declare a pair of instructions, one which sets CC and one which doesn't.
4301// The CC-setting form ends with "S" and sets the low bit of M5.
4302// Also create aliases to make use of M5 operand optional in assembler.
4303multiclass TernaryOptVRRbSPair<string mnemonic, bits<16> opcode,
4304                               SDPatternOperator operator,
4305                               SDPatternOperator operator_cc,
4306                               TypedReg tr1, TypedReg tr2, bits<4> type,
4307                               bits<4> modifier = 0> {
4308  def "" : TernaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
4309                       imm32zx4even_timm, !and (modifier, 14)>;
4310  def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
4311                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4312                                            tr2.op:$V3, 0)>;
4313  let Defs = [CC] in
4314    def S : TernaryVRRb<mnemonic##"s", opcode, operator_cc, tr1, tr2, type,
4315                        imm32zx4even_timm, !add(!and (modifier, 14), 1)>;
4316  def : InstAlias<mnemonic#"s\t$V1, $V2, $V3",
4317                  (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4318                                                tr2.op:$V3, 0)>;
4319}
4320
4321multiclass TernaryOptVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
4322  let Defs = [CC] in
4323    def "" : InstVRRb<opcode, (outs VR128:$V1),
4324                     (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
4325                     mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
4326  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
4327                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4328                                            imm32zx4:$M4, 0)>;
4329}
4330
4331class TernaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4332                  TypedReg tr1, TypedReg tr2>
4333  : InstVRRc<opcode, (outs tr1.op:$V1),
4334             (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M4),
4335             mnemonic#"\t$V1, $V2, $V3, $M4",
4336             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4337                                                  (tr2.vt tr2.op:$V3),
4338                                                  imm32zx4_timm:$M4))]> {
4339  let M5 = 0;
4340  let M6 = 0;
4341}
4342
4343class TernaryVRRcFloat<string mnemonic, bits<16> opcode,
4344                       SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4345                       bits<4> type = 0, bits<4> m5 = 0>
4346  : InstVRRc<opcode, (outs tr1.op:$V1),
4347             (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M6),
4348             mnemonic#"\t$V1, $V2, $V3, $M6",
4349             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4350                                                  (tr2.vt tr2.op:$V3),
4351                                                  imm32zx4_timm:$M6))]> {
4352  let M4 = type;
4353  let M5 = m5;
4354}
4355
4356class TernaryVRRcFloatGeneric<string mnemonic, bits<16> opcode>
4357  : InstVRRc<opcode, (outs VR128:$V1),
4358             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
4359                  imm32zx4:$M6),
4360             mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
4361
4362class TernaryVRRd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4363                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m6 = 0>
4364  : InstVRRd<opcode, (outs tr1.op:$V1),
4365             (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4366             mnemonic#"\t$V1, $V2, $V3, $V4",
4367             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4368                                                  (tr2.vt tr2.op:$V3),
4369                                                  (tr1.vt tr1.op:$V4)))]> {
4370  let M5 = type;
4371  let M6 = m6;
4372}
4373
4374class TernaryVRRdGeneric<string mnemonic, bits<16> opcode>
4375  : InstVRRd<opcode, (outs VR128:$V1),
4376             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5),
4377             mnemonic#"\t$V1, $V2, $V3, $V4, $M5", []> {
4378  let M6 = 0;
4379}
4380
4381// Ternary operation where the assembler mnemonic has an extra operand to
4382// optionally allow specifiying arbitrary M6 values.
4383multiclass TernaryExtraVRRd<string mnemonic, bits<16> opcode,
4384                             SDPatternOperator operator,
4385                             TypedReg tr1, TypedReg tr2, bits<4> type> {
4386  let M5 = type, Defs = [CC] in
4387    def "" : InstVRRd<opcode, (outs tr1.op:$V1),
4388                      (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4, imm32zx4:$M6),
4389                      mnemonic#"\t$V1, $V2, $V3, $V4, $M6", []>;
4390  def : Pat<(operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3),
4391                      (tr1.vt tr1.op:$V4)),
4392            (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, tr1.op:$V4, 0)>;
4393  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
4394                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4395                                            tr2.op:$V3, tr1.op:$V4, 0)>;
4396}
4397
4398multiclass TernaryExtraVRRdGeneric<string mnemonic, bits<16> opcode> {
4399  let Defs = [CC] in
4400    def "" : InstVRRd<opcode, (outs VR128:$V1),
4401                      (ins VR128:$V2, VR128:$V3, VR128:$V4,
4402                       imm32zx4:$M5, imm32zx4:$M6),
4403                      mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4404  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
4405                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4406                                            VR128:$V4, imm32zx4:$M5, 0)>;
4407}
4408
4409class TernaryVRRe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4410                  TypedReg tr1, TypedReg tr2, bits<4> m5 = 0, bits<4> type = 0>
4411  : InstVRRe<opcode, (outs tr1.op:$V1),
4412             (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4413             mnemonic#"\t$V1, $V2, $V3, $V4",
4414             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4415                                                  (tr2.vt tr2.op:$V3),
4416                                                  (tr1.vt tr1.op:$V4)))]> {
4417  let M5 = m5;
4418  let M6 = type;
4419}
4420
4421class TernaryVRReFloatGeneric<string mnemonic, bits<16> opcode>
4422  : InstVRRe<opcode, (outs VR128:$V1),
4423             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4424             mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4425
4426class TernaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4427                  TypedReg tr1, TypedReg tr2, RegisterOperand cls, bits<4> type>
4428  : InstVRSb<opcode, (outs tr1.op:$V1),
4429             (ins tr2.op:$V1src, cls:$R3, shift12only:$BD2),
4430             mnemonic#"\t$V1, $R3, $BD2",
4431             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4432                                                  cls:$R3,
4433                                                  shift12only:$BD2))]> {
4434  let Constraints = "$V1 = $V1src";
4435  let DisableEncoding = "$V1src";
4436  let M4 = type;
4437}
4438
4439class TernaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
4440  : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2,
4441                                      imm32zx4:$M3, imm32zx4:$M4),
4442             mnemonic#"\t$R1, $V2, $M3, $M4", []>;
4443
4444class TernaryVRSbGeneric<string mnemonic, bits<16> opcode>
4445  : InstVRSb<opcode, (outs VR128:$V1),
4446             (ins VR128:$V1src, GR64:$R3, shift12only:$BD2, imm32zx4:$M4),
4447             mnemonic#"\t$V1, $R3, $BD2, $M4", []> {
4448  let Constraints = "$V1 = $V1src";
4449  let DisableEncoding = "$V1src";
4450}
4451
4452class TernaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
4453                 ImmOpWithPattern index>
4454  : InstVRV<opcode, (outs VR128:$V1),
4455           (ins VR128:$V1src, bdvaddr12only:$VBD2, index:$M3),
4456           mnemonic#"\t$V1, $VBD2, $M3", []> {
4457  let Constraints = "$V1 = $V1src";
4458  let DisableEncoding = "$V1src";
4459  let mayLoad = 1;
4460  let AccessBytes = bytes;
4461}
4462
4463class TernaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4464                 TypedReg tr1, TypedReg tr2, bits<5> bytes, ImmOpWithPattern index>
4465  : InstVRX<opcode, (outs tr1.op:$V1),
4466           (ins tr2.op:$V1src, bdxaddr12only:$XBD2, index:$M3),
4467           mnemonic#"\t$V1, $XBD2, $M3",
4468           [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4469                                                bdxaddr12only:$XBD2,
4470                                                index:$M3))]> {
4471  let Constraints = "$V1 = $V1src";
4472  let DisableEncoding = "$V1src";
4473  let mayLoad = 1;
4474  let AccessBytes = bytes;
4475}
4476
4477class QuaternaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4478                     TypedReg tr1, TypedReg tr2, bits<4> type>
4479  : InstVRId<opcode, (outs tr1.op:$V1),
4480             (ins tr2.op:$V1src, tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4481             mnemonic#"\t$V1, $V2, $V3, $I4",
4482             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4483                                                  (tr2.vt tr2.op:$V2),
4484                                                  (tr2.vt tr2.op:$V3),
4485                                                  imm32zx8_timm:$I4))]> {
4486  let Constraints = "$V1 = $V1src";
4487  let DisableEncoding = "$V1src";
4488  let M5 = type;
4489}
4490
4491class QuaternaryVRIdGeneric<string mnemonic, bits<16> opcode>
4492  : InstVRId<opcode, (outs VR128:$V1),
4493             (ins VR128:$V1src, VR128:$V2, VR128:$V3,
4494                  imm32zx8:$I4, imm32zx4:$M5),
4495             mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []> {
4496  let Constraints = "$V1 = $V1src";
4497  let DisableEncoding = "$V1src";
4498}
4499
4500class QuaternaryVRIf<string mnemonic, bits<16> opcode>
4501  : InstVRIf<opcode, (outs VR128:$V1),
4502             (ins VR128:$V2, VR128:$V3,
4503                  imm32zx8:$I4, imm32zx4:$M5),
4504            mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []>;
4505
4506class QuaternaryVRIg<string mnemonic, bits<16> opcode>
4507  : InstVRIg<opcode, (outs VR128:$V1),
4508             (ins VR128:$V2, imm32zx8:$I3,
4509                  imm32zx8:$I4, imm32zx4:$M5),
4510             mnemonic#"\t$V1, $V2, $I3, $I4, $M5", []>;
4511
4512class QuaternaryVRRd<string mnemonic, bits<16> opcode,
4513                     SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4514                     TypedReg tr3, TypedReg tr4, bits<4> type,
4515                     SDPatternOperator m6mask = imm32zx4_timm, bits<4> m6or = 0>
4516  : InstVRRd<opcode, (outs tr1.op:$V1),
4517             (ins tr2.op:$V2, tr3.op:$V3, tr4.op:$V4, m6mask:$M6),
4518             mnemonic#"\t$V1, $V2, $V3, $V4, $M6",
4519             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4520                                                  (tr3.vt tr3.op:$V3),
4521                                                  (tr4.vt tr4.op:$V4),
4522                                                  m6mask:$M6))],
4523             m6or> {
4524  let M5 = type;
4525}
4526
4527class QuaternaryVRRdGeneric<string mnemonic, bits<16> opcode>
4528  : InstVRRd<opcode, (outs VR128:$V1),
4529             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4530             mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4531
4532// Declare a pair of instructions, one which sets CC and one which doesn't.
4533// The CC-setting form ends with "S" and sets the low bit of M6.
4534// Also create aliases to make use of M6 operand optional in assembler.
4535multiclass QuaternaryOptVRRdSPair<string mnemonic, bits<16> opcode,
4536                                  SDPatternOperator operator,
4537                                SDPatternOperator operator_cc,
4538                                TypedReg tr1, TypedReg tr2, bits<4> type,
4539                                bits<4> modifier = 0> {
4540  def "" : QuaternaryVRRd<mnemonic, opcode, operator,
4541                          tr1, tr2, tr2, tr2, type,
4542                          imm32zx4even_timm, !and (modifier, 14)>;
4543  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
4544                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4545                                            tr2.op:$V3, tr2.op:$V4, 0)>;
4546  let Defs = [CC] in
4547    def S : QuaternaryVRRd<mnemonic##"s", opcode, operator_cc,
4548                           tr1, tr2, tr2, tr2, type,
4549                           imm32zx4even_timm, !add (!and (modifier, 14), 1)>;
4550  def : InstAlias<mnemonic#"s\t$V1, $V2, $V3, $V4",
4551                  (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4552                                                tr2.op:$V3, tr2.op:$V4, 0)>;
4553}
4554
4555multiclass QuaternaryOptVRRdSPairGeneric<string mnemonic, bits<16> opcode> {
4556  let Defs = [CC] in
4557    def "" : QuaternaryVRRdGeneric<mnemonic, opcode>;
4558  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
4559                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4560                                            VR128:$V4, imm32zx4_timm:$M5, 0)>;
4561}
4562
4563class SideEffectQuaternaryRRFa<string mnemonic, bits<16> opcode,
4564                               RegisterOperand cls1, RegisterOperand cls2,
4565                               RegisterOperand cls3>
4566  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4567             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4568
4569multiclass SideEffectQuaternaryRRFaOptOpt<string mnemonic, bits<16> opcode,
4570                                          RegisterOperand cls1,
4571                                          RegisterOperand cls2,
4572                                          RegisterOperand cls3> {
4573  def "" : SideEffectQuaternaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4574  def Opt : SideEffectTernaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4575  def OptOpt : SideEffectBinaryRRFa<mnemonic, opcode, cls1, cls2>;
4576}
4577
4578class SideEffectQuaternaryRRFb<string mnemonic, bits<16> opcode,
4579                               RegisterOperand cls1, RegisterOperand cls2,
4580                               RegisterOperand cls3>
4581  : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4582             mnemonic#"\t$R1, $R3, $R2, $M4", []>;
4583
4584multiclass SideEffectQuaternaryRRFbOpt<string mnemonic, bits<16> opcode,
4585                                       RegisterOperand cls1,
4586                                       RegisterOperand cls2,
4587                                       RegisterOperand cls3> {
4588  def "" : SideEffectQuaternaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4589  def Opt : SideEffectTernaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4590}
4591
4592class SideEffectQuaternarySSe<string mnemonic, bits<8> opcode,
4593                              RegisterOperand cls>
4594  : InstSSe<opcode, (outs),
4595            (ins cls:$R1, bdaddr12only:$BD2, cls:$R3, bdaddr12only:$BD4),
4596            mnemonic#"\t$R1, $BD2, $R3, $BD4", []>;
4597
4598class LoadAndOpRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4599                  RegisterOperand cls, AddressingMode mode = bdaddr20only>
4600  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
4601             mnemonic#"\t$R1, $R3, $BD2",
4602             [(set cls:$R1, (operator mode:$BD2, cls:$R3))]> {
4603  let mayLoad = 1;
4604  let mayStore = 1;
4605}
4606
4607class CmpSwapRRE<string mnemonic, bits<16> opcode,
4608                 RegisterOperand cls1, RegisterOperand cls2>
4609  : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
4610            mnemonic#"\t$R1, $R2", []> {
4611  let Constraints = "$R1 = $R1src";
4612  let DisableEncoding = "$R1src";
4613  let mayLoad = 1;
4614  let mayStore = 1;
4615}
4616
4617class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
4618                RegisterOperand cls, AddressingMode mode = bdaddr12only>
4619  : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4620            mnemonic#"\t$R1, $R3, $BD2",
4621            [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4622  let Constraints = "$R1 = $R1src";
4623  let DisableEncoding = "$R1src";
4624  let mayLoad = 1;
4625  let mayStore = 1;
4626}
4627
4628class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4629                 RegisterOperand cls, AddressingMode mode = bdaddr20only>
4630  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4631             mnemonic#"\t$R1, $R3, $BD2",
4632             [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4633  let Constraints = "$R1 = $R1src";
4634  let DisableEncoding = "$R1src";
4635  let mayLoad = 1;
4636  let mayStore = 1;
4637}
4638
4639multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4640                         SDPatternOperator operator, RegisterOperand cls> {
4641  let DispKey = mnemonic ## #cls in {
4642    let DispSize = "12" in
4643      def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
4644    let DispSize = "20" in
4645      def Y  : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
4646  }
4647}
4648
4649class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4650                       RegisterOperand cls2>
4651  : InstRIEf<opcode, (outs cls1:$R1),
4652             (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4653                  imm32zx6:$I5),
4654             mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
4655  let Constraints = "$R1 = $R1src";
4656  let DisableEncoding = "$R1src";
4657}
4658
4659class PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator>
4660  : InstRXYb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr20only:$XBD2),
4661             mnemonic##"\t$M1, $XBD2",
4662             [(operator imm32zx4_timm:$M1, bdxaddr20only:$XBD2)]>;
4663
4664class PrefetchRILPC<string mnemonic, bits<12> opcode,
4665                    SDPatternOperator operator>
4666  : InstRILc<opcode, (outs), (ins imm32zx4_timm:$M1, pcrel32:$RI2),
4667             mnemonic##"\t$M1, $RI2",
4668             [(operator imm32zx4_timm:$M1, pcrel32:$RI2)]> {
4669  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
4670  // However, BDXs have two extra operands and are therefore 6 units more
4671  // complex.
4672  let AddedComplexity = 7;
4673}
4674
4675class BranchPreloadSMI<string mnemonic, bits<8> opcode>
4676  : InstSMI<opcode, (outs),
4677            (ins imm32zx4:$M1, brtarget16bpp:$RI2, bdxaddr12only:$BD3),
4678            mnemonic#"\t$M1, $RI2, $BD3", []>;
4679
4680class BranchPreloadMII<string mnemonic, bits<8> opcode>
4681  : InstMII<opcode, (outs),
4682            (ins imm32zx4:$M1, brtarget12bpp:$RI2, brtarget24bpp:$RI3),
4683            mnemonic#"\t$M1, $RI2, $RI3", []>;
4684
4685// A floating-point load-and test operation.  Create both a normal unary
4686// operation and one that acts as a comparison against zero.
4687// Note that the comparison against zero operation is not available if we
4688// have vector support, since load-and-test instructions will partially
4689// clobber the target (vector) register.
4690multiclass LoadAndTestRRE<string mnemonic, bits<16> opcode,
4691                          RegisterOperand cls> {
4692  def "" : UnaryRRE<mnemonic, opcode, null_frag, cls, cls>;
4693  let isCodeGenOnly = 1, Predicates = [FeatureNoVector] in
4694    def Compare : CompareRRE<mnemonic, opcode, null_frag, cls, cls>;
4695}
4696
4697//===----------------------------------------------------------------------===//
4698// Pseudo instructions
4699//===----------------------------------------------------------------------===//
4700//
4701// Convenience instructions that get lowered to real instructions
4702// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
4703// or SystemZInstrInfo::expandPostRAPseudo().
4704//
4705//===----------------------------------------------------------------------===//
4706
4707class Pseudo<dag outs, dag ins, list<dag> pattern>
4708  : InstSystemZ<0, outs, ins, "", pattern> {
4709  let isPseudo = 1;
4710  let isCodeGenOnly = 1;
4711}
4712
4713// Like UnaryRI, but expanded after RA depending on the choice of register.
4714class UnaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4715                    ImmOpWithPattern imm>
4716  : Pseudo<(outs cls:$R1), (ins imm:$I2),
4717           [(set cls:$R1, (operator imm:$I2))]>;
4718
4719// Like UnaryRXY, but expanded after RA depending on the choice of register.
4720class UnaryRXYPseudo<string key, SDPatternOperator operator,
4721                     RegisterOperand cls, bits<5> bytes,
4722                     AddressingMode mode = bdxaddr20only>
4723  : Pseudo<(outs cls:$R1), (ins mode:$XBD2),
4724           [(set cls:$R1, (operator mode:$XBD2))]> {
4725  let OpKey = key#"r"#cls;
4726  let OpType = "mem";
4727  let mayLoad = 1;
4728  let Has20BitOffset = 1;
4729  let HasIndex = 1;
4730  let AccessBytes = bytes;
4731}
4732
4733// Like UnaryRR, but expanded after RA depending on the choice of registers.
4734class UnaryRRPseudo<string key, SDPatternOperator operator,
4735                    RegisterOperand cls1, RegisterOperand cls2>
4736  : Pseudo<(outs cls1:$R1), (ins cls2:$R2),
4737           [(set cls1:$R1, (operator cls2:$R2))]> {
4738  let OpKey = key#cls1;
4739  let OpType = "reg";
4740}
4741
4742// Like BinaryRI, but expanded after RA depending on the choice of register.
4743class BinaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4744                     ImmOpWithPattern imm>
4745  : Pseudo<(outs cls:$R1), (ins cls:$R1src, imm:$I2),
4746           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4747  let Constraints = "$R1 = $R1src";
4748}
4749
4750// Like BinaryRIE, but expanded after RA depending on the choice of register.
4751class BinaryRIEPseudo<SDPatternOperator operator, RegisterOperand cls,
4752                      ImmOpWithPattern imm>
4753  : Pseudo<(outs cls:$R1), (ins cls:$R3, imm:$I2),
4754           [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
4755
4756// Like BinaryRIAndK, but expanded after RA depending on the choice of register.
4757multiclass BinaryRIAndKPseudo<string key, SDPatternOperator operator,
4758                              RegisterOperand cls, ImmOpWithPattern imm> {
4759  let NumOpsKey = key in {
4760    let NumOpsValue = "3" in
4761      def K : BinaryRIEPseudo<operator, cls, imm>,
4762              Requires<[FeatureHighWord, FeatureDistinctOps]>;
4763    let NumOpsValue = "2" in
4764      def "" : BinaryRIPseudo<operator, cls, imm>,
4765               Requires<[FeatureHighWord]>;
4766  }
4767}
4768
4769// A pseudo that is used during register allocation when folding a memory
4770// operand. The 3-address register instruction with a spilled source cannot
4771// be converted directly to a target 2-address reg/mem instruction.
4772// Mapping:  <INSN>R  ->  MemFoldPseudo  ->  <INSN>
4773class MemFoldPseudo<string mnemonic, RegisterOperand cls, bits<5> bytes,
4774                    AddressingMode mode>
4775  : Pseudo<(outs cls:$R1), (ins cls:$R2, mode:$XBD2), []> {
4776    let OpKey = !subst("mscrk", "msrkc",
4777                !subst("msgcrk", "msgrkc",
4778                mnemonic#"rk"#cls));
4779    let OpType = "mem";
4780    let MemKey = mnemonic#cls;
4781    let MemType = "pseudo";
4782    let mayLoad = 1;
4783    let AccessBytes = bytes;
4784    let HasIndex = 1;
4785    let hasNoSchedulingInfo = 1;
4786}
4787
4788// Same as MemFoldPseudo but for Load On Condition with CC operands.
4789class MemFoldPseudo_CondMove<string mnemonic, RegisterOperand cls, bits<5> bytes,
4790                             AddressingMode mode>
4791  : Pseudo<(outs cls:$R1),
4792           (ins cls:$R2, mode:$XBD2, cond4:$valid, cond4:$M3), []> {
4793    let OpKey = !subst("loc", "sel", mnemonic)#"r"#cls;
4794    let OpType = "mem";
4795    let MemKey = mnemonic#cls;
4796    let MemType = "pseudo";
4797    let mayLoad = 1;
4798    let AccessBytes = bytes;
4799    let hasNoSchedulingInfo = 1;
4800}
4801
4802// Like CompareRI, but expanded after RA depending on the choice of register.
4803class CompareRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4804                      ImmOpWithPattern imm>
4805  : Pseudo<(outs), (ins cls:$R1, imm:$I2),
4806           [(set CC, (operator cls:$R1, imm:$I2))]> {
4807  let isCompare = 1;
4808}
4809
4810// Like CompareRXY, but expanded after RA depending on the choice of register.
4811class CompareRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4812                       SDPatternOperator load, bits<5> bytes,
4813                       AddressingMode mode = bdxaddr20only>
4814  : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4815           [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
4816  let mayLoad = 1;
4817  let Has20BitOffset = 1;
4818  let HasIndex = 1;
4819  let AccessBytes = bytes;
4820}
4821
4822// Like TestBinarySIL, but expanded later.
4823class TestBinarySILPseudo<SDPatternOperator operator, ImmOpWithPattern imm>
4824  : Pseudo<(outs), (ins bdaddr12only:$BD1, imm:$I2),
4825           [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
4826
4827// Like CondBinaryRRF, but expanded after RA depending on the choice of
4828// register.
4829class CondBinaryRRFPseudo<string mnemonic, RegisterOperand cls1,
4830                          RegisterOperand cls2>
4831  : Pseudo<(outs cls1:$R1),
4832           (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
4833           [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
4834                                            cond4:$valid, cond4:$M3))]> {
4835  let Constraints = "$R1 = $R1src";
4836  let DisableEncoding = "$R1src";
4837  let CCMaskLast = 1;
4838  let NumOpsKey = !subst("loc", "sel", mnemonic);
4839  let NumOpsValue = "2";
4840  let OpKey = mnemonic#cls1;
4841  let OpType = "reg";
4842}
4843
4844// Like CondBinaryRRFa, but expanded after RA depending on the choice of
4845// register.
4846class CondBinaryRRFaPseudo<string mnemonic, RegisterOperand cls1,
4847                           RegisterOperand cls2, RegisterOperand cls3>
4848  : Pseudo<(outs cls1:$R1),
4849           (ins cls3:$R3, cls2:$R2, cond4:$valid, cond4:$M4),
4850           [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls3:$R3,
4851                                            cond4:$valid, cond4:$M4))]> {
4852  let CCMaskLast = 1;
4853  let NumOpsKey = mnemonic;
4854  let NumOpsValue = "3";
4855  let OpKey = mnemonic#cls1;
4856  let OpType = "reg";
4857}
4858
4859// Like CondBinaryRIE, but expanded after RA depending on the choice of
4860// register.
4861class CondBinaryRIEPseudo<RegisterOperand cls, ImmOpWithPattern imm>
4862  : Pseudo<(outs cls:$R1),
4863           (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
4864           [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
4865                                           cond4:$valid, cond4:$M3))]> {
4866  let Constraints = "$R1 = $R1src";
4867  let DisableEncoding = "$R1src";
4868  let CCMaskLast = 1;
4869}
4870
4871// Like CondUnaryRSY, but expanded after RA depending on the choice of
4872// register.
4873class CondUnaryRSYPseudo<string mnemonic, SDPatternOperator operator,
4874                         RegisterOperand cls, bits<5> bytes,
4875                         AddressingMode mode = bdaddr20only>
4876  : Pseudo<(outs cls:$R1),
4877           (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
4878           [(set cls:$R1,
4879                 (z_select_ccmask (operator mode:$BD2), cls:$R1src,
4880                                  cond4:$valid, cond4:$R3))]> {
4881  let Constraints = "$R1 = $R1src";
4882  let DisableEncoding = "$R1src";
4883  let mayLoad = 1;
4884  let AccessBytes = bytes;
4885  let CCMaskLast = 1;
4886  let OpKey = mnemonic#"r"#cls;
4887  let OpType = "mem";
4888  let MemKey = mnemonic#cls;
4889  let MemType = "target";
4890}
4891
4892// Like CondStoreRSY, but expanded after RA depending on the choice of
4893// register.
4894class CondStoreRSYPseudo<RegisterOperand cls, bits<5> bytes,
4895                         AddressingMode mode = bdaddr20only>
4896  : Pseudo<(outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3), []> {
4897  let mayStore = 1;
4898  let AccessBytes = bytes;
4899  let CCMaskLast = 1;
4900}
4901
4902// Like StoreRXY, but expanded after RA depending on the choice of register.
4903class StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4904                     bits<5> bytes, AddressingMode mode = bdxaddr20only>
4905  : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4906           [(operator cls:$R1, mode:$XBD2)]> {
4907  let mayStore = 1;
4908  let Has20BitOffset = 1;
4909  let HasIndex = 1;
4910  let AccessBytes = bytes;
4911}
4912
4913// Like RotateSelectRIEf, but expanded after RA depending on the choice
4914// of registers.
4915class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>
4916  : Pseudo<(outs cls1:$R1),
4917           (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4918                imm32zx6:$I5),
4919           []> {
4920  let Constraints = "$R1 = $R1src";
4921  let DisableEncoding = "$R1src";
4922}
4923
4924// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
4925// the value of the PSW's 2-bit condition code field.
4926class SelectWrapper<ValueType vt, RegisterOperand cls>
4927  : Pseudo<(outs cls:$dst),
4928           (ins cls:$src1, cls:$src2, imm32zx4:$valid, imm32zx4:$cc),
4929           [(set (vt cls:$dst), (z_select_ccmask cls:$src1, cls:$src2,
4930                                            imm32zx4_timm:$valid, imm32zx4_timm:$cc))]> {
4931  let usesCustomInserter = 1;
4932  let hasNoSchedulingInfo = 1;
4933  let Uses = [CC];
4934}
4935
4936// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
4937multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
4938                      SDPatternOperator load, AddressingMode mode> {
4939  let Uses = [CC], usesCustomInserter = 1, hasNoSchedulingInfo = 1,
4940      mayLoad = 1, mayStore = 1 in {
4941    def "" : Pseudo<(outs),
4942                    (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4943                    [(store (z_select_ccmask cls:$new, (load mode:$addr),
4944                                             imm32zx4_timm:$valid, imm32zx4_timm:$cc),
4945                            mode:$addr)]>;
4946    def Inv : Pseudo<(outs),
4947                     (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4948                     [(store (z_select_ccmask (load mode:$addr), cls:$new,
4949                                              imm32zx4_timm:$valid, imm32zx4_timm:$cc),
4950                              mode:$addr)]>;
4951  }
4952}
4953
4954// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation.  PAT and OPERAND
4955// describe the second (non-memory) operand.
4956class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
4957                       dag pat, DAGOperand operand>
4958  : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
4959           [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
4960  let Defs = [CC];
4961  let Has20BitOffset = 1;
4962  let mayLoad = 1;
4963  let mayStore = 1;
4964  let usesCustomInserter = 1;
4965  let hasNoSchedulingInfo = 1;
4966}
4967
4968// Specializations of AtomicLoadWBinary.
4969class AtomicLoadBinaryReg32<SDPatternOperator operator>
4970  : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
4971class AtomicLoadBinaryImm32<SDPatternOperator operator, ImmOpWithPattern imm>
4972  : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
4973class AtomicLoadBinaryReg64<SDPatternOperator operator>
4974  : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
4975class AtomicLoadBinaryImm64<SDPatternOperator operator, ImmOpWithPattern imm>
4976  : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
4977
4978// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation.  PAT and OPERAND
4979// describe the second (non-memory) operand.
4980class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
4981                        DAGOperand operand>
4982  : Pseudo<(outs GR32:$dst),
4983           (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
4984                ADDR32:$negbitshift, uimm32:$bitsize),
4985           [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
4986                                      ADDR32:$negbitshift, uimm32:$bitsize))]> {
4987  let Defs = [CC];
4988  let Has20BitOffset = 1;
4989  let mayLoad = 1;
4990  let mayStore = 1;
4991  let usesCustomInserter = 1;
4992  let hasNoSchedulingInfo = 1;
4993}
4994
4995// Specializations of AtomicLoadWBinary.
4996class AtomicLoadWBinaryReg<SDPatternOperator operator>
4997  : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
4998class AtomicLoadWBinaryImm<SDPatternOperator operator, ImmOpWithPattern imm>
4999  : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;
5000
5001// A pseudo instruction that is a direct alias of a real instruction.
5002// These aliases are used in cases where a particular register operand is
5003// fixed or where the same instruction is used with different register sizes.
5004// The size parameter is the size in bytes of the associated real instruction.
5005class Alias<int size, dag outs, dag ins, list<dag> pattern>
5006  : InstSystemZ<size, outs, ins, "", pattern> {
5007  let isPseudo = 1;
5008  let isCodeGenOnly = 1;
5009}
5010
5011class UnaryAliasVRS<RegisterOperand cls1, RegisterOperand cls2>
5012 : Alias<6, (outs cls1:$src1), (ins cls2:$src2), []>;
5013
5014// An alias of a UnaryVRR*, but with different register sizes.
5015class UnaryAliasVRR<SDPatternOperator operator, TypedReg tr1, TypedReg tr2>
5016  : Alias<6, (outs tr1.op:$V1), (ins tr2.op:$V2),
5017          [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]>;
5018
5019// An alias of a UnaryVRX, but with different register sizes.
5020class UnaryAliasVRX<SDPatternOperator operator, TypedReg tr,
5021                    AddressingMode mode = bdxaddr12only>
5022  : Alias<6, (outs tr.op:$V1), (ins mode:$XBD2),
5023          [(set (tr.vt tr.op:$V1), (operator mode:$XBD2))]>;
5024
5025// An alias of a StoreVRX, but with different register sizes.
5026class StoreAliasVRX<SDPatternOperator operator, TypedReg tr,
5027                    AddressingMode mode = bdxaddr12only>
5028  : Alias<6, (outs), (ins tr.op:$V1, mode:$XBD2),
5029          [(operator (tr.vt tr.op:$V1), mode:$XBD2)]>;
5030
5031// An alias of a BinaryRI, but with different register sizes.
5032class BinaryAliasRI<SDPatternOperator operator, RegisterOperand cls,
5033                    ImmOpWithPattern imm>
5034  : Alias<4, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
5035          [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
5036  let Constraints = "$R1 = $R1src";
5037}
5038
5039// An alias of a BinaryRIL, but with different register sizes.
5040class BinaryAliasRIL<SDPatternOperator operator, RegisterOperand cls,
5041                     ImmOpWithPattern imm>
5042  : Alias<6, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
5043          [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
5044  let Constraints = "$R1 = $R1src";
5045}
5046
5047// An alias of a BinaryVRRf, but with different register sizes.
5048class BinaryAliasVRRf<RegisterOperand cls>
5049  : Alias<6, (outs VR128:$V1), (ins cls:$R2, cls:$R3), []>;
5050
5051// An alias of a CompareRI, but with different register sizes.
5052class CompareAliasRI<SDPatternOperator operator, RegisterOperand cls,
5053                     ImmOpWithPattern imm>
5054  : Alias<4, (outs), (ins cls:$R1, imm:$I2),
5055          [(set CC, (operator cls:$R1, imm:$I2))]> {
5056  let isCompare = 1;
5057}
5058
5059// An alias of a RotateSelectRIEf, but with different register sizes.
5060class RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>
5061  : Alias<6, (outs cls1:$R1),
5062          (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
5063               imm32zx6:$I5), []> {
5064  let Constraints = "$R1 = $R1src";
5065}
5066
5067//===----------------------------------------------------------------------===//
5068// Multiclasses that emit both real and pseudo instructions
5069//===----------------------------------------------------------------------===//
5070
5071multiclass BinaryRXYAndPseudo<string mnemonic, bits<16> opcode,
5072                              SDPatternOperator operator, RegisterOperand cls,
5073                              SDPatternOperator load, bits<5> bytes,
5074                              AddressingMode mode = bdxaddr20only> {
5075
5076  def "" : BinaryRXY<mnemonic, opcode, operator, cls, load, bytes, mode> {
5077    let MemKey = mnemonic#cls;
5078    let MemType = "target";
5079  }
5080  let Has20BitOffset = 1 in
5081    def _MemFoldPseudo : MemFoldPseudo<mnemonic, cls, bytes, mode>;
5082}
5083
5084multiclass BinaryRXPairAndPseudo<string mnemonic, bits<8> rxOpcode,
5085                                 bits<16> rxyOpcode, SDPatternOperator operator,
5086                                 RegisterOperand cls,
5087                                 SDPatternOperator load, bits<5> bytes> {
5088  let DispKey = mnemonic ## #cls in {
5089    def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
5090                      bdxaddr12pair> {
5091      let DispSize = "12";
5092      let MemKey = mnemonic#cls;
5093      let MemType = "target";
5094    }
5095    let DispSize = "20" in
5096      def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load,
5097                         bytes, bdxaddr20pair>;
5098  }
5099  def _MemFoldPseudo : MemFoldPseudo<mnemonic, cls, bytes, bdxaddr12pair>;
5100}
5101
5102multiclass CondUnaryRSYPairAndMemFold<string mnemonic, bits<16> opcode,
5103                                      SDPatternOperator operator,
5104                                      RegisterOperand cls, bits<5> bytes,
5105                                      AddressingMode mode = bdaddr20only> {
5106  defm "" : CondUnaryRSYPair<mnemonic, opcode, operator, cls, bytes, mode>;
5107  def _MemFoldPseudo : MemFoldPseudo_CondMove<mnemonic, cls, bytes, mode>;
5108}
5109
5110multiclass CondUnaryRSYPseudoAndMemFold<string mnemonic,
5111                                        SDPatternOperator operator,
5112                                        RegisterOperand cls, bits<5> bytes,
5113                                        AddressingMode mode = bdaddr20only> {
5114  def "" : CondUnaryRSYPseudo<mnemonic, operator, cls, bytes, mode>;
5115  def _MemFoldPseudo : MemFoldPseudo_CondMove<mnemonic, cls, bytes, mode>;
5116}
5117
5118// Define an instruction that operates on two fixed-length blocks of memory,
5119// and associated pseudo instructions for operating on blocks of any size.
5120// The Sequence form uses a straight-line sequence of instructions and
5121// the Loop form uses a loop of length-256 instructions followed by
5122// another instruction to handle the excess.
5123multiclass MemorySS<string mnemonic, bits<8> opcode,
5124                    SDPatternOperator sequence, SDPatternOperator loop> {
5125  def "" : SideEffectBinarySSa<mnemonic, opcode>;
5126  let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CC] in {
5127    def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5128                                       imm64:$length),
5129                           [(sequence bdaddr12only:$dest, bdaddr12only:$src,
5130                                      imm64:$length)]>;
5131    def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5132                                   imm64:$length, GR64:$count256),
5133                      [(loop bdaddr12only:$dest, bdaddr12only:$src,
5134                             imm64:$length, GR64:$count256)]>;
5135  }
5136}
5137
5138// The same, but setting a CC result as comparion operator.
5139multiclass CompareMemorySS<string mnemonic, bits<8> opcode,
5140                          SDPatternOperator sequence, SDPatternOperator loop> {
5141  def "" : SideEffectBinarySSa<mnemonic, opcode>;
5142  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
5143    def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5144                                       imm64:$length),
5145                           [(set CC, (sequence bdaddr12only:$dest, bdaddr12only:$src,
5146                                               imm64:$length))]>;
5147    def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5148                                   imm64:$length, GR64:$count256),
5149                      [(set CC, (loop bdaddr12only:$dest, bdaddr12only:$src,
5150                                      imm64:$length, GR64:$count256))]>;
5151  }
5152}
5153
5154// Define an instruction that operates on two strings, both terminated
5155// by the character in R0.  The instruction processes a CPU-determinated
5156// number of bytes at a time and sets CC to 3 if the instruction needs
5157// to be repeated.  Also define a pseudo instruction that represents
5158// the full loop (the main instruction plus the branch on CC==3).
5159multiclass StringRRE<string mnemonic, bits<16> opcode,
5160                     SDPatternOperator operator> {
5161  let Uses = [R0L] in
5162    def "" : SideEffectBinaryMemMemRRE<mnemonic, opcode, GR64, GR64>;
5163  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
5164    def Loop : Pseudo<(outs GR64:$end),
5165                      (ins GR64:$start1, GR64:$start2, GR32:$char),
5166                      [(set GR64:$end, (operator GR64:$start1, GR64:$start2,
5167                                                 GR32:$char))]>;
5168}
5169