[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg()

From: Daniel Henrique Barboza
Subject: Re: [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg()
Date: Fri, 17 Feb 2023 05:39:28 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2

On 2/16/23 23:55, LIU Zhiwei wrote:

On 2023/2/17 5:55, Daniel Henrique Barboza wrote:
We're going to do changes that requires accessing the RISCVCPUConfig
struct from the RISCVCPU, having access only to a CPURISCVState 'env'
pointer. Add a helper to make the code easier to read.

Signed-off-by: Daniel Henrique Barboza<dbarboza@ventanamicro.com>
  target/riscv/cpu.h | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 01803a020d..5e9626837b 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -653,6 +653,11 @@ static inline RISCVMXL riscv_cpu_mxl(CPURISCVState *env)
  #define riscv_cpu_mxl_bits(env) (1UL << (4 + riscv_cpu_mxl(env)))
+static inline const RISCVCPUConfig *riscv_cpu_cfg(CPURISCVState *env)
+    return &env_archcpu(env)->cfg;

There many places in branch should use this interface, not just in this patch 

For example,

static RISCVException seed(CPURISCVState *env, int csrno)
     RISCVCPU *cpu = env_archcpu(env);

     if (!cpu->cfg.ext_zkr) {
         return RISCV_EXCP_ILLEGAL_INST;

The cpu here will not be used, except referring to the cfg.

Do you mind to unify the use?

Sure, I can look into that to make the cfg access more uniform across the code.

I believe this would be too much to do in this series though. Let's do it as a




  #if defined(TARGET_RISCV32)
  #define cpu_recompute_xl(env)  ((void)(env), MXL_RV32)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]