root / target-sparc / translate.c @ e00c1e71
History | View | Annotate | Download (183.6 kB)
1 |
/*
|
---|---|
2 |
SPARC translation
|
3 |
|
4 |
Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
|
5 |
Copyright (C) 2003-2005 Fabrice Bellard
|
6 |
|
7 |
This library is free software; you can redistribute it and/or
|
8 |
modify it under the terms of the GNU Lesser General Public
|
9 |
License as published by the Free Software Foundation; either
|
10 |
version 2 of the License, or (at your option) any later version.
|
11 |
|
12 |
This library is distributed in the hope that it will be useful,
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 |
Lesser General Public License for more details.
|
16 |
|
17 |
You should have received a copy of the GNU Lesser General Public
|
18 |
License along with this library; if not, write to the Free Software
|
19 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20 |
*/
|
21 |
|
22 |
#include <stdarg.h> |
23 |
#include <stdlib.h> |
24 |
#include <stdio.h> |
25 |
#include <string.h> |
26 |
#include <inttypes.h> |
27 |
|
28 |
#include "cpu.h" |
29 |
#include "exec-all.h" |
30 |
#include "disas.h" |
31 |
#include "helper.h" |
32 |
#include "tcg-op.h" |
33 |
|
34 |
#define DEBUG_DISAS
|
35 |
|
36 |
#define DYNAMIC_PC 1 /* dynamic pc value */ |
37 |
#define JUMP_PC 2 /* dynamic pc value which takes only two values |
38 |
according to jump_pc[T2] */
|
39 |
|
40 |
/* global register indexes */
|
41 |
static TCGv cpu_env, cpu_T[2], cpu_regwptr; |
42 |
static TCGv cpu_cc_src, cpu_cc_src2, cpu_cc_dst;
|
43 |
static TCGv cpu_psr, cpu_fsr, cpu_pc, cpu_npc, cpu_gregs[8]; |
44 |
static TCGv cpu_cond, cpu_src1, cpu_src2, cpu_dst, cpu_addr, cpu_val;
|
45 |
#ifdef TARGET_SPARC64
|
46 |
static TCGv cpu_xcc;
|
47 |
#endif
|
48 |
/* local register indexes (only used inside old micro ops) */
|
49 |
static TCGv cpu_tmp0, cpu_tmp32, cpu_tmp64;
|
50 |
|
51 |
typedef struct DisasContext { |
52 |
target_ulong pc; /* current Program Counter: integer or DYNAMIC_PC */
|
53 |
target_ulong npc; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
|
54 |
target_ulong jump_pc[2]; /* used when JUMP_PC pc value is used */ |
55 |
int is_br;
|
56 |
int mem_idx;
|
57 |
int fpu_enabled;
|
58 |
struct TranslationBlock *tb;
|
59 |
uint32_t features; |
60 |
} DisasContext; |
61 |
|
62 |
// This function uses non-native bit order
|
63 |
#define GET_FIELD(X, FROM, TO) \
|
64 |
((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1)) |
65 |
|
66 |
// This function uses the order in the manuals, i.e. bit 0 is 2^0
|
67 |
#define GET_FIELD_SP(X, FROM, TO) \
|
68 |
GET_FIELD(X, 31 - (TO), 31 - (FROM)) |
69 |
|
70 |
#define GET_FIELDs(x,a,b) sign_extend (GET_FIELD(x,a,b), (b) - (a) + 1) |
71 |
#define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1)) |
72 |
|
73 |
#ifdef TARGET_SPARC64
|
74 |
#define FFPREG(r) (r)
|
75 |
#define DFPREG(r) (((r & 1) << 5) | (r & 0x1e)) |
76 |
#define QFPREG(r) (((r & 1) << 5) | (r & 0x1c)) |
77 |
#else
|
78 |
#define FFPREG(r) (r)
|
79 |
#define DFPREG(r) (r & 0x1e) |
80 |
#define QFPREG(r) (r & 0x1c) |
81 |
#endif
|
82 |
|
83 |
static int sign_extend(int x, int len) |
84 |
{ |
85 |
len = 32 - len;
|
86 |
return (x << len) >> len;
|
87 |
} |
88 |
|
89 |
#define IS_IMM (insn & (1<<13)) |
90 |
|
91 |
/* floating point registers moves */
|
92 |
static void gen_op_load_fpr_FT0(unsigned int src) |
93 |
{ |
94 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src])); |
95 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ft0)); |
96 |
} |
97 |
|
98 |
static void gen_op_load_fpr_FT1(unsigned int src) |
99 |
{ |
100 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src])); |
101 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ft1)); |
102 |
} |
103 |
|
104 |
static void gen_op_store_FT0_fpr(unsigned int dst) |
105 |
{ |
106 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, ft0)); |
107 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst])); |
108 |
} |
109 |
|
110 |
static void gen_op_load_fpr_DT0(unsigned int src) |
111 |
{ |
112 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src])); |
113 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + |
114 |
offsetof(CPU_DoubleU, l.upper)); |
115 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
|
116 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + |
117 |
offsetof(CPU_DoubleU, l.lower)); |
118 |
} |
119 |
|
120 |
static void gen_op_load_fpr_DT1(unsigned int src) |
121 |
{ |
122 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src])); |
123 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt1) + |
124 |
offsetof(CPU_DoubleU, l.upper)); |
125 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
|
126 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt1) + |
127 |
offsetof(CPU_DoubleU, l.lower)); |
128 |
} |
129 |
|
130 |
static void gen_op_store_DT0_fpr(unsigned int dst) |
131 |
{ |
132 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + |
133 |
offsetof(CPU_DoubleU, l.upper)); |
134 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst])); |
135 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, dt0) + |
136 |
offsetof(CPU_DoubleU, l.lower)); |
137 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 1]));
|
138 |
} |
139 |
|
140 |
static void gen_op_load_fpr_QT0(unsigned int src) |
141 |
{ |
142 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src])); |
143 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
144 |
offsetof(CPU_QuadU, l.upmost)); |
145 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
|
146 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
147 |
offsetof(CPU_QuadU, l.upper)); |
148 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 2]));
|
149 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
150 |
offsetof(CPU_QuadU, l.lower)); |
151 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 3]));
|
152 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
153 |
offsetof(CPU_QuadU, l.lowest)); |
154 |
} |
155 |
|
156 |
static void gen_op_load_fpr_QT1(unsigned int src) |
157 |
{ |
158 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src])); |
159 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + |
160 |
offsetof(CPU_QuadU, l.upmost)); |
161 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 1]));
|
162 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + |
163 |
offsetof(CPU_QuadU, l.upper)); |
164 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 2]));
|
165 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + |
166 |
offsetof(CPU_QuadU, l.lower)); |
167 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[src + 3]));
|
168 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt1) + |
169 |
offsetof(CPU_QuadU, l.lowest)); |
170 |
} |
171 |
|
172 |
static void gen_op_store_QT0_fpr(unsigned int dst) |
173 |
{ |
174 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
175 |
offsetof(CPU_QuadU, l.upmost)); |
176 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst])); |
177 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
178 |
offsetof(CPU_QuadU, l.upper)); |
179 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 1]));
|
180 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
181 |
offsetof(CPU_QuadU, l.lower)); |
182 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 2]));
|
183 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, qt0) + |
184 |
offsetof(CPU_QuadU, l.lowest)); |
185 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, fpr[dst + 3]));
|
186 |
} |
187 |
|
188 |
/* moves */
|
189 |
#ifdef CONFIG_USER_ONLY
|
190 |
#define supervisor(dc) 0 |
191 |
#ifdef TARGET_SPARC64
|
192 |
#define hypervisor(dc) 0 |
193 |
#endif
|
194 |
#else
|
195 |
#define supervisor(dc) (dc->mem_idx >= 1) |
196 |
#ifdef TARGET_SPARC64
|
197 |
#define hypervisor(dc) (dc->mem_idx == 2) |
198 |
#else
|
199 |
#endif
|
200 |
#endif
|
201 |
|
202 |
#ifdef TARGET_ABI32
|
203 |
#define ABI32_MASK(addr) tcg_gen_andi_tl(addr, addr, 0xffffffffULL); |
204 |
#else
|
205 |
#define ABI32_MASK(addr)
|
206 |
#endif
|
207 |
|
208 |
static inline void gen_movl_reg_TN(int reg, TCGv tn) |
209 |
{ |
210 |
if (reg == 0) |
211 |
tcg_gen_movi_tl(tn, 0);
|
212 |
else if (reg < 8) |
213 |
tcg_gen_mov_tl(tn, cpu_gregs[reg]); |
214 |
else {
|
215 |
tcg_gen_ld_tl(tn, cpu_regwptr, (reg - 8) * sizeof(target_ulong)); |
216 |
} |
217 |
} |
218 |
|
219 |
static inline void gen_movl_TN_reg(int reg, TCGv tn) |
220 |
{ |
221 |
if (reg == 0) |
222 |
return;
|
223 |
else if (reg < 8) |
224 |
tcg_gen_mov_tl(cpu_gregs[reg], tn); |
225 |
else {
|
226 |
tcg_gen_st_tl(tn, cpu_regwptr, (reg - 8) * sizeof(target_ulong)); |
227 |
} |
228 |
} |
229 |
|
230 |
static inline void gen_goto_tb(DisasContext *s, int tb_num, |
231 |
target_ulong pc, target_ulong npc) |
232 |
{ |
233 |
TranslationBlock *tb; |
234 |
|
235 |
tb = s->tb; |
236 |
if ((pc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) &&
|
237 |
(npc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK)) { |
238 |
/* jump to same page: we can use a direct jump */
|
239 |
tcg_gen_goto_tb(tb_num); |
240 |
tcg_gen_movi_tl(cpu_pc, pc); |
241 |
tcg_gen_movi_tl(cpu_npc, npc); |
242 |
tcg_gen_exit_tb((long)tb + tb_num);
|
243 |
} else {
|
244 |
/* jump to another page: currently not optimized */
|
245 |
tcg_gen_movi_tl(cpu_pc, pc); |
246 |
tcg_gen_movi_tl(cpu_npc, npc); |
247 |
tcg_gen_exit_tb(0);
|
248 |
} |
249 |
} |
250 |
|
251 |
// XXX suboptimal
|
252 |
static inline void gen_mov_reg_N(TCGv reg, TCGv src) |
253 |
{ |
254 |
tcg_gen_extu_i32_tl(reg, src); |
255 |
tcg_gen_shri_tl(reg, reg, PSR_NEG_SHIFT); |
256 |
tcg_gen_andi_tl(reg, reg, 0x1);
|
257 |
} |
258 |
|
259 |
static inline void gen_mov_reg_Z(TCGv reg, TCGv src) |
260 |
{ |
261 |
tcg_gen_extu_i32_tl(reg, src); |
262 |
tcg_gen_shri_tl(reg, reg, PSR_ZERO_SHIFT); |
263 |
tcg_gen_andi_tl(reg, reg, 0x1);
|
264 |
} |
265 |
|
266 |
static inline void gen_mov_reg_V(TCGv reg, TCGv src) |
267 |
{ |
268 |
tcg_gen_extu_i32_tl(reg, src); |
269 |
tcg_gen_shri_tl(reg, reg, PSR_OVF_SHIFT); |
270 |
tcg_gen_andi_tl(reg, reg, 0x1);
|
271 |
} |
272 |
|
273 |
static inline void gen_mov_reg_C(TCGv reg, TCGv src) |
274 |
{ |
275 |
tcg_gen_extu_i32_tl(reg, src); |
276 |
tcg_gen_shri_tl(reg, reg, PSR_CARRY_SHIFT); |
277 |
tcg_gen_andi_tl(reg, reg, 0x1);
|
278 |
} |
279 |
|
280 |
static inline void gen_cc_clear_icc(void) |
281 |
{ |
282 |
tcg_gen_movi_i32(cpu_psr, 0);
|
283 |
} |
284 |
|
285 |
#ifdef TARGET_SPARC64
|
286 |
static inline void gen_cc_clear_xcc(void) |
287 |
{ |
288 |
tcg_gen_movi_i32(cpu_xcc, 0);
|
289 |
} |
290 |
#endif
|
291 |
|
292 |
/* old op:
|
293 |
if (!T0)
|
294 |
env->psr |= PSR_ZERO;
|
295 |
if ((int32_t) T0 < 0)
|
296 |
env->psr |= PSR_NEG;
|
297 |
*/
|
298 |
static inline void gen_cc_NZ_icc(TCGv dst) |
299 |
{ |
300 |
TCGv r_temp; |
301 |
int l1, l2;
|
302 |
|
303 |
l1 = gen_new_label(); |
304 |
l2 = gen_new_label(); |
305 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
306 |
tcg_gen_andi_tl(r_temp, dst, 0xffffffffULL);
|
307 |
tcg_gen_brcondi_tl(TCG_COND_NE, r_temp, 0, l1);
|
308 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_ZERO); |
309 |
gen_set_label(l1); |
310 |
tcg_gen_ext_i32_tl(r_temp, dst); |
311 |
tcg_gen_brcondi_tl(TCG_COND_GE, r_temp, 0, l2);
|
312 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_NEG); |
313 |
gen_set_label(l2); |
314 |
tcg_temp_free(r_temp); |
315 |
} |
316 |
|
317 |
#ifdef TARGET_SPARC64
|
318 |
static inline void gen_cc_NZ_xcc(TCGv dst) |
319 |
{ |
320 |
int l1, l2;
|
321 |
|
322 |
l1 = gen_new_label(); |
323 |
l2 = gen_new_label(); |
324 |
tcg_gen_brcondi_tl(TCG_COND_NE, dst, 0, l1);
|
325 |
tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_ZERO); |
326 |
gen_set_label(l1); |
327 |
tcg_gen_brcondi_tl(TCG_COND_GE, dst, 0, l2);
|
328 |
tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_NEG); |
329 |
gen_set_label(l2); |
330 |
} |
331 |
#endif
|
332 |
|
333 |
/* old op:
|
334 |
if (T0 < src1)
|
335 |
env->psr |= PSR_CARRY;
|
336 |
*/
|
337 |
static inline void gen_cc_C_add_icc(TCGv dst, TCGv src1) |
338 |
{ |
339 |
TCGv r_temp; |
340 |
int l1;
|
341 |
|
342 |
l1 = gen_new_label(); |
343 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
344 |
tcg_gen_andi_tl(r_temp, dst, 0xffffffffULL);
|
345 |
tcg_gen_brcond_tl(TCG_COND_GEU, dst, src1, l1); |
346 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_CARRY); |
347 |
gen_set_label(l1); |
348 |
tcg_temp_free(r_temp); |
349 |
} |
350 |
|
351 |
#ifdef TARGET_SPARC64
|
352 |
static inline void gen_cc_C_add_xcc(TCGv dst, TCGv src1) |
353 |
{ |
354 |
int l1;
|
355 |
|
356 |
l1 = gen_new_label(); |
357 |
tcg_gen_brcond_tl(TCG_COND_GEU, dst, src1, l1); |
358 |
tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_CARRY); |
359 |
gen_set_label(l1); |
360 |
} |
361 |
#endif
|
362 |
|
363 |
/* old op:
|
364 |
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
|
365 |
env->psr |= PSR_OVF;
|
366 |
*/
|
367 |
static inline void gen_cc_V_add_icc(TCGv dst, TCGv src1, TCGv src2) |
368 |
{ |
369 |
TCGv r_temp; |
370 |
|
371 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
372 |
tcg_gen_xor_tl(r_temp, src1, src2); |
373 |
tcg_gen_xori_tl(r_temp, r_temp, -1);
|
374 |
tcg_gen_xor_tl(cpu_tmp0, src1, dst); |
375 |
tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0); |
376 |
tcg_gen_andi_tl(r_temp, r_temp, (1 << 31)); |
377 |
tcg_gen_shri_tl(r_temp, r_temp, 31 - PSR_OVF_SHIFT);
|
378 |
tcg_gen_trunc_tl_i32(cpu_tmp32, r_temp); |
379 |
tcg_temp_free(r_temp); |
380 |
tcg_gen_or_i32(cpu_psr, cpu_psr, cpu_tmp32); |
381 |
} |
382 |
|
383 |
#ifdef TARGET_SPARC64
|
384 |
static inline void gen_cc_V_add_xcc(TCGv dst, TCGv src1, TCGv src2) |
385 |
{ |
386 |
TCGv r_temp; |
387 |
|
388 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
389 |
tcg_gen_xor_tl(r_temp, src1, src2); |
390 |
tcg_gen_xori_tl(r_temp, r_temp, -1);
|
391 |
tcg_gen_xor_tl(cpu_tmp0, src1, dst); |
392 |
tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0); |
393 |
tcg_gen_andi_tl(r_temp, r_temp, (1ULL << 63)); |
394 |
tcg_gen_shri_tl(r_temp, r_temp, 63 - PSR_OVF_SHIFT);
|
395 |
tcg_gen_trunc_tl_i32(cpu_tmp32, r_temp); |
396 |
tcg_temp_free(r_temp); |
397 |
tcg_gen_or_i32(cpu_xcc, cpu_xcc, cpu_tmp32); |
398 |
} |
399 |
#endif
|
400 |
|
401 |
static inline void gen_add_tv(TCGv dst, TCGv src1, TCGv src2) |
402 |
{ |
403 |
TCGv r_temp, r_const; |
404 |
int l1;
|
405 |
|
406 |
l1 = gen_new_label(); |
407 |
|
408 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
409 |
tcg_gen_xor_tl(r_temp, src1, src2); |
410 |
tcg_gen_xori_tl(r_temp, r_temp, -1);
|
411 |
tcg_gen_xor_tl(cpu_tmp0, src1, dst); |
412 |
tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0); |
413 |
tcg_gen_andi_tl(r_temp, r_temp, (1 << 31)); |
414 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_temp, 0, l1);
|
415 |
r_const = tcg_const_i32(TT_TOVF); |
416 |
tcg_gen_helper_0_1(raise_exception, r_const); |
417 |
tcg_temp_free(r_const); |
418 |
gen_set_label(l1); |
419 |
tcg_temp_free(r_temp); |
420 |
} |
421 |
|
422 |
static inline void gen_cc_V_tag(TCGv src1, TCGv src2) |
423 |
{ |
424 |
int l1;
|
425 |
|
426 |
l1 = gen_new_label(); |
427 |
tcg_gen_or_tl(cpu_tmp0, src1, src2); |
428 |
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0x3);
|
429 |
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, l1);
|
430 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF); |
431 |
gen_set_label(l1); |
432 |
} |
433 |
|
434 |
static inline void gen_tag_tv(TCGv src1, TCGv src2) |
435 |
{ |
436 |
int l1;
|
437 |
TCGv r_const; |
438 |
|
439 |
l1 = gen_new_label(); |
440 |
tcg_gen_or_tl(cpu_tmp0, src1, src2); |
441 |
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0x3);
|
442 |
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, l1);
|
443 |
r_const = tcg_const_i32(TT_TOVF); |
444 |
tcg_gen_helper_0_1(raise_exception, r_const); |
445 |
tcg_temp_free(r_const); |
446 |
gen_set_label(l1); |
447 |
} |
448 |
|
449 |
static inline void gen_op_add_cc(TCGv dst, TCGv src1, TCGv src2) |
450 |
{ |
451 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
452 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
453 |
tcg_gen_add_tl(dst, src1, src2); |
454 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
455 |
gen_cc_clear_icc(); |
456 |
gen_cc_NZ_icc(cpu_cc_dst); |
457 |
gen_cc_C_add_icc(cpu_cc_dst, cpu_cc_src); |
458 |
gen_cc_V_add_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
459 |
#ifdef TARGET_SPARC64
|
460 |
gen_cc_clear_xcc(); |
461 |
gen_cc_NZ_xcc(cpu_cc_dst); |
462 |
gen_cc_C_add_xcc(cpu_cc_dst, cpu_cc_src); |
463 |
gen_cc_V_add_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
464 |
#endif
|
465 |
} |
466 |
|
467 |
static inline void gen_op_addx_cc(TCGv dst, TCGv src1, TCGv src2) |
468 |
{ |
469 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
470 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
471 |
gen_mov_reg_C(cpu_tmp0, cpu_psr); |
472 |
tcg_gen_add_tl(dst, src1, cpu_tmp0); |
473 |
gen_cc_clear_icc(); |
474 |
gen_cc_C_add_icc(dst, cpu_cc_src); |
475 |
#ifdef TARGET_SPARC64
|
476 |
gen_cc_clear_xcc(); |
477 |
gen_cc_C_add_xcc(dst, cpu_cc_src); |
478 |
#endif
|
479 |
tcg_gen_add_tl(dst, dst, cpu_cc_src2); |
480 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
481 |
gen_cc_NZ_icc(cpu_cc_dst); |
482 |
gen_cc_C_add_icc(cpu_cc_dst, cpu_cc_src); |
483 |
gen_cc_V_add_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
484 |
#ifdef TARGET_SPARC64
|
485 |
gen_cc_NZ_xcc(cpu_cc_dst); |
486 |
gen_cc_C_add_xcc(cpu_cc_dst, cpu_cc_src); |
487 |
gen_cc_V_add_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
488 |
#endif
|
489 |
} |
490 |
|
491 |
static inline void gen_op_tadd_cc(TCGv dst, TCGv src1, TCGv src2) |
492 |
{ |
493 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
494 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
495 |
tcg_gen_add_tl(dst, src1, src2); |
496 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
497 |
gen_cc_clear_icc(); |
498 |
gen_cc_NZ_icc(cpu_cc_dst); |
499 |
gen_cc_C_add_icc(cpu_cc_dst, cpu_cc_src); |
500 |
gen_cc_V_add_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
501 |
gen_cc_V_tag(cpu_cc_src, cpu_cc_src2); |
502 |
#ifdef TARGET_SPARC64
|
503 |
gen_cc_clear_xcc(); |
504 |
gen_cc_NZ_xcc(cpu_cc_dst); |
505 |
gen_cc_C_add_xcc(cpu_cc_dst, cpu_cc_src); |
506 |
gen_cc_V_add_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
507 |
#endif
|
508 |
} |
509 |
|
510 |
static inline void gen_op_tadd_ccTV(TCGv dst, TCGv src1, TCGv src2) |
511 |
{ |
512 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
513 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
514 |
gen_tag_tv(cpu_cc_src, cpu_cc_src2); |
515 |
tcg_gen_add_tl(dst, src1, src2); |
516 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
517 |
gen_add_tv(dst, cpu_cc_src, cpu_cc_src2); |
518 |
gen_cc_clear_icc(); |
519 |
gen_cc_NZ_icc(cpu_cc_dst); |
520 |
gen_cc_C_add_icc(cpu_cc_dst, cpu_cc_src); |
521 |
#ifdef TARGET_SPARC64
|
522 |
gen_cc_clear_xcc(); |
523 |
gen_cc_NZ_xcc(cpu_cc_dst); |
524 |
gen_cc_C_add_xcc(cpu_cc_dst, cpu_cc_src); |
525 |
gen_cc_V_add_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
526 |
#endif
|
527 |
} |
528 |
|
529 |
/* old op:
|
530 |
if (src1 < T1)
|
531 |
env->psr |= PSR_CARRY;
|
532 |
*/
|
533 |
static inline void gen_cc_C_sub_icc(TCGv src1, TCGv src2) |
534 |
{ |
535 |
TCGv r_temp1, r_temp2; |
536 |
int l1;
|
537 |
|
538 |
l1 = gen_new_label(); |
539 |
r_temp1 = tcg_temp_new(TCG_TYPE_TL); |
540 |
r_temp2 = tcg_temp_new(TCG_TYPE_TL); |
541 |
tcg_gen_andi_tl(r_temp1, src1, 0xffffffffULL);
|
542 |
tcg_gen_andi_tl(r_temp2, src2, 0xffffffffULL);
|
543 |
tcg_gen_brcond_tl(TCG_COND_GEU, r_temp1, r_temp2, l1); |
544 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_CARRY); |
545 |
gen_set_label(l1); |
546 |
tcg_temp_free(r_temp1); |
547 |
tcg_temp_free(r_temp2); |
548 |
} |
549 |
|
550 |
#ifdef TARGET_SPARC64
|
551 |
static inline void gen_cc_C_sub_xcc(TCGv src1, TCGv src2) |
552 |
{ |
553 |
int l1;
|
554 |
|
555 |
l1 = gen_new_label(); |
556 |
tcg_gen_brcond_tl(TCG_COND_GEU, src1, src2, l1); |
557 |
tcg_gen_ori_i32(cpu_xcc, cpu_xcc, PSR_CARRY); |
558 |
gen_set_label(l1); |
559 |
} |
560 |
#endif
|
561 |
|
562 |
/* old op:
|
563 |
if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
|
564 |
env->psr |= PSR_OVF;
|
565 |
*/
|
566 |
static inline void gen_cc_V_sub_icc(TCGv dst, TCGv src1, TCGv src2) |
567 |
{ |
568 |
TCGv r_temp; |
569 |
|
570 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
571 |
tcg_gen_xor_tl(r_temp, src1, src2); |
572 |
tcg_gen_xor_tl(cpu_tmp0, src1, dst); |
573 |
tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0); |
574 |
tcg_gen_andi_tl(r_temp, r_temp, (1 << 31)); |
575 |
tcg_gen_shri_tl(r_temp, r_temp, 31 - PSR_OVF_SHIFT);
|
576 |
tcg_gen_trunc_tl_i32(cpu_tmp32, r_temp); |
577 |
tcg_gen_or_i32(cpu_psr, cpu_psr, cpu_tmp32); |
578 |
tcg_temp_free(r_temp); |
579 |
} |
580 |
|
581 |
#ifdef TARGET_SPARC64
|
582 |
static inline void gen_cc_V_sub_xcc(TCGv dst, TCGv src1, TCGv src2) |
583 |
{ |
584 |
TCGv r_temp; |
585 |
|
586 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
587 |
tcg_gen_xor_tl(r_temp, src1, src2); |
588 |
tcg_gen_xor_tl(cpu_tmp0, src1, dst); |
589 |
tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0); |
590 |
tcg_gen_andi_tl(r_temp, r_temp, (1ULL << 63)); |
591 |
tcg_gen_shri_tl(r_temp, r_temp, 63 - PSR_OVF_SHIFT);
|
592 |
tcg_gen_trunc_tl_i32(cpu_tmp32, r_temp); |
593 |
tcg_gen_or_i32(cpu_xcc, cpu_xcc, cpu_tmp32); |
594 |
tcg_temp_free(r_temp); |
595 |
} |
596 |
#endif
|
597 |
|
598 |
static inline void gen_sub_tv(TCGv dst, TCGv src1, TCGv src2) |
599 |
{ |
600 |
TCGv r_temp, r_const; |
601 |
int l1;
|
602 |
|
603 |
l1 = gen_new_label(); |
604 |
|
605 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
606 |
tcg_gen_xor_tl(r_temp, src1, src2); |
607 |
tcg_gen_xor_tl(cpu_tmp0, src1, dst); |
608 |
tcg_gen_and_tl(r_temp, r_temp, cpu_tmp0); |
609 |
tcg_gen_andi_tl(r_temp, r_temp, (1 << 31)); |
610 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_temp, 0, l1);
|
611 |
r_const = tcg_const_i32(TT_TOVF); |
612 |
tcg_gen_helper_0_1(raise_exception, r_const); |
613 |
tcg_temp_free(r_const); |
614 |
gen_set_label(l1); |
615 |
tcg_temp_free(r_temp); |
616 |
} |
617 |
|
618 |
static inline void gen_op_sub_cc(TCGv dst, TCGv src1, TCGv src2) |
619 |
{ |
620 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
621 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
622 |
tcg_gen_sub_tl(dst, src1, src2); |
623 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
624 |
gen_cc_clear_icc(); |
625 |
gen_cc_NZ_icc(cpu_cc_dst); |
626 |
gen_cc_C_sub_icc(cpu_cc_src, cpu_cc_src2); |
627 |
gen_cc_V_sub_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
628 |
#ifdef TARGET_SPARC64
|
629 |
gen_cc_clear_xcc(); |
630 |
gen_cc_NZ_xcc(cpu_cc_dst); |
631 |
gen_cc_C_sub_xcc(cpu_cc_src, cpu_cc_src2); |
632 |
gen_cc_V_sub_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
633 |
#endif
|
634 |
} |
635 |
|
636 |
static inline void gen_op_subx_cc(TCGv dst, TCGv src1, TCGv src2) |
637 |
{ |
638 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
639 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
640 |
gen_mov_reg_C(cpu_tmp0, cpu_psr); |
641 |
tcg_gen_sub_tl(dst, src1, cpu_tmp0); |
642 |
gen_cc_clear_icc(); |
643 |
gen_cc_C_sub_icc(dst, cpu_cc_src); |
644 |
#ifdef TARGET_SPARC64
|
645 |
gen_cc_clear_xcc(); |
646 |
gen_cc_C_sub_xcc(dst, cpu_cc_src); |
647 |
#endif
|
648 |
tcg_gen_sub_tl(dst, dst, cpu_cc_src2); |
649 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
650 |
gen_cc_NZ_icc(cpu_cc_dst); |
651 |
gen_cc_C_sub_icc(cpu_cc_dst, cpu_cc_src); |
652 |
gen_cc_V_sub_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
653 |
#ifdef TARGET_SPARC64
|
654 |
gen_cc_NZ_xcc(cpu_cc_dst); |
655 |
gen_cc_C_sub_xcc(cpu_cc_dst, cpu_cc_src); |
656 |
gen_cc_V_sub_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
657 |
#endif
|
658 |
} |
659 |
|
660 |
static inline void gen_op_tsub_cc(TCGv dst, TCGv src1, TCGv src2) |
661 |
{ |
662 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
663 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
664 |
tcg_gen_sub_tl(dst, src1, src2); |
665 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
666 |
gen_cc_clear_icc(); |
667 |
gen_cc_NZ_icc(cpu_cc_dst); |
668 |
gen_cc_C_sub_icc(cpu_cc_src, cpu_cc_src2); |
669 |
gen_cc_V_sub_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
670 |
gen_cc_V_tag(cpu_cc_src, cpu_cc_src2); |
671 |
#ifdef TARGET_SPARC64
|
672 |
gen_cc_clear_xcc(); |
673 |
gen_cc_NZ_xcc(cpu_cc_dst); |
674 |
gen_cc_C_sub_xcc(cpu_cc_src, cpu_cc_src2); |
675 |
gen_cc_V_sub_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
676 |
#endif
|
677 |
} |
678 |
|
679 |
static inline void gen_op_tsub_ccTV(TCGv dst, TCGv src1, TCGv src2) |
680 |
{ |
681 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
682 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
683 |
gen_tag_tv(cpu_cc_src, cpu_cc_src2); |
684 |
tcg_gen_sub_tl(dst, src1, src2); |
685 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
686 |
gen_sub_tv(dst, cpu_cc_src, cpu_cc_src2); |
687 |
gen_cc_clear_icc(); |
688 |
gen_cc_NZ_icc(cpu_cc_dst); |
689 |
gen_cc_C_sub_icc(cpu_cc_src, cpu_cc_src2); |
690 |
#ifdef TARGET_SPARC64
|
691 |
gen_cc_clear_xcc(); |
692 |
gen_cc_NZ_xcc(cpu_cc_dst); |
693 |
gen_cc_C_sub_xcc(cpu_cc_src, cpu_cc_src2); |
694 |
gen_cc_V_sub_xcc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
695 |
#endif
|
696 |
} |
697 |
|
698 |
static inline void gen_op_mulscc(TCGv dst, TCGv src1, TCGv src2) |
699 |
{ |
700 |
TCGv r_temp, r_temp2; |
701 |
int l1;
|
702 |
|
703 |
l1 = gen_new_label(); |
704 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
705 |
r_temp2 = tcg_temp_new(TCG_TYPE_I32); |
706 |
|
707 |
/* old op:
|
708 |
if (!(env->y & 1))
|
709 |
T1 = 0;
|
710 |
*/
|
711 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
712 |
tcg_gen_ld32u_tl(r_temp, cpu_env, offsetof(CPUSPARCState, y)); |
713 |
tcg_gen_trunc_tl_i32(r_temp2, r_temp); |
714 |
tcg_gen_andi_i32(r_temp2, r_temp2, 0x1);
|
715 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
716 |
tcg_gen_brcondi_i32(TCG_COND_NE, r_temp2, 0, l1);
|
717 |
tcg_gen_movi_tl(cpu_cc_src2, 0);
|
718 |
gen_set_label(l1); |
719 |
|
720 |
// b2 = T0 & 1;
|
721 |
// env->y = (b2 << 31) | (env->y >> 1);
|
722 |
tcg_gen_trunc_tl_i32(r_temp2, cpu_cc_src); |
723 |
tcg_gen_andi_i32(r_temp2, r_temp2, 0x1);
|
724 |
tcg_gen_shli_i32(r_temp2, r_temp2, 31);
|
725 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, y)); |
726 |
tcg_gen_shri_i32(cpu_tmp32, cpu_tmp32, 1);
|
727 |
tcg_gen_or_i32(cpu_tmp32, cpu_tmp32, r_temp2); |
728 |
tcg_temp_free(r_temp2); |
729 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, offsetof(CPUSPARCState, y)); |
730 |
|
731 |
// b1 = N ^ V;
|
732 |
gen_mov_reg_N(cpu_tmp0, cpu_psr); |
733 |
gen_mov_reg_V(r_temp, cpu_psr); |
734 |
tcg_gen_xor_tl(cpu_tmp0, cpu_tmp0, r_temp); |
735 |
tcg_temp_free(r_temp); |
736 |
|
737 |
// T0 = (b1 << 31) | (T0 >> 1);
|
738 |
// src1 = T0;
|
739 |
tcg_gen_shli_tl(cpu_tmp0, cpu_tmp0, 31);
|
740 |
tcg_gen_shri_tl(cpu_cc_src, cpu_cc_src, 1);
|
741 |
tcg_gen_or_tl(cpu_cc_src, cpu_cc_src, cpu_tmp0); |
742 |
|
743 |
/* do addition and update flags */
|
744 |
tcg_gen_add_tl(dst, cpu_cc_src, cpu_cc_src2); |
745 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
746 |
|
747 |
gen_cc_clear_icc(); |
748 |
gen_cc_NZ_icc(cpu_cc_dst); |
749 |
gen_cc_V_add_icc(cpu_cc_dst, cpu_cc_src, cpu_cc_src2); |
750 |
gen_cc_C_add_icc(cpu_cc_dst, cpu_cc_src); |
751 |
} |
752 |
|
753 |
static inline void gen_op_umul(TCGv dst, TCGv src1, TCGv src2) |
754 |
{ |
755 |
TCGv r_temp, r_temp2; |
756 |
|
757 |
r_temp = tcg_temp_new(TCG_TYPE_I64); |
758 |
r_temp2 = tcg_temp_new(TCG_TYPE_I64); |
759 |
|
760 |
tcg_gen_extu_tl_i64(r_temp, src2); |
761 |
tcg_gen_extu_tl_i64(r_temp2, src1); |
762 |
tcg_gen_mul_i64(r_temp2, r_temp, r_temp2); |
763 |
|
764 |
tcg_gen_shri_i64(r_temp, r_temp2, 32);
|
765 |
tcg_gen_trunc_i64_i32(r_temp, r_temp); |
766 |
tcg_gen_st_i32(r_temp, cpu_env, offsetof(CPUSPARCState, y)); |
767 |
tcg_temp_free(r_temp); |
768 |
#ifdef TARGET_SPARC64
|
769 |
tcg_gen_mov_i64(dst, r_temp2); |
770 |
#else
|
771 |
tcg_gen_trunc_i64_tl(dst, r_temp2); |
772 |
#endif
|
773 |
tcg_temp_free(r_temp2); |
774 |
} |
775 |
|
776 |
static inline void gen_op_smul(TCGv dst, TCGv src1, TCGv src2) |
777 |
{ |
778 |
TCGv r_temp, r_temp2; |
779 |
|
780 |
r_temp = tcg_temp_new(TCG_TYPE_I64); |
781 |
r_temp2 = tcg_temp_new(TCG_TYPE_I64); |
782 |
|
783 |
tcg_gen_ext_tl_i64(r_temp, src2); |
784 |
tcg_gen_ext_tl_i64(r_temp2, src1); |
785 |
tcg_gen_mul_i64(r_temp2, r_temp, r_temp2); |
786 |
|
787 |
tcg_gen_shri_i64(r_temp, r_temp2, 32);
|
788 |
tcg_gen_trunc_i64_i32(r_temp, r_temp); |
789 |
tcg_gen_st_i32(r_temp, cpu_env, offsetof(CPUSPARCState, y)); |
790 |
tcg_temp_free(r_temp); |
791 |
#ifdef TARGET_SPARC64
|
792 |
tcg_gen_mov_i64(dst, r_temp2); |
793 |
#else
|
794 |
tcg_gen_trunc_i64_tl(dst, r_temp2); |
795 |
#endif
|
796 |
tcg_temp_free(r_temp2); |
797 |
} |
798 |
|
799 |
#ifdef TARGET_SPARC64
|
800 |
static inline void gen_trap_ifdivzero_tl(TCGv divisor) |
801 |
{ |
802 |
TCGv r_const; |
803 |
int l1;
|
804 |
|
805 |
l1 = gen_new_label(); |
806 |
tcg_gen_brcondi_tl(TCG_COND_NE, divisor, 0, l1);
|
807 |
r_const = tcg_const_i32(TT_DIV_ZERO); |
808 |
tcg_gen_helper_0_1(raise_exception, r_const); |
809 |
tcg_temp_free(r_const); |
810 |
gen_set_label(l1); |
811 |
} |
812 |
|
813 |
static inline void gen_op_sdivx(TCGv dst, TCGv src1, TCGv src2) |
814 |
{ |
815 |
int l1, l2;
|
816 |
|
817 |
l1 = gen_new_label(); |
818 |
l2 = gen_new_label(); |
819 |
tcg_gen_mov_tl(cpu_cc_src, src1); |
820 |
tcg_gen_mov_tl(cpu_cc_src2, src2); |
821 |
gen_trap_ifdivzero_tl(src2); |
822 |
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_cc_src, INT64_MIN, l1); |
823 |
tcg_gen_brcondi_tl(TCG_COND_NE, cpu_cc_src2, -1, l1);
|
824 |
tcg_gen_movi_i64(dst, INT64_MIN); |
825 |
tcg_gen_br(l2); |
826 |
gen_set_label(l1); |
827 |
tcg_gen_div_i64(dst, cpu_cc_src, cpu_cc_src2); |
828 |
gen_set_label(l2); |
829 |
} |
830 |
#endif
|
831 |
|
832 |
static inline void gen_op_div_cc(TCGv dst) |
833 |
{ |
834 |
int l1;
|
835 |
|
836 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
837 |
gen_cc_clear_icc(); |
838 |
gen_cc_NZ_icc(cpu_cc_dst); |
839 |
l1 = gen_new_label(); |
840 |
tcg_gen_ld_tl(cpu_tmp0, cpu_env, offsetof(CPUSPARCState, cc_src2)); |
841 |
tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_tmp0, 0, l1);
|
842 |
tcg_gen_ori_i32(cpu_psr, cpu_psr, PSR_OVF); |
843 |
gen_set_label(l1); |
844 |
} |
845 |
|
846 |
static inline void gen_op_logic_cc(TCGv dst) |
847 |
{ |
848 |
tcg_gen_mov_tl(cpu_cc_dst, dst); |
849 |
|
850 |
gen_cc_clear_icc(); |
851 |
gen_cc_NZ_icc(cpu_cc_dst); |
852 |
#ifdef TARGET_SPARC64
|
853 |
gen_cc_clear_xcc(); |
854 |
gen_cc_NZ_xcc(cpu_cc_dst); |
855 |
#endif
|
856 |
} |
857 |
|
858 |
// 1
|
859 |
static inline void gen_op_eval_ba(TCGv dst) |
860 |
{ |
861 |
tcg_gen_movi_tl(dst, 1);
|
862 |
} |
863 |
|
864 |
// Z
|
865 |
static inline void gen_op_eval_be(TCGv dst, TCGv src) |
866 |
{ |
867 |
gen_mov_reg_Z(dst, src); |
868 |
} |
869 |
|
870 |
// Z | (N ^ V)
|
871 |
static inline void gen_op_eval_ble(TCGv dst, TCGv src) |
872 |
{ |
873 |
gen_mov_reg_N(cpu_tmp0, src); |
874 |
gen_mov_reg_V(dst, src); |
875 |
tcg_gen_xor_tl(dst, dst, cpu_tmp0); |
876 |
gen_mov_reg_Z(cpu_tmp0, src); |
877 |
tcg_gen_or_tl(dst, dst, cpu_tmp0); |
878 |
} |
879 |
|
880 |
// N ^ V
|
881 |
static inline void gen_op_eval_bl(TCGv dst, TCGv src) |
882 |
{ |
883 |
gen_mov_reg_V(cpu_tmp0, src); |
884 |
gen_mov_reg_N(dst, src); |
885 |
tcg_gen_xor_tl(dst, dst, cpu_tmp0); |
886 |
} |
887 |
|
888 |
// C | Z
|
889 |
static inline void gen_op_eval_bleu(TCGv dst, TCGv src) |
890 |
{ |
891 |
gen_mov_reg_Z(cpu_tmp0, src); |
892 |
gen_mov_reg_C(dst, src); |
893 |
tcg_gen_or_tl(dst, dst, cpu_tmp0); |
894 |
} |
895 |
|
896 |
// C
|
897 |
static inline void gen_op_eval_bcs(TCGv dst, TCGv src) |
898 |
{ |
899 |
gen_mov_reg_C(dst, src); |
900 |
} |
901 |
|
902 |
// V
|
903 |
static inline void gen_op_eval_bvs(TCGv dst, TCGv src) |
904 |
{ |
905 |
gen_mov_reg_V(dst, src); |
906 |
} |
907 |
|
908 |
// 0
|
909 |
static inline void gen_op_eval_bn(TCGv dst) |
910 |
{ |
911 |
tcg_gen_movi_tl(dst, 0);
|
912 |
} |
913 |
|
914 |
// N
|
915 |
static inline void gen_op_eval_bneg(TCGv dst, TCGv src) |
916 |
{ |
917 |
gen_mov_reg_N(dst, src); |
918 |
} |
919 |
|
920 |
// !Z
|
921 |
static inline void gen_op_eval_bne(TCGv dst, TCGv src) |
922 |
{ |
923 |
gen_mov_reg_Z(dst, src); |
924 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
925 |
} |
926 |
|
927 |
// !(Z | (N ^ V))
|
928 |
static inline void gen_op_eval_bg(TCGv dst, TCGv src) |
929 |
{ |
930 |
gen_mov_reg_N(cpu_tmp0, src); |
931 |
gen_mov_reg_V(dst, src); |
932 |
tcg_gen_xor_tl(dst, dst, cpu_tmp0); |
933 |
gen_mov_reg_Z(cpu_tmp0, src); |
934 |
tcg_gen_or_tl(dst, dst, cpu_tmp0); |
935 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
936 |
} |
937 |
|
938 |
// !(N ^ V)
|
939 |
static inline void gen_op_eval_bge(TCGv dst, TCGv src) |
940 |
{ |
941 |
gen_mov_reg_V(cpu_tmp0, src); |
942 |
gen_mov_reg_N(dst, src); |
943 |
tcg_gen_xor_tl(dst, dst, cpu_tmp0); |
944 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
945 |
} |
946 |
|
947 |
// !(C | Z)
|
948 |
static inline void gen_op_eval_bgu(TCGv dst, TCGv src) |
949 |
{ |
950 |
gen_mov_reg_Z(cpu_tmp0, src); |
951 |
gen_mov_reg_C(dst, src); |
952 |
tcg_gen_or_tl(dst, dst, cpu_tmp0); |
953 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
954 |
} |
955 |
|
956 |
// !C
|
957 |
static inline void gen_op_eval_bcc(TCGv dst, TCGv src) |
958 |
{ |
959 |
gen_mov_reg_C(dst, src); |
960 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
961 |
} |
962 |
|
963 |
// !N
|
964 |
static inline void gen_op_eval_bpos(TCGv dst, TCGv src) |
965 |
{ |
966 |
gen_mov_reg_N(dst, src); |
967 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
968 |
} |
969 |
|
970 |
// !V
|
971 |
static inline void gen_op_eval_bvc(TCGv dst, TCGv src) |
972 |
{ |
973 |
gen_mov_reg_V(dst, src); |
974 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
975 |
} |
976 |
|
977 |
/*
|
978 |
FPSR bit field FCC1 | FCC0:
|
979 |
0 =
|
980 |
1 <
|
981 |
2 >
|
982 |
3 unordered
|
983 |
*/
|
984 |
static inline void gen_mov_reg_FCC0(TCGv reg, TCGv src, |
985 |
unsigned int fcc_offset) |
986 |
{ |
987 |
tcg_gen_extu_i32_tl(reg, src); |
988 |
tcg_gen_shri_tl(reg, reg, FSR_FCC0_SHIFT + fcc_offset); |
989 |
tcg_gen_andi_tl(reg, reg, 0x1);
|
990 |
} |
991 |
|
992 |
static inline void gen_mov_reg_FCC1(TCGv reg, TCGv src, |
993 |
unsigned int fcc_offset) |
994 |
{ |
995 |
tcg_gen_extu_i32_tl(reg, src); |
996 |
tcg_gen_shri_tl(reg, reg, FSR_FCC1_SHIFT + fcc_offset); |
997 |
tcg_gen_andi_tl(reg, reg, 0x1);
|
998 |
} |
999 |
|
1000 |
// !0: FCC0 | FCC1
|
1001 |
static inline void gen_op_eval_fbne(TCGv dst, TCGv src, |
1002 |
unsigned int fcc_offset) |
1003 |
{ |
1004 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1005 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1006 |
tcg_gen_or_tl(dst, dst, cpu_tmp0); |
1007 |
} |
1008 |
|
1009 |
// 1 or 2: FCC0 ^ FCC1
|
1010 |
static inline void gen_op_eval_fblg(TCGv dst, TCGv src, |
1011 |
unsigned int fcc_offset) |
1012 |
{ |
1013 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1014 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1015 |
tcg_gen_xor_tl(dst, dst, cpu_tmp0); |
1016 |
} |
1017 |
|
1018 |
// 1 or 3: FCC0
|
1019 |
static inline void gen_op_eval_fbul(TCGv dst, TCGv src, |
1020 |
unsigned int fcc_offset) |
1021 |
{ |
1022 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1023 |
} |
1024 |
|
1025 |
// 1: FCC0 & !FCC1
|
1026 |
static inline void gen_op_eval_fbl(TCGv dst, TCGv src, |
1027 |
unsigned int fcc_offset) |
1028 |
{ |
1029 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1030 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1031 |
tcg_gen_xori_tl(cpu_tmp0, cpu_tmp0, 0x1);
|
1032 |
tcg_gen_and_tl(dst, dst, cpu_tmp0); |
1033 |
} |
1034 |
|
1035 |
// 2 or 3: FCC1
|
1036 |
static inline void gen_op_eval_fbug(TCGv dst, TCGv src, |
1037 |
unsigned int fcc_offset) |
1038 |
{ |
1039 |
gen_mov_reg_FCC1(dst, src, fcc_offset); |
1040 |
} |
1041 |
|
1042 |
// 2: !FCC0 & FCC1
|
1043 |
static inline void gen_op_eval_fbg(TCGv dst, TCGv src, |
1044 |
unsigned int fcc_offset) |
1045 |
{ |
1046 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1047 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1048 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1049 |
tcg_gen_and_tl(dst, dst, cpu_tmp0); |
1050 |
} |
1051 |
|
1052 |
// 3: FCC0 & FCC1
|
1053 |
static inline void gen_op_eval_fbu(TCGv dst, TCGv src, |
1054 |
unsigned int fcc_offset) |
1055 |
{ |
1056 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1057 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1058 |
tcg_gen_and_tl(dst, dst, cpu_tmp0); |
1059 |
} |
1060 |
|
1061 |
// 0: !(FCC0 | FCC1)
|
1062 |
static inline void gen_op_eval_fbe(TCGv dst, TCGv src, |
1063 |
unsigned int fcc_offset) |
1064 |
{ |
1065 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1066 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1067 |
tcg_gen_or_tl(dst, dst, cpu_tmp0); |
1068 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1069 |
} |
1070 |
|
1071 |
// 0 or 3: !(FCC0 ^ FCC1)
|
1072 |
static inline void gen_op_eval_fbue(TCGv dst, TCGv src, |
1073 |
unsigned int fcc_offset) |
1074 |
{ |
1075 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1076 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1077 |
tcg_gen_xor_tl(dst, dst, cpu_tmp0); |
1078 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1079 |
} |
1080 |
|
1081 |
// 0 or 2: !FCC0
|
1082 |
static inline void gen_op_eval_fbge(TCGv dst, TCGv src, |
1083 |
unsigned int fcc_offset) |
1084 |
{ |
1085 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1086 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1087 |
} |
1088 |
|
1089 |
// !1: !(FCC0 & !FCC1)
|
1090 |
static inline void gen_op_eval_fbuge(TCGv dst, TCGv src, |
1091 |
unsigned int fcc_offset) |
1092 |
{ |
1093 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1094 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1095 |
tcg_gen_xori_tl(cpu_tmp0, cpu_tmp0, 0x1);
|
1096 |
tcg_gen_and_tl(dst, dst, cpu_tmp0); |
1097 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1098 |
} |
1099 |
|
1100 |
// 0 or 1: !FCC1
|
1101 |
static inline void gen_op_eval_fble(TCGv dst, TCGv src, |
1102 |
unsigned int fcc_offset) |
1103 |
{ |
1104 |
gen_mov_reg_FCC1(dst, src, fcc_offset); |
1105 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1106 |
} |
1107 |
|
1108 |
// !2: !(!FCC0 & FCC1)
|
1109 |
static inline void gen_op_eval_fbule(TCGv dst, TCGv src, |
1110 |
unsigned int fcc_offset) |
1111 |
{ |
1112 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1113 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1114 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1115 |
tcg_gen_and_tl(dst, dst, cpu_tmp0); |
1116 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1117 |
} |
1118 |
|
1119 |
// !3: !(FCC0 & FCC1)
|
1120 |
static inline void gen_op_eval_fbo(TCGv dst, TCGv src, |
1121 |
unsigned int fcc_offset) |
1122 |
{ |
1123 |
gen_mov_reg_FCC0(dst, src, fcc_offset); |
1124 |
gen_mov_reg_FCC1(cpu_tmp0, src, fcc_offset); |
1125 |
tcg_gen_and_tl(dst, dst, cpu_tmp0); |
1126 |
tcg_gen_xori_tl(dst, dst, 0x1);
|
1127 |
} |
1128 |
|
1129 |
static inline void gen_branch2(DisasContext *dc, target_ulong pc1, |
1130 |
target_ulong pc2, TCGv r_cond) |
1131 |
{ |
1132 |
int l1;
|
1133 |
|
1134 |
l1 = gen_new_label(); |
1135 |
|
1136 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
1137 |
|
1138 |
gen_goto_tb(dc, 0, pc1, pc1 + 4); |
1139 |
|
1140 |
gen_set_label(l1); |
1141 |
gen_goto_tb(dc, 1, pc2, pc2 + 4); |
1142 |
} |
1143 |
|
1144 |
static inline void gen_branch_a(DisasContext *dc, target_ulong pc1, |
1145 |
target_ulong pc2, TCGv r_cond) |
1146 |
{ |
1147 |
int l1;
|
1148 |
|
1149 |
l1 = gen_new_label(); |
1150 |
|
1151 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
1152 |
|
1153 |
gen_goto_tb(dc, 0, pc2, pc1);
|
1154 |
|
1155 |
gen_set_label(l1); |
1156 |
gen_goto_tb(dc, 1, pc2 + 4, pc2 + 8); |
1157 |
} |
1158 |
|
1159 |
static inline void gen_generic_branch(target_ulong npc1, target_ulong npc2, |
1160 |
TCGv r_cond) |
1161 |
{ |
1162 |
int l1, l2;
|
1163 |
|
1164 |
l1 = gen_new_label(); |
1165 |
l2 = gen_new_label(); |
1166 |
|
1167 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
1168 |
|
1169 |
tcg_gen_movi_tl(cpu_npc, npc1); |
1170 |
tcg_gen_br(l2); |
1171 |
|
1172 |
gen_set_label(l1); |
1173 |
tcg_gen_movi_tl(cpu_npc, npc2); |
1174 |
gen_set_label(l2); |
1175 |
} |
1176 |
|
1177 |
/* call this function before using the condition register as it may
|
1178 |
have been set for a jump */
|
1179 |
static inline void flush_cond(DisasContext *dc, TCGv cond) |
1180 |
{ |
1181 |
if (dc->npc == JUMP_PC) {
|
1182 |
gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1], cond); |
1183 |
dc->npc = DYNAMIC_PC; |
1184 |
} |
1185 |
} |
1186 |
|
1187 |
static inline void save_npc(DisasContext *dc, TCGv cond) |
1188 |
{ |
1189 |
if (dc->npc == JUMP_PC) {
|
1190 |
gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1], cond); |
1191 |
dc->npc = DYNAMIC_PC; |
1192 |
} else if (dc->npc != DYNAMIC_PC) { |
1193 |
tcg_gen_movi_tl(cpu_npc, dc->npc); |
1194 |
} |
1195 |
} |
1196 |
|
1197 |
static inline void save_state(DisasContext *dc, TCGv cond) |
1198 |
{ |
1199 |
tcg_gen_movi_tl(cpu_pc, dc->pc); |
1200 |
save_npc(dc, cond); |
1201 |
} |
1202 |
|
1203 |
static inline void gen_mov_pc_npc(DisasContext *dc, TCGv cond) |
1204 |
{ |
1205 |
if (dc->npc == JUMP_PC) {
|
1206 |
gen_generic_branch(dc->jump_pc[0], dc->jump_pc[1], cond); |
1207 |
tcg_gen_mov_tl(cpu_pc, cpu_npc); |
1208 |
dc->pc = DYNAMIC_PC; |
1209 |
} else if (dc->npc == DYNAMIC_PC) { |
1210 |
tcg_gen_mov_tl(cpu_pc, cpu_npc); |
1211 |
dc->pc = DYNAMIC_PC; |
1212 |
} else {
|
1213 |
dc->pc = dc->npc; |
1214 |
} |
1215 |
} |
1216 |
|
1217 |
static inline void gen_op_next_insn(void) |
1218 |
{ |
1219 |
tcg_gen_mov_tl(cpu_pc, cpu_npc); |
1220 |
tcg_gen_addi_tl(cpu_npc, cpu_npc, 4);
|
1221 |
} |
1222 |
|
1223 |
static inline void gen_cond(TCGv r_dst, unsigned int cc, unsigned int cond) |
1224 |
{ |
1225 |
TCGv r_src; |
1226 |
|
1227 |
#ifdef TARGET_SPARC64
|
1228 |
if (cc)
|
1229 |
r_src = cpu_xcc; |
1230 |
else
|
1231 |
r_src = cpu_psr; |
1232 |
#else
|
1233 |
r_src = cpu_psr; |
1234 |
#endif
|
1235 |
switch (cond) {
|
1236 |
case 0x0: |
1237 |
gen_op_eval_bn(r_dst); |
1238 |
break;
|
1239 |
case 0x1: |
1240 |
gen_op_eval_be(r_dst, r_src); |
1241 |
break;
|
1242 |
case 0x2: |
1243 |
gen_op_eval_ble(r_dst, r_src); |
1244 |
break;
|
1245 |
case 0x3: |
1246 |
gen_op_eval_bl(r_dst, r_src); |
1247 |
break;
|
1248 |
case 0x4: |
1249 |
gen_op_eval_bleu(r_dst, r_src); |
1250 |
break;
|
1251 |
case 0x5: |
1252 |
gen_op_eval_bcs(r_dst, r_src); |
1253 |
break;
|
1254 |
case 0x6: |
1255 |
gen_op_eval_bneg(r_dst, r_src); |
1256 |
break;
|
1257 |
case 0x7: |
1258 |
gen_op_eval_bvs(r_dst, r_src); |
1259 |
break;
|
1260 |
case 0x8: |
1261 |
gen_op_eval_ba(r_dst); |
1262 |
break;
|
1263 |
case 0x9: |
1264 |
gen_op_eval_bne(r_dst, r_src); |
1265 |
break;
|
1266 |
case 0xa: |
1267 |
gen_op_eval_bg(r_dst, r_src); |
1268 |
break;
|
1269 |
case 0xb: |
1270 |
gen_op_eval_bge(r_dst, r_src); |
1271 |
break;
|
1272 |
case 0xc: |
1273 |
gen_op_eval_bgu(r_dst, r_src); |
1274 |
break;
|
1275 |
case 0xd: |
1276 |
gen_op_eval_bcc(r_dst, r_src); |
1277 |
break;
|
1278 |
case 0xe: |
1279 |
gen_op_eval_bpos(r_dst, r_src); |
1280 |
break;
|
1281 |
case 0xf: |
1282 |
gen_op_eval_bvc(r_dst, r_src); |
1283 |
break;
|
1284 |
} |
1285 |
} |
1286 |
|
1287 |
static inline void gen_fcond(TCGv r_dst, unsigned int cc, unsigned int cond) |
1288 |
{ |
1289 |
unsigned int offset; |
1290 |
|
1291 |
switch (cc) {
|
1292 |
default:
|
1293 |
case 0x0: |
1294 |
offset = 0;
|
1295 |
break;
|
1296 |
case 0x1: |
1297 |
offset = 32 - 10; |
1298 |
break;
|
1299 |
case 0x2: |
1300 |
offset = 34 - 10; |
1301 |
break;
|
1302 |
case 0x3: |
1303 |
offset = 36 - 10; |
1304 |
break;
|
1305 |
} |
1306 |
|
1307 |
switch (cond) {
|
1308 |
case 0x0: |
1309 |
gen_op_eval_bn(r_dst); |
1310 |
break;
|
1311 |
case 0x1: |
1312 |
gen_op_eval_fbne(r_dst, cpu_fsr, offset); |
1313 |
break;
|
1314 |
case 0x2: |
1315 |
gen_op_eval_fblg(r_dst, cpu_fsr, offset); |
1316 |
break;
|
1317 |
case 0x3: |
1318 |
gen_op_eval_fbul(r_dst, cpu_fsr, offset); |
1319 |
break;
|
1320 |
case 0x4: |
1321 |
gen_op_eval_fbl(r_dst, cpu_fsr, offset); |
1322 |
break;
|
1323 |
case 0x5: |
1324 |
gen_op_eval_fbug(r_dst, cpu_fsr, offset); |
1325 |
break;
|
1326 |
case 0x6: |
1327 |
gen_op_eval_fbg(r_dst, cpu_fsr, offset); |
1328 |
break;
|
1329 |
case 0x7: |
1330 |
gen_op_eval_fbu(r_dst, cpu_fsr, offset); |
1331 |
break;
|
1332 |
case 0x8: |
1333 |
gen_op_eval_ba(r_dst); |
1334 |
break;
|
1335 |
case 0x9: |
1336 |
gen_op_eval_fbe(r_dst, cpu_fsr, offset); |
1337 |
break;
|
1338 |
case 0xa: |
1339 |
gen_op_eval_fbue(r_dst, cpu_fsr, offset); |
1340 |
break;
|
1341 |
case 0xb: |
1342 |
gen_op_eval_fbge(r_dst, cpu_fsr, offset); |
1343 |
break;
|
1344 |
case 0xc: |
1345 |
gen_op_eval_fbuge(r_dst, cpu_fsr, offset); |
1346 |
break;
|
1347 |
case 0xd: |
1348 |
gen_op_eval_fble(r_dst, cpu_fsr, offset); |
1349 |
break;
|
1350 |
case 0xe: |
1351 |
gen_op_eval_fbule(r_dst, cpu_fsr, offset); |
1352 |
break;
|
1353 |
case 0xf: |
1354 |
gen_op_eval_fbo(r_dst, cpu_fsr, offset); |
1355 |
break;
|
1356 |
} |
1357 |
} |
1358 |
|
1359 |
#ifdef TARGET_SPARC64
|
1360 |
// Inverted logic
|
1361 |
static const int gen_tcg_cond_reg[8] = { |
1362 |
-1,
|
1363 |
TCG_COND_NE, |
1364 |
TCG_COND_GT, |
1365 |
TCG_COND_GE, |
1366 |
-1,
|
1367 |
TCG_COND_EQ, |
1368 |
TCG_COND_LE, |
1369 |
TCG_COND_LT, |
1370 |
}; |
1371 |
|
1372 |
static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src) |
1373 |
{ |
1374 |
int l1;
|
1375 |
|
1376 |
l1 = gen_new_label(); |
1377 |
tcg_gen_movi_tl(r_dst, 0);
|
1378 |
tcg_gen_brcondi_tl(gen_tcg_cond_reg[cond], r_src, 0, l1);
|
1379 |
tcg_gen_movi_tl(r_dst, 1);
|
1380 |
gen_set_label(l1); |
1381 |
} |
1382 |
#endif
|
1383 |
|
1384 |
/* XXX: potentially incorrect if dynamic npc */
|
1385 |
static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, |
1386 |
TCGv r_cond) |
1387 |
{ |
1388 |
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29)); |
1389 |
target_ulong target = dc->pc + offset; |
1390 |
|
1391 |
if (cond == 0x0) { |
1392 |
/* unconditional not taken */
|
1393 |
if (a) {
|
1394 |
dc->pc = dc->npc + 4;
|
1395 |
dc->npc = dc->pc + 4;
|
1396 |
} else {
|
1397 |
dc->pc = dc->npc; |
1398 |
dc->npc = dc->pc + 4;
|
1399 |
} |
1400 |
} else if (cond == 0x8) { |
1401 |
/* unconditional taken */
|
1402 |
if (a) {
|
1403 |
dc->pc = target; |
1404 |
dc->npc = dc->pc + 4;
|
1405 |
} else {
|
1406 |
dc->pc = dc->npc; |
1407 |
dc->npc = target; |
1408 |
} |
1409 |
} else {
|
1410 |
flush_cond(dc, r_cond); |
1411 |
gen_cond(r_cond, cc, cond); |
1412 |
if (a) {
|
1413 |
gen_branch_a(dc, target, dc->npc, r_cond); |
1414 |
dc->is_br = 1;
|
1415 |
} else {
|
1416 |
dc->pc = dc->npc; |
1417 |
dc->jump_pc[0] = target;
|
1418 |
dc->jump_pc[1] = dc->npc + 4; |
1419 |
dc->npc = JUMP_PC; |
1420 |
} |
1421 |
} |
1422 |
} |
1423 |
|
1424 |
/* XXX: potentially incorrect if dynamic npc */
|
1425 |
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, |
1426 |
TCGv r_cond) |
1427 |
{ |
1428 |
unsigned int cond = GET_FIELD(insn, 3, 6), a = (insn & (1 << 29)); |
1429 |
target_ulong target = dc->pc + offset; |
1430 |
|
1431 |
if (cond == 0x0) { |
1432 |
/* unconditional not taken */
|
1433 |
if (a) {
|
1434 |
dc->pc = dc->npc + 4;
|
1435 |
dc->npc = dc->pc + 4;
|
1436 |
} else {
|
1437 |
dc->pc = dc->npc; |
1438 |
dc->npc = dc->pc + 4;
|
1439 |
} |
1440 |
} else if (cond == 0x8) { |
1441 |
/* unconditional taken */
|
1442 |
if (a) {
|
1443 |
dc->pc = target; |
1444 |
dc->npc = dc->pc + 4;
|
1445 |
} else {
|
1446 |
dc->pc = dc->npc; |
1447 |
dc->npc = target; |
1448 |
} |
1449 |
} else {
|
1450 |
flush_cond(dc, r_cond); |
1451 |
gen_fcond(r_cond, cc, cond); |
1452 |
if (a) {
|
1453 |
gen_branch_a(dc, target, dc->npc, r_cond); |
1454 |
dc->is_br = 1;
|
1455 |
} else {
|
1456 |
dc->pc = dc->npc; |
1457 |
dc->jump_pc[0] = target;
|
1458 |
dc->jump_pc[1] = dc->npc + 4; |
1459 |
dc->npc = JUMP_PC; |
1460 |
} |
1461 |
} |
1462 |
} |
1463 |
|
1464 |
#ifdef TARGET_SPARC64
|
1465 |
/* XXX: potentially incorrect if dynamic npc */
|
1466 |
static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, |
1467 |
TCGv r_cond, TCGv r_reg) |
1468 |
{ |
1469 |
unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29)); |
1470 |
target_ulong target = dc->pc + offset; |
1471 |
|
1472 |
flush_cond(dc, r_cond); |
1473 |
gen_cond_reg(r_cond, cond, r_reg); |
1474 |
if (a) {
|
1475 |
gen_branch_a(dc, target, dc->npc, r_cond); |
1476 |
dc->is_br = 1;
|
1477 |
} else {
|
1478 |
dc->pc = dc->npc; |
1479 |
dc->jump_pc[0] = target;
|
1480 |
dc->jump_pc[1] = dc->npc + 4; |
1481 |
dc->npc = JUMP_PC; |
1482 |
} |
1483 |
} |
1484 |
|
1485 |
static GenOpFunc * const gen_fcmps[4] = { |
1486 |
helper_fcmps, |
1487 |
helper_fcmps_fcc1, |
1488 |
helper_fcmps_fcc2, |
1489 |
helper_fcmps_fcc3, |
1490 |
}; |
1491 |
|
1492 |
static GenOpFunc * const gen_fcmpd[4] = { |
1493 |
helper_fcmpd, |
1494 |
helper_fcmpd_fcc1, |
1495 |
helper_fcmpd_fcc2, |
1496 |
helper_fcmpd_fcc3, |
1497 |
}; |
1498 |
|
1499 |
static GenOpFunc * const gen_fcmpq[4] = { |
1500 |
helper_fcmpq, |
1501 |
helper_fcmpq_fcc1, |
1502 |
helper_fcmpq_fcc2, |
1503 |
helper_fcmpq_fcc3, |
1504 |
}; |
1505 |
|
1506 |
static GenOpFunc * const gen_fcmpes[4] = { |
1507 |
helper_fcmpes, |
1508 |
helper_fcmpes_fcc1, |
1509 |
helper_fcmpes_fcc2, |
1510 |
helper_fcmpes_fcc3, |
1511 |
}; |
1512 |
|
1513 |
static GenOpFunc * const gen_fcmped[4] = { |
1514 |
helper_fcmped, |
1515 |
helper_fcmped_fcc1, |
1516 |
helper_fcmped_fcc2, |
1517 |
helper_fcmped_fcc3, |
1518 |
}; |
1519 |
|
1520 |
static GenOpFunc * const gen_fcmpeq[4] = { |
1521 |
helper_fcmpeq, |
1522 |
helper_fcmpeq_fcc1, |
1523 |
helper_fcmpeq_fcc2, |
1524 |
helper_fcmpeq_fcc3, |
1525 |
}; |
1526 |
|
1527 |
static inline void gen_op_fcmps(int fccno) |
1528 |
{ |
1529 |
tcg_gen_helper_0_0(gen_fcmps[fccno]); |
1530 |
} |
1531 |
|
1532 |
static inline void gen_op_fcmpd(int fccno) |
1533 |
{ |
1534 |
tcg_gen_helper_0_0(gen_fcmpd[fccno]); |
1535 |
} |
1536 |
|
1537 |
static inline void gen_op_fcmpq(int fccno) |
1538 |
{ |
1539 |
tcg_gen_helper_0_0(gen_fcmpq[fccno]); |
1540 |
} |
1541 |
|
1542 |
static inline void gen_op_fcmpes(int fccno) |
1543 |
{ |
1544 |
tcg_gen_helper_0_0(gen_fcmpes[fccno]); |
1545 |
} |
1546 |
|
1547 |
static inline void gen_op_fcmped(int fccno) |
1548 |
{ |
1549 |
tcg_gen_helper_0_0(gen_fcmped[fccno]); |
1550 |
} |
1551 |
|
1552 |
static inline void gen_op_fcmpeq(int fccno) |
1553 |
{ |
1554 |
tcg_gen_helper_0_0(gen_fcmpeq[fccno]); |
1555 |
} |
1556 |
|
1557 |
#else
|
1558 |
|
1559 |
static inline void gen_op_fcmps(int fccno) |
1560 |
{ |
1561 |
tcg_gen_helper_0_0(helper_fcmps); |
1562 |
} |
1563 |
|
1564 |
static inline void gen_op_fcmpd(int fccno) |
1565 |
{ |
1566 |
tcg_gen_helper_0_0(helper_fcmpd); |
1567 |
} |
1568 |
|
1569 |
static inline void gen_op_fcmpq(int fccno) |
1570 |
{ |
1571 |
tcg_gen_helper_0_0(helper_fcmpq); |
1572 |
} |
1573 |
|
1574 |
static inline void gen_op_fcmpes(int fccno) |
1575 |
{ |
1576 |
tcg_gen_helper_0_0(helper_fcmpes); |
1577 |
} |
1578 |
|
1579 |
static inline void gen_op_fcmped(int fccno) |
1580 |
{ |
1581 |
tcg_gen_helper_0_0(helper_fcmped); |
1582 |
} |
1583 |
|
1584 |
static inline void gen_op_fcmpeq(int fccno) |
1585 |
{ |
1586 |
tcg_gen_helper_0_0(helper_fcmpeq); |
1587 |
} |
1588 |
#endif
|
1589 |
|
1590 |
static inline void gen_op_fpexception_im(int fsr_flags) |
1591 |
{ |
1592 |
TCGv r_const; |
1593 |
|
1594 |
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~FSR_FTT_MASK); |
1595 |
tcg_gen_ori_tl(cpu_fsr, cpu_fsr, fsr_flags); |
1596 |
r_const = tcg_const_i32(TT_FP_EXCP); |
1597 |
tcg_gen_helper_0_1(raise_exception, r_const); |
1598 |
tcg_temp_free(r_const); |
1599 |
} |
1600 |
|
1601 |
static int gen_trap_ifnofpu(DisasContext *dc, TCGv r_cond) |
1602 |
{ |
1603 |
#if !defined(CONFIG_USER_ONLY)
|
1604 |
if (!dc->fpu_enabled) {
|
1605 |
TCGv r_const; |
1606 |
|
1607 |
save_state(dc, r_cond); |
1608 |
r_const = tcg_const_i32(TT_NFPU_INSN); |
1609 |
tcg_gen_helper_0_1(raise_exception, r_const); |
1610 |
tcg_temp_free(r_const); |
1611 |
dc->is_br = 1;
|
1612 |
return 1; |
1613 |
} |
1614 |
#endif
|
1615 |
return 0; |
1616 |
} |
1617 |
|
1618 |
static inline void gen_op_clear_ieee_excp_and_FTT(void) |
1619 |
{ |
1620 |
tcg_gen_andi_tl(cpu_fsr, cpu_fsr, ~(FSR_FTT_MASK | FSR_CEXC_MASK)); |
1621 |
} |
1622 |
|
1623 |
static inline void gen_clear_float_exceptions(void) |
1624 |
{ |
1625 |
tcg_gen_helper_0_0(helper_clear_float_exceptions); |
1626 |
} |
1627 |
|
1628 |
/* asi moves */
|
1629 |
#ifdef TARGET_SPARC64
|
1630 |
static inline TCGv gen_get_asi(int insn, TCGv r_addr) |
1631 |
{ |
1632 |
int asi, offset;
|
1633 |
TCGv r_asi; |
1634 |
|
1635 |
if (IS_IMM) {
|
1636 |
r_asi = tcg_temp_new(TCG_TYPE_I32); |
1637 |
offset = GET_FIELD(insn, 25, 31); |
1638 |
tcg_gen_addi_tl(r_addr, r_addr, offset); |
1639 |
tcg_gen_ld_i32(r_asi, cpu_env, offsetof(CPUSPARCState, asi)); |
1640 |
} else {
|
1641 |
asi = GET_FIELD(insn, 19, 26); |
1642 |
r_asi = tcg_const_i32(asi); |
1643 |
} |
1644 |
return r_asi;
|
1645 |
} |
1646 |
|
1647 |
static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size, |
1648 |
int sign)
|
1649 |
{ |
1650 |
TCGv r_asi, r_size, r_sign; |
1651 |
|
1652 |
r_asi = gen_get_asi(insn, addr); |
1653 |
r_size = tcg_const_i32(size); |
1654 |
r_sign = tcg_const_i32(sign); |
1655 |
tcg_gen_helper_1_4(helper_ld_asi, dst, addr, r_asi, r_size, r_sign); |
1656 |
tcg_temp_free(r_sign); |
1657 |
tcg_temp_free(r_size); |
1658 |
tcg_temp_free(r_asi); |
1659 |
} |
1660 |
|
1661 |
static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size) |
1662 |
{ |
1663 |
TCGv r_asi, r_size; |
1664 |
|
1665 |
r_asi = gen_get_asi(insn, addr); |
1666 |
r_size = tcg_const_i32(size); |
1667 |
tcg_gen_helper_0_4(helper_st_asi, addr, src, r_asi, r_size); |
1668 |
tcg_temp_free(r_size); |
1669 |
tcg_temp_free(r_asi); |
1670 |
} |
1671 |
|
1672 |
static inline void gen_ldf_asi(TCGv addr, int insn, int size, int rd) |
1673 |
{ |
1674 |
TCGv r_asi, r_size, r_rd; |
1675 |
|
1676 |
r_asi = gen_get_asi(insn, addr); |
1677 |
r_size = tcg_const_i32(size); |
1678 |
r_rd = tcg_const_i32(rd); |
1679 |
tcg_gen_helper_0_4(helper_ldf_asi, addr, r_asi, r_size, r_rd); |
1680 |
tcg_temp_free(r_rd); |
1681 |
tcg_temp_free(r_size); |
1682 |
tcg_temp_free(r_asi); |
1683 |
} |
1684 |
|
1685 |
static inline void gen_stf_asi(TCGv addr, int insn, int size, int rd) |
1686 |
{ |
1687 |
TCGv r_asi, r_size, r_rd; |
1688 |
|
1689 |
r_asi = gen_get_asi(insn, addr); |
1690 |
r_size = tcg_const_i32(size); |
1691 |
r_rd = tcg_const_i32(rd); |
1692 |
tcg_gen_helper_0_4(helper_stf_asi, addr, r_asi, r_size, r_rd); |
1693 |
tcg_temp_free(r_rd); |
1694 |
tcg_temp_free(r_size); |
1695 |
tcg_temp_free(r_asi); |
1696 |
} |
1697 |
|
1698 |
static inline void gen_swap_asi(TCGv dst, TCGv addr, int insn) |
1699 |
{ |
1700 |
TCGv r_asi, r_size, r_sign; |
1701 |
|
1702 |
r_asi = gen_get_asi(insn, addr); |
1703 |
r_size = tcg_const_i32(4);
|
1704 |
r_sign = tcg_const_i32(0);
|
1705 |
tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi, r_size, r_sign); |
1706 |
tcg_temp_free(r_sign); |
1707 |
tcg_gen_helper_0_4(helper_st_asi, addr, dst, r_asi, r_size); |
1708 |
tcg_temp_free(r_size); |
1709 |
tcg_temp_free(r_asi); |
1710 |
tcg_gen_trunc_i64_tl(dst, cpu_tmp64); |
1711 |
} |
1712 |
|
1713 |
static inline void gen_ldda_asi(TCGv lo, TCGv hi, TCGv addr, int insn) |
1714 |
{ |
1715 |
TCGv r_asi, r_size, r_sign; |
1716 |
|
1717 |
r_asi = gen_get_asi(insn, addr); |
1718 |
r_size = tcg_const_i32(8);
|
1719 |
r_sign = tcg_const_i32(0);
|
1720 |
tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi, r_size, r_sign); |
1721 |
tcg_temp_free(r_sign); |
1722 |
tcg_temp_free(r_size); |
1723 |
tcg_temp_free(r_asi); |
1724 |
tcg_gen_andi_i64(lo, cpu_tmp64, 0xffffffffULL);
|
1725 |
tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);
|
1726 |
tcg_gen_andi_i64(hi, cpu_tmp64, 0xffffffffULL);
|
1727 |
} |
1728 |
|
1729 |
static inline void gen_stda_asi(TCGv hi, TCGv addr, int insn, int rd) |
1730 |
{ |
1731 |
TCGv r_temp, r_asi, r_size; |
1732 |
|
1733 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
1734 |
gen_movl_reg_TN(rd + 1, r_temp);
|
1735 |
tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, hi, |
1736 |
r_temp); |
1737 |
tcg_temp_free(r_temp); |
1738 |
r_asi = gen_get_asi(insn, addr); |
1739 |
r_size = tcg_const_i32(8);
|
1740 |
tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, r_asi, r_size); |
1741 |
tcg_temp_free(r_size); |
1742 |
tcg_temp_free(r_asi); |
1743 |
} |
1744 |
|
1745 |
static inline void gen_cas_asi(TCGv dst, TCGv addr, TCGv val2, int insn, |
1746 |
int rd)
|
1747 |
{ |
1748 |
TCGv r_val1, r_asi; |
1749 |
|
1750 |
r_val1 = tcg_temp_new(TCG_TYPE_TL); |
1751 |
gen_movl_reg_TN(rd, r_val1); |
1752 |
r_asi = gen_get_asi(insn, addr); |
1753 |
tcg_gen_helper_1_4(helper_cas_asi, dst, addr, r_val1, val2, r_asi); |
1754 |
tcg_temp_free(r_asi); |
1755 |
tcg_temp_free(r_val1); |
1756 |
} |
1757 |
|
1758 |
static inline void gen_casx_asi(TCGv dst, TCGv addr, TCGv val2, int insn, |
1759 |
int rd)
|
1760 |
{ |
1761 |
TCGv r_asi; |
1762 |
|
1763 |
gen_movl_reg_TN(rd, cpu_tmp64); |
1764 |
r_asi = gen_get_asi(insn, addr); |
1765 |
tcg_gen_helper_1_4(helper_casx_asi, dst, addr, cpu_tmp64, val2, r_asi); |
1766 |
tcg_temp_free(r_asi); |
1767 |
} |
1768 |
|
1769 |
#elif !defined(CONFIG_USER_ONLY)
|
1770 |
|
1771 |
static inline void gen_ld_asi(TCGv dst, TCGv addr, int insn, int size, |
1772 |
int sign)
|
1773 |
{ |
1774 |
TCGv r_asi, r_size, r_sign; |
1775 |
|
1776 |
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26)); |
1777 |
r_size = tcg_const_i32(size); |
1778 |
r_sign = tcg_const_i32(sign); |
1779 |
tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi, r_size, r_sign); |
1780 |
tcg_temp_free(r_sign); |
1781 |
tcg_temp_free(r_size); |
1782 |
tcg_temp_free(r_asi); |
1783 |
tcg_gen_trunc_i64_tl(dst, cpu_tmp64); |
1784 |
} |
1785 |
|
1786 |
static inline void gen_st_asi(TCGv src, TCGv addr, int insn, int size) |
1787 |
{ |
1788 |
TCGv r_asi, r_size; |
1789 |
|
1790 |
tcg_gen_extu_tl_i64(cpu_tmp64, src); |
1791 |
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26)); |
1792 |
r_size = tcg_const_i32(size); |
1793 |
tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, r_asi, r_size); |
1794 |
tcg_temp_free(r_size); |
1795 |
tcg_temp_free(r_asi); |
1796 |
} |
1797 |
|
1798 |
static inline void gen_swap_asi(TCGv dst, TCGv addr, int insn) |
1799 |
{ |
1800 |
TCGv r_asi, r_size, r_sign; |
1801 |
|
1802 |
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26)); |
1803 |
r_size = tcg_const_i32(4);
|
1804 |
r_sign = tcg_const_i32(0);
|
1805 |
tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi, r_size, r_sign); |
1806 |
tcg_temp_free(r_sign); |
1807 |
tcg_gen_helper_0_4(helper_st_asi, addr, dst, r_asi, r_size); |
1808 |
tcg_temp_free(r_size); |
1809 |
tcg_temp_free(r_asi); |
1810 |
tcg_gen_trunc_i64_tl(dst, cpu_tmp64); |
1811 |
} |
1812 |
|
1813 |
static inline void gen_ldda_asi(TCGv lo, TCGv hi, TCGv addr, int insn) |
1814 |
{ |
1815 |
TCGv r_asi, r_size, r_sign; |
1816 |
|
1817 |
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26)); |
1818 |
r_size = tcg_const_i32(8);
|
1819 |
r_sign = tcg_const_i32(0);
|
1820 |
tcg_gen_helper_1_4(helper_ld_asi, cpu_tmp64, addr, r_asi, r_size, r_sign); |
1821 |
tcg_temp_free(r_sign); |
1822 |
tcg_temp_free(r_size); |
1823 |
tcg_temp_free(r_asi); |
1824 |
tcg_gen_trunc_i64_tl(lo, cpu_tmp64); |
1825 |
tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);
|
1826 |
tcg_gen_trunc_i64_tl(hi, cpu_tmp64); |
1827 |
} |
1828 |
|
1829 |
static inline void gen_stda_asi(TCGv hi, TCGv addr, int insn, int rd) |
1830 |
{ |
1831 |
TCGv r_temp, r_asi, r_size; |
1832 |
|
1833 |
r_temp = tcg_temp_new(TCG_TYPE_TL); |
1834 |
gen_movl_reg_TN(rd + 1, r_temp);
|
1835 |
tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, hi, r_temp); |
1836 |
tcg_temp_free(r_temp); |
1837 |
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26)); |
1838 |
r_size = tcg_const_i32(8);
|
1839 |
tcg_gen_helper_0_4(helper_st_asi, addr, cpu_tmp64, r_asi, r_size); |
1840 |
tcg_temp_free(r_size); |
1841 |
tcg_temp_free(r_asi); |
1842 |
} |
1843 |
#endif
|
1844 |
|
1845 |
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
1846 |
static inline void gen_ldstub_asi(TCGv dst, TCGv addr, int insn) |
1847 |
{ |
1848 |
TCGv r_val, r_asi, r_size; |
1849 |
|
1850 |
gen_ld_asi(dst, addr, insn, 1, 0); |
1851 |
|
1852 |
r_val = tcg_const_i64(0xffULL);
|
1853 |
r_asi = tcg_const_i32(GET_FIELD(insn, 19, 26)); |
1854 |
r_size = tcg_const_i32(1);
|
1855 |
tcg_gen_helper_0_4(helper_st_asi, addr, r_val, r_asi, r_size); |
1856 |
tcg_temp_free(r_size); |
1857 |
tcg_temp_free(r_asi); |
1858 |
tcg_temp_free(r_val); |
1859 |
} |
1860 |
#endif
|
1861 |
|
1862 |
static inline TCGv get_src1(unsigned int insn, TCGv def) |
1863 |
{ |
1864 |
TCGv r_rs1 = def; |
1865 |
unsigned int rs1; |
1866 |
|
1867 |
rs1 = GET_FIELD(insn, 13, 17); |
1868 |
if (rs1 == 0) |
1869 |
//r_rs1 = tcg_const_tl(0);
|
1870 |
tcg_gen_movi_tl(def, 0);
|
1871 |
else if (rs1 < 8) |
1872 |
//r_rs1 = cpu_gregs[rs1];
|
1873 |
tcg_gen_mov_tl(def, cpu_gregs[rs1]); |
1874 |
else
|
1875 |
tcg_gen_ld_tl(def, cpu_regwptr, (rs1 - 8) * sizeof(target_ulong)); |
1876 |
return r_rs1;
|
1877 |
} |
1878 |
|
1879 |
static inline TCGv get_src2(unsigned int insn, TCGv def) |
1880 |
{ |
1881 |
TCGv r_rs2 = def; |
1882 |
unsigned int rs2; |
1883 |
|
1884 |
if (IS_IMM) { /* immediate */ |
1885 |
rs2 = GET_FIELDs(insn, 19, 31); |
1886 |
r_rs2 = tcg_const_tl((int)rs2); // XXX how to free? |
1887 |
} else { /* register */ |
1888 |
rs2 = GET_FIELD(insn, 27, 31); |
1889 |
if (rs2 == 0) |
1890 |
r_rs2 = tcg_const_tl(0); // XXX how to free? |
1891 |
else if (rs2 < 8) |
1892 |
r_rs2 = cpu_gregs[rs2]; |
1893 |
else
|
1894 |
tcg_gen_ld_tl(def, cpu_regwptr, (rs2 - 8) * sizeof(target_ulong)); |
1895 |
} |
1896 |
return r_rs2;
|
1897 |
} |
1898 |
|
1899 |
#define CHECK_IU_FEATURE(dc, FEATURE) \
|
1900 |
if (!((dc)->features & CPU_FEATURE_ ## FEATURE)) \ |
1901 |
goto illegal_insn;
|
1902 |
#define CHECK_FPU_FEATURE(dc, FEATURE) \
|
1903 |
if (!((dc)->features & CPU_FEATURE_ ## FEATURE)) \ |
1904 |
goto nfpu_insn;
|
1905 |
|
1906 |
/* before an instruction, dc->pc must be static */
|
1907 |
static void disas_sparc_insn(DisasContext * dc) |
1908 |
{ |
1909 |
unsigned int insn, opc, rs1, rs2, rd; |
1910 |
|
1911 |
if (unlikely(loglevel & CPU_LOG_TB_OP))
|
1912 |
tcg_gen_debug_insn_start(dc->pc); |
1913 |
insn = ldl_code(dc->pc); |
1914 |
opc = GET_FIELD(insn, 0, 1); |
1915 |
|
1916 |
rd = GET_FIELD(insn, 2, 6); |
1917 |
|
1918 |
cpu_dst = cpu_T[0];
|
1919 |
cpu_src1 = cpu_T[0]; // const |
1920 |
cpu_src2 = cpu_T[1]; // const |
1921 |
|
1922 |
// loads and stores
|
1923 |
cpu_addr = cpu_T[0];
|
1924 |
cpu_val = cpu_T[1];
|
1925 |
|
1926 |
switch (opc) {
|
1927 |
case 0: /* branches/sethi */ |
1928 |
{ |
1929 |
unsigned int xop = GET_FIELD(insn, 7, 9); |
1930 |
int32_t target; |
1931 |
switch (xop) {
|
1932 |
#ifdef TARGET_SPARC64
|
1933 |
case 0x1: /* V9 BPcc */ |
1934 |
{ |
1935 |
int cc;
|
1936 |
|
1937 |
target = GET_FIELD_SP(insn, 0, 18); |
1938 |
target = sign_extend(target, 18);
|
1939 |
target <<= 2;
|
1940 |
cc = GET_FIELD_SP(insn, 20, 21); |
1941 |
if (cc == 0) |
1942 |
do_branch(dc, target, insn, 0, cpu_cond);
|
1943 |
else if (cc == 2) |
1944 |
do_branch(dc, target, insn, 1, cpu_cond);
|
1945 |
else
|
1946 |
goto illegal_insn;
|
1947 |
goto jmp_insn;
|
1948 |
} |
1949 |
case 0x3: /* V9 BPr */ |
1950 |
{ |
1951 |
target = GET_FIELD_SP(insn, 0, 13) | |
1952 |
(GET_FIELD_SP(insn, 20, 21) << 14); |
1953 |
target = sign_extend(target, 16);
|
1954 |
target <<= 2;
|
1955 |
cpu_src1 = get_src1(insn, cpu_src1); |
1956 |
do_branch_reg(dc, target, insn, cpu_cond, cpu_src1); |
1957 |
goto jmp_insn;
|
1958 |
} |
1959 |
case 0x5: /* V9 FBPcc */ |
1960 |
{ |
1961 |
int cc = GET_FIELD_SP(insn, 20, 21); |
1962 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
1963 |
goto jmp_insn;
|
1964 |
target = GET_FIELD_SP(insn, 0, 18); |
1965 |
target = sign_extend(target, 19);
|
1966 |
target <<= 2;
|
1967 |
do_fbranch(dc, target, insn, cc, cpu_cond); |
1968 |
goto jmp_insn;
|
1969 |
} |
1970 |
#else
|
1971 |
case 0x7: /* CBN+x */ |
1972 |
{ |
1973 |
goto ncp_insn;
|
1974 |
} |
1975 |
#endif
|
1976 |
case 0x2: /* BN+x */ |
1977 |
{ |
1978 |
target = GET_FIELD(insn, 10, 31); |
1979 |
target = sign_extend(target, 22);
|
1980 |
target <<= 2;
|
1981 |
do_branch(dc, target, insn, 0, cpu_cond);
|
1982 |
goto jmp_insn;
|
1983 |
} |
1984 |
case 0x6: /* FBN+x */ |
1985 |
{ |
1986 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
1987 |
goto jmp_insn;
|
1988 |
target = GET_FIELD(insn, 10, 31); |
1989 |
target = sign_extend(target, 22);
|
1990 |
target <<= 2;
|
1991 |
do_fbranch(dc, target, insn, 0, cpu_cond);
|
1992 |
goto jmp_insn;
|
1993 |
} |
1994 |
case 0x4: /* SETHI */ |
1995 |
if (rd) { // nop |
1996 |
uint32_t value = GET_FIELD(insn, 10, 31); |
1997 |
TCGv r_const; |
1998 |
|
1999 |
r_const = tcg_const_tl(value << 10);
|
2000 |
gen_movl_TN_reg(rd, r_const); |
2001 |
tcg_temp_free(r_const); |
2002 |
} |
2003 |
break;
|
2004 |
case 0x0: /* UNIMPL */ |
2005 |
default:
|
2006 |
goto illegal_insn;
|
2007 |
} |
2008 |
break;
|
2009 |
} |
2010 |
break;
|
2011 |
case 1: |
2012 |
/*CALL*/ {
|
2013 |
target_long target = GET_FIELDs(insn, 2, 31) << 2; |
2014 |
TCGv r_const; |
2015 |
|
2016 |
r_const = tcg_const_tl(dc->pc); |
2017 |
gen_movl_TN_reg(15, r_const);
|
2018 |
tcg_temp_free(r_const); |
2019 |
target += dc->pc; |
2020 |
gen_mov_pc_npc(dc, cpu_cond); |
2021 |
dc->npc = target; |
2022 |
} |
2023 |
goto jmp_insn;
|
2024 |
case 2: /* FPU & Logical Operations */ |
2025 |
{ |
2026 |
unsigned int xop = GET_FIELD(insn, 7, 12); |
2027 |
if (xop == 0x3a) { /* generate trap */ |
2028 |
int cond;
|
2029 |
|
2030 |
cpu_src1 = get_src1(insn, cpu_src1); |
2031 |
if (IS_IMM) {
|
2032 |
rs2 = GET_FIELD(insn, 25, 31); |
2033 |
tcg_gen_addi_tl(cpu_dst, cpu_src1, rs2); |
2034 |
} else {
|
2035 |
rs2 = GET_FIELD(insn, 27, 31); |
2036 |
if (rs2 != 0) { |
2037 |
gen_movl_reg_TN(rs2, cpu_src2); |
2038 |
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); |
2039 |
} else
|
2040 |
tcg_gen_mov_tl(cpu_dst, cpu_src1); |
2041 |
} |
2042 |
cond = GET_FIELD(insn, 3, 6); |
2043 |
if (cond == 0x8) { |
2044 |
save_state(dc, cpu_cond); |
2045 |
tcg_gen_helper_0_1(helper_trap, cpu_dst); |
2046 |
} else if (cond != 0) { |
2047 |
TCGv r_cond = tcg_temp_new(TCG_TYPE_TL); |
2048 |
#ifdef TARGET_SPARC64
|
2049 |
/* V9 icc/xcc */
|
2050 |
int cc = GET_FIELD_SP(insn, 11, 12); |
2051 |
|
2052 |
save_state(dc, cpu_cond); |
2053 |
if (cc == 0) |
2054 |
gen_cond(r_cond, 0, cond);
|
2055 |
else if (cc == 2) |
2056 |
gen_cond(r_cond, 1, cond);
|
2057 |
else
|
2058 |
goto illegal_insn;
|
2059 |
#else
|
2060 |
save_state(dc, cpu_cond); |
2061 |
gen_cond(r_cond, 0, cond);
|
2062 |
#endif
|
2063 |
tcg_gen_helper_0_2(helper_trapcc, cpu_dst, r_cond); |
2064 |
tcg_temp_free(r_cond); |
2065 |
} |
2066 |
gen_op_next_insn(); |
2067 |
tcg_gen_exit_tb(0);
|
2068 |
dc->is_br = 1;
|
2069 |
goto jmp_insn;
|
2070 |
} else if (xop == 0x28) { |
2071 |
rs1 = GET_FIELD(insn, 13, 17); |
2072 |
switch(rs1) {
|
2073 |
case 0: /* rdy */ |
2074 |
#ifndef TARGET_SPARC64
|
2075 |
case 0x01 ... 0x0e: /* undefined in the SPARCv8 |
2076 |
manual, rdy on the microSPARC
|
2077 |
II */
|
2078 |
case 0x0f: /* stbar in the SPARCv8 manual, |
2079 |
rdy on the microSPARC II */
|
2080 |
case 0x10 ... 0x1f: /* implementation-dependent in the |
2081 |
SPARCv8 manual, rdy on the
|
2082 |
microSPARC II */
|
2083 |
#endif
|
2084 |
tcg_gen_ld_tl(cpu_dst, cpu_env, |
2085 |
offsetof(CPUSPARCState, y)); |
2086 |
gen_movl_TN_reg(rd, cpu_dst); |
2087 |
break;
|
2088 |
#ifdef TARGET_SPARC64
|
2089 |
case 0x2: /* V9 rdccr */ |
2090 |
tcg_gen_helper_1_0(helper_rdccr, cpu_dst); |
2091 |
gen_movl_TN_reg(rd, cpu_dst); |
2092 |
break;
|
2093 |
case 0x3: /* V9 rdasi */ |
2094 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2095 |
offsetof(CPUSPARCState, asi)); |
2096 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2097 |
gen_movl_TN_reg(rd, cpu_dst); |
2098 |
break;
|
2099 |
case 0x4: /* V9 rdtick */ |
2100 |
{ |
2101 |
TCGv r_tickptr; |
2102 |
|
2103 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
2104 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
2105 |
offsetof(CPUState, tick)); |
2106 |
tcg_gen_helper_1_1(helper_tick_get_count, cpu_dst, |
2107 |
r_tickptr); |
2108 |
tcg_temp_free(r_tickptr); |
2109 |
gen_movl_TN_reg(rd, cpu_dst); |
2110 |
} |
2111 |
break;
|
2112 |
case 0x5: /* V9 rdpc */ |
2113 |
{ |
2114 |
TCGv r_const; |
2115 |
|
2116 |
r_const = tcg_const_tl(dc->pc); |
2117 |
gen_movl_TN_reg(rd, r_const); |
2118 |
tcg_temp_free(r_const); |
2119 |
} |
2120 |
break;
|
2121 |
case 0x6: /* V9 rdfprs */ |
2122 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2123 |
offsetof(CPUSPARCState, fprs)); |
2124 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2125 |
gen_movl_TN_reg(rd, cpu_dst); |
2126 |
break;
|
2127 |
case 0xf: /* V9 membar */ |
2128 |
break; /* no effect */ |
2129 |
case 0x13: /* Graphics Status */ |
2130 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
2131 |
goto jmp_insn;
|
2132 |
tcg_gen_ld_tl(cpu_dst, cpu_env, |
2133 |
offsetof(CPUSPARCState, gsr)); |
2134 |
gen_movl_TN_reg(rd, cpu_dst); |
2135 |
break;
|
2136 |
case 0x17: /* Tick compare */ |
2137 |
tcg_gen_ld_tl(cpu_dst, cpu_env, |
2138 |
offsetof(CPUSPARCState, tick_cmpr)); |
2139 |
gen_movl_TN_reg(rd, cpu_dst); |
2140 |
break;
|
2141 |
case 0x18: /* System tick */ |
2142 |
{ |
2143 |
TCGv r_tickptr; |
2144 |
|
2145 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
2146 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
2147 |
offsetof(CPUState, stick)); |
2148 |
tcg_gen_helper_1_1(helper_tick_get_count, cpu_dst, |
2149 |
r_tickptr); |
2150 |
tcg_temp_free(r_tickptr); |
2151 |
gen_movl_TN_reg(rd, cpu_dst); |
2152 |
} |
2153 |
break;
|
2154 |
case 0x19: /* System tick compare */ |
2155 |
tcg_gen_ld_tl(cpu_dst, cpu_env, |
2156 |
offsetof(CPUSPARCState, stick_cmpr)); |
2157 |
gen_movl_TN_reg(rd, cpu_dst); |
2158 |
break;
|
2159 |
case 0x10: /* Performance Control */ |
2160 |
case 0x11: /* Performance Instrumentation Counter */ |
2161 |
case 0x12: /* Dispatch Control */ |
2162 |
case 0x14: /* Softint set, WO */ |
2163 |
case 0x15: /* Softint clear, WO */ |
2164 |
case 0x16: /* Softint write */ |
2165 |
#endif
|
2166 |
default:
|
2167 |
goto illegal_insn;
|
2168 |
} |
2169 |
#if !defined(CONFIG_USER_ONLY)
|
2170 |
} else if (xop == 0x29) { /* rdpsr / UA2005 rdhpr */ |
2171 |
#ifndef TARGET_SPARC64
|
2172 |
if (!supervisor(dc))
|
2173 |
goto priv_insn;
|
2174 |
tcg_gen_helper_1_0(helper_rdpsr, cpu_dst); |
2175 |
#else
|
2176 |
if (!hypervisor(dc))
|
2177 |
goto priv_insn;
|
2178 |
rs1 = GET_FIELD(insn, 13, 17); |
2179 |
switch (rs1) {
|
2180 |
case 0: // hpstate |
2181 |
// gen_op_rdhpstate();
|
2182 |
break;
|
2183 |
case 1: // htstate |
2184 |
// gen_op_rdhtstate();
|
2185 |
break;
|
2186 |
case 3: // hintp |
2187 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2188 |
offsetof(CPUSPARCState, hintp)); |
2189 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2190 |
break;
|
2191 |
case 5: // htba |
2192 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2193 |
offsetof(CPUSPARCState, htba)); |
2194 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2195 |
break;
|
2196 |
case 6: // hver |
2197 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2198 |
offsetof(CPUSPARCState, hver)); |
2199 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2200 |
break;
|
2201 |
case 31: // hstick_cmpr |
2202 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
2203 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
2204 |
offsetof(CPUSPARCState, hstick_cmpr)); |
2205 |
break;
|
2206 |
default:
|
2207 |
goto illegal_insn;
|
2208 |
} |
2209 |
#endif
|
2210 |
gen_movl_TN_reg(rd, cpu_dst); |
2211 |
break;
|
2212 |
} else if (xop == 0x2a) { /* rdwim / V9 rdpr */ |
2213 |
if (!supervisor(dc))
|
2214 |
goto priv_insn;
|
2215 |
#ifdef TARGET_SPARC64
|
2216 |
rs1 = GET_FIELD(insn, 13, 17); |
2217 |
switch (rs1) {
|
2218 |
case 0: // tpc |
2219 |
{ |
2220 |
TCGv r_tsptr; |
2221 |
|
2222 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
2223 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
2224 |
offsetof(CPUState, tsptr)); |
2225 |
tcg_gen_ld_tl(cpu_dst, r_tsptr, |
2226 |
offsetof(trap_state, tpc)); |
2227 |
tcg_temp_free(r_tsptr); |
2228 |
} |
2229 |
break;
|
2230 |
case 1: // tnpc |
2231 |
{ |
2232 |
TCGv r_tsptr; |
2233 |
|
2234 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
2235 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
2236 |
offsetof(CPUState, tsptr)); |
2237 |
tcg_gen_ld_tl(cpu_dst, r_tsptr, |
2238 |
offsetof(trap_state, tnpc)); |
2239 |
tcg_temp_free(r_tsptr); |
2240 |
} |
2241 |
break;
|
2242 |
case 2: // tstate |
2243 |
{ |
2244 |
TCGv r_tsptr; |
2245 |
|
2246 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
2247 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
2248 |
offsetof(CPUState, tsptr)); |
2249 |
tcg_gen_ld_tl(cpu_dst, r_tsptr, |
2250 |
offsetof(trap_state, tstate)); |
2251 |
tcg_temp_free(r_tsptr); |
2252 |
} |
2253 |
break;
|
2254 |
case 3: // tt |
2255 |
{ |
2256 |
TCGv r_tsptr; |
2257 |
|
2258 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
2259 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
2260 |
offsetof(CPUState, tsptr)); |
2261 |
tcg_gen_ld_i32(cpu_dst, r_tsptr, |
2262 |
offsetof(trap_state, tt)); |
2263 |
tcg_temp_free(r_tsptr); |
2264 |
} |
2265 |
break;
|
2266 |
case 4: // tick |
2267 |
{ |
2268 |
TCGv r_tickptr; |
2269 |
|
2270 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
2271 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
2272 |
offsetof(CPUState, tick)); |
2273 |
tcg_gen_helper_1_1(helper_tick_get_count, cpu_dst, |
2274 |
r_tickptr); |
2275 |
gen_movl_TN_reg(rd, cpu_dst); |
2276 |
tcg_temp_free(r_tickptr); |
2277 |
} |
2278 |
break;
|
2279 |
case 5: // tba |
2280 |
tcg_gen_ld_tl(cpu_dst, cpu_env, |
2281 |
offsetof(CPUSPARCState, tbr)); |
2282 |
break;
|
2283 |
case 6: // pstate |
2284 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2285 |
offsetof(CPUSPARCState, pstate)); |
2286 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2287 |
break;
|
2288 |
case 7: // tl |
2289 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2290 |
offsetof(CPUSPARCState, tl)); |
2291 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2292 |
break;
|
2293 |
case 8: // pil |
2294 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2295 |
offsetof(CPUSPARCState, psrpil)); |
2296 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2297 |
break;
|
2298 |
case 9: // cwp |
2299 |
tcg_gen_helper_1_0(helper_rdcwp, cpu_dst); |
2300 |
break;
|
2301 |
case 10: // cansave |
2302 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2303 |
offsetof(CPUSPARCState, cansave)); |
2304 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2305 |
break;
|
2306 |
case 11: // canrestore |
2307 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2308 |
offsetof(CPUSPARCState, canrestore)); |
2309 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2310 |
break;
|
2311 |
case 12: // cleanwin |
2312 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2313 |
offsetof(CPUSPARCState, cleanwin)); |
2314 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2315 |
break;
|
2316 |
case 13: // otherwin |
2317 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2318 |
offsetof(CPUSPARCState, otherwin)); |
2319 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2320 |
break;
|
2321 |
case 14: // wstate |
2322 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2323 |
offsetof(CPUSPARCState, wstate)); |
2324 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2325 |
break;
|
2326 |
case 16: // UA2005 gl |
2327 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2328 |
offsetof(CPUSPARCState, gl)); |
2329 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2330 |
break;
|
2331 |
case 26: // UA2005 strand status |
2332 |
if (!hypervisor(dc))
|
2333 |
goto priv_insn;
|
2334 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2335 |
offsetof(CPUSPARCState, ssr)); |
2336 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2337 |
break;
|
2338 |
case 31: // ver |
2339 |
tcg_gen_ld_tl(cpu_dst, cpu_env, |
2340 |
offsetof(CPUSPARCState, version)); |
2341 |
break;
|
2342 |
case 15: // fq |
2343 |
default:
|
2344 |
goto illegal_insn;
|
2345 |
} |
2346 |
#else
|
2347 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
2348 |
offsetof(CPUSPARCState, wim)); |
2349 |
tcg_gen_ext_i32_tl(cpu_dst, cpu_tmp32); |
2350 |
#endif
|
2351 |
gen_movl_TN_reg(rd, cpu_dst); |
2352 |
break;
|
2353 |
} else if (xop == 0x2b) { /* rdtbr / V9 flushw */ |
2354 |
#ifdef TARGET_SPARC64
|
2355 |
tcg_gen_helper_0_0(helper_flushw); |
2356 |
#else
|
2357 |
if (!supervisor(dc))
|
2358 |
goto priv_insn;
|
2359 |
tcg_gen_ld_tl(cpu_dst, cpu_env, offsetof(CPUSPARCState, tbr)); |
2360 |
gen_movl_TN_reg(rd, cpu_dst); |
2361 |
#endif
|
2362 |
break;
|
2363 |
#endif
|
2364 |
} else if (xop == 0x34) { /* FPU Operations */ |
2365 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
2366 |
goto jmp_insn;
|
2367 |
gen_op_clear_ieee_excp_and_FTT(); |
2368 |
rs1 = GET_FIELD(insn, 13, 17); |
2369 |
rs2 = GET_FIELD(insn, 27, 31); |
2370 |
xop = GET_FIELD(insn, 18, 26); |
2371 |
switch (xop) {
|
2372 |
case 0x1: /* fmovs */ |
2373 |
gen_op_load_fpr_FT0(rs2); |
2374 |
gen_op_store_FT0_fpr(rd); |
2375 |
break;
|
2376 |
case 0x5: /* fnegs */ |
2377 |
gen_op_load_fpr_FT1(rs2); |
2378 |
tcg_gen_helper_0_0(helper_fnegs); |
2379 |
gen_op_store_FT0_fpr(rd); |
2380 |
break;
|
2381 |
case 0x9: /* fabss */ |
2382 |
gen_op_load_fpr_FT1(rs2); |
2383 |
tcg_gen_helper_0_0(helper_fabss); |
2384 |
gen_op_store_FT0_fpr(rd); |
2385 |
break;
|
2386 |
case 0x29: /* fsqrts */ |
2387 |
CHECK_FPU_FEATURE(dc, FSQRT); |
2388 |
gen_op_load_fpr_FT1(rs2); |
2389 |
gen_clear_float_exceptions(); |
2390 |
tcg_gen_helper_0_0(helper_fsqrts); |
2391 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2392 |
gen_op_store_FT0_fpr(rd); |
2393 |
break;
|
2394 |
case 0x2a: /* fsqrtd */ |
2395 |
CHECK_FPU_FEATURE(dc, FSQRT); |
2396 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2397 |
gen_clear_float_exceptions(); |
2398 |
tcg_gen_helper_0_0(helper_fsqrtd); |
2399 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2400 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2401 |
break;
|
2402 |
case 0x2b: /* fsqrtq */ |
2403 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2404 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2405 |
gen_clear_float_exceptions(); |
2406 |
tcg_gen_helper_0_0(helper_fsqrtq); |
2407 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2408 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2409 |
break;
|
2410 |
case 0x41: |
2411 |
gen_op_load_fpr_FT0(rs1); |
2412 |
gen_op_load_fpr_FT1(rs2); |
2413 |
gen_clear_float_exceptions(); |
2414 |
tcg_gen_helper_0_0(helper_fadds); |
2415 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2416 |
gen_op_store_FT0_fpr(rd); |
2417 |
break;
|
2418 |
case 0x42: |
2419 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2420 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2421 |
gen_clear_float_exceptions(); |
2422 |
tcg_gen_helper_0_0(helper_faddd); |
2423 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2424 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2425 |
break;
|
2426 |
case 0x43: /* faddq */ |
2427 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2428 |
gen_op_load_fpr_QT0(QFPREG(rs1)); |
2429 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2430 |
gen_clear_float_exceptions(); |
2431 |
tcg_gen_helper_0_0(helper_faddq); |
2432 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2433 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2434 |
break;
|
2435 |
case 0x45: |
2436 |
gen_op_load_fpr_FT0(rs1); |
2437 |
gen_op_load_fpr_FT1(rs2); |
2438 |
gen_clear_float_exceptions(); |
2439 |
tcg_gen_helper_0_0(helper_fsubs); |
2440 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2441 |
gen_op_store_FT0_fpr(rd); |
2442 |
break;
|
2443 |
case 0x46: |
2444 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2445 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2446 |
gen_clear_float_exceptions(); |
2447 |
tcg_gen_helper_0_0(helper_fsubd); |
2448 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2449 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2450 |
break;
|
2451 |
case 0x47: /* fsubq */ |
2452 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2453 |
gen_op_load_fpr_QT0(QFPREG(rs1)); |
2454 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2455 |
gen_clear_float_exceptions(); |
2456 |
tcg_gen_helper_0_0(helper_fsubq); |
2457 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2458 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2459 |
break;
|
2460 |
case 0x49: /* fmuls */ |
2461 |
CHECK_FPU_FEATURE(dc, FMUL); |
2462 |
gen_op_load_fpr_FT0(rs1); |
2463 |
gen_op_load_fpr_FT1(rs2); |
2464 |
gen_clear_float_exceptions(); |
2465 |
tcg_gen_helper_0_0(helper_fmuls); |
2466 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2467 |
gen_op_store_FT0_fpr(rd); |
2468 |
break;
|
2469 |
case 0x4a: /* fmuld */ |
2470 |
CHECK_FPU_FEATURE(dc, FMUL); |
2471 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2472 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2473 |
gen_clear_float_exceptions(); |
2474 |
tcg_gen_helper_0_0(helper_fmuld); |
2475 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2476 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2477 |
break;
|
2478 |
case 0x4b: /* fmulq */ |
2479 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2480 |
CHECK_FPU_FEATURE(dc, FMUL); |
2481 |
gen_op_load_fpr_QT0(QFPREG(rs1)); |
2482 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2483 |
gen_clear_float_exceptions(); |
2484 |
tcg_gen_helper_0_0(helper_fmulq); |
2485 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2486 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2487 |
break;
|
2488 |
case 0x4d: |
2489 |
gen_op_load_fpr_FT0(rs1); |
2490 |
gen_op_load_fpr_FT1(rs2); |
2491 |
gen_clear_float_exceptions(); |
2492 |
tcg_gen_helper_0_0(helper_fdivs); |
2493 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2494 |
gen_op_store_FT0_fpr(rd); |
2495 |
break;
|
2496 |
case 0x4e: |
2497 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2498 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2499 |
gen_clear_float_exceptions(); |
2500 |
tcg_gen_helper_0_0(helper_fdivd); |
2501 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2502 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2503 |
break;
|
2504 |
case 0x4f: /* fdivq */ |
2505 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2506 |
gen_op_load_fpr_QT0(QFPREG(rs1)); |
2507 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2508 |
gen_clear_float_exceptions(); |
2509 |
tcg_gen_helper_0_0(helper_fdivq); |
2510 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2511 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2512 |
break;
|
2513 |
case 0x69: |
2514 |
gen_op_load_fpr_FT0(rs1); |
2515 |
gen_op_load_fpr_FT1(rs2); |
2516 |
gen_clear_float_exceptions(); |
2517 |
tcg_gen_helper_0_0(helper_fsmuld); |
2518 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2519 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2520 |
break;
|
2521 |
case 0x6e: /* fdmulq */ |
2522 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2523 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2524 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2525 |
gen_clear_float_exceptions(); |
2526 |
tcg_gen_helper_0_0(helper_fdmulq); |
2527 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2528 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2529 |
break;
|
2530 |
case 0xc4: |
2531 |
gen_op_load_fpr_FT1(rs2); |
2532 |
gen_clear_float_exceptions(); |
2533 |
tcg_gen_helper_0_0(helper_fitos); |
2534 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2535 |
gen_op_store_FT0_fpr(rd); |
2536 |
break;
|
2537 |
case 0xc6: |
2538 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2539 |
gen_clear_float_exceptions(); |
2540 |
tcg_gen_helper_0_0(helper_fdtos); |
2541 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2542 |
gen_op_store_FT0_fpr(rd); |
2543 |
break;
|
2544 |
case 0xc7: /* fqtos */ |
2545 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2546 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2547 |
gen_clear_float_exceptions(); |
2548 |
tcg_gen_helper_0_0(helper_fqtos); |
2549 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2550 |
gen_op_store_FT0_fpr(rd); |
2551 |
break;
|
2552 |
case 0xc8: |
2553 |
gen_op_load_fpr_FT1(rs2); |
2554 |
tcg_gen_helper_0_0(helper_fitod); |
2555 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2556 |
break;
|
2557 |
case 0xc9: |
2558 |
gen_op_load_fpr_FT1(rs2); |
2559 |
tcg_gen_helper_0_0(helper_fstod); |
2560 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2561 |
break;
|
2562 |
case 0xcb: /* fqtod */ |
2563 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2564 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2565 |
gen_clear_float_exceptions(); |
2566 |
tcg_gen_helper_0_0(helper_fqtod); |
2567 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2568 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2569 |
break;
|
2570 |
case 0xcc: /* fitoq */ |
2571 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2572 |
gen_op_load_fpr_FT1(rs2); |
2573 |
tcg_gen_helper_0_0(helper_fitoq); |
2574 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2575 |
break;
|
2576 |
case 0xcd: /* fstoq */ |
2577 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2578 |
gen_op_load_fpr_FT1(rs2); |
2579 |
tcg_gen_helper_0_0(helper_fstoq); |
2580 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2581 |
break;
|
2582 |
case 0xce: /* fdtoq */ |
2583 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2584 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2585 |
tcg_gen_helper_0_0(helper_fdtoq); |
2586 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2587 |
break;
|
2588 |
case 0xd1: |
2589 |
gen_op_load_fpr_FT1(rs2); |
2590 |
gen_clear_float_exceptions(); |
2591 |
tcg_gen_helper_0_0(helper_fstoi); |
2592 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2593 |
gen_op_store_FT0_fpr(rd); |
2594 |
break;
|
2595 |
case 0xd2: |
2596 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2597 |
gen_clear_float_exceptions(); |
2598 |
tcg_gen_helper_0_0(helper_fdtoi); |
2599 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2600 |
gen_op_store_FT0_fpr(rd); |
2601 |
break;
|
2602 |
case 0xd3: /* fqtoi */ |
2603 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2604 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2605 |
gen_clear_float_exceptions(); |
2606 |
tcg_gen_helper_0_0(helper_fqtoi); |
2607 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2608 |
gen_op_store_FT0_fpr(rd); |
2609 |
break;
|
2610 |
#ifdef TARGET_SPARC64
|
2611 |
case 0x2: /* V9 fmovd */ |
2612 |
gen_op_load_fpr_DT0(DFPREG(rs2)); |
2613 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2614 |
break;
|
2615 |
case 0x3: /* V9 fmovq */ |
2616 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2617 |
gen_op_load_fpr_QT0(QFPREG(rs2)); |
2618 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2619 |
break;
|
2620 |
case 0x6: /* V9 fnegd */ |
2621 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2622 |
tcg_gen_helper_0_0(helper_fnegd); |
2623 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2624 |
break;
|
2625 |
case 0x7: /* V9 fnegq */ |
2626 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2627 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2628 |
tcg_gen_helper_0_0(helper_fnegq); |
2629 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2630 |
break;
|
2631 |
case 0xa: /* V9 fabsd */ |
2632 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2633 |
tcg_gen_helper_0_0(helper_fabsd); |
2634 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2635 |
break;
|
2636 |
case 0xb: /* V9 fabsq */ |
2637 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2638 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2639 |
tcg_gen_helper_0_0(helper_fabsq); |
2640 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2641 |
break;
|
2642 |
case 0x81: /* V9 fstox */ |
2643 |
gen_op_load_fpr_FT1(rs2); |
2644 |
gen_clear_float_exceptions(); |
2645 |
tcg_gen_helper_0_0(helper_fstox); |
2646 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2647 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2648 |
break;
|
2649 |
case 0x82: /* V9 fdtox */ |
2650 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2651 |
gen_clear_float_exceptions(); |
2652 |
tcg_gen_helper_0_0(helper_fdtox); |
2653 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2654 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2655 |
break;
|
2656 |
case 0x83: /* V9 fqtox */ |
2657 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2658 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2659 |
gen_clear_float_exceptions(); |
2660 |
tcg_gen_helper_0_0(helper_fqtox); |
2661 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2662 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2663 |
break;
|
2664 |
case 0x84: /* V9 fxtos */ |
2665 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2666 |
gen_clear_float_exceptions(); |
2667 |
tcg_gen_helper_0_0(helper_fxtos); |
2668 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2669 |
gen_op_store_FT0_fpr(rd); |
2670 |
break;
|
2671 |
case 0x88: /* V9 fxtod */ |
2672 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2673 |
gen_clear_float_exceptions(); |
2674 |
tcg_gen_helper_0_0(helper_fxtod); |
2675 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2676 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2677 |
break;
|
2678 |
case 0x8c: /* V9 fxtoq */ |
2679 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2680 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2681 |
gen_clear_float_exceptions(); |
2682 |
tcg_gen_helper_0_0(helper_fxtoq); |
2683 |
tcg_gen_helper_0_0(helper_check_ieee_exceptions); |
2684 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2685 |
break;
|
2686 |
#endif
|
2687 |
default:
|
2688 |
goto illegal_insn;
|
2689 |
} |
2690 |
} else if (xop == 0x35) { /* FPU Operations */ |
2691 |
#ifdef TARGET_SPARC64
|
2692 |
int cond;
|
2693 |
#endif
|
2694 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
2695 |
goto jmp_insn;
|
2696 |
gen_op_clear_ieee_excp_and_FTT(); |
2697 |
rs1 = GET_FIELD(insn, 13, 17); |
2698 |
rs2 = GET_FIELD(insn, 27, 31); |
2699 |
xop = GET_FIELD(insn, 18, 26); |
2700 |
#ifdef TARGET_SPARC64
|
2701 |
if ((xop & 0x11f) == 0x005) { // V9 fmovsr |
2702 |
int l1;
|
2703 |
|
2704 |
l1 = gen_new_label(); |
2705 |
cond = GET_FIELD_SP(insn, 14, 17); |
2706 |
cpu_src1 = get_src1(insn, cpu_src1); |
2707 |
tcg_gen_brcondi_tl(gen_tcg_cond_reg[cond], cpu_src1, |
2708 |
0, l1);
|
2709 |
gen_op_load_fpr_FT0(rs2); |
2710 |
gen_op_store_FT0_fpr(rd); |
2711 |
gen_set_label(l1); |
2712 |
break;
|
2713 |
} else if ((xop & 0x11f) == 0x006) { // V9 fmovdr |
2714 |
int l1;
|
2715 |
|
2716 |
l1 = gen_new_label(); |
2717 |
cond = GET_FIELD_SP(insn, 14, 17); |
2718 |
cpu_src1 = get_src1(insn, cpu_src1); |
2719 |
tcg_gen_brcondi_tl(gen_tcg_cond_reg[cond], cpu_src1, |
2720 |
0, l1);
|
2721 |
gen_op_load_fpr_DT0(DFPREG(rs2)); |
2722 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
2723 |
gen_set_label(l1); |
2724 |
break;
|
2725 |
} else if ((xop & 0x11f) == 0x007) { // V9 fmovqr |
2726 |
int l1;
|
2727 |
|
2728 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2729 |
l1 = gen_new_label(); |
2730 |
cond = GET_FIELD_SP(insn, 14, 17); |
2731 |
cpu_src1 = get_src1(insn, cpu_src1); |
2732 |
tcg_gen_brcondi_tl(gen_tcg_cond_reg[cond], cpu_src1, |
2733 |
0, l1);
|
2734 |
gen_op_load_fpr_QT0(QFPREG(rs2)); |
2735 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
2736 |
gen_set_label(l1); |
2737 |
break;
|
2738 |
} |
2739 |
#endif
|
2740 |
switch (xop) {
|
2741 |
#ifdef TARGET_SPARC64
|
2742 |
#define FMOVCC(size_FDQ, fcc) \
|
2743 |
{ \ |
2744 |
TCGv r_cond; \ |
2745 |
int l1; \
|
2746 |
\ |
2747 |
l1 = gen_new_label(); \ |
2748 |
r_cond = tcg_temp_new(TCG_TYPE_TL); \ |
2749 |
cond = GET_FIELD_SP(insn, 14, 17); \ |
2750 |
gen_fcond(r_cond, fcc, cond); \ |
2751 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, \ |
2752 |
0, l1); \
|
2753 |
glue(glue(gen_op_load_fpr_, size_FDQ), T0) \ |
2754 |
(glue(size_FDQ, FPREG(rs2))); \ |
2755 |
glue(glue(gen_op_store_, size_FDQ), T0_fpr) \ |
2756 |
(glue(size_FDQ, FPREG(rd))); \ |
2757 |
gen_set_label(l1); \ |
2758 |
tcg_temp_free(r_cond); \ |
2759 |
} |
2760 |
case 0x001: /* V9 fmovscc %fcc0 */ |
2761 |
FMOVCC(F, 0);
|
2762 |
break;
|
2763 |
case 0x002: /* V9 fmovdcc %fcc0 */ |
2764 |
FMOVCC(D, 0);
|
2765 |
break;
|
2766 |
case 0x003: /* V9 fmovqcc %fcc0 */ |
2767 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2768 |
FMOVCC(Q, 0);
|
2769 |
break;
|
2770 |
case 0x041: /* V9 fmovscc %fcc1 */ |
2771 |
FMOVCC(F, 1);
|
2772 |
break;
|
2773 |
case 0x042: /* V9 fmovdcc %fcc1 */ |
2774 |
FMOVCC(D, 1);
|
2775 |
break;
|
2776 |
case 0x043: /* V9 fmovqcc %fcc1 */ |
2777 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2778 |
FMOVCC(Q, 1);
|
2779 |
break;
|
2780 |
case 0x081: /* V9 fmovscc %fcc2 */ |
2781 |
FMOVCC(F, 2);
|
2782 |
break;
|
2783 |
case 0x082: /* V9 fmovdcc %fcc2 */ |
2784 |
FMOVCC(D, 2);
|
2785 |
break;
|
2786 |
case 0x083: /* V9 fmovqcc %fcc2 */ |
2787 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2788 |
FMOVCC(Q, 2);
|
2789 |
break;
|
2790 |
case 0x0c1: /* V9 fmovscc %fcc3 */ |
2791 |
FMOVCC(F, 3);
|
2792 |
break;
|
2793 |
case 0x0c2: /* V9 fmovdcc %fcc3 */ |
2794 |
FMOVCC(D, 3);
|
2795 |
break;
|
2796 |
case 0x0c3: /* V9 fmovqcc %fcc3 */ |
2797 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2798 |
FMOVCC(Q, 3);
|
2799 |
break;
|
2800 |
#undef FMOVCC
|
2801 |
#define FMOVCC(size_FDQ, icc) \
|
2802 |
{ \ |
2803 |
TCGv r_cond; \ |
2804 |
int l1; \
|
2805 |
\ |
2806 |
l1 = gen_new_label(); \ |
2807 |
r_cond = tcg_temp_new(TCG_TYPE_TL); \ |
2808 |
cond = GET_FIELD_SP(insn, 14, 17); \ |
2809 |
gen_cond(r_cond, icc, cond); \ |
2810 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, \ |
2811 |
0, l1); \
|
2812 |
glue(glue(gen_op_load_fpr_, size_FDQ), T0) \ |
2813 |
(glue(size_FDQ, FPREG(rs2))); \ |
2814 |
glue(glue(gen_op_store_, size_FDQ), T0_fpr) \ |
2815 |
(glue(size_FDQ, FPREG(rd))); \ |
2816 |
gen_set_label(l1); \ |
2817 |
tcg_temp_free(r_cond); \ |
2818 |
} |
2819 |
|
2820 |
case 0x101: /* V9 fmovscc %icc */ |
2821 |
FMOVCC(F, 0);
|
2822 |
break;
|
2823 |
case 0x102: /* V9 fmovdcc %icc */ |
2824 |
FMOVCC(D, 0);
|
2825 |
case 0x103: /* V9 fmovqcc %icc */ |
2826 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2827 |
FMOVCC(Q, 0);
|
2828 |
break;
|
2829 |
case 0x181: /* V9 fmovscc %xcc */ |
2830 |
FMOVCC(F, 1);
|
2831 |
break;
|
2832 |
case 0x182: /* V9 fmovdcc %xcc */ |
2833 |
FMOVCC(D, 1);
|
2834 |
break;
|
2835 |
case 0x183: /* V9 fmovqcc %xcc */ |
2836 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2837 |
FMOVCC(Q, 1);
|
2838 |
break;
|
2839 |
#undef FMOVCC
|
2840 |
#endif
|
2841 |
case 0x51: /* fcmps, V9 %fcc */ |
2842 |
gen_op_load_fpr_FT0(rs1); |
2843 |
gen_op_load_fpr_FT1(rs2); |
2844 |
gen_op_fcmps(rd & 3);
|
2845 |
break;
|
2846 |
case 0x52: /* fcmpd, V9 %fcc */ |
2847 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2848 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2849 |
gen_op_fcmpd(rd & 3);
|
2850 |
break;
|
2851 |
case 0x53: /* fcmpq, V9 %fcc */ |
2852 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2853 |
gen_op_load_fpr_QT0(QFPREG(rs1)); |
2854 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2855 |
gen_op_fcmpq(rd & 3);
|
2856 |
break;
|
2857 |
case 0x55: /* fcmpes, V9 %fcc */ |
2858 |
gen_op_load_fpr_FT0(rs1); |
2859 |
gen_op_load_fpr_FT1(rs2); |
2860 |
gen_op_fcmpes(rd & 3);
|
2861 |
break;
|
2862 |
case 0x56: /* fcmped, V9 %fcc */ |
2863 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
2864 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
2865 |
gen_op_fcmped(rd & 3);
|
2866 |
break;
|
2867 |
case 0x57: /* fcmpeq, V9 %fcc */ |
2868 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
2869 |
gen_op_load_fpr_QT0(QFPREG(rs1)); |
2870 |
gen_op_load_fpr_QT1(QFPREG(rs2)); |
2871 |
gen_op_fcmpeq(rd & 3);
|
2872 |
break;
|
2873 |
default:
|
2874 |
goto illegal_insn;
|
2875 |
} |
2876 |
} else if (xop == 0x2) { |
2877 |
// clr/mov shortcut
|
2878 |
|
2879 |
rs1 = GET_FIELD(insn, 13, 17); |
2880 |
if (rs1 == 0) { |
2881 |
// or %g0, x, y -> mov T0, x; mov y, T0
|
2882 |
if (IS_IMM) { /* immediate */ |
2883 |
TCGv r_const; |
2884 |
|
2885 |
rs2 = GET_FIELDs(insn, 19, 31); |
2886 |
r_const = tcg_const_tl((int)rs2);
|
2887 |
gen_movl_TN_reg(rd, r_const); |
2888 |
tcg_temp_free(r_const); |
2889 |
} else { /* register */ |
2890 |
rs2 = GET_FIELD(insn, 27, 31); |
2891 |
gen_movl_reg_TN(rs2, cpu_dst); |
2892 |
gen_movl_TN_reg(rd, cpu_dst); |
2893 |
} |
2894 |
} else {
|
2895 |
cpu_src1 = get_src1(insn, cpu_src1); |
2896 |
if (IS_IMM) { /* immediate */ |
2897 |
rs2 = GET_FIELDs(insn, 19, 31); |
2898 |
tcg_gen_ori_tl(cpu_dst, cpu_src1, (int)rs2);
|
2899 |
gen_movl_TN_reg(rd, cpu_dst); |
2900 |
} else { /* register */ |
2901 |
// or x, %g0, y -> mov T1, x; mov y, T1
|
2902 |
rs2 = GET_FIELD(insn, 27, 31); |
2903 |
if (rs2 != 0) { |
2904 |
gen_movl_reg_TN(rs2, cpu_src2); |
2905 |
tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2); |
2906 |
gen_movl_TN_reg(rd, cpu_dst); |
2907 |
} else
|
2908 |
gen_movl_TN_reg(rd, cpu_src1); |
2909 |
} |
2910 |
} |
2911 |
#ifdef TARGET_SPARC64
|
2912 |
} else if (xop == 0x25) { /* sll, V9 sllx */ |
2913 |
cpu_src1 = get_src1(insn, cpu_src1); |
2914 |
if (IS_IMM) { /* immediate */ |
2915 |
rs2 = GET_FIELDs(insn, 20, 31); |
2916 |
if (insn & (1 << 12)) { |
2917 |
tcg_gen_shli_i64(cpu_dst, cpu_src1, rs2 & 0x3f);
|
2918 |
} else {
|
2919 |
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2920 |
tcg_gen_shli_i64(cpu_dst, cpu_dst, rs2 & 0x1f);
|
2921 |
} |
2922 |
} else { /* register */ |
2923 |
rs2 = GET_FIELD(insn, 27, 31); |
2924 |
gen_movl_reg_TN(rs2, cpu_src2); |
2925 |
if (insn & (1 << 12)) { |
2926 |
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
2927 |
tcg_gen_shl_i64(cpu_dst, cpu_src1, cpu_tmp0); |
2928 |
} else {
|
2929 |
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2930 |
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2931 |
tcg_gen_shl_i64(cpu_dst, cpu_dst, cpu_tmp0); |
2932 |
} |
2933 |
} |
2934 |
gen_movl_TN_reg(rd, cpu_dst); |
2935 |
} else if (xop == 0x26) { /* srl, V9 srlx */ |
2936 |
cpu_src1 = get_src1(insn, cpu_src1); |
2937 |
if (IS_IMM) { /* immediate */ |
2938 |
rs2 = GET_FIELDs(insn, 20, 31); |
2939 |
if (insn & (1 << 12)) { |
2940 |
tcg_gen_shri_i64(cpu_dst, cpu_src1, rs2 & 0x3f);
|
2941 |
} else {
|
2942 |
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2943 |
tcg_gen_shri_i64(cpu_dst, cpu_dst, rs2 & 0x1f);
|
2944 |
} |
2945 |
} else { /* register */ |
2946 |
rs2 = GET_FIELD(insn, 27, 31); |
2947 |
gen_movl_reg_TN(rs2, cpu_src2); |
2948 |
if (insn & (1 << 12)) { |
2949 |
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
2950 |
tcg_gen_shr_i64(cpu_dst, cpu_src1, cpu_tmp0); |
2951 |
} else {
|
2952 |
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2953 |
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2954 |
tcg_gen_shr_i64(cpu_dst, cpu_dst, cpu_tmp0); |
2955 |
} |
2956 |
} |
2957 |
gen_movl_TN_reg(rd, cpu_dst); |
2958 |
} else if (xop == 0x27) { /* sra, V9 srax */ |
2959 |
cpu_src1 = get_src1(insn, cpu_src1); |
2960 |
if (IS_IMM) { /* immediate */ |
2961 |
rs2 = GET_FIELDs(insn, 20, 31); |
2962 |
if (insn & (1 << 12)) { |
2963 |
tcg_gen_sari_i64(cpu_dst, cpu_src1, rs2 & 0x3f);
|
2964 |
} else {
|
2965 |
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2966 |
tcg_gen_ext_i32_i64(cpu_dst, cpu_dst); |
2967 |
tcg_gen_sari_i64(cpu_dst, cpu_dst, rs2 & 0x1f);
|
2968 |
} |
2969 |
} else { /* register */ |
2970 |
rs2 = GET_FIELD(insn, 27, 31); |
2971 |
gen_movl_reg_TN(rs2, cpu_src2); |
2972 |
if (insn & (1 << 12)) { |
2973 |
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x3f);
|
2974 |
tcg_gen_sar_i64(cpu_dst, cpu_src1, cpu_tmp0); |
2975 |
} else {
|
2976 |
tcg_gen_andi_i64(cpu_tmp0, cpu_src2, 0x1f);
|
2977 |
tcg_gen_andi_i64(cpu_dst, cpu_src1, 0xffffffffULL);
|
2978 |
tcg_gen_sar_i64(cpu_dst, cpu_dst, cpu_tmp0); |
2979 |
} |
2980 |
} |
2981 |
gen_movl_TN_reg(rd, cpu_dst); |
2982 |
#endif
|
2983 |
} else if (xop < 0x36) { |
2984 |
cpu_src1 = get_src1(insn, cpu_src1); |
2985 |
cpu_src2 = get_src2(insn, cpu_src2); |
2986 |
if (xop < 0x20) { |
2987 |
switch (xop & ~0x10) { |
2988 |
case 0x0: |
2989 |
if (xop & 0x10) |
2990 |
gen_op_add_cc(cpu_dst, cpu_src1, cpu_src2); |
2991 |
else
|
2992 |
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); |
2993 |
break;
|
2994 |
case 0x1: |
2995 |
tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_src2); |
2996 |
if (xop & 0x10) |
2997 |
gen_op_logic_cc(cpu_dst); |
2998 |
break;
|
2999 |
case 0x2: |
3000 |
tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_src2); |
3001 |
if (xop & 0x10) |
3002 |
gen_op_logic_cc(cpu_dst); |
3003 |
break;
|
3004 |
case 0x3: |
3005 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3006 |
if (xop & 0x10) |
3007 |
gen_op_logic_cc(cpu_dst); |
3008 |
break;
|
3009 |
case 0x4: |
3010 |
if (xop & 0x10) |
3011 |
gen_op_sub_cc(cpu_dst, cpu_src1, cpu_src2); |
3012 |
else
|
3013 |
tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_src2); |
3014 |
break;
|
3015 |
case 0x5: |
3016 |
tcg_gen_xori_tl(cpu_tmp0, cpu_src2, -1);
|
3017 |
tcg_gen_and_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3018 |
if (xop & 0x10) |
3019 |
gen_op_logic_cc(cpu_dst); |
3020 |
break;
|
3021 |
case 0x6: |
3022 |
tcg_gen_xori_tl(cpu_tmp0, cpu_src2, -1);
|
3023 |
tcg_gen_or_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3024 |
if (xop & 0x10) |
3025 |
gen_op_logic_cc(cpu_dst); |
3026 |
break;
|
3027 |
case 0x7: |
3028 |
tcg_gen_xori_tl(cpu_tmp0, cpu_src2, -1);
|
3029 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3030 |
if (xop & 0x10) |
3031 |
gen_op_logic_cc(cpu_dst); |
3032 |
break;
|
3033 |
case 0x8: |
3034 |
if (xop & 0x10) |
3035 |
gen_op_addx_cc(cpu_dst, cpu_src1, cpu_src2); |
3036 |
else {
|
3037 |
gen_mov_reg_C(cpu_tmp0, cpu_psr); |
3038 |
tcg_gen_add_tl(cpu_tmp0, cpu_src2, cpu_tmp0); |
3039 |
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3040 |
} |
3041 |
break;
|
3042 |
#ifdef TARGET_SPARC64
|
3043 |
case 0x9: /* V9 mulx */ |
3044 |
tcg_gen_mul_i64(cpu_dst, cpu_src1, cpu_src2); |
3045 |
break;
|
3046 |
#endif
|
3047 |
case 0xa: |
3048 |
CHECK_IU_FEATURE(dc, MUL); |
3049 |
gen_op_umul(cpu_dst, cpu_src1, cpu_src2); |
3050 |
if (xop & 0x10) |
3051 |
gen_op_logic_cc(cpu_dst); |
3052 |
break;
|
3053 |
case 0xb: |
3054 |
CHECK_IU_FEATURE(dc, MUL); |
3055 |
gen_op_smul(cpu_dst, cpu_src1, cpu_src2); |
3056 |
if (xop & 0x10) |
3057 |
gen_op_logic_cc(cpu_dst); |
3058 |
break;
|
3059 |
case 0xc: |
3060 |
if (xop & 0x10) |
3061 |
gen_op_subx_cc(cpu_dst, cpu_src1, cpu_src2); |
3062 |
else {
|
3063 |
gen_mov_reg_C(cpu_tmp0, cpu_psr); |
3064 |
tcg_gen_add_tl(cpu_tmp0, cpu_src2, cpu_tmp0); |
3065 |
tcg_gen_sub_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3066 |
} |
3067 |
break;
|
3068 |
#ifdef TARGET_SPARC64
|
3069 |
case 0xd: /* V9 udivx */ |
3070 |
gen_trap_ifdivzero_tl(cpu_src2); |
3071 |
tcg_gen_divu_i64(cpu_dst, cpu_src1, cpu_src2); |
3072 |
break;
|
3073 |
#endif
|
3074 |
case 0xe: |
3075 |
CHECK_IU_FEATURE(dc, DIV); |
3076 |
tcg_gen_helper_1_2(helper_udiv, cpu_dst, cpu_src1, |
3077 |
cpu_src2); |
3078 |
if (xop & 0x10) |
3079 |
gen_op_div_cc(cpu_dst); |
3080 |
break;
|
3081 |
case 0xf: |
3082 |
CHECK_IU_FEATURE(dc, DIV); |
3083 |
tcg_gen_helper_1_2(helper_sdiv, cpu_dst, cpu_src1, |
3084 |
cpu_src2); |
3085 |
if (xop & 0x10) |
3086 |
gen_op_div_cc(cpu_dst); |
3087 |
break;
|
3088 |
default:
|
3089 |
goto illegal_insn;
|
3090 |
} |
3091 |
gen_movl_TN_reg(rd, cpu_dst); |
3092 |
} else {
|
3093 |
switch (xop) {
|
3094 |
case 0x20: /* taddcc */ |
3095 |
gen_op_tadd_cc(cpu_dst, cpu_src1, cpu_src2); |
3096 |
gen_movl_TN_reg(rd, cpu_dst); |
3097 |
break;
|
3098 |
case 0x21: /* tsubcc */ |
3099 |
gen_op_tsub_cc(cpu_dst, cpu_src1, cpu_src2); |
3100 |
gen_movl_TN_reg(rd, cpu_dst); |
3101 |
break;
|
3102 |
case 0x22: /* taddcctv */ |
3103 |
save_state(dc, cpu_cond); |
3104 |
gen_op_tadd_ccTV(cpu_dst, cpu_src1, cpu_src2); |
3105 |
gen_movl_TN_reg(rd, cpu_dst); |
3106 |
break;
|
3107 |
case 0x23: /* tsubcctv */ |
3108 |
save_state(dc, cpu_cond); |
3109 |
gen_op_tsub_ccTV(cpu_dst, cpu_src1, cpu_src2); |
3110 |
gen_movl_TN_reg(rd, cpu_dst); |
3111 |
break;
|
3112 |
case 0x24: /* mulscc */ |
3113 |
gen_op_mulscc(cpu_dst, cpu_src1, cpu_src2); |
3114 |
gen_movl_TN_reg(rd, cpu_dst); |
3115 |
break;
|
3116 |
#ifndef TARGET_SPARC64
|
3117 |
case 0x25: /* sll */ |
3118 |
if (IS_IMM) { /* immediate */ |
3119 |
rs2 = GET_FIELDs(insn, 20, 31); |
3120 |
tcg_gen_shli_tl(cpu_dst, cpu_src1, rs2 & 0x1f);
|
3121 |
} else { /* register */ |
3122 |
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
3123 |
tcg_gen_shl_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3124 |
} |
3125 |
gen_movl_TN_reg(rd, cpu_dst); |
3126 |
break;
|
3127 |
case 0x26: /* srl */ |
3128 |
if (IS_IMM) { /* immediate */ |
3129 |
rs2 = GET_FIELDs(insn, 20, 31); |
3130 |
tcg_gen_shri_tl(cpu_dst, cpu_src1, rs2 & 0x1f);
|
3131 |
} else { /* register */ |
3132 |
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
3133 |
tcg_gen_shr_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3134 |
} |
3135 |
gen_movl_TN_reg(rd, cpu_dst); |
3136 |
break;
|
3137 |
case 0x27: /* sra */ |
3138 |
if (IS_IMM) { /* immediate */ |
3139 |
rs2 = GET_FIELDs(insn, 20, 31); |
3140 |
tcg_gen_sari_tl(cpu_dst, cpu_src1, rs2 & 0x1f);
|
3141 |
} else { /* register */ |
3142 |
tcg_gen_andi_tl(cpu_tmp0, cpu_src2, 0x1f);
|
3143 |
tcg_gen_sar_tl(cpu_dst, cpu_src1, cpu_tmp0); |
3144 |
} |
3145 |
gen_movl_TN_reg(rd, cpu_dst); |
3146 |
break;
|
3147 |
#endif
|
3148 |
case 0x30: |
3149 |
{ |
3150 |
switch(rd) {
|
3151 |
case 0: /* wry */ |
3152 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3153 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3154 |
offsetof(CPUSPARCState, y)); |
3155 |
break;
|
3156 |
#ifndef TARGET_SPARC64
|
3157 |
case 0x01 ... 0x0f: /* undefined in the |
3158 |
SPARCv8 manual, nop
|
3159 |
on the microSPARC
|
3160 |
II */
|
3161 |
case 0x10 ... 0x1f: /* implementation-dependent |
3162 |
in the SPARCv8
|
3163 |
manual, nop on the
|
3164 |
microSPARC II */
|
3165 |
break;
|
3166 |
#else
|
3167 |
case 0x2: /* V9 wrccr */ |
3168 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3169 |
tcg_gen_helper_0_1(helper_wrccr, cpu_dst); |
3170 |
break;
|
3171 |
case 0x3: /* V9 wrasi */ |
3172 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3173 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3174 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3175 |
offsetof(CPUSPARCState, asi)); |
3176 |
break;
|
3177 |
case 0x6: /* V9 wrfprs */ |
3178 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3179 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3180 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3181 |
offsetof(CPUSPARCState, fprs)); |
3182 |
save_state(dc, cpu_cond); |
3183 |
gen_op_next_insn(); |
3184 |
tcg_gen_exit_tb(0);
|
3185 |
dc->is_br = 1;
|
3186 |
break;
|
3187 |
case 0xf: /* V9 sir, nop if user */ |
3188 |
#if !defined(CONFIG_USER_ONLY)
|
3189 |
if (supervisor(dc))
|
3190 |
; // XXX
|
3191 |
#endif
|
3192 |
break;
|
3193 |
case 0x13: /* Graphics Status */ |
3194 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
3195 |
goto jmp_insn;
|
3196 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3197 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3198 |
offsetof(CPUSPARCState, gsr)); |
3199 |
break;
|
3200 |
case 0x17: /* Tick compare */ |
3201 |
#if !defined(CONFIG_USER_ONLY)
|
3202 |
if (!supervisor(dc))
|
3203 |
goto illegal_insn;
|
3204 |
#endif
|
3205 |
{ |
3206 |
TCGv r_tickptr; |
3207 |
|
3208 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, |
3209 |
cpu_src2); |
3210 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3211 |
offsetof(CPUSPARCState, |
3212 |
tick_cmpr)); |
3213 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
3214 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
3215 |
offsetof(CPUState, tick)); |
3216 |
tcg_gen_helper_0_2(helper_tick_set_limit, |
3217 |
r_tickptr, cpu_dst); |
3218 |
tcg_temp_free(r_tickptr); |
3219 |
} |
3220 |
break;
|
3221 |
case 0x18: /* System tick */ |
3222 |
#if !defined(CONFIG_USER_ONLY)
|
3223 |
if (!supervisor(dc))
|
3224 |
goto illegal_insn;
|
3225 |
#endif
|
3226 |
{ |
3227 |
TCGv r_tickptr; |
3228 |
|
3229 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, |
3230 |
cpu_src2); |
3231 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
3232 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
3233 |
offsetof(CPUState, stick)); |
3234 |
tcg_gen_helper_0_2(helper_tick_set_count, |
3235 |
r_tickptr, cpu_dst); |
3236 |
tcg_temp_free(r_tickptr); |
3237 |
} |
3238 |
break;
|
3239 |
case 0x19: /* System tick compare */ |
3240 |
#if !defined(CONFIG_USER_ONLY)
|
3241 |
if (!supervisor(dc))
|
3242 |
goto illegal_insn;
|
3243 |
#endif
|
3244 |
{ |
3245 |
TCGv r_tickptr; |
3246 |
|
3247 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, |
3248 |
cpu_src2); |
3249 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3250 |
offsetof(CPUSPARCState, |
3251 |
stick_cmpr)); |
3252 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
3253 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
3254 |
offsetof(CPUState, stick)); |
3255 |
tcg_gen_helper_0_2(helper_tick_set_limit, |
3256 |
r_tickptr, cpu_dst); |
3257 |
tcg_temp_free(r_tickptr); |
3258 |
} |
3259 |
break;
|
3260 |
|
3261 |
case 0x10: /* Performance Control */ |
3262 |
case 0x11: /* Performance Instrumentation |
3263 |
Counter */
|
3264 |
case 0x12: /* Dispatch Control */ |
3265 |
case 0x14: /* Softint set */ |
3266 |
case 0x15: /* Softint clear */ |
3267 |
case 0x16: /* Softint write */ |
3268 |
#endif
|
3269 |
default:
|
3270 |
goto illegal_insn;
|
3271 |
} |
3272 |
} |
3273 |
break;
|
3274 |
#if !defined(CONFIG_USER_ONLY)
|
3275 |
case 0x31: /* wrpsr, V9 saved, restored */ |
3276 |
{ |
3277 |
if (!supervisor(dc))
|
3278 |
goto priv_insn;
|
3279 |
#ifdef TARGET_SPARC64
|
3280 |
switch (rd) {
|
3281 |
case 0: |
3282 |
tcg_gen_helper_0_0(helper_saved); |
3283 |
break;
|
3284 |
case 1: |
3285 |
tcg_gen_helper_0_0(helper_restored); |
3286 |
break;
|
3287 |
case 2: /* UA2005 allclean */ |
3288 |
case 3: /* UA2005 otherw */ |
3289 |
case 4: /* UA2005 normalw */ |
3290 |
case 5: /* UA2005 invalw */ |
3291 |
// XXX
|
3292 |
default:
|
3293 |
goto illegal_insn;
|
3294 |
} |
3295 |
#else
|
3296 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3297 |
tcg_gen_helper_0_1(helper_wrpsr, cpu_dst); |
3298 |
save_state(dc, cpu_cond); |
3299 |
gen_op_next_insn(); |
3300 |
tcg_gen_exit_tb(0);
|
3301 |
dc->is_br = 1;
|
3302 |
#endif
|
3303 |
} |
3304 |
break;
|
3305 |
case 0x32: /* wrwim, V9 wrpr */ |
3306 |
{ |
3307 |
if (!supervisor(dc))
|
3308 |
goto priv_insn;
|
3309 |
tcg_gen_xor_tl(cpu_dst, cpu_src1, cpu_src2); |
3310 |
#ifdef TARGET_SPARC64
|
3311 |
switch (rd) {
|
3312 |
case 0: // tpc |
3313 |
{ |
3314 |
TCGv r_tsptr; |
3315 |
|
3316 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
3317 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
3318 |
offsetof(CPUState, tsptr)); |
3319 |
tcg_gen_st_tl(cpu_dst, r_tsptr, |
3320 |
offsetof(trap_state, tpc)); |
3321 |
tcg_temp_free(r_tsptr); |
3322 |
} |
3323 |
break;
|
3324 |
case 1: // tnpc |
3325 |
{ |
3326 |
TCGv r_tsptr; |
3327 |
|
3328 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
3329 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
3330 |
offsetof(CPUState, tsptr)); |
3331 |
tcg_gen_st_tl(cpu_dst, r_tsptr, |
3332 |
offsetof(trap_state, tnpc)); |
3333 |
tcg_temp_free(r_tsptr); |
3334 |
} |
3335 |
break;
|
3336 |
case 2: // tstate |
3337 |
{ |
3338 |
TCGv r_tsptr; |
3339 |
|
3340 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
3341 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
3342 |
offsetof(CPUState, tsptr)); |
3343 |
tcg_gen_st_tl(cpu_dst, r_tsptr, |
3344 |
offsetof(trap_state, |
3345 |
tstate)); |
3346 |
tcg_temp_free(r_tsptr); |
3347 |
} |
3348 |
break;
|
3349 |
case 3: // tt |
3350 |
{ |
3351 |
TCGv r_tsptr; |
3352 |
|
3353 |
r_tsptr = tcg_temp_new(TCG_TYPE_PTR); |
3354 |
tcg_gen_ld_ptr(r_tsptr, cpu_env, |
3355 |
offsetof(CPUState, tsptr)); |
3356 |
tcg_gen_st_i32(cpu_dst, r_tsptr, |
3357 |
offsetof(trap_state, tt)); |
3358 |
tcg_temp_free(r_tsptr); |
3359 |
} |
3360 |
break;
|
3361 |
case 4: // tick |
3362 |
{ |
3363 |
TCGv r_tickptr; |
3364 |
|
3365 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
3366 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
3367 |
offsetof(CPUState, tick)); |
3368 |
tcg_gen_helper_0_2(helper_tick_set_count, |
3369 |
r_tickptr, cpu_dst); |
3370 |
tcg_temp_free(r_tickptr); |
3371 |
} |
3372 |
break;
|
3373 |
case 5: // tba |
3374 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3375 |
offsetof(CPUSPARCState, tbr)); |
3376 |
break;
|
3377 |
case 6: // pstate |
3378 |
save_state(dc, cpu_cond); |
3379 |
tcg_gen_helper_0_1(helper_wrpstate, cpu_dst); |
3380 |
gen_op_next_insn(); |
3381 |
tcg_gen_exit_tb(0);
|
3382 |
dc->is_br = 1;
|
3383 |
break;
|
3384 |
case 7: // tl |
3385 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3386 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3387 |
offsetof(CPUSPARCState, tl)); |
3388 |
break;
|
3389 |
case 8: // pil |
3390 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3391 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3392 |
offsetof(CPUSPARCState, |
3393 |
psrpil)); |
3394 |
break;
|
3395 |
case 9: // cwp |
3396 |
tcg_gen_helper_0_1(helper_wrcwp, cpu_dst); |
3397 |
break;
|
3398 |
case 10: // cansave |
3399 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3400 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3401 |
offsetof(CPUSPARCState, |
3402 |
cansave)); |
3403 |
break;
|
3404 |
case 11: // canrestore |
3405 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3406 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3407 |
offsetof(CPUSPARCState, |
3408 |
canrestore)); |
3409 |
break;
|
3410 |
case 12: // cleanwin |
3411 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3412 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3413 |
offsetof(CPUSPARCState, |
3414 |
cleanwin)); |
3415 |
break;
|
3416 |
case 13: // otherwin |
3417 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3418 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3419 |
offsetof(CPUSPARCState, |
3420 |
otherwin)); |
3421 |
break;
|
3422 |
case 14: // wstate |
3423 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3424 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3425 |
offsetof(CPUSPARCState, |
3426 |
wstate)); |
3427 |
break;
|
3428 |
case 16: // UA2005 gl |
3429 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3430 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3431 |
offsetof(CPUSPARCState, gl)); |
3432 |
break;
|
3433 |
case 26: // UA2005 strand status |
3434 |
if (!hypervisor(dc))
|
3435 |
goto priv_insn;
|
3436 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3437 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3438 |
offsetof(CPUSPARCState, ssr)); |
3439 |
break;
|
3440 |
default:
|
3441 |
goto illegal_insn;
|
3442 |
} |
3443 |
#else
|
3444 |
tcg_gen_andi_tl(cpu_dst, cpu_dst, |
3445 |
((1 << NWINDOWS) - 1)); |
3446 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3447 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3448 |
offsetof(CPUSPARCState, wim)); |
3449 |
#endif
|
3450 |
} |
3451 |
break;
|
3452 |
case 0x33: /* wrtbr, UA2005 wrhpr */ |
3453 |
{ |
3454 |
#ifndef TARGET_SPARC64
|
3455 |
if (!supervisor(dc))
|
3456 |
goto priv_insn;
|
3457 |
tcg_gen_xor_tl(cpu_dst, cpu_dst, cpu_src2); |
3458 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3459 |
offsetof(CPUSPARCState, tbr)); |
3460 |
#else
|
3461 |
if (!hypervisor(dc))
|
3462 |
goto priv_insn;
|
3463 |
tcg_gen_xor_tl(cpu_dst, cpu_dst, cpu_src2); |
3464 |
switch (rd) {
|
3465 |
case 0: // hpstate |
3466 |
// XXX gen_op_wrhpstate();
|
3467 |
save_state(dc, cpu_cond); |
3468 |
gen_op_next_insn(); |
3469 |
tcg_gen_exit_tb(0);
|
3470 |
dc->is_br = 1;
|
3471 |
break;
|
3472 |
case 1: // htstate |
3473 |
// XXX gen_op_wrhtstate();
|
3474 |
break;
|
3475 |
case 3: // hintp |
3476 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3477 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3478 |
offsetof(CPUSPARCState, hintp)); |
3479 |
break;
|
3480 |
case 5: // htba |
3481 |
tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_dst); |
3482 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
3483 |
offsetof(CPUSPARCState, htba)); |
3484 |
break;
|
3485 |
case 31: // hstick_cmpr |
3486 |
{ |
3487 |
TCGv r_tickptr; |
3488 |
|
3489 |
tcg_gen_st_tl(cpu_dst, cpu_env, |
3490 |
offsetof(CPUSPARCState, |
3491 |
hstick_cmpr)); |
3492 |
r_tickptr = tcg_temp_new(TCG_TYPE_PTR); |
3493 |
tcg_gen_ld_ptr(r_tickptr, cpu_env, |
3494 |
offsetof(CPUState, hstick)); |
3495 |
tcg_gen_helper_0_2(helper_tick_set_limit, |
3496 |
r_tickptr, cpu_dst); |
3497 |
tcg_temp_free(r_tickptr); |
3498 |
} |
3499 |
break;
|
3500 |
case 6: // hver readonly |
3501 |
default:
|
3502 |
goto illegal_insn;
|
3503 |
} |
3504 |
#endif
|
3505 |
} |
3506 |
break;
|
3507 |
#endif
|
3508 |
#ifdef TARGET_SPARC64
|
3509 |
case 0x2c: /* V9 movcc */ |
3510 |
{ |
3511 |
int cc = GET_FIELD_SP(insn, 11, 12); |
3512 |
int cond = GET_FIELD_SP(insn, 14, 17); |
3513 |
TCGv r_cond; |
3514 |
int l1;
|
3515 |
|
3516 |
r_cond = tcg_temp_new(TCG_TYPE_TL); |
3517 |
if (insn & (1 << 18)) { |
3518 |
if (cc == 0) |
3519 |
gen_cond(r_cond, 0, cond);
|
3520 |
else if (cc == 2) |
3521 |
gen_cond(r_cond, 1, cond);
|
3522 |
else
|
3523 |
goto illegal_insn;
|
3524 |
} else {
|
3525 |
gen_fcond(r_cond, cc, cond); |
3526 |
} |
3527 |
|
3528 |
l1 = gen_new_label(); |
3529 |
|
3530 |
tcg_gen_brcondi_tl(TCG_COND_EQ, r_cond, 0, l1);
|
3531 |
if (IS_IMM) { /* immediate */ |
3532 |
TCGv r_const; |
3533 |
|
3534 |
rs2 = GET_FIELD_SPs(insn, 0, 10); |
3535 |
r_const = tcg_const_tl((int)rs2);
|
3536 |
gen_movl_TN_reg(rd, r_const); |
3537 |
tcg_temp_free(r_const); |
3538 |
} else {
|
3539 |
rs2 = GET_FIELD_SP(insn, 0, 4); |
3540 |
gen_movl_reg_TN(rs2, cpu_tmp0); |
3541 |
gen_movl_TN_reg(rd, cpu_tmp0); |
3542 |
} |
3543 |
gen_set_label(l1); |
3544 |
tcg_temp_free(r_cond); |
3545 |
break;
|
3546 |
} |
3547 |
case 0x2d: /* V9 sdivx */ |
3548 |
gen_op_sdivx(cpu_dst, cpu_src1, cpu_src2); |
3549 |
gen_movl_TN_reg(rd, cpu_dst); |
3550 |
break;
|
3551 |
case 0x2e: /* V9 popc */ |
3552 |
{ |
3553 |
cpu_src2 = get_src2(insn, cpu_src2); |
3554 |
tcg_gen_helper_1_1(helper_popc, cpu_dst, |
3555 |
cpu_src2); |
3556 |
gen_movl_TN_reg(rd, cpu_dst); |
3557 |
} |
3558 |
case 0x2f: /* V9 movr */ |
3559 |
{ |
3560 |
int cond = GET_FIELD_SP(insn, 10, 12); |
3561 |
int l1;
|
3562 |
|
3563 |
cpu_src1 = get_src1(insn, cpu_src1); |
3564 |
|
3565 |
l1 = gen_new_label(); |
3566 |
|
3567 |
tcg_gen_brcondi_tl(gen_tcg_cond_reg[cond], |
3568 |
cpu_src1, 0, l1);
|
3569 |
if (IS_IMM) { /* immediate */ |
3570 |
TCGv r_const; |
3571 |
|
3572 |
rs2 = GET_FIELD_SPs(insn, 0, 9); |
3573 |
r_const = tcg_const_tl((int)rs2);
|
3574 |
gen_movl_TN_reg(rd, r_const); |
3575 |
tcg_temp_free(r_const); |
3576 |
} else {
|
3577 |
rs2 = GET_FIELD_SP(insn, 0, 4); |
3578 |
gen_movl_reg_TN(rs2, cpu_tmp0); |
3579 |
gen_movl_TN_reg(rd, cpu_tmp0); |
3580 |
} |
3581 |
gen_set_label(l1); |
3582 |
break;
|
3583 |
} |
3584 |
#endif
|
3585 |
default:
|
3586 |
goto illegal_insn;
|
3587 |
} |
3588 |
} |
3589 |
} else if (xop == 0x36) { /* UltraSparc shutdown, VIS, V8 CPop1 */ |
3590 |
#ifdef TARGET_SPARC64
|
3591 |
int opf = GET_FIELD_SP(insn, 5, 13); |
3592 |
rs1 = GET_FIELD(insn, 13, 17); |
3593 |
rs2 = GET_FIELD(insn, 27, 31); |
3594 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
3595 |
goto jmp_insn;
|
3596 |
|
3597 |
switch (opf) {
|
3598 |
case 0x000: /* VIS I edge8cc */ |
3599 |
case 0x001: /* VIS II edge8n */ |
3600 |
case 0x002: /* VIS I edge8lcc */ |
3601 |
case 0x003: /* VIS II edge8ln */ |
3602 |
case 0x004: /* VIS I edge16cc */ |
3603 |
case 0x005: /* VIS II edge16n */ |
3604 |
case 0x006: /* VIS I edge16lcc */ |
3605 |
case 0x007: /* VIS II edge16ln */ |
3606 |
case 0x008: /* VIS I edge32cc */ |
3607 |
case 0x009: /* VIS II edge32n */ |
3608 |
case 0x00a: /* VIS I edge32lcc */ |
3609 |
case 0x00b: /* VIS II edge32ln */ |
3610 |
// XXX
|
3611 |
goto illegal_insn;
|
3612 |
case 0x010: /* VIS I array8 */ |
3613 |
CHECK_FPU_FEATURE(dc, VIS1); |
3614 |
cpu_src1 = get_src1(insn, cpu_src1); |
3615 |
gen_movl_reg_TN(rs2, cpu_src2); |
3616 |
tcg_gen_helper_1_2(helper_array8, cpu_dst, cpu_src1, |
3617 |
cpu_src2); |
3618 |
gen_movl_TN_reg(rd, cpu_dst); |
3619 |
break;
|
3620 |
case 0x012: /* VIS I array16 */ |
3621 |
CHECK_FPU_FEATURE(dc, VIS1); |
3622 |
cpu_src1 = get_src1(insn, cpu_src1); |
3623 |
gen_movl_reg_TN(rs2, cpu_src2); |
3624 |
tcg_gen_helper_1_2(helper_array8, cpu_dst, cpu_src1, |
3625 |
cpu_src2); |
3626 |
tcg_gen_shli_i64(cpu_dst, cpu_dst, 1);
|
3627 |
gen_movl_TN_reg(rd, cpu_dst); |
3628 |
break;
|
3629 |
case 0x014: /* VIS I array32 */ |
3630 |
CHECK_FPU_FEATURE(dc, VIS1); |
3631 |
cpu_src1 = get_src1(insn, cpu_src1); |
3632 |
gen_movl_reg_TN(rs2, cpu_src2); |
3633 |
tcg_gen_helper_1_2(helper_array8, cpu_dst, cpu_src1, |
3634 |
cpu_src2); |
3635 |
tcg_gen_shli_i64(cpu_dst, cpu_dst, 2);
|
3636 |
gen_movl_TN_reg(rd, cpu_dst); |
3637 |
break;
|
3638 |
case 0x018: /* VIS I alignaddr */ |
3639 |
CHECK_FPU_FEATURE(dc, VIS1); |
3640 |
cpu_src1 = get_src1(insn, cpu_src1); |
3641 |
gen_movl_reg_TN(rs2, cpu_src2); |
3642 |
tcg_gen_helper_1_2(helper_alignaddr, cpu_dst, cpu_src1, |
3643 |
cpu_src2); |
3644 |
gen_movl_TN_reg(rd, cpu_dst); |
3645 |
break;
|
3646 |
case 0x019: /* VIS II bmask */ |
3647 |
case 0x01a: /* VIS I alignaddrl */ |
3648 |
// XXX
|
3649 |
goto illegal_insn;
|
3650 |
case 0x020: /* VIS I fcmple16 */ |
3651 |
CHECK_FPU_FEATURE(dc, VIS1); |
3652 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3653 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3654 |
tcg_gen_helper_0_0(helper_fcmple16); |
3655 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3656 |
break;
|
3657 |
case 0x022: /* VIS I fcmpne16 */ |
3658 |
CHECK_FPU_FEATURE(dc, VIS1); |
3659 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3660 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3661 |
tcg_gen_helper_0_0(helper_fcmpne16); |
3662 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3663 |
break;
|
3664 |
case 0x024: /* VIS I fcmple32 */ |
3665 |
CHECK_FPU_FEATURE(dc, VIS1); |
3666 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3667 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3668 |
tcg_gen_helper_0_0(helper_fcmple32); |
3669 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3670 |
break;
|
3671 |
case 0x026: /* VIS I fcmpne32 */ |
3672 |
CHECK_FPU_FEATURE(dc, VIS1); |
3673 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3674 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3675 |
tcg_gen_helper_0_0(helper_fcmpne32); |
3676 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3677 |
break;
|
3678 |
case 0x028: /* VIS I fcmpgt16 */ |
3679 |
CHECK_FPU_FEATURE(dc, VIS1); |
3680 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3681 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3682 |
tcg_gen_helper_0_0(helper_fcmpgt16); |
3683 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3684 |
break;
|
3685 |
case 0x02a: /* VIS I fcmpeq16 */ |
3686 |
CHECK_FPU_FEATURE(dc, VIS1); |
3687 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3688 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3689 |
tcg_gen_helper_0_0(helper_fcmpeq16); |
3690 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3691 |
break;
|
3692 |
case 0x02c: /* VIS I fcmpgt32 */ |
3693 |
CHECK_FPU_FEATURE(dc, VIS1); |
3694 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3695 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3696 |
tcg_gen_helper_0_0(helper_fcmpgt32); |
3697 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3698 |
break;
|
3699 |
case 0x02e: /* VIS I fcmpeq32 */ |
3700 |
CHECK_FPU_FEATURE(dc, VIS1); |
3701 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3702 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3703 |
tcg_gen_helper_0_0(helper_fcmpeq32); |
3704 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3705 |
break;
|
3706 |
case 0x031: /* VIS I fmul8x16 */ |
3707 |
CHECK_FPU_FEATURE(dc, VIS1); |
3708 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3709 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3710 |
tcg_gen_helper_0_0(helper_fmul8x16); |
3711 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3712 |
break;
|
3713 |
case 0x033: /* VIS I fmul8x16au */ |
3714 |
CHECK_FPU_FEATURE(dc, VIS1); |
3715 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3716 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3717 |
tcg_gen_helper_0_0(helper_fmul8x16au); |
3718 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3719 |
break;
|
3720 |
case 0x035: /* VIS I fmul8x16al */ |
3721 |
CHECK_FPU_FEATURE(dc, VIS1); |
3722 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3723 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3724 |
tcg_gen_helper_0_0(helper_fmul8x16al); |
3725 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3726 |
break;
|
3727 |
case 0x036: /* VIS I fmul8sux16 */ |
3728 |
CHECK_FPU_FEATURE(dc, VIS1); |
3729 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3730 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3731 |
tcg_gen_helper_0_0(helper_fmul8sux16); |
3732 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3733 |
break;
|
3734 |
case 0x037: /* VIS I fmul8ulx16 */ |
3735 |
CHECK_FPU_FEATURE(dc, VIS1); |
3736 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3737 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3738 |
tcg_gen_helper_0_0(helper_fmul8ulx16); |
3739 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3740 |
break;
|
3741 |
case 0x038: /* VIS I fmuld8sux16 */ |
3742 |
CHECK_FPU_FEATURE(dc, VIS1); |
3743 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3744 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3745 |
tcg_gen_helper_0_0(helper_fmuld8sux16); |
3746 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3747 |
break;
|
3748 |
case 0x039: /* VIS I fmuld8ulx16 */ |
3749 |
CHECK_FPU_FEATURE(dc, VIS1); |
3750 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3751 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3752 |
tcg_gen_helper_0_0(helper_fmuld8ulx16); |
3753 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3754 |
break;
|
3755 |
case 0x03a: /* VIS I fpack32 */ |
3756 |
case 0x03b: /* VIS I fpack16 */ |
3757 |
case 0x03d: /* VIS I fpackfix */ |
3758 |
case 0x03e: /* VIS I pdist */ |
3759 |
// XXX
|
3760 |
goto illegal_insn;
|
3761 |
case 0x048: /* VIS I faligndata */ |
3762 |
CHECK_FPU_FEATURE(dc, VIS1); |
3763 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3764 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3765 |
tcg_gen_helper_0_0(helper_faligndata); |
3766 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3767 |
break;
|
3768 |
case 0x04b: /* VIS I fpmerge */ |
3769 |
CHECK_FPU_FEATURE(dc, VIS1); |
3770 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3771 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3772 |
tcg_gen_helper_0_0(helper_fpmerge); |
3773 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3774 |
break;
|
3775 |
case 0x04c: /* VIS II bshuffle */ |
3776 |
// XXX
|
3777 |
goto illegal_insn;
|
3778 |
case 0x04d: /* VIS I fexpand */ |
3779 |
CHECK_FPU_FEATURE(dc, VIS1); |
3780 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3781 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3782 |
tcg_gen_helper_0_0(helper_fexpand); |
3783 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3784 |
break;
|
3785 |
case 0x050: /* VIS I fpadd16 */ |
3786 |
CHECK_FPU_FEATURE(dc, VIS1); |
3787 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3788 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3789 |
tcg_gen_helper_0_0(helper_fpadd16); |
3790 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3791 |
break;
|
3792 |
case 0x051: /* VIS I fpadd16s */ |
3793 |
CHECK_FPU_FEATURE(dc, VIS1); |
3794 |
gen_op_load_fpr_FT0(rs1); |
3795 |
gen_op_load_fpr_FT1(rs2); |
3796 |
tcg_gen_helper_0_0(helper_fpadd16s); |
3797 |
gen_op_store_FT0_fpr(rd); |
3798 |
break;
|
3799 |
case 0x052: /* VIS I fpadd32 */ |
3800 |
CHECK_FPU_FEATURE(dc, VIS1); |
3801 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3802 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3803 |
tcg_gen_helper_0_0(helper_fpadd32); |
3804 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3805 |
break;
|
3806 |
case 0x053: /* VIS I fpadd32s */ |
3807 |
CHECK_FPU_FEATURE(dc, VIS1); |
3808 |
gen_op_load_fpr_FT0(rs1); |
3809 |
gen_op_load_fpr_FT1(rs2); |
3810 |
tcg_gen_helper_0_0(helper_fpadd32s); |
3811 |
gen_op_store_FT0_fpr(rd); |
3812 |
break;
|
3813 |
case 0x054: /* VIS I fpsub16 */ |
3814 |
CHECK_FPU_FEATURE(dc, VIS1); |
3815 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3816 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3817 |
tcg_gen_helper_0_0(helper_fpsub16); |
3818 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3819 |
break;
|
3820 |
case 0x055: /* VIS I fpsub16s */ |
3821 |
CHECK_FPU_FEATURE(dc, VIS1); |
3822 |
gen_op_load_fpr_FT0(rs1); |
3823 |
gen_op_load_fpr_FT1(rs2); |
3824 |
tcg_gen_helper_0_0(helper_fpsub16s); |
3825 |
gen_op_store_FT0_fpr(rd); |
3826 |
break;
|
3827 |
case 0x056: /* VIS I fpsub32 */ |
3828 |
CHECK_FPU_FEATURE(dc, VIS1); |
3829 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3830 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3831 |
tcg_gen_helper_0_0(helper_fpadd32); |
3832 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3833 |
break;
|
3834 |
case 0x057: /* VIS I fpsub32s */ |
3835 |
CHECK_FPU_FEATURE(dc, VIS1); |
3836 |
gen_op_load_fpr_FT0(rs1); |
3837 |
gen_op_load_fpr_FT1(rs2); |
3838 |
tcg_gen_helper_0_0(helper_fpsub32s); |
3839 |
gen_op_store_FT0_fpr(rd); |
3840 |
break;
|
3841 |
case 0x060: /* VIS I fzero */ |
3842 |
CHECK_FPU_FEATURE(dc, VIS1); |
3843 |
tcg_gen_helper_0_0(helper_movl_DT0_0); |
3844 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3845 |
break;
|
3846 |
case 0x061: /* VIS I fzeros */ |
3847 |
CHECK_FPU_FEATURE(dc, VIS1); |
3848 |
tcg_gen_helper_0_0(helper_movl_FT0_0); |
3849 |
gen_op_store_FT0_fpr(rd); |
3850 |
break;
|
3851 |
case 0x062: /* VIS I fnor */ |
3852 |
CHECK_FPU_FEATURE(dc, VIS1); |
3853 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3854 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3855 |
tcg_gen_helper_0_0(helper_fnor); |
3856 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3857 |
break;
|
3858 |
case 0x063: /* VIS I fnors */ |
3859 |
CHECK_FPU_FEATURE(dc, VIS1); |
3860 |
gen_op_load_fpr_FT0(rs1); |
3861 |
gen_op_load_fpr_FT1(rs2); |
3862 |
tcg_gen_helper_0_0(helper_fnors); |
3863 |
gen_op_store_FT0_fpr(rd); |
3864 |
break;
|
3865 |
case 0x064: /* VIS I fandnot2 */ |
3866 |
CHECK_FPU_FEATURE(dc, VIS1); |
3867 |
gen_op_load_fpr_DT1(DFPREG(rs1)); |
3868 |
gen_op_load_fpr_DT0(DFPREG(rs2)); |
3869 |
tcg_gen_helper_0_0(helper_fandnot); |
3870 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3871 |
break;
|
3872 |
case 0x065: /* VIS I fandnot2s */ |
3873 |
CHECK_FPU_FEATURE(dc, VIS1); |
3874 |
gen_op_load_fpr_FT1(rs1); |
3875 |
gen_op_load_fpr_FT0(rs2); |
3876 |
tcg_gen_helper_0_0(helper_fandnots); |
3877 |
gen_op_store_FT0_fpr(rd); |
3878 |
break;
|
3879 |
case 0x066: /* VIS I fnot2 */ |
3880 |
CHECK_FPU_FEATURE(dc, VIS1); |
3881 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3882 |
tcg_gen_helper_0_0(helper_fnot); |
3883 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3884 |
break;
|
3885 |
case 0x067: /* VIS I fnot2s */ |
3886 |
CHECK_FPU_FEATURE(dc, VIS1); |
3887 |
gen_op_load_fpr_FT1(rs2); |
3888 |
tcg_gen_helper_0_0(helper_fnot); |
3889 |
gen_op_store_FT0_fpr(rd); |
3890 |
break;
|
3891 |
case 0x068: /* VIS I fandnot1 */ |
3892 |
CHECK_FPU_FEATURE(dc, VIS1); |
3893 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3894 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3895 |
tcg_gen_helper_0_0(helper_fandnot); |
3896 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3897 |
break;
|
3898 |
case 0x069: /* VIS I fandnot1s */ |
3899 |
CHECK_FPU_FEATURE(dc, VIS1); |
3900 |
gen_op_load_fpr_FT0(rs1); |
3901 |
gen_op_load_fpr_FT1(rs2); |
3902 |
tcg_gen_helper_0_0(helper_fandnots); |
3903 |
gen_op_store_FT0_fpr(rd); |
3904 |
break;
|
3905 |
case 0x06a: /* VIS I fnot1 */ |
3906 |
CHECK_FPU_FEATURE(dc, VIS1); |
3907 |
gen_op_load_fpr_DT1(DFPREG(rs1)); |
3908 |
tcg_gen_helper_0_0(helper_fnot); |
3909 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3910 |
break;
|
3911 |
case 0x06b: /* VIS I fnot1s */ |
3912 |
CHECK_FPU_FEATURE(dc, VIS1); |
3913 |
gen_op_load_fpr_FT1(rs1); |
3914 |
tcg_gen_helper_0_0(helper_fnot); |
3915 |
gen_op_store_FT0_fpr(rd); |
3916 |
break;
|
3917 |
case 0x06c: /* VIS I fxor */ |
3918 |
CHECK_FPU_FEATURE(dc, VIS1); |
3919 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3920 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3921 |
tcg_gen_helper_0_0(helper_fxor); |
3922 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3923 |
break;
|
3924 |
case 0x06d: /* VIS I fxors */ |
3925 |
CHECK_FPU_FEATURE(dc, VIS1); |
3926 |
gen_op_load_fpr_FT0(rs1); |
3927 |
gen_op_load_fpr_FT1(rs2); |
3928 |
tcg_gen_helper_0_0(helper_fxors); |
3929 |
gen_op_store_FT0_fpr(rd); |
3930 |
break;
|
3931 |
case 0x06e: /* VIS I fnand */ |
3932 |
CHECK_FPU_FEATURE(dc, VIS1); |
3933 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3934 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3935 |
tcg_gen_helper_0_0(helper_fnand); |
3936 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3937 |
break;
|
3938 |
case 0x06f: /* VIS I fnands */ |
3939 |
CHECK_FPU_FEATURE(dc, VIS1); |
3940 |
gen_op_load_fpr_FT0(rs1); |
3941 |
gen_op_load_fpr_FT1(rs2); |
3942 |
tcg_gen_helper_0_0(helper_fnands); |
3943 |
gen_op_store_FT0_fpr(rd); |
3944 |
break;
|
3945 |
case 0x070: /* VIS I fand */ |
3946 |
CHECK_FPU_FEATURE(dc, VIS1); |
3947 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3948 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3949 |
tcg_gen_helper_0_0(helper_fand); |
3950 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3951 |
break;
|
3952 |
case 0x071: /* VIS I fands */ |
3953 |
CHECK_FPU_FEATURE(dc, VIS1); |
3954 |
gen_op_load_fpr_FT0(rs1); |
3955 |
gen_op_load_fpr_FT1(rs2); |
3956 |
tcg_gen_helper_0_0(helper_fands); |
3957 |
gen_op_store_FT0_fpr(rd); |
3958 |
break;
|
3959 |
case 0x072: /* VIS I fxnor */ |
3960 |
CHECK_FPU_FEATURE(dc, VIS1); |
3961 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3962 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
3963 |
tcg_gen_helper_0_0(helper_fxnor); |
3964 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3965 |
break;
|
3966 |
case 0x073: /* VIS I fxnors */ |
3967 |
CHECK_FPU_FEATURE(dc, VIS1); |
3968 |
gen_op_load_fpr_FT0(rs1); |
3969 |
gen_op_load_fpr_FT1(rs2); |
3970 |
tcg_gen_helper_0_0(helper_fxnors); |
3971 |
gen_op_store_FT0_fpr(rd); |
3972 |
break;
|
3973 |
case 0x074: /* VIS I fsrc1 */ |
3974 |
CHECK_FPU_FEATURE(dc, VIS1); |
3975 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
3976 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3977 |
break;
|
3978 |
case 0x075: /* VIS I fsrc1s */ |
3979 |
CHECK_FPU_FEATURE(dc, VIS1); |
3980 |
gen_op_load_fpr_FT0(rs1); |
3981 |
gen_op_store_FT0_fpr(rd); |
3982 |
break;
|
3983 |
case 0x076: /* VIS I fornot2 */ |
3984 |
CHECK_FPU_FEATURE(dc, VIS1); |
3985 |
gen_op_load_fpr_DT1(DFPREG(rs1)); |
3986 |
gen_op_load_fpr_DT0(DFPREG(rs2)); |
3987 |
tcg_gen_helper_0_0(helper_fornot); |
3988 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
3989 |
break;
|
3990 |
case 0x077: /* VIS I fornot2s */ |
3991 |
CHECK_FPU_FEATURE(dc, VIS1); |
3992 |
gen_op_load_fpr_FT1(rs1); |
3993 |
gen_op_load_fpr_FT0(rs2); |
3994 |
tcg_gen_helper_0_0(helper_fornots); |
3995 |
gen_op_store_FT0_fpr(rd); |
3996 |
break;
|
3997 |
case 0x078: /* VIS I fsrc2 */ |
3998 |
CHECK_FPU_FEATURE(dc, VIS1); |
3999 |
gen_op_load_fpr_DT0(DFPREG(rs2)); |
4000 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
4001 |
break;
|
4002 |
case 0x079: /* VIS I fsrc2s */ |
4003 |
CHECK_FPU_FEATURE(dc, VIS1); |
4004 |
gen_op_load_fpr_FT0(rs2); |
4005 |
gen_op_store_FT0_fpr(rd); |
4006 |
break;
|
4007 |
case 0x07a: /* VIS I fornot1 */ |
4008 |
CHECK_FPU_FEATURE(dc, VIS1); |
4009 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
4010 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
4011 |
tcg_gen_helper_0_0(helper_fornot); |
4012 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
4013 |
break;
|
4014 |
case 0x07b: /* VIS I fornot1s */ |
4015 |
CHECK_FPU_FEATURE(dc, VIS1); |
4016 |
gen_op_load_fpr_FT0(rs1); |
4017 |
gen_op_load_fpr_FT1(rs2); |
4018 |
tcg_gen_helper_0_0(helper_fornots); |
4019 |
gen_op_store_FT0_fpr(rd); |
4020 |
break;
|
4021 |
case 0x07c: /* VIS I for */ |
4022 |
CHECK_FPU_FEATURE(dc, VIS1); |
4023 |
gen_op_load_fpr_DT0(DFPREG(rs1)); |
4024 |
gen_op_load_fpr_DT1(DFPREG(rs2)); |
4025 |
tcg_gen_helper_0_0(helper_for); |
4026 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
4027 |
break;
|
4028 |
case 0x07d: /* VIS I fors */ |
4029 |
CHECK_FPU_FEATURE(dc, VIS1); |
4030 |
gen_op_load_fpr_FT0(rs1); |
4031 |
gen_op_load_fpr_FT1(rs2); |
4032 |
tcg_gen_helper_0_0(helper_fors); |
4033 |
gen_op_store_FT0_fpr(rd); |
4034 |
break;
|
4035 |
case 0x07e: /* VIS I fone */ |
4036 |
CHECK_FPU_FEATURE(dc, VIS1); |
4037 |
tcg_gen_helper_0_0(helper_movl_DT0_1); |
4038 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
4039 |
break;
|
4040 |
case 0x07f: /* VIS I fones */ |
4041 |
CHECK_FPU_FEATURE(dc, VIS1); |
4042 |
tcg_gen_helper_0_0(helper_movl_FT0_1); |
4043 |
gen_op_store_FT0_fpr(rd); |
4044 |
break;
|
4045 |
case 0x080: /* VIS I shutdown */ |
4046 |
case 0x081: /* VIS II siam */ |
4047 |
// XXX
|
4048 |
goto illegal_insn;
|
4049 |
default:
|
4050 |
goto illegal_insn;
|
4051 |
} |
4052 |
#else
|
4053 |
goto ncp_insn;
|
4054 |
#endif
|
4055 |
} else if (xop == 0x37) { /* V8 CPop2, V9 impdep2 */ |
4056 |
#ifdef TARGET_SPARC64
|
4057 |
goto illegal_insn;
|
4058 |
#else
|
4059 |
goto ncp_insn;
|
4060 |
#endif
|
4061 |
#ifdef TARGET_SPARC64
|
4062 |
} else if (xop == 0x39) { /* V9 return */ |
4063 |
TCGv r_const; |
4064 |
|
4065 |
save_state(dc, cpu_cond); |
4066 |
cpu_src1 = get_src1(insn, cpu_src1); |
4067 |
if (IS_IMM) { /* immediate */ |
4068 |
rs2 = GET_FIELDs(insn, 19, 31); |
4069 |
tcg_gen_addi_tl(cpu_dst, cpu_src1, (int)rs2);
|
4070 |
} else { /* register */ |
4071 |
rs2 = GET_FIELD(insn, 27, 31); |
4072 |
if (rs2) {
|
4073 |
gen_movl_reg_TN(rs2, cpu_src2); |
4074 |
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); |
4075 |
} else
|
4076 |
tcg_gen_mov_tl(cpu_dst, cpu_src1); |
4077 |
} |
4078 |
tcg_gen_helper_0_0(helper_restore); |
4079 |
gen_mov_pc_npc(dc, cpu_cond); |
4080 |
r_const = tcg_const_i32(3);
|
4081 |
tcg_gen_helper_0_2(helper_check_align, cpu_dst, r_const); |
4082 |
tcg_temp_free(r_const); |
4083 |
tcg_gen_mov_tl(cpu_npc, cpu_dst); |
4084 |
dc->npc = DYNAMIC_PC; |
4085 |
goto jmp_insn;
|
4086 |
#endif
|
4087 |
} else {
|
4088 |
cpu_src1 = get_src1(insn, cpu_src1); |
4089 |
if (IS_IMM) { /* immediate */ |
4090 |
rs2 = GET_FIELDs(insn, 19, 31); |
4091 |
tcg_gen_addi_tl(cpu_dst, cpu_src1, (int)rs2);
|
4092 |
} else { /* register */ |
4093 |
rs2 = GET_FIELD(insn, 27, 31); |
4094 |
if (rs2) {
|
4095 |
gen_movl_reg_TN(rs2, cpu_src2); |
4096 |
tcg_gen_add_tl(cpu_dst, cpu_src1, cpu_src2); |
4097 |
} else
|
4098 |
tcg_gen_mov_tl(cpu_dst, cpu_src1); |
4099 |
} |
4100 |
switch (xop) {
|
4101 |
case 0x38: /* jmpl */ |
4102 |
{ |
4103 |
TCGv r_const; |
4104 |
|
4105 |
r_const = tcg_const_tl(dc->pc); |
4106 |
gen_movl_TN_reg(rd, r_const); |
4107 |
tcg_temp_free(r_const); |
4108 |
gen_mov_pc_npc(dc, cpu_cond); |
4109 |
r_const = tcg_const_i32(3);
|
4110 |
tcg_gen_helper_0_2(helper_check_align, cpu_dst, |
4111 |
r_const); |
4112 |
tcg_temp_free(r_const); |
4113 |
tcg_gen_mov_tl(cpu_npc, cpu_dst); |
4114 |
dc->npc = DYNAMIC_PC; |
4115 |
} |
4116 |
goto jmp_insn;
|
4117 |
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
|
4118 |
case 0x39: /* rett, V9 return */ |
4119 |
{ |
4120 |
TCGv r_const; |
4121 |
|
4122 |
if (!supervisor(dc))
|
4123 |
goto priv_insn;
|
4124 |
gen_mov_pc_npc(dc, cpu_cond); |
4125 |
r_const = tcg_const_i32(3);
|
4126 |
tcg_gen_helper_0_2(helper_check_align, cpu_dst, |
4127 |
r_const); |
4128 |
tcg_temp_free(r_const); |
4129 |
tcg_gen_mov_tl(cpu_npc, cpu_dst); |
4130 |
dc->npc = DYNAMIC_PC; |
4131 |
tcg_gen_helper_0_0(helper_rett); |
4132 |
} |
4133 |
goto jmp_insn;
|
4134 |
#endif
|
4135 |
case 0x3b: /* flush */ |
4136 |
if (!((dc)->features & CPU_FEATURE_FLUSH))
|
4137 |
goto unimp_flush;
|
4138 |
tcg_gen_helper_0_1(helper_flush, cpu_dst); |
4139 |
break;
|
4140 |
case 0x3c: /* save */ |
4141 |
save_state(dc, cpu_cond); |
4142 |
tcg_gen_helper_0_0(helper_save); |
4143 |
gen_movl_TN_reg(rd, cpu_dst); |
4144 |
break;
|
4145 |
case 0x3d: /* restore */ |
4146 |
save_state(dc, cpu_cond); |
4147 |
tcg_gen_helper_0_0(helper_restore); |
4148 |
gen_movl_TN_reg(rd, cpu_dst); |
4149 |
break;
|
4150 |
#if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
|
4151 |
case 0x3e: /* V9 done/retry */ |
4152 |
{ |
4153 |
switch (rd) {
|
4154 |
case 0: |
4155 |
if (!supervisor(dc))
|
4156 |
goto priv_insn;
|
4157 |
dc->npc = DYNAMIC_PC; |
4158 |
dc->pc = DYNAMIC_PC; |
4159 |
tcg_gen_helper_0_0(helper_done); |
4160 |
goto jmp_insn;
|
4161 |
case 1: |
4162 |
if (!supervisor(dc))
|
4163 |
goto priv_insn;
|
4164 |
dc->npc = DYNAMIC_PC; |
4165 |
dc->pc = DYNAMIC_PC; |
4166 |
tcg_gen_helper_0_0(helper_retry); |
4167 |
goto jmp_insn;
|
4168 |
default:
|
4169 |
goto illegal_insn;
|
4170 |
} |
4171 |
} |
4172 |
break;
|
4173 |
#endif
|
4174 |
default:
|
4175 |
goto illegal_insn;
|
4176 |
} |
4177 |
} |
4178 |
break;
|
4179 |
} |
4180 |
break;
|
4181 |
case 3: /* load/store instructions */ |
4182 |
{ |
4183 |
unsigned int xop = GET_FIELD(insn, 7, 12); |
4184 |
|
4185 |
cpu_src1 = get_src1(insn, cpu_src1); |
4186 |
if (xop == 0x3c || xop == 0x3e) |
4187 |
{ |
4188 |
rs2 = GET_FIELD(insn, 27, 31); |
4189 |
gen_movl_reg_TN(rs2, cpu_src2); |
4190 |
} |
4191 |
else if (IS_IMM) { /* immediate */ |
4192 |
rs2 = GET_FIELDs(insn, 19, 31); |
4193 |
tcg_gen_addi_tl(cpu_addr, cpu_src1, (int)rs2);
|
4194 |
} else { /* register */ |
4195 |
rs2 = GET_FIELD(insn, 27, 31); |
4196 |
if (rs2 != 0) { |
4197 |
gen_movl_reg_TN(rs2, cpu_src2); |
4198 |
tcg_gen_add_tl(cpu_addr, cpu_src1, cpu_src2); |
4199 |
} else
|
4200 |
tcg_gen_mov_tl(cpu_addr, cpu_src1); |
4201 |
} |
4202 |
if (xop < 4 || (xop > 7 && xop < 0x14 && xop != 0x0e) || |
4203 |
(xop > 0x17 && xop <= 0x1d ) || |
4204 |
(xop > 0x2c && xop <= 0x33) || xop == 0x1f || xop == 0x3d) { |
4205 |
switch (xop) {
|
4206 |
case 0x0: /* load unsigned word */ |
4207 |
ABI32_MASK(cpu_addr); |
4208 |
tcg_gen_qemu_ld32u(cpu_val, cpu_addr, dc->mem_idx); |
4209 |
break;
|
4210 |
case 0x1: /* load unsigned byte */ |
4211 |
ABI32_MASK(cpu_addr); |
4212 |
tcg_gen_qemu_ld8u(cpu_val, cpu_addr, dc->mem_idx); |
4213 |
break;
|
4214 |
case 0x2: /* load unsigned halfword */ |
4215 |
ABI32_MASK(cpu_addr); |
4216 |
tcg_gen_qemu_ld16u(cpu_val, cpu_addr, dc->mem_idx); |
4217 |
break;
|
4218 |
case 0x3: /* load double word */ |
4219 |
if (rd & 1) |
4220 |
goto illegal_insn;
|
4221 |
else {
|
4222 |
TCGv r_const; |
4223 |
|
4224 |
save_state(dc, cpu_cond); |
4225 |
r_const = tcg_const_i32(7);
|
4226 |
tcg_gen_helper_0_2(helper_check_align, cpu_dst, |
4227 |
r_const); // XXX remove
|
4228 |
tcg_temp_free(r_const); |
4229 |
ABI32_MASK(cpu_addr); |
4230 |
tcg_gen_qemu_ld64(cpu_tmp64, cpu_addr, dc->mem_idx); |
4231 |
tcg_gen_trunc_i64_tl(cpu_tmp0, cpu_tmp64); |
4232 |
tcg_gen_andi_tl(cpu_tmp0, cpu_tmp0, 0xffffffffULL);
|
4233 |
gen_movl_TN_reg(rd + 1, cpu_tmp0);
|
4234 |
tcg_gen_shri_i64(cpu_tmp64, cpu_tmp64, 32);
|
4235 |
tcg_gen_trunc_i64_tl(cpu_val, cpu_tmp64); |
4236 |
tcg_gen_andi_tl(cpu_val, cpu_val, 0xffffffffULL);
|
4237 |
} |
4238 |
break;
|
4239 |
case 0x9: /* load signed byte */ |
4240 |
ABI32_MASK(cpu_addr); |
4241 |
tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx); |
4242 |
break;
|
4243 |
case 0xa: /* load signed halfword */ |
4244 |
ABI32_MASK(cpu_addr); |
4245 |
tcg_gen_qemu_ld16s(cpu_val, cpu_addr, dc->mem_idx); |
4246 |
break;
|
4247 |
case 0xd: /* ldstub -- XXX: should be atomically */ |
4248 |
{ |
4249 |
TCGv r_const; |
4250 |
|
4251 |
ABI32_MASK(cpu_addr); |
4252 |
tcg_gen_qemu_ld8s(cpu_val, cpu_addr, dc->mem_idx); |
4253 |
r_const = tcg_const_tl(0xff);
|
4254 |
tcg_gen_qemu_st8(r_const, cpu_addr, dc->mem_idx); |
4255 |
tcg_temp_free(r_const); |
4256 |
} |
4257 |
break;
|
4258 |
case 0x0f: /* swap register with memory. Also |
4259 |
atomically */
|
4260 |
CHECK_IU_FEATURE(dc, SWAP); |
4261 |
gen_movl_reg_TN(rd, cpu_val); |
4262 |
ABI32_MASK(cpu_addr); |
4263 |
tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx); |
4264 |
tcg_gen_qemu_st32(cpu_val, cpu_addr, dc->mem_idx); |
4265 |
tcg_gen_extu_i32_tl(cpu_val, cpu_tmp32); |
4266 |
break;
|
4267 |
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
4268 |
case 0x10: /* load word alternate */ |
4269 |
#ifndef TARGET_SPARC64
|
4270 |
if (IS_IMM)
|
4271 |
goto illegal_insn;
|
4272 |
if (!supervisor(dc))
|
4273 |
goto priv_insn;
|
4274 |
#endif
|
4275 |
save_state(dc, cpu_cond); |
4276 |
gen_ld_asi(cpu_val, cpu_addr, insn, 4, 0); |
4277 |
break;
|
4278 |
case 0x11: /* load unsigned byte alternate */ |
4279 |
#ifndef TARGET_SPARC64
|
4280 |
if (IS_IMM)
|
4281 |
goto illegal_insn;
|
4282 |
if (!supervisor(dc))
|
4283 |
goto priv_insn;
|
4284 |
#endif
|
4285 |
save_state(dc, cpu_cond); |
4286 |
gen_ld_asi(cpu_val, cpu_addr, insn, 1, 0); |
4287 |
break;
|
4288 |
case 0x12: /* load unsigned halfword alternate */ |
4289 |
#ifndef TARGET_SPARC64
|
4290 |
if (IS_IMM)
|
4291 |
goto illegal_insn;
|
4292 |
if (!supervisor(dc))
|
4293 |
goto priv_insn;
|
4294 |
#endif
|
4295 |
save_state(dc, cpu_cond); |
4296 |
gen_ld_asi(cpu_val, cpu_addr, insn, 2, 0); |
4297 |
break;
|
4298 |
case 0x13: /* load double word alternate */ |
4299 |
#ifndef TARGET_SPARC64
|
4300 |
if (IS_IMM)
|
4301 |
goto illegal_insn;
|
4302 |
if (!supervisor(dc))
|
4303 |
goto priv_insn;
|
4304 |
#endif
|
4305 |
if (rd & 1) |
4306 |
goto illegal_insn;
|
4307 |
save_state(dc, cpu_cond); |
4308 |
gen_ldda_asi(cpu_tmp0, cpu_val, cpu_addr, insn); |
4309 |
gen_movl_TN_reg(rd + 1, cpu_tmp0);
|
4310 |
break;
|
4311 |
case 0x19: /* load signed byte alternate */ |
4312 |
#ifndef TARGET_SPARC64
|
4313 |
if (IS_IMM)
|
4314 |
goto illegal_insn;
|
4315 |
if (!supervisor(dc))
|
4316 |
goto priv_insn;
|
4317 |
#endif
|
4318 |
save_state(dc, cpu_cond); |
4319 |
gen_ld_asi(cpu_val, cpu_addr, insn, 1, 1); |
4320 |
break;
|
4321 |
case 0x1a: /* load signed halfword alternate */ |
4322 |
#ifndef TARGET_SPARC64
|
4323 |
if (IS_IMM)
|
4324 |
goto illegal_insn;
|
4325 |
if (!supervisor(dc))
|
4326 |
goto priv_insn;
|
4327 |
#endif
|
4328 |
save_state(dc, cpu_cond); |
4329 |
gen_ld_asi(cpu_val, cpu_addr, insn, 2, 1); |
4330 |
break;
|
4331 |
case 0x1d: /* ldstuba -- XXX: should be atomically */ |
4332 |
#ifndef TARGET_SPARC64
|
4333 |
if (IS_IMM)
|
4334 |
goto illegal_insn;
|
4335 |
if (!supervisor(dc))
|
4336 |
goto priv_insn;
|
4337 |
#endif
|
4338 |
save_state(dc, cpu_cond); |
4339 |
gen_ldstub_asi(cpu_val, cpu_addr, insn); |
4340 |
break;
|
4341 |
case 0x1f: /* swap reg with alt. memory. Also |
4342 |
atomically */
|
4343 |
CHECK_IU_FEATURE(dc, SWAP); |
4344 |
#ifndef TARGET_SPARC64
|
4345 |
if (IS_IMM)
|
4346 |
goto illegal_insn;
|
4347 |
if (!supervisor(dc))
|
4348 |
goto priv_insn;
|
4349 |
#endif
|
4350 |
save_state(dc, cpu_cond); |
4351 |
gen_movl_reg_TN(rd, cpu_val); |
4352 |
gen_swap_asi(cpu_val, cpu_addr, insn); |
4353 |
break;
|
4354 |
|
4355 |
#ifndef TARGET_SPARC64
|
4356 |
case 0x30: /* ldc */ |
4357 |
case 0x31: /* ldcsr */ |
4358 |
case 0x33: /* lddc */ |
4359 |
goto ncp_insn;
|
4360 |
#endif
|
4361 |
#endif
|
4362 |
#ifdef TARGET_SPARC64
|
4363 |
case 0x08: /* V9 ldsw */ |
4364 |
ABI32_MASK(cpu_addr); |
4365 |
tcg_gen_qemu_ld32s(cpu_val, cpu_addr, dc->mem_idx); |
4366 |
break;
|
4367 |
case 0x0b: /* V9 ldx */ |
4368 |
ABI32_MASK(cpu_addr); |
4369 |
tcg_gen_qemu_ld64(cpu_val, cpu_addr, dc->mem_idx); |
4370 |
break;
|
4371 |
case 0x18: /* V9 ldswa */ |
4372 |
save_state(dc, cpu_cond); |
4373 |
gen_ld_asi(cpu_val, cpu_addr, insn, 4, 1); |
4374 |
break;
|
4375 |
case 0x1b: /* V9 ldxa */ |
4376 |
save_state(dc, cpu_cond); |
4377 |
gen_ld_asi(cpu_val, cpu_addr, insn, 8, 0); |
4378 |
break;
|
4379 |
case 0x2d: /* V9 prefetch, no effect */ |
4380 |
goto skip_move;
|
4381 |
case 0x30: /* V9 ldfa */ |
4382 |
save_state(dc, cpu_cond); |
4383 |
gen_ldf_asi(cpu_addr, insn, 4, rd);
|
4384 |
goto skip_move;
|
4385 |
case 0x33: /* V9 lddfa */ |
4386 |
save_state(dc, cpu_cond); |
4387 |
gen_ldf_asi(cpu_addr, insn, 8, DFPREG(rd));
|
4388 |
goto skip_move;
|
4389 |
case 0x3d: /* V9 prefetcha, no effect */ |
4390 |
goto skip_move;
|
4391 |
case 0x32: /* V9 ldqfa */ |
4392 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
4393 |
save_state(dc, cpu_cond); |
4394 |
gen_ldf_asi(cpu_addr, insn, 16, QFPREG(rd));
|
4395 |
goto skip_move;
|
4396 |
#endif
|
4397 |
default:
|
4398 |
goto illegal_insn;
|
4399 |
} |
4400 |
gen_movl_TN_reg(rd, cpu_val); |
4401 |
#ifdef TARGET_SPARC64
|
4402 |
skip_move: ;
|
4403 |
#endif
|
4404 |
} else if (xop >= 0x20 && xop < 0x24) { |
4405 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
4406 |
goto jmp_insn;
|
4407 |
save_state(dc, cpu_cond); |
4408 |
switch (xop) {
|
4409 |
case 0x20: /* load fpreg */ |
4410 |
ABI32_MASK(cpu_addr); |
4411 |
tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx); |
4412 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
4413 |
offsetof(CPUState, fpr[rd])); |
4414 |
break;
|
4415 |
case 0x21: /* load fsr */ |
4416 |
ABI32_MASK(cpu_addr); |
4417 |
tcg_gen_qemu_ld32u(cpu_tmp32, cpu_addr, dc->mem_idx); |
4418 |
tcg_gen_st_i32(cpu_tmp32, cpu_env, |
4419 |
offsetof(CPUState, ft0)); |
4420 |
tcg_gen_helper_0_0(helper_ldfsr); |
4421 |
break;
|
4422 |
case 0x22: /* load quad fpreg */ |
4423 |
{ |
4424 |
TCGv r_const; |
4425 |
|
4426 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
4427 |
r_const = tcg_const_i32(dc->mem_idx); |
4428 |
tcg_gen_helper_0_2(helper_ldqf, cpu_addr, r_const); |
4429 |
tcg_temp_free(r_const); |
4430 |
gen_op_store_QT0_fpr(QFPREG(rd)); |
4431 |
} |
4432 |
break;
|
4433 |
case 0x23: /* load double fpreg */ |
4434 |
{ |
4435 |
TCGv r_const; |
4436 |
|
4437 |
r_const = tcg_const_i32(dc->mem_idx); |
4438 |
tcg_gen_helper_0_2(helper_lddf, cpu_addr, r_const); |
4439 |
tcg_temp_free(r_const); |
4440 |
gen_op_store_DT0_fpr(DFPREG(rd)); |
4441 |
} |
4442 |
break;
|
4443 |
default:
|
4444 |
goto illegal_insn;
|
4445 |
} |
4446 |
} else if (xop < 8 || (xop >= 0x14 && xop < 0x18) || \ |
4447 |
xop == 0xe || xop == 0x1e) { |
4448 |
gen_movl_reg_TN(rd, cpu_val); |
4449 |
switch (xop) {
|
4450 |
case 0x4: /* store word */ |
4451 |
ABI32_MASK(cpu_addr); |
4452 |
tcg_gen_qemu_st32(cpu_val, cpu_addr, dc->mem_idx); |
4453 |
break;
|
4454 |
case 0x5: /* store byte */ |
4455 |
ABI32_MASK(cpu_addr); |
4456 |
tcg_gen_qemu_st8(cpu_val, cpu_addr, dc->mem_idx); |
4457 |
break;
|
4458 |
case 0x6: /* store halfword */ |
4459 |
ABI32_MASK(cpu_addr); |
4460 |
tcg_gen_qemu_st16(cpu_val, cpu_addr, dc->mem_idx); |
4461 |
break;
|
4462 |
case 0x7: /* store double word */ |
4463 |
if (rd & 1) |
4464 |
goto illegal_insn;
|
4465 |
else {
|
4466 |
TCGv r_low, r_const; |
4467 |
|
4468 |
save_state(dc, cpu_cond); |
4469 |
ABI32_MASK(cpu_addr); |
4470 |
r_const = tcg_const_i32(7);
|
4471 |
tcg_gen_helper_0_2(helper_check_align, cpu_addr, |
4472 |
r_const); // XXX remove
|
4473 |
tcg_temp_free(r_const); |
4474 |
r_low = tcg_temp_new(TCG_TYPE_TL); |
4475 |
gen_movl_reg_TN(rd + 1, r_low);
|
4476 |
tcg_gen_helper_1_2(helper_pack64, cpu_tmp64, cpu_val, |
4477 |
r_low); |
4478 |
tcg_temp_free(r_low); |
4479 |
tcg_gen_qemu_st64(cpu_tmp64, cpu_addr, dc->mem_idx); |
4480 |
} |
4481 |
break;
|
4482 |
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
|
4483 |
case 0x14: /* store word alternate */ |
4484 |
#ifndef TARGET_SPARC64
|
4485 |
if (IS_IMM)
|
4486 |
goto illegal_insn;
|
4487 |
if (!supervisor(dc))
|
4488 |
goto priv_insn;
|
4489 |
#endif
|
4490 |
save_state(dc, cpu_cond); |
4491 |
gen_st_asi(cpu_val, cpu_addr, insn, 4);
|
4492 |
break;
|
4493 |
case 0x15: /* store byte alternate */ |
4494 |
#ifndef TARGET_SPARC64
|
4495 |
if (IS_IMM)
|
4496 |
goto illegal_insn;
|
4497 |
if (!supervisor(dc))
|
4498 |
goto priv_insn;
|
4499 |
#endif
|
4500 |
save_state(dc, cpu_cond); |
4501 |
gen_st_asi(cpu_val, cpu_addr, insn, 1);
|
4502 |
break;
|
4503 |
case 0x16: /* store halfword alternate */ |
4504 |
#ifndef TARGET_SPARC64
|
4505 |
if (IS_IMM)
|
4506 |
goto illegal_insn;
|
4507 |
if (!supervisor(dc))
|
4508 |
goto priv_insn;
|
4509 |
#endif
|
4510 |
save_state(dc, cpu_cond); |
4511 |
gen_st_asi(cpu_val, cpu_addr, insn, 2);
|
4512 |
break;
|
4513 |
case 0x17: /* store double word alternate */ |
4514 |
#ifndef TARGET_SPARC64
|
4515 |
if (IS_IMM)
|
4516 |
goto illegal_insn;
|
4517 |
if (!supervisor(dc))
|
4518 |
goto priv_insn;
|
4519 |
#endif
|
4520 |
if (rd & 1) |
4521 |
goto illegal_insn;
|
4522 |
else {
|
4523 |
save_state(dc, cpu_cond); |
4524 |
gen_stda_asi(cpu_val, cpu_addr, insn, rd); |
4525 |
} |
4526 |
break;
|
4527 |
#endif
|
4528 |
#ifdef TARGET_SPARC64
|
4529 |
case 0x0e: /* V9 stx */ |
4530 |
ABI32_MASK(cpu_addr); |
4531 |
tcg_gen_qemu_st64(cpu_val, cpu_addr, dc->mem_idx); |
4532 |
break;
|
4533 |
case 0x1e: /* V9 stxa */ |
4534 |
save_state(dc, cpu_cond); |
4535 |
gen_st_asi(cpu_val, cpu_addr, insn, 8);
|
4536 |
break;
|
4537 |
#endif
|
4538 |
default:
|
4539 |
goto illegal_insn;
|
4540 |
} |
4541 |
} else if (xop > 0x23 && xop < 0x28) { |
4542 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
4543 |
goto jmp_insn;
|
4544 |
save_state(dc, cpu_cond); |
4545 |
switch (xop) {
|
4546 |
case 0x24: /* store fpreg */ |
4547 |
ABI32_MASK(cpu_addr); |
4548 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
4549 |
offsetof(CPUState, fpr[rd])); |
4550 |
tcg_gen_qemu_st32(cpu_tmp32, cpu_addr, dc->mem_idx); |
4551 |
break;
|
4552 |
case 0x25: /* stfsr, V9 stxfsr */ |
4553 |
ABI32_MASK(cpu_addr); |
4554 |
tcg_gen_helper_0_0(helper_stfsr); |
4555 |
tcg_gen_ld_i32(cpu_tmp32, cpu_env, |
4556 |
offsetof(CPUState, ft0)); |
4557 |
tcg_gen_qemu_st32(cpu_tmp32, cpu_addr, dc->mem_idx); |
4558 |
break;
|
4559 |
case 0x26: |
4560 |
#ifdef TARGET_SPARC64
|
4561 |
/* V9 stqf, store quad fpreg */
|
4562 |
{ |
4563 |
TCGv r_const; |
4564 |
|
4565 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
4566 |
gen_op_load_fpr_QT0(QFPREG(rd)); |
4567 |
r_const = tcg_const_i32(dc->mem_idx); |
4568 |
tcg_gen_helper_0_2(helper_stqf, cpu_addr, r_const); |
4569 |
tcg_temp_free(r_const); |
4570 |
} |
4571 |
break;
|
4572 |
#else /* !TARGET_SPARC64 */ |
4573 |
/* stdfq, store floating point queue */
|
4574 |
#if defined(CONFIG_USER_ONLY)
|
4575 |
goto illegal_insn;
|
4576 |
#else
|
4577 |
if (!supervisor(dc))
|
4578 |
goto priv_insn;
|
4579 |
if (gen_trap_ifnofpu(dc, cpu_cond))
|
4580 |
goto jmp_insn;
|
4581 |
goto nfq_insn;
|
4582 |
#endif
|
4583 |
#endif
|
4584 |
case 0x27: /* store double fpreg */ |
4585 |
{ |
4586 |
TCGv r_const; |
4587 |
|
4588 |
gen_op_load_fpr_DT0(DFPREG(rd)); |
4589 |
r_const = tcg_const_i32(dc->mem_idx); |
4590 |
tcg_gen_helper_0_2(helper_stdf, cpu_addr, r_const); |
4591 |
tcg_temp_free(r_const); |
4592 |
} |
4593 |
break;
|
4594 |
default:
|
4595 |
goto illegal_insn;
|
4596 |
} |
4597 |
} else if (xop > 0x33 && xop < 0x3f) { |
4598 |
save_state(dc, cpu_cond); |
4599 |
switch (xop) {
|
4600 |
#ifdef TARGET_SPARC64
|
4601 |
case 0x34: /* V9 stfa */ |
4602 |
gen_op_load_fpr_FT0(rd); |
4603 |
gen_stf_asi(cpu_addr, insn, 4, rd);
|
4604 |
break;
|
4605 |
case 0x36: /* V9 stqfa */ |
4606 |
{ |
4607 |
TCGv r_const; |
4608 |
|
4609 |
CHECK_FPU_FEATURE(dc, FLOAT128); |
4610 |
r_const = tcg_const_i32(7);
|
4611 |
tcg_gen_helper_0_2(helper_check_align, cpu_addr, |
4612 |
r_const); |
4613 |
tcg_temp_free(r_const); |
4614 |
gen_op_load_fpr_QT0(QFPREG(rd)); |
4615 |
gen_stf_asi(cpu_addr, insn, 16, QFPREG(rd));
|
4616 |
} |
4617 |
break;
|
4618 |
case 0x37: /* V9 stdfa */ |
4619 |
gen_op_load_fpr_DT0(DFPREG(rd)); |
4620 |
gen_stf_asi(cpu_addr, insn, 8, DFPREG(rd));
|
4621 |
break;
|
4622 |
case 0x3c: /* V9 casa */ |
4623 |
gen_cas_asi(cpu_val, cpu_addr, cpu_val, insn, rd); |
4624 |
gen_movl_TN_reg(rd, cpu_val); |
4625 |
break;
|
4626 |
case 0x3e: /* V9 casxa */ |
4627 |
gen_casx_asi(cpu_val, cpu_addr, cpu_val, insn, rd); |
4628 |
gen_movl_TN_reg(rd, cpu_val); |
4629 |
break;
|
4630 |
#else
|
4631 |
case 0x34: /* stc */ |
4632 |
case 0x35: /* stcsr */ |
4633 |
case 0x36: /* stdcq */ |
4634 |
case 0x37: /* stdc */ |
4635 |
goto ncp_insn;
|
4636 |
#endif
|
4637 |
default:
|
4638 |
goto illegal_insn;
|
4639 |
} |
4640 |
} |
4641 |
else
|
4642 |
goto illegal_insn;
|
4643 |
} |
4644 |
break;
|
4645 |
} |
4646 |
/* default case for non jump instructions */
|
4647 |
if (dc->npc == DYNAMIC_PC) {
|
4648 |
dc->pc = DYNAMIC_PC; |
4649 |
gen_op_next_insn(); |
4650 |
} else if (dc->npc == JUMP_PC) { |
4651 |
/* we can do a static jump */
|
4652 |
gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond); |
4653 |
dc->is_br = 1;
|
4654 |
} else {
|
4655 |
dc->pc = dc->npc; |
4656 |
dc->npc = dc->npc + 4;
|
4657 |
} |
4658 |
jmp_insn:
|
4659 |
return;
|
4660 |
illegal_insn:
|
4661 |
{ |
4662 |
TCGv r_const; |
4663 |
|
4664 |
save_state(dc, cpu_cond); |
4665 |
r_const = tcg_const_i32(TT_ILL_INSN); |
4666 |
tcg_gen_helper_0_1(raise_exception, r_const); |
4667 |
tcg_temp_free(r_const); |
4668 |
dc->is_br = 1;
|
4669 |
} |
4670 |
return;
|
4671 |
unimp_flush:
|
4672 |
{ |
4673 |
TCGv r_const; |
4674 |
|
4675 |
save_state(dc, cpu_cond); |
4676 |
r_const = tcg_const_i32(TT_UNIMP_FLUSH); |
4677 |
tcg_gen_helper_0_1(raise_exception, r_const); |
4678 |
tcg_temp_free(r_const); |
4679 |
dc->is_br = 1;
|
4680 |
} |
4681 |
return;
|
4682 |
#if !defined(CONFIG_USER_ONLY)
|
4683 |
priv_insn:
|
4684 |
{ |
4685 |
TCGv r_const; |
4686 |
|
4687 |
save_state(dc, cpu_cond); |
4688 |
r_const = tcg_const_i32(TT_PRIV_INSN); |
4689 |
tcg_gen_helper_0_1(raise_exception, r_const); |
4690 |
tcg_temp_free(r_const); |
4691 |
dc->is_br = 1;
|
4692 |
} |
4693 |
return;
|
4694 |
#endif
|
4695 |
nfpu_insn:
|
4696 |
save_state(dc, cpu_cond); |
4697 |
gen_op_fpexception_im(FSR_FTT_UNIMPFPOP); |
4698 |
dc->is_br = 1;
|
4699 |
return;
|
4700 |
#if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
|
4701 |
nfq_insn:
|
4702 |
save_state(dc, cpu_cond); |
4703 |
gen_op_fpexception_im(FSR_FTT_SEQ_ERROR); |
4704 |
dc->is_br = 1;
|
4705 |
return;
|
4706 |
#endif
|
4707 |
#ifndef TARGET_SPARC64
|
4708 |
ncp_insn:
|
4709 |
{ |
4710 |
TCGv r_const; |
4711 |
|
4712 |
save_state(dc, cpu_cond); |
4713 |
r_const = tcg_const_i32(TT_NCP_INSN); |
4714 |
tcg_gen_helper_0_1(raise_exception, r_const); |
4715 |
tcg_temp_free(r_const); |
4716 |
dc->is_br = 1;
|
4717 |
} |
4718 |
return;
|
4719 |
#endif
|
4720 |
} |
4721 |
|
4722 |
static inline int gen_intermediate_code_internal(TranslationBlock * tb, |
4723 |
int spc, CPUSPARCState *env)
|
4724 |
{ |
4725 |
target_ulong pc_start, last_pc; |
4726 |
uint16_t *gen_opc_end; |
4727 |
DisasContext dc1, *dc = &dc1; |
4728 |
int j, lj = -1; |
4729 |
|
4730 |
memset(dc, 0, sizeof(DisasContext)); |
4731 |
dc->tb = tb; |
4732 |
pc_start = tb->pc; |
4733 |
dc->pc = pc_start; |
4734 |
last_pc = dc->pc; |
4735 |
dc->npc = (target_ulong) tb->cs_base; |
4736 |
dc->mem_idx = cpu_mmu_index(env); |
4737 |
dc->features = env->features; |
4738 |
if ((dc->features & CPU_FEATURE_FLOAT)) {
|
4739 |
dc->fpu_enabled = cpu_fpu_enabled(env); |
4740 |
#if defined(CONFIG_USER_ONLY)
|
4741 |
dc->features |= CPU_FEATURE_FLOAT128; |
4742 |
#endif
|
4743 |
} else
|
4744 |
dc->fpu_enabled = 0;
|
4745 |
gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
4746 |
|
4747 |
cpu_tmp0 = tcg_temp_new(TCG_TYPE_TL); |
4748 |
cpu_tmp32 = tcg_temp_new(TCG_TYPE_I32); |
4749 |
cpu_tmp64 = tcg_temp_new(TCG_TYPE_I64); |
4750 |
|
4751 |
do {
|
4752 |
if (env->nb_breakpoints > 0) { |
4753 |
for(j = 0; j < env->nb_breakpoints; j++) { |
4754 |
if (env->breakpoints[j] == dc->pc) {
|
4755 |
if (dc->pc != pc_start)
|
4756 |
save_state(dc, cpu_cond); |
4757 |
tcg_gen_helper_0_0(helper_debug); |
4758 |
tcg_gen_exit_tb(0);
|
4759 |
dc->is_br = 1;
|
4760 |
goto exit_gen_loop;
|
4761 |
} |
4762 |
} |
4763 |
} |
4764 |
if (spc) {
|
4765 |
if (loglevel > 0) |
4766 |
fprintf(logfile, "Search PC...\n");
|
4767 |
j = gen_opc_ptr - gen_opc_buf; |
4768 |
if (lj < j) {
|
4769 |
lj++; |
4770 |
while (lj < j)
|
4771 |
gen_opc_instr_start[lj++] = 0;
|
4772 |
gen_opc_pc[lj] = dc->pc; |
4773 |
gen_opc_npc[lj] = dc->npc; |
4774 |
gen_opc_instr_start[lj] = 1;
|
4775 |
} |
4776 |
} |
4777 |
last_pc = dc->pc; |
4778 |
disas_sparc_insn(dc); |
4779 |
|
4780 |
if (dc->is_br)
|
4781 |
break;
|
4782 |
/* if the next PC is different, we abort now */
|
4783 |
if (dc->pc != (last_pc + 4)) |
4784 |
break;
|
4785 |
/* if we reach a page boundary, we stop generation so that the
|
4786 |
PC of a TT_TFAULT exception is always in the right page */
|
4787 |
if ((dc->pc & (TARGET_PAGE_SIZE - 1)) == 0) |
4788 |
break;
|
4789 |
/* if single step mode, we generate only one instruction and
|
4790 |
generate an exception */
|
4791 |
if (env->singlestep_enabled) {
|
4792 |
tcg_gen_movi_tl(cpu_pc, dc->pc); |
4793 |
tcg_gen_exit_tb(0);
|
4794 |
break;
|
4795 |
} |
4796 |
} while ((gen_opc_ptr < gen_opc_end) &&
|
4797 |
(dc->pc - pc_start) < (TARGET_PAGE_SIZE - 32));
|
4798 |
|
4799 |
exit_gen_loop:
|
4800 |
tcg_temp_free(cpu_tmp64); |
4801 |
tcg_temp_free(cpu_tmp32); |
4802 |
tcg_temp_free(cpu_tmp0); |
4803 |
if (!dc->is_br) {
|
4804 |
if (dc->pc != DYNAMIC_PC &&
|
4805 |
(dc->npc != DYNAMIC_PC && dc->npc != JUMP_PC)) { |
4806 |
/* static PC and NPC: we can use direct chaining */
|
4807 |
gen_goto_tb(dc, 0, dc->pc, dc->npc);
|
4808 |
} else {
|
4809 |
if (dc->pc != DYNAMIC_PC)
|
4810 |
tcg_gen_movi_tl(cpu_pc, dc->pc); |
4811 |
save_npc(dc, cpu_cond); |
4812 |
tcg_gen_exit_tb(0);
|
4813 |
} |
4814 |
} |
4815 |
*gen_opc_ptr = INDEX_op_end; |
4816 |
if (spc) {
|
4817 |
j = gen_opc_ptr - gen_opc_buf; |
4818 |
lj++; |
4819 |
while (lj <= j)
|
4820 |
gen_opc_instr_start[lj++] = 0;
|
4821 |
#if 0
|
4822 |
if (loglevel > 0) {
|
4823 |
page_dump(logfile);
|
4824 |
}
|
4825 |
#endif
|
4826 |
gen_opc_jump_pc[0] = dc->jump_pc[0]; |
4827 |
gen_opc_jump_pc[1] = dc->jump_pc[1]; |
4828 |
} else {
|
4829 |
tb->size = last_pc + 4 - pc_start;
|
4830 |
} |
4831 |
#ifdef DEBUG_DISAS
|
4832 |
if (loglevel & CPU_LOG_TB_IN_ASM) {
|
4833 |
fprintf(logfile, "--------------\n");
|
4834 |
fprintf(logfile, "IN: %s\n", lookup_symbol(pc_start));
|
4835 |
target_disas(logfile, pc_start, last_pc + 4 - pc_start, 0); |
4836 |
fprintf(logfile, "\n");
|
4837 |
} |
4838 |
#endif
|
4839 |
return 0; |
4840 |
} |
4841 |
|
4842 |
int gen_intermediate_code(CPUSPARCState * env, TranslationBlock * tb)
|
4843 |
{ |
4844 |
return gen_intermediate_code_internal(tb, 0, env); |
4845 |
} |
4846 |
|
4847 |
int gen_intermediate_code_pc(CPUSPARCState * env, TranslationBlock * tb)
|
4848 |
{ |
4849 |
return gen_intermediate_code_internal(tb, 1, env); |
4850 |
} |
4851 |
|
4852 |
void gen_intermediate_code_init(CPUSPARCState *env)
|
4853 |
{ |
4854 |
unsigned int i; |
4855 |
static int inited; |
4856 |
static const char * const gregnames[8] = { |
4857 |
NULL, // g0 not used |
4858 |
"g1",
|
4859 |
"g2",
|
4860 |
"g3",
|
4861 |
"g4",
|
4862 |
"g5",
|
4863 |
"g6",
|
4864 |
"g7",
|
4865 |
}; |
4866 |
|
4867 |
/* init various static tables */
|
4868 |
if (!inited) {
|
4869 |
inited = 1;
|
4870 |
|
4871 |
cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
|
4872 |
cpu_regwptr = tcg_global_mem_new(TCG_TYPE_PTR, TCG_AREG0, |
4873 |
offsetof(CPUState, regwptr), |
4874 |
"regwptr");
|
4875 |
#ifdef TARGET_SPARC64
|
4876 |
cpu_xcc = tcg_global_mem_new(TCG_TYPE_I32, |
4877 |
TCG_AREG0, offsetof(CPUState, xcc), |
4878 |
"xcc");
|
4879 |
#endif
|
4880 |
/* XXX: T0 and T1 should be temporaries */
|
4881 |
cpu_T[0] = tcg_global_mem_new(TCG_TYPE_TL,
|
4882 |
TCG_AREG0, offsetof(CPUState, t0), "T0");
|
4883 |
cpu_T[1] = tcg_global_mem_new(TCG_TYPE_TL,
|
4884 |
TCG_AREG0, offsetof(CPUState, t1), "T1");
|
4885 |
cpu_cond = tcg_global_mem_new(TCG_TYPE_TL, |
4886 |
TCG_AREG0, offsetof(CPUState, cond), |
4887 |
"cond");
|
4888 |
cpu_cc_src = tcg_global_mem_new(TCG_TYPE_TL, |
4889 |
TCG_AREG0, offsetof(CPUState, cc_src), |
4890 |
"cc_src");
|
4891 |
cpu_cc_src2 = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0, |
4892 |
offsetof(CPUState, cc_src2), |
4893 |
"cc_src2");
|
4894 |
cpu_cc_dst = tcg_global_mem_new(TCG_TYPE_TL, |
4895 |
TCG_AREG0, offsetof(CPUState, cc_dst), |
4896 |
"cc_dst");
|
4897 |
cpu_psr = tcg_global_mem_new(TCG_TYPE_I32, |
4898 |
TCG_AREG0, offsetof(CPUState, psr), |
4899 |
"psr");
|
4900 |
cpu_fsr = tcg_global_mem_new(TCG_TYPE_TL, |
4901 |
TCG_AREG0, offsetof(CPUState, fsr), |
4902 |
"fsr");
|
4903 |
cpu_pc = tcg_global_mem_new(TCG_TYPE_TL, |
4904 |
TCG_AREG0, offsetof(CPUState, pc), |
4905 |
"pc");
|
4906 |
cpu_npc = tcg_global_mem_new(TCG_TYPE_TL, |
4907 |
TCG_AREG0, offsetof(CPUState, npc), |
4908 |
"npc");
|
4909 |
for (i = 1; i < 8; i++) |
4910 |
cpu_gregs[i] = tcg_global_mem_new(TCG_TYPE_TL, TCG_AREG0, |
4911 |
offsetof(CPUState, gregs[i]), |
4912 |
gregnames[i]); |
4913 |
/* register helpers */
|
4914 |
|
4915 |
#undef DEF_HELPER
|
4916 |
#define DEF_HELPER(ret, name, params) tcg_register_helper(name, #name); |
4917 |
#include "helper.h" |
4918 |
} |
4919 |
} |
4920 |
|
4921 |
void gen_pc_load(CPUState *env, TranslationBlock *tb,
|
4922 |
unsigned long searched_pc, int pc_pos, void *puc) |
4923 |
{ |
4924 |
target_ulong npc; |
4925 |
env->pc = gen_opc_pc[pc_pos]; |
4926 |
npc = gen_opc_npc[pc_pos]; |
4927 |
if (npc == 1) { |
4928 |
/* dynamic NPC: already stored */
|
4929 |
} else if (npc == 2) { |
4930 |
target_ulong t2 = (target_ulong)(unsigned long)puc; |
4931 |
/* jump PC: use T2 and the jump targets of the translation */
|
4932 |
if (t2)
|
4933 |
env->npc = gen_opc_jump_pc[0];
|
4934 |
else
|
4935 |
env->npc = gen_opc_jump_pc[1];
|
4936 |
} else {
|
4937 |
env->npc = npc; |
4938 |
} |
4939 |
} |