diff mbox series

[v2,08/28] target/ppc/mmu_common.c: Simplify checking for real mode

Message ID 6ff205449ce39d0aa76eef96cd8d758f568f4b50.1714606359.git.balaton@eik.bme.hu
State New
Headers show
Series Misc PPC exception and BookE MMU clean ups | expand

Commit Message

BALATON Zoltan May 1, 2024, 11:43 p.m. UTC
In get_physical_address_wtlb() the real_mode flag depends on either
the MSR[IR] or MSR[DR] bit depending on access_type. Extract just the
needed bit in a more straight forward way instead of doing unnecessary
computation.

Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
 target/ppc/mmu_common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Nicholas Piggin May 7, 2024, 9:34 a.m. UTC | #1
On Thu May 2, 2024 at 9:43 AM AEST, BALATON Zoltan wrote:
> In get_physical_address_wtlb() the real_mode flag depends on either
> the MSR[IR] or MSR[DR] bit depending on access_type. Extract just the
> needed bit in a more straight forward way instead of doing unnecessary
> computation.

Hopefully the compiler should be able to work it out, but IMO it
reads better with your change.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>  target/ppc/mmu_common.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
> index 74c3b814c9..45b6501ecb 100644
> --- a/target/ppc/mmu_common.c
> +++ b/target/ppc/mmu_common.c
> @@ -1183,8 +1183,10 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,
>                                       int mmu_idx)
>  {
>      int ret = -1;
> -    bool real_mode = (type == ACCESS_CODE && !FIELD_EX64(env->msr, MSR, IR)) ||
> -                     (type != ACCESS_CODE && !FIELD_EX64(env->msr, MSR, DR));
> +    bool real_mode;
> +
> +    real_mode = (type == ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, IR)
> +                                      : !FIELD_EX64(env->msr, MSR, DR);
>  
>      switch (env->mmu_model) {
>      case POWERPC_MMU_SOFT_6xx:
diff mbox series

Patch

diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
index 74c3b814c9..45b6501ecb 100644
--- a/target/ppc/mmu_common.c
+++ b/target/ppc/mmu_common.c
@@ -1183,8 +1183,10 @@  int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx,
                                      int mmu_idx)
 {
     int ret = -1;
-    bool real_mode = (type == ACCESS_CODE && !FIELD_EX64(env->msr, MSR, IR)) ||
-                     (type != ACCESS_CODE && !FIELD_EX64(env->msr, MSR, DR));
+    bool real_mode;
+
+    real_mode = (type == ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, IR)
+                                      : !FIELD_EX64(env->msr, MSR, DR);
 
     switch (env->mmu_model) {
     case POWERPC_MMU_SOFT_6xx: