blob: 58110ecec2a84c6469c4a2812bd09f65f119c633 [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
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000132class InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
133 : InstSystemZ<6, outs, ins, asmstr, pattern> {
134 field bits<48> Inst;
135 field bits<48> SoftFail = 0;
136
137 bits<4> R1;
138 bits<8> I2;
139 bits<4> M3;
140 bits<16> RI4;
141
142 let Inst{47-40} = op{15-8};
143 let Inst{39-36} = R1;
144 let Inst{35-32} = M3;
145 let Inst{31-16} = RI4;
146 let Inst{15-8} = I2;
147 let Inst{7-0} = op{7-0};
148}
149
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000150class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
151 : InstSystemZ<6, outs, ins, asmstr, pattern> {
152 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000153 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000154
155 bits<4> R1;
156 bits<4> R2;
157 bits<8> I3;
158 bits<8> I4;
159 bits<8> I5;
160
161 let Inst{47-40} = op{15-8};
162 let Inst{39-36} = R1;
163 let Inst{35-32} = R2;
164 let Inst{31-24} = I3;
165 let Inst{23-16} = I4;
166 let Inst{15-8} = I5;
167 let Inst{7-0} = op{7-0};
168}
169
170class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
171 : InstSystemZ<6, outs, ins, asmstr, pattern> {
172 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000173 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000174
175 bits<4> R1;
176 bits<32> I2;
177
178 let Inst{47-40} = op{11-4};
179 let Inst{39-36} = R1;
180 let Inst{35-32} = op{3-0};
181 let Inst{31-0} = I2;
182}
183
184class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
185 : InstSystemZ<2, outs, ins, asmstr, pattern> {
186 field bits<16> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000187 field bits<16> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000188
189 bits<4> R1;
190 bits<4> R2;
191
192 let Inst{15-8} = op;
193 let Inst{7-4} = R1;
194 let Inst{3-0} = R2;
195}
196
197class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
198 : InstSystemZ<4, outs, ins, asmstr, pattern> {
199 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000200 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000201
202 bits<4> R1;
203 bits<4> R3;
204 bits<4> R2;
205
206 let Inst{31-16} = op;
207 let Inst{15-12} = R1;
208 let Inst{11-8} = 0;
209 let Inst{7-4} = R3;
210 let Inst{3-0} = R2;
211}
212
213class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
214 : InstSystemZ<4, outs, ins, asmstr, pattern> {
215 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000216 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000217
218 bits<4> R1;
219 bits<4> R2;
220
221 let Inst{31-16} = op;
222 let Inst{15-8} = 0;
223 let Inst{7-4} = R1;
224 let Inst{3-0} = R2;
225}
226
227class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
228 : InstSystemZ<4, outs, ins, asmstr, pattern> {
229 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000230 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000231
232 bits<4> R1;
233 bits<4> R2;
234 bits<4> R3;
235
236 let Inst{31-16} = op;
237 let Inst{15-12} = R3;
238 let Inst{11-8} = 0;
239 let Inst{7-4} = R1;
240 let Inst{3-0} = R2;
241}
242
243class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
244 : InstSystemZ<4, outs, ins, asmstr, pattern> {
245 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000246 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000247
248 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000249 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000250
251 let Inst{31-24} = op;
252 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000253 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000254
255 let HasIndex = 1;
256}
257
258class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
259 : InstSystemZ<6, outs, ins, asmstr, pattern> {
260 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000261 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000262
263 bits<4> R1;
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} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000268 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000269 let Inst{15-8} = 0;
270 let Inst{7-0} = op{7-0};
271
272 let HasIndex = 1;
273}
274
275class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
276 : InstSystemZ<6, outs, ins, asmstr, pattern> {
277 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000278 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000279
280 bits<4> R1;
281 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000282 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000283
284 let Inst{47-40} = op{15-8};
285 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000286 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000287 let Inst{15-12} = R1;
288 let Inst{11-8} = 0;
289 let Inst{7-0} = op{7-0};
290
291 let HasIndex = 1;
292}
293
294class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
295 : InstSystemZ<6, outs, ins, asmstr, pattern> {
296 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000297 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000298
299 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000300 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000301
302 let Inst{47-40} = op{15-8};
303 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000304 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000305 let Inst{7-0} = op{7-0};
306
307 let Has20BitOffset = 1;
308 let HasIndex = 1;
309}
310
311class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
312 : InstSystemZ<4, outs, ins, asmstr, pattern> {
313 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000314 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000315
316 bits<4> R1;
317 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000318 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000319
320 let Inst{31-24} = op;
321 let Inst{23-20} = R1;
322 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000323 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000324}
325
326class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
327 : InstSystemZ<6, outs, ins, asmstr, pattern> {
328 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000329 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000330
331 bits<4> R1;
332 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000333 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000334
335 let Inst{47-40} = op{15-8};
336 let Inst{39-36} = R1;
337 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000338 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000339 let Inst{7-0} = op{7-0};
340
341 let Has20BitOffset = 1;
342}
343
344class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
345 : InstSystemZ<4, outs, ins, asmstr, pattern> {
346 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000347 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000348
Richard Sandifordd454ec02013-05-14 09:28:21 +0000349 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000350 bits<8> I2;
351
352 let Inst{31-24} = op;
353 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000354 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000355}
356
357class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
358 : InstSystemZ<6, outs, ins, asmstr, pattern> {
359 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000360 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000361
Richard Sandifordd454ec02013-05-14 09:28:21 +0000362 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000363 bits<16> I2;
364
365 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000366 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000367 let Inst{15-0} = I2;
368}
369
370class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
371 : InstSystemZ<6, outs, ins, asmstr, pattern> {
372 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000373 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000374
Richard Sandifordd454ec02013-05-14 09:28:21 +0000375 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000376 bits<8> I2;
377
378 let Inst{47-40} = op{15-8};
379 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000380 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000381 let Inst{7-0} = op{7-0};
382
383 let Has20BitOffset = 1;
384}
385
Richard Sandiford1d959002013-07-02 14:56:45 +0000386class InstSS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
387 : InstSystemZ<6, outs, ins, asmstr, pattern> {
388 field bits<48> Inst;
389 field bits<48> SoftFail = 0;
390
391 bits<24> BDL1;
392 bits<16> BD2;
393
394 let Inst{47-40} = op;
395 let Inst{39-16} = BDL1;
396 let Inst{15-0} = BD2;
397}
398
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000399//===----------------------------------------------------------------------===//
400// Instruction definitions with semantics
401//===----------------------------------------------------------------------===//
402//
403// These classes have the form <Category><Format>, where <Format> is one
404// of the formats defined above and where <Category> describes the inputs
405// and outputs. <Category> can be one of:
406//
407// Inherent:
408// One register output operand and no input operands.
409//
410// Store:
411// One register or immediate input operand and one address input operand.
412// The instruction stores the first operand to the address.
413//
414// This category is used for both pure and truncating stores.
415//
416// LoadMultiple:
417// One address input operand and two explicit output operands.
418// The instruction loads a range of registers from the address,
419// with the explicit operands giving the first and last register
420// to load. Other loaded registers are added as implicit definitions.
421//
422// StoreMultiple:
423// Two explicit input register operands and an address operand.
424// The instruction stores a range of registers to the address,
425// with the explicit operands giving the first and last register
426// to store. Other stored registers are added as implicit uses.
427//
428// Unary:
429// One register output operand and one input operand. The input
430// operand may be a register, immediate or memory.
431//
432// Binary:
433// One register output operand and two input operands. The first
434// input operand is always a register and he second may be a register,
435// immediate or memory.
436//
437// Shift:
438// One register output operand and two input operands. The first
439// input operand is a register and the second has the same form as
440// an address (although it isn't actually used to address memory).
441//
442// Compare:
443// Two input operands. The first operand is always a register,
444// the second may be a register, immediate or memory.
445//
446// Ternary:
447// One register output operand and three register input operands.
448//
449// CmpSwap:
450// One output operand and three input operands. The first two
451// operands are registers and the third is an address. The instruction
452// both reads from and writes to the address.
453//
454// RotateSelect:
455// One output operand and five input operands. The first two operands
456// are registers and the other three are immediates.
457//
458// The format determines which input operands are tied to output operands,
459// and also determines the shape of any address operand.
460//
461// Multiclasses of the form <Category><Format>Pair define two instructions,
462// one with <Category><Format> and one with <Category><Format>Y. The name
463// of the first instruction has no suffix, the name of the second has
464// an extra "y".
465//
466//===----------------------------------------------------------------------===//
467
468class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
469 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000470 : InstRRE<opcode, (outs cls:$R1), (ins),
471 mnemonic#"\t$R1",
472 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000473 let R2 = 0;
474}
475
476class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000477 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
478 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000479 let mayLoad = 1;
480}
481
482class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
483 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000484 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
485 mnemonic#"\t$R1, $I2",
486 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000487 let mayStore = 1;
488 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
489 // However, BDXs have two extra operands and are therefore 6 units more
490 // complex.
491 let AddedComplexity = 7;
492}
493
494class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
495 RegisterOperand cls, AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000496 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
497 mnemonic#"\t$R1, $XBD2",
498 [(operator cls:$R1, mode:$XBD2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000499 let mayStore = 1;
500}
501
502class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
503 RegisterOperand cls, AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000504 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
505 mnemonic#"\t$R1, $XBD2",
506 [(operator cls:$R1, mode:$XBD2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000507 let mayStore = 1;
508}
509
510multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
511 SDPatternOperator operator, RegisterOperand cls> {
512 let Function = mnemonic ## #cls in {
513 let PairType = "12" in
514 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bdxaddr12pair>;
515 let PairType = "20" in
516 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bdxaddr20pair>;
517 }
518}
519
520class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000521 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
522 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000523 let mayStore = 1;
524}
525
526class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
527 Immediate imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000528 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
529 mnemonic#"\t$BD1, $I2",
530 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000531 let mayStore = 1;
532}
533
534class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
535 Immediate imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000536 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
537 mnemonic#"\t$BD1, $I2",
538 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000539 let mayStore = 1;
540}
541
542class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
543 Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000544 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
545 mnemonic#"\t$BD1, $I2",
546 [(operator imm:$I2, bdaddr12only:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000547 let mayStore = 1;
548}
549
550multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
551 SDPatternOperator operator, Immediate imm> {
552 let Function = mnemonic in {
553 let PairType = "12" in
554 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
555 let PairType = "20" in
556 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
557 }
558}
559
560class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
561 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000562 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
563 mnemonic#"\t$R1, $R2",
564 [(set cls1:$R1, (operator cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000565
566class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
567 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000568 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
569 mnemonic#"\t$R1, $R2",
570 [(set cls1:$R1, (operator cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000571
572class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
573 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000574 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
575 mnemonic#"\t$R1, $R3, $R2", []>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000576
577class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
578 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000579 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
580 mnemonic#"\t$R1, $I2",
581 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000582
583class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
584 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000585 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
586 mnemonic#"\t$R1, $I2",
587 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000588
589class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
590 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000591 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
592 mnemonic#"\t$R1, $I2",
593 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000594 let mayLoad = 1;
595 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
596 // However, BDXs have two extra operands and are therefore 6 units more
597 // complex.
598 let AddedComplexity = 7;
599}
600
601class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
602 RegisterOperand cls, AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000603 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
604 mnemonic#"\t$R1, $XBD2",
605 [(set cls:$R1, (operator mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000606 let mayLoad = 1;
607}
608
609class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
610 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000611 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
612 mnemonic#"\t$R1, $XBD2",
613 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000614 let mayLoad = 1;
615}
616
617class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
618 RegisterOperand cls, AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000619 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
620 mnemonic#"\t$R1, $XBD2",
621 [(set cls:$R1, (operator mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000622 let mayLoad = 1;
623}
624
625multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
626 SDPatternOperator operator, RegisterOperand cls> {
627 let Function = mnemonic ## #cls in {
628 let PairType = "12" in
629 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bdxaddr12pair>;
630 let PairType = "20" in
631 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bdxaddr20pair>;
632 }
633}
634
635class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
636 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000637 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
638 mnemonic#"\t$R1, $R2",
639 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
640 let Constraints = "$R1 = $R1src";
641 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000642}
643
644class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
645 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000646 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
647 mnemonic#"\t$R1, $R2",
648 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
649 let Constraints = "$R1 = $R1src";
650 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000651}
652
Richard Sandifordd454ec02013-05-14 09:28:21 +0000653class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
654 RegisterOperand cls1, RegisterOperand cls2>
655 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
656 mnemonic#"\t$R1, $R3, $R2",
657 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000658
659class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
660 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000661 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
662 mnemonic#"\t$R1, $I2",
663 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
664 let Constraints = "$R1 = $R1src";
665 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000666}
667
668class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
669 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000670 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
671 mnemonic#"\t$R1, $I2",
672 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
673 let Constraints = "$R1 = $R1src";
674 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000675}
676
677class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
678 RegisterOperand cls, SDPatternOperator load,
679 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000680 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
681 mnemonic#"\t$R1, $XBD2",
682 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
683 let Constraints = "$R1 = $R1src";
684 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000685 let mayLoad = 1;
686}
687
688class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
689 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000690 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
691 mnemonic#"\t$R1, $XBD2",
692 [(set cls:$R1, (operator cls:$R1src,
693 (load bdxaddr12only:$XBD2)))]> {
694 let Constraints = "$R1 = $R1src";
695 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000696 let mayLoad = 1;
697}
698
699class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
700 RegisterOperand cls, SDPatternOperator load,
701 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000702 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
703 mnemonic#"\t$R1, $XBD2",
704 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
705 let Constraints = "$R1 = $R1src";
706 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000707 let mayLoad = 1;
708}
709
710multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
711 SDPatternOperator operator, RegisterOperand cls,
712 SDPatternOperator load> {
713 let Function = mnemonic ## #cls in {
714 let PairType = "12" in
715 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bdxaddr12pair>;
716 let PairType = "20" in
717 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load,
718 bdxaddr20pair>;
719 }
720}
721
722class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
723 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000724 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
725 mnemonic#"\t$BD1, $I2",
726 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000727 let mayLoad = 1;
728 let mayStore = 1;
729}
730
731class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
732 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000733 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
734 mnemonic#"\t$BD1, $I2",
735 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000736 let mayLoad = 1;
737 let mayStore = 1;
738}
739
740multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
741 bits<16> siyOpcode, SDPatternOperator operator,
742 Operand imm> {
743 let Function = mnemonic ## #cls in {
744 let PairType = "12" in
745 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
746 let PairType = "20" in
747 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
748 }
749}
750
751class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
752 RegisterOperand cls, AddressingMode mode>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000753 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
754 mnemonic#"\t$R1, $BD2",
755 [(set cls:$R1, (operator cls:$R1src, mode:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000756 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000757 let Constraints = "$R1 = $R1src";
758 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000759}
760
761class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
762 RegisterOperand cls, AddressingMode mode>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000763 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, mode:$BD2),
764 mnemonic#"\t$R1, $R3, $BD2",
765 [(set cls:$R1, (operator cls:$R3, mode:$BD2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000766
767class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
768 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000769 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
770 mnemonic#"\t$R1, $R2",
771 [(operator cls1:$R1, cls2:$R2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000772
773class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
774 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000775 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
776 mnemonic#"\t$R1, $R2",
777 [(operator cls1:$R1, cls2:$R2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000778
779class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
780 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000781 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
782 mnemonic#"\t$R1, $I2",
783 [(operator cls:$R1, imm:$I2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000784
785class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
786 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000787 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
788 mnemonic#"\t$R1, $I2",
789 [(operator cls:$R1, imm:$I2)]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000790
791class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
792 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000793 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
794 mnemonic#"\t$R1, $I2",
795 [(operator cls:$R1, (load pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000796 let mayLoad = 1;
797 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
798 // However, BDXs have two extra operands and are therefore 6 units more
799 // complex.
800 let AddedComplexity = 7;
801}
802
803class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
804 RegisterOperand cls, SDPatternOperator load,
805 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000806 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
807 mnemonic#"\t$R1, $XBD2",
808 [(operator cls:$R1, (load mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000809 let mayLoad = 1;
810}
811
812class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
813 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000814 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
815 mnemonic#"\t$R1, $XBD2",
816 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000817 let mayLoad = 1;
818}
819
820class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
821 RegisterOperand cls, SDPatternOperator load,
822 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000823 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
824 mnemonic#"\t$R1, $XBD2",
825 [(operator cls:$R1, (load mode:$XBD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000826 let mayLoad = 1;
827}
828
829multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
830 SDPatternOperator operator, RegisterOperand cls,
831 SDPatternOperator load> {
832 let Function = mnemonic ## #cls in {
833 let PairType = "12" in
834 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
835 load, bdxaddr12pair>;
836 let PairType = "20" in
837 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
838 load, bdxaddr20pair>;
839 }
840}
841
842class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
843 SDPatternOperator load, Immediate imm,
844 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000845 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
846 mnemonic#"\t$BD1, $I2",
847 [(operator (load mode:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000848 let mayLoad = 1;
849}
850
851class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
852 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000853 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
854 mnemonic#"\t$BD1, $I2",
855 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000856 let mayLoad = 1;
857}
858
859class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
860 SDPatternOperator load, Immediate imm,
861 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000862 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
863 mnemonic#"\t$BD1, $I2",
864 [(operator (load mode:$BD1), imm:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000865 let mayLoad = 1;
866}
867
868multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
869 SDPatternOperator operator, SDPatternOperator load,
870 Immediate imm> {
871 let Function = mnemonic in {
872 let PairType = "12" in
873 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
874 let PairType = "20" in
875 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
876 bdaddr20pair>;
877 }
878}
879
880class TernaryRRD<string mnemonic, bits<16> opcode,
881 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000882 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
883 mnemonic#"\t$R1, $R3, $R2",
884 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
885 let Constraints = "$R1 = $R1src";
886 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000887}
888
889class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
890 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000891 : InstRXF<opcode, (outs cls:$R1),
892 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
893 mnemonic#"\t$R1, $R3, $XBD2",
894 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
895 (load bdxaddr12only:$XBD2)))]> {
896 let Constraints = "$R1 = $R1src";
897 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000898 let mayLoad = 1;
899}
900
901class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
902 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000903 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
904 mnemonic#"\t$R1, $R3, $BD2",
905 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
906 let Constraints = "$R1 = $R1src";
907 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000908 let mayLoad = 1;
909 let mayStore = 1;
910}
911
912class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
913 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000914 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
915 mnemonic#"\t$R1, $R3, $BD2",
916 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
917 let Constraints = "$R1 = $R1src";
918 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000919 let mayLoad = 1;
920 let mayStore = 1;
921}
922
923multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
924 SDPatternOperator operator, RegisterOperand cls> {
925 let Function = mnemonic ## #cls in {
926 let PairType = "12" in
927 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
928 let PairType = "20" in
929 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
930 }
931}
932
933class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
934 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000935 : InstRIEf<opcode, (outs cls1:$R1),
936 (ins cls1:$R1src, cls2:$R2,
937 uimm8zx6:$I3, uimm8zx6:$I4, uimm8zx6:$I5),
938 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
939 let Constraints = "$R1 = $R1src";
940 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000941}
942
943//===----------------------------------------------------------------------===//
944// Pseudo instructions
945//===----------------------------------------------------------------------===//
946//
947// Convenience instructions that get lowered to real instructions
948// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
949// or SystemZInstrInfo::expandPostRAPseudo().
950//
951//===----------------------------------------------------------------------===//
952
953class Pseudo<dag outs, dag ins, list<dag> pattern>
954 : InstSystemZ<0, outs, ins, "", pattern> {
955 let isPseudo = 1;
956 let isCodeGenOnly = 1;
957}
958
959// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
960// the value of the PSW's 2-bit condition code field.
961class SelectWrapper<RegisterOperand cls>
962 : Pseudo<(outs cls:$dst), (ins cls:$src1, cls:$src2, i8imm:$cc),
963 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2, imm:$cc))]> {
964 let usesCustomInserter = 1;
965 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +0000966 // change CC, the insertion requires new blocks, and CC cannot be live
967 // across them.
968 let Defs = [CC];
969 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000970}
971
Richard Sandifordb86a8342013-06-27 09:27:40 +0000972// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
973multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
974 SDPatternOperator load, AddressingMode mode> {
975 let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {
976 def "" : Pseudo<(outs), (ins mode:$addr, cls:$new, i8imm:$cc),
977 [(store (z_select_ccmask cls:$new, (load mode:$addr),
978 imm:$cc), mode:$addr)]>;
979 def Inv : Pseudo<(outs), (ins mode:$addr, cls:$new, i8imm:$cc),
980 [(store (z_select_ccmask (load mode:$addr), cls:$new,
981 imm:$cc), mode:$addr)]>;
982 }
983}
984
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000985// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
986// describe the second (non-memory) operand.
987class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
988 dag pat, DAGOperand operand>
989 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
990 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +0000991 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000992 let Has20BitOffset = 1;
993 let mayLoad = 1;
994 let mayStore = 1;
995 let usesCustomInserter = 1;
996}
997
998// Specializations of AtomicLoadWBinary.
999class AtomicLoadBinaryReg32<SDPatternOperator operator>
1000 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
1001class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
1002 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
1003class AtomicLoadBinaryReg64<SDPatternOperator operator>
1004 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
1005class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
1006 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
1007
1008// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
1009// describe the second (non-memory) operand.
1010class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
1011 DAGOperand operand>
1012 : Pseudo<(outs GR32:$dst),
1013 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
1014 ADDR32:$negbitshift, uimm32:$bitsize),
1015 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
1016 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001017 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001018 let Has20BitOffset = 1;
1019 let mayLoad = 1;
1020 let mayStore = 1;
1021 let usesCustomInserter = 1;
1022}
1023
1024// Specializations of AtomicLoadWBinary.
1025class AtomicLoadWBinaryReg<SDPatternOperator operator>
1026 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
1027class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
1028 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;