blob: a9bc5629d0e7131686f06cb85fcabcb06e2aab06 [file] [log] [blame]
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001//==- SystemZInstrFormats.td - SystemZ Instruction Formats --*- tablegen -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11// Basic SystemZ instruction definition
12//===----------------------------------------------------------------------===//
13
14class InstSystemZ<int size, dag outs, dag ins, string asmstr,
15 list<dag> pattern> : Instruction {
16 let Namespace = "SystemZ";
17
18 dag OutOperandList = outs;
19 dag InOperandList = ins;
20 let Size = size;
21 let Pattern = pattern;
22 let AsmString = asmstr;
23
24 // Used to identify a group of related instructions, such as ST and STY.
25 string Function = "";
26
27 // "12" for an instruction that has a ...Y equivalent, "20" for that
28 // ...Y equivalent.
29 string PairType = "none";
30
31 // True if this instruction is a simple D(X,B) load of a register
32 // (with no sign or zero extension).
33 bit SimpleBDXLoad = 0;
34
35 // True if this instruction is a simple D(X,B) store of a register
36 // (with no truncation).
37 bit SimpleBDXStore = 0;
38
39 // True if this instruction has a 20-bit displacement field.
40 bit Has20BitOffset = 0;
41
42 // True if addresses in this instruction have an index register.
43 bit HasIndex = 0;
44
45 // True if this is a 128-bit pseudo instruction that combines two 64-bit
46 // operations.
47 bit Is128Bit = 0;
48
49 let TSFlags{0} = SimpleBDXLoad;
50 let TSFlags{1} = SimpleBDXStore;
51 let TSFlags{2} = Has20BitOffset;
52 let TSFlags{3} = HasIndex;
53 let TSFlags{4} = Is128Bit;
54}
55
56//===----------------------------------------------------------------------===//
57// Mappings between instructions
58//===----------------------------------------------------------------------===//
59
60// Return the version of an instruction that has an unsigned 12-bit
61// displacement.
62def getDisp12Opcode : InstrMapping {
63 let FilterClass = "InstSystemZ";
64 let RowFields = ["Function"];
65 let ColFields = ["PairType"];
66 let KeyCol = ["20"];
67 let ValueCols = [["12"]];
68}
69
70// Return the version of an instruction that has a signed 20-bit displacement.
71def getDisp20Opcode : InstrMapping {
72 let FilterClass = "InstSystemZ";
73 let RowFields = ["Function"];
74 let ColFields = ["PairType"];
75 let KeyCol = ["12"];
76 let ValueCols = [["20"]];
77}
78
79//===----------------------------------------------------------------------===//
80// Instruction formats
81//===----------------------------------------------------------------------===//
82//
83// Formats are specified using operand field declarations of the form:
84//
Richard Sandifordd454ec02013-05-14 09:28:21 +000085// bits<4> Rn : register input or output for operand n
86// bits<m> In : immediate value of width m for operand n
87// bits<4> BDn : address operand n, which has a base and a displacement
88// bits<m> XBDn : address operand n, which has an index, a base and a
89// displacement
90// bits<4> Xn : index register for address operand n
91// bits<4> Mn : mode value for operand n
Ulrich Weigand5f613df2013-05-06 16:15:19 +000092//
Richard Sandifordd454ec02013-05-14 09:28:21 +000093// The operand numbers ("n" in the list above) follow the architecture manual.
94// Assembly operands sometimes have a different order; in particular, R3 often
95// is often written between operands 1 and 2.
Ulrich Weigand5f613df2013-05-06 16:15:19 +000096//
97//===----------------------------------------------------------------------===//
98
99class InstRI<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
100 : InstSystemZ<4, outs, ins, asmstr, pattern> {
101 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000102 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000103
104 bits<4> R1;
105 bits<16> I2;
106
107 let Inst{31-24} = op{11-4};
108 let Inst{23-20} = R1;
109 let Inst{19-16} = op{3-0};
110 let Inst{15-0} = I2;
111}
112
113class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
114 : InstSystemZ<6, outs, ins, asmstr, pattern> {
115 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000116 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000117
118 bits<4> R1;
119 bits<4> R2;
120 bits<8> I3;
121 bits<8> I4;
122 bits<8> I5;
123
124 let Inst{47-40} = op{15-8};
125 let Inst{39-36} = R1;
126 let Inst{35-32} = R2;
127 let Inst{31-24} = I3;
128 let Inst{23-16} = I4;
129 let Inst{15-8} = I5;
130 let Inst{7-0} = op{7-0};
131}
132
133class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
134 : InstSystemZ<6, outs, ins, asmstr, pattern> {
135 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000136 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000137
138 bits<4> R1;
139 bits<32> I2;
140
141 let Inst{47-40} = op{11-4};
142 let Inst{39-36} = R1;
143 let Inst{35-32} = op{3-0};
144 let Inst{31-0} = I2;
145}
146
147class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
148 : InstSystemZ<2, outs, ins, asmstr, pattern> {
149 field bits<16> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000150 field bits<16> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000151
152 bits<4> R1;
153 bits<4> R2;
154
155 let Inst{15-8} = op;
156 let Inst{7-4} = R1;
157 let Inst{3-0} = R2;
158}
159
160class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
161 : InstSystemZ<4, outs, ins, asmstr, pattern> {
162 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000163 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000164
165 bits<4> R1;
166 bits<4> R3;
167 bits<4> R2;
168
169 let Inst{31-16} = op;
170 let Inst{15-12} = R1;
171 let Inst{11-8} = 0;
172 let Inst{7-4} = R3;
173 let Inst{3-0} = R2;
174}
175
176class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
177 : InstSystemZ<4, outs, ins, asmstr, pattern> {
178 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000179 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000180
181 bits<4> R1;
182 bits<4> R2;
183
184 let Inst{31-16} = op;
185 let Inst{15-8} = 0;
186 let Inst{7-4} = R1;
187 let Inst{3-0} = R2;
188}
189
190class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
191 : InstSystemZ<4, outs, ins, asmstr, pattern> {
192 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000193 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000194
195 bits<4> R1;
196 bits<4> R2;
197 bits<4> R3;
198
199 let Inst{31-16} = op;
200 let Inst{15-12} = R3;
201 let Inst{11-8} = 0;
202 let Inst{7-4} = R1;
203 let Inst{3-0} = R2;
204}
205
206class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
207 : InstSystemZ<4, outs, ins, asmstr, pattern> {
208 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000209 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000210
211 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000212 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000213
214 let Inst{31-24} = op;
215 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000216 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000217
218 let HasIndex = 1;
219}
220
221class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
222 : InstSystemZ<6, outs, ins, asmstr, pattern> {
223 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000224 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000225
226 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000227 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000228
229 let Inst{47-40} = op{15-8};
230 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000231 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000232 let Inst{15-8} = 0;
233 let Inst{7-0} = op{7-0};
234
235 let HasIndex = 1;
236}
237
238class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
239 : InstSystemZ<6, outs, ins, asmstr, pattern> {
240 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000241 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000242
243 bits<4> R1;
244 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000245 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000246
247 let Inst{47-40} = op{15-8};
248 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000249 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000250 let Inst{15-12} = R1;
251 let Inst{11-8} = 0;
252 let Inst{7-0} = op{7-0};
253
254 let HasIndex = 1;
255}
256
257class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
258 : InstSystemZ<6, outs, ins, asmstr, pattern> {
259 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000260 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000261
262 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000263 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000264
265 let Inst{47-40} = op{15-8};
266 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000267 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000268 let Inst{7-0} = op{7-0};
269
270 let Has20BitOffset = 1;
271 let HasIndex = 1;
272}
273
274class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
275 : InstSystemZ<4, outs, ins, asmstr, pattern> {
276 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000277 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000278
279 bits<4> R1;
280 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000281 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000282
283 let Inst{31-24} = op;
284 let Inst{23-20} = R1;
285 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000286 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000287}
288
289class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
290 : InstSystemZ<6, outs, ins, asmstr, pattern> {
291 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000292 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000293
294 bits<4> R1;
295 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000296 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000297
298 let Inst{47-40} = op{15-8};
299 let Inst{39-36} = R1;
300 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000301 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000302 let Inst{7-0} = op{7-0};
303
304 let Has20BitOffset = 1;
305}
306
307class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
308 : InstSystemZ<4, outs, ins, asmstr, pattern> {
309 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000310 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000311
Richard Sandifordd454ec02013-05-14 09:28:21 +0000312 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000313 bits<8> I2;
314
315 let Inst{31-24} = op;
316 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000317 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000318}
319
320class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
321 : InstSystemZ<6, outs, ins, asmstr, pattern> {
322 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000323 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000324
Richard Sandifordd454ec02013-05-14 09:28:21 +0000325 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000326 bits<16> I2;
327
328 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000329 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000330 let Inst{15-0} = I2;
331}
332
333class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
334 : InstSystemZ<6, outs, ins, asmstr, pattern> {
335 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000336 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000337
Richard Sandifordd454ec02013-05-14 09:28:21 +0000338 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000339 bits<8> I2;
340
341 let Inst{47-40} = op{15-8};
342 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000343 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000344 let Inst{7-0} = op{7-0};
345
346 let Has20BitOffset = 1;
347}
348
349//===----------------------------------------------------------------------===//
350// Instruction definitions with semantics
351//===----------------------------------------------------------------------===//
352//
353// These classes have the form <Category><Format>, where <Format> is one
354// of the formats defined above and where <Category> describes the inputs
355// and outputs. <Category> can be one of:
356//
357// Inherent:
358// One register output operand and no input operands.
359//
360// Store:
361// One register or immediate input operand and one address input operand.
362// The instruction stores the first operand to the address.
363//
364// This category is used for both pure and truncating stores.
365//
366// LoadMultiple:
367// One address input operand and two explicit output operands.
368// The instruction loads a range of registers from the address,
369// with the explicit operands giving the first and last register
370// to load. Other loaded registers are added as implicit definitions.
371//
372// StoreMultiple:
373// Two explicit input register operands and an address operand.
374// The instruction stores a range of registers to the address,
375// with the explicit operands giving the first and last register
376// to store. Other stored registers are added as implicit uses.
377//
378// Unary:
379// One register output operand and one input operand. The input
380// operand may be a register, immediate or memory.
381//
382// Binary:
383// One register output operand and two input operands. The first
384// input operand is always a register and he second may be a register,
385// immediate or memory.
386//
387// Shift:
388// One register output operand and two input operands. The first
389// input operand is a register and the second has the same form as
390// an address (although it isn't actually used to address memory).
391//
392// Compare:
393// Two input operands. The first operand is always a register,
394// the second may be a register, immediate or memory.
395//
396// Ternary:
397// One register output operand and three register input operands.
398//
399// CmpSwap:
400// One output operand and three input operands. The first two
401// operands are registers and the third is an address. The instruction
402// both reads from and writes to the address.
403//
404// RotateSelect:
405// One output operand and five input operands. The first two operands
406// are registers and the other three are immediates.
407//
408// The format determines which input operands are tied to output operands,
409// and also determines the shape of any address operand.
410//
411// Multiclasses of the form <Category><Format>Pair define two instructions,
412// one with <Category><Format> and one with <Category><Format>Y. The name
413// of the first instruction has no suffix, the name of the second has
414// an extra "y".
415//
416//===----------------------------------------------------------------------===//
417
418class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
419 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000420 : InstRRE<opcode, (outs cls:$R1), (ins),
421 mnemonic#"\t$R1",
422 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000423 let R2 = 0;
424}
425
426class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000427 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
428 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000429 let mayLoad = 1;
430}
431
432class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
433 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000434 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
435 mnemonic#"\t$R1, $I2",
436 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000437 let mayStore = 1;
438 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
439 // However, BDXs have two extra operands and are therefore 6 units more
440 // complex.
441 let AddedComplexity = 7;
442}
443
444class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
445 RegisterOperand cls, AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000446 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
447 mnemonic#"\t$R1, $XBD2",
448 [(operator cls:$R1, mode:$XBD2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000449 let mayStore = 1;
450}
451
452class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
453 RegisterOperand cls, AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000454 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
455 mnemonic#"\t$R1, $XBD2",
456 [(operator cls:$R1, mode:$XBD2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000457 let mayStore = 1;
458}
459
460multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
461 SDPatternOperator operator, RegisterOperand cls> {
462 let Function = mnemonic ## #cls in {
463 let PairType = "12" in
464 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bdxaddr12pair>;
465 let PairType = "20" in
466 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bdxaddr20pair>;
467 }
468}
469
470class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000471 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
472 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000473 let mayStore = 1;
474}
475
476class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
477 Immediate imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000478 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
479 mnemonic#"\t$BD1, $I2",
480 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000481 let mayStore = 1;
482}
483
484class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
485 Immediate imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000486 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
487 mnemonic#"\t$BD1, $I2",
488 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000489 let mayStore = 1;
490}
491
492class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
493 Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000494 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
495 mnemonic#"\t$BD1, $I2",
496 [(operator imm:$I2, bdaddr12only:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000497 let mayStore = 1;
498}
499
500multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
501 SDPatternOperator operator, Immediate imm> {
502 let Function = mnemonic in {
503 let PairType = "12" in
504 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
505 let PairType = "20" in
506 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
507 }
508}
509
510class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
511 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000512 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
513 mnemonic#"\t$R1, $R2",
514 [(set cls1:$R1, (operator cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000515
516class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
517 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000518 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
519 mnemonic#"\t$R1, $R2",
520 [(set cls1:$R1, (operator cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000521
522class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
523 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000524 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
525 mnemonic#"\t$R1, $R3, $R2", []>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000526
527class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
528 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000529 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
530 mnemonic#"\t$R1, $I2",
531 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000532
533class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
534 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000535 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
536 mnemonic#"\t$R1, $I2",
537 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000538
539class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
540 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000541 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
542 mnemonic#"\t$R1, $I2",
543 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000544 let mayLoad = 1;
545 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
546 // However, BDXs have two extra operands and are therefore 6 units more
547 // complex.
548 let AddedComplexity = 7;
549}
550
551class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
552 RegisterOperand cls, AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000553 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
554 mnemonic#"\t$R1, $XBD2",
555 [(set cls:$R1, (operator mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000556 let mayLoad = 1;
557}
558
559class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
560 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000561 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
562 mnemonic#"\t$R1, $XBD2",
563 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000564 let mayLoad = 1;
565}
566
567class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
568 RegisterOperand cls, AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000569 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
570 mnemonic#"\t$R1, $XBD2",
571 [(set cls:$R1, (operator mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000572 let mayLoad = 1;
573}
574
575multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
576 SDPatternOperator operator, RegisterOperand cls> {
577 let Function = mnemonic ## #cls in {
578 let PairType = "12" in
579 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bdxaddr12pair>;
580 let PairType = "20" in
581 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bdxaddr20pair>;
582 }
583}
584
585class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
586 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000587 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
588 mnemonic#"\t$R1, $R2",
589 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
590 let Constraints = "$R1 = $R1src";
591 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000592}
593
594class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
595 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000596 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
597 mnemonic#"\t$R1, $R2",
598 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
599 let Constraints = "$R1 = $R1src";
600 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000601}
602
Richard Sandifordd454ec02013-05-14 09:28:21 +0000603class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
604 RegisterOperand cls1, RegisterOperand cls2>
605 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
606 mnemonic#"\t$R1, $R3, $R2",
607 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000608
609class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
610 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000611 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
612 mnemonic#"\t$R1, $I2",
613 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
614 let Constraints = "$R1 = $R1src";
615 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000616}
617
618class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
619 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000620 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
621 mnemonic#"\t$R1, $I2",
622 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
623 let Constraints = "$R1 = $R1src";
624 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000625}
626
627class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
628 RegisterOperand cls, SDPatternOperator load,
629 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000630 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
631 mnemonic#"\t$R1, $XBD2",
632 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
633 let Constraints = "$R1 = $R1src";
634 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000635 let mayLoad = 1;
636}
637
638class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
639 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000640 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
641 mnemonic#"\t$R1, $XBD2",
642 [(set cls:$R1, (operator cls:$R1src,
643 (load bdxaddr12only:$XBD2)))]> {
644 let Constraints = "$R1 = $R1src";
645 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000646 let mayLoad = 1;
647}
648
649class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
650 RegisterOperand cls, SDPatternOperator load,
651 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000652 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
653 mnemonic#"\t$R1, $XBD2",
654 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
655 let Constraints = "$R1 = $R1src";
656 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000657 let mayLoad = 1;
658}
659
660multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
661 SDPatternOperator operator, RegisterOperand cls,
662 SDPatternOperator load> {
663 let Function = mnemonic ## #cls in {
664 let PairType = "12" in
665 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bdxaddr12pair>;
666 let PairType = "20" in
667 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load,
668 bdxaddr20pair>;
669 }
670}
671
672class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
673 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000674 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
675 mnemonic#"\t$BD1, $I2",
676 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000677 let mayLoad = 1;
678 let mayStore = 1;
679}
680
681class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
682 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000683 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
684 mnemonic#"\t$BD1, $I2",
685 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000686 let mayLoad = 1;
687 let mayStore = 1;
688}
689
690multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
691 bits<16> siyOpcode, SDPatternOperator operator,
692 Operand imm> {
693 let Function = mnemonic ## #cls in {
694 let PairType = "12" in
695 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
696 let PairType = "20" in
697 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
698 }
699}
700
701class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
702 RegisterOperand cls, AddressingMode mode>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000703 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
704 mnemonic#"\t$R1, $BD2",
705 [(set cls:$R1, (operator cls:$R1src, mode:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000706 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000707 let Constraints = "$R1 = $R1src";
708 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000709}
710
711class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
712 RegisterOperand cls, AddressingMode mode>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000713 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
714 mnemonic#"\t$R1, $R3, $BD2",
715 [(set cls:$R1, (operator cls:$R3, mode:$BD2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000716
717class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
718 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000719 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
720 mnemonic#"\t$R1, $R2",
721 [(operator cls1:$R1, cls2:$R2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000722
723class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
724 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000725 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
726 mnemonic#"\t$R1, $R2",
727 [(operator cls1:$R1, cls2:$R2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000728
729class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
730 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000731 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
732 mnemonic#"\t$R1, $I2",
733 [(operator cls:$R1, imm:$I2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000734
735class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
736 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000737 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
738 mnemonic#"\t$R1, $I2",
739 [(operator cls:$R1, imm:$I2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000740
741class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
742 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000743 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
744 mnemonic#"\t$R1, $I2",
745 [(operator cls:$R1, (load pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000746 let mayLoad = 1;
747 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
748 // However, BDXs have two extra operands and are therefore 6 units more
749 // complex.
750 let AddedComplexity = 7;
751}
752
753class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
754 RegisterOperand cls, SDPatternOperator load,
755 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000756 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
757 mnemonic#"\t$R1, $XBD2",
758 [(operator cls:$R1, (load mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000759 let mayLoad = 1;
760}
761
762class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
763 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000764 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
765 mnemonic#"\t$R1, $XBD2",
766 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000767 let mayLoad = 1;
768}
769
770class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
771 RegisterOperand cls, SDPatternOperator load,
772 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000773 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
774 mnemonic#"\t$R1, $XBD2",
775 [(operator cls:$R1, (load mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000776 let mayLoad = 1;
777}
778
779multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
780 SDPatternOperator operator, RegisterOperand cls,
781 SDPatternOperator load> {
782 let Function = mnemonic ## #cls in {
783 let PairType = "12" in
784 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
785 load, bdxaddr12pair>;
786 let PairType = "20" in
787 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
788 load, bdxaddr20pair>;
789 }
790}
791
792class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
793 SDPatternOperator load, Immediate imm,
794 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000795 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
796 mnemonic#"\t$BD1, $I2",
797 [(operator (load mode:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000798 let mayLoad = 1;
799}
800
801class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
802 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000803 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
804 mnemonic#"\t$BD1, $I2",
805 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000806 let mayLoad = 1;
807}
808
809class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
810 SDPatternOperator load, Immediate imm,
811 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000812 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
813 mnemonic#"\t$BD1, $I2",
814 [(operator (load mode:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000815 let mayLoad = 1;
816}
817
818multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
819 SDPatternOperator operator, SDPatternOperator load,
820 Immediate imm> {
821 let Function = mnemonic in {
822 let PairType = "12" in
823 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
824 let PairType = "20" in
825 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
826 bdaddr20pair>;
827 }
828}
829
830class TernaryRRD<string mnemonic, bits<16> opcode,
831 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000832 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
833 mnemonic#"\t$R1, $R3, $R2",
834 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
835 let Constraints = "$R1 = $R1src";
836 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000837}
838
839class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
840 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000841 : InstRXF<opcode, (outs cls:$R1),
842 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
843 mnemonic#"\t$R1, $R3, $XBD2",
844 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
845 (load bdxaddr12only:$XBD2)))]> {
846 let Constraints = "$R1 = $R1src";
847 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000848 let mayLoad = 1;
849}
850
851class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
852 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000853 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
854 mnemonic#"\t$R1, $R3, $BD2",
855 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
856 let Constraints = "$R1 = $R1src";
857 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000858 let mayLoad = 1;
859 let mayStore = 1;
860}
861
862class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
863 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000864 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
865 mnemonic#"\t$R1, $R3, $BD2",
866 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
867 let Constraints = "$R1 = $R1src";
868 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000869 let mayLoad = 1;
870 let mayStore = 1;
871}
872
873multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
874 SDPatternOperator operator, RegisterOperand cls> {
875 let Function = mnemonic ## #cls in {
876 let PairType = "12" in
877 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
878 let PairType = "20" in
879 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
880 }
881}
882
883class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
884 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000885 : InstRIEf<opcode, (outs cls1:$R1),
886 (ins cls1:$R1src, cls2:$R2,
887 uimm8zx6:$I3, uimm8zx6:$I4, uimm8zx6:$I5),
888 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
889 let Constraints = "$R1 = $R1src";
890 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000891}
892
893//===----------------------------------------------------------------------===//
894// Pseudo instructions
895//===----------------------------------------------------------------------===//
896//
897// Convenience instructions that get lowered to real instructions
898// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
899// or SystemZInstrInfo::expandPostRAPseudo().
900//
901//===----------------------------------------------------------------------===//
902
903class Pseudo<dag outs, dag ins, list<dag> pattern>
904 : InstSystemZ<0, outs, ins, "", pattern> {
905 let isPseudo = 1;
906 let isCodeGenOnly = 1;
907}
908
909// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
910// the value of the PSW's 2-bit condition code field.
911class SelectWrapper<RegisterOperand cls>
912 : Pseudo<(outs cls:$dst), (ins cls:$src1, cls:$src2, i8imm:$cc),
913 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2, imm:$cc))]> {
914 let usesCustomInserter = 1;
915 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +0000916 // change CC, the insertion requires new blocks, and CC cannot be live
917 // across them.
918 let Defs = [CC];
919 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000920}
921
922// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
923// describe the second (non-memory) operand.
924class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
925 dag pat, DAGOperand operand>
926 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
927 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +0000928 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000929 let Has20BitOffset = 1;
930 let mayLoad = 1;
931 let mayStore = 1;
932 let usesCustomInserter = 1;
933}
934
935// Specializations of AtomicLoadWBinary.
936class AtomicLoadBinaryReg32<SDPatternOperator operator>
937 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
938class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
939 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
940class AtomicLoadBinaryReg64<SDPatternOperator operator>
941 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
942class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
943 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
944
945// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
946// describe the second (non-memory) operand.
947class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
948 DAGOperand operand>
949 : Pseudo<(outs GR32:$dst),
950 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
951 ADDR32:$negbitshift, uimm32:$bitsize),
952 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
953 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +0000954 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000955 let Has20BitOffset = 1;
956 let mayLoad = 1;
957 let mayStore = 1;
958 let usesCustomInserter = 1;
959}
960
961// Specializations of AtomicLoadWBinary.
962class AtomicLoadWBinaryReg<SDPatternOperator operator>
963 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
964class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
965 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;