From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 750543858D35 for ; Wed, 9 Nov 2022 20:01:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 750543858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 14817340E7C; Wed, 9 Nov 2022 20:01:36 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 3/7] sim: ppc: collapse is_valid switch table more Date: Thu, 10 Nov 2022 03:01:22 +0700 Message-Id: <20221109200126.21090-3-vapier@gentoo.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221109200126.21090-1-vapier@gentoo.org> References: <20221109200126.21090-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 :). --- 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 0cc210b5fed1..d2ea922ffc91 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"); } -- 2.38.1