On 26/3/25 19:22, Richard Henderson wrote:
On 3/25/25 10:40, Philippe Mathieu-Daudé wrote:
mips_cpu_is_64bit() returns whether the CPU is a
32-bit or a 64-bit one.

Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
  target/mips/cpu-qom.h | 2 ++
  target/mips/cpu.c     | 6 ++++++
  2 files changed, 8 insertions(+)

diff --git a/target/mips/cpu-qom.h b/target/mips/cpu-qom.h
index 9acf647420c..52996e7c354 100644
--- a/target/mips/cpu-qom.h
+++ b/target/mips/cpu-qom.h
@@ -33,4 +33,6 @@ OBJECT_DECLARE_CPU_TYPE(MIPSCPU, MIPSCPUClass, MIPS_CPU)
  #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU
  #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX
+bool mips_cpu_is_64bit(MIPSCPU *cpu);
+
  #endif
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index d8930468b7d..05b3ce42af5 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -516,6 +516,12 @@ static void mips_cpu_initfn(Object *obj)
  #endif
  }
+bool mips_cpu_is_64bit(MIPSCPU *cpu)
+{
+    return !!object_class_dynamic_cast(OBJECT_CLASS(CPU(cpu)->cc),
+                                       TYPE_MIPS64_CPU);
+}

This is very nearly object_dynamic_cast.  So why not just

   return object_dynamic_cast(OBJECT(cpu), TYPE_MIPS64_CPU);

?

Good point!


Reply via email to