1 //===-- SparcInstrAliases.td - Instruction Aliases for Sparc Target -------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file contains instruction aliases for Sparc.
10 //===----------------------------------------------------------------------===//
12 // Instruction aliases for conditional moves.
14 // mov<cond> <ccreg> rs2, rd
15 multiclass intcond_mov_alias<string cond, int condVal, string ccreg,
16 Instruction movrr, Instruction movri,
17 Instruction fmovs, Instruction fmovd> {
19 // mov<cond> (%icc|%xcc), rs2, rd
20 def : InstAlias<!strconcat(!strconcat(!strconcat("mov", cond), ccreg),
22 (movrr IntRegs:$rd, IntRegs:$rs2, condVal)>;
24 // mov<cond> (%icc|%xcc), simm11, rd
25 def : InstAlias<!strconcat(!strconcat(!strconcat("mov", cond), ccreg),
27 (movri IntRegs:$rd, i32imm:$simm11, condVal)>;
29 // fmovs<cond> (%icc|%xcc), $rs2, $rd
30 def : InstAlias<!strconcat(!strconcat(!strconcat("fmovs", cond), ccreg),
32 (fmovs FPRegs:$rd, FPRegs:$rs2, condVal)>;
34 // fmovd<cond> (%icc|%xcc), $rs2, $rd
35 def : InstAlias<!strconcat(!strconcat(!strconcat("fmovd", cond), ccreg),
37 (fmovd DFPRegs:$rd, DFPRegs:$rs2, condVal)>;
40 // mov<cond> <ccreg> rs2, rd
41 multiclass fpcond_mov_alias<string cond, int condVal,
42 Instruction movrr, Instruction movri,
43 Instruction fmovs, Instruction fmovd> {
45 // mov<cond> %fcc[0-3], rs2, rd
46 def : InstAlias<!strconcat(!strconcat("mov", cond), " $cc, $rs2, $rd"),
47 (movrr IntRegs:$rd, FCCRegs:$cc, IntRegs:$rs2, condVal)>;
49 // mov<cond> %fcc[0-3], simm11, rd
50 def : InstAlias<!strconcat(!strconcat("mov", cond), " $cc, $simm11, $rd"),
51 (movri IntRegs:$rd, FCCRegs:$cc, i32imm:$simm11, condVal)>;
53 // fmovs<cond> %fcc[0-3], $rs2, $rd
54 def : InstAlias<!strconcat(!strconcat("fmovs", cond), " $cc, $rs2, $rd"),
55 (fmovs FPRegs:$rd, FCCRegs:$cc, FPRegs:$rs2, condVal)>;
57 // fmovd<cond> %fcc[0-3], $rs2, $rd
58 def : InstAlias<!strconcat(!strconcat("fmovd", cond), " $cc, $rs2, $rd"),
59 (fmovd DFPRegs:$rd, FCCRegs:$cc, DFPRegs:$rs2, condVal)>;
62 // movr<cond> rs1, rs2, rd
63 multiclass regcond_mov_alias<string rcond, int condVal,
64 Instruction movrrr, Instruction movrri,
65 Instruction fmovrs, Instruction fmovrd,
68 // movr<cond> $rs1, $rs2, $rd
69 def : InstAlias<!strconcat(!strconcat("movr", rcond), " $rs1, $rs2, $rd"),
70 (movrrr IntRegs:$rd, I64Regs:$rs1, IntRegs:$rs2, condVal)>;
72 // movr<cond> $rs1, $simm10, $rd
73 def : InstAlias<!strconcat(!strconcat("movr", rcond), " $rs1, $simm10, $rd"),
74 (movrri IntRegs:$rd, I64Regs:$rs1, i32imm:$simm10, condVal)>;
76 // fmovrs<cond> $rs1, $rs2, $rd
77 def : InstAlias<!strconcat(!strconcat("fmovrs", rcond), " $rs1, $rs2, $rd"),
78 (fmovrs FPRegs:$rd, I64Regs:$rs1, FPRegs:$rs2, condVal)>;
80 // fmovrd<cond> $rs1, $rs2, $rd
81 def : InstAlias<!strconcat(!strconcat("fmovrd", rcond), " $rs1, $rs2, $rd"),
82 (fmovrd DFPRegs:$rd, I64Regs:$rs1, DFPRegs:$rs2, condVal)>;
84 // fmovrq<cond> $rs1, $rs2, $rd
85 let Predicates = [HasHardQuad] in
86 def : InstAlias<!strconcat(!strconcat("fmovrq", rcond), " $rs1, $rs2, $rd"),
87 (fmovrq QFPRegs:$rd, I64Regs:$rs1, QFPRegs:$rs2, condVal)>;
90 // Instruction aliases for integer conditional branches and moves.
91 multiclass int_cond_alias<string cond, int condVal> {
94 def : InstAlias<!strconcat(!strconcat("b", cond), " $imm"),
95 (BCOND brtarget:$imm, condVal)>;
98 def : InstAlias<!strconcat(!strconcat("b", cond), ",a $imm"),
99 (BCONDA brtarget:$imm, condVal)>;
101 // b<cond> %icc, $imm
102 def : InstAlias<!strconcat(!strconcat("b", cond), " %icc, $imm"),
103 (BPICC brtarget:$imm, condVal)>, Requires<[HasV9]>;
105 // b<cond>,pt %icc, $imm
106 def : InstAlias<!strconcat(!strconcat("b", cond), ",pt %icc, $imm"),
107 (BPICC brtarget:$imm, condVal)>, Requires<[HasV9]>;
109 // b<cond>,a %icc, $imm
110 def : InstAlias<!strconcat(!strconcat("b", cond), ",a %icc, $imm"),
111 (BPICCA brtarget:$imm, condVal)>, Requires<[HasV9]>;
113 // b<cond>,a,pt %icc, $imm
114 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pt %icc, $imm"),
115 (BPICCA brtarget:$imm, condVal)>, Requires<[HasV9]>;
117 // b<cond>,pn %icc, $imm
118 def : InstAlias<!strconcat(!strconcat("b", cond), ",pn %icc, $imm"),
119 (BPICCNT brtarget:$imm, condVal)>, Requires<[HasV9]>;
121 // b<cond>,a,pn %icc, $imm
122 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pn %icc, $imm"),
123 (BPICCANT brtarget:$imm, condVal)>, Requires<[HasV9]>;
125 // b<cond> %xcc, $imm
126 def : InstAlias<!strconcat(!strconcat("b", cond), " %xcc, $imm"),
127 (BPXCC brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
129 // b<cond>,pt %xcc, $imm
130 def : InstAlias<!strconcat(!strconcat("b", cond), ",pt %xcc, $imm"),
131 (BPXCC brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
133 // b<cond>,a %xcc, $imm
134 def : InstAlias<!strconcat(!strconcat("b", cond), ",a %xcc, $imm"),
135 (BPXCCA brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
137 // b<cond>,a,pt %xcc, $imm
138 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pt %xcc, $imm"),
139 (BPXCCA brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
141 // b<cond>,pn %xcc, $imm
142 def : InstAlias<!strconcat(!strconcat("b", cond), ",pn %xcc, $imm"),
143 (BPXCCNT brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
145 // b<cond>,a,pn %xcc, $imm
146 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pn %xcc, $imm"),
147 (BPXCCANT brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
150 defm : intcond_mov_alias<cond, condVal, " %icc",
152 FMOVS_ICC, FMOVD_ICC>, Requires<[HasV9]>;
154 defm : intcond_mov_alias<cond, condVal, " %xcc",
156 FMOVS_XCC, FMOVD_XCC>, Requires<[Is64Bit]>;
158 // fmovq<cond> (%icc|%xcc), $rs2, $rd
159 def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %icc, $rs2, $rd"),
160 (FMOVQ_ICC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
161 Requires<[HasV9, HasHardQuad]>;
162 def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %xcc, $rs2, $rd"),
163 (FMOVQ_XCC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
164 Requires<[Is64Bit, HasHardQuad]>;
166 // t<cond> %icc, rs => t<cond> %icc, G0 + rs
167 def : InstAlias<!strconcat(!strconcat("t", cond), " %icc, $rs2"),
168 (TICCrr G0, IntRegs:$rs2, condVal)>,
170 // t<cond> %icc, rs1 + rs2
171 def : InstAlias<!strconcat(!strconcat("t", cond), " %icc, $rs1 + $rs2"),
172 (TICCrr IntRegs:$rs1, IntRegs:$rs2, condVal)>,
176 // t<cond> %xcc, rs => t<cond> %xcc, G0 + rs
177 def : InstAlias<!strconcat(!strconcat("t", cond), " %xcc, $rs2"),
178 (TXCCrr G0, IntRegs:$rs2, condVal)>,
180 // t<cond> %xcc, rs1 + rs2
181 def : InstAlias<!strconcat(!strconcat("t", cond), " %xcc, $rs1 + $rs2"),
182 (TXCCrr IntRegs:$rs1, IntRegs:$rs2, condVal)>,
186 // t<cond> rs=> t<cond> %icc, G0 + rs2
187 //def : InstAlias<!strconcat(!strconcat("t", cond), " $rs2"),
188 // (TICCrr G0, IntRegs:$rs2, condVal)>,
189 // Requires<[HasV9]>;
191 // t<cond> rs1 + rs2 => t<cond> %icc, rs1 + rs2
192 //def : InstAlias<!strconcat(!strconcat("t", cond), " $rs1 + $rs2"),
193 // (TICCrr IntRegs:$rs1, IntRegs:$rs2, condVal)>,
194 // Requires<[HasV9]>;
196 // t<cond> %icc, imm => t<cond> %icc, G0 + imm
197 def : InstAlias<!strconcat(!strconcat("t", cond), " %icc, $imm"),
198 (TICCri G0, i32imm:$imm, condVal)>,
200 // t<cond> %icc, rs1 + imm
201 def : InstAlias<!strconcat(!strconcat("t", cond), " %icc, $rs1 + $imm"),
202 (TICCri IntRegs:$rs1, i32imm:$imm, condVal)>,
204 // t<cond> %xcc, imm => t<cond> %xcc, G0 + imm
205 def : InstAlias<!strconcat(!strconcat("t", cond), " %xcc, $imm"),
206 (TXCCri G0, i32imm:$imm, condVal)>,
208 // t<cond> %xcc, rs1 + imm
209 def : InstAlias<!strconcat(!strconcat("t", cond), " %xcc, $rs1 + $imm"),
210 (TXCCri IntRegs:$rs1, i32imm:$imm, condVal)>,
213 // t<cond> imm => t<cond> G0 + imm
214 def : InstAlias<!strconcat(!strconcat("t", cond), " $imm"),
215 (TRAPri G0, i32imm:$imm, condVal)>;
217 // t<cond> rs1 + imm => t<cond> rs1 + imm
218 def : InstAlias<!strconcat(!strconcat("t", cond), " $rs1 + $imm"),
219 (TRAPri IntRegs:$rs1, i32imm:$imm, condVal)>;
221 // t<cond> rs1 => t<cond> G0 + rs1
222 def : InstAlias<!strconcat(!strconcat("t", cond), " $rs1"),
223 (TRAPrr G0, IntRegs:$rs1, condVal)>;
226 def : InstAlias<!strconcat(!strconcat("t", cond), " $rs1 + $rs2"),
227 (TRAPrr IntRegs:$rs1, IntRegs:$rs2, condVal)>;
231 // Instruction aliases for floating point conditional branches and moves.
232 multiclass fp_cond_alias<string cond, int condVal> {
235 def : InstAlias<!strconcat(!strconcat("fb", cond), " $imm"),
236 (FBCOND brtarget:$imm, condVal), 0>;
239 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a $imm"),
240 (FBCONDA brtarget:$imm, condVal), 0>;
242 // fb<cond> %fcc0, $imm
243 def : InstAlias<!strconcat(!strconcat("fb", cond), " $cc, $imm"),
244 (BPFCC brtarget:$imm, condVal, FCCRegs:$cc)>,
247 // fb<cond>,pt %fcc0, $imm
248 def : InstAlias<!strconcat(!strconcat("fb", cond), ",pt $cc, $imm"),
249 (BPFCC brtarget:$imm, condVal, FCCRegs:$cc)>,
252 // fb<cond>,a %fcc0, $imm
253 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a $cc, $imm"),
254 (BPFCCA brtarget:$imm, condVal, FCCRegs:$cc)>,
257 // fb<cond>,a,pt %fcc0, $imm
258 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a,pt $cc, $imm"),
259 (BPFCCA brtarget:$imm, condVal, FCCRegs:$cc)>,
262 // fb<cond>,pn %fcc0, $imm
263 def : InstAlias<!strconcat(!strconcat("fb", cond), ",pn $cc, $imm"),
264 (BPFCCNT brtarget:$imm, condVal, FCCRegs:$cc)>,
267 // fb<cond>,a,pn %fcc0, $imm
268 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a,pn $cc, $imm"),
269 (BPFCCANT brtarget:$imm, condVal, FCCRegs:$cc)>,
272 defm : fpcond_mov_alias<cond, condVal,
273 V9MOVFCCrr, V9MOVFCCri,
274 V9FMOVS_FCC, V9FMOVD_FCC>, Requires<[HasV9]>;
276 // fmovq<cond> %fcc0, $rs2, $rd
277 def : InstAlias<!strconcat(!strconcat("fmovq", cond), " $cc, $rs2, $rd"),
278 (V9FMOVQ_FCC QFPRegs:$rd, FCCRegs:$cc, QFPRegs:$rs2,
280 Requires<[HasV9, HasHardQuad]>;
284 // Instruction aliases for co-processor conditional branches.
285 multiclass cp_cond_alias<string cond, int condVal> {
288 def : InstAlias<!strconcat(!strconcat("cb", cond), " $imm"),
289 (CBCOND brtarget:$imm, condVal), 0>;
292 def : InstAlias<!strconcat(!strconcat("cb", cond), ",a $imm"),
293 (CBCONDA brtarget:$imm, condVal), 0>;
296 // Instruction aliases for register conditional branches and moves.
297 multiclass reg_cond_alias<string rcond, int condVal> {
298 // br<rcond> $rs1, $imm
299 def : InstAlias<!strconcat(!strconcat("br", rcond), " $rs1, $imm"),
300 (BPR bprtarget16:$imm, condVal, I64Regs:$rs1)>,
303 // br<rcond>,pt $rs1, $imm
304 def : InstAlias<!strconcat(!strconcat("br", rcond), ",pt $rs1, $imm"),
305 (BPR bprtarget16:$imm, condVal, I64Regs:$rs1)>,
308 // br<rcond>,pn $rs1, $imm
309 def : InstAlias<!strconcat(!strconcat("br", rcond), ",pn $rs1, $imm"),
310 (BPRNT bprtarget16:$imm, condVal, I64Regs:$rs1)>,
313 // br<rcond>,a $rs1, $imm
314 def : InstAlias<!strconcat(!strconcat("br", rcond), ",a $rs1, $imm"),
315 (BPRA bprtarget16:$imm, condVal, I64Regs:$rs1)>,
318 // br<rcond>,a,pt $rs1, $imm
319 def : InstAlias<!strconcat(!strconcat("br", rcond), ",a,pt $rs1, $imm"),
320 (BPRA bprtarget16:$imm, condVal, I64Regs:$rs1)>,
323 // br<rcond>,a,pn $rs1, $imm
324 def : InstAlias<!strconcat(!strconcat("br", rcond), ",a,pn $rs1, $imm"),
325 (BPRANT bprtarget16:$imm, condVal, I64Regs:$rs1)>,
328 defm : regcond_mov_alias<rcond, condVal,
330 FMOVRS, FMOVRD, FMOVRQ>,
334 defm : int_cond_alias<"a", 0b1000>;
335 defm : int_cond_alias<"n", 0b0000>;
336 defm : int_cond_alias<"ne", 0b1001>;
337 defm : int_cond_alias<"e", 0b0001>;
338 defm : int_cond_alias<"g", 0b1010>;
339 defm : int_cond_alias<"le", 0b0010>;
340 defm : int_cond_alias<"ge", 0b1011>;
341 defm : int_cond_alias<"l", 0b0011>;
342 defm : int_cond_alias<"gu", 0b1100>;
343 defm : int_cond_alias<"leu", 0b0100>;
344 defm : int_cond_alias<"cc", 0b1101>;
345 defm : int_cond_alias<"cs", 0b0101>;
346 defm : int_cond_alias<"pos", 0b1110>;
347 defm : int_cond_alias<"neg", 0b0110>;
348 defm : int_cond_alias<"vc", 0b1111>;
349 defm : int_cond_alias<"vs", 0b0111>;
350 let EmitPriority = 0 in
352 defm : int_cond_alias<"", 0b1000>; // same as a; gnu asm, not in manual
353 defm : int_cond_alias<"gt", 0b1010>; // same as g; gnu asm, not in manual
354 defm : int_cond_alias<"lt", 0b0011>; // same as l; gnu asm, not in manual
355 defm : int_cond_alias<"nz", 0b1001>; // same as ne
356 defm : int_cond_alias<"eq", 0b0001>; // same as e
357 defm : int_cond_alias<"z", 0b0001>; // same as e
358 defm : int_cond_alias<"geu", 0b1101>; // same as cc
359 defm : int_cond_alias<"lu", 0b0101>; // same as cs
361 defm : fp_cond_alias<"a", 0b1000>;
362 defm : fp_cond_alias<"n", 0b0000>;
363 defm : fp_cond_alias<"u", 0b0111>;
364 defm : fp_cond_alias<"g", 0b0110>;
365 defm : fp_cond_alias<"ug", 0b0101>;
366 defm : fp_cond_alias<"l", 0b0100>;
367 defm : fp_cond_alias<"ul", 0b0011>;
368 defm : fp_cond_alias<"lg", 0b0010>;
369 defm : fp_cond_alias<"ne", 0b0001>;
370 defm : fp_cond_alias<"e", 0b1001>;
371 defm : fp_cond_alias<"ue", 0b1010>;
372 defm : fp_cond_alias<"ge", 0b1011>;
373 defm : fp_cond_alias<"uge", 0b1100>;
374 defm : fp_cond_alias<"le", 0b1101>;
375 defm : fp_cond_alias<"ule", 0b1110>;
376 defm : fp_cond_alias<"o", 0b1111>;
377 let EmitPriority = 0 in
379 defm : fp_cond_alias<"", 0b1000>; // same as a; gnu asm, not in manual
380 defm : fp_cond_alias<"nz", 0b0001>; // same as ne
381 defm : fp_cond_alias<"z", 0b1001>; // same as e
384 defm : cp_cond_alias<"a", 0b1000>;
385 defm : cp_cond_alias<"n", 0b0000>;
386 defm : cp_cond_alias<"3", 0b0111>;
387 defm : cp_cond_alias<"2", 0b0110>;
388 defm : cp_cond_alias<"23", 0b0101>;
389 defm : cp_cond_alias<"1", 0b0100>;
390 defm : cp_cond_alias<"13", 0b0011>;
391 defm : cp_cond_alias<"12", 0b0010>;
392 defm : cp_cond_alias<"123", 0b0001>;
393 defm : cp_cond_alias<"0", 0b1001>;
394 defm : cp_cond_alias<"03", 0b1010>;
395 defm : cp_cond_alias<"02", 0b1011>;
396 defm : cp_cond_alias<"023", 0b1100>;
397 defm : cp_cond_alias<"01", 0b1101>;
398 defm : cp_cond_alias<"013", 0b1110>;
399 defm : cp_cond_alias<"012", 0b1111>;
400 let EmitPriority = 0 in defm : cp_cond_alias<"", 0b1000>; // same as a; gnu asm, not in manual
402 defm : reg_cond_alias<"z", 0b001>;
403 defm : reg_cond_alias<"e", 0b001>;
404 defm : reg_cond_alias<"lez", 0b010>;
405 defm : reg_cond_alias<"lz", 0b011>;
406 defm : reg_cond_alias<"nz", 0b101>;
407 defm : reg_cond_alias<"ne", 0b101>;
408 defm : reg_cond_alias<"gz", 0b110>;
409 defm : reg_cond_alias<"gez", 0b111>;
411 // Section A.3 Synthetic Instructions
413 // Most are marked as Emit=0, so that they are not used for disassembly. This is
414 // an aesthetic issue, but the chosen policy is to typically prefer using the
415 // non-alias form, except for the most obvious and clarifying aliases: cmp, jmp,
416 // call, tst, ret, retl.
418 // Note: jmp/call/ret/retl have special case handling for output in
419 // SparcInstPrinter.cpp
421 // cmp rs1, reg_or_imm -> subcc rs1, reg_or_imm, %g0
422 def : InstAlias<"cmp $rs1, $rs2", (SUBCCrr G0, IntRegs:$rs1, IntRegs:$rs2)>;
423 def : InstAlias<"cmp $rs1, $imm", (SUBCCri G0, IntRegs:$rs1, simm13Op:$imm)>;
425 // jmp addr -> jmpl addr, %g0
426 def : InstAlias<"jmp $addr", (JMPLrr G0, MEMrr:$addr), 0>;
427 def : InstAlias<"jmp $addr", (JMPLri G0, MEMri:$addr), 0>;
429 // call addr -> jmpl addr, %o7
430 def : InstAlias<"call $addr", (JMPLrr O7, MEMrr:$addr), 0>;
431 def : InstAlias<"call $addr", (JMPLri O7, MEMri:$addr), 0>;
433 // tst reg -> orcc %g0, reg, %g0
434 def : InstAlias<"tst $rs2", (ORCCrr G0, IntRegs:$rs2, G0)>;
436 // ret -> jmpl %i7+8, %g0 (aka RET 8)
437 def : InstAlias<"ret", (RET 8)>;
439 // retl -> jmpl %o7+8, %g0 (aka RETL 8)
440 def : InstAlias<"retl", (RETL 8)>;
442 // restore -> restore %g0, %g0, %g0
443 def : InstAlias<"restore", (RESTORErr G0, G0, G0)>;
445 // save -> restore %g0, %g0, %g0
446 def : InstAlias<"save", (SAVErr G0, G0, G0)>;
449 // (turns into a sequence of sethi+or, depending on the value)
450 // def : InstAlias<"set $val, $rd", (ORri IntRegs:$rd, (SETHIi (HI22 imm:$val)), (LO10 imm:$val))>;
451 def SET : AsmPseudoInst<(outs IntRegs:$rd), (ins i32imm:$val), "set $val, $rd">;
453 // setx value, tmp, rd
454 // (turns into a sequence of sethi+or+shift, depending on the value)
455 def SETX : AsmPseudoInst<(outs I64Regs:$rd),
456 (ins i64imm:$val, I64Regs:$tmp),
457 "setx $val, $tmp, $rd">,
458 Requires<[Is64Bit, HasV9]>;
460 // not rd -> xnor rd, %g0, rd
461 def : InstAlias<"not $rd", (XNORrr IntRegs:$rd, IntRegs:$rd, G0), 0>;
463 // not reg, rd -> xnor reg, %g0, rd
464 def : InstAlias<"not $rs1, $rd", (XNORrr IntRegs:$rd, IntRegs:$rs1, G0), 0>;
466 // neg rd -> sub %g0, rd, rd
467 def : InstAlias<"neg $rd", (SUBrr IntRegs:$rd, G0, IntRegs:$rd), 0>;
469 // neg reg, rd -> sub %g0, reg, rd
470 def : InstAlias<"neg $rs2, $rd", (SUBrr IntRegs:$rd, G0, IntRegs:$rs2), 0>;
472 let Predicates = [HasV9] in {
473 // cas [rs1], rs2, rd -> casa [rs1] #ASI_P, rs2, rd
474 def : InstAlias<"cas [$rs1], $rs2, $rd",
475 (CASArr IntRegs:$rd, IntRegs:$rs1, IntRegs:$rs2, 0x80)>;
477 // casl [rs1], rs2, rd -> casa [rs1] #ASI_P_L, rs2, rd
478 def : InstAlias<"casl [$rs1], $rs2, $rd",
479 (CASArr IntRegs:$rd, IntRegs:$rs1, IntRegs:$rs2, 0x88)>;
481 // casx [rs1], rs2, rd -> casxa [rs1] #ASI_P, rs2, rd
482 def : InstAlias<"casx [$rs1], $rs2, $rd",
483 (CASXArr I64Regs:$rd, I64Regs:$rs1, I64Regs:$rs2, 0x80)>;
485 // casxl [rs1], rs2, rd -> casxa [rs1] #ASI_P_L, rs2, rd
486 def : InstAlias<"casxl [$rs1], $rs2, $rd",
487 (CASXArr I64Regs:$rd, I64Regs:$rs1, I64Regs:$rs2, 0x88)>;
490 // inc rd -> add rd, 1, rd
491 def : InstAlias<"inc $rd", (ADDri IntRegs:$rd, IntRegs:$rd, 1), 0>;
493 // inc simm13, rd -> add rd, simm13, rd
494 def : InstAlias<"inc $simm13, $rd", (ADDri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
496 // inccc rd -> addcc rd, 1, rd
497 def : InstAlias<"inccc $rd", (ADDCCri IntRegs:$rd, IntRegs:$rd, 1), 0>;
499 // inccc simm13, rd -> addcc rd, simm13, rd
500 def : InstAlias<"inccc $simm13, $rd", (ADDCCri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
502 // dec rd -> sub rd, 1, rd
503 def : InstAlias<"dec $rd", (SUBri IntRegs:$rd, IntRegs:$rd, 1), 0>;
505 // dec simm13, rd -> sub rd, simm13, rd
506 def : InstAlias<"dec $simm13, $rd", (SUBri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
508 // deccc rd -> subcc rd, 1, rd
509 def : InstAlias<"deccc $rd", (SUBCCri IntRegs:$rd, IntRegs:$rd, 1), 0>;
511 // deccc simm13, rd -> subcc rd, simm13, rd
512 def : InstAlias<"deccc $simm13, $rd", (SUBCCri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
514 // btst reg_or_imm, reg -> andcc reg,reg_or_imm,%g0
515 def : InstAlias<"btst $rs2, $rs1", (ANDCCrr G0, IntRegs:$rs1, IntRegs:$rs2), 0>;
516 def : InstAlias<"btst $simm13, $rs1", (ANDCCri G0, IntRegs:$rs1, simm13Op:$simm13), 0>;
518 // bset reg_or_imm, rd -> or rd,reg_or_imm,rd
519 def : InstAlias<"bset $rs2, $rd", (ORrr IntRegs:$rd, IntRegs:$rd, IntRegs:$rs2), 0>;
520 def : InstAlias<"bset $simm13, $rd", (ORri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
522 // bclr reg_or_imm, rd -> andn rd,reg_or_imm,rd
523 def : InstAlias<"bclr $rs2, $rd", (ANDNrr IntRegs:$rd, IntRegs:$rd, IntRegs:$rs2), 0>;
524 def : InstAlias<"bclr $simm13, $rd", (ANDNri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
526 // btog reg_or_imm, rd -> xor rd,reg_or_imm,rd
527 def : InstAlias<"btog $rs2, $rd", (XORrr IntRegs:$rd, IntRegs:$rd, IntRegs:$rs2), 0>;
528 def : InstAlias<"btog $simm13, $rd", (XORri IntRegs:$rd, IntRegs:$rd, simm13Op:$simm13), 0>;
531 // clr rd -> or %g0, %g0, rd
532 def : InstAlias<"clr $rd", (ORrr IntRegs:$rd, G0, G0), 0>;
534 // clr{b,h,} [addr] -> st{b,h,} %g0, [addr]
535 def : InstAlias<"clrb [$addr]", (STBrr MEMrr:$addr, G0), 0>;
536 def : InstAlias<"clrb [$addr]", (STBri MEMri:$addr, G0), 0>;
537 def : InstAlias<"clrh [$addr]", (STHrr MEMrr:$addr, G0), 0>;
538 def : InstAlias<"clrh [$addr]", (STHri MEMri:$addr, G0), 0>;
539 def : InstAlias<"clr [$addr]", (STrr MEMrr:$addr, G0), 0>;
540 def : InstAlias<"clr [$addr]", (STri MEMri:$addr, G0), 0>;
543 // mov reg_or_imm, rd -> or %g0, reg_or_imm, rd
544 def : InstAlias<"mov $rs2, $rd", (ORrr IntRegs:$rd, G0, IntRegs:$rs2)>;
545 def : InstAlias<"mov $simm13, $rd", (ORri IntRegs:$rd, G0, simm13Op:$simm13)>;
547 // mov specialreg, rd -> rd specialreg, rd
548 def : InstAlias<"mov $asr, $rd", (RDASR IntRegs:$rd, ASRRegs:$asr), 0>;
549 def : InstAlias<"mov %psr, $rd", (RDPSR IntRegs:$rd), 0>;
550 def : InstAlias<"mov %wim, $rd", (RDWIM IntRegs:$rd), 0>;
551 def : InstAlias<"mov %tbr, $rd", (RDTBR IntRegs:$rd), 0>;
553 // mov reg_or_imm, specialreg -> wr %g0, reg_or_imm, specialreg
554 def : InstAlias<"mov $rs2, $asr", (WRASRrr ASRRegs:$asr, G0, IntRegs:$rs2), 0>;
555 def : InstAlias<"mov $simm13, $asr", (WRASRri ASRRegs:$asr, G0, simm13Op:$simm13), 0>;
556 def : InstAlias<"mov $rs2, %psr", (WRPSRrr G0, IntRegs:$rs2), 0>;
557 def : InstAlias<"mov $simm13, %psr", (WRPSRri G0, simm13Op:$simm13), 0>;
558 def : InstAlias<"mov $rs2, %wim", (WRWIMrr G0, IntRegs:$rs2), 0>;
559 def : InstAlias<"mov $simm13, %wim", (WRWIMri G0, simm13Op:$simm13), 0>;
560 def : InstAlias<"mov $rs2, %tbr", (WRTBRrr G0, IntRegs:$rs2), 0>;
561 def : InstAlias<"mov $simm13, %tbr", (WRTBRri G0, simm13Op:$simm13), 0>;
563 // End of Section A.3
566 // Nonstandard GNU extensions.
567 let EmitPriority = 0 in {
568 // or imm, reg, rd -> or reg, imm, rd
569 def : InstAlias<"or $simm13, $rs1, $rd", (ORri IntRegs:$rd, IntRegs:$rs1, simm13Op:$simm13)>;
571 // addc/addx imm, reg, rd -> addc/addx reg, imm, rd
572 def : InstAlias<"addx $simm13, $rs1, $rd", (ADDCri IntRegs:$rd, IntRegs:$rs1, simm13Op:$simm13)>;
575 // wr reg_or_imm, specialreg -> wr %g0, reg_or_imm, specialreg
576 // (aka: omit the first arg when it's g0. This is not in the manual, but is
577 // supported by gnu and solaris as)
578 def : InstAlias<"wr $rs2, $asr", (WRASRrr ASRRegs:$asr, G0, IntRegs:$rs2), 0>;
579 def : InstAlias<"wr $simm13, $asr", (WRASRri ASRRegs:$asr, G0, simm13Op:$simm13), 0>;
580 def : InstAlias<"wr $rs2, %psr", (WRPSRrr G0, IntRegs:$rs2), 0>;
581 def : InstAlias<"wr $simm13, %psr", (WRPSRri G0, simm13Op:$simm13), 0>;
582 def : InstAlias<"wr $rs2, %wim", (WRWIMrr G0, IntRegs:$rs2), 0>;
583 def : InstAlias<"wr $simm13, %wim", (WRWIMri G0, simm13Op:$simm13), 0>;
584 def : InstAlias<"wr $rs2, %tbr", (WRTBRrr G0, IntRegs:$rs2), 0>;
585 def : InstAlias<"wr $simm13, %tbr", (WRTBRri G0, simm13Op:$simm13), 0>;
587 def : InstAlias<"pwr $rs2, %psr", (PWRPSRrr G0, IntRegs:$rs2), 0>;
588 def : InstAlias<"pwr $simm13, %psr", (PWRPSRri G0, simm13Op:$simm13), 0>;
590 // wrpr %reg, %rd -> wrpr %reg, %g0, %rd
591 // wrpr imm, %rd -> wrpr %g0, imm, %rd
592 // Nonstandard GNU extensions.
593 let Predicates = [HasV9] in {
594 def : InstAlias<"wrpr $rs1, $rd", (WRPRrr PRRegs:$rd, IntRegs:$rs1, G0), 0>;
595 def : InstAlias<"wrpr $simm13, $rd", (WRPRri PRRegs:$rd, G0, simm13Op:$simm13), 0>;
598 // flush -> flush %g0
599 def : InstAlias<"flush", (FLUSH), 0>;
602 def : InstAlias<"unimp", (UNIMP 0), 0>;
604 // Not in spec, but we follow Solaris behavior of having `illtrap`
605 // interchangeable with `unimp` all the time.
606 def : MnemonicAlias<"illtrap", "unimp">;
608 def : MnemonicAlias<"iflush", "flush">;
610 def : MnemonicAlias<"stub", "stb">;
611 def : MnemonicAlias<"stsb", "stb">;
613 def : MnemonicAlias<"stuba", "stba">;
614 def : MnemonicAlias<"stsba", "stba">;
616 def : MnemonicAlias<"stuh", "sth">;
617 def : MnemonicAlias<"stsh", "sth">;
619 def : MnemonicAlias<"stuha", "stha">;
620 def : MnemonicAlias<"stsha", "stha">;
622 def : MnemonicAlias<"stw", "st">, Requires<[HasV9]>;
623 def : MnemonicAlias<"stuw", "st">, Requires<[HasV9]>;
624 def : MnemonicAlias<"stsw", "st">, Requires<[HasV9]>;
626 def : MnemonicAlias<"stwa", "sta">, Requires<[HasV9]>;
627 def : MnemonicAlias<"stuwa", "sta">, Requires<[HasV9]>;
628 def : MnemonicAlias<"stswa", "sta">, Requires<[HasV9]>;
630 def : MnemonicAlias<"lduw", "ld">, Requires<[HasV9]>;
631 def : MnemonicAlias<"lduwa", "lda">, Requires<[HasV9]>;
633 def : MnemonicAlias<"return", "rett">, Requires<[HasV9]>;
635 def : MnemonicAlias<"addc", "addx">, Requires<[HasV9]>;
636 def : MnemonicAlias<"addccc", "addxcc">, Requires<[HasV9]>;
638 def : MnemonicAlias<"subc", "subx">, Requires<[HasV9]>;
639 def : MnemonicAlias<"subccc", "subxcc">, Requires<[HasV9]>;
642 def : InstAlias<"fcmps $rs1, $rs2", (V9FCMPS FCC0, FPRegs:$rs1, FPRegs:$rs2)>;
643 def : InstAlias<"fcmpd $rs1, $rs2", (V9FCMPD FCC0, DFPRegs:$rs1, DFPRegs:$rs2)>;
644 def : InstAlias<"fcmpq $rs1, $rs2", (V9FCMPQ FCC0, QFPRegs:$rs1, QFPRegs:$rs2)>,
645 Requires<[HasHardQuad]>;
647 def : InstAlias<"fcmpes $rs1, $rs2", (V9FCMPES FCC0, FPRegs:$rs1, FPRegs:$rs2)>;
648 def : InstAlias<"fcmped $rs1, $rs2", (V9FCMPED FCC0, DFPRegs:$rs1,
650 def : InstAlias<"fcmpeq $rs1, $rs2", (V9FCMPEQ FCC0, QFPRegs:$rs1,
652 Requires<[HasHardQuad]>;
654 // signx rd -> sra rd, %g0, rd
655 def : InstAlias<"signx $rd", (SRArr IntRegs:$rd, IntRegs:$rd, G0), 0>, Requires<[HasV9]>;
657 // signx reg, rd -> sra reg, %g0, rd
658 def : InstAlias<"signx $rs1, $rd", (SRArr IntRegs:$rd, IntRegs:$rs1, G0), 0>, Requires<[HasV9]>;
661 def : InstAlias<"sir", (SIR 0), 0>;