From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id EA20B3858D28; Thu, 10 Nov 2022 07:32:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA20B3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668065557; bh=Q3vbDMPwl7vvXim4t3MQxrDGe6uvWhV40awfGw0kBDc=; h=From:To:Subject:Date:From; b=wqnWVDqJ+uBr0xIOVmuQaDh8Dj2eQsHMehfsR1WWTqsLHxqsOSfMb5+MRS5hhF11r 6hwlOEy2lzKUW2Ni8QiNaEn3axbLVnBaS9kZWIsPi3Ni9oyJ3iSaNsy9uxQIRgUKRo n+6zhv+cqyTIIDHetmhvimhmNaEFE2BbOBEYfr6M= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Frysinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: ppc: collapse is_valid switch table more X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: 99961e814f795e4e4fd40e5f7f5bae52150963d5 X-Git-Newrev: 1eff12f75acd62066399437042b7c016463ad932 Message-Id: <20221110073237.EA20B3858D28@sourceware.org> Date: Thu, 10 Nov 2022 07:32:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1eff12f75acd= 62066399437042b7c016463ad932 commit 1eff12f75acd62066399437042b7c016463ad932 Author: Mike Frysinger Date: Thu Nov 10 02:15:34 2022 +0700 sim: ppc: collapse is_valid switch table more =20 Instead of writing: case 1: return 1; case 2: return 1; ...etc... =20 Output a single return so we get: case 1: case 2: case ... return 1; =20 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 =3D table->sprs; entry !=3D NULL; entry =3D entry->next) { lf_printf(file, " case %d:\n", entry->spreg_nr); if (strcmp(*attribute, "is_valid") =3D=3D 0) - lf_printf(file, " return 1;\n"); + /* No return -- see below. */; else if (strcmp(*attribute, "is_readonly") =3D=3D 0) lf_printf(file, " return %d;\n", entry->is_readonly); else if (strcmp(*attribute, "length") =3D=3D 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") =3D=3D 0) + lf_printf(file, " return 1;\n"); lf_printf(file, " }\n"); lf_printf(file, " return 0;\n"); }