|
From: | Richard Henderson |
Subject: | Re: [PATCH v12 3/7] [RISCV_PM] Support CSRs required for RISC-V PM extension except for the h-mode |
Date: | Wed, 29 Sep 2021 06:55:55 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 9/28/21 3:00 PM, Alexey Baturo wrote:
+ switch (env->priv) { + case PRV_M: + cur_bit_pos = M_PM_CURRENT; + break; + case PRV_S: + cur_bit_pos = S_PM_CURRENT; + break; + case PRV_U: + cur_bit_pos = U_PM_CURRENT; + break; + default: + g_assert_not_reached(); + } + pm_current = get_field(env->mmte, cur_bit_pos);
Nit: If you have a look at what the get_field macro does, you'll see that you always want to give it a constant, so the compiler can fold all of the arithmetic into a constant bitfield extract. It is not a win to pull the field argument out into a variable like this.
For this reason I prefer the hw/registerfields.h interface -- it is more difficult to misuse. r~
[Prev in Thread] | Current Thread | [Next in Thread] |