From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>,
Alistair Francis <alistair23@gmail.com>,
Frank Chang <frank.chang@sifive.com>, Dao Lu <daolu@rivosinc.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Subject: [RFC PATCH 0/1] target/riscv: Make property names lowercase and add capitalized aliases
Date: Fri, 13 May 2022 18:46:52 +0900 [thread overview]
Message-ID: <cover.1652435208.git.research_trasio@irq.a4lg.com> (raw)
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
next reply other threads:[~2022-05-13 9:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 9:46 Tsukasa OI [this message]
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
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=cover.1652435208.git.research_trasio@irq.a4lg.com \
--to=research_trasio@irq.a4lg.com \
--cc=alistair23@gmail.com \
--cc=daolu@rivosinc.com \
--cc=frank.chang@sifive.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/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).