target/xtensa: Use new min/max expanders

The generic expanders replace nearly identical code in the translator.

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20180508151437.4232-4-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2018-05-10 18:10:57 +01:00 committed by Peter Maydell
parent ecb8ab8d71
commit 426afc3bd9

View File

@ -1527,10 +1527,8 @@ static void translate_clamps(DisasContext *dc, const uint32_t arg[],
TCGv_i32 tmp1 = tcg_const_i32(-1u << arg[2]); TCGv_i32 tmp1 = tcg_const_i32(-1u << arg[2]);
TCGv_i32 tmp2 = tcg_const_i32((1 << arg[2]) - 1); TCGv_i32 tmp2 = tcg_const_i32((1 << arg[2]) - 1);
tcg_gen_movcond_i32(TCG_COND_GT, tmp1, tcg_gen_smax_i32(tmp1, tmp1, cpu_R[arg[1]]);
cpu_R[arg[1]], tmp1, cpu_R[arg[1]], tmp1); tcg_gen_smin_i32(cpu_R[arg[0]], tmp1, tmp2);
tcg_gen_movcond_i32(TCG_COND_LT, cpu_R[arg[0]],
tmp1, tmp2, tmp1, tmp2);
tcg_temp_free(tmp1); tcg_temp_free(tmp1);
tcg_temp_free(tmp2); tcg_temp_free(tmp2);
} }
@ -1855,13 +1853,35 @@ static void translate_memw(DisasContext *dc, const uint32_t arg[],
tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL); tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL);
} }
static void translate_minmax(DisasContext *dc, const uint32_t arg[], static void translate_smin(DisasContext *dc, const uint32_t arg[],
const uint32_t par[]) const uint32_t par[])
{ {
if (gen_window_check3(dc, arg[0], arg[1], arg[2])) { if (gen_window_check3(dc, arg[0], arg[1], arg[2])) {
tcg_gen_movcond_i32(par[0], cpu_R[arg[0]], tcg_gen_smin_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]);
cpu_R[arg[1]], cpu_R[arg[2]], }
cpu_R[arg[1]], cpu_R[arg[2]]); }
static void translate_umin(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
{
if (gen_window_check3(dc, arg[0], arg[1], arg[2])) {
tcg_gen_umin_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]);
}
}
static void translate_smax(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
{
if (gen_window_check3(dc, arg[0], arg[1], arg[2])) {
tcg_gen_smax_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]);
}
}
static void translate_umax(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
{
if (gen_window_check3(dc, arg[0], arg[1], arg[2])) {
tcg_gen_umax_i32(cpu_R[arg[0]], cpu_R[arg[1]], cpu_R[arg[2]]);
} }
} }
@ -2984,23 +3004,19 @@ static const XtensaOpcodeOps core_ops[] = {
.par = (const uint32_t[]){TCG_COND_NE}, .par = (const uint32_t[]){TCG_COND_NE},
}, { }, {
.name = "max", .name = "max",
.translate = translate_minmax, .translate = translate_smax,
.par = (const uint32_t[]){TCG_COND_GE},
}, { }, {
.name = "maxu", .name = "maxu",
.translate = translate_minmax, .translate = translate_umax,
.par = (const uint32_t[]){TCG_COND_GEU},
}, { }, {
.name = "memw", .name = "memw",
.translate = translate_memw, .translate = translate_memw,
}, { }, {
.name = "min", .name = "min",
.translate = translate_minmax, .translate = translate_smin,
.par = (const uint32_t[]){TCG_COND_LT},
}, { }, {
.name = "minu", .name = "minu",
.translate = translate_minmax, .translate = translate_umin,
.par = (const uint32_t[]){TCG_COND_LTU},
}, { }, {
.name = "mov", .name = "mov",
.translate = translate_mov, .translate = translate_mov,