From patchwork Sat Mar 16 21:40:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 31869 Received: (qmail 71256 invoked by alias); 16 Mar 2019 21:40:36 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 71198 invoked by uid 89); 16 Mar 2019 21:40:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=collect2, dhave_config_h, DHAVE_CONFIG_H, ADDR X-HELO: mail-pf1-f193.google.com Received: from mail-pf1-f193.google.com (HELO mail-pf1-f193.google.com) (209.85.210.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 16 Mar 2019 21:40:32 +0000 Received: by mail-pf1-f193.google.com with SMTP id c8so2024204pfd.10 for ; Sat, 16 Mar 2019 14:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gaQ320/ubjidnK1RNXj3O6Pp25KXeeTqKqmrIYY60NE=; b=Riu2g7z1rPxw9wgYirFb3z6Dyob760ru9s8xPASEWPYwWfJ6VJoXQ12rSjIZIgemrH 8neZYo8eAQw4NQNrWz/uOpxSFik1CsWniUfdONmF3GZRp0dL4BA4bvS9k3q/uBJ+rtaE 2yR1BGvlzcjXPlDXH7tQR7+CCiFG5cn6JNMjKP3Qa85VXOmXTpEI2hy5TRhMQisitENT 2qAxL0CzzSJ51KJsd6cdoY465H4Ihmd6agybL/YXbVSTl2M6T+n/WDJh1HP8pBiV8Rck Aksh3hGw7tXT9CbdXzU1hz0dRmOiaL2ZEDDNrxPNCxbHNbYrmEdr97pRg7Pl0GihwDnt 3DpQ== Return-Path: Received: from localhost (g203.124-44-7.ppp.wakwak.ne.jp. [124.44.7.203]) by smtp.gmail.com with ESMTPSA id i126sm7791572pfb.15.2019.03.16.14.40.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Mar 2019 14:40:30 -0700 (PDT) From: Stafford Horne To: GDB patches Cc: Simon Marchi , Stafford Horne Subject: [PATCH v2 1/2] sim/common: convert sim-arange to use sim-inline Date: Sun, 17 Mar 2019 06:40:17 +0900 Message-Id: <20190316214018.9398-2-shorne@gmail.com> In-Reply-To: <20190316214018.9398-1-shorne@gmail.com> References: <20190316214018.9398-1-shorne@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes This fixes a TODO item and also fixes an error which we get when building with no optimizations (-O0) in at least gcc 8.2.1. Tested with sims that use cgen code lm32, or1k, cris, m32r and inlining is working corretly. Reference Error: gcc -DHAVE_CONFIG_H -DWITH_DEFAULT_MODEL='"or1200"' -DWITH_ALIGNMENT=STRICT_ALIGNMENT \ -DWITH_TARGET_WORD_BITSIZE=32 -DWITH_TARGET_WORD_MSB=31 -DWITH_TARGET_ADDRESS_BITSIZE=32 \ -DWITH_TARGET_BYTE_ORDER=BFD_ENDIAN_BIG -DDEFAULT_INLINE=0 -DWITH_SCACHE=16384 \ -I. -I../../../binutils-gdb/sim/or1k -I../common -I../../../binutils-gdb/sim/or1k/../common \ -I../../include -I../../../binutils-gdb/sim/or1k/../../include -I../../bfd \ -I../../../binutils-gdb/sim/or1k/../../bfd -I../../opcodes -I../../../binutils-gdb/sim/or1k/../../opcodes \ -g -o run nrun.o libsim.a ../../bfd/libbfd.a ../../opcodes/libopcodes.a ../../libiberty/libiberty.a \ -ldl -lz -lm /usr/bin/ld: libsim.a(mloop.o): in function `extract': /home/shorne/work/openrisc/gdb-musl/sim/or1k/mloop.c:82: undefined reference to `sim_addr_range_hit_p' /usr/bin/ld: /home/shorne/work/openrisc/gdb-musl/sim/or1k/mloop.c:83: undefined reference to `sim_addr_range_hit_p' collect2: error: ld returned 1 exit status make[3]: *** [Makefile:305: run] Error 1 sim/common/ChangeLog: * Make-common.in (sim-arange_h): Remove sim-arange.c * sim-arange.c: Remove SIM_ARANGE_C. Add ifdef for _SIM_ARANGE_C_. Include "sim-arange.h". Remove include for unused "sim-assert.h". Remove DEFINE_INLINE_P. Remove DEFINE_NON_INLINE_P. (sim_addr_range_add): Declare as INLINE_SIM_ARANGE. (sim_addr_range_delete): Declare as INLINE_SIM_ARANGE. (sim_addr_range_hit_p): Change from SIM_ARANGE_INLINE to INLINE_SIM_ARANGE. * sim-arange.h (sim_addr_range_add): Declare as INLINE_SIM_ARANGE. (sim_addr_range_delete): Declare as INLINE_SIM_ARANGE. (sim_addr_range_hit_p) Declare as INLINE_SIM_ARANGE. Remove definition of SIM_ARANGE_INLINE. Remove [HAVE_INLINE]. Wrap include "sim-arange.c" in H_REVEALS_MODULE_P. * sim-base.h: Include "sim-arange.h" * sim-basics.h: Remove include of "sim-arange.h" * sim-inline.c: Include "sim-arange.c" * sim-inline.h: Define INLINE_SIM_ARANGE. Define SIM_ARANGE_INLINE. Define EXTERN_SIM_ARANGE_P. Define STATIC_INLINE_SIM_ARANGE. Define STATIC_SIM_ARANGE. --- sim/common/Make-common.in | 3 +-- sim/common/sim-arange.c | 21 ++++++++++----------- sim/common/sim-arange.h | 30 +++++++++--------------------- sim/common/sim-base.h | 1 + sim/common/sim-basics.h | 1 - sim/common/sim-inline.c | 5 ++++- sim/common/sim-inline.h | 32 ++++++++++++++++++++++++++++++++ 7 files changed, 57 insertions(+), 36 deletions(-) diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index 1a3bcc9417..5d8ac910af 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -319,8 +319,7 @@ SIM_MAIN_DEPS = \ $(sim_main_headers) sim-alu_h = $(srccom)/sim-alu.h -sim-arange_h = $(srccom)/sim-arange.h \ - $(srccom)/sim-arange.c +sim-arange_h = $(srccom)/sim-arange.h sim-assert_h = $(srccom)/sim-assert.h sim-base_h = $(srccom)/sim-base.h \ $(sim-module_h) \ diff --git a/sim/common/sim-arange.c b/sim/common/sim-arange.c index b3488ab564..c75245b94b 100644 --- a/sim/common/sim-arange.c +++ b/sim/common/sim-arange.c @@ -17,12 +17,12 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -/* Tell sim-arange.h it's us. */ -#define SIM_ARANGE_C +#ifndef _SIM_ARANGE_C_ +#define _SIM_ARANGE_C_ #include "libiberty.h" #include "sim-basics.h" -#include "sim-assert.h" +#include "sim-arange.h" #ifdef HAVE_STDLIB_H #include @@ -32,8 +32,6 @@ along with this program. If not, see . */ #include #endif -#ifdef SIM_ARANGE_C_INCLUDED - /* Insert a range. */ static void @@ -251,7 +249,8 @@ build_search_tree (ADDR_RANGE *ar) free (asrtab); } -void +INLINE_SIM_ARANGE\ +(void) sim_addr_range_add (ADDR_RANGE *ar, address_word start, address_word end) { frob_range (ar, start, end, 0); @@ -264,7 +263,8 @@ sim_addr_range_add (ADDR_RANGE *ar, address_word start, address_word end) build_search_tree (ar); } -void +INLINE_SIM_ARANGE\ +(void) sim_addr_range_delete (ADDR_RANGE *ar, address_word start, address_word end) { frob_range (ar, start, end, 1); @@ -277,9 +277,8 @@ sim_addr_range_delete (ADDR_RANGE *ar, address_word start, address_word end) build_search_tree (ar); } -#else /* SIM_ARANGE_C_INCLUDED */ - -SIM_ARANGE_INLINE int +INLINE_SIM_ARANGE\ +(int) sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr) { ADDR_RANGE_TREE *t = ar->range_tree; @@ -296,4 +295,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr) return 0; } -#endif /* SIM_ARANGE_C_INCLUDED */ +#endif /* _SIM_ARANGE_C_ */ diff --git a/sim/common/sim-arange.h b/sim/common/sim-arange.h index f2ac595390..529d1650c2 100644 --- a/sim/common/sim-arange.h +++ b/sim/common/sim-arange.h @@ -51,36 +51,24 @@ typedef struct _addr_range { } ADDR_RANGE; /* Add address range START,END to AR. */ -extern void sim_addr_range_add (ADDR_RANGE * /*ar*/, - address_word /*start*/, - address_word /*end*/); +INLINE_SIM_ARANGE (void) sim_addr_range_add (ADDR_RANGE * /*ar*/, + address_word /*start*/, + address_word /*end*/); /* Delete address range START,END from AR. */ -extern void sim_addr_range_delete (ADDR_RANGE * /*ar*/, - address_word /*start*/, - address_word /*end*/); - -/* TODO: This should get moved into sim-inline.h. */ -#ifdef HAVE_INLINE -#ifdef SIM_ARANGE_C -#define SIM_ARANGE_INLINE INLINE -#else -#define SIM_ARANGE_INLINE EXTERN_INLINE -#endif -#else -#define SIM_ARANGE_INLINE extern -#endif +INLINE_SIM_ARANGE (void) sim_addr_range_delete (ADDR_RANGE * /*ar*/, + address_word /*start*/, + address_word /*end*/); /* Return non-zero if ADDR is in range AR, traversing the entire tree. If no range is specified, that is defined to mean "everything". */ -SIM_ARANGE_INLINE int -sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, address_word /*addr*/); +INLINE_SIM_ARANGE (int) sim_addr_range_hit_p (ADDR_RANGE * /*ar*/, + address_word /*addr*/); #define ADDR_RANGE_HIT_P(ar, addr) \ ((ar)->range_tree == NULL || sim_addr_range_hit_p ((ar), (addr))) -#ifdef HAVE_INLINE +#if H_REVEALS_MODULE_P (SIM_ARANGE_INLINE) #include "sim-arange.c" #endif -#define SIM_ARANGE_C_INCLUDED #endif /* SIM_ARANGE_H */ diff --git a/sim/common/sim-base.h b/sim/common/sim-base.h index 3123c07e2b..d07ff2168c 100644 --- a/sim/common/sim-base.h +++ b/sim/common/sim-base.h @@ -82,6 +82,7 @@ typedef struct _sim_cpu sim_cpu; #include "sim-module.h" +#include "sim-arange.h" #include "sim-trace.h" #include "sim-core.h" #include "sim-events.h" diff --git a/sim/common/sim-basics.h b/sim/common/sim-basics.h index c796b057ce..5aa76db424 100644 --- a/sim/common/sim-basics.h +++ b/sim/common/sim-basics.h @@ -144,7 +144,6 @@ typedef enum { #include "sim-bits.h" #include "sim-endian.h" #include "sim-signal.h" -#include "sim-arange.h" #include "sim-utils.h" diff --git a/sim/common/sim-inline.c b/sim/common/sim-inline.c index 9021e2a4a9..3a2af7917a 100644 --- a/sim/common/sim-inline.c +++ b/sim/common/sim-inline.c @@ -29,6 +29,10 @@ #include "sim-inline.h" #include "sim-main.h" +#if C_REVEALS_MODULE_P (SIM_ARANGE_INLINE) +#include "sim-arange.c" +#endif + #if C_REVEALS_MODULE_P (SIM_BITS_INLINE) #include "sim-bits.c" @@ -64,7 +68,6 @@ #include "sim-main.c" #endif - #if C_REVEALS_MODULE_P (ENGINE_INLINE) /* #include "engine.c" - handled by generator */ #endif diff --git a/sim/common/sim-inline.h b/sim/common/sim-inline.h index 11c58b9622..87dfbb5dc4 100644 --- a/sim/common/sim-inline.h +++ b/sim/common/sim-inline.h @@ -348,6 +348,38 @@ + +/* sim_arange */ + +#if !defined (SIM_ARANGE_INLINE) && (DEFAULT_INLINE) +# define SIM_ARANGE_INLINE (ALL_H_INLINE) +#endif + +#if ((H_REVEALS_MODULE_P (SIM_ARANGE_INLINE) || defined (SIM_INLINE_C)) \ + && !defined (SIM_ARANGE_C) \ + && (REVEAL_MODULE_P (SIM_ARANGE_INLINE))) +# if (SIM_ARANGE_INLINE & INLINE_GLOBALS) +# define INLINE_SIM_ARANGE(TYPE) static INLINE TYPE UNUSED +# define EXTERN_SIM_ARANGE_P 0 +# else +# define INLINE_SIM_ARANGE(TYPE) static TYPE UNUSED +# define EXTERN_SIM_ARANGE_P 0 +# endif +#else +# define INLINE_SIM_ARANGE(TYPE) TYPE +# define EXTERN_SIM_ARANGE_P 1 +#endif + +#if (SIM_ARANGE_INLINE & INLINE_LOCALS) +# define STATIC_INLINE_SIM_ARANGE(TYPE) static INLINE TYPE +#else +# define STATIC_INLINE_SIM_ARANGE(TYPE) static TYPE +#endif + +#define STATIC_SIM_ARANGE(TYPE) static TYPE + + + /* ***** sim-bits and sim-endian are treated differently from the rest of the modules below. Their default value is ALL_H_INLINE.