blob: 353a0d3f73748cc7030bf35d1cec5def6c237dce [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
Richard Sandiforddf313ff2013-07-03 09:19:58 +000024 // Some instructions come in pairs, one having a 12-bit displacement
25 // and the other having a 20-bit displacement. Both instructions in
26 // the pair have the same DispKey and their DispSizes are "12" and "20"
27 // respectively.
28 string DispKey = "";
29 string DispSize = "none";
Ulrich Weigand5f613df2013-05-06 16:15:19 +000030
Richard Sandiforded1fab62013-07-03 10:10:02 +000031 // Many register-based <INSN>R instructions have a memory-based <INSN>
32 // counterpart. OpKey uniquely identifies <INSN>, while OpType is
33 // "reg" for <INSN>R and "mem" for <INSN>.
34 string OpKey = "";
35 string OpType = "none";
36
Richard Sandifordff6c5a52013-07-19 16:12:08 +000037 // Many distinct-operands instructions have older 2-operand equivalents.
38 // NumOpsKey uniquely identifies one of these 2-operand and 3-operand pairs,
39 // with NumOpsValue being "2" or "3" as appropriate.
40 string NumOpsKey = "";
41 string NumOpsValue = "none";
42
Ulrich Weigand5f613df2013-05-06 16:15:19 +000043 // True if this instruction is a simple D(X,B) load of a register
44 // (with no sign or zero extension).
45 bit SimpleBDXLoad = 0;
46
47 // True if this instruction is a simple D(X,B) store of a register
48 // (with no truncation).
49 bit SimpleBDXStore = 0;
50
51 // True if this instruction has a 20-bit displacement field.
52 bit Has20BitOffset = 0;
53
54 // True if addresses in this instruction have an index register.
55 bit HasIndex = 0;
56
57 // True if this is a 128-bit pseudo instruction that combines two 64-bit
58 // operations.
59 bit Is128Bit = 0;
60
Richard Sandiforded1fab62013-07-03 10:10:02 +000061 // The access size of all memory operands in bytes, or 0 if not known.
62 bits<5> AccessBytes = 0;
63
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +000064 // If the instruction sets CC to a useful value, this gives the mask
65 // of all possible CC results. The mask has the same form as
66 // SystemZ::CCMASK_*.
67 bits<4> CCValues = 0;
68
Richard Sandiford0897fce2013-08-07 11:10:06 +000069 // The subset of CCValues that have the same meaning as they would after
70 // a comparison of the first operand against zero.
71 bits<4> CompareZeroCCMask = 0;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +000072
73 // True if the instruction is conditional and if the CC mask operand
74 // comes first (as for BRC, etc.).
75 bit CCMaskFirst = 0;
76
77 // Similar, but true if the CC mask operand comes last (as for LOC, etc.).
78 bit CCMaskLast = 0;
79
80 // True if the instruction is the "logical" rather than "arithmetic" form,
81 // in cases where a distinction exists.
82 bit IsLogical = 0;
83
84 let TSFlags{0} = SimpleBDXLoad;
85 let TSFlags{1} = SimpleBDXStore;
86 let TSFlags{2} = Has20BitOffset;
87 let TSFlags{3} = HasIndex;
88 let TSFlags{4} = Is128Bit;
89 let TSFlags{9-5} = AccessBytes;
90 let TSFlags{13-10} = CCValues;
Richard Sandiford0897fce2013-08-07 11:10:06 +000091 let TSFlags{17-14} = CompareZeroCCMask;
92 let TSFlags{18} = CCMaskFirst;
93 let TSFlags{19} = CCMaskLast;
94 let TSFlags{20} = IsLogical;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000095}
96
97//===----------------------------------------------------------------------===//
98// Mappings between instructions
99//===----------------------------------------------------------------------===//
100
101// Return the version of an instruction that has an unsigned 12-bit
102// displacement.
103def getDisp12Opcode : InstrMapping {
104 let FilterClass = "InstSystemZ";
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000105 let RowFields = ["DispKey"];
106 let ColFields = ["DispSize"];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000107 let KeyCol = ["20"];
108 let ValueCols = [["12"]];
109}
110
111// Return the version of an instruction that has a signed 20-bit displacement.
112def getDisp20Opcode : InstrMapping {
113 let FilterClass = "InstSystemZ";
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000114 let RowFields = ["DispKey"];
115 let ColFields = ["DispSize"];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000116 let KeyCol = ["12"];
117 let ValueCols = [["20"]];
118}
119
Richard Sandifordff6c5a52013-07-19 16:12:08 +0000120// Return the memory form of a register instruction.
Richard Sandiforded1fab62013-07-03 10:10:02 +0000121def getMemOpcode : InstrMapping {
122 let FilterClass = "InstSystemZ";
123 let RowFields = ["OpKey"];
124 let ColFields = ["OpType"];
125 let KeyCol = ["reg"];
126 let ValueCols = [["mem"]];
127}
128
Richard Sandifordff6c5a52013-07-19 16:12:08 +0000129// Return the 3-operand form of a 2-operand instruction.
130def getThreeOperandOpcode : InstrMapping {
131 let FilterClass = "InstSystemZ";
132 let RowFields = ["NumOpsKey"];
133 let ColFields = ["NumOpsValue"];
134 let KeyCol = ["2"];
135 let ValueCols = [["3"]];
136}
137
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000138//===----------------------------------------------------------------------===//
139// Instruction formats
140//===----------------------------------------------------------------------===//
141//
142// Formats are specified using operand field declarations of the form:
143//
Richard Sandifordd454ec02013-05-14 09:28:21 +0000144// bits<4> Rn : register input or output for operand n
145// bits<m> In : immediate value of width m for operand n
146// bits<4> BDn : address operand n, which has a base and a displacement
147// bits<m> XBDn : address operand n, which has an index, a base and a
148// displacement
149// bits<4> Xn : index register for address operand n
150// bits<4> Mn : mode value for operand n
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000151//
Richard Sandifordd454ec02013-05-14 09:28:21 +0000152// The operand numbers ("n" in the list above) follow the architecture manual.
153// Assembly operands sometimes have a different order; in particular, R3 often
154// is often written between operands 1 and 2.
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000155//
156//===----------------------------------------------------------------------===//
157
158class InstRI<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
159 : InstSystemZ<4, outs, ins, asmstr, pattern> {
160 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000161 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000162
163 bits<4> R1;
164 bits<16> I2;
165
166 let Inst{31-24} = op{11-4};
167 let Inst{23-20} = R1;
168 let Inst{19-16} = op{3-0};
169 let Inst{15-0} = I2;
170}
171
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000172class InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
173 : InstSystemZ<6, outs, ins, asmstr, pattern> {
174 field bits<48> Inst;
175 field bits<48> SoftFail = 0;
176
177 bits<4> R1;
178 bits<4> R2;
179 bits<4> M3;
180 bits<16> RI4;
181
182 let Inst{47-40} = op{15-8};
183 let Inst{39-36} = R1;
184 let Inst{35-32} = R2;
185 let Inst{31-16} = RI4;
186 let Inst{15-12} = M3;
187 let Inst{11-8} = 0;
188 let Inst{7-0} = op{7-0};
189}
190
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000191class InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
192 : InstSystemZ<6, outs, ins, asmstr, pattern> {
193 field bits<48> Inst;
194 field bits<48> SoftFail = 0;
195
196 bits<4> R1;
197 bits<8> I2;
198 bits<4> M3;
199 bits<16> RI4;
200
201 let Inst{47-40} = op{15-8};
202 let Inst{39-36} = R1;
203 let Inst{35-32} = M3;
204 let Inst{31-16} = RI4;
205 let Inst{15-8} = I2;
206 let Inst{7-0} = op{7-0};
207}
208
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000209class InstRIEd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
210 : InstSystemZ<6, outs, ins, asmstr, pattern> {
211 field bits<48> Inst;
212 field bits<48> SoftFail = 0;
213
214 bits<4> R1;
215 bits<4> R3;
216 bits<16> I2;
217
218 let Inst{47-40} = op{15-8};
219 let Inst{39-36} = R1;
220 let Inst{35-32} = R3;
221 let Inst{31-16} = I2;
222 let Inst{15-8} = 0;
223 let Inst{7-0} = op{7-0};
224}
225
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000226class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
227 : InstSystemZ<6, outs, ins, asmstr, pattern> {
228 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000229 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000230
231 bits<4> R1;
232 bits<4> R2;
233 bits<8> I3;
234 bits<8> I4;
235 bits<8> I5;
236
237 let Inst{47-40} = op{15-8};
238 let Inst{39-36} = R1;
239 let Inst{35-32} = R2;
240 let Inst{31-24} = I3;
241 let Inst{23-16} = I4;
242 let Inst{15-8} = I5;
243 let Inst{7-0} = op{7-0};
244}
245
246class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
247 : InstSystemZ<6, outs, ins, asmstr, pattern> {
248 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000249 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000250
251 bits<4> R1;
252 bits<32> I2;
253
254 let Inst{47-40} = op{11-4};
255 let Inst{39-36} = R1;
256 let Inst{35-32} = op{3-0};
257 let Inst{31-0} = I2;
258}
259
260class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
261 : InstSystemZ<2, outs, ins, asmstr, pattern> {
262 field bits<16> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000263 field bits<16> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000264
265 bits<4> R1;
266 bits<4> R2;
267
268 let Inst{15-8} = op;
269 let Inst{7-4} = R1;
270 let Inst{3-0} = R2;
271}
272
273class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
274 : InstSystemZ<4, outs, ins, asmstr, pattern> {
275 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000276 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000277
278 bits<4> R1;
279 bits<4> R3;
280 bits<4> R2;
281
282 let Inst{31-16} = op;
283 let Inst{15-12} = R1;
284 let Inst{11-8} = 0;
285 let Inst{7-4} = R3;
286 let Inst{3-0} = R2;
287}
288
289class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
290 : InstSystemZ<4, outs, ins, asmstr, pattern> {
291 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000292 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000293
294 bits<4> R1;
295 bits<4> R2;
296
297 let Inst{31-16} = op;
298 let Inst{15-8} = 0;
299 let Inst{7-4} = R1;
300 let Inst{3-0} = R2;
301}
302
303class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
304 : InstSystemZ<4, outs, ins, asmstr, pattern> {
305 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000306 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000307
308 bits<4> R1;
309 bits<4> R2;
310 bits<4> R3;
Richard Sandiford8e92c382013-08-21 08:58:08 +0000311 bits<4> R4;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000312
313 let Inst{31-16} = op;
314 let Inst{15-12} = R3;
Richard Sandiford8e92c382013-08-21 08:58:08 +0000315 let Inst{11-8} = R4;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000316 let Inst{7-4} = R1;
317 let Inst{3-0} = R2;
318}
319
320class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
321 : InstSystemZ<4, outs, ins, asmstr, pattern> {
322 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000323 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000324
325 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000326 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000327
328 let Inst{31-24} = op;
329 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000330 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000331
332 let HasIndex = 1;
333}
334
335class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
336 : InstSystemZ<6, outs, ins, asmstr, pattern> {
337 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000338 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000339
340 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000341 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000342
343 let Inst{47-40} = op{15-8};
344 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000345 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000346 let Inst{15-8} = 0;
347 let Inst{7-0} = op{7-0};
348
349 let HasIndex = 1;
350}
351
352class InstRXF<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
357 bits<4> R1;
358 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000359 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000360
361 let Inst{47-40} = op{15-8};
362 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000363 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000364 let Inst{15-12} = R1;
365 let Inst{11-8} = 0;
366 let Inst{7-0} = op{7-0};
367
368 let HasIndex = 1;
369}
370
371class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
372 : InstSystemZ<6, outs, ins, asmstr, pattern> {
373 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000374 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000375
376 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000377 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000378
379 let Inst{47-40} = op{15-8};
380 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000381 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000382 let Inst{7-0} = op{7-0};
383
384 let Has20BitOffset = 1;
385 let HasIndex = 1;
386}
387
388class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
389 : InstSystemZ<4, outs, ins, asmstr, pattern> {
390 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000391 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000392
393 bits<4> R1;
394 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000395 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000396
397 let Inst{31-24} = op;
398 let Inst{23-20} = R1;
399 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000400 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000401}
402
403class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
404 : InstSystemZ<6, outs, ins, asmstr, pattern> {
405 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000406 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000407
408 bits<4> R1;
409 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000410 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000411
412 let Inst{47-40} = op{15-8};
413 let Inst{39-36} = R1;
414 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000415 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000416 let Inst{7-0} = op{7-0};
417
418 let Has20BitOffset = 1;
419}
420
421class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
422 : InstSystemZ<4, outs, ins, asmstr, pattern> {
423 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000424 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000425
Richard Sandifordd454ec02013-05-14 09:28:21 +0000426 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000427 bits<8> I2;
428
429 let Inst{31-24} = op;
430 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000431 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000432}
433
434class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
435 : InstSystemZ<6, outs, ins, asmstr, pattern> {
436 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000437 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000438
Richard Sandifordd454ec02013-05-14 09:28:21 +0000439 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000440 bits<16> I2;
441
442 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000443 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000444 let Inst{15-0} = I2;
445}
446
447class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
448 : InstSystemZ<6, outs, ins, asmstr, pattern> {
449 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000450 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000451
Richard Sandifordd454ec02013-05-14 09:28:21 +0000452 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000453 bits<8> I2;
454
455 let Inst{47-40} = op{15-8};
456 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000457 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000458 let Inst{7-0} = op{7-0};
459
460 let Has20BitOffset = 1;
461}
462
Richard Sandiford1d959002013-07-02 14:56:45 +0000463class InstSS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
464 : InstSystemZ<6, outs, ins, asmstr, pattern> {
465 field bits<48> Inst;
466 field bits<48> SoftFail = 0;
467
468 bits<24> BDL1;
469 bits<16> BD2;
470
471 let Inst{47-40} = op;
472 let Inst{39-16} = BDL1;
473 let Inst{15-0} = BD2;
474}
475
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000476//===----------------------------------------------------------------------===//
477// Instruction definitions with semantics
478//===----------------------------------------------------------------------===//
479//
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000480// These classes have the form [Cond]<Category><Format>, where <Format> is one
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000481// of the formats defined above and where <Category> describes the inputs
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000482// and outputs. "Cond" is used if the instruction is conditional,
483// in which case the 4-bit condition-code mask is added as a final operand.
484// <Category> can be one of:
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000485//
486// Inherent:
487// One register output operand and no input operands.
488//
Richard Sandiford9795d8e2013-08-05 11:07:38 +0000489// BranchUnary:
490// One register output operand, one register input operand and
491// one branch displacement. The instructions stores a modified
492// form of the source register in the destination register and
493// branches on the result.
494//
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000495// Store:
496// One register or immediate input operand and one address input operand.
497// The instruction stores the first operand to the address.
498//
499// This category is used for both pure and truncating stores.
500//
501// LoadMultiple:
502// One address input operand and two explicit output operands.
503// The instruction loads a range of registers from the address,
504// with the explicit operands giving the first and last register
505// to load. Other loaded registers are added as implicit definitions.
506//
507// StoreMultiple:
508// Two explicit input register operands and an address operand.
509// The instruction stores a range of registers to the address,
510// with the explicit operands giving the first and last register
511// to store. Other stored registers are added as implicit uses.
512//
513// Unary:
514// One register output operand and one input operand. The input
515// operand may be a register, immediate or memory.
516//
517// Binary:
518// One register output operand and two input operands. The first
519// input operand is always a register and he second may be a register,
520// immediate or memory.
521//
522// Shift:
523// One register output operand and two input operands. The first
524// input operand is a register and the second has the same form as
525// an address (although it isn't actually used to address memory).
526//
527// Compare:
528// Two input operands. The first operand is always a register,
529// the second may be a register, immediate or memory.
530//
531// Ternary:
532// One register output operand and three register input operands.
533//
534// CmpSwap:
535// One output operand and three input operands. The first two
536// operands are registers and the third is an address. The instruction
537// both reads from and writes to the address.
538//
539// RotateSelect:
540// One output operand and five input operands. The first two operands
541// are registers and the other three are immediates.
542//
Richard Sandiford03481332013-08-23 11:36:42 +0000543// Prefetch:
544// One 4-bit immediate operand and one address operand. The immediate
545// operand is 1 for a load prefetch and 2 for a store prefetch.
546//
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000547// The format determines which input operands are tied to output operands,
548// and also determines the shape of any address operand.
549//
550// Multiclasses of the form <Category><Format>Pair define two instructions,
551// one with <Category><Format> and one with <Category><Format>Y. The name
552// of the first instruction has no suffix, the name of the second has
553// an extra "y".
554//
555//===----------------------------------------------------------------------===//
556
557class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
558 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000559 : InstRRE<opcode, (outs cls:$R1), (ins),
Richard Sandiford87326c72013-08-12 10:05:58 +0000560 mnemonic#"\t$R1",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000561 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000562 let R2 = 0;
563}
564
Richard Sandiford9795d8e2013-08-05 11:07:38 +0000565class BranchUnaryRI<string mnemonic, bits<12> opcode, RegisterOperand cls>
566 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget16:$I2),
567 mnemonic##"\t$R1, $I2", []> {
568 let isBranch = 1;
569 let isTerminator = 1;
570 let Constraints = "$R1 = $R1src";
571 let DisableEncoding = "$R1src";
572}
573
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000574class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000575 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
576 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000577 let mayLoad = 1;
578}
579
580class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
581 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000582 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
583 mnemonic#"\t$R1, $I2",
584 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000585 let mayStore = 1;
586 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
587 // However, BDXs have two extra operands and are therefore 6 units more
588 // complex.
589 let AddedComplexity = 7;
590}
591
592class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000593 RegisterOperand cls, bits<5> bytes,
594 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000595 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
596 mnemonic#"\t$R1, $XBD2",
597 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000598 let OpKey = mnemonic ## cls;
599 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000600 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000601 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000602}
603
604class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000605 RegisterOperand cls, bits<5> bytes,
606 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000607 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
608 mnemonic#"\t$R1, $XBD2",
609 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000610 let OpKey = mnemonic ## cls;
611 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000612 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000613 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000614}
615
616multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000617 SDPatternOperator operator, RegisterOperand cls,
618 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000619 let DispKey = mnemonic ## #cls in {
620 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000621 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000622 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000623 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
624 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000625 }
626}
627
628class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000629 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
630 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000631 let mayStore = 1;
632}
633
Richard Sandiforda481f582013-08-23 11:18:53 +0000634// StoreSI* instructions are used to store an integer to memory, but the
635// addresses are more restricted than for normal stores. If we are in the
636// situation of having to force either the address into a register or the
637// constant into a register, it's usually better to do the latter.
638// We therefore match the address in the same way as a normal store and
639// only use the StoreSI* instruction if the matched address is suitable.
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000640class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforda481f582013-08-23 11:18:53 +0000641 Immediate imm>
642 : InstSI<opcode, (outs), (ins mviaddr12pair:$BD1, imm:$I2),
Richard Sandifordd454ec02013-05-14 09:28:21 +0000643 mnemonic#"\t$BD1, $I2",
Richard Sandiforda481f582013-08-23 11:18:53 +0000644 [(operator imm:$I2, mviaddr12pair:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000645 let mayStore = 1;
646}
647
648class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforda481f582013-08-23 11:18:53 +0000649 Immediate imm>
650 : InstSIY<opcode, (outs), (ins mviaddr20pair:$BD1, imm:$I2),
Richard Sandifordd454ec02013-05-14 09:28:21 +0000651 mnemonic#"\t$BD1, $I2",
Richard Sandiforda481f582013-08-23 11:18:53 +0000652 [(operator imm:$I2, mviaddr20pair:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000653 let mayStore = 1;
654}
655
656class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
657 Immediate imm>
Richard Sandiforda481f582013-08-23 11:18:53 +0000658 : InstSIL<opcode, (outs), (ins mviaddr12pair:$BD1, imm:$I2),
Richard Sandifordd454ec02013-05-14 09:28:21 +0000659 mnemonic#"\t$BD1, $I2",
Richard Sandiforda481f582013-08-23 11:18:53 +0000660 [(operator imm:$I2, mviaddr12pair:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000661 let mayStore = 1;
662}
663
664multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
665 SDPatternOperator operator, Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000666 let DispKey = mnemonic in {
667 let DispSize = "12" in
Richard Sandiforda481f582013-08-23 11:18:53 +0000668 def "" : StoreSI<mnemonic, siOpcode, operator, imm>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000669 let DispSize = "20" in
Richard Sandiforda481f582013-08-23 11:18:53 +0000670 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000671 }
672}
673
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000674class CondStoreRSY<string mnemonic, bits<16> opcode,
675 RegisterOperand cls, bits<5> bytes,
676 AddressingMode mode = bdaddr20only>
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000677 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3),
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000678 mnemonic#"$R3\t$R1, $BD2", []>,
679 Requires<[FeatureLoadStoreOnCond]> {
680 let mayStore = 1;
681 let AccessBytes = bytes;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000682 let CCMaskLast = 1;
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000683}
684
685// Like CondStoreRSY, but used for the raw assembly form. The condition-code
686// mask is the third operand rather than being part of the mnemonic.
687class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
688 RegisterOperand cls, bits<5> bytes,
689 AddressingMode mode = bdaddr20only>
690 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, uimm8zx4:$R3),
691 mnemonic#"\t$R1, $BD2, $R3", []>,
692 Requires<[FeatureLoadStoreOnCond]> {
693 let mayStore = 1;
694 let AccessBytes = bytes;
695}
696
697// Like CondStoreRSY, but with a fixed CC mask.
698class FixedCondStoreRSY<string mnemonic, bits<16> opcode,
699 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
700 AddressingMode mode = bdaddr20only>
701 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2),
702 mnemonic#"\t$R1, $BD2", []>,
703 Requires<[FeatureLoadStoreOnCond]> {
704 let mayStore = 1;
705 let AccessBytes = bytes;
706 let R3 = ccmask;
707}
708
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000709class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
710 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000711 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000712 mnemonic#"r\t$R1, $R2",
713 [(set cls1:$R1, (operator cls2:$R2))]> {
714 let OpKey = mnemonic ## cls1;
715 let OpType = "reg";
716}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000717
718class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
719 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000720 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000721 mnemonic#"r\t$R1, $R2",
722 [(set cls1:$R1, (operator cls2:$R2))]> {
723 let OpKey = mnemonic ## cls1;
724 let OpType = "reg";
725}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000726
727class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
728 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000729 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000730 mnemonic#"r\t$R1, $R3, $R2", []> {
731 let OpKey = mnemonic ## cls1;
732 let OpType = "reg";
Richard Sandiford8e92c382013-08-21 08:58:08 +0000733 let R4 = 0;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000734}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000735
Richard Sandiford8e92c382013-08-21 08:58:08 +0000736class UnaryRRF4<string mnemonic, bits<16> opcode, RegisterOperand cls1,
737 RegisterOperand cls2>
738 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2, uimm8zx4:$R4),
739 mnemonic#"\t$R1, $R3, $R2, $R4", []>;
740
Richard Sandifordf2404162013-07-25 09:11:15 +0000741// These instructions are generated by if conversion. The old value of R1
742// is added as an implicit use.
743class CondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
744 RegisterOperand cls2>
Richard Sandiford3d768e32013-07-31 12:30:20 +0000745 : InstRRF<opcode, (outs cls1:$R1), (ins cls2:$R2, cond4:$valid, cond4:$R3),
Richard Sandifordf2404162013-07-25 09:11:15 +0000746 mnemonic#"r$R3\t$R1, $R2", []>,
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000747 Requires<[FeatureLoadStoreOnCond]> {
748 let CCMaskLast = 1;
Richard Sandiford8e92c382013-08-21 08:58:08 +0000749 let R4 = 0;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000750}
Richard Sandifordf2404162013-07-25 09:11:15 +0000751
752// Like CondUnaryRRF, but used for the raw assembly form. The condition-code
753// mask is the third operand rather than being part of the mnemonic.
754class AsmCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
755 RegisterOperand cls2>
756 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2, uimm8zx4:$R3),
757 mnemonic#"r\t$R1, $R2, $R3", []>,
758 Requires<[FeatureLoadStoreOnCond]> {
759 let Constraints = "$R1 = $R1src";
760 let DisableEncoding = "$R1src";
Richard Sandiford8e92c382013-08-21 08:58:08 +0000761 let R4 = 0;
Richard Sandifordf2404162013-07-25 09:11:15 +0000762}
763
764// Like CondUnaryRRF, but with a fixed CC mask.
765class FixedCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
766 RegisterOperand cls2, bits<4> ccmask>
767 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
768 mnemonic#"\t$R1, $R2", []>,
769 Requires<[FeatureLoadStoreOnCond]> {
770 let Constraints = "$R1 = $R1src";
771 let DisableEncoding = "$R1src";
772 let R3 = ccmask;
Richard Sandiford8e92c382013-08-21 08:58:08 +0000773 let R4 = 0;
Richard Sandifordf2404162013-07-25 09:11:15 +0000774}
775
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000776class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
777 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000778 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
779 mnemonic#"\t$R1, $I2",
780 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000781
782class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
783 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000784 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
785 mnemonic#"\t$R1, $I2",
786 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000787
788class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
789 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000790 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
791 mnemonic#"\t$R1, $I2",
792 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000793 let mayLoad = 1;
794 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
795 // However, BDXs have two extra operands and are therefore 6 units more
796 // complex.
797 let AddedComplexity = 7;
798}
799
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000800class CondUnaryRSY<string mnemonic, bits<16> opcode,
Richard Sandifordee834382013-07-31 12:38:08 +0000801 SDPatternOperator operator, RegisterOperand cls,
802 bits<5> bytes, AddressingMode mode = bdaddr20only>
803 : InstRSY<opcode, (outs cls:$R1),
804 (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
805 mnemonic#"$R3\t$R1, $BD2",
806 [(set cls:$R1,
807 (z_select_ccmask (load bdaddr20only:$BD2), cls:$R1src,
808 cond4:$valid, cond4:$R3))]>,
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000809 Requires<[FeatureLoadStoreOnCond]> {
810 let Constraints = "$R1 = $R1src";
811 let DisableEncoding = "$R1src";
812 let mayLoad = 1;
813 let AccessBytes = bytes;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000814 let CCMaskLast = 1;
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000815}
816
817// Like CondUnaryRSY, but used for the raw assembly form. The condition-code
818// mask is the third operand rather than being part of the mnemonic.
819class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
820 RegisterOperand cls, bits<5> bytes,
821 AddressingMode mode = bdaddr20only>
822 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, uimm8zx4:$R3),
823 mnemonic#"\t$R1, $BD2, $R3", []>,
824 Requires<[FeatureLoadStoreOnCond]> {
825 let mayLoad = 1;
826 let AccessBytes = bytes;
827 let Constraints = "$R1 = $R1src";
828 let DisableEncoding = "$R1src";
829}
830
831// Like CondUnaryRSY, but with a fixed CC mask.
832class FixedCondUnaryRSY<string mnemonic, bits<16> opcode,
833 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
834 AddressingMode mode = bdaddr20only>
835 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
836 mnemonic#"\t$R1, $BD2", []>,
837 Requires<[FeatureLoadStoreOnCond]> {
838 let Constraints = "$R1 = $R1src";
839 let DisableEncoding = "$R1src";
840 let R3 = ccmask;
841 let mayLoad = 1;
842 let AccessBytes = bytes;
843}
844
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000845class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000846 RegisterOperand cls, bits<5> bytes,
847 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000848 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
849 mnemonic#"\t$R1, $XBD2",
850 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000851 let OpKey = mnemonic ## cls;
852 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000853 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000854 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000855}
856
857class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000858 RegisterOperand cls, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000859 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
860 mnemonic#"\t$R1, $XBD2",
861 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000862 let OpKey = mnemonic ## cls;
863 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000864 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000865 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000866}
867
868class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000869 RegisterOperand cls, bits<5> bytes,
870 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000871 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
872 mnemonic#"\t$R1, $XBD2",
873 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000874 let OpKey = mnemonic ## cls;
875 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000876 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000877 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000878}
879
880multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000881 SDPatternOperator operator, RegisterOperand cls,
882 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000883 let DispKey = mnemonic ## #cls in {
884 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000885 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000886 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000887 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
888 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000889 }
890}
891
892class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
893 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000894 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000895 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000896 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000897 let OpKey = mnemonic ## cls1;
898 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000899 let Constraints = "$R1 = $R1src";
900 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000901}
902
903class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
904 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000905 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000906 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000907 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000908 let OpKey = mnemonic ## cls1;
909 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000910 let Constraints = "$R1 = $R1src";
911 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000912}
913
Richard Sandifordd454ec02013-05-14 09:28:21 +0000914class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
915 RegisterOperand cls1, RegisterOperand cls2>
916 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000917 mnemonic#"r\t$R1, $R3, $R2",
918 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]> {
919 let OpKey = mnemonic ## cls1;
920 let OpType = "reg";
Richard Sandiford8e92c382013-08-21 08:58:08 +0000921 let R4 = 0;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000922}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000923
Richard Sandiford0175b4a2013-07-19 16:21:55 +0000924class BinaryRRFK<string mnemonic, bits<16> opcode, SDPatternOperator operator,
925 RegisterOperand cls1, RegisterOperand cls2>
926 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R2, cls2:$R3),
927 mnemonic#"rk\t$R1, $R2, $R3",
Richard Sandiford8e92c382013-08-21 08:58:08 +0000928 [(set cls1:$R1, (operator cls1:$R2, cls2:$R3))]> {
929 let R4 = 0;
930}
Richard Sandiford0175b4a2013-07-19 16:21:55 +0000931
932multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
933 SDPatternOperator operator, RegisterOperand cls1,
934 RegisterOperand cls2> {
935 let NumOpsKey = mnemonic in {
936 let NumOpsValue = "3" in
937 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
938 Requires<[FeatureDistinctOps]>;
939 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
940 def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
941 }
942}
943
Richard Sandifordc57e5862013-07-19 16:24:22 +0000944multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
945 SDPatternOperator operator, RegisterOperand cls1,
946 RegisterOperand cls2> {
947 let NumOpsKey = mnemonic in {
948 let NumOpsValue = "3" in
949 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
950 Requires<[FeatureDistinctOps]>;
951 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
952 def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
953 }
954}
955
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000956class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
957 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000958 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
959 mnemonic#"\t$R1, $I2",
960 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
961 let Constraints = "$R1 = $R1src";
962 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000963}
964
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000965class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
966 RegisterOperand cls, Immediate imm>
967 : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
968 mnemonic#"\t$R1, $R3, $I2",
969 [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
970
971multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
972 SDPatternOperator operator, RegisterOperand cls,
973 Immediate imm> {
974 let NumOpsKey = mnemonic in {
975 let NumOpsValue = "3" in
976 def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
977 Requires<[FeatureDistinctOps]>;
978 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
979 def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
980 }
981}
982
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000983class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
984 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000985 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
986 mnemonic#"\t$R1, $I2",
987 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
988 let Constraints = "$R1 = $R1src";
989 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000990}
991
992class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000993 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000994 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000995 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
996 mnemonic#"\t$R1, $XBD2",
997 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000998 let OpKey = mnemonic ## cls;
999 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001000 let Constraints = "$R1 = $R1src";
1001 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001002 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001003 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001004}
1005
1006class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001007 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001008 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
1009 mnemonic#"\t$R1, $XBD2",
1010 [(set cls:$R1, (operator cls:$R1src,
1011 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001012 let OpKey = mnemonic ## cls;
1013 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001014 let Constraints = "$R1 = $R1src";
1015 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001016 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001017 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001018}
1019
1020class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001021 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001022 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001023 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
1024 mnemonic#"\t$R1, $XBD2",
1025 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001026 let OpKey = mnemonic ## cls;
1027 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001028 let Constraints = "$R1 = $R1src";
1029 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001030 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001031 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001032}
1033
1034multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1035 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001036 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001037 let DispKey = mnemonic ## #cls in {
1038 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +00001039 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
1040 bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001041 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +00001042 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001043 bdxaddr20pair>;
1044 }
1045}
1046
1047class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1048 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001049 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1050 mnemonic#"\t$BD1, $I2",
1051 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001052 let mayLoad = 1;
1053 let mayStore = 1;
1054}
1055
1056class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1057 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001058 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1059 mnemonic#"\t$BD1, $I2",
1060 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001061 let mayLoad = 1;
1062 let mayStore = 1;
1063}
1064
1065multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
1066 bits<16> siyOpcode, SDPatternOperator operator,
1067 Operand imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001068 let DispKey = mnemonic ## #cls in {
1069 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001070 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001071 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001072 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
1073 }
1074}
1075
1076class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001077 RegisterOperand cls>
1078 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001079 mnemonic#"\t$R1, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001080 [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001081 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +00001082 let Constraints = "$R1 = $R1src";
1083 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001084}
1085
1086class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001087 RegisterOperand cls>
1088 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001089 mnemonic#"\t$R1, $R3, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001090 [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
1091
1092multiclass ShiftRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
1093 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandifordff6c5a52013-07-19 16:12:08 +00001094 let NumOpsKey = mnemonic in {
1095 let NumOpsValue = "3" in
1096 def K : ShiftRSY<mnemonic##"k", opcode2, null_frag, cls>,
1097 Requires<[FeatureDistinctOps]>;
1098 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
1099 def "" : ShiftRS<mnemonic, opcode1, operator, cls>;
1100 }
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001101}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001102
1103class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1104 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001105 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001106 mnemonic#"r\t$R1, $R2",
1107 [(operator cls1:$R1, cls2:$R2)]> {
1108 let OpKey = mnemonic ## cls1;
1109 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001110 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001111}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001112
1113class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1114 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001115 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001116 mnemonic#"r\t$R1, $R2",
1117 [(operator cls1:$R1, cls2:$R2)]> {
1118 let OpKey = mnemonic ## cls1;
1119 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001120 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001121}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001122
1123class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1124 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001125 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
1126 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001127 [(operator cls:$R1, imm:$I2)]> {
1128 let isCompare = 1;
1129}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001130
1131class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1132 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001133 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
1134 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001135 [(operator cls:$R1, imm:$I2)]> {
1136 let isCompare = 1;
1137}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001138
1139class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1140 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001141 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
1142 mnemonic#"\t$R1, $I2",
1143 [(operator cls:$R1, (load pcrel32:$I2))]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001144 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001145 let mayLoad = 1;
1146 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
1147 // However, BDXs have two extra operands and are therefore 6 units more
1148 // complex.
1149 let AddedComplexity = 7;
1150}
1151
1152class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001153 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001154 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001155 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1156 mnemonic#"\t$R1, $XBD2",
1157 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001158 let OpKey = mnemonic ## cls;
1159 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001160 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001161 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001162 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001163}
1164
1165class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001166 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001167 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
1168 mnemonic#"\t$R1, $XBD2",
1169 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001170 let OpKey = mnemonic ## cls;
1171 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001172 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001173 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001174 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001175}
1176
1177class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001178 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001179 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001180 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1181 mnemonic#"\t$R1, $XBD2",
1182 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001183 let OpKey = mnemonic ## cls;
1184 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001185 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001186 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001187 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001188}
1189
1190multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1191 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001192 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001193 let DispKey = mnemonic ## #cls in {
1194 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001195 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001196 load, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001197 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001198 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001199 load, bytes, bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001200 }
1201}
1202
1203class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1204 SDPatternOperator load, Immediate imm,
1205 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001206 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1207 mnemonic#"\t$BD1, $I2",
1208 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001209 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001210 let mayLoad = 1;
1211}
1212
1213class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1214 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001215 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
1216 mnemonic#"\t$BD1, $I2",
1217 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001218 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001219 let mayLoad = 1;
1220}
1221
1222class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1223 SDPatternOperator load, Immediate imm,
1224 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001225 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1226 mnemonic#"\t$BD1, $I2",
1227 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001228 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001229 let mayLoad = 1;
1230}
1231
1232multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
1233 SDPatternOperator operator, SDPatternOperator load,
1234 Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001235 let DispKey = mnemonic in {
1236 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001237 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001238 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001239 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
1240 bdaddr20pair>;
1241 }
1242}
1243
1244class TernaryRRD<string mnemonic, bits<16> opcode,
1245 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001246 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001247 mnemonic#"r\t$R1, $R3, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +00001248 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001249 let OpKey = mnemonic ## cls;
1250 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001251 let Constraints = "$R1 = $R1src";
1252 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001253}
1254
1255class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001256 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001257 : InstRXF<opcode, (outs cls:$R1),
1258 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
1259 mnemonic#"\t$R1, $R3, $XBD2",
1260 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
1261 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001262 let OpKey = mnemonic ## cls;
1263 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001264 let Constraints = "$R1 = $R1src";
1265 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001266 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001267 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001268}
1269
1270class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1271 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001272 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1273 mnemonic#"\t$R1, $R3, $BD2",
1274 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1275 let Constraints = "$R1 = $R1src";
1276 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001277 let mayLoad = 1;
1278 let mayStore = 1;
1279}
1280
1281class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1282 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001283 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1284 mnemonic#"\t$R1, $R3, $BD2",
1285 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1286 let Constraints = "$R1 = $R1src";
1287 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001288 let mayLoad = 1;
1289 let mayStore = 1;
1290}
1291
1292multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
1293 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001294 let DispKey = mnemonic ## #cls in {
1295 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001296 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001297 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001298 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
1299 }
1300}
1301
1302class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
1303 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001304 : InstRIEf<opcode, (outs cls1:$R1),
Richard Sandiford67ddcd62013-07-11 08:37:13 +00001305 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001306 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
1307 let Constraints = "$R1 = $R1src";
1308 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001309}
1310
Richard Sandiford03481332013-08-23 11:36:42 +00001311class PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator>
1312 : InstRXY<opcode, (outs), (ins uimm8zx4:$R1, bdxaddr20only:$XBD2),
1313 mnemonic##"\t$R1, $XBD2",
1314 [(operator uimm8zx4:$R1, bdxaddr20only:$XBD2)]>;
1315
1316class PrefetchRILPC<string mnemonic, bits<12> opcode,
1317 SDPatternOperator operator>
1318 : InstRIL<opcode, (outs), (ins uimm8zx4:$R1, pcrel32:$I2),
1319 mnemonic##"\t$R1, $I2",
1320 [(operator uimm8zx4:$R1, pcrel32:$I2)]> {
1321 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
1322 // However, BDXs have two extra operands and are therefore 6 units more
1323 // complex.
1324 let AddedComplexity = 7;
1325}
1326
Richard Sandiford9f11bc12013-08-07 11:03:34 +00001327// A floating-point load-and test operation. Create both a normal unary
1328// operation and one that acts as a comparison against zero.
1329multiclass LoadAndTestRRE<string mnemonic, bits<16> opcode,
1330 RegisterOperand cls> {
1331 def "" : UnaryRRE<mnemonic, opcode, null_frag, cls, cls>;
1332 let isCodeGenOnly = 1 in
1333 def Compare : CompareRRE<mnemonic, opcode, null_frag, cls, cls>;
1334}
1335
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001336//===----------------------------------------------------------------------===//
1337// Pseudo instructions
1338//===----------------------------------------------------------------------===//
1339//
1340// Convenience instructions that get lowered to real instructions
1341// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
1342// or SystemZInstrInfo::expandPostRAPseudo().
1343//
1344//===----------------------------------------------------------------------===//
1345
1346class Pseudo<dag outs, dag ins, list<dag> pattern>
1347 : InstSystemZ<0, outs, ins, "", pattern> {
1348 let isPseudo = 1;
1349 let isCodeGenOnly = 1;
1350}
1351
Richard Sandiford01240232013-10-01 13:02:28 +00001352// Like UnaryRI, but expanded after RA depending on the choice of register.
1353class UnaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
1354 Immediate imm>
1355 : Pseudo<(outs cls:$R1), (ins imm:$I2),
1356 [(set cls:$R1, (operator imm:$I2))]>;
1357
Richard Sandifordb63e3002013-10-01 15:00:44 +00001358// Like UnaryRXY, but expanded after RA depending on the choice of register.
Richard Sandiford0755c932013-10-01 11:26:28 +00001359class UnaryRXYPseudo<string key, SDPatternOperator operator,
1360 RegisterOperand cls, bits<5> bytes,
1361 AddressingMode mode = bdxaddr20only>
1362 : Pseudo<(outs cls:$R1), (ins mode:$XBD2),
1363 [(set cls:$R1, (operator mode:$XBD2))]> {
1364 let OpKey = key ## cls;
1365 let OpType = "mem";
1366 let mayLoad = 1;
1367 let Has20BitOffset = 1;
1368 let HasIndex = 1;
1369 let AccessBytes = bytes;
1370}
1371
1372// Like UnaryRR, but expanded after RA depending on the choice of registers.
1373class UnaryRRPseudo<string key, SDPatternOperator operator,
1374 RegisterOperand cls1, RegisterOperand cls2>
1375 : Pseudo<(outs cls1:$R1), (ins cls2:$R2),
1376 [(set cls1:$R1, (operator cls2:$R2))]> {
1377 let OpKey = key ## cls1;
1378 let OpType = "reg";
1379}
1380
Richard Sandiford1a569312013-10-01 13:18:56 +00001381// Like BinaryRI, but expanded after RA depending on the choice of register.
1382class BinaryRIPseudo<SDPatternOperator operator, RegisterOperand cls,
1383 Immediate imm>
1384 : Pseudo<(outs cls:$R1), (ins cls:$R1src, imm:$I2),
1385 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
1386 let Constraints = "$R1 = $R1src";
1387}
1388
Richard Sandiford42a694f2013-10-01 14:53:46 +00001389// Like BinaryRIE, but expanded after RA depending on the choice of register.
1390class BinaryRIEPseudo<SDPatternOperator operator, RegisterOperand cls,
1391 Immediate imm>
1392 : Pseudo<(outs cls:$R1), (ins cls:$R3, imm:$I2),
1393 [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
1394
1395// Like BinaryRIAndK, but expanded after RA depending on the choice of register.
1396multiclass BinaryRIAndKPseudo<string key, SDPatternOperator operator,
1397 RegisterOperand cls, Immediate imm> {
1398 let NumOpsKey = key in {
1399 let NumOpsValue = "3" in
1400 def K : BinaryRIEPseudo<null_frag, cls, imm>,
1401 Requires<[FeatureHighWord, FeatureDistinctOps]>;
1402 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
1403 def "" : BinaryRIPseudo<operator, cls, imm>,
1404 Requires<[FeatureHighWord]>;
1405 }
1406}
1407
Richard Sandiford2cac7632013-10-01 14:41:52 +00001408// Like CompareRI, but expanded after RA depending on the choice of register.
1409class CompareRIPseudo<SDPatternOperator operator, RegisterOperand cls,
1410 Immediate imm>
1411 : Pseudo<(outs), (ins cls:$R1, imm:$I2), [(operator cls:$R1, imm:$I2)]>;
1412
Richard Sandifordb63e3002013-10-01 15:00:44 +00001413// Like CompareRXY, but expanded after RA depending on the choice of register.
1414class CompareRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
1415 SDPatternOperator load, bits<5> bytes,
1416 AddressingMode mode = bdxaddr20only>
1417 : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
1418 [(operator cls:$R1, (load mode:$XBD2))]> {
1419 let mayLoad = 1;
1420 let Has20BitOffset = 1;
1421 let HasIndex = 1;
1422 let AccessBytes = bytes;
1423}
1424
1425// Like StoreRXY, but expanded after RA depending on the choice of register.
Richard Sandiford0755c932013-10-01 11:26:28 +00001426class StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,
1427 bits<5> bytes, AddressingMode mode = bdxaddr20only>
1428 : Pseudo<(outs), (ins cls:$R1, mode:$XBD2),
1429 [(operator cls:$R1, mode:$XBD2)]> {
1430 let mayStore = 1;
1431 let Has20BitOffset = 1;
1432 let HasIndex = 1;
1433 let AccessBytes = bytes;
1434}
1435
Richard Sandiford70284282013-10-01 14:20:41 +00001436// Like RotateSelectRIEf, but expanded after RA depending on the choice
1437// of registers.
1438class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>
1439 : Pseudo<(outs cls1:$R1),
1440 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5),
1441 []> {
1442 let Constraints = "$R1 = $R1src";
1443 let DisableEncoding = "$R1src";
1444}
1445
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001446// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
1447// the value of the PSW's 2-bit condition code field.
1448class SelectWrapper<RegisterOperand cls>
Richard Sandiford3d768e32013-07-31 12:30:20 +00001449 : Pseudo<(outs cls:$dst),
1450 (ins cls:$src1, cls:$src2, uimm8zx4:$valid, uimm8zx4:$cc),
1451 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2,
1452 uimm8zx4:$valid, uimm8zx4:$cc))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001453 let usesCustomInserter = 1;
1454 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +00001455 // change CC, the insertion requires new blocks, and CC cannot be live
1456 // across them.
1457 let Defs = [CC];
1458 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001459}
1460
Richard Sandifordb86a8342013-06-27 09:27:40 +00001461// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
1462multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
1463 SDPatternOperator load, AddressingMode mode> {
1464 let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {
Richard Sandiford3d768e32013-07-31 12:30:20 +00001465 def "" : Pseudo<(outs),
1466 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001467 [(store (z_select_ccmask cls:$new, (load mode:$addr),
Richard Sandiford3d768e32013-07-31 12:30:20 +00001468 uimm8zx4:$valid, uimm8zx4:$cc),
1469 mode:$addr)]>;
1470 def Inv : Pseudo<(outs),
1471 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001472 [(store (z_select_ccmask (load mode:$addr), cls:$new,
Richard Sandiford3d768e32013-07-31 12:30:20 +00001473 uimm8zx4:$valid, uimm8zx4:$cc),
1474 mode:$addr)]>;
Richard Sandifordb86a8342013-06-27 09:27:40 +00001475 }
1476}
1477
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001478// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
1479// describe the second (non-memory) operand.
1480class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
1481 dag pat, DAGOperand operand>
1482 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
1483 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001484 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001485 let Has20BitOffset = 1;
1486 let mayLoad = 1;
1487 let mayStore = 1;
1488 let usesCustomInserter = 1;
1489}
1490
1491// Specializations of AtomicLoadWBinary.
1492class AtomicLoadBinaryReg32<SDPatternOperator operator>
1493 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
1494class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
1495 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
1496class AtomicLoadBinaryReg64<SDPatternOperator operator>
1497 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
1498class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
1499 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
1500
1501// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
1502// describe the second (non-memory) operand.
1503class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
1504 DAGOperand operand>
1505 : Pseudo<(outs GR32:$dst),
1506 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
1507 ADDR32:$negbitshift, uimm32:$bitsize),
1508 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
1509 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001510 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001511 let Has20BitOffset = 1;
1512 let mayLoad = 1;
1513 let mayStore = 1;
1514 let usesCustomInserter = 1;
1515}
1516
1517// Specializations of AtomicLoadWBinary.
1518class AtomicLoadWBinaryReg<SDPatternOperator operator>
1519 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
1520class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
1521 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;
Richard Sandiford761703a2013-08-12 10:17:33 +00001522
Richard Sandiford5e318f02013-08-27 09:54:29 +00001523// Define an instruction that operates on two fixed-length blocks of memory,
1524// and associated pseudo instructions for operating on blocks of any size.
1525// The Sequence form uses a straight-line sequence of instructions and
1526// the Loop form uses a loop of length-256 instructions followed by
1527// another instruction to handle the excess.
Richard Sandiford761703a2013-08-12 10:17:33 +00001528multiclass MemorySS<string mnemonic, bits<8> opcode,
Richard Sandiford5e318f02013-08-27 09:54:29 +00001529 SDPatternOperator sequence, SDPatternOperator loop> {
Richard Sandiford761703a2013-08-12 10:17:33 +00001530 def "" : InstSS<opcode, (outs), (ins bdladdr12onlylen8:$BDL1,
1531 bdaddr12only:$BD2),
1532 mnemonic##"\t$BDL1, $BD2", []>;
Richard Sandiford5e318f02013-08-27 09:54:29 +00001533 let usesCustomInserter = 1 in {
1534 def Sequence : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
1535 imm64:$length),
1536 [(sequence bdaddr12only:$dest, bdaddr12only:$src,
1537 imm64:$length)]>;
1538 def Loop : Pseudo<(outs), (ins bdaddr12only:$dest, bdaddr12only:$src,
1539 imm64:$length, GR64:$count256),
1540 [(loop bdaddr12only:$dest, bdaddr12only:$src,
1541 imm64:$length, GR64:$count256)]>;
1542 }
Richard Sandiford761703a2013-08-12 10:17:33 +00001543}
Richard Sandifordca232712013-08-16 11:21:54 +00001544
1545// Define an instruction that operates on two strings, both terminated
1546// by the character in R0. The instruction processes a CPU-determinated
1547// number of bytes at a time and sets CC to 3 if the instruction needs
1548// to be repeated. Also define a pseudo instruction that represents
1549// the full loop (the main instruction plus the branch on CC==3).
1550multiclass StringRRE<string mnemonic, bits<16> opcode,
1551 SDPatternOperator operator> {
1552 def "" : InstRRE<opcode, (outs GR64:$R1, GR64:$R2),
1553 (ins GR64:$R1src, GR64:$R2src),
1554 mnemonic#"\t$R1, $R2", []> {
1555 let Constraints = "$R1 = $R1src, $R2 = $R2src";
1556 let DisableEncoding = "$R1src, $R2src";
1557 }
1558 let usesCustomInserter = 1 in
1559 def Loop : Pseudo<(outs GR64:$end),
1560 (ins GR64:$start1, GR64:$start2, GR32:$char),
1561 [(set GR64:$end, (operator GR64:$start1, GR64:$start2,
1562 GR32:$char))]>;
1563}
Richard Sandiford9ab97cd2013-09-25 10:20:08 +00001564
1565// A pseudo instruction that is a direct alias of a real instruction.
1566// These aliases are used in cases where a particular register operand is
1567// fixed or where the same instruction is used with different register sizes.
1568// The size parameter is the size in bytes of the associated real instruction.
1569class Alias<int size, dag outs, dag ins, list<dag> pattern>
1570 : InstSystemZ<size, outs, ins, "", pattern> {
1571 let isPseudo = 1;
1572 let isCodeGenOnly = 1;
1573}
Richard Sandiford652784e2013-09-25 11:11:53 +00001574
1575// An alias of a BinaryRI, but with different register sizes.
1576class BinaryAliasRI<SDPatternOperator operator, RegisterOperand cls,
1577 Immediate imm>
1578 : Alias<4, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
1579 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
1580 let Constraints = "$R1 = $R1src";
1581}
1582
1583// An alias of a BinaryRIL, but with different register sizes.
1584class BinaryAliasRIL<SDPatternOperator operator, RegisterOperand cls,
1585 Immediate imm>
1586 : Alias<6, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
1587 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
1588 let Constraints = "$R1 = $R1src";
1589}
Richard Sandiford0755c932013-10-01 11:26:28 +00001590
1591// An alias of a RotateSelectRIEf, but with different register sizes.
1592class RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>
1593 : Alias<6, (outs cls1:$R1),
1594 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5), []> {
1595 let Constraints = "$R1 = $R1src";
1596}