target/ppc: vmulh* instructions without helpers

Changed vmulhuw, vmulhud, vmulhsw, vmulhsd to not
use helpers.

Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220225210936.1749575-5-matheus.ferst@eldorado.org.br>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
Lucas Mateus Castro (alqotel) 2022-03-02 06:51:36 +01:00 committed by Cédric Le Goater
parent d45da01428
commit 29e9dfcf75
3 changed files with 87 additions and 43 deletions

View file

@ -2151,10 +2151,93 @@ TRANS_FLAGS2(ISA310, VMULOSD, do_vx_vmuleo, false, tcg_gen_muls2_i64)
TRANS_FLAGS2(ISA310, VMULEUD, do_vx_vmuleo, true , tcg_gen_mulu2_i64)
TRANS_FLAGS2(ISA310, VMULOUD, do_vx_vmuleo, false, tcg_gen_mulu2_i64)
TRANS_FLAGS2(ISA310, VMULHSW, do_vx_helper, gen_helper_VMULHSW)
TRANS_FLAGS2(ISA310, VMULHSD, do_vx_helper, gen_helper_VMULHSD)
TRANS_FLAGS2(ISA310, VMULHUW, do_vx_helper, gen_helper_VMULHUW)
TRANS_FLAGS2(ISA310, VMULHUD, do_vx_helper, gen_helper_VMULHUD)
static void do_vx_vmulhw_i64(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b, bool sign)
{
TCGv_i64 hh, lh, temp;
uint64_t c;
hh = tcg_temp_new_i64();
lh = tcg_temp_new_i64();
temp = tcg_temp_new_i64();
c = 0xFFFFFFFF;
if (sign) {
tcg_gen_ext32s_i64(lh, a);
tcg_gen_ext32s_i64(temp, b);
} else {
tcg_gen_andi_i64(lh, a, c);
tcg_gen_andi_i64(temp, b, c);
}
tcg_gen_mul_i64(lh, lh, temp);
if (sign) {
tcg_gen_sari_i64(hh, a, 32);
tcg_gen_sari_i64(temp, b, 32);
} else {
tcg_gen_shri_i64(hh, a, 32);
tcg_gen_shri_i64(temp, b, 32);
}
tcg_gen_mul_i64(hh, hh, temp);
tcg_gen_shri_i64(lh, lh, 32);
tcg_gen_andi_i64(hh, hh, c << 32);
tcg_gen_or_i64(t, hh, lh);
tcg_temp_free_i64(hh);
tcg_temp_free_i64(lh);
tcg_temp_free_i64(temp);
}
static void do_vx_vmulhd_i64(TCGv_i64 t, TCGv_i64 a, TCGv_i64 b, bool sign)
{
TCGv_i64 tlow;
tlow = tcg_temp_new_i64();
if (sign) {
tcg_gen_muls2_i64(tlow, t, a, b);
} else {
tcg_gen_mulu2_i64(tlow, t, a, b);
}
tcg_temp_free_i64(tlow);
}
static bool do_vx_mulh(DisasContext *ctx, arg_VX *a, bool sign,
void (*func)(TCGv_i64, TCGv_i64, TCGv_i64, bool))
{
REQUIRE_INSNS_FLAGS2(ctx, ISA310);
REQUIRE_VECTOR(ctx);
TCGv_i64 vra, vrb, vrt;
int i;
vra = tcg_temp_new_i64();
vrb = tcg_temp_new_i64();
vrt = tcg_temp_new_i64();
for (i = 0; i < 2; i++) {
get_avr64(vra, a->vra, i);
get_avr64(vrb, a->vrb, i);
get_avr64(vrt, a->vrt, i);
func(vrt, vra, vrb, sign);
set_avr64(a->vrt, vrt, i);
}
tcg_temp_free_i64(vra);
tcg_temp_free_i64(vrb);
tcg_temp_free_i64(vrt);
return true;
}
TRANS(VMULHSW, do_vx_mulh, true , do_vx_vmulhw_i64)
TRANS(VMULHSD, do_vx_mulh, true , do_vx_vmulhd_i64)
TRANS(VMULHUW, do_vx_mulh, false, do_vx_vmulhw_i64)
TRANS(VMULHUD, do_vx_mulh, false, do_vx_vmulhd_i64)
#undef GEN_VR_LDX
#undef GEN_VR_STX