public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 7/7] sim: overhaul alignment settings management
Date: Mon,  7 Jun 2021 01:33:55 -0400	[thread overview]
Message-ID: <20210607053355.9965-7-vapier@gentoo.org> (raw)
In-Reply-To: <20210607053355.9965-1-vapier@gentoo.org>

Currently, the sim-config module will abort if alignment settings
haven't been specified by the port's configure.ac.  This is a bit
weird when we've allowed SIM_AC_OPTION_ALIGNMENT to seem like it's
optional to use.  Thus everyone invokes it.

There are 4 alignment settings, but really only 2 matters: strict
and nonstrict.  The "mixed" setting is just the default ("unset"),
and "forced" isn't used directly by anyone (it's available as a
runtime option for some ports).

The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified).  If none are specified, then the
build won't work (see above as if SIM_AC_OPTION_ALIGNMENT wasn't
called).  If default settings are provided, then that is used, but
we allow the user to override at runtime.  Otherwise, the "wire"
settings are used and user runtime options to change are ignored.

Most ports specify a default, or set the "wire" to nonstrict.  A
few set "wire" to strict, but it's not clear that's necessary as
it doesn't make the code behavior, by default, any different.  It
might make things a little faster, but we should provide the user
the choice of the compromises to make: force a specific mode at
compile time for faster runtime, or allow the choice at runtime.
More likely it seems like an oversight when these ports were
initially created, and/or copied & pasted from existing ports.

With all that backstory, let's get to what this commit does.

First kill off the idea of a compile-time default alignment and
set it to nonstrict in the common code.  For any ports that want
strict alignment by default, that code is moved to sim_open while
initializing the sim.  That means WITH_DEFAULT_ALIGNMENT can be
completely removed.

Moving the default alignment to the runtime also allows removal
of setting the "wire" settings at configure time.  Which allows
removing of all arguments to SIM_AC_OPTION_ALIGNMENT and moving
that call to common code.

The macro logic can be reworked to not pass WITH_ALIGNMENT as -D
CPPFLAG and instead move it to config.h.

