xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/SystemZInstrFormats.td (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
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, string fp_mnemonic = "">
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  let OpKey = fp_mnemonic#!subst("VR", "FP", !cast<string>(tr1.op));
2922  let OpType = "reg";
2923}
2924
2925class UnaryVRRaGeneric<string mnemonic, bits<16> opcode, bits<4> m4 = 0,
2926                       bits<4> m5 = 0>
2927  : InstVRRa<opcode, (outs VR128:$V1), (ins VR128:$V2, imm32zx4:$M3),
2928             mnemonic#"\t$V1, $V2, $M3", []> {
2929  let M4 = m4;
2930  let M5 = m5;
2931}
2932
2933class UnaryVRRaFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0>
2934  : InstVRRa<opcode, (outs VR128:$V1),
2935             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4),
2936             mnemonic#"\t$V1, $V2, $M3, $M4", []> {
2937  let M5 = m5;
2938}
2939
2940// Declare a pair of instructions, one which sets CC and one which doesn't.
2941// The CC-setting form ends with "S" and sets the low bit of M5.
2942// The form that does not set CC has an extra operand to optionally allow
2943// specifying arbitrary M5 values in assembler.
2944multiclass UnaryExtraVRRaSPair<string mnemonic, bits<16> opcode,
2945                               SDPatternOperator operator,
2946                               SDPatternOperator operator_cc,
2947                               TypedReg tr1, TypedReg tr2, bits<4> type> {
2948  let M3 = type, M4 = 0 in
2949    def "" : InstVRRa<opcode, (outs tr1.op:$V1),
2950                      (ins tr2.op:$V2, imm32zx4:$M5),
2951                      mnemonic#"\t$V1, $V2, $M5", []>;
2952  def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2))),
2953            (!cast<Instruction>(NAME) tr2.op:$V2, 0)>;
2954  def : InstAlias<mnemonic#"\t$V1, $V2",
2955                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2, 0)>;
2956  let Defs = [CC] in
2957    def S : UnaryVRRa<mnemonic#"s", opcode, operator_cc, tr1, tr2,
2958                      type, 0, 1>;
2959}
2960
2961multiclass UnaryExtraVRRaSPairGeneric<string mnemonic, bits<16> opcode> {
2962  let M4 = 0, Defs = [CC] in
2963    def "" : InstVRRa<opcode, (outs VR128:$V1),
2964                     (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M5),
2965                     mnemonic#"\t$V1, $V2, $M3, $M5", []>;
2966  def : InstAlias<mnemonic#"\t$V1, $V2, $M3",
2967                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2,
2968                                            imm32zx4:$M3, 0)>;
2969}
2970
2971class UnaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
2972               TypedReg tr, bits<5> bytes, bits<4> type = 0>
2973  : InstVRX<opcode, (outs tr.op:$V1), (ins bdxaddr12only:$XBD2),
2974            mnemonic#"\t$V1, $XBD2",
2975            [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2))]> {
2976  let M3 = type;
2977  let mayLoad = 1;
2978  let AccessBytes = bytes;
2979}
2980
2981class UnaryVRXGeneric<string mnemonic, bits<16> opcode>
2982  : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
2983            mnemonic#"\t$V1, $XBD2, $M3", []> {
2984  let mayLoad = 1;
2985}
2986
2987multiclass UnaryVRXAlign<string mnemonic, bits<16> opcode> {
2988  let mayLoad = 1, AccessBytes = 16 in {
2989    def Align : InstVRX<opcode, (outs VR128:$V1),
2990                        (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
2991                        mnemonic#"\t$V1, $XBD2, $M3", []>;
2992    let M3 = 0 in
2993      def "" : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2),
2994                       mnemonic#"\t$V1, $XBD2", []>;
2995  }
2996}
2997
2998class SideEffectBinaryRX<string mnemonic, bits<8> opcode,
2999                         RegisterOperand cls>
3000  : InstRXa<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3001            mnemonic#"\t$R1, $XBD2", []>;
3002
3003class SideEffectBinaryRXY<string mnemonic, bits<16> opcode,
3004                          RegisterOperand cls>
3005  : InstRXYa<opcode, (outs), (ins cls:$R1, bdxaddr20only:$XBD2),
3006             mnemonic#"\t$R1, $XBD2", []>;
3007
3008class SideEffectBinaryRILPC<string mnemonic, bits<12> opcode,
3009                            RegisterOperand cls>
3010  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
3011             mnemonic#"\t$R1, $RI2", []> {
3012  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
3013  // However, BDXs have two extra operands and are therefore 6 units more
3014  // complex.
3015  let AddedComplexity = 7;
3016}
3017
3018class SideEffectBinaryRRE<string mnemonic, bits<16> opcode,
3019                          RegisterOperand cls1, RegisterOperand cls2>
3020  : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3021            mnemonic#"\t$R1, $R2", []>;
3022
3023class SideEffectBinaryRRFa<string mnemonic, bits<16> opcode,
3024                           RegisterOperand cls1, RegisterOperand cls2>
3025  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3026             mnemonic#"\t$R1, $R2", []> {
3027  let R3 = 0;
3028  let M4 = 0;
3029}
3030
3031class SideEffectBinaryRRFc<string mnemonic, bits<16> opcode,
3032                           RegisterOperand cls1, RegisterOperand cls2>
3033  : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3034             mnemonic#"\t$R1, $R2", []> {
3035  let M3 = 0;
3036}
3037
3038class SideEffectBinaryIE<string mnemonic, bits<16> opcode,
3039                         ImmOpWithPattern imm1, ImmOpWithPattern imm2>
3040  : InstIE<opcode, (outs), (ins imm1:$I1, imm2:$I2),
3041           mnemonic#"\t$I1, $I2", []>;
3042
3043class SideEffectBinarySI<string mnemonic, bits<8> opcode, Operand imm>
3044  : InstSI<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3045           mnemonic#"\t$BD1, $I2", []>;
3046
3047class SideEffectBinarySIL<string mnemonic, bits<16> opcode,
3048                          SDPatternOperator operator, ImmOpWithPattern imm>
3049  : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3050            mnemonic#"\t$BD1, $I2", [(operator bdaddr12only:$BD1, imm:$I2)]>;
3051
3052class SideEffectBinarySSa<string mnemonic, bits<8> opcode>
3053  : InstSSa<opcode, (outs), (ins bdladdr12onlylen8:$BDL1, bdaddr12only:$BD2),
3054            mnemonic#"\t$BDL1, $BD2", []>;
3055
3056class SideEffectBinarySSb<string mnemonic, bits<8> opcode>
3057  : InstSSb<opcode,
3058            (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
3059            mnemonic#"\t$BDL1, $BDL2", []>;
3060
3061class SideEffectBinarySSf<string mnemonic, bits<8> opcode>
3062  : InstSSf<opcode, (outs), (ins bdaddr12only:$BD1, bdladdr12onlylen8:$BDL2),
3063            mnemonic#"\t$BD1, $BDL2", []>;
3064
3065class SideEffectBinarySSE<string mnemonic, bits<16> opcode>
3066  : InstSSE<opcode, (outs), (ins bdaddr12only:$BD1, bdaddr12only:$BD2),
3067            mnemonic#"\t$BD1, $BD2", []>;
3068
3069class SideEffectBinaryMemMemRR<string mnemonic, bits<8> opcode,
3070                               RegisterOperand cls1, RegisterOperand cls2>
3071  : InstRR<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3072           mnemonic#"\t$R1, $R2", []> {
3073    let Constraints = "$R1 = $R1src, $R2 = $R2src";
3074    let DisableEncoding = "$R1src, $R2src";
3075}
3076
3077class SideEffectBinaryMemRRE<string mnemonic, bits<16> opcode,
3078                             RegisterOperand cls1, RegisterOperand cls2>
3079  : InstRRE<opcode, (outs cls2:$R2), (ins cls1:$R1, cls2:$R2src),
3080            mnemonic#"\t$R1, $R2", []> {
3081  let Constraints = "$R2 = $R2src";
3082  let DisableEncoding = "$R2src";
3083}
3084
3085class SideEffectBinaryMemMemRRE<string mnemonic, bits<16> opcode,
3086                                RegisterOperand cls1, RegisterOperand cls2>
3087  : InstRRE<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3088            mnemonic#"\t$R1, $R2", []> {
3089    let Constraints = "$R1 = $R1src, $R2 = $R2src";
3090    let DisableEncoding = "$R1src, $R2src";
3091}
3092
3093class SideEffectBinaryMemMemRRFc<string mnemonic, bits<16> opcode,
3094                                 RegisterOperand cls1, RegisterOperand cls2>
3095  : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2), (ins cls1:$R1src, cls2:$R2src),
3096             mnemonic#"\t$R1, $R2", []> {
3097  let Constraints = "$R1 = $R1src, $R2 = $R2src";
3098  let DisableEncoding = "$R1src, $R2src";
3099  let M3 = 0;
3100}
3101
3102class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3103               RegisterOperand cls1, RegisterOperand cls2>
3104  : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3105           mnemonic#"\t$R1, $R2",
3106           [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
3107  let OpKey = mnemonic#cls1;
3108  let OpType = "reg";
3109  let Constraints = "$R1 = $R1src";
3110  let DisableEncoding = "$R1src";
3111}
3112
3113class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3114                RegisterOperand cls1, RegisterOperand cls2>
3115  : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3116            mnemonic#"\t$R1, $R2",
3117            [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
3118  let OpKey = mnemonic#cls1;
3119  let OpType = "reg";
3120  let Constraints = "$R1 = $R1src";
3121  let DisableEncoding = "$R1src";
3122}
3123
3124class BinaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3125                RegisterOperand cls1, RegisterOperand cls2>
3126  : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R3, cls2:$R2),
3127            mnemonic#"\t$R1, $R3, $R2",
3128            [(set cls1:$R1, (operator cls2:$R3, cls2:$R2))]> {
3129  let OpKey = mnemonic#cls;
3130  let OpType = "reg";
3131}
3132
3133class BinaryRRFa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3134                 RegisterOperand cls1, RegisterOperand cls2,
3135                 RegisterOperand cls3>
3136  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
3137             mnemonic#"\t$R1, $R2, $R3",
3138             [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
3139  let M4 = 0;
3140  let OpKey = mnemonic#cls1;
3141  let OpType = "reg";
3142}
3143
3144multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3145                        SDPatternOperator operator, RegisterOperand cls1,
3146                        RegisterOperand cls2> {
3147  let NumOpsKey = mnemonic in {
3148    let NumOpsValue = "3" in
3149      def K : BinaryRRFa<mnemonic#"k", opcode2, operator, cls1, cls1, cls2>,
3150              Requires<[FeatureDistinctOps]>;
3151    let NumOpsValue = "2" in
3152      def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
3153  }
3154}
3155
3156multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
3157                         SDPatternOperator operator, RegisterOperand cls1,
3158                         RegisterOperand cls2> {
3159  let NumOpsKey = mnemonic in {
3160    let NumOpsValue = "3" in
3161      def K : BinaryRRFa<mnemonic#"k", opcode2, operator, cls1, cls1, cls2>,
3162              Requires<[FeatureDistinctOps]>;
3163    let NumOpsValue = "2" in
3164      def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
3165  }
3166}
3167
3168class BinaryRRFb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3169                 RegisterOperand cls1, RegisterOperand cls2,
3170                 RegisterOperand cls3>
3171  : InstRRFb<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3),
3172             mnemonic#"\t$R1, $R3, $R2",
3173             [(set cls1:$R1, (operator cls2:$R2, cls3:$R3))]> {
3174  let M4 = 0;
3175}
3176
3177class BinaryRRFc<string mnemonic, bits<16> opcode,
3178                 RegisterOperand cls1, RegisterOperand cls2>
3179  : InstRRFc<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M3),
3180             mnemonic#"\t$R1, $R2, $M3", []>;
3181
3182class BinaryMemRRFc<string mnemonic, bits<16> opcode,
3183                    RegisterOperand cls1, RegisterOperand cls2, ImmOpWithPattern imm>
3184  : InstRRFc<opcode, (outs cls2:$R2, cls1:$R1), (ins cls1:$R1src, imm:$M3),
3185            mnemonic#"\t$R1, $R2, $M3", []> {
3186  let Constraints = "$R1 = $R1src";
3187  let DisableEncoding = "$R1src";
3188}
3189
3190multiclass BinaryMemRRFcOpt<string mnemonic, bits<16> opcode,
3191                            RegisterOperand cls1, RegisterOperand cls2> {
3192  def "" : BinaryMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
3193  def Opt : UnaryMemRRFc<mnemonic, opcode, cls1, cls2>;
3194}
3195
3196class BinaryRRFd<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3197                RegisterOperand cls2>
3198  : InstRRFd<opcode, (outs cls1:$R1), (ins cls2:$R2, imm32zx4:$M4),
3199             mnemonic#"\t$R1, $R2, $M4", []>;
3200
3201class BinaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3202                RegisterOperand cls2>
3203  : InstRRFe<opcode, (outs cls1:$R1), (ins imm32zx4:$M3, cls2:$R2),
3204             mnemonic#"\t$R1, $M3, $R2", []> {
3205  let M4 = 0;
3206}
3207
3208class CondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3209                   RegisterOperand cls2>
3210  : InstRRFc<opcode, (outs cls1:$R1),
3211             (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
3212             mnemonic#"$M3\t$R1, $R2",
3213             [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
3214                                              cond4:$valid, cond4:$M3))]> {
3215  let Constraints = "$R1 = $R1src";
3216  let DisableEncoding = "$R1src";
3217  let CCMaskLast = 1;
3218  let NumOpsKey = !subst("loc", "sel", mnemonic);
3219  let NumOpsValue = "2";
3220  let OpKey = mnemonic#cls1;
3221  let OpType = "reg";
3222}
3223
3224// Like CondBinaryRRF, but used for the raw assembly form.  The condition-code
3225// mask is the third operand rather than being part of the mnemonic.
3226class AsmCondBinaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3227                       RegisterOperand cls2>
3228  : InstRRFc<opcode, (outs cls1:$R1),
3229             (ins cls1:$R1src, cls2:$R2, imm32zx4:$M3),
3230             mnemonic#"\t$R1, $R2, $M3", []> {
3231  let Constraints = "$R1 = $R1src";
3232  let DisableEncoding = "$R1src";
3233}
3234
3235// Like CondBinaryRRF, but with a fixed CC mask.
3236class FixedCondBinaryRRF<CondVariant V, string mnemonic, bits<16> opcode,
3237                         RegisterOperand cls1, RegisterOperand cls2>
3238  : InstRRFc<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
3239             mnemonic#V.suffix#"\t$R1, $R2", []> {
3240  let Constraints = "$R1 = $R1src";
3241  let DisableEncoding = "$R1src";
3242  let isAsmParserOnly = V.alternate;
3243  let M3 = V.ccmask;
3244}
3245
3246multiclass CondBinaryRRFPair<string mnemonic, bits<16> opcode,
3247                             RegisterOperand cls1, RegisterOperand cls2> {
3248  let isCodeGenOnly = 1 in
3249    def "" : CondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3250  def Asm : AsmCondBinaryRRF<mnemonic, opcode, cls1, cls2>;
3251}
3252
3253class CondBinaryRRFa<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3254                    RegisterOperand cls2, RegisterOperand cls3>
3255  : InstRRFa<opcode, (outs cls1:$R1),
3256             (ins cls3:$R3, cls2:$R2, cond4:$valid, cond4:$M4),
3257             mnemonic#"$M4\t$R1, $R2, $R3",
3258             [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls3:$R3,
3259                                              cond4:$valid, cond4:$M4))]> {
3260  let CCMaskLast = 1;
3261  let NumOpsKey = mnemonic;
3262  let NumOpsValue = "3";
3263  let OpKey = mnemonic#cls1;
3264  let OpType = "reg";
3265}
3266
3267// Like CondBinaryRRFa, but used for the raw assembly form.  The condition-code
3268// mask is the third operand rather than being part of the mnemonic.
3269class AsmCondBinaryRRFa<string mnemonic, bits<16> opcode, RegisterOperand cls1,
3270                        RegisterOperand cls2, RegisterOperand cls3>
3271  : InstRRFa<opcode, (outs cls1:$R1), (ins cls3:$R3, cls2:$R2, imm32zx4:$M4),
3272             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
3273
3274// Like CondBinaryRRFa, but with a fixed CC mask.
3275class FixedCondBinaryRRFa<CondVariant V, string mnemonic, bits<16> opcode,
3276                         RegisterOperand cls1, RegisterOperand cls2,
3277                         RegisterOperand cls3>
3278  : InstRRFa<opcode, (outs cls1:$R1), (ins cls3:$R3, cls2:$R2),
3279             mnemonic#V.suffix#"\t$R1, $R2, $R3", []> {
3280  let isAsmParserOnly = V.alternate;
3281  let M4 = V.ccmask;
3282}
3283
3284multiclass CondBinaryRRFaPair<string mnemonic, bits<16> opcode,
3285                             RegisterOperand cls1, RegisterOperand cls2,
3286                             RegisterOperand cls3> {
3287  let isCodeGenOnly = 1 in
3288    def "" : CondBinaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
3289  def Asm : AsmCondBinaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
3290}
3291
3292class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3293               RegisterOperand cls, ImmOpWithPattern imm>
3294  : InstRIa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3295            mnemonic#"\t$R1, $I2",
3296            [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3297  let Constraints = "$R1 = $R1src";
3298  let DisableEncoding = "$R1src";
3299}
3300
3301class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3302                RegisterOperand cls, ImmOpWithPattern imm>
3303  : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
3304             mnemonic#"\t$R1, $R3, $I2",
3305             [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
3306
3307multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
3308                        SDPatternOperator operator, RegisterOperand cls,
3309                        ImmOpWithPattern imm> {
3310  let NumOpsKey = mnemonic in {
3311    let NumOpsValue = "3" in
3312      def K : BinaryRIE<mnemonic#"k", opcode2, operator, cls, imm>,
3313              Requires<[FeatureDistinctOps]>;
3314    let NumOpsValue = "2" in
3315      def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
3316  }
3317}
3318
3319class CondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3320                    ImmOpWithPattern imm>
3321  : InstRIEg<opcode, (outs cls:$R1),
3322             (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
3323             mnemonic#"$M3\t$R1, $I2",
3324             [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
3325                                             cond4:$valid, cond4:$M3))]> {
3326  let Constraints = "$R1 = $R1src";
3327  let DisableEncoding = "$R1src";
3328  let CCMaskLast = 1;
3329}
3330
3331// Like CondBinaryRIE, but used for the raw assembly form.  The condition-code
3332// mask is the third operand rather than being part of the mnemonic.
3333class AsmCondBinaryRIE<string mnemonic, bits<16> opcode, RegisterOperand cls,
3334                       ImmOpWithPattern imm>
3335  : InstRIEg<opcode, (outs cls:$R1),
3336             (ins cls:$R1src, imm:$I2, imm32zx4:$M3),
3337             mnemonic#"\t$R1, $I2, $M3", []> {
3338  let Constraints = "$R1 = $R1src";
3339  let DisableEncoding = "$R1src";
3340}
3341
3342// Like CondBinaryRIE, but with a fixed CC mask.
3343class FixedCondBinaryRIE<CondVariant V, string mnemonic, bits<16> opcode,
3344                         RegisterOperand cls, ImmOpWithPattern imm>
3345  : InstRIEg<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3346             mnemonic#V.suffix#"\t$R1, $I2", []> {
3347  let Constraints = "$R1 = $R1src";
3348  let DisableEncoding = "$R1src";
3349  let isAsmParserOnly = V.alternate;
3350  let M3 = V.ccmask;
3351}
3352
3353multiclass CondBinaryRIEPair<string mnemonic, bits<16> opcode,
3354                             RegisterOperand cls, ImmOpWithPattern imm> {
3355  let isCodeGenOnly = 1 in
3356    def "" : CondBinaryRIE<mnemonic, opcode, cls, imm>;
3357  def Asm : AsmCondBinaryRIE<mnemonic, opcode, cls, imm>;
3358}
3359
3360class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3361                RegisterOperand cls, ImmOpWithPattern imm>
3362  : InstRILa<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
3363             mnemonic#"\t$R1, $I2",
3364             [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
3365  let Constraints = "$R1 = $R1src";
3366  let DisableEncoding = "$R1src";
3367}
3368
3369class BinaryRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3370               RegisterOperand cls>
3371  : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
3372            mnemonic#"\t$R1, $BD2",
3373            [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
3374  let R3 = 0;
3375  let Constraints = "$R1 = $R1src";
3376  let DisableEncoding = "$R1src";
3377}
3378
3379class BinaryRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3380                RegisterOperand cls>
3381  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
3382             mnemonic#"\t$R1, $R3, $BD2",
3383             [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
3384
3385multiclass BinaryRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
3386                        SDPatternOperator operator, RegisterOperand cls> {
3387  let NumOpsKey = mnemonic in {
3388    let NumOpsValue = "3" in
3389      def K  : BinaryRSY<mnemonic#"k", opcode2, operator, cls>,
3390               Requires<[FeatureDistinctOps]>;
3391    let NumOpsValue = "2" in
3392      def "" : BinaryRS<mnemonic, opcode1, operator, cls>;
3393  }
3394}
3395
3396class BinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3397  : InstRSLb<opcode, (outs cls:$R1),
3398             (ins bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3399             mnemonic#"\t$R1, $BDL2, $M3", []> {
3400  let mayLoad = 1;
3401}
3402
3403class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3404               RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3405               AddressingMode mode = bdxaddr12only>
3406  : InstRXa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3407            mnemonic#"\t$R1, $XBD2",
3408            [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3409  let OpKey = mnemonic#"r"#cls;
3410  let OpType = "mem";
3411  let Constraints = "$R1 = $R1src";
3412  let DisableEncoding = "$R1src";
3413  let mayLoad = 1;
3414  let AccessBytes = bytes;
3415}
3416
3417class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3418                  RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3419  : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
3420            mnemonic#"\t$R1, $XBD2",
3421            [(set cls:$R1, (operator cls:$R1src,
3422                                     (load bdxaddr12only:$XBD2)))]> {
3423  let OpKey = mnemonic#"r"#cls;
3424  let OpType = "mem";
3425  let Constraints = "$R1 = $R1src";
3426  let DisableEncoding = "$R1src";
3427  let mayLoad = 1;
3428  let AccessBytes = bytes;
3429  let M3 = 0;
3430}
3431
3432class BinaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3433                RegisterOperand cls1, RegisterOperand cls2,
3434                SDPatternOperator load, bits<5> bytes>
3435  : InstRXF<opcode, (outs cls1:$R1), (ins cls2:$R3, bdxaddr12only:$XBD2),
3436            mnemonic#"\t$R1, $R3, $XBD2",
3437            [(set cls1:$R1, (operator cls2:$R3, (load bdxaddr12only:$XBD2)))]> {
3438  let OpKey = mnemonic#"r"#cls;
3439  let OpType = "mem";
3440  let mayLoad = 1;
3441  let AccessBytes = bytes;
3442}
3443
3444class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3445                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3446                AddressingMode mode = bdxaddr20only>
3447  : InstRXYa<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
3448             mnemonic#"\t$R1, $XBD2",
3449             [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
3450  let OpKey = mnemonic#"r"#cls;
3451  let OpType = "mem";
3452  let Constraints = "$R1 = $R1src";
3453  let DisableEncoding = "$R1src";
3454  let mayLoad = 1;
3455  let AccessBytes = bytes;
3456}
3457
3458multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3459                        SDPatternOperator operator, RegisterOperand cls,
3460                        SDPatternOperator load, bits<5> bytes> {
3461  let DispKey = mnemonic # cls in {
3462    let DispSize = "12" in
3463      def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
3464                        bdxaddr12pair>;
3465    let DispSize = "20" in
3466      def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
3467                         bdxaddr20pair>;
3468  }
3469}
3470
3471class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3472               Operand imm, AddressingMode mode = bdaddr12only>
3473  : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3474           mnemonic#"\t$BD1, $I2",
3475           [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3476  let mayLoad = 1;
3477  let mayStore = 1;
3478}
3479
3480class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3481                Operand imm, AddressingMode mode = bdaddr20only>
3482  : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3483            mnemonic#"\t$BD1, $I2",
3484            [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
3485  let mayLoad = 1;
3486  let mayStore = 1;
3487}
3488
3489multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
3490                        bits<16> siyOpcode, SDPatternOperator operator,
3491                        Operand imm> {
3492  let DispKey = mnemonic # cls in {
3493    let DispSize = "12" in
3494      def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
3495    let DispSize = "20" in
3496      def Y  : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
3497  }
3498}
3499
3500class BinarySSF<string mnemonic, bits<12> opcode, RegisterOperand cls>
3501  : InstSSF<opcode, (outs cls:$R3), (ins bdaddr12pair:$BD1, bdaddr12pair:$BD2),
3502            mnemonic#"\t$R3, $BD1, $BD2", []> {
3503  let mayLoad = 1;
3504}
3505
3506class BinaryVRIb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3507                 TypedReg tr, bits<4> type>
3508  : InstVRIb<opcode, (outs tr.op:$V1), (ins imm32zx8:$I2, imm32zx8:$I3),
3509             mnemonic#"\t$V1, $I2, $I3",
3510             [(set (tr.vt tr.op:$V1), (operator imm32zx8_timm:$I2, imm32zx8_timm:$I3))]> {
3511  let M4 = type;
3512}
3513
3514class BinaryVRIbGeneric<string mnemonic, bits<16> opcode>
3515  : InstVRIb<opcode, (outs VR128:$V1),
3516             (ins imm32zx8:$I2, imm32zx8:$I3, imm32zx4:$M4),
3517             mnemonic#"\t$V1, $I2, $I3, $M4", []>;
3518
3519class BinaryVRIc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3520                 TypedReg tr1, TypedReg tr2, bits<4> type>
3521  : InstVRIc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, imm32zx16:$I2),
3522             mnemonic#"\t$V1, $V3, $I2",
3523             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
3524                                                  imm32zx16_timm:$I2))]> {
3525  let M4 = type;
3526}
3527
3528class BinaryVRIcGeneric<string mnemonic, bits<16> opcode>
3529  : InstVRIc<opcode, (outs VR128:$V1),
3530             (ins VR128:$V3, imm32zx16:$I2, imm32zx4:$M4),
3531             mnemonic#"\t$V1, $V3, $I2, $M4", []>;
3532
3533class BinaryVRIe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3534                 TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m5>
3535  : InstVRIe<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx12:$I3),
3536             mnemonic#"\t$V1, $V2, $I3",
3537             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3538                                                  imm32zx12_timm:$I3))]> {
3539  let M4 = type;
3540  let M5 = m5;
3541}
3542
3543class BinaryVRIeFloatGeneric<string mnemonic, bits<16> opcode>
3544  : InstVRIe<opcode, (outs VR128:$V1),
3545             (ins VR128:$V2, imm32zx12:$I3, imm32zx4:$M4, imm32zx4:$M5),
3546             mnemonic#"\t$V1, $V2, $I3, $M4, $M5", []>;
3547
3548class BinaryVRIh<string mnemonic, bits<16> opcode>
3549  : InstVRIh<opcode, (outs VR128:$V1),
3550             (ins imm32zx16:$I2, imm32zx4:$I3),
3551             mnemonic#"\t$V1, $I2, $I3", []>;
3552
3553class BinaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3554                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m4 = 0>
3555  : InstVRRa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, imm32zx4:$M5),
3556             mnemonic#"\t$V1, $V2, $M5",
3557             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3558                                                  imm32zx12:$M5))]> {
3559  let M3 = type;
3560  let M4 = m4;
3561}
3562
3563class BinaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
3564  : InstVRRa<opcode, (outs VR128:$V1),
3565             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
3566             mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
3567
3568class BinaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3569                 TypedReg tr1, TypedReg tr2, bits<4> type = 0,
3570                 bits<4> modifier = 0>
3571  : InstVRRb<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3572             mnemonic#"\t$V1, $V2, $V3",
3573             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3574                                                  (tr2.vt tr2.op:$V3)))]> {
3575  let M4 = type;
3576  let M5 = modifier;
3577}
3578
3579// Declare a pair of instructions, one which sets CC and one which doesn't.
3580// The CC-setting form ends with "S" and sets the low bit of M5.
3581multiclass BinaryVRRbSPair<string mnemonic, bits<16> opcode,
3582                           SDPatternOperator operator,
3583                           SDPatternOperator operator_cc, TypedReg tr1,
3584                           TypedReg tr2, bits<4> type, bits<4> modifier = 0> {
3585  def "" : BinaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
3586                      !and (modifier, 14)>;
3587  let Defs = [CC] in
3588    def S : BinaryVRRb<mnemonic#"s", opcode, operator_cc, tr1, tr2, type,
3589                       !add (!and (modifier, 14), 1)>;
3590}
3591
3592class BinaryVRRbSPairGeneric<string mnemonic, bits<16> opcode>
3593  : InstVRRb<opcode, (outs VR128:$V1),
3594             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3595             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3596  let Defs = [CC];
3597}
3598
3599// Declare a pair of instructions, one which sets CC and one which doesn't.
3600// The CC-setting form ends with "S" and sets the low bit of M5.
3601// The form that does not set CC has an extra operand to optionally allow
3602// specifying arbitrary M5 values in assembler.
3603multiclass BinaryExtraVRRbSPair<string mnemonic, bits<16> opcode,
3604                                SDPatternOperator operator,
3605                                SDPatternOperator operator_cc,
3606                                TypedReg tr1, TypedReg tr2, bits<4> type> {
3607  let M4 = type in
3608    def "" : InstVRRb<opcode, (outs tr1.op:$V1),
3609                      (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M5),
3610                      mnemonic#"\t$V1, $V2, $V3, $M5", []>;
3611  def : Pat<(tr1.vt (operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3))),
3612            (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, 0)>;
3613  def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
3614                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
3615                                            tr2.op:$V3, 0)>;
3616  let Defs = [CC] in
3617    def S : BinaryVRRb<mnemonic#"s", opcode, operator_cc, tr1, tr2, type, 1>;
3618}
3619
3620multiclass BinaryExtraVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
3621  let Defs = [CC] in
3622    def "" : InstVRRb<opcode, (outs VR128:$V1),
3623                     (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3624                     mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
3625  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
3626                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
3627                                            imm32zx4:$M4, 0)>;
3628}
3629
3630class BinaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3631                 TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m5 = 0,
3632                 bits<4> m6 = 0, string fp_mnemonic = "">
3633  : InstVRRc<opcode, (outs tr1.op:$V1), (ins tr2.op:$V2, tr2.op:$V3),
3634             mnemonic#"\t$V1, $V2, $V3",
3635             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
3636                                                  (tr2.vt tr2.op:$V3)))]> {
3637  let M4 = type;
3638  let M5 = m5;
3639  let M6 = m6;
3640  let OpKey = fp_mnemonic#"MemFold"#!subst("VR", "FP", !cast<string>(tr1.op));
3641  let OpType = "reg";
3642}
3643
3644class BinaryVRRcGeneric<string mnemonic, bits<16> opcode, bits<4> m5 = 0,
3645                        bits<4> m6 = 0>
3646  : InstVRRc<opcode, (outs VR128:$V1),
3647             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4),
3648             mnemonic#"\t$V1, $V2, $V3, $M4", []> {
3649  let M5 = m5;
3650  let M6 = m6;
3651}
3652
3653class BinaryVRRcFloatGeneric<string mnemonic, bits<16> opcode, bits<4> m6 = 0>
3654  : InstVRRc<opcode, (outs VR128:$V1),
3655             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
3656             mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []> {
3657  let M6 = m6;
3658}
3659
3660// Declare a pair of instructions, one which sets CC and one which doesn't.
3661// The CC-setting form ends with "S" and sets the low bit of M5.
3662multiclass BinaryVRRcSPair<string mnemonic, bits<16> opcode,
3663                           SDPatternOperator operator,
3664                           SDPatternOperator operator_cc, TypedReg tr1,
3665                           TypedReg tr2, bits<4> type, bits<4> m5,
3666                           bits<4> modifier = 0> {
3667  def "" : BinaryVRRc<mnemonic, opcode, operator, tr1, tr2, type,
3668                      m5, !and (modifier, 14)>;
3669  let Defs = [CC] in
3670    def S : BinaryVRRc<mnemonic#"s", opcode, operator_cc, tr1, tr2, type,
3671                       m5, !add (!and (modifier, 14), 1)>;
3672}
3673
3674class BinaryVRRcSPairFloatGeneric<string mnemonic, bits<16> opcode>
3675  : InstVRRc<opcode, (outs VR128:$V1),
3676             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
3677                  imm32zx4:$M6),
3678             mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
3679
3680class BinaryVRRf<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3681                 TypedReg tr>
3682  : InstVRRf<opcode, (outs tr.op:$V1), (ins GR64:$R2, GR64:$R3),
3683             mnemonic#"\t$V1, $R2, $R3",
3684             [(set (tr.vt tr.op:$V1), (operator GR64:$R2, GR64:$R3))]>;
3685
3686class BinaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
3687  : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2, imm32zx4:$M3),
3688             mnemonic#"\t$R1, $V2, $M3", []> {
3689  let M4 = 0;
3690}
3691
3692class BinaryVRSa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3693                 TypedReg tr1, TypedReg tr2, bits<4> type>
3694  : InstVRSa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V3, shift12only:$BD2),
3695             mnemonic#"\t$V1, $V3, $BD2",
3696             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V3),
3697                                                  shift12only:$BD2))]> {
3698  let M4 = type;
3699}
3700
3701class BinaryVRSaGeneric<string mnemonic, bits<16> opcode>
3702  : InstVRSa<opcode, (outs VR128:$V1),
3703             (ins VR128:$V3, shift12only:$BD2, imm32zx4:$M4),
3704             mnemonic#"\t$V1, $V3, $BD2, $M4", []>;
3705
3706class BinaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3707                 bits<5> bytes>
3708  : InstVRSb<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3709             mnemonic#"\t$V1, $R3, $BD2",
3710             [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3711  let M4 = 0;
3712  let mayLoad = 1;
3713  let AccessBytes = bytes;
3714}
3715
3716class BinaryVRSc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3717                 TypedReg tr, bits<4> type>
3718  : InstVRSc<opcode, (outs GR64:$R1), (ins tr.op:$V3, shift12only:$BD2),
3719           mnemonic#"\t$R1, $V3, $BD2",
3720           [(set GR64:$R1, (operator (tr.vt tr.op:$V3), shift12only:$BD2))]> {
3721  let M4 = type;
3722}
3723
3724class BinaryVRScGeneric<string mnemonic, bits<16> opcode>
3725  : InstVRSc<opcode, (outs GR64:$R1),
3726             (ins VR128:$V3, shift12only:$BD2, imm32zx4: $M4),
3727             mnemonic#"\t$R1, $V3, $BD2, $M4", []>;
3728
3729class BinaryVRSd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3730                 bits<5> bytes>
3731  : InstVRSd<opcode, (outs VR128:$V1), (ins GR32:$R3, bdaddr12only:$BD2),
3732             mnemonic#"\t$V1, $R3, $BD2",
3733             [(set VR128:$V1, (operator GR32:$R3, bdaddr12only:$BD2))]> {
3734  let mayLoad = 1;
3735  let AccessBytes = bytes;
3736}
3737
3738class BinaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3739                TypedReg tr, bits<5> bytes>
3740  : InstVRX<opcode, (outs VR128:$V1), (ins bdxaddr12only:$XBD2, imm32zx4:$M3),
3741            mnemonic#"\t$V1, $XBD2, $M3",
3742            [(set (tr.vt tr.op:$V1), (operator bdxaddr12only:$XBD2,
3743                                               imm32zx4_timm:$M3))]> {
3744  let mayLoad = 1;
3745  let AccessBytes = bytes;
3746}
3747
3748class StoreBinaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3749                    bits<5> bytes, AddressingMode mode = bdaddr12only>
3750  : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3751            mnemonic#"\t$R1, $M3, $BD2", []> {
3752  let mayStore = 1;
3753  let AccessBytes = bytes;
3754}
3755
3756class StoreBinaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3757                     bits<5> bytes, AddressingMode mode = bdaddr20only>
3758  : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3759             mnemonic#"\t$R1, $M3, $BD2", []> {
3760  let mayStore = 1;
3761  let AccessBytes = bytes;
3762}
3763
3764multiclass StoreBinaryRSPair<string mnemonic, bits<8> rsOpcode,
3765                             bits<16> rsyOpcode, RegisterOperand cls,
3766                             bits<5> bytes> {
3767  let DispKey = mnemonic # cls in {
3768    let DispSize = "12" in
3769      def "" : StoreBinaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3770    let DispSize = "20" in
3771      def Y  : StoreBinaryRSY<mnemonic#"y", rsyOpcode, cls, bytes,
3772                              bdaddr20pair>;
3773  }
3774}
3775
3776class StoreBinaryRSL<string mnemonic, bits<16> opcode, RegisterOperand cls>
3777  : InstRSLb<opcode, (outs),
3778             (ins cls:$R1, bdladdr12onlylen8:$BDL2, imm32zx4:$M3),
3779             mnemonic#"\t$R1, $BDL2, $M3", []> {
3780  let mayStore = 1;
3781}
3782
3783class BinaryVSI<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3784                bits<5> bytes>
3785  : InstVSI<opcode, (outs VR128:$V1), (ins bdaddr12only:$BD2, imm32zx8:$I3),
3786            mnemonic#"\t$V1, $BD2, $I3",
3787            [(set VR128:$V1, (operator imm32zx8:$I3, bdaddr12only:$BD2))]> {
3788  let mayLoad = 1;
3789  let AccessBytes = bytes;
3790}
3791
3792class StoreBinaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
3793                     ImmOpWithPattern index>
3794  : InstVRV<opcode, (outs), (ins VR128:$V1, bdvaddr12only:$VBD2, index:$M3),
3795            mnemonic#"\t$V1, $VBD2, $M3", []> {
3796  let mayStore = 1;
3797  let AccessBytes = bytes;
3798}
3799
3800class StoreBinaryVRX<string mnemonic, bits<16> opcode,
3801                     SDPatternOperator operator, TypedReg tr, bits<5> bytes,
3802                     ImmOpWithPattern index>
3803  : InstVRX<opcode, (outs), (ins tr.op:$V1, bdxaddr12only:$XBD2, index:$M3),
3804            mnemonic#"\t$V1, $XBD2, $M3",
3805            [(operator (tr.vt tr.op:$V1), bdxaddr12only:$XBD2, index:$M3)]> {
3806  let mayStore = 1;
3807  let AccessBytes = bytes;
3808}
3809
3810class MemoryBinarySSd<string mnemonic, bits<8> opcode,
3811                      RegisterOperand cls>
3812  : InstSSd<opcode, (outs),
3813            (ins bdraddr12only:$RBD1, bdaddr12only:$BD2, cls:$R3),
3814            mnemonic#"\t$RBD1, $BD2, $R3", []>;
3815
3816class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3817                RegisterOperand cls1, RegisterOperand cls2>
3818  : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3819           mnemonic#"\t$R1, $R2",
3820           [(set CC, (operator cls1:$R1, cls2:$R2))]> {
3821  let OpKey = mnemonic#cls1;
3822  let OpType = "reg";
3823  let isCompare = 1;
3824}
3825
3826class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3827                 RegisterOperand cls1, RegisterOperand cls2>
3828  : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
3829            mnemonic#"\t$R1, $R2",
3830            [(set CC, (operator cls1:$R1, cls2:$R2))]> {
3831  let OpKey = mnemonic#cls1;
3832  let OpType = "reg";
3833  let isCompare = 1;
3834}
3835
3836class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3837                RegisterOperand cls, ImmOpWithPattern imm>
3838  : InstRIa<opcode, (outs), (ins cls:$R1, imm:$I2),
3839            mnemonic#"\t$R1, $I2",
3840            [(set CC, (operator cls:$R1, imm:$I2))]> {
3841  let isCompare = 1;
3842}
3843
3844class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3845                 RegisterOperand cls, ImmOpWithPattern imm>
3846  : InstRILa<opcode, (outs), (ins cls:$R1, imm:$I2),
3847             mnemonic#"\t$R1, $I2",
3848             [(set CC, (operator cls:$R1, imm:$I2))]> {
3849  let isCompare = 1;
3850}
3851
3852class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
3853                   RegisterOperand cls, SDPatternOperator load>
3854  : InstRILb<opcode, (outs), (ins cls:$R1, pcrel32:$RI2),
3855             mnemonic#"\t$R1, $RI2",
3856             [(set CC, (operator cls:$R1, (load pcrel32:$RI2)))]> {
3857  let isCompare = 1;
3858  let mayLoad = 1;
3859  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
3860  // However, BDXs have two extra operands and are therefore 6 units more
3861  // complex.
3862  let AddedComplexity = 7;
3863}
3864
3865class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3866                RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3867                AddressingMode mode = bdxaddr12only>
3868  : InstRXa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3869            mnemonic#"\t$R1, $XBD2",
3870            [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
3871  let OpKey = mnemonic#"r"#cls;
3872  let OpType = "mem";
3873  let isCompare = 1;
3874  let mayLoad = 1;
3875  let AccessBytes = bytes;
3876}
3877
3878class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3879                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
3880  : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
3881            mnemonic#"\t$R1, $XBD2",
3882            [(set CC, (operator cls:$R1, (load bdxaddr12only:$XBD2)))]> {
3883  let OpKey = mnemonic#"r"#cls;
3884  let OpType = "mem";
3885  let isCompare = 1;
3886  let mayLoad = 1;
3887  let AccessBytes = bytes;
3888  let M3 = 0;
3889}
3890
3891class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3892                 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
3893                 AddressingMode mode = bdxaddr20only>
3894  : InstRXYa<opcode, (outs), (ins cls:$R1, mode:$XBD2),
3895             mnemonic#"\t$R1, $XBD2",
3896             [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
3897  let OpKey = mnemonic#"r"#cls;
3898  let OpType = "mem";
3899  let isCompare = 1;
3900  let mayLoad = 1;
3901  let AccessBytes = bytes;
3902}
3903
3904multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
3905                         SDPatternOperator operator, RegisterOperand cls,
3906                         SDPatternOperator load, bits<5> bytes> {
3907  let DispKey = mnemonic # cls in {
3908    let DispSize = "12" in
3909      def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
3910                         load, bytes, bdxaddr12pair>;
3911    let DispSize = "20" in
3912      def Y  : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
3913                          load, bytes, bdxaddr20pair>;
3914  }
3915}
3916
3917class CompareRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
3918                bits<5> bytes, AddressingMode mode = bdaddr12only>
3919  : InstRSb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3920            mnemonic#"\t$R1, $M3, $BD2", []> {
3921  let mayLoad = 1;
3922  let AccessBytes = bytes;
3923}
3924
3925class CompareRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
3926                 bits<5> bytes, AddressingMode mode = bdaddr20only>
3927  : InstRSYb<opcode, (outs), (ins cls:$R1, imm32zx4:$M3, mode:$BD2),
3928             mnemonic#"\t$R1, $M3, $BD2", []> {
3929  let mayLoad = 1;
3930  let AccessBytes = bytes;
3931}
3932
3933multiclass CompareRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
3934                         RegisterOperand cls, bits<5> bytes> {
3935  let DispKey = mnemonic # cls in {
3936    let DispSize = "12" in
3937      def "" : CompareRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
3938    let DispSize = "20" in
3939      def Y  : CompareRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
3940  }
3941}
3942
3943class CompareSSb<string mnemonic, bits<8> opcode>
3944  : InstSSb<opcode,
3945            (outs), (ins bdladdr12onlylen4:$BDL1, bdladdr12onlylen4:$BDL2),
3946            mnemonic#"\t$BDL1, $BDL2", []> {
3947  let isCompare = 1;
3948  let mayLoad = 1;
3949}
3950
3951class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
3952                SDPatternOperator load, ImmOpWithPattern imm,
3953                AddressingMode mode = bdaddr12only>
3954  : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
3955           mnemonic#"\t$BD1, $I2",
3956           [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
3957  let isCompare = 1;
3958  let mayLoad = 1;
3959}
3960
3961class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3962                 SDPatternOperator load, ImmOpWithPattern imm>
3963  : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
3964            mnemonic#"\t$BD1, $I2",
3965            [(set CC, (operator (load bdaddr12only:$BD1), imm:$I2))]> {
3966  let isCompare = 1;
3967  let mayLoad = 1;
3968}
3969
3970class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3971                 SDPatternOperator load, ImmOpWithPattern imm,
3972                 AddressingMode mode = bdaddr20only>
3973  : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
3974            mnemonic#"\t$BD1, $I2",
3975            [(set CC, (operator (load mode:$BD1), imm:$I2))]> {
3976  let isCompare = 1;
3977  let mayLoad = 1;
3978}
3979
3980multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
3981                         SDPatternOperator operator, SDPatternOperator load,
3982                         ImmOpWithPattern imm> {
3983  let DispKey = mnemonic in {
3984    let DispSize = "12" in
3985      def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
3986    let DispSize = "20" in
3987      def Y  : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
3988                          bdaddr20pair>;
3989  }
3990}
3991
3992class CompareVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
3993                  TypedReg tr, bits<4> type, string fp_mnemonic = "">
3994  : InstVRRa<opcode, (outs), (ins tr.op:$V1, tr.op:$V2),
3995             mnemonic#"\t$V1, $V2",
3996             [(set CC, (operator (tr.vt tr.op:$V1), (tr.vt tr.op:$V2)))]> {
3997  let isCompare = 1;
3998  let M3 = type;
3999  let M4 = 0;
4000  let M5 = 0;
4001  let OpKey = fp_mnemonic#!subst("VR", "FP", !cast<string>(tr.op));
4002  let OpType = "reg";
4003}
4004
4005class CompareVRRaGeneric<string mnemonic, bits<16> opcode>
4006  : InstVRRa<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
4007             mnemonic#"\t$V1, $V2, $M3", []> {
4008  let isCompare = 1;
4009  let M4 = 0;
4010  let M5 = 0;
4011}
4012
4013class CompareVRRaFloatGeneric<string mnemonic, bits<16> opcode>
4014  : InstVRRa<opcode, (outs),
4015             (ins VR64:$V1, VR64:$V2, imm32zx4:$M3, imm32zx4:$M4),
4016             mnemonic#"\t$V1, $V2, $M3, $M4", []> {
4017  let isCompare = 1;
4018  let M5 = 0;
4019}
4020
4021class CompareVRRh<string mnemonic, bits<16> opcode>
4022  : InstVRRh<opcode, (outs), (ins VR128:$V1, VR128:$V2, imm32zx4:$M3),
4023             mnemonic#"\t$V1, $V2, $M3", []> {
4024  let isCompare = 1;
4025}
4026
4027class TestInherentS<string mnemonic, bits<16> opcode,
4028                    SDPatternOperator operator>
4029  : InstS<opcode, (outs), (ins), mnemonic, [(set CC, (operator))]> {
4030  let BD2 = 0;
4031}
4032
4033class TestRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4034              RegisterOperand cls>
4035  : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
4036            mnemonic#"\t$R1, $XBD2",
4037            [(set CC, (operator cls:$R1, bdxaddr12only:$XBD2))]> {
4038  let M3 = 0;
4039}
4040
4041class TestBinarySIL<string mnemonic, bits<16> opcode,
4042                    SDPatternOperator operator, ImmOpWithPattern imm>
4043  : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
4044            mnemonic#"\t$BD1, $I2",
4045            [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
4046
4047class TestRSL<string mnemonic, bits<16> opcode>
4048  : InstRSLa<opcode, (outs), (ins bdladdr12onlylen4:$BDL1),
4049             mnemonic#"\t$BDL1", []> {
4050  let mayLoad = 1;
4051}
4052
4053class TestVRRg<string mnemonic, bits<16> opcode>
4054  : InstVRRg<opcode, (outs), (ins VR128:$V1),
4055             mnemonic#"\t$V1", []>;
4056
4057class SideEffectTernarySSc<string mnemonic, bits<8> opcode>
4058  : InstSSc<opcode, (outs), (ins bdladdr12onlylen4:$BDL1,
4059                                 shift12only:$BD2, imm32zx4:$I3),
4060            mnemonic#"\t$BDL1, $BD2, $I3", []>;
4061
4062class SideEffectTernaryRRFa<string mnemonic, bits<16> opcode,
4063                            RegisterOperand cls1, RegisterOperand cls2,
4064                            RegisterOperand cls3>
4065  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
4066             mnemonic#"\t$R1, $R2, $R3", []> {
4067  let M4 = 0;
4068}
4069
4070class SideEffectTernaryMemMemRRFa<string mnemonic, bits<16> opcode,
4071                                  RegisterOperand cls1, RegisterOperand cls2,
4072                                  RegisterOperand cls3>
4073  : InstRRFa<opcode, (outs cls1:$R1, cls2:$R2),
4074             (ins cls1:$R1src, cls2:$R2src, cls3:$R3),
4075             mnemonic#"\t$R1, $R2, $R3", []> {
4076  let Constraints = "$R1 = $R1src, $R2 = $R2src";
4077  let DisableEncoding = "$R1src, $R2src";
4078  let M4 = 0;
4079}
4080
4081class SideEffectTernaryRRFb<string mnemonic, bits<16> opcode,
4082                            RegisterOperand cls1, RegisterOperand cls2,
4083                            RegisterOperand cls3>
4084  : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3),
4085             mnemonic#"\t$R1, $R3, $R2", []> {
4086  let M4 = 0;
4087}
4088
4089class SideEffectTernaryMemMemMemRRFb<string mnemonic, bits<16> opcode,
4090                                     RegisterOperand cls1,
4091                                     RegisterOperand cls2,
4092                                     RegisterOperand cls3>
4093  : InstRRFb<opcode, (outs cls1:$R1, cls2:$R2, cls3:$R3),
4094             (ins cls1:$R1src, cls2:$R2src, cls3:$R3src),
4095             mnemonic#"\t$R1, $R3, $R2", []> {
4096  let Constraints = "$R1 = $R1src, $R2 = $R2src, $R3 = $R3src";
4097  let DisableEncoding = "$R1src, $R2src, $R3src";
4098  let M4 = 0;
4099}
4100
4101class SideEffectTernaryRRFc<string mnemonic, bits<16> opcode,
4102                            RegisterOperand cls1, RegisterOperand cls2,
4103                            ImmOpWithPattern imm>
4104  : InstRRFc<opcode, (outs), (ins cls1:$R1, cls2:$R2, imm:$M3),
4105             mnemonic#"\t$R1, $R2, $M3", []>;
4106
4107multiclass SideEffectTernaryRRFcOpt<string mnemonic, bits<16> opcode,
4108                                    RegisterOperand cls1,
4109                                    RegisterOperand cls2> {
4110  def "" : SideEffectTernaryRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
4111  def Opt : SideEffectBinaryRRFc<mnemonic, opcode, cls1, cls2>;
4112}
4113
4114class SideEffectTernaryMemMemRRFc<string mnemonic, bits<16> opcode,
4115                                  RegisterOperand cls1, RegisterOperand cls2,
4116                                  ImmOpWithPattern imm>
4117  : InstRRFc<opcode, (outs cls1:$R1, cls2:$R2),
4118             (ins cls1:$R1src, cls2:$R2src, imm:$M3),
4119             mnemonic#"\t$R1, $R2, $M3", []> {
4120  let Constraints = "$R1 = $R1src, $R2 = $R2src";
4121  let DisableEncoding = "$R1src, $R2src";
4122}
4123
4124multiclass SideEffectTernaryMemMemRRFcOpt<string mnemonic, bits<16> opcode,
4125                                          RegisterOperand cls1,
4126                                          RegisterOperand cls2> {
4127  def "" : SideEffectTernaryMemMemRRFc<mnemonic, opcode, cls1, cls2, imm32zx4>;
4128  def Opt : SideEffectBinaryMemMemRRFc<mnemonic, opcode, cls1, cls2>;
4129}
4130
4131class SideEffectTernarySSF<string mnemonic, bits<12> opcode,
4132                           RegisterOperand cls>
4133  : InstSSF<opcode, (outs),
4134            (ins bdaddr12only:$BD1, bdaddr12only:$BD2, cls:$R3),
4135            mnemonic#"\t$BD1, $BD2, $R3", []>;
4136
4137class TernaryRRFa<string mnemonic, bits<16> opcode,
4138                 RegisterOperand cls1, RegisterOperand cls2,
4139                 RegisterOperand cls3>
4140  : InstRRFa<opcode, (outs cls1:$R1), (ins cls2:$R2, cls3:$R3, imm32zx4:$M4),
4141             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4142
4143class TernaryRRFb<string mnemonic, bits<16> opcode,
4144                  RegisterOperand cls1, RegisterOperand cls2,
4145                  RegisterOperand cls3>
4146  : InstRRFb<opcode, (outs cls1:$R1, cls3:$R3),
4147             (ins cls1:$R1src, cls2:$R2, imm32zx4:$M4),
4148             mnemonic#"\t$R1, $R3, $R2, $M4", []> {
4149  let Constraints = "$R1 = $R1src";
4150  let DisableEncoding = "$R1src";
4151}
4152
4153class TernaryRRFe<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4154                  RegisterOperand cls2>
4155  : InstRRFe<opcode, (outs cls1:$R1),
4156             (ins imm32zx4:$M3, cls2:$R2, imm32zx4:$M4),
4157             mnemonic#"\t$R1, $M3, $R2, $M4", []>;
4158
4159class TernaryRRD<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4160                 RegisterOperand cls1, RegisterOperand cls2>
4161  : InstRRD<opcode, (outs cls1:$R1), (ins cls2:$R1src, cls2:$R3, cls2:$R2),
4162            mnemonic#"\t$R1, $R3, $R2",
4163            [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3, cls2:$R2))]> {
4164  let OpKey = mnemonic#cls;
4165  let OpType = "reg";
4166  let Constraints = "$R1 = $R1src";
4167  let DisableEncoding = "$R1src";
4168}
4169
4170class TernaryRS<string mnemonic, bits<8> opcode, RegisterOperand cls,
4171                bits<5> bytes, AddressingMode mode = bdaddr12only>
4172  : InstRSb<opcode, (outs cls:$R1),
4173            (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4174            mnemonic#"\t$R1, $M3, $BD2", []> {
4175
4176  let Constraints = "$R1 = $R1src";
4177  let DisableEncoding = "$R1src";
4178  let mayLoad = 1;
4179  let AccessBytes = bytes;
4180}
4181
4182class TernaryRSY<string mnemonic, bits<16> opcode, RegisterOperand cls,
4183                bits<5> bytes, AddressingMode mode = bdaddr20only>
4184  : InstRSYb<opcode, (outs cls:$R1),
4185             (ins cls:$R1src, imm32zx4:$M3, mode:$BD2),
4186             mnemonic#"\t$R1, $M3, $BD2", []> {
4187
4188  let Constraints = "$R1 = $R1src";
4189  let DisableEncoding = "$R1src";
4190  let mayLoad = 1;
4191  let AccessBytes = bytes;
4192}
4193
4194multiclass TernaryRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4195                         RegisterOperand cls, bits<5> bytes> {
4196  let DispKey = mnemonic # cls in {
4197    let DispSize = "12" in
4198      def "" : TernaryRS<mnemonic, rsOpcode, cls, bytes, bdaddr12pair>;
4199    let DispSize = "20" in
4200      def Y  : TernaryRSY<mnemonic#"y", rsyOpcode, cls, bytes, bdaddr20pair>;
4201  }
4202}
4203
4204class SideEffectTernaryRS<string mnemonic, bits<8> opcode,
4205                          RegisterOperand cls1, RegisterOperand cls2>
4206  : InstRSa<opcode, (outs),
4207            (ins cls1:$R1, cls2:$R3, bdaddr12only:$BD2),
4208            mnemonic#"\t$R1, $R3, $BD2", []>;
4209
4210class SideEffectTernaryRSY<string mnemonic, bits<16> opcode,
4211                           RegisterOperand cls1, RegisterOperand cls2>
4212  : InstRSYa<opcode, (outs),
4213             (ins cls1:$R1, cls2:$R3, bdaddr20only:$BD2),
4214             mnemonic#"\t$R1, $R3, $BD2", []>;
4215
4216class SideEffectTernaryMemMemRS<string mnemonic, bits<8> opcode,
4217                                RegisterOperand cls1, RegisterOperand cls2>
4218  : InstRSa<opcode, (outs cls1:$R1, cls2:$R3),
4219            (ins cls1:$R1src, cls2:$R3src, shift12only:$BD2),
4220            mnemonic#"\t$R1, $R3, $BD2", []> {
4221    let Constraints = "$R1 = $R1src, $R3 = $R3src";
4222    let DisableEncoding = "$R1src, $R3src";
4223}
4224
4225class SideEffectTernaryMemMemRSY<string mnemonic, bits<16> opcode,
4226                                 RegisterOperand cls1, RegisterOperand cls2>
4227  : InstRSYa<opcode, (outs cls1:$R1, cls2:$R3),
4228             (ins cls1:$R1src, cls2:$R3src, shift20only:$BD2),
4229             mnemonic#"\t$R1, $R3, $BD2", []> {
4230    let Constraints = "$R1 = $R1src, $R3 = $R3src";
4231    let DisableEncoding = "$R1src, $R3src";
4232}
4233
4234class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4235                 RegisterOperand cls1, RegisterOperand cls2,
4236                 SDPatternOperator load, bits<5> bytes>
4237  : InstRXF<opcode, (outs cls1:$R1),
4238            (ins cls2:$R1src, cls2:$R3, bdxaddr12only:$XBD2),
4239            mnemonic#"\t$R1, $R3, $XBD2",
4240            [(set cls1:$R1, (operator cls2:$R1src, cls2:$R3,
4241                                      (load bdxaddr12only:$XBD2)))]> {
4242  let OpKey = mnemonic#"r"#cls;
4243  let OpType = "mem";
4244  let Constraints = "$R1 = $R1src";
4245  let DisableEncoding = "$R1src";
4246  let mayLoad = 1;
4247  let AccessBytes = bytes;
4248}
4249
4250class TernaryVRIa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4251                  TypedReg tr1, TypedReg tr2, ImmOpWithPattern imm, ImmOpWithPattern index>
4252  : InstVRIa<opcode, (outs tr1.op:$V1), (ins tr2.op:$V1src, imm:$I2, index:$M3),
4253             mnemonic#"\t$V1, $I2, $M3",
4254             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4255                                                  imm:$I2, index:$M3))]> {
4256  let Constraints = "$V1 = $V1src";
4257  let DisableEncoding = "$V1src";
4258}
4259
4260class TernaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4261                  TypedReg tr1, TypedReg tr2, bits<4> type>
4262  : InstVRId<opcode, (outs tr1.op:$V1),
4263             (ins tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4264             mnemonic#"\t$V1, $V2, $V3, $I4",
4265             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4266                                                  (tr2.vt tr2.op:$V3),
4267                                                  imm32zx8_timm:$I4))]> {
4268  let M5 = type;
4269}
4270
4271class TernaryVRIi<string mnemonic, bits<16> opcode, RegisterOperand cls>
4272  : InstVRIi<opcode, (outs VR128:$V1),
4273             (ins cls:$R2, imm32zx8:$I3, imm32zx4:$M4),
4274             mnemonic#"\t$V1, $R2, $I3, $M4", []>;
4275
4276class TernaryVRRa<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4277                  TypedReg tr1, TypedReg tr2, bits<4> type, bits<4> m4or>
4278  : InstVRRa<opcode, (outs tr1.op:$V1),
4279             (ins tr2.op:$V2, imm32zx4:$M4, imm32zx4:$M5),
4280             mnemonic#"\t$V1, $V2, $M4, $M5",
4281             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4282                                                  imm32zx4_timm:$M4,
4283                                                  imm32zx4_timm:$M5))],
4284             m4or> {
4285  let M3 = type;
4286}
4287
4288class TernaryVRRaFloatGeneric<string mnemonic, bits<16> opcode>
4289  : InstVRRa<opcode, (outs VR128:$V1),
4290             (ins VR128:$V2, imm32zx4:$M3, imm32zx4:$M4, imm32zx4:$M5),
4291             mnemonic#"\t$V1, $V2, $M3, $M4, $M5", []>;
4292
4293class TernaryVRRb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4294                  TypedReg tr1, TypedReg tr2, bits<4> type,
4295                  SDPatternOperator m5mask, bits<4> m5or>
4296  : InstVRRb<opcode, (outs tr1.op:$V1),
4297             (ins tr2.op:$V2, tr2.op:$V3, m5mask:$M5),
4298             mnemonic#"\t$V1, $V2, $V3, $M5",
4299             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4300                                                  (tr2.vt tr2.op:$V3),
4301                                                  m5mask:$M5))],
4302             m5or> {
4303  let M4 = type;
4304}
4305
4306// Declare a pair of instructions, one which sets CC and one which doesn't.
4307// The CC-setting form ends with "S" and sets the low bit of M5.
4308// Also create aliases to make use of M5 operand optional in assembler.
4309multiclass TernaryOptVRRbSPair<string mnemonic, bits<16> opcode,
4310                               SDPatternOperator operator,
4311                               SDPatternOperator operator_cc,
4312                               TypedReg tr1, TypedReg tr2, bits<4> type,
4313                               bits<4> modifier = 0> {
4314  def "" : TernaryVRRb<mnemonic, opcode, operator, tr1, tr2, type,
4315                       imm32zx4even_timm, !and (modifier, 14)>;
4316  def : InstAlias<mnemonic#"\t$V1, $V2, $V3",
4317                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4318                                            tr2.op:$V3, 0)>;
4319  let Defs = [CC] in
4320    def S : TernaryVRRb<mnemonic#"s", opcode, operator_cc, tr1, tr2, type,
4321                        imm32zx4even_timm, !add(!and (modifier, 14), 1)>;
4322  def : InstAlias<mnemonic#"s\t$V1, $V2, $V3",
4323                  (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4324                                                tr2.op:$V3, 0)>;
4325}
4326
4327multiclass TernaryOptVRRbSPairGeneric<string mnemonic, bits<16> opcode> {
4328  let Defs = [CC] in
4329    def "" : InstVRRb<opcode, (outs VR128:$V1),
4330                     (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5),
4331                     mnemonic#"\t$V1, $V2, $V3, $M4, $M5", []>;
4332  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $M4",
4333                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4334                                            imm32zx4:$M4, 0)>;
4335}
4336
4337class TernaryVRRc<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4338                  TypedReg tr1, TypedReg tr2>
4339  : InstVRRc<opcode, (outs tr1.op:$V1),
4340             (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M4),
4341             mnemonic#"\t$V1, $V2, $V3, $M4",
4342             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4343                                                  (tr2.vt tr2.op:$V3),
4344                                                  imm32zx4_timm:$M4))]> {
4345  let M5 = 0;
4346  let M6 = 0;
4347}
4348
4349class TernaryVRRcFloat<string mnemonic, bits<16> opcode,
4350                       SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4351                       bits<4> type = 0, bits<4> m5 = 0>
4352  : InstVRRc<opcode, (outs tr1.op:$V1),
4353             (ins tr2.op:$V2, tr2.op:$V3, imm32zx4:$M6),
4354             mnemonic#"\t$V1, $V2, $V3, $M6",
4355             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4356                                                  (tr2.vt tr2.op:$V3),
4357                                                  imm32zx4_timm:$M6))]> {
4358  let M4 = type;
4359  let M5 = m5;
4360}
4361
4362class TernaryVRRcFloatGeneric<string mnemonic, bits<16> opcode>
4363  : InstVRRc<opcode, (outs VR128:$V1),
4364             (ins VR128:$V2, VR128:$V3, imm32zx4:$M4, imm32zx4:$M5,
4365                  imm32zx4:$M6),
4366             mnemonic#"\t$V1, $V2, $V3, $M4, $M5, $M6", []>;
4367
4368class TernaryVRRd<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4369                  TypedReg tr1, TypedReg tr2, bits<4> type = 0, bits<4> m6 = 0>
4370  : InstVRRd<opcode, (outs tr1.op:$V1),
4371             (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4372             mnemonic#"\t$V1, $V2, $V3, $V4",
4373             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4374                                                  (tr2.vt tr2.op:$V3),
4375                                                  (tr1.vt tr1.op:$V4)))]> {
4376  let M5 = type;
4377  let M6 = m6;
4378}
4379
4380class TernaryVRRdGeneric<string mnemonic, bits<16> opcode>
4381  : InstVRRd<opcode, (outs VR128:$V1),
4382             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5),
4383             mnemonic#"\t$V1, $V2, $V3, $V4, $M5", []> {
4384  let M6 = 0;
4385}
4386
4387// Ternary operation where the assembler mnemonic has an extra operand to
4388// optionally allow specifying arbitrary M6 values.
4389multiclass TernaryExtraVRRd<string mnemonic, bits<16> opcode,
4390                             SDPatternOperator operator,
4391                             TypedReg tr1, TypedReg tr2, bits<4> type> {
4392  let M5 = type, Defs = [CC] in
4393    def "" : InstVRRd<opcode, (outs tr1.op:$V1),
4394                      (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4, imm32zx4:$M6),
4395                      mnemonic#"\t$V1, $V2, $V3, $V4, $M6", []>;
4396  def : Pat<(operator (tr2.vt tr2.op:$V2), (tr2.vt tr2.op:$V3),
4397                      (tr1.vt tr1.op:$V4)),
4398            (!cast<Instruction>(NAME) tr2.op:$V2, tr2.op:$V3, tr1.op:$V4, 0)>;
4399  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
4400                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4401                                            tr2.op:$V3, tr1.op:$V4, 0)>;
4402}
4403
4404multiclass TernaryExtraVRRdGeneric<string mnemonic, bits<16> opcode> {
4405  let Defs = [CC] in
4406    def "" : InstVRRd<opcode, (outs VR128:$V1),
4407                      (ins VR128:$V2, VR128:$V3, VR128:$V4,
4408                       imm32zx4:$M5, imm32zx4:$M6),
4409                      mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4410  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
4411                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4412                                            VR128:$V4, imm32zx4:$M5, 0)>;
4413}
4414
4415class TernaryVRRe<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4416                  TypedReg tr1, TypedReg tr2, bits<4> m5 = 0, bits<4> type = 0,
4417                  string fp_mnemonic = "">
4418  : InstVRRe<opcode, (outs tr1.op:$V1),
4419             (ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
4420             mnemonic#"\t$V1, $V2, $V3, $V4",
4421             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4422                                                  (tr2.vt tr2.op:$V3),
4423                                                  (tr1.vt tr1.op:$V4)))]> {
4424  let M5 = m5;
4425  let M6 = type;
4426  let OpKey = fp_mnemonic#"MemFold"#!subst("VR", "FP", !cast<string>(tr1.op));
4427  let OpType = "reg";
4428}
4429
4430class TernaryVRReFloatGeneric<string mnemonic, bits<16> opcode>
4431  : InstVRRe<opcode, (outs VR128:$V1),
4432             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4433             mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4434
4435class TernaryVRSb<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4436                  TypedReg tr1, TypedReg tr2, RegisterOperand cls, bits<4> type>
4437  : InstVRSb<opcode, (outs tr1.op:$V1),
4438             (ins tr2.op:$V1src, cls:$R3, shift12only:$BD2),
4439             mnemonic#"\t$V1, $R3, $BD2",
4440             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4441                                                  cls:$R3,
4442                                                  shift12only:$BD2))]> {
4443  let Constraints = "$V1 = $V1src";
4444  let DisableEncoding = "$V1src";
4445  let M4 = type;
4446}
4447
4448class TernaryVRRi<string mnemonic, bits<16> opcode, RegisterOperand cls>
4449  : InstVRRi<opcode, (outs cls:$R1), (ins VR128:$V2,
4450                                      imm32zx4:$M3, imm32zx4:$M4),
4451             mnemonic#"\t$R1, $V2, $M3, $M4", []>;
4452
4453class TernaryVRSbGeneric<string mnemonic, bits<16> opcode>
4454  : InstVRSb<opcode, (outs VR128:$V1),
4455             (ins VR128:$V1src, GR64:$R3, shift12only:$BD2, imm32zx4:$M4),
4456             mnemonic#"\t$V1, $R3, $BD2, $M4", []> {
4457  let Constraints = "$V1 = $V1src";
4458  let DisableEncoding = "$V1src";
4459}
4460
4461class TernaryVRV<string mnemonic, bits<16> opcode, bits<5> bytes,
4462                 ImmOpWithPattern index>
4463  : InstVRV<opcode, (outs VR128:$V1),
4464           (ins VR128:$V1src, bdvaddr12only:$VBD2, index:$M3),
4465           mnemonic#"\t$V1, $VBD2, $M3", []> {
4466  let Constraints = "$V1 = $V1src";
4467  let DisableEncoding = "$V1src";
4468  let mayLoad = 1;
4469  let AccessBytes = bytes;
4470}
4471
4472class TernaryVRX<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4473                 TypedReg tr1, TypedReg tr2, bits<5> bytes, ImmOpWithPattern index>
4474  : InstVRX<opcode, (outs tr1.op:$V1),
4475           (ins tr2.op:$V1src, bdxaddr12only:$XBD2, index:$M3),
4476           mnemonic#"\t$V1, $XBD2, $M3",
4477           [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4478                                                bdxaddr12only:$XBD2,
4479                                                index:$M3))]> {
4480  let Constraints = "$V1 = $V1src";
4481  let DisableEncoding = "$V1src";
4482  let mayLoad = 1;
4483  let AccessBytes = bytes;
4484}
4485
4486class QuaternaryVRId<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4487                     TypedReg tr1, TypedReg tr2, bits<4> type>
4488  : InstVRId<opcode, (outs tr1.op:$V1),
4489             (ins tr2.op:$V1src, tr2.op:$V2, tr2.op:$V3, imm32zx8:$I4),
4490             mnemonic#"\t$V1, $V2, $V3, $I4",
4491             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V1src),
4492                                                  (tr2.vt tr2.op:$V2),
4493                                                  (tr2.vt tr2.op:$V3),
4494                                                  imm32zx8_timm:$I4))]> {
4495  let Constraints = "$V1 = $V1src";
4496  let DisableEncoding = "$V1src";
4497  let M5 = type;
4498}
4499
4500class QuaternaryVRIdGeneric<string mnemonic, bits<16> opcode>
4501  : InstVRId<opcode, (outs VR128:$V1),
4502             (ins VR128:$V1src, VR128:$V2, VR128:$V3,
4503                  imm32zx8:$I4, imm32zx4:$M5),
4504             mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []> {
4505  let Constraints = "$V1 = $V1src";
4506  let DisableEncoding = "$V1src";
4507}
4508
4509class QuaternaryVRIf<string mnemonic, bits<16> opcode>
4510  : InstVRIf<opcode, (outs VR128:$V1),
4511             (ins VR128:$V2, VR128:$V3,
4512                  imm32zx8:$I4, imm32zx4:$M5),
4513            mnemonic#"\t$V1, $V2, $V3, $I4, $M5", []>;
4514
4515class QuaternaryVRIg<string mnemonic, bits<16> opcode>
4516  : InstVRIg<opcode, (outs VR128:$V1),
4517             (ins VR128:$V2, imm32zx8:$I3,
4518                  imm32zx8:$I4, imm32zx4:$M5),
4519             mnemonic#"\t$V1, $V2, $I3, $I4, $M5", []>;
4520
4521class QuaternaryVRRd<string mnemonic, bits<16> opcode,
4522                     SDPatternOperator operator, TypedReg tr1, TypedReg tr2,
4523                     TypedReg tr3, TypedReg tr4, bits<4> type,
4524                     SDPatternOperator m6mask = imm32zx4_timm, bits<4> m6or = 0>
4525  : InstVRRd<opcode, (outs tr1.op:$V1),
4526             (ins tr2.op:$V2, tr3.op:$V3, tr4.op:$V4, m6mask:$M6),
4527             mnemonic#"\t$V1, $V2, $V3, $V4, $M6",
4528             [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2),
4529                                                  (tr3.vt tr3.op:$V3),
4530                                                  (tr4.vt tr4.op:$V4),
4531                                                  m6mask:$M6))],
4532             m6or> {
4533  let M5 = type;
4534}
4535
4536class QuaternaryVRRdGeneric<string mnemonic, bits<16> opcode>
4537  : InstVRRd<opcode, (outs VR128:$V1),
4538             (ins VR128:$V2, VR128:$V3, VR128:$V4, imm32zx4:$M5, imm32zx4:$M6),
4539             mnemonic#"\t$V1, $V2, $V3, $V4, $M5, $M6", []>;
4540
4541// Declare a pair of instructions, one which sets CC and one which doesn't.
4542// The CC-setting form ends with "S" and sets the low bit of M6.
4543// Also create aliases to make use of M6 operand optional in assembler.
4544multiclass QuaternaryOptVRRdSPair<string mnemonic, bits<16> opcode,
4545                                  SDPatternOperator operator,
4546                                SDPatternOperator operator_cc,
4547                                TypedReg tr1, TypedReg tr2, bits<4> type,
4548                                bits<4> modifier = 0> {
4549  def "" : QuaternaryVRRd<mnemonic, opcode, operator,
4550                          tr1, tr2, tr2, tr2, type,
4551                          imm32zx4even_timm, !and (modifier, 14)>;
4552  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4",
4553                  (!cast<Instruction>(NAME) tr1.op:$V1, tr2.op:$V2,
4554                                            tr2.op:$V3, tr2.op:$V4, 0)>;
4555  let Defs = [CC] in
4556    def S : QuaternaryVRRd<mnemonic#"s", opcode, operator_cc,
4557                           tr1, tr2, tr2, tr2, type,
4558                           imm32zx4even_timm, !add (!and (modifier, 14), 1)>;
4559  def : InstAlias<mnemonic#"s\t$V1, $V2, $V3, $V4",
4560                  (!cast<Instruction>(NAME#"S") tr1.op:$V1, tr2.op:$V2,
4561                                                tr2.op:$V3, tr2.op:$V4, 0)>;
4562}
4563
4564multiclass QuaternaryOptVRRdSPairGeneric<string mnemonic, bits<16> opcode> {
4565  let Defs = [CC] in
4566    def "" : QuaternaryVRRdGeneric<mnemonic, opcode>;
4567  def : InstAlias<mnemonic#"\t$V1, $V2, $V3, $V4, $M5",
4568                  (!cast<Instruction>(NAME) VR128:$V1, VR128:$V2, VR128:$V3,
4569                                            VR128:$V4, imm32zx4_timm:$M5, 0)>;
4570}
4571
4572class SideEffectQuaternaryRRFa<string mnemonic, bits<16> opcode,
4573                               RegisterOperand cls1, RegisterOperand cls2,
4574                               RegisterOperand cls3>
4575  : InstRRFa<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4576             mnemonic#"\t$R1, $R2, $R3, $M4", []>;
4577
4578multiclass SideEffectQuaternaryRRFaOptOpt<string mnemonic, bits<16> opcode,
4579                                          RegisterOperand cls1,
4580                                          RegisterOperand cls2,
4581                                          RegisterOperand cls3> {
4582  def "" : SideEffectQuaternaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4583  def Opt : SideEffectTernaryRRFa<mnemonic, opcode, cls1, cls2, cls3>;
4584  def OptOpt : SideEffectBinaryRRFa<mnemonic, opcode, cls1, cls2>;
4585}
4586
4587class SideEffectQuaternaryRRFb<string mnemonic, bits<16> opcode,
4588                               RegisterOperand cls1, RegisterOperand cls2,
4589                               RegisterOperand cls3>
4590  : InstRRFb<opcode, (outs), (ins cls1:$R1, cls2:$R2, cls3:$R3, imm32zx4:$M4),
4591             mnemonic#"\t$R1, $R3, $R2, $M4", []>;
4592
4593multiclass SideEffectQuaternaryRRFbOpt<string mnemonic, bits<16> opcode,
4594                                       RegisterOperand cls1,
4595                                       RegisterOperand cls2,
4596                                       RegisterOperand cls3> {
4597  def "" : SideEffectQuaternaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4598  def Opt : SideEffectTernaryRRFb<mnemonic, opcode, cls1, cls2, cls3>;
4599}
4600
4601class SideEffectQuaternarySSe<string mnemonic, bits<8> opcode,
4602                              RegisterOperand cls>
4603  : InstSSe<opcode, (outs),
4604            (ins cls:$R1, bdaddr12only:$BD2, cls:$R3, bdaddr12only:$BD4),
4605            mnemonic#"\t$R1, $BD2, $R3, $BD4", []>;
4606
4607class LoadAndOpRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4608                  RegisterOperand cls, AddressingMode mode = bdaddr20only>
4609  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
4610             mnemonic#"\t$R1, $R3, $BD2",
4611             [(set cls:$R1, (operator mode:$BD2, cls:$R3))]> {
4612  let mayLoad = 1;
4613  let mayStore = 1;
4614}
4615
4616class CmpSwapRRE<string mnemonic, bits<16> opcode,
4617                 RegisterOperand cls1, RegisterOperand cls2>
4618  : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
4619            mnemonic#"\t$R1, $R2", []> {
4620  let Constraints = "$R1 = $R1src";
4621  let DisableEncoding = "$R1src";
4622  let mayLoad = 1;
4623  let mayStore = 1;
4624}
4625
4626class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
4627                RegisterOperand cls, AddressingMode mode = bdaddr12only>
4628  : InstRSa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4629            mnemonic#"\t$R1, $R3, $BD2",
4630            [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4631  let Constraints = "$R1 = $R1src";
4632  let DisableEncoding = "$R1src";
4633  let mayLoad = 1;
4634  let mayStore = 1;
4635}
4636
4637class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
4638                 RegisterOperand cls, AddressingMode mode = bdaddr20only>
4639  : InstRSYa<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
4640             mnemonic#"\t$R1, $R3, $BD2",
4641             [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
4642  let Constraints = "$R1 = $R1src";
4643  let DisableEncoding = "$R1src";
4644  let mayLoad = 1;
4645  let mayStore = 1;
4646}
4647
4648multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
4649                         SDPatternOperator operator, RegisterOperand cls> {
4650  let DispKey = mnemonic # cls in {
4651    let DispSize = "12" in
4652      def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
4653    let DispSize = "20" in
4654      def Y  : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
4655  }
4656}
4657
4658class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
4659                       RegisterOperand cls2>
4660  : InstRIEf<opcode, (outs cls1:$R1),
4661             (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4662                  imm32zx6:$I5),
4663             mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
4664  let Constraints = "$R1 = $R1src";
4665  let DisableEncoding = "$R1src";
4666}
4667
4668class PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator>
4669  : InstRXYb<opcode, (outs), (ins imm32zx4:$M1, bdxaddr20only:$XBD2),
4670             mnemonic#"\t$M1, $XBD2",
4671             [(operator imm32zx4_timm:$M1, bdxaddr20only:$XBD2)]>;
4672
4673class PrefetchRILPC<string mnemonic, bits<12> opcode,
4674                    SDPatternOperator operator>
4675  : InstRILc<opcode, (outs), (ins imm32zx4_timm:$M1, pcrel32:$RI2),
4676             mnemonic#"\t$M1, $RI2",
4677             [(operator imm32zx4_timm:$M1, pcrel32:$RI2)]> {
4678  // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
4679  // However, BDXs have two extra operands and are therefore 6 units more
4680  // complex.
4681  let AddedComplexity = 7;
4682}
4683
4684class BranchPreloadSMI<string mnemonic, bits<8> opcode>
4685  : InstSMI<opcode, (outs),
4686            (ins imm32zx4:$M1, brtarget16bpp:$RI2, bdxaddr12only:$BD3),
4687            mnemonic#"\t$M1, $RI2, $BD3", []>;
4688
4689class BranchPreloadMII<string mnemonic, bits<8> opcode>
4690  : InstMII<opcode, (outs),
4691            (ins imm32zx4:$M1, brtarget12bpp:$RI2, brtarget24bpp:$RI3),
4692            mnemonic#"\t$M1, $RI2, $RI3", []>;
4693
4694// A floating-point load-and test operation.  Create both a normal unary
4695// operation and one that acts as a comparison against zero.
4696// Note that the comparison against zero operation is not available if we
4697// have vector support, since load-and-test instructions will partially
4698// clobber the target (vector) register.
4699multiclass LoadAndTestRRE<string mnemonic, bits<16> opcode,
4700                          RegisterOperand cls> {
4701  def "" : UnaryRRE<mnemonic, opcode, null_frag, cls, cls>;
4702  let isCodeGenOnly = 1, Predicates = [FeatureNoVector] in
4703    def Compare : CompareRRE<mnemonic, opcode, null_frag, cls, cls>;
4704}
4705
4706//===----------------------------------------------------------------------===//
4707// Pseudo instructions
4708//===----------------------------------------------------------------------===//
4709//
4710// Convenience instructions that get lowered to real instructions
4711// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
4712// or SystemZInstrInfo::expandPostRAPseudo().
4713//
4714//===----------------------------------------------------------------------===//
4715
4716class Pseudo<dag outs, dag ins, list<dag> pattern>
4717  : InstSystemZ<0, outs, ins, "", pattern> {
4718  let isPseudo = 1;
4719  let isCodeGenOnly = 1;
4720}
4721
4722// Like UnaryRI, but expanded after RA depending on the choice of register.
4723class UnaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4724                    ImmOpWithPattern imm>
4725  : Pseudo<(outs cls:$R1), (ins imm:$I2),
4726           [(set cls:$R1, (operator imm:$I2))]>;
4727
4728// Like UnaryRXY, but expanded after RA depending on the choice of register.
4729class UnaryRXYPseudo<string key, SDPatternOperator operator,
4730                     RegisterOperand cls, bits<5> bytes,
4731                     AddressingMode mode = bdxaddr20only>
4732  : Pseudo<(outs cls:$R1), (ins mode:$XBD2),
4733           [(set cls:$R1, (operator mode:$XBD2))]> {
4734  let OpKey = key#"r"#cls;
4735  let OpType = "mem";
4736  let mayLoad = 1;
4737  let Has20BitOffset = 1;
4738  let HasIndex = 1;
4739  let AccessBytes = bytes;
4740}
4741
4742// Like UnaryRR, but expanded after RA depending on the choice of registers.
4743class UnaryRRPseudo<string key, SDPatternOperator operator,
4744                    RegisterOperand cls1, RegisterOperand cls2>
4745  : Pseudo<(outs cls1:$R1), (ins cls2:$R2),
4746           [(set cls1:$R1, (operator cls2:$R2))]> {
4747  let OpKey = key#cls1;
4748  let OpType = "reg";
4749}
4750
4751// Like BinaryRI, but expanded after RA depending on the choice of register.
4752class BinaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4753                     ImmOpWithPattern imm>
4754  : Pseudo<(outs cls:$R1), (ins cls:$R1src, imm:$I2),
4755           [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
4756  let Constraints = "$R1 = $R1src";
4757}
4758
4759// Like BinaryRIE, but expanded after RA depending on the choice of register.
4760class BinaryRIEPseudo<SDPatternOperator operator, RegisterOperand cls,
4761                      ImmOpWithPattern imm>
4762  : Pseudo<(outs cls:$R1), (ins cls:$R3, imm:$I2),
4763           [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
4764
4765// Like BinaryRIAndK, but expanded after RA depending on the choice of register.
4766multiclass BinaryRIAndKPseudo<string key, SDPatternOperator operator,
4767                              RegisterOperand cls, ImmOpWithPattern imm> {
4768  let NumOpsKey = key in {
4769    let NumOpsValue = "3" in
4770      def K : BinaryRIEPseudo<operator, cls, imm>,
4771              Requires<[FeatureHighWord, FeatureDistinctOps]>;
4772    let NumOpsValue = "2" in
4773      def "" : BinaryRIPseudo<operator, cls, imm>,
4774               Requires<[FeatureHighWord]>;
4775  }
4776}
4777
4778// A pseudo that is used during register allocation when folding a memory
4779// operand. The 3-address register instruction with a spilled source cannot
4780// be converted directly to a target 2-address reg/mem instruction.
4781// Mapping:  <INSN>R  ->  MemFoldPseudo  ->  <INSN>
4782class MemFoldPseudo<string mnemonic, RegisterOperand cls, bits<5> bytes,
4783                    AddressingMode mode>
4784  : Pseudo<(outs cls:$R1), (ins cls:$R2, mode:$XBD2), []> {
4785    let OpKey = !subst("mscrk", "msrkc",
4786                !subst("msgcrk", "msgrkc",
4787                mnemonic#"rk"#cls));
4788    let OpType = "mem";
4789    let MemKey = mnemonic#cls;
4790    let MemType = "pseudo";
4791    let mayLoad = 1;
4792    let AccessBytes = bytes;
4793    let HasIndex = 1;
4794    let hasNoSchedulingInfo = 1;
4795}
4796
4797// Same as MemFoldPseudo but for mapping a W... vector instruction
4798class MemFoldPseudo_FP<string mnemonic, RegisterOperand cls, bits<5> bytes,
4799                    AddressingMode mode>
4800  : MemFoldPseudo<mnemonic, cls, bytes, mode> {
4801    let OpKey = mnemonic#"r"#"MemFold"#cls;
4802}
4803
4804class MemFoldPseudo_FPTern<string mnemonic, RegisterOperand cls, bits<5> bytes,
4805                           AddressingMode mode>
4806  : Pseudo<(outs cls:$R1), (ins cls:$R2, cls:$R3, mode:$XBD2), []> {
4807    let OpKey = mnemonic#"r"#"MemFold"#cls;
4808    let OpType = "mem";
4809    let MemKey = mnemonic#cls;
4810    let MemType = "pseudo";
4811    let mayLoad = 1;
4812    let AccessBytes = bytes;
4813    let HasIndex = 1;
4814    let hasNoSchedulingInfo = 1;
4815}
4816
4817// Same as MemFoldPseudo but for Load On Condition with CC operands.
4818class MemFoldPseudo_CondMove<string mnemonic, RegisterOperand cls, bits<5> bytes,
4819                             AddressingMode mode>
4820  : Pseudo<(outs cls:$R1),
4821           (ins cls:$R2, mode:$XBD2, cond4:$valid, cond4:$M3), []> {
4822    let OpKey = !subst("loc", "sel", mnemonic)#"r"#cls;
4823    let OpType = "mem";
4824    let MemKey = mnemonic#cls;
4825    let MemType = "pseudo";
4826    let mayLoad = 1;
4827    let AccessBytes = bytes;
4828    let hasNoSchedulingInfo = 1;
4829}
4830
4831// Like CompareRI, but expanded after RA depending on the choice of register.
4832class CompareRIPseudo<SDPatternOperator operator, RegisterOperand cls,
4833                      ImmOpWithPattern imm>
4834  : Pseudo<(outs), (ins cls:$R1, imm:$I2),
4835           [(set CC, (operator cls:$R1, imm:$I2))]> {
4836  let isCompare = 1;
4837}
4838
4839// Like CompareRXY, but expanded after RA depending on the choice of register.
4840class CompareRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4841                       SDPatternOperator load, bits<5> bytes,
4842                       AddressingMode mode = bdxaddr20only>
4843  : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4844           [(set CC, (operator cls:$R1, (load mode:$XBD2)))]> {
4845  let mayLoad = 1;
4846  let Has20BitOffset = 1;
4847  let HasIndex = 1;
4848  let AccessBytes = bytes;
4849}
4850
4851// Like TestBinarySIL, but expanded later.
4852class TestBinarySILPseudo<SDPatternOperator operator, ImmOpWithPattern imm>
4853  : Pseudo<(outs), (ins bdaddr12only:$BD1, imm:$I2),
4854           [(set CC, (operator bdaddr12only:$BD1, imm:$I2))]>;
4855
4856// Like CondBinaryRRF, but expanded after RA depending on the choice of
4857// register.
4858class CondBinaryRRFPseudo<string mnemonic, RegisterOperand cls1,
4859                          RegisterOperand cls2>
4860  : Pseudo<(outs cls1:$R1),
4861           (ins cls1:$R1src, cls2:$R2, cond4:$valid, cond4:$M3),
4862           [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls1:$R1src,
4863                                            cond4:$valid, cond4:$M3))]> {
4864  let Constraints = "$R1 = $R1src";
4865  let DisableEncoding = "$R1src";
4866  let CCMaskLast = 1;
4867  let NumOpsKey = !subst("loc", "sel", mnemonic);
4868  let NumOpsValue = "2";
4869  let OpKey = mnemonic#cls1;
4870  let OpType = "reg";
4871}
4872
4873// Like CondBinaryRRFa, but expanded after RA depending on the choice of
4874// register.
4875class CondBinaryRRFaPseudo<string mnemonic, RegisterOperand cls1,
4876                           RegisterOperand cls2, RegisterOperand cls3>
4877  : Pseudo<(outs cls1:$R1),
4878           (ins cls3:$R3, cls2:$R2, cond4:$valid, cond4:$M4),
4879           [(set cls1:$R1, (z_select_ccmask cls2:$R2, cls3:$R3,
4880                                            cond4:$valid, cond4:$M4))]> {
4881  let CCMaskLast = 1;
4882  let NumOpsKey = mnemonic;
4883  let NumOpsValue = "3";
4884  let OpKey = mnemonic#cls1;
4885  let OpType = "reg";
4886}
4887
4888// Like CondBinaryRIE, but expanded after RA depending on the choice of
4889// register.
4890class CondBinaryRIEPseudo<RegisterOperand cls, ImmOpWithPattern imm>
4891  : Pseudo<(outs cls:$R1),
4892           (ins cls:$R1src, imm:$I2, cond4:$valid, cond4:$M3),
4893           [(set cls:$R1, (z_select_ccmask imm:$I2, cls:$R1src,
4894                                           cond4:$valid, cond4:$M3))]> {
4895  let Constraints = "$R1 = $R1src";
4896  let DisableEncoding = "$R1src";
4897  let CCMaskLast = 1;
4898}
4899
4900// Like CondUnaryRSY, but expanded after RA depending on the choice of
4901// register.
4902class CondUnaryRSYPseudo<string mnemonic, SDPatternOperator operator,
4903                         RegisterOperand cls, bits<5> bytes,
4904                         AddressingMode mode = bdaddr20only>
4905  : Pseudo<(outs cls:$R1),
4906           (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
4907           [(set cls:$R1,
4908                 (z_select_ccmask (operator mode:$BD2), cls:$R1src,
4909                                  cond4:$valid, cond4:$R3))]> {
4910  let Constraints = "$R1 = $R1src";
4911  let DisableEncoding = "$R1src";
4912  let mayLoad = 1;
4913  let AccessBytes = bytes;
4914  let CCMaskLast = 1;
4915  let OpKey = mnemonic#"r"#cls;
4916  let OpType = "mem";
4917  let MemKey = mnemonic#cls;
4918  let MemType = "target";
4919}
4920
4921// Like CondStoreRSY, but expanded after RA depending on the choice of
4922// register.
4923class CondStoreRSYPseudo<RegisterOperand cls, bits<5> bytes,
4924                         AddressingMode mode = bdaddr20only>
4925  : Pseudo<(outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3), []> {
4926  let mayStore = 1;
4927  let AccessBytes = bytes;
4928  let CCMaskLast = 1;
4929}
4930
4931// Like StoreRXY, but expanded after RA depending on the choice of register.
4932class StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
4933                     bits<5> bytes, AddressingMode mode = bdxaddr20only>
4934  : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
4935           [(operator cls:$R1, mode:$XBD2)]> {
4936  let mayStore = 1;
4937  let Has20BitOffset = 1;
4938  let HasIndex = 1;
4939  let AccessBytes = bytes;
4940}
4941
4942// Like RotateSelectRIEf, but expanded after RA depending on the choice
4943// of registers.
4944class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>
4945  : Pseudo<(outs cls1:$R1),
4946           (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
4947                imm32zx6:$I5),
4948           []> {
4949  let Constraints = "$R1 = $R1src";
4950  let DisableEncoding = "$R1src";
4951}
4952
4953// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
4954// the value of the PSW's 2-bit condition code field.
4955class SelectWrapper<ValueType vt, RegisterOperand cls>
4956  : Pseudo<(outs cls:$dst),
4957           (ins cls:$src1, cls:$src2, imm32zx4:$valid, imm32zx4:$cc),
4958           [(set (vt cls:$dst), (z_select_ccmask cls:$src1, cls:$src2,
4959                                            imm32zx4_timm:$valid, imm32zx4_timm:$cc))]> {
4960  let usesCustomInserter = 1;
4961  let hasNoSchedulingInfo = 1;
4962  let Uses = [CC];
4963}
4964
4965// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
4966multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
4967                      SDPatternOperator load, AddressingMode mode> {
4968  let Uses = [CC], usesCustomInserter = 1, hasNoSchedulingInfo = 1,
4969      mayLoad = 1, mayStore = 1 in {
4970    def "" : Pseudo<(outs),
4971                    (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4972                    [(store (z_select_ccmask cls:$new, (load mode:$addr),
4973                                             imm32zx4_timm:$valid, imm32zx4_timm:$cc),
4974                            mode:$addr)]>;
4975    def Inv : Pseudo<(outs),
4976                     (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),
4977                     [(store (z_select_ccmask (load mode:$addr), cls:$new,
4978                                              imm32zx4_timm:$valid, imm32zx4_timm:$cc),
4979                              mode:$addr)]>;
4980  }
4981}
4982
4983// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation.  PAT and OPERAND
4984// describe the second (non-memory) operand.
4985class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
4986                       dag pat, DAGOperand operand>
4987  : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
4988           [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
4989  let Defs = [CC];
4990  let Has20BitOffset = 1;
4991  let mayLoad = 1;
4992  let mayStore = 1;
4993  let usesCustomInserter = 1;
4994  let hasNoSchedulingInfo = 1;
4995}
4996
4997// Specializations of AtomicLoadWBinary.
4998class AtomicLoadBinaryReg32<SDPatternOperator operator>
4999  : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
5000class AtomicLoadBinaryImm32<SDPatternOperator operator, ImmOpWithPattern imm>
5001  : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
5002class AtomicLoadBinaryReg64<SDPatternOperator operator>
5003  : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
5004class AtomicLoadBinaryImm64<SDPatternOperator operator, ImmOpWithPattern imm>
5005  : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
5006
5007// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation.  PAT and OPERAND
5008// describe the second (non-memory) operand.
5009class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
5010                        DAGOperand operand>
5011  : Pseudo<(outs GR32:$dst),
5012           (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
5013                ADDR32:$negbitshift, uimm32:$bitsize),
5014           [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
5015                                      ADDR32:$negbitshift, uimm32:$bitsize))]> {
5016  let Defs = [CC];
5017  let Has20BitOffset = 1;
5018  let mayLoad = 1;
5019  let mayStore = 1;
5020  let usesCustomInserter = 1;
5021  let hasNoSchedulingInfo = 1;
5022}
5023
5024// Specializations of AtomicLoadWBinary.
5025class AtomicLoadWBinaryReg<SDPatternOperator operator>
5026  : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
5027class AtomicLoadWBinaryImm<SDPatternOperator operator, ImmOpWithPattern imm>
5028  : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;
5029
5030// A pseudo instruction that is a direct alias of a real instruction.
5031// These aliases are used in cases where a particular register operand is
5032// fixed or where the same instruction is used with different register sizes.
5033// The size parameter is the size in bytes of the associated real instruction.
5034class Alias<int size, dag outs, dag ins, list<dag> pattern>
5035  : InstSystemZ<size, outs, ins, "", pattern> {
5036  let isPseudo = 1;
5037  let isCodeGenOnly = 1;
5038}
5039
5040class UnaryAliasVRS<RegisterOperand cls1, RegisterOperand cls2>
5041 : Alias<6, (outs cls1:$src1), (ins cls2:$src2), []>;
5042
5043// An alias of a UnaryVRR*, but with different register sizes.
5044class UnaryAliasVRR<SDPatternOperator operator, TypedReg tr1, TypedReg tr2>
5045  : Alias<6, (outs tr1.op:$V1), (ins tr2.op:$V2),
5046          [(set (tr1.vt tr1.op:$V1), (operator (tr2.vt tr2.op:$V2)))]>;
5047
5048// An alias of a UnaryVRX, but with different register sizes.
5049class UnaryAliasVRX<SDPatternOperator operator, TypedReg tr,
5050                    AddressingMode mode = bdxaddr12only>
5051  : Alias<6, (outs tr.op:$V1), (ins mode:$XBD2),
5052          [(set (tr.vt tr.op:$V1), (operator mode:$XBD2))]>;
5053
5054// An alias of a StoreVRX, but with different register sizes.
5055class StoreAliasVRX<SDPatternOperator operator, TypedReg tr,
5056                    AddressingMode mode = bdxaddr12only>
5057  : Alias<6, (outs), (ins tr.op:$V1, mode:$XBD2),
5058          [(operator (tr.vt tr.op:$V1), mode:$XBD2)]>;
5059
5060// An alias of a BinaryRI, but with different register sizes.
5061class BinaryAliasRI<SDPatternOperator operator, RegisterOperand cls,
5062                    ImmOpWithPattern imm>
5063  : Alias<4, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
5064          [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
5065  let Constraints = "$R1 = $R1src";
5066}
5067
5068// An alias of a BinaryRIL, but with different register sizes.
5069class BinaryAliasRIL<SDPatternOperator operator, RegisterOperand cls,
5070                     ImmOpWithPattern imm>
5071  : Alias<6, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
5072          [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
5073  let Constraints = "$R1 = $R1src";
5074}
5075
5076// An alias of a BinaryVRRf, but with different register sizes.
5077class BinaryAliasVRRf<RegisterOperand cls>
5078  : Alias<6, (outs VR128:$V1), (ins cls:$R2, cls:$R3), []>;
5079
5080// An alias of a CompareRI, but with different register sizes.
5081class CompareAliasRI<SDPatternOperator operator, RegisterOperand cls,
5082                     ImmOpWithPattern imm>
5083  : Alias<4, (outs), (ins cls:$R1, imm:$I2),
5084          [(set CC, (operator cls:$R1, imm:$I2))]> {
5085  let isCompare = 1;
5086}
5087
5088// An alias of a RotateSelectRIEf, but with different register sizes.
5089class RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>
5090  : Alias<6, (outs cls1:$R1),
5091          (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4,
5092               imm32zx6:$I5), []> {
5093  let Constraints = "$R1 = $R1src";
5094}
5095
5096//===----------------------------------------------------------------------===//
5097// Multiclasses that emit both real and pseudo instructions
5098//===----------------------------------------------------------------------===//
5099
5100multiclass BinaryRXYAndPseudo<string mnemonic, bits<16> opcode,
5101                              SDPatternOperator operator, RegisterOperand cls,
5102                              SDPatternOperator load, bits<5> bytes,
5103                              AddressingMode mode = bdxaddr20only> {
5104  def "" : BinaryRXY<mnemonic, opcode, operator, cls, load, bytes, mode> {
5105    let MemKey = mnemonic#cls;
5106    let MemType = "target";
5107  }
5108  let Has20BitOffset = 1 in
5109    def _MemFoldPseudo : MemFoldPseudo<mnemonic, cls, bytes, mode>;
5110}
5111
5112multiclass BinaryRXPairAndPseudo<string mnemonic, bits<8> rxOpcode,
5113                                 bits<16> rxyOpcode, SDPatternOperator operator,
5114                                 RegisterOperand cls,
5115                                 SDPatternOperator load, bits<5> bytes> {
5116  let DispKey = mnemonic # cls in {
5117    def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
5118                      bdxaddr12pair> {
5119      let DispSize = "12";
5120      let MemKey = mnemonic#cls;
5121      let MemType = "target";
5122    }
5123    let DispSize = "20" in
5124      def Y  : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load,
5125                         bytes, bdxaddr20pair>;
5126  }
5127  def _MemFoldPseudo : MemFoldPseudo<mnemonic, cls, bytes, bdxaddr12pair>;
5128}
5129
5130multiclass BinaryRXEAndPseudo<string mnemonic, bits<16> opcode,
5131                              SDPatternOperator operator, RegisterOperand cls,
5132                              SDPatternOperator load, bits<5> bytes> {
5133  def "" : BinaryRXE<mnemonic, opcode, operator, cls, load, bytes> {
5134    let MemKey = mnemonic#cls;
5135    let MemType = "target";
5136  }
5137  def _MemFoldPseudo : MemFoldPseudo_FP<mnemonic, cls, bytes, bdxaddr12pair>;
5138}
5139
5140multiclass TernaryRXFAndPseudo<string mnemonic, bits<16> opcode,
5141                               SDPatternOperator operator, RegisterOperand cls1,
5142                               RegisterOperand cls2, SDPatternOperator load,
5143                               bits<5> bytes> {
5144  def "" : TernaryRXF<mnemonic, opcode, operator, cls1, cls2, load, bytes> {
5145    let MemKey = mnemonic#cls1;
5146    let MemType = "target";
5147  }
5148  def _MemFoldPseudo : MemFoldPseudo_FPTern<mnemonic, cls1, bytes, bdxaddr12pair>;
5149}
5150
5151multiclass CondUnaryRSYPairAndMemFold<string mnemonic, bits<16> opcode,
5152                                      SDPatternOperator operator,
5153                                      RegisterOperand cls, bits<5> bytes,
5154                                      AddressingMode mode = bdaddr20only> {
5155  defm "" : CondUnaryRSYPair<mnemonic, opcode, operator, cls, bytes, mode>;
5156  def _MemFoldPseudo : MemFoldPseudo_CondMove<mnemonic, cls, bytes, mode>;
5157}
5158
5159multiclass CondUnaryRSYPseudoAndMemFold<string mnemonic,
5160                                        SDPatternOperator operator,
5161                                        RegisterOperand cls, bits<5> bytes,
5162                                        AddressingMode mode = bdaddr20only> {
5163  def "" : CondUnaryRSYPseudo<mnemonic, operator, cls, bytes, mode>;
5164  def _MemFoldPseudo : MemFoldPseudo_CondMove<mnemonic, cls, bytes, mode>;
5165}
5166
5167// Define an instruction that operates on two fixed-length blocks of memory,
5168// and associated pseudo instructions for operating on blocks of any size.
5169// The Sequence form uses a straight-line sequence of instructions and
5170// the Loop form uses a loop of length-256 instructions followed by
5171// another instruction to handle the excess.
5172multiclass MemorySS<string mnemonic, bits<8> opcode,
5173                    SDPatternOperator sequence, SDPatternOperator loop> {
5174  def "" : SideEffectBinarySSa<mnemonic, opcode>;
5175  let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CC] in {
5176    def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5177                                       imm64:$length),
5178                           [(sequence bdaddr12only:$dest, bdaddr12only:$src,
5179                                      imm64:$length)]>;
5180    def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5181                                   imm64:$length, GR64:$count256),
5182                      [(loop bdaddr12only:$dest, bdaddr12only:$src,
5183                             imm64:$length, GR64:$count256)]>;
5184  }
5185}
5186
5187// The same, but setting a CC result as comparison operator.
5188multiclass CompareMemorySS<string mnemonic, bits<8> opcode,
5189                          SDPatternOperator sequence, SDPatternOperator loop> {
5190  def "" : SideEffectBinarySSa<mnemonic, opcode>;
5191  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
5192    def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5193                                       imm64:$length),
5194                           [(set CC, (sequence bdaddr12only:$dest, bdaddr12only:$src,
5195                                               imm64:$length))]>;
5196    def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
5197                                   imm64:$length, GR64:$count256),
5198                      [(set CC, (loop bdaddr12only:$dest, bdaddr12only:$src,
5199                                      imm64:$length, GR64:$count256))]>;
5200  }
5201}
5202
5203// Define an instruction that operates on two strings, both terminated
5204// by the character in R0.  The instruction processes a CPU-determinated
5205// number of bytes at a time and sets CC to 3 if the instruction needs
5206// to be repeated.  Also define a pseudo instruction that represents
5207// the full loop (the main instruction plus the branch on CC==3).
5208multiclass StringRRE<string mnemonic, bits<16> opcode,
5209                     SDPatternOperator operator> {
5210  let Uses = [R0L] in
5211    def "" : SideEffectBinaryMemMemRRE<mnemonic, opcode, GR64, GR64>;
5212  let usesCustomInserter = 1, hasNoSchedulingInfo = 1 in
5213    def Loop : Pseudo<(outs GR64:$end),
5214                      (ins GR64:$start1, GR64:$start2, GR32:$char),
5215                      [(set GR64:$end, (operator GR64:$start1, GR64:$start2,
5216                                                 GR32:$char))]>;
5217}
5218