diff options
author | Luis Pires <luis.pires@eldorado.org.br> | 2021-10-29 17:23:57 -0300 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2021-11-09 10:32:51 +1100 |
commit | 82be6e02b480b2c7427b0ab91f2c297717d3cfa6 (patch) | |
tree | da458baff7a739478f94530e496b984e4557af28 /target/ppc/translate/fixedpoint-impl.c.inc | |
parent | 49de064889b9af091767b78d575d361cba6c8f82 (diff) | |
download | qemu-82be6e02b480b2c7427b0ab91f2c297717d3cfa6.zip qemu-82be6e02b480b2c7427b0ab91f2c297717d3cfa6.tar.gz qemu-82be6e02b480b2c7427b0ab91f2c297717d3cfa6.tar.bz2 |
target/ppc: Implement cntlzdm
Implement the following PowerISA v3.1 instruction:
cntlzdm: Count Leading Zeros Doubleword Under Bit Mask
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br>
Message-Id: <20211029202424.175401-8-matheus.ferst@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target/ppc/translate/fixedpoint-impl.c.inc')
-rw-r--r-- | target/ppc/translate/fixedpoint-impl.c.inc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/target/ppc/translate/fixedpoint-impl.c.inc b/target/ppc/translate/fixedpoint-impl.c.inc index 0d9c6e0..c9e9ae3 100644 --- a/target/ppc/translate/fixedpoint-impl.c.inc +++ b/target/ppc/translate/fixedpoint-impl.c.inc @@ -413,3 +413,39 @@ static bool trans_CFUGED(DisasContext *ctx, arg_X *a) #endif return true; } + +#if defined(TARGET_PPC64) +static void do_cntlzdm(TCGv_i64 dst, TCGv_i64 src, TCGv_i64 mask) +{ + TCGv_i64 tmp; + TCGLabel *l1; + + tmp = tcg_temp_local_new_i64(); + l1 = gen_new_label(); + + tcg_gen_and_i64(tmp, src, mask); + tcg_gen_clzi_i64(tmp, tmp, 64); + + tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, l1); + + tcg_gen_subfi_i64(tmp, 64, tmp); + tcg_gen_shr_i64(tmp, mask, tmp); + tcg_gen_ctpop_i64(tmp, tmp); + + gen_set_label(l1); + + tcg_gen_mov_i64(dst, tmp); +} +#endif + +static bool trans_CNTLZDM(DisasContext *ctx, arg_X *a) +{ + REQUIRE_64BIT(ctx); + REQUIRE_INSNS_FLAGS2(ctx, ISA310); +#if defined(TARGET_PPC64) + do_cntlzdm(cpu_gpr[a->ra], cpu_gpr[a->rt], cpu_gpr[a->rb]); +#else + qemu_build_not_reached(); +#endif + return true; +} |