All of these taken together mean we can hoist the macro up to the
top level and share it among all sims so behavior is consistent
among all the ports.
---
 sim/Makefile.in                   |  1 +
 sim/aarch64/aclocal.m4            |  1 -
 sim/aarch64/configure             | 62 ++-----------------------------
 sim/aarch64/configure.ac          |  5 ---
 sim/aarch64/interp.c              |  5 +++
 sim/aclocal.m4                    |  1 +
 sim/arm/aclocal.m4                |  1 -
 sim/arm/configure                 | 58 ++---------------------------
 sim/arm/configure.ac              |  1 -
 sim/arm/wrapper.c                 |  3 ++
 sim/avr/aclocal.m4                |  1 -
 sim/avr/configure                 | 58 ++---------------------------
 sim/avr/configure.ac              |  1 -
 sim/avr/interp.c                  |  3 ++
 sim/bfin/aclocal.m4               |  1 -
 sim/bfin/configure                | 58 ++---------------------------
 sim/bfin/configure.ac             |  1 -
 sim/bfin/interp.c                 |  3 ++
 sim/bpf/aclocal.m4                |  1 -
 sim/bpf/configure                 | 58 ++---------------------------
 sim/bpf/configure.ac              |  1 -
 sim/common/Make-common.in         |  2 -
 sim/common/sim-config.c           |  8 +---
 sim/common/sim-config.h           | 11 +-----
 sim/config.h.in                   |  3 ++
 sim/configure                     | 24 ++++++++++++
 sim/configure.ac                  |  1 +
 sim/cr16/aclocal.m4               |  1 -
 sim/cr16/configure                | 58 ++---------------------------
 sim/cr16/configure.ac             |  1 -
 sim/cris/aclocal.m4               |  1 -
 sim/cris/configure                | 58 ++---------------------------
 sim/cris/configure.ac             |  1 -
 sim/d10v/aclocal.m4               |  1 -
 sim/d10v/configure                | 58 ++---------------------------
 sim/d10v/configure.ac             |  1 -
 sim/d10v/interp.c                 |  3 ++
 sim/example-synacor/aclocal.m4    |  1 -
 sim/example-synacor/configure     | 58 ++---------------------------
 sim/example-synacor/configure.ac  |  1 -
 sim/example-synacor/interp.c      |  3 ++
 sim/frv/aclocal.m4                |  1 -
 sim/frv/configure                 | 58 ++---------------------------
 sim/frv/configure.ac              |  1 -
 sim/frv/sim-if.c                  |  3 ++
 sim/ft32/aclocal.m4               |  1 -
 sim/ft32/configure                | 58 ++---------------------------
 sim/ft32/configure.ac             |  1 -
 sim/ft32/interp.c                 |  3 ++
 sim/h8300/aclocal.m4              |  1 -
 sim/h8300/configure               | 58 ++---------------------------
 sim/h8300/configure.ac            |  1 -
 sim/iq2000/aclocal.m4             |  1 -
 sim/iq2000/configure              | 58 ++---------------------------
 sim/iq2000/configure.ac           |  1 -
 sim/iq2000/sim-if.c               |  3 ++
 sim/lm32/aclocal.m4               |  1 -
 sim/lm32/configure                | 58 ++---------------------------
 sim/lm32/configure.ac             |  1 -
 sim/lm32/sim-if.c                 |  3 ++
 sim/m32r/aclocal.m4               |  1 -
 sim/m32r/configure                | 58 ++---------------------------
 sim/m32r/configure.ac             |  1 -
 sim/m32r/sim-if.c                 |  3 ++
 sim/m4/sim_ac_option_alignment.m4 | 53 +++++---------------------
 sim/m68hc11/aclocal.m4            |  1 -
 sim/m68hc11/configure             | 58 ++---------------------------
 sim/m68hc11/configure.ac          |  1 -
 sim/mcore/aclocal.m4              |  1 -
 sim/mcore/configure               | 58 ++---------------------------
 sim/mcore/configure.ac            |  1 -
 sim/microblaze/aclocal.m4         |  1 -
 sim/microblaze/configure          | 58 ++---------------------------
 sim/microblaze/configure.ac       |  1 -
 sim/mips/aclocal.m4               |  1 -
 sim/mips/configure                | 58 ++---------------------------
 sim/mips/configure.ac             |  1 -
 sim/mn10300/aclocal.m4            |  1 -
 sim/mn10300/configure             | 58 ++---------------------------
 sim/mn10300/configure.ac          |  1 -
 sim/moxie/aclocal.m4              |  1 -
 sim/moxie/configure               | 58 ++---------------------------
 sim/moxie/configure.ac            |  1 -
 sim/msp430/aclocal.m4             |  1 -
 sim/msp430/configure              | 58 ++---------------------------
 sim/msp430/configure.ac           |  1 -
 sim/or1k/aclocal.m4               |  1 -
 sim/or1k/configure                | 58 ++---------------------------
 sim/or1k/configure.ac             |  1 -
 sim/pru/aclocal.m4                |  1 -
 sim/pru/configure                 | 58 ++---------------------------
 sim/pru/configure.ac              |  1 -
 sim/pru/interp.c                  |  3 ++
 sim/riscv/aclocal.m4              |  1 -
 sim/riscv/configure               | 58 ++---------------------------
 sim/riscv/configure.ac            |  1 -
 sim/sh/aclocal.m4                 |  1 -
 sim/sh/configure                  | 58 ++---------------------------
 sim/sh/configure.ac               |  1 -
 sim/sh/interp.c                   |  3 ++
 sim/v850/aclocal.m4               |  1 -
 sim/v850/configure                | 58 ++---------------------------
 sim/v850/configure.ac             |  1 -
 103 files changed, 193 insertions(+), 1580 deletions(-)

