qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/1] target/riscv: Make property names lowercase and add capitalized aliases
@ 2022-05-13  9:46 Tsukasa OI
  2022-05-13  9:46 ` [RFC PATCH 1/1] target/riscv: Make property names lowercase Tsukasa OI
  2022-05-25  9:54 ` [PATCH v2 0/3] target/riscv: Make CPU property names lowercase (w/ capitalized aliases) Tsukasa OI
  0 siblings, 2 replies; 19+ messages in thread
From: Tsukasa OI @ 2022-05-13  9:46 UTC (permalink / raw)
  To: Tsukasa OI, Alistair Francis, Frank Chang, Dao Lu; +Cc: qemu-devel, qemu-riscv

Hello,

While I'm reviewing Dao Lu's Zihintpause patch, I noticed something.

c.f. <https://lists.gnu.org/archive/html/qemu-riscv/2022-05/msg00210.html>

While some CPU configuration properties have capitalized names but others
have lowercase names.  See riscv_cpu_properties in target/riscv/cpu.c
for example:

    DEFINE_PROP_BOOL("i", RISCVCPU, cfg.ext_i, true),
    DEFINE_PROP_BOOL("e", RISCVCPU, cfg.ext_e, false),
    DEFINE_PROP_BOOL("g", RISCVCPU, cfg.ext_g, true),

...

    DEFINE_PROP_BOOL("Counters", RISCVCPU, cfg.ext_counters, true),
    DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true),
    DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true),

...

    DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true),
    DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true),
    DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true),

...

I think this is not good.  Property names should have some sort of
consistency (especially when those names are case sensitive).  This is
what happens when invalid property is specified:

Invalid: -cpu rv64,counters=off
Valid  : -cpu rv64,Counters=off

    qemu-system-riscv64: can't apply global rv64-riscv-cpu.counters=off: Property 'rv64-riscv-cpu.counters' not found

But we can't just remove such names for compatibility.

I found a way to make "property aliases" and that way, we can make both
"Counters" and "counters" valid.  I chose lowercase names (because of
number of properties implemented) as primary ones and capitalized names
are defined as aliases.

For instance, I'll show how both "counters" and "Counters" are implemented
below. They share three arguments but on alias (the second one),:

-   it uses DEFINE_PROP on alias to disable setting default value and
-   it defines property type (that is generally set by DEFINE_PROP_BOOL but
    must be set manually because the alias uses DEFINE_PROP).

    DEFINE_PROP_BOOL("counters", RISCVCPU, cfg.ext_counters, true),
    DEFINE_PROP     ("Counters", RISCVCPU, cfg.ext_counters, qdev_prop_bool, bool),




Tsukasa OI (1):
  target/riscv: Make property names lowercase

 target/riscv/cpu.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)


base-commit: 178bacb66d98d9ee7a702b9f2a4dfcd88b72a9ab
-- 
2.34.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-06-06  6:09 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-13  9:46 [RFC PATCH 0/1] target/riscv: Make property names lowercase and add capitalized aliases Tsukasa OI
2022-05-13  9:46 ` [RFC PATCH 1/1] target/riscv: Make property names lowercase Tsukasa OI
2022-05-23  6:36   ` Alistair Francis
2022-05-25  9:54 ` [PATCH v2 0/3] target/riscv: Make CPU property names lowercase (w/ capitalized aliases) Tsukasa OI
2022-05-25  9:54   ` [PATCH v2 1/3] target/riscv: Reorganize riscv_cpu_properties Tsukasa OI
2022-06-01  4:05     ` Alistair Francis
2022-05-25  9:54   ` [PATCH v2 2/3] target/riscv: Make CPU property names lowercase Tsukasa OI
2022-05-25 12:10     ` Víctor Colombo
2022-05-25 14:55       ` Tsukasa OI
2022-06-02  1:17         ` Alistair Francis
2022-05-25 14:32     ` [PATCH v2.1 " Tsukasa OI
2022-05-25  9:54   ` [PATCH v2 3/3] target/riscv: Deprecate capitalized property names Tsukasa OI
2022-06-02  1:20     ` Alistair Francis
2022-06-03 11:36   ` [PATCH v3 0/3] target/riscv: Make CPU property names lowercase (w/ capitalized aliases) Tsukasa OI
2022-06-03 11:36     ` [PATCH v3 1/3] target/riscv: Reorganize riscv_cpu_properties Tsukasa OI
2022-06-06  6:02       ` Alistair Francis
2022-06-03 11:36     ` [PATCH v3 2/3] target/riscv: Make CPU property names lowercase Tsukasa OI
2022-06-06  6:03       ` Alistair Francis
2022-06-03 11:36     ` [PATCH v3 3/3] target/riscv: Deprecate capitalized property names Tsukasa OI

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).