Fix undefined behavior converting TCGv_i32 to TCGv_i64
This commit is contained in:
@@ -452,9 +452,11 @@ static void gen_sub_carry(TCGContext *tcg_ctx, TCGv_i32 dest, TCGv_i32 t0, TCGv_
|
|||||||
tcg_gen_subi_i32(tcg_ctx, dest, dest, 1);
|
tcg_gen_subi_i32(tcg_ctx, dest, dest, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mb_tcg_opcode_cmp_hook(TCGContext *tcg_ctx, TCGv_i64 v0, TCGv_i64 v1, uint32_t size)
|
static inline void mb_tcg_opcode_cmp_hook(TCGContext *tcg_ctx, TCGv_i32 v0, TCGv_i32 v1, uint32_t size)
|
||||||
{
|
{
|
||||||
uc_engine *uc = tcg_ctx->uc;
|
uc_engine *uc = tcg_ctx->uc;
|
||||||
|
TCGv_i64 targ1 = temp_tcgv_i64(tcg_ctx, tcgv_i32_temp(tcg_ctx, v0));
|
||||||
|
TCGv_i64 targ2 = temp_tcgv_i64(tcg_ctx, tcgv_i32_temp(tcg_ctx, v1));
|
||||||
if (HOOK_EXISTS_BOUNDED(uc, UC_HOOK_TCG_OPCODE, tcg_ctx->pc_start)) {
|
if (HOOK_EXISTS_BOUNDED(uc, UC_HOOK_TCG_OPCODE, tcg_ctx->pc_start)) {
|
||||||
struct hook *hook;
|
struct hook *hook;
|
||||||
HOOK_FOREACH_VAR_DECLARE;
|
HOOK_FOREACH_VAR_DECLARE;
|
||||||
@@ -462,7 +464,7 @@ static inline void mb_tcg_opcode_cmp_hook(TCGContext *tcg_ctx, TCGv_i64 v0, TCGv
|
|||||||
if (hook->to_delete)
|
if (hook->to_delete)
|
||||||
continue;
|
continue;
|
||||||
if (hook->op == UC_TCG_OP_SUB && (hook->op_flags & UC_TCG_OP_FLAG_CMP)) {
|
if (hook->op == UC_TCG_OP_SUB && (hook->op_flags & UC_TCG_OP_FLAG_CMP)) {
|
||||||
gen_uc_traceopcode(tcg_ctx, hook, v0, v1, size, uc, tcg_ctx->pc_start);
|
gen_uc_traceopcode(tcg_ctx, hook, targ1, targ2, size, uc, tcg_ctx->pc_start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -471,7 +473,7 @@ static inline void mb_tcg_opcode_cmp_hook(TCGContext *tcg_ctx, TCGv_i64 v0, TCGv
|
|||||||
/* dest = T0 + T1. Compute C, N, V and Z flags */
|
/* dest = T0 + T1. Compute C, N, V and Z flags */
|
||||||
static void gen_add_CC(TCGContext *tcg_ctx, TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1)
|
static void gen_add_CC(TCGContext *tcg_ctx, TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1)
|
||||||
{
|
{
|
||||||
mb_tcg_opcode_cmp_hook(tcg_ctx, (TCGv_i64)t0, (TCGv_i64)t1, 32);
|
mb_tcg_opcode_cmp_hook(tcg_ctx, t0, t1, 32);
|
||||||
|
|
||||||
TCGv_i32 tmp = tcg_temp_new_i32(tcg_ctx);
|
TCGv_i32 tmp = tcg_temp_new_i32(tcg_ctx);
|
||||||
tcg_gen_movi_i32(tcg_ctx, tmp, 0);
|
tcg_gen_movi_i32(tcg_ctx, tmp, 0);
|
||||||
@@ -515,7 +517,7 @@ static void gen_adc_CC(TCGContext *tcg_ctx, TCGv_i32 dest, TCGv_i32 t0, TCGv_i32
|
|||||||
/* dest = T0 - T1. Compute C, N, V and Z flags */
|
/* dest = T0 - T1. Compute C, N, V and Z flags */
|
||||||
static void gen_sub_CC(TCGContext *tcg_ctx, TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1)
|
static void gen_sub_CC(TCGContext *tcg_ctx, TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1)
|
||||||
{
|
{
|
||||||
mb_tcg_opcode_cmp_hook(tcg_ctx, (TCGv_i64)t0, (TCGv_i64)t1, 32);
|
mb_tcg_opcode_cmp_hook(tcg_ctx, t0, t1, 32);
|
||||||
|
|
||||||
TCGv_i32 tmp;
|
TCGv_i32 tmp;
|
||||||
tcg_gen_sub_i32(tcg_ctx, tcg_ctx->cpu_NF, t0, t1);
|
tcg_gen_sub_i32(tcg_ctx, tcg_ctx->cpu_NF, t0, t1);
|
||||||
|
|||||||
Reference in New Issue
Block a user