diff --git a/sim/aarch64/configure.ac b/sim/aarch64/configure.ac
index 1c212dc2c955..381682fb5f09 100644
--- a/sim/aarch64/configure.ac
+++ b/sim/aarch64/configure.ac
@@ -25,11 +25,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN
-## We use NONSTRICT_ALIGNMENT as the default because AArch64 only
-## enforces 4-byte alignment, even for 8-byte reads/writes.  The
-## common core does not support this, so we opt for non-strict
-## alignment instead.
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT,NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/aarch64/interp.c b/sim/aarch64/interp.c
index fd35f4fa683d..18c2fc0eacbd 100644
--- a/sim/aarch64/interp.c
+++ b/sim/aarch64/interp.c
@@ -330,6 +330,11 @@ sim_open (SIM_OPEN_KIND                  kind,
 
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* We use NONSTRICT_ALIGNMENT as the default because AArch64 only enforces
+     4-byte alignment, even for 8-byte reads/writes.  The common core does not
+     support this, so we opt for non-strict alignment instead.  */
+  current_alignment = NONSTRICT_ALIGNMENT;
+
   /* Perform the initialization steps one by one.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK
       || sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK
diff --git a/sim/arm/configure.ac b/sim/arm/configure.ac
index 88fac82e7b4c..7638b6d8e11b 100644
--- a/sim/arm/configure.ac
+++ b/sim/arm/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index a1147e402cc0..e697d55a6b5e 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -801,6 +801,9 @@ sim_open (SIM_OPEN_KIND kind,
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/avr/configure.ac b/sim/avr/configure.ac
index 92046a1762dd..9d6e1e6ded71 100644
--- a/sim/avr/configure.ac
+++ b/sim/avr/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/avr/interp.c b/sim/avr/interp.c
index d456c39390a7..1626fadaa973 100644
--- a/sim/avr/interp.c
+++ b/sim/avr/interp.c
@@ -1684,6 +1684,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_DESC sd = sim_state_alloc_extra (kind, cb, sizeof (struct avr_sim_state));
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/bfin/configure.ac b/sim/bfin/configure.ac
index 18e82fae66b9..e2d53bcc7ca9 100644
--- a/sim/bfin/configure.ac
+++ b/sim/bfin/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_DEFAULT_MODEL(bf537)
 SIM_AC_OPTION_WARNINGS
 SIM_AC_OPTION_HARDWARE(\
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index 34357201934c..2e9696f8bfe1 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -720,6 +720,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   SIM_DESC sd = sim_state_alloc_extra (kind, callback,
 				       sizeof (struct bfin_board_data));
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/bpf/configure.ac b/sim/bpf/configure.ac
index a0f8576fc392..4e00c1316090 100644
--- a/sim/bpf/configure.ac
+++ b/sim/bpf/configure.ac
@@ -6,7 +6,6 @@ SIM_AC_COMMON
 
 SIM_AC_OPTION_BITSIZE([64])
 SIM_AC_OPTION_ENDIAN([], [LITTLE])
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL([bpf-def])
 SIM_AC_OPTION_WARNINGS(no)
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index b17b2e0f4530..f82c12968ff3 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -82,7 +82,6 @@ CPPFLAGS = @CPPFLAGS@
 CXXFLAGS = @CXXFLAGS@
 LDFLAGS = @LDFLAGS@
 
-SIM_ALIGNMENT = @sim_alignment@
 SIM_BITSIZE = @sim_bitsize@
 SIM_DEFAULT_MODEL = @sim_default_model@
 SIM_ENDIAN = @sim_endian@
@@ -221,7 +220,6 @@ CGEN_INCLUDE_DEPS = \
 CONFIG_CFLAGS = \
 	@DEFS@ \
 	$(SIM_DEFAULT_MODEL) \
-	$(SIM_ALIGNMENT) \
 	$(SIM_BITSIZE) \
 	$(SIM_ENDIAN) \
 	$(SIM_FLOAT) \
diff --git a/sim/common/sim-config.c b/sim/common/sim-config.c
index df99d6a957fd..c9005f449fe6 100644
--- a/sim/common/sim-config.c
+++ b/sim/common/sim-config.c
@@ -253,8 +253,9 @@ sim_config (SIM_DESC sd)
 #endif
   if (current_alignment == 0)
     current_alignment = WITH_ALIGNMENT;
+  /* If the port hasn't specified an alignment, default to not enforcing.  */
   if (current_alignment == 0)
-    current_alignment = WITH_DEFAULT_ALIGNMENT;
+    current_alignment = NONSTRICT_ALIGNMENT;
 
   /* verify the alignment */
   if (CURRENT_ALIGNMENT == 0)
@@ -331,11 +332,6 @@ sim_config_print (SIM_DESC sd)
   sim_io_printf (sd, "WITH_ALIGNMENT = %s\n",
 		 config_alignment_to_a (WITH_ALIGNMENT));
 
-#if defined (WITH_DEFAULT_ALIGNMENT)
-  sim_io_printf (sd, "WITH_DEFAULT_ALIGNMENT = %s\n",
-		 config_alignment_to_a (WITH_DEFAULT_ALIGNMENT));
-#endif
-
 #if defined (WITH_XOR_ENDIAN)
   sim_io_printf (sd, "WITH_XOR_ENDIAN = %d\n", WITH_XOR_ENDIAN);
 #endif
diff --git a/sim/common/sim-config.h b/sim/common/sim-config.h
index 6ab8d1a97eca..2b6ed3d0b7d4 100644
--- a/sim/common/sim-config.h
+++ b/sim/common/sim-config.h
@@ -195,11 +195,11 @@ extern char *simulator_sysroot;
 
 /* Alignment:
 
-   A processor architecture may or may not handle miss aligned
+   A processor architecture may or may not handle misaligned
    transfers.
 
    As alternatives: both little and big endian modes take an exception
-   (STRICT_ALIGNMENT); big and little endian models handle mis aligned
+   (STRICT_ALIGNMENT); big and little endian models handle misaligned
    transfers (NONSTRICT_ALIGNMENT); or the address is forced into
    alignment using a mask (FORCED_ALIGNMENT).
 
@@ -220,13 +220,6 @@ extern enum sim_alignments current_alignment;
 #define WITH_ALIGNMENT 0
 #endif
 
-#if !defined (WITH_DEFAULT_ALIGNMENT)
-#define WITH_DEFAULT_ALIGNMENT 0 /* fatal */
-#endif
-
-
-
-
 #define CURRENT_ALIGNMENT (WITH_ALIGNMENT \
 			   ? WITH_ALIGNMENT \
 			   : current_alignment)
diff --git a/sim/configure.ac b/sim/configure.ac
index 8022a11bc91a..e7f3f535ef59 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -108,6 +108,7 @@ AM_CONDITIONAL([SIM_ENABLE_IGEN], [test "$sim_igen" = "yes"])
 
 dnl Standard (and optional) simulator options.
 dnl Eventually all simulators will support these.
+SIM_AC_OPTION_ALIGNMENT
 SIM_AC_OPTION_ASSERT
 SIM_AC_OPTION_DEBUG
 SIM_AC_OPTION_ENVIRONMENT
diff --git a/sim/cr16/configure.ac b/sim/cr16/configure.ac
index f4dc9c1314db..8cd4d23a479b 100644
--- a/sim/cr16/configure.ac
+++ b/sim/cr16/configure.ac
@@ -5,6 +5,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 
 SIM_AC_OUTPUT
diff --git a/sim/cris/configure.ac b/sim/cris/configure.ac
index b5eaea7b8adf..cc5bb4922f18 100644
--- a/sim/cris/configure.ac
+++ b/sim/cris/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_WARNINGS(no)
 SIM_AC_OPTION_HARDWARE(rv cris cris_900000xx)
diff --git a/sim/d10v/configure.ac b/sim/d10v/configure.ac
index 811452094557..ec8a87e7d397 100644
--- a/sim/d10v/configure.ac
+++ b/sim/d10v/configure.ac
@@ -5,6 +5,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 
 SIM_AC_OUTPUT
diff --git a/sim/d10v/interp.c b/sim/d10v/interp.c
index b587cc18654f..c0cdc034700d 100644
--- a/sim/d10v/interp.c
+++ b/sim/d10v/interp.c
@@ -755,6 +755,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/example-synacor/configure.ac b/sim/example-synacor/configure.ac
index 13b311197e36..8cd4d23a479b 100644
--- a/sim/example-synacor/configure.ac
+++ b/sim/example-synacor/configure.ac
@@ -5,6 +5,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 
 SIM_AC_OUTPUT
diff --git a/sim/example-synacor/interp.c b/sim/example-synacor/interp.c
index eaf8f1fdf975..784c9cbc5755 100644
--- a/sim/example-synacor/interp.c
+++ b/sim/example-synacor/interp.c
@@ -82,6 +82,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
   int i;
   SIM_DESC sd = sim_state_alloc (kind, callback);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/frv/configure.ac b/sim/frv/configure.ac
