From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1521) id 579F43858D28; Thu, 10 Nov 2022 07:34:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 579F43858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668065641; bh=V45xBWRXPlAwgPLOtKF3p0cL3gktjqsSUIGIVybshdM=; h=From:To:Subject:Date:From; b=swmAHLvH6HSanLBvCd+EHrl5xM6DtcWinU/VnJC6LpSHC9upG24wCV22KOXpSb2bx 1GnYgjYvGlKv6JvgUNAiJKG4wTDVooQ/cezPtLcJyUiF2yxdIhzt9Tmpt3JbLNJ9Lc XeRV4INNJ8WxjpVdjnIBiJLHX8+R3HHRhqjzRBg0= 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_readonly & length switch tables heavily X-Act-Checkin: binutils-gdb X-Git-Author: Mike Frysinger X-Git-Refname: refs/heads/master X-Git-Oldrev: 1eff12f75acd62066399437042b7c016463ad932 X-Git-Newrev: 40466c48e843221e010209e4baa4197debf7a092 Message-Id: <20221110073401.579F43858D28@sourceware.org> Date: Thu, 10 Nov 2022 07:34:00 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D40466c48e843= 221e010209e4baa4197debf7a092 commit 40466c48e843221e010209e4baa4197debf7a092 Author: Mike Frysinger Date: Thu Nov 10 02:24:41 2022 +0700 sim: ppc: collapse is_readonly & length switch tables heavily =20 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. Diff: --- 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 d2ea922ffc9..d772771b9fa 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 =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) + if (strcmp(*attribute, "is_valid") =3D=3D 0) { + lf_printf(file, " case %d:\n", entry->spreg_nr); /* 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) - lf_printf(file, " return %d;\n", entry->length); - else + } else if (strcmp(*attribute, "is_readonly") =3D=3D 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") =3D=3D 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. */