[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/4] target/nios2: Shadow register set
|
From: |
Richard Henderson |
|
Subject: |
Re: [PATCH v2 1/4] target/nios2: Shadow register set |
|
Date: |
Thu, 24 Feb 2022 11:59:42 -1000 |
|
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 2/24/22 03:48, Amir Gonnen wrote:
@@ -88,7 +93,9 @@ struct Nios2CPUClass {
#define CR_STATUS_IH (1 << 3)
#define CR_STATUS_IL (63 << 4)
#define CR_STATUS_CRS (63 << 10)
+#define CR_STATUS_CRS_OFFSET 10
#define CR_STATUS_PRS (63 << 16)
+#define CR_STATUS_PRS_OFFSET 16
#define CR_STATUS_NMI (1 << 22)
#define CR_STATUS_RSIE (1 << 23)
#define CR_ESTATUS (CR_BASE + 1)
It would be preferable to use hw/registerfields.h:
FIELD(CR_STATUS, IL, 4, 6)
FIELD(CR_STATUS, CRS, 10, 6)
FIELD(CR_STATUS, PRS, 16, 6)
+static inline uint32_t cpu_get_crs(const CPUNios2State *env)
+{
+ return (env->regs[CR_STATUS] & CR_STATUS_CRS)
+ >> CR_STATUS_CRS_OFFSET;
+}
This becomes
return FIELD_EX32(env->regs[CR_STATUS], CR_STATUS, CRS);
+ env->regs[CR_STATUS] = (env->regs[CR_STATUS] & (~CR_STATUS_PRS))
+ | ((prev_set << CR_STATUS_PRS_OFFSET) & CR_STATUS_PRS);
This becomes
env->regs[CR_STATUS] = FIELD_DP32(env->regs[CR_STATUS],
CR_STATUS, PRS, prev_set);
etc.
r~