index e5bbdbfba228..fcc2e8836bb7 100644
--- a/sim/frv/configure.ac
+++ b/sim/frv/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT)
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL(fr500)
 SIM_AC_OPTION_WARNINGS(no)
diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c
index c5fd93f0b310..2afec9ac78b6 100644
--- a/sim/frv/sim-if.c
+++ b/sim/frv/sim-if.c
@@ -54,6 +54,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, bfd *abfd,
   unsigned long elf_flags = 0;
   SIM_DESC sd = sim_state_alloc (kind, callback);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/ft32/configure.ac b/sim/ft32/configure.ac
index 658a0a459d01..9d6e1e6ded71 100644
--- a/sim/ft32/configure.ac
+++ b/sim/ft32/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/ft32/interp.c b/sim/ft32/interp.c
index 5fc9ea246583..8a44a472f605 100644
--- a/sim/ft32/interp.c
+++ b/sim/ft32/interp.c
@@ -808,6 +808,9 @@ sim_open (SIM_OPEN_KIND kind,
   size_t i;
   SIM_DESC sd = sim_state_alloc (kind, cb);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/h8300/configure.ac b/sim/h8300/configure.ac
index 43250f817416..7e2a166307ed 100644
--- a/sim/h8300/configure.ac
+++ b/sim/h8300/configure.ac
@@ -5,6 +5,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 
 SIM_AC_OUTPUT
diff --git a/sim/iq2000/configure.ac b/sim/iq2000/configure.ac
index 623fa192d74b..c61c9480d5e5 100644
--- a/sim/iq2000/configure.ac
+++ b/sim/iq2000/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT)
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL(iq2000)
 SIM_AC_OPTION_WARNINGS(no)
diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
index b363eb04a218..61b4b48d5e83 100644
--- a/sim/iq2000/sim-if.c
+++ b/sim/iq2000/sim-if.c
@@ -60,6 +60,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   int i;
   SIM_DESC sd = sim_state_alloc (kind, callback);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/lm32/configure.ac b/sim/lm32/configure.ac
index 63548874a114..4a2037468dee 100644
--- a/sim/lm32/configure.ac
+++ b/sim/lm32/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL(lm32)
 SIM_AC_OPTION_WARNINGS(no)
diff --git a/sim/lm32/sim-if.c b/sim/lm32/sim-if.c
index 1cccf626b670..74b605706e74 100644
--- a/sim/lm32/sim-if.c
+++ b/sim/lm32/sim-if.c
@@ -91,6 +91,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   int i;
   unsigned long base, limit;
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/m32r/configure.ac b/sim/m32r/configure.ac
index 8ab55bc155a8..a5cea83849e7 100644
--- a/sim/m32r/configure.ac
+++ b/sim/m32r/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT)
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL(m32r/d)
 SIM_AC_OPTION_WARNINGS(no)
diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
index a6d8c486168c..355a52d9bc66 100644
--- a/sim/m32r/sim-if.c
+++ b/sim/m32r/sim-if.c
@@ -54,6 +54,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd,
   char c;
   int i;
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/m4/sim_ac_option_alignment.m4 b/sim/m4/sim_ac_option_alignment.m4
index dcfa47984a63..409fbfc1a432 100644
--- a/sim/m4/sim_ac_option_alignment.m4
+++ b/sim/m4/sim_ac_option_alignment.m4
@@ -15,52 +15,19 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 dnl
 dnl Specify the alignment restrictions of the target architecture.
 dnl Without this option all possible alignment restrictions are accommodated.
