mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
target/riscv: Reassign instructions to the Zbb-extension
This reassigns the instructions that are part of Zbb into it, with the notable exceptions of the instructions (rev8, zext.w and orc.b) that changed due to gorci, grevi and pack not being part of Zb[abcs]. Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Acked-by: Bin Meng <bmeng.cn@gmail.com> Message-id: 20210911140016.834071-11-philipp.tomsich@vrull.eu Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
fd4b81a304
commit
16c38f36f5
2 changed files with 50 additions and 41 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* RISC-V translation routines for the Zb[acs] Standard Extension.
|
||||
* RISC-V translation routines for the Zb[abcs] Standard Extension.
|
||||
*
|
||||
* Copyright (c) 2020 Kito Cheng, kito.cheng@sifive.com
|
||||
* Copyright (c) 2020 Frank Chang, frank.chang@sifive.com
|
||||
|
@ -24,6 +24,12 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define REQUIRE_ZBB(ctx) do { \
|
||||
if (!RISCV_CPU(ctx->cs)->cfg.ext_zbb) { \
|
||||
return false; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define REQUIRE_ZBC(ctx) do { \
|
||||
if (!RISCV_CPU(ctx->cs)->cfg.ext_zbc) { \
|
||||
return false; \
|
||||
|
@ -40,9 +46,10 @@ static void gen_clz(TCGv ret, TCGv arg1)
|
|||
{
|
||||
tcg_gen_clzi_tl(ret, arg1, TARGET_LONG_BITS);
|
||||
}
|
||||
|
||||
static bool trans_clz(DisasContext *ctx, arg_clz *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_ZERO, gen_clz);
|
||||
}
|
||||
|
||||
|
@ -53,31 +60,31 @@ static void gen_ctz(TCGv ret, TCGv arg1)
|
|||
|
||||
static bool trans_ctz(DisasContext *ctx, arg_ctz *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_ZERO, gen_ctz);
|
||||
}
|
||||
|
||||
static bool trans_cpop(DisasContext *ctx, arg_cpop *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl);
|
||||
}
|
||||
|
||||
static bool trans_andn(DisasContext *ctx, arg_andn *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_NONE, tcg_gen_andc_tl);
|
||||
}
|
||||
|
||||
static bool trans_orn(DisasContext *ctx, arg_orn *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_NONE, tcg_gen_orc_tl);
|
||||
}
|
||||
|
||||
static bool trans_xnor(DisasContext *ctx, arg_xnor *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_NONE, tcg_gen_eqv_tl);
|
||||
}
|
||||
|
||||
|
@ -124,37 +131,37 @@ static bool trans_packh(DisasContext *ctx, arg_packh *a)
|
|||
|
||||
static bool trans_min(DisasContext *ctx, arg_min *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_SIGN, tcg_gen_smin_tl);
|
||||
}
|
||||
|
||||
static bool trans_max(DisasContext *ctx, arg_max *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_SIGN, tcg_gen_smax_tl);
|
||||
}
|
||||
|
||||
static bool trans_minu(DisasContext *ctx, arg_minu *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_SIGN, tcg_gen_umin_tl);
|
||||
}
|
||||
|
||||
static bool trans_maxu(DisasContext *ctx, arg_maxu *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_arith(ctx, a, EXT_SIGN, tcg_gen_umax_tl);
|
||||
}
|
||||
|
||||
static bool trans_sext_b(DisasContext *ctx, arg_sext_b *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_NONE, tcg_gen_ext8s_tl);
|
||||
}
|
||||
|
||||
static bool trans_sext_h(DisasContext *ctx, arg_sext_h *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_NONE, tcg_gen_ext16s_tl);
|
||||
}
|
||||
|
||||
|
@ -250,19 +257,19 @@ static bool trans_bexti(DisasContext *ctx, arg_bexti *a)
|
|||
|
||||
static bool trans_ror(DisasContext *ctx, arg_ror *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotr_tl);
|
||||
}
|
||||
|
||||
static bool trans_rori(DisasContext *ctx, arg_rori *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_shift_imm_fn(ctx, a, EXT_NONE, tcg_gen_rotri_tl);
|
||||
}
|
||||
|
||||
static bool trans_rol(DisasContext *ctx, arg_rol *a)
|
||||
{
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_shift(ctx, a, EXT_NONE, tcg_gen_rotl_tl);
|
||||
}
|
||||
|
||||
|
@ -337,7 +344,7 @@ static void gen_clzw(TCGv ret, TCGv arg1)
|
|||
static bool trans_clzw(DisasContext *ctx, arg_clzw *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_NONE, gen_clzw);
|
||||
}
|
||||
|
||||
|
@ -350,14 +357,14 @@ static void gen_ctzw(TCGv ret, TCGv arg1)
|
|||
static bool trans_ctzw(DisasContext *ctx, arg_ctzw *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
return gen_unary(ctx, a, EXT_NONE, gen_ctzw);
|
||||
}
|
||||
|
||||
static bool trans_cpopw(DisasContext *ctx, arg_cpopw *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
ctx->w = true;
|
||||
return gen_unary(ctx, a, EXT_ZERO, tcg_gen_ctpop_tl);
|
||||
}
|
||||
|
@ -414,7 +421,7 @@ static void gen_rorw(TCGv ret, TCGv arg1, TCGv arg2)
|
|||
static bool trans_rorw(DisasContext *ctx, arg_rorw *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
ctx->w = true;
|
||||
return gen_shift(ctx, a, EXT_NONE, gen_rorw);
|
||||
}
|
||||
|
@ -422,7 +429,7 @@ static bool trans_rorw(DisasContext *ctx, arg_rorw *a)
|
|||
static bool trans_roriw(DisasContext *ctx, arg_roriw *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
ctx->w = true;
|
||||
return gen_shift_imm_tl(ctx, a, EXT_NONE, gen_rorw);
|
||||
}
|
||||
|
@ -448,7 +455,7 @@ static void gen_rolw(TCGv ret, TCGv arg1, TCGv arg2)
|
|||
static bool trans_rolw(DisasContext *ctx, arg_rolw *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_EXT(ctx, RVB);
|
||||
REQUIRE_ZBB(ctx);
|
||||
ctx->w = true;
|
||||
return gen_shift(ctx, a, EXT_NONE, gen_rolw);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue