From patchwork Wed Nov 9 20:01:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 60301 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B14F0388551E for ; Wed, 9 Nov 2022 20:02:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B14F0388551E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668024173; bh=O/Fn9O+JftyaZ+uSMGQfYQAyvcf8IQXl7SbtppiqTTs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HEKbAwt0tCf9LfrlOgWL9XUFT5WzpBqbx5TRtd8/JdfLSzCoKtGu+yi0hWFQuVROS 2qJLeazN4xvG3fdPkh/UJ4wSOBzGFeXCNI9OIMJfkXtA2ZYemxJnP9zV8r+yX6/uS0 4890CUN8/9AxrqCBXh+W17WdtbxPSM56wvD1tmjU= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id A76E83858CDA for ; Wed, 9 Nov 2022 20:01:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A76E83858CDA Received: by smtp.gentoo.org (Postfix, from userid 559) id 4B32D340E82; Wed, 9 Nov 2022 20:01:42 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 6/7] sim: ppc: change spreg switch table generation to compile-time Date: Thu, 10 Nov 2022 03:01:25 +0700 Message-Id: <20221109200126.21090-6-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 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mike Frysinger via Gdb-patches From: Mike Frysinger Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Simplify the generator by always outputting the switch tables, and leave the choice of whether to use them to the compiler via a -D flag. --- sim/ppc/Makefile.in | 6 ++++-- sim/ppc/configure | 2 +- sim/ppc/configure.ac | 2 +- sim/ppc/dgen.c | 21 ++++++++++----------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index 05f357a31a0a..a07a3262961a 100644 --- a/sim/ppc/Makefile.in +++ b/sim/ppc/Makefile.in @@ -70,6 +70,7 @@ FLOAT_CFLAGS = @sim_float@ MONITOR_CFLAGS = @sim_monitor@ MODEL_CFLAGS = @sim_model@ @sim_default_model@ @sim_model_issue@ TERMIO_CFLAGS = @sim_termio@ +SWITCH_CFLAGS = @sim_switch@ CONFIG_CFLAGS = \ $(SMP_CFLAGS) \ $(XOR_ENDIAN_CFLAGS) \ @@ -79,7 +80,8 @@ CONFIG_CFLAGS = \ $(FLOAT_CFLAGS) \ $(MONITOR_CFLAGS) \ $(MODEL_CFLAGS) \ - $(TERMIO_CFLAGS) + $(TERMIO_CFLAGS) \ + $(SWITCH_CFLAGS) SIM_FPU_CFLAGS = -DHAVE_COMMON_FPU -I../common -I${srcdir}/../common STD_CFLAGS = $(CFLAGS) $(WERROR_CFLAGS) $(INLINE_CFLAGS) $(CONFIG_CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(INCGNU) $(SIM_FPU_CFLAGS) @@ -99,7 +101,7 @@ IGEN_FILTER = @sim_filter@ IGEN_ICACHE = @sim_icache@ IGEN_SMP = @sim_igen_smp@ IGEN_LINE_NR = @sim_line_nr@ -DGEN_FLAGS = @sim_switch@ +DGEN_FLAGS = IGEN_FLAGS = \ $(IGEN_DECODE_MECHANISM) \ diff --git a/sim/ppc/configure.ac b/sim/ppc/configure.ac index cd9edd0de4cd..5260fa0ba7af 100644 --- a/sim/ppc/configure.ac +++ b/sim/ppc/configure.ac @@ -345,7 +345,7 @@ fi])dnl AC_ARG_ENABLE(sim-switch, [ --enable-sim-switch Use a switch instead of a table for instruction call.], [case "${enableval}" in - yes) sim_switch="-s";; + yes) sim_switch="-DWITH_SPREG_SWITCH_TABLE";; no) sim_switch="";; *) AC_MSG_ERROR("--enable-sim-switch does not take a value"); sim_switch="";; esac diff --git a/sim/ppc/dgen.c b/sim/ppc/dgen.c index 8a17700820e5..73f8d7d45825 100644 --- a/sim/ppc/dgen.c +++ b/sim/ppc/dgen.c @@ -39,7 +39,6 @@ /****************************************************************/ -int spreg_lookup_table = 1; enum { nr_of_sprs = 1024, }; @@ -185,6 +184,7 @@ gen_spreg_c(spreg_table *table, lf *file) spreg_table_entry *entry; char **attribute; int spreg_nr; + int spreg_lookup_table; lf_print__gnu_copyleft(file); lf_printf(file, "\n"); @@ -229,13 +229,11 @@ gen_spreg_c(spreg_table *table, lf *file) } lf_printf(file, "spr_%s(sprs spr)\n", *attribute); lf_printf(file, "{\n"); - if (spreg_lookup_table - || strcmp(*attribute, "name") == 0 - || strcmp(*attribute, "index") == 0) - lf_printf(file, " return spr_info[spr].%s;\n", - *attribute); - else { + spreg_lookup_table = !(strcmp(*attribute, "name") == 0 + || strcmp(*attribute, "index") == 0); + if (spreg_lookup_table) { spreg_table_entry *entry; + lf_printf(file, "#ifdef WITH_SPREG_SWITCH_TABLE\n"); lf_printf(file, " switch (spr) {\n"); for (entry = table->sprs; entry != NULL; entry = entry->next) { if (strcmp(*attribute, "is_valid") == 0) { @@ -261,7 +259,12 @@ gen_spreg_c(spreg_table *table, lf *file) lf_printf(file, " return 1;\n"); lf_printf(file, " }\n"); lf_printf(file, " return 0;\n"); + lf_printf(file, "#else\n"); } + lf_printf(file, " return spr_info[spr].%s;\n", + *attribute); + if (spreg_lookup_table) + lf_printf(file, "#endif\n"); lf_printf(file, "}\n"); } @@ -288,7 +291,6 @@ main(int argc, if (argc <= 1) { printf("Usage: dgen ...\n"); - printf("-s Use switch instead of table\n"); printf("-n Use this as cpp line numbering name\n"); printf("-h Output header file\n"); printf("-p Output spreg.h(P) or spreg.c(p)\n"); @@ -301,9 +303,6 @@ main(int argc, fprintf(stderr, "\t-%c %s\n", ch, ( optarg ? optarg : "")); #endif switch(ch) { - case 's': - spreg_lookup_table = 0; - break; case 'r': sprs = spreg_table_load(optarg); break;