[3/5] sim: mips: move bitsize defines to top-level configure

Message ID 20221221051322.4163-3-vapier@gentoo.org
State Committed
Headers
Series [1/5] sim: mips: always resolve active bfd mach dynamically |

Commit Message

Mike Frysinger Dec. 21, 2022, 5:13 a.m. UTC
  Since the msb value is always defined as the wordsize-1, stop
hardcoding that value directly, and use a CPP value instead.
---
 sim/Makefile.in           |  1 +
 sim/arch-subdir.mk.in     |  1 +
 sim/configure             | 30 ++++++++++++++-
 sim/mips/Makefile.in      |  2 +
 sim/mips/acinclude-top.m4 | 14 +++++++
 sim/mips/aclocal.m4       |  1 -
 sim/mips/configure        | 81 +--------------------------------------
 sim/mips/configure.ac     | 17 --------
 8 files changed, 48 insertions(+), 99 deletions(-)
  

Patch

diff --git a/sim/arch-subdir.mk.in b/sim/arch-subdir.mk.in
index 086a5cd80a68..38a18a378fd7 100644
--- a/sim/arch-subdir.mk.in
+++ b/sim/arch-subdir.mk.in
@@ -77,3 +77,4 @@  SIM_HW_OBJS = $(SIM_COMMON_HW_OBJS) $(SIM_HW_DEVICES:%=dv-%.o) $(SIM_HW_SOCKSER)
 
 # This can be removed once mips/configure is gone.
 SIM_MIPS_SUBTARGET = @SIM_MIPS_SUBTARGET@
+SIM_MIPS_BITSIZE = -DWITH_TARGET_WORD_BITSIZE=@SIM_MIPS_BITSIZE@ -DWITH_TARGET_WORD_MSB=WITH_TARGET_WORD_BITSIZE-1
diff --git a/sim/mips/Makefile.in b/sim/mips/Makefile.in
index 50fa7a8fc27f..aa872883ec70 100644
--- a/sim/mips/Makefile.in
+++ b/sim/mips/Makefile.in
@@ -69,6 +69,8 @@  SIM_EXTRA_HW_DEVICES = tx3904cpu tx3904irc tx3904tmr tx3904sio
 # List of flags to always pass to $(CC).
 SIM_EXTRA_CFLAGS = $(SIM_MIPS_SUBTARGET)
 
+SIM_BITSIZE = $(SIM_MIPS_BITSIZE)
+
 SIM_EXTRA_CLEAN = clean-extra
 SIM_EXTRA_DISTCLEAN = distclean-extra
 
diff --git a/sim/mips/acinclude-top.m4 b/sim/mips/acinclude-top.m4
index 4eb6c19f8123..2d53bee13576 100644
--- a/sim/mips/acinclude-top.m4
+++ b/sim/mips/acinclude-top.m4
@@ -32,3 +32,17 @@  AS_CASE([${target}],
   [mipsisa64*-*-*], [SIM_MIPS_SUBTARGET="-DTARGET_ENABLE_FR=1"])
 AC_MSG_RESULT([${SIM_MIPS_SUBTARGET:-none}])
 AC_SUBST(SIM_MIPS_SUBTARGET)
+
+dnl Select the bitsize of the target.
+AC_MSG_CHECKING([mips bitsize])
+SIM_MIPS_BITSIZE=64
+AS_CASE([${target}],
+  [mips*-sde-elf*], [SIM_MIPS_BITSIZE=64],
+  [mips*-mti-elf*], [SIM_MIPS_BITSIZE=64],
+  [mips64*-*-*],    [SIM_MIPS_BITSIZE=64],
+  [mips16*-*-*],    [SIM_MIPS_BITSIZE=64],
+  [mipsisa32*-*-*], [SIM_MIPS_BITSIZE=32],
+  [mipsisa64*-*-*], [SIM_MIPS_BITSIZE=64],
+  [mips*-*-*],      [SIM_MIPS_BITSIZE=32])
+AC_MSG_RESULT([$SIM_MIPS_BITSIZE])
+AC_SUBST(SIM_MIPS_BITSIZE)
diff --git a/sim/mips/configure.ac b/sim/mips/configure.ac
index 308b3aefbeb1..d820b816fe01 100644
--- a/sim/mips/configure.ac
+++ b/sim/mips/configure.ac
@@ -6,23 +6,6 @@  dnl The sim shouldn't be checking $target and changing behavior.  But it is,
 dnl and until we clean that up, we need to expand --target for use below.
 AC_CANONICAL_SYSTEM
 
-#
-# Select the bitsize of the target
-#
-case "${target}" in
-  mips*-sde-elf*)       mips_bitsize=64 ; mips_msb=63 ;;
-  mips*-mti-elf*)       mips_bitsize=64 ; mips_msb=63 ;;
-  mips64*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
-  mips16*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
-  mipsisa32*-*-*)       mips_bitsize=32 ; mips_msb=31 ;;
-  mipsisa64*-*-*)       mips_bitsize=64 ; mips_msb=63 ;;
-  mips*-*-*)            mips_bitsize=32 ; mips_msb=31 ;;
-  *)                    mips_bitsize=64 ; mips_msb=63 ;;
-esac
-SIM_AC_OPTION_BITSIZE($mips_bitsize,$mips_msb)
-
-
-
 #
 # Select the floating hardware support of the target
 #