qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Gavin Shan <gshan@redhat.com>, qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
	peter.maydell@linaro.org, b.galvani@gmail.com,
	strahinja.p.jankovic@gmail.com, sundeep.lkml@gmail.com,
	kfting@nuvoton.com, wuhaotsh@google.com,
	nieklinnenbank@gmail.com, rad@semihalf.com,
	quic_llindhol@quicinc.com, marcin.juszkiewicz@linaro.org,
	eduardo@habkost.net, marcel.apfelbaum@gmail.com,
	philmd@linaro.org, wangyanan55@huawei.com, laurent@vivier.eu,
	vijai@behindbytes.com, palmer@dabbelt.com,
	alistair.francis@wdc.com, bin.meng@windriver.com,
	liweiwei@iscas.ac.cn, dbarboza@ventanamicro.com,
	zhiwei_liu@linux.alibaba.com, imammedo@redhat.com,
	cohuck@redhat.com, pbonzini@redhat.com, shan.gavin@gmail.com
Subject: Re: [PATCH v2 3/8] machine: Print supported CPU models instead of typenames
Date: Thu, 27 Jul 2023 07:27:40 -0700	[thread overview]
Message-ID: <af279f3d-35b9-e782-8d55-98cd6b3ceb80@linaro.org> (raw)
In-Reply-To: <0454c1ad-314c-3df6-d6e9-1a05cb4c4050@redhat.com>

On 7/26/23 22:16, Gavin Shan wrote:
> 
> On 7/27/23 09:08, Richard Henderson wrote:
>> On 7/25/23 17:32, Gavin Shan wrote:
>>> -static const char *q800_machine_valid_cpu_types[] = {
>>> +static const char * const q800_machine_valid_cpu_types[] = {
>>>       M68K_CPU_TYPE_NAME("m68040"),
>>>       NULL
>>>   };
>>> +static const char * const q800_machine_valid_cpu_models[] = {
>>> +    "m68040",
>>> +    NULL
>>> +};
>>
>> I really don't like this replication.
>>
> 
> Right, it's going to be lots of replications, but gives much flexibility.
> There are 21 targets and we don't have fixed pattern for the mapping between
> CPU model name and CPU typename. I'm summarizing the used patterns like below.
> 
>    1 All CPU model names are mappinged to fixed CPU typename;
>    2 CPU model name is same to CPU typename;
>    3 CPU model name is alias to CPU typename;
>    4 CPU model name is prefix of CPU typename;
> 
>    Target         Categories    suffix-of-CPU-typename
>    -------------------------------------------------------
>    alpha          -234          -alpha-cpu
>    arm            ---4          -arm-cpu
>    avr            -2--
>    cris           --34          -cris-cpu
>    hexagon        ---4          -hexagon-cpu
>    hppa           1---
>    i386           ---4          -i386-cpu
>    loongarch      -2-4          -loongarch-cpu
>    m68k           ---4          -m68k-cpu
>    microblaze     1---
>    mips           ---4          -mips64-cpu  -mips-cpu
>    nios2          1---
>    openrisc       ---4          -or1k-cpu
>    ppc            --34          -powerpc64-cpu  -powerpc-cpu
>    riscv          ---4          -riscv-cpu
>    rx             -2-4          -rx-cpu
>    s390x          ---4          -s390x-cpu
>    sh4            --34          -superh-cpu
>    sparc          -2--
>    tricore        ---4          -tricore-cpu
>    xtensa         ---4          -xtensa-cpu

That is unfortunate, however...


> There are several options as below. Please let me know which one or something
> else is the best.
> 
> (a) Keep what we have and use mc->valid_{cpu_types, cpu_models}[] to track
> the valid CPU typenames and CPU model names.
> 
> (b) Introduce CPUClass::model_name_by_typename(). Every target has their own
> implementation to convert CPU typename to CPU model name. The CPU model name
> is parsed from mc->valid_cpu_types[i].
> 
>      char *CPUClass::model_by_typename(const char *typename);
> 
> (c) As we discussed before, use mc->valid_cpu_type_suffix and mc->valid_cpu_models
> because the CPU type check is currently needed by target arm/m68k/riscv where we
> do have fixed pattern to convert CPU model names to CPU typenames. The CPU typename
> is comprised of CPU model name and suffix. However, it won't be working when the CPU
> type check is required by other target where we have patterns other than this.

(d) Merge the two arrays together and use macro expansion, e.g.

typedef struct {
     const char *name;
     const char *type;
} Something;

#define ARM_SOMETHING(x)  { x, ARM_CPU_TYPE_NAME(x) }

static const Something valid[] = {
     ARM_SOMETHING("cortex-a53"),
     { NULL, NULL }
};

where Something ought to be better named.


r~


  parent reply	other threads:[~2023-07-27 14:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-26  0:31 [PATCH v2 0/8] machine: Unified CPU type check Gavin Shan
2023-07-26  0:31 ` [PATCH v2 1/8] machine: Use error handling when CPU type is checked Gavin Shan
2023-07-26  0:31 ` [PATCH v2 2/8] machine: Introduce helper is_cpu_type_supported() Gavin Shan
2023-07-26 23:03   ` Richard Henderson
2023-07-26  0:32 ` [PATCH v2 3/8] machine: Print supported CPU models instead of typenames Gavin Shan
2023-07-26 23:08   ` Richard Henderson
2023-07-27  5:16     ` Gavin Shan
2023-07-27  9:00       ` Igor Mammedov
2023-07-31  5:07         ` Gavin Shan
2023-08-28 14:46           ` Igor Mammedov
2023-08-29  6:28             ` Gavin Shan
2023-08-29  9:03               ` Igor Mammedov
2023-08-30  7:34                 ` Gavin Shan
2023-08-31  9:02                   ` Igor Mammedov
2023-07-27 14:27       ` Richard Henderson [this message]
2023-07-31  5:33         ` Gavin Shan
2023-07-26  0:32 ` [PATCH v2 4/8] hw/arm/virt: Check CPU type in machine_run_board_init() Gavin Shan
2023-07-26  0:32 ` [PATCH v2 5/8] hw/arm/virt: Unsupported host CPU model on TCG Gavin Shan
2023-07-26  0:32 ` [PATCH v2 6/8] hw/arm/sbsa-ref: Check CPU type in machine_run_board_init() Gavin Shan
2023-07-26  0:32 ` [PATCH v2 7/8] hw/arm: " Gavin Shan
2023-07-26  0:32 ` [PATCH v2 8/8] hw/riscv/shakti_c: " Gavin Shan

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=af279f3d-35b9-e782-8d55-98cd6b3ceb80@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=b.galvani@gmail.com \
    --cc=bin.meng@windriver.com \
    --cc=cohuck@redhat.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=eduardo@habkost.net \
    --cc=gshan@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kfting@nuvoton.com \
    --cc=laurent@vivier.eu \
    --cc=liweiwei@iscas.ac.cn \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=marcin.juszkiewicz@linaro.org \
    --cc=nieklinnenbank@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=quic_llindhol@quicinc.com \
    --cc=rad@semihalf.com \
    --cc=shan.gavin@gmail.com \
    --cc=strahinja.p.jankovic@gmail.com \
    --cc=sundeep.lkml@gmail.com \
    --cc=vijai@behindbytes.com \
    --cc=wangyanan55@huawei.com \
    --cc=wuhaotsh@google.com \
    --cc=zhiwei_liu@linux.alibaba.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).