From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/7] sim: ppc: collapse is_readonly & length switch tables heavily
Date: Thu, 10 Nov 2022 03:01:23 +0700 [thread overview]
Message-ID: <20221109200126.21090-4-vapier@gentoo.org> (raw)
In-Reply-To: <20221109200126.21090-1-vapier@gentoo.org>
Since we know we'll return 0 by default, we don't have to output case
statements for readonly or length fields whose values are also zero.
This is the most common case by far and thus generates a much smaller
switch table in the end.
---
sim/ppc/dgen.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/sim/ppc/dgen.c b/sim/ppc/dgen.c
index d2ea922ffc91..d772771b9fa7 100644
--- a/sim/ppc/dgen.c
+++ b/sim/ppc/dgen.c
@@ -238,14 +238,22 @@ gen_spreg_c(spreg_table *table, lf *file)
spreg_table_entry *entry;
lf_printf(file, " switch (spr) {\n");
for (entry = table->sprs; entry != NULL; entry = entry->next) {
- lf_printf(file, " case %d:\n", entry->spreg_nr);
- if (strcmp(*attribute, "is_valid") == 0)
+ if (strcmp(*attribute, "is_valid") == 0) {
+ lf_printf(file, " case %d:\n", entry->spreg_nr);
/* No return -- see below. */;
- else if (strcmp(*attribute, "is_readonly") == 0)
- lf_printf(file, " return %d;\n", entry->is_readonly);
- else if (strcmp(*attribute, "length") == 0)
- lf_printf(file, " return %d;\n", entry->length);
- else
+ } else if (strcmp(*attribute, "is_readonly") == 0) {
+ /* Since we return 0 by default, only output non-zero entries. */
+ if (entry->is_readonly) {
+ lf_printf(file, " case %d:\n", entry->spreg_nr);
+ lf_printf(file, " return %d;\n", entry->is_readonly);
+ }
+ } else if (strcmp(*attribute, "length") == 0) {
+ /* Since we return 0 by default, only output non-zero entries. */
+ if (entry->length) {
+ lf_printf(file, " case %d:\n", entry->spreg_nr);
+ lf_printf(file, " return %d;\n", entry->length);
+ }
+ } else
ASSERT(0);
}
/* Output a single return for is_valid. */
--
2.38.1
next prev parent reply other threads:[~2022-11-09 20:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 20:01 [PATCH 1/7] sim: ppc: constify spreg table Mike Frysinger
2022-11-09 20:01 ` [PATCH 2/7] sim: ppc: pull default switch return out Mike Frysinger
2022-11-09 20:01 ` [PATCH 3/7] sim: ppc: collapse is_valid switch table more Mike Frysinger
2022-11-09 20:01 ` Mike Frysinger [this message]
2022-11-09 20:01 ` [PATCH 5/7] sim: ppc: drop support for dgen -L option Mike Frysinger
2022-11-09 20:01 ` [PATCH 6/7] sim: ppc: change spreg switch table generation to compile-time Mike Frysinger
2022-11-09 20:01 ` [PATCH 7/7] sim: ppc: move spreg.[ch] files to the source tree Mike Frysinger
2022-12-20 1:50 ` [PATCH 1/2] " Mike Frysinger
2022-12-20 1:50 ` [PATCH 2/2] sim: ppc: drop old dgen.c generator Mike Frysinger
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=20221109200126.21090-4-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).