target/xtensa: get rid of gen_callw[i]

Merge gen_callwi and gen_callw into their only users, translate_callw
and translate_callxw. Extract jump slot adjustment logic into a separate
function and use it in gen_jumpi and translate_callw.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
Max Filippov 2019-02-11 02:00:06 -08:00
parent fe7869d69c
commit 9791e7e918

View File

@ -387,13 +387,19 @@ static void gen_jump(DisasContext *dc, TCGv dest)
gen_jump_slot(dc, dest, -1); gen_jump_slot(dc, dest, -1);
} }
static int adjust_jump_slot(DisasContext *dc, uint32_t dest, int slot)
{
if (((dc->base.pc_first ^ dest) & TARGET_PAGE_MASK) != 0) {
return -1;
} else {
return slot;
}
}
static void gen_jumpi(DisasContext *dc, uint32_t dest, int slot) static void gen_jumpi(DisasContext *dc, uint32_t dest, int slot)
{ {
TCGv_i32 tmp = tcg_const_i32(dest); TCGv_i32 tmp = tcg_const_i32(dest);
if (((dc->base.pc_first ^ dest) & TARGET_PAGE_MASK) != 0) { gen_jump_slot(dc, tmp, adjust_jump_slot(dc, dest, slot));
slot = -1;
}
gen_jump_slot(dc, tmp, slot);
tcg_temp_free(tmp); tcg_temp_free(tmp);
} }
@ -410,21 +416,6 @@ static void gen_callw_slot(DisasContext *dc, int callinc, TCGv_i32 dest,
gen_jump_slot(dc, dest, slot); gen_jump_slot(dc, dest, slot);
} }
static void gen_callw(DisasContext *dc, int callinc, TCGv_i32 dest)
{
gen_callw_slot(dc, callinc, dest, -1);
}
static void gen_callwi(DisasContext *dc, int callinc, uint32_t dest, int slot)
{
TCGv_i32 tmp = tcg_const_i32(dest);
if (((dc->base.pc_first ^ dest) & TARGET_PAGE_MASK) != 0) {
slot = -1;
}
gen_callw_slot(dc, callinc, tmp, slot);
tcg_temp_free(tmp);
}
static bool gen_check_loop_end(DisasContext *dc, int slot) static bool gen_check_loop_end(DisasContext *dc, int slot)
{ {
if (dc->base.pc_next == dc->lend) { if (dc->base.pc_next == dc->lend) {
@ -1477,7 +1468,9 @@ static void translate_call0(DisasContext *dc, const uint32_t arg[],
static void translate_callw(DisasContext *dc, const uint32_t arg[], static void translate_callw(DisasContext *dc, const uint32_t arg[],
const uint32_t par[]) const uint32_t par[])
{ {
gen_callwi(dc, par[0], arg[0], 0); TCGv_i32 tmp = tcg_const_i32(arg[0]);
gen_callw_slot(dc, par[0], tmp, adjust_jump_slot(dc, arg[0], 0));
tcg_temp_free(tmp);
} }
static void translate_callx0(DisasContext *dc, const uint32_t arg[], static void translate_callx0(DisasContext *dc, const uint32_t arg[],
@ -1496,7 +1489,7 @@ static void translate_callxw(DisasContext *dc, const uint32_t arg[],
TCGv_i32 tmp = tcg_temp_new_i32(); TCGv_i32 tmp = tcg_temp_new_i32();
tcg_gen_mov_i32(tmp, cpu_R[arg[0]]); tcg_gen_mov_i32(tmp, cpu_R[arg[0]]);
gen_callw(dc, par[0], tmp); gen_callw_slot(dc, par[0], tmp, -1);
tcg_temp_free(tmp); tcg_temp_free(tmp);
} }