summaryrefslogtreecommitdiff
path: root/lib/Target/Sparc/SparcInstrAliases.td
blob: 93a6c24a0838b415f3680bf387915c3d46bc087e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
//===-- SparcInstrAliases.td - Instruction Aliases for Sparc Target -------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains instruction aliases for Sparc.
//===----------------------------------------------------------------------===//

// Instruction aliases for conditional moves.

// mov<cond> <ccreg> rs2, rd
multiclass cond_mov_alias<string cond, int condVal, string ccreg,
                          Instruction movrr, Instruction movri,
                          Instruction fmovs, Instruction fmovd> {

  // mov<cond> (%icc|%xcc|%fcc0), rs2, rd
  def : InstAlias<!strconcat(!strconcat(!strconcat("mov", cond), ccreg),
                             ", $rs2, $rd"),
                  (movrr IntRegs:$rd, IntRegs:$rs2, condVal)>;

  // mov<cond> (%icc|%xcc|%fcc0), simm11, rd
  def : InstAlias<!strconcat(!strconcat(!strconcat("mov", cond), ccreg),
                             ", $simm11, $rd"),
                  (movri IntRegs:$rd, i32imm:$simm11, condVal)>;

  // fmovs<cond> (%icc|%xcc|%fcc0), $rs2, $rd
  def : InstAlias<!strconcat(!strconcat(!strconcat("fmovs", cond), ccreg),
                             ", $rs2, $rd"),
                  (fmovs FPRegs:$rd, FPRegs:$rs2, condVal)>;

  // fmovd<cond> (%icc|%xcc|%fcc0), $rs2, $rd
  def : InstAlias<!strconcat(!strconcat(!strconcat("fmovd", cond), ccreg),
                             ", $rs2, $rd"),
                  (fmovd DFPRegs:$rd, DFPRegs:$rs2, condVal)>;
}