-dnl arg[1] is hardwired target alignment
-dnl arg[2] is default target alignment
 AC_DEFUN([SIM_AC_OPTION_ALIGNMENT],
-wire_alignment="[$1]"
-default_alignment="[$2]"
-[
+[dnl
+AC_MSG_CHECKING([whether to force sim alignment])
+sim_alignment=
 AC_ARG_ENABLE(sim-alignment,
 [AS_HELP_STRING([--enable-sim-alignment=align],
 		[Specify strict, nonstrict or forced alignment of memory accesses])],
 [case "${enableval}" in
-  strict | STRICT)       sim_alignment="-DWITH_ALIGNMENT=STRICT_ALIGNMENT";;
-  nonstrict | NONSTRICT) sim_alignment="-DWITH_ALIGNMENT=NONSTRICT_ALIGNMENT";;
-  forced | FORCED)       sim_alignment="-DWITH_ALIGNMENT=FORCED_ALIGNMENT";;
-  yes) if test x"$wire_alignment" != x; then
-	 sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
-       else
-         if test x"$default_alignment" != x; then
-           sim_alignment="-DWITH_ALIGNMENT=${default_alignment}"
-         else
-	   echo "No hard-wired alignment for target $target" 1>&6
-	   sim_alignment="-DWITH_ALIGNMENT=0"
-         fi
-       fi;;
-  no)  if test x"$default_alignment" != x; then
-	 sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
-       else
-         if test x"$wire_alignment" != x; then
-	   sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${wire_alignment}"
-         else
-           echo "No default alignment for target $target" 1>&6
-           sim_alignment="-DWITH_DEFAULT_ALIGNMENT=0"
-         fi
-       fi;;
-  *)   AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment"); sim_alignment="";;
-esac
-if test x"$silent" != x"yes" && test x"$sim_alignment" != x""; then
-  echo "Setting alignment flags = $sim_alignment" 6>&1
-fi],
-[if test x"$default_alignment" != x; then
-  sim_alignment="-DWITH_DEFAULT_ALIGNMENT=${default_alignment}"
-else
-  if test x"$wire_alignment" != x; then
-    sim_alignment="-DWITH_ALIGNMENT=${wire_alignment}"
-  else
-    sim_alignment=
-  fi
-fi])dnl
+  yes | strict | STRICT)      sim_alignment="STRICT_ALIGNMENT";;
+  no | nonstrict | NONSTRICT) sim_alignment="NONSTRICT_ALIGNMENT";;
+  forced | FORCED)            sim_alignment="FORCED_ALIGNMENT";;
+  *) AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-alignment");;
+esac])dnl
+AC_DEFINE_UNQUOTED([WITH_ALIGNMENT], [${sim_alignment:-0}], [Sim alignment settings])
+AC_MSG_RESULT([${sim_alignment:-no}])
 ])dnl
-AC_SUBST(sim_alignment)
diff --git a/sim/m68hc11/configure.ac b/sim/m68hc11/configure.ac
index 57e13e207bdd..b2685040f61e 100644
--- a/sim/m68hc11/configure.ac
+++ b/sim/m68hc11/configure.ac
@@ -6,7 +6,6 @@ SIM_AC_COMMON
 
 dnl Options available in this module
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_HARDWARE(\
   m68hc11 m68hc11sio m68hc11eepr m68hc11tim m68hc11spi nvram)
 
diff --git a/sim/mcore/configure.ac b/sim/mcore/configure.ac
index 811452094557..ec8a87e7d397 100644
--- a/sim/mcore/configure.ac
+++ b/sim/mcore/configure.ac
@@ -5,6 +5,5 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 
 SIM_AC_OUTPUT
diff --git a/sim/microblaze/configure.ac b/sim/microblaze/configure.ac
index 88fac82e7b4c..7638b6d8e11b 100644
--- a/sim/microblaze/configure.ac
+++ b/sim/microblaze/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/mips/configure.ac b/sim/mips/configure.ac
index f4e67376c12e..f0b26b4f0acb 100644
--- a/sim/mips/configure.ac
+++ b/sim/mips/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 dnl Options available in this module
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS(no)
 SIM_AC_OPTION_RESERVED_BITS(1)
 
diff --git a/sim/mn10300/configure.ac b/sim/mn10300/configure.ac
index 55aec73be500..b09159d7d47f 100644
--- a/sim/mn10300/configure.ac
+++ b/sim/mn10300/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS(no)
 SIM_AC_OPTION_RESERVED_BITS
 SIM_AC_OPTION_BITSIZE(32,31)
diff --git a/sim/moxie/configure.ac b/sim/moxie/configure.ac
index fb5a91eacf8f..75a6f37ed265 100644
--- a/sim/moxie/configure.ac
+++ b/sim/moxie/configure.ac
@@ -7,6 +7,5 @@ SIM_AC_COMMON
 AC_CHECK_TOOL(DTC, dtc)
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT)
 
 SIM_AC_OUTPUT
