public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: ppc: collapse is_readonly & length switch tables heavily
@ 2022-11-10 7:34 Michael Frysinger
0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2022-11-10 7:34 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=40466c48e843221e010209e4baa4197debf7a092
commit 40466c48e843221e010209e4baa4197debf7a092
Author: Mike Frysinger <vapier@gentoo.org>
Date: Thu Nov 10 02:24:41 2022 +0700
sim: ppc: collapse is_readonly & length switch tables heavily
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.
Diff:
---
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 d2ea922ffc9..d772771b9fa 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. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-10 7:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 7:34 [binutils-gdb] sim: ppc: collapse is_readonly & length switch tables heavily Michael Frysinger
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).