// Instruction aliases for integer conditional branches and moves.
multiclass int_cond_alias<string cond, int condVal> {

  // b<cond> $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), " $imm"),
                  (BCOND brtarget:$imm, condVal)>;

  // b<cond>,a $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a $imm"),
                  (BCONDA brtarget:$imm, condVal)>;

  // b<cond> %icc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), " %icc, $imm"),
                  (BPICC brtarget:$imm, condVal)>, Requires<[HasV9]>;

  // b<cond>,pt %icc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",pt %icc, $imm"),
                  (BPICC brtarget:$imm, condVal)>, Requires<[HasV9]>;

  // b<cond>,a %icc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a %icc, $imm"),
                  (BPICCA brtarget:$imm, condVal)>, Requires<[HasV9]>;

  // b<cond>,a,pt %icc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pt %icc, $imm"),
                  (BPICCA brtarget:$imm, condVal)>, Requires<[HasV9]>;

  // b<cond>,pn %icc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",pn %icc, $imm"),
                  (BPICCNT brtarget:$imm, condVal)>, Requires<[HasV9]>;

  // b<cond>,a,pn %icc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pn %icc, $imm"),
                  (BPICCANT brtarget:$imm, condVal)>, Requires<[HasV9]>;

  // b<cond> %xcc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), " %xcc, $imm"),
                  (BPXCC brtarget:$imm, condVal)>, Requires<[Is64Bit]>;

  // b<cond>,pt %xcc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",pt %xcc, $imm"),
                  (BPXCC brtarget:$imm, condVal)>, Requires<[Is64Bit]>;

  // b<cond>,a %xcc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a %xcc, $imm"),
                  (BPXCCA brtarget:$imm, condVal)>, Requires<[Is64Bit]>;

  // b<cond>,a,pt %xcc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pt %xcc, $imm"),
                  (BPXCCA brtarget:$imm, condVal)>, Requires<[Is64Bit]>;

  // b<cond>,pn %xcc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",pn %xcc, $imm"),
                  (BPXCCNT brtarget:$imm, condVal)>, Requires<[Is64Bit]>;

  // b<cond>,a,pn %xcc, $imm
  def : InstAlias<!strconcat(!strconcat("b", cond), ",a,pn %xcc, $imm"),
                  (BPXCCANT brtarget:$imm, condVal)>, Requires<[Is64Bit]>;


  defm : cond_mov_alias<cond, condVal, " %icc",
                            MOVICCrr, MOVICCri,
                            FMOVS_ICC, FMOVD_ICC>, Requires<[HasV9]>;

  defm : cond_mov_alias<cond, condVal, " %xcc",
                            MOVXCCrr, MOVXCCri,
                            FMOVS_XCC, FMOVD_XCC>, Requires<[Is64Bit]>;

  // fmovq<cond> (%icc|%xcc), $rs2, $rd
  def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %icc, $rs2, $rd"),
                  (FMOVQ_ICC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
                  Requires<[HasV9, HasHardQuad]>;
  def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %xcc, $rs2, $rd"),
                  (FMOVQ_XCC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
                  Requires<[Is64Bit, HasHardQuad]>;

}


// Instruction aliases for floating point conditional branches and moves.
multiclass fp_cond_alias<string cond, int condVal> {

  // fb<cond> $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), " $imm"),
                  (FBCOND brtarget:$imm, condVal), 0>;

  // fb<cond>,a $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), ",a $imm"),
                  (FBCONDA brtarget:$imm, condVal), 0>;

  // fb<cond> %fcc0, $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), " %fcc0, $imm"),
                  (BPFCC brtarget:$imm, condVal, FCC0)>, Requires<[HasV9]>;

  // fb<cond>,pt %fcc0, $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), ",pt %fcc0, $imm"),
                  (BPFCC brtarget:$imm, condVal, FCC0)>, Requires<[HasV9]>;

  // fb<cond>,a %fcc0, $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), ",a %fcc0, $imm"),
                  (BPFCCA brtarget:$imm, condVal, FCC0)>, Requires<[HasV9]>;

  // fb<cond>,a,pt %fcc0, $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), ",a,pt %fcc0, $imm"),
                  (BPFCCA brtarget:$imm, condVal, FCC0)>, Requires<[HasV9]>;

  // fb<cond>,pn %fcc0, $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), ",pn %fcc0, $imm"),
                  (BPFCCNT brtarget:$imm, condVal, FCC0)>, Requires<[HasV9]>;

  // fb<cond>,a,pn %fcc0, $imm
  def : InstAlias<!strconcat(!strconcat("fb", cond), ",a,pn %fcc0, $imm"),
                  (BPFCCANT brtarget:$imm, condVal, FCC0)>, Requires<[HasV9]>;

  defm : cond_mov_alias<cond, condVal, " %fcc0",
                        MOVFCCrr, MOVFCCri,
                        FMOVS_FCC, FMOVD_FCC>, Requires<[HasV9]>;

  // fmovq<cond> %fcc0, $rs2, $rd
  def : InstAlias<!strconcat(!strconcat("fmovq", cond), " %fcc0, $rs2, $rd"),
                  (FMOVQ_ICC QFPRegs:$rd, QFPRegs:$rs2, condVal)>,
                  Requires<[HasV9, HasHardQuad]>;
}

defm : int_cond_alias<"a",    0b1000>;
defm : int_cond_alias<"n",    0b0000>;
defm : int_cond_alias<"ne",   0b1001>;
defm : int_cond_alias<"e",    0b0001>;
defm : int_cond_alias<"g",    0b1010>;
defm : int_cond_alias<"le",   0b0010>;
defm : int_cond_alias<"ge",   0b1011>;
defm : int_cond_alias<"l",    0b0011>;
defm : int_cond_alias<"gu",   0b1100>;
defm : int_cond_alias<"leu",  0b0100>;
defm : int_cond_alias<"cc",   0b1101>;
defm : int_cond_alias<"cs",   0b0101>;
defm : int_cond_alias<"pos",  0b1110>;
defm : int_cond_alias<"neg",  0b0110>;
defm : int_cond_alias<"vc",   0b1111>;
defm : int_cond_alias<"vs",   0b0111>;

defm : fp_cond_alias<"a",     0b0000>;
defm : fp_cond_alias<"n",     0b1000>;
defm : fp_cond_alias<"u",     0b0111>;
defm : fp_cond_alias<"g",     0b0110>;
defm : fp_cond_alias<"ug",    0b0101>;
defm : fp_cond_alias<"l",     0b0100>;
defm : fp_cond_alias<"ul",    0b0011>;
defm : fp_cond_alias<"lg",    0b0010>;
defm : fp_cond_alias<"ne",    0b0001>;
defm : fp_cond_alias<"e",     0b1001>;
defm : fp_cond_alias<"ue",    0b1010>;
defm : fp_cond_alias<"ge",    0b1011>;
defm : fp_cond_alias<"uge",   0b1100>;
defm : fp_cond_alias<"le",    0b1101>;
defm : fp_cond_alias<"ule",   0b1110>;
defm : fp_cond_alias<"o",     0b1111>;


// Instruction aliases for JMPL.

// jmp addr -> jmpl addr, %g0
def : InstAlias<"jmp $addr", (JMPLrr G0, MEMrr:$addr)>;
def : InstAlias<"jmp $addr", (JMPLri G0, MEMri:$addr)>;

// call addr -> jmpl addr, %o7
def : InstAlias<"call $addr", (JMPLrr O7, MEMrr:$addr)>;
def : InstAlias<"call $addr", (JMPLri O7, MEMri:$addr)>;

// retl -> RETL 8
def : InstAlias<"retl", (RETL 8)>;

// ret -> RET 8
def : InstAlias<"ret", (RET 8)>;

// mov reg, rd -> or %g0, reg, rd
def : InstAlias<"mov $rs2, $rd", (ORrr IntRegs:$rd, G0, IntRegs:$rs2)>;

// mov simm13, rd -> or %g0, simm13, rd
def : InstAlias<"mov $simm13, $rd", (ORri IntRegs:$rd, G0, i32imm:$simm13)>;

// restore -> restore %g0, %g0, %g0
def : InstAlias<"restore", (RESTORErr G0, G0, G0)>;

def : MnemonicAlias<"addc", "addx">, Requires<[HasV9]>;
def : MnemonicAlias<"addccc", "addxcc">, Requires<[HasV9]>;

def : MnemonicAlias<"subc", "subx">, Requires<[HasV9]>;
def : MnemonicAlias<"subccc", "subxcc">, Requires<[HasV9]>;


def : InstAlias<"fcmps $rs1, $rs2", (V9FCMPS FCC0, FPRegs:$rs1, FPRegs:$rs2)>;
def : InstAlias<"fcmpd $rs1, $rs2", (V9FCMPD FCC0, DFPRegs:$rs1, DFPRegs:$rs2)>;
def : InstAlias<"fcmpq $rs1, $rs2", (V9FCMPQ FCC0, QFPRegs:$rs1, QFPRegs:$rs2)>,
                Requires<[HasHardQuad]>;