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.1 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/>.
21 #include "qemu/osdep.h"
24 #include "disas/disas.h"
25 #include "exec/helper-proto.h"
26 #include "exec/exec-all.h"
27 #include "tcg/tcg-op.h"
28 #include "exec/cpu_ldst.h"
30 #include "exec/helper-gen.h"
32 #include "exec/translator.h"
39 #define DYNAMIC_PC 1 /* dynamic pc value */
40 #define JUMP_PC 2 /* dynamic pc value which takes only two values
41 according to jump_pc[T2] */
43 #define DISAS_EXIT DISAS_TARGET_0
45 /* global register indexes */
46 static TCGv_ptr cpu_regwptr
;
47 static TCGv cpu_cc_src
, cpu_cc_src2
, cpu_cc_dst
;
48 static TCGv_i32 cpu_cc_op
;
49 static TCGv_i32 cpu_psr
;
50 static TCGv cpu_fsr
, cpu_pc
, cpu_npc
;
51 static TCGv cpu_regs
[32];
53 #ifndef CONFIG_USER_ONLY
58 static TCGv_i32 cpu_xcc
, cpu_fprs
;
60 static TCGv cpu_tick_cmpr
, cpu_stick_cmpr
, cpu_hstick_cmpr
;
61 static TCGv cpu_hintp
, cpu_htba
, cpu_hver
, cpu_ssr
, cpu_ver
;
65 /* Floating point registers */
66 static TCGv_i64 cpu_fpr
[TARGET_DPREGS
];
68 #include "exec/gen-icount.h"
70 typedef struct DisasContext
{
71 DisasContextBase base
;
72 target_ulong pc
; /* current Program Counter: integer or DYNAMIC_PC */
73 target_ulong npc
; /* next PC: integer or DYNAMIC_PC or JUMP_PC */
74 target_ulong jump_pc
[2]; /* used when JUMP_PC pc value is used */
77 bool address_mask_32bit
;
78 #ifndef CONFIG_USER_ONLY
85 uint32_t cc_op
; /* current CC operation */
104 // This function uses non-native bit order
105 #define GET_FIELD(X, FROM, TO) \
106 ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
108 // This function uses the order in the manuals, i.e. bit 0 is 2^0
109 #define GET_FIELD_SP(X, FROM, TO) \
110 GET_FIELD(X, 31 - (TO), 31 - (FROM))
112 #define GET_FIELDs(x,a,b) sign_extend (GET_FIELD(x,a,b), (b) - (a) + 1)
113 #define GET_FIELD_SPs(x,a,b) sign_extend (GET_FIELD_SP(x,a,b), ((b) - (a) + 1))
115 #ifdef TARGET_SPARC64
116 #define DFPREG(r) (((r & 1) << 5) | (r & 0x1e))
117 #define QFPREG(r) (((r & 1) << 5) | (r & 0x1c))
119 #define DFPREG(r) (r & 0x1e)
120 #define QFPREG(r) (r & 0x1c)
123 #define UA2005_HTRAP_MASK 0xff
124 #define V8_TRAP_MASK 0x7f
126 static int sign_extend(int x
, int len
)
129 return (x
<< len
) >> len
;
132 #define IS_IMM (insn & (1<<13))
134 static inline TCGv_i32
get_temp_i32(DisasContext
*dc
)
137 assert(dc
->n_t32
< ARRAY_SIZE(dc
->t32
));
138 dc
->t32
[dc
->n_t32
++] = t
= tcg_temp_new_i32();
142 static inline TCGv
get_temp_tl(DisasContext
*dc
)
145 assert(dc
->n_ttl
< ARRAY_SIZE(dc
->ttl
));
146 dc
->ttl
[dc
->n_ttl
++] = t
= tcg_temp_new();
150 static inline void gen_update_fprs_dirty(DisasContext
*dc
, int rd
)
152 #if defined(TARGET_SPARC64)
153 int bit
= (rd
< 32) ? 1 : 2;
154 /* If we know we've already set this bit within the TB,
155 we can avoid setting it again. */
156 if (!(dc
->fprs_dirty
& bit
)) {
157 dc
->fprs_dirty
|= bit
;
158 tcg_gen_ori_i32(cpu_fprs
, cpu_fprs
, bit
);
163 /* floating point registers moves */
164 static TCGv_i32
gen_load_fpr_F(DisasContext
*dc
, unsigned int src
)
166 #if TCG_TARGET_REG_BITS == 32
168 return TCGV_LOW(cpu_fpr
[src
/ 2]);
170 return TCGV_HIGH(cpu_fpr
[src
/ 2]);
173 TCGv_i32 ret
= get_temp_i32(dc
);
175 tcg_gen_extrl_i64_i32(ret
, cpu_fpr
[src
/ 2]);
177 tcg_gen_extrh_i64_i32(ret
, cpu_fpr
[src
/ 2]);
183 static void gen_store_fpr_F(DisasContext
*dc
, unsigned int dst
, TCGv_i32 v
)
185 #if TCG_TARGET_REG_BITS == 32
187 tcg_gen_mov_i32(TCGV_LOW(cpu_fpr
[dst
/ 2]), v
);
189 tcg_gen_mov_i32(TCGV_HIGH(cpu_fpr
[dst
/ 2]), v
);
192 TCGv_i64 t
= (TCGv_i64
)v
;
193 tcg_gen_deposit_i64(cpu_fpr
[dst
/ 2], cpu_fpr
[dst
/ 2], t
,
194 (dst
& 1 ? 0 : 32), 32);
196 gen_update_fprs_dirty(dc
, dst
);
199 static TCGv_i32
gen_dest_fpr_F(DisasContext
*dc
)
201 return get_temp_i32(dc
);
204 static TCGv_i64
gen_load_fpr_D(DisasContext
*dc
, unsigned int src
)
207 return cpu_fpr
[src
/ 2];
210 static void gen_store_fpr_D(DisasContext
*dc
, unsigned int dst
, TCGv_i64 v
)
213 tcg_gen_mov_i64(cpu_fpr
[dst
/ 2], v
);
214 gen_update_fprs_dirty(dc
, dst
);
217 static TCGv_i64
gen_dest_fpr_D(DisasContext
*dc
, unsigned int dst
)
219 return cpu_fpr
[DFPREG(dst
) / 2];
222 static void gen_op_load_fpr_QT0(unsigned int src
)
224 tcg_gen_st_i64(cpu_fpr
[src
/ 2], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
225 offsetof(CPU_QuadU
, ll
.upper
));
226 tcg_gen_st_i64(cpu_fpr
[src
/2 + 1], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
227 offsetof(CPU_QuadU
, ll
.lower
));
230 static void gen_op_load_fpr_QT1(unsigned int src
)
232 tcg_gen_st_i64(cpu_fpr
[src
/ 2], cpu_env
, offsetof(CPUSPARCState
, qt1
) +
233 offsetof(CPU_QuadU
, ll
.upper
));
234 tcg_gen_st_i64(cpu_fpr
[src
/2 + 1], cpu_env
, offsetof(CPUSPARCState
, qt1
) +
235 offsetof(CPU_QuadU
, ll
.lower
));
238 static void gen_op_store_QT0_fpr(unsigned int dst
)
240 tcg_gen_ld_i64(cpu_fpr
[dst
/ 2], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
241 offsetof(CPU_QuadU
, ll
.upper
));
242 tcg_gen_ld_i64(cpu_fpr
[dst
/2 + 1], cpu_env
, offsetof(CPUSPARCState
, qt0
) +
243 offsetof(CPU_QuadU
, ll
.lower
));
246 static void gen_store_fpr_Q(DisasContext
*dc
, unsigned int dst
,
247 TCGv_i64 v1
, TCGv_i64 v2
)
251 tcg_gen_mov_i64(cpu_fpr
[dst
/ 2], v1
);
252 tcg_gen_mov_i64(cpu_fpr
[dst
/ 2 + 1], v2
);
253 gen_update_fprs_dirty(dc
, dst
);
256 #ifdef TARGET_SPARC64
257 static TCGv_i64
gen_load_fpr_Q0(DisasContext
*dc
, unsigned int src
)
260 return cpu_fpr
[src
/ 2];
263 static TCGv_i64
gen_load_fpr_Q1(DisasContext
*dc
, unsigned int src
)
266 return cpu_fpr
[src
/ 2 + 1];
269 static void gen_move_Q(DisasContext
*dc
, unsigned int rd
, unsigned int rs
)
274 tcg_gen_mov_i64(cpu_fpr
[rd
/ 2], cpu_fpr
[rs
/ 2]);
275 tcg_gen_mov_i64(cpu_fpr
[rd
/ 2 + 1], cpu_fpr
[rs
/ 2 + 1]);
276 gen_update_fprs_dirty(dc
, rd
);
281 #ifdef CONFIG_USER_ONLY
282 #define supervisor(dc) 0
283 #ifdef TARGET_SPARC64
284 #define hypervisor(dc) 0
287 #ifdef TARGET_SPARC64
288 #define hypervisor(dc) (dc->hypervisor)
289 #define supervisor(dc) (dc->supervisor | dc->hypervisor)
291 #define supervisor(dc) (dc->supervisor)
295 #ifdef TARGET_SPARC64
297 #define AM_CHECK(dc) ((dc)->address_mask_32bit)
299 #define AM_CHECK(dc) (1)
303 static inline void gen_address_mask(DisasContext
*dc
, TCGv addr
)
305 #ifdef TARGET_SPARC64
307 tcg_gen_andi_tl(addr
, addr
, 0xffffffffULL
);
311 static inline TCGv
gen_load_gpr(DisasContext
*dc
, int reg
)
315 return cpu_regs
[reg
];
317 TCGv t
= get_temp_tl(dc
);
318 tcg_gen_movi_tl(t
, 0);
323 static inline void gen_store_gpr(DisasContext
*dc
, int reg
, TCGv v
)
327 tcg_gen_mov_tl(cpu_regs
[reg
], v
);
331 static inline TCGv
gen_dest_gpr(DisasContext
*dc
, int reg
)
335 return cpu_regs
[reg
];
337 return get_temp_tl(dc
);
341 static bool use_goto_tb(DisasContext
*s
, target_ulong pc
, target_ulong npc
)
343 return translator_use_goto_tb(&s
->base
, pc
) &&
344 translator_use_goto_tb(&s
->base
, npc
);
347 static void gen_goto_tb(DisasContext
*s
, int tb_num
,
348 target_ulong pc
, target_ulong npc
)
350 if (use_goto_tb(s
, pc
, npc
)) {
351 /* jump to same page: we can use a direct jump */
352 tcg_gen_goto_tb(tb_num
);
353 tcg_gen_movi_tl(cpu_pc
, pc
);
354 tcg_gen_movi_tl(cpu_npc
, npc
);
355 tcg_gen_exit_tb(s
->base
.tb
, tb_num
);
357 /* jump to another page: currently not optimized */
358 tcg_gen_movi_tl(cpu_pc
, pc
);
359 tcg_gen_movi_tl(cpu_npc
, npc
);
360 tcg_gen_exit_tb(NULL
, 0);
365 static inline void gen_mov_reg_N(TCGv reg
, TCGv_i32 src
)
367 tcg_gen_extu_i32_tl(reg
, src
);
368 tcg_gen_extract_tl(reg
, reg
, PSR_NEG_SHIFT
, 1);
371 static inline void gen_mov_reg_Z(TCGv reg
, TCGv_i32 src
)
373 tcg_gen_extu_i32_tl(reg
, src
);
374 tcg_gen_extract_tl(reg
, reg
, PSR_ZERO_SHIFT
, 1);
377 static inline void gen_mov_reg_V(TCGv reg
, TCGv_i32 src
)
379 tcg_gen_extu_i32_tl(reg
, src
);
380 tcg_gen_extract_tl(reg
, reg
, PSR_OVF_SHIFT
, 1);
383 static inline void gen_mov_reg_C(TCGv reg
, TCGv_i32 src
)
385 tcg_gen_extu_i32_tl(reg
, src
);
386 tcg_gen_extract_tl(reg
, reg
, PSR_CARRY_SHIFT
, 1);
389 static inline void gen_op_add_cc(TCGv dst
, TCGv src1
, TCGv src2
)
391 tcg_gen_mov_tl(cpu_cc_src
, src1
);
392 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
393 tcg_gen_add_tl(cpu_cc_dst
, cpu_cc_src
, cpu_cc_src2
);
394 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
397 static TCGv_i32
gen_add32_carry32(void)
399 TCGv_i32 carry_32
, cc_src1_32
, cc_src2_32
;
401 /* Carry is computed from a previous add: (dst < src) */
402 #if TARGET_LONG_BITS == 64
403 cc_src1_32
= tcg_temp_new_i32();
404 cc_src2_32
= tcg_temp_new_i32();
405 tcg_gen_extrl_i64_i32(cc_src1_32
, cpu_cc_dst
);
406 tcg_gen_extrl_i64_i32(cc_src2_32
, cpu_cc_src
);
408 cc_src1_32
= cpu_cc_dst
;
409 cc_src2_32
= cpu_cc_src
;
412 carry_32
= tcg_temp_new_i32();
413 tcg_gen_setcond_i32(TCG_COND_LTU
, carry_32
, cc_src1_32
, cc_src2_32
);
415 #if TARGET_LONG_BITS == 64
416 tcg_temp_free_i32(cc_src1_32
);
417 tcg_temp_free_i32(cc_src2_32
);
423 static TCGv_i32
gen_sub32_carry32(void)
425 TCGv_i32 carry_32
, cc_src1_32
, cc_src2_32
;
427 /* Carry is computed from a previous borrow: (src1 < src2) */
428 #if TARGET_LONG_BITS == 64
429 cc_src1_32
= tcg_temp_new_i32();
430 cc_src2_32
= tcg_temp_new_i32();
431 tcg_gen_extrl_i64_i32(cc_src1_32
, cpu_cc_src
);
432 tcg_gen_extrl_i64_i32(cc_src2_32
, cpu_cc_src2
);
434 cc_src1_32
= cpu_cc_src
;
435 cc_src2_32
= cpu_cc_src2
;
438 carry_32
= tcg_temp_new_i32();
439 tcg_gen_setcond_i32(TCG_COND_LTU
, carry_32
, cc_src1_32
, cc_src2_32
);
441 #if TARGET_LONG_BITS == 64
442 tcg_temp_free_i32(cc_src1_32
);
443 tcg_temp_free_i32(cc_src2_32
);
449 static void gen_op_addx_int(DisasContext
*dc
, TCGv dst
, TCGv src1
,
450 TCGv src2
, int update_cc
)
458 /* Carry is known to be zero. Fall back to plain ADD. */
460 gen_op_add_cc(dst
, src1
, src2
);
462 tcg_gen_add_tl(dst
, src1
, src2
);
469 if (TARGET_LONG_BITS
== 32) {
470 /* We can re-use the host's hardware carry generation by using
471 an ADD2 opcode. We discard the low part of the output.
472 Ideally we'd combine this operation with the add that
473 generated the carry in the first place. */
474 carry
= tcg_temp_new();
475 tcg_gen_add2_tl(carry
, dst
, cpu_cc_src
, src1
, cpu_cc_src2
, src2
);
476 tcg_temp_free(carry
);
479 carry_32
= gen_add32_carry32();
485 carry_32
= gen_sub32_carry32();
489 /* We need external help to produce the carry. */
490 carry_32
= tcg_temp_new_i32();
491 gen_helper_compute_C_icc(carry_32
, cpu_env
);
495 #if TARGET_LONG_BITS == 64
496 carry
= tcg_temp_new();
497 tcg_gen_extu_i32_i64(carry
, carry_32
);
502 tcg_gen_add_tl(dst
, src1
, src2
);
503 tcg_gen_add_tl(dst
, dst
, carry
);
505 tcg_temp_free_i32(carry_32
);
506 #if TARGET_LONG_BITS == 64
507 tcg_temp_free(carry
);
512 tcg_gen_mov_tl(cpu_cc_src
, src1
);
513 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
514 tcg_gen_mov_tl(cpu_cc_dst
, dst
);
515 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_ADDX
);
516 dc
->cc_op
= CC_OP_ADDX
;
520 static inline void gen_op_sub_cc(TCGv dst
, TCGv src1
, TCGv src2
)
522 tcg_gen_mov_tl(cpu_cc_src
, src1
);
523 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
524 tcg_gen_sub_tl(cpu_cc_dst
, cpu_cc_src
, cpu_cc_src2
);
525 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
528 static void gen_op_subx_int(DisasContext
*dc
, TCGv dst
, TCGv src1
,
529 TCGv src2
, int update_cc
)
537 /* Carry is known to be zero. Fall back to plain SUB. */
539 gen_op_sub_cc(dst
, src1
, src2
);
541 tcg_gen_sub_tl(dst
, src1
, src2
);
548 carry_32
= gen_add32_carry32();
554 if (TARGET_LONG_BITS
== 32) {
555 /* We can re-use the host's hardware carry generation by using
556 a SUB2 opcode. We discard the low part of the output.
557 Ideally we'd combine this operation with the add that
558 generated the carry in the first place. */
559 carry
= tcg_temp_new();
560 tcg_gen_sub2_tl(carry
, dst
, cpu_cc_src
, src1
, cpu_cc_src2
, src2
);
561 tcg_temp_free(carry
);
564 carry_32
= gen_sub32_carry32();
568 /* We need external help to produce the carry. */
569 carry_32
= tcg_temp_new_i32();
570 gen_helper_compute_C_icc(carry_32
, cpu_env
);
574 #if TARGET_LONG_BITS == 64
575 carry
= tcg_temp_new();
576 tcg_gen_extu_i32_i64(carry
, carry_32
);
581 tcg_gen_sub_tl(dst
, src1
, src2
);
582 tcg_gen_sub_tl(dst
, dst
, carry
);
584 tcg_temp_free_i32(carry_32
);
585 #if TARGET_LONG_BITS == 64
586 tcg_temp_free(carry
);
591 tcg_gen_mov_tl(cpu_cc_src
, src1
);
592 tcg_gen_mov_tl(cpu_cc_src2
, src2
);
593 tcg_gen_mov_tl(cpu_cc_dst
, dst
);
594 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUBX
);
595 dc
->cc_op
= CC_OP_SUBX
;
599 static inline void gen_op_mulscc(TCGv dst
, TCGv src1
, TCGv src2
)
601 TCGv r_temp
, zero
, t0
;
603 r_temp
= tcg_temp_new();
610 zero
= tcg_const_tl(0);
611 tcg_gen_andi_tl(cpu_cc_src
, src1
, 0xffffffff);
612 tcg_gen_andi_tl(r_temp
, cpu_y
, 0x1);
613 tcg_gen_andi_tl(cpu_cc_src2
, src2
, 0xffffffff);
614 tcg_gen_movcond_tl(TCG_COND_EQ
, cpu_cc_src2
, r_temp
, zero
,
619 // env->y = (b2 << 31) | (env->y >> 1);
620 tcg_gen_extract_tl(t0
, cpu_y
, 1, 31);
621 tcg_gen_deposit_tl(cpu_y
, t0
, cpu_cc_src
, 31, 1);
624 gen_mov_reg_N(t0
, cpu_psr
);
625 gen_mov_reg_V(r_temp
, cpu_psr
);
626 tcg_gen_xor_tl(t0
, t0
, r_temp
);
627 tcg_temp_free(r_temp
);
629 // T0 = (b1 << 31) | (T0 >> 1);
631 tcg_gen_shli_tl(t0
, t0
, 31);
632 tcg_gen_shri_tl(cpu_cc_src
, cpu_cc_src
, 1);
633 tcg_gen_or_tl(cpu_cc_src
, cpu_cc_src
, t0
);
636 tcg_gen_add_tl(cpu_cc_dst
, cpu_cc_src
, cpu_cc_src2
);
638 tcg_gen_mov_tl(dst
, cpu_cc_dst
);
641 static inline void gen_op_multiply(TCGv dst
, TCGv src1
, TCGv src2
, int sign_ext
)
643 #if TARGET_LONG_BITS == 32
645 tcg_gen_muls2_tl(dst
, cpu_y
, src1
, src2
);
647 tcg_gen_mulu2_tl(dst
, cpu_y
, src1
, src2
);
650 TCGv t0
= tcg_temp_new_i64();
651 TCGv t1
= tcg_temp_new_i64();
654 tcg_gen_ext32s_i64(t0
, src1
);
655 tcg_gen_ext32s_i64(t1
, src2
);
657 tcg_gen_ext32u_i64(t0
, src1
);
658 tcg_gen_ext32u_i64(t1
, src2
);
661 tcg_gen_mul_i64(dst
, t0
, t1
);
665 tcg_gen_shri_i64(cpu_y
, dst
, 32);
669 static inline void gen_op_umul(TCGv dst
, TCGv src1
, TCGv src2
)
671 /* zero-extend truncated operands before multiplication */
672 gen_op_multiply(dst
, src1
, src2
, 0);
675 static inline void gen_op_smul(TCGv dst
, TCGv src1
, TCGv src2
)
677 /* sign-extend truncated operands before multiplication */
678 gen_op_multiply(dst
, src1
, src2
, 1);
682 static inline void gen_op_eval_ba(TCGv dst
)
684 tcg_gen_movi_tl(dst
, 1);
688 static inline void gen_op_eval_be(TCGv dst
, TCGv_i32 src
)
690 gen_mov_reg_Z(dst
, src
);
694 static inline void gen_op_eval_ble(TCGv dst
, TCGv_i32 src
)
696 TCGv t0
= tcg_temp_new();
697 gen_mov_reg_N(t0
, src
);
698 gen_mov_reg_V(dst
, src
);
699 tcg_gen_xor_tl(dst
, dst
, t0
);
700 gen_mov_reg_Z(t0
, src
);
701 tcg_gen_or_tl(dst
, dst
, t0
);
706 static inline void gen_op_eval_bl(TCGv dst
, TCGv_i32 src
)
708 TCGv t0
= tcg_temp_new();
709 gen_mov_reg_V(t0
, src
);
710 gen_mov_reg_N(dst
, src
);
711 tcg_gen_xor_tl(dst
, dst
, t0
);
716 static inline void gen_op_eval_bleu(TCGv dst
, TCGv_i32 src
)
718 TCGv t0
= tcg_temp_new();
719 gen_mov_reg_Z(t0
, src
);
720 gen_mov_reg_C(dst
, src
);
721 tcg_gen_or_tl(dst
, dst
, t0
);
726 static inline void gen_op_eval_bcs(TCGv dst
, TCGv_i32 src
)
728 gen_mov_reg_C(dst
, src
);
732 static inline void gen_op_eval_bvs(TCGv dst
, TCGv_i32 src
)
734 gen_mov_reg_V(dst
, src
);
738 static inline void gen_op_eval_bn(TCGv dst
)
740 tcg_gen_movi_tl(dst
, 0);
744 static inline void gen_op_eval_bneg(TCGv dst
, TCGv_i32 src
)
746 gen_mov_reg_N(dst
, src
);
750 static inline void gen_op_eval_bne(TCGv dst
, TCGv_i32 src
)
752 gen_mov_reg_Z(dst
, src
);
753 tcg_gen_xori_tl(dst
, dst
, 0x1);
757 static inline void gen_op_eval_bg(TCGv dst
, TCGv_i32 src
)
759 gen_op_eval_ble(dst
, src
);
760 tcg_gen_xori_tl(dst
, dst
, 0x1);
764 static inline void gen_op_eval_bge(TCGv dst
, TCGv_i32 src
)
766 gen_op_eval_bl(dst
, src
);
767 tcg_gen_xori_tl(dst
, dst
, 0x1);
771 static inline void gen_op_eval_bgu(TCGv dst
, TCGv_i32 src
)
773 gen_op_eval_bleu(dst
, src
);
774 tcg_gen_xori_tl(dst
, dst
, 0x1);
778 static inline void gen_op_eval_bcc(TCGv dst
, TCGv_i32 src
)
780 gen_mov_reg_C(dst
, src
);
781 tcg_gen_xori_tl(dst
, dst
, 0x1);
785 static inline void gen_op_eval_bpos(TCGv dst
, TCGv_i32 src
)
787 gen_mov_reg_N(dst
, src
);
788 tcg_gen_xori_tl(dst
, dst
, 0x1);
792 static inline void gen_op_eval_bvc(TCGv dst
, TCGv_i32 src
)
794 gen_mov_reg_V(dst
, src
);
795 tcg_gen_xori_tl(dst
, dst
, 0x1);
799 FPSR bit field FCC1 | FCC0:
805 static inline void gen_mov_reg_FCC0(TCGv reg
, TCGv src
,
806 unsigned int fcc_offset
)
808 tcg_gen_shri_tl(reg
, src
, FSR_FCC0_SHIFT
+ fcc_offset
);
809 tcg_gen_andi_tl(reg
, reg
, 0x1);
812 static inline void gen_mov_reg_FCC1(TCGv reg
, TCGv src
,
813 unsigned int fcc_offset
)
815 tcg_gen_shri_tl(reg
, src
, FSR_FCC1_SHIFT
+ fcc_offset
);
816 tcg_gen_andi_tl(reg
, reg
, 0x1);
820 static inline void gen_op_eval_fbne(TCGv dst
, TCGv src
,
821 unsigned int fcc_offset
)
823 TCGv t0
= tcg_temp_new();
824 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
825 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
826 tcg_gen_or_tl(dst
, dst
, t0
);
830 // 1 or 2: FCC0 ^ FCC1
831 static inline void gen_op_eval_fblg(TCGv dst
, TCGv src
,
832 unsigned int fcc_offset
)
834 TCGv t0
= tcg_temp_new();
835 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
836 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
837 tcg_gen_xor_tl(dst
, dst
, t0
);
842 static inline void gen_op_eval_fbul(TCGv dst
, TCGv src
,
843 unsigned int fcc_offset
)
845 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
849 static inline void gen_op_eval_fbl(TCGv dst
, TCGv src
,
850 unsigned int fcc_offset
)
852 TCGv t0
= tcg_temp_new();
853 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
854 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
855 tcg_gen_andc_tl(dst
, dst
, t0
);
860 static inline void gen_op_eval_fbug(TCGv dst
, TCGv src
,
861 unsigned int fcc_offset
)
863 gen_mov_reg_FCC1(dst
, src
, fcc_offset
);
867 static inline void gen_op_eval_fbg(TCGv dst
, TCGv src
,
868 unsigned int fcc_offset
)
870 TCGv t0
= tcg_temp_new();
871 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
872 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
873 tcg_gen_andc_tl(dst
, t0
, dst
);
878 static inline void gen_op_eval_fbu(TCGv dst
, TCGv src
,
879 unsigned int fcc_offset
)
881 TCGv t0
= tcg_temp_new();
882 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
883 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
884 tcg_gen_and_tl(dst
, dst
, t0
);
889 static inline void gen_op_eval_fbe(TCGv dst
, TCGv src
,
890 unsigned int fcc_offset
)
892 TCGv t0
= tcg_temp_new();
893 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
894 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
895 tcg_gen_or_tl(dst
, dst
, t0
);
896 tcg_gen_xori_tl(dst
, dst
, 0x1);
900 // 0 or 3: !(FCC0 ^ FCC1)
901 static inline void gen_op_eval_fbue(TCGv dst
, TCGv src
,
902 unsigned int fcc_offset
)
904 TCGv t0
= tcg_temp_new();
905 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
906 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
907 tcg_gen_xor_tl(dst
, dst
, t0
);
908 tcg_gen_xori_tl(dst
, dst
, 0x1);
913 static inline void gen_op_eval_fbge(TCGv dst
, TCGv src
,
914 unsigned int fcc_offset
)
916 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
917 tcg_gen_xori_tl(dst
, dst
, 0x1);
920 // !1: !(FCC0 & !FCC1)
921 static inline void gen_op_eval_fbuge(TCGv dst
, TCGv src
,
922 unsigned int fcc_offset
)
924 TCGv t0
= tcg_temp_new();
925 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
926 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
927 tcg_gen_andc_tl(dst
, dst
, t0
);
928 tcg_gen_xori_tl(dst
, dst
, 0x1);
933 static inline void gen_op_eval_fble(TCGv dst
, TCGv src
,
934 unsigned int fcc_offset
)
936 gen_mov_reg_FCC1(dst
, src
, fcc_offset
);
937 tcg_gen_xori_tl(dst
, dst
, 0x1);
940 // !2: !(!FCC0 & FCC1)
941 static inline void gen_op_eval_fbule(TCGv dst
, TCGv src
,
942 unsigned int fcc_offset
)
944 TCGv t0
= tcg_temp_new();
945 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
946 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
947 tcg_gen_andc_tl(dst
, t0
, dst
);
948 tcg_gen_xori_tl(dst
, dst
, 0x1);
952 // !3: !(FCC0 & FCC1)
953 static inline void gen_op_eval_fbo(TCGv dst
, TCGv src
,
954 unsigned int fcc_offset
)
956 TCGv t0
= tcg_temp_new();
957 gen_mov_reg_FCC0(dst
, src
, fcc_offset
);
958 gen_mov_reg_FCC1(t0
, src
, fcc_offset
);
959 tcg_gen_and_tl(dst
, dst
, t0
);
960 tcg_gen_xori_tl(dst
, dst
, 0x1);
964 static inline void gen_branch2(DisasContext
*dc
, target_ulong pc1
,
965 target_ulong pc2
, TCGv r_cond
)
967 TCGLabel
*l1
= gen_new_label();
969 tcg_gen_brcondi_tl(TCG_COND_EQ
, r_cond
, 0, l1
);
971 gen_goto_tb(dc
, 0, pc1
, pc1
+ 4);
974 gen_goto_tb(dc
, 1, pc2
, pc2
+ 4);
977 static void gen_branch_a(DisasContext
*dc
, target_ulong pc1
)
979 TCGLabel
*l1
= gen_new_label();
980 target_ulong npc
= dc
->npc
;
982 tcg_gen_brcondi_tl(TCG_COND_EQ
, cpu_cond
, 0, l1
);
984 gen_goto_tb(dc
, 0, npc
, pc1
);
987 gen_goto_tb(dc
, 1, npc
+ 4, npc
+ 8);
989 dc
->base
.is_jmp
= DISAS_NORETURN
;
992 static void gen_branch_n(DisasContext
*dc
, target_ulong pc1
)
994 target_ulong npc
= dc
->npc
;
996 if (likely(npc
!= DYNAMIC_PC
)) {
998 dc
->jump_pc
[0] = pc1
;
999 dc
->jump_pc
[1] = npc
+ 4;
1004 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1006 tcg_gen_addi_tl(cpu_npc
, cpu_npc
, 4);
1007 t
= tcg_const_tl(pc1
);
1008 z
= tcg_const_tl(0);
1009 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_npc
, cpu_cond
, z
, t
, cpu_npc
);
1013 dc
->pc
= DYNAMIC_PC
;
1017 static inline void gen_generic_branch(DisasContext
*dc
)
1019 TCGv npc0
= tcg_const_tl(dc
->jump_pc
[0]);
1020 TCGv npc1
= tcg_const_tl(dc
->jump_pc
[1]);
1021 TCGv zero
= tcg_const_tl(0);
1023 tcg_gen_movcond_tl(TCG_COND_NE
, cpu_npc
, cpu_cond
, zero
, npc0
, npc1
);
1025 tcg_temp_free(npc0
);
1026 tcg_temp_free(npc1
);
1027 tcg_temp_free(zero
);
1030 /* call this function before using the condition register as it may
1031 have been set for a jump */
1032 static inline void flush_cond(DisasContext
*dc
)
1034 if (dc
->npc
== JUMP_PC
) {
1035 gen_generic_branch(dc
);
1036 dc
->npc
= DYNAMIC_PC
;
1040 static inline void save_npc(DisasContext
*dc
)
1042 if (dc
->npc
== JUMP_PC
) {
1043 gen_generic_branch(dc
);
1044 dc
->npc
= DYNAMIC_PC
;
1045 } else if (dc
->npc
!= DYNAMIC_PC
) {
1046 tcg_gen_movi_tl(cpu_npc
, dc
->npc
);
1050 static inline void update_psr(DisasContext
*dc
)
1052 if (dc
->cc_op
!= CC_OP_FLAGS
) {
1053 dc
->cc_op
= CC_OP_FLAGS
;
1054 gen_helper_compute_psr(cpu_env
);
1058 static inline void save_state(DisasContext
*dc
)
1060 tcg_gen_movi_tl(cpu_pc
, dc
->pc
);
1064 static void gen_exception(DisasContext
*dc
, int which
)
1069 t
= tcg_const_i32(which
);
1070 gen_helper_raise_exception(cpu_env
, t
);
1071 tcg_temp_free_i32(t
);
1072 dc
->base
.is_jmp
= DISAS_NORETURN
;
1075 static void gen_check_align(TCGv addr
, int mask
)
1077 TCGv_i32 r_mask
= tcg_const_i32(mask
);
1078 gen_helper_check_align(cpu_env
, addr
, r_mask
);
1079 tcg_temp_free_i32(r_mask
);
1082 static inline void gen_mov_pc_npc(DisasContext
*dc
)
1084 if (dc
->npc
== JUMP_PC
) {
1085 gen_generic_branch(dc
);
1086 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1087 dc
->pc
= DYNAMIC_PC
;
1088 } else if (dc
->npc
== DYNAMIC_PC
) {
1089 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1090 dc
->pc
= DYNAMIC_PC
;
1096 static inline void gen_op_next_insn(void)
1098 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1099 tcg_gen_addi_tl(cpu_npc
, cpu_npc
, 4);
1102 static void free_compare(DisasCompare
*cmp
)
1105 tcg_temp_free(cmp
->c1
);
1108 tcg_temp_free(cmp
->c2
);
1112 static void gen_compare(DisasCompare
*cmp
, bool xcc
, unsigned int cond
,
1115 static int subcc_cond
[16] = {
1131 -1, /* no overflow */
1134 static int logic_cond
[16] = {
1136 TCG_COND_EQ
, /* eq: Z */
1137 TCG_COND_LE
, /* le: Z | (N ^ V) -> Z | N */
1138 TCG_COND_LT
, /* lt: N ^ V -> N */
1139 TCG_COND_EQ
, /* leu: C | Z -> Z */
1140 TCG_COND_NEVER
, /* ltu: C -> 0 */
1141 TCG_COND_LT
, /* neg: N */
1142 TCG_COND_NEVER
, /* vs: V -> 0 */
1144 TCG_COND_NE
, /* ne: !Z */
1145 TCG_COND_GT
, /* gt: !(Z | (N ^ V)) -> !(Z | N) */
1146 TCG_COND_GE
, /* ge: !(N ^ V) -> !N */
1147 TCG_COND_NE
, /* gtu: !(C | Z) -> !Z */
1148 TCG_COND_ALWAYS
, /* geu: !C -> 1 */
1149 TCG_COND_GE
, /* pos: !N */
1150 TCG_COND_ALWAYS
, /* vc: !V -> 1 */
1156 #ifdef TARGET_SPARC64
1166 switch (dc
->cc_op
) {
1168 cmp
->cond
= logic_cond
[cond
];
1170 cmp
->is_bool
= false;
1172 cmp
->c2
= tcg_const_tl(0);
1173 #ifdef TARGET_SPARC64
1176 cmp
->c1
= tcg_temp_new();
1177 tcg_gen_ext32s_tl(cmp
->c1
, cpu_cc_dst
);
1182 cmp
->c1
= cpu_cc_dst
;
1189 cmp
->cond
= (cond
== 6 ? TCG_COND_LT
: TCG_COND_GE
);
1190 goto do_compare_dst_0
;
1192 case 7: /* overflow */
1193 case 15: /* !overflow */
1197 cmp
->cond
= subcc_cond
[cond
];
1198 cmp
->is_bool
= false;
1199 #ifdef TARGET_SPARC64
1201 /* Note that sign-extension works for unsigned compares as
1202 long as both operands are sign-extended. */
1203 cmp
->g1
= cmp
->g2
= false;
1204 cmp
->c1
= tcg_temp_new();
1205 cmp
->c2
= tcg_temp_new();
1206 tcg_gen_ext32s_tl(cmp
->c1
, cpu_cc_src
);
1207 tcg_gen_ext32s_tl(cmp
->c2
, cpu_cc_src2
);
1211 cmp
->g1
= cmp
->g2
= true;
1212 cmp
->c1
= cpu_cc_src
;
1213 cmp
->c2
= cpu_cc_src2
;
1220 gen_helper_compute_psr(cpu_env
);
1221 dc
->cc_op
= CC_OP_FLAGS
;
1225 /* We're going to generate a boolean result. */
1226 cmp
->cond
= TCG_COND_NE
;
1227 cmp
->is_bool
= true;
1228 cmp
->g1
= cmp
->g2
= false;
1229 cmp
->c1
= r_dst
= tcg_temp_new();
1230 cmp
->c2
= tcg_const_tl(0);
1234 gen_op_eval_bn(r_dst
);
1237 gen_op_eval_be(r_dst
, r_src
);
1240 gen_op_eval_ble(r_dst
, r_src
);
1243 gen_op_eval_bl(r_dst
, r_src
);
1246 gen_op_eval_bleu(r_dst
, r_src
);
1249 gen_op_eval_bcs(r_dst
, r_src
);
1252 gen_op_eval_bneg(r_dst
, r_src
);
1255 gen_op_eval_bvs(r_dst
, r_src
);
1258 gen_op_eval_ba(r_dst
);
1261 gen_op_eval_bne(r_dst
, r_src
);
1264 gen_op_eval_bg(r_dst
, r_src
);
1267 gen_op_eval_bge(r_dst
, r_src
);
1270 gen_op_eval_bgu(r_dst
, r_src
);
1273 gen_op_eval_bcc(r_dst
, r_src
);
1276 gen_op_eval_bpos(r_dst
, r_src
);
1279 gen_op_eval_bvc(r_dst
, r_src
);
1286 static void gen_fcompare(DisasCompare
*cmp
, unsigned int cc
, unsigned int cond
)
1288 unsigned int offset
;
1291 /* For now we still generate a straight boolean result. */
1292 cmp
->cond
= TCG_COND_NE
;
1293 cmp
->is_bool
= true;
1294 cmp
->g1
= cmp
->g2
= false;
1295 cmp
->c1
= r_dst
= tcg_temp_new();
1296 cmp
->c2
= tcg_const_tl(0);
1316 gen_op_eval_bn(r_dst
);
1319 gen_op_eval_fbne(r_dst
, cpu_fsr
, offset
);
1322 gen_op_eval_fblg(r_dst
, cpu_fsr
, offset
);
1325 gen_op_eval_fbul(r_dst
, cpu_fsr
, offset
);
1328 gen_op_eval_fbl(r_dst
, cpu_fsr
, offset
);
1331 gen_op_eval_fbug(r_dst
, cpu_fsr
, offset
);
1334 gen_op_eval_fbg(r_dst
, cpu_fsr
, offset
);
1337 gen_op_eval_fbu(r_dst
, cpu_fsr
, offset
);
1340 gen_op_eval_ba(r_dst
);
1343 gen_op_eval_fbe(r_dst
, cpu_fsr
, offset
);
1346 gen_op_eval_fbue(r_dst
, cpu_fsr
, offset
);
1349 gen_op_eval_fbge(r_dst
, cpu_fsr
, offset
);
1352 gen_op_eval_fbuge(r_dst
, cpu_fsr
, offset
);
1355 gen_op_eval_fble(r_dst
, cpu_fsr
, offset
);
1358 gen_op_eval_fbule(r_dst
, cpu_fsr
, offset
);
1361 gen_op_eval_fbo(r_dst
, cpu_fsr
, offset
);
1366 static void gen_cond(TCGv r_dst
, unsigned int cc
, unsigned int cond
,
1370 gen_compare(&cmp
, cc
, cond
, dc
);
1372 /* The interface is to return a boolean in r_dst. */
1374 tcg_gen_mov_tl(r_dst
, cmp
.c1
);
1376 tcg_gen_setcond_tl(cmp
.cond
, r_dst
, cmp
.c1
, cmp
.c2
);
1382 static void gen_fcond(TCGv r_dst
, unsigned int cc
, unsigned int cond
)
1385 gen_fcompare(&cmp
, cc
, cond
);
1387 /* The interface is to return a boolean in r_dst. */
1389 tcg_gen_mov_tl(r_dst
, cmp
.c1
);
1391 tcg_gen_setcond_tl(cmp
.cond
, r_dst
, cmp
.c1
, cmp
.c2
);
1397 #ifdef TARGET_SPARC64
1399 static const int gen_tcg_cond_reg
[8] = {
1410 static void gen_compare_reg(DisasCompare
*cmp
, int cond
, TCGv r_src
)
1412 cmp
->cond
= tcg_invert_cond(gen_tcg_cond_reg
[cond
]);
1413 cmp
->is_bool
= false;
1417 cmp
->c2
= tcg_const_tl(0);
1420 static inline void gen_cond_reg(TCGv r_dst
, int cond
, TCGv r_src
)
1423 gen_compare_reg(&cmp
, cond
, r_src
);
1425 /* The interface is to return a boolean in r_dst. */
1426 tcg_gen_setcond_tl(cmp
.cond
, r_dst
, cmp
.c1
, cmp
.c2
);
1432 static void do_branch(DisasContext
*dc
, int32_t offset
, uint32_t insn
, int cc
)
1434 unsigned int cond
= GET_FIELD(insn
, 3, 6), a
= (insn
& (1 << 29));
1435 target_ulong target
= dc
->pc
+ offset
;
1437 #ifdef TARGET_SPARC64
1438 if (unlikely(AM_CHECK(dc
))) {
1439 target
&= 0xffffffffULL
;
1443 /* unconditional not taken */
1445 dc
->pc
= dc
->npc
+ 4;
1446 dc
->npc
= dc
->pc
+ 4;
1449 dc
->npc
= dc
->pc
+ 4;
1451 } else if (cond
== 0x8) {
1452 /* unconditional taken */
1455 dc
->npc
= dc
->pc
+ 4;
1459 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1463 gen_cond(cpu_cond
, cc
, cond
, dc
);
1465 gen_branch_a(dc
, target
);
1467 gen_branch_n(dc
, target
);
1472 static void do_fbranch(DisasContext
*dc
, int32_t offset
, uint32_t insn
, int cc
)
1474 unsigned int cond
= GET_FIELD(insn
, 3, 6), a
= (insn
& (1 << 29));
1475 target_ulong target
= dc
->pc
+ offset
;
1477 #ifdef TARGET_SPARC64
1478 if (unlikely(AM_CHECK(dc
))) {
1479 target
&= 0xffffffffULL
;
1483 /* unconditional not taken */
1485 dc
->pc
= dc
->npc
+ 4;
1486 dc
->npc
= dc
->pc
+ 4;
1489 dc
->npc
= dc
->pc
+ 4;
1491 } else if (cond
== 0x8) {
1492 /* unconditional taken */
1495 dc
->npc
= dc
->pc
+ 4;
1499 tcg_gen_mov_tl(cpu_pc
, cpu_npc
);
1503 gen_fcond(cpu_cond
, cc
, cond
);
1505 gen_branch_a(dc
, target
);
1507 gen_branch_n(dc
, target
);
1512 #ifdef TARGET_SPARC64
1513 static void do_branch_reg(DisasContext
*dc
, int32_t offset
, uint32_t insn
,
1516 unsigned int cond
= GET_FIELD_SP(insn
, 25, 27), a
= (insn
& (1 << 29));
1517 target_ulong target
= dc
->pc
+ offset
;
1519 if (unlikely(AM_CHECK(dc
))) {
1520 target
&= 0xffffffffULL
;
1523 gen_cond_reg(cpu_cond
, cond
, r_reg
);
1525 gen_branch_a(dc
, target
);
1527 gen_branch_n(dc
, target
);
1531 static inline void gen_op_fcmps(int fccno
, TCGv_i32 r_rs1
, TCGv_i32 r_rs2
)
1535 gen_helper_fcmps(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1538 gen_helper_fcmps_fcc1(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1541 gen_helper_fcmps_fcc2(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1544 gen_helper_fcmps_fcc3(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1549 static inline void gen_op_fcmpd(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1553 gen_helper_fcmpd(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1556 gen_helper_fcmpd_fcc1(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1559 gen_helper_fcmpd_fcc2(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1562 gen_helper_fcmpd_fcc3(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1567 static inline void gen_op_fcmpq(int fccno
)
1571 gen_helper_fcmpq(cpu_fsr
, cpu_env
);
1574 gen_helper_fcmpq_fcc1(cpu_fsr
, cpu_env
);
1577 gen_helper_fcmpq_fcc2(cpu_fsr
, cpu_env
);
1580 gen_helper_fcmpq_fcc3(cpu_fsr
, cpu_env
);
1585 static inline void gen_op_fcmpes(int fccno
, TCGv_i32 r_rs1
, TCGv_i32 r_rs2
)
1589 gen_helper_fcmpes(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1592 gen_helper_fcmpes_fcc1(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1595 gen_helper_fcmpes_fcc2(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1598 gen_helper_fcmpes_fcc3(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1603 static inline void gen_op_fcmped(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1607 gen_helper_fcmped(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1610 gen_helper_fcmped_fcc1(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1613 gen_helper_fcmped_fcc2(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1616 gen_helper_fcmped_fcc3(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1621 static inline void gen_op_fcmpeq(int fccno
)
1625 gen_helper_fcmpeq(cpu_fsr
, cpu_env
);
1628 gen_helper_fcmpeq_fcc1(cpu_fsr
, cpu_env
);
1631 gen_helper_fcmpeq_fcc2(cpu_fsr
, cpu_env
);
1634 gen_helper_fcmpeq_fcc3(cpu_fsr
, cpu_env
);
1641 static inline void gen_op_fcmps(int fccno
, TCGv r_rs1
, TCGv r_rs2
)
1643 gen_helper_fcmps(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1646 static inline void gen_op_fcmpd(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1648 gen_helper_fcmpd(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1651 static inline void gen_op_fcmpq(int fccno
)
1653 gen_helper_fcmpq(cpu_fsr
, cpu_env
);
1656 static inline void gen_op_fcmpes(int fccno
, TCGv r_rs1
, TCGv r_rs2
)
1658 gen_helper_fcmpes(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1661 static inline void gen_op_fcmped(int fccno
, TCGv_i64 r_rs1
, TCGv_i64 r_rs2
)
1663 gen_helper_fcmped(cpu_fsr
, cpu_env
, r_rs1
, r_rs2
);
1666 static inline void gen_op_fcmpeq(int fccno
)
1668 gen_helper_fcmpeq(cpu_fsr
, cpu_env
);
1672 static void gen_op_fpexception_im(DisasContext
*dc
, int fsr_flags
)
1674 tcg_gen_andi_tl(cpu_fsr
, cpu_fsr
, FSR_FTT_NMASK
);
1675 tcg_gen_ori_tl(cpu_fsr
, cpu_fsr
, fsr_flags
);
1676 gen_exception(dc
, TT_FP_EXCP
);
1679 static int gen_trap_ifnofpu(DisasContext
*dc
)
1681 #if !defined(CONFIG_USER_ONLY)
1682 if (!dc
->fpu_enabled
) {
1683 gen_exception(dc
, TT_NFPU_INSN
);
1690 static inline void gen_op_clear_ieee_excp_and_FTT(void)
1692 tcg_gen_andi_tl(cpu_fsr
, cpu_fsr
, FSR_FTT_CEXC_NMASK
);
1695 static inline void gen_fop_FF(DisasContext
*dc
, int rd
, int rs
,
1696 void (*gen
)(TCGv_i32
, TCGv_ptr
, TCGv_i32
))
1700 src
= gen_load_fpr_F(dc
, rs
);
1701 dst
= gen_dest_fpr_F(dc
);
1703 gen(dst
, cpu_env
, src
);
1704 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1706 gen_store_fpr_F(dc
, rd
, dst
);
1709 static inline void gen_ne_fop_FF(DisasContext
*dc
, int rd
, int rs
,
1710 void (*gen
)(TCGv_i32
, TCGv_i32
))
1714 src
= gen_load_fpr_F(dc
, rs
);
1715 dst
= gen_dest_fpr_F(dc
);
1719 gen_store_fpr_F(dc
, rd
, dst
);
1722 static inline void gen_fop_FFF(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1723 void (*gen
)(TCGv_i32
, TCGv_ptr
, TCGv_i32
, TCGv_i32
))
1725 TCGv_i32 dst
, src1
, src2
;
1727 src1
= gen_load_fpr_F(dc
, rs1
);
1728 src2
= gen_load_fpr_F(dc
, rs2
);
1729 dst
= gen_dest_fpr_F(dc
);
1731 gen(dst
, cpu_env
, src1
, src2
);
1732 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1734 gen_store_fpr_F(dc
, rd
, dst
);
1737 #ifdef TARGET_SPARC64
1738 static inline void gen_ne_fop_FFF(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1739 void (*gen
)(TCGv_i32
, 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
, src1
, src2
);
1749 gen_store_fpr_F(dc
, rd
, dst
);
1753 static inline void gen_fop_DD(DisasContext
*dc
, int rd
, int rs
,
1754 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i64
))
1758 src
= gen_load_fpr_D(dc
, rs
);
1759 dst
= gen_dest_fpr_D(dc
, rd
);
1761 gen(dst
, cpu_env
, src
);
1762 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1764 gen_store_fpr_D(dc
, rd
, dst
);
1767 #ifdef TARGET_SPARC64
1768 static inline void gen_ne_fop_DD(DisasContext
*dc
, int rd
, int rs
,
1769 void (*gen
)(TCGv_i64
, TCGv_i64
))
1773 src
= gen_load_fpr_D(dc
, rs
);
1774 dst
= gen_dest_fpr_D(dc
, rd
);
1778 gen_store_fpr_D(dc
, rd
, dst
);
1782 static inline void gen_fop_DDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1783 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i64
, TCGv_i64
))
1785 TCGv_i64 dst
, src1
, src2
;
1787 src1
= gen_load_fpr_D(dc
, rs1
);
1788 src2
= gen_load_fpr_D(dc
, rs2
);
1789 dst
= gen_dest_fpr_D(dc
, rd
);
1791 gen(dst
, cpu_env
, src1
, src2
);
1792 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1794 gen_store_fpr_D(dc
, rd
, dst
);
1797 #ifdef TARGET_SPARC64
1798 static inline void gen_ne_fop_DDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1799 void (*gen
)(TCGv_i64
, TCGv_i64
, TCGv_i64
))
1801 TCGv_i64 dst
, src1
, src2
;
1803 src1
= gen_load_fpr_D(dc
, rs1
);
1804 src2
= gen_load_fpr_D(dc
, rs2
);
1805 dst
= gen_dest_fpr_D(dc
, rd
);
1807 gen(dst
, src1
, src2
);
1809 gen_store_fpr_D(dc
, rd
, dst
);
1812 static inline void gen_gsr_fop_DDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1813 void (*gen
)(TCGv_i64
, TCGv_i64
, TCGv_i64
, TCGv_i64
))
1815 TCGv_i64 dst
, src1
, src2
;
1817 src1
= gen_load_fpr_D(dc
, rs1
);
1818 src2
= gen_load_fpr_D(dc
, rs2
);
1819 dst
= gen_dest_fpr_D(dc
, rd
);
1821 gen(dst
, cpu_gsr
, src1
, src2
);
1823 gen_store_fpr_D(dc
, rd
, dst
);
1826 static inline void gen_ne_fop_DDDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1827 void (*gen
)(TCGv_i64
, TCGv_i64
, TCGv_i64
, TCGv_i64
))
1829 TCGv_i64 dst
, src0
, src1
, src2
;
1831 src1
= gen_load_fpr_D(dc
, rs1
);
1832 src2
= gen_load_fpr_D(dc
, rs2
);
1833 src0
= gen_load_fpr_D(dc
, rd
);
1834 dst
= gen_dest_fpr_D(dc
, rd
);
1836 gen(dst
, src0
, src1
, src2
);
1838 gen_store_fpr_D(dc
, rd
, dst
);
1842 static inline void gen_fop_QQ(DisasContext
*dc
, int rd
, int rs
,
1843 void (*gen
)(TCGv_ptr
))
1845 gen_op_load_fpr_QT1(QFPREG(rs
));
1848 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1850 gen_op_store_QT0_fpr(QFPREG(rd
));
1851 gen_update_fprs_dirty(dc
, QFPREG(rd
));
1854 #ifdef TARGET_SPARC64
1855 static inline void gen_ne_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(dc
, QFPREG(rd
));
1867 static inline void gen_fop_QQQ(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1868 void (*gen
)(TCGv_ptr
))
1870 gen_op_load_fpr_QT0(QFPREG(rs1
));
1871 gen_op_load_fpr_QT1(QFPREG(rs2
));
1874 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1876 gen_op_store_QT0_fpr(QFPREG(rd
));
1877 gen_update_fprs_dirty(dc
, QFPREG(rd
));
1880 static inline void gen_fop_DFF(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1881 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i32
, TCGv_i32
))
1884 TCGv_i32 src1
, src2
;
1886 src1
= gen_load_fpr_F(dc
, rs1
);
1887 src2
= gen_load_fpr_F(dc
, rs2
);
1888 dst
= gen_dest_fpr_D(dc
, rd
);
1890 gen(dst
, cpu_env
, src1
, src2
);
1891 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1893 gen_store_fpr_D(dc
, rd
, dst
);
1896 static inline void gen_fop_QDD(DisasContext
*dc
, int rd
, int rs1
, int rs2
,
1897 void (*gen
)(TCGv_ptr
, TCGv_i64
, TCGv_i64
))
1899 TCGv_i64 src1
, src2
;
1901 src1
= gen_load_fpr_D(dc
, rs1
);
1902 src2
= gen_load_fpr_D(dc
, rs2
);
1904 gen(cpu_env
, src1
, src2
);
1905 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1907 gen_op_store_QT0_fpr(QFPREG(rd
));
1908 gen_update_fprs_dirty(dc
, QFPREG(rd
));
1911 #ifdef TARGET_SPARC64
1912 static inline void gen_fop_DF(DisasContext
*dc
, int rd
, int rs
,
1913 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i32
))
1918 src
= gen_load_fpr_F(dc
, rs
);
1919 dst
= gen_dest_fpr_D(dc
, rd
);
1921 gen(dst
, cpu_env
, src
);
1922 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1924 gen_store_fpr_D(dc
, rd
, dst
);
1928 static inline void gen_ne_fop_DF(DisasContext
*dc
, int rd
, int rs
,
1929 void (*gen
)(TCGv_i64
, TCGv_ptr
, TCGv_i32
))
1934 src
= gen_load_fpr_F(dc
, rs
);
1935 dst
= gen_dest_fpr_D(dc
, rd
);
1937 gen(dst
, cpu_env
, src
);
1939 gen_store_fpr_D(dc
, rd
, dst
);
1942 static inline void gen_fop_FD(DisasContext
*dc
, int rd
, int rs
,
1943 void (*gen
)(TCGv_i32
, TCGv_ptr
, TCGv_i64
))
1948 src
= gen_load_fpr_D(dc
, rs
);
1949 dst
= gen_dest_fpr_F(dc
);
1951 gen(dst
, cpu_env
, src
);
1952 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1954 gen_store_fpr_F(dc
, rd
, dst
);
1957 static inline void gen_fop_FQ(DisasContext
*dc
, int rd
, int rs
,
1958 void (*gen
)(TCGv_i32
, TCGv_ptr
))
1962 gen_op_load_fpr_QT1(QFPREG(rs
));
1963 dst
= gen_dest_fpr_F(dc
);
1966 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1968 gen_store_fpr_F(dc
, rd
, dst
);
1971 static inline void gen_fop_DQ(DisasContext
*dc
, int rd
, int rs
,
1972 void (*gen
)(TCGv_i64
, TCGv_ptr
))
1976 gen_op_load_fpr_QT1(QFPREG(rs
));
1977 dst
= gen_dest_fpr_D(dc
, rd
);
1980 gen_helper_check_ieee_exceptions(cpu_fsr
, cpu_env
);
1982 gen_store_fpr_D(dc
, rd
, dst
);
1985 static inline void gen_ne_fop_QF(DisasContext
*dc
, int rd
, int rs
,
1986 void (*gen
)(TCGv_ptr
, TCGv_i32
))
1990 src
= gen_load_fpr_F(dc
, rs
);
1994 gen_op_store_QT0_fpr(QFPREG(rd
));
1995 gen_update_fprs_dirty(dc
, QFPREG(rd
));
1998 static inline void gen_ne_fop_QD(DisasContext
*dc
, int rd
, int rs
,
1999 void (*gen
)(TCGv_ptr
, TCGv_i64
))
2003 src
= gen_load_fpr_D(dc
, rs
);
2007 gen_op_store_QT0_fpr(QFPREG(rd
));
2008 gen_update_fprs_dirty(dc
, QFPREG(rd
));
2011 static void gen_swap(DisasContext
*dc
, TCGv dst
, TCGv src
,
2012 TCGv addr
, int mmu_idx
, MemOp memop
)
2014 gen_address_mask(dc
, addr
);
2015 tcg_gen_atomic_xchg_tl(dst
, addr
, src
, mmu_idx
, memop
);
2018 static void gen_ldstub(DisasContext
*dc
, TCGv dst
, TCGv addr
, int mmu_idx
)
2020 TCGv m1
= tcg_const_tl(0xff);
2021 gen_address_mask(dc
, addr
);
2022 tcg_gen_atomic_xchg_tl(dst
, addr
, m1
, mmu_idx
, MO_UB
);
2027 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
2046 static DisasASI
get_asi(DisasContext
*dc
, int insn
, MemOp memop
)
2048 int asi
= GET_FIELD(insn
, 19, 26);
2049 ASIType type
= GET_ASI_HELPER
;
2050 int mem_idx
= dc
->mem_idx
;
2052 #ifndef TARGET_SPARC64
2053 /* Before v9, all asis are immediate and privileged. */
2055 gen_exception(dc
, TT_ILL_INSN
);
2056 type
= GET_ASI_EXCP
;
2057 } else if (supervisor(dc
)
2058 /* Note that LEON accepts ASI_USERDATA in user mode, for
2059 use with CASA. Also note that previous versions of
2060 QEMU allowed (and old versions of gcc emitted) ASI_P
2061 for LEON, which is incorrect. */
2062 || (asi
== ASI_USERDATA
2063 && (dc
->def
->features
& CPU_FEATURE_CASA
))) {
2065 case ASI_USERDATA
: /* User data access */
2066 mem_idx
= MMU_USER_IDX
;
2067 type
= GET_ASI_DIRECT
;
2069 case ASI_KERNELDATA
: /* Supervisor data access */
2070 mem_idx
= MMU_KERNEL_IDX
;
2071 type
= GET_ASI_DIRECT
;
2073 case ASI_M_BYPASS
: /* MMU passthrough */
2074 case ASI_LEON_BYPASS
: /* LEON MMU passthrough */
2075 mem_idx
= MMU_PHYS_IDX
;
2076 type
= GET_ASI_DIRECT
;
2078 case ASI_M_BCOPY
: /* Block copy, sta access */
2079 mem_idx
= MMU_KERNEL_IDX
;
2080 type
= GET_ASI_BCOPY
;
2082 case ASI_M_BFILL
: /* Block fill, stda access */
2083 mem_idx
= MMU_KERNEL_IDX
;
2084 type
= GET_ASI_BFILL
;
2088 /* MMU_PHYS_IDX is used when the MMU is disabled to passthrough the
2089 * permissions check in get_physical_address(..).
2091 mem_idx
= (dc
->mem_idx
== MMU_PHYS_IDX
) ? MMU_PHYS_IDX
: mem_idx
;
2093 gen_exception(dc
, TT_PRIV_INSN
);
2094 type
= GET_ASI_EXCP
;
2100 /* With v9, all asis below 0x80 are privileged. */
2101 /* ??? We ought to check cpu_has_hypervisor, but we didn't copy
2102 down that bit into DisasContext. For the moment that's ok,
2103 since the direct implementations below doesn't have any ASIs
2104 in the restricted [0x30, 0x7f] range, and the check will be
2105 done properly in the helper. */
2106 if (!supervisor(dc
) && asi
< 0x80) {
2107 gen_exception(dc
, TT_PRIV_ACT
);
2108 type
= GET_ASI_EXCP
;
2111 case ASI_REAL
: /* Bypass */
2112 case ASI_REAL_IO
: /* Bypass, non-cacheable */
2113 case ASI_REAL_L
: /* Bypass LE */
2114 case ASI_REAL_IO_L
: /* Bypass, non-cacheable LE */
2115 case ASI_TWINX_REAL
: /* Real address, twinx */
2116 case ASI_TWINX_REAL_L
: /* Real address, twinx, LE */
2117 case ASI_QUAD_LDD_PHYS
:
2118 case ASI_QUAD_LDD_PHYS_L
:
2119 mem_idx
= MMU_PHYS_IDX
;
2121 case ASI_N
: /* Nucleus */
2122 case ASI_NL
: /* Nucleus LE */
2125 case ASI_NUCLEUS_QUAD_LDD
:
2126 case ASI_NUCLEUS_QUAD_LDD_L
:
2127 if (hypervisor(dc
)) {
2128 mem_idx
= MMU_PHYS_IDX
;
2130 mem_idx
= MMU_NUCLEUS_IDX
;
2133 case ASI_AIUP
: /* As if user primary */
2134 case ASI_AIUPL
: /* As if user primary LE */
2135 case ASI_TWINX_AIUP
:
2136 case ASI_TWINX_AIUP_L
:
2137 case ASI_BLK_AIUP_4V
:
2138 case ASI_BLK_AIUP_L_4V
:
2141 mem_idx
= MMU_USER_IDX
;
2143 case ASI_AIUS
: /* As if user secondary */
2144 case ASI_AIUSL
: /* As if user secondary LE */
2145 case ASI_TWINX_AIUS
:
2146 case ASI_TWINX_AIUS_L
:
2147 case ASI_BLK_AIUS_4V
:
2148 case ASI_BLK_AIUS_L_4V
:
2151 mem_idx
= MMU_USER_SECONDARY_IDX
;
2153 case ASI_S
: /* Secondary */
2154 case ASI_SL
: /* Secondary LE */
2157 case ASI_BLK_COMMIT_S
:
2164 if (mem_idx
== MMU_USER_IDX
) {
2165 mem_idx
= MMU_USER_SECONDARY_IDX
;
2166 } else if (mem_idx
== MMU_KERNEL_IDX
) {
2167 mem_idx
= MMU_KERNEL_SECONDARY_IDX
;
2170 case ASI_P
: /* Primary */
2171 case ASI_PL
: /* Primary LE */
2174 case ASI_BLK_COMMIT_P
:
2198 type
= GET_ASI_DIRECT
;
2200 case ASI_TWINX_REAL
:
2201 case ASI_TWINX_REAL_L
:
2204 case ASI_TWINX_AIUP
:
2205 case ASI_TWINX_AIUP_L
:
2206 case ASI_TWINX_AIUS
:
2207 case ASI_TWINX_AIUS_L
:
2212 case ASI_QUAD_LDD_PHYS
:
2213 case ASI_QUAD_LDD_PHYS_L
:
2214 case ASI_NUCLEUS_QUAD_LDD
:
2215 case ASI_NUCLEUS_QUAD_LDD_L
:
2216 type
= GET_ASI_DTWINX
;
2218 case ASI_BLK_COMMIT_P
:
2219 case ASI_BLK_COMMIT_S
:
2220 case ASI_BLK_AIUP_4V
:
2221 case ASI_BLK_AIUP_L_4V
:
2224 case ASI_BLK_AIUS_4V
:
2225 case ASI_BLK_AIUS_L_4V
:
2232 type
= GET_ASI_BLOCK
;
2239 type
= GET_ASI_SHORT
;
2246 type
= GET_ASI_SHORT
;
2249 /* The little-endian asis all have bit 3 set. */
2256 return (DisasASI
){ type
, asi
, mem_idx
, memop
};
2259 static void gen_ld_asi(DisasContext
*dc
, TCGv dst
, TCGv addr
,
2260 int insn
, MemOp memop
)
2262 DisasASI da
= get_asi(dc
, insn
, memop
);
2267 case GET_ASI_DTWINX
: /* Reserved for ldda. */
2268 gen_exception(dc
, TT_ILL_INSN
);
2270 case GET_ASI_DIRECT
:
2271 gen_address_mask(dc
, addr
);
2272 tcg_gen_qemu_ld_tl(dst
, addr
, da
.mem_idx
, da
.memop
);
2276 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2277 TCGv_i32 r_mop
= tcg_const_i32(memop
);
2280 #ifdef TARGET_SPARC64
2281 gen_helper_ld_asi(dst
, cpu_env
, addr
, r_asi
, r_mop
);
2284 TCGv_i64 t64
= tcg_temp_new_i64();
2285 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_mop
);
2286 tcg_gen_trunc_i64_tl(dst
, t64
);
2287 tcg_temp_free_i64(t64
);
2290 tcg_temp_free_i32(r_mop
);
2291 tcg_temp_free_i32(r_asi
);
2297 static void gen_st_asi(DisasContext
*dc
, TCGv src
, TCGv addr
,
2298 int insn
, MemOp memop
)
2300 DisasASI da
= get_asi(dc
, insn
, memop
);
2305 case GET_ASI_DTWINX
: /* Reserved for stda. */
2306 #ifndef TARGET_SPARC64
2307 gen_exception(dc
, TT_ILL_INSN
);
2310 if (!(dc
->def
->features
& CPU_FEATURE_HYPV
)) {
2311 /* Pre OpenSPARC CPUs don't have these */
2312 gen_exception(dc
, TT_ILL_INSN
);
2315 /* in OpenSPARC T1+ CPUs TWINX ASIs in store instructions
2316 * are ST_BLKINIT_ ASIs */
2319 case GET_ASI_DIRECT
:
2320 gen_address_mask(dc
, addr
);
2321 tcg_gen_qemu_st_tl(src
, addr
, da
.mem_idx
, da
.memop
);
2323 #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
2325 /* Copy 32 bytes from the address in SRC to ADDR. */
2326 /* ??? The original qemu code suggests 4-byte alignment, dropping
2327 the low bits, but the only place I can see this used is in the
2328 Linux kernel with 32 byte alignment, which would make more sense
2329 as a cacheline-style operation. */
2331 TCGv saddr
= tcg_temp_new();
2332 TCGv daddr
= tcg_temp_new();
2333 TCGv four
= tcg_const_tl(4);
2334 TCGv_i32 tmp
= tcg_temp_new_i32();
2337 tcg_gen_andi_tl(saddr
, src
, -4);
2338 tcg_gen_andi_tl(daddr
, addr
, -4);
2339 for (i
= 0; i
< 32; i
+= 4) {
2340 /* Since the loads and stores are paired, allow the
2341 copy to happen in the host endianness. */
2342 tcg_gen_qemu_ld_i32(tmp
, saddr
, da
.mem_idx
, MO_UL
);
2343 tcg_gen_qemu_st_i32(tmp
, daddr
, da
.mem_idx
, MO_UL
);
2344 tcg_gen_add_tl(saddr
, saddr
, four
);
2345 tcg_gen_add_tl(daddr
, daddr
, four
);
2348 tcg_temp_free(saddr
);
2349 tcg_temp_free(daddr
);
2350 tcg_temp_free(four
);
2351 tcg_temp_free_i32(tmp
);
2357 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2358 TCGv_i32 r_mop
= tcg_const_i32(memop
& MO_SIZE
);
2361 #ifdef TARGET_SPARC64
2362 gen_helper_st_asi(cpu_env
, addr
, src
, r_asi
, r_mop
);
2365 TCGv_i64 t64
= tcg_temp_new_i64();
2366 tcg_gen_extu_tl_i64(t64
, src
);
2367 gen_helper_st_asi(cpu_env
, addr
, t64
, r_asi
, r_mop
);
2368 tcg_temp_free_i64(t64
);
2371 tcg_temp_free_i32(r_mop
);
2372 tcg_temp_free_i32(r_asi
);
2374 /* A write to a TLB register may alter page maps. End the TB. */
2375 dc
->npc
= DYNAMIC_PC
;
2381 static void gen_swap_asi(DisasContext
*dc
, TCGv dst
, TCGv src
,
2382 TCGv addr
, int insn
)
2384 DisasASI da
= get_asi(dc
, insn
, MO_TEUL
);
2389 case GET_ASI_DIRECT
:
2390 gen_swap(dc
, dst
, src
, addr
, da
.mem_idx
, da
.memop
);
2393 /* ??? Should be DAE_invalid_asi. */
2394 gen_exception(dc
, TT_DATA_ACCESS
);
2399 static void gen_cas_asi(DisasContext
*dc
, TCGv addr
, TCGv cmpv
,
2402 DisasASI da
= get_asi(dc
, insn
, MO_TEUL
);
2408 case GET_ASI_DIRECT
:
2409 oldv
= tcg_temp_new();
2410 tcg_gen_atomic_cmpxchg_tl(oldv
, addr
, cmpv
, gen_load_gpr(dc
, rd
),
2411 da
.mem_idx
, da
.memop
);
2412 gen_store_gpr(dc
, rd
, oldv
);
2413 tcg_temp_free(oldv
);
2416 /* ??? Should be DAE_invalid_asi. */
2417 gen_exception(dc
, TT_DATA_ACCESS
);
2422 static void gen_ldstub_asi(DisasContext
*dc
, TCGv dst
, TCGv addr
, int insn
)
2424 DisasASI da
= get_asi(dc
, insn
, MO_UB
);
2429 case GET_ASI_DIRECT
:
2430 gen_ldstub(dc
, dst
, addr
, da
.mem_idx
);
2433 /* ??? In theory, this should be raise DAE_invalid_asi.
2434 But the SS-20 roms do ldstuba [%l0] #ASI_M_CTL, %o1. */
2435 if (tb_cflags(dc
->base
.tb
) & CF_PARALLEL
) {
2436 gen_helper_exit_atomic(cpu_env
);
2438 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2439 TCGv_i32 r_mop
= tcg_const_i32(MO_UB
);
2443 t64
= tcg_temp_new_i64();
2444 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_mop
);
2446 s64
= tcg_const_i64(0xff);
2447 gen_helper_st_asi(cpu_env
, addr
, s64
, r_asi
, r_mop
);
2448 tcg_temp_free_i64(s64
);
2449 tcg_temp_free_i32(r_mop
);
2450 tcg_temp_free_i32(r_asi
);
2452 tcg_gen_trunc_i64_tl(dst
, t64
);
2453 tcg_temp_free_i64(t64
);
2456 dc
->npc
= DYNAMIC_PC
;
2463 #ifdef TARGET_SPARC64
2464 static void gen_ldf_asi(DisasContext
*dc
, TCGv addr
,
2465 int insn
, int size
, int rd
)
2467 DisasASI da
= get_asi(dc
, insn
, (size
== 4 ? MO_TEUL
: MO_TEUQ
));
2475 case GET_ASI_DIRECT
:
2476 gen_address_mask(dc
, addr
);
2479 d32
= gen_dest_fpr_F(dc
);
2480 tcg_gen_qemu_ld_i32(d32
, addr
, da
.mem_idx
, da
.memop
);
2481 gen_store_fpr_F(dc
, rd
, d32
);
2484 tcg_gen_qemu_ld_i64(cpu_fpr
[rd
/ 2], addr
, da
.mem_idx
,
2485 da
.memop
| MO_ALIGN_4
);
2488 d64
= tcg_temp_new_i64();
2489 tcg_gen_qemu_ld_i64(d64
, addr
, da
.mem_idx
, da
.memop
| MO_ALIGN_4
);
2490 tcg_gen_addi_tl(addr
, addr
, 8);
2491 tcg_gen_qemu_ld_i64(cpu_fpr
[rd
/2+1], addr
, da
.mem_idx
,
2492 da
.memop
| MO_ALIGN_4
);
2493 tcg_gen_mov_i64(cpu_fpr
[rd
/ 2], d64
);
2494 tcg_temp_free_i64(d64
);
2497 g_assert_not_reached();
2502 /* Valid for lddfa on aligned registers only. */
2503 if (size
== 8 && (rd
& 7) == 0) {
2508 gen_address_mask(dc
, addr
);
2510 /* The first operation checks required alignment. */
2511 memop
= da
.memop
| MO_ALIGN_64
;
2512 eight
= tcg_const_tl(8);
2513 for (i
= 0; ; ++i
) {
2514 tcg_gen_qemu_ld_i64(cpu_fpr
[rd
/ 2 + i
], addr
,
2519 tcg_gen_add_tl(addr
, addr
, eight
);
2522 tcg_temp_free(eight
);
2524 gen_exception(dc
, TT_ILL_INSN
);
2529 /* Valid for lddfa only. */
2531 gen_address_mask(dc
, addr
);
2532 tcg_gen_qemu_ld_i64(cpu_fpr
[rd
/ 2], addr
, da
.mem_idx
, da
.memop
);
2534 gen_exception(dc
, TT_ILL_INSN
);
2540 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2541 TCGv_i32 r_mop
= tcg_const_i32(da
.memop
);
2544 /* According to the table in the UA2011 manual, the only
2545 other asis that are valid for ldfa/lddfa/ldqfa are
2546 the NO_FAULT asis. We still need a helper for these,
2547 but we can just use the integer asi helper for them. */
2550 d64
= tcg_temp_new_i64();
2551 gen_helper_ld_asi(d64
, cpu_env
, addr
, r_asi
, r_mop
);
2552 d32
= gen_dest_fpr_F(dc
);
2553 tcg_gen_extrl_i64_i32(d32
, d64
);
2554 tcg_temp_free_i64(d64
);
2555 gen_store_fpr_F(dc
, rd
, d32
);
2558 gen_helper_ld_asi(cpu_fpr
[rd
/ 2], cpu_env
, addr
, r_asi
, r_mop
);
2561 d64
= tcg_temp_new_i64();
2562 gen_helper_ld_asi(d64
, cpu_env
, addr
, r_asi
, r_mop
);
2563 tcg_gen_addi_tl(addr
, addr
, 8);
2564 gen_helper_ld_asi(cpu_fpr
[rd
/2+1], cpu_env
, addr
, r_asi
, r_mop
);
2565 tcg_gen_mov_i64(cpu_fpr
[rd
/ 2], d64
);
2566 tcg_temp_free_i64(d64
);
2569 g_assert_not_reached();
2571 tcg_temp_free_i32(r_mop
);
2572 tcg_temp_free_i32(r_asi
);
2578 static void gen_stf_asi(DisasContext
*dc
, TCGv addr
,
2579 int insn
, int size
, int rd
)
2581 DisasASI da
= get_asi(dc
, insn
, (size
== 4 ? MO_TEUL
: MO_TEUQ
));
2588 case GET_ASI_DIRECT
:
2589 gen_address_mask(dc
, addr
);
2592 d32
= gen_load_fpr_F(dc
, rd
);
2593 tcg_gen_qemu_st_i32(d32
, addr
, da
.mem_idx
, da
.memop
);
2596 tcg_gen_qemu_st_i64(cpu_fpr
[rd
/ 2], addr
, da
.mem_idx
,
2597 da
.memop
| MO_ALIGN_4
);
2600 /* Only 4-byte alignment required. However, it is legal for the
2601 cpu to signal the alignment fault, and the OS trap handler is
2602 required to fix it up. Requiring 16-byte alignment here avoids
2603 having to probe the second page before performing the first
2605 tcg_gen_qemu_st_i64(cpu_fpr
[rd
/ 2], addr
, da
.mem_idx
,
2606 da
.memop
| MO_ALIGN_16
);
2607 tcg_gen_addi_tl(addr
, addr
, 8);
2608 tcg_gen_qemu_st_i64(cpu_fpr
[rd
/2+1], addr
, da
.mem_idx
, da
.memop
);
2611 g_assert_not_reached();
2616 /* Valid for stdfa on aligned registers only. */
2617 if (size
== 8 && (rd
& 7) == 0) {
2622 gen_address_mask(dc
, addr
);
2624 /* The first operation checks required alignment. */
2625 memop
= da
.memop
| MO_ALIGN_64
;
2626 eight
= tcg_const_tl(8);
2627 for (i
= 0; ; ++i
) {
2628 tcg_gen_qemu_st_i64(cpu_fpr
[rd
/ 2 + i
], addr
,
2633 tcg_gen_add_tl(addr
, addr
, eight
);
2636 tcg_temp_free(eight
);
2638 gen_exception(dc
, TT_ILL_INSN
);
2643 /* Valid for stdfa only. */
2645 gen_address_mask(dc
, addr
);
2646 tcg_gen_qemu_st_i64(cpu_fpr
[rd
/ 2], addr
, da
.mem_idx
, da
.memop
);
2648 gen_exception(dc
, TT_ILL_INSN
);
2653 /* According to the table in the UA2011 manual, the only
2654 other asis that are valid for ldfa/lddfa/ldqfa are
2655 the PST* asis, which aren't currently handled. */
2656 gen_exception(dc
, TT_ILL_INSN
);
2661 static void gen_ldda_asi(DisasContext
*dc
, TCGv addr
, int insn
, int rd
)
2663 DisasASI da
= get_asi(dc
, insn
, MO_TEUQ
);
2664 TCGv_i64 hi
= gen_dest_gpr(dc
, rd
);
2665 TCGv_i64 lo
= gen_dest_gpr(dc
, rd
+ 1);
2671 case GET_ASI_DTWINX
:
2672 gen_address_mask(dc
, addr
);
2673 tcg_gen_qemu_ld_i64(hi
, addr
, da
.mem_idx
, da
.memop
| MO_ALIGN_16
);
2674 tcg_gen_addi_tl(addr
, addr
, 8);
2675 tcg_gen_qemu_ld_i64(lo
, addr
, da
.mem_idx
, da
.memop
);
2678 case GET_ASI_DIRECT
:
2680 TCGv_i64 tmp
= tcg_temp_new_i64();
2682 gen_address_mask(dc
, addr
);
2683 tcg_gen_qemu_ld_i64(tmp
, addr
, da
.mem_idx
, da
.memop
);
2685 /* Note that LE ldda acts as if each 32-bit register
2686 result is byte swapped. Having just performed one
2687 64-bit bswap, we need now to swap the writebacks. */
2688 if ((da
.memop
& MO_BSWAP
) == MO_TE
) {
2689 tcg_gen_extr32_i64(lo
, hi
, tmp
);
2691 tcg_gen_extr32_i64(hi
, lo
, tmp
);
2693 tcg_temp_free_i64(tmp
);
2698 /* ??? In theory we've handled all of the ASIs that are valid
2699 for ldda, and this should raise DAE_invalid_asi. However,
2700 real hardware allows others. This can be seen with e.g.
2701 FreeBSD 10.3 wrt ASI_IC_TAG. */
2703 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2704 TCGv_i32 r_mop
= tcg_const_i32(da
.memop
);
2705 TCGv_i64 tmp
= tcg_temp_new_i64();
2708 gen_helper_ld_asi(tmp
, cpu_env
, addr
, r_asi
, r_mop
);
2709 tcg_temp_free_i32(r_asi
);
2710 tcg_temp_free_i32(r_mop
);
2713 if ((da
.memop
& MO_BSWAP
) == MO_TE
) {
2714 tcg_gen_extr32_i64(lo
, hi
, tmp
);
2716 tcg_gen_extr32_i64(hi
, lo
, tmp
);
2718 tcg_temp_free_i64(tmp
);
2723 gen_store_gpr(dc
, rd
, hi
);
2724 gen_store_gpr(dc
, rd
+ 1, lo
);
2727 static void gen_stda_asi(DisasContext
*dc
, TCGv hi
, TCGv addr
,
2730 DisasASI da
= get_asi(dc
, insn
, MO_TEUQ
);
2731 TCGv lo
= gen_load_gpr(dc
, rd
+ 1);
2737 case GET_ASI_DTWINX
:
2738 gen_address_mask(dc
, addr
);
2739 tcg_gen_qemu_st_i64(hi
, addr
, da
.mem_idx
, da
.memop
| MO_ALIGN_16
);
2740 tcg_gen_addi_tl(addr
, addr
, 8);
2741 tcg_gen_qemu_st_i64(lo
, addr
, da
.mem_idx
, da
.memop
);
2744 case GET_ASI_DIRECT
:
2746 TCGv_i64 t64
= tcg_temp_new_i64();
2748 /* Note that LE stda acts as if each 32-bit register result is
2749 byte swapped. We will perform one 64-bit LE store, so now
2750 we must swap the order of the construction. */
2751 if ((da
.memop
& MO_BSWAP
) == MO_TE
) {
2752 tcg_gen_concat32_i64(t64
, lo
, hi
);
2754 tcg_gen_concat32_i64(t64
, hi
, lo
);
2756 gen_address_mask(dc
, addr
);
2757 tcg_gen_qemu_st_i64(t64
, addr
, da
.mem_idx
, da
.memop
);
2758 tcg_temp_free_i64(t64
);
2763 /* ??? In theory we've handled all of the ASIs that are valid
2764 for stda, and this should raise DAE_invalid_asi. */
2766 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2767 TCGv_i32 r_mop
= tcg_const_i32(da
.memop
);
2768 TCGv_i64 t64
= tcg_temp_new_i64();
2771 if ((da
.memop
& MO_BSWAP
) == MO_TE
) {
2772 tcg_gen_concat32_i64(t64
, lo
, hi
);
2774 tcg_gen_concat32_i64(t64
, hi
, lo
);
2778 gen_helper_st_asi(cpu_env
, addr
, t64
, r_asi
, r_mop
);
2779 tcg_temp_free_i32(r_mop
);
2780 tcg_temp_free_i32(r_asi
);
2781 tcg_temp_free_i64(t64
);
2787 static void gen_casx_asi(DisasContext
*dc
, TCGv addr
, TCGv cmpv
,
2790 DisasASI da
= get_asi(dc
, insn
, MO_TEUQ
);
2796 case GET_ASI_DIRECT
:
2797 oldv
= tcg_temp_new();
2798 tcg_gen_atomic_cmpxchg_tl(oldv
, addr
, cmpv
, gen_load_gpr(dc
, rd
),
2799 da
.mem_idx
, da
.memop
);
2800 gen_store_gpr(dc
, rd
, oldv
);
2801 tcg_temp_free(oldv
);
2804 /* ??? Should be DAE_invalid_asi. */
2805 gen_exception(dc
, TT_DATA_ACCESS
);
2810 #elif !defined(CONFIG_USER_ONLY)
2811 static void gen_ldda_asi(DisasContext
*dc
, TCGv addr
, int insn
, int rd
)
2813 /* ??? Work around an apparent bug in Ubuntu gcc 4.8.2-10ubuntu2+12,
2814 whereby "rd + 1" elicits "error: array subscript is above array".
2815 Since we have already asserted that rd is even, the semantics
2817 TCGv lo
= gen_dest_gpr(dc
, rd
| 1);
2818 TCGv hi
= gen_dest_gpr(dc
, rd
);
2819 TCGv_i64 t64
= tcg_temp_new_i64();
2820 DisasASI da
= get_asi(dc
, insn
, MO_TEUQ
);
2824 tcg_temp_free_i64(t64
);
2826 case GET_ASI_DIRECT
:
2827 gen_address_mask(dc
, addr
);
2828 tcg_gen_qemu_ld_i64(t64
, addr
, da
.mem_idx
, da
.memop
);
2832 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2833 TCGv_i32 r_mop
= tcg_const_i32(MO_UQ
);
2836 gen_helper_ld_asi(t64
, cpu_env
, addr
, r_asi
, r_mop
);
2837 tcg_temp_free_i32(r_mop
);
2838 tcg_temp_free_i32(r_asi
);
2843 tcg_gen_extr_i64_i32(lo
, hi
, t64
);
2844 tcg_temp_free_i64(t64
);
2845 gen_store_gpr(dc
, rd
| 1, lo
);
2846 gen_store_gpr(dc
, rd
, hi
);
2849 static void gen_stda_asi(DisasContext
*dc
, TCGv hi
, TCGv addr
,
2852 DisasASI da
= get_asi(dc
, insn
, MO_TEUQ
);
2853 TCGv lo
= gen_load_gpr(dc
, rd
+ 1);
2854 TCGv_i64 t64
= tcg_temp_new_i64();
2856 tcg_gen_concat_tl_i64(t64
, lo
, hi
);
2861 case GET_ASI_DIRECT
:
2862 gen_address_mask(dc
, addr
);
2863 tcg_gen_qemu_st_i64(t64
, addr
, da
.mem_idx
, da
.memop
);
2866 /* Store 32 bytes of T64 to ADDR. */
2867 /* ??? The original qemu code suggests 8-byte alignment, dropping
2868 the low bits, but the only place I can see this used is in the
2869 Linux kernel with 32 byte alignment, which would make more sense
2870 as a cacheline-style operation. */
2872 TCGv d_addr
= tcg_temp_new();
2873 TCGv eight
= tcg_const_tl(8);
2876 tcg_gen_andi_tl(d_addr
, addr
, -8);
2877 for (i
= 0; i
< 32; i
+= 8) {
2878 tcg_gen_qemu_st_i64(t64
, d_addr
, da
.mem_idx
, da
.memop
);
2879 tcg_gen_add_tl(d_addr
, d_addr
, eight
);
2882 tcg_temp_free(d_addr
);
2883 tcg_temp_free(eight
);
2888 TCGv_i32 r_asi
= tcg_const_i32(da
.asi
);
2889 TCGv_i32 r_mop
= tcg_const_i32(MO_UQ
);
2892 gen_helper_st_asi(cpu_env
, addr
, t64
, r_asi
, r_mop
);
2893 tcg_temp_free_i32(r_mop
);
2894 tcg_temp_free_i32(r_asi
);
2899 tcg_temp_free_i64(t64
);
2903 static TCGv
get_src1(DisasContext
*dc
, unsigned int insn
)
2905 unsigned int rs1
= GET_FIELD(insn
, 13, 17);
2906 return gen_load_gpr(dc
, rs1
);
2909 static TCGv
get_src2(DisasContext
*dc
, unsigned int insn
)
2911 if (IS_IMM
) { /* immediate */
2912 target_long simm
= GET_FIELDs(insn
, 19, 31);
2913 TCGv t
= get_temp_tl(dc
);
2914 tcg_gen_movi_tl(t
, simm
);
2916 } else { /* register */
2917 unsigned int rs2
= GET_FIELD(insn
, 27, 31);
2918 return gen_load_gpr(dc
, rs2
);
2922 #ifdef TARGET_SPARC64
2923 static void gen_fmovs(DisasContext
*dc
, DisasCompare
*cmp
, int rd
, int rs
)
2925 TCGv_i32 c32
, zero
, dst
, s1
, s2
;
2927 /* We have two choices here: extend the 32 bit data and use movcond_i64,
2928 or fold the comparison down to 32 bits and use movcond_i32. Choose
2930 c32
= tcg_temp_new_i32();
2932 tcg_gen_extrl_i64_i32(c32
, cmp
->c1
);
2934 TCGv_i64 c64
= tcg_temp_new_i64();
2935 tcg_gen_setcond_i64(cmp
->cond
, c64
, cmp
->c1
, cmp
->c2
);
2936 tcg_gen_extrl_i64_i32(c32
, c64
);
2937 tcg_temp_free_i64(c64
);
2940 s1
= gen_load_fpr_F(dc
, rs
);
2941 s2
= gen_load_fpr_F(dc
, rd
);
2942 dst
= gen_dest_fpr_F(dc
);
2943 zero
= tcg_const_i32(0);
2945 tcg_gen_movcond_i32(TCG_COND_NE
, dst
, c32
, zero
, s1
, s2
);
2947 tcg_temp_free_i32(c32
);
2948 tcg_temp_free_i32(zero
);
2949 gen_store_fpr_F(dc
, rd
, dst
);
2952 static void gen_fmovd(DisasContext
*dc
, DisasCompare
*cmp
, int rd
, int rs
)
2954 TCGv_i64 dst
= gen_dest_fpr_D(dc
, rd
);
2955 tcg_gen_movcond_i64(cmp
->cond
, dst
, cmp
->c1
, cmp
->c2
,
2956 gen_load_fpr_D(dc
, rs
),
2957 gen_load_fpr_D(dc
, rd
));
2958 gen_store_fpr_D(dc
, rd
, dst
);
2961 static void gen_fmovq(DisasContext
*dc
, DisasCompare
*cmp
, int rd
, int rs
)
2963 int qd
= QFPREG(rd
);
2964 int qs
= QFPREG(rs
);
2966 tcg_gen_movcond_i64(cmp
->cond
, cpu_fpr
[qd
/ 2], cmp
->c1
, cmp
->c2
,
2967 cpu_fpr
[qs
/ 2], cpu_fpr
[qd
/ 2]);
2968 tcg_gen_movcond_i64(cmp
->cond
, cpu_fpr
[qd
/ 2 + 1], cmp
->c1
, cmp
->c2
,
2969 cpu_fpr
[qs
/ 2 + 1], cpu_fpr
[qd
/ 2 + 1]);
2971 gen_update_fprs_dirty(dc
, qd
);
2974 #ifndef CONFIG_USER_ONLY
2975 static inline void gen_load_trap_state_at_tl(TCGv_ptr r_tsptr
, TCGv_env cpu_env
)
2977 TCGv_i32 r_tl
= tcg_temp_new_i32();
2979 /* load env->tl into r_tl */
2980 tcg_gen_ld_i32(r_tl
, cpu_env
, offsetof(CPUSPARCState
, tl
));
2982 /* tl = [0 ... MAXTL_MASK] where MAXTL_MASK must be power of 2 */
2983 tcg_gen_andi_i32(r_tl
, r_tl
, MAXTL_MASK
);
2985 /* calculate offset to current trap state from env->ts, reuse r_tl */
2986 tcg_gen_muli_i32(r_tl
, r_tl
, sizeof (trap_state
));
2987 tcg_gen_addi_ptr(r_tsptr
, cpu_env
, offsetof(CPUSPARCState
, ts
));
2989 /* tsptr = env->ts[env->tl & MAXTL_MASK] */
2991 TCGv_ptr r_tl_tmp
= tcg_temp_new_ptr();
2992 tcg_gen_ext_i32_ptr(r_tl_tmp
, r_tl
);
2993 tcg_gen_add_ptr(r_tsptr
, r_tsptr
, r_tl_tmp
);
2994 tcg_temp_free_ptr(r_tl_tmp
);
2997 tcg_temp_free_i32(r_tl
);
3001 static void gen_edge(DisasContext
*dc
, TCGv dst
, TCGv s1
, TCGv s2
,
3002 int width
, bool cc
, bool left
)
3004 TCGv lo1
, lo2
, t1
, t2
;
3005 uint64_t amask
, tabl
, tabr
;
3006 int shift
, imask
, omask
;
3009 tcg_gen_mov_tl(cpu_cc_src
, s1
);
3010 tcg_gen_mov_tl(cpu_cc_src2
, s2
);
3011 tcg_gen_sub_tl(cpu_cc_dst
, s1
, s2
);
3012 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUB
);
3013 dc
->cc_op
= CC_OP_SUB
;
3016 /* Theory of operation: there are two tables, left and right (not to
3017 be confused with the left and right versions of the opcode). These
3018 are indexed by the low 3 bits of the inputs. To make things "easy",
3019 these tables are loaded into two constants, TABL and TABR below.
3020 The operation index = (input & imask) << shift calculates the index
3021 into the constant, while val = (table >> index) & omask calculates
3022 the value we're looking for. */
3029 tabl
= 0x80c0e0f0f8fcfeffULL
;
3030 tabr
= 0xff7f3f1f0f070301ULL
;
3032 tabl
= 0x0103070f1f3f7fffULL
;
3033 tabr
= 0xfffefcf8f0e0c080ULL
;
3053 tabl
= (2 << 2) | 3;
3054 tabr
= (3 << 2) | 1;
3056 tabl
= (1 << 2) | 3;
3057 tabr
= (3 << 2) | 2;
3064 lo1
= tcg_temp_new();
3065 lo2
= tcg_temp_new();
3066 tcg_gen_andi_tl(lo1
, s1
, imask
);
3067 tcg_gen_andi_tl(lo2
, s2
, imask
);
3068 tcg_gen_shli_tl(lo1
, lo1
, shift
);
3069 tcg_gen_shli_tl(lo2
, lo2
, shift
);
3071 t1
= tcg_const_tl(tabl
);
3072 t2
= tcg_const_tl(tabr
);
3073 tcg_gen_shr_tl(lo1
, t1
, lo1
);
3074 tcg_gen_shr_tl(lo2
, t2
, lo2
);
3075 tcg_gen_andi_tl(dst
, lo1
, omask
);
3076 tcg_gen_andi_tl(lo2
, lo2
, omask
);
3080 amask
&= 0xffffffffULL
;
3082 tcg_gen_andi_tl(s1
, s1
, amask
);
3083 tcg_gen_andi_tl(s2
, s2
, amask
);
3085 /* We want to compute
3086 dst = (s1 == s2 ? lo1 : lo1 & lo2).
3087 We've already done dst = lo1, so this reduces to
3088 dst &= (s1 == s2 ? -1 : lo2)
3093 tcg_gen_setcond_tl(TCG_COND_EQ
, t1
, s1
, s2
);
3094 tcg_gen_neg_tl(t1
, t1
);
3095 tcg_gen_or_tl(lo2
, lo2
, t1
);
3096 tcg_gen_and_tl(dst
, dst
, lo2
);
3104 static void gen_alignaddr(TCGv dst
, TCGv s1
, TCGv s2
, bool left
)
3106 TCGv tmp
= tcg_temp_new();
3108 tcg_gen_add_tl(tmp
, s1
, s2
);
3109 tcg_gen_andi_tl(dst
, tmp
, -8);
3111 tcg_gen_neg_tl(tmp
, tmp
);
3113 tcg_gen_deposit_tl(cpu_gsr
, cpu_gsr
, tmp
, 0, 3);
3118 static void gen_faligndata(TCGv dst
, TCGv gsr
, TCGv s1
, TCGv s2
)
3122 t1
= tcg_temp_new();
3123 t2
= tcg_temp_new();
3124 shift
= tcg_temp_new();
3126 tcg_gen_andi_tl(shift
, gsr
, 7);
3127 tcg_gen_shli_tl(shift
, shift
, 3);
3128 tcg_gen_shl_tl(t1
, s1
, shift
);
3130 /* A shift of 64 does not produce 0 in TCG. Divide this into a
3131 shift of (up to 63) followed by a constant shift of 1. */
3132 tcg_gen_xori_tl(shift
, shift
, 63);
3133 tcg_gen_shr_tl(t2
, s2
, shift
);
3134 tcg_gen_shri_tl(t2
, t2
, 1);
3136 tcg_gen_or_tl(dst
, t1
, t2
);
3140 tcg_temp_free(shift
);
3144 #define CHECK_IU_FEATURE(dc, FEATURE) \
3145 if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
3147 #define CHECK_FPU_FEATURE(dc, FEATURE) \
3148 if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \
3151 /* before an instruction, dc->pc must be static */
3152 static void disas_sparc_insn(DisasContext
* dc
, unsigned int insn
)
3154 unsigned int opc
, rs1
, rs2
, rd
;
3155 TCGv cpu_src1
, cpu_src2
;
3156 TCGv_i32 cpu_src1_32
, cpu_src2_32
, cpu_dst_32
;
3157 TCGv_i64 cpu_src1_64
, cpu_src2_64
, cpu_dst_64
;
3160 opc
= GET_FIELD(insn
, 0, 1);
3161 rd
= GET_FIELD(insn
, 2, 6);
3164 case 0: /* branches/sethi */
3166 unsigned int xop
= GET_FIELD(insn
, 7, 9);
3169 #ifdef TARGET_SPARC64
3170 case 0x1: /* V9 BPcc */
3174 target
= GET_FIELD_SP(insn
, 0, 18);
3175 target
= sign_extend(target
, 19);
3177 cc
= GET_FIELD_SP(insn
, 20, 21);
3179 do_branch(dc
, target
, insn
, 0);
3181 do_branch(dc
, target
, insn
, 1);
3186 case 0x3: /* V9 BPr */
3188 target
= GET_FIELD_SP(insn
, 0, 13) |
3189 (GET_FIELD_SP(insn
, 20, 21) << 14);
3190 target
= sign_extend(target
, 16);
3192 cpu_src1
= get_src1(dc
, insn
);
3193 do_branch_reg(dc
, target
, insn
, cpu_src1
);
3196 case 0x5: /* V9 FBPcc */
3198 int cc
= GET_FIELD_SP(insn
, 20, 21);
3199 if (gen_trap_ifnofpu(dc
)) {
3202 target
= GET_FIELD_SP(insn
, 0, 18);
3203 target
= sign_extend(target
, 19);
3205 do_fbranch(dc
, target
, insn
, cc
);
3209 case 0x7: /* CBN+x */
3214 case 0x2: /* BN+x */
3216 target
= GET_FIELD(insn
, 10, 31);
3217 target
= sign_extend(target
, 22);
3219 do_branch(dc
, target
, insn
, 0);
3222 case 0x6: /* FBN+x */
3224 if (gen_trap_ifnofpu(dc
)) {
3227 target
= GET_FIELD(insn
, 10, 31);
3228 target
= sign_extend(target
, 22);
3230 do_fbranch(dc
, target
, insn
, 0);
3233 case 0x4: /* SETHI */
3234 /* Special-case %g0 because that's the canonical nop. */
3236 uint32_t value
= GET_FIELD(insn
, 10, 31);
3237 TCGv t
= gen_dest_gpr(dc
, rd
);
3238 tcg_gen_movi_tl(t
, value
<< 10);
3239 gen_store_gpr(dc
, rd
, t
);
3242 case 0x0: /* UNIMPL */
3251 target_long target
= GET_FIELDs(insn
, 2, 31) << 2;
3252 TCGv o7
= gen_dest_gpr(dc
, 15);
3254 tcg_gen_movi_tl(o7
, dc
->pc
);
3255 gen_store_gpr(dc
, 15, o7
);
3258 #ifdef TARGET_SPARC64
3259 if (unlikely(AM_CHECK(dc
))) {
3260 target
&= 0xffffffffULL
;
3266 case 2: /* FPU & Logical Operations */
3268 unsigned int xop
= GET_FIELD(insn
, 7, 12);
3269 TCGv cpu_dst
= get_temp_tl(dc
);
3272 if (xop
== 0x3a) { /* generate trap */
3273 int cond
= GET_FIELD(insn
, 3, 6);
3275 TCGLabel
*l1
= NULL
;
3286 /* Conditional trap. */
3288 #ifdef TARGET_SPARC64
3290 int cc
= GET_FIELD_SP(insn
, 11, 12);
3292 gen_compare(&cmp
, 0, cond
, dc
);
3293 } else if (cc
== 2) {
3294 gen_compare(&cmp
, 1, cond
, dc
);
3299 gen_compare(&cmp
, 0, cond
, dc
);
3301 l1
= gen_new_label();
3302 tcg_gen_brcond_tl(tcg_invert_cond(cmp
.cond
),
3303 cmp
.c1
, cmp
.c2
, l1
);
3307 mask
= ((dc
->def
->features
& CPU_FEATURE_HYPV
) && supervisor(dc
)
3308 ? UA2005_HTRAP_MASK
: V8_TRAP_MASK
);
3310 /* Don't use the normal temporaries, as they may well have
3311 gone out of scope with the branch above. While we're
3312 doing that we might as well pre-truncate to 32-bit. */
3313 trap
= tcg_temp_new_i32();
3315 rs1
= GET_FIELD_SP(insn
, 14, 18);
3317 rs2
= GET_FIELD_SP(insn
, 0, 7);
3319 tcg_gen_movi_i32(trap
, (rs2
& mask
) + TT_TRAP
);
3320 /* Signal that the trap value is fully constant. */
3323 TCGv t1
= gen_load_gpr(dc
, rs1
);
3324 tcg_gen_trunc_tl_i32(trap
, t1
);
3325 tcg_gen_addi_i32(trap
, trap
, rs2
);
3329 rs2
= GET_FIELD_SP(insn
, 0, 4);
3330 t1
= gen_load_gpr(dc
, rs1
);
3331 t2
= gen_load_gpr(dc
, rs2
);
3332 tcg_gen_add_tl(t1
, t1
, t2
);
3333 tcg_gen_trunc_tl_i32(trap
, t1
);
3336 tcg_gen_andi_i32(trap
, trap
, mask
);
3337 tcg_gen_addi_i32(trap
, trap
, TT_TRAP
);
3340 gen_helper_raise_exception(cpu_env
, trap
);
3341 tcg_temp_free_i32(trap
);
3344 /* An unconditional trap ends the TB. */
3345 dc
->base
.is_jmp
= DISAS_NORETURN
;
3348 /* A conditional trap falls through to the next insn. */
3352 } else if (xop
== 0x28) {
3353 rs1
= GET_FIELD(insn
, 13, 17);
3356 #ifndef TARGET_SPARC64
3357 case 0x01 ... 0x0e: /* undefined in the SPARCv8
3358 manual, rdy on the microSPARC
3360 case 0x0f: /* stbar in the SPARCv8 manual,
3361 rdy on the microSPARC II */
3362 case 0x10 ... 0x1f: /* implementation-dependent in the
3363 SPARCv8 manual, rdy on the
3366 if (rs1
== 0x11 && dc
->def
->features
& CPU_FEATURE_ASR17
) {
3367 TCGv t
= gen_dest_gpr(dc
, rd
);
3368 /* Read Asr17 for a Leon3 monoprocessor */
3369 tcg_gen_movi_tl(t
, (1 << 8) | (dc
->def
->nwindows
- 1));
3370 gen_store_gpr(dc
, rd
, t
);
3374 gen_store_gpr(dc
, rd
, cpu_y
);
3376 #ifdef TARGET_SPARC64
3377 case 0x2: /* V9 rdccr */
3379 gen_helper_rdccr(cpu_dst
, cpu_env
);
3380 gen_store_gpr(dc
, rd
, cpu_dst
);
3382 case 0x3: /* V9 rdasi */
3383 tcg_gen_movi_tl(cpu_dst
, dc
->asi
);
3384 gen_store_gpr(dc
, rd
, cpu_dst
);
3386 case 0x4: /* V9 rdtick */
3391 r_tickptr
= tcg_temp_new_ptr();
3392 r_const
= tcg_const_i32(dc
->mem_idx
);
3393 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3394 offsetof(CPUSPARCState
, tick
));
3395 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
3398 gen_helper_tick_get_count(cpu_dst
, cpu_env
, r_tickptr
,
3400 tcg_temp_free_ptr(r_tickptr
);
3401 tcg_temp_free_i32(r_const
);
3402 gen_store_gpr(dc
, rd
, cpu_dst
);
3403 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
3404 /* I/O operations in icount mode must end the TB */
3405 dc
->base
.is_jmp
= DISAS_EXIT
;
3409 case 0x5: /* V9 rdpc */
3411 TCGv t
= gen_dest_gpr(dc
, rd
);
3412 if (unlikely(AM_CHECK(dc
))) {
3413 tcg_gen_movi_tl(t
, dc
->pc
& 0xffffffffULL
);
3415 tcg_gen_movi_tl(t
, dc
->pc
);
3417 gen_store_gpr(dc
, rd
, t
);
3420 case 0x6: /* V9 rdfprs */
3421 tcg_gen_ext_i32_tl(cpu_dst
, cpu_fprs
);
3422 gen_store_gpr(dc
, rd
, cpu_dst
);
3424 case 0xf: /* V9 membar */
3425 break; /* no effect */
3426 case 0x13: /* Graphics Status */
3427 if (gen_trap_ifnofpu(dc
)) {
3430 gen_store_gpr(dc
, rd
, cpu_gsr
);
3432 case 0x16: /* Softint */
3433 tcg_gen_ld32s_tl(cpu_dst
, cpu_env
,
3434 offsetof(CPUSPARCState
, softint
));
3435 gen_store_gpr(dc
, rd
, cpu_dst
);
3437 case 0x17: /* Tick compare */
3438 gen_store_gpr(dc
, rd
, cpu_tick_cmpr
);
3440 case 0x18: /* System tick */
3445 r_tickptr
= tcg_temp_new_ptr();
3446 r_const
= tcg_const_i32(dc
->mem_idx
);
3447 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3448 offsetof(CPUSPARCState
, stick
));
3449 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
3452 gen_helper_tick_get_count(cpu_dst
, cpu_env
, r_tickptr
,
3454 tcg_temp_free_ptr(r_tickptr
);
3455 tcg_temp_free_i32(r_const
);
3456 gen_store_gpr(dc
, rd
, cpu_dst
);
3457 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
3458 /* I/O operations in icount mode must end the TB */
3459 dc
->base
.is_jmp
= DISAS_EXIT
;
3463 case 0x19: /* System tick compare */
3464 gen_store_gpr(dc
, rd
, cpu_stick_cmpr
);
3466 case 0x1a: /* UltraSPARC-T1 Strand status */
3467 /* XXX HYPV check maybe not enough, UA2005 & UA2007 describe
3468 * this ASR as impl. dep
3470 CHECK_IU_FEATURE(dc
, HYPV
);
3472 TCGv t
= gen_dest_gpr(dc
, rd
);
3473 tcg_gen_movi_tl(t
, 1UL);
3474 gen_store_gpr(dc
, rd
, t
);
3477 case 0x10: /* Performance Control */
3478 case 0x11: /* Performance Instrumentation Counter */
3479 case 0x12: /* Dispatch Control */
3480 case 0x14: /* Softint set, WO */
3481 case 0x15: /* Softint clear, WO */
3486 #if !defined(CONFIG_USER_ONLY)
3487 } else if (xop
== 0x29) { /* rdpsr / UA2005 rdhpr */
3488 #ifndef TARGET_SPARC64
3489 if (!supervisor(dc
)) {
3493 gen_helper_rdpsr(cpu_dst
, cpu_env
);
3495 CHECK_IU_FEATURE(dc
, HYPV
);
3496 if (!hypervisor(dc
))
3498 rs1
= GET_FIELD(insn
, 13, 17);
3501 tcg_gen_ld_i64(cpu_dst
, cpu_env
,
3502 offsetof(CPUSPARCState
, hpstate
));
3505 // gen_op_rdhtstate();
3508 tcg_gen_mov_tl(cpu_dst
, cpu_hintp
);
3511 tcg_gen_mov_tl(cpu_dst
, cpu_htba
);
3514 tcg_gen_mov_tl(cpu_dst
, cpu_hver
);
3516 case 31: // hstick_cmpr
3517 tcg_gen_mov_tl(cpu_dst
, cpu_hstick_cmpr
);
3523 gen_store_gpr(dc
, rd
, cpu_dst
);
3525 } else if (xop
== 0x2a) { /* rdwim / V9 rdpr */
3526 if (!supervisor(dc
)) {
3529 cpu_tmp0
= get_temp_tl(dc
);
3530 #ifdef TARGET_SPARC64
3531 rs1
= GET_FIELD(insn
, 13, 17);
3537 r_tsptr
= tcg_temp_new_ptr();
3538 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3539 tcg_gen_ld_tl(cpu_tmp0
, r_tsptr
,
3540 offsetof(trap_state
, tpc
));
3541 tcg_temp_free_ptr(r_tsptr
);
3548 r_tsptr
= tcg_temp_new_ptr();
3549 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3550 tcg_gen_ld_tl(cpu_tmp0
, r_tsptr
,
3551 offsetof(trap_state
, tnpc
));
3552 tcg_temp_free_ptr(r_tsptr
);
3559 r_tsptr
= tcg_temp_new_ptr();
3560 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3561 tcg_gen_ld_tl(cpu_tmp0
, r_tsptr
,
3562 offsetof(trap_state
, tstate
));
3563 tcg_temp_free_ptr(r_tsptr
);
3568 TCGv_ptr r_tsptr
= tcg_temp_new_ptr();
3570 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
3571 tcg_gen_ld32s_tl(cpu_tmp0
, r_tsptr
,
3572 offsetof(trap_state
, tt
));
3573 tcg_temp_free_ptr(r_tsptr
);
3581 r_tickptr
= tcg_temp_new_ptr();
3582 r_const
= tcg_const_i32(dc
->mem_idx
);
3583 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
3584 offsetof(CPUSPARCState
, tick
));
3585 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
3588 gen_helper_tick_get_count(cpu_tmp0
, cpu_env
,
3589 r_tickptr
, r_const
);
3590 tcg_temp_free_ptr(r_tickptr
);
3591 tcg_temp_free_i32(r_const
);
3592 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
3593 /* I/O operations in icount mode must end the TB */
3594 dc
->base
.is_jmp
= DISAS_EXIT
;
3599 tcg_gen_mov_tl(cpu_tmp0
, cpu_tbr
);
3602 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3603 offsetof(CPUSPARCState
, pstate
));
3606 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3607 offsetof(CPUSPARCState
, tl
));
3610 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3611 offsetof(CPUSPARCState
, psrpil
));
3614 gen_helper_rdcwp(cpu_tmp0
, cpu_env
);
3617 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3618 offsetof(CPUSPARCState
, cansave
));
3620 case 11: // canrestore
3621 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3622 offsetof(CPUSPARCState
, canrestore
));
3624 case 12: // cleanwin
3625 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3626 offsetof(CPUSPARCState
, cleanwin
));
3628 case 13: // otherwin
3629 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3630 offsetof(CPUSPARCState
, otherwin
));
3633 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3634 offsetof(CPUSPARCState
, wstate
));
3636 case 16: // UA2005 gl
3637 CHECK_IU_FEATURE(dc
, GL
);
3638 tcg_gen_ld32s_tl(cpu_tmp0
, cpu_env
,
3639 offsetof(CPUSPARCState
, gl
));
3641 case 26: // UA2005 strand status
3642 CHECK_IU_FEATURE(dc
, HYPV
);
3643 if (!hypervisor(dc
))
3645 tcg_gen_mov_tl(cpu_tmp0
, cpu_ssr
);
3648 tcg_gen_mov_tl(cpu_tmp0
, cpu_ver
);
3655 tcg_gen_ext_i32_tl(cpu_tmp0
, cpu_wim
);
3657 gen_store_gpr(dc
, rd
, cpu_tmp0
);
3660 #if defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)
3661 } else if (xop
== 0x2b) { /* rdtbr / V9 flushw */
3662 #ifdef TARGET_SPARC64
3663 gen_helper_flushw(cpu_env
);
3665 if (!supervisor(dc
))
3667 gen_store_gpr(dc
, rd
, cpu_tbr
);
3671 } else if (xop
== 0x34) { /* FPU Operations */
3672 if (gen_trap_ifnofpu(dc
)) {
3675 gen_op_clear_ieee_excp_and_FTT();
3676 rs1
= GET_FIELD(insn
, 13, 17);
3677 rs2
= GET_FIELD(insn
, 27, 31);
3678 xop
= GET_FIELD(insn
, 18, 26);
3681 case 0x1: /* fmovs */
3682 cpu_src1_32
= gen_load_fpr_F(dc
, rs2
);
3683 gen_store_fpr_F(dc
, rd
, cpu_src1_32
);
3685 case 0x5: /* fnegs */
3686 gen_ne_fop_FF(dc
, rd
, rs2
, gen_helper_fnegs
);
3688 case 0x9: /* fabss */
3689 gen_ne_fop_FF(dc
, rd
, rs2
, gen_helper_fabss
);
3691 case 0x29: /* fsqrts */
3692 CHECK_FPU_FEATURE(dc
, FSQRT
);
3693 gen_fop_FF(dc
, rd
, rs2
, gen_helper_fsqrts
);
3695 case 0x2a: /* fsqrtd */
3696 CHECK_FPU_FEATURE(dc
, FSQRT
);
3697 gen_fop_DD(dc
, rd
, rs2
, gen_helper_fsqrtd
);
3699 case 0x2b: /* fsqrtq */
3700 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3701 gen_fop_QQ(dc
, rd
, rs2
, gen_helper_fsqrtq
);
3703 case 0x41: /* fadds */
3704 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fadds
);
3706 case 0x42: /* faddd */
3707 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_faddd
);
3709 case 0x43: /* faddq */
3710 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3711 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_faddq
);
3713 case 0x45: /* fsubs */
3714 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fsubs
);
3716 case 0x46: /* fsubd */
3717 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fsubd
);
3719 case 0x47: /* fsubq */
3720 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3721 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_fsubq
);
3723 case 0x49: /* fmuls */
3724 CHECK_FPU_FEATURE(dc
, FMUL
);
3725 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fmuls
);
3727 case 0x4a: /* fmuld */
3728 CHECK_FPU_FEATURE(dc
, FMUL
);
3729 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmuld
);
3731 case 0x4b: /* fmulq */
3732 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3733 CHECK_FPU_FEATURE(dc
, FMUL
);
3734 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_fmulq
);
3736 case 0x4d: /* fdivs */
3737 gen_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fdivs
);
3739 case 0x4e: /* fdivd */
3740 gen_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fdivd
);
3742 case 0x4f: /* fdivq */
3743 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3744 gen_fop_QQQ(dc
, rd
, rs1
, rs2
, gen_helper_fdivq
);
3746 case 0x69: /* fsmuld */
3747 CHECK_FPU_FEATURE(dc
, FSMULD
);
3748 gen_fop_DFF(dc
, rd
, rs1
, rs2
, gen_helper_fsmuld
);
3750 case 0x6e: /* fdmulq */
3751 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3752 gen_fop_QDD(dc
, rd
, rs1
, rs2
, gen_helper_fdmulq
);
3754 case 0xc4: /* fitos */
3755 gen_fop_FF(dc
, rd
, rs2
, gen_helper_fitos
);
3757 case 0xc6: /* fdtos */
3758 gen_fop_FD(dc
, rd
, rs2
, gen_helper_fdtos
);
3760 case 0xc7: /* fqtos */
3761 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3762 gen_fop_FQ(dc
, rd
, rs2
, gen_helper_fqtos
);
3764 case 0xc8: /* fitod */
3765 gen_ne_fop_DF(dc
, rd
, rs2
, gen_helper_fitod
);
3767 case 0xc9: /* fstod */
3768 gen_ne_fop_DF(dc
, rd
, rs2
, gen_helper_fstod
);
3770 case 0xcb: /* fqtod */
3771 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3772 gen_fop_DQ(dc
, rd
, rs2
, gen_helper_fqtod
);
3774 case 0xcc: /* fitoq */
3775 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3776 gen_ne_fop_QF(dc
, rd
, rs2
, gen_helper_fitoq
);
3778 case 0xcd: /* fstoq */
3779 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3780 gen_ne_fop_QF(dc
, rd
, rs2
, gen_helper_fstoq
);
3782 case 0xce: /* fdtoq */
3783 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3784 gen_ne_fop_QD(dc
, rd
, rs2
, gen_helper_fdtoq
);
3786 case 0xd1: /* fstoi */
3787 gen_fop_FF(dc
, rd
, rs2
, gen_helper_fstoi
);
3789 case 0xd2: /* fdtoi */
3790 gen_fop_FD(dc
, rd
, rs2
, gen_helper_fdtoi
);
3792 case 0xd3: /* fqtoi */
3793 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3794 gen_fop_FQ(dc
, rd
, rs2
, gen_helper_fqtoi
);
3796 #ifdef TARGET_SPARC64
3797 case 0x2: /* V9 fmovd */
3798 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
3799 gen_store_fpr_D(dc
, rd
, cpu_src1_64
);
3801 case 0x3: /* V9 fmovq */
3802 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3803 gen_move_Q(dc
, rd
, rs2
);
3805 case 0x6: /* V9 fnegd */
3806 gen_ne_fop_DD(dc
, rd
, rs2
, gen_helper_fnegd
);
3808 case 0x7: /* V9 fnegq */
3809 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3810 gen_ne_fop_QQ(dc
, rd
, rs2
, gen_helper_fnegq
);
3812 case 0xa: /* V9 fabsd */
3813 gen_ne_fop_DD(dc
, rd
, rs2
, gen_helper_fabsd
);
3815 case 0xb: /* V9 fabsq */
3816 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3817 gen_ne_fop_QQ(dc
, rd
, rs2
, gen_helper_fabsq
);
3819 case 0x81: /* V9 fstox */
3820 gen_fop_DF(dc
, rd
, rs2
, gen_helper_fstox
);
3822 case 0x82: /* V9 fdtox */
3823 gen_fop_DD(dc
, rd
, rs2
, gen_helper_fdtox
);
3825 case 0x83: /* V9 fqtox */
3826 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3827 gen_fop_DQ(dc
, rd
, rs2
, gen_helper_fqtox
);
3829 case 0x84: /* V9 fxtos */
3830 gen_fop_FD(dc
, rd
, rs2
, gen_helper_fxtos
);
3832 case 0x88: /* V9 fxtod */
3833 gen_fop_DD(dc
, rd
, rs2
, gen_helper_fxtod
);
3835 case 0x8c: /* V9 fxtoq */
3836 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3837 gen_ne_fop_QD(dc
, rd
, rs2
, gen_helper_fxtoq
);
3843 } else if (xop
== 0x35) { /* FPU Operations */
3844 #ifdef TARGET_SPARC64
3847 if (gen_trap_ifnofpu(dc
)) {
3850 gen_op_clear_ieee_excp_and_FTT();
3851 rs1
= GET_FIELD(insn
, 13, 17);
3852 rs2
= GET_FIELD(insn
, 27, 31);
3853 xop
= GET_FIELD(insn
, 18, 26);
3855 #ifdef TARGET_SPARC64
3859 cond = GET_FIELD_SP(insn, 10, 12); \
3860 cpu_src1 = get_src1(dc, insn); \
3861 gen_compare_reg(&cmp, cond, cpu_src1); \
3862 gen_fmov##sz(dc, &cmp, rd, rs2); \
3863 free_compare(&cmp); \
3866 if ((xop
& 0x11f) == 0x005) { /* V9 fmovsr */
3869 } else if ((xop
& 0x11f) == 0x006) { // V9 fmovdr
3872 } else if ((xop
& 0x11f) == 0x007) { // V9 fmovqr
3873 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3880 #ifdef TARGET_SPARC64
3881 #define FMOVCC(fcc, sz) \
3884 cond = GET_FIELD_SP(insn, 14, 17); \
3885 gen_fcompare(&cmp, fcc, cond); \
3886 gen_fmov##sz(dc, &cmp, rd, rs2); \
3887 free_compare(&cmp); \
3890 case 0x001: /* V9 fmovscc %fcc0 */
3893 case 0x002: /* V9 fmovdcc %fcc0 */
3896 case 0x003: /* V9 fmovqcc %fcc0 */
3897 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3900 case 0x041: /* V9 fmovscc %fcc1 */
3903 case 0x042: /* V9 fmovdcc %fcc1 */
3906 case 0x043: /* V9 fmovqcc %fcc1 */
3907 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3910 case 0x081: /* V9 fmovscc %fcc2 */
3913 case 0x082: /* V9 fmovdcc %fcc2 */
3916 case 0x083: /* V9 fmovqcc %fcc2 */
3917 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3920 case 0x0c1: /* V9 fmovscc %fcc3 */
3923 case 0x0c2: /* V9 fmovdcc %fcc3 */
3926 case 0x0c3: /* V9 fmovqcc %fcc3 */
3927 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3931 #define FMOVCC(xcc, sz) \
3934 cond = GET_FIELD_SP(insn, 14, 17); \
3935 gen_compare(&cmp, xcc, cond, dc); \
3936 gen_fmov##sz(dc, &cmp, rd, rs2); \
3937 free_compare(&cmp); \
3940 case 0x101: /* V9 fmovscc %icc */
3943 case 0x102: /* V9 fmovdcc %icc */
3946 case 0x103: /* V9 fmovqcc %icc */
3947 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3950 case 0x181: /* V9 fmovscc %xcc */
3953 case 0x182: /* V9 fmovdcc %xcc */
3956 case 0x183: /* V9 fmovqcc %xcc */
3957 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3962 case 0x51: /* fcmps, V9 %fcc */
3963 cpu_src1_32
= gen_load_fpr_F(dc
, rs1
);
3964 cpu_src2_32
= gen_load_fpr_F(dc
, rs2
);
3965 gen_op_fcmps(rd
& 3, cpu_src1_32
, cpu_src2_32
);
3967 case 0x52: /* fcmpd, V9 %fcc */
3968 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
3969 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
3970 gen_op_fcmpd(rd
& 3, cpu_src1_64
, cpu_src2_64
);
3972 case 0x53: /* fcmpq, V9 %fcc */
3973 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3974 gen_op_load_fpr_QT0(QFPREG(rs1
));
3975 gen_op_load_fpr_QT1(QFPREG(rs2
));
3976 gen_op_fcmpq(rd
& 3);
3978 case 0x55: /* fcmpes, V9 %fcc */
3979 cpu_src1_32
= gen_load_fpr_F(dc
, rs1
);
3980 cpu_src2_32
= gen_load_fpr_F(dc
, rs2
);
3981 gen_op_fcmpes(rd
& 3, cpu_src1_32
, cpu_src2_32
);
3983 case 0x56: /* fcmped, V9 %fcc */
3984 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
3985 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
3986 gen_op_fcmped(rd
& 3, cpu_src1_64
, cpu_src2_64
);
3988 case 0x57: /* fcmpeq, V9 %fcc */
3989 CHECK_FPU_FEATURE(dc
, FLOAT128
);
3990 gen_op_load_fpr_QT0(QFPREG(rs1
));
3991 gen_op_load_fpr_QT1(QFPREG(rs2
));
3992 gen_op_fcmpeq(rd
& 3);
3997 } else if (xop
== 0x2) {
3998 TCGv dst
= gen_dest_gpr(dc
, rd
);
3999 rs1
= GET_FIELD(insn
, 13, 17);
4001 /* clr/mov shortcut : or %g0, x, y -> mov x, y */
4002 if (IS_IMM
) { /* immediate */
4003 simm
= GET_FIELDs(insn
, 19, 31);
4004 tcg_gen_movi_tl(dst
, simm
);
4005 gen_store_gpr(dc
, rd
, dst
);
4006 } else { /* register */
4007 rs2
= GET_FIELD(insn
, 27, 31);
4009 tcg_gen_movi_tl(dst
, 0);
4010 gen_store_gpr(dc
, rd
, dst
);
4012 cpu_src2
= gen_load_gpr(dc
, rs2
);
4013 gen_store_gpr(dc
, rd
, cpu_src2
);
4017 cpu_src1
= get_src1(dc
, insn
);
4018 if (IS_IMM
) { /* immediate */
4019 simm
= GET_FIELDs(insn
, 19, 31);
4020 tcg_gen_ori_tl(dst
, cpu_src1
, simm
);
4021 gen_store_gpr(dc
, rd
, dst
);
4022 } else { /* register */
4023 rs2
= GET_FIELD(insn
, 27, 31);
4025 /* mov shortcut: or x, %g0, y -> mov x, y */
4026 gen_store_gpr(dc
, rd
, cpu_src1
);
4028 cpu_src2
= gen_load_gpr(dc
, rs2
);
4029 tcg_gen_or_tl(dst
, cpu_src1
, cpu_src2
);
4030 gen_store_gpr(dc
, rd
, dst
);
4034 #ifdef TARGET_SPARC64
4035 } else if (xop
== 0x25) { /* sll, V9 sllx */
4036 cpu_src1
= get_src1(dc
, insn
);
4037 if (IS_IMM
) { /* immediate */
4038 simm
= GET_FIELDs(insn
, 20, 31);
4039 if (insn
& (1 << 12)) {
4040 tcg_gen_shli_i64(cpu_dst
, cpu_src1
, simm
& 0x3f);
4042 tcg_gen_shli_i64(cpu_dst
, cpu_src1
, simm
& 0x1f);
4044 } else { /* register */
4045 rs2
= GET_FIELD(insn
, 27, 31);
4046 cpu_src2
= gen_load_gpr(dc
, rs2
);
4047 cpu_tmp0
= get_temp_tl(dc
);
4048 if (insn
& (1 << 12)) {
4049 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x3f);
4051 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x1f);
4053 tcg_gen_shl_i64(cpu_dst
, cpu_src1
, cpu_tmp0
);
4055 gen_store_gpr(dc
, rd
, cpu_dst
);
4056 } else if (xop
== 0x26) { /* srl, V9 srlx */
4057 cpu_src1
= get_src1(dc
, insn
);
4058 if (IS_IMM
) { /* immediate */
4059 simm
= GET_FIELDs(insn
, 20, 31);
4060 if (insn
& (1 << 12)) {
4061 tcg_gen_shri_i64(cpu_dst
, cpu_src1
, simm
& 0x3f);
4063 tcg_gen_andi_i64(cpu_dst
, cpu_src1
, 0xffffffffULL
);
4064 tcg_gen_shri_i64(cpu_dst
, cpu_dst
, simm
& 0x1f);
4066 } else { /* register */
4067 rs2
= GET_FIELD(insn
, 27, 31);
4068 cpu_src2
= gen_load_gpr(dc
, rs2
);
4069 cpu_tmp0
= get_temp_tl(dc
);
4070 if (insn
& (1 << 12)) {
4071 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x3f);
4072 tcg_gen_shr_i64(cpu_dst
, cpu_src1
, cpu_tmp0
);
4074 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x1f);
4075 tcg_gen_andi_i64(cpu_dst
, cpu_src1
, 0xffffffffULL
);
4076 tcg_gen_shr_i64(cpu_dst
, cpu_dst
, cpu_tmp0
);
4079 gen_store_gpr(dc
, rd
, cpu_dst
);
4080 } else if (xop
== 0x27) { /* sra, V9 srax */
4081 cpu_src1
= get_src1(dc
, insn
);
4082 if (IS_IMM
) { /* immediate */
4083 simm
= GET_FIELDs(insn
, 20, 31);
4084 if (insn
& (1 << 12)) {
4085 tcg_gen_sari_i64(cpu_dst
, cpu_src1
, simm
& 0x3f);
4087 tcg_gen_ext32s_i64(cpu_dst
, cpu_src1
);
4088 tcg_gen_sari_i64(cpu_dst
, cpu_dst
, simm
& 0x1f);
4090 } else { /* register */
4091 rs2
= GET_FIELD(insn
, 27, 31);
4092 cpu_src2
= gen_load_gpr(dc
, rs2
);
4093 cpu_tmp0
= get_temp_tl(dc
);
4094 if (insn
& (1 << 12)) {
4095 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x3f);
4096 tcg_gen_sar_i64(cpu_dst
, cpu_src1
, cpu_tmp0
);
4098 tcg_gen_andi_i64(cpu_tmp0
, cpu_src2
, 0x1f);
4099 tcg_gen_ext32s_i64(cpu_dst
, cpu_src1
);
4100 tcg_gen_sar_i64(cpu_dst
, cpu_dst
, cpu_tmp0
);
4103 gen_store_gpr(dc
, rd
, cpu_dst
);
4105 } else if (xop
< 0x36) {
4107 cpu_src1
= get_src1(dc
, insn
);
4108 cpu_src2
= get_src2(dc
, insn
);
4109 switch (xop
& ~0x10) {
4112 gen_op_add_cc(cpu_dst
, cpu_src1
, cpu_src2
);
4113 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_ADD
);
4114 dc
->cc_op
= CC_OP_ADD
;
4116 tcg_gen_add_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4120 tcg_gen_and_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4122 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4123 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4124 dc
->cc_op
= CC_OP_LOGIC
;
4128 tcg_gen_or_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4130 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4131 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4132 dc
->cc_op
= CC_OP_LOGIC
;
4136 tcg_gen_xor_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4138 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4139 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4140 dc
->cc_op
= CC_OP_LOGIC
;
4145 gen_op_sub_cc(cpu_dst
, cpu_src1
, cpu_src2
);
4146 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_SUB
);
4147 dc
->cc_op
= CC_OP_SUB
;
4149 tcg_gen_sub_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4152 case 0x5: /* andn */
4153 tcg_gen_andc_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4155 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4156 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4157 dc
->cc_op
= CC_OP_LOGIC
;
4161 tcg_gen_orc_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4163 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4164 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4165 dc
->cc_op
= CC_OP_LOGIC
;
4168 case 0x7: /* xorn */
4169 tcg_gen_eqv_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4171 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4172 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4173 dc
->cc_op
= CC_OP_LOGIC
;
4176 case 0x8: /* addx, V9 addc */
4177 gen_op_addx_int(dc
, cpu_dst
, cpu_src1
, cpu_src2
,
4180 #ifdef TARGET_SPARC64
4181 case 0x9: /* V9 mulx */
4182 tcg_gen_mul_i64(cpu_dst
, cpu_src1
, cpu_src2
);
4185 case 0xa: /* umul */
4186 CHECK_IU_FEATURE(dc
, MUL
);
4187 gen_op_umul(cpu_dst
, cpu_src1
, cpu_src2
);
4189 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4190 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4191 dc
->cc_op
= CC_OP_LOGIC
;
4194 case 0xb: /* smul */
4195 CHECK_IU_FEATURE(dc
, MUL
);
4196 gen_op_smul(cpu_dst
, cpu_src1
, cpu_src2
);
4198 tcg_gen_mov_tl(cpu_cc_dst
, cpu_dst
);
4199 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_LOGIC
);
4200 dc
->cc_op
= CC_OP_LOGIC
;
4203 case 0xc: /* subx, V9 subc */
4204 gen_op_subx_int(dc
, cpu_dst
, cpu_src1
, cpu_src2
,
4207 #ifdef TARGET_SPARC64
4208 case 0xd: /* V9 udivx */
4209 gen_helper_udivx(cpu_dst
, cpu_env
, cpu_src1
, cpu_src2
);
4212 case 0xe: /* udiv */
4213 CHECK_IU_FEATURE(dc
, DIV
);
4215 gen_helper_udiv_cc(cpu_dst
, cpu_env
, cpu_src1
,
4217 dc
->cc_op
= CC_OP_DIV
;
4219 gen_helper_udiv(cpu_dst
, cpu_env
, cpu_src1
,
4223 case 0xf: /* sdiv */
4224 CHECK_IU_FEATURE(dc
, DIV
);
4226 gen_helper_sdiv_cc(cpu_dst
, cpu_env
, cpu_src1
,
4228 dc
->cc_op
= CC_OP_DIV
;
4230 gen_helper_sdiv(cpu_dst
, cpu_env
, cpu_src1
,
4237 gen_store_gpr(dc
, rd
, cpu_dst
);
4239 cpu_src1
= get_src1(dc
, insn
);
4240 cpu_src2
= get_src2(dc
, insn
);
4242 case 0x20: /* taddcc */
4243 gen_op_add_cc(cpu_dst
, cpu_src1
, cpu_src2
);
4244 gen_store_gpr(dc
, rd
, cpu_dst
);
4245 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_TADD
);
4246 dc
->cc_op
= CC_OP_TADD
;
4248 case 0x21: /* tsubcc */
4249 gen_op_sub_cc(cpu_dst
, cpu_src1
, cpu_src2
);
4250 gen_store_gpr(dc
, rd
, cpu_dst
);
4251 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_TSUB
);
4252 dc
->cc_op
= CC_OP_TSUB
;
4254 case 0x22: /* taddcctv */
4255 gen_helper_taddcctv(cpu_dst
, cpu_env
,
4256 cpu_src1
, cpu_src2
);
4257 gen_store_gpr(dc
, rd
, cpu_dst
);
4258 dc
->cc_op
= CC_OP_TADDTV
;
4260 case 0x23: /* tsubcctv */
4261 gen_helper_tsubcctv(cpu_dst
, cpu_env
,
4262 cpu_src1
, cpu_src2
);
4263 gen_store_gpr(dc
, rd
, cpu_dst
);
4264 dc
->cc_op
= CC_OP_TSUBTV
;
4266 case 0x24: /* mulscc */
4268 gen_op_mulscc(cpu_dst
, cpu_src1
, cpu_src2
);
4269 gen_store_gpr(dc
, rd
, cpu_dst
);
4270 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_ADD
);
4271 dc
->cc_op
= CC_OP_ADD
;
4273 #ifndef TARGET_SPARC64
4274 case 0x25: /* sll */
4275 if (IS_IMM
) { /* immediate */
4276 simm
= GET_FIELDs(insn
, 20, 31);
4277 tcg_gen_shli_tl(cpu_dst
, cpu_src1
, simm
& 0x1f);
4278 } else { /* register */
4279 cpu_tmp0
= get_temp_tl(dc
);
4280 tcg_gen_andi_tl(cpu_tmp0
, cpu_src2
, 0x1f);
4281 tcg_gen_shl_tl(cpu_dst
, cpu_src1
, cpu_tmp0
);
4283 gen_store_gpr(dc
, rd
, cpu_dst
);
4285 case 0x26: /* srl */
4286 if (IS_IMM
) { /* immediate */
4287 simm
= GET_FIELDs(insn
, 20, 31);
4288 tcg_gen_shri_tl(cpu_dst
, cpu_src1
, simm
& 0x1f);
4289 } else { /* register */
4290 cpu_tmp0
= get_temp_tl(dc
);
4291 tcg_gen_andi_tl(cpu_tmp0
, cpu_src2
, 0x1f);
4292 tcg_gen_shr_tl(cpu_dst
, cpu_src1
, cpu_tmp0
);
4294 gen_store_gpr(dc
, rd
, cpu_dst
);
4296 case 0x27: /* sra */
4297 if (IS_IMM
) { /* immediate */
4298 simm
= GET_FIELDs(insn
, 20, 31);
4299 tcg_gen_sari_tl(cpu_dst
, cpu_src1
, simm
& 0x1f);
4300 } else { /* register */
4301 cpu_tmp0
= get_temp_tl(dc
);
4302 tcg_gen_andi_tl(cpu_tmp0
, cpu_src2
, 0x1f);
4303 tcg_gen_sar_tl(cpu_dst
, cpu_src1
, cpu_tmp0
);
4305 gen_store_gpr(dc
, rd
, cpu_dst
);
4310 cpu_tmp0
= get_temp_tl(dc
);
4313 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4314 tcg_gen_andi_tl(cpu_y
, cpu_tmp0
, 0xffffffff);
4316 #ifndef TARGET_SPARC64
4317 case 0x01 ... 0x0f: /* undefined in the
4321 case 0x10 ... 0x1f: /* implementation-dependent
4325 if ((rd
== 0x13) && (dc
->def
->features
&
4326 CPU_FEATURE_POWERDOWN
)) {
4327 /* LEON3 power-down */
4329 gen_helper_power_down(cpu_env
);
4333 case 0x2: /* V9 wrccr */
4334 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4335 gen_helper_wrccr(cpu_env
, cpu_tmp0
);
4336 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_FLAGS
);
4337 dc
->cc_op
= CC_OP_FLAGS
;
4339 case 0x3: /* V9 wrasi */
4340 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4341 tcg_gen_andi_tl(cpu_tmp0
, cpu_tmp0
, 0xff);
4342 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4343 offsetof(CPUSPARCState
, asi
));
4344 /* End TB to notice changed ASI. */
4347 tcg_gen_exit_tb(NULL
, 0);
4348 dc
->base
.is_jmp
= DISAS_NORETURN
;
4350 case 0x6: /* V9 wrfprs */
4351 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4352 tcg_gen_trunc_tl_i32(cpu_fprs
, cpu_tmp0
);
4356 tcg_gen_exit_tb(NULL
, 0);
4357 dc
->base
.is_jmp
= DISAS_NORETURN
;
4359 case 0xf: /* V9 sir, nop if user */
4360 #if !defined(CONFIG_USER_ONLY)
4361 if (supervisor(dc
)) {
4366 case 0x13: /* Graphics Status */
4367 if (gen_trap_ifnofpu(dc
)) {
4370 tcg_gen_xor_tl(cpu_gsr
, cpu_src1
, cpu_src2
);
4372 case 0x14: /* Softint set */
4373 if (!supervisor(dc
))
4375 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4376 gen_helper_set_softint(cpu_env
, cpu_tmp0
);
4378 case 0x15: /* Softint clear */
4379 if (!supervisor(dc
))
4381 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4382 gen_helper_clear_softint(cpu_env
, cpu_tmp0
);
4384 case 0x16: /* Softint write */
4385 if (!supervisor(dc
))
4387 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4388 gen_helper_write_softint(cpu_env
, cpu_tmp0
);
4390 case 0x17: /* Tick compare */
4391 #if !defined(CONFIG_USER_ONLY)
4392 if (!supervisor(dc
))
4398 tcg_gen_xor_tl(cpu_tick_cmpr
, cpu_src1
,
4400 r_tickptr
= tcg_temp_new_ptr();
4401 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
4402 offsetof(CPUSPARCState
, tick
));
4403 if (tb_cflags(dc
->base
.tb
) &
4407 gen_helper_tick_set_limit(r_tickptr
,
4409 tcg_temp_free_ptr(r_tickptr
);
4410 /* End TB to handle timer interrupt */
4411 dc
->base
.is_jmp
= DISAS_EXIT
;
4414 case 0x18: /* System tick */
4415 #if !defined(CONFIG_USER_ONLY)
4416 if (!supervisor(dc
))
4422 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
,
4424 r_tickptr
= tcg_temp_new_ptr();
4425 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
4426 offsetof(CPUSPARCState
, stick
));
4427 if (tb_cflags(dc
->base
.tb
) &
4431 gen_helper_tick_set_count(r_tickptr
,
4433 tcg_temp_free_ptr(r_tickptr
);
4434 /* End TB to handle timer interrupt */
4435 dc
->base
.is_jmp
= DISAS_EXIT
;
4438 case 0x19: /* System tick compare */
4439 #if !defined(CONFIG_USER_ONLY)
4440 if (!supervisor(dc
))
4446 tcg_gen_xor_tl(cpu_stick_cmpr
, cpu_src1
,
4448 r_tickptr
= tcg_temp_new_ptr();
4449 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
4450 offsetof(CPUSPARCState
, stick
));
4451 if (tb_cflags(dc
->base
.tb
) &
4455 gen_helper_tick_set_limit(r_tickptr
,
4457 tcg_temp_free_ptr(r_tickptr
);
4458 /* End TB to handle timer interrupt */
4459 dc
->base
.is_jmp
= DISAS_EXIT
;
4463 case 0x10: /* Performance Control */
4464 case 0x11: /* Performance Instrumentation
4466 case 0x12: /* Dispatch Control */
4473 #if !defined(CONFIG_USER_ONLY)
4474 case 0x31: /* wrpsr, V9 saved, restored */
4476 if (!supervisor(dc
))
4478 #ifdef TARGET_SPARC64
4481 gen_helper_saved(cpu_env
);
4484 gen_helper_restored(cpu_env
);
4486 case 2: /* UA2005 allclean */
4487 case 3: /* UA2005 otherw */
4488 case 4: /* UA2005 normalw */
4489 case 5: /* UA2005 invalw */
4495 cpu_tmp0
= get_temp_tl(dc
);
4496 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4497 gen_helper_wrpsr(cpu_env
, cpu_tmp0
);
4498 tcg_gen_movi_i32(cpu_cc_op
, CC_OP_FLAGS
);
4499 dc
->cc_op
= CC_OP_FLAGS
;
4502 tcg_gen_exit_tb(NULL
, 0);
4503 dc
->base
.is_jmp
= DISAS_NORETURN
;
4507 case 0x32: /* wrwim, V9 wrpr */
4509 if (!supervisor(dc
))
4511 cpu_tmp0
= get_temp_tl(dc
);
4512 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4513 #ifdef TARGET_SPARC64
4519 r_tsptr
= tcg_temp_new_ptr();
4520 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
4521 tcg_gen_st_tl(cpu_tmp0
, r_tsptr
,
4522 offsetof(trap_state
, tpc
));
4523 tcg_temp_free_ptr(r_tsptr
);
4530 r_tsptr
= tcg_temp_new_ptr();
4531 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
4532 tcg_gen_st_tl(cpu_tmp0
, r_tsptr
,
4533 offsetof(trap_state
, tnpc
));
4534 tcg_temp_free_ptr(r_tsptr
);
4541 r_tsptr
= tcg_temp_new_ptr();
4542 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
4543 tcg_gen_st_tl(cpu_tmp0
, r_tsptr
,
4544 offsetof(trap_state
,
4546 tcg_temp_free_ptr(r_tsptr
);
4553 r_tsptr
= tcg_temp_new_ptr();
4554 gen_load_trap_state_at_tl(r_tsptr
, cpu_env
);
4555 tcg_gen_st32_tl(cpu_tmp0
, r_tsptr
,
4556 offsetof(trap_state
, tt
));
4557 tcg_temp_free_ptr(r_tsptr
);
4564 r_tickptr
= tcg_temp_new_ptr();
4565 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
4566 offsetof(CPUSPARCState
, tick
));
4567 if (tb_cflags(dc
->base
.tb
) &
4571 gen_helper_tick_set_count(r_tickptr
,
4573 tcg_temp_free_ptr(r_tickptr
);
4574 /* End TB to handle timer interrupt */
4575 dc
->base
.is_jmp
= DISAS_EXIT
;
4579 tcg_gen_mov_tl(cpu_tbr
, cpu_tmp0
);
4583 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
4586 gen_helper_wrpstate(cpu_env
, cpu_tmp0
);
4587 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
4588 /* I/O ops in icount mode must end the TB */
4589 dc
->base
.is_jmp
= DISAS_EXIT
;
4591 dc
->npc
= DYNAMIC_PC
;
4595 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4596 offsetof(CPUSPARCState
, tl
));
4597 dc
->npc
= DYNAMIC_PC
;
4600 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
4603 gen_helper_wrpil(cpu_env
, cpu_tmp0
);
4604 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
4605 /* I/O ops in icount mode must end the TB */
4606 dc
->base
.is_jmp
= DISAS_EXIT
;
4610 gen_helper_wrcwp(cpu_env
, cpu_tmp0
);
4613 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4614 offsetof(CPUSPARCState
,
4617 case 11: // canrestore
4618 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4619 offsetof(CPUSPARCState
,
4622 case 12: // cleanwin
4623 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4624 offsetof(CPUSPARCState
,
4627 case 13: // otherwin
4628 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4629 offsetof(CPUSPARCState
,
4633 tcg_gen_st32_tl(cpu_tmp0
, cpu_env
,
4634 offsetof(CPUSPARCState
,
4637 case 16: // UA2005 gl
4638 CHECK_IU_FEATURE(dc
, GL
);
4639 gen_helper_wrgl(cpu_env
, cpu_tmp0
);
4641 case 26: // UA2005 strand status
4642 CHECK_IU_FEATURE(dc
, HYPV
);
4643 if (!hypervisor(dc
))
4645 tcg_gen_mov_tl(cpu_ssr
, cpu_tmp0
);
4651 tcg_gen_trunc_tl_i32(cpu_wim
, cpu_tmp0
);
4652 if (dc
->def
->nwindows
!= 32) {
4653 tcg_gen_andi_tl(cpu_wim
, cpu_wim
,
4654 (1 << dc
->def
->nwindows
) - 1);
4659 case 0x33: /* wrtbr, UA2005 wrhpr */
4661 #ifndef TARGET_SPARC64
4662 if (!supervisor(dc
))
4664 tcg_gen_xor_tl(cpu_tbr
, cpu_src1
, cpu_src2
);
4666 CHECK_IU_FEATURE(dc
, HYPV
);
4667 if (!hypervisor(dc
))
4669 cpu_tmp0
= get_temp_tl(dc
);
4670 tcg_gen_xor_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
4673 tcg_gen_st_i64(cpu_tmp0
, cpu_env
,
4674 offsetof(CPUSPARCState
,
4678 tcg_gen_exit_tb(NULL
, 0);
4679 dc
->base
.is_jmp
= DISAS_NORETURN
;
4682 // XXX gen_op_wrhtstate();
4685 tcg_gen_mov_tl(cpu_hintp
, cpu_tmp0
);
4688 tcg_gen_mov_tl(cpu_htba
, cpu_tmp0
);
4690 case 31: // hstick_cmpr
4694 tcg_gen_mov_tl(cpu_hstick_cmpr
, cpu_tmp0
);
4695 r_tickptr
= tcg_temp_new_ptr();
4696 tcg_gen_ld_ptr(r_tickptr
, cpu_env
,
4697 offsetof(CPUSPARCState
, hstick
));
4698 if (tb_cflags(dc
->base
.tb
) &
4702 gen_helper_tick_set_limit(r_tickptr
,
4704 tcg_temp_free_ptr(r_tickptr
);
4705 /* End TB to handle timer interrupt */
4706 dc
->base
.is_jmp
= DISAS_EXIT
;
4709 case 6: // hver readonly
4717 #ifdef TARGET_SPARC64
4718 case 0x2c: /* V9 movcc */
4720 int cc
= GET_FIELD_SP(insn
, 11, 12);
4721 int cond
= GET_FIELD_SP(insn
, 14, 17);
4725 if (insn
& (1 << 18)) {
4727 gen_compare(&cmp
, 0, cond
, dc
);
4728 } else if (cc
== 2) {
4729 gen_compare(&cmp
, 1, cond
, dc
);
4734 gen_fcompare(&cmp
, cc
, cond
);
4737 /* The get_src2 above loaded the normal 13-bit
4738 immediate field, not the 11-bit field we have
4739 in movcc. But it did handle the reg case. */
4741 simm
= GET_FIELD_SPs(insn
, 0, 10);
4742 tcg_gen_movi_tl(cpu_src2
, simm
);
4745 dst
= gen_load_gpr(dc
, rd
);
4746 tcg_gen_movcond_tl(cmp
.cond
, dst
,
4750 gen_store_gpr(dc
, rd
, dst
);
4753 case 0x2d: /* V9 sdivx */
4754 gen_helper_sdivx(cpu_dst
, cpu_env
, cpu_src1
, cpu_src2
);
4755 gen_store_gpr(dc
, rd
, cpu_dst
);
4757 case 0x2e: /* V9 popc */
4758 tcg_gen_ctpop_tl(cpu_dst
, cpu_src2
);
4759 gen_store_gpr(dc
, rd
, cpu_dst
);
4761 case 0x2f: /* V9 movr */
4763 int cond
= GET_FIELD_SP(insn
, 10, 12);
4767 gen_compare_reg(&cmp
, cond
, cpu_src1
);
4769 /* The get_src2 above loaded the normal 13-bit
4770 immediate field, not the 10-bit field we have
4771 in movr. But it did handle the reg case. */
4773 simm
= GET_FIELD_SPs(insn
, 0, 9);
4774 tcg_gen_movi_tl(cpu_src2
, simm
);
4777 dst
= gen_load_gpr(dc
, rd
);
4778 tcg_gen_movcond_tl(cmp
.cond
, dst
,
4782 gen_store_gpr(dc
, rd
, dst
);
4790 } else if (xop
== 0x36) { /* UltraSparc shutdown, VIS, V8 CPop1 */
4791 #ifdef TARGET_SPARC64
4792 int opf
= GET_FIELD_SP(insn
, 5, 13);
4793 rs1
= GET_FIELD(insn
, 13, 17);
4794 rs2
= GET_FIELD(insn
, 27, 31);
4795 if (gen_trap_ifnofpu(dc
)) {
4800 case 0x000: /* VIS I edge8cc */
4801 CHECK_FPU_FEATURE(dc
, VIS1
);
4802 cpu_src1
= gen_load_gpr(dc
, rs1
);
4803 cpu_src2
= gen_load_gpr(dc
, rs2
);
4804 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 1, 0);
4805 gen_store_gpr(dc
, rd
, cpu_dst
);
4807 case 0x001: /* VIS II edge8n */
4808 CHECK_FPU_FEATURE(dc
, VIS2
);
4809 cpu_src1
= gen_load_gpr(dc
, rs1
);
4810 cpu_src2
= gen_load_gpr(dc
, rs2
);
4811 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 0, 0);
4812 gen_store_gpr(dc
, rd
, cpu_dst
);
4814 case 0x002: /* VIS I edge8lcc */
4815 CHECK_FPU_FEATURE(dc
, VIS1
);
4816 cpu_src1
= gen_load_gpr(dc
, rs1
);
4817 cpu_src2
= gen_load_gpr(dc
, rs2
);
4818 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 1, 1);
4819 gen_store_gpr(dc
, rd
, cpu_dst
);
4821 case 0x003: /* VIS II edge8ln */
4822 CHECK_FPU_FEATURE(dc
, VIS2
);
4823 cpu_src1
= gen_load_gpr(dc
, rs1
);
4824 cpu_src2
= gen_load_gpr(dc
, rs2
);
4825 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 8, 0, 1);
4826 gen_store_gpr(dc
, rd
, cpu_dst
);
4828 case 0x004: /* VIS I edge16cc */
4829 CHECK_FPU_FEATURE(dc
, VIS1
);
4830 cpu_src1
= gen_load_gpr(dc
, rs1
);
4831 cpu_src2
= gen_load_gpr(dc
, rs2
);
4832 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 1, 0);
4833 gen_store_gpr(dc
, rd
, cpu_dst
);
4835 case 0x005: /* VIS II edge16n */
4836 CHECK_FPU_FEATURE(dc
, VIS2
);
4837 cpu_src1
= gen_load_gpr(dc
, rs1
);
4838 cpu_src2
= gen_load_gpr(dc
, rs2
);
4839 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 0, 0);
4840 gen_store_gpr(dc
, rd
, cpu_dst
);
4842 case 0x006: /* VIS I edge16lcc */
4843 CHECK_FPU_FEATURE(dc
, VIS1
);
4844 cpu_src1
= gen_load_gpr(dc
, rs1
);
4845 cpu_src2
= gen_load_gpr(dc
, rs2
);
4846 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 1, 1);
4847 gen_store_gpr(dc
, rd
, cpu_dst
);
4849 case 0x007: /* VIS II edge16ln */
4850 CHECK_FPU_FEATURE(dc
, VIS2
);
4851 cpu_src1
= gen_load_gpr(dc
, rs1
);
4852 cpu_src2
= gen_load_gpr(dc
, rs2
);
4853 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 16, 0, 1);
4854 gen_store_gpr(dc
, rd
, cpu_dst
);
4856 case 0x008: /* VIS I edge32cc */
4857 CHECK_FPU_FEATURE(dc
, VIS1
);
4858 cpu_src1
= gen_load_gpr(dc
, rs1
);
4859 cpu_src2
= gen_load_gpr(dc
, rs2
);
4860 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 1, 0);
4861 gen_store_gpr(dc
, rd
, cpu_dst
);
4863 case 0x009: /* VIS II edge32n */
4864 CHECK_FPU_FEATURE(dc
, VIS2
);
4865 cpu_src1
= gen_load_gpr(dc
, rs1
);
4866 cpu_src2
= gen_load_gpr(dc
, rs2
);
4867 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 0, 0);
4868 gen_store_gpr(dc
, rd
, cpu_dst
);
4870 case 0x00a: /* VIS I edge32lcc */
4871 CHECK_FPU_FEATURE(dc
, VIS1
);
4872 cpu_src1
= gen_load_gpr(dc
, rs1
);
4873 cpu_src2
= gen_load_gpr(dc
, rs2
);
4874 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 1, 1);
4875 gen_store_gpr(dc
, rd
, cpu_dst
);
4877 case 0x00b: /* VIS II edge32ln */
4878 CHECK_FPU_FEATURE(dc
, VIS2
);
4879 cpu_src1
= gen_load_gpr(dc
, rs1
);
4880 cpu_src2
= gen_load_gpr(dc
, rs2
);
4881 gen_edge(dc
, cpu_dst
, cpu_src1
, cpu_src2
, 32, 0, 1);
4882 gen_store_gpr(dc
, rd
, cpu_dst
);
4884 case 0x010: /* VIS I array8 */
4885 CHECK_FPU_FEATURE(dc
, VIS1
);
4886 cpu_src1
= gen_load_gpr(dc
, rs1
);
4887 cpu_src2
= gen_load_gpr(dc
, rs2
);
4888 gen_helper_array8(cpu_dst
, cpu_src1
, cpu_src2
);
4889 gen_store_gpr(dc
, rd
, cpu_dst
);
4891 case 0x012: /* VIS I array16 */
4892 CHECK_FPU_FEATURE(dc
, VIS1
);
4893 cpu_src1
= gen_load_gpr(dc
, rs1
);
4894 cpu_src2
= gen_load_gpr(dc
, rs2
);
4895 gen_helper_array8(cpu_dst
, cpu_src1
, cpu_src2
);
4896 tcg_gen_shli_i64(cpu_dst
, cpu_dst
, 1);
4897 gen_store_gpr(dc
, rd
, cpu_dst
);
4899 case 0x014: /* VIS I array32 */
4900 CHECK_FPU_FEATURE(dc
, VIS1
);
4901 cpu_src1
= gen_load_gpr(dc
, rs1
);
4902 cpu_src2
= gen_load_gpr(dc
, rs2
);
4903 gen_helper_array8(cpu_dst
, cpu_src1
, cpu_src2
);
4904 tcg_gen_shli_i64(cpu_dst
, cpu_dst
, 2);
4905 gen_store_gpr(dc
, rd
, cpu_dst
);
4907 case 0x018: /* VIS I alignaddr */
4908 CHECK_FPU_FEATURE(dc
, VIS1
);
4909 cpu_src1
= gen_load_gpr(dc
, rs1
);
4910 cpu_src2
= gen_load_gpr(dc
, rs2
);
4911 gen_alignaddr(cpu_dst
, cpu_src1
, cpu_src2
, 0);
4912 gen_store_gpr(dc
, rd
, cpu_dst
);
4914 case 0x01a: /* VIS I alignaddrl */
4915 CHECK_FPU_FEATURE(dc
, VIS1
);
4916 cpu_src1
= gen_load_gpr(dc
, rs1
);
4917 cpu_src2
= gen_load_gpr(dc
, rs2
);
4918 gen_alignaddr(cpu_dst
, cpu_src1
, cpu_src2
, 1);
4919 gen_store_gpr(dc
, rd
, cpu_dst
);
4921 case 0x019: /* VIS II bmask */
4922 CHECK_FPU_FEATURE(dc
, VIS2
);
4923 cpu_src1
= gen_load_gpr(dc
, rs1
);
4924 cpu_src2
= gen_load_gpr(dc
, rs2
);
4925 tcg_gen_add_tl(cpu_dst
, cpu_src1
, cpu_src2
);
4926 tcg_gen_deposit_tl(cpu_gsr
, cpu_gsr
, cpu_dst
, 32, 32);
4927 gen_store_gpr(dc
, rd
, cpu_dst
);
4929 case 0x020: /* VIS I fcmple16 */
4930 CHECK_FPU_FEATURE(dc
, VIS1
);
4931 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4932 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4933 gen_helper_fcmple16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4934 gen_store_gpr(dc
, rd
, cpu_dst
);
4936 case 0x022: /* VIS I fcmpne16 */
4937 CHECK_FPU_FEATURE(dc
, VIS1
);
4938 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4939 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4940 gen_helper_fcmpne16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4941 gen_store_gpr(dc
, rd
, cpu_dst
);
4943 case 0x024: /* VIS I fcmple32 */
4944 CHECK_FPU_FEATURE(dc
, VIS1
);
4945 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4946 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4947 gen_helper_fcmple32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4948 gen_store_gpr(dc
, rd
, cpu_dst
);
4950 case 0x026: /* VIS I fcmpne32 */
4951 CHECK_FPU_FEATURE(dc
, VIS1
);
4952 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4953 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4954 gen_helper_fcmpne32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4955 gen_store_gpr(dc
, rd
, cpu_dst
);
4957 case 0x028: /* VIS I fcmpgt16 */
4958 CHECK_FPU_FEATURE(dc
, VIS1
);
4959 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4960 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4961 gen_helper_fcmpgt16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4962 gen_store_gpr(dc
, rd
, cpu_dst
);
4964 case 0x02a: /* VIS I fcmpeq16 */
4965 CHECK_FPU_FEATURE(dc
, VIS1
);
4966 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4967 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4968 gen_helper_fcmpeq16(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4969 gen_store_gpr(dc
, rd
, cpu_dst
);
4971 case 0x02c: /* VIS I fcmpgt32 */
4972 CHECK_FPU_FEATURE(dc
, VIS1
);
4973 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4974 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4975 gen_helper_fcmpgt32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4976 gen_store_gpr(dc
, rd
, cpu_dst
);
4978 case 0x02e: /* VIS I fcmpeq32 */
4979 CHECK_FPU_FEATURE(dc
, VIS1
);
4980 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
4981 cpu_src2_64
= gen_load_fpr_D(dc
, rs2
);
4982 gen_helper_fcmpeq32(cpu_dst
, cpu_src1_64
, cpu_src2_64
);
4983 gen_store_gpr(dc
, rd
, cpu_dst
);
4985 case 0x031: /* VIS I fmul8x16 */
4986 CHECK_FPU_FEATURE(dc
, VIS1
);
4987 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8x16
);
4989 case 0x033: /* VIS I fmul8x16au */
4990 CHECK_FPU_FEATURE(dc
, VIS1
);
4991 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8x16au
);
4993 case 0x035: /* VIS I fmul8x16al */
4994 CHECK_FPU_FEATURE(dc
, VIS1
);
4995 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8x16al
);
4997 case 0x036: /* VIS I fmul8sux16 */
4998 CHECK_FPU_FEATURE(dc
, VIS1
);
4999 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8sux16
);
5001 case 0x037: /* VIS I fmul8ulx16 */
5002 CHECK_FPU_FEATURE(dc
, VIS1
);
5003 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmul8ulx16
);
5005 case 0x038: /* VIS I fmuld8sux16 */
5006 CHECK_FPU_FEATURE(dc
, VIS1
);
5007 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmuld8sux16
);
5009 case 0x039: /* VIS I fmuld8ulx16 */
5010 CHECK_FPU_FEATURE(dc
, VIS1
);
5011 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fmuld8ulx16
);
5013 case 0x03a: /* VIS I fpack32 */
5014 CHECK_FPU_FEATURE(dc
, VIS1
);
5015 gen_gsr_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpack32
);
5017 case 0x03b: /* VIS I fpack16 */
5018 CHECK_FPU_FEATURE(dc
, VIS1
);
5019 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
5020 cpu_dst_32
= gen_dest_fpr_F(dc
);
5021 gen_helper_fpack16(cpu_dst_32
, cpu_gsr
, cpu_src1_64
);
5022 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
5024 case 0x03d: /* VIS I fpackfix */
5025 CHECK_FPU_FEATURE(dc
, VIS1
);
5026 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
5027 cpu_dst_32
= gen_dest_fpr_F(dc
);
5028 gen_helper_fpackfix(cpu_dst_32
, cpu_gsr
, cpu_src1_64
);
5029 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
5031 case 0x03e: /* VIS I pdist */
5032 CHECK_FPU_FEATURE(dc
, VIS1
);
5033 gen_ne_fop_DDDD(dc
, rd
, rs1
, rs2
, gen_helper_pdist
);
5035 case 0x048: /* VIS I faligndata */
5036 CHECK_FPU_FEATURE(dc
, VIS1
);
5037 gen_gsr_fop_DDD(dc
, rd
, rs1
, rs2
, gen_faligndata
);
5039 case 0x04b: /* VIS I fpmerge */
5040 CHECK_FPU_FEATURE(dc
, VIS1
);
5041 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpmerge
);
5043 case 0x04c: /* VIS II bshuffle */
5044 CHECK_FPU_FEATURE(dc
, VIS2
);
5045 gen_gsr_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_bshuffle
);
5047 case 0x04d: /* VIS I fexpand */
5048 CHECK_FPU_FEATURE(dc
, VIS1
);
5049 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fexpand
);
5051 case 0x050: /* VIS I fpadd16 */
5052 CHECK_FPU_FEATURE(dc
, VIS1
);
5053 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpadd16
);
5055 case 0x051: /* VIS I fpadd16s */
5056 CHECK_FPU_FEATURE(dc
, VIS1
);
5057 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fpadd16s
);
5059 case 0x052: /* VIS I fpadd32 */
5060 CHECK_FPU_FEATURE(dc
, VIS1
);
5061 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpadd32
);
5063 case 0x053: /* VIS I fpadd32s */
5064 CHECK_FPU_FEATURE(dc
, VIS1
);
5065 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_add_i32
);
5067 case 0x054: /* VIS I fpsub16 */
5068 CHECK_FPU_FEATURE(dc
, VIS1
);
5069 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpsub16
);
5071 case 0x055: /* VIS I fpsub16s */
5072 CHECK_FPU_FEATURE(dc
, VIS1
);
5073 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, gen_helper_fpsub16s
);
5075 case 0x056: /* VIS I fpsub32 */
5076 CHECK_FPU_FEATURE(dc
, VIS1
);
5077 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, gen_helper_fpsub32
);
5079 case 0x057: /* VIS I fpsub32s */
5080 CHECK_FPU_FEATURE(dc
, VIS1
);
5081 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_sub_i32
);
5083 case 0x060: /* VIS I fzero */
5084 CHECK_FPU_FEATURE(dc
, VIS1
);
5085 cpu_dst_64
= gen_dest_fpr_D(dc
, rd
);
5086 tcg_gen_movi_i64(cpu_dst_64
, 0);
5087 gen_store_fpr_D(dc
, rd
, cpu_dst_64
);
5089 case 0x061: /* VIS I fzeros */
5090 CHECK_FPU_FEATURE(dc
, VIS1
);
5091 cpu_dst_32
= gen_dest_fpr_F(dc
);
5092 tcg_gen_movi_i32(cpu_dst_32
, 0);
5093 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
5095 case 0x062: /* VIS I fnor */
5096 CHECK_FPU_FEATURE(dc
, VIS1
);
5097 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_nor_i64
);
5099 case 0x063: /* VIS I fnors */
5100 CHECK_FPU_FEATURE(dc
, VIS1
);
5101 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_nor_i32
);
5103 case 0x064: /* VIS I fandnot2 */
5104 CHECK_FPU_FEATURE(dc
, VIS1
);
5105 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_andc_i64
);
5107 case 0x065: /* VIS I fandnot2s */
5108 CHECK_FPU_FEATURE(dc
, VIS1
);
5109 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_andc_i32
);
5111 case 0x066: /* VIS I fnot2 */
5112 CHECK_FPU_FEATURE(dc
, VIS1
);
5113 gen_ne_fop_DD(dc
, rd
, rs2
, tcg_gen_not_i64
);
5115 case 0x067: /* VIS I fnot2s */
5116 CHECK_FPU_FEATURE(dc
, VIS1
);
5117 gen_ne_fop_FF(dc
, rd
, rs2
, tcg_gen_not_i32
);
5119 case 0x068: /* VIS I fandnot1 */
5120 CHECK_FPU_FEATURE(dc
, VIS1
);
5121 gen_ne_fop_DDD(dc
, rd
, rs2
, rs1
, tcg_gen_andc_i64
);
5123 case 0x069: /* VIS I fandnot1s */
5124 CHECK_FPU_FEATURE(dc
, VIS1
);
5125 gen_ne_fop_FFF(dc
, rd
, rs2
, rs1
, tcg_gen_andc_i32
);
5127 case 0x06a: /* VIS I fnot1 */
5128 CHECK_FPU_FEATURE(dc
, VIS1
);
5129 gen_ne_fop_DD(dc
, rd
, rs1
, tcg_gen_not_i64
);
5131 case 0x06b: /* VIS I fnot1s */
5132 CHECK_FPU_FEATURE(dc
, VIS1
);
5133 gen_ne_fop_FF(dc
, rd
, rs1
, tcg_gen_not_i32
);
5135 case 0x06c: /* VIS I fxor */
5136 CHECK_FPU_FEATURE(dc
, VIS1
);
5137 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_xor_i64
);
5139 case 0x06d: /* VIS I fxors */
5140 CHECK_FPU_FEATURE(dc
, VIS1
);
5141 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_xor_i32
);
5143 case 0x06e: /* VIS I fnand */
5144 CHECK_FPU_FEATURE(dc
, VIS1
);
5145 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_nand_i64
);
5147 case 0x06f: /* VIS I fnands */
5148 CHECK_FPU_FEATURE(dc
, VIS1
);
5149 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_nand_i32
);
5151 case 0x070: /* VIS I fand */
5152 CHECK_FPU_FEATURE(dc
, VIS1
);
5153 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_and_i64
);
5155 case 0x071: /* VIS I fands */
5156 CHECK_FPU_FEATURE(dc
, VIS1
);
5157 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_and_i32
);
5159 case 0x072: /* VIS I fxnor */
5160 CHECK_FPU_FEATURE(dc
, VIS1
);
5161 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_eqv_i64
);
5163 case 0x073: /* VIS I fxnors */
5164 CHECK_FPU_FEATURE(dc
, VIS1
);
5165 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_eqv_i32
);
5167 case 0x074: /* VIS I fsrc1 */
5168 CHECK_FPU_FEATURE(dc
, VIS1
);
5169 cpu_src1_64
= gen_load_fpr_D(dc
, rs1
);
5170 gen_store_fpr_D(dc
, rd
, cpu_src1_64
);
5172 case 0x075: /* VIS I fsrc1s */
5173 CHECK_FPU_FEATURE(dc
, VIS1
);
5174 cpu_src1_32
= gen_load_fpr_F(dc
, rs1
);
5175 gen_store_fpr_F(dc
, rd
, cpu_src1_32
);
5177 case 0x076: /* VIS I fornot2 */
5178 CHECK_FPU_FEATURE(dc
, VIS1
);
5179 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_orc_i64
);
5181 case 0x077: /* VIS I fornot2s */
5182 CHECK_FPU_FEATURE(dc
, VIS1
);
5183 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_orc_i32
);
5185 case 0x078: /* VIS I fsrc2 */
5186 CHECK_FPU_FEATURE(dc
, VIS1
);
5187 cpu_src1_64
= gen_load_fpr_D(dc
, rs2
);
5188 gen_store_fpr_D(dc
, rd
, cpu_src1_64
);
5190 case 0x079: /* VIS I fsrc2s */
5191 CHECK_FPU_FEATURE(dc
, VIS1
);
5192 cpu_src1_32
= gen_load_fpr_F(dc
, rs2
);
5193 gen_store_fpr_F(dc
, rd
, cpu_src1_32
);
5195 case 0x07a: /* VIS I fornot1 */
5196 CHECK_FPU_FEATURE(dc
, VIS1
);
5197 gen_ne_fop_DDD(dc
, rd
, rs2
, rs1
, tcg_gen_orc_i64
);
5199 case 0x07b: /* VIS I fornot1s */
5200 CHECK_FPU_FEATURE(dc
, VIS1
);
5201 gen_ne_fop_FFF(dc
, rd
, rs2
, rs1
, tcg_gen_orc_i32
);
5203 case 0x07c: /* VIS I for */
5204 CHECK_FPU_FEATURE(dc
, VIS1
);
5205 gen_ne_fop_DDD(dc
, rd
, rs1
, rs2
, tcg_gen_or_i64
);
5207 case 0x07d: /* VIS I fors */
5208 CHECK_FPU_FEATURE(dc
, VIS1
);
5209 gen_ne_fop_FFF(dc
, rd
, rs1
, rs2
, tcg_gen_or_i32
);
5211 case 0x07e: /* VIS I fone */
5212 CHECK_FPU_FEATURE(dc
, VIS1
);
5213 cpu_dst_64
= gen_dest_fpr_D(dc
, rd
);
5214 tcg_gen_movi_i64(cpu_dst_64
, -1);
5215 gen_store_fpr_D(dc
, rd
, cpu_dst_64
);
5217 case 0x07f: /* VIS I fones */
5218 CHECK_FPU_FEATURE(dc
, VIS1
);
5219 cpu_dst_32
= gen_dest_fpr_F(dc
);
5220 tcg_gen_movi_i32(cpu_dst_32
, -1);
5221 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
5223 case 0x080: /* VIS I shutdown */
5224 case 0x081: /* VIS II siam */
5233 } else if (xop
== 0x37) { /* V8 CPop2, V9 impdep2 */
5234 #ifdef TARGET_SPARC64
5239 #ifdef TARGET_SPARC64
5240 } else if (xop
== 0x39) { /* V9 return */
5242 cpu_src1
= get_src1(dc
, insn
);
5243 cpu_tmp0
= get_temp_tl(dc
);
5244 if (IS_IMM
) { /* immediate */
5245 simm
= GET_FIELDs(insn
, 19, 31);
5246 tcg_gen_addi_tl(cpu_tmp0
, cpu_src1
, simm
);
5247 } else { /* register */
5248 rs2
= GET_FIELD(insn
, 27, 31);
5250 cpu_src2
= gen_load_gpr(dc
, rs2
);
5251 tcg_gen_add_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
5253 tcg_gen_mov_tl(cpu_tmp0
, cpu_src1
);
5256 gen_helper_restore(cpu_env
);
5258 gen_check_align(cpu_tmp0
, 3);
5259 tcg_gen_mov_tl(cpu_npc
, cpu_tmp0
);
5260 dc
->npc
= DYNAMIC_PC
;
5264 cpu_src1
= get_src1(dc
, insn
);
5265 cpu_tmp0
= get_temp_tl(dc
);
5266 if (IS_IMM
) { /* immediate */
5267 simm
= GET_FIELDs(insn
, 19, 31);
5268 tcg_gen_addi_tl(cpu_tmp0
, cpu_src1
, simm
);
5269 } else { /* register */
5270 rs2
= GET_FIELD(insn
, 27, 31);
5272 cpu_src2
= gen_load_gpr(dc
, rs2
);
5273 tcg_gen_add_tl(cpu_tmp0
, cpu_src1
, cpu_src2
);
5275 tcg_gen_mov_tl(cpu_tmp0
, cpu_src1
);
5279 case 0x38: /* jmpl */
5281 TCGv t
= gen_dest_gpr(dc
, rd
);
5282 tcg_gen_movi_tl(t
, dc
->pc
);
5283 gen_store_gpr(dc
, rd
, t
);
5286 gen_check_align(cpu_tmp0
, 3);
5287 gen_address_mask(dc
, cpu_tmp0
);
5288 tcg_gen_mov_tl(cpu_npc
, cpu_tmp0
);
5289 dc
->npc
= DYNAMIC_PC
;
5292 #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
5293 case 0x39: /* rett, V9 return */
5295 if (!supervisor(dc
))
5298 gen_check_align(cpu_tmp0
, 3);
5299 tcg_gen_mov_tl(cpu_npc
, cpu_tmp0
);
5300 dc
->npc
= DYNAMIC_PC
;
5301 gen_helper_rett(cpu_env
);
5305 case 0x3b: /* flush */
5306 if (!((dc
)->def
->features
& CPU_FEATURE_FLUSH
))
5310 case 0x3c: /* save */
5311 gen_helper_save(cpu_env
);
5312 gen_store_gpr(dc
, rd
, cpu_tmp0
);
5314 case 0x3d: /* restore */
5315 gen_helper_restore(cpu_env
);
5316 gen_store_gpr(dc
, rd
, cpu_tmp0
);
5318 #if !defined(CONFIG_USER_ONLY) && defined(TARGET_SPARC64)
5319 case 0x3e: /* V9 done/retry */
5323 if (!supervisor(dc
))
5325 dc
->npc
= DYNAMIC_PC
;
5326 dc
->pc
= DYNAMIC_PC
;
5327 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
5330 gen_helper_done(cpu_env
);
5333 if (!supervisor(dc
))
5335 dc
->npc
= DYNAMIC_PC
;
5336 dc
->pc
= DYNAMIC_PC
;
5337 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
5340 gen_helper_retry(cpu_env
);
5355 case 3: /* load/store instructions */
5357 unsigned int xop
= GET_FIELD(insn
, 7, 12);
5358 /* ??? gen_address_mask prevents us from using a source
5359 register directly. Always generate a temporary. */
5360 TCGv cpu_addr
= get_temp_tl(dc
);
5362 tcg_gen_mov_tl(cpu_addr
, get_src1(dc
, insn
));
5363 if (xop
== 0x3c || xop
== 0x3e) {
5364 /* V9 casa/casxa : no offset */
5365 } else if (IS_IMM
) { /* immediate */
5366 simm
= GET_FIELDs(insn
, 19, 31);
5368 tcg_gen_addi_tl(cpu_addr
, cpu_addr
, simm
);
5370 } else { /* register */
5371 rs2
= GET_FIELD(insn
, 27, 31);
5373 tcg_gen_add_tl(cpu_addr
, cpu_addr
, gen_load_gpr(dc
, rs2
));
5376 if (xop
< 4 || (xop
> 7 && xop
< 0x14 && xop
!= 0x0e) ||
5377 (xop
> 0x17 && xop
<= 0x1d ) ||
5378 (xop
> 0x2c && xop
<= 0x33) || xop
== 0x1f || xop
== 0x3d) {
5379 TCGv cpu_val
= gen_dest_gpr(dc
, rd
);
5382 case 0x0: /* ld, V9 lduw, load unsigned word */
5383 gen_address_mask(dc
, cpu_addr
);
5384 tcg_gen_qemu_ld32u(cpu_val
, cpu_addr
, dc
->mem_idx
);
5386 case 0x1: /* ldub, load unsigned byte */
5387 gen_address_mask(dc
, cpu_addr
);
5388 tcg_gen_qemu_ld8u(cpu_val
, cpu_addr
, dc
->mem_idx
);
5390 case 0x2: /* lduh, load unsigned halfword */
5391 gen_address_mask(dc
, cpu_addr
);
5392 tcg_gen_qemu_ld16u(cpu_val
, cpu_addr
, dc
->mem_idx
);
5394 case 0x3: /* ldd, load double word */
5400 gen_address_mask(dc
, cpu_addr
);
5401 t64
= tcg_temp_new_i64();
5402 tcg_gen_qemu_ld64(t64
, cpu_addr
, dc
->mem_idx
);
5403 tcg_gen_trunc_i64_tl(cpu_val
, t64
);
5404 tcg_gen_ext32u_tl(cpu_val
, cpu_val
);
5405 gen_store_gpr(dc
, rd
+ 1, cpu_val
);
5406 tcg_gen_shri_i64(t64
, t64
, 32);
5407 tcg_gen_trunc_i64_tl(cpu_val
, t64
);
5408 tcg_temp_free_i64(t64
);
5409 tcg_gen_ext32u_tl(cpu_val
, cpu_val
);
5412 case 0x9: /* ldsb, load signed byte */
5413 gen_address_mask(dc
, cpu_addr
);
5414 tcg_gen_qemu_ld8s(cpu_val
, cpu_addr
, dc
->mem_idx
);
5416 case 0xa: /* ldsh, load signed halfword */
5417 gen_address_mask(dc
, cpu_addr
);
5418 tcg_gen_qemu_ld16s(cpu_val
, cpu_addr
, dc
->mem_idx
);
5420 case 0xd: /* ldstub */
5421 gen_ldstub(dc
, cpu_val
, cpu_addr
, dc
->mem_idx
);
5424 /* swap, swap register with memory. Also atomically */
5425 CHECK_IU_FEATURE(dc
, SWAP
);
5426 cpu_src1
= gen_load_gpr(dc
, rd
);
5427 gen_swap(dc
, cpu_val
, cpu_src1
, cpu_addr
,
5428 dc
->mem_idx
, MO_TEUL
);
5430 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
5431 case 0x10: /* lda, V9 lduwa, load word alternate */
5432 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TEUL
);
5434 case 0x11: /* lduba, load unsigned byte alternate */
5435 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_UB
);
5437 case 0x12: /* lduha, load unsigned halfword alternate */
5438 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TEUW
);
5440 case 0x13: /* ldda, load double word alternate */
5444 gen_ldda_asi(dc
, cpu_addr
, insn
, rd
);
5446 case 0x19: /* ldsba, load signed byte alternate */
5447 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_SB
);
5449 case 0x1a: /* ldsha, load signed halfword alternate */
5450 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TESW
);
5452 case 0x1d: /* ldstuba -- XXX: should be atomically */
5453 gen_ldstub_asi(dc
, cpu_val
, cpu_addr
, insn
);
5455 case 0x1f: /* swapa, swap reg with alt. memory. Also
5457 CHECK_IU_FEATURE(dc
, SWAP
);
5458 cpu_src1
= gen_load_gpr(dc
, rd
);
5459 gen_swap_asi(dc
, cpu_val
, cpu_src1
, cpu_addr
, insn
);
5462 #ifndef TARGET_SPARC64
5463 case 0x30: /* ldc */
5464 case 0x31: /* ldcsr */
5465 case 0x33: /* lddc */
5469 #ifdef TARGET_SPARC64
5470 case 0x08: /* V9 ldsw */
5471 gen_address_mask(dc
, cpu_addr
);
5472 tcg_gen_qemu_ld32s(cpu_val
, cpu_addr
, dc
->mem_idx
);
5474 case 0x0b: /* V9 ldx */
5475 gen_address_mask(dc
, cpu_addr
);
5476 tcg_gen_qemu_ld64(cpu_val
, cpu_addr
, dc
->mem_idx
);
5478 case 0x18: /* V9 ldswa */
5479 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TESL
);
5481 case 0x1b: /* V9 ldxa */
5482 gen_ld_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TEUQ
);
5484 case 0x2d: /* V9 prefetch, no effect */
5486 case 0x30: /* V9 ldfa */
5487 if (gen_trap_ifnofpu(dc
)) {
5490 gen_ldf_asi(dc
, cpu_addr
, insn
, 4, rd
);
5491 gen_update_fprs_dirty(dc
, rd
);
5493 case 0x33: /* V9 lddfa */
5494 if (gen_trap_ifnofpu(dc
)) {
5497 gen_ldf_asi(dc
, cpu_addr
, insn
, 8, DFPREG(rd
));
5498 gen_update_fprs_dirty(dc
, DFPREG(rd
));
5500 case 0x3d: /* V9 prefetcha, no effect */
5502 case 0x32: /* V9 ldqfa */
5503 CHECK_FPU_FEATURE(dc
, FLOAT128
);
5504 if (gen_trap_ifnofpu(dc
)) {
5507 gen_ldf_asi(dc
, cpu_addr
, insn
, 16, QFPREG(rd
));
5508 gen_update_fprs_dirty(dc
, QFPREG(rd
));
5514 gen_store_gpr(dc
, rd
, cpu_val
);
5515 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
5518 } else if (xop
>= 0x20 && xop
< 0x24) {
5519 if (gen_trap_ifnofpu(dc
)) {
5523 case 0x20: /* ldf, load fpreg */
5524 gen_address_mask(dc
, cpu_addr
);
5525 cpu_dst_32
= gen_dest_fpr_F(dc
);
5526 tcg_gen_qemu_ld_i32(cpu_dst_32
, cpu_addr
,
5527 dc
->mem_idx
, MO_TEUL
);
5528 gen_store_fpr_F(dc
, rd
, cpu_dst_32
);
5530 case 0x21: /* ldfsr, V9 ldxfsr */
5531 #ifdef TARGET_SPARC64
5532 gen_address_mask(dc
, cpu_addr
);
5534 TCGv_i64 t64
= tcg_temp_new_i64();
5535 tcg_gen_qemu_ld_i64(t64
, cpu_addr
,
5536 dc
->mem_idx
, MO_TEUQ
);
5537 gen_helper_ldxfsr(cpu_fsr
, cpu_env
, cpu_fsr
, t64
);
5538 tcg_temp_free_i64(t64
);
5542 cpu_dst_32
= get_temp_i32(dc
);
5543 tcg_gen_qemu_ld_i32(cpu_dst_32
, cpu_addr
,
5544 dc
->mem_idx
, MO_TEUL
);
5545 gen_helper_ldfsr(cpu_fsr
, cpu_env
, cpu_fsr
, cpu_dst_32
);
5547 case 0x22: /* ldqf, load quad fpreg */
5548 CHECK_FPU_FEATURE(dc
, FLOAT128
);
5549 gen_address_mask(dc
, cpu_addr
);
5550 cpu_src1_64
= tcg_temp_new_i64();
5551 tcg_gen_qemu_ld_i64(cpu_src1_64
, cpu_addr
, dc
->mem_idx
,
5552 MO_TEUQ
| MO_ALIGN_4
);
5553 tcg_gen_addi_tl(cpu_addr
, cpu_addr
, 8);
5554 cpu_src2_64
= tcg_temp_new_i64();
5555 tcg_gen_qemu_ld_i64(cpu_src2_64
, cpu_addr
, dc
->mem_idx
,
5556 MO_TEUQ
| MO_ALIGN_4
);
5557 gen_store_fpr_Q(dc
, rd
, cpu_src1_64
, cpu_src2_64
);
5558 tcg_temp_free_i64(cpu_src1_64
);
5559 tcg_temp_free_i64(cpu_src2_64
);
5561 case 0x23: /* lddf, load double fpreg */
5562 gen_address_mask(dc
, cpu_addr
);
5563 cpu_dst_64
= gen_dest_fpr_D(dc
, rd
);
5564 tcg_gen_qemu_ld_i64(cpu_dst_64
, cpu_addr
, dc
->mem_idx
,
5565 MO_TEUQ
| MO_ALIGN_4
);
5566 gen_store_fpr_D(dc
, rd
, cpu_dst_64
);
5571 } else if (xop
< 8 || (xop
>= 0x14 && xop
< 0x18) ||
5572 xop
== 0xe || xop
== 0x1e) {
5573 TCGv cpu_val
= gen_load_gpr(dc
, rd
);
5576 case 0x4: /* st, store word */
5577 gen_address_mask(dc
, cpu_addr
);
5578 tcg_gen_qemu_st32(cpu_val
, cpu_addr
, dc
->mem_idx
);
5580 case 0x5: /* stb, store byte */
5581 gen_address_mask(dc
, cpu_addr
);
5582 tcg_gen_qemu_st8(cpu_val
, cpu_addr
, dc
->mem_idx
);
5584 case 0x6: /* sth, store halfword */
5585 gen_address_mask(dc
, cpu_addr
);
5586 tcg_gen_qemu_st16(cpu_val
, cpu_addr
, dc
->mem_idx
);
5588 case 0x7: /* std, store double word */
5595 gen_address_mask(dc
, cpu_addr
);
5596 lo
= gen_load_gpr(dc
, rd
+ 1);
5597 t64
= tcg_temp_new_i64();
5598 tcg_gen_concat_tl_i64(t64
, lo
, cpu_val
);
5599 tcg_gen_qemu_st64(t64
, cpu_addr
, dc
->mem_idx
);
5600 tcg_temp_free_i64(t64
);
5603 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
5604 case 0x14: /* sta, V9 stwa, store word alternate */
5605 gen_st_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TEUL
);
5607 case 0x15: /* stba, store byte alternate */
5608 gen_st_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_UB
);
5610 case 0x16: /* stha, store halfword alternate */
5611 gen_st_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TEUW
);
5613 case 0x17: /* stda, store double word alternate */
5617 gen_stda_asi(dc
, cpu_val
, cpu_addr
, insn
, rd
);
5620 #ifdef TARGET_SPARC64
5621 case 0x0e: /* V9 stx */
5622 gen_address_mask(dc
, cpu_addr
);
5623 tcg_gen_qemu_st64(cpu_val
, cpu_addr
, dc
->mem_idx
);
5625 case 0x1e: /* V9 stxa */
5626 gen_st_asi(dc
, cpu_val
, cpu_addr
, insn
, MO_TEUQ
);
5632 } else if (xop
> 0x23 && xop
< 0x28) {
5633 if (gen_trap_ifnofpu(dc
)) {
5637 case 0x24: /* stf, store fpreg */
5638 gen_address_mask(dc
, cpu_addr
);
5639 cpu_src1_32
= gen_load_fpr_F(dc
, rd
);
5640 tcg_gen_qemu_st_i32(cpu_src1_32
, cpu_addr
,
5641 dc
->mem_idx
, MO_TEUL
);
5643 case 0x25: /* stfsr, V9 stxfsr */
5645 #ifdef TARGET_SPARC64
5646 gen_address_mask(dc
, cpu_addr
);
5648 tcg_gen_qemu_st64(cpu_fsr
, cpu_addr
, dc
->mem_idx
);
5652 tcg_gen_qemu_st32(cpu_fsr
, cpu_addr
, dc
->mem_idx
);
5656 #ifdef TARGET_SPARC64
5657 /* V9 stqf, store quad fpreg */
5658 CHECK_FPU_FEATURE(dc
, FLOAT128
);
5659 gen_address_mask(dc
, cpu_addr
);
5660 /* ??? While stqf only requires 4-byte alignment, it is
5661 legal for the cpu to signal the unaligned exception.
5662 The OS trap handler is then required to fix it up.
5663 For qemu, this avoids having to probe the second page
5664 before performing the first write. */
5665 cpu_src1_64
= gen_load_fpr_Q0(dc
, rd
);
5666 tcg_gen_qemu_st_i64(cpu_src1_64
, cpu_addr
,
5667 dc
->mem_idx
, MO_TEUQ
| MO_ALIGN_16
);
5668 tcg_gen_addi_tl(cpu_addr
, cpu_addr
, 8);
5669 cpu_src2_64
= gen_load_fpr_Q1(dc
, rd
);
5670 tcg_gen_qemu_st_i64(cpu_src1_64
, cpu_addr
,
5671 dc
->mem_idx
, MO_TEUQ
);
5673 #else /* !TARGET_SPARC64 */
5674 /* stdfq, store floating point queue */
5675 #if defined(CONFIG_USER_ONLY)
5678 if (!supervisor(dc
))
5680 if (gen_trap_ifnofpu(dc
)) {
5686 case 0x27: /* stdf, store double fpreg */
5687 gen_address_mask(dc
, cpu_addr
);
5688 cpu_src1_64
= gen_load_fpr_D(dc
, rd
);
5689 tcg_gen_qemu_st_i64(cpu_src1_64
, cpu_addr
, dc
->mem_idx
,
5690 MO_TEUQ
| MO_ALIGN_4
);
5695 } else if (xop
> 0x33 && xop
< 0x3f) {
5697 #ifdef TARGET_SPARC64
5698 case 0x34: /* V9 stfa */
5699 if (gen_trap_ifnofpu(dc
)) {
5702 gen_stf_asi(dc
, cpu_addr
, insn
, 4, rd
);
5704 case 0x36: /* V9 stqfa */
5706 CHECK_FPU_FEATURE(dc
, FLOAT128
);
5707 if (gen_trap_ifnofpu(dc
)) {
5710 gen_stf_asi(dc
, cpu_addr
, insn
, 16, QFPREG(rd
));
5713 case 0x37: /* V9 stdfa */
5714 if (gen_trap_ifnofpu(dc
)) {
5717 gen_stf_asi(dc
, cpu_addr
, insn
, 8, DFPREG(rd
));
5719 case 0x3e: /* V9 casxa */
5720 rs2
= GET_FIELD(insn
, 27, 31);
5721 cpu_src2
= gen_load_gpr(dc
, rs2
);
5722 gen_casx_asi(dc
, cpu_addr
, cpu_src2
, insn
, rd
);
5725 case 0x34: /* stc */
5726 case 0x35: /* stcsr */
5727 case 0x36: /* stdcq */
5728 case 0x37: /* stdc */
5731 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
5732 case 0x3c: /* V9 or LEON3 casa */
5733 #ifndef TARGET_SPARC64
5734 CHECK_IU_FEATURE(dc
, CASA
);
5736 rs2
= GET_FIELD(insn
, 27, 31);
5737 cpu_src2
= gen_load_gpr(dc
, rs2
);
5738 gen_cas_asi(dc
, cpu_addr
, cpu_src2
, insn
, rd
);
5750 /* default case for non jump instructions */
5751 if (dc
->npc
== DYNAMIC_PC
) {
5752 dc
->pc
= DYNAMIC_PC
;
5754 } else if (dc
->npc
== JUMP_PC
) {
5755 /* we can do a static jump */
5756 gen_branch2(dc
, dc
->jump_pc
[0], dc
->jump_pc
[1], cpu_cond
);
5757 dc
->base
.is_jmp
= DISAS_NORETURN
;
5760 dc
->npc
= dc
->npc
+ 4;
5765 gen_exception(dc
, TT_ILL_INSN
);
5768 gen_exception(dc
, TT_UNIMP_FLUSH
);
5770 #if !defined(CONFIG_USER_ONLY)
5772 gen_exception(dc
, TT_PRIV_INSN
);
5776 gen_op_fpexception_im(dc
, FSR_FTT_UNIMPFPOP
);
5778 #if !defined(CONFIG_USER_ONLY) && !defined(TARGET_SPARC64)
5780 gen_op_fpexception_im(dc
, FSR_FTT_SEQ_ERROR
);
5783 #ifndef TARGET_SPARC64
5785 gen_exception(dc
, TT_NCP_INSN
);
5789 if (dc
->n_t32
!= 0) {
5791 for (i
= dc
->n_t32
- 1; i
>= 0; --i
) {
5792 tcg_temp_free_i32(dc
->t32
[i
]);
5796 if (dc
->n_ttl
!= 0) {
5798 for (i
= dc
->n_ttl
- 1; i
>= 0; --i
) {
5799 tcg_temp_free(dc
->ttl
[i
]);
5805 static void sparc_tr_init_disas_context(DisasContextBase
*dcbase
, CPUState
*cs
)
5807 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
5808 CPUSPARCState
*env
= cs
->env_ptr
;
5811 dc
->pc
= dc
->base
.pc_first
;
5812 dc
->npc
= (target_ulong
)dc
->base
.tb
->cs_base
;
5813 dc
->cc_op
= CC_OP_DYNAMIC
;
5814 dc
->mem_idx
= dc
->base
.tb
->flags
& TB_FLAG_MMU_MASK
;
5815 dc
->def
= &env
->def
;
5816 dc
->fpu_enabled
= tb_fpu_enabled(dc
->base
.tb
->flags
);
5817 dc
->address_mask_32bit
= tb_am_enabled(dc
->base
.tb
->flags
);
5818 #ifndef CONFIG_USER_ONLY
5819 dc
->supervisor
= (dc
->base
.tb
->flags
& TB_FLAG_SUPER
) != 0;
5821 #ifdef TARGET_SPARC64
5823 dc
->asi
= (dc
->base
.tb
->flags
>> TB_FLAG_ASI_SHIFT
) & 0xff;
5824 #ifndef CONFIG_USER_ONLY
5825 dc
->hypervisor
= (dc
->base
.tb
->flags
& TB_FLAG_HYPER
) != 0;
5829 * if we reach a page boundary, we stop generation so that the
5830 * PC of a TT_TFAULT exception is always in the right page
5832 bound
= -(dc
->base
.pc_first
| TARGET_PAGE_MASK
) / 4;
5833 dc
->base
.max_insns
= MIN(dc
->base
.max_insns
, bound
);
5836 static void sparc_tr_tb_start(DisasContextBase
*db
, CPUState
*cs
)
5840 static void sparc_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cs
)
5842 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
5844 if (dc
->npc
& JUMP_PC
) {
5845 assert(dc
->jump_pc
[1] == dc
->pc
+ 4);
5846 tcg_gen_insn_start(dc
->pc
, dc
->jump_pc
[0] | JUMP_PC
);
5848 tcg_gen_insn_start(dc
->pc
, dc
->npc
);
5852 static void sparc_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cs
)
5854 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
5855 CPUSPARCState
*env
= cs
->env_ptr
;
5858 insn
= translator_ldl(env
, &dc
->base
, dc
->pc
);
5859 dc
->base
.pc_next
+= 4;
5860 disas_sparc_insn(dc
, insn
);
5862 if (dc
->base
.is_jmp
== DISAS_NORETURN
) {
5865 if (dc
->pc
!= dc
->base
.pc_next
) {
5866 dc
->base
.is_jmp
= DISAS_TOO_MANY
;
5870 static void sparc_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cs
)
5872 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
5874 switch (dc
->base
.is_jmp
) {
5876 case DISAS_TOO_MANY
:
5877 if (dc
->pc
!= DYNAMIC_PC
&&
5878 (dc
->npc
!= DYNAMIC_PC
&& dc
->npc
!= JUMP_PC
)) {
5879 /* static PC and NPC: we can use direct chaining */
5880 gen_goto_tb(dc
, 0, dc
->pc
, dc
->npc
);
5882 if (dc
->pc
!= DYNAMIC_PC
) {
5883 tcg_gen_movi_tl(cpu_pc
, dc
->pc
);
5886 tcg_gen_exit_tb(NULL
, 0);
5890 case DISAS_NORETURN
:
5896 tcg_gen_exit_tb(NULL
, 0);
5900 g_assert_not_reached();
5904 static void sparc_tr_disas_log(const DisasContextBase
*dcbase
, CPUState
*cpu
)
5906 qemu_log("IN: %s\n", lookup_symbol(dcbase
->pc_first
));
5907 log_target_disas(cpu
, dcbase
->pc_first
, dcbase
->tb
->size
);
5910 static const TranslatorOps sparc_tr_ops
= {
5911 .init_disas_context
= sparc_tr_init_disas_context
,
5912 .tb_start
= sparc_tr_tb_start
,
5913 .insn_start
= sparc_tr_insn_start
,
5914 .translate_insn
= sparc_tr_translate_insn
,
5915 .tb_stop
= sparc_tr_tb_stop
,
5916 .disas_log
= sparc_tr_disas_log
,
5919 void gen_intermediate_code(CPUState
*cs
, TranslationBlock
*tb
, int max_insns
)
5921 DisasContext dc
= {};
5923 translator_loop(&sparc_tr_ops
, &dc
.base
, cs
, tb
, max_insns
);
5926 void sparc_tcg_init(void)
5928 static const char gregnames
[32][4] = {
5929 "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
5930 "o0", "o1", "o2", "o3", "o4", "o5", "o6", "o7",
5931 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
5932 "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
5934 static const char fregnames
[32][4] = {
5935 "f0", "f2", "f4", "f6", "f8", "f10", "f12", "f14",
5936 "f16", "f18", "f20", "f22", "f24", "f26", "f28", "f30",
5937 "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46",
5938 "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",
5941 static const struct { TCGv_i32
*ptr
; int off
; const char *name
; } r32
[] = {
5942 #ifdef TARGET_SPARC64
5943 { &cpu_xcc
, offsetof(CPUSPARCState
, xcc
), "xcc" },
5944 { &cpu_fprs
, offsetof(CPUSPARCState
, fprs
), "fprs" },
5946 { &cpu_wim
, offsetof(CPUSPARCState
, wim
), "wim" },
5948 { &cpu_cc_op
, offsetof(CPUSPARCState
, cc_op
), "cc_op" },
5949 { &cpu_psr
, offsetof(CPUSPARCState
, psr
), "psr" },
5952 static const struct { TCGv
*ptr
; int off
; const char *name
; } rtl
[] = {
5953 #ifdef TARGET_SPARC64
5954 { &cpu_gsr
, offsetof(CPUSPARCState
, gsr
), "gsr" },
5955 { &cpu_tick_cmpr
, offsetof(CPUSPARCState
, tick_cmpr
), "tick_cmpr" },
5956 { &cpu_stick_cmpr
, offsetof(CPUSPARCState
, stick_cmpr
), "stick_cmpr" },
5957 { &cpu_hstick_cmpr
, offsetof(CPUSPARCState
, hstick_cmpr
),
5959 { &cpu_hintp
, offsetof(CPUSPARCState
, hintp
), "hintp" },
5960 { &cpu_htba
, offsetof(CPUSPARCState
, htba
), "htba" },
5961 { &cpu_hver
, offsetof(CPUSPARCState
, hver
), "hver" },
5962 { &cpu_ssr
, offsetof(CPUSPARCState
, ssr
), "ssr" },
5963 { &cpu_ver
, offsetof(CPUSPARCState
, version
), "ver" },
5965 { &cpu_cond
, offsetof(CPUSPARCState
, cond
), "cond" },
5966 { &cpu_cc_src
, offsetof(CPUSPARCState
, cc_src
), "cc_src" },
5967 { &cpu_cc_src2
, offsetof(CPUSPARCState
, cc_src2
), "cc_src2" },
5968 { &cpu_cc_dst
, offsetof(CPUSPARCState
, cc_dst
), "cc_dst" },
5969 { &cpu_fsr
, offsetof(CPUSPARCState
, fsr
), "fsr" },
5970 { &cpu_pc
, offsetof(CPUSPARCState
, pc
), "pc" },
5971 { &cpu_npc
, offsetof(CPUSPARCState
, npc
), "npc" },
5972 { &cpu_y
, offsetof(CPUSPARCState
, y
), "y" },
5973 #ifndef CONFIG_USER_ONLY
5974 { &cpu_tbr
, offsetof(CPUSPARCState
, tbr
), "tbr" },
5980 cpu_regwptr
= tcg_global_mem_new_ptr(cpu_env
,
5981 offsetof(CPUSPARCState
, regwptr
),
5984 for (i
= 0; i
< ARRAY_SIZE(r32
); ++i
) {
5985 *r32
[i
].ptr
= tcg_global_mem_new_i32(cpu_env
, r32
[i
].off
, r32
[i
].name
);
5988 for (i
= 0; i
< ARRAY_SIZE(rtl
); ++i
) {
5989 *rtl
[i
].ptr
= tcg_global_mem_new(cpu_env
, rtl
[i
].off
, rtl
[i
].name
);
5993 for (i
= 1; i
< 8; ++i
) {
5994 cpu_regs
[i
] = tcg_global_mem_new(cpu_env
,
5995 offsetof(CPUSPARCState
, gregs
[i
]),
5999 for (i
= 8; i
< 32; ++i
) {
6000 cpu_regs
[i
] = tcg_global_mem_new(cpu_regwptr
,
6001 (i
- 8) * sizeof(target_ulong
),
6005 for (i
= 0; i
< TARGET_DPREGS
; i
++) {
6006 cpu_fpr
[i
] = tcg_global_mem_new_i64(cpu_env
,
6007 offsetof(CPUSPARCState
, fpr
[i
]),
6012 void restore_state_to_opc(CPUSPARCState
*env
, TranslationBlock
*tb
,
6015 target_ulong pc
= data
[0];
6016 target_ulong npc
= data
[1];
6019 if (npc
== DYNAMIC_PC
) {
6020 /* dynamic NPC: already stored */
6021 } else if (npc
& JUMP_PC
) {
6022 /* jump PC: use 'cond' and the jump targets of the translation */
6024 env
->npc
= npc
& ~3;