This usermode targets:
aarch64_be
armeb
microblazeel
mipsn32
mipsn32el
ppc64le
sparc32plus
are not in machine.json

This is a prepare for directly using TARGET_ARCH_VARIANT latter.

Also get target-info.c to be compatible with future TARGET_ARCH_VARIANT only 
usage.
So that we can define TARGET_ARCH_VARIANT to target_name directly

Signed-off-by: Yonggang Luo <[email protected]>
---
 include/qemu/base-arch-defs.h | 13 +++++++++++++
 qapi/machine.json             | 25 +++++++++++++------------
 target-info.c                 | 26 +++++++++-----------------
 3 files changed, 35 insertions(+), 29 deletions(-)

diff --git a/include/qemu/base-arch-defs.h b/include/qemu/base-arch-defs.h
index 7ddecc3d0be..6f3dadcc3a8 100644
--- a/include/qemu/base-arch-defs.h
+++ b/include/qemu/base-arch-defs.h
@@ -11,25 +11,38 @@
 
 #define QEMU_ARCH_BIT(target) (1ULL << (target))
 
+/* Unsuffixed family masks cover system targets; _ALL includes user targets. */
 enum {
     QEMU_ARCH_ALPHA =       QEMU_ARCH_BIT(EMU_TARGET_ALPHA),
     QEMU_ARCH_ARM =         QEMU_ARCH_BIT(EMU_TARGET_ARM) |
                             QEMU_ARCH_BIT(EMU_TARGET_AARCH64),
+    QEMU_ARCH_ARM_ALL =     QEMU_ARCH_ARM |
+                            QEMU_ARCH_BIT(EMU_TARGET_AARCH64_BE) |
+                            QEMU_ARCH_BIT(EMU_TARGET_ARMEB),
     QEMU_ARCH_I386 =        QEMU_ARCH_BIT(EMU_TARGET_I386) |
                             QEMU_ARCH_BIT(EMU_TARGET_X86_64),
     QEMU_ARCH_M68K =        QEMU_ARCH_BIT(EMU_TARGET_M68K),
     QEMU_ARCH_MICROBLAZE =  QEMU_ARCH_BIT(EMU_TARGET_MICROBLAZE),
+    QEMU_ARCH_MICROBLAZE_ALL = QEMU_ARCH_MICROBLAZE |
+                               QEMU_ARCH_BIT(EMU_TARGET_MICROBLAZEEL),
     QEMU_ARCH_MIPS =        QEMU_ARCH_BIT(EMU_TARGET_MIPS) |
                             QEMU_ARCH_BIT(EMU_TARGET_MIPSEL) |
                             QEMU_ARCH_BIT(EMU_TARGET_MIPS64) |
                             QEMU_ARCH_BIT(EMU_TARGET_MIPS64EL),
+    QEMU_ARCH_MIPS_ALL =    QEMU_ARCH_MIPS |
+                            QEMU_ARCH_BIT(EMU_TARGET_MIPSN32) |
+                            QEMU_ARCH_BIT(EMU_TARGET_MIPSN32EL),
     QEMU_ARCH_PPC =         QEMU_ARCH_BIT(EMU_TARGET_PPC) |
                             QEMU_ARCH_BIT(EMU_TARGET_PPC64),
+    QEMU_ARCH_PPC_ALL =     QEMU_ARCH_PPC |
+                            QEMU_ARCH_BIT(EMU_TARGET_PPC64LE),
     QEMU_ARCH_S390X =       QEMU_ARCH_BIT(EMU_TARGET_S390X),
     QEMU_ARCH_SH4 =         QEMU_ARCH_BIT(EMU_TARGET_SH4) |
                             QEMU_ARCH_BIT(EMU_TARGET_SH4EB),
     QEMU_ARCH_SPARC =       QEMU_ARCH_BIT(EMU_TARGET_SPARC) |
                             QEMU_ARCH_BIT(EMU_TARGET_SPARC64),
+    QEMU_ARCH_SPARC_ALL =   QEMU_ARCH_SPARC |
+                            QEMU_ARCH_BIT(EMU_TARGET_SPARC32PLUS),
     QEMU_ARCH_XTENSA =      QEMU_ARCH_BIT(EMU_TARGET_XTENSA) |
                             QEMU_ARCH_BIT(EMU_TARGET_XTENSAEB),
     QEMU_ARCH_OR1K =        QEMU_ARCH_BIT(EMU_TARGET_OR1K),
diff --git a/qapi/machine.json b/qapi/machine.json
index 07fac4f0764..a3d6e08a847 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -15,11 +15,10 @@
 
 ##
 # @EmuTarget:
-#     The comprehensive enumeration of QEMU system emulation
-#     ("softmmu") targets.  Run "./configure --help" in the project
-#     root directory, and look for the \*-softmmu targets near the
-#     "--target-list" option.  The individual target constants are not
-#     documented here, for the time being.
+#     The comprehensive enumeration of QEMU system and user-mode
+#     emulation targets.  Run "./configure --help" in the project root
+#     directory, and look for the targets near the "--target-list"
+#     option.  Individual target constants are not documented here.
 #
 # @rx: since 5.0
 #
@@ -30,17 +29,19 @@
 # @hexagon: since 11.0
 #
 # .. note:: The resulting QMP strings can be appended to the
-#    "qemu-system-" prefix to produce the corresponding QEMU
-#    executable name.  This is true even for "qemu-system-x86_64".
+#    "qemu-system-" prefix for system emulation, or the "qemu-" prefix
+#    for user-mode emulation, to produce the corresponding executable
+#    name, where that target supports the respective emulation mode.
 #
 # Since: 3.0
 ##
 { 'enum' : 'EmuTarget',
-  'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386',
-             'loongarch64', 'm68k', 'microblaze', 'mips', 'mips64',
-             'mips64el', 'mipsel', 'or1k', 'ppc',
-             'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
-             'sh4eb', 'sparc', 'sparc64', 'tricore',
+  'data' : [ 'aarch64', 'aarch64_be', 'alpha', 'arm', 'armeb', 'avr',
+             'hexagon', 'hppa', 'i386', 'loongarch64', 'm68k', 'microblaze',
+             'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel',
+             'mipsn32', 'mipsn32el', 'or1k', 'ppc', 'ppc64', 'ppc64le',
+             'riscv32', 'riscv64', 'rx', 's390x', 'sh4', 'sh4eb', 'sparc',
+             'sparc32plus', 'sparc64', 'tricore',
              'x86_64', 'xtensa', 'xtensaeb' ] }
 
 ##
diff --git a/target-info.c b/target-info.c
index 241be2b5563..b2abcd55bd3 100644
--- a/target-info.c
+++ b/target-info.c
@@ -7,6 +7,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/base-arch-defs.h"
 #include "qemu/target-info.h"
 #include "qemu/target-info-qapi.h"
 #include "qemu/target-info-def.h"
@@ -44,23 +45,19 @@ bool target_big_endian(void)
 
 bool target_base_arm(void)
 {
-    switch (target_arch()) {
-    case EMU_TARGET_ARM:
-    case EMU_TARGET_AARCH64:
-        return true;
-    default:
-        return false;
-    }
+    return (QEMU_ARCH_ARM_ALL & QEMU_ARCH_BIT(target_arch())) != 0;
 }
 
 bool target_arm(void)
 {
-    return target_arch() == EMU_TARGET_ARM;
+    return target_arch() == EMU_TARGET_ARM ||
+           target_arch() == EMU_TARGET_ARMEB;
 }
 
 bool target_aarch64(void)
 {
-    return target_arch() == EMU_TARGET_AARCH64;
+    return target_arch() == EMU_TARGET_AARCH64 ||
+           target_arch() == EMU_TARGET_AARCH64_BE;
 }
 
 bool target_m68k(void)
@@ -75,13 +72,7 @@ bool target_or1k(void)
 
 bool target_base_ppc(void)
 {
-    switch (target_arch()) {
-    case EMU_TARGET_PPC:
-    case EMU_TARGET_PPC64:
-        return true;
-    default:
-        return false;
-    }
+    return (QEMU_ARCH_PPC_ALL & QEMU_ARCH_BIT(target_arch())) != 0;
 }
 
 bool target_ppc(void)
@@ -91,7 +82,8 @@ bool target_ppc(void)
 
 bool target_ppc64(void)
 {
-    return target_arch() == EMU_TARGET_PPC64;
+    return target_arch() == EMU_TARGET_PPC64 ||
+           target_arch() == EMU_TARGET_PPC64LE;
 }
 
 bool target_s390x(void)
-- 
2.55.0.windows.3


Reply via email to