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
1 changed files with 33 additions and 17 deletions

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 tmp2 = tcg_const_i32((1 << arg[2]) - 1);
tcg_gen_movcond_i32(TCG_COND_GT, tmp1,
cpu_R[arg[1]], tmp1, cpu_R[arg[1]], tmp1);
tcg_gen_movcond_i32(TCG_COND_LT, cpu_R[arg[0]],
tmp1, tmp2, tmp1, tmp2);
tcg_gen_smax_i32(tmp1, tmp1, cpu_R[arg[1]]);
tcg_gen_smin_i32(cpu_R[arg[0]], tmp1, tmp2);
tcg_temp_free(tmp1);
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);
}
static void translate_minmax(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
static void translate_smin(DisasContext *dc, const uint32_t arg[],
const uint32_t par[])
{
if (gen_window_check3(dc, arg[0], arg[1], arg[2])) {
tcg_gen_movcond_i32(par[0], cpu_R[arg[0]],
cpu_R[arg[1]], cpu_R[arg[2]],
cpu_R[arg[1]], cpu_R[arg[2]]);
tcg_gen_smin_i32(cpu_R[arg[0]], 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},
}, {
.name = "max",
.translate = translate_minmax,
.par = (const uint32_t[]){TCG_COND_GE},
.translate = translate_smax,
}, {
.name = "maxu",
.translate = translate_minmax,
.par = (const uint32_t[]){TCG_COND_GEU},
.translate = translate_umax,
}, {
.name = "memw",
.translate = translate_memw,
}, {
.name = "min",
.translate = translate_minmax,
.par = (const uint32_t[]){TCG_COND_LT},
.translate = translate_smin,
}, {
.name = "minu",
.translate = translate_minmax,
.par = (const uint32_t[]){TCG_COND_LTU},
.translate = translate_umin,
}, {
.name = "mov",
.translate = translate_mov,