From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 8922E3858D38 for ; Wed, 9 Nov 2022 20:01:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8922E3858D38 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 27A03340E7F; Wed, 9 Nov 2022 20:01:38 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH 4/7] sim: ppc: collapse is_readonly & length switch tables heavily Date: Thu, 10 Nov 2022 03:01:23 +0700 Message-Id: <20221109200126.21090-4-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.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,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: 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. --- 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 d2ea922ffc91..d772771b9fa7 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. */ -- 2.38.1