diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-06-07 00:54:20 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-06-12 21:14:50 -0400 |
commit | ba307cddcf7e42c5099632dcbad598d8f96044f4 (patch) | |
tree | 4e47888728073d7d203ecc10effb1cff3d59f794 /sim/common | |
parent | 6dd65fc048dbe167b809f687acc6228eb07ecec6 (diff) | |
download | gdb-ba307cddcf7e42c5099632dcbad598d8f96044f4.zip gdb-ba307cddcf7e42c5099632dcbad598d8f96044f4.tar.gz gdb-ba307cddcf7e42c5099632dcbad598d8f96044f4.tar.bz2 |
sim: overhaul alignment settings management
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.
Diffstat (limited to 'sim/common')
-rw-r--r-- | sim/common/ChangeLog | 8 | ||||
-rw-r--r-- | sim/common/Make-common.in | 2 | ||||
-rw-r--r-- | sim/common/sim-config.c | 8 | ||||
-rw-r--r-- | sim/common/sim-config.h | 11 |
4 files changed, 12 insertions, 17 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 25cf339..ff0f4e2 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,5 +1,13 @@ 2021-06-12 Mike Frysinger <vapier@gentoo.org> + * Make-common.in: Delete SIM_ALIGNMENT. + * sim-config.c (sim_config): Change WITH_DEFAULT_ALIGNMENT to + NONSTRICT_ALIGNMENT. + (sim_config_print): Delete WITH_DEFAULT_ALIGNMENT logic. + * sim-config.h (WITH_DEFAULT_ALIGNMENT): Delete. + +2021-06-12 Mike Frysinger <vapier@gentoo.org> + * defs.h: Include ../config.h. Undefine PACKAGE* defines. 2021-06-09 Mike Frysinger <vapier@gentoo.org> diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index f32026e..999b1ee 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@ @@ -222,7 +221,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 df99d6a..c9005f4 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 6ab8d1a..2b6ed3d 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) |