blob: 98837149030a02c86e110b673f4943985cfdea4d [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
69 // True if the instruction sets CC to 0 when the result is 0.
70 bit CCHasZero = 0;
71
72 // True if the instruction sets CC to 1 when the result is less than 0
73 // and to 2 when the result is greater than 0.
74 bit CCHasOrder = 0;
75
76 // True if the instruction is conditional and if the CC mask operand
77 // comes first (as for BRC, etc.).
78 bit CCMaskFirst = 0;
79
80 // Similar, but true if the CC mask operand comes last (as for LOC, etc.).
81 bit CCMaskLast = 0;
82
83 // True if the instruction is the "logical" rather than "arithmetic" form,
84 // in cases where a distinction exists.
85 bit IsLogical = 0;
86
87 let TSFlags{0} = SimpleBDXLoad;
88 let TSFlags{1} = SimpleBDXStore;
89 let TSFlags{2} = Has20BitOffset;
90 let TSFlags{3} = HasIndex;
91 let TSFlags{4} = Is128Bit;
92 let TSFlags{9-5} = AccessBytes;
93 let TSFlags{13-10} = CCValues;
94 let TSFlags{14} = CCHasZero;
95 let TSFlags{15} = CCHasOrder;
96 let TSFlags{16} = CCMaskFirst;
97 let TSFlags{17} = CCMaskLast;
98 let TSFlags{18} = IsLogical;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000099}
100
101//===----------------------------------------------------------------------===//
102// Mappings between instructions
103//===----------------------------------------------------------------------===//
104
105// Return the version of an instruction that has an unsigned 12-bit
106// displacement.
107def getDisp12Opcode : InstrMapping {
108 let FilterClass = "InstSystemZ";
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000109 let RowFields = ["DispKey"];
110 let ColFields = ["DispSize"];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000111 let KeyCol = ["20"];
112 let ValueCols = [["12"]];
113}
114
115// Return the version of an instruction that has a signed 20-bit displacement.
116def getDisp20Opcode : InstrMapping {
117 let FilterClass = "InstSystemZ";
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000118 let RowFields = ["DispKey"];
119 let ColFields = ["DispSize"];
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000120 let KeyCol = ["12"];
121 let ValueCols = [["20"]];
122}
123
Richard Sandifordff6c5a52013-07-19 16:12:08 +0000124// Return the memory form of a register instruction.
Richard Sandiforded1fab62013-07-03 10:10:02 +0000125def getMemOpcode : InstrMapping {
126 let FilterClass = "InstSystemZ";
127 let RowFields = ["OpKey"];
128 let ColFields = ["OpType"];
129 let KeyCol = ["reg"];
130 let ValueCols = [["mem"]];
131}
132
Richard Sandifordff6c5a52013-07-19 16:12:08 +0000133// Return the 3-operand form of a 2-operand instruction.
134def getThreeOperandOpcode : InstrMapping {
135 let FilterClass = "InstSystemZ";
136 let RowFields = ["NumOpsKey"];
137 let ColFields = ["NumOpsValue"];
138 let KeyCol = ["2"];
139 let ValueCols = [["3"]];
140}
141
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000142//===----------------------------------------------------------------------===//
143// Instruction formats
144//===----------------------------------------------------------------------===//
145//
146// Formats are specified using operand field declarations of the form:
147//
Richard Sandifordd454ec02013-05-14 09:28:21 +0000148// bits<4> Rn : register input or output for operand n
149// bits<m> In : immediate value of width m for operand n
150// bits<4> BDn : address operand n, which has a base and a displacement
151// bits<m> XBDn : address operand n, which has an index, a base and a
152// displacement
153// bits<4> Xn : index register for address operand n
154// bits<4> Mn : mode value for operand n
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000155//
Richard Sandifordd454ec02013-05-14 09:28:21 +0000156// The operand numbers ("n" in the list above) follow the architecture manual.
157// Assembly operands sometimes have a different order; in particular, R3 often
158// is often written between operands 1 and 2.
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000159//
160//===----------------------------------------------------------------------===//
161
162class InstRI<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
163 : InstSystemZ<4, outs, ins, asmstr, pattern> {
164 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000165 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000166
167 bits<4> R1;
168 bits<16> I2;
169
170 let Inst{31-24} = op{11-4};
171 let Inst{23-20} = R1;
172 let Inst{19-16} = op{3-0};
173 let Inst{15-0} = I2;
174}
175
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000176class InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
177 : InstSystemZ<6, outs, ins, asmstr, pattern> {
178 field bits<48> Inst;
179 field bits<48> SoftFail = 0;
180
181 bits<4> R1;
182 bits<4> R2;
183 bits<4> M3;
184 bits<16> RI4;
185
186 let Inst{47-40} = op{15-8};
187 let Inst{39-36} = R1;
188 let Inst{35-32} = R2;
189 let Inst{31-16} = RI4;
190 let Inst{15-12} = M3;
191 let Inst{11-8} = 0;
192 let Inst{7-0} = op{7-0};
193}
194
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000195class InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
196 : InstSystemZ<6, outs, ins, asmstr, pattern> {
197 field bits<48> Inst;
198 field bits<48> SoftFail = 0;
199
200 bits<4> R1;
201 bits<8> I2;
202 bits<4> M3;
203 bits<16> RI4;
204
205 let Inst{47-40} = op{15-8};
206 let Inst{39-36} = R1;
207 let Inst{35-32} = M3;
208 let Inst{31-16} = RI4;
209 let Inst{15-8} = I2;
210 let Inst{7-0} = op{7-0};
211}
212
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000213class InstRIEd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
214 : InstSystemZ<6, outs, ins, asmstr, pattern> {
215 field bits<48> Inst;
216 field bits<48> SoftFail = 0;
217
218 bits<4> R1;
219 bits<4> R3;
220 bits<16> I2;
221
222 let Inst{47-40} = op{15-8};
223 let Inst{39-36} = R1;
224 let Inst{35-32} = R3;
225 let Inst{31-16} = I2;
226 let Inst{15-8} = 0;
227 let Inst{7-0} = op{7-0};
228}
229
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000230class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
231 : InstSystemZ<6, outs, ins, asmstr, pattern> {
232 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000233 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000234
235 bits<4> R1;
236 bits<4> R2;
237 bits<8> I3;
238 bits<8> I4;
239 bits<8> I5;
240
241 let Inst{47-40} = op{15-8};
242 let Inst{39-36} = R1;
243 let Inst{35-32} = R2;
244 let Inst{31-24} = I3;
245 let Inst{23-16} = I4;
246 let Inst{15-8} = I5;
247 let Inst{7-0} = op{7-0};
248}
249
250class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
251 : InstSystemZ<6, outs, ins, asmstr, pattern> {
252 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000253 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000254
255 bits<4> R1;
256 bits<32> I2;
257
258 let Inst{47-40} = op{11-4};
259 let Inst{39-36} = R1;
260 let Inst{35-32} = op{3-0};
261 let Inst{31-0} = I2;
262}
263
264class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
265 : InstSystemZ<2, outs, ins, asmstr, pattern> {
266 field bits<16> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000267 field bits<16> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000268
269 bits<4> R1;
270 bits<4> R2;
271
272 let Inst{15-8} = op;
273 let Inst{7-4} = R1;
274 let Inst{3-0} = R2;
275}
276
277class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
278 : InstSystemZ<4, outs, ins, asmstr, pattern> {
279 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000280 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000281
282 bits<4> R1;
283 bits<4> R3;
284 bits<4> R2;
285
286 let Inst{31-16} = op;
287 let Inst{15-12} = R1;
288 let Inst{11-8} = 0;
289 let Inst{7-4} = R3;
290 let Inst{3-0} = R2;
291}
292
293class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
294 : InstSystemZ<4, outs, ins, asmstr, pattern> {
295 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000296 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000297
298 bits<4> R1;
299 bits<4> R2;
300
301 let Inst{31-16} = op;
302 let Inst{15-8} = 0;
303 let Inst{7-4} = R1;
304 let Inst{3-0} = R2;
305}
306
307class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
308 : InstSystemZ<4, outs, ins, asmstr, pattern> {
309 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000310 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000311
312 bits<4> R1;
313 bits<4> R2;
314 bits<4> R3;
315
316 let Inst{31-16} = op;
317 let Inst{15-12} = R3;
318 let Inst{11-8} = 0;
319 let Inst{7-4} = R1;
320 let Inst{3-0} = R2;
321}
322
323class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
324 : InstSystemZ<4, outs, ins, asmstr, pattern> {
325 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000326 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000327
328 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000329 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000330
331 let Inst{31-24} = op;
332 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000333 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000334
335 let HasIndex = 1;
336}
337
338class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
339 : InstSystemZ<6, outs, ins, asmstr, pattern> {
340 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000341 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000342
343 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000344 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000345
346 let Inst{47-40} = op{15-8};
347 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000348 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000349 let Inst{15-8} = 0;
350 let Inst{7-0} = op{7-0};
351
352 let HasIndex = 1;
353}
354
355class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
356 : InstSystemZ<6, outs, ins, asmstr, pattern> {
357 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000358 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000359
360 bits<4> R1;
361 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000362 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000363
364 let Inst{47-40} = op{15-8};
365 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000366 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000367 let Inst{15-12} = R1;
368 let Inst{11-8} = 0;
369 let Inst{7-0} = op{7-0};
370
371 let HasIndex = 1;
372}
373
374class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
375 : InstSystemZ<6, outs, ins, asmstr, pattern> {
376 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000377 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000378
379 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000380 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000381
382 let Inst{47-40} = op{15-8};
383 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000384 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000385 let Inst{7-0} = op{7-0};
386
387 let Has20BitOffset = 1;
388 let HasIndex = 1;
389}
390
391class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
392 : InstSystemZ<4, outs, ins, asmstr, pattern> {
393 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000394 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000395
396 bits<4> R1;
397 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000398 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000399
400 let Inst{31-24} = op;
401 let Inst{23-20} = R1;
402 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000403 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000404}
405
406class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
407 : InstSystemZ<6, outs, ins, asmstr, pattern> {
408 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000409 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000410
411 bits<4> R1;
412 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000413 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000414
415 let Inst{47-40} = op{15-8};
416 let Inst{39-36} = R1;
417 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000418 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000419 let Inst{7-0} = op{7-0};
420
421 let Has20BitOffset = 1;
422}
423
424class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
425 : InstSystemZ<4, outs, ins, asmstr, pattern> {
426 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000427 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000428
Richard Sandifordd454ec02013-05-14 09:28:21 +0000429 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000430 bits<8> I2;
431
432 let Inst{31-24} = op;
433 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000434 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000435}
436
437class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
438 : InstSystemZ<6, outs, ins, asmstr, pattern> {
439 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000440 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000441
Richard Sandifordd454ec02013-05-14 09:28:21 +0000442 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000443 bits<16> I2;
444
445 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000446 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000447 let Inst{15-0} = I2;
448}
449
450class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
451 : InstSystemZ<6, outs, ins, asmstr, pattern> {
452 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000453 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000454
Richard Sandifordd454ec02013-05-14 09:28:21 +0000455 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000456 bits<8> I2;
457
458 let Inst{47-40} = op{15-8};
459 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000460 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000461 let Inst{7-0} = op{7-0};
462
463 let Has20BitOffset = 1;
464}
465
Richard Sandiford1d959002013-07-02 14:56:45 +0000466class InstSS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
467 : InstSystemZ<6, outs, ins, asmstr, pattern> {
468 field bits<48> Inst;
469 field bits<48> SoftFail = 0;
470
471 bits<24> BDL1;
472 bits<16> BD2;
473
474 let Inst{47-40} = op;
475 let Inst{39-16} = BDL1;
476 let Inst{15-0} = BD2;
477}
478
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000479//===----------------------------------------------------------------------===//
480// Instruction definitions with semantics
481//===----------------------------------------------------------------------===//
482//
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000483// These classes have the form [Cond]<Category><Format>, where <Format> is one
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000484// of the formats defined above and where <Category> describes the inputs
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000485// and outputs. "Cond" is used if the instruction is conditional,
486// in which case the 4-bit condition-code mask is added as a final operand.
487// <Category> can be one of:
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000488//
489// Inherent:
490// One register output operand and no input operands.
491//
492// Store:
493// One register or immediate input operand and one address input operand.
494// The instruction stores the first operand to the address.
495//
496// This category is used for both pure and truncating stores.
497//
498// LoadMultiple:
499// One address input operand and two explicit output operands.
500// The instruction loads a range of registers from the address,
501// with the explicit operands giving the first and last register
502// to load. Other loaded registers are added as implicit definitions.
503//
504// StoreMultiple:
505// Two explicit input register operands and an address operand.
506// The instruction stores a range of registers to the address,
507// with the explicit operands giving the first and last register
508// to store. Other stored registers are added as implicit uses.
509//
510// Unary:
511// One register output operand and one input operand. The input
512// operand may be a register, immediate or memory.
513//
514// Binary:
515// One register output operand and two input operands. The first
516// input operand is always a register and he second may be a register,
517// immediate or memory.
518//
519// Shift:
520// One register output operand and two input operands. The first
521// input operand is a register and the second has the same form as
522// an address (although it isn't actually used to address memory).
523//
524// Compare:
525// Two input operands. The first operand is always a register,
526// the second may be a register, immediate or memory.
527//
528// Ternary:
529// One register output operand and three register input operands.
530//
531// CmpSwap:
532// One output operand and three input operands. The first two
533// operands are registers and the third is an address. The instruction
534// both reads from and writes to the address.
535//
536// RotateSelect:
537// One output operand and five input operands. The first two operands
538// are registers and the other three are immediates.
539//
540// The format determines which input operands are tied to output operands,
541// and also determines the shape of any address operand.
542//
543// Multiclasses of the form <Category><Format>Pair define two instructions,
544// one with <Category><Format> and one with <Category><Format>Y. The name
545// of the first instruction has no suffix, the name of the second has
546// an extra "y".
547//
548//===----------------------------------------------------------------------===//
549
550class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
551 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000552 : InstRRE<opcode, (outs cls:$R1), (ins),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000553 mnemonic#"r\t$R1",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000554 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000555 let R2 = 0;
556}
557
558class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000559 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
560 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000561 let mayLoad = 1;
562}
563
564class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
565 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000566 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
567 mnemonic#"\t$R1, $I2",
568 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000569 let mayStore = 1;
570 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
571 // However, BDXs have two extra operands and are therefore 6 units more
572 // complex.
573 let AddedComplexity = 7;
574}
575
576class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000577 RegisterOperand cls, bits<5> bytes,
578 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000579 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
580 mnemonic#"\t$R1, $XBD2",
581 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000582 let OpKey = mnemonic ## cls;
583 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000584 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000585 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000586}
587
588class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000589 RegisterOperand cls, bits<5> bytes,
590 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000591 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
592 mnemonic#"\t$R1, $XBD2",
593 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000594 let OpKey = mnemonic ## cls;
595 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000596 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000597 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000598}
599
600multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000601 SDPatternOperator operator, RegisterOperand cls,
602 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000603 let DispKey = mnemonic ## #cls in {
604 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000605 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000606 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000607 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
608 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000609 }
610}
611
612class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000613 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
614 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000615 let mayStore = 1;
616}
617
618class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
619 Immediate imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000620 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
621 mnemonic#"\t$BD1, $I2",
622 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000623 let mayStore = 1;
624}
625
626class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
627 Immediate imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000628 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
629 mnemonic#"\t$BD1, $I2",
630 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000631 let mayStore = 1;
632}
633
634class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
635 Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000636 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
637 mnemonic#"\t$BD1, $I2",
638 [(operator imm:$I2, bdaddr12only:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000639 let mayStore = 1;
640}
641
642multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
643 SDPatternOperator operator, Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000644 let DispKey = mnemonic in {
645 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000646 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000647 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000648 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
649 }
650}
651
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000652class CondStoreRSY<string mnemonic, bits<16> opcode,
653 RegisterOperand cls, bits<5> bytes,
654 AddressingMode mode = bdaddr20only>
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000655 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$valid, cond4:$R3),
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000656 mnemonic#"$R3\t$R1, $BD2", []>,
657 Requires<[FeatureLoadStoreOnCond]> {
658 let mayStore = 1;
659 let AccessBytes = bytes;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000660 let CCMaskLast = 1;
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000661}
662
663// Like CondStoreRSY, but used for the raw assembly form. The condition-code
664// mask is the third operand rather than being part of the mnemonic.
665class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
666 RegisterOperand cls, bits<5> bytes,
667 AddressingMode mode = bdaddr20only>
668 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, uimm8zx4:$R3),
669 mnemonic#"\t$R1, $BD2, $R3", []>,
670 Requires<[FeatureLoadStoreOnCond]> {
671 let mayStore = 1;
672 let AccessBytes = bytes;
673}
674
675// Like CondStoreRSY, but with a fixed CC mask.
676class FixedCondStoreRSY<string mnemonic, bits<16> opcode,
677 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
678 AddressingMode mode = bdaddr20only>
679 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2),
680 mnemonic#"\t$R1, $BD2", []>,
681 Requires<[FeatureLoadStoreOnCond]> {
682 let mayStore = 1;
683 let AccessBytes = bytes;
684 let R3 = ccmask;
685}
686
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000687class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
688 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000689 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000690 mnemonic#"r\t$R1, $R2",
691 [(set cls1:$R1, (operator cls2:$R2))]> {
692 let OpKey = mnemonic ## cls1;
693 let OpType = "reg";
694}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000695
696class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
697 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000698 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000699 mnemonic#"r\t$R1, $R2",
700 [(set cls1:$R1, (operator cls2:$R2))]> {
701 let OpKey = mnemonic ## cls1;
702 let OpType = "reg";
703}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000704
705class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
706 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000707 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000708 mnemonic#"r\t$R1, $R3, $R2", []> {
709 let OpKey = mnemonic ## cls1;
710 let OpType = "reg";
711}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000712
Richard Sandifordf2404162013-07-25 09:11:15 +0000713// These instructions are generated by if conversion. The old value of R1
714// is added as an implicit use.
715class CondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
716 RegisterOperand cls2>
Richard Sandiford3d768e32013-07-31 12:30:20 +0000717 : InstRRF<opcode, (outs cls1:$R1), (ins cls2:$R2, cond4:$valid, cond4:$R3),
Richard Sandifordf2404162013-07-25 09:11:15 +0000718 mnemonic#"r$R3\t$R1, $R2", []>,
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000719 Requires<[FeatureLoadStoreOnCond]> {
720 let CCMaskLast = 1;
721}
Richard Sandifordf2404162013-07-25 09:11:15 +0000722
723// Like CondUnaryRRF, but used for the raw assembly form. The condition-code
724// mask is the third operand rather than being part of the mnemonic.
725class AsmCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
726 RegisterOperand cls2>
727 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2, uimm8zx4:$R3),
728 mnemonic#"r\t$R1, $R2, $R3", []>,
729 Requires<[FeatureLoadStoreOnCond]> {
730 let Constraints = "$R1 = $R1src";
731 let DisableEncoding = "$R1src";
732}
733
734// Like CondUnaryRRF, but with a fixed CC mask.
735class FixedCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
736 RegisterOperand cls2, bits<4> ccmask>
737 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
738 mnemonic#"\t$R1, $R2", []>,
739 Requires<[FeatureLoadStoreOnCond]> {
740 let Constraints = "$R1 = $R1src";
741 let DisableEncoding = "$R1src";
742 let R3 = ccmask;
743}
744
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000745class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
746 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000747 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
748 mnemonic#"\t$R1, $I2",
749 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000750
751class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
752 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000753 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
754 mnemonic#"\t$R1, $I2",
755 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000756
757class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
758 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000759 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
760 mnemonic#"\t$R1, $I2",
761 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000762 let mayLoad = 1;
763 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
764 // However, BDXs have two extra operands and are therefore 6 units more
765 // complex.
766 let AddedComplexity = 7;
767}
768
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000769class CondUnaryRSY<string mnemonic, bits<16> opcode,
Richard Sandifordee834382013-07-31 12:38:08 +0000770 SDPatternOperator operator, RegisterOperand cls,
771 bits<5> bytes, AddressingMode mode = bdaddr20only>
772 : InstRSY<opcode, (outs cls:$R1),
773 (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
774 mnemonic#"$R3\t$R1, $BD2",
775 [(set cls:$R1,
776 (z_select_ccmask (load bdaddr20only:$BD2), cls:$R1src,
777 cond4:$valid, cond4:$R3))]>,
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000778 Requires<[FeatureLoadStoreOnCond]> {
779 let Constraints = "$R1 = $R1src";
780 let DisableEncoding = "$R1src";
781 let mayLoad = 1;
782 let AccessBytes = bytes;
Richard Sandifordfd7f4ae2013-08-01 10:39:40 +0000783 let CCMaskLast = 1;
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000784}
785
786// Like CondUnaryRSY, but used for the raw assembly form. The condition-code
787// mask is the third operand rather than being part of the mnemonic.
788class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
789 RegisterOperand cls, bits<5> bytes,
790 AddressingMode mode = bdaddr20only>
791 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, uimm8zx4:$R3),
792 mnemonic#"\t$R1, $BD2, $R3", []>,
793 Requires<[FeatureLoadStoreOnCond]> {
794 let mayLoad = 1;
795 let AccessBytes = bytes;
796 let Constraints = "$R1 = $R1src";
797 let DisableEncoding = "$R1src";
798}
799
800// Like CondUnaryRSY, but with a fixed CC mask.
801class FixedCondUnaryRSY<string mnemonic, bits<16> opcode,
802 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
803 AddressingMode mode = bdaddr20only>
804 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
805 mnemonic#"\t$R1, $BD2", []>,
806 Requires<[FeatureLoadStoreOnCond]> {
807 let Constraints = "$R1 = $R1src";
808 let DisableEncoding = "$R1src";
809 let R3 = ccmask;
810 let mayLoad = 1;
811 let AccessBytes = bytes;
812}
813
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000814class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000815 RegisterOperand cls, bits<5> bytes,
816 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000817 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
818 mnemonic#"\t$R1, $XBD2",
819 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000820 let OpKey = mnemonic ## cls;
821 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000822 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000823 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000824}
825
826class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000827 RegisterOperand cls, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000828 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
829 mnemonic#"\t$R1, $XBD2",
830 [(set cls:$R1, (operator bdxaddr12only:$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 UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000838 RegisterOperand cls, bits<5> bytes,
839 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000840 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
841 mnemonic#"\t$R1, $XBD2",
842 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000843 let OpKey = mnemonic ## cls;
844 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000845 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000846 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000847}
848
849multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000850 SDPatternOperator operator, RegisterOperand cls,
851 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000852 let DispKey = mnemonic ## #cls in {
853 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000854 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000855 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000856 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
857 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000858 }
859}
860
861class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
862 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000863 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000864 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000865 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000866 let OpKey = mnemonic ## cls1;
867 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000868 let Constraints = "$R1 = $R1src";
869 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000870}
871
872class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
873 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000874 : InstRRE<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
Richard Sandifordd454ec02013-05-14 09:28:21 +0000883class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
884 RegisterOperand cls1, RegisterOperand cls2>
885 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000886 mnemonic#"r\t$R1, $R3, $R2",
887 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]> {
888 let OpKey = mnemonic ## cls1;
889 let OpType = "reg";
890}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000891
Richard Sandiford0175b4a2013-07-19 16:21:55 +0000892class BinaryRRFK<string mnemonic, bits<16> opcode, SDPatternOperator operator,
893 RegisterOperand cls1, RegisterOperand cls2>
894 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R2, cls2:$R3),
895 mnemonic#"rk\t$R1, $R2, $R3",
896 [(set cls1:$R1, (operator cls1:$R2, cls2:$R3))]>;
897
898multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
899 SDPatternOperator operator, RegisterOperand cls1,
900 RegisterOperand cls2> {
901 let NumOpsKey = mnemonic in {
902 let NumOpsValue = "3" in
903 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
904 Requires<[FeatureDistinctOps]>;
905 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
906 def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
907 }
908}
909
Richard Sandifordc57e5862013-07-19 16:24:22 +0000910multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
911 SDPatternOperator operator, RegisterOperand cls1,
912 RegisterOperand cls2> {
913 let NumOpsKey = mnemonic in {
914 let NumOpsValue = "3" in
915 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
916 Requires<[FeatureDistinctOps]>;
917 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
918 def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
919 }
920}
921
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000922class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
923 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000924 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
925 mnemonic#"\t$R1, $I2",
926 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
927 let Constraints = "$R1 = $R1src";
928 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000929}
930
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000931class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
932 RegisterOperand cls, Immediate imm>
933 : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
934 mnemonic#"\t$R1, $R3, $I2",
935 [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
936
937multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
938 SDPatternOperator operator, RegisterOperand cls,
939 Immediate imm> {
940 let NumOpsKey = mnemonic in {
941 let NumOpsValue = "3" in
942 def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
943 Requires<[FeatureDistinctOps]>;
944 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
945 def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
946 }
947}
948
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000949class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
950 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000951 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
952 mnemonic#"\t$R1, $I2",
953 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
954 let Constraints = "$R1 = $R1src";
955 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000956}
957
958class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000959 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000960 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000961 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
962 mnemonic#"\t$R1, $XBD2",
963 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000964 let OpKey = mnemonic ## cls;
965 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000966 let Constraints = "$R1 = $R1src";
967 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000968 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000969 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000970}
971
972class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000973 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000974 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
975 mnemonic#"\t$R1, $XBD2",
976 [(set cls:$R1, (operator cls:$R1src,
977 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000978 let OpKey = mnemonic ## cls;
979 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000980 let Constraints = "$R1 = $R1src";
981 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000982 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000983 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000984}
985
986class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000987 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000988 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000989 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
990 mnemonic#"\t$R1, $XBD2",
991 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000992 let OpKey = mnemonic ## cls;
993 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000994 let Constraints = "$R1 = $R1src";
995 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000996 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000997 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000998}
999
1000multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1001 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001002 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001003 let DispKey = mnemonic ## #cls in {
1004 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +00001005 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
1006 bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001007 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +00001008 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001009 bdxaddr20pair>;
1010 }
1011}
1012
1013class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1014 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001015 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1016 mnemonic#"\t$BD1, $I2",
1017 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001018 let mayLoad = 1;
1019 let mayStore = 1;
1020}
1021
1022class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1023 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001024 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1025 mnemonic#"\t$BD1, $I2",
1026 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001027 let mayLoad = 1;
1028 let mayStore = 1;
1029}
1030
1031multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
1032 bits<16> siyOpcode, SDPatternOperator operator,
1033 Operand imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001034 let DispKey = mnemonic ## #cls in {
1035 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001036 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001037 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001038 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
1039 }
1040}
1041
1042class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001043 RegisterOperand cls>
1044 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001045 mnemonic#"\t$R1, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001046 [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001047 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +00001048 let Constraints = "$R1 = $R1src";
1049 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001050}
1051
1052class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001053 RegisterOperand cls>
1054 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001055 mnemonic#"\t$R1, $R3, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001056 [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
1057
1058multiclass ShiftRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
1059 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandifordff6c5a52013-07-19 16:12:08 +00001060 let NumOpsKey = mnemonic in {
1061 let NumOpsValue = "3" in
1062 def K : ShiftRSY<mnemonic##"k", opcode2, null_frag, cls>,
1063 Requires<[FeatureDistinctOps]>;
1064 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
1065 def "" : ShiftRS<mnemonic, opcode1, operator, cls>;
1066 }
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001067}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001068
1069class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1070 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001071 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001072 mnemonic#"r\t$R1, $R2",
1073 [(operator cls1:$R1, cls2:$R2)]> {
1074 let OpKey = mnemonic ## cls1;
1075 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001076 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001077}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001078
1079class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1080 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001081 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001082 mnemonic#"r\t$R1, $R2",
1083 [(operator cls1:$R1, cls2:$R2)]> {
1084 let OpKey = mnemonic ## cls1;
1085 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001086 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001087}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001088
1089class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1090 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001091 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
1092 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001093 [(operator cls:$R1, imm:$I2)]> {
1094 let isCompare = 1;
1095}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001096
1097class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1098 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001099 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
1100 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001101 [(operator cls:$R1, imm:$I2)]> {
1102 let isCompare = 1;
1103}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001104
1105class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1106 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001107 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
1108 mnemonic#"\t$R1, $I2",
1109 [(operator cls:$R1, (load pcrel32:$I2))]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001110 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001111 let mayLoad = 1;
1112 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
1113 // However, BDXs have two extra operands and are therefore 6 units more
1114 // complex.
1115 let AddedComplexity = 7;
1116}
1117
1118class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001119 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001120 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001121 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1122 mnemonic#"\t$R1, $XBD2",
1123 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001124 let OpKey = mnemonic ## cls;
1125 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001126 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001127 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001128 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001129}
1130
1131class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001132 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001133 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
1134 mnemonic#"\t$R1, $XBD2",
1135 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001136 let OpKey = mnemonic ## cls;
1137 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001138 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001139 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001140 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001141}
1142
1143class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001144 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001145 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001146 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1147 mnemonic#"\t$R1, $XBD2",
1148 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001149 let OpKey = mnemonic ## cls;
1150 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001151 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001152 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001153 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001154}
1155
1156multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1157 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001158 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001159 let DispKey = mnemonic ## #cls in {
1160 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001161 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001162 load, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001163 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001164 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001165 load, bytes, bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001166 }
1167}
1168
1169class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1170 SDPatternOperator load, Immediate imm,
1171 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001172 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1173 mnemonic#"\t$BD1, $I2",
1174 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001175 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001176 let mayLoad = 1;
1177}
1178
1179class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1180 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001181 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
1182 mnemonic#"\t$BD1, $I2",
1183 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001184 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001185 let mayLoad = 1;
1186}
1187
1188class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1189 SDPatternOperator load, Immediate imm,
1190 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001191 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1192 mnemonic#"\t$BD1, $I2",
1193 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001194 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001195 let mayLoad = 1;
1196}
1197
1198multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
1199 SDPatternOperator operator, SDPatternOperator load,
1200 Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001201 let DispKey = mnemonic in {
1202 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001203 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001204 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001205 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
1206 bdaddr20pair>;
1207 }
1208}
1209
1210class TernaryRRD<string mnemonic, bits<16> opcode,
1211 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001212 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001213 mnemonic#"r\t$R1, $R3, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +00001214 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001215 let OpKey = mnemonic ## cls;
1216 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001217 let Constraints = "$R1 = $R1src";
1218 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001219}
1220
1221class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001222 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001223 : InstRXF<opcode, (outs cls:$R1),
1224 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
1225 mnemonic#"\t$R1, $R3, $XBD2",
1226 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
1227 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001228 let OpKey = mnemonic ## cls;
1229 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001230 let Constraints = "$R1 = $R1src";
1231 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001232 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001233 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001234}
1235
1236class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1237 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001238 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1239 mnemonic#"\t$R1, $R3, $BD2",
1240 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1241 let Constraints = "$R1 = $R1src";
1242 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001243 let mayLoad = 1;
1244 let mayStore = 1;
1245}
1246
1247class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1248 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001249 : InstRSY<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
1258multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
1259 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001260 let DispKey = mnemonic ## #cls in {
1261 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001262 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001263 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001264 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
1265 }
1266}
1267
1268class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
1269 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001270 : InstRIEf<opcode, (outs cls1:$R1),
Richard Sandiford67ddcd62013-07-11 08:37:13 +00001271 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001272 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
1273 let Constraints = "$R1 = $R1src";
1274 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001275}
1276
1277//===----------------------------------------------------------------------===//
1278// Pseudo instructions
1279//===----------------------------------------------------------------------===//
1280//
1281// Convenience instructions that get lowered to real instructions
1282// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
1283// or SystemZInstrInfo::expandPostRAPseudo().
1284//
1285//===----------------------------------------------------------------------===//
1286
1287class Pseudo<dag outs, dag ins, list<dag> pattern>
1288 : InstSystemZ<0, outs, ins, "", pattern> {
1289 let isPseudo = 1;
1290 let isCodeGenOnly = 1;
1291}
1292
1293// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
1294// the value of the PSW's 2-bit condition code field.
1295class SelectWrapper<RegisterOperand cls>
Richard Sandiford3d768e32013-07-31 12:30:20 +00001296 : Pseudo<(outs cls:$dst),
1297 (ins cls:$src1, cls:$src2, uimm8zx4:$valid, uimm8zx4:$cc),
1298 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2,
1299 uimm8zx4:$valid, uimm8zx4:$cc))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001300 let usesCustomInserter = 1;
1301 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +00001302 // change CC, the insertion requires new blocks, and CC cannot be live
1303 // across them.
1304 let Defs = [CC];
1305 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001306}
1307
Richard Sandifordb86a8342013-06-27 09:27:40 +00001308// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
1309multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
1310 SDPatternOperator load, AddressingMode mode> {
1311 let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {
Richard Sandiford3d768e32013-07-31 12:30:20 +00001312 def "" : Pseudo<(outs),
1313 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001314 [(store (z_select_ccmask cls:$new, (load mode:$addr),
Richard Sandiford3d768e32013-07-31 12:30:20 +00001315 uimm8zx4:$valid, uimm8zx4:$cc),
1316 mode:$addr)]>;
1317 def Inv : Pseudo<(outs),
1318 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001319 [(store (z_select_ccmask (load mode:$addr), cls:$new,
Richard Sandiford3d768e32013-07-31 12:30:20 +00001320 uimm8zx4:$valid, uimm8zx4:$cc),
1321 mode:$addr)]>;
Richard Sandifordb86a8342013-06-27 09:27:40 +00001322 }
1323}
1324
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001325// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
1326// describe the second (non-memory) operand.
1327class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
1328 dag pat, DAGOperand operand>
1329 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
1330 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001331 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001332 let Has20BitOffset = 1;
1333 let mayLoad = 1;
1334 let mayStore = 1;
1335 let usesCustomInserter = 1;
1336}
1337
1338// Specializations of AtomicLoadWBinary.
1339class AtomicLoadBinaryReg32<SDPatternOperator operator>
1340 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
1341class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
1342 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
1343class AtomicLoadBinaryReg64<SDPatternOperator operator>
1344 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
1345class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
1346 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
1347
1348// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
1349// describe the second (non-memory) operand.
1350class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
1351 DAGOperand operand>
1352 : Pseudo<(outs GR32:$dst),
1353 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
1354 ADDR32:$negbitshift, uimm32:$bitsize),
1355 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
1356 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001357 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001358 let Has20BitOffset = 1;
1359 let mayLoad = 1;
1360 let mayStore = 1;
1361 let usesCustomInserter = 1;
1362}
1363
1364// Specializations of AtomicLoadWBinary.
1365class AtomicLoadWBinaryReg<SDPatternOperator operator>
1366 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
1367class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
1368 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;