Skip to content

Commit

Permalink
target/ppc: implement vclrrb
Browse files Browse the repository at this point in the history
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20220225210936.1749575-17-matheus.ferst@eldorado.org.br>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
  • Loading branch information
mferst authored and legoater committed Mar 2, 2022
1 parent 08d512e commit fb1b567
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions target/ppc/insn32.decode
Expand Up @@ -530,6 +530,7 @@ VSTRIHL 000100 ..... 00010 ..... . 0000001101 @VX_tb_rc
VSTRIHR 000100 ..... 00011 ..... . 0000001101 @VX_tb_rc

VCLRLB 000100 ..... ..... ..... 00110001101 @VX
VCLRRB 000100 ..... ..... ..... 00111001101 @VX

# VSX Load/Store Instructions

Expand Down
32 changes: 24 additions & 8 deletions target/ppc/translate/vmx-impl.c.inc
Expand Up @@ -1940,7 +1940,7 @@ TRANS(VSTRIBR, do_vstri, gen_helper_VSTRIBR)
TRANS(VSTRIHL, do_vstri, gen_helper_VSTRIHL)
TRANS(VSTRIHR, do_vstri, gen_helper_VSTRIHR)

static bool trans_VCLRLB(DisasContext *ctx, arg_VX *a)
static bool do_vclrb(DisasContext *ctx, arg_VX *a, bool right)
{
TCGv_i64 rb, mh, ml, tmp,
ones = tcg_constant_i64(-1),
Expand All @@ -1954,15 +1954,28 @@ static bool trans_VCLRLB(DisasContext *ctx, arg_VX *a)
tcg_gen_extu_tl_i64(rb, cpu_gpr[a->vrb]);
tcg_gen_andi_i64(tmp, rb, 7);
tcg_gen_shli_i64(tmp, tmp, 3);
tcg_gen_shl_i64(tmp, ones, tmp);
if (right) {
tcg_gen_shr_i64(tmp, ones, tmp);
} else {
tcg_gen_shl_i64(tmp, ones, tmp);
}
tcg_gen_not_i64(tmp, tmp);

tcg_gen_movcond_i64(TCG_COND_LTU, ml, rb, tcg_constant_i64(8),
tmp, ones);
tcg_gen_movcond_i64(TCG_COND_LTU, mh, rb, tcg_constant_i64(8),
zero, tmp);
tcg_gen_movcond_i64(TCG_COND_LTU, mh, rb, tcg_constant_i64(16),
mh, ones);
if (right) {
tcg_gen_movcond_i64(TCG_COND_LTU, mh, rb, tcg_constant_i64(8),
tmp, ones);
tcg_gen_movcond_i64(TCG_COND_LTU, ml, rb, tcg_constant_i64(8),
zero, tmp);
tcg_gen_movcond_i64(TCG_COND_LTU, ml, rb, tcg_constant_i64(16),
ml, ones);
} else {
tcg_gen_movcond_i64(TCG_COND_LTU, ml, rb, tcg_constant_i64(8),
tmp, ones);
tcg_gen_movcond_i64(TCG_COND_LTU, mh, rb, tcg_constant_i64(8),
zero, tmp);
tcg_gen_movcond_i64(TCG_COND_LTU, mh, rb, tcg_constant_i64(16),
mh, ones);
}

get_avr64(tmp, a->vra, true);
tcg_gen_and_i64(tmp, tmp, mh);
Expand All @@ -1980,6 +1993,9 @@ static bool trans_VCLRLB(DisasContext *ctx, arg_VX *a)
return true;
}

TRANS(VCLRLB, do_vclrb, false)
TRANS(VCLRRB, do_vclrb, true)

#define GEN_VAFORM_PAIRED(name0, name1, opc2) \
static void glue(gen_, name0##_##name1)(DisasContext *ctx) \
{ \
Expand Down

0 comments on commit fb1b567

Please sign in to comment.