aboutsummaryrefslogtreecommitdiff
path: root/target/riscv/cpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'target/riscv/cpu.c')
-rw-r--r--target/riscv/cpu.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index f18bb4b21e..3d144af1ab 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -108,11 +108,6 @@ const char *riscv_cpu_get_trap_name(target_ulong cause, bool async)
}
}
-bool riscv_cpu_is_32bit(CPURISCVState *env)
-{
- return env->misa_mxl == MXL_RV32;
-}
-
static void set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext)
{
env->misa_mxl_max = env->misa_mxl = mxl;
@@ -249,7 +244,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
#ifndef CONFIG_USER_ONLY
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid);
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)env->mstatus);
- if (riscv_cpu_is_32bit(env)) {
+ if (riscv_cpu_mxl(env) == MXL_RV32) {
qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ",
(target_ulong)(env->mstatus >> 32));
}
@@ -372,10 +367,16 @@ static void riscv_cpu_reset(DeviceState *dev)
static void riscv_cpu_disas_set_info(CPUState *s, disassemble_info *info)
{
RISCVCPU *cpu = RISCV_CPU(s);
- if (riscv_cpu_is_32bit(&cpu->env)) {
+
+ switch (riscv_cpu_mxl(&cpu->env)) {
+ case MXL_RV32:
info->print_insn = print_insn_riscv32;
- } else {
+ break;
+ case MXL_RV64:
info->print_insn = print_insn_riscv64;
+ break;
+ default:
+ g_assert_not_reached();
}
}
@@ -634,10 +635,13 @@ static gchar *riscv_gdb_arch_name(CPUState *cs)
RISCVCPU *cpu = RISCV_CPU(cs);
CPURISCVState *env = &cpu->env;
- if (riscv_cpu_is_32bit(env)) {
+ switch (riscv_cpu_mxl(env)) {
+ case MXL_RV32:
return g_strdup("riscv:rv32");
- } else {
+ case MXL_RV64:
return g_strdup("riscv:rv64");
+ default:
+ g_assert_not_reached();
}
}