blob: c52e2a29f3cf04864b626db7d1737ade96d01aa9 [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
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000113class InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
114 : InstSystemZ<6, outs, ins, asmstr, pattern> {
115 field bits<48> Inst;
116 field bits<48> SoftFail = 0;
117
118 bits<4> R1;
119 bits<4> R2;
120 bits<4> M3;
121 bits<16> RI4;
122
123 let Inst{47-40} = op{15-8};
124 let Inst{39-36} = R1;
125 let Inst{35-32} = R2;
126 let Inst{31-16} = RI4;
127 let Inst{15-12} = M3;
128 let Inst{11-8} = 0;
129 let Inst{7-0} = op{7-0};
130}
131
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000132class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
133 : InstSystemZ<6, outs, ins, asmstr, pattern> {
134 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000135 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000136
137 bits<4> R1;
138 bits<4> R2;
139 bits<8> I3;
140 bits<8> I4;
141 bits<8> I5;
142
143 let Inst{47-40} = op{15-8};
144 let Inst{39-36} = R1;
145 let Inst{35-32} = R2;
146 let Inst{31-24} = I3;
147 let Inst{23-16} = I4;
148 let Inst{15-8} = I5;
149 let Inst{7-0} = op{7-0};
150}
151
152class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
153 : InstSystemZ<6, outs, ins, asmstr, pattern> {
154 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000155 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000156
157 bits<4> R1;
158 bits<32> I2;
159
160 let Inst{47-40} = op{11-4};
161 let Inst{39-36} = R1;
162 let Inst{35-32} = op{3-0};
163 let Inst{31-0} = I2;
164}
165
166class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
167 : InstSystemZ<2, outs, ins, asmstr, pattern> {
168 field bits<16> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000169 field bits<16> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000170
171 bits<4> R1;
172 bits<4> R2;
173
174 let Inst{15-8} = op;
175 let Inst{7-4} = R1;
176 let Inst{3-0} = R2;
177}
178
179class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
180 : InstSystemZ<4, outs, ins, asmstr, pattern> {
181 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000182 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000183
184 bits<4> R1;
185 bits<4> R3;
186 bits<4> R2;
187
188 let Inst{31-16} = op;
189 let Inst{15-12} = R1;
190 let Inst{11-8} = 0;
191 let Inst{7-4} = R3;
192 let Inst{3-0} = R2;
193}
194
195class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
196 : InstSystemZ<4, outs, ins, asmstr, pattern> {
197 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000198 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000199
200 bits<4> R1;
201 bits<4> R2;
202
203 let Inst{31-16} = op;
204 let Inst{15-8} = 0;
205 let Inst{7-4} = R1;
206 let Inst{3-0} = R2;
207}
208
209class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
210 : InstSystemZ<4, outs, ins, asmstr, pattern> {
211 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000212 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000213
214 bits<4> R1;
215 bits<4> R2;
216 bits<4> R3;
217
218 let Inst{31-16} = op;
219 let Inst{15-12} = R3;
220 let Inst{11-8} = 0;
221 let Inst{7-4} = R1;
222 let Inst{3-0} = R2;
223}
224
225class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
226 : InstSystemZ<4, outs, ins, asmstr, pattern> {
227 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000228 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000229
230 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000231 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000232
233 let Inst{31-24} = op;
234 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000235 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000236
237 let HasIndex = 1;
238}
239
240class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
241 : InstSystemZ<6, outs, ins, asmstr, pattern> {
242 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000243 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000244
245 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000246 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000247
248 let Inst{47-40} = op{15-8};
249 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000250 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000251 let Inst{15-8} = 0;
252 let Inst{7-0} = op{7-0};
253
254 let HasIndex = 1;
255}
256
257class InstRXF<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;
263 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000264 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000265
266 let Inst{47-40} = op{15-8};
267 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000268 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000269 let Inst{15-12} = R1;
270 let Inst{11-8} = 0;
271 let Inst{7-0} = op{7-0};
272
273 let HasIndex = 1;
274}
275
276class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
277 : InstSystemZ<6, outs, ins, asmstr, pattern> {
278 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000279 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000280
281 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000282 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000283
284 let Inst{47-40} = op{15-8};
285 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000286 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000287 let Inst{7-0} = op{7-0};
288
289 let Has20BitOffset = 1;
290 let HasIndex = 1;
291}
292
293class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
294 : InstSystemZ<4, outs, ins, asmstr, pattern> {
295 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000296 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000297
298 bits<4> R1;
299 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000300 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000301
302 let Inst{31-24} = op;
303 let Inst{23-20} = R1;
304 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000305 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000306}
307
308class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
309 : InstSystemZ<6, outs, ins, asmstr, pattern> {
310 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000311 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000312
313 bits<4> R1;
314 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000315 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000316
317 let Inst{47-40} = op{15-8};
318 let Inst{39-36} = R1;
319 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000320 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000321 let Inst{7-0} = op{7-0};
322
323 let Has20BitOffset = 1;
324}
325
326class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
327 : InstSystemZ<4, outs, ins, asmstr, pattern> {
328 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000329 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000330
Richard Sandifordd454ec02013-05-14 09:28:21 +0000331 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000332 bits<8> I2;
333
334 let Inst{31-24} = op;
335 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000336 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000337}
338
339class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
340 : InstSystemZ<6, outs, ins, asmstr, pattern> {
341 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000342 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000343
Richard Sandifordd454ec02013-05-14 09:28:21 +0000344 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000345 bits<16> I2;
346
347 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000348 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000349 let Inst{15-0} = I2;
350}
351
352class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
353 : InstSystemZ<6, outs, ins, asmstr, pattern> {
354 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000355 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000356
Richard Sandifordd454ec02013-05-14 09:28:21 +0000357 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000358 bits<8> I2;
359
360 let Inst{47-40} = op{15-8};
361 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000362 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000363 let Inst{7-0} = op{7-0};
364
365 let Has20BitOffset = 1;
366}
367
368//===----------------------------------------------------------------------===//
369// Instruction definitions with semantics
370//===----------------------------------------------------------------------===//
371//
372// These classes have the form <Category><Format>, where <Format> is one
373// of the formats defined above and where <Category> describes the inputs
374// and outputs. <Category> can be one of:
375//
376// Inherent:
377// One register output operand and no input operands.
378//
379// Store:
380// One register or immediate input operand and one address input operand.
381// The instruction stores the first operand to the address.
382//
383// This category is used for both pure and truncating stores.
384//
385// LoadMultiple:
386// One address input operand and two explicit output operands.
387// The instruction loads a range of registers from the address,
388// with the explicit operands giving the first and last register
389// to load. Other loaded registers are added as implicit definitions.
390//
391// StoreMultiple:
392// Two explicit input register operands and an address operand.
393// The instruction stores a range of registers to the address,
394// with the explicit operands giving the first and last register
395// to store. Other stored registers are added as implicit uses.
396//
397// Unary:
398// One register output operand and one input operand. The input
399// operand may be a register, immediate or memory.
400//
401// Binary:
402// One register output operand and two input operands. The first
403// input operand is always a register and he second may be a register,
404// immediate or memory.
405//
406// Shift:
407// One register output operand and two input operands. The first
408// input operand is a register and the second has the same form as
409// an address (although it isn't actually used to address memory).
410//
411// Compare:
412// Two input operands. The first operand is always a register,
413// the second may be a register, immediate or memory.
414//
415// Ternary:
416// One register output operand and three register input operands.
417//
418// CmpSwap:
419// One output operand and three input operands. The first two
420// operands are registers and the third is an address. The instruction
421// both reads from and writes to the address.
422//
423// RotateSelect:
424// One output operand and five input operands. The first two operands
425// are registers and the other three are immediates.
426//
427// The format determines which input operands are tied to output operands,
428// and also determines the shape of any address operand.
429//
430// Multiclasses of the form <Category><Format>Pair define two instructions,
431// one with <Category><Format> and one with <Category><Format>Y. The name
432// of the first instruction has no suffix, the name of the second has
433// an extra "y".
434//
435//===----------------------------------------------------------------------===//
436
437class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
438 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000439 : InstRRE<opcode, (outs cls:$R1), (ins),
440 mnemonic#"\t$R1",
441 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000442 let R2 = 0;
443}
444
445class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000446 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
447 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000448 let mayLoad = 1;
449}
450
451class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
452 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000453 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
454 mnemonic#"\t$R1, $I2",
455 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000456 let mayStore = 1;
457 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
458 // However, BDXs have two extra operands and are therefore 6 units more
459 // complex.
460 let AddedComplexity = 7;
461}
462
463class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
464 RegisterOperand cls, AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000465 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
466 mnemonic#"\t$R1, $XBD2",
467 [(operator cls:$R1, mode:$XBD2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000468 let mayStore = 1;
469}
470
471class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
472 RegisterOperand cls, AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000473 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
474 mnemonic#"\t$R1, $XBD2",
475 [(operator cls:$R1, mode:$XBD2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000476 let mayStore = 1;
477}
478
479multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
480 SDPatternOperator operator, RegisterOperand cls> {
481 let Function = mnemonic ## #cls in {
482 let PairType = "12" in
483 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bdxaddr12pair>;
484 let PairType = "20" in
485 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bdxaddr20pair>;
486 }
487}
488
489class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000490 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
491 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000492 let mayStore = 1;
493}
494
495class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
496 Immediate imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000497 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
498 mnemonic#"\t$BD1, $I2",
499 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000500 let mayStore = 1;
501}
502
503class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
504 Immediate imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000505 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
506 mnemonic#"\t$BD1, $I2",
507 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000508 let mayStore = 1;
509}
510
511class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
512 Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000513 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
514 mnemonic#"\t$BD1, $I2",
515 [(operator imm:$I2, bdaddr12only:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000516 let mayStore = 1;
517}
518
519multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
520 SDPatternOperator operator, Immediate imm> {
521 let Function = mnemonic in {
522 let PairType = "12" in
523 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
524 let PairType = "20" in
525 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
526 }
527}
528
529class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
530 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000531 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
532 mnemonic#"\t$R1, $R2",
533 [(set cls1:$R1, (operator cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000534
535class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
536 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000537 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
538 mnemonic#"\t$R1, $R2",
539 [(set cls1:$R1, (operator cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000540
541class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
542 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000543 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
544 mnemonic#"\t$R1, $R3, $R2", []>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000545
546class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
547 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000548 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
549 mnemonic#"\t$R1, $I2",
550 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000551
552class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
553 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000554 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
555 mnemonic#"\t$R1, $I2",
556 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000557
558class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
559 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000560 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
561 mnemonic#"\t$R1, $I2",
562 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000563 let mayLoad = 1;
564 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
565 // However, BDXs have two extra operands and are therefore 6 units more
566 // complex.
567 let AddedComplexity = 7;
568}
569
570class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
571 RegisterOperand cls, AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000572 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
573 mnemonic#"\t$R1, $XBD2",
574 [(set cls:$R1, (operator mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000575 let mayLoad = 1;
576}
577
578class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
579 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000580 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
581 mnemonic#"\t$R1, $XBD2",
582 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000583 let mayLoad = 1;
584}
585
586class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
587 RegisterOperand cls, AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000588 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
589 mnemonic#"\t$R1, $XBD2",
590 [(set cls:$R1, (operator mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000591 let mayLoad = 1;
592}
593
594multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
595 SDPatternOperator operator, RegisterOperand cls> {
596 let Function = mnemonic ## #cls in {
597 let PairType = "12" in
598 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bdxaddr12pair>;
599 let PairType = "20" in
600 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bdxaddr20pair>;
601 }
602}
603
604class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
605 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000606 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
607 mnemonic#"\t$R1, $R2",
608 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
609 let Constraints = "$R1 = $R1src";
610 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000611}
612
613class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
614 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000615 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
616 mnemonic#"\t$R1, $R2",
617 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
618 let Constraints = "$R1 = $R1src";
619 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000620}
621
Richard Sandifordd454ec02013-05-14 09:28:21 +0000622class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
623 RegisterOperand cls1, RegisterOperand cls2>
624 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
625 mnemonic#"\t$R1, $R3, $R2",
626 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000627
628class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
629 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000630 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
631 mnemonic#"\t$R1, $I2",
632 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
633 let Constraints = "$R1 = $R1src";
634 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000635}
636
637class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
638 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000639 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
640 mnemonic#"\t$R1, $I2",
641 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
642 let Constraints = "$R1 = $R1src";
643 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000644}
645
646class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
647 RegisterOperand cls, SDPatternOperator load,
648 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000649 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
650 mnemonic#"\t$R1, $XBD2",
651 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
652 let Constraints = "$R1 = $R1src";
653 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000654 let mayLoad = 1;
655}
656
657class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
658 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000659 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
660 mnemonic#"\t$R1, $XBD2",
661 [(set cls:$R1, (operator cls:$R1src,
662 (load bdxaddr12only:$XBD2)))]> {
663 let Constraints = "$R1 = $R1src";
664 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000665 let mayLoad = 1;
666}
667
668class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
669 RegisterOperand cls, SDPatternOperator load,
670 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000671 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
672 mnemonic#"\t$R1, $XBD2",
673 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
674 let Constraints = "$R1 = $R1src";
675 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000676 let mayLoad = 1;
677}
678
679multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
680 SDPatternOperator operator, RegisterOperand cls,
681 SDPatternOperator load> {
682 let Function = mnemonic ## #cls in {
683 let PairType = "12" in
684 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bdxaddr12pair>;
685 let PairType = "20" in
686 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load,
687 bdxaddr20pair>;
688 }
689}
690
691class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
692 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000693 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
694 mnemonic#"\t$BD1, $I2",
695 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000696 let mayLoad = 1;
697 let mayStore = 1;
698}
699
700class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
701 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000702 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
703 mnemonic#"\t$BD1, $I2",
704 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000705 let mayLoad = 1;
706 let mayStore = 1;
707}
708
709multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
710 bits<16> siyOpcode, SDPatternOperator operator,
711 Operand imm> {
712 let Function = mnemonic ## #cls in {
713 let PairType = "12" in
714 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
715 let PairType = "20" in
716 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
717 }
718}
719
720class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
721 RegisterOperand cls, AddressingMode mode>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000722 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
723 mnemonic#"\t$R1, $BD2",
724 [(set cls:$R1, (operator cls:$R1src, mode:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000725 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000726 let Constraints = "$R1 = $R1src";
727 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000728}
729
730class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
731 RegisterOperand cls, AddressingMode mode>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000732 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
733 mnemonic#"\t$R1, $R3, $BD2",
734 [(set cls:$R1, (operator cls:$R3, mode:$BD2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000735
736class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
737 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000738 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
739 mnemonic#"\t$R1, $R2",
740 [(operator cls1:$R1, cls2:$R2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000741
742class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
743 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000744 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
745 mnemonic#"\t$R1, $R2",
746 [(operator cls1:$R1, cls2:$R2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000747
748class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
749 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000750 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
751 mnemonic#"\t$R1, $I2",
752 [(operator cls:$R1, imm:$I2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000753
754class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
755 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000756 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
757 mnemonic#"\t$R1, $I2",
758 [(operator cls:$R1, imm:$I2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000759
760class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
761 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000762 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
763 mnemonic#"\t$R1, $I2",
764 [(operator cls:$R1, (load pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000765 let mayLoad = 1;
766 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
767 // However, BDXs have two extra operands and are therefore 6 units more
768 // complex.
769 let AddedComplexity = 7;
770}
771
772class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
773 RegisterOperand cls, SDPatternOperator load,
774 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000775 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
776 mnemonic#"\t$R1, $XBD2",
777 [(operator cls:$R1, (load mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000778 let mayLoad = 1;
779}
780
781class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
782 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000783 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
784 mnemonic#"\t$R1, $XBD2",
785 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000786 let mayLoad = 1;
787}
788
789class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
790 RegisterOperand cls, SDPatternOperator load,
791 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000792 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
793 mnemonic#"\t$R1, $XBD2",
794 [(operator cls:$R1, (load mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000795 let mayLoad = 1;
796}
797
798multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
799 SDPatternOperator operator, RegisterOperand cls,
800 SDPatternOperator load> {
801 let Function = mnemonic ## #cls in {
802 let PairType = "12" in
803 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
804 load, bdxaddr12pair>;
805 let PairType = "20" in
806 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
807 load, bdxaddr20pair>;
808 }
809}
810
811class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
812 SDPatternOperator load, Immediate imm,
813 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000814 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
815 mnemonic#"\t$BD1, $I2",
816 [(operator (load mode:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000817 let mayLoad = 1;
818}
819
820class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
821 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000822 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
823 mnemonic#"\t$BD1, $I2",
824 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000825 let mayLoad = 1;
826}
827
828class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
829 SDPatternOperator load, Immediate imm,
830 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000831 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
832 mnemonic#"\t$BD1, $I2",
833 [(operator (load mode:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000834 let mayLoad = 1;
835}
836
837multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
838 SDPatternOperator operator, SDPatternOperator load,
839 Immediate imm> {
840 let Function = mnemonic in {
841 let PairType = "12" in
842 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
843 let PairType = "20" in
844 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
845 bdaddr20pair>;
846 }
847}
848
849class TernaryRRD<string mnemonic, bits<16> opcode,
850 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000851 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
852 mnemonic#"\t$R1, $R3, $R2",
853 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
854 let Constraints = "$R1 = $R1src";
855 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000856}
857
858class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
859 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000860 : InstRXF<opcode, (outs cls:$R1),
861 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
862 mnemonic#"\t$R1, $R3, $XBD2",
863 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
864 (load bdxaddr12only:$XBD2)))]> {
865 let Constraints = "$R1 = $R1src";
866 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000867 let mayLoad = 1;
868}
869
870class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
871 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000872 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
873 mnemonic#"\t$R1, $R3, $BD2",
874 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
875 let Constraints = "$R1 = $R1src";
876 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000877 let mayLoad = 1;
878 let mayStore = 1;
879}
880
881class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
882 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000883 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
884 mnemonic#"\t$R1, $R3, $BD2",
885 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
886 let Constraints = "$R1 = $R1src";
887 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000888 let mayLoad = 1;
889 let mayStore = 1;
890}
891
892multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
893 SDPatternOperator operator, RegisterOperand cls> {
894 let Function = mnemonic ## #cls in {
895 let PairType = "12" in
896 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
897 let PairType = "20" in
898 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
899 }
900}
901
902class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
903 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000904 : InstRIEf<opcode, (outs cls1:$R1),
905 (ins cls1:$R1src, cls2:$R2,
906 uimm8zx6:$I3, uimm8zx6:$I4, uimm8zx6:$I5),
907 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
908 let Constraints = "$R1 = $R1src";
909 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000910}
911
912//===----------------------------------------------------------------------===//
913// Pseudo instructions
914//===----------------------------------------------------------------------===//
915//
916// Convenience instructions that get lowered to real instructions
917// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
918// or SystemZInstrInfo::expandPostRAPseudo().
919//
920//===----------------------------------------------------------------------===//
921
922class Pseudo<dag outs, dag ins, list<dag> pattern>
923 : InstSystemZ<0, outs, ins, "", pattern> {
924 let isPseudo = 1;
925 let isCodeGenOnly = 1;
926}
927
928// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
929// the value of the PSW's 2-bit condition code field.
930class SelectWrapper<RegisterOperand cls>
931 : Pseudo<(outs cls:$dst), (ins cls:$src1, cls:$src2, i8imm:$cc),
932 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2, imm:$cc))]> {
933 let usesCustomInserter = 1;
934 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +0000935 // change CC, the insertion requires new blocks, and CC cannot be live
936 // across them.
937 let Defs = [CC];
938 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000939}
940
941// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
942// describe the second (non-memory) operand.
943class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
944 dag pat, DAGOperand operand>
945 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
946 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +0000947 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000948 let Has20BitOffset = 1;
949 let mayLoad = 1;
950 let mayStore = 1;
951 let usesCustomInserter = 1;
952}
953
954// Specializations of AtomicLoadWBinary.
955class AtomicLoadBinaryReg32<SDPatternOperator operator>
956 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
957class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
958 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
959class AtomicLoadBinaryReg64<SDPatternOperator operator>
960 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
961class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
962 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
963
964// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
965// describe the second (non-memory) operand.
966class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
967 DAGOperand operand>
968 : Pseudo<(outs GR32:$dst),
969 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
970 ADDR32:$negbitshift, uimm32:$bitsize),
971 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
972 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +0000973 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000974 let Has20BitOffset = 1;
975 let mayLoad = 1;
976 let mayStore = 1;
977 let usesCustomInserter = 1;
978}
979
980// Specializations of AtomicLoadWBinary.
981class AtomicLoadWBinaryReg<SDPatternOperator operator>
982 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
983class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
984 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;