Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-21 Thread Richard Henderson
On 4/21/22 02:15, yangxiaojuan wrote: On 2022/4/20 上午1:05, Richard Henderson wrote: You'd use a store, just like you were already doing in trans_csrwr. But here's how I'd improve this.  For avoidance of doubt, all of this would go in trans_priviledged.c.inc -- there's no use of csr_offsets[]

Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-21 Thread yangxiaojuan
On 2022/4/20 上午1:05, Richard Henderson wrote: You'd use a store, just like you were already doing in trans_csrwr. But here's how I'd improve this.  For avoidance of doubt, all of this would go in trans_priviledged.c.inc -- there's no use of csr_offsets[] outside of that file. Thanks you

Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-19 Thread Richard Henderson
On 4/19/22 00:33, yangxiaojuan wrote: On 2022/4/16 上午9:04, Richard Henderson wrote: On 4/15/22 02:40, Xiaojuan Yang wrote: ... +void  helper_csr_update(CPULoongArchState *env, target_ulong new_val, +    target_ulong csr_offset) +{ +    uint64_t *csr = (void *)env +

Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-19 Thread yangxiaojuan
On 2022/4/16 上午9:04, Richard Henderson wrote: On 4/15/22 02:40, Xiaojuan Yang wrote: ... +void  helper_csr_update(CPULoongArchState *env, target_ulong new_val, +    target_ulong csr_offset) +{ +    uint64_t *csr = (void *)env + csr_offset; + +    *csr = new_val; +} This

Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-18 Thread Richard Henderson
On 4/18/22 05:38, yangxiaojuan wrote: On 2022/4/16 上午9:04, Richard Henderson wrote: +int cpu_csr_offset(unsigned csr_num); ... +static const uint64_t csr_offsets[] = { There's no reason for this array to be uint64_t. It really should match the function. Yes,  we shoud do this. If we use

Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-18 Thread yangxiaojuan
On 2022/4/16 上午9:04, Richard Henderson wrote: +int cpu_csr_offset(unsigned csr_num); ... +static const uint64_t csr_offsets[] = { There's no reason for this array to be uint64_t. It really should match the function. Yes,  we shoud do this. If we use 'int', we may get a warning:

Re: [PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-15 Thread Richard Henderson
On 4/15/22 02:40, Xiaojuan Yang wrote: +int cpu_csr_offset(unsigned csr_num); ... +static const uint64_t csr_offsets[] = { There's no reason for this array to be uint64_t. It really should match the function. +target_ulong helper_csrwr_estat(CPULoongArchState *env, target_ulong val) +{ +

[PATCH v1 25/43] target/loongarch: Add LoongArch CSR instruction

2022-04-15 Thread Xiaojuan Yang
This includes: - CSRRD - CSRWR - CSRXCHG Signed-off-by: Xiaojuan Yang Signed-off-by: Song Gao --- target/loongarch/cpu-csr.h| 2 + target/loongarch/csr_helper.c | 186 ++ target/loongarch/disas.c | 15 ++