blob: 915891d09d7c19bd1e52b6f231c147eb1c65bdbe [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
Ulrich Weigand5f613df2013-05-06 16:15:19 +000064 let TSFlags{0} = SimpleBDXLoad;
65 let TSFlags{1} = SimpleBDXStore;
66 let TSFlags{2} = Has20BitOffset;
67 let TSFlags{3} = HasIndex;
68 let TSFlags{4} = Is128Bit;
Richard Sandiforded1fab62013-07-03 10:10:02 +000069 let TSFlags{9-5} = AccessBytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +000070}
71
72//===----------------------------------------------------------------------===//
73// Mappings between instructions
74//===----------------------------------------------------------------------===//
75
76// Return the version of an instruction that has an unsigned 12-bit
77// displacement.
78def getDisp12Opcode : InstrMapping {
79 let FilterClass = "InstSystemZ";
Richard Sandiforddf313ff2013-07-03 09:19:58 +000080 let RowFields = ["DispKey"];
81 let ColFields = ["DispSize"];
Ulrich Weigand5f613df2013-05-06 16:15:19 +000082 let KeyCol = ["20"];
83 let ValueCols = [["12"]];
84}
85
86// Return the version of an instruction that has a signed 20-bit displacement.
87def getDisp20Opcode : InstrMapping {
88 let FilterClass = "InstSystemZ";
Richard Sandiforddf313ff2013-07-03 09:19:58 +000089 let RowFields = ["DispKey"];
90 let ColFields = ["DispSize"];
Ulrich Weigand5f613df2013-05-06 16:15:19 +000091 let KeyCol = ["12"];
92 let ValueCols = [["20"]];
93}
94
Richard Sandifordff6c5a52013-07-19 16:12:08 +000095// Return the memory form of a register instruction.
Richard Sandiforded1fab62013-07-03 10:10:02 +000096def getMemOpcode : InstrMapping {
97 let FilterClass = "InstSystemZ";
98 let RowFields = ["OpKey"];
99 let ColFields = ["OpType"];
100 let KeyCol = ["reg"];
101 let ValueCols = [["mem"]];
102}
103
Richard Sandifordff6c5a52013-07-19 16:12:08 +0000104// Return the 3-operand form of a 2-operand instruction.
105def getThreeOperandOpcode : InstrMapping {
106 let FilterClass = "InstSystemZ";
107 let RowFields = ["NumOpsKey"];
108 let ColFields = ["NumOpsValue"];
109 let KeyCol = ["2"];
110 let ValueCols = [["3"]];
111}
112
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000113//===----------------------------------------------------------------------===//
114// Instruction formats
115//===----------------------------------------------------------------------===//
116//
117// Formats are specified using operand field declarations of the form:
118//
Richard Sandifordd454ec02013-05-14 09:28:21 +0000119// bits<4> Rn : register input or output for operand n
120// bits<m> In : immediate value of width m for operand n
121// bits<4> BDn : address operand n, which has a base and a displacement
122// bits<m> XBDn : address operand n, which has an index, a base and a
123// displacement
124// bits<4> Xn : index register for address operand n
125// bits<4> Mn : mode value for operand n
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000126//
Richard Sandifordd454ec02013-05-14 09:28:21 +0000127// The operand numbers ("n" in the list above) follow the architecture manual.
128// Assembly operands sometimes have a different order; in particular, R3 often
129// is often written between operands 1 and 2.
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000130//
131//===----------------------------------------------------------------------===//
132
133class InstRI<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
134 : InstSystemZ<4, outs, ins, asmstr, pattern> {
135 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000136 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000137
138 bits<4> R1;
139 bits<16> I2;
140
141 let Inst{31-24} = op{11-4};
142 let Inst{23-20} = R1;
143 let Inst{19-16} = op{3-0};
144 let Inst{15-0} = I2;
145}
146
Richard Sandiford0fb90ab2013-05-28 10:41:11 +0000147class InstRIEb<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
148 : InstSystemZ<6, outs, ins, asmstr, pattern> {
149 field bits<48> Inst;
150 field bits<48> SoftFail = 0;
151
152 bits<4> R1;
153 bits<4> R2;
154 bits<4> M3;
155 bits<16> RI4;
156
157 let Inst{47-40} = op{15-8};
158 let Inst{39-36} = R1;
159 let Inst{35-32} = R2;
160 let Inst{31-16} = RI4;
161 let Inst{15-12} = M3;
162 let Inst{11-8} = 0;
163 let Inst{7-0} = op{7-0};
164}
165
Richard Sandiforde1d9f002013-05-29 11:58:52 +0000166class InstRIEc<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
167 : InstSystemZ<6, outs, ins, asmstr, pattern> {
168 field bits<48> Inst;
169 field bits<48> SoftFail = 0;
170
171 bits<4> R1;
172 bits<8> I2;
173 bits<4> M3;
174 bits<16> RI4;
175
176 let Inst{47-40} = op{15-8};
177 let Inst{39-36} = R1;
178 let Inst{35-32} = M3;
179 let Inst{31-16} = RI4;
180 let Inst{15-8} = I2;
181 let Inst{7-0} = op{7-0};
182}
183
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000184class InstRIEd<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
185 : InstSystemZ<6, outs, ins, asmstr, pattern> {
186 field bits<48> Inst;
187 field bits<48> SoftFail = 0;
188
189 bits<4> R1;
190 bits<4> R3;
191 bits<16> I2;
192
193 let Inst{47-40} = op{15-8};
194 let Inst{39-36} = R1;
195 let Inst{35-32} = R3;
196 let Inst{31-16} = I2;
197 let Inst{15-8} = 0;
198 let Inst{7-0} = op{7-0};
199}
200
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000201class InstRIEf<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
202 : InstSystemZ<6, outs, ins, asmstr, pattern> {
203 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000204 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000205
206 bits<4> R1;
207 bits<4> R2;
208 bits<8> I3;
209 bits<8> I4;
210 bits<8> I5;
211
212 let Inst{47-40} = op{15-8};
213 let Inst{39-36} = R1;
214 let Inst{35-32} = R2;
215 let Inst{31-24} = I3;
216 let Inst{23-16} = I4;
217 let Inst{15-8} = I5;
218 let Inst{7-0} = op{7-0};
219}
220
221class InstRIL<bits<12> op, dag outs, dag ins, string asmstr, list<dag> pattern>
222 : InstSystemZ<6, outs, ins, asmstr, pattern> {
223 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000224 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000225
226 bits<4> R1;
227 bits<32> I2;
228
229 let Inst{47-40} = op{11-4};
230 let Inst{39-36} = R1;
231 let Inst{35-32} = op{3-0};
232 let Inst{31-0} = I2;
233}
234
235class InstRR<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
236 : InstSystemZ<2, outs, ins, asmstr, pattern> {
237 field bits<16> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000238 field bits<16> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000239
240 bits<4> R1;
241 bits<4> R2;
242
243 let Inst{15-8} = op;
244 let Inst{7-4} = R1;
245 let Inst{3-0} = R2;
246}
247
248class InstRRD<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
249 : InstSystemZ<4, outs, ins, asmstr, pattern> {
250 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000251 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000252
253 bits<4> R1;
254 bits<4> R3;
255 bits<4> R2;
256
257 let Inst{31-16} = op;
258 let Inst{15-12} = R1;
259 let Inst{11-8} = 0;
260 let Inst{7-4} = R3;
261 let Inst{3-0} = R2;
262}
263
264class InstRRE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
265 : InstSystemZ<4, outs, ins, asmstr, pattern> {
266 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000267 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000268
269 bits<4> R1;
270 bits<4> R2;
271
272 let Inst{31-16} = op;
273 let Inst{15-8} = 0;
274 let Inst{7-4} = R1;
275 let Inst{3-0} = R2;
276}
277
278class InstRRF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
279 : InstSystemZ<4, outs, ins, asmstr, pattern> {
280 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000281 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000282
283 bits<4> R1;
284 bits<4> R2;
285 bits<4> R3;
286
287 let Inst{31-16} = op;
288 let Inst{15-12} = R3;
289 let Inst{11-8} = 0;
290 let Inst{7-4} = R1;
291 let Inst{3-0} = R2;
292}
293
294class InstRX<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
295 : InstSystemZ<4, outs, ins, asmstr, pattern> {
296 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000297 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000298
299 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000300 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000301
302 let Inst{31-24} = op;
303 let Inst{23-20} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000304 let Inst{19-0} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000305
306 let HasIndex = 1;
307}
308
309class InstRXE<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
310 : InstSystemZ<6, outs, ins, asmstr, pattern> {
311 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000312 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000313
314 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000315 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000316
317 let Inst{47-40} = op{15-8};
318 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000319 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000320 let Inst{15-8} = 0;
321 let Inst{7-0} = op{7-0};
322
323 let HasIndex = 1;
324}
325
326class InstRXF<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
327 : InstSystemZ<6, outs, ins, asmstr, pattern> {
328 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000329 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000330
331 bits<4> R1;
332 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000333 bits<20> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000334
335 let Inst{47-40} = op{15-8};
336 let Inst{39-36} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000337 let Inst{35-16} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000338 let Inst{15-12} = R1;
339 let Inst{11-8} = 0;
340 let Inst{7-0} = op{7-0};
341
342 let HasIndex = 1;
343}
344
345class InstRXY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
346 : InstSystemZ<6, outs, ins, asmstr, pattern> {
347 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000348 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000349
350 bits<4> R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000351 bits<28> XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000352
353 let Inst{47-40} = op{15-8};
354 let Inst{39-36} = R1;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000355 let Inst{35-8} = XBD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000356 let Inst{7-0} = op{7-0};
357
358 let Has20BitOffset = 1;
359 let HasIndex = 1;
360}
361
362class InstRS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
363 : InstSystemZ<4, outs, ins, asmstr, pattern> {
364 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000365 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000366
367 bits<4> R1;
368 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000369 bits<16> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000370
371 let Inst{31-24} = op;
372 let Inst{23-20} = R1;
373 let Inst{19-16} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000374 let Inst{15-0} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000375}
376
377class InstRSY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
378 : InstSystemZ<6, outs, ins, asmstr, pattern> {
379 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000380 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000381
382 bits<4> R1;
383 bits<4> R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000384 bits<24> BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000385
386 let Inst{47-40} = op{15-8};
387 let Inst{39-36} = R1;
388 let Inst{35-32} = R3;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000389 let Inst{31-8} = BD2;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000390 let Inst{7-0} = op{7-0};
391
392 let Has20BitOffset = 1;
393}
394
395class InstSI<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
396 : InstSystemZ<4, outs, ins, asmstr, pattern> {
397 field bits<32> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000398 field bits<32> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000399
Richard Sandifordd454ec02013-05-14 09:28:21 +0000400 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000401 bits<8> I2;
402
403 let Inst{31-24} = op;
404 let Inst{23-16} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000405 let Inst{15-0} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000406}
407
408class InstSIL<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
409 : InstSystemZ<6, outs, ins, asmstr, pattern> {
410 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000411 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000412
Richard Sandifordd454ec02013-05-14 09:28:21 +0000413 bits<16> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000414 bits<16> I2;
415
416 let Inst{47-32} = op;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000417 let Inst{31-16} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000418 let Inst{15-0} = I2;
419}
420
421class InstSIY<bits<16> op, dag outs, dag ins, string asmstr, list<dag> pattern>
422 : InstSystemZ<6, outs, ins, asmstr, pattern> {
423 field bits<48> Inst;
Richard Sandifordeb9af292013-05-14 10:17:52 +0000424 field bits<48> SoftFail = 0;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000425
Richard Sandifordd454ec02013-05-14 09:28:21 +0000426 bits<24> BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000427 bits<8> I2;
428
429 let Inst{47-40} = op{15-8};
430 let Inst{39-32} = I2;
Richard Sandifordd454ec02013-05-14 09:28:21 +0000431 let Inst{31-8} = BD1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000432 let Inst{7-0} = op{7-0};
433
434 let Has20BitOffset = 1;
435}
436
Richard Sandiford1d959002013-07-02 14:56:45 +0000437class InstSS<bits<8> op, dag outs, dag ins, string asmstr, list<dag> pattern>
438 : InstSystemZ<6, outs, ins, asmstr, pattern> {
439 field bits<48> Inst;
440 field bits<48> SoftFail = 0;
441
442 bits<24> BDL1;
443 bits<16> BD2;
444
445 let Inst{47-40} = op;
446 let Inst{39-16} = BDL1;
447 let Inst{15-0} = BD2;
448}
449
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000450//===----------------------------------------------------------------------===//
451// Instruction definitions with semantics
452//===----------------------------------------------------------------------===//
453//
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000454// These classes have the form [Cond]<Category><Format>, where <Format> is one
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000455// of the formats defined above and where <Category> describes the inputs
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000456// and outputs. "Cond" is used if the instruction is conditional,
457// in which case the 4-bit condition-code mask is added as a final operand.
458// <Category> can be one of:
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000459//
460// Inherent:
461// One register output operand and no input operands.
462//
463// Store:
464// One register or immediate input operand and one address input operand.
465// The instruction stores the first operand to the address.
466//
467// This category is used for both pure and truncating stores.
468//
469// LoadMultiple:
470// One address input operand and two explicit output operands.
471// The instruction loads a range of registers from the address,
472// with the explicit operands giving the first and last register
473// to load. Other loaded registers are added as implicit definitions.
474//
475// StoreMultiple:
476// Two explicit input register operands and an address operand.
477// The instruction stores a range of registers to the address,
478// with the explicit operands giving the first and last register
479// to store. Other stored registers are added as implicit uses.
480//
481// Unary:
482// One register output operand and one input operand. The input
483// operand may be a register, immediate or memory.
484//
485// Binary:
486// One register output operand and two input operands. The first
487// input operand is always a register and he second may be a register,
488// immediate or memory.
489//
490// Shift:
491// One register output operand and two input operands. The first
492// input operand is a register and the second has the same form as
493// an address (although it isn't actually used to address memory).
494//
495// Compare:
496// Two input operands. The first operand is always a register,
497// the second may be a register, immediate or memory.
498//
499// Ternary:
500// One register output operand and three register input operands.
501//
502// CmpSwap:
503// One output operand and three input operands. The first two
504// operands are registers and the third is an address. The instruction
505// both reads from and writes to the address.
506//
507// RotateSelect:
508// One output operand and five input operands. The first two operands
509// are registers and the other three are immediates.
510//
511// The format determines which input operands are tied to output operands,
512// and also determines the shape of any address operand.
513//
514// Multiclasses of the form <Category><Format>Pair define two instructions,
515// one with <Category><Format> and one with <Category><Format>Y. The name
516// of the first instruction has no suffix, the name of the second has
517// an extra "y".
518//
519//===----------------------------------------------------------------------===//
520
521class InherentRRE<string mnemonic, bits<16> opcode, RegisterOperand cls,
522 dag src>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000523 : InstRRE<opcode, (outs cls:$R1), (ins),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000524 mnemonic#"r\t$R1",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000525 [(set cls:$R1, src)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000526 let R2 = 0;
527}
528
529class LoadMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000530 : InstRSY<opcode, (outs cls:$R1, cls:$R3), (ins bdaddr20only:$BD2),
531 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000532 let mayLoad = 1;
533}
534
535class StoreRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
536 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000537 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
538 mnemonic#"\t$R1, $I2",
539 [(operator cls:$R1, pcrel32:$I2)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000540 let mayStore = 1;
541 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
542 // However, BDXs have two extra operands and are therefore 6 units more
543 // complex.
544 let AddedComplexity = 7;
545}
546
547class StoreRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000548 RegisterOperand cls, bits<5> bytes,
549 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000550 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
551 mnemonic#"\t$R1, $XBD2",
552 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000553 let OpKey = mnemonic ## cls;
554 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000555 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000556 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000557}
558
559class StoreRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000560 RegisterOperand cls, bits<5> bytes,
561 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000562 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
563 mnemonic#"\t$R1, $XBD2",
564 [(operator cls:$R1, mode:$XBD2)]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000565 let OpKey = mnemonic ## cls;
566 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000567 let mayStore = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000568 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000569}
570
571multiclass StoreRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000572 SDPatternOperator operator, RegisterOperand cls,
573 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000574 let DispKey = mnemonic ## #cls in {
575 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000576 def "" : StoreRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000577 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000578 def Y : StoreRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
579 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000580 }
581}
582
583class StoreMultipleRSY<string mnemonic, bits<16> opcode, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000584 : InstRSY<opcode, (outs), (ins cls:$R1, cls:$R3, bdaddr20only:$BD2),
585 mnemonic#"\t$R1, $R3, $BD2", []> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000586 let mayStore = 1;
587}
588
589class StoreSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
590 Immediate imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000591 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
592 mnemonic#"\t$BD1, $I2",
593 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000594 let mayStore = 1;
595}
596
597class StoreSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
598 Immediate imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000599 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
600 mnemonic#"\t$BD1, $I2",
601 [(operator imm:$I2, mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000602 let mayStore = 1;
603}
604
605class StoreSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
606 Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000607 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
608 mnemonic#"\t$BD1, $I2",
609 [(operator imm:$I2, bdaddr12only:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000610 let mayStore = 1;
611}
612
613multiclass StoreSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
614 SDPatternOperator operator, Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000615 let DispKey = mnemonic in {
616 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000617 def "" : StoreSI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000618 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000619 def Y : StoreSIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
620 }
621}
622
Richard Sandiforda68e6f52013-07-25 08:57:02 +0000623class CondStoreRSY<string mnemonic, bits<16> opcode,
624 RegisterOperand cls, bits<5> bytes,
625 AddressingMode mode = bdaddr20only>
626 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, cond4:$R3),
627 mnemonic#"$R3\t$R1, $BD2", []>,
628 Requires<[FeatureLoadStoreOnCond]> {
629 let mayStore = 1;
630 let AccessBytes = bytes;
631}
632
633// Like CondStoreRSY, but used for the raw assembly form. The condition-code
634// mask is the third operand rather than being part of the mnemonic.
635class AsmCondStoreRSY<string mnemonic, bits<16> opcode,
636 RegisterOperand cls, bits<5> bytes,
637 AddressingMode mode = bdaddr20only>
638 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, uimm8zx4:$R3),
639 mnemonic#"\t$R1, $BD2, $R3", []>,
640 Requires<[FeatureLoadStoreOnCond]> {
641 let mayStore = 1;
642 let AccessBytes = bytes;
643}
644
645// Like CondStoreRSY, but with a fixed CC mask.
646class FixedCondStoreRSY<string mnemonic, bits<16> opcode,
647 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
648 AddressingMode mode = bdaddr20only>
649 : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2),
650 mnemonic#"\t$R1, $BD2", []>,
651 Requires<[FeatureLoadStoreOnCond]> {
652 let mayStore = 1;
653 let AccessBytes = bytes;
654 let R3 = ccmask;
655}
656
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000657class UnaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
658 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000659 : InstRR<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000660 mnemonic#"r\t$R1, $R2",
661 [(set cls1:$R1, (operator cls2:$R2))]> {
662 let OpKey = mnemonic ## cls1;
663 let OpType = "reg";
664}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000665
666class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
667 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000668 : InstRRE<opcode, (outs cls1:$R1), (ins cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000669 mnemonic#"r\t$R1, $R2",
670 [(set cls1:$R1, (operator cls2:$R2))]> {
671 let OpKey = mnemonic ## cls1;
672 let OpType = "reg";
673}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000674
675class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
676 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000677 : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000678 mnemonic#"r\t$R1, $R3, $R2", []> {
679 let OpKey = mnemonic ## cls1;
680 let OpType = "reg";
681}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000682
Richard Sandifordf2404162013-07-25 09:11:15 +0000683// These instructions are generated by if conversion. The old value of R1
684// is added as an implicit use.
685class CondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
686 RegisterOperand cls2>
Richard Sandiford3d768e32013-07-31 12:30:20 +0000687 : InstRRF<opcode, (outs cls1:$R1), (ins cls2:$R2, cond4:$valid, cond4:$R3),
Richard Sandifordf2404162013-07-25 09:11:15 +0000688 mnemonic#"r$R3\t$R1, $R2", []>,
689 Requires<[FeatureLoadStoreOnCond]>;
690
691// Like CondUnaryRRF, but used for the raw assembly form. The condition-code
692// mask is the third operand rather than being part of the mnemonic.
693class AsmCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
694 RegisterOperand cls2>
695 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2, uimm8zx4:$R3),
696 mnemonic#"r\t$R1, $R2, $R3", []>,
697 Requires<[FeatureLoadStoreOnCond]> {
698 let Constraints = "$R1 = $R1src";
699 let DisableEncoding = "$R1src";
700}
701
702// Like CondUnaryRRF, but with a fixed CC mask.
703class FixedCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,
704 RegisterOperand cls2, bits<4> ccmask>
705 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
706 mnemonic#"\t$R1, $R2", []>,
707 Requires<[FeatureLoadStoreOnCond]> {
708 let Constraints = "$R1 = $R1src";
709 let DisableEncoding = "$R1src";
710 let R3 = ccmask;
711}
712
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000713class UnaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
714 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000715 : InstRI<opcode, (outs cls:$R1), (ins imm:$I2),
716 mnemonic#"\t$R1, $I2",
717 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000718
719class UnaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
720 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000721 : InstRIL<opcode, (outs cls:$R1), (ins imm:$I2),
722 mnemonic#"\t$R1, $I2",
723 [(set cls:$R1, (operator imm:$I2))]>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000724
725class UnaryRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
726 RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000727 : InstRIL<opcode, (outs cls:$R1), (ins pcrel32:$I2),
728 mnemonic#"\t$R1, $I2",
729 [(set cls:$R1, (operator pcrel32:$I2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000730 let mayLoad = 1;
731 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
732 // However, BDXs have two extra operands and are therefore 6 units more
733 // complex.
734 let AddedComplexity = 7;
735}
736
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000737class CondUnaryRSY<string mnemonic, bits<16> opcode,
Richard Sandifordee834382013-07-31 12:38:08 +0000738 SDPatternOperator operator, RegisterOperand cls,
739 bits<5> bytes, AddressingMode mode = bdaddr20only>
740 : InstRSY<opcode, (outs cls:$R1),
741 (ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
742 mnemonic#"$R3\t$R1, $BD2",
743 [(set cls:$R1,
744 (z_select_ccmask (load bdaddr20only:$BD2), cls:$R1src,
745 cond4:$valid, cond4:$R3))]>,
Richard Sandiford09a8cf32013-07-25 09:04:52 +0000746 Requires<[FeatureLoadStoreOnCond]> {
747 let Constraints = "$R1 = $R1src";
748 let DisableEncoding = "$R1src";
749 let mayLoad = 1;
750 let AccessBytes = bytes;
751}
752
753// Like CondUnaryRSY, but used for the raw assembly form. The condition-code
754// mask is the third operand rather than being part of the mnemonic.
755class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,
756 RegisterOperand cls, bits<5> bytes,
757 AddressingMode mode = bdaddr20only>
758 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, uimm8zx4:$R3),
759 mnemonic#"\t$R1, $BD2, $R3", []>,
760 Requires<[FeatureLoadStoreOnCond]> {
761 let mayLoad = 1;
762 let AccessBytes = bytes;
763 let Constraints = "$R1 = $R1src";
764 let DisableEncoding = "$R1src";
765}
766
767// Like CondUnaryRSY, but with a fixed CC mask.
768class FixedCondUnaryRSY<string mnemonic, bits<16> opcode,
769 RegisterOperand cls, bits<4> ccmask, bits<5> bytes,
770 AddressingMode mode = bdaddr20only>
771 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2),
772 mnemonic#"\t$R1, $BD2", []>,
773 Requires<[FeatureLoadStoreOnCond]> {
774 let Constraints = "$R1 = $R1src";
775 let DisableEncoding = "$R1src";
776 let R3 = ccmask;
777 let mayLoad = 1;
778 let AccessBytes = bytes;
779}
780
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000781class UnaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000782 RegisterOperand cls, bits<5> bytes,
783 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000784 : InstRX<opcode, (outs cls:$R1), (ins mode:$XBD2),
785 mnemonic#"\t$R1, $XBD2",
786 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000787 let OpKey = mnemonic ## cls;
788 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000789 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000790 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000791}
792
793class UnaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000794 RegisterOperand cls, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000795 : InstRXE<opcode, (outs cls:$R1), (ins bdxaddr12only:$XBD2),
796 mnemonic#"\t$R1, $XBD2",
797 [(set cls:$R1, (operator bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000798 let OpKey = mnemonic ## cls;
799 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000800 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000801 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000802}
803
804class UnaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000805 RegisterOperand cls, bits<5> bytes,
806 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000807 : InstRXY<opcode, (outs cls:$R1), (ins mode:$XBD2),
808 mnemonic#"\t$R1, $XBD2",
809 [(set cls:$R1, (operator mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000810 let OpKey = mnemonic ## cls;
811 let OpType = "mem";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000812 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000813 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000814}
815
816multiclass UnaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000817 SDPatternOperator operator, RegisterOperand cls,
818 bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000819 let DispKey = mnemonic ## #cls in {
820 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000821 def "" : UnaryRX<mnemonic, rxOpcode, operator, cls, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000822 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000823 def Y : UnaryRXY<mnemonic#"y", rxyOpcode, operator, cls, bytes,
824 bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000825 }
826}
827
828class BinaryRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
829 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000830 : InstRR<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000831 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000832 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000833 let OpKey = mnemonic ## cls1;
834 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000835 let Constraints = "$R1 = $R1src";
836 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000837}
838
839class BinaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
840 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000841 : InstRRE<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000842 mnemonic#"r\t$R1, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +0000843 [(set cls1:$R1, (operator cls1:$R1src, cls2:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000844 let OpKey = mnemonic ## cls1;
845 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000846 let Constraints = "$R1 = $R1src";
847 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000848}
849
Richard Sandifordd454ec02013-05-14 09:28:21 +0000850class BinaryRRF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
851 RegisterOperand cls1, RegisterOperand cls2>
852 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R3, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +0000853 mnemonic#"r\t$R1, $R3, $R2",
854 [(set cls1:$R1, (operator cls1:$R3, cls2:$R2))]> {
855 let OpKey = mnemonic ## cls1;
856 let OpType = "reg";
857}
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000858
Richard Sandiford0175b4a2013-07-19 16:21:55 +0000859class BinaryRRFK<string mnemonic, bits<16> opcode, SDPatternOperator operator,
860 RegisterOperand cls1, RegisterOperand cls2>
861 : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R2, cls2:$R3),
862 mnemonic#"rk\t$R1, $R2, $R3",
863 [(set cls1:$R1, (operator cls1:$R2, cls2:$R3))]>;
864
865multiclass BinaryRRAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
866 SDPatternOperator operator, RegisterOperand cls1,
867 RegisterOperand cls2> {
868 let NumOpsKey = mnemonic in {
869 let NumOpsValue = "3" in
870 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
871 Requires<[FeatureDistinctOps]>;
872 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
873 def "" : BinaryRR<mnemonic, opcode1, operator, cls1, cls2>;
874 }
875}
876
Richard Sandifordc57e5862013-07-19 16:24:22 +0000877multiclass BinaryRREAndK<string mnemonic, bits<16> opcode1, bits<16> opcode2,
878 SDPatternOperator operator, RegisterOperand cls1,
879 RegisterOperand cls2> {
880 let NumOpsKey = mnemonic in {
881 let NumOpsValue = "3" in
882 def K : BinaryRRFK<mnemonic, opcode2, null_frag, cls1, cls2>,
883 Requires<[FeatureDistinctOps]>;
884 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
885 def "" : BinaryRRE<mnemonic, opcode1, operator, cls1, cls2>;
886 }
887}
888
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000889class BinaryRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
890 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000891 : InstRI<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
892 mnemonic#"\t$R1, $I2",
893 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
894 let Constraints = "$R1 = $R1src";
895 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000896}
897
Richard Sandiford7d6a4532013-07-19 16:32:12 +0000898class BinaryRIE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
899 RegisterOperand cls, Immediate imm>
900 : InstRIEd<opcode, (outs cls:$R1), (ins cls:$R3, imm:$I2),
901 mnemonic#"\t$R1, $R3, $I2",
902 [(set cls:$R1, (operator cls:$R3, imm:$I2))]>;
903
904multiclass BinaryRIAndK<string mnemonic, bits<12> opcode1, bits<16> opcode2,
905 SDPatternOperator operator, RegisterOperand cls,
906 Immediate imm> {
907 let NumOpsKey = mnemonic in {
908 let NumOpsValue = "3" in
909 def K : BinaryRIE<mnemonic##"k", opcode2, null_frag, cls, imm>,
910 Requires<[FeatureDistinctOps]>;
911 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
912 def "" : BinaryRI<mnemonic, opcode1, operator, cls, imm>;
913 }
914}
915
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000916class BinaryRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
917 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000918 : InstRIL<opcode, (outs cls:$R1), (ins cls:$R1src, imm:$I2),
919 mnemonic#"\t$R1, $I2",
920 [(set cls:$R1, (operator cls:$R1src, imm:$I2))]> {
921 let Constraints = "$R1 = $R1src";
922 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000923}
924
925class BinaryRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000926 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000927 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000928 : InstRX<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
929 mnemonic#"\t$R1, $XBD2",
930 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000931 let OpKey = mnemonic ## cls;
932 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000933 let Constraints = "$R1 = $R1src";
934 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000935 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000936 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000937}
938
939class BinaryRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000940 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000941 : InstRXE<opcode, (outs cls:$R1), (ins cls:$R1src, bdxaddr12only:$XBD2),
942 mnemonic#"\t$R1, $XBD2",
943 [(set cls:$R1, (operator cls:$R1src,
944 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000945 let OpKey = mnemonic ## cls;
946 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000947 let Constraints = "$R1 = $R1src";
948 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000949 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000950 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000951}
952
953class BinaryRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000954 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000955 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000956 : InstRXY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$XBD2),
957 mnemonic#"\t$R1, $XBD2",
958 [(set cls:$R1, (operator cls:$R1src, (load mode:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +0000959 let OpKey = mnemonic ## cls;
960 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +0000961 let Constraints = "$R1 = $R1src";
962 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000963 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +0000964 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000965}
966
967multiclass BinaryRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
968 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +0000969 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000970 let DispKey = mnemonic ## #cls in {
971 let DispSize = "12" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000972 def "" : BinaryRX<mnemonic, rxOpcode, operator, cls, load, bytes,
973 bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +0000974 let DispSize = "20" in
Richard Sandiforded1fab62013-07-03 10:10:02 +0000975 def Y : BinaryRXY<mnemonic#"y", rxyOpcode, operator, cls, load, bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000976 bdxaddr20pair>;
977 }
978}
979
980class BinarySI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
981 Operand imm, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000982 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
983 mnemonic#"\t$BD1, $I2",
984 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000985 let mayLoad = 1;
986 let mayStore = 1;
987}
988
989class BinarySIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
990 Operand imm, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +0000991 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
992 mnemonic#"\t$BD1, $I2",
993 [(store (operator (load mode:$BD1), imm:$I2), mode:$BD1)]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +0000994 let mayLoad = 1;
995 let mayStore = 1;
996}
997
998multiclass BinarySIPair<string mnemonic, bits<8> siOpcode,
999 bits<16> siyOpcode, SDPatternOperator operator,
1000 Operand imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001001 let DispKey = mnemonic ## #cls in {
1002 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001003 def "" : BinarySI<mnemonic, siOpcode, operator, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001004 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001005 def Y : BinarySIY<mnemonic#"y", siyOpcode, operator, imm, bdaddr20pair>;
1006 }
1007}
1008
1009class ShiftRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001010 RegisterOperand cls>
1011 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, shift12only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001012 mnemonic#"\t$R1, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001013 [(set cls:$R1, (operator cls:$R1src, shift12only:$BD2))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001014 let R3 = 0;
Richard Sandifordd454ec02013-05-14 09:28:21 +00001015 let Constraints = "$R1 = $R1src";
1016 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001017}
1018
1019class ShiftRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001020 RegisterOperand cls>
1021 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R3, shift20only:$BD2),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001022 mnemonic#"\t$R1, $R3, $BD2",
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001023 [(set cls:$R1, (operator cls:$R3, shift20only:$BD2))]>;
1024
1025multiclass ShiftRSAndK<string mnemonic, bits<8> opcode1, bits<16> opcode2,
1026 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandifordff6c5a52013-07-19 16:12:08 +00001027 let NumOpsKey = mnemonic in {
1028 let NumOpsValue = "3" in
1029 def K : ShiftRSY<mnemonic##"k", opcode2, null_frag, cls>,
1030 Requires<[FeatureDistinctOps]>;
1031 let NumOpsValue = "2", isConvertibleToThreeAddress = 1 in
1032 def "" : ShiftRS<mnemonic, opcode1, operator, cls>;
1033 }
Richard Sandiford27d1cfe2013-07-19 16:09:03 +00001034}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001035
1036class CompareRR<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1037 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001038 : InstRR<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001039 mnemonic#"r\t$R1, $R2",
1040 [(operator cls1:$R1, cls2:$R2)]> {
1041 let OpKey = mnemonic ## cls1;
1042 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001043 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001044}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001045
1046class CompareRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1047 RegisterOperand cls1, RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001048 : InstRRE<opcode, (outs), (ins cls1:$R1, cls2:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001049 mnemonic#"r\t$R1, $R2",
1050 [(operator cls1:$R1, cls2:$R2)]> {
1051 let OpKey = mnemonic ## cls1;
1052 let OpType = "reg";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001053 let isCompare = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001054}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001055
1056class CompareRI<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1057 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001058 : InstRI<opcode, (outs), (ins cls:$R1, imm:$I2),
1059 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001060 [(operator cls:$R1, imm:$I2)]> {
1061 let isCompare = 1;
1062}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001063
1064class CompareRIL<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1065 RegisterOperand cls, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001066 : InstRIL<opcode, (outs), (ins cls:$R1, imm:$I2),
1067 mnemonic#"\t$R1, $I2",
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001068 [(operator cls:$R1, imm:$I2)]> {
1069 let isCompare = 1;
1070}
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001071
1072class CompareRILPC<string mnemonic, bits<12> opcode, SDPatternOperator operator,
1073 RegisterOperand cls, SDPatternOperator load>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001074 : InstRIL<opcode, (outs), (ins cls:$R1, pcrel32:$I2),
1075 mnemonic#"\t$R1, $I2",
1076 [(operator cls:$R1, (load pcrel32:$I2))]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001077 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001078 let mayLoad = 1;
1079 // We want PC-relative addresses to be tried ahead of BD and BDX addresses.
1080 // However, BDXs have two extra operands and are therefore 6 units more
1081 // complex.
1082 let AddedComplexity = 7;
1083}
1084
1085class CompareRX<string mnemonic, bits<8> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001086 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001087 AddressingMode mode = bdxaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001088 : InstRX<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1089 mnemonic#"\t$R1, $XBD2",
1090 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001091 let OpKey = mnemonic ## cls;
1092 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001093 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001094 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001095 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001096}
1097
1098class CompareRXE<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001099 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001100 : InstRXE<opcode, (outs), (ins cls:$R1, bdxaddr12only:$XBD2),
1101 mnemonic#"\t$R1, $XBD2",
1102 [(operator cls:$R1, (load bdxaddr12only:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001103 let OpKey = mnemonic ## cls;
1104 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001105 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001106 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001107 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001108}
1109
1110class CompareRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001111 RegisterOperand cls, SDPatternOperator load, bits<5> bytes,
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001112 AddressingMode mode = bdxaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001113 : InstRXY<opcode, (outs), (ins cls:$R1, mode:$XBD2),
1114 mnemonic#"\t$R1, $XBD2",
1115 [(operator cls:$R1, (load mode:$XBD2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001116 let OpKey = mnemonic ## cls;
1117 let OpType = "mem";
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001118 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001119 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001120 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001121}
1122
1123multiclass CompareRXPair<string mnemonic, bits<8> rxOpcode, bits<16> rxyOpcode,
1124 SDPatternOperator operator, RegisterOperand cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001125 SDPatternOperator load, bits<5> bytes> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001126 let DispKey = mnemonic ## #cls in {
1127 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001128 def "" : CompareRX<mnemonic, rxOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001129 load, bytes, bdxaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001130 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001131 def Y : CompareRXY<mnemonic#"y", rxyOpcode, operator, cls,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001132 load, bytes, bdxaddr20pair>;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001133 }
1134}
1135
1136class CompareSI<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1137 SDPatternOperator load, Immediate imm,
1138 AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001139 : InstSI<opcode, (outs), (ins mode:$BD1, imm:$I2),
1140 mnemonic#"\t$BD1, $I2",
1141 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001142 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001143 let mayLoad = 1;
1144}
1145
1146class CompareSIL<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1147 SDPatternOperator load, Immediate imm>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001148 : InstSIL<opcode, (outs), (ins bdaddr12only:$BD1, imm:$I2),
1149 mnemonic#"\t$BD1, $I2",
1150 [(operator (load bdaddr12only:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001151 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001152 let mayLoad = 1;
1153}
1154
1155class CompareSIY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1156 SDPatternOperator load, Immediate imm,
1157 AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001158 : InstSIY<opcode, (outs), (ins mode:$BD1, imm:$I2),
1159 mnemonic#"\t$BD1, $I2",
1160 [(operator (load mode:$BD1), imm:$I2)]> {
Richard Sandifordc3f85d72013-07-25 09:34:38 +00001161 let isCompare = 1;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001162 let mayLoad = 1;
1163}
1164
1165multiclass CompareSIPair<string mnemonic, bits<8> siOpcode, bits<16> siyOpcode,
1166 SDPatternOperator operator, SDPatternOperator load,
1167 Immediate imm> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001168 let DispKey = mnemonic in {
1169 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001170 def "" : CompareSI<mnemonic, siOpcode, operator, load, imm, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001171 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001172 def Y : CompareSIY<mnemonic#"y", siyOpcode, operator, load, imm,
1173 bdaddr20pair>;
1174 }
1175}
1176
1177class TernaryRRD<string mnemonic, bits<16> opcode,
1178 SDPatternOperator operator, RegisterOperand cls>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001179 : InstRRD<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, cls:$R2),
Richard Sandiforded1fab62013-07-03 10:10:02 +00001180 mnemonic#"r\t$R1, $R3, $R2",
Richard Sandifordd454ec02013-05-14 09:28:21 +00001181 [(set cls:$R1, (operator cls:$R1src, cls:$R3, cls:$R2))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001182 let OpKey = mnemonic ## cls;
1183 let OpType = "reg";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001184 let Constraints = "$R1 = $R1src";
1185 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001186}
1187
1188class TernaryRXF<string mnemonic, bits<16> opcode, SDPatternOperator operator,
Richard Sandiforded1fab62013-07-03 10:10:02 +00001189 RegisterOperand cls, SDPatternOperator load, bits<5> bytes>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001190 : InstRXF<opcode, (outs cls:$R1),
1191 (ins cls:$R1src, cls:$R3, bdxaddr12only:$XBD2),
1192 mnemonic#"\t$R1, $R3, $XBD2",
1193 [(set cls:$R1, (operator cls:$R1src, cls:$R3,
1194 (load bdxaddr12only:$XBD2)))]> {
Richard Sandiforded1fab62013-07-03 10:10:02 +00001195 let OpKey = mnemonic ## cls;
1196 let OpType = "mem";
Richard Sandifordd454ec02013-05-14 09:28:21 +00001197 let Constraints = "$R1 = $R1src";
1198 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001199 let mayLoad = 1;
Richard Sandiforded1fab62013-07-03 10:10:02 +00001200 let AccessBytes = bytes;
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001201}
1202
1203class CmpSwapRS<string mnemonic, bits<8> opcode, SDPatternOperator operator,
1204 RegisterOperand cls, AddressingMode mode = bdaddr12only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001205 : InstRS<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1206 mnemonic#"\t$R1, $R3, $BD2",
1207 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1208 let Constraints = "$R1 = $R1src";
1209 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001210 let mayLoad = 1;
1211 let mayStore = 1;
1212}
1213
1214class CmpSwapRSY<string mnemonic, bits<16> opcode, SDPatternOperator operator,
1215 RegisterOperand cls, AddressingMode mode = bdaddr20only>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001216 : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, cls:$R3, mode:$BD2),
1217 mnemonic#"\t$R1, $R3, $BD2",
1218 [(set cls:$R1, (operator mode:$BD2, cls:$R1src, cls:$R3))]> {
1219 let Constraints = "$R1 = $R1src";
1220 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001221 let mayLoad = 1;
1222 let mayStore = 1;
1223}
1224
1225multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,
1226 SDPatternOperator operator, RegisterOperand cls> {
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001227 let DispKey = mnemonic ## #cls in {
1228 let DispSize = "12" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001229 def "" : CmpSwapRS<mnemonic, rsOpcode, operator, cls, bdaddr12pair>;
Richard Sandiforddf313ff2013-07-03 09:19:58 +00001230 let DispSize = "20" in
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001231 def Y : CmpSwapRSY<mnemonic#"y", rsyOpcode, operator, cls, bdaddr20pair>;
1232 }
1233}
1234
1235class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,
1236 RegisterOperand cls2>
Richard Sandifordd454ec02013-05-14 09:28:21 +00001237 : InstRIEf<opcode, (outs cls1:$R1),
Richard Sandiford67ddcd62013-07-11 08:37:13 +00001238 (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5),
Richard Sandifordd454ec02013-05-14 09:28:21 +00001239 mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {
1240 let Constraints = "$R1 = $R1src";
1241 let DisableEncoding = "$R1src";
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001242}
1243
1244//===----------------------------------------------------------------------===//
1245// Pseudo instructions
1246//===----------------------------------------------------------------------===//
1247//
1248// Convenience instructions that get lowered to real instructions
1249// by either SystemZTargetLowering::EmitInstrWithCustomInserter()
1250// or SystemZInstrInfo::expandPostRAPseudo().
1251//
1252//===----------------------------------------------------------------------===//
1253
1254class Pseudo<dag outs, dag ins, list<dag> pattern>
1255 : InstSystemZ<0, outs, ins, "", pattern> {
1256 let isPseudo = 1;
1257 let isCodeGenOnly = 1;
1258}
1259
1260// Implements "$dst = $cc & (8 >> CC) ? $src1 : $src2", where CC is
1261// the value of the PSW's 2-bit condition code field.
1262class SelectWrapper<RegisterOperand cls>
Richard Sandiford3d768e32013-07-31 12:30:20 +00001263 : Pseudo<(outs cls:$dst),
1264 (ins cls:$src1, cls:$src2, uimm8zx4:$valid, uimm8zx4:$cc),
1265 [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2,
1266 uimm8zx4:$valid, uimm8zx4:$cc))]> {
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001267 let usesCustomInserter = 1;
1268 // Although the instructions used by these nodes do not in themselves
Richard Sandiford14a44492013-05-22 13:38:45 +00001269 // change CC, the insertion requires new blocks, and CC cannot be live
1270 // across them.
1271 let Defs = [CC];
1272 let Uses = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001273}
1274
Richard Sandifordb86a8342013-06-27 09:27:40 +00001275// Stores $new to $addr if $cc is true ("" case) or false (Inv case).
1276multiclass CondStores<RegisterOperand cls, SDPatternOperator store,
1277 SDPatternOperator load, AddressingMode mode> {
1278 let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {
Richard Sandiford3d768e32013-07-31 12:30:20 +00001279 def "" : Pseudo<(outs),
1280 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001281 [(store (z_select_ccmask cls:$new, (load mode:$addr),
Richard Sandiford3d768e32013-07-31 12:30:20 +00001282 uimm8zx4:$valid, uimm8zx4:$cc),
1283 mode:$addr)]>;
1284 def Inv : Pseudo<(outs),
1285 (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc),
Richard Sandifordb86a8342013-06-27 09:27:40 +00001286 [(store (z_select_ccmask (load mode:$addr), cls:$new,
Richard Sandiford3d768e32013-07-31 12:30:20 +00001287 uimm8zx4:$valid, uimm8zx4:$cc),
1288 mode:$addr)]>;
Richard Sandifordb86a8342013-06-27 09:27:40 +00001289 }
1290}
1291
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001292// OPERATOR is ATOMIC_SWAP or an ATOMIC_LOAD_* operation. PAT and OPERAND
1293// describe the second (non-memory) operand.
1294class AtomicLoadBinary<SDPatternOperator operator, RegisterOperand cls,
1295 dag pat, DAGOperand operand>
1296 : Pseudo<(outs cls:$dst), (ins bdaddr20only:$ptr, operand:$src2),
1297 [(set cls:$dst, (operator bdaddr20only:$ptr, pat))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001298 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001299 let Has20BitOffset = 1;
1300 let mayLoad = 1;
1301 let mayStore = 1;
1302 let usesCustomInserter = 1;
1303}
1304
1305// Specializations of AtomicLoadWBinary.
1306class AtomicLoadBinaryReg32<SDPatternOperator operator>
1307 : AtomicLoadBinary<operator, GR32, (i32 GR32:$src2), GR32>;
1308class AtomicLoadBinaryImm32<SDPatternOperator operator, Immediate imm>
1309 : AtomicLoadBinary<operator, GR32, (i32 imm:$src2), imm>;
1310class AtomicLoadBinaryReg64<SDPatternOperator operator>
1311 : AtomicLoadBinary<operator, GR64, (i64 GR64:$src2), GR64>;
1312class AtomicLoadBinaryImm64<SDPatternOperator operator, Immediate imm>
1313 : AtomicLoadBinary<operator, GR64, (i64 imm:$src2), imm>;
1314
1315// OPERATOR is ATOMIC_SWAPW or an ATOMIC_LOADW_* operation. PAT and OPERAND
1316// describe the second (non-memory) operand.
1317class AtomicLoadWBinary<SDPatternOperator operator, dag pat,
1318 DAGOperand operand>
1319 : Pseudo<(outs GR32:$dst),
1320 (ins bdaddr20only:$ptr, operand:$src2, ADDR32:$bitshift,
1321 ADDR32:$negbitshift, uimm32:$bitsize),
1322 [(set GR32:$dst, (operator bdaddr20only:$ptr, pat, ADDR32:$bitshift,
1323 ADDR32:$negbitshift, uimm32:$bitsize))]> {
Richard Sandiford14a44492013-05-22 13:38:45 +00001324 let Defs = [CC];
Ulrich Weigand5f613df2013-05-06 16:15:19 +00001325 let Has20BitOffset = 1;
1326 let mayLoad = 1;
1327 let mayStore = 1;
1328 let usesCustomInserter = 1;
1329}
1330
1331// Specializations of AtomicLoadWBinary.
1332class AtomicLoadWBinaryReg<SDPatternOperator operator>
1333 : AtomicLoadWBinary<operator, (i32 GR32:$src2), GR32>;
1334class AtomicLoadWBinaryImm<SDPatternOperator operator, Immediate imm>
1335 : AtomicLoadWBinary<operator, (i32 imm:$src2), imm>;