diff options
author | Mike Frysinger <vapier@gentoo.org> | 2022-11-10 02:15:34 +0700 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2022-11-10 14:27:40 +0700 |
commit | 1eff12f75acd62066399437042b7c016463ad932 (patch) | |
tree | 2227dd6a06ddbea5ad70723034f163f41a215531 | |
parent | 99961e814f795e4e4fd40e5f7f5bae52150963d5 (diff) | |
download | gdb-1eff12f75acd62066399437042b7c016463ad932.zip gdb-1eff12f75acd62066399437042b7c016463ad932.tar.gz gdb-1eff12f75acd62066399437042b7c016463ad932.tar.bz2 |
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 :).
-rw-r--r-- | sim/ppc/dgen.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sim/ppc/dgen.c b/sim/ppc/dgen.c index 0cc210b..d2ea922 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"); } |