public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: ppc: collapse is_valid switch table more
@ 2022-11-10 7:32 Michael Frysinger
0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2022-11-10 7:32 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1eff12f75acd62066399437042b7c016463ad932
commit 1eff12f75acd62066399437042b7c016463ad932
Author: Mike Frysinger <vapier@gentoo.org>
Date: Thu Nov 10 02:15:34 2022 +0700
sim: ppc: collapse is_valid switch table more
Instead of writing:
case 1:
return 1;
case 2:
return 1;
...etc...
Output a single return so we get:
case 1:
case 2:
case ...
return 1;
This saves ~100 lines of code. Hopefully the compiler was already
smart enough to optimize to the same code, but if not, this probably
helps there too :).
Diff:
---
sim/ppc/dgen.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sim/ppc/dgen.c b/sim/ppc/dgen.c
index 0cc210b5fed..d2ea922ffc9 100644
--- a/sim/ppc/dgen.c
+++ b/sim/ppc/dgen.c
@@ -240,7 +240,7 @@ gen_spreg_c(spreg_table *table, lf *file)
for (entry = table->sprs; entry != NULL; entry = entry->next) {
lf_printf(file, " case %d:\n", entry->spreg_nr);
if (strcmp(*attribute, "is_valid") == 0)
- lf_printf(file, " return 1;\n");
+ /* 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)
@@ -248,6 +248,9 @@ gen_spreg_c(spreg_table *table, lf *file)
else
ASSERT(0);
}
+ /* Output a single return for is_valid. */
+ if (strcmp(*attribute, "is_valid") == 0)
+ lf_printf(file, " return 1;\n");
lf_printf(file, " }\n");
lf_printf(file, " return 0;\n");
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-10 7:32 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:32 [binutils-gdb] sim: ppc: collapse is_valid switch table more 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).