public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/5] sim: hw: rework configure option & device selection
@ 2021-06-20  5:55 Mike Frysinger
  2021-06-20  5:55 ` [PATCH 2/5] sim: unify hardware settings Mike Frysinger
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Mike Frysinger @ 2021-06-20  5:55 UTC (permalink / raw)
  To: gdb-patches

The sim-hardware configure option allows builders to select a set of
device models to enable.  But this seems like unnecessary overkill:
the existence of individual device models doesn't affect performance
at all as they are only enabled at runtime if the config uses them,
and individually these are all <5KB a piece.  Stripping off a total
of ~50KB from a ~1MB binary doesn't seem useful, and it's extremely
unlikely anyone will ever bother.

So let's simplify the configure/make logic by turning sim-hardware
into a boolean option like many of the other sim options.  Any ports
that have unique device models will declare them in their Makefile
instead of at configure time.  This will allow us to (eventually)
unify the setting into the common dir.
---
 sim/README-HACKING               |   4 +-
 sim/aarch64/configure            |  64 ++++++---------
 sim/arm/configure                |  64 ++++++---------
 sim/avr/configure                |  64 ++++++---------
 sim/bfin/Makefile.in             |  33 ++++++++
 sim/bfin/configure               | 136 +++++++++++--------------------
 sim/bfin/configure.ac            |  33 --------
 sim/bpf/configure                |  62 ++++++--------
 sim/common/Make-common.in        |  11 ++-
 sim/cr16/configure               |  64 ++++++---------
 sim/cris/Makefile.in             |   2 +
 sim/cris/configure               |  90 +++++++++-----------
 sim/cris/configure.ac            |   1 -
 sim/d10v/configure               |  64 ++++++---------
 sim/erc32/configure              |  64 ++++++---------
 sim/example-synacor/configure    |  64 ++++++---------
 sim/frv/configure                |  62 ++++++--------
 sim/ft32/configure               |  64 ++++++---------
 sim/h8300/configure              |  64 ++++++---------
 sim/iq2000/configure             |  62 ++++++--------
 sim/lm32/Makefile.in             |   2 +
 sim/lm32/configure               |  60 ++++++--------
 sim/lm32/configure.ac            |   1 -
 sim/m32c/configure               |  64 ++++++---------
 sim/m32r/Makefile.in             |   2 +
 sim/m32r/configure               |  61 ++++++--------
 sim/m32r/configure.ac            |   2 -
 sim/m4/sim_ac_option_hardware.m4 |  57 +++++--------
 sim/m4/sim_ac_output.m4          |   3 -
 sim/m68hc11/Makefile.in          |   2 +
 sim/m68hc11/configure            |  64 ++++++---------
 sim/m68hc11/configure.ac         |   4 -
 sim/mcore/configure              |  64 ++++++---------
 sim/microblaze/configure         |  64 ++++++---------
 sim/mips/Makefile.in             |   1 +
 sim/mips/configure               |  63 ++++++--------
 sim/mips/configure.ac            |   4 -
 sim/mn10300/Makefile.in          |   2 +
 sim/mn10300/configure            |  60 ++++++--------
 sim/mn10300/configure.ac         |   1 -
 sim/moxie/configure              |  64 ++++++---------
 sim/msp430/configure             |  64 ++++++---------
 sim/or1k/configure               |  62 ++++++--------
 sim/pru/configure                |  64 ++++++---------
 sim/riscv/configure              |  62 ++++++--------
 sim/rl78/configure               |  64 ++++++---------
 sim/rx/configure                 |  64 ++++++---------
 sim/sh/configure                 |  64 ++++++---------
 sim/v850/configure               |  62 ++++++--------
 49 files changed, 899 insertions(+), 1324 deletions(-)

diff --git a/sim/README-HACKING b/sim/README-HACKING
index 3715467337f7..9bb705e655eb 100644
--- a/sim/README-HACKING
+++ b/sim/README-HACKING
@@ -387,8 +387,8 @@ Hardware Devices
 ================
 
 The simplest simulator doesn't include hardware device support.  Once you're
-ready to move on to the next level, call the common macro in your configure.ac:
-SIM_AC_OPTION_HARDWARE(devone devtwo devthree)
+ready to move on to the next level, declare in your Makefile.in:
+SIM_EXTRA_HW_DEVICES = devone devtwo devthree
 
 The basic hardware API is documented in common/hw-device.h.
 
diff --git a/sim/bfin/Makefile.in b/sim/bfin/Makefile.in
index e3536158a2ad..57b9b5eb0625 100644
--- a/sim/bfin/Makefile.in
+++ b/sim/bfin/Makefile.in
@@ -26,6 +26,39 @@ SIM_OBJS = \
 	machs.o \
 	sim-resume.o
 
+SIM_EXTRA_HW_DEVICES = \
+	bfin_cec \
+	bfin_ctimer \
+	bfin_dma \
+	bfin_dmac \
+	bfin_ebiu_amc \
+	bfin_ebiu_ddrc \
+	bfin_ebiu_sdc \
+	bfin_emac \
+	bfin_eppi \
+	bfin_evt \
+	bfin_gpio \
+	bfin_gpio2 \
+	bfin_gptimer \
+	bfin_jtag \
+	bfin_mmu \
+	bfin_nfc \
+	bfin_otp \
+	bfin_pfmon \
+	bfin_pint \
+	bfin_pll \
+	bfin_ppi \
+	bfin_rtc \
+	bfin_sic \
+	bfin_spi \
+	bfin_trace \
+	bfin_twi \
+	bfin_uart \
+	bfin_uart2 \
+	bfin_wdog \
+	bfin_wp \
+	eth_phy
+
 SIM_EXTRA_CFLAGS = @SDL_CFLAGS@
 SIM_EXTRA_LIBS = @SDL_LIBS@ -lm
 
diff --git a/sim/bfin/configure.ac b/sim/bfin/configure.ac
index 4e31c6f13594..ab3bd5b0b99d 100644
--- a/sim/bfin/configure.ac
+++ b/sim/bfin/configure.ac
@@ -3,39 +3,6 @@ AC_INIT(Makefile.in)
 AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_DEFAULT_MODEL(bf537)
-SIM_AC_OPTION_HARDWARE(\
-	bfin_cec \
-	bfin_ctimer \
-	bfin_dma \
-	bfin_dmac \
-	bfin_ebiu_amc \
-	bfin_ebiu_ddrc \
-	bfin_ebiu_sdc \
-	bfin_emac \
-	bfin_eppi \
-	bfin_evt \
-	bfin_gpio \
-	bfin_gpio2 \
-	bfin_gptimer \
-	bfin_jtag \
-	bfin_mmu \
-	bfin_nfc \
-	bfin_otp \
-	bfin_pfmon \
-	bfin_pint \
-	bfin_pll \
-	bfin_ppi \
-	bfin_rtc \
-	bfin_sic \
-	bfin_spi \
-	bfin_trace \
-	bfin_twi \
-	bfin_uart \
-	bfin_uart2 \
-	bfin_wdog \
-	bfin_wp \
-	eth_phy \
-)
 
 PKG_PROG_PKG_CONFIG
 PKG_CHECK_MODULES(SDL, sdl, [
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index ba62c32772c1..6d7c9c47b64a 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -73,8 +73,7 @@ SIM_BITSIZE = @sim_bitsize@
 SIM_DEFAULT_MODEL = @sim_default_model@
 SIM_FLOAT = @sim_float@
 SIM_HW_CFLAGS = @sim_hw_cflags@
-SIM_HW_OBJS = @sim_hw_objs@
-SIM_HW = @sim_hw@
+SIM_HW_SOCKSER = @sim_hw_sockser@
 SIM_RESERVED_BITS = @sim_reserved_bits@
 SIM_SCACHE = @sim_scache@
 SIM_WARN_CFLAGS = $(WARN_CFLAGS)
@@ -216,6 +215,10 @@ BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH)
 
 COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS)
 
+SIM_HW_DEVICES = cfi core pal glue $(SIM_EXTRA_HW_DEVICES)
+SIM_HW_OBJS = $(SIM_COMMON_HW_OBJS) $(SIM_HW_DEVICES:%=dv-%.o) $(SIM_HW_SOCKSER)
+@SIM_ENABLE_HW_FALSE@SIM_HW_OBJS =
+
 ZLIB = $(zlibdir) -lz
 LIBIBERTY_LIB = ../../libiberty/libiberty.a
 BFD_LIB = ../../bfd/libbfd.a
@@ -417,12 +420,12 @@ hw-config.h: stamp-hw ; @true
 stamp-hw: Makefile.in $(srccom)/Make-common.in config.status Makefile
 	rm -f tmp-hw.h
 	echo "/* generated by Makefile */" > tmp-hw.h
-	sim_hw="$(SIM_HW)"; \
+	sim_hw="$(SIM_HW_DEVICES)"; \
 	for hw in $$sim_hw ; do \
 	  echo "extern const struct hw_descriptor dv_$${hw}_descriptor[];" ; \
 	done >> tmp-hw.h
 	echo "const struct hw_descriptor *hw_descriptors[] = {" >> tmp-hw.h
-	sim_hw="$(SIM_HW)"; \
+	sim_hw="$(SIM_HW_DEVICES)"; \
 	for hw in $$sim_hw ; do \
 	  echo "  dv_$${hw}_descriptor," ; \
 	done >> tmp-hw.h
diff --git a/sim/cris/Makefile.in b/sim/cris/Makefile.in
index ef83ce818260..dfc6d6c5ac40 100644
--- a/sim/cris/Makefile.in
+++ b/sim/cris/Makefile.in
@@ -31,6 +31,8 @@ SIM_OBJS = \
 	$(CRISV32F_OBJS) \
 	traps.o
 
+SIM_EXTRA_HW_DEVICES = rv cris cris_900000xx
+
 # Extra headers included by sim-main.h.
 # FIXME: $(srccom)/cgen-ops.h should be in CGEN_INCLUDE_DEPS.
 SIM_EXTRA_DEPS = \
diff --git a/sim/cris/configure.ac b/sim/cris/configure.ac
index 13500a09a495..57a2d5fe3d7a 100644
--- a/sim/cris/configure.ac
+++ b/sim/cris/configure.ac
@@ -3,7 +3,6 @@ AC_INIT(Makefile.in)
 AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_SCACHE(16384)
-SIM_AC_OPTION_HARDWARE(rv cris cris_900000xx)
 
 # The default model shouldn't matter as long as there's a BFD.
 SIM_AC_OPTION_DEFAULT_MODEL(crisv32)
diff --git a/sim/lm32/Makefile.in b/sim/lm32/Makefile.in
index 268882745c7e..bac9861ec53b 100644
--- a/sim/lm32/Makefile.in
+++ b/sim/lm32/Makefile.in
@@ -12,6 +12,8 @@ SIM_OBJS = \
         cpu.o decode.o sem.o model.o mloop.o \
         lm32.o traps.o user.o 
 
+SIM_EXTRA_HW_DEVICES = lm32cpu lm32timer lm32uart
+
 # List of extra dependencies.
 # Generally this consists of simulator specific files included by sim-main.h.
 SIM_EXTRA_DEPS = $(CGEN_INCLUDE_DEPS) $(srcdir)/../../opcodes/lm32-desc.h \
diff --git a/sim/lm32/configure.ac b/sim/lm32/configure.ac
index edf7968b3e04..96b6f0e98e25 100644
--- a/sim/lm32/configure.ac
+++ b/sim/lm32/configure.ac
@@ -4,6 +4,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL(lm32)
-SIM_AC_OPTION_HARDWARE(lm32cpu lm32timer lm32uart)
 
 SIM_AC_OUTPUT
diff --git a/sim/m32r/Makefile.in b/sim/m32r/Makefile.in
index f8ccb97d77b0..eb9641ee8e67 100644
--- a/sim/m32r/Makefile.in
+++ b/sim/m32r/Makefile.in
@@ -34,6 +34,8 @@ SIM_OBJS = \
 	$(M32R2_OBJS) \
 	$(TRAPS_OBJ)
 
+SIM_EXTRA_HW_DEVICES = m32r_cache m32r_uart
+
 # Extra headers included by sim-main.h.
 SIM_EXTRA_DEPS = \
 	$(CGEN_INCLUDE_DEPS) \
diff --git a/sim/m32r/configure.ac b/sim/m32r/configure.ac
index a45eebdfedff..f98adb26c46d 100644
--- a/sim/m32r/configure.ac
+++ b/sim/m32r/configure.ac
@@ -18,6 +18,4 @@ SIM_AC_OPTION_DEFAULT_MODEL(m32r/d)
 AC_SUBST(traps_obj)
 AC_SUBST(sim_extra_cflags)
 
-SIM_AC_OPTION_HARDWARE(m32r_cache m32r_uart)
-
 SIM_AC_OUTPUT
diff --git a/sim/m4/sim_ac_option_hardware.m4 b/sim/m4/sim_ac_option_hardware.m4
index 477ab2669093..14101830e828 100644
--- a/sim/m4/sim_ac_option_hardware.m4
+++ b/sim/m4/sim_ac_option_hardware.m4
@@ -14,55 +14,42 @@ dnl You should have received a copy of the GNU General Public License
 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
 dnl --enable-sim-hardware is for users of the simulator
-dnl arg[1] is a space separated list of extra target specific devices.
 AC_DEFUN([SIM_AC_OPTION_HARDWARE],
-[
-hardware="cfi core pal glue [$1]"
-sim_hw_cflags="-DWITH_HW=1"
-sim_hw="$hardware"
-sim_hw_objs="\$(SIM_COMMON_HW_OBJS) `echo $sim_hw | sed -e 's/\([[^ ]][[^ ]]*\)/dv-\1.o/g'`"
-
+[dnl
+AC_MSG_CHECKING([for sim hardware settings])
 AC_ARG_ENABLE(sim-hardware,
-  [AS_HELP_STRING([--enable-sim-hardware=LIST],
-                  [Specify the hardware to be included in the build.])],
+  [AS_HELP_STRING([--enable-sim-hardware],
+		  [Whether to enable hardware/device simulation])],
   ,[enable_sim_hardware="yes"])
-case ${enable_sim_hardware} in
-  yes|no) ;;
-  ,*) hardware="${hardware} `echo ${enableval} | sed -e 's/,/ /'`";;
-  *,) hardware="`echo ${enableval} | sed -e 's/,/ /'` ${hardware}";;
-  *)  hardware="`echo ${enableval} | sed -e 's/,/ /'`"'';;
-esac
-
+sim_hw_sockser=
 if test "$enable_sim_hardware" = no; then
-  sim_hw_objs=
   sim_hw_cflags="-DWITH_HW=0"
-  sim_hw=
-else
+elif test "$enable_sim_hardware" = yes; then
   sim_hw_cflags="-DWITH_HW=1"
-  # remove duplicates
-  sim_hw=""
-  sim_hw_objs="\$(SIM_COMMON_HW_OBJS)"
-  for i in $hardware ; do
-    case " $sim_hw " in
-      *" $i "*) ;;
-      *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";;
-    esac
-  done
   # mingw does not support sockser
   case ${host} in
     *mingw*) ;;
     *) # TODO: We don't add dv-sockser to sim_hw as it is not a "real" device
        # that you instatiate.  Instead, other code will call into it directly.
        # At some point, we should convert it over.
-       sim_hw_objs="$sim_hw_objs dv-sockser.o"
+       sim_hw_sockser="dv-sockser.o"
        sim_hw_cflags="$sim_hw_cflags -DHAVE_DV_SOCKSER"
        ;;
   esac
-  if test x"$silent" != x"yes"; then
-    echo "Setting hardware to $sim_hw_cflags, $sim_hw, $sim_hw_objs"
-  fi
+else
+  AC_MSG_ERROR([unknown argument "$enable_sim_hardware"])
 fi
-])
+dnl AM_CONDITIONAL([SIM_ENABLE_HW], [test "$enable_sim_hardware" = "yes"])
+if test "$enable_sim_hardware" = "yes"; then
+  SIM_ENABLE_HW_TRUE=
+  SIM_ENABLE_HW_FALSE='#'
+else
+  SIM_ENABLE_HW_TRUE='#'
+  SIM_ENABLE_HW_FALSE=
+fi
+AC_SUBST(SIM_ENABLE_HW_TRUE)
+AC_SUBST(SIM_ENABLE_HW_FALSE)
+AC_MSG_RESULT(${enable_sim_hardware})
 AC_SUBST(sim_hw_cflags)
-AC_SUBST(sim_hw_objs)
-AC_SUBST(sim_hw)
+AC_SUBST(sim_hw_sockser)
+])
diff --git a/sim/m4/sim_ac_output.m4 b/sim/m4/sim_ac_output.m4
index 98385b99f76d..8d260421e0e9 100644
--- a/sim/m4/sim_ac_output.m4
+++ b/sim/m4/sim_ac_output.m4
@@ -51,9 +51,6 @@ AC_SUBST(sim_bitsize)
 AC_SUBST(sim_float)
 AC_SUBST(sim_scache)
 AC_SUBST(sim_default_model)
-AC_SUBST(sim_hw_cflags)
-AC_SUBST(sim_hw_objs)
-AC_SUBST(sim_hw)
 AC_SUBST(sim_reserved_bits)
 
 AC_OUTPUT
diff --git a/sim/m68hc11/Makefile.in b/sim/m68hc11/Makefile.in
index 8a044914ed65..e7b668648558 100644
--- a/sim/m68hc11/Makefile.in
+++ b/sim/m68hc11/Makefile.in
@@ -24,6 +24,8 @@ SIM_OBJS = $(M68HC11_OBJS) \
 	$(SIM_NEW_COMMON_OBJS) \
 	sim-resume.o
 
+SIM_EXTRA_HW_DEVICES = m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram
+
 SIM_PROFILE= -DPROFILE=1 -DWITH_PROFILE=-1
 # We must use 32-bit addresses to support memory bank switching.
 # The WORD_BITSIZE is normally 16 but must be switched (temporarily)
diff --git a/sim/m68hc11/configure.ac b/sim/m68hc11/configure.ac
index 02eccf0ddcb7..99370b3a5770 100644
--- a/sim/m68hc11/configure.ac
+++ b/sim/m68hc11/configure.ac
@@ -2,8 +2,4 @@ dnl Process this file with autoconf to produce a configure script.
 AC_INIT(Makefile.in)
 AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
-dnl Options available in this module
-SIM_AC_OPTION_HARDWARE(\
-  m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram)
-
 SIM_AC_OUTPUT
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 2f79c56cbcbc..c04736ba0802 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -69,6 +69,7 @@ SIM_OBJS = \
 	sim-main.o \
 	sim-resume.o \
 
+SIM_EXTRA_HW_DEVICES = tx3904cpu tx3904irc tx3904tmr tx3904sio
 
 # List of flags to always pass to $(CC).
 SIM_SUBTARGET=@SIM_SUBTARGET@
diff --git a/sim/mips/configure.ac b/sim/mips/configure.ac
index a8c16b259251..e3a44a0055fa 100644
--- a/sim/mips/configure.ac
+++ b/sim/mips/configure.ac
@@ -400,9 +400,5 @@ AC_SUBST(sim_multi_flags)
 AC_SUBST(sim_multi_igen_configs)
 AC_SUBST(sim_multi_src)
 AC_SUBST(sim_multi_obj)
-#
-# Add simulated hardware devices
-#
-SIM_AC_OPTION_HARDWARE(tx3904cpu tx3904irc tx3904tmr tx3904sio)
 
 SIM_AC_OUTPUT
diff --git a/sim/mn10300/Makefile.in b/sim/mn10300/Makefile.in
index ba48273ba848..968378cafe62 100644
--- a/sim/mn10300/Makefile.in
+++ b/sim/mn10300/Makefile.in
@@ -25,6 +25,8 @@ MN10300_OBJS = \
 
 SIM_OBJS = $(MN10300_OBJS) interp.o
 
+SIM_EXTRA_HW_DEVICES = mn103cpu mn103int mn103tim mn103ser mn103iop
+
 SIM_EXTRA_CLEAN = clean-igen
 # Extra dependencies for "sim-main.h"
 SIM_EXTRA_DEPS = mn10300_sim.h itable.h idecode.h
diff --git a/sim/mn10300/configure.ac b/sim/mn10300/configure.ac
index e531be971cd7..74eb1fa54685 100644
--- a/sim/mn10300/configure.ac
+++ b/sim/mn10300/configure.ac
@@ -4,6 +4,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 
 SIM_AC_OPTION_RESERVED_BITS
 SIM_AC_OPTION_BITSIZE(32,31)
-SIM_AC_OPTION_HARDWARE(mn103cpu mn103int mn103tim mn103ser mn103iop)
 
 SIM_AC_OUTPUT
-- 
2.31.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-06-23 13:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-20  5:55 [PATCH 1/5] sim: hw: rework configure option & device selection Mike Frysinger
2021-06-20  5:55 ` [PATCH 2/5] sim: unify hardware settings Mike Frysinger
2021-06-20  5:55 ` [PATCH 3/5] sim: drop configure scripts for simple ports Mike Frysinger
2021-06-23  1:05   ` Simon Marchi
2021-06-23  2:09     ` Mike Frysinger
2021-06-23  2:59     ` [PATCH] sim: switch common srcdir to abs_srcdir Mike Frysinger
2021-06-23 13:01       ` Simon Marchi
2021-06-20  5:55 ` [PATCH 4/5] sim: rx: merge with common configure script Mike Frysinger
2021-06-20  5:55 ` [PATCH 5/5] sim: hw: move cfi & glue to common code Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).