diff mbox series

[PATCH-for-10.1,8/8] target/mips: Introduce mips_env_64bit_enabled() helper

Message ID 20250325154058.92735-9-philmd@linaro.org
State New
Headers show
Series target/mips: Make 'cpu-qom.h' target agnostic | expand

Commit Message

Philippe Mathieu-Daudé March 25, 2025, 3:40 p.m. UTC
mips_env_64bit_enabled() returns whether the CPU is running
in 32-bit or 64-bit (behavior which might change at runtime).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/mips/internal.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Pierrick Bouvier March 26, 2025, 3:29 p.m. UTC | #1
On 3/25/25 08:40, Philippe Mathieu-Daudé wrote:
> mips_env_64bit_enabled() returns whether the CPU is running
> in 32-bit or 64-bit (behavior which might change at runtime).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/mips/internal.h | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/target/mips/internal.h b/target/mips/internal.h
> index 28eb28936ba..8107a59b908 100644
> --- a/target/mips/internal.h
> +++ b/target/mips/internal.h
> @@ -225,6 +225,11 @@ static inline void mips_env_set_pc(CPUMIPSState *env, target_ulong value)
>       }
>   }
>   
> +static inline bool mips_env_64bit_enabled(CPUMIPSState *env)
> +{
> +    return env->hflags & MIPS_HFLAG_64;
> +}
> +
>   static inline bool mips_env_is_bigendian(CPUMIPSState *env)
>   {
>       return extract32(env->CP0_Config0, CP0C0_BE, 1);

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Richard Henderson March 26, 2025, 6:26 p.m. UTC | #2
On 3/25/25 10:40, Philippe Mathieu-Daudé wrote:
> mips_env_64bit_enabled() returns whether the CPU is running
> in 32-bit or 64-bit (behavior which might change at runtime).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/mips/internal.h | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/target/mips/internal.h b/target/mips/internal.h
> index 28eb28936ba..8107a59b908 100644
> --- a/target/mips/internal.h
> +++ b/target/mips/internal.h
> @@ -225,6 +225,11 @@ static inline void mips_env_set_pc(CPUMIPSState *env, target_ulong value)
>       }
>   }
>   
> +static inline bool mips_env_64bit_enabled(CPUMIPSState *env)
> +{
> +    return env->hflags & MIPS_HFLAG_64;
> +}
> +
>   static inline bool mips_env_is_bigendian(CPUMIPSState *env)
>   {
>       return extract32(env->CP0_Config0, CP0C0_BE, 1);

Maybe delay this until you need it?

r~
diff mbox series

Patch

diff --git a/target/mips/internal.h b/target/mips/internal.h
index 28eb28936ba..8107a59b908 100644
--- a/target/mips/internal.h
+++ b/target/mips/internal.h
@@ -225,6 +225,11 @@  static inline void mips_env_set_pc(CPUMIPSState *env, target_ulong value)
     }
 }
 
+static inline bool mips_env_64bit_enabled(CPUMIPSState *env)
+{
+    return env->hflags & MIPS_HFLAG_64;
+}
+
 static inline bool mips_env_is_bigendian(CPUMIPSState *env)
 {
     return extract32(env->CP0_Config0, CP0C0_BE, 1);