1 //===-- SparcInstrAliases.td - Instruction Aliases for Sparc Target -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains instruction aliases for Sparc.
11 //===----------------------------------------------------------------------===//
13 // Instruction aliases for conditional moves.
15 // mov<cond> <ccreg> rs2, rd
16 multiclass intcond_mov_alias<string cond, int condVal, string ccreg,
17 Instruction movrr, Instruction movri,
18 Instruction fmovs, Instruction fmovd> {
20 // mov<cond> (%icc|%xcc), rs2, rd
21 def : InstAlias<!strconcat(!strconcat(!strconcat("mov", cond), ccreg),
23 (movrr IntRegs:$rd, IntRegs:$rs2, condVal)>;
25 // mov<cond> (%icc|%xcc), simm11, rd
26 def : InstAlias<!strconcat(!strconcat(!strconcat("mov", cond), ccreg),
28 (movri IntRegs:$rd, i32imm:$simm11, condVal)>;
30 // fmovs<cond> (%icc|%xcc), $rs2, $rd
31 def : InstAlias<!strconcat(!strconcat(!strconcat("fmovs", cond), ccreg),
33 (fmovs FPRegs:$rd, FPRegs:$rs2, condVal)>;
35 // fmovd<cond> (%icc|%xcc), $rs2, $rd
36 def : InstAlias<!strconcat(!strconcat(!strconcat("fmovd", cond), ccreg),
38 (fmovd DFPRegs:$rd, DFPRegs:$rs2, condVal)>;
41 // mov<cond> <ccreg> rs2, rd
42 multiclass fpcond_mov_alias<string cond, int condVal,
43 Instruction movrr, Instruction movri,
44 Instruction fmovs, Instruction fmovd> {
46 // mov<cond> %fcc[0-3], rs2, rd
47 def : InstAlias<!strconcat(!strconcat("mov", cond), " $cc, $rs2, $rd"),
48 (movrr IntRegs:$rd, FCCRegs:$cc, IntRegs:$rs2, condVal)>;
50 // mov<cond> %fcc[0-3], simm11, rd
51 def : InstAlias<!strconcat(!strconcat("mov", cond), " $cc, $simm11, $rd"),
52 (movri IntRegs:$rd, FCCRegs:$cc, i32imm:$simm11, condVal)>;
54 // fmovs<cond> %fcc[0-3], $rs2, $rd
55 def : InstAlias<!strconcat(!strconcat("fmovs", cond), " $cc, $rs2, $rd"),
56 (fmovs FPRegs:$rd, FCCRegs:$cc, FPRegs:$rs2, condVal)>;
58 // fmovd<cond> %fcc[0-3], $rs2, $rd
59 def : InstAlias<!strconcat(!strconcat("fmovd", cond), " $cc, $rs2, $rd"),
60 (fmovd DFPRegs:$rd, FCCRegs:$cc, DFPRegs:$rs2, condVal)>;
63 // Instruction aliases for integer conditional branches and moves.
64 multiclass int_cond_alias<string cond, int condVal> {
67 def : InstAlias<!strconcat(!strconcat("b", cond), " $imm"),
68 (BCOND brtarget:$imm, condVal)>;
71 def : InstAlias<!strconcat(!strconcat("b", cond), ",a $imm"),
72 (BCONDA brtarget:$imm, condVal)>;
75 def : InstAlias<!strconcat(!strconcat("b", cond), " %icc, $imm"),
76 (BPICC brtarget:$imm, condVal)>, Requires<[HasV9]>;
78 // b<cond>,pt %icc, $imm
79 def : InstAlias<!strconcat(!strconcat("b", cond), ",pt %icc, $imm"),
80 (BPICC brtarget:$imm, condVal)>, Requires<[HasV9]>;
82 // b<cond>,a %icc, $imm
83 def : InstAlias<!strconcat(!strconcat("b", cond), ",a %icc, $imm"),
84 (BPICCA brtarget:$imm, condVal)>, Requires<[HasV9]>;
86 // b<cond>,a,pt %icc, $imm
87 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pt %icc, $imm"),
88 (BPICCA brtarget:$imm, condVal)>, Requires<[HasV9]>;
90 // b<cond>,pn %icc, $imm
91 def : InstAlias<!strconcat(!strconcat("b", cond), ",pn %icc, $imm"),
92 (BPICCNT brtarget:$imm, condVal)>, Requires<[HasV9]>;
94 // b<cond>,a,pn %icc, $imm
95 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pn %icc, $imm"),
96 (BPICCANT brtarget:$imm, condVal)>, Requires<[HasV9]>;
99 def : InstAlias<!strconcat(!strconcat("b", cond), " %xcc, $imm"),
100 (BPXCC brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
102 // b<cond>,pt %xcc, $imm
103 def : InstAlias<!strconcat(!strconcat("b", cond), ",pt %xcc, $imm"),
104 (BPXCC brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
106 // b<cond>,a %xcc, $imm
107 def : InstAlias<!strconcat(!strconcat("b", cond), ",a %xcc, $imm"),
108 (BPXCCA brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
110 // b<cond>,a,pt %xcc, $imm
111 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pt %xcc, $imm"),
112 (BPXCCA brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
114 // b<cond>,pn %xcc, $imm
115 def : InstAlias<!strconcat(!strconcat("b", cond), ",pn %xcc, $imm"),
116 (BPXCCNT brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
118 // b<cond>,a,pn %xcc, $imm
119 def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pn %xcc, $imm"),
120 (BPXCCANT brtarget:$imm, condVal)>, Requires<[Is64Bit]>;
123 defm : intcond_mov_alias<cond, condVal, " %icc",
125 FMOVS_ICC, FMOVD_ICC>, Requires<[HasV9]>;
127 defm : intcond_mov_alias<cond, condVal, " %xcc",
129 FMOVS_XCC, FMOVD_XCC>, Requires<[Is64Bit]>;
131 // fmovq<cond> (%icc|%xcc), $rs2, $rd
132 def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %icc, $rs2, $rd"),
133 (FMOVQ_ICC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
134 Requires<[HasV9, HasHardQuad]>;
135 def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %xcc, $rs2, $rd"),
136 (FMOVQ_XCC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
137 Requires<[Is64Bit, HasHardQuad]>;
142 // Instruction aliases for floating point conditional branches and moves.
143 multiclass fp_cond_alias<string cond, int condVal> {
146 def : InstAlias<!strconcat(!strconcat("fb", cond), " $imm"),
147 (FBCOND brtarget:$imm, condVal), 0>;
150 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a $imm"),
151 (FBCONDA brtarget:$imm, condVal), 0>;
153 // fb<cond> %fcc0, $imm
154 def : InstAlias<!strconcat(!strconcat("fb", cond), " $cc, $imm"),
155 (BPFCC brtarget:$imm, condVal, FCCRegs:$cc)>,
158 // fb<cond>,pt %fcc0, $imm
159 def : InstAlias<!strconcat(!strconcat("fb", cond), ",pt $cc, $imm"),
160 (BPFCC brtarget:$imm, condVal, FCCRegs:$cc)>,
163 // fb<cond>,a %fcc0, $imm
164 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a $cc, $imm"),
165 (BPFCCA brtarget:$imm, condVal, FCCRegs:$cc)>,
168 // fb<cond>,a,pt %fcc0, $imm
169 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a,pt $cc, $imm"),
170 (BPFCCA brtarget:$imm, condVal, FCCRegs:$cc)>,
173 // fb<cond>,pn %fcc0, $imm
174 def : InstAlias<!strconcat(!strconcat("fb", cond), ",pn $cc, $imm"),
175 (BPFCCNT brtarget:$imm, condVal, FCCRegs:$cc)>,
178 // fb<cond>,a,pn %fcc0, $imm
179 def : InstAlias<!strconcat(!strconcat("fb", cond), ",a,pn $cc, $imm"),
180 (BPFCCANT brtarget:$imm, condVal, FCCRegs:$cc)>, Requires<[HasV9]>;
182 defm : fpcond_mov_alias<cond, condVal,
183 V9MOVFCCrr, V9MOVFCCri,
184 V9FMOVS_FCC, V9FMOVD_FCC>, Requires<[HasV9]>;
186 // fmovq<cond> %fcc0, $rs2, $rd
187 def : InstAlias<!strconcat(!strconcat("fmovq", cond), " $cc, $rs2, $rd"),
188 (V9FMOVQ_FCC QFPRegs:$rd, FCCRegs:$cc, QFPRegs:$rs2,
190 Requires<[HasV9, HasHardQuad]>;
193 defm : int_cond_alias<"a", 0b1000>;
194 defm : int_cond_alias<"n", 0b0000>;
195 defm : int_cond_alias<"ne", 0b1001>;
196 defm : int_cond_alias<"e", 0b0001>;
197 defm : int_cond_alias<"g", 0b1010>;
198 defm : int_cond_alias<"le", 0b0010>;
199 defm : int_cond_alias<"ge", 0b1011>;
200 defm : int_cond_alias<"l", 0b0011>;
201 defm : int_cond_alias<"gu", 0b1100>;
202 defm : int_cond_alias<"leu", 0b0100>;
203 defm : int_cond_alias<"cc", 0b1101>;
204 defm : int_cond_alias<"cs", 0b0101>;
205 defm : int_cond_alias<"pos", 0b1110>;
206 defm : int_cond_alias<"neg", 0b0110>;
207 defm : int_cond_alias<"vc", 0b1111>;
208 defm : int_cond_alias<"vs", 0b0111>;
210 defm : fp_cond_alias<"a", 0b0000>;
211 defm : fp_cond_alias<"n", 0b1000>;
212 defm : fp_cond_alias<"u", 0b0111>;
213 defm : fp_cond_alias<"g", 0b0110>;
214 defm : fp_cond_alias<"ug", 0b0101>;
215 defm : fp_cond_alias<"l", 0b0100>;
216 defm : fp_cond_alias<"ul", 0b0011>;
217 defm : fp_cond_alias<"lg", 0b0010>;
218 defm : fp_cond_alias<"ne", 0b0001>;
219 defm : fp_cond_alias<"e", 0b1001>;
220 defm : fp_cond_alias<"ue", 0b1010>;
221 defm : fp_cond_alias<"ge", 0b1011>;
222 defm : fp_cond_alias<"uge", 0b1100>;
223 defm : fp_cond_alias<"le", 0b1101>;
224 defm : fp_cond_alias<"ule", 0b1110>;
225 defm : fp_cond_alias<"o", 0b1111>;
228 // Instruction aliases for JMPL.
230 // jmp addr -> jmpl addr, %g0
231 def : InstAlias<"jmp $addr", (JMPLrr G0, MEMrr:$addr)>;
232 def : InstAlias<"jmp $addr", (JMPLri G0, MEMri:$addr)>;
234 // call addr -> jmpl addr, %o7
235 def : InstAlias<"call $addr", (JMPLrr O7, MEMrr:$addr)>;
236 def : InstAlias<"call $addr", (JMPLri O7, MEMri:$addr)>;
239 def : InstAlias<"retl", (RETL 8)>;
242 def : InstAlias<"ret", (RET 8)>;
244 // mov reg, rd -> or %g0, reg, rd
245 def : InstAlias<"mov $rs2, $rd", (ORrr IntRegs:$rd, G0, IntRegs:$rs2)>;
247 // mov simm13, rd -> or %g0, simm13, rd
248 def : InstAlias<"mov $simm13, $rd", (ORri IntRegs:$rd, G0, i32imm:$simm13)>;
250 // restore -> restore %g0, %g0, %g0
251 def : InstAlias<"restore", (RESTORErr G0, G0, G0)>;
253 def : MnemonicAlias<"addc", "addx">, Requires<[HasV9]>;
254 def : MnemonicAlias<"addccc", "addxcc">, Requires<[HasV9]>;
256 def : MnemonicAlias<"subc", "subx">, Requires<[HasV9]>;
257 def : MnemonicAlias<"subccc", "subxcc">, Requires<[HasV9]>;
260 def : InstAlias<"fcmps $rs1, $rs2", (V9FCMPS FCC0, FPRegs:$rs1, FPRegs:$rs2)>;
261 def : InstAlias<"fcmpd $rs1, $rs2", (V9FCMPD FCC0, DFPRegs:$rs1, DFPRegs:$rs2)>;
262 def : InstAlias<"fcmpq $rs1, $rs2", (V9FCMPQ FCC0, QFPRegs:$rs1, QFPRegs:$rs2)>,
263 Requires<[HasHardQuad]>;