qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [RFC PATCH 10/11] qemu: Introduce qemu_arch_name() helper
Date: Tue, 4 Mar 2025 18:23:16 -0800	[thread overview]
Message-ID: <c3a1a692-4b8c-48e0-bebd-be9cf760c1a5@linaro.org> (raw)
In-Reply-To: <20250305005225.95051-11-philmd@linaro.org>

On 3/4/25 16:52, Philippe Mathieu-Daudé wrote:
> Introduce a generic helper to get the target name of a QemuArchBit.
> (This will be used for single / heterogeneous binaries).
> Use it in target_name(), removing the last use of the TARGET_NAME
> definition.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/qemu/arch_info.h |  2 ++
>   arch_info-target.c       | 34 +++++++++++++++++++++++++++++++++-
>   2 files changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/include/qemu/arch_info.h b/include/qemu/arch_info.h
> index 613dc2037db..7e3192f590f 100644
> --- a/include/qemu/arch_info.h
> +++ b/include/qemu/arch_info.h
> @@ -46,6 +46,8 @@ typedef enum QemuArchBit {
>   #define QEMU_ARCH_LOONGARCH     BIT(QEMU_ARCH_BIT_LOONGARCH)
>   #define QEMU_ARCH_ALL           -1
>   
> +const char *qemu_arch_name(QemuArchBit qemu_arch_bit);
> +
>   const char *target_name(void);
>   
>   bool qemu_arch_available(unsigned qemu_arch_mask);
> diff --git a/arch_info-target.c b/arch_info-target.c
> index 61007415b30..9b19fe8d56d 100644
> --- a/arch_info-target.c
> +++ b/arch_info-target.c
> @@ -24,9 +24,41 @@
>   #include "qemu/osdep.h"
>   #include "qemu/arch_info.h"
>   
> +const char *qemu_arch_name(QemuArchBit qemu_arch_bit)
> +{
> +    static const char *legacy_target_names[] = {
> +        [QEMU_ARCH_ALPHA] = "alpha",
> +        [QEMU_ARCH_BIT_ARM] = TARGET_LONG_BITS == 32 ? "arm" : "aarch64",
> +        [QEMU_ARCH_BIT_AVR] = "avr",
> +        [QEMU_ARCH_BIT_HEXAGON] = "hexagon",
> +        [QEMU_ARCH_BIT_HPPA] = "hppa",
> +        [QEMU_ARCH_BIT_I386] = TARGET_LONG_BITS == 32 ? "i386" : "x86_64",
> +        [QEMU_ARCH_BIT_LOONGARCH] = "loongarch64",
> +        [QEMU_ARCH_BIT_M68K] = "m68k",
> +        [QEMU_ARCH_BIT_MICROBLAZE] = TARGET_BIG_ENDIAN ? "microblaze"
> +                                                       : "microblazeel",
> +        [QEMU_ARCH_BIT_MIPS] = TARGET_BIG_ENDIAN
> +                             ? (TARGET_LONG_BITS == 32 ? "mips" : "mips64")
> +                             : (TARGET_LONG_BITS == 32 ? "mipsel" : "mips64el"),
> +        [QEMU_ARCH_BIT_OPENRISC] = "or1k",
> +        [QEMU_ARCH_BIT_PPC] = TARGET_LONG_BITS == 32 ? "ppc" : "ppc64",
> +        [QEMU_ARCH_BIT_RISCV] = TARGET_LONG_BITS == 32 ? "riscv32" : "riscv64",
> +        [QEMU_ARCH_BIT_RX] = "rx",
> +        [QEMU_ARCH_BIT_S390X] = "s390x",
> +        [QEMU_ARCH_BIT_SH4] = TARGET_BIG_ENDIAN ? "sh4eb" : "sh4",
> +        [QEMU_ARCH_BIT_SPARC] = TARGET_LONG_BITS == 32 ? "sparc" : "sparc64",
> +        [QEMU_ARCH_BIT_TRICORE] = "tricore",
> +        [QEMU_ARCH_BIT_XTENSA] = TARGET_BIG_ENDIAN ? "xtensaeb" : "xtensa",
> +    };
> +
> +    assert(qemu_arch_bit < ARRAY_SIZE(legacy_target_names));
> +    assert(legacy_target_names[qemu_arch_bit]);
> +    return legacy_target_names[qemu_arch_bit];
> +}

Given all of the other #defines checked in this function,
I don't think it's helpful at all.

I think you should drop this patch for now.


r~


  parent reply	other threads:[~2025-03-05  2:23 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05  0:52 [RFC PATCH 00/11] qemu: Remove TARGET_NAME definition Philippe Mathieu-Daudé
2025-03-05  0:52 ` [RFC PATCH 01/11] system: Extract target-specific globals to their own compilation unit Philippe Mathieu-Daudé
2025-03-05  1:20   ` Pierrick Bouvier
2025-03-05  1:33     ` Philippe Mathieu-Daudé
2025-03-05  1:41       ` Pierrick Bouvier
2025-03-11 10:24   ` Alex Bennée
2025-03-05  0:52 ` [RFC PATCH 02/11] system: Open-code qemu_init_arch_modules() using target_name() Philippe Mathieu-Daudé
2025-03-05  2:27   ` Richard Henderson
2025-03-05  0:52 ` [RFC PATCH 03/11] system: Introduce QemuArchBit enum Philippe Mathieu-Daudé
2025-03-05  1:23   ` Pierrick Bouvier
2025-03-05  1:31     ` Philippe Mathieu-Daudé
2025-03-05  1:36       ` Pierrick Bouvier
2025-03-05  1:39         ` Philippe Mathieu-Daudé
2025-03-05  2:27   ` Richard Henderson
2025-03-05  8:55   ` Daniel P. Berrangé
2025-03-05  9:00     ` Daniel P. Berrangé
2025-03-05  0:52 ` [RFC PATCH 04/11] system: Replace arch_type global by qemu_arch_available() helper Philippe Mathieu-Daudé
2025-03-05  2:29   ` Richard Henderson
2025-03-05  0:52 ` [RFC PATCH 05/11] include: Expose QemuArchBit enum to user emulation Philippe Mathieu-Daudé
2025-03-05  2:43   ` Richard Henderson
2025-03-05  0:52 ` [RFC PATCH 06/11] include: Declare target_name() in common "qemu/arch_info.h" Philippe Mathieu-Daudé
2025-03-05  2:44   ` Richard Henderson
2025-03-05  0:52 ` [RFC PATCH 07/11] plugins/loader: populate target_name with target_name() Philippe Mathieu-Daudé
2025-03-05  0:52 ` [RFC PATCH 08/11] tests/qtest: Replace TARGET_NAME -> target_name() Philippe Mathieu-Daudé
2025-03-05  3:02   ` Richard Henderson
2025-03-05  0:52 ` [RFC PATCH 09/11] user: " Philippe Mathieu-Daudé
2025-03-05  0:52 ` [RFC PATCH 10/11] qemu: Introduce qemu_arch_name() helper Philippe Mathieu-Daudé
2025-03-05  1:32   ` BALATON Zoltan
2025-03-05  1:36     ` Philippe Mathieu-Daudé
2025-03-05  2:05       ` BALATON Zoltan
2025-03-05  2:23   ` Richard Henderson [this message]
2025-03-05  8:59   ` Daniel P. Berrangé
2025-03-05  0:52 ` [RFC PATCH 11/11] qemu: Remove C definitions of TARGET_NAME Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c3a1a692-4b8c-48e0-bebd-be9cf760c1a5@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).