From patchwork Mon Jan 1 23:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83081 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 A3E5C385842D for ; Mon, 1 Jan 2024 23:22:57 +0000 (GMT) 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 5D6203858D1E for ; Mon, 1 Jan 2024 23:22:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D6203858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5D6203858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151347; cv=none; b=Lc27ecjJ+WG43Jkxv9Am5GdxrV2bY093sGecMBQ2R25+sepGli0N8F+YVhrrSTpClzd58Vo54UtluraP2BiMtiaND0gpeA8vBygg2JGxdTvzgkEa6VRCjCvwJlEkFzldjTF0wXjBS6fmsfZpjAgObVtm8YnhOmxesMgFz55S79k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151347; c=relaxed/simple; bh=vsxF1oY1I6OiOE3amtAP7j9tC4Zq2JZ734Hr/Jy9J5Q=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=SkkCO8INrXwflCgg+dWqEucHKo3BhexZQz+BeUOzmnClPJiAVN/a3yghLmoRIIiOg4aiHwTnUu8A75dWfxIsgkWAWF/xQwTsOd4EjL+eG1u9vHjGaG100+WeRdxhE+3+0+PnRKq8+jZB96cM81JYiK7D3Gdg5feA+i8sw3+C2H4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 954583406C2; Mon, 1 Jan 2024 23:22:23 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 1/8] sim: ppc: hoist igen compilation into top-level Date: Mon, 1 Jan 2024 18:22:12 -0500 Message-ID: <20240101232219.3003-1-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This simplifies the build a bit (especially for deps in port subdirs), and avoids recursive make. This in turn speeds up the build, and lets us reuse existing build-time vs host-time logic from Makefile.am. --- sim/Makefile.in | 354 ++++++++++++++++++++++++++++++++------------ sim/ppc/Makefile.in | 60 +------- sim/ppc/local.mk | 64 +++++++- 3 files changed, 325 insertions(+), 153 deletions(-) diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index ee8fb0462eb5..f7c37cc68f79 100644 --- a/sim/ppc/Makefile.in +++ b/sim/ppc/Makefile.in @@ -88,7 +88,6 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(INCLUDES) $(WARN_CFLAGS) LIBS = $(COMMON_LIBS) @LIBS@ $(LIBGNU) $(LIBGNU_EXTRA_LIBS) -COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@ IGEN_OPCODE_RULES = @sim_opcode@ @@ -616,63 +615,6 @@ tmp-igen: igen $(srcdir)/powerpc.igen $(srcdir)/altivec.igen $(srcdir)/e500.igen $(TARGETLIB): tmp-igen itable.h itable.c icache.h icache.c idecode.h idecode.c semantics.h semantics.c model.h model.c support.h support.c: tmp-igen -igen: igen.o table.o lf.o misc.o filter_host.o ld-decode.o ld-cache.o filter.o ld-insn.o gen-model.o gen-itable.o gen-icache.o gen-semantics.o gen-idecode.o gen-support.o - $(ECHO_CCLD) $(LINK_FOR_BUILD) igen.o table.o lf.o misc.o filter_host.o ld-decode.o ld-cache.o filter.o ld-insn.o gen-model.o gen-itable.o gen-icache.o gen-semantics.o gen-idecode.o gen-support.o - -filter_host.o: filter_host.c $(CONFIG_H) $(FILTER_FILENAME_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/filter_host.c - -table.o: table.c $(CONFIG_H) $(MISC_H) $(LF_H) $(TABLE_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/table.c - -lf.o: lf.c $(CONFIG_H) $(MISC_H) $(LF_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/lf.c - -filter.o: filter.c $(CONFIG_H) $(MISC_H) $(FILTER_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/filter.c -tmp-filter: filter.c $(MISC_H) misc.o - $(ECHO_CCLD) $(LINK_FOR_BUILD) -DMAIN $(srcdir)/filter.c misc.o - -ld-decode.o: ld-decode.c $(MISC_H) $(LF_H) $(TABLE_H) $(LD_DECODE_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/ld-decode.c -tmp-ld-decode: ld-decode.c misc.o lf.o table.o filter_host.o - $(ECHO_CCLD) $(LINK_FOR_BUILD) -DMAIN $(srcdir)/ld-decode.c misc.o lf.o table.o filter_host.o - -ld-cache.o: ld-cache.c $(MISC_H) $(LF_H) $(TABLE_H) $(LD_CACHE_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/ld-cache.c -tmp-ld-cache: ld-cache.c misc.o lf.o table.o filter_host.o - $(ECHO_CCLD) $(LINK_FOR_BUILD) -DMAIN $(srcdir)/ld-cache.c misc.o lf.o table.o filter_host.o - -ld-insn.o: ld-insn.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECODE_H) $(LD_CACHE_H) $(LD_INSN_H) $(IGEN_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/ld-insn.c -tmp-ld-insn: ld-insn.c ld-cache.o misc.o lf.o table.o ld-decode.o filter_host.o filter.o - $(ECHO_CCLD) $(LINK_FOR_BUILD) -DMAIN $(srcdir)/ld-insn.c ld-cache.o misc.o lf.o table.o ld-decode.o filter_host.o filter.o - -gen-model.o: gen-model.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_CACHE_H) $(LD_DECODE_H) $(LD_INSN_H) $(GEN_MODEL_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-model.c - -gen-itable.o: gen-itable.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_CACHE_H) $(LD_DECODE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_ITABLE_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-itable.c - -gen-icache.o: gen-icache.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECODE_H) $(LD_CACHE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_SEMANTICS_H) $(GEN_IDECODE_H) $(GEN_ICACHE_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-icache.c - -gen-semantics.o: gen-semantics.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECODE_H) $(LD_CACHE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_SEMANTICS_H) $(GEN_ICACHE_H) $(GEN_IDECODE_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-semantics.c - -gen-idecode.o: gen-idecode.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECODE_H) $(LD_CACHE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_IDECODE_H) $(GEN_ICACHE_H) $(GEN_SEMANTICS_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-idecode.c - -gen-support.o: gen-support.c $(MISC_H) $(LF_H) $(TABLE_H) $(FILTER_H) $(LD_DECODE_H) $(LD_CACHE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_SEMANTICS_H) $(GEN_SUPPORT_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/gen-support.c - -igen.o: igen.c $(MISC_H) $(LF_H) $(TABLE_H) $(CONFIG_H) $(FILTER_H) $(LD_CACHE_H) $(LD_DECODE_H) $(LD_INSN_H) $(IGEN_H) $(GEN_MODEL_H) $(GEN_ICACHE_H) $(GEN_ITABLE_H) $(GEN_IDECODE_H) $(GEN_SEMANTICS_H) $(GEN_SUPPORT_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/igen.c - -misc.o: misc.c $(CONFIG_H) $(MISC_H) - $(ECHO_CC) $(COMPILE_FOR_BUILD) -c $(srcdir)/misc.c - - # real hardware hw.c hw.h: tmp-hw; @true @@ -762,7 +704,7 @@ TAGS: $(BUILT_SRC) etags $(srcdir)/*.h $(srcdir)/*.c $(BUILT_SRC) clean mostlyclean: - rm -f tmp-* *.[oasi] core igen $(BUILT_SRC_WO_CONFIG) + rm -f tmp-* *.[oasi] core $(BUILT_SRC_WO_CONFIG) distclean realclean: clean rm -f TAGS Makefile config.cache config.status config.h defines.h stamp-h config.log diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk index 9f55629dfe16..915642293542 100644 --- a/sim/ppc/local.mk +++ b/sim/ppc/local.mk @@ -28,7 +28,7 @@ SIM_ALL_RECURSIVE_DEPS += common/libcommon.a $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) ## Helper targets for running make from the top-level due to run's sis.o. -%D%/%.o: %D%/%.c | %D%/libsim.a $(SIM_ALL_RECURSIVE_DEPS) +%D%/main.o: %D%/%.o: %D%/%.c | %D%/libsim.a $(SIM_ALL_RECURSIVE_DEPS) $(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) noinst_PROGRAMS += %D%/run @@ -43,5 +43,67 @@ noinst_PROGRAMS += %D%/run $(AM_V_at)$(SHELL) $(srcroot)/move-if-change $@.tmp $(srcdir)/%D%/spreg.h $(AM_V_at)touch $(srcdir)/%D%/spreg.h +EXTRA_LIBRARIES += %D%/libigen.a +%C%_libigen_a_SOURCES = \ + %D%/table.c \ + %D%/lf.c \ + %D%/misc.c \ + %D%/filter_host.c \ + %D%/ld-decode.c \ + %D%/ld-cache.c \ + %D%/filter.c \ + %D%/ld-insn.c \ + %D%/gen-model.c \ + %D%/gen-itable.c \ + %D%/gen-icache.c \ + %D%/gen-semantics.c \ + %D%/gen-idecode.c \ + %D%/gen-support.c + +%C%_igen_SOURCES = %D%/igen.c +%C%_igen_LDADD = %D%/libigen.a + +PPC_IGEN = %D%/igen$(EXEEXT) + +SIM_ALL_RECURSIVE_DEPS += $(PPC_IGEN) + +## These rules are copied from automake, but tweaked to use FOR_BUILD variables. +%D%/libigen.a: $(%C%_libigen_a_OBJECTS) $(%C%_libigen_a_DEPENDENCIES) $(EXTRA_%C%_libigen_a_DEPENDENCIES) %D%/$(am__dirstamp) + $(AM_V_at)-rm -f $@ + $(AM_V_AR)$(AR_FOR_BUILD) $(ARFLAGS) $@ $(%C%_libigen_a_OBJECTS) $(%C%_libigen_a_LIBADD) + $(AM_V_at)$(RANLIB_FOR_BUILD) $@ + +## igen is a build-time only tool. Override the default rules for it. +%D%/igen$(EXEEXT): $(%C%_igen_OBJECTS) $(%C%_igen_DEPENDENCIES) %D%/$(am__dirstamp) + $(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_igen_OBJECTS) $(%C%_igen_LDADD) + +$(%C%_libigen_a_OBJECTS) $(%C%_igen_OBJECTS): %D%/%.o: %D%/%.c + $(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@ + +## Build some of the files in standalone mode for developers of igen itself. +%D%/%-main.o: %D%/%.c + $(AM_V_CC)$(COMPILE_FOR_BUILD) -DMAIN -c $< -o $@ + +%C%_filter_SOURCES = +%C%_filter_LDADD = %D%/filter-main.o %D%/libigen.a + +%C%_ld_cache_SOURCES = +%C%_ld_cache_LDADD = %D%/ld-cache-main.o %D%/libigen.a + +%C%_ld_decode_SOURCES = +%C%_ld_decode_LDADD = %D%/ld-decode-main.o %D%/libigen.a + +%C%_ld_insn_SOURCES = +%C%_ld_insn_LDADD = %D%/ld-insn-main.o %D%/libigen.a + +%C%_IGEN_TOOLS = \ + $(PPC_IGEN) \ + %D%/filter \ + %D%/ld-cache \ + %D%/ld-decode \ + %D%/ld-insn +EXTRA_PROGRAMS += $(%C%_IGEN_TOOLS) +MOSTLYCLEANFILES += $(%C%_IGEN_TOOLS) %D%/libigen.a + %C%docdir = $(docdir)/%C% %C%doc_DATA = %D%/BUGS %D%/INSTALL %D%/README %D%/RUN From patchwork Mon Jan 1 23:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83083 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 51D143858293 for ; Mon, 1 Jan 2024 23:23:47 +0000 (GMT) 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 5FED63858CDB for ; Mon, 1 Jan 2024 23:22:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FED63858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5FED63858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151347; cv=none; b=thgl1mQhsB8eDpqHt373qPiOn2yX4n4O/hGj4oU71zT7Q3n1ujVYw+K9zW2d4SlXIuCqEYuq73rjkyaY4L4Hq5MCbn31lo/DRoH0ap8WsW7ww+ga7DU2017hhNddF8NGoTbcWewE0LvlmYEFGtTZocUGiGXtHj7LqNe9o87H7bE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151347; c=relaxed/simple; bh=5iut+5noL6ipo6ou8v08gfXBp51yCpqxkuKNoAeWd9o=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Ja3FAqnKN2zJAfcg6o258bgY/9qSpnA43gzQPz7jt0cUGkQaxgSvgJsttnceEp2v1O59JjUsdzgVTcmUHYdgl9ib0v47cqMo4Y/xQFv5dRhATTTnrIXmqzIrWvGXM9a+bxczBSSXTM8JXQvojHqNjGNprjvXfyJurF5XONZNeRw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id B40CD340775; Mon, 1 Jan 2024 23:22:25 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 2/8] sim: ppc: replace filter_filename with lbasename Date: Mon, 1 Jan 2024 18:22:13 -0500 Message-ID: <20240101232219.3003-2-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The lbasename function from libiberty provides the same API as this custom function. The common/ code already made the switch, so make the same change to the ppc code to avoid target duplication. --- sim/ppc/Makefile.in | 11 ++--------- sim/ppc/debug.h | 12 ++++++------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index f7c37cc68f79..b8e7fbfd45f1 100644 --- a/sim/ppc/Makefile.in +++ b/sim/ppc/Makefile.in @@ -198,8 +198,7 @@ CPU_H = \ cpu.c DEBUG_H = \ - debug.h \ - $(FILTER_FILENAME_H) + debug.h DEVICE_H = \ device.h @@ -240,9 +239,6 @@ EMUL_UNIX_H = \ EVENTS_H = \ events.h -FILTER_FILENAME_H = \ - filter_filename.h - FILTER_H = \ filter.h @@ -304,8 +300,7 @@ LF_H = \ MISC_H = \ misc.h \ - $(CONFIG_H) \ - $(FILTER_FILENAME_H) + $(CONFIG_H) MON_H = \ mon.h \ @@ -466,7 +461,6 @@ COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/%) # first LIB_OBJ = \ debug.o \ - filter_filename.o \ bits.o \ sim-endian.o \ os_emul.o \ @@ -519,7 +513,6 @@ psim.o: psim.c $(CPU_H) $(IDECODE_H) $(OPTIONS_H) $(TREE_H) $(BFD_H) bits.o: bits.c $(BASICS_H) debug.o: debug.c $(CONFIG_H) $(BASICS_H) -filter_filename.o: filter_filename.c $(CONFIG_H) $(FILTER_FILENAME_H) sim-endian.o: sim-endian.c $(CONFIG_H) $(BASICS_H) $(SIM_ENDIAN_N_H) diff --git a/sim/ppc/debug.h b/sim/ppc/debug.h index 28e42c7bb753..e221ce553d36 100644 --- a/sim/ppc/debug.h +++ b/sim/ppc/debug.h @@ -21,7 +21,7 @@ #ifndef _DEBUG_H_ #define _DEBUG_H_ -#include "filter_filename.h" +#include "libiberty.h" typedef enum { trace_invalid, @@ -87,7 +87,7 @@ extern int ppc_trace[nr_trace_options]; do { \ if (WITH_TRACE) { \ if (ppc_trace[OBJECT]) { \ - sim_io_printf_filtered("%s:%d: ", filter_filename(__FILE__), __LINE__); \ + sim_io_printf_filtered("%s:%d: ", lbasename(__FILE__), __LINE__); \ sim_io_printf_filtered ARGS; \ } \ } \ @@ -113,7 +113,7 @@ do { \ || ppc_trace[trace_##OBJECT##_device] \ || trace_device) { \ sim_io_printf_filtered("%s:%d:%s:%s%s ", \ - filter_filename(__FILE__), __LINE__, #OBJECT, \ + lbasename(__FILE__), __LINE__, #OBJECT, \ trace_device ? device_path(me) : "", \ trace_device ? ":" : ""); \ sim_io_printf_filtered ARGS; \ @@ -131,7 +131,7 @@ do { \ || ppc_trace[trace_##OBJECT##_device] \ || trace_device) { \ sim_io_printf_filtered("%s:%d:%s:%s%s ", \ - filter_filename(__FILE__), __LINE__, #OBJECT, \ + lbasename(__FILE__), __LINE__, #OBJECT, \ trace_device ? device_path(_me) : "", \ trace_device ? ":" : ""); \ sim_io_printf_filtered ARGS; \ @@ -144,7 +144,7 @@ do { \ do { \ if (WITH_TRACE) { \ if (ppc_trace[trace_##OBJECT##_package]) { \ - sim_io_printf_filtered("%s:%d:%s: ", filter_filename(__FILE__), __LINE__, #OBJECT); \ + sim_io_printf_filtered("%s:%d:%s: ", lbasename(__FILE__), __LINE__, #OBJECT); \ sim_io_printf_filtered ARGS; \ } \ } \ @@ -156,7 +156,7 @@ do { \ if (WITH_ASSERT) { \ if (!(EXPRESSION)) { \ error("%s:%d: assertion failed - %s\n", \ - filter_filename(__FILE__), __LINE__, #EXPRESSION); \ + lbasename(__FILE__), __LINE__, #EXPRESSION); \ } \ } \ } while (0) From patchwork Mon Jan 1 23:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83082 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 47CC73858281 for ; Mon, 1 Jan 2024 23:23:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 58D053858C2F for ; Mon, 1 Jan 2024 23:22:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 58D053858C2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 58D053858C2F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151351; cv=none; b=dgGkAj32TE5587kBWXGjHZvR9HCaYRJlekkRYCaFZeNQTB/SRHfd0KJjRYblYt0mONDl+sYc7Ewe8yzYxRsB3rz0tMpqDDpJ/vPzw6yPvSaeF4K/HBRs6bLkfTA6hqgNBIDZFvjkbKZWEMtAXbr82NKlcV/ux/qS1fDX0ltF2Ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151351; c=relaxed/simple; bh=N7l2hdGBwAXAVrdbJKOpu78q/kbRjBnFAXSHdFkrKCo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=LHbuqvX1u5jZu1Is+xoHcKfBlkvcYk4X22OvpmAjeT4RWnD74Uj3/2gpQCShJHHXmTmQYr9uFHws8WXzr9p2mAKuZwCCXsUIRlkf2m4/8foDi0WQfSKzXxcYv2v0yU2YW6Au8YdUpQmun+HzukRY2o9Oyf+MWlqliUoF5KPPJPQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id C57763406C2; Mon, 1 Jan 2024 23:22:27 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 3/8] sim: ppc: unify igen filter_filename implementations Date: Mon, 1 Jan 2024 18:22:14 -0500 Message-ID: <20240101232219.3003-3-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Now that both igen implementations are in the top-level, we can unify the filter_filename implementation between them since they're the same (literally the same code). --- sim/Makefile.in | 11 ++++------- sim/ppc/Makefile.in | 3 +-- sim/ppc/filter_filename.c | 35 ----------------------------------- sim/ppc/filter_filename.h | 26 -------------------------- sim/ppc/filter_host.c | 18 ------------------ sim/ppc/local.mk | 4 ++-- sim/ppc/misc.h | 2 +- 7 files changed, 8 insertions(+), 91 deletions(-) delete mode 100644 sim/ppc/filter_filename.c delete mode 100644 sim/ppc/filter_filename.h delete mode 100644 sim/ppc/filter_host.c diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index b8e7fbfd45f1..fc9e32453666 100644 --- a/sim/ppc/Makefile.in +++ b/sim/ppc/Makefile.in @@ -409,8 +409,7 @@ BUILT_SRC_WO_CONFIG = \ model.h model.c \ support.h support.c \ pk.h \ - hw.h hw.c \ - filter_host.c + hw.h hw.c BUILT_SRC = \ $(BUILT_SRC_WO_CONFIG) \ diff --git a/sim/ppc/filter_filename.c b/sim/ppc/filter_filename.c deleted file mode 100644 index fb2457c0b2c2..000000000000 --- a/sim/ppc/filter_filename.c +++ /dev/null @@ -1,35 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1995, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 . - - */ - -#include "filter_filename.h" - -/* Shorten traces by eliminating the directory component to filenames. */ -extern const char * -filter_filename (const char *filename) -{ - const char *p = filename; - const char *last = filename; - int ch; - - while ((ch = *p++) != '\0' && ch != ':') - if (ch == '/') - last = p; - - return last; -} diff --git a/sim/ppc/filter_filename.h b/sim/ppc/filter_filename.h deleted file mode 100644 index 5c42e284cef2..000000000000 --- a/sim/ppc/filter_filename.h +++ /dev/null @@ -1,26 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1995, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 . - - */ - -#ifndef _FILTER_FILENAME_H -#define _FILTER_FILENAME_H - -/* Remove directory part from filename */ -extern const char * -filter_filename(const char *filename); -#endif diff --git a/sim/ppc/filter_host.c b/sim/ppc/filter_host.c deleted file mode 100644 index 87d9bbc2e222..000000000000 --- a/sim/ppc/filter_host.c +++ /dev/null @@ -1,18 +0,0 @@ -/* Shim to share files between build & host programs. - - Copyright (C) 2024 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 . */ - -#include "filter_filename.c" diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk index 915642293542..c72668c69c46 100644 --- a/sim/ppc/local.mk +++ b/sim/ppc/local.mk @@ -48,7 +48,6 @@ EXTRA_LIBRARIES += %D%/libigen.a %D%/table.c \ %D%/lf.c \ %D%/misc.c \ - %D%/filter_host.c \ %D%/ld-decode.c \ %D%/ld-cache.c \ %D%/filter.c \ @@ -59,6 +58,7 @@ EXTRA_LIBRARIES += %D%/libigen.a %D%/gen-semantics.c \ %D%/gen-idecode.c \ %D%/gen-support.c +%C%_libigen_a_LIBADD = igen/filter_host.o %C%_igen_SOURCES = %D%/igen.c %C%_igen_LDADD = %D%/libigen.a @@ -78,7 +78,7 @@ SIM_ALL_RECURSIVE_DEPS += $(PPC_IGEN) $(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_igen_OBJECTS) $(%C%_igen_LDADD) $(%C%_libigen_a_OBJECTS) $(%C%_igen_OBJECTS): %D%/%.o: %D%/%.c - $(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@ + $(AM_V_CC)$(COMPILE_FOR_BUILD) -I$(srcdir)/igen -I$(srcdir)/%D% -c $< -o $@ ## Build some of the files in standalone mode for developers of igen itself. %D%/%-main.o: %D%/%.c diff --git a/sim/ppc/misc.h b/sim/ppc/misc.h index a9e97a003e5b..0073467863ad 100644 --- a/sim/ppc/misc.h +++ b/sim/ppc/misc.h @@ -26,7 +26,7 @@ #include #include "ansidecl.h" -#include "filter_filename.h" +#include "filter_host.h" extern void error (const char *msg, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); From patchwork Mon Jan 1 23:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83087 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 7BD6A385843A for ; Mon, 1 Jan 2024 23:24:44 +0000 (GMT) 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 4E3803858412 for ; Mon, 1 Jan 2024 23:22:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4E3803858412 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4E3803858412 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151352; cv=none; b=ksjuattOfH3N7UB8mDx/oBOoYGiIrWc6vKGrNp6u0XeSrETPPFG7r7VYCVIR1rQfzhixNZRXGPv05jcWzIB+60ayQPQi98W1pQqzV8nXRXyJPl87wbtO+9P4iI+bRJUSmZpRcQ72y7fd6nykf2LgJtldEMA30d0i2BFjbLImiac= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151352; c=relaxed/simple; bh=NmIC+pQfutrouhYeayaWPg04pprur973twMoPBeJJJg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=xAGL/uIooLdtAVRrk9uBLgwYHtOYPrgJti4VM5Ysc1khougaHUHLsWIZYqw3jG96sbakHKQ4de37jJsToANAKyvD25iOpGxayeSvLLrL2Gd6BY8WVcx4VSik6pj1SMFQu2AosC8n1NGPWF7VUdBGfVzrp7X7LsDnC07dFY3XztE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id C972E340775; Mon, 1 Jan 2024 23:22:29 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 4/8] sim: igen: minor constify logic Date: Mon, 1 Jan 2024 18:22:15 -0500 Message-ID: <20240101232219.3003-4-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Copy some improvements from the ppc igen code. --- sim/igen/misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sim/igen/misc.c b/sim/igen/misc.c index a083f6d1bbd2..fface6f66d5a 100644 --- a/sim/igen/misc.c +++ b/sim/igen/misc.c @@ -215,8 +215,8 @@ name2i (const char *names, const name_map * map) while (*name != '\0') { /* find our name */ - char *end = strchr (name, ','); - char *next; + const char *end = strchr (name, ','); + const char *next; unsigned len; if (end == NULL) { From patchwork Mon Jan 1 23:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83084 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 9CEF0385829F for ; Mon, 1 Jan 2024 23:23:47 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 1E78B3858428 for ; Mon, 1 Jan 2024 23:22:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E78B3858428 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1E78B3858428 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151353; cv=none; b=Vl+Z18juO5w4niXpJw83xUgSEnRRdtIVt7L6KS8cJbE0GZUbUs4G0Hv1wU9LDSzBs5LuALiQ119rlyOVm2nClwETdAgR110uSyuCOsMse0scDHc+WeW7zKJLKBR4TX/z3FmTWAli3Njl8WHLHmPnck97bfkS1QGpRLeUdH3NAy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151353; c=relaxed/simple; bh=U6fBSKwm4sHYXOYgeMixl6JqrYizYHiIQsk75jqMdes=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=pz3l1vpN8ATLgAZycY+lAFlzoH0U33bGe7FOnWSGdBuxya3h5FC9sg7y/ltMvW3R+Gluz/+d6oGHZERkmQZNg4YI5Gj/c+YPiGM7Ges2pmAVKjqIQACe9XjKEgqF9crOxl7PvTCNUasAjPQYHPN91W+mdsb5lJngRmmyMc+SH7M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id E8CE43407E6; Mon, 1 Jan 2024 23:22:31 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 5/8] sim: ppc: rename igen max_insn_bit_size Date: Mon, 1 Jan 2024 18:22:16 -0500 Message-ID: <20240101232219.3003-5-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org We want to avoid conflicts with the common igen enums. This should get migrated over to the common parsing logic, but for now, switch the name to avoid redefinition. --- sim/ppc/igen.c | 4 ++-- sim/ppc/ld-insn.c | 2 +- sim/ppc/ld-insn.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c index 4de7469b4e36..61afa491bb9e 100644 --- a/sim/ppc/igen.c +++ b/sim/ppc/igen.c @@ -40,7 +40,7 @@ #include "gen-support.h" int hi_bit_nr; -int insn_bit_size = max_insn_bit_size; +int insn_bit_size = ppc_max_insn_bit_size; igen_code code = generate_calls; @@ -472,7 +472,7 @@ main(int argc, break; case 'B': insn_bit_size = a2i(optarg); - ASSERT(insn_bit_size > 0 && insn_bit_size <= max_insn_bit_size + ASSERT(insn_bit_size > 0 && insn_bit_size <= ppc_max_insn_bit_size && (hi_bit_nr == insn_bit_size-1 || hi_bit_nr == 0)); break; case 'H': diff --git a/sim/ppc/ld-insn.c b/sim/ppc/ld-insn.c index a94464d44bbf..5cb72b226226 100644 --- a/sim/ppc/ld-insn.c +++ b/sim/ppc/ld-insn.c @@ -966,7 +966,7 @@ dump_insn_table(insn_table *table, } } -int insn_bit_size = max_insn_bit_size; +int insn_bit_size = ppc_max_insn_bit_size; int hi_bit_nr; int generate_expanded_instructions; diff --git a/sim/ppc/ld-insn.h b/sim/ppc/ld-insn.h index 52baeaa2d846..562e6d8742b4 100644 --- a/sim/ppc/ld-insn.h +++ b/sim/ppc/ld-insn.h @@ -56,7 +56,7 @@ /* Global constants */ enum { - max_insn_bit_size = 32, + ppc_max_insn_bit_size = 32, }; @@ -77,7 +77,7 @@ struct _insn_field { typedef struct _insn_fields insn_fields; struct _insn_fields { - insn_field *bits[max_insn_bit_size]; + insn_field *bits[ppc_max_insn_bit_size]; insn_field *first; insn_field *last; unsigned value; From patchwork Mon Jan 1 23:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83085 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 D26B13858292 for ; Mon, 1 Jan 2024 23:23:49 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 98FE33858417 for ; Mon, 1 Jan 2024 23:22:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98FE33858417 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 98FE33858417 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151356; cv=none; b=tfRwCvLJ6HM/czM6kKGo8ncmt6yhk2O/3dxxT2fVzJ7hAjrGTEzSv4rZITum7UE5fFzyBcOuSUw4sEM91LN6P8zeQApmJY9bq7Z5xeZObHh3kHeyp8XEP0LtMJAAReaIw8PMeT62pbLIuIY3D4v8FtgY569uMenzfZbdHFkOWMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151356; c=relaxed/simple; bh=SHbEtQcSiAWUaR9ip2U6aKDVo2vTOhaK2rfv3lU0DQU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=f+YKFgfc+2W/E8MSwHulQYEs6HrUXcJA4F2KmBO8G3wHTTbgtvZ3FWE6WS1kcO+sQ87hLrMjRy5j2hAzYC1ixNMorNGZGkTQS8ouuJ5Dn8GrTvpH4gdRuMFFPV+GmH+0iJfEvi0ieEPrlqOFcLNxmw4z8jh3bb0GnhirG7k0WYI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 039123406C2; Mon, 1 Jan 2024 23:22:34 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 6/8] sim: igen: extend error to take arguments Date: Mon, 1 Jan 2024 18:22:17 -0500 Message-ID: <20240101232219.3003-6-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The ppc igen error helper allows arbitrary printf calls, so extend the common one to do the same. --- sim/igen/misc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sim/igen/misc.h b/sim/igen/misc.h index eff8a203cabf..45610558a262 100644 --- a/sim/igen/misc.h +++ b/sim/igen/misc.h @@ -56,12 +56,12 @@ extern error_func warning; extern error_func notify; -#define ERROR(EXPRESSION) \ +#define ERROR(EXPRESSION, args...) \ do { \ line_ref line; \ line.file_name = filter_filename (__FILE__); \ line.line_nr = __LINE__; \ - error (&line, EXPRESSION "\n"); \ + error (&line, EXPRESSION "\n", ## args); \ } while (0) #define ASSERT(EXPRESSION) \ From patchwork Mon Jan 1 23:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83088 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 791633858287 for ; Mon, 1 Jan 2024 23:24:46 +0000 (GMT) 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 6BF8F3858413 for ; Mon, 1 Jan 2024 23:22:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6BF8F3858413 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6BF8F3858413 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.211.166.183 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151358; cv=none; b=pIwh+ATWqQJiYgyURKKzGM20sk1E/ujxrk8P3df+8W9MHEpuxhB+7OSNSvczhgM8R4tTx3R6Yskd0EgoCjYXlQ37oJOpp+jDQQJ1cjkSXKL8r5cPWUKuOgmsisTJcxKyoq1zSktIoU0VSs+6pdEdhAMugAaXqyQ9uUDJNojgoWI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151358; c=relaxed/simple; bh=30M+KfWtStOC1MvCz2YDy5KVyXZJCD/Ouc+o6Ol2QPc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=rVaEBCWXwA01Qg62N3RfRZjfROzzVp3/z34tohrXTSbu6Cxqu4dJ/hqEQqHcER6VzfMGLhMKTSkRgFogyfXzKSQLu/+Z++tqJVQpsJcc7z5gCeq9ACLWV2Kp7/nsZlg6I4oalQFy5Gt2xtnjhzi72RlNo8N/JmsWpNMDFnbuhuQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 162EF340775; Mon, 1 Jan 2024 23:22:36 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 7/8] sim: ppc: rework igen error to match common Date: Mon, 1 Jan 2024 18:22:18 -0500 Message-ID: <20240101232219.3003-7-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Switch to an ERROR macro and tweak the error signature to match the common igen version in preparation for merging the two implementations. --- sim/ppc/gen-idecode.c | 2 +- sim/ppc/gen-model.c | 4 ++-- sim/ppc/igen.c | 4 ++-- sim/ppc/ld-cache.c | 2 +- sim/ppc/ld-decode.c | 2 +- sim/ppc/ld-insn.c | 14 +++++++------- sim/ppc/lf.c | 2 +- sim/ppc/misc.c | 8 ++++---- sim/ppc/misc.h | 7 +++++-- sim/ppc/table.c | 2 +- 10 files changed, 25 insertions(+), 22 deletions(-) diff --git a/sim/ppc/gen-idecode.c b/sim/ppc/gen-idecode.c index 256ba7586b89..5d2253500594 100644 --- a/sim/ppc/gen-idecode.c +++ b/sim/ppc/gen-idecode.c @@ -1543,6 +1543,6 @@ gen_idecode_c(lf *file, } else { - error("Something is wrong!\n"); + ERROR("Something is wrong!\n"); } } diff --git a/sim/ppc/gen-model.c b/sim/ppc/gen-model.c index a8bcc66e9f14..11a533b2d93a 100644 --- a/sim/ppc/gen-model.c +++ b/sim/ppc/gen-model.c @@ -52,7 +52,7 @@ model_c_or_h_function(insn_table *entry, { if (function->fields[function_type] == NULL || function->fields[function_type][0] == '\0') { - error("Model function type not specified for %s", function->fields[function_name]); + ERROR("Model function type not specified for %s", function->fields[function_name]); } lf_printf(file, "\n"); lf_print_function_type(file, function->fields[function_type], prefix, " "); @@ -203,7 +203,7 @@ model_c_function(insn_table *table, { if (function->fields[function_type] == NULL || function->fields[function_type][0] == '\0') { - error("Model function return type not specified for %s", function->fields[function_name]); + ERROR("Model function return type not specified for %s", function->fields[function_name]); } else { lf_printf(file, "\n"); diff --git a/sim/ppc/igen.c b/sim/ppc/igen.c index 61afa491bb9e..264d8086874a 100644 --- a/sim/ppc/igen.c +++ b/sim/ppc/igen.c @@ -450,7 +450,7 @@ main(int argc, code &= ~generate_with_icache; break; default: - error ("Expecting -Ggen-icache or -Ggen-icache=\n"); + ERROR ("Expecting -Ggen-icache or -Ggen-icache=\n"); } } break; @@ -568,7 +568,7 @@ main(int argc, real_file_name = NULL; break; default: - error("unknown option\n"); + ERROR("unknown option\n"); } } return 0; diff --git a/sim/ppc/ld-cache.c b/sim/ppc/ld-cache.c index 9a78f908b05a..a5d101daf6c9 100644 --- a/sim/ppc/ld-cache.c +++ b/sim/ppc/ld-cache.c @@ -115,7 +115,7 @@ main(int argc, char **argv) { cache_table *rules; if (argc != 3) - error("Usage: cache \n"); + ERROR("Usage: cache \n"); rules = load_cache_table(argv[1], a2i(argv[2])); dump_cache_rules(rules, 0); return 0; diff --git a/sim/ppc/ld-decode.c b/sim/ppc/ld-decode.c index 63c2c2e53d40..a631645f54de 100644 --- a/sim/ppc/ld-decode.c +++ b/sim/ppc/ld-decode.c @@ -143,7 +143,7 @@ main(int argc, char **argv) { decode_table *rules; if (argc != 3) - error("Usage: decode \n"); + ERROR("Usage: decode \n"); rules = load_decode_table(argv[1], a2i(argv[2])); dump_decode_rules(rules, 0); return 0; diff --git a/sim/ppc/ld-insn.c b/sim/ppc/ld-insn.c index 5cb72b226226..c11b449a58c1 100644 --- a/sim/ppc/ld-insn.c +++ b/sim/ppc/ld-insn.c @@ -110,7 +110,7 @@ parse_insn_format(table_entry *entry, /* sanity check */ if (!isdigit(*chp)) { - error("%s:%d: missing position field at `%s'\n", + ERROR("%s:%d: missing position field at `%s'\n", entry->file_name, entry->line_nr, chp); } @@ -122,7 +122,7 @@ parse_insn_format(table_entry *entry, if (*chp == '.' && strlen_pos > 0) chp++; else { - error("%s:%d: missing field value at %s\n", + ERROR("%s:%d: missing field value at %s\n", entry->file_name, entry->line_nr, chp); break; } @@ -137,7 +137,7 @@ parse_insn_format(table_entry *entry, if (*chp == ',') chp++; else if (*chp != '\0' || strlen_val == 0) { - error("%s:%d: missing field terminator at %s\n", + ERROR("%s:%d: missing field terminator at %s\n", entry->file_name, entry->line_nr, chp); break; } @@ -216,7 +216,7 @@ parse_include_entry (table *file, { /* parse the include file_entry */ if (file_entry->nr_fields < 4) - error ("Incorrect nr fields for include record\n"); + ERROR ("Incorrect nr fields for include record\n"); /* process it */ if (!is_filtered_out(file_entry->fields[include_flags], filters)) { @@ -326,7 +326,7 @@ insn_table_insert_insn(insn_table *table, } if (!model_ptr) - error("%s:%d: machine model `%s' was not known about\n", + ERROR("%s:%d: machine model `%s' was not known about\n", file_entry->file_name, file_entry->line_nr, name); } @@ -663,7 +663,7 @@ insn_table_find_opcode_field(insn *insns, curr_opcode->boolean_constant = rule->special_constant; break; default: - error("Something is going wrong\n"); + ERROR("Something is going wrong\n"); } return curr_opcode; @@ -979,7 +979,7 @@ main(int argc, char **argv) cache_table *cache_rules = NULL; if (argc != 5) - error("Usage: insn \n"); + ERROR("Usage: insn \n"); filters = new_filter(argv[1], filters); hi_bit_nr = a2i(argv[2]); diff --git a/sim/ppc/lf.c b/sim/ppc/lf.c index 9a9d6151c6e8..9deb2d2bb523 100644 --- a/sim/ppc/lf.c +++ b/sim/ppc/lf.c @@ -274,7 +274,7 @@ lf_print__c_code(lf *file, chp++; } if (in_bit_field) - error("bit field paren miss match some where\n"); + ERROR("bit field paren miss match some where\n"); if (*chp == '\n') { nr += lf_putchr(file, '\n'); chp++; diff --git a/sim/ppc/misc.c b/sim/ppc/misc.c index a281d62b0af1..9499101b6029 100644 --- a/sim/ppc/misc.c +++ b/sim/ppc/misc.c @@ -28,7 +28,7 @@ #include void -error (const char *msg, ...) +error (const void *line, const char *msg, ...) { va_list ap; va_start(ap, msg); @@ -42,7 +42,7 @@ zalloc(long size) { void *memory = malloc(size); if (memory == NULL) - error("zalloc failed\n"); + ERROR("zalloc failed\n"); memset(memory, 0, size); return memory; } @@ -186,7 +186,7 @@ name2i(const char *names, if (curr->i >= 0) return curr->i; else - error("%s contains no valid names\n", names); + ERROR("%s contains no valid names\n", names); return 0; } @@ -199,6 +199,6 @@ i2name(const int i, return map->name; map++; } - error("map lookup failed for %d\n", i); + ERROR("map lookup failed for %d\n", i); return NULL; } diff --git a/sim/ppc/misc.h b/sim/ppc/misc.h index 0073467863ad..243d5c93605a 100644 --- a/sim/ppc/misc.h +++ b/sim/ppc/misc.h @@ -28,8 +28,11 @@ #include "ansidecl.h" #include "filter_host.h" -extern void error (const char *msg, ...) - ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); +extern void error (const void *line, const char *msg, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3); + +#define ERROR(EXPRESSION, args...) \ + error (NULL, EXPRESSION, ## args) #define ASSERT(EXPRESSION) \ do { \ diff --git a/sim/ppc/table.c b/sim/ppc/table.c index cb9a73aa8c49..0c5b6fcd925a 100644 --- a/sim/ppc/table.c +++ b/sim/ppc/table.c @@ -98,7 +98,7 @@ table_push (table *root, /* free (dup_name); */ if (include->next == NULL) { - error ("Problem opening file `%s'\n", file_name); + ERROR ("Problem opening file `%s'\n", file_name); perror (file_name); exit (1); } From patchwork Mon Jan 1 23:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 83086 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 A00473858436 for ; Mon, 1 Jan 2024 23:24:08 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 63943385841C for ; Mon, 1 Jan 2024 23:22:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63943385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 63943385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:ea4a:1:5054:ff:fec7:86e4 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151361; cv=none; b=vEsJXjbsWRjgDbcC07ihgZNMh1dNuyq8ODRjXJvELpt0p5c+6mkC/XeqEHGs2R4m7xnojVMcd+v/e4vQCXi7/529c/p4/pOpEGYrbXE7Xo/ukdJiBMtF9DW5bNFP2ELufMDKNLzXZ0U92yqKEx2/4KHDvhRrML5215GNSycpgYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704151361; c=relaxed/simple; bh=+0MnCdxxEpU6YyHLzU+03zNDpQeX3N/cb6nwimKw4b8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=EhZyt9uMuuUt9xvjg0VvsQ6txSO4jCQs8EMkKIAu+mRFCVND6R3nj2PE5VyKSIBlW/cSKAym30yUziyBQIk/cr7abPkcvea4o7g8h8IPI4uSVNIRTF9azLp8Iyk3446gjVJdZ8DjTrOa2CX5LrAuKSiNY/3yNSCz7oj2cw46bVU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 27D0D3406C2; Mon, 1 Jan 2024 23:22:38 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH/committed 8/8] sim: ppc: merge misc igen APIs Date: Mon, 1 Jan 2024 18:22:19 -0500 Message-ID: <20240101232219.3003-8-vapier@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240101232219.3003-1-vapier@gentoo.org> References: <20240101232219.3003-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The common igen code provides the same misc APIs as the ppc version, so delete the ppc code and pull in the common one. There is one minor difference: the ppc code has a unique dumpf function. The common code switched to lf_printf for the same functionality, but since that requires changes throughout the igen codebase, delay that cleanup for now so we can merge the rest. --- sim/Makefile.in | 15 ++-- sim/ppc/dumpf.c | 40 +++++++++ sim/ppc/dumpf.h | 25 ++++++ sim/ppc/ld-cache.c | 1 + sim/ppc/ld-decode.c | 1 + sim/ppc/ld-insn.c | 1 + sim/ppc/local.mk | 6 +- sim/ppc/misc.c | 204 -------------------------------------------- sim/ppc/misc.h | 80 ----------------- sim/ppc/table.c | 1 + 10 files changed, 82 insertions(+), 292 deletions(-) create mode 100644 sim/ppc/dumpf.c create mode 100644 sim/ppc/dumpf.h delete mode 100644 sim/ppc/misc.c delete mode 100644 sim/ppc/misc.h diff --git a/sim/ppc/dumpf.c b/sim/ppc/dumpf.c new file mode 100644 index 000000000000..6aaae16e62e4 --- /dev/null +++ b/sim/ppc/dumpf.c @@ -0,0 +1,40 @@ +/* This file is part of the program psim. + + Copyright (C) 1994-1997, Andrew Cagney + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . + + */ + +/* TODO: Convert callers to lf_printf like common igen/. */ + +#include +#include +#include + +#include "dumpf.h" + +#include +#include + +void +dumpf (int indent, const char *msg, ...) +{ + va_list ap; + for (; indent > 0; indent--) + printf(" "); + va_start(ap, msg); + vprintf(msg, ap); + va_end(ap); +} diff --git a/sim/ppc/dumpf.h b/sim/ppc/dumpf.h new file mode 100644 index 000000000000..91374637ae6e --- /dev/null +++ b/sim/ppc/dumpf.h @@ -0,0 +1,25 @@ +/* This file is part of the program psim. + + Copyright (C) 1994-1995, Andrew Cagney + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . + + */ + +/* TODO: Convert callers to lf_printf like common igen/. */ + +#include "ansidecl.h" + +extern void dumpf (int indent, const char *msg, ...) + ATTRIBUTE_PRINTF (2, 3); diff --git a/sim/ppc/ld-cache.c b/sim/ppc/ld-cache.c index a5d101daf6c9..67e60ebbb492 100644 --- a/sim/ppc/ld-cache.c +++ b/sim/ppc/ld-cache.c @@ -22,6 +22,7 @@ #include "lf.h" #include "table.h" #include "ld-cache.h" +#include "dumpf.h" enum { diff --git a/sim/ppc/ld-decode.c b/sim/ppc/ld-decode.c index a631645f54de..09ed4b198608 100644 --- a/sim/ppc/ld-decode.c +++ b/sim/ppc/ld-decode.c @@ -23,6 +23,7 @@ #include "lf.h" #include "table.h" #include "ld-decode.h" +#include "dumpf.h" enum { diff --git a/sim/ppc/ld-insn.c b/sim/ppc/ld-insn.c index c11b449a58c1..6b5402676b30 100644 --- a/sim/ppc/ld-insn.c +++ b/sim/ppc/ld-insn.c @@ -25,6 +25,7 @@ #include "ld-decode.h" #include "ld-cache.h" #include "ld-insn.h" +#include "dumpf.h" #include "igen.h" diff --git a/sim/ppc/local.mk b/sim/ppc/local.mk index c72668c69c46..8bcc7e7b9c39 100644 --- a/sim/ppc/local.mk +++ b/sim/ppc/local.mk @@ -47,7 +47,7 @@ EXTRA_LIBRARIES += %D%/libigen.a %C%_libigen_a_SOURCES = \ %D%/table.c \ %D%/lf.c \ - %D%/misc.c \ + %D%/dumpf.c \ %D%/ld-decode.c \ %D%/ld-cache.c \ %D%/filter.c \ @@ -58,7 +58,9 @@ EXTRA_LIBRARIES += %D%/libigen.a %D%/gen-semantics.c \ %D%/gen-idecode.c \ %D%/gen-support.c -%C%_libigen_a_LIBADD = igen/filter_host.o +%C%_libigen_a_LIBADD = \ + igen/filter_host.o \ + igen/misc.o %C%_igen_SOURCES = %D%/igen.c %C%_igen_LDADD = %D%/libigen.a diff --git a/sim/ppc/misc.c b/sim/ppc/misc.c deleted file mode 100644 index 9499101b6029..000000000000 --- a/sim/ppc/misc.c +++ /dev/null @@ -1,204 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1997, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 . - - */ - - -#include -#include -#include - -#include "misc.h" - -#include -#include - -void -error (const void *line, const char *msg, ...) -{ - va_list ap; - va_start(ap, msg); - vprintf(msg, ap); - va_end(ap); - exit (1); -} - -void * -zalloc(long size) -{ - void *memory = malloc(size); - if (memory == NULL) - ERROR("zalloc failed\n"); - memset(memory, 0, size); - return memory; -} - -void -dumpf (int indent, const char *msg, ...) -{ - va_list ap; - for (; indent > 0; indent--) - printf(" "); - va_start(ap, msg); - vprintf(msg, ap); - va_end(ap); -} - - -unsigned -a2i(const char *a) -{ - int neg = 0; - int base = 10; - unsigned num = 0; - int looping; - - while (isspace (*a)) - a++; - - if (*a == '-') { - neg = 1; - a++; - } - - if (*a == '0') { - if (a[1] == 'x' || a[1] == 'X') { - a += 2; - base = 16; - } - else - base = 8; - } - - looping = 1; - while (looping) { - int ch = *a++; - - switch (base) { - default: - looping = 0; - break; - - case 10: - if (ch >= '0' && ch <= '9') { - num = (num * 10) + (ch - '0'); - } else { - looping = 0; - } - break; - - case 8: - if (ch >= '0' && ch <= '7') { - num = (num * 8) + (ch - '0'); - } else { - looping = 0; - } - break; - - case 16: - if (ch >= '0' && ch <= '9') { - num = (num * 16) + (ch - '0'); - } else if (ch >= 'a' && ch <= 'f') { - num = (num * 16) + (ch - 'a' + 10); - } else if (ch >= 'A' && ch <= 'F') { - num = (num * 16) + (ch - 'A' + 10); - } else { - looping = 0; - } - break; - } - } - - if (neg) - num = - num; - - return num; -} - -unsigned -target_a2i(int ms_bit_nr, - const char *a) -{ - if (ms_bit_nr) - return (ms_bit_nr - a2i(a)); - else - return a2i(a); -} - -unsigned -i2target(int ms_bit_nr, - unsigned bit) -{ - if (ms_bit_nr) - return ms_bit_nr - bit; - else - return bit; -} - - -int -name2i(const char *names, - const name_map *map) -{ - const name_map *curr; - const char *name = names; - while (*name != '\0') { - /* find our name */ - const char *end = strchr(name, ','); - const char *next; - int len; - if (end == NULL) { - end = strchr(name, '\0'); - next = end; - } - else { - next = end + 1; - } - len = end - name; - /* look it up */ - curr = map; - while (curr->name != NULL) { - if (strncmp(curr->name, name, len) == 0 - && strlen(curr->name) == len) - return curr->i; - curr++; - } - name = next; - } - /* nothing found, possibly return a default */ - curr = map; - while (curr->name != NULL) - curr++; - if (curr->i >= 0) - return curr->i; - else - ERROR("%s contains no valid names\n", names); - return 0; -} - -const char * -i2name(const int i, - const name_map *map) -{ - while (map->name != NULL) { - if (map->i == i) - return map->name; - map++; - } - ERROR("map lookup failed for %d\n", i); - return NULL; -} diff --git a/sim/ppc/misc.h b/sim/ppc/misc.h deleted file mode 100644 index 243d5c93605a..000000000000 --- a/sim/ppc/misc.h +++ /dev/null @@ -1,80 +0,0 @@ -/* This file is part of the program psim. - - Copyright (C) 1994-1995, Andrew Cagney - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - 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 . - - */ - - -/* Frustrating header junk */ - -#include -#include -#include -#include - -#include "ansidecl.h" -#include "filter_host.h" - -extern void error (const void *line, const char *msg, ...) - ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3); - -#define ERROR(EXPRESSION, args...) \ - error (NULL, EXPRESSION, ## args) - -#define ASSERT(EXPRESSION) \ -do { \ - if (!(EXPRESSION)) { \ - error("%s:%d: assertion failed - %s\n", \ - filter_filename (__FILE__), __LINE__, #EXPRESSION); \ - } \ -} while (0) - -#define ZALLOC(TYPE) (TYPE*)zalloc(sizeof(TYPE)) -#define NZALLOC(TYPE,N) ((TYPE*) zalloc (sizeof(TYPE) * (N))) - -extern void *zalloc -(long size); - -extern void dumpf (int indent, const char *msg, ...) - ATTRIBUTE_PRINTF (2, 3); - -extern unsigned target_a2i -(int ms_bit_nr, - const char *a); - -extern unsigned i2target -(int ms_bit_nr, - unsigned bit); - -extern unsigned a2i -(const char *a); - -/* Try looking for name in the map table (returning the corresponding - integer value). If that fails, try converting the name into an - integer */ - -typedef struct _name_map { - const char *name; - int i; -} name_map; - -extern int name2i -(const char *name, - const name_map *map); - -extern const char *i2name -(const int i, - const name_map *map); diff --git a/sim/ppc/table.c b/sim/ppc/table.c index 0c5b6fcd925a..5cac56eec9b9 100644 --- a/sim/ppc/table.c +++ b/sim/ppc/table.c @@ -27,6 +27,7 @@ #include "misc.h" #include "lf.h" #include "table.h" +#include "dumpf.h" #include #include