blob: 954df112693c631e15d39c3d11a5803bc13247b1 [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;
311
312 let Inst{31-16} = op;
313 let Inst{15-12} = R3;
314 let Inst{11-8} = 0;
315 let Inst{7-4} = R1;
316 let Inst{3-0} = R2;
317}
318
319class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
320 : InstSystemZ<4, outs, ins, asmstr, pattern> {
321 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000322 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000323
324 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000325 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000326
327 let Inst{31-24} = op;
328 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000329 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000330
331 let HasIndex = 1;
332}
333
334class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
335 : InstSystemZ<6, outs, ins, asmstr, pattern> {
336 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000337 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000338
339 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000340 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000341
342 let Inst{47-40} = op{15-8};
343 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000344 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000345 let Inst{15-8} = 0;
346 let Inst{7-0} = op{7-0};
347
348 let HasIndex = 1;
349}
350
351class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
352 : InstSystemZ<6, outs, ins, asmstr, pattern> {
353 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000354 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000355
356 bits<4> R1;
357 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000358 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000359
360 let Inst{47-40} = op{15-8};
361 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000362 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000363 let Inst{15-12} = R1;
364 let Inst{11-8} = 0;
365 let Inst{7-0} = op{7-0};
366
367 let HasIndex = 1;
368}
369
370class InstRXY<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
375 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000376 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000377
378 let Inst{47-40} = op{15-8};
379 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000380 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000381 let Inst{7-0} = op{7-0};
382
383 let Has20BitOffset = 1;
384 let HasIndex = 1;
385}
386
387class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
388 : InstSystemZ<4, outs, ins, asmstr, pattern> {
389 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000390 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000391
392 bits<4> R1;
393 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000394 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000395
396 let Inst{31-24} = op;
397 let Inst{23-20} = R1;
398 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000399 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000400}
401
402class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
403 : InstSystemZ<6, outs, ins, asmstr, pattern> {
404 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000405 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000406
407 bits<4> R1;
408 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000409 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000410
411 let Inst{47-40} = op{15-8};
412 let Inst{39-36} = R1;
413 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000414 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000415 let Inst{7-0} = op{7-0};
416
417 let Has20BitOffset = 1;
418}
419
420class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
421 : InstSystemZ<4, outs, ins, asmstr, pattern> {
422 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000423 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000424
Richard Sandifordd454ec02013-05-14 09:28:21 +0000425 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000426 bits<8> I2;
427
428 let Inst{31-24} = op;
429 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000430 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000431}
432
433class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
434 : InstSystemZ<6, outs, ins, asmstr, pattern> {
435 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000436 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000437
Richard Sandifordd454ec02013-05-14 09:28:21 +0000438 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000439 bits<16> I2;
440
441 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000442 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000443 let Inst{15-0} = I2;
444}
445
446class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
447 : InstSystemZ<6, outs, ins, asmstr, pattern> {
448 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000449 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000450
Richard Sandifordd454ec02013-05-14 09:28:21 +0000451 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000452 bits<8> I2;
453
454 let Inst{47-40} = op{15-8};
455 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000456 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000457 let Inst{7-0} = op{7-0};
458
459 let Has20BitOffset = 1;
460}
461
Richard Sandiford1d959002013-07-02 14:56:45 +0000462class InstSS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
463 : InstSystemZ<6, outs, ins, asmstr, pattern> {
464 field bits<48> Inst;
465 field bits<48> SoftFail = 0;
466
467 bits<24> BDL1;
468 bits<16> BD2;
469
470 let Inst{47-40} = op;
471 let Inst{39-16} = BDL1;
472 let Inst{15-0} = BD2;
473}
474
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000475//===----------------------------------------------------------------------===//
476// Instruction definitions with semantics
477//===----------------------------------------------------------------------===//
478//
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000479// These classes have the form [Cond]<Category><Format>, where <Format> is one
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000480// of the formats defined above and where <Category> describes the inputs
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000481// and outputs. "Cond" is used if the instruction is conditional,
482// in which case the 4-bit condition-code mask is added as a final operand.
483// <Category> can be one of:
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000484//
485// Inherent:
486// One register output operand and no input operands.
487//
Richard Sandiford9795d8e2013-08-05 11:07:38 +0000488// BranchUnary:
489// One register output operand, one register input operand and
490// one branch displacement. The instructions stores a modified
491// form of the source register in the destination register and
492// branches on the result.
493//
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000494// Store:
495// One register or immediate input operand and one address input operand.
496// The instruction stores the first operand to the address.
497//
498// This category is used for both pure and truncating stores.
499//
500// LoadMultiple:
501// One address input operand and two explicit output operands.
502// The instruction loads a range of registers from the address,
503// with the explicit operands giving the first and last register
504// to load. Other loaded registers are added as implicit definitions.
505//
506// StoreMultiple:
507// Two explicit input register operands and an address operand.
508// The instruction stores a range of registers to the address,
509// with the explicit operands giving the first and last register
510// to store. Other stored registers are added as implicit uses.
511//
512// Unary:
513// One register output operand and one input operand. The input
514// operand may be a register, immediate or memory.
515//
516// Binary:
517// One register output operand and two input operands. The first
518// input operand is always a register and he second may be a register,
519// immediate or memory.
520//
521// Shift:
522// One register output operand and two input operands. The first
523// input operand is a register and the second has the same form as
524// an address (although it isn't actually used to address memory).
525//
526// Compare:
527// Two input operands. The first operand is always a register,
528// the second may be a register, immediate or memory.
529//
530// Ternary:
531// One register output operand and three register input operands.
532//
533// CmpSwap:
534// One output operand and three input operands. The first two
535// operands are registers and the third is an address. The instruction
536// both reads from and writes to the address.
537//
538// RotateSelect:
539// One output operand and five input operands. The first two operands
540// are registers and the other three are immediates.
541//
542// The format determines which input operands are tied to output operands,
543// and also determines the shape of any address operand.
544//
545// Multiclasses of the form <Category><Format>Pair define two instructions,
546// one with <Category><Format> and one with <Category><Format>Y. The name
547// of the first instruction has no suffix, the name of the second has
548// an extra "y".
549//
550//===----------------------------------------------------------------------===//
551
552class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
553 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000554 : InstRRE<opcode, (outs cls:$R1), (ins),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000555 mnemonic#"r\t$R1",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000556 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000557 let R2 = 0;
558}
559
Richard Sandiford9795d8e2013-08-05 11:07:38 +0000560class BranchUnaryRI<string mnemonic, bits<12> opcode, RegisterOperand cls>
561 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, brtarget16:$I2),
562 mnemonic##"\t$R1, $I2", []> {
563 let isBranch = 1;
564 let isTerminator = 1;
565 let Constraints = "$R1 = $R1src";
566 let DisableEncoding = "$R1src";
567}
568
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000569class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000570 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
571 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000572 let mayLoad = 1;
573}
574
575class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
576 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000577 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
578 mnemonic#"\t$R1, $I2",
579 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000580 let mayStore = 1;
581 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
582 // However, BDXs have two extra operands and are therefore 6 units more
583 // complex.
584 let AddedComplexity = 7;
585}
586
587class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000588 RegisterOperand cls, bits<5> bytes,
589 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000590 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
591 mnemonic#"\t$R1, $XBD2",
592 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000593 let OpKey = mnemonic ## cls;
594 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000595 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000596 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000597}
598
599class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000600 RegisterOperand cls, bits<5> bytes,
601 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000602 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
603 mnemonic#"\t$R1, $XBD2",
604 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000605 let OpKey = mnemonic ## cls;
606 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000607 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000608 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000609}
610
611multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000612 SDPatternOperator operator, RegisterOperand cls,
613 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000614 let DispKey = mnemonic ## #cls in {
615 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000616 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000617 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000618 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
619 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000620 }
621}
622
623class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000624 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
625 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000626 let mayStore = 1;
627}
628
629class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
630 Immediate imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000631 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
632 mnemonic#"\t$BD1, $I2",
633 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000634 let mayStore = 1;
635}
636
637class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
638 Immediate imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000639 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
640 mnemonic#"\t$BD1, $I2",
641 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000642 let mayStore = 1;
643}
644
645class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
646 Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000647 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
648 mnemonic#"\t$BD1, $I2",
649 [(operator imm:$I2, bdaddr12only:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000650 let mayStore = 1;
651}
652
653multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
654 SDPatternOperator operator, Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000655 let DispKey = mnemonic in {
656 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000657 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000658 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000659 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
660 }
661}
662
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000663class CondStoreRSY<string mnemonic, bits<16> opcode,
664 RegisterOperand cls, bits<5> bytes,
665 AddressingMode mode = bdaddr20only>
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000666 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3),
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000667 mnemonic#"$R3\t$R1, $BD2", []>,
668 Requires<[FeatureLoadStoreOnCond]> {
669 let mayStore = 1;
670 let AccessBytes = bytes;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000671 let CCMaskLast = 1;
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000672}
673
674// Like CondStoreRSY, but used for the raw assembly form. The condition-code
675// mask is the third operand rather than being part of the mnemonic.
676class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
677 RegisterOperand cls, bits<5> bytes,
678 AddressingMode mode = bdaddr20only>
679 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, uimm8zx4:$R3),
680 mnemonic#"\t$R1, $BD2, $R3", []>,
681 Requires<[FeatureLoadStoreOnCond]> {
682 let mayStore = 1;
683 let AccessBytes = bytes;
684}
685
686// Like CondStoreRSY, but with a fixed CC mask.
687class FixedCondStoreRSY<string mnemonic, bits<16> opcode,
688 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
689 AddressingMode mode = bdaddr20only>
690 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2),
691 mnemonic#"\t$R1, $BD2", []>,
692 Requires<[FeatureLoadStoreOnCond]> {
693 let mayStore = 1;
694 let AccessBytes = bytes;
695 let R3 = ccmask;
696}
697
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000698class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
699 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000700 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000701 mnemonic#"r\t$R1, $R2",
702 [(set cls1:$R1, (operator cls2:$R2))]> {
703 let OpKey = mnemonic ## cls1;
704 let OpType = "reg";
705}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000706
707class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
708 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000709 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000710 mnemonic#"r\t$R1, $R2",
711 [(set cls1:$R1, (operator cls2:$R2))]> {
712 let OpKey = mnemonic ## cls1;
713 let OpType = "reg";
714}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000715
716class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
717 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000718 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000719 mnemonic#"r\t$R1, $R3, $R2", []> {
720 let OpKey = mnemonic ## cls1;
721 let OpType = "reg";
722}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000723
Richard Sandifordf2404162013-07-25 09:11:15 +0000724// These instructions are generated by if conversion. The old value of R1
725// is added as an implicit use.
726class CondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
727 RegisterOperand cls2>
Richard Sandiford3d768e32013-07-31 12:30:20 +0000728 : InstRRF<opcode, (outs cls1:$R1), (ins cls2:$R2, cond4:$valid, cond4:$R3),
Richard Sandifordf2404162013-07-25 09:11:15 +0000729 mnemonic#"r$R3\t$R1, $R2", []>,
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000730 Requires<[FeatureLoadStoreOnCond]> {
731 let CCMaskLast = 1;
732}
Richard Sandifordf2404162013-07-25 09:11:15 +0000733
734// Like CondUnaryRRF, but used for the raw assembly form. The condition-code
735// mask is the third operand rather than being part of the mnemonic.
736class AsmCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
737 RegisterOperand cls2>
738 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2, uimm8zx4:$R3),
739 mnemonic#"r\t$R1, $R2, $R3", []>,
740 Requires<[FeatureLoadStoreOnCond]> {
741 let Constraints = "$R1 = $R1src";
742 let DisableEncoding = "$R1src";
743}
744
745// Like CondUnaryRRF, but with a fixed CC mask.
746class FixedCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
747 RegisterOperand cls2, bits<4> ccmask>
748 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
749 mnemonic#"\t$R1, $R2", []>,
750 Requires<[FeatureLoadStoreOnCond]> {
751 let Constraints = "$R1 = $R1src";
752 let DisableEncoding = "$R1src";
753 let R3 = ccmask;
754}
755
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000756class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
757 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000758 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
759 mnemonic#"\t$R1, $I2",
760 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000761
762class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
763 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000764 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
765 mnemonic#"\t$R1, $I2",
766 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000767
768class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
769 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000770 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
771 mnemonic#"\t$R1, $I2",
772 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000773 let mayLoad = 1;
774 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
775 // However, BDXs have two extra operands and are therefore 6 units more
776 // complex.
777 let AddedComplexity = 7;
778}
779
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000780class CondUnaryRSY<string mnemonic, bits<16> opcode,
Richard Sandifordee834382013-07-31 12:38:08 +0000781 SDPatternOperator operator, RegisterOperand cls,
782 bits<5> bytes, AddressingMode mode = bdaddr20only>
783 : InstRSY<opcode, (outs cls:$R1),
784 (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
785 mnemonic#"$R3\t$R1, $BD2",
786 [(set cls:$R1,
787 (z_select_ccmask (load bdaddr20only:$BD2), cls:$R1src,
788 cond4:$valid, cond4:$R3))]>,
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000789 Requires<[FeatureLoadStoreOnCond]> {
790 let Constraints = "$R1 = $R1src";
791 let DisableEncoding = "$R1src";
792 let mayLoad = 1;
793 let AccessBytes = bytes;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000794 let CCMaskLast = 1;
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000795}
796
797// Like CondUnaryRSY, but used for the raw assembly form. The condition-code
798// mask is the third operand rather than being part of the mnemonic.
799class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
800 RegisterOperand cls, bits<5> bytes,
801 AddressingMode mode = bdaddr20only>
802 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, uimm8zx4:$R3),
803 mnemonic#"\t$R1, $BD2, $R3", []>,
804 Requires<[FeatureLoadStoreOnCond]> {
805 let mayLoad = 1;
806 let AccessBytes = bytes;
807 let Constraints = "$R1 = $R1src";
808 let DisableEncoding = "$R1src";
809}
810
811// Like CondUnaryRSY, but with a fixed CC mask.
812class FixedCondUnaryRSY<string mnemonic, bits<16> opcode,
813 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
814 AddressingMode mode = bdaddr20only>
815 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
816 mnemonic#"\t$R1, $BD2", []>,
817 Requires<[FeatureLoadStoreOnCond]> {
818 let Constraints = "$R1 = $R1src";
819 let DisableEncoding = "$R1src";
820 let R3 = ccmask;
821 let mayLoad = 1;
822 let AccessBytes = bytes;
823}
824
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000825class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000826 RegisterOperand cls, bits<5> bytes,
827 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000828 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
829 mnemonic#"\t$R1, $XBD2",
830 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000831 let OpKey = mnemonic ## cls;
832 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000833 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000834 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000835}
836
837class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000838 RegisterOperand cls, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000839 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
840 mnemonic#"\t$R1, $XBD2",
841 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000842 let OpKey = mnemonic ## cls;
843 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000844 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000845 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000846}
847
848class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000849 RegisterOperand cls, bits<5> bytes,
850 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000851 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
852 mnemonic#"\t$R1, $XBD2",
853 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000854 let OpKey = mnemonic ## cls;
855 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000856 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000857 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000858}
859
860multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000861 SDPatternOperator operator, RegisterOperand cls,
862 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000863 let DispKey = mnemonic ## #cls in {
864 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000865 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000866 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000867 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
868 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000869 }
870}
871
872class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
873 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000874 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000875 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000876 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000877 let OpKey = mnemonic ## cls1;
878 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000879 let Constraints = "$R1 = $R1src";
880 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000881}
882
883class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
884 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000885 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000886 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000887 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000888 let OpKey = mnemonic ## cls1;
889 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000890 let Constraints = "$R1 = $R1src";
891 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000892}
893
Richard Sandifordd454ec02013-05-14 09:28:21 +0000894class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
895 RegisterOperand cls1, RegisterOperand cls2>
896 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000897 mnemonic#"r\t$R1, $R3, $R2",
898 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]> {
899 let OpKey = mnemonic ## cls1;
900 let OpType = "reg";
901}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000902
Richard Sandiford0175b4a2013-07-19 16:21:55 +0000903class BinaryRRFK<string mnemonic, bits<16> opcode, SDPatternOperator operator,
904 RegisterOperand cls1, RegisterOperand cls2>
905 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R2, cls2:$R3),
906 mnemonic#"rk\t$R1, $R2, $R3",
907 [(set cls1:$R1, (operator cls1:$R2, cls2:$R3))]>;
908
909multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
910 SDPatternOperator operator, RegisterOperand cls1,
911 RegisterOperand cls2> {
912 let NumOpsKey = mnemonic in {
913 let NumOpsValue = "3" in
914 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
915 Requires<[FeatureDistinctOps]>;
916 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
917 def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
918 }
919}
920
Richard Sandifordc57e5862013-07-19 16:24:22 +0000921multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
922 SDPatternOperator operator, RegisterOperand cls1,
923 RegisterOperand cls2> {
924 let NumOpsKey = mnemonic in {
925 let NumOpsValue = "3" in
926 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
927 Requires<[FeatureDistinctOps]>;
928 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
929 def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
930 }
931}
932
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000933class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
934 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000935 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
936 mnemonic#"\t$R1, $I2",
937 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
938 let Constraints = "$R1 = $R1src";
939 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000940}
941
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000942class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
943 RegisterOperand cls, Immediate imm>
944 : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
945 mnemonic#"\t$R1, $R3, $I2",
946 [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
947
948multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
949 SDPatternOperator operator, RegisterOperand cls,
950 Immediate imm> {
951 let NumOpsKey = mnemonic in {
952 let NumOpsValue = "3" in
953 def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
954 Requires<[FeatureDistinctOps]>;
955 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
956 def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
957 }
958}
959
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000960class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
961 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000962 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
963 mnemonic#"\t$R1, $I2",
964 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
965 let Constraints = "$R1 = $R1src";
966 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000967}
968
969class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000970 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000971 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000972 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
973 mnemonic#"\t$R1, $XBD2",
974 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000975 let OpKey = mnemonic ## cls;
976 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000977 let Constraints = "$R1 = $R1src";
978 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000979 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000980 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000981}
982
983class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000984 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000985 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
986 mnemonic#"\t$R1, $XBD2",
987 [(set cls:$R1, (operator cls:$R1src,
988 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000989 let OpKey = mnemonic ## cls;
990 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000991 let Constraints = "$R1 = $R1src";
992 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000993 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000994 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000995}
996
997class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000998 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000999 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001000 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
1001 mnemonic#"\t$R1, $XBD2",
1002 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001003 let OpKey = mnemonic ## cls;
1004 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001005 let Constraints = "$R1 = $R1src";
1006 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001007 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001008 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001009}
1010
1011multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1012 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001013 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001014 let DispKey = mnemonic ## #cls in {
1015 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +00001016 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
1017 bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001018 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +00001019 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001020 bdxaddr20pair>;
1021 }
1022}
1023
1024class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1025 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001026 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1027 mnemonic#"\t$BD1, $I2",
1028 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001029 let mayLoad = 1;
1030 let mayStore = 1;
1031}
1032
1033class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1034 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001035 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1036 mnemonic#"\t$BD1, $I2",
1037 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001038 let mayLoad = 1;
1039 let mayStore = 1;
1040}
1041
1042multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
1043 bits<16> siyOpcode, SDPatternOperator operator,
1044 Operand imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001045 let DispKey = mnemonic ## #cls in {
1046 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001047 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001048 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001049 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
1050 }
1051}
1052
1053class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001054 RegisterOperand cls>
1055 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001056 mnemonic#"\t$R1, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001057 [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001058 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +00001059 let Constraints = "$R1 = $R1src";
1060 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001061}
1062
1063class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001064 RegisterOperand cls>
1065 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001066 mnemonic#"\t$R1, $R3, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001067 [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
1068
1069multiclass ShiftRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
1070 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandifordff6c5a52013-07-19 16:12:08 +00001071 let NumOpsKey = mnemonic in {
1072 let NumOpsValue = "3" in
1073 def K : ShiftRSY<mnemonic##"k", opcode2, null_frag, cls>,
1074 Requires<[FeatureDistinctOps]>;
1075 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
1076 def "" : ShiftRS<mnemonic, opcode1, operator, cls>;
1077 }
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001078}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001079
1080class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1081 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001082 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001083 mnemonic#"r\t$R1, $R2",
1084 [(operator cls1:$R1, cls2:$R2)]> {
1085 let OpKey = mnemonic ## cls1;
1086 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001087 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001088}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001089
1090class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1091 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001092 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001093 mnemonic#"r\t$R1, $R2",
1094 [(operator cls1:$R1, cls2:$R2)]> {
1095 let OpKey = mnemonic ## cls1;
1096 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001097 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001098}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001099
1100class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1101 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001102 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
1103 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001104 [(operator cls:$R1, imm:$I2)]> {
1105 let isCompare = 1;
1106}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001107
1108class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1109 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001110 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
1111 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001112 [(operator cls:$R1, imm:$I2)]> {
1113 let isCompare = 1;
1114}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001115
1116class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1117 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001118 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
1119 mnemonic#"\t$R1, $I2",
1120 [(operator cls:$R1, (load pcrel32:$I2))]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001121 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001122 let mayLoad = 1;
1123 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
1124 // However, BDXs have two extra operands and are therefore 6 units more
1125 // complex.
1126 let AddedComplexity = 7;
1127}
1128
1129class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001130 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001131 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001132 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1133 mnemonic#"\t$R1, $XBD2",
1134 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001135 let OpKey = mnemonic ## cls;
1136 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001137 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001138 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001139 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001140}
1141
1142class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001143 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001144 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
1145 mnemonic#"\t$R1, $XBD2",
1146 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001147 let OpKey = mnemonic ## cls;
1148 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001149 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001150 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001151 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001152}
1153
1154class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001155 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001156 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001157 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1158 mnemonic#"\t$R1, $XBD2",
1159 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001160 let OpKey = mnemonic ## cls;
1161 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001162 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001163 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001164 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001165}
1166
1167multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1168 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001169 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001170 let DispKey = mnemonic ## #cls in {
1171 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001172 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001173 load, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001174 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001175 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001176 load, bytes, bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001177 }
1178}
1179
1180class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1181 SDPatternOperator load, Immediate imm,
1182 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001183 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1184 mnemonic#"\t$BD1, $I2",
1185 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001186 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001187 let mayLoad = 1;
1188}
1189
1190class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1191 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001192 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
1193 mnemonic#"\t$BD1, $I2",
1194 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001195 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001196 let mayLoad = 1;
1197}
1198
1199class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1200 SDPatternOperator load, Immediate imm,
1201 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001202 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1203 mnemonic#"\t$BD1, $I2",
1204 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001205 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001206 let mayLoad = 1;
1207}
1208
1209multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
1210 SDPatternOperator operator, SDPatternOperator load,
1211 Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001212 let DispKey = mnemonic in {
1213 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001214 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001215 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001216 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
1217 bdaddr20pair>;
1218 }
1219}
1220
1221class TernaryRRD<string mnemonic, bits<16> opcode,
1222 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001223 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001224 mnemonic#"r\t$R1, $R3, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +00001225 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001226 let OpKey = mnemonic ## cls;
1227 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001228 let Constraints = "$R1 = $R1src";
1229 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001230}
1231
1232class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001233 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001234 : InstRXF<opcode, (outs cls:$R1),
1235 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
1236 mnemonic#"\t$R1, $R3, $XBD2",
1237 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
1238 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001239 let OpKey = mnemonic ## cls;
1240 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001241 let Constraints = "$R1 = $R1src";
1242 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001243 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001244 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001245}
1246
1247class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1248 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001249 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1250 mnemonic#"\t$R1, $R3, $BD2",
1251 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1252 let Constraints = "$R1 = $R1src";
1253 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001254 let mayLoad = 1;
1255 let mayStore = 1;
1256}
1257
1258class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1259 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001260 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1261 mnemonic#"\t$R1, $R3, $BD2",
1262 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1263 let Constraints = "$R1 = $R1src";
1264 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001265 let mayLoad = 1;
1266 let mayStore = 1;
1267}
1268
1269multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
1270 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001271 let DispKey = mnemonic ## #cls in {
1272 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001273 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001274 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001275 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
1276 }
1277}
1278
1279class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
1280 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001281 : InstRIEf<opcode, (outs cls1:$R1),
Richard Sandiford67ddcd62013-07-11 08:37:13 +00001282 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001283 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
1284 let Constraints = "$R1 = $R1src";
1285 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001286}
1287
Richard Sandiford9f11bc12013-08-07 11:03:34 +00001288// A floating-point load-and test operation. Create both a normal unary
1289// operation and one that acts as a comparison against zero.
1290multiclass LoadAndTestRRE<string mnemonic, bits<16> opcode,
1291 RegisterOperand cls> {
1292 def "" : UnaryRRE<mnemonic, opcode, null_frag, cls, cls>;
1293 let isCodeGenOnly = 1 in
1294 def Compare : CompareRRE<mnemonic, opcode, null_frag, cls, cls>;
1295}
1296
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001297//===----------------------------------------------------------------------===//
1298// Pseudo instructions
1299//===----------------------------------------------------------------------===//
1300//
1301// Convenience instructions that get lowered to real instructions
1302// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
1303// or SystemZInstrInfo::expandPostRAPseudo().
1304//
1305//===----------------------------------------------------------------------===//
1306
1307class Pseudo<dag outs, dag ins, list<dag> pattern>
1308 : InstSystemZ<0, outs, ins, "", pattern> {
1309 let isPseudo = 1;
1310 let isCodeGenOnly = 1;
1311}
1312
1313// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
1314// the value of the PSW's 2-bit condition code field.
1315class SelectWrapper<RegisterOperand cls>
Richard Sandiford3d768e32013-07-31 12:30:20 +00001316 : Pseudo<(outs cls:$dst),
1317 (ins cls:$src1, cls:$src2, uimm8zx4:$valid, uimm8zx4:$cc),
1318 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2,
1319 uimm8zx4:$valid, uimm8zx4:$cc))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001320 let usesCustomInserter = 1;
1321 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +00001322 // change CC, the insertion requires new blocks, and CC cannot be live
1323 // across them.
1324 let Defs = [CC];
1325 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001326}
1327
Richard Sandifordb86a8342013-06-27 09:27:40 +00001328// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
1329multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
1330 SDPatternOperator load, AddressingMode mode> {
1331 let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {
Richard Sandiford3d768e32013-07-31 12:30:20 +00001332 def "" : Pseudo<(outs),
1333 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001334 [(store (z_select_ccmask cls:$new, (load mode:$addr),
Richard Sandiford3d768e32013-07-31 12:30:20 +00001335 uimm8zx4:$valid, uimm8zx4:$cc),
1336 mode:$addr)]>;
1337 def Inv : Pseudo<(outs),
1338 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001339 [(store (z_select_ccmask (load mode:$addr), cls:$new,
Richard Sandiford3d768e32013-07-31 12:30:20 +00001340 uimm8zx4:$valid, uimm8zx4:$cc),
1341 mode:$addr)]>;
Richard Sandifordb86a8342013-06-27 09:27:40 +00001342 }
1343}
1344
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001345// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
1346// describe the second (non-memory) operand.
1347class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
1348 dag pat, DAGOperand operand>
1349 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
1350 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001351 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001352 let Has20BitOffset = 1;
1353 let mayLoad = 1;
1354 let mayStore = 1;
1355 let usesCustomInserter = 1;
1356}
1357
1358// Specializations of AtomicLoadWBinary.
1359class AtomicLoadBinaryReg32<SDPatternOperator operator>
1360 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
1361class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
1362 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
1363class AtomicLoadBinaryReg64<SDPatternOperator operator>
1364 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
1365class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
1366 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
1367
1368// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
1369// describe the second (non-memory) operand.
1370class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
1371 DAGOperand operand>
1372 : Pseudo<(outs GR32:$dst),
1373 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
1374 ADDR32:$negbitshift, uimm32:$bitsize),
1375 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
1376 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001377 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001378 let Has20BitOffset = 1;
1379 let mayLoad = 1;
1380 let mayStore = 1;
1381 let usesCustomInserter = 1;
1382}
1383
1384// Specializations of AtomicLoadWBinary.
1385class AtomicLoadWBinaryReg<SDPatternOperator operator>
1386 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
1387class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
1388 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;