From patchwork Fri Dec 23 06:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 62341 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 32C41382FCBF for ; Fri, 23 Dec 2022 06:09:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32C41382FCBF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1671775798; bh=DlUzyZgaKASdT0nKK00adPzlUcjSt3leTz2n+fBXKkA=; 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=GRFVQOK9zwDeKej2V9mgTsvMrvdzq8/bq7oLbVlOcUj1CmsJVO9ZsrKHFVSALiNCM G2mCWVg1okVct9CRqji9O3HSFZzXiBW5vZzBPjCQgsIsqWkapAFzKjVflYSG5/8kMU 1YwdQ/69ayv72Os4ZOmC52JuHEvSiFA5fR8lM86k= 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 A505E385B507 for ; Fri, 23 Dec 2022 06:08:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A505E385B507 Received: by smtp.gentoo.org (Postfix, from userid 559) id 40F66341172; Fri, 23 Dec 2022 06:08:01 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 20/20] sim: m32r: move arch-specific settings to internal header Date: Fri, 23 Dec 2022 01:07:13 -0500 Message-Id: <20221223060713.28821-21-vapier@gentoo.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221223060713.28821-1-vapier@gentoo.org> References: <20221223060713.28821-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, KAM_SHORT, 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" There's no need for these settings to be in sim-main.h which is shared with common/ sim code, so move it all out to the existing m32r-sim.h. Unfortunately, we can't yet drop the m32r-sim.h include from sim-main.h as many of the generated CGEN files refer only to sim-main.h. We'll have to improve the CGEN interface before we can make more progress, but this is at least a minor improvement. --- sim/m32r/m32r-sim.h | 22 ++++++++++++++++++++++ sim/m32r/m32r.c | 2 ++ sim/m32r/m32r2.c | 2 ++ sim/m32r/m32rx.c | 2 ++ sim/m32r/sim-if.c | 1 + sim/m32r/sim-main.h | 24 ++---------------------- sim/m32r/traps.c | 2 ++ 7 files changed, 33 insertions(+), 22 deletions(-) diff --git a/sim/m32r/m32r-sim.h b/sim/m32r/m32r-sim.h index fc41c2146f75..3586f3297880 100644 --- a/sim/m32r/m32r-sim.h +++ b/sim/m32r/m32r-sim.h @@ -166,5 +166,27 @@ do { \ /* Handle the trap insn. */ USI m32r_trap (SIM_CPU *, PCADDR, int); + +struct m32r_sim_cpu { + M32R_MISC_PROFILE m32r_misc_profile; +#define CPU_M32R_MISC_PROFILE(cpu) (& M32R_SIM_CPU (cpu)->m32r_misc_profile) + + /* CPU specific parts go here. + Note that in files that don't need to access these pieces WANT_CPU_FOO + won't be defined and thus these parts won't appear. This is ok in the + sense that things work. It is a source of bugs though. + One has to of course be careful to not take the size of this + struct and no structure members accessed in non-cpu specific files can + go after here. Oh for a better language. */ +#if defined (WANT_CPU_M32RBF) + M32RBF_CPU_DATA cpu_data; +#endif +#if defined (WANT_CPU_M32RXF) + M32RXF_CPU_DATA cpu_data; +#elif defined (WANT_CPU_M32R2F) + M32R2F_CPU_DATA cpu_data; +#endif +}; +#define M32R_SIM_CPU(cpu) ((struct m32r_sim_cpu *) CPU_ARCH_DATA (cpu)) #endif /* M32R_SIM_H */ diff --git a/sim/m32r/m32r.c b/sim/m32r/m32r.c index 478a45c25869..014aa712c160 100644 --- a/sim/m32r/m32r.c +++ b/sim/m32r/m32r.c @@ -28,6 +28,8 @@ #include "cgen-ops.h" #include +#include "m32r-sim.h" + /* Return the size of REGNO in bytes. */ static int diff --git a/sim/m32r/m32r2.c b/sim/m32r/m32r2.c index 8881bc68081f..b95e509a41aa 100644 --- a/sim/m32r/m32r2.c +++ b/sim/m32r/m32r2.c @@ -27,6 +27,8 @@ #include "cgen-mem.h" #include "cgen-ops.h" +#include "m32r-sim.h" + /* The contents of BUF are in target byte order. */ int diff --git a/sim/m32r/m32rx.c b/sim/m32r/m32rx.c index e5724c5410d6..52073e1344a0 100644 --- a/sim/m32r/m32rx.c +++ b/sim/m32r/m32rx.c @@ -27,6 +27,8 @@ along with this program. If not, see . */ #include "cgen-mem.h" #include "cgen-ops.h" +#include "m32r-sim.h" + /* The contents of BUF are in target byte order. */ int diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c index e11545461c5d..c8c04b38b68a 100644 --- a/sim/m32r/sim-if.c +++ b/sim/m32r/sim-if.c @@ -30,6 +30,7 @@ #include "libiberty.h" #include "bfd.h" +#include "m32r-sim.h" #include "dv-m32r_uart.h" #define M32R_DEFAULT_MEM_SIZE 0x2000000 /* 32M */ diff --git a/sim/m32r/sim-main.h b/sim/m32r/sim-main.h index 70962320dfc7..9a52563f25a2 100644 --- a/sim/m32r/sim-main.h +++ b/sim/m32r/sim-main.h @@ -14,29 +14,9 @@ #include "arch.h" #include "sim-base.h" #include "cgen-sim.h" -#include "m32r-sim.h" - -struct m32r_sim_cpu { - M32R_MISC_PROFILE m32r_misc_profile; -#define CPU_M32R_MISC_PROFILE(cpu) (& M32R_SIM_CPU (cpu)->m32r_misc_profile) - /* CPU specific parts go here. - Note that in files that don't need to access these pieces WANT_CPU_FOO - won't be defined and thus these parts won't appear. This is ok in the - sense that things work. It is a source of bugs though. - One has to of course be careful to not take the size of this - struct and no structure members accessed in non-cpu specific files can - go after here. Oh for a better language. */ -#if defined (WANT_CPU_M32RBF) - M32RBF_CPU_DATA cpu_data; -#endif -#if defined (WANT_CPU_M32RXF) - M32RXF_CPU_DATA cpu_data; -#elif defined (WANT_CPU_M32R2F) - M32R2F_CPU_DATA cpu_data; -#endif -}; -#define M32R_SIM_CPU(cpu) ((struct m32r_sim_cpu *) CPU_ARCH_DATA (cpu)) +/* TODO: Move this to the CGEN generated files instead. */ +#include "m32r-sim.h" /* Misc. */ diff --git a/sim/m32r/traps.c b/sim/m32r/traps.c index 12a87b4a6978..b82f974dc534 100644 --- a/sim/m32r/traps.c +++ b/sim/m32r/traps.c @@ -55,6 +55,8 @@ #include #endif +#include "m32r-sim.h" + #define TRAP_LINUX_SYSCALL 2 #define TRAP_FLUSH_CACHE 12 /* The semantic code invokes this for invalid (unrecognized) instructions. */