qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v2 14/15] target/riscv: csr: Remove compile time XLEN checks


From: Richard Henderson
Subject: Re: [PATCH v2 14/15] target/riscv: csr: Remove compile time XLEN checks
Date: Wed, 9 Dec 2020 11:34:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 12/8/20 4:56 PM, Alistair Francis wrote:
> @@ -1053,11 +1077,11 @@ static int read_htimedelta(CPURISCVState *env, int 
> csrno, target_ulong *val)
>          return -RISCV_EXCP_ILLEGAL_INST;
>      }
>  
> -#if defined(TARGET_RISCV32)
> -    *val = env->htimedelta & 0xffffffff;
> -#else
> -    *val = env->htimedelta;
> -#endif
> +    if (riscv_cpu_is_32bit(env)) {
> +        *val = env->htimedelta & 0xffffffff;
> +    } else {
> +        *val = env->htimedelta;
> +    }
>      return 0;
>  }

Certainly this mask was useless before the patch, because of the ifdef and
target_ulong.

Afterward, target_ulong may be larger than uint32_t... but what does the rest
of the value, and the register into which it is stored, represent?

Are you going to keep the register values sign-extended, as-if by addw et al,
in which case casting to int32_t would be better.  Are you going to simply
ignore the upper 32 bits, in which case dropping the masking entirely would be
better.


r~



reply via email to

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