4 Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
5 Copyright (C) 2003-2005 Fabrice Bellard
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.
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.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, see <http://www.gnu.org/licenses/>.
37 #define DYNAMIC_PC 1 /* dynamic pc value */
38 #define JUMP_PC 2 /* dynamic pc value which takes only two values
39 according to jump_pc[T2] */
41 /* global register indexes */
42 static TCGv_ptr cpu_env
, cpu_regwptr
;
43 static TCGv cpu_cc_src
, cpu_cc_src2
, cpu_cc_dst
;
44 static TCGv_i32 cpu_cc_op
;
45 static TCGv_i32 cpu_psr
;
46 static TCGv cpu_fsr
, cpu_pc
, cpu_npc
, cpu_gregs
[8];
48 #ifndef CONFIG_USER_ONLY
53 static TCGv_i32 cpu_xcc
, cpu_asi
, cpu_fprs
;
55 static TCGv cpu_tick_cmpr
, cpu_stick_cmpr
, cpu_hstick_cmpr
;
56 static TCGv cpu_hintp
, cpu_htba
, cpu_hver
, cpu_ssr
, cpu_ver
;
57 static TCGv_i32 cpu_softint
;
61 /* Floating point registers */
62 static TCGv_i64 cpu_fpr
[TARGET_DPREGS
];
64 static target_ulong gen_opc_npc
[OPC_BUF_SIZE
];
65 static target_ulong gen_opc_jump_pc
[2];
67 #include "gen-icount.h"
69 typedef struct DisasContext
{
70 target_ulong pc
; /* current Program Counter: integer or DYNAMIC_PC */
71 target_ulong npc
; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
72 target_ulong jump_pc
[2]; /* used when JUMP_PC pc value is used */
76 int address_mask_32bit
;
78 uint32_t cc_op
; /* current CC operation */
79 struct TranslationBlock
*tb
;
94 // This function uses non-native bit order
95 #define GET_FIELD(X, FROM, TO) \
96 ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
98 // This function uses the order in the manuals, i.e. bit 0 is 2^0
99 #define GET_FIELD_SP(X, FROM, TO) \
100 GET_FIELD(X, 31 - (TO), 31 - (FROM))
102 #define GET_FIELDs(x,a,b) sign_extend (GET_FIELD(x,a,b), (b) - (a) + 1)
103 #define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1))
105 #ifdef TARGET_SPARC64
106 #define DFPREG(r) (((r & 1) << 5) | (r & 0x1e))
107 #define QFPREG(r) (((r & 1) << 5) | (r & 0x1c))
109 #define DFPREG(r) (r & 0x1e)
110 #define QFPREG(r) (r & 0x1c)
113 #define UA2005_HTRAP_MASK 0xff
114 #define V8_TRAP_MASK 0x7f
116 static int sign_extend(int x
, int len
)
119 return (x
<< len
) >> len
;
122 #define IS_IMM (insn & (1<<13))
124 static inline TCGv_i32
get_temp_i32(DisasContext
*dc
)
127 assert(dc
->n_t32
< ARRAY_SIZE(dc
->t32
));
128 dc
->t32
[dc
->n_t32
++] = t
= tcg_temp_new_i32();
132 static inline TCGv
get_temp_tl(DisasContext
*dc
)
135 assert(dc
->n_ttl
< ARRAY_SIZE(dc
->ttl
));
136 dc
->ttl
[dc
->n_ttl
++] = t
= tcg_temp_new();
140 static inline void gen_update_fprs_dirty(int rd
)
142 #if defined(TARGET_SPARC64)
143 tcg_gen_ori_i32(cpu_fprs
, cpu_fprs
, (rd
< 32) ? 1 : 2);
147 /* floating point registers moves */
148 static TCGv_i32
gen_load_fpr_F(DisasContext
*dc
, unsigned int src
)
150 #if TCG_TARGET_REG_BITS == 32
152 return TCGV_LOW(cpu_fpr
[src
/ 2]);
154 return TCGV_HIGH(cpu_fpr
[src
/ 2]);
158 return MAKE_TCGV_I32(GET_TCGV_I64(cpu_fpr
[src
/ 2]));
160 TCGv_i32 ret
= get_temp_i32(dc
);
161 TCGv_i64 t
= tcg_temp_new_i64();
163 tcg_gen_shri_i64(t
, cpu_fpr
[src
/ 2], 32);
164 tcg_gen_trunc_i64_i32(ret
, t
);
165 tcg_temp_free_i64(t
);
172 static void gen_store_fpr_F(DisasContext
*dc
, unsigned int dst
, TCGv_i32 v
)
174 #if TCG_TARGET_REG_BITS == 32
176 tcg_gen_mov_i32(TCGV_LOW(cpu_fpr
[dst
/ 2]), v
);
178 tcg_gen_mov_i32(TCGV_HIGH(cpu_fpr
[dst
/ 2]), v
);
181 TCGv_i64 t
= MAKE_TCGV_I64(GET_TCGV_I32(v
));
182 tcg_gen_deposit_i64(cpu_fpr
[dst
/ 2], cpu_fpr
[dst
/ 2], t
,
183 (dst
& 1 ? 0 : 32), 32);
185 gen_update_fprs_dirty(dst
);
188 static TCGv_i32
gen_dest_fpr_F(DisasContext
*dc
)
190 return get_temp_i32(dc
);
193 static TCGv_i64
gen_load_fpr_D(DisasContext
*dc
, unsigned int src
)
196 return cpu_fpr
[src
/ 2];
199 static void gen_store_fpr_D(DisasContext
*dc
, unsigned int dst
, TCGv_i64 v
)
202 tcg_gen_mov_i64(cpu_fpr
[dst
/ 2], v
);
203 gen_update_fprs_dirty(dst
);
206 static TCGv_i64
gen_dest_fpr_D(DisasContext
*dc
, unsigned int dst
)
208 return cpu_fpr
[DFPREG(dst
) / 2];
211 static void gen_op_load_fpr_QT0(unsigned int src
)
213 tcg_gen_st_i64(cpu_fpr
[src
/ 2], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
214 offsetof(CPU_QuadU
, ll
.upper
));
215 tcg_gen_st_i64(cpu_fpr
[src
/2 + 1], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
216 offsetof(CPU_QuadU
, ll
.lower
));
219 static void gen_op_load_fpr_QT1(unsigned int src
)
221 tcg_gen_st_i64(cpu_fpr
[src
/ 2], cpu_env
, offsetof(CPUSPARCState
, qt1
) +
222 offsetof(CPU_QuadU
, ll
.upper
));
223 tcg_gen_st_i64(cpu_fpr
[src
/2 + 1], cpu_env
, offsetof(CPUSPARCState
, qt1
) +
224 offsetof(CPU_QuadU
, ll
.lower
));
227 static void gen_op_store_QT0_fpr(unsigned int dst
)
229 tcg_gen_ld_i64(cpu_fpr
[dst
/ 2], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
230 offsetof(CPU_QuadU
, ll
.upper
));
231 tcg_gen_ld_i64(cpu_fpr
[dst
/2 + 1], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
232 offsetof(CPU_QuadU
, ll
.lower
));
235 #ifdef TARGET_SPARC64
236 static void gen_move_Q(unsigned int rd
, unsigned int rs
)
241 tcg_gen_mov_i64(cpu_fpr
[rd
/ 2], cpu_fpr
[rs
/ 2]);
242 tcg_gen_mov_i64(cpu_fpr
[rd
/ 2 + 1], cpu_fpr
[rs
/ 2 + 1]);
243 gen_update_fprs_dirty(rd
);
248 #ifdef CONFIG_USER_ONLY
249 #define supervisor(dc) 0
250 #ifdef TARGET_SPARC64
251 #define hypervisor(dc) 0
254 #define supervisor(dc) (dc->mem_idx >= MMU_KERNEL_IDX)
255 #ifdef TARGET_SPARC64
256 #define hypervisor(dc) (dc->mem_idx == MMU_HYPV_IDX)
261 #ifdef TARGET_SPARC64
263 #define AM_CHECK(dc) ((dc)->address_mask_32bit)
265 #define AM_CHECK(dc) (1)
269 static inline void gen_address_mask(DisasContext
*dc
, TCGv addr
)
271 #ifdef TARGET_SPARC64
273 tcg_gen_andi_tl(addr
, addr
, 0xffffffffULL
);
277 static inline TCGv
gen_load_gpr(DisasContext
*dc
, int reg
)
279 if (reg
== 0 || reg
>= 8) {
280 TCGv t
= get_temp_tl(dc
);
282 tcg_gen_movi_tl(t
, 0);
284 tcg_gen_ld_tl(t
, cpu_regwptr
, (reg
- 8) * sizeof(target_ulong
));
288 return cpu_gregs
[reg
];
292 static inline void gen_store_gpr(DisasContext
*dc
, int reg
, TCGv v
)
296 tcg_gen_mov_tl(cpu_gregs
[reg
], v
);
298 tcg_gen_st_tl(v
, cpu_regwptr
, (reg
- 8) * sizeof(target_ulong
));
303 static inline TCGv
gen_dest_gpr(DisasContext
*dc
, int reg
)
305 if (reg
== 0 || reg
>= 8) {
306 return get_temp_tl(dc
);
308 return cpu_gregs
[reg
];
312 static inline void gen_goto_tb(DisasContext
*s
, int tb_num
,
313 target_ulong pc
, target_ulong npc
)
315 TranslationBlock
*tb
;
318 if ((pc
& TARGET_PAGE_MASK
) == (tb
->pc
& TARGET_PAGE_MASK
) &&
319 (npc
& TARGET_PAGE_MASK
) == (tb
->pc
& TARGET_PAGE_MASK
) &&
321 /* jump to same page: we can use a direct jump */
322 tcg_gen_goto_tb(tb_num
);
323 tcg_gen_movi_tl(cpu_pc
, pc
);
324 tcg_gen_movi_tl(cpu_npc
, npc
);
325 tcg_gen_exit_tb((tcg_target_long
)tb
+ tb_num
);
327 /* jump to another page: currently not optimized */
328 tcg_gen_movi_tl(cpu_pc
, pc
);
329 tcg_gen_movi_tl(cpu_npc
, npc
);
335 static inline void gen_mov_reg_N(TCGv reg
, TCGv_i32 src
)
337 tcg_gen_extu_i32_tl(reg
, src
);
338 tcg_gen_shri_tl(reg
, reg
, PSR_NEG_SHIFT
);
339 tcg_gen_andi_tl(reg
, reg
, 0x1);
342 static inline void gen_mov_reg_Z(TCGv reg
, TCGv_i32 src
)
344 tcg_gen_extu_i32_tl(reg
, src
);
345 tcg_gen_shri_tl(reg
, reg
, PSR_ZERO_SHIFT
);
346 tcg_gen_andi_tl(reg
, reg
, 0x1);
349 static inline void gen_mov_reg_V(TCGv reg
, TCGv_i32 src
)
351 tcg_gen_extu_i32_tl(reg
, src
);
352 tcg_gen_shri_tl(reg
, reg
, PSR_OVF_SHIFT
);
353 tcg_gen_andi_tl(reg
, reg
, 0x1);
356 static inline void gen_mov_reg_C(TCGv reg
, TCGv_i32 src
)
358 tcg_gen_extu_i32_tl(reg
, src
);
359 tcg_gen_shri_tl(reg
, reg
, PSR_CARRY_SHIFT
);
360 tcg_gen_andi_tl(reg
, reg
, 0x1);
363 static inline void gen_op_addi_cc(TCGv dst
, TCGv src1
, target_long src2
)
365 tcg_gen_mov_tl(cpu_cc_src
, src1
);
366 tcg_gen_movi_tl(cpu_cc_src2
, src2
);
367 tcg_gen_addi_tl(cpu_cc_dst
, cpu_cc_src
, src2
);
368 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
371 static inline void gen_op_add_cc(TCGv dst
, TCGv src1
, TCGv src2
)
373 tcg_gen_mov_tl(cpu_cc_src
, src1
);
374 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
375 tcg_gen_add_tl(cpu_cc_dst
, cpu_cc_src
, cpu_cc_src2
);
376 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
379 static TCGv_i32
gen_add32_carry32(void)
381 TCGv_i32 carry_32
, cc_src1_32
, cc_src2_32
;
383 /* Carry is computed from a previous add: (dst < src) */
384 #if TARGET_LONG_BITS == 64
385 cc_src1_32
= tcg_temp_new_i32();
386 cc_src2_32
= tcg_temp_new_i32();
387 tcg_gen_trunc_i64_i32(cc_src1_32
, cpu_cc_dst
);
388 tcg_gen_trunc_i64_i32(cc_src2_32
, cpu_cc_src
);
390 cc_src1_32
= cpu_cc_dst
;
391 cc_src2_32
= cpu_cc_src
;
394 carry_32
= tcg_temp_new_i32();
395 tcg_gen_setcond_i32(TCG_COND_LTU
, carry_32
, cc_src1_32
, cc_src2_32
);
397 #if TARGET_LONG_BITS == 64
398 tcg_temp_free_i32(cc_src1_32
);
399 tcg_temp_free_i32(cc_src2_32
);
405 static TCGv_i32
gen_sub32_carry32(void)
407 TCGv_i32 carry_32
, cc_src1_32
, cc_src2_32
;
409 /* Carry is computed from a previous borrow: (src1 < src2) */
410 #if TARGET_LONG_BITS == 64
411 cc_src1_32
= tcg_temp_new_i32();
412 cc_src2_32
= tcg_temp_new_i32();
413 tcg_gen_trunc_i64_i32(cc_src1_32
, cpu_cc_src
);
414 tcg_gen_trunc_i64_i32(cc_src2_32
, cpu_cc_src2
);
416 cc_src1_32
= cpu_cc_src
;
417 cc_src2_32
= cpu_cc_src2
;
420 carry_32
= tcg_temp_new_i32();
421 tcg_gen_setcond_i32(TCG_COND_LTU
, carry_32
, cc_src1_32
, cc_src2_32
);
423 #if TARGET_LONG_BITS == 64
424 tcg_temp_free_i32(cc_src1_32
);
425 tcg_temp_free_i32(cc_src2_32
);
431 static void gen_op_addx_int(DisasContext
*dc
, TCGv dst
, TCGv src1
,
432 TCGv src2
, int update_cc
)
440 /* Carry is known to be zero. Fall back to plain ADD. */
442 gen_op_add_cc(dst
, src1
, src2
);
444 tcg_gen_add_tl(dst
, src1
, src2
);
451 #if TCG_TARGET_REG_BITS == 32 && TARGET_LONG_BITS == 32
453 /* For 32-bit hosts, we can re-use the host's hardware carry
454 generation by using an ADD2 opcode. We discard the low
455 part of the output. Ideally we'd combine this operation
456 with the add that generated the carry in the first place. */
457 TCGv dst_low
= tcg_temp_new();
458 tcg_gen_op6_i32(INDEX_op_add2_i32
, dst_low
, dst
,
459 cpu_cc_src
, src1
, cpu_cc_src2
, src2
);
460 tcg_temp_free(dst_low
);
464 carry_32
= gen_add32_carry32();
470 carry_32
= gen_sub32_carry32();
474 /* We need external help to produce the carry. */
475 carry_32
= tcg_temp_new_i32();
476 gen_helper_compute_C_icc(carry_32
, cpu_env
);
480 #if TARGET_LONG_BITS == 64
481 carry
= tcg_temp_new();
482 tcg_gen_extu_i32_i64(carry
, carry_32
);
487 tcg_gen_add_tl(dst
, src1
, src2
);
488 tcg_gen_add_tl(dst
, dst
, carry
);
490 tcg_temp_free_i32(carry_32
);
491 #if TARGET_LONG_BITS == 64
492 tcg_temp_free(carry
);
495 #if TCG_TARGET_REG_BITS == 32 && TARGET_LONG_BITS == 32
499 tcg_gen_mov_tl(cpu_cc_src
, src1
);
500 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
501 tcg_gen_mov_tl(cpu_cc_dst
, dst
);
502 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_ADDX
);
503 dc
->cc_op
= CC_OP_ADDX
;
507 static inline void gen_op_subi_cc(TCGv dst
, TCGv src1
, target_long src2
, DisasContext
*dc
)
509 tcg_gen_mov_tl(cpu_cc_src
, src1
);
510 tcg_gen_movi_tl(cpu_cc_src2
, src2
);
512 tcg_gen_mov_tl(cpu_cc_dst
, src1
);
513 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
514 dc
->cc_op
= CC_OP_LOGIC
;
516 tcg_gen_subi_tl(cpu_cc_dst
, cpu_cc_src
, src2
);
517 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUB
);
518 dc
->cc_op
= CC_OP_SUB
;
520 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
523 static inline void gen_op_sub_cc(TCGv dst
, TCGv src1
, TCGv src2
)
525 tcg_gen_mov_tl(cpu_cc_src
, src1
);
526 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
527 tcg_gen_sub_tl(cpu_cc_dst
, cpu_cc_src
, cpu_cc_src2
);
528 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
531 static void gen_op_subx_int(DisasContext
*dc
, TCGv dst
, TCGv src1
,
532 TCGv src2
, int update_cc
)
540 /* Carry is known to be zero. Fall back to plain SUB. */
542 gen_op_sub_cc(dst
, src1
, src2
);
544 tcg_gen_sub_tl(dst
, src1
, src2
);
551 carry_32
= gen_add32_carry32();
557 #if TCG_TARGET_REG_BITS == 32 && TARGET_LONG_BITS == 32
559 /* For 32-bit hosts, we can re-use the host's hardware carry
560 generation by using a SUB2 opcode. We discard the low
561 part of the output. Ideally we'd combine this operation
562 with the add that generated the carry in the first place. */
563 TCGv dst_low
= tcg_temp_new();
564 tcg_gen_op6_i32(INDEX_op_sub2_i32
, dst_low
, dst
,
565 cpu_cc_src
, src1
, cpu_cc_src2
, src2
);
566 tcg_temp_free(dst_low
);
570 carry_32
= gen_sub32_carry32();
574 /* We need external help to produce the carry. */
575 carry_32
= tcg_temp_new_i32();
576 gen_helper_compute_C_icc(carry_32
, cpu_env
);
580 #if TARGET_LONG_BITS == 64
581 carry
= tcg_temp_new();
582 tcg_gen_extu_i32_i64(carry
, carry_32
);
587 tcg_gen_sub_tl(dst
, src1
, src2
);
588 tcg_gen_sub_tl(dst
, dst
, carry
);
590 tcg_temp_free_i32(carry_32
);
591 #if TARGET_LONG_BITS == 64
592 tcg_temp_free(carry
);
595 #if TCG_TARGET_REG_BITS == 32 && TARGET_LONG_BITS == 32
599 tcg_gen_mov_tl(cpu_cc_src
, src1
);
600 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
601 tcg_gen_mov_tl(cpu_cc_dst
, dst
);
602 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUBX
);
603 dc
->cc_op
= CC_OP_SUBX
;
607 static inline void gen_op_mulscc(TCGv dst
, TCGv src1
, TCGv src2
)
609 TCGv r_temp
, zero
, t0
;
611 r_temp
= tcg_temp_new();
618 zero
= tcg_const_tl(0);
619 tcg_gen_andi_tl(cpu_cc_src
, src1
, 0xffffffff);
620 tcg_gen_andi_tl(r_temp
, cpu_y
, 0x1);
621 tcg_gen_andi_tl(cpu_cc_src2
, src2
, 0xffffffff);
622 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_cc_src2
, r_temp
, zero
,
627 // env->y = (b2 << 31) | (env->y >> 1);
628 tcg_gen_andi_tl(r_temp
, cpu_cc_src
, 0x1);
629 tcg_gen_shli_tl(r_temp
, r_temp
, 31);
630 tcg_gen_shri_tl(t0
, cpu_y
, 1);
631 tcg_gen_andi_tl(t0
, t0
, 0x7fffffff);
632 tcg_gen_or_tl(t0
, t0
, r_temp
);
633 tcg_gen_andi_tl(cpu_y
, t0
, 0xffffffff);
636 gen_mov_reg_N(t0
, cpu_psr
);
637 gen_mov_reg_V(r_temp
, cpu_psr
);
638 tcg_gen_xor_tl(t0
, t0
, r_temp
);
639 tcg_temp_free(r_temp
);
641 // T0 = (b1 << 31) | (T0 >> 1);
643 tcg_gen_shli_tl(t0
, t0
, 31);
644 tcg_gen_shri_tl(cpu_cc_src
, cpu_cc_src
, 1);
645 tcg_gen_or_tl(cpu_cc_src
, cpu_cc_src
, t0
);
648 tcg_gen_add_tl(cpu_cc_dst
, cpu_cc_src
, cpu_cc_src2
);
650 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
653 static inline void gen_op_multiply(TCGv dst
, TCGv src1
, TCGv src2
, int sign_ext
)
655 TCGv_i32 r_src1
, r_src2
;
656 TCGv_i64 r_temp
, r_temp2
;
658 r_src1
= tcg_temp_new_i32();
659 r_src2
= tcg_temp_new_i32();
661 tcg_gen_trunc_tl_i32(r_src1
, src1
);
662 tcg_gen_trunc_tl_i32(r_src2
, src2
);
664 r_temp
= tcg_temp_new_i64();
665 r_temp2
= tcg_temp_new_i64();
668 tcg_gen_ext_i32_i64(r_temp
, r_src2
);
669 tcg_gen_ext_i32_i64(r_temp2
, r_src1
);
671 tcg_gen_extu_i32_i64(r_temp
, r_src2
);
672 tcg_gen_extu_i32_i64(r_temp2
, r_src1
);
675 tcg_gen_mul_i64(r_temp2
, r_temp
, r_temp2
);
677 tcg_gen_shri_i64(r_temp
, r_temp2
, 32);
678 tcg_gen_trunc_i64_tl(cpu_y
, r_temp
);
679 tcg_temp_free_i64(r_temp
);
680 tcg_gen_andi_tl(cpu_y
, cpu_y
, 0xffffffff);
682 tcg_gen_trunc_i64_tl(dst
, r_temp2
);
684 tcg_temp_free_i64(r_temp2
);
686 tcg_temp_free_i32(r_src1
);
687 tcg_temp_free_i32(r_src2
);
690 static inline void gen_op_umul(TCGv dst
, TCGv src1
, TCGv src2
)
692 /* zero-extend truncated operands before multiplication */
693 gen_op_multiply(dst
, src1
, src2
, 0);
696 static inline void gen_op_smul(TCGv dst
, TCGv src1
, TCGv src2
)
698 /* sign-extend truncated operands before multiplication */
699 gen_op_multiply(dst
, src1
, src2
, 1);
703 static inline void gen_op_eval_ba(TCGv dst
)
705 tcg_gen_movi_tl(dst
, 1);
709 static inline void gen_op_eval_be(TCGv dst
, TCGv_i32 src
)
711 gen_mov_reg_Z(dst
, src
);
715 static inline void gen_op_eval_ble(TCGv dst
, TCGv_i32 src
)
717 TCGv t0
= tcg_temp_new();
718 gen_mov_reg_N(t0
, src
);
719 gen_mov_reg_V(dst
, src
);
720 tcg_gen_xor_tl(dst
, dst
, t0
);
721 gen_mov_reg_Z(t0
, src
);
722 tcg_gen_or_tl(dst
, dst
, t0
);
727 static inline void gen_op_eval_bl(TCGv dst
, TCGv_i32 src
)
729 TCGv t0
= tcg_temp_new();
730 gen_mov_reg_V(t0
, src
);
731 gen_mov_reg_N(dst
, src
);
732 tcg_gen_xor_tl(dst
, dst
, t0
);
737 static inline void gen_op_eval_bleu(TCGv dst
, TCGv_i32 src
)
739 TCGv t0
= tcg_temp_new();
740 gen_mov_reg_Z(t0
, src
);
741 gen_mov_reg_C(dst
, src
);
742 tcg_gen_or_tl(dst
, dst
, t0
);
747 static inline void gen_op_eval_bcs(TCGv dst
, TCGv_i32 src
)
749 gen_mov_reg_C(dst
, src
);
753 static inline void gen_op_eval_bvs(TCGv dst
, TCGv_i32 src
)
755 gen_mov_reg_V(dst
, src
);
759 static inline void gen_op_eval_bn(TCGv dst
)
761 tcg_gen_movi_tl(dst
, 0);
765 static inline void gen_op_eval_bneg(TCGv dst
, TCGv_i32 src
)
767 gen_mov_reg_N(dst
, src
);
771 static inline void gen_op_eval_bne(TCGv dst
, TCGv_i32 src
)
773 gen_mov_reg_Z(dst
, src
);
774 tcg_gen_xori_tl(dst
, dst
, 0x1);
778 static inline void gen_op_eval_bg(TCGv dst
, TCGv_i32 src
)
780 gen_op_eval_ble(dst
, src
);
781 tcg_gen_xori_tl(dst
, dst
, 0x1);
785 static inline void gen_op_eval_bge(TCGv dst
, TCGv_i32 src
)
787 gen_op_eval_bl(dst
, src
);
788 tcg_gen_xori_tl(dst
, dst
, 0x1);
792 static inline void gen_op_eval_bgu(TCGv dst
, TCGv_i32 src
)
794 gen_op_eval_bleu(dst
, src
);
795 tcg_gen_xori_tl(dst
, dst
, 0x1);
799 static inline void gen_op_eval_bcc(TCGv dst
, TCGv_i32 src
)
801 gen_mov_reg_C(dst
, src
);
802 tcg_gen_xori_tl(dst
, dst
, 0x1);
806 static inline void gen_op_eval_bpos(TCGv dst
, TCGv_i32 src
)
808 gen_mov_reg_N(dst
, src
);
809 tcg_gen_xori_tl(dst
, dst
, 0x1);
813 static inline void gen_op_eval_bvc(TCGv dst
, TCGv_i32 src
)
815 gen_mov_reg_V(dst
, src
);
816 tcg_gen_xori_tl(dst
, dst
, 0x1);
820 FPSR bit field FCC1 | FCC0:
826 static inline void gen_mov_reg_FCC0(TCGv reg
, TCGv src
,
827 unsigned int fcc_offset
)
829 tcg_gen_shri_tl(reg
, src
, FSR_FCC0_SHIFT
+ fcc_offset
);
830 tcg_gen_andi_tl(reg
, reg
, 0x1);
833 static inline void gen_mov_reg_FCC1(TCGv reg
, TCGv src
,
834 unsigned int fcc_offset
)
836 tcg_gen_shri_tl(reg
, src
, FSR_FCC1_SHIFT
+ fcc_offset
);
837 tcg_gen_andi_tl(reg
, reg
, 0x1);
841 static inline void gen_op_eval_fbne(TCGv dst
, TCGv src
,
842 unsigned int fcc_offset
)
844 TCGv t0
= tcg_temp_new();
845 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
846 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
847 tcg_gen_or_tl(dst
, dst
, t0
);
851 // 1 or 2: FCC0 ^ FCC1
852 static inline void gen_op_eval_fblg(TCGv dst
, TCGv src
,
853 unsigned int fcc_offset
)
855 TCGv t0
= tcg_temp_new();
856 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
857 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
858 tcg_gen_xor_tl(dst
, dst
, t0
);
863 static inline void gen_op_eval_fbul(TCGv dst
, TCGv src
,
864 unsigned int fcc_offset
)
866 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
870 static inline void gen_op_eval_fbl(TCGv dst
, TCGv src
,
871 unsigned int fcc_offset
)
873 TCGv t0
= tcg_temp_new();
874 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
875 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
876 tcg_gen_andc_tl(dst
, dst
, t0
);
881 static inline void gen_op_eval_fbug(TCGv dst
, TCGv src
,
882 unsigned int fcc_offset
)
884 gen_mov_reg_FCC1(dst
, src
, fcc_offset
);
888 static inline void gen_op_eval_fbg(TCGv dst
, TCGv src
,
889 unsigned int fcc_offset
)
891 TCGv t0
= tcg_temp_new();
892 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
893 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
894 tcg_gen_andc_tl(dst
, t0
, dst
);
899 static inline void gen_op_eval_fbu(TCGv dst
, TCGv src
,
900 unsigned int fcc_offset
)
902 TCGv t0
= tcg_temp_new();
903 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
904 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
905 tcg_gen_and_tl(dst
, dst
, t0
);
910 static inline void gen_op_eval_fbe(TCGv dst
, TCGv src
,
911 unsigned int fcc_offset
)
913 TCGv t0
= tcg_temp_new();
914 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
915 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
916 tcg_gen_or_tl(dst
, dst
, t0
);
917 tcg_gen_xori_tl(dst
, dst
, 0x1);
921 // 0 or 3: !(FCC0 ^ FCC1)
922 static inline void gen_op_eval_fbue(TCGv dst
, TCGv src
,
923 unsigned int fcc_offset
)
925 TCGv t0
= tcg_temp_new();
926 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
927 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
928 tcg_gen_xor_tl(dst
, dst
, t0
);
929 tcg_gen_xori_tl(dst
, dst
, 0x1);
934 static inline void gen_op_eval_fbge(TCGv dst
, TCGv src
,
935 unsigned int fcc_offset
)
937 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
938 tcg_gen_xori_tl(dst
, dst
, 0x1);
941 // !1: !(FCC0 & !FCC1)
942 static inline void gen_op_eval_fbuge(TCGv dst
, TCGv src
,
943 unsigned int fcc_offset
)
945 TCGv t0
= tcg_temp_new();
946 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
947 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
948 tcg_gen_andc_tl(dst
, dst
, t0
);
949 tcg_gen_xori_tl(dst
, dst
, 0x1);
954 static inline void gen_op_eval_fble(TCGv dst
, TCGv src
,
955 unsigned int fcc_offset
)
957 gen_mov_reg_FCC1(dst
, src
, fcc_offset
);
958 tcg_gen_xori_tl(dst
, dst
, 0x1);
961 // !2: !(!FCC0 & FCC1)
962 static inline void gen_op_eval_fbule(TCGv dst
, TCGv src
,
963 unsigned int fcc_offset
)
965 TCGv t0
= tcg_temp_new();
966 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
967 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
968 tcg_gen_andc_tl(dst
, t0
, dst
);
969 tcg_gen_xori_tl(dst
, dst
, 0x1);
973 // !3: !(FCC0 & FCC1)
974 static inline void gen_op_eval_fbo(TCGv dst
, TCGv src
,
975 unsigned int fcc_offset
)
977 TCGv t0
= tcg_temp_new();
978 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
979 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
980 tcg_gen_and_tl(dst
, dst
, t0
);
981 tcg_gen_xori_tl(dst
, dst
, 0x1);
985 static inline void gen_branch2(DisasContext
*dc
, target_ulong pc1
,
986 target_ulong pc2
, TCGv r_cond
)
990 l1
= gen_new_label();
992 tcg_gen_brcondi_tl(TCG_COND_EQ
, r_cond
, 0, l1
);
994 gen_goto_tb(dc
, 0, pc1
, pc1
+ 4);
997 gen_goto_tb(dc
, 1, pc2
, pc2
+ 4);
1000 static inline void gen_branch_a(DisasContext
*dc
, target_ulong pc1
,
1001 target_ulong pc2
, TCGv r_cond
)
1005 l1
= gen_new_label();
1007 tcg_gen_brcondi_tl(TCG_COND_EQ
, r_cond
, 0, l1
);
1009 gen_goto_tb(dc
, 0, pc2
, pc1
);
1012 gen_goto_tb(dc
, 1, pc2
+ 4, pc2
+ 8);
1015 static inline void gen_generic_branch(DisasContext
*dc
)
1017 TCGv npc0
= tcg_const_tl(dc
->jump_pc
[0]);
1018 TCGv npc1
= tcg_const_tl(dc
->jump_pc
[1]);
1019 TCGv zero
= tcg_const_tl(0);
1021 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_npc
, cpu_cond
, zero
, npc0
, npc1
);
1023 tcg_temp_free(npc0
);
1024 tcg_temp_free(npc1
);
1025 tcg_temp_free(zero
);
1028 /* call this function before using the condition register as it may
1029 have been set for a jump */
1030 static inline void flush_cond(DisasContext
*dc
)
1032 if (dc
->npc
== JUMP_PC
) {
1033 gen_generic_branch(dc
);
1034 dc
->npc
= DYNAMIC_PC
;
1038 static inline void save_npc(DisasContext
*dc
)
1040 if (dc
->npc
== JUMP_PC
) {
1041 gen_generic_branch(dc
);
1042 dc
->npc
= DYNAMIC_PC
;
1043 } else if (dc
->npc
!= DYNAMIC_PC
) {
1044 tcg_gen_movi_tl(cpu_npc
, dc
->npc
);
1048 static inline void update_psr(DisasContext
*dc
)
1050 if (dc
->cc_op
!= CC_OP_FLAGS
) {
1051 dc
->cc_op
= CC_OP_FLAGS
;
1052 gen_helper_compute_psr(cpu_env
);
1056 static inline void save_state(DisasContext
*dc
)
1058 tcg_gen_movi_tl(cpu_pc
, dc
->pc
);
1062 static inline void gen_mov_pc_npc(DisasContext
*dc
)
1064 if (dc
->npc
== JUMP_PC
) {
1065 gen_generic_branch(dc
);
1066 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1067 dc
->pc
= DYNAMIC_PC
;
1068 } else if (dc
->npc
== DYNAMIC_PC
) {
1069 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1070 dc
->pc
= DYNAMIC_PC
;
1076 static inline void gen_op_next_insn(void)
1078 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1079 tcg_gen_addi_tl(cpu_npc
, cpu_npc
, 4);
1082 static void free_compare(DisasCompare
*cmp
)
1085 tcg_temp_free(cmp
->c1
);
1088 tcg_temp_free(cmp
->c2
);
1092 static void gen_compare(DisasCompare
*cmp
, bool xcc
, unsigned int cond
,
1095 static int subcc_cond
[16] = {
1111 -1, /* no overflow */
1114 static int logic_cond
[16] = {
1116 TCG_COND_EQ
, /* eq: Z */
1117 TCG_COND_LE
, /* le: Z | (N ^ V) -> Z | N */
1118 TCG_COND_LT
, /* lt: N ^ V -> N */
1119 TCG_COND_EQ
, /* leu: C | Z -> Z */
1120 TCG_COND_NEVER
, /* ltu: C -> 0 */
1121 TCG_COND_LT
, /* neg: N */
1122 TCG_COND_NEVER
, /* vs: V -> 0 */
1124 TCG_COND_NE
, /* ne: !Z */
1125 TCG_COND_GT
, /* gt: !(Z | (N ^ V)) -> !(Z | N) */
1126 TCG_COND_GE
, /* ge: !(N ^ V) -> !N */
1127 TCG_COND_NE
, /* gtu: !(C | Z) -> !Z */
1128 TCG_COND_ALWAYS
, /* geu: !C -> 1 */
1129 TCG_COND_GE
, /* pos: !N */
1130 TCG_COND_ALWAYS
, /* vc: !V -> 1 */
1136 #ifdef TARGET_SPARC64
1146 switch (dc
->cc_op
) {
1148 cmp
->cond
= logic_cond
[cond
];
1150 cmp
->is_bool
= false;
1152 cmp
->c2
= tcg_const_tl(0);
1153 #ifdef TARGET_SPARC64
1156 cmp
->c1
= tcg_temp_new();
1157 tcg_gen_ext32s_tl(cmp
->c1
, cpu_cc_dst
);
1162 cmp
->c1
= cpu_cc_dst
;
1169 cmp
->cond
= (cond
== 6 ? TCG_COND_LT
: TCG_COND_GE
);
1170 goto do_compare_dst_0
;
1172 case 7: /* overflow */
1173 case 15: /* !overflow */
1177 cmp
->cond
= subcc_cond
[cond
];
1178 cmp
->is_bool
= false;
1179 #ifdef TARGET_SPARC64
1181 /* Note that sign-extension works for unsigned compares as
1182 long as both operands are sign-extended. */
1183 cmp
->g1
= cmp
->g2
= false;
1184 cmp
->c1
= tcg_temp_new();
1185 cmp
->c2
= tcg_temp_new();
1186 tcg_gen_ext32s_tl(cmp
->c1
, cpu_cc_src
);
1187 tcg_gen_ext32s_tl(cmp
->c2
, cpu_cc_src2
);
1191 cmp
->g1
= cmp
->g2
= true;
1192 cmp
->c1
= cpu_cc_src
;
1193 cmp
->c2
= cpu_cc_src2
;
1200 gen_helper_compute_psr(cpu_env
);
1201 dc
->cc_op
= CC_OP_FLAGS
;
1205 /* We're going to generate a boolean result. */
1206 cmp
->cond
= TCG_COND_NE
;
1207 cmp
->is_bool
= true;
1208 cmp
->g1
= cmp
->g2
= false;
1209 cmp
->c1
= r_dst
= tcg_temp_new();
1210 cmp
->c2
= tcg_const_tl(0);
1214 gen_op_eval_bn(r_dst
);
1217 gen_op_eval_be(r_dst
, r_src
);
1220 gen_op_eval_ble(r_dst
, r_src
);
1223 gen_op_eval_bl(r_dst
, r_src
);
1226 gen_op_eval_bleu(r_dst
, r_src
);
1229 gen_op_eval_bcs(r_dst
, r_src
);
1232 gen_op_eval_bneg(r_dst
, r_src
);
1235 gen_op_eval_bvs(r_dst
, r_src
);
1238 gen_op_eval_ba(r_dst
);
1241 gen_op_eval_bne(r_dst
, r_src
);
1244 gen_op_eval_bg(r_dst
, r_src
);
1247 gen_op_eval_bge(r_dst
, r_src
);
1250 gen_op_eval_bgu(r_dst
, r_src
);
1253 gen_op_eval_bcc(r_dst
, r_src
);
1256 gen_op_eval_bpos(r_dst
, r_src
);
1259 gen_op_eval_bvc(r_dst
, r_src
);
1266 static void gen_fcompare(DisasCompare
*cmp
, unsigned int cc
, unsigned int cond
)
1268 unsigned int offset
;
1271 /* For now we still generate a straight boolean result. */
1272 cmp
->cond
= TCG_COND_NE
;
1273 cmp
->is_bool
= true;
1274 cmp
->g1
= cmp
->g2
= false;
1275 cmp
->c1
= r_dst
= tcg_temp_new();
1276 cmp
->c2
= tcg_const_tl(0);
1296 gen_op_eval_bn(r_dst
);
1299 gen_op_eval_fbne(r_dst
, cpu_fsr
, offset
);
1302 gen_op_eval_fblg(r_dst
, cpu_fsr
, offset
);
1305 gen_op_eval_fbul(r_dst
, cpu_fsr
, offset
);
1308 gen_op_eval_fbl(r_dst
, cpu_fsr
, offset
);
1311 gen_op_eval_fbug(r_dst
, cpu_fsr
, offset
);
1314 gen_op_eval_fbg(r_dst
, cpu_fsr
, offset
);
1317 gen_op_eval_fbu(r_dst
, cpu_fsr
, offset
);
1320 gen_op_eval_ba(r_dst
);
1323 gen_op_eval_fbe(r_dst
, cpu_fsr
, offset
);
1326 gen_op_eval_fbue(r_dst
, cpu_fsr
, offset
);
1329 gen_op_eval_fbge(r_dst
, cpu_fsr
, offset
);
1332 gen_op_eval_fbuge(r_dst
, cpu_fsr
, offset
);
1335 gen_op_eval_fble(r_dst
, cpu_fsr
, offset
);
1338 gen_op_eval_fbule(r_dst
, cpu_fsr
, offset
);
1341 gen_op_eval_fbo(r_dst
, cpu_fsr
, offset
);
1346 static void gen_cond(TCGv r_dst
, unsigned int cc
, unsigned int cond
,
1350 gen_compare(&cmp
, cc
, cond
, dc
);
1352 /* The interface is to return a boolean in r_dst. */
1354 tcg_gen_mov_tl(r_dst
, cmp
.c1
);
1356 tcg_gen_setcond_tl(cmp
.cond
, r_dst
, cmp
.c1
, cmp
.c2
);
1362 static void gen_fcond(TCGv r_dst
, unsigned int cc
, unsigned int cond
)
1365 gen_fcompare(&cmp
, cc
, cond
);
1367 /* The interface is to return a boolean in r_dst. */
1369 tcg_gen_mov_tl(r_dst
, cmp
.c1
);
1371 tcg_gen_setcond_tl(cmp
.cond
, r_dst
, cmp
.c1
, cmp
.c2
);
1377 #ifdef TARGET_SPARC64
1379 static const int gen_tcg_cond_reg
[8] = {
1390 static void gen_compare_reg(DisasCompare
*cmp
, int cond
, TCGv r_src
)
1392 cmp
->cond
= tcg_invert_cond(gen_tcg_cond_reg
[cond
]);
1393 cmp
->is_bool
= false;
1397 cmp
->c2
= tcg_const_tl(0);
1400 static inline void gen_cond_reg(TCGv r_dst
, int cond
, TCGv r_src
)
1403 gen_compare_reg(&cmp
, cond
, r_src
);
1405 /* The interface is to return a boolean in r_dst. */
1406 tcg_gen_setcond_tl(cmp
.cond
, r_dst
, cmp
.c1
, cmp
.c2
);
1412 static void do_branch(DisasContext
*dc
, int32_t offset
, uint32_t insn
, int cc
)
1414 unsigned int cond
= GET_FIELD(insn
, 3, 6), a
= (insn
& (1 << 29));
1415 target_ulong target
= dc
->pc
+ offset
;
1417 #ifdef TARGET_SPARC64
1418 if (unlikely(AM_CHECK(dc
))) {
1419 target
&= 0xffffffffULL
;
1423 /* unconditional not taken */
1425 dc
->pc
= dc
->npc
+ 4;
1426 dc
->npc
= dc
->pc
+ 4;
1429 dc
->npc
= dc
->pc
+ 4;
1431 } else if (cond
== 0x8) {
1432 /* unconditional taken */
1435 dc
->npc
= dc
->pc
+ 4;
1439 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1443 gen_cond(cpu_cond
, cc
, cond
, dc
);
1445 gen_branch_a(dc
, target
, dc
->npc
, cpu_cond
);
1449 dc
->jump_pc
[0] = target
;
1450 if (unlikely(dc
->npc
== DYNAMIC_PC
)) {
1451 dc
->jump_pc
[1] = DYNAMIC_PC
;
1452 tcg_gen_addi_tl(cpu_pc
, cpu_npc
, 4);
1454 dc
->jump_pc
[1] = dc
->npc
+ 4;
1461 static void do_fbranch(DisasContext
*dc
, int32_t offset
, uint32_t insn
, int cc
)
1463 unsigned int cond
= GET_FIELD(insn
, 3, 6), a
= (insn
& (1 << 29));
1464 target_ulong target
= dc
->pc
+ offset
;
1466 #ifdef TARGET_SPARC64
1467 if (unlikely(AM_CHECK(dc
))) {
1468 target
&= 0xffffffffULL
;
1472 /* unconditional not taken */
1474 dc
->pc
= dc
->npc
+ 4;
1475 dc
->npc
= dc
->pc
+ 4;
1478 dc
->npc
= dc
->pc
+ 4;
1480 } else if (cond
== 0x8) {
1481 /* unconditional taken */
1484 dc
->npc
= dc
->pc
+ 4;
1488 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1492 gen_fcond(cpu_cond
, cc
, cond
);
1494 gen_branch_a(dc
, target
, dc
->npc
, cpu_cond
);
1498 dc
->jump_pc
[0] = target
;
1499 if (unlikely(dc
->npc
== DYNAMIC_PC
)) {
1500 dc
->jump_pc
[1] = DYNAMIC_PC
;
1501 tcg_gen_addi_tl(cpu_pc
, cpu_npc
, 4);
1503 dc
->jump_pc
[1] = dc
->npc
+ 4;
1510 #ifdef TARGET_SPARC64
1511 static void do_branch_reg(DisasContext
*dc
, int32_t offset
, uint32_t insn
,
1514 unsigned int cond
= GET_FIELD_SP(insn
, 25, 27), a
= (insn
& (1 << 29));
1515 target_ulong target
= dc
->pc
+ offset
;
1517 if (unlikely(AM_CHECK(dc
))) {
1518 target
&= 0xffffffffULL
;
1521 gen_cond_reg(cpu_cond
, cond
, r_reg
);
1523 gen_branch_a(dc
, target
, dc
->npc
, cpu_cond
);
1527 dc
->jump_pc
[0] = target
;
1528 if (unlikely(dc
->npc
== DYNAMIC_PC
)) {
1529 dc
->jump_pc
[1] = DYNAMIC_PC
;
1530 tcg_gen_addi_tl(cpu_pc
, cpu_npc
, 4);
1532 dc
->jump_pc
[1] = dc
->npc
+ 4;
1538 static inline void gen_op_fcmps(int fccno
, TCGv_i32 r_rs1
, TCGv_i32 r_rs2
)
1542 gen_helper_fcmps(cpu_env
, r_rs1
, r_rs2
);
1545 gen_helper_fcmps_fcc1(cpu_env
, r_rs1
, r_rs2
);
1548 gen_helper_fcmps_fcc2(cpu_env
, r_rs1
, r_rs2
);
1551 gen_helper_fcmps_fcc3(cpu_env
, r_rs1
, r_rs2
);
1556 static inline void gen_op_fcmpd(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1560 gen_helper_fcmpd(cpu_env
, r_rs1
, r_rs2
);
1563 gen_helper_fcmpd_fcc1(cpu_env
, r_rs1
, r_rs2
);
1566 gen_helper_fcmpd_fcc2(cpu_env
, r_rs1
, r_rs2
);
1569 gen_helper_fcmpd_fcc3(cpu_env
, r_rs1
, r_rs2
);
1574 static inline void gen_op_fcmpq(int fccno
)
1578 gen_helper_fcmpq(cpu_env
);
1581 gen_helper_fcmpq_fcc1(cpu_env
);
1584 gen_helper_fcmpq_fcc2(cpu_env
);
1587 gen_helper_fcmpq_fcc3(cpu_env
);
1592 static inline void gen_op_fcmpes(int fccno
, TCGv_i32 r_rs1
, TCGv_i32 r_rs2
)
1596 gen_helper_fcmpes(cpu_env
, r_rs1
, r_rs2
);
1599 gen_helper_fcmpes_fcc1(cpu_env
, r_rs1
, r_rs2
);
1602 gen_helper_fcmpes_fcc2(cpu_env
, r_rs1
, r_rs2
);
1605 gen_helper_fcmpes_fcc3(cpu_env
, r_rs1
, r_rs2
);
1610 static inline void gen_op_fcmped(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1614 gen_helper_fcmped(cpu_env
, r_rs1
, r_rs2
);
1617 gen_helper_fcmped_fcc1(cpu_env
, r_rs1
, r_rs2
);
1620 gen_helper_fcmped_fcc2(cpu_env
, r_rs1
, r_rs2
);
1623 gen_helper_fcmped_fcc3(cpu_env
, r_rs1
, r_rs2
);
1628 static inline void gen_op_fcmpeq(int fccno
)
1632 gen_helper_fcmpeq(cpu_env
);
1635 gen_helper_fcmpeq_fcc1(cpu_env
);
1638 gen_helper_fcmpeq_fcc2(cpu_env
);
1641 gen_helper_fcmpeq_fcc3(cpu_env
);
1648 static inline void gen_op_fcmps(int fccno
, TCGv r_rs1
, TCGv r_rs2
)
1650 gen_helper_fcmps(cpu_env
, r_rs1
, r_rs2
);
1653 static inline void gen_op_fcmpd(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1655 gen_helper_fcmpd(cpu_env
, r_rs1
, r_rs2
);
1658 static inline void gen_op_fcmpq(int fccno
)
1660 gen_helper_fcmpq(cpu_env
);
1663 static inline void gen_op_fcmpes(int fccno
, TCGv r_rs1
, TCGv r_rs2
)
1665 gen_helper_fcmpes(cpu_env
, r_rs1
, r_rs2
);
1668 static inline void gen_op_fcmped(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1670 gen_helper_fcmped(cpu_env
, r_rs1
, r_rs2
);
1673 static inline void gen_op_fcmpeq(int fccno
)
1675 gen_helper_fcmpeq(cpu_env
);
1679 static inline void gen_op_fpexception_im(int fsr_flags
)
1683 tcg_gen_andi_tl(cpu_fsr
, cpu_fsr
, FSR_FTT_NMASK
);
1684 tcg_gen_ori_tl(cpu_fsr
, cpu_fsr
, fsr_flags
);
1685 r_const
= tcg_const_i32(TT_FP_EXCP
);
1686 gen_helper_raise_exception(cpu_env
, r_const
);
1687 tcg_temp_free_i32(r_const
);
1690 static int gen_trap_ifnofpu(DisasContext
*dc
)
1692 #if !defined(CONFIG_USER_ONLY)
1693 if (!dc
->fpu_enabled
) {
1697 r_const
= tcg_const_i32(TT_NFPU_INSN
);
1698 gen_helper_raise_exception(cpu_env
, r_const
);
1699 tcg_temp_free_i32(r_const
);
1707 static inline void gen_op_clear_ieee_excp_and_FTT(void)
1709 tcg_gen_andi_tl(cpu_fsr
, cpu_fsr
, FSR_FTT_CEXC_NMASK
);
1712 static inline void gen_fop_FF(DisasContext
*dc
, int rd
, int rs
,
1713 void (*gen
)(TCGv_i32
, TCGv_ptr
, TCGv_i32
))
1717 src
= gen_load_fpr_F(dc
, rs
);
1718 dst
= gen_dest_fpr_F(dc
);
1720 gen(dst
, cpu_env
, src
);
1722 gen_store_fpr_F(dc
, rd
, dst
);
1725 static inline void gen_ne_fop_FF(DisasContext
*dc
, int rd
, int rs
,
1726 void (*gen
)(TCGv_i32
, TCGv_i32
))
1730 src
= gen_load_fpr_F(dc
, rs
);
1731 dst
= gen_dest_fpr_F(dc
);
1735 gen_store_fpr_F(dc
, rd
, dst
);
1738 static inline void gen_fop_FFF(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1739 void (*gen
)(TCGv_i32
, TCGv_ptr
, TCGv_i32
, TCGv_i32
))
1741 TCGv_i32 dst
, src1
, src2
;
1743 src1
= gen_load_fpr_F(dc
, rs1
);
1744 src2
= gen_load_fpr_F(dc
, rs2
);
1745 dst
= gen_dest_fpr_F(dc
);
1747 gen(dst
, cpu_env
, src1
, src2
);
1749 gen_store_fpr_F(dc
, rd
, dst
);
1752 #ifdef TARGET_SPARC64
1753 static inline void gen_ne_fop_FFF(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1754 void (*gen
)(TCGv_i32
, TCGv_i32
, TCGv_i32
))
1756 TCGv_i32 dst
, src1
, src2
;
1758 src1
= gen_load_fpr_F(dc
, rs1
);
1759 src2
= gen_load_fpr_F(dc
, rs2
);
1760 dst
= gen_dest_fpr_F(dc
);
1762 gen(dst
, src1
, src2
);
1764 gen_store_fpr_F(dc
, rd
, dst
);
1768 static inline void gen_fop_DD(DisasContext
*dc
, int rd
, int rs
,
1769 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i64
))
1773 src
= gen_load_fpr_D(dc
, rs
);
1774 dst
= gen_dest_fpr_D(dc
, rd
);
1776 gen(dst
, cpu_env
, src
);
1778 gen_store_fpr_D(dc
, rd
, dst
);
1781 #ifdef TARGET_SPARC64
1782 static inline void gen_ne_fop_DD(DisasContext
*dc
, int rd
, int rs
,
1783 void (*gen
)(TCGv_i64
, TCGv_i64
))
1787 src
= gen_load_fpr_D(dc
, rs
);
1788 dst
= gen_dest_fpr_D(dc
, rd
);
1792 gen_store_fpr_D(dc
, rd
, dst
);
1796 static inline void gen_fop_DDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1797 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i64
, TCGv_i64
))
1799 TCGv_i64 dst
, src1
, src2
;
1801 src1
= gen_load_fpr_D(dc
, rs1
);
1802 src2
= gen_load_fpr_D(dc
, rs2
);
1803 dst
= gen_dest_fpr_D(dc
, rd
);
1805 gen(dst
, cpu_env
, src1
, src2
);
1807 gen_store_fpr_D(dc
, rd
, dst
);
1810 #ifdef TARGET_SPARC64
1811 static inline void gen_ne_fop_DDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1812 void (*gen
)(TCGv_i64
, TCGv_i64
, TCGv_i64
))
1814 TCGv_i64 dst
, src1
, src2
;
1816 src1
= gen_load_fpr_D(dc
, rs1
);
1817 src2
= gen_load_fpr_D(dc
, rs2
);
1818 dst
= gen_dest_fpr_D(dc
, rd
);
1820 gen(dst
, src1
, src2
);
1822 gen_store_fpr_D(dc
, rd
, dst
);
1825 static inline void gen_gsr_fop_DDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1826 void (*gen
)(TCGv_i64
, TCGv_i64
, TCGv_i64
, TCGv_i64
))
1828 TCGv_i64 dst
, src1
, src2
;
1830 src1
= gen_load_fpr_D(dc
, rs1
);
1831 src2
= gen_load_fpr_D(dc
, rs2
);
1832 dst
= gen_dest_fpr_D(dc
, rd
);
1834 gen(dst
, cpu_gsr
, src1
, src2
);
1836 gen_store_fpr_D(dc
, rd
, dst
);
1839 static inline void gen_ne_fop_DDDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1840 void (*gen
)(TCGv_i64
, TCGv_i64
, TCGv_i64
, TCGv_i64
))
1842 TCGv_i64 dst
, src0
, src1
, src2
;
1844 src1
= gen_load_fpr_D(dc
, rs1
);
1845 src2
= gen_load_fpr_D(dc
, rs2
);
1846 src0
= gen_load_fpr_D(dc
, rd
);
1847 dst
= gen_dest_fpr_D(dc
, rd
);
1849 gen(dst
, src0
, src1
, src2
);
1851 gen_store_fpr_D(dc
, rd
, dst
);
1855 static inline void gen_fop_QQ(DisasContext
*dc
, int rd
, int rs
,
1856 void (*gen
)(TCGv_ptr
))
1858 gen_op_load_fpr_QT1(QFPREG(rs
));
1862 gen_op_store_QT0_fpr(QFPREG(rd
));
1863 gen_update_fprs_dirty(QFPREG(rd
));
1866 #ifdef TARGET_SPARC64
1867 static inline void gen_ne_fop_QQ(DisasContext
*dc
, int rd
, int rs
,
1868 void (*gen
)(TCGv_ptr
))
1870 gen_op_load_fpr_QT1(QFPREG(rs
));
1874 gen_op_store_QT0_fpr(QFPREG(rd
));
1875 gen_update_fprs_dirty(QFPREG(rd
));
1879 static inline void gen_fop_QQQ(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1880 void (*gen
)(TCGv_ptr
))
1882 gen_op_load_fpr_QT0(QFPREG(rs1
));
1883 gen_op_load_fpr_QT1(QFPREG(rs2
));
1887 gen_op_store_QT0_fpr(QFPREG(rd
));
1888 gen_update_fprs_dirty(QFPREG(rd
));
1891 static inline void gen_fop_DFF(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1892 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i32
, TCGv_i32
))
1895 TCGv_i32 src1
, src2
;
1897 src1
= gen_load_fpr_F(dc
, rs1
);
1898 src2
= gen_load_fpr_F(dc
, rs2
);
1899 dst
= gen_dest_fpr_D(dc
, rd
);
1901 gen(dst
, cpu_env
, src1
, src2
);
1903 gen_store_fpr_D(dc
, rd
, dst
);
1906 static inline void gen_fop_QDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1907 void (*gen
)(TCGv_ptr
, TCGv_i64
, TCGv_i64
))
1909 TCGv_i64 src1
, src2
;
1911 src1
= gen_load_fpr_D(dc
, rs1
);
1912 src2
= gen_load_fpr_D(dc
, rs2
);
1914 gen(cpu_env
, src1
, src2
);
1916 gen_op_store_QT0_fpr(QFPREG(rd
));
1917 gen_update_fprs_dirty(QFPREG(rd
));
1920 #ifdef TARGET_SPARC64
1921 static inline void gen_fop_DF(DisasContext
*dc
, int rd
, int rs
,
1922 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i32
))
1927 src
= gen_load_fpr_F(dc
, rs
);
1928 dst
= gen_dest_fpr_D(dc
, rd
);
1930 gen(dst
, cpu_env
, src
);
1932 gen_store_fpr_D(dc
, rd
, dst
);
1936 static inline void gen_ne_fop_DF(DisasContext
*dc
, int rd
, int rs
,
1937 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i32
))
1942 src
= gen_load_fpr_F(dc
, rs
);
1943 dst
= gen_dest_fpr_D(dc
, rd
);
1945 gen(dst
, cpu_env
, src
);
1947 gen_store_fpr_D(dc
, rd
, dst
);
1950 static inline void gen_fop_FD(DisasContext
*dc
, int rd
, int rs
,
1951 void (*gen
)(TCGv_i32
, TCGv_ptr
, TCGv_i64
))
1956 src
= gen_load_fpr_D(dc
, rs
);
1957 dst
= gen_dest_fpr_F(dc
);
1959 gen(dst
, cpu_env
, src
);
1961 gen_store_fpr_F(dc
, rd
, dst
);
1964 static inline void gen_fop_FQ(DisasContext
*dc
, int rd
, int rs
,
1965 void (*gen
)(TCGv_i32
, TCGv_ptr
))
1969 gen_op_load_fpr_QT1(QFPREG(rs
));
1970 dst
= gen_dest_fpr_F(dc
);
1974 gen_store_fpr_F(dc
, rd
, dst
);
1977 static inline void gen_fop_DQ(DisasContext
*dc
, int rd
, int rs
,
1978 void (*gen
)(TCGv_i64
, TCGv_ptr
))
1982 gen_op_load_fpr_QT1(QFPREG(rs
));
1983 dst
= gen_dest_fpr_D(dc
, rd
);
1987 gen_store_fpr_D(dc
, rd
, dst
);
1990 static inline void gen_ne_fop_QF(DisasContext
*dc
, int rd
, int rs
,
1991 void (*gen
)(TCGv_ptr
, TCGv_i32
))
1995 src
= gen_load_fpr_F(dc
, rs
);
1999 gen_op_store_QT0_fpr(QFPREG(rd
));
2000 gen_update_fprs_dirty(QFPREG(rd
));
2003 static inline void gen_ne_fop_QD(DisasContext
*dc
, int rd
, int rs
,
2004 void (*gen
)(TCGv_ptr
, TCGv_i64
))
2008 src
= gen_load_fpr_D(dc
, rs
);
2012 gen_op_store_QT0_fpr(QFPREG(rd
));
2013 gen_update_fprs_dirty(QFPREG(rd
));
2017 #ifdef TARGET_SPARC64
2018 static inline TCGv_i32
gen_get_asi(int insn
, TCGv r_addr
)
2024 r_asi
= tcg_temp_new_i32();
2025 tcg_gen_mov_i32(r_asi
, cpu_asi
);
2027 asi
= GET_FIELD(insn
, 19, 26);
2028 r_asi
= tcg_const_i32(asi
);
2033 static inline void gen_ld_asi(TCGv dst
, TCGv addr
, int insn
, int size
,
2036 TCGv_i32 r_asi
, r_size
, r_sign
;
2038 r_asi
= gen_get_asi(insn
, addr
);
2039 r_size
= tcg_const_i32(size
);
2040 r_sign
= tcg_const_i32(sign
);
2041 gen_helper_ld_asi(dst
, cpu_env
, addr
, r_asi
, r_size
, r_sign
);
2042 tcg_temp_free_i32(r_sign
);
2043 tcg_temp_free_i32(r_size
);
2044 tcg_temp_free_i32(r_asi
);
2047 static inline void gen_st_asi(TCGv src
, TCGv addr
, int insn
, int size
)
2049 TCGv_i32 r_asi
, r_size
;
2051 r_asi
= gen_get_asi(insn
, addr
);
2052 r_size
= tcg_const_i32(size
);
2053 gen_helper_st_asi(cpu_env
, addr
, src
, r_asi
, r_size
);
2054 tcg_temp_free_i32(r_size
);
2055 tcg_temp_free_i32(r_asi
);
2058 static inline void gen_ldf_asi(TCGv addr
, int insn
, int size
, int rd
)
2060 TCGv_i32 r_asi
, r_size
, r_rd
;
2062 r_asi
= gen_get_asi(insn
, addr
);
2063 r_size
= tcg_const_i32(size
);
2064 r_rd
= tcg_const_i32(rd
);
2065 gen_helper_ldf_asi(cpu_env
, addr
, r_asi
, r_size
, r_rd
);
2066 tcg_temp_free_i32(r_rd
);
2067 tcg_temp_free_i32(r_size
);
2068 tcg_temp_free_i32(r_asi
);
2071 static inline void gen_stf_asi(TCGv addr
, int insn
, int size
, int rd
)
2073 TCGv_i32 r_asi
, r_size
, r_rd
;
2075 r_asi
= gen_get_asi(insn
, addr
);
2076 r_size
= tcg_const_i32(size
);
2077 r_rd
= tcg_const_i32(rd
);
2078 gen_helper_stf_asi(cpu_env
, addr
, r_asi
, r_size
, r_rd
);
2079 tcg_temp_free_i32(r_rd
);
2080 tcg_temp_free_i32(r_size
);
2081 tcg_temp_free_i32(r_asi
);
2084 static inline void gen_swap_asi(TCGv dst
, TCGv src
, TCGv addr
, int insn
)
2086 TCGv_i32 r_asi
, r_size
, r_sign
;
2087 TCGv_i64 t64
= tcg_temp_new_i64();
2089 r_asi
= gen_get_asi(insn
, addr
);
2090 r_size
= tcg_const_i32(4);
2091 r_sign
= tcg_const_i32(0);
2092 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_size
, r_sign
);
2093 tcg_temp_free_i32(r_sign
);
2094 gen_helper_st_asi(cpu_env
, addr
, src
, r_asi
, r_size
);
2095 tcg_temp_free_i32(r_size
);
2096 tcg_temp_free_i32(r_asi
);
2097 tcg_gen_trunc_i64_tl(dst
, t64
);
2098 tcg_temp_free_i64(t64
);
2101 static inline void gen_ldda_asi(DisasContext
*dc
, TCGv hi
, TCGv addr
,
2104 TCGv_i32 r_asi
, r_rd
;
2106 r_asi
= gen_get_asi(insn
, addr
);
2107 r_rd
= tcg_const_i32(rd
);
2108 gen_helper_ldda_asi(cpu_env
, addr
, r_asi
, r_rd
);
2109 tcg_temp_free_i32(r_rd
);
2110 tcg_temp_free_i32(r_asi
);
2113 static inline void gen_stda_asi(DisasContext
*dc
, TCGv hi
, TCGv addr
,
2116 TCGv_i32 r_asi
, r_size
;
2117 TCGv lo
= gen_load_gpr(dc
, rd
+ 1);
2118 TCGv_i64 t64
= tcg_temp_new_i64();
2120 tcg_gen_concat_tl_i64(t64
, lo
, hi
);
2121 r_asi
= gen_get_asi(insn
, addr
);
2122 r_size
= tcg_const_i32(8);
2123 gen_helper_st_asi(cpu_env
, addr
, t64
, r_asi
, r_size
);
2124 tcg_temp_free_i32(r_size
);
2125 tcg_temp_free_i32(r_asi
);
2126 tcg_temp_free_i64(t64
);
2129 static inline void gen_cas_asi(DisasContext
*dc
, TCGv addr
,
2130 TCGv val2
, int insn
, int rd
)
2132 TCGv val1
= gen_load_gpr(dc
, rd
);
2133 TCGv dst
= gen_dest_gpr(dc
, rd
);
2134 TCGv_i32 r_asi
= gen_get_asi(insn
, addr
);
2136 gen_helper_cas_asi(dst
, cpu_env
, addr
, val1
, val2
, r_asi
);
2137 tcg_temp_free_i32(r_asi
);
2138 gen_store_gpr(dc
, rd
, dst
);
2141 static inline void gen_casx_asi(DisasContext
*dc
, TCGv addr
,
2142 TCGv val2
, int insn
, int rd
)
2144 TCGv val1
= gen_load_gpr(dc
, rd
);
2145 TCGv dst
= gen_dest_gpr(dc
, rd
);
2146 TCGv_i32 r_asi
= gen_get_asi(insn
, addr
);
2148 gen_helper_casx_asi(dst
, cpu_env
, addr
, val1
, val2
, r_asi
);
2149 tcg_temp_free_i32(r_asi
);
2150 gen_store_gpr(dc
, rd
, dst
);
2153 #elif !defined(CONFIG_USER_ONLY)
2155 static inline void gen_ld_asi(TCGv dst
, TCGv addr
, int insn
, int size
,
2158 TCGv_i32 r_asi
, r_size
, r_sign
;
2159 TCGv_i64 t64
= tcg_temp_new_i64();
2161 r_asi
= tcg_const_i32(GET_FIELD(insn
, 19, 26));
2162 r_size
= tcg_const_i32(size
);
2163 r_sign
= tcg_const_i32(sign
);
2164 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_size
, r_sign
);
2165 tcg_temp_free_i32(r_sign
);
2166 tcg_temp_free_i32(r_size
);
2167 tcg_temp_free_i32(r_asi
);
2168 tcg_gen_trunc_i64_tl(dst
, t64
);
2169 tcg_temp_free_i64(t64
);
2172 static inline void gen_st_asi(TCGv src
, TCGv addr
, int insn
, int size
)
2174 TCGv_i32 r_asi
, r_size
;
2175 TCGv_i64 t64
= tcg_temp_new_i64();
2177 tcg_gen_extu_tl_i64(t64
, src
);
2178 r_asi
= tcg_const_i32(GET_FIELD(insn
, 19, 26));
2179 r_size
= tcg_const_i32(size
);
2180 gen_helper_st_asi(cpu_env
, addr
, t64
, r_asi
, r_size
);
2181 tcg_temp_free_i32(r_size
);
2182 tcg_temp_free_i32(r_asi
);
2183 tcg_temp_free_i64(t64
);
2186 static inline void gen_swap_asi(TCGv dst
, TCGv src
, TCGv addr
, int insn
)
2188 TCGv_i32 r_asi
, r_size
, r_sign
;
2189 TCGv_i64 r_val
, t64
;
2191 r_asi
= tcg_const_i32(GET_FIELD(insn
, 19, 26));
2192 r_size
= tcg_const_i32(4);
2193 r_sign
= tcg_const_i32(0);
2194 t64
= tcg_temp_new_i64();
2195 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_size
, r_sign
);
2196 tcg_temp_free(r_sign
);
2197 r_val
= tcg_temp_new_i64();
2198 tcg_gen_extu_tl_i64(r_val
, src
);
2199 gen_helper_st_asi(cpu_env
, addr
, r_val
, r_asi
, r_size
);
2200 tcg_temp_free_i64(r_val
);
2201 tcg_temp_free_i32(r_size
);
2202 tcg_temp_free_i32(r_asi
);
2203 tcg_gen_trunc_i64_tl(dst
, t64
);
2204 tcg_temp_free_i64(t64
);
2207 static inline void gen_ldda_asi(DisasContext
*dc
, TCGv hi
, TCGv addr
,
2210 TCGv_i32 r_asi
, r_size
, r_sign
;
2214 r_asi
= tcg_const_i32(GET_FIELD(insn
, 19, 26));
2215 r_size
= tcg_const_i32(8);
2216 r_sign
= tcg_const_i32(0);
2217 t64
= tcg_temp_new_i64();
2218 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_size
, r_sign
);
2219 tcg_temp_free_i32(r_sign
);
2220 tcg_temp_free_i32(r_size
);
2221 tcg_temp_free_i32(r_asi
);
2223 t
= gen_dest_gpr(dc
, rd
+ 1);
2224 tcg_gen_trunc_i64_tl(t
, t64
);
2225 gen_store_gpr(dc
, rd
+ 1, t
);
2227 tcg_gen_shri_i64(t64
, t64
, 32);
2228 tcg_gen_trunc_i64_tl(hi
, t64
);
2229 tcg_temp_free_i64(t64
);
2230 gen_store_gpr(dc
, rd
, hi
);
2233 static inline void gen_stda_asi(DisasContext
*dc
, TCGv hi
, TCGv addr
,
2236 TCGv_i32 r_asi
, r_size
;
2237 TCGv lo
= gen_load_gpr(dc
, rd
+ 1);
2238 TCGv_i64 t64
= tcg_temp_new_i64();
2240 tcg_gen_concat_tl_i64(t64
, lo
, hi
);
2241 r_asi
= tcg_const_i32(GET_FIELD(insn
, 19, 26));
2242 r_size
= tcg_const_i32(8);
2243 gen_helper_st_asi(cpu_env
, addr
, t64
, r_asi
, r_size
);
2244 tcg_temp_free_i32(r_size
);
2245 tcg_temp_free_i32(r_asi
);
2246 tcg_temp_free_i64(t64
);
2250 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
2251 static inline void gen_ldstub_asi(TCGv dst
, TCGv addr
, int insn
)
2254 TCGv_i32 r_asi
, r_size
;
2256 gen_ld_asi(dst
, addr
, insn
, 1, 0);
2258 r_val
= tcg_const_i64(0xffULL
);
2259 r_asi
= tcg_const_i32(GET_FIELD(insn
, 19, 26));
2260 r_size
= tcg_const_i32(1);
2261 gen_helper_st_asi(cpu_env
, addr
, r_val
, r_asi
, r_size
);
2262 tcg_temp_free_i32(r_size
);
2263 tcg_temp_free_i32(r_asi
);
2264 tcg_temp_free_i64(r_val
);
2268 static TCGv
get_src1(DisasContext
*dc
, unsigned int insn
)
2270 unsigned int rs1
= GET_FIELD(insn
, 13, 17);
2271 return gen_load_gpr(dc
, rs1
);
2274 static TCGv
get_src2(DisasContext
*dc
, unsigned int insn
)
2276 if (IS_IMM
) { /* immediate */
2277 target_long simm
= GET_FIELDs(insn
, 19, 31);
2278 TCGv t
= get_temp_tl(dc
);
2279 tcg_gen_movi_tl(t
, simm
);
2281 } else { /* register */
2282 unsigned int rs2
= GET_FIELD(insn
, 27, 31);
2283 return gen_load_gpr(dc
, rs2
);
2287 #ifdef TARGET_SPARC64
2288 static void gen_fmovs(DisasContext
*dc
, DisasCompare
*cmp
, int rd
, int rs
)
2290 TCGv_i32 c32
, zero
, dst
, s1
, s2
;
2292 /* We have two choices here: extend the 32 bit data and use movcond_i64,
2293 or fold the comparison down to 32 bits and use movcond_i32. Choose
2295 c32
= tcg_temp_new_i32();
2297 tcg_gen_trunc_i64_i32(c32
, cmp
->c1
);
2299 TCGv_i64 c64
= tcg_temp_new_i64();
2300 tcg_gen_setcond_i64(cmp
->cond
, c64
, cmp
->c1
, cmp
->c2
);
2301 tcg_gen_trunc_i64_i32(c32
, c64
);
2302 tcg_temp_free_i64(c64
);
2305 s1
= gen_load_fpr_F(dc
, rs
);
2306 s2
= gen_load_fpr_F(dc
, rd
);
2307 dst
= gen_dest_fpr_F(dc
);
2308 zero
= tcg_const_i32(0);
2310 tcg_gen_movcond_i32(TCG_COND_NE
, dst
, c32
, zero
, s1
, s2
);
2312 tcg_temp_free_i32(c32
);
2313 tcg_temp_free_i32(zero
);
2314 gen_store_fpr_F(dc
, rd
, dst
);
2317 static void gen_fmovd(DisasContext
*dc
, DisasCompare
*cmp
, int rd
, int rs
)
2319 TCGv_i64 dst
= gen_dest_fpr_D(dc
, rd
);
2320 tcg_gen_movcond_i64(cmp
->cond
, dst
, cmp
->c1
, cmp
->c2
,
2321 gen_load_fpr_D(dc
, rs
),
2322 gen_load_fpr_D(dc
, rd
));
2323 gen_store_fpr_D(dc
, rd
, dst
);
2326 static void gen_fmovq(DisasContext
*dc
, DisasCompare
*cmp
, int rd
, int rs
)
2328 int qd
= QFPREG(rd
);
2329 int qs
= QFPREG(rs
);
2331 tcg_gen_movcond_i64(cmp
->cond
, cpu_fpr
[qd
/ 2], cmp
->c1
, cmp
->c2
,
2332 cpu_fpr
[qs
/ 2], cpu_fpr
[qd
/ 2]);
2333 tcg_gen_movcond_i64(cmp
->cond
, cpu_fpr
[qd
/ 2 + 1], cmp
->c1
, cmp
->c2
,
2334 cpu_fpr
[qs
/ 2 + 1], cpu_fpr
[qd
/ 2 + 1]);
2336 gen_update_fprs_dirty(qd
);
2339 static inline void gen_load_trap_state_at_tl(TCGv_ptr r_tsptr
, TCGv_ptr cpu_env
)
2341 TCGv_i32 r_tl
= tcg_temp_new_i32();
2343 /* load env->tl into r_tl */
2344 tcg_gen_ld_i32(r_tl
, cpu_env
, offsetof(CPUSPARCState
, tl
));
2346 /* tl = [0 ... MAXTL_MASK] where MAXTL_MASK must be power of 2 */
2347 tcg_gen_andi_i32(r_tl
, r_tl
, MAXTL_MASK
);
2349 /* calculate offset to current trap state from env->ts, reuse r_tl */
2350 tcg_gen_muli_i32(r_tl
, r_tl
, sizeof (trap_state
));
2351 tcg_gen_addi_ptr(r_tsptr
, cpu_env
, offsetof(CPUSPARCState
, ts
));
2353 /* tsptr = env->ts[env->tl & MAXTL_MASK] */
2355 TCGv_ptr r_tl_tmp
= tcg_temp_new_ptr();
2356 tcg_gen_ext_i32_ptr(r_tl_tmp
, r_tl
);
2357 tcg_gen_add_ptr(r_tsptr
, r_tsptr
, r_tl_tmp
);
2358 tcg_temp_free_ptr(r_tl_tmp
);
2361 tcg_temp_free_i32(r_tl
);
2364 static void gen_edge(DisasContext
*dc
, TCGv dst
, TCGv s1
, TCGv s2
,
2365 int width
, bool cc
, bool left
)
2367 TCGv lo1
, lo2
, t1
, t2
;
2368 uint64_t amask
, tabl
, tabr
;
2369 int shift
, imask
, omask
;
2372 tcg_gen_mov_tl(cpu_cc_src
, s1
);
2373 tcg_gen_mov_tl(cpu_cc_src2
, s2
);
2374 tcg_gen_sub_tl(cpu_cc_dst
, s1
, s2
);
2375 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUB
);
2376 dc
->cc_op
= CC_OP_SUB
;
2379 /* Theory of operation: there are two tables, left and right (not to
2380 be confused with the left and right versions of the opcode). These
2381 are indexed by the low 3 bits of the inputs. To make things "easy",
2382 these tables are loaded into two constants, TABL and TABR below.
2383 The operation index = (input & imask) << shift calculates the index
2384 into the constant, while val = (table >> index) & omask calculates
2385 the value we're looking for. */
2392 tabl
= 0x80c0e0f0f8fcfeffULL
;
2393 tabr
= 0xff7f3f1f0f070301ULL
;
2395 tabl
= 0x0103070f1f3f7fffULL
;
2396 tabr
= 0xfffefcf8f0e0c080ULL
;
2416 tabl
= (2 << 2) | 3;
2417 tabr
= (3 << 2) | 1;
2419 tabl
= (1 << 2) | 3;
2420 tabr
= (3 << 2) | 2;
2427 lo1
= tcg_temp_new();
2428 lo2
= tcg_temp_new();
2429 tcg_gen_andi_tl(lo1
, s1
, imask
);
2430 tcg_gen_andi_tl(lo2
, s2
, imask
);
2431 tcg_gen_shli_tl(lo1
, lo1
, shift
);
2432 tcg_gen_shli_tl(lo2
, lo2
, shift
);
2434 t1
= tcg_const_tl(tabl
);
2435 t2
= tcg_const_tl(tabr
);
2436 tcg_gen_shr_tl(lo1
, t1
, lo1
);
2437 tcg_gen_shr_tl(lo2
, t2
, lo2
);
2438 tcg_gen_andi_tl(dst
, lo1
, omask
);
2439 tcg_gen_andi_tl(lo2
, lo2
, omask
);
2443 amask
&= 0xffffffffULL
;
2445 tcg_gen_andi_tl(s1
, s1
, amask
);
2446 tcg_gen_andi_tl(s2
, s2
, amask
);
2448 /* We want to compute
2449 dst = (s1 == s2 ? lo1 : lo1 & lo2).
2450 We've already done dst = lo1, so this reduces to
2451 dst &= (s1 == s2 ? -1 : lo2)
2456 tcg_gen_setcond_tl(TCG_COND_EQ
, t1
, s1
, s2
);
2457 tcg_gen_neg_tl(t1
, t1
);
2458 tcg_gen_or_tl(lo2
, lo2
, t1
);
2459 tcg_gen_and_tl(dst
, dst
, lo2
);
2467 static void gen_alignaddr(TCGv dst
, TCGv s1
, TCGv s2
, bool left
)
2469 TCGv tmp
= tcg_temp_new();
2471 tcg_gen_add_tl(tmp
, s1
, s2
);
2472 tcg_gen_andi_tl(dst
, tmp
, -8);
2474 tcg_gen_neg_tl(tmp
, tmp
);
2476 tcg_gen_deposit_tl(cpu_gsr
, cpu_gsr
, tmp
, 0, 3);
2481 static void gen_faligndata(TCGv dst
, TCGv gsr
, TCGv s1
, TCGv s2
)
2485 t1
= tcg_temp_new();
2486 t2
= tcg_temp_new();
2487 shift
= tcg_temp_new();
2489 tcg_gen_andi_tl(shift
, gsr
, 7);
2490 tcg_gen_shli_tl(shift
, shift
, 3);
2491 tcg_gen_shl_tl(t1
, s1
, shift
);
2493 /* A shift of 64 does not produce 0 in TCG. Divide this into a
2494 shift of (up to 63) followed by a constant shift of 1. */
2495 tcg_gen_xori_tl(shift
, shift
, 63);
2496 tcg_gen_shr_tl(t2
, s2
, shift
);
2497 tcg_gen_shri_tl(t2
, t2
, 1);
2499 tcg_gen_or_tl(dst
, t1
, t2
);
2503 tcg_temp_free(shift
);
2507 #define CHECK_IU_FEATURE(dc, FEATURE) \
2508 if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
2510 #define CHECK_FPU_FEATURE(dc, FEATURE) \
2511 if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
2514 /* before an instruction, dc->pc must be static */
2515 static void disas_sparc_insn(DisasContext
* dc
, unsigned int insn
)
2517 unsigned int opc
, rs1
, rs2
, rd
;
2518 TCGv cpu_src1
, cpu_src2
;
2519 TCGv_i32 cpu_src1_32
, cpu_src2_32
, cpu_dst_32
;
2520 TCGv_i64 cpu_src1_64
, cpu_src2_64
, cpu_dst_64
;
2523 if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP
| CPU_LOG_TB_OP_OPT
))) {
2524 tcg_gen_debug_insn_start(dc
->pc
);
2527 opc
= GET_FIELD(insn
, 0, 1);
2528 rd
= GET_FIELD(insn
, 2, 6);
2531 case 0: /* branches/sethi */
2533 unsigned int xop
= GET_FIELD(insn
, 7, 9);
2536 #ifdef TARGET_SPARC64
2537 case 0x1: /* V9 BPcc */
2541 target
= GET_FIELD_SP(insn
, 0, 18);
2542 target
= sign_extend(target
, 19);
2544 cc
= GET_FIELD_SP(insn
, 20, 21);
2546 do_branch(dc
, target
, insn
, 0);
2548 do_branch(dc
, target
, insn
, 1);
2553 case 0x3: /* V9 BPr */
2555 target
= GET_FIELD_SP(insn
, 0, 13) |
2556 (GET_FIELD_SP(insn
, 20, 21) << 14);
2557 target
= sign_extend(target
, 16);
2559 cpu_src1
= get_src1(dc
, insn
);
2560 do_branch_reg(dc
, target
, insn
, cpu_src1
);
2563 case 0x5: /* V9 FBPcc */
2565 int cc
= GET_FIELD_SP(insn
, 20, 21);
2566 if (gen_trap_ifnofpu(dc
)) {
2569 target
= GET_FIELD_SP(insn
, 0, 18);
2570 target
= sign_extend(target
, 19);
2572 do_fbranch(dc
, target
, insn
, cc
);
2576 case 0x7: /* CBN+x */
2581 case 0x2: /* BN+x */
2583 target
= GET_FIELD(insn
, 10, 31);
2584 target
= sign_extend(target
, 22);
2586 do_branch(dc
, target
, insn
, 0);
2589 case 0x6: /* FBN+x */
2591 if (gen_trap_ifnofpu(dc
)) {
2594 target
= GET_FIELD(insn
, 10, 31);
2595 target
= sign_extend(target
, 22);
2597 do_fbranch(dc
, target
, insn
, 0);
2600 case 0x4: /* SETHI */
2601 /* Special-case %g0 because that's the canonical nop. */
2603 uint32_t value
= GET_FIELD(insn
, 10, 31);
2604 TCGv t
= gen_dest_gpr(dc
, rd
);
2605 tcg_gen_movi_tl(t
, value
<< 10);
2606 gen_store_gpr(dc
, rd
, t
);
2609 case 0x0: /* UNIMPL */
2618 target_long target
= GET_FIELDs(insn
, 2, 31) << 2;
2619 TCGv o7
= gen_dest_gpr(dc
, 15);
2621 tcg_gen_movi_tl(o7
, dc
->pc
);
2622 gen_store_gpr(dc
, 15, o7
);
2625 #ifdef TARGET_SPARC64
2626 if (unlikely(AM_CHECK(dc
))) {
2627 target
&= 0xffffffffULL
;
2633 case 2: /* FPU & Logical Operations */
2635 unsigned int xop
= GET_FIELD(insn
, 7, 12);
2636 TCGv cpu_dst
= get_temp_tl(dc
);
2639 if (xop
== 0x3a) { /* generate trap */
2640 int cond
= GET_FIELD(insn
, 3, 6);
2652 /* Conditional trap. */
2654 #ifdef TARGET_SPARC64
2656 int cc
= GET_FIELD_SP(insn
, 11, 12);
2658 gen_compare(&cmp
, 0, cond
, dc
);
2659 } else if (cc
== 2) {
2660 gen_compare(&cmp
, 1, cond
, dc
);
2665 gen_compare(&cmp
, 0, cond
, dc
);
2667 l1
= gen_new_label();
2668 tcg_gen_brcond_tl(tcg_invert_cond(cmp
.cond
),
2669 cmp
.c1
, cmp
.c2
, l1
);
2673 mask
= ((dc
->def
->features
& CPU_FEATURE_HYPV
) && supervisor(dc
)
2674 ? UA2005_HTRAP_MASK
: V8_TRAP_MASK
);
2676 /* Don't use the normal temporaries, as they may well have
2677 gone out of scope with the branch above. While we're
2678 doing that we might as well pre-truncate to 32-bit. */
2679 trap
= tcg_temp_new_i32();
2681 rs1
= GET_FIELD_SP(insn
, 14, 18);
2683 rs2
= GET_FIELD_SP(insn
, 0, 6);
2685 tcg_gen_movi_i32(trap
, (rs2
& mask
) + TT_TRAP
);
2686 /* Signal that the trap value is fully constant. */
2689 TCGv t1
= gen_load_gpr(dc
, rs1
);
2690 tcg_gen_trunc_tl_i32(trap
, t1
);
2691 tcg_gen_addi_i32(trap
, trap
, rs2
);
2695 rs2
= GET_FIELD_SP(insn
, 0, 4);
2696 t1
= gen_load_gpr(dc
, rs1
);
2697 t2
= gen_load_gpr(dc
, rs2
);
2698 tcg_gen_add_tl(t1
, t1
, t2
);
2699 tcg_gen_trunc_tl_i32(trap
, t1
);
2702 tcg_gen_andi_i32(trap
, trap
, mask
);
2703 tcg_gen_addi_i32(trap
, trap
, TT_TRAP
);
2706 gen_helper_raise_exception(cpu_env
, trap
);
2707 tcg_temp_free_i32(trap
);
2710 /* An unconditional trap ends the TB. */
2714 /* A conditional trap falls through to the next insn. */
2718 } else if (xop
== 0x28) {
2719 rs1
= GET_FIELD(insn
, 13, 17);
2722 #ifndef TARGET_SPARC64
2723 case 0x01 ... 0x0e: /* undefined in the SPARCv8
2724 manual, rdy on the microSPARC
2726 case 0x0f: /* stbar in the SPARCv8 manual,
2727 rdy on the microSPARC II */
2728 case 0x10 ... 0x1f: /* implementation-dependent in the
2729 SPARCv8 manual, rdy on the
2732 if (rs1
== 0x11 && dc
->def
->features
& CPU_FEATURE_ASR17
) {
2733 TCGv t
= gen_dest_gpr(dc
, rd
);
2734 /* Read Asr17 for a Leon3 monoprocessor */
2735 tcg_gen_movi_tl(t
, (1 << 8) | (dc
->def
->nwindows
- 1));
2736 gen_store_gpr(dc
, rd
, t
);
2740 gen_store_gpr(dc
, rd
, cpu_y
);
2742 #ifdef TARGET_SPARC64
2743 case 0x2: /* V9 rdccr */
2745 gen_helper_rdccr(cpu_dst
, cpu_env
);
2746 gen_store_gpr(dc
, rd
, cpu_dst
);
2748 case 0x3: /* V9 rdasi */
2749 tcg_gen_ext_i32_tl(cpu_dst
, cpu_asi
);
2750 gen_store_gpr(dc
, rd
, cpu_dst
);
2752 case 0x4: /* V9 rdtick */
2756 r_tickptr
= tcg_temp_new_ptr();
2757 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
2758 offsetof(CPUSPARCState
, tick
));
2759 gen_helper_tick_get_count(cpu_dst
, r_tickptr
);
2760 tcg_temp_free_ptr(r_tickptr
);
2761 gen_store_gpr(dc
, rd
, cpu_dst
);
2764 case 0x5: /* V9 rdpc */
2766 TCGv t
= gen_dest_gpr(dc
, rd
);
2767 if (unlikely(AM_CHECK(dc
))) {
2768 tcg_gen_movi_tl(t
, dc
->pc
& 0xffffffffULL
);
2770 tcg_gen_movi_tl(t
, dc
->pc
);
2772 gen_store_gpr(dc
, rd
, t
);
2775 case 0x6: /* V9 rdfprs */
2776 tcg_gen_ext_i32_tl(cpu_dst
, cpu_fprs
);
2777 gen_store_gpr(dc
, rd
, cpu_dst
);
2779 case 0xf: /* V9 membar */
2780 break; /* no effect */
2781 case 0x13: /* Graphics Status */
2782 if (gen_trap_ifnofpu(dc
)) {
2785 gen_store_gpr(dc
, rd
, cpu_gsr
);
2787 case 0x16: /* Softint */
2788 tcg_gen_ext_i32_tl(cpu_dst
, cpu_softint
);
2789 gen_store_gpr(dc
, rd
, cpu_dst
);
2791 case 0x17: /* Tick compare */
2792 gen_store_gpr(dc
, rd
, cpu_tick_cmpr
);
2794 case 0x18: /* System tick */
2798 r_tickptr
= tcg_temp_new_ptr();
2799 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
2800 offsetof(CPUSPARCState
, stick
));
2801 gen_helper_tick_get_count(cpu_dst
, r_tickptr
);
2802 tcg_temp_free_ptr(r_tickptr
);
2803 gen_store_gpr(dc
, rd
, cpu_dst
);
2806 case 0x19: /* System tick compare */
2807 gen_store_gpr(dc
, rd
, cpu_stick_cmpr
);
2809 case 0x10: /* Performance Control */
2810 case 0x11: /* Performance Instrumentation Counter */
2811 case 0x12: /* Dispatch Control */
2812 case 0x14: /* Softint set, WO */
2813 case 0x15: /* Softint clear, WO */
2818 #if !defined(CONFIG_USER_ONLY)
2819 } else if (xop
== 0x29) { /* rdpsr / UA2005 rdhpr */
2820 #ifndef TARGET_SPARC64
2821 if (!supervisor(dc
)) {
2825 gen_helper_rdpsr(cpu_dst
, cpu_env
);
2827 CHECK_IU_FEATURE(dc
, HYPV
);
2828 if (!hypervisor(dc
))
2830 rs1
= GET_FIELD(insn
, 13, 17);
2833 // gen_op_rdhpstate();
2836 // gen_op_rdhtstate();
2839 tcg_gen_mov_tl(cpu_dst
, cpu_hintp
);
2842 tcg_gen_mov_tl(cpu_dst
, cpu_htba
);
2845 tcg_gen_mov_tl(cpu_dst
, cpu_hver
);
2847 case 31: // hstick_cmpr
2848 tcg_gen_mov_tl(cpu_dst
, cpu_hstick_cmpr
);
2854 gen_store_gpr(dc
, rd
, cpu_dst
);
2856 } else if (xop
== 0x2a) { /* rdwim / V9 rdpr */
2857 if (!supervisor(dc
)) {
2860 cpu_tmp0
= get_temp_tl(dc
);
2861 #ifdef TARGET_SPARC64
2862 rs1
= GET_FIELD(insn
, 13, 17);
2868 r_tsptr
= tcg_temp_new_ptr();
2869 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
2870 tcg_gen_ld_tl(cpu_tmp0
, r_tsptr
,
2871 offsetof(trap_state
, tpc
));
2872 tcg_temp_free_ptr(r_tsptr
);
2879 r_tsptr
= tcg_temp_new_ptr();
2880 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
2881 tcg_gen_ld_tl(cpu_tmp0
, r_tsptr
,
2882 offsetof(trap_state
, tnpc
));
2883 tcg_temp_free_ptr(r_tsptr
);
2890 r_tsptr
= tcg_temp_new_ptr();
2891 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
2892 tcg_gen_ld_tl(cpu_tmp0
, r_tsptr
,
2893 offsetof(trap_state
, tstate
));
2894 tcg_temp_free_ptr(r_tsptr
);
2899 TCGv_ptr r_tsptr
= tcg_temp_new_ptr();
2901 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
2902 tcg_gen_ld32s_tl(cpu_tmp0
, r_tsptr
,
2903 offsetof(trap_state
, tt
));
2904 tcg_temp_free_ptr(r_tsptr
);
2911 r_tickptr
= tcg_temp_new_ptr();
2912 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
2913 offsetof(CPUSPARCState
, tick
));
2914 gen_helper_tick_get_count(cpu_tmp0
, r_tickptr
);
2915 tcg_temp_free_ptr(r_tickptr
);
2919 tcg_gen_mov_tl(cpu_tmp0
, cpu_tbr
);
2922 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2923 offsetof(CPUSPARCState
, pstate
));
2926 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2927 offsetof(CPUSPARCState
, tl
));
2930 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2931 offsetof(CPUSPARCState
, psrpil
));
2934 gen_helper_rdcwp(cpu_tmp0
, cpu_env
);
2937 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2938 offsetof(CPUSPARCState
, cansave
));
2940 case 11: // canrestore
2941 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2942 offsetof(CPUSPARCState
, canrestore
));
2944 case 12: // cleanwin
2945 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2946 offsetof(CPUSPARCState
, cleanwin
));
2948 case 13: // otherwin
2949 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2950 offsetof(CPUSPARCState
, otherwin
));
2953 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2954 offsetof(CPUSPARCState
, wstate
));
2956 case 16: // UA2005 gl
2957 CHECK_IU_FEATURE(dc
, GL
);
2958 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
2959 offsetof(CPUSPARCState
, gl
));
2961 case 26: // UA2005 strand status
2962 CHECK_IU_FEATURE(dc
, HYPV
);
2963 if (!hypervisor(dc
))
2965 tcg_gen_mov_tl(cpu_tmp0
, cpu_ssr
);
2968 tcg_gen_mov_tl(cpu_tmp0
, cpu_ver
);
2975 tcg_gen_ext_i32_tl(cpu_tmp0
, cpu_wim
);
2977 gen_store_gpr(dc
, rd
, cpu_tmp0
);
2979 } else if (xop
== 0x2b) { /* rdtbr / V9 flushw */
2980 #ifdef TARGET_SPARC64
2982 gen_helper_flushw(cpu_env
);
2984 if (!supervisor(dc
))
2986 gen_store_gpr(dc
, rd
, cpu_tbr
);
2990 } else if (xop
== 0x34) { /* FPU Operations */
2991 if (gen_trap_ifnofpu(dc
)) {
2994 gen_op_clear_ieee_excp_and_FTT();
2995 rs1
= GET_FIELD(insn
, 13, 17);
2996 rs2
= GET_FIELD(insn
, 27, 31);
2997 xop
= GET_FIELD(insn
, 18, 26);
3000 case 0x1: /* fmovs */
3001 cpu_src1_32
= gen_load_fpr_F(dc
, rs2
);
3002 gen_store_fpr_F(dc
, rd
, cpu_src1_32
);
3004 case 0x5: /* fnegs */
3005 gen_ne_fop_FF(dc
, rd
, rs2
, gen_helper_fnegs
);
3007 case 0x9: /* fabss */
3008 gen_ne_fop_FF(dc
, rd
, rs2
, gen_helper_fabss
);
3010 case 0x29: /* fsqrts */
3011 CHECK_FPU_FEATURE(dc
, FSQRT
);
3012 gen_fop_FF(dc
, rd
, rs2
, gen_helper_fsqrts
);
3014 case 0x2a: /* fsqrtd */
3015 CHECK_FPU_FEATURE(dc
, FSQRT
);
3016 gen_fop_DD(dc
, rd
, rs2
, gen_helper_fsqrtd
);
3018 case 0x2b: /* fsqrtq */
3019 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3020 gen_fop_QQ(dc
, rd
, rs2
, gen_helper_fsqrtq
);
3022 case 0x41: /* fadds */
3023 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fadds
);
3025 case 0x42: /* faddd */
3026 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_faddd
);
3028 case 0x43: /* faddq */
3029 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3030 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_faddq
);
3032 case 0x45: /* fsubs */
3033 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fsubs
);
3035 case 0x46: /* fsubd */
3036 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fsubd
);
3038 case 0x47: /* fsubq */
3039 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3040 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_fsubq
);
3042 case 0x49: /* fmuls */
3043 CHECK_FPU_FEATURE(dc
, FMUL
);
3044 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fmuls
);
3046 case 0x4a: /* fmuld */
3047 CHECK_FPU_FEATURE(dc
, FMUL
);
3048 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmuld
);
3050 case 0x4b: /* fmulq */
3051 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3052 CHECK_FPU_FEATURE(dc
, FMUL
);
3053 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_fmulq
);
3055 case 0x4d: /* fdivs */
3056 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fdivs
);
3058 case 0x4e: /* fdivd */
3059 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fdivd
);
3061 case 0x4f: /* fdivq */
3062 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3063 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_fdivq
);
3065 case 0x69: /* fsmuld */
3066 CHECK_FPU_FEATURE(dc
, FSMULD
);
3067 gen_fop_DFF(dc
, rd
, rs1
, rs2
, gen_helper_fsmuld
);
3069 case 0x6e: /* fdmulq */
3070 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3071 gen_fop_QDD(dc
, rd
, rs1
, rs2
, gen_helper_fdmulq
);
3073 case 0xc4: /* fitos */
3074 gen_fop_FF(dc
, rd
, rs2
, gen_helper_fitos
);
3076 case 0xc6: /* fdtos */
3077 gen_fop_FD(dc
, rd
, rs2
, gen_helper_fdtos
);
3079 case 0xc7: /* fqtos */
3080 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3081 gen_fop_FQ(dc
, rd
, rs2
, gen_helper_fqtos
);
3083 case 0xc8: /* fitod */
3084 gen_ne_fop_DF(dc
, rd
, rs2
, gen_helper_fitod
);
3086 case 0xc9: /* fstod */
3087 gen_ne_fop_DF(dc
, rd
, rs2
, gen_helper_fstod
);
3089 case 0xcb: /* fqtod */
3090 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3091 gen_fop_DQ(dc
, rd
, rs2
, gen_helper_fqtod
);
3093 case 0xcc: /* fitoq */
3094 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3095 gen_ne_fop_QF(dc
, rd
, rs2
, gen_helper_fitoq
);
3097 case 0xcd: /* fstoq */
3098 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3099 gen_ne_fop_QF(dc
, rd
, rs2
, gen_helper_fstoq
);
3101 case 0xce: /* fdtoq */
3102 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3103 gen_ne_fop_QD(dc
, rd
, rs2
, gen_helper_fdtoq
);
3105 case 0xd1: /* fstoi */
3106 gen_fop_FF(dc
, rd
, rs2
, gen_helper_fstoi
);
3108 case 0xd2: /* fdtoi */
3109 gen_fop_FD(dc
, rd
, rs2
, gen_helper_fdtoi
);
3111 case 0xd3: /* fqtoi */
3112 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3113 gen_fop_FQ(dc
, rd
, rs2
, gen_helper_fqtoi
);
3115 #ifdef TARGET_SPARC64
3116 case 0x2: /* V9 fmovd */
3117 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
3118 gen_store_fpr_D(dc
, rd
, cpu_src1_64
);
3120 case 0x3: /* V9 fmovq */
3121 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3122 gen_move_Q(rd
, rs2
);
3124 case 0x6: /* V9 fnegd */
3125 gen_ne_fop_DD(dc
, rd
, rs2
, gen_helper_fnegd
);
3127 case 0x7: /* V9 fnegq */
3128 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3129 gen_ne_fop_QQ(dc
, rd
, rs2
, gen_helper_fnegq
);
3131 case 0xa: /* V9 fabsd */
3132 gen_ne_fop_DD(dc
, rd
, rs2
, gen_helper_fabsd
);
3134 case 0xb: /* V9 fabsq */
3135 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3136 gen_ne_fop_QQ(dc
, rd
, rs2
, gen_helper_fabsq
);
3138 case 0x81: /* V9 fstox */
3139 gen_fop_DF(dc
, rd
, rs2
, gen_helper_fstox
);
3141 case 0x82: /* V9 fdtox */
3142 gen_fop_DD(dc
, rd
, rs2
, gen_helper_fdtox
);
3144 case 0x83: /* V9 fqtox */
3145 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3146 gen_fop_DQ(dc
, rd
, rs2
, gen_helper_fqtox
);
3148 case 0x84: /* V9 fxtos */
3149 gen_fop_FD(dc
, rd
, rs2
, gen_helper_fxtos
);
3151 case 0x88: /* V9 fxtod */
3152 gen_fop_DD(dc
, rd
, rs2
, gen_helper_fxtod
);
3154 case 0x8c: /* V9 fxtoq */
3155 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3156 gen_ne_fop_QD(dc
, rd
, rs2
, gen_helper_fxtoq
);
3162 } else if (xop
== 0x35) { /* FPU Operations */
3163 #ifdef TARGET_SPARC64
3166 if (gen_trap_ifnofpu(dc
)) {
3169 gen_op_clear_ieee_excp_and_FTT();
3170 rs1
= GET_FIELD(insn
, 13, 17);
3171 rs2
= GET_FIELD(insn
, 27, 31);
3172 xop
= GET_FIELD(insn
, 18, 26);
3175 #ifdef TARGET_SPARC64
3179 cond = GET_FIELD_SP(insn, 10, 12); \
3180 cpu_src1 = get_src1(dc, insn); \
3181 gen_compare_reg(&cmp, cond, cpu_src1); \
3182 gen_fmov##sz(dc, &cmp, rd, rs2); \
3183 free_compare(&cmp); \
3186 if ((xop
& 0x11f) == 0x005) { /* V9 fmovsr */
3189 } else if ((xop
& 0x11f) == 0x006) { // V9 fmovdr
3192 } else if ((xop
& 0x11f) == 0x007) { // V9 fmovqr
3193 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3200 #ifdef TARGET_SPARC64
3201 #define FMOVCC(fcc, sz) \
3204 cond = GET_FIELD_SP(insn, 14, 17); \
3205 gen_fcompare(&cmp, fcc, cond); \
3206 gen_fmov##sz(dc, &cmp, rd, rs2); \
3207 free_compare(&cmp); \
3210 case 0x001: /* V9 fmovscc %fcc0 */
3213 case 0x002: /* V9 fmovdcc %fcc0 */
3216 case 0x003: /* V9 fmovqcc %fcc0 */
3217 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3220 case 0x041: /* V9 fmovscc %fcc1 */
3223 case 0x042: /* V9 fmovdcc %fcc1 */
3226 case 0x043: /* V9 fmovqcc %fcc1 */
3227 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3230 case 0x081: /* V9 fmovscc %fcc2 */
3233 case 0x082: /* V9 fmovdcc %fcc2 */
3236 case 0x083: /* V9 fmovqcc %fcc2 */
3237 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3240 case 0x0c1: /* V9 fmovscc %fcc3 */
3243 case 0x0c2: /* V9 fmovdcc %fcc3 */
3246 case 0x0c3: /* V9 fmovqcc %fcc3 */
3247 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3251 #define FMOVCC(xcc, sz) \
3254 cond = GET_FIELD_SP(insn, 14, 17); \
3255 gen_compare(&cmp, xcc, cond, dc); \
3256 gen_fmov##sz(dc, &cmp, rd, rs2); \
3257 free_compare(&cmp); \
3260 case 0x101: /* V9 fmovscc %icc */
3263 case 0x102: /* V9 fmovdcc %icc */
3266 case 0x103: /* V9 fmovqcc %icc */
3267 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3270 case 0x181: /* V9 fmovscc %xcc */
3273 case 0x182: /* V9 fmovdcc %xcc */
3276 case 0x183: /* V9 fmovqcc %xcc */
3277 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3282 case 0x51: /* fcmps, V9 %fcc */
3283 cpu_src1_32
= gen_load_fpr_F(dc
, rs1
);
3284 cpu_src2_32
= gen_load_fpr_F(dc
, rs2
);
3285 gen_op_fcmps(rd
& 3, cpu_src1_32
, cpu_src2_32
);
3287 case 0x52: /* fcmpd, V9 %fcc */
3288 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
3289 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
3290 gen_op_fcmpd(rd
& 3, cpu_src1_64
, cpu_src2_64
);
3292 case 0x53: /* fcmpq, V9 %fcc */
3293 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3294 gen_op_load_fpr_QT0(QFPREG(rs1
));
3295 gen_op_load_fpr_QT1(QFPREG(rs2
));
3296 gen_op_fcmpq(rd
& 3);
3298 case 0x55: /* fcmpes, V9 %fcc */
3299 cpu_src1_32
= gen_load_fpr_F(dc
, rs1
);
3300 cpu_src2_32
= gen_load_fpr_F(dc
, rs2
);
3301 gen_op_fcmpes(rd
& 3, cpu_src1_32
, cpu_src2_32
);
3303 case 0x56: /* fcmped, V9 %fcc */
3304 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
3305 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
3306 gen_op_fcmped(rd
& 3, cpu_src1_64
, cpu_src2_64
);
3308 case 0x57: /* fcmpeq, V9 %fcc */
3309 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3310 gen_op_load_fpr_QT0(QFPREG(rs1
));
3311 gen_op_load_fpr_QT1(QFPREG(rs2
));
3312 gen_op_fcmpeq(rd
& 3);
3317 } else if (xop
== 0x2) {
3318 TCGv dst
= gen_dest_gpr(dc
, rd
);
3319 rs1
= GET_FIELD(insn
, 13, 17);
3321 /* clr/mov shortcut : or %g0, x, y -> mov x, y */
3322 if (IS_IMM
) { /* immediate */
3323 simm
= GET_FIELDs(insn
, 19, 31);
3324 tcg_gen_movi_tl(dst
, simm
);
3325 gen_store_gpr(dc
, rd
, dst
);
3326 } else { /* register */
3327 rs2
= GET_FIELD(insn
, 27, 31);
3329 tcg_gen_movi_tl(dst
, 0);
3330 gen_store_gpr(dc
, rd
, dst
);
3332 cpu_src2
= gen_load_gpr(dc
, rs2
);
3333 gen_store_gpr(dc
, rd
, cpu_src2
);
3337 cpu_src1
= get_src1(dc
, insn
);
3338 if (IS_IMM
) { /* immediate */
3339 simm
= GET_FIELDs(insn
, 19, 31);
3340 tcg_gen_ori_tl(dst
, cpu_src1
, simm
);
3341 gen_store_gpr(dc
, rd
, dst
);
3342 } else { /* register */
3343 rs2
= GET_FIELD(insn
, 27, 31);
3345 /* mov shortcut: or x, %g0, y -> mov x, y */
3346 gen_store_gpr(dc
, rd
, cpu_src1
);
3348 cpu_src2
= gen_load_gpr(dc
, rs2
);
3349 tcg_gen_or_tl(dst
, cpu_src1
, cpu_src2
);
3350 gen_store_gpr(dc
, rd
, dst
);
3354 #ifdef TARGET_SPARC64
3355 } else if (xop
== 0x25) { /* sll, V9 sllx */
3356 cpu_src1
= get_src1(dc
, insn
);
3357 if (IS_IMM
) { /* immediate */
3358 simm
= GET_FIELDs(insn
, 20, 31);
3359 if (insn
& (1 << 12)) {
3360 tcg_gen_shli_i64(cpu_dst
, cpu_src1
, simm
& 0x3f);
3362 tcg_gen_shli_i64(cpu_dst
, cpu_src1
, simm
& 0x1f);
3364 } else { /* register */
3365 rs2
= GET_FIELD(insn
, 27, 31);
3366 cpu_src2
= gen_load_gpr(dc
, rs2
);
3367 cpu_tmp0
= get_temp_tl(dc
);
3368 if (insn
& (1 << 12)) {
3369 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x3f);
3371 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x1f);
3373 tcg_gen_shl_i64(cpu_dst
, cpu_src1
, cpu_tmp0
);
3375 gen_store_gpr(dc
, rd
, cpu_dst
);
3376 } else if (xop
== 0x26) { /* srl, V9 srlx */
3377 cpu_src1
= get_src1(dc
, insn
);
3378 if (IS_IMM
) { /* immediate */
3379 simm
= GET_FIELDs(insn
, 20, 31);
3380 if (insn
& (1 << 12)) {
3381 tcg_gen_shri_i64(cpu_dst
, cpu_src1
, simm
& 0x3f);
3383 tcg_gen_andi_i64(cpu_dst
, cpu_src1
, 0xffffffffULL
);
3384 tcg_gen_shri_i64(cpu_dst
, cpu_dst
, simm
& 0x1f);
3386 } else { /* register */
3387 rs2
= GET_FIELD(insn
, 27, 31);
3388 cpu_src2
= gen_load_gpr(dc
, rs2
);
3389 cpu_tmp0
= get_temp_tl(dc
);
3390 if (insn
& (1 << 12)) {
3391 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x3f);
3392 tcg_gen_shr_i64(cpu_dst
, cpu_src1
, cpu_tmp0
);
3394 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x1f);
3395 tcg_gen_andi_i64(cpu_dst
, cpu_src1
, 0xffffffffULL
);
3396 tcg_gen_shr_i64(cpu_dst
, cpu_dst
, cpu_tmp0
);
3399 gen_store_gpr(dc
, rd
, cpu_dst
);
3400 } else if (xop
== 0x27) { /* sra, V9 srax */
3401 cpu_src1
= get_src1(dc
, insn
);
3402 if (IS_IMM
) { /* immediate */
3403 simm
= GET_FIELDs(insn
, 20, 31);
3404 if (insn
& (1 << 12)) {
3405 tcg_gen_sari_i64(cpu_dst
, cpu_src1
, simm
& 0x3f);
3407 tcg_gen_ext32s_i64(cpu_dst
, cpu_src1
);
3408 tcg_gen_sari_i64(cpu_dst
, cpu_dst
, simm
& 0x1f);
3410 } else { /* register */
3411 rs2
= GET_FIELD(insn
, 27, 31);
3412 cpu_src2
= gen_load_gpr(dc
, rs2
);
3413 cpu_tmp0
= get_temp_tl(dc
);
3414 if (insn
& (1 << 12)) {
3415 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x3f);
3416 tcg_gen_sar_i64(cpu_dst
, cpu_src1
, cpu_tmp0
);
3418 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x1f);
3419 tcg_gen_ext32s_i64(cpu_dst
, cpu_src1
);
3420 tcg_gen_sar_i64(cpu_dst
, cpu_dst
, cpu_tmp0
);
3423 gen_store_gpr(dc
, rd
, cpu_dst
);
3425 } else if (xop
< 0x36) {
3427 cpu_src1
= get_src1(dc
, insn
);
3428 cpu_src2
= get_src2(dc
, insn
);
3429 switch (xop
& ~0x10) {
3432 gen_op_add_cc(cpu_dst
, cpu_src1
, cpu_src2
);
3433 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_ADD
);
3434 dc
->cc_op
= CC_OP_ADD
;
3436 tcg_gen_add_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3440 tcg_gen_and_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3442 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3443 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3444 dc
->cc_op
= CC_OP_LOGIC
;
3448 tcg_gen_or_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3450 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3451 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3452 dc
->cc_op
= CC_OP_LOGIC
;
3456 tcg_gen_xor_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3458 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3459 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3460 dc
->cc_op
= CC_OP_LOGIC
;
3465 gen_op_sub_cc(cpu_dst
, cpu_src1
, cpu_src2
);
3466 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUB
);
3467 dc
->cc_op
= CC_OP_SUB
;
3469 tcg_gen_sub_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3472 case 0x5: /* andn */
3473 tcg_gen_andc_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3475 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3476 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3477 dc
->cc_op
= CC_OP_LOGIC
;
3481 tcg_gen_orc_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3483 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3484 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3485 dc
->cc_op
= CC_OP_LOGIC
;
3488 case 0x7: /* xorn */
3489 tcg_gen_eqv_tl(cpu_dst
, cpu_src1
, cpu_src2
);
3491 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3492 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3493 dc
->cc_op
= CC_OP_LOGIC
;
3496 case 0x8: /* addx, V9 addc */
3497 gen_op_addx_int(dc
, cpu_dst
, cpu_src1
, cpu_src2
,
3500 #ifdef TARGET_SPARC64
3501 case 0x9: /* V9 mulx */
3502 tcg_gen_mul_i64(cpu_dst
, cpu_src1
, cpu_src2
);
3505 case 0xa: /* umul */
3506 CHECK_IU_FEATURE(dc
, MUL
);
3507 gen_op_umul(cpu_dst
, cpu_src1
, cpu_src2
);
3509 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3510 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3511 dc
->cc_op
= CC_OP_LOGIC
;
3514 case 0xb: /* smul */
3515 CHECK_IU_FEATURE(dc
, MUL
);
3516 gen_op_smul(cpu_dst
, cpu_src1
, cpu_src2
);
3518 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
3519 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
3520 dc
->cc_op
= CC_OP_LOGIC
;
3523 case 0xc: /* subx, V9 subc */
3524 gen_op_subx_int(dc
, cpu_dst
, cpu_src1
, cpu_src2
,
3527 #ifdef TARGET_SPARC64
3528 case 0xd: /* V9 udivx */
3529 gen_helper_udivx(cpu_dst
, cpu_env
, cpu_src1
, cpu_src2
);
3532 case 0xe: /* udiv */
3533 CHECK_IU_FEATURE(dc
, DIV
);
3535 gen_helper_udiv_cc(cpu_dst
, cpu_env
, cpu_src1
,
3537 dc
->cc_op
= CC_OP_DIV
;
3539 gen_helper_udiv(cpu_dst
, cpu_env
, cpu_src1
,
3543 case 0xf: /* sdiv */
3544 CHECK_IU_FEATURE(dc
, DIV
);
3546 gen_helper_sdiv_cc(cpu_dst
, cpu_env
, cpu_src1
,
3548 dc
->cc_op
= CC_OP_DIV
;
3550 gen_helper_sdiv(cpu_dst
, cpu_env
, cpu_src1
,
3557 gen_store_gpr(dc
, rd
, cpu_dst
);
3559 cpu_src1
= get_src1(dc
, insn
);
3560 cpu_src2
= get_src2(dc
, insn
);
3562 case 0x20: /* taddcc */
3563 gen_op_add_cc(cpu_dst
, cpu_src1
, cpu_src2
);
3564 gen_store_gpr(dc
, rd
, cpu_dst
);
3565 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_TADD
);
3566 dc
->cc_op
= CC_OP_TADD
;
3568 case 0x21: /* tsubcc */
3569 gen_op_sub_cc(cpu_dst
, cpu_src1
, cpu_src2
);
3570 gen_store_gpr(dc
, rd
, cpu_dst
);
3571 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_TSUB
);
3572 dc
->cc_op
= CC_OP_TSUB
;
3574 case 0x22: /* taddcctv */
3575 gen_helper_taddcctv(cpu_dst
, cpu_env
,
3576 cpu_src1
, cpu_src2
);
3577 gen_store_gpr(dc
, rd
, cpu_dst
);
3578 dc
->cc_op
= CC_OP_TADDTV
;
3580 case 0x23: /* tsubcctv */
3581 gen_helper_tsubcctv(cpu_dst
, cpu_env
,
3582 cpu_src1
, cpu_src2
);
3583 gen_store_gpr(dc
, rd
, cpu_dst
);
3584 dc
->cc_op
= CC_OP_TSUBTV
;
3586 case 0x24: /* mulscc */
3588 gen_op_mulscc(cpu_dst
, cpu_src1
, cpu_src2
);
3589 gen_store_gpr(dc
, rd
, cpu_dst
);
3590 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_ADD
);
3591 dc
->cc_op
= CC_OP_ADD
;
3593 #ifndef TARGET_SPARC64
3594 case 0x25: /* sll */
3595 if (IS_IMM
) { /* immediate */
3596 simm
= GET_FIELDs(insn
, 20, 31);
3597 tcg_gen_shli_tl(cpu_dst
, cpu_src1
, simm
& 0x1f);
3598 } else { /* register */
3599 cpu_tmp0
= get_temp_tl(dc
);
3600 tcg_gen_andi_tl(cpu_tmp0
, cpu_src2
, 0x1f);
3601 tcg_gen_shl_tl(cpu_dst
, cpu_src1
, cpu_tmp0
);
3603 gen_store_gpr(dc
, rd
, cpu_dst
);
3605 case 0x26: /* srl */
3606 if (IS_IMM
) { /* immediate */
3607 simm
= GET_FIELDs(insn
, 20, 31);
3608 tcg_gen_shri_tl(cpu_dst
, cpu_src1
, simm
& 0x1f);
3609 } else { /* register */
3610 cpu_tmp0
= get_temp_tl(dc
);
3611 tcg_gen_andi_tl(cpu_tmp0
, cpu_src2
, 0x1f);
3612 tcg_gen_shr_tl(cpu_dst
, cpu_src1
, cpu_tmp0
);
3614 gen_store_gpr(dc
, rd
, cpu_dst
);
3616 case 0x27: /* sra */
3617 if (IS_IMM
) { /* immediate */
3618 simm
= GET_FIELDs(insn
, 20, 31);
3619 tcg_gen_sari_tl(cpu_dst
, cpu_src1
, simm
& 0x1f);
3620 } else { /* register */
3621 cpu_tmp0
= get_temp_tl(dc
);
3622 tcg_gen_andi_tl(cpu_tmp0
, cpu_src2
, 0x1f);
3623 tcg_gen_sar_tl(cpu_dst
, cpu_src1
, cpu_tmp0
);
3625 gen_store_gpr(dc
, rd
, cpu_dst
);
3630 cpu_tmp0
= get_temp_tl(dc
);
3633 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3634 tcg_gen_andi_tl(cpu_y
, cpu_tmp0
, 0xffffffff);
3636 #ifndef TARGET_SPARC64
3637 case 0x01 ... 0x0f: /* undefined in the
3641 case 0x10 ... 0x1f: /* implementation-dependent
3647 case 0x2: /* V9 wrccr */
3648 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3649 gen_helper_wrccr(cpu_env
, cpu_tmp0
);
3650 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_FLAGS
);
3651 dc
->cc_op
= CC_OP_FLAGS
;
3653 case 0x3: /* V9 wrasi */
3654 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3655 tcg_gen_andi_tl(cpu_tmp0
, cpu_tmp0
, 0xff);
3656 tcg_gen_trunc_tl_i32(cpu_asi
, cpu_tmp0
);
3658 case 0x6: /* V9 wrfprs */
3659 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3660 tcg_gen_trunc_tl_i32(cpu_fprs
, cpu_tmp0
);
3666 case 0xf: /* V9 sir, nop if user */
3667 #if !defined(CONFIG_USER_ONLY)
3668 if (supervisor(dc
)) {
3673 case 0x13: /* Graphics Status */
3674 if (gen_trap_ifnofpu(dc
)) {
3677 tcg_gen_xor_tl(cpu_gsr
, cpu_src1
, cpu_src2
);
3679 case 0x14: /* Softint set */
3680 if (!supervisor(dc
))
3682 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3683 gen_helper_set_softint(cpu_env
, cpu_tmp0
);
3685 case 0x15: /* Softint clear */
3686 if (!supervisor(dc
))
3688 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3689 gen_helper_clear_softint(cpu_env
, cpu_tmp0
);
3691 case 0x16: /* Softint write */
3692 if (!supervisor(dc
))
3694 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3695 gen_helper_write_softint(cpu_env
, cpu_tmp0
);
3697 case 0x17: /* Tick compare */
3698 #if !defined(CONFIG_USER_ONLY)
3699 if (!supervisor(dc
))
3705 tcg_gen_xor_tl(cpu_tick_cmpr
, cpu_src1
,
3707 r_tickptr
= tcg_temp_new_ptr();
3708 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3709 offsetof(CPUSPARCState
, tick
));
3710 gen_helper_tick_set_limit(r_tickptr
,
3712 tcg_temp_free_ptr(r_tickptr
);
3715 case 0x18: /* System tick */
3716 #if !defined(CONFIG_USER_ONLY)
3717 if (!supervisor(dc
))
3723 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
,
3725 r_tickptr
= tcg_temp_new_ptr();
3726 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3727 offsetof(CPUSPARCState
, stick
));
3728 gen_helper_tick_set_count(r_tickptr
,
3730 tcg_temp_free_ptr(r_tickptr
);
3733 case 0x19: /* System tick compare */
3734 #if !defined(CONFIG_USER_ONLY)
3735 if (!supervisor(dc
))
3741 tcg_gen_xor_tl(cpu_stick_cmpr
, cpu_src1
,
3743 r_tickptr
= tcg_temp_new_ptr();
3744 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3745 offsetof(CPUSPARCState
, stick
));
3746 gen_helper_tick_set_limit(r_tickptr
,
3748 tcg_temp_free_ptr(r_tickptr
);
3752 case 0x10: /* Performance Control */
3753 case 0x11: /* Performance Instrumentation
3755 case 0x12: /* Dispatch Control */
3762 #if !defined(CONFIG_USER_ONLY)
3763 case 0x31: /* wrpsr, V9 saved, restored */
3765 if (!supervisor(dc
))
3767 #ifdef TARGET_SPARC64
3770 gen_helper_saved(cpu_env
);
3773 gen_helper_restored(cpu_env
);
3775 case 2: /* UA2005 allclean */
3776 case 3: /* UA2005 otherw */
3777 case 4: /* UA2005 normalw */
3778 case 5: /* UA2005 invalw */
3784 cpu_tmp0
= get_temp_tl(dc
);
3785 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3786 gen_helper_wrpsr(cpu_env
, cpu_tmp0
);
3787 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_FLAGS
);
3788 dc
->cc_op
= CC_OP_FLAGS
;
3796 case 0x32: /* wrwim, V9 wrpr */
3798 if (!supervisor(dc
))
3800 cpu_tmp0
= get_temp_tl(dc
);
3801 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3802 #ifdef TARGET_SPARC64
3808 r_tsptr
= tcg_temp_new_ptr();
3809 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3810 tcg_gen_st_tl(cpu_tmp0
, r_tsptr
,
3811 offsetof(trap_state
, tpc
));
3812 tcg_temp_free_ptr(r_tsptr
);
3819 r_tsptr
= tcg_temp_new_ptr();
3820 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3821 tcg_gen_st_tl(cpu_tmp0
, r_tsptr
,
3822 offsetof(trap_state
, tnpc
));
3823 tcg_temp_free_ptr(r_tsptr
);
3830 r_tsptr
= tcg_temp_new_ptr();
3831 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3832 tcg_gen_st_tl(cpu_tmp0
, r_tsptr
,
3833 offsetof(trap_state
,
3835 tcg_temp_free_ptr(r_tsptr
);
3842 r_tsptr
= tcg_temp_new_ptr();
3843 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3844 tcg_gen_st32_tl(cpu_tmp0
, r_tsptr
,
3845 offsetof(trap_state
, tt
));
3846 tcg_temp_free_ptr(r_tsptr
);
3853 r_tickptr
= tcg_temp_new_ptr();
3854 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3855 offsetof(CPUSPARCState
, tick
));
3856 gen_helper_tick_set_count(r_tickptr
,
3858 tcg_temp_free_ptr(r_tickptr
);
3862 tcg_gen_mov_tl(cpu_tbr
, cpu_tmp0
);
3866 gen_helper_wrpstate(cpu_env
, cpu_tmp0
);
3867 dc
->npc
= DYNAMIC_PC
;
3871 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3872 offsetof(CPUSPARCState
, tl
));
3873 dc
->npc
= DYNAMIC_PC
;
3876 gen_helper_wrpil(cpu_env
, cpu_tmp0
);
3879 gen_helper_wrcwp(cpu_env
, cpu_tmp0
);
3882 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3883 offsetof(CPUSPARCState
,
3886 case 11: // canrestore
3887 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3888 offsetof(CPUSPARCState
,
3891 case 12: // cleanwin
3892 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3893 offsetof(CPUSPARCState
,
3896 case 13: // otherwin
3897 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3898 offsetof(CPUSPARCState
,
3902 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3903 offsetof(CPUSPARCState
,
3906 case 16: // UA2005 gl
3907 CHECK_IU_FEATURE(dc
, GL
);
3908 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
3909 offsetof(CPUSPARCState
, gl
));
3911 case 26: // UA2005 strand status
3912 CHECK_IU_FEATURE(dc
, HYPV
);
3913 if (!hypervisor(dc
))
3915 tcg_gen_mov_tl(cpu_ssr
, cpu_tmp0
);
3921 tcg_gen_trunc_tl_i32(cpu_wim
, cpu_tmp0
);
3922 if (dc
->def
->nwindows
!= 32) {
3923 tcg_gen_andi_tl(cpu_wim
, cpu_wim
,
3924 (1 << dc
->def
->nwindows
) - 1);
3929 case 0x33: /* wrtbr, UA2005 wrhpr */
3931 #ifndef TARGET_SPARC64
3932 if (!supervisor(dc
))
3934 tcg_gen_xor_tl(cpu_tbr
, cpu_src1
, cpu_src2
);
3936 CHECK_IU_FEATURE(dc
, HYPV
);
3937 if (!hypervisor(dc
))
3939 cpu_tmp0
= get_temp_tl(dc
);
3940 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
3943 // XXX gen_op_wrhpstate();
3950 // XXX gen_op_wrhtstate();
3953 tcg_gen_mov_tl(cpu_hintp
, cpu_tmp0
);
3956 tcg_gen_mov_tl(cpu_htba
, cpu_tmp0
);
3958 case 31: // hstick_cmpr
3962 tcg_gen_mov_tl(cpu_hstick_cmpr
, cpu_tmp0
);
3963 r_tickptr
= tcg_temp_new_ptr();
3964 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3965 offsetof(CPUSPARCState
, hstick
));
3966 gen_helper_tick_set_limit(r_tickptr
,
3968 tcg_temp_free_ptr(r_tickptr
);
3971 case 6: // hver readonly
3979 #ifdef TARGET_SPARC64
3980 case 0x2c: /* V9 movcc */
3982 int cc
= GET_FIELD_SP(insn
, 11, 12);
3983 int cond
= GET_FIELD_SP(insn
, 14, 17);
3987 if (insn
& (1 << 18)) {
3989 gen_compare(&cmp
, 0, cond
, dc
);
3990 } else if (cc
== 2) {
3991 gen_compare(&cmp
, 1, cond
, dc
);
3996 gen_fcompare(&cmp
, cc
, cond
);
3999 /* The get_src2 above loaded the normal 13-bit
4000 immediate field, not the 11-bit field we have
4001 in movcc. But it did handle the reg case. */
4003 simm
= GET_FIELD_SPs(insn
, 0, 10);
4004 tcg_gen_movi_tl(cpu_src2
, simm
);
4007 dst
= gen_load_gpr(dc
, rd
);
4008 tcg_gen_movcond_tl(cmp
.cond
, dst
,
4012 gen_store_gpr(dc
, rd
, dst
);
4015 case 0x2d: /* V9 sdivx */
4016 gen_helper_sdivx(cpu_dst
, cpu_env
, cpu_src1
, cpu_src2
);
4017 gen_store_gpr(dc
, rd
, cpu_dst
);
4019 case 0x2e: /* V9 popc */
4020 gen_helper_popc(cpu_dst
, cpu_src2
);
4021 gen_store_gpr(dc
, rd
, cpu_dst
);
4023 case 0x2f: /* V9 movr */
4025 int cond
= GET_FIELD_SP(insn
, 10, 12);
4029 gen_compare_reg(&cmp
, cond
, cpu_src1
);
4031 /* The get_src2 above loaded the normal 13-bit
4032 immediate field, not the 10-bit field we have
4033 in movr. But it did handle the reg case. */
4035 simm
= GET_FIELD_SPs(insn
, 0, 9);
4036 tcg_gen_movi_tl(cpu_src2
, simm
);
4039 dst
= gen_load_gpr(dc
, rd
);
4040 tcg_gen_movcond_tl(cmp
.cond
, dst
,
4044 gen_store_gpr(dc
, rd
, dst
);
4052 } else if (xop
== 0x36) { /* UltraSparc shutdown, VIS, V8 CPop1 */
4053 #ifdef TARGET_SPARC64
4054 int opf
= GET_FIELD_SP(insn
, 5, 13);
4055 rs1
= GET_FIELD(insn
, 13, 17);
4056 rs2
= GET_FIELD(insn
, 27, 31);
4057 if (gen_trap_ifnofpu(dc
)) {
4062 case 0x000: /* VIS I edge8cc */
4063 CHECK_FPU_FEATURE(dc
, VIS1
);
4064 cpu_src1
= gen_load_gpr(dc
, rs1
);
4065 cpu_src2
= gen_load_gpr(dc
, rs2
);
4066 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 1, 0);
4067 gen_store_gpr(dc
, rd
, cpu_dst
);
4069 case 0x001: /* VIS II edge8n */
4070 CHECK_FPU_FEATURE(dc
, VIS2
);
4071 cpu_src1
= gen_load_gpr(dc
, rs1
);
4072 cpu_src2
= gen_load_gpr(dc
, rs2
);
4073 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 0, 0);
4074 gen_store_gpr(dc
, rd
, cpu_dst
);
4076 case 0x002: /* VIS I edge8lcc */
4077 CHECK_FPU_FEATURE(dc
, VIS1
);
4078 cpu_src1
= gen_load_gpr(dc
, rs1
);
4079 cpu_src2
= gen_load_gpr(dc
, rs2
);
4080 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 1, 1);
4081 gen_store_gpr(dc
, rd
, cpu_dst
);
4083 case 0x003: /* VIS II edge8ln */
4084 CHECK_FPU_FEATURE(dc
, VIS2
);
4085 cpu_src1
= gen_load_gpr(dc
, rs1
);
4086 cpu_src2
= gen_load_gpr(dc
, rs2
);
4087 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 0, 1);
4088 gen_store_gpr(dc
, rd
, cpu_dst
);
4090 case 0x004: /* VIS I edge16cc */
4091 CHECK_FPU_FEATURE(dc
, VIS1
);
4092 cpu_src1
= gen_load_gpr(dc
, rs1
);
4093 cpu_src2
= gen_load_gpr(dc
, rs2
);
4094 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 1, 0);
4095 gen_store_gpr(dc
, rd
, cpu_dst
);
4097 case 0x005: /* VIS II edge16n */
4098 CHECK_FPU_FEATURE(dc
, VIS2
);
4099 cpu_src1
= gen_load_gpr(dc
, rs1
);
4100 cpu_src2
= gen_load_gpr(dc
, rs2
);
4101 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 0, 0);
4102 gen_store_gpr(dc
, rd
, cpu_dst
);
4104 case 0x006: /* VIS I edge16lcc */
4105 CHECK_FPU_FEATURE(dc
, VIS1
);
4106 cpu_src1
= gen_load_gpr(dc
, rs1
);
4107 cpu_src2
= gen_load_gpr(dc
, rs2
);
4108 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 1, 1);
4109 gen_store_gpr(dc
, rd
, cpu_dst
);
4111 case 0x007: /* VIS II edge16ln */
4112 CHECK_FPU_FEATURE(dc
, VIS2
);
4113 cpu_src1
= gen_load_gpr(dc
, rs1
);
4114 cpu_src2
= gen_load_gpr(dc
, rs2
);
4115 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 0, 1);
4116 gen_store_gpr(dc
, rd
, cpu_dst
);
4118 case 0x008: /* VIS I edge32cc */
4119 CHECK_FPU_FEATURE(dc
, VIS1
);
4120 cpu_src1
= gen_load_gpr(dc
, rs1
);
4121 cpu_src2
= gen_load_gpr(dc
, rs2
);
4122 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 1, 0);
4123 gen_store_gpr(dc
, rd
, cpu_dst
);
4125 case 0x009: /* VIS II edge32n */
4126 CHECK_FPU_FEATURE(dc
, VIS2
);
4127 cpu_src1
= gen_load_gpr(dc
, rs1
);
4128 cpu_src2
= gen_load_gpr(dc
, rs2
);
4129 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 0, 0);
4130 gen_store_gpr(dc
, rd
, cpu_dst
);
4132 case 0x00a: /* VIS I edge32lcc */
4133 CHECK_FPU_FEATURE(dc
, VIS1
);
4134 cpu_src1
= gen_load_gpr(dc
, rs1
);
4135 cpu_src2
= gen_load_gpr(dc
, rs2
);
4136 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 1, 1);
4137 gen_store_gpr(dc
, rd
, cpu_dst
);
4139 case 0x00b: /* VIS II edge32ln */
4140 CHECK_FPU_FEATURE(dc
, VIS2
);
4141 cpu_src1
= gen_load_gpr(dc
, rs1
);
4142 cpu_src2
= gen_load_gpr(dc
, rs2
);
4143 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 0, 1);
4144 gen_store_gpr(dc
, rd
, cpu_dst
);
4146 case 0x010: /* VIS I array8 */
4147 CHECK_FPU_FEATURE(dc
, VIS1
);
4148 cpu_src1
= gen_load_gpr(dc
, rs1
);
4149 cpu_src2
= gen_load_gpr(dc
, rs2
);
4150 gen_helper_array8(cpu_dst
, cpu_src1
, cpu_src2
);
4151 gen_store_gpr(dc
, rd
, cpu_dst
);
4153 case 0x012: /* VIS I array16 */
4154 CHECK_FPU_FEATURE(dc
, VIS1
);
4155 cpu_src1
= gen_load_gpr(dc
, rs1
);
4156 cpu_src2
= gen_load_gpr(dc
, rs2
);
4157 gen_helper_array8(cpu_dst
, cpu_src1
, cpu_src2
);
4158 tcg_gen_shli_i64(cpu_dst
, cpu_dst
, 1);
4159 gen_store_gpr(dc
, rd
, cpu_dst
);
4161 case 0x014: /* VIS I array32 */
4162 CHECK_FPU_FEATURE(dc
, VIS1
);
4163 cpu_src1
= gen_load_gpr(dc
, rs1
);
4164 cpu_src2
= gen_load_gpr(dc
, rs2
);
4165 gen_helper_array8(cpu_dst
, cpu_src1
, cpu_src2
);
4166 tcg_gen_shli_i64(cpu_dst
, cpu_dst
, 2);
4167 gen_store_gpr(dc
, rd
, cpu_dst
);
4169 case 0x018: /* VIS I alignaddr */
4170 CHECK_FPU_FEATURE(dc
, VIS1
);
4171 cpu_src1
= gen_load_gpr(dc
, rs1
);
4172 cpu_src2
= gen_load_gpr(dc
, rs2
);
4173 gen_alignaddr(cpu_dst
, cpu_src1
, cpu_src2
, 0);
4174 gen_store_gpr(dc
, rd
, cpu_dst
);
4176 case 0x01a: /* VIS I alignaddrl */
4177 CHECK_FPU_FEATURE(dc
, VIS1
);
4178 cpu_src1
= gen_load_gpr(dc
, rs1
);
4179 cpu_src2
= gen_load_gpr(dc
, rs2
);
4180 gen_alignaddr(cpu_dst
, cpu_src1
, cpu_src2
, 1);
4181 gen_store_gpr(dc
, rd
, cpu_dst
);
4183 case 0x019: /* VIS II bmask */
4184 CHECK_FPU_FEATURE(dc
, VIS2
);
4185 cpu_src1
= gen_load_gpr(dc
, rs1
);
4186 cpu_src2
= gen_load_gpr(dc
, rs2
);
4187 tcg_gen_add_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4188 tcg_gen_deposit_tl(cpu_gsr
, cpu_gsr
, cpu_dst
, 32, 32);
4189 gen_store_gpr(dc
, rd
, cpu_dst
);
4191 case 0x020: /* VIS I fcmple16 */
4192 CHECK_FPU_FEATURE(dc
, VIS1
);
4193 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4194 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4195 gen_helper_fcmple16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4196 gen_store_gpr(dc
, rd
, cpu_dst
);
4198 case 0x022: /* VIS I fcmpne16 */
4199 CHECK_FPU_FEATURE(dc
, VIS1
);
4200 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4201 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4202 gen_helper_fcmpne16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4203 gen_store_gpr(dc
, rd
, cpu_dst
);
4205 case 0x024: /* VIS I fcmple32 */
4206 CHECK_FPU_FEATURE(dc
, VIS1
);
4207 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4208 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4209 gen_helper_fcmple32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4210 gen_store_gpr(dc
, rd
, cpu_dst
);
4212 case 0x026: /* VIS I fcmpne32 */
4213 CHECK_FPU_FEATURE(dc
, VIS1
);
4214 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4215 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4216 gen_helper_fcmpne32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4217 gen_store_gpr(dc
, rd
, cpu_dst
);
4219 case 0x028: /* VIS I fcmpgt16 */
4220 CHECK_FPU_FEATURE(dc
, VIS1
);
4221 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4222 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4223 gen_helper_fcmpgt16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4224 gen_store_gpr(dc
, rd
, cpu_dst
);
4226 case 0x02a: /* VIS I fcmpeq16 */
4227 CHECK_FPU_FEATURE(dc
, VIS1
);
4228 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4229 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4230 gen_helper_fcmpeq16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4231 gen_store_gpr(dc
, rd
, cpu_dst
);
4233 case 0x02c: /* VIS I fcmpgt32 */
4234 CHECK_FPU_FEATURE(dc
, VIS1
);
4235 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4236 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4237 gen_helper_fcmpgt32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4238 gen_store_gpr(dc
, rd
, cpu_dst
);
4240 case 0x02e: /* VIS I fcmpeq32 */
4241 CHECK_FPU_FEATURE(dc
, VIS1
);
4242 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4243 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4244 gen_helper_fcmpeq32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4245 gen_store_gpr(dc
, rd
, cpu_dst
);
4247 case 0x031: /* VIS I fmul8x16 */
4248 CHECK_FPU_FEATURE(dc
, VIS1
);
4249 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8x16
);
4251 case 0x033: /* VIS I fmul8x16au */
4252 CHECK_FPU_FEATURE(dc
, VIS1
);
4253 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8x16au
);
4255 case 0x035: /* VIS I fmul8x16al */
4256 CHECK_FPU_FEATURE(dc
, VIS1
);
4257 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8x16al
);
4259 case 0x036: /* VIS I fmul8sux16 */
4260 CHECK_FPU_FEATURE(dc
, VIS1
);
4261 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8sux16
);
4263 case 0x037: /* VIS I fmul8ulx16 */
4264 CHECK_FPU_FEATURE(dc
, VIS1
);
4265 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8ulx16
);
4267 case 0x038: /* VIS I fmuld8sux16 */
4268 CHECK_FPU_FEATURE(dc
, VIS1
);
4269 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmuld8sux16
);
4271 case 0x039: /* VIS I fmuld8ulx16 */
4272 CHECK_FPU_FEATURE(dc
, VIS1
);
4273 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmuld8ulx16
);
4275 case 0x03a: /* VIS I fpack32 */
4276 CHECK_FPU_FEATURE(dc
, VIS1
);
4277 gen_gsr_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpack32
);
4279 case 0x03b: /* VIS I fpack16 */
4280 CHECK_FPU_FEATURE(dc
, VIS1
);
4281 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
4282 cpu_dst_32
= gen_dest_fpr_F(dc
);
4283 gen_helper_fpack16(cpu_dst_32
, cpu_gsr
, cpu_src1_64
);
4284 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
4286 case 0x03d: /* VIS I fpackfix */
4287 CHECK_FPU_FEATURE(dc
, VIS1
);
4288 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
4289 cpu_dst_32
= gen_dest_fpr_F(dc
);
4290 gen_helper_fpackfix(cpu_dst_32
, cpu_gsr
, cpu_src1_64
);
4291 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
4293 case 0x03e: /* VIS I pdist */
4294 CHECK_FPU_FEATURE(dc
, VIS1
);
4295 gen_ne_fop_DDDD(dc
, rd
, rs1
, rs2
, gen_helper_pdist
);
4297 case 0x048: /* VIS I faligndata */
4298 CHECK_FPU_FEATURE(dc
, VIS1
);
4299 gen_gsr_fop_DDD(dc
, rd
, rs1
, rs2
, gen_faligndata
);
4301 case 0x04b: /* VIS I fpmerge */
4302 CHECK_FPU_FEATURE(dc
, VIS1
);
4303 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpmerge
);
4305 case 0x04c: /* VIS II bshuffle */
4306 CHECK_FPU_FEATURE(dc
, VIS2
);
4307 gen_gsr_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_bshuffle
);
4309 case 0x04d: /* VIS I fexpand */
4310 CHECK_FPU_FEATURE(dc
, VIS1
);
4311 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fexpand
);
4313 case 0x050: /* VIS I fpadd16 */
4314 CHECK_FPU_FEATURE(dc
, VIS1
);
4315 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpadd16
);
4317 case 0x051: /* VIS I fpadd16s */
4318 CHECK_FPU_FEATURE(dc
, VIS1
);
4319 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fpadd16s
);
4321 case 0x052: /* VIS I fpadd32 */
4322 CHECK_FPU_FEATURE(dc
, VIS1
);
4323 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpadd32
);
4325 case 0x053: /* VIS I fpadd32s */
4326 CHECK_FPU_FEATURE(dc
, VIS1
);
4327 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_add_i32
);
4329 case 0x054: /* VIS I fpsub16 */
4330 CHECK_FPU_FEATURE(dc
, VIS1
);
4331 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpsub16
);
4333 case 0x055: /* VIS I fpsub16s */
4334 CHECK_FPU_FEATURE(dc
, VIS1
);
4335 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fpsub16s
);
4337 case 0x056: /* VIS I fpsub32 */
4338 CHECK_FPU_FEATURE(dc
, VIS1
);
4339 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpsub32
);
4341 case 0x057: /* VIS I fpsub32s */
4342 CHECK_FPU_FEATURE(dc
, VIS1
);
4343 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_sub_i32
);
4345 case 0x060: /* VIS I fzero */
4346 CHECK_FPU_FEATURE(dc
, VIS1
);
4347 cpu_dst_64
= gen_dest_fpr_D(dc
, rd
);
4348 tcg_gen_movi_i64(cpu_dst_64
, 0);
4349 gen_store_fpr_D(dc
, rd
, cpu_dst_64
);
4351 case 0x061: /* VIS I fzeros */
4352 CHECK_FPU_FEATURE(dc
, VIS1
);
4353 cpu_dst_32
= gen_dest_fpr_F(dc
);
4354 tcg_gen_movi_i32(cpu_dst_32
, 0);
4355 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
4357 case 0x062: /* VIS I fnor */
4358 CHECK_FPU_FEATURE(dc
, VIS1
);
4359 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_nor_i64
);
4361 case 0x063: /* VIS I fnors */
4362 CHECK_FPU_FEATURE(dc
, VIS1
);
4363 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_nor_i32
);
4365 case 0x064: /* VIS I fandnot2 */
4366 CHECK_FPU_FEATURE(dc
, VIS1
);
4367 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_andc_i64
);
4369 case 0x065: /* VIS I fandnot2s */
4370 CHECK_FPU_FEATURE(dc
, VIS1
);
4371 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_andc_i32
);
4373 case 0x066: /* VIS I fnot2 */
4374 CHECK_FPU_FEATURE(dc
, VIS1
);
4375 gen_ne_fop_DD(dc
, rd
, rs2
, tcg_gen_not_i64
);
4377 case 0x067: /* VIS I fnot2s */
4378 CHECK_FPU_FEATURE(dc
, VIS1
);
4379 gen_ne_fop_FF(dc
, rd
, rs2
, tcg_gen_not_i32
);
4381 case 0x068: /* VIS I fandnot1 */
4382 CHECK_FPU_FEATURE(dc
, VIS1
);
4383 gen_ne_fop_DDD(dc
, rd
, rs2
, rs1
, tcg_gen_andc_i64
);
4385 case 0x069: /* VIS I fandnot1s */
4386 CHECK_FPU_FEATURE(dc
, VIS1
);
4387 gen_ne_fop_FFF(dc
, rd
, rs2
, rs1
, tcg_gen_andc_i32
);
4389 case 0x06a: /* VIS I fnot1 */
4390 CHECK_FPU_FEATURE(dc
, VIS1
);
4391 gen_ne_fop_DD(dc
, rd
, rs1
, tcg_gen_not_i64
);
4393 case 0x06b: /* VIS I fnot1s */
4394 CHECK_FPU_FEATURE(dc
, VIS1
);
4395 gen_ne_fop_FF(dc
, rd
, rs1
, tcg_gen_not_i32
);
4397 case 0x06c: /* VIS I fxor */
4398 CHECK_FPU_FEATURE(dc
, VIS1
);
4399 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_xor_i64
);
4401 case 0x06d: /* VIS I fxors */
4402 CHECK_FPU_FEATURE(dc
, VIS1
);
4403 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_xor_i32
);
4405 case 0x06e: /* VIS I fnand */
4406 CHECK_FPU_FEATURE(dc
, VIS1
);
4407 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_nand_i64
);
4409 case 0x06f: /* VIS I fnands */
4410 CHECK_FPU_FEATURE(dc
, VIS1
);
4411 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_nand_i32
);
4413 case 0x070: /* VIS I fand */
4414 CHECK_FPU_FEATURE(dc
, VIS1
);
4415 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_and_i64
);
4417 case 0x071: /* VIS I fands */
4418 CHECK_FPU_FEATURE(dc
, VIS1
);
4419 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_and_i32
);
4421 case 0x072: /* VIS I fxnor */
4422 CHECK_FPU_FEATURE(dc
, VIS1
);
4423 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_eqv_i64
);
4425 case 0x073: /* VIS I fxnors */
4426 CHECK_FPU_FEATURE(dc
, VIS1
);
4427 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_eqv_i32
);
4429 case 0x074: /* VIS I fsrc1 */
4430 CHECK_FPU_FEATURE(dc
, VIS1
);
4431 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4432 gen_store_fpr_D(dc
, rd
, cpu_src1_64
);
4434 case 0x075: /* VIS I fsrc1s */
4435 CHECK_FPU_FEATURE(dc
, VIS1
);
4436 cpu_src1_32
= gen_load_fpr_F(dc
, rs1
);
4437 gen_store_fpr_F(dc
, rd
, cpu_src1_32
);
4439 case 0x076: /* VIS I fornot2 */
4440 CHECK_FPU_FEATURE(dc
, VIS1
);
4441 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_orc_i64
);
4443 case 0x077: /* VIS I fornot2s */
4444 CHECK_FPU_FEATURE(dc
, VIS1
);
4445 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_orc_i32
);
4447 case 0x078: /* VIS I fsrc2 */
4448 CHECK_FPU_FEATURE(dc
, VIS1
);
4449 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
4450 gen_store_fpr_D(dc
, rd
, cpu_src1_64
);
4452 case 0x079: /* VIS I fsrc2s */
4453 CHECK_FPU_FEATURE(dc
, VIS1
);
4454 cpu_src1_32
= gen_load_fpr_F(dc
, rs2
);
4455 gen_store_fpr_F(dc
, rd
, cpu_src1_32
);
4457 case 0x07a: /* VIS I fornot1 */
4458 CHECK_FPU_FEATURE(dc
, VIS1
);
4459 gen_ne_fop_DDD(dc
, rd
, rs2
, rs1
, tcg_gen_orc_i64
);
4461 case 0x07b: /* VIS I fornot1s */
4462 CHECK_FPU_FEATURE(dc
, VIS1
);
4463 gen_ne_fop_FFF(dc
, rd
, rs2
, rs1
, tcg_gen_orc_i32
);
4465 case 0x07c: /* VIS I for */
4466 CHECK_FPU_FEATURE(dc
, VIS1
);
4467 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_or_i64
);
4469 case 0x07d: /* VIS I fors */
4470 CHECK_FPU_FEATURE(dc
, VIS1
);
4471 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_or_i32
);
4473 case 0x07e: /* VIS I fone */
4474 CHECK_FPU_FEATURE(dc
, VIS1
);
4475 cpu_dst_64
= gen_dest_fpr_D(dc
, rd
);
4476 tcg_gen_movi_i64(cpu_dst_64
, -1);
4477 gen_store_fpr_D(dc
, rd
, cpu_dst_64
);
4479 case 0x07f: /* VIS I fones */
4480 CHECK_FPU_FEATURE(dc
, VIS1
);
4481 cpu_dst_32
= gen_dest_fpr_F(dc
);
4482 tcg_gen_movi_i32(cpu_dst_32
, -1);
4483 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
4485 case 0x080: /* VIS I shutdown */
4486 case 0x081: /* VIS II siam */
4495 } else if (xop
== 0x37) { /* V8 CPop2, V9 impdep2 */
4496 #ifdef TARGET_SPARC64
4501 #ifdef TARGET_SPARC64
4502 } else if (xop
== 0x39) { /* V9 return */
4506 cpu_src1
= get_src1(dc
, insn
);
4507 cpu_tmp0
= get_temp_tl(dc
);
4508 if (IS_IMM
) { /* immediate */
4509 simm
= GET_FIELDs(insn
, 19, 31);
4510 tcg_gen_addi_tl(cpu_tmp0
, cpu_src1
, simm
);
4511 } else { /* register */
4512 rs2
= GET_FIELD(insn
, 27, 31);
4514 cpu_src2
= gen_load_gpr(dc
, rs2
);
4515 tcg_gen_add_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4517 tcg_gen_mov_tl(cpu_tmp0
, cpu_src1
);
4520 gen_helper_restore(cpu_env
);
4522 r_const
= tcg_const_i32(3);
4523 gen_helper_check_align(cpu_env
, cpu_tmp0
, r_const
);
4524 tcg_temp_free_i32(r_const
);
4525 tcg_gen_mov_tl(cpu_npc
, cpu_tmp0
);
4526 dc
->npc
= DYNAMIC_PC
;
4530 cpu_src1
= get_src1(dc
, insn
);
4531 cpu_tmp0
= get_temp_tl(dc
);
4532 if (IS_IMM
) { /* immediate */
4533 simm
= GET_FIELDs(insn
, 19, 31);
4534 tcg_gen_addi_tl(cpu_tmp0
, cpu_src1
, simm
);
4535 } else { /* register */
4536 rs2
= GET_FIELD(insn
, 27, 31);
4538 cpu_src2
= gen_load_gpr(dc
, rs2
);
4539 tcg_gen_add_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4541 tcg_gen_mov_tl(cpu_tmp0
, cpu_src1
);
4545 case 0x38: /* jmpl */
4550 t
= gen_dest_gpr(dc
, rd
);
4551 tcg_gen_movi_tl(t
, dc
->pc
);
4552 gen_store_gpr(dc
, rd
, t
);
4554 r_const
= tcg_const_i32(3);
4555 gen_helper_check_align(cpu_env
, cpu_tmp0
, r_const
);
4556 tcg_temp_free_i32(r_const
);
4557 gen_address_mask(dc
, cpu_tmp0
);
4558 tcg_gen_mov_tl(cpu_npc
, cpu_tmp0
);
4559 dc
->npc
= DYNAMIC_PC
;
4562 #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
4563 case 0x39: /* rett, V9 return */
4567 if (!supervisor(dc
))
4570 r_const
= tcg_const_i32(3);
4571 gen_helper_check_align(cpu_env
, cpu_tmp0
, r_const
);
4572 tcg_temp_free_i32(r_const
);
4573 tcg_gen_mov_tl(cpu_npc
, cpu_tmp0
);
4574 dc
->npc
= DYNAMIC_PC
;
4575 gen_helper_rett(cpu_env
);
4579 case 0x3b: /* flush */
4580 if (!((dc
)->def
->features
& CPU_FEATURE_FLUSH
))
4584 case 0x3c: /* save */
4586 gen_helper_save(cpu_env
);
4587 gen_store_gpr(dc
, rd
, cpu_tmp0
);
4589 case 0x3d: /* restore */
4591 gen_helper_restore(cpu_env
);
4592 gen_store_gpr(dc
, rd
, cpu_tmp0
);
4594 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
4595 case 0x3e: /* V9 done/retry */
4599 if (!supervisor(dc
))
4601 dc
->npc
= DYNAMIC_PC
;
4602 dc
->pc
= DYNAMIC_PC
;
4603 gen_helper_done(cpu_env
);
4606 if (!supervisor(dc
))
4608 dc
->npc
= DYNAMIC_PC
;
4609 dc
->pc
= DYNAMIC_PC
;
4610 gen_helper_retry(cpu_env
);
4625 case 3: /* load/store instructions */
4627 unsigned int xop
= GET_FIELD(insn
, 7, 12);
4628 /* ??? gen_address_mask prevents us from using a source
4629 register directly. Always generate a temporary. */
4630 TCGv cpu_addr
= get_temp_tl(dc
);
4632 tcg_gen_mov_tl(cpu_addr
, get_src1(dc
, insn
));
4633 if (xop
== 0x3c || xop
== 0x3e) {
4634 /* V9 casa/casxa : no offset */
4635 } else if (IS_IMM
) { /* immediate */
4636 simm
= GET_FIELDs(insn
, 19, 31);
4638 tcg_gen_addi_tl(cpu_addr
, cpu_addr
, simm
);
4640 } else { /* register */
4641 rs2
= GET_FIELD(insn
, 27, 31);
4643 tcg_gen_add_tl(cpu_addr
, cpu_addr
, gen_load_gpr(dc
, rs2
));
4646 if (xop
< 4 || (xop
> 7 && xop
< 0x14 && xop
!= 0x0e) ||
4647 (xop
> 0x17 && xop
<= 0x1d ) ||
4648 (xop
> 0x2c && xop
<= 0x33) || xop
== 0x1f || xop
== 0x3d) {
4649 TCGv cpu_val
= gen_dest_gpr(dc
, rd
);
4652 case 0x0: /* ld, V9 lduw, load unsigned word */
4653 gen_address_mask(dc
, cpu_addr
);
4654 tcg_gen_qemu_ld32u(cpu_val
, cpu_addr
, dc
->mem_idx
);
4656 case 0x1: /* ldub, load unsigned byte */
4657 gen_address_mask(dc
, cpu_addr
);
4658 tcg_gen_qemu_ld8u(cpu_val
, cpu_addr
, dc
->mem_idx
);
4660 case 0x2: /* lduh, load unsigned halfword */
4661 gen_address_mask(dc
, cpu_addr
);
4662 tcg_gen_qemu_ld16u(cpu_val
, cpu_addr
, dc
->mem_idx
);
4664 case 0x3: /* ldd, load double word */
4672 r_const
= tcg_const_i32(7);
4673 /* XXX remove alignment check */
4674 gen_helper_check_align(cpu_env
, cpu_addr
, r_const
);
4675 tcg_temp_free_i32(r_const
);
4676 gen_address_mask(dc
, cpu_addr
);
4677 t64
= tcg_temp_new_i64();
4678 tcg_gen_qemu_ld64(t64
, cpu_addr
, dc
->mem_idx
);
4679 tcg_gen_trunc_i64_tl(cpu_val
, t64
);
4680 tcg_gen_ext32u_tl(cpu_val
, cpu_val
);
4681 gen_store_gpr(dc
, rd
+ 1, cpu_val
);
4682 tcg_gen_shri_i64(t64
, t64
, 32);
4683 tcg_gen_trunc_i64_tl(cpu_val
, t64
);
4684 tcg_temp_free_i64(t64
);
4685 tcg_gen_ext32u_tl(cpu_val
, cpu_val
);
4688 case 0x9: /* ldsb, load signed byte */
4689 gen_address_mask(dc
, cpu_addr
);
4690 tcg_gen_qemu_ld8s(cpu_val
, cpu_addr
, dc
->mem_idx
);
4692 case 0xa: /* ldsh, load signed halfword */
4693 gen_address_mask(dc
, cpu_addr
);
4694 tcg_gen_qemu_ld16s(cpu_val
, cpu_addr
, dc
->mem_idx
);
4696 case 0xd: /* ldstub -- XXX: should be atomically */
4700 gen_address_mask(dc
, cpu_addr
);
4701 tcg_gen_qemu_ld8s(cpu_val
, cpu_addr
, dc
->mem_idx
);
4702 r_const
= tcg_const_tl(0xff);
4703 tcg_gen_qemu_st8(r_const
, cpu_addr
, dc
->mem_idx
);
4704 tcg_temp_free(r_const
);
4708 /* swap, swap register with memory. Also atomically */
4710 TCGv t0
= get_temp_tl(dc
);
4711 CHECK_IU_FEATURE(dc
, SWAP
);
4712 cpu_src1
= gen_load_gpr(dc
, rd
);
4713 gen_address_mask(dc
, cpu_addr
);
4714 tcg_gen_qemu_ld32u(t0
, cpu_addr
, dc
->mem_idx
);
4715 tcg_gen_qemu_st32(cpu_src1
, cpu_addr
, dc
->mem_idx
);
4716 tcg_gen_mov_tl(cpu_val
, t0
);
4719 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
4720 case 0x10: /* lda, V9 lduwa, load word alternate */
4721 #ifndef TARGET_SPARC64
4724 if (!supervisor(dc
))
4728 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 4, 0);
4730 case 0x11: /* lduba, load unsigned byte alternate */
4731 #ifndef TARGET_SPARC64
4734 if (!supervisor(dc
))
4738 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 1, 0);
4740 case 0x12: /* lduha, load unsigned halfword alternate */
4741 #ifndef TARGET_SPARC64
4744 if (!supervisor(dc
))
4748 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 2, 0);
4750 case 0x13: /* ldda, load double word alternate */
4751 #ifndef TARGET_SPARC64
4754 if (!supervisor(dc
))
4760 gen_ldda_asi(dc
, cpu_val
, cpu_addr
, insn
, rd
);
4762 case 0x19: /* ldsba, load signed byte alternate */
4763 #ifndef TARGET_SPARC64
4766 if (!supervisor(dc
))
4770 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 1, 1);
4772 case 0x1a: /* ldsha, load signed halfword alternate */
4773 #ifndef TARGET_SPARC64
4776 if (!supervisor(dc
))
4780 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 2, 1);
4782 case 0x1d: /* ldstuba -- XXX: should be atomically */
4783 #ifndef TARGET_SPARC64
4786 if (!supervisor(dc
))
4790 gen_ldstub_asi(cpu_val
, cpu_addr
, insn
);
4792 case 0x1f: /* swapa, swap reg with alt. memory. Also
4794 CHECK_IU_FEATURE(dc
, SWAP
);
4795 #ifndef TARGET_SPARC64
4798 if (!supervisor(dc
))
4802 cpu_src1
= gen_load_gpr(dc
, rd
);
4803 gen_swap_asi(cpu_val
, cpu_src1
, cpu_addr
, insn
);
4806 #ifndef TARGET_SPARC64
4807 case 0x30: /* ldc */
4808 case 0x31: /* ldcsr */
4809 case 0x33: /* lddc */
4813 #ifdef TARGET_SPARC64
4814 case 0x08: /* V9 ldsw */
4815 gen_address_mask(dc
, cpu_addr
);
4816 tcg_gen_qemu_ld32s(cpu_val
, cpu_addr
, dc
->mem_idx
);
4818 case 0x0b: /* V9 ldx */
4819 gen_address_mask(dc
, cpu_addr
);
4820 tcg_gen_qemu_ld64(cpu_val
, cpu_addr
, dc
->mem_idx
);
4822 case 0x18: /* V9 ldswa */
4824 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 4, 1);
4826 case 0x1b: /* V9 ldxa */
4828 gen_ld_asi(cpu_val
, cpu_addr
, insn
, 8, 0);
4830 case 0x2d: /* V9 prefetch, no effect */
4832 case 0x30: /* V9 ldfa */
4833 if (gen_trap_ifnofpu(dc
)) {
4837 gen_ldf_asi(cpu_addr
, insn
, 4, rd
);
4838 gen_update_fprs_dirty(rd
);
4840 case 0x33: /* V9 lddfa */
4841 if (gen_trap_ifnofpu(dc
)) {
4845 gen_ldf_asi(cpu_addr
, insn
, 8, DFPREG(rd
));
4846 gen_update_fprs_dirty(DFPREG(rd
));
4848 case 0x3d: /* V9 prefetcha, no effect */
4850 case 0x32: /* V9 ldqfa */
4851 CHECK_FPU_FEATURE(dc
, FLOAT128
);
4852 if (gen_trap_ifnofpu(dc
)) {
4856 gen_ldf_asi(cpu_addr
, insn
, 16, QFPREG(rd
));
4857 gen_update_fprs_dirty(QFPREG(rd
));
4863 gen_store_gpr(dc
, rd
, cpu_val
);
4864 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
4867 } else if (xop
>= 0x20 && xop
< 0x24) {
4870 if (gen_trap_ifnofpu(dc
)) {
4875 case 0x20: /* ldf, load fpreg */
4876 gen_address_mask(dc
, cpu_addr
);
4877 t0
= get_temp_tl(dc
);
4878 tcg_gen_qemu_ld32u(t0
, cpu_addr
, dc
->mem_idx
);
4879 cpu_dst_32
= gen_dest_fpr_F(dc
);
4880 tcg_gen_trunc_tl_i32(cpu_dst_32
, t0
);
4881 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
4883 case 0x21: /* ldfsr, V9 ldxfsr */
4884 #ifdef TARGET_SPARC64
4885 gen_address_mask(dc
, cpu_addr
);
4887 TCGv_i64 t64
= tcg_temp_new_i64();
4888 tcg_gen_qemu_ld64(t64
, cpu_addr
, dc
->mem_idx
);
4889 gen_helper_ldxfsr(cpu_env
, t64
);
4890 tcg_temp_free_i64(t64
);
4894 cpu_dst_32
= get_temp_i32(dc
);
4895 t0
= get_temp_tl(dc
);
4896 tcg_gen_qemu_ld32u(t0
, cpu_addr
, dc
->mem_idx
);
4897 tcg_gen_trunc_tl_i32(cpu_dst_32
, t0
);
4898 gen_helper_ldfsr(cpu_env
, cpu_dst_32
);
4900 case 0x22: /* ldqf, load quad fpreg */
4904 CHECK_FPU_FEATURE(dc
, FLOAT128
);
4905 r_const
= tcg_const_i32(dc
->mem_idx
);
4906 gen_address_mask(dc
, cpu_addr
);
4907 gen_helper_ldqf(cpu_env
, cpu_addr
, r_const
);
4908 tcg_temp_free_i32(r_const
);
4909 gen_op_store_QT0_fpr(QFPREG(rd
));
4910 gen_update_fprs_dirty(QFPREG(rd
));
4913 case 0x23: /* lddf, load double fpreg */
4914 gen_address_mask(dc
, cpu_addr
);
4915 cpu_dst_64
= gen_dest_fpr_D(dc
, rd
);
4916 tcg_gen_qemu_ld64(cpu_dst_64
, cpu_addr
, dc
->mem_idx
);
4917 gen_store_fpr_D(dc
, rd
, cpu_dst_64
);
4922 } else if (xop
< 8 || (xop
>= 0x14 && xop
< 0x18) ||
4923 xop
== 0xe || xop
== 0x1e) {
4924 TCGv cpu_val
= gen_load_gpr(dc
, rd
);
4927 case 0x4: /* st, store word */
4928 gen_address_mask(dc
, cpu_addr
);
4929 tcg_gen_qemu_st32(cpu_val
, cpu_addr
, dc
->mem_idx
);
4931 case 0x5: /* stb, store byte */
4932 gen_address_mask(dc
, cpu_addr
);
4933 tcg_gen_qemu_st8(cpu_val
, cpu_addr
, dc
->mem_idx
);
4935 case 0x6: /* sth, store halfword */
4936 gen_address_mask(dc
, cpu_addr
);
4937 tcg_gen_qemu_st16(cpu_val
, cpu_addr
, dc
->mem_idx
);
4939 case 0x7: /* std, store double word */
4948 gen_address_mask(dc
, cpu_addr
);
4949 r_const
= tcg_const_i32(7);
4950 /* XXX remove alignment check */
4951 gen_helper_check_align(cpu_env
, cpu_addr
, r_const
);
4952 tcg_temp_free_i32(r_const
);
4953 lo
= gen_load_gpr(dc
, rd
+ 1);
4955 t64
= tcg_temp_new_i64();
4956 tcg_gen_concat_tl_i64(t64
, lo
, cpu_val
);
4957 tcg_gen_qemu_st64(t64
, cpu_addr
, dc
->mem_idx
);
4958 tcg_temp_free_i64(t64
);
4961 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
4962 case 0x14: /* sta, V9 stwa, store word alternate */
4963 #ifndef TARGET_SPARC64
4966 if (!supervisor(dc
))
4970 gen_st_asi(cpu_val
, cpu_addr
, insn
, 4);
4971 dc
->npc
= DYNAMIC_PC
;
4973 case 0x15: /* stba, store byte alternate */
4974 #ifndef TARGET_SPARC64
4977 if (!supervisor(dc
))
4981 gen_st_asi(cpu_val
, cpu_addr
, insn
, 1);
4982 dc
->npc
= DYNAMIC_PC
;
4984 case 0x16: /* stha, store halfword alternate */
4985 #ifndef TARGET_SPARC64
4988 if (!supervisor(dc
))
4992 gen_st_asi(cpu_val
, cpu_addr
, insn
, 2);
4993 dc
->npc
= DYNAMIC_PC
;
4995 case 0x17: /* stda, store double word alternate */
4996 #ifndef TARGET_SPARC64
4999 if (!supervisor(dc
))
5006 gen_stda_asi(dc
, cpu_val
, cpu_addr
, insn
, rd
);
5010 #ifdef TARGET_SPARC64
5011 case 0x0e: /* V9 stx */
5012 gen_address_mask(dc
, cpu_addr
);
5013 tcg_gen_qemu_st64(cpu_val
, cpu_addr
, dc
->mem_idx
);
5015 case 0x1e: /* V9 stxa */
5017 gen_st_asi(cpu_val
, cpu_addr
, insn
, 8);
5018 dc
->npc
= DYNAMIC_PC
;
5024 } else if (xop
> 0x23 && xop
< 0x28) {
5025 if (gen_trap_ifnofpu(dc
)) {
5030 case 0x24: /* stf, store fpreg */
5032 TCGv t
= get_temp_tl(dc
);
5033 gen_address_mask(dc
, cpu_addr
);
5034 cpu_src1_32
= gen_load_fpr_F(dc
, rd
);
5035 tcg_gen_ext_i32_tl(t
, cpu_src1_32
);
5036 tcg_gen_qemu_st32(t
, cpu_addr
, dc
->mem_idx
);
5039 case 0x25: /* stfsr, V9 stxfsr */
5041 TCGv t
= get_temp_tl(dc
);
5043 tcg_gen_ld_tl(t
, cpu_env
, offsetof(CPUSPARCState
, fsr
));
5044 #ifdef TARGET_SPARC64
5045 gen_address_mask(dc
, cpu_addr
);
5047 tcg_gen_qemu_st64(t
, cpu_addr
, dc
->mem_idx
);
5051 tcg_gen_qemu_st32(t
, cpu_addr
, dc
->mem_idx
);
5055 #ifdef TARGET_SPARC64
5056 /* V9 stqf, store quad fpreg */
5060 CHECK_FPU_FEATURE(dc
, FLOAT128
);
5061 gen_op_load_fpr_QT0(QFPREG(rd
));
5062 r_const
= tcg_const_i32(dc
->mem_idx
);
5063 gen_address_mask(dc
, cpu_addr
);
5064 gen_helper_stqf(cpu_env
, cpu_addr
, r_const
);
5065 tcg_temp_free_i32(r_const
);
5068 #else /* !TARGET_SPARC64 */
5069 /* stdfq, store floating point queue */
5070 #if defined(CONFIG_USER_ONLY)
5073 if (!supervisor(dc
))
5075 if (gen_trap_ifnofpu(dc
)) {
5081 case 0x27: /* stdf, store double fpreg */
5082 gen_address_mask(dc
, cpu_addr
);
5083 cpu_src1_64
= gen_load_fpr_D(dc
, rd
);
5084 tcg_gen_qemu_st64(cpu_src1_64
, cpu_addr
, dc
->mem_idx
);
5089 } else if (xop
> 0x33 && xop
< 0x3f) {
5092 #ifdef TARGET_SPARC64
5093 case 0x34: /* V9 stfa */
5094 if (gen_trap_ifnofpu(dc
)) {
5097 gen_stf_asi(cpu_addr
, insn
, 4, rd
);
5099 case 0x36: /* V9 stqfa */
5103 CHECK_FPU_FEATURE(dc
, FLOAT128
);
5104 if (gen_trap_ifnofpu(dc
)) {
5107 r_const
= tcg_const_i32(7);
5108 gen_helper_check_align(cpu_env
, cpu_addr
, r_const
);
5109 tcg_temp_free_i32(r_const
);
5110 gen_stf_asi(cpu_addr
, insn
, 16, QFPREG(rd
));
5113 case 0x37: /* V9 stdfa */
5114 if (gen_trap_ifnofpu(dc
)) {
5117 gen_stf_asi(cpu_addr
, insn
, 8, DFPREG(rd
));
5119 case 0x3c: /* V9 casa */
5120 rs2
= GET_FIELD(insn
, 27, 31);
5121 cpu_src2
= gen_load_gpr(dc
, rs2
);
5122 gen_cas_asi(dc
, cpu_addr
, cpu_src2
, insn
, rd
);
5124 case 0x3e: /* V9 casxa */
5125 rs2
= GET_FIELD(insn
, 27, 31);
5126 cpu_src2
= gen_load_gpr(dc
, rs2
);
5127 gen_casx_asi(dc
, cpu_addr
, cpu_src2
, insn
, rd
);
5130 case 0x34: /* stc */
5131 case 0x35: /* stcsr */
5132 case 0x36: /* stdcq */
5133 case 0x37: /* stdc */
5145 /* default case for non jump instructions */
5146 if (dc
->npc
== DYNAMIC_PC
) {
5147 dc
->pc
= DYNAMIC_PC
;
5149 } else if (dc
->npc
== JUMP_PC
) {
5150 /* we can do a static jump */
5151 gen_branch2(dc
, dc
->jump_pc
[0], dc
->jump_pc
[1], cpu_cond
);
5155 dc
->npc
= dc
->npc
+ 4;
5164 r_const
= tcg_const_i32(TT_ILL_INSN
);
5165 gen_helper_raise_exception(cpu_env
, r_const
);
5166 tcg_temp_free_i32(r_const
);
5175 r_const
= tcg_const_i32(TT_UNIMP_FLUSH
);
5176 gen_helper_raise_exception(cpu_env
, r_const
);
5177 tcg_temp_free_i32(r_const
);
5181 #if !defined(CONFIG_USER_ONLY)
5187 r_const
= tcg_const_i32(TT_PRIV_INSN
);
5188 gen_helper_raise_exception(cpu_env
, r_const
);
5189 tcg_temp_free_i32(r_const
);
5196 gen_op_fpexception_im(FSR_FTT_UNIMPFPOP
);
5199 #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
5202 gen_op_fpexception_im(FSR_FTT_SEQ_ERROR
);
5206 #ifndef TARGET_SPARC64
5212 r_const
= tcg_const_i32(TT_NCP_INSN
);
5213 gen_helper_raise_exception(cpu_env
, r_const
);
5214 tcg_temp_free(r_const
);
5220 if (dc
->n_t32
!= 0) {
5222 for (i
= dc
->n_t32
- 1; i
>= 0; --i
) {
5223 tcg_temp_free_i32(dc
->t32
[i
]);
5227 if (dc
->n_ttl
!= 0) {
5229 for (i
= dc
->n_ttl
- 1; i
>= 0; --i
) {
5230 tcg_temp_free(dc
->ttl
[i
]);
5236 static inline void gen_intermediate_code_internal(TranslationBlock
* tb
,
5237 int spc
, CPUSPARCState
*env
)
5239 target_ulong pc_start
, last_pc
;
5240 uint16_t *gen_opc_end
;
5241 DisasContext dc1
, *dc
= &dc1
;
5248 memset(dc
, 0, sizeof(DisasContext
));
5253 dc
->npc
= (target_ulong
) tb
->cs_base
;
5254 dc
->cc_op
= CC_OP_DYNAMIC
;
5255 dc
->mem_idx
= cpu_mmu_index(env
);
5257 dc
->fpu_enabled
= tb_fpu_enabled(tb
->flags
);
5258 dc
->address_mask_32bit
= tb_am_enabled(tb
->flags
);
5259 dc
->singlestep
= (env
->singlestep_enabled
|| singlestep
);
5260 gen_opc_end
= tcg_ctx
.gen_opc_buf
+ OPC_MAX_SIZE
;
5263 max_insns
= tb
->cflags
& CF_COUNT_MASK
;
5265 max_insns
= CF_COUNT_MASK
;
5268 if (unlikely(!QTAILQ_EMPTY(&env
->breakpoints
))) {
5269 QTAILQ_FOREACH(bp
, &env
->breakpoints
, entry
) {
5270 if (bp
->pc
== dc
->pc
) {
5271 if (dc
->pc
!= pc_start
)
5273 gen_helper_debug(cpu_env
);
5281 qemu_log("Search PC...\n");
5282 j
= tcg_ctx
.gen_opc_ptr
- tcg_ctx
.gen_opc_buf
;
5286 gen_opc_instr_start
[lj
++] = 0;
5287 gen_opc_pc
[lj
] = dc
->pc
;
5288 gen_opc_npc
[lj
] = dc
->npc
;
5289 gen_opc_instr_start
[lj
] = 1;
5290 gen_opc_icount
[lj
] = num_insns
;
5293 if (num_insns
+ 1 == max_insns
&& (tb
->cflags
& CF_LAST_IO
))
5296 insn
= cpu_ldl_code(env
, dc
->pc
);
5298 disas_sparc_insn(dc
, insn
);
5303 /* if the next PC is different, we abort now */
5304 if (dc
->pc
!= (last_pc
+ 4))
5306 /* if we reach a page boundary, we stop generation so that the
5307 PC of a TT_TFAULT exception is always in the right page */
5308 if ((dc
->pc
& (TARGET_PAGE_SIZE
- 1)) == 0)
5310 /* if single step mode, we generate only one instruction and
5311 generate an exception */
5312 if (dc
->singlestep
) {
5315 } while ((tcg_ctx
.gen_opc_ptr
< gen_opc_end
) &&
5316 (dc
->pc
- pc_start
) < (TARGET_PAGE_SIZE
- 32) &&
5317 num_insns
< max_insns
);
5320 if (tb
->cflags
& CF_LAST_IO
) {
5324 if (dc
->pc
!= DYNAMIC_PC
&&
5325 (dc
->npc
!= DYNAMIC_PC
&& dc
->npc
!= JUMP_PC
)) {
5326 /* static PC and NPC: we can use direct chaining */
5327 gen_goto_tb(dc
, 0, dc
->pc
, dc
->npc
);
5329 if (dc
->pc
!= DYNAMIC_PC
) {
5330 tcg_gen_movi_tl(cpu_pc
, dc
->pc
);
5336 gen_icount_end(tb
, num_insns
);
5337 *tcg_ctx
.gen_opc_ptr
= INDEX_op_end
;
5339 j
= tcg_ctx
.gen_opc_ptr
- tcg_ctx
.gen_opc_buf
;
5342 gen_opc_instr_start
[lj
++] = 0;
5346 gen_opc_jump_pc
[0] = dc
->jump_pc
[0];
5347 gen_opc_jump_pc
[1] = dc
->jump_pc
[1];
5349 tb
->size
= last_pc
+ 4 - pc_start
;
5350 tb
->icount
= num_insns
;
5353 if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM
)) {
5354 qemu_log("--------------\n");
5355 qemu_log("IN: %s\n", lookup_symbol(pc_start
));
5356 log_target_disas(env
, pc_start
, last_pc
+ 4 - pc_start
, 0);
5362 void gen_intermediate_code(CPUSPARCState
* env
, TranslationBlock
* tb
)
5364 gen_intermediate_code_internal(tb
, 0, env
);
5367 void gen_intermediate_code_pc(CPUSPARCState
* env
, TranslationBlock
* tb
)
5369 gen_intermediate_code_internal(tb
, 1, env
);
5372 void gen_intermediate_code_init(CPUSPARCState
*env
)
5376 static const char * const gregnames
[8] = {
5377 NULL
, // g0 not used
5386 static const char * const fregnames
[32] = {
5387 "f0", "f2", "f4", "f6", "f8", "f10", "f12", "f14",
5388 "f16", "f18", "f20", "f22", "f24", "f26", "f28", "f30",
5389 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",
5390 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",
5393 /* init various static tables */
5397 cpu_env
= tcg_global_reg_new_ptr(TCG_AREG0
, "env");
5398 cpu_regwptr
= tcg_global_mem_new_ptr(TCG_AREG0
,
5399 offsetof(CPUSPARCState
, regwptr
),
5401 #ifdef TARGET_SPARC64
5402 cpu_xcc
= tcg_global_mem_new_i32(TCG_AREG0
, offsetof(CPUSPARCState
, xcc
),
5404 cpu_asi
= tcg_global_mem_new_i32(TCG_AREG0
, offsetof(CPUSPARCState
, asi
),
5406 cpu_fprs
= tcg_global_mem_new_i32(TCG_AREG0
, offsetof(CPUSPARCState
, fprs
),
5408 cpu_gsr
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, gsr
),
5410 cpu_tick_cmpr
= tcg_global_mem_new(TCG_AREG0
,
5411 offsetof(CPUSPARCState
, tick_cmpr
),
5413 cpu_stick_cmpr
= tcg_global_mem_new(TCG_AREG0
,
5414 offsetof(CPUSPARCState
, stick_cmpr
),
5416 cpu_hstick_cmpr
= tcg_global_mem_new(TCG_AREG0
,
5417 offsetof(CPUSPARCState
, hstick_cmpr
),
5419 cpu_hintp
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, hintp
),
5421 cpu_htba
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, htba
),
5423 cpu_hver
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, hver
),
5425 cpu_ssr
= tcg_global_mem_new(TCG_AREG0
,
5426 offsetof(CPUSPARCState
, ssr
), "ssr");
5427 cpu_ver
= tcg_global_mem_new(TCG_AREG0
,
5428 offsetof(CPUSPARCState
, version
), "ver");
5429 cpu_softint
= tcg_global_mem_new_i32(TCG_AREG0
,
5430 offsetof(CPUSPARCState
, softint
),
5433 cpu_wim
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, wim
),
5436 cpu_cond
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, cond
),
5438 cpu_cc_src
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, cc_src
),
5440 cpu_cc_src2
= tcg_global_mem_new(TCG_AREG0
,
5441 offsetof(CPUSPARCState
, cc_src2
),
5443 cpu_cc_dst
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, cc_dst
),
5445 cpu_cc_op
= tcg_global_mem_new_i32(TCG_AREG0
, offsetof(CPUSPARCState
, cc_op
),
5447 cpu_psr
= tcg_global_mem_new_i32(TCG_AREG0
, offsetof(CPUSPARCState
, psr
),
5449 cpu_fsr
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, fsr
),
5451 cpu_pc
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, pc
),
5453 cpu_npc
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, npc
),
5455 cpu_y
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, y
), "y");
5456 #ifndef CONFIG_USER_ONLY
5457 cpu_tbr
= tcg_global_mem_new(TCG_AREG0
, offsetof(CPUSPARCState
, tbr
),
5460 for (i
= 1; i
< 8; i
++) {
5461 cpu_gregs
[i
] = tcg_global_mem_new(TCG_AREG0
,
5462 offsetof(CPUSPARCState
, gregs
[i
]),
5465 for (i
= 0; i
< TARGET_DPREGS
; i
++) {
5466 cpu_fpr
[i
] = tcg_global_mem_new_i64(TCG_AREG0
,
5467 offsetof(CPUSPARCState
, fpr
[i
]),
5471 /* register helpers */
5473 #define GEN_HELPER 2
5478 void restore_state_to_opc(CPUSPARCState
*env
, TranslationBlock
*tb
, int pc_pos
)
5481 env
->pc
= gen_opc_pc
[pc_pos
];
5482 npc
= gen_opc_npc
[pc_pos
];
5484 /* dynamic NPC: already stored */
5485 } else if (npc
== 2) {
5486 /* jump PC: use 'cond' and the jump targets of the translation */
5488 env
->npc
= gen_opc_jump_pc
[0];
5490 env
->npc
= gen_opc_jump_pc
[1];