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