Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
target/riscv: remove cpu->cfg.ext_e
Create a new "e" RISCVCPUMisaExtConfig property that will update
env->misa_ext* with RVE. Instances of cpu->cfg.ext_e and similar are
replaced with riscv_has_ext(env, RVE).

Remove the old "e" property and 'ext_e' from RISCVCPUConfig.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20230406180351.570807-11-dbarboza@ventanamicro.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
danielhb authored and alistair23 committed May 5, 2023
1 parent 74828ea commit 427d8e7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions target/riscv/cpu.c
Expand Up @@ -831,13 +831,13 @@ static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
env->misa_ext_mask = env->misa_ext;
}

if (riscv_has_ext(env, RVI) && cpu->cfg.ext_e) {
if (riscv_has_ext(env, RVI) && riscv_has_ext(env, RVE)) {
error_setg(errp,
"I and E extensions are incompatible");
return;
}

if (!riscv_has_ext(env, RVI) && !cpu->cfg.ext_e) {
if (!riscv_has_ext(env, RVI) && !riscv_has_ext(env, RVE)) {
error_setg(errp,
"Either I or E extension must be set");
return;
Expand Down Expand Up @@ -1150,7 +1150,7 @@ static void riscv_cpu_sync_misa_cfg(CPURISCVState *env)
if (riscv_has_ext(env, RVI)) {
ext |= RVI;
}
if (riscv_cpu_cfg(env)->ext_e) {
if (riscv_has_ext(env, RVE)) {
ext |= RVE;
}
if (riscv_cpu_cfg(env)->ext_m) {
Expand Down Expand Up @@ -1503,6 +1503,8 @@ static const RISCVCPUMisaExtConfig misa_ext_cfgs[] = {
.misa_bit = RVF, .enabled = true},
{.name = "i", .description = "Base integer instruction set",
.misa_bit = RVI, .enabled = true},
{.name = "e", .description = "Base integer instruction set (embedded)",
.misa_bit = RVE, .enabled = false},
};

static void riscv_cpu_add_misa_properties(Object *cpu_obj)
Expand All @@ -1525,7 +1527,6 @@ static void riscv_cpu_add_misa_properties(Object *cpu_obj)

static Property riscv_cpu_extensions[] = {
/* Defaults for standard extensions */
DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false),
DEFINE_PROP_BOOL("g", RISCVCPU, cfg.ext_g, false),
DEFINE_PROP_BOOL("m", RISCVCPU, cfg.ext_m, true),
DEFINE_PROP_BOOL("s", RISCVCPU, cfg.ext_s, true),
Expand Down Expand Up @@ -1644,7 +1645,6 @@ static void register_cpu_props(Object *obj)
* later on.
*/
if (cpu->env.misa_ext != 0) {
cpu->cfg.ext_e = misa_ext & RVE;
cpu->cfg.ext_m = misa_ext & RVM;
cpu->cfg.ext_v = misa_ext & RVV;
cpu->cfg.ext_s = misa_ext & RVS;
Expand Down
1 change: 0 additions & 1 deletion target/riscv/cpu.h
Expand Up @@ -422,7 +422,6 @@ typedef struct {
} RISCVSATPMap;

struct RISCVCPUConfig {
bool ext_e;
bool ext_g;
bool ext_m;
bool ext_s;
Expand Down
2 changes: 1 addition & 1 deletion target/riscv/insn_trans/trans_rvzce.c.inc
Expand Up @@ -117,7 +117,7 @@ static uint32_t decode_push_pop_list(DisasContext *ctx, target_ulong rlist)
{
uint32_t reg_bitmap = 0;

if (ctx->cfg_ptr->ext_e && rlist > 6) {
if (has_ext(ctx, RVE) && rlist > 6) {
return 0;
}

Expand Down

0 comments on commit 427d8e7

Please sign in to comment.