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