diff --git a/sim/msp430/configure.ac b/sim/msp430/configure.ac
index 0277d7f497e3..19839d11822a 100644
--- a/sim/msp430/configure.ac
+++ b/sim/msp430/configure.ac
@@ -24,7 +24,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/or1k/configure.ac b/sim/or1k/configure.ac
index 32fb0d49b95d..e09fee1ac13d 100644
--- a/sim/or1k/configure.ac
+++ b/sim/or1k/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(BIG)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT)
 SIM_AC_OPTION_BITSIZE([32], [31], [32])
 SIM_AC_OPTION_SCACHE(16384)
 SIM_AC_OPTION_DEFAULT_MODEL([or1200])
diff --git a/sim/pru/configure.ac b/sim/pru/configure.ac
index a4db77beec2f..79dab8b24039 100644
--- a/sim/pru/configure.ac
+++ b/sim/pru/configure.ac
@@ -24,7 +24,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 SIM_AC_OUTPUT
diff --git a/sim/pru/interp.c b/sim/pru/interp.c
index 58ac333c1e6c..38269df44ce7 100644
--- a/sim/pru/interp.c
+++ b/sim/pru/interp.c
@@ -745,6 +745,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/riscv/configure.ac b/sim/riscv/configure.ac
index e5a07bbc46b0..3d678acb47be 100644
--- a/sim/riscv/configure.ac
+++ b/sim/riscv/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS
 
 # Select the default model for the target.
diff --git a/sim/sh/configure.ac b/sim/sh/configure.ac
index 4417ba4e561e..dd975d3259e6 100644
--- a/sim/sh/configure.ac
+++ b/sim/sh/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN
-SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT)
 SIM_AC_OPTION_WARNINGS(no)
 
 SIM_AC_OUTPUT
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 87fb863887f7..264e9b1de465 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -2358,6 +2358,9 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
   SIM_DESC sd = sim_state_alloc (kind, cb);
   SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
 
+  /* Set default options before parsing user options.  */
+  current_alignment = STRICT_ALIGNMENT;
+
   /* The cpu data is kept in a separately allocated chunk of memory.  */
   if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)
     {
diff --git a/sim/v850/configure.ac b/sim/v850/configure.ac
index 9a7c1ec3df4b..6d586f194fd0 100644
--- a/sim/v850/configure.ac
+++ b/sim/v850/configure.ac
@@ -5,7 +5,6 @@ AC_CONFIG_MACRO_DIRS([../m4 ../.. ../../config])
 SIM_AC_COMMON
 
 SIM_AC_OPTION_ENDIAN(LITTLE)
-SIM_AC_OPTION_ALIGNMENT(,NONSTRICT_ALIGNMENT)
 SIM_AC_OPTION_RESERVED_BITS
 SIM_AC_OPTION_BITSIZE(32,31)
 
-- 
2.31.1


  parent reply	other threads:[~2021-06-07  5:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07  5:33 [PATCH 1/7] sim: unify platform function & header tests Mike Frysinger
2021-06-07  5:33 ` [PATCH 2/7] sim: unify assert build settings Mike Frysinger
2021-06-07  5:33 ` [PATCH 3/7] sim: unify environment " Mike Frysinger
2021-06-12 17:17   ` [PATCH/committed] sim: ppc: unify env settings too Mike Frysinger
2021-06-07  5:33 ` [PATCH 4/7] sim: split debug/stdio/trace/profile options into dedicated m4 files Mike Frysinger
2021-06-07  5:33 ` [PATCH 5/7] sim: unify debug/stdio/trace/profile build settings Mike Frysinger
2021-06-13  0:09   ` [PATCH 5/7 v2] " Mike Frysinger
2021-06-07  5:33 ` [PATCH 6/7] sim: unify bug & package settings Mike Frysinger
2021-06-13  0:25   ` [PATCH 6/7 v2] " Mike Frysinger
2021-06-07  5:33 ` Mike Frysinger [this message]
2021-06-13  1:19   ` [PATCH 7/7 v2] sim: overhaul alignment settings management Mike Frysinger
2021-06-12 18:40 ` [PATCH/committed] sim: ppc: unify header & function & type tests too Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210607053355.9965-7-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).