Commit Graph

761 Commits

Author SHA1 Message Date
Mike Frysinger
ac9b6df28f sim: igen: tighten up build output
Add a new stamp helper for quiet builds, and don't dump the command
line options when it runs.  That isn't standard tool behavior, and
doesn't really seem necessary in any way.
2021-10-31 00:55:50 -04:00
Mike Frysinger
b6143d3162 sim: silence stamp touch rules
We pretty much never care about these stamp touches, so silence them.
Also switch to using $@ when it makes sense.
2021-10-31 00:46:28 -04:00
Mike Frysinger
4f2b181ecb sim: standardize move-if-change rules
Use the srcroot path and make them all silent.
2021-10-31 00:39:40 -04:00
Mike Frysinger
bdcbd1b67f sim: mips/v850: remove redundant variable setup
The common/Make-common.in fragment already provides these variables.
2021-10-31 00:23:36 -04:00
Mike Frysinger
7eb2a68f28 sim: mips: delete unused PSIZE define
It's unclear what this define is for as it appears to be unused, and
has never been used in the history of the mips sim.  Delete it to tidy
up, and to fix build errors for Windows targets that have a standard
"PSIZE" struct in their system headers.  This doesn't show up yet as
most sim files don't include many system headers, but enabling sockser
code for mingw uncovers the conflict.

Unfortunately the error produced by gcc is inscrutable, but running
it through the preprocessor manually manages to provide a pointer to
the underlying issue.

$ i686-w64-mingw32-gcc ... -c -o dv-sockser.o ../../../../sim/mips/../common/dv-sockser.c
<command-line>: error: expected identifier or '(' before numeric constant
In file included from /usr/i686-w64-mingw32/usr/include/windows.h:71,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from ../../../../sim/mips/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/wingdi.h:2934:59: error: unknown type name 'LPSIZE'; did you mean 'LPSIZEL'?
 2934 |   WINGDIAPI WINBOOL WINAPI GetAspectRatioFilterEx(HDC hdc,LPSIZE lpsize);
      |                                                           ^~~~~~
      |                                                           LPSIZEL
...

$ i686-w64-mingw32-gcc ... -E -dD -o dv-sockser.i ../../../../sim/mips/../common/dv-sockser.c
$ i686-w64-mingw32-gcc -c dv-sockser.i
In file included from /usr/i686-w64-mingw32/usr/include/windows.h:69,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from ../../../../sim/mips/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/windef.h:104:9: error: expected identifier or '(' before numeric constant
  104 | } SIZE,*PSIZE,*LPSIZE;
      |         ^~
2021-09-09 00:34:21 -04:00
Mike Frysinger
9335d9f823 sim: rename ChangeLog files to ChangeLog-2021
Now that ChangeLog entries are no longer used for sim patches,
this commit renames all relevant sim ChangeLog to ChangeLog-2021,
similar to what we would do in the context of the "Start of New
Year" procedure.

The purpose of this change is to avoid people merging ChangeLog
entries by mistake when applying existing commits that they are
currently working on.

Also throw in a .gitignore entry to keep people from adding new
ChangeLog files anywhere in the sim tree.
2021-08-17 20:27:36 -04:00
Mike Frysinger
7eb1f99ada sim: unify reserved instruction bits settings
Move these options up to the common dir so we only test & export
them once across all ports.

The setting only affects igen based ports, and they were turning
this on by default, so keep the default in place.
2021-07-01 20:53:00 -04:00
Mike Frysinger
b79efe264f sim: unify scache settings
The cgen scache module is enabled by every cgen port, and with the
same default value of 16k (which matches the common default value).
Let's pull this option out of the individual ports (via CPPFLAGS)
and into the common code (via config.h).

The object itself is compiled only for cgen ports atm, so that part
doesn't change.  The scache code is initialized dynamically via the
modules.c logic.  That's why the profile code needs an additional
CGEN_ARCH check.

This will allow us to collapse arch configure files more.  Merging
the source files will require more future work, but integrating the
cgen & non-cgen worlds itself will take a lot.
2021-06-30 13:33:18 -04:00
Mike Frysinger
d414eb3e7f sim: move default model to the runtime sim state
This kills off another compile-time option by moving the setting to
the individual arch runtimes.  This will allow dynamic selection by
the arch when doing a single build with multiple arches.

The sim_model_init rework is a little funky.  In the past it was
disabled entirely if no default model was set.  We maintain the
spirit of the logic by gating the fallback logic on whether the
port has defined any models.
2021-06-30 02:57:45 -04:00
Mike Frysinger
36bb57e40c sim: drop configure scripts for simple ports
These ports only use the pieces that have been unified, so we can
merge them into the common configure script and get rid of their
unique one entirely.

We still compile & link separate run programs, and have dedicated
subdir Makefiles, but the configure script portion is merged.
2021-06-22 19:26:13 -04:00
Mike Frysinger
456ef1c1d4 sim: unify hardware settings
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-21 22:20:18 -04:00
Mike Frysinger
be0387eed0 sim: hw: rework configure option & device selection
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.
2021-06-21 21:36:51 -04:00
Mike Frysinger
3eda63f2e4 sim: delete SIM_AC_COMMON macro
Now that we've moved all content out to the common file, this is
empty and can be deleted it entirely.
2021-06-20 00:39:38 -04:00
Mike Frysinger
3a829bc50c sim: unify general maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports.  This takes a page from the cgen maint
logic to make $(MAINT) work for non-automake Makefiles which will
allow us to merge it together.
2021-06-20 00:31:27 -04:00
Mike Frysinger
d73f39ee43 sim: move sim-inline to the common code
This will allow us to build the common code with the same inline
settings as the arch subdirs, and only do the test once.
2021-06-20 00:12:11 -04:00
Mike Frysinger
ce3ec98acd sim: unify gettext/intl probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 16:18:07 -04:00
Mike Frysinger
bc56166f66 sim: unify toolchain dependency logic
The common dir is already probing this info since it's using automake,
so pass it down to the subdirs so they don't have to probe it at all.
2021-06-19 16:07:31 -04:00
Mike Frysinger
d3562f83a7 sim: unify toolchain probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 16:01:37 -04:00
Mike Frysinger
b5689863bd sim: unify bfd library dependency testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 01:08:39 -04:00
Mike Frysinger
17a5da800d sim: mips: drop unused AC_PATH_X call
We don't use anything from X, so no sense in probing the env.
2021-06-19 01:03:20 -04:00
Mike Frysinger
07490bf81d sim: unify various library testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 01:01:21 -04:00
Mike Frysinger
47ce766a8b sim: unify -Werror build settings
Move these options up to the common dir so we only test & export
them once across all ports.  It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.
2021-06-18 10:25:04 -04:00
Mike Frysinger
982c3a65ca sim: move -Werror disabling to Makefile
For the ports that still don't build with -Werror, rather than disable
the flag at configure time, do it at make time.  This will allow us to
unify these tests in the common sim configure script.
2021-06-18 10:15:15 -04:00
Mike Frysinger
1fef66b0dc sim: split sim-signal.h include out
The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.
2021-06-18 00:50:14 -04:00
Mike Frysinger
f9a4d54332 sim: overhaul & unify endian settings management
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, the arch is
expected to support both, and the value will be probed based on the
user runtime options or the input program.

Only two arches today set the default value (bpf & mips).  We can
probably let this go as it only shows up in one scenario: the sim
is invoked, but with no inputs, and no user endian selection.  This
means bpf will not behave like the other arches: an error is shown
and forces the user to make a choice.  If an input program is used
though, we'll still switch the default to that.  This allows us to
remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting.

For the ports that set a "wire" endian, move it to the runtime init
of the respective sim_open calls.  This allows us to change the
WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting
if they want to force a specific endianness.

With all the endian logic moved to runtime selection, we can move
the configure call up to the common dir so we only process it once
across all ports.

The ppc arch was picking the wire endian based on the target used,
but since we weren't doing that for other biendian arches, we can
let this go too.  We'll rely on the input selecting the endian, or
make the user decide.
2021-06-17 23:20:13 -04:00
Mike Frysinger
b80d447580 sim: mips: add printf attribute to trace func
This helps catch format errors in code, although they're all clean
at this point already.
2021-06-16 01:56:22 -04:00
Mike Frysinger
6828a30253 sim: mips: rework dynamic printf logic to avoid compiler warnings
The compiler doesn't like passing non-constant strings to printf
functions, so tweak the code to always pass one in.  This code is
a little more verbose, but it's probably the same performance.

The macro usage is a bit ugly, but maybe less than copying &
pasting the extended conditional format logic.
2021-06-16 01:55:31 -04:00
Mike Frysinger
df32b446c3 sim: mips: tweak buffer sign
This model uses unsigned char buffers, but this temporary pointer is
declared as signed.  Switch it to unsigned since it's just a temporary
variable to hold the new pointer.
2021-06-16 01:53:09 -04:00
Mike Frysinger
7b2298cbd8 sim: mips: fix uninitialized register use
In the default case, this code will read from this variable before
it is initialized as a dummy access.  Set it to 0 to fix the compiler
warning.
2021-06-16 01:51:32 -04:00
Mike Frysinger
a8a3d90792 sim: drop obsolete AC_EXEEXT call
The current autoconf 2.69 defines this to nothing because the logic
in AC_PROG_CC takes care of it all the time now.  Delete the call.
2021-06-16 01:29:41 -04:00
Mike Frysinger
dae666c968 sim: mips: fix format warnings when setting up memory
The majority of these inputs are not long's, so don't use %lx.
This fixes compiler warnings about type mismatches.
2021-06-16 00:50:56 -04:00
Mike Frysinger
52d37d2c91 sim: drop arch-specific config.h
All of the settings in here are handled by the common top-level
config.h, so drop the individual arch-config.h files entirely.

This will also help guarantee that we don't add any new arch
specific defines that would affect common code which will help
with the effort of unifying them.
2021-06-16 00:22:53 -04:00
Mike Frysinger
bcaa61f7c8 sim: move dv-sockser define to CPPFLAGS
This is the only define left in m4/ that is not in the common config.h,
so move it to sim_hw_cflags so we can drop the arch-specific config.h.
2021-06-15 23:27:14 -04:00
Mike Frysinger
ba307cddcf 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.
2021-06-12 21:14:50 -04:00
Mike Frysinger
6dd65fc048 sim: unify bug & package settings
Move these options up to the common dir so we only test & export
them once across all ports.  The AC_INIT macro does a lot of the
heavy lifting already which allows further simplification.
2021-06-12 20:24:08 -04:00
Mike Frysinger
04381273a9 sim: unify debug/stdio/trace/profile build settings
Move these options up to the common dir so we only test & export
them once across all ports.

The ppc code needs a little extra care with its trace settings as
it's not exactly the same API as the common code.  The other knobs
are the same though.
2021-06-12 20:07:57 -04:00
Mike Frysinger
5ea4547402 sim: unify environment build settings
Move the --sim-enable-environment option up to the common dir so we
only test & export it once across all ports.
2021-06-12 11:01:57 -04:00
Mike Frysinger
dba333c1e4 sim: unify assert build settings
Move the --sim-enable-assert option up to the common dir so we only
test & export it once across all ports.
2021-06-12 10:58:22 -04:00
Mike Frysinger
b15c5d7a51 sim: unify platform function & header tests
Move the various platform tests up a level to avoid duplication
across the ports.  When building multiple versions, this speeds
things up a bit.

For now we move the obvious stuff up a level, but we don't turn
own the config.h entirely just yet -- we still have some tests
related to libraries that need consideration.
2021-06-12 10:45:36 -04:00
Mike Frysinger
a55b92be28 sim: igen: harmonize tool variables
Separate the name of the igen program from the options used to run it.
This allows us to avoid duplicating ../igen/igen in Makefiles and reuse
the existing setting in the common Makefile.  This also allows us to
easily harmonize the use of EXEEXT between igen/local.mk and the common
makefiles when cross-compiling for e.g. Windows.
2021-06-08 00:57:58 -04:00
Mike Frysinger
8ea881d9e3 sim: mips: fix build w/out dv-sockser
Make sure we don't fail to build when dv-socker is unavailable.
2021-05-29 15:29:54 -04:00
Faraz Shahbazker
168671c14c sim: mips: Add shadow mappings for 32-bit memory address space
32-bit MIPS programs run on the 64-bit simulator model in 64-bit
sign-extended space. The mapping from 64-bit sign-extended addresses to
32-bit addresses was removed by commit
26f8bf63bf, breaking the 64-bit simulator
model. Add shadow mappings from 64-bit sign extended address space to
32-bit address spaces, in lieu of the AddressTranslation function.

2021-05-04  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/mips/ChangeLog:
	* interp.c (sim_open): Add shadow mappings from 32-bit
	address space to 64-bit sign-extended address space.
2021-05-22 11:32:35 +05:30
Faraz Shahbazker
b312488f10 sim: mips: Only truncate sign extension bits for 32-bit target models
64-bit BFD for MIPS applies a standard sign extension on all addresses
assuming 64-bit target.  These bits are required for 64-bit and can only
be safely truncated for 32-bit target models. This partially reverts commit
b36d953bce

The sign-extension logic modeled by BFD is an integral part of the
MIPS64 architecture spec. It appears in the virtual address map, where
sign extension allows for 32-bit compatibility segments [1] with 64-bit
addressing. Truncating these addresses prematurely (commit
models (-DWITH_TARGET_WORD_BITSIZE=64).

In the ISA itself, direct addressing (Load-Upper-Immediate) and indirect
addressing (Load-Word) both automatically sign-extend their results. These
instructions regenerate the sign-extended addresses even if we don't start
with one (see pr gdb/19447).

Moreover, some instructions like ADD*/SUB* have unpredictable behaviour when
an operand is not correctly sign extended [3]. This affects PC-relative
addressing in particular, so arithmetic on the link-address generated in the
return address register by a jump-and-link is no longer possible, neither is
the use of the PC-relative addressing instructions provided by MIPSR6.

[1] "MIPS64 Architecture for Programmers Volume III: The MIPS64
    Privileged Resource Architecture", Document Number: MD00091,
    Revision 6.02, December 10, 2015, Section 4.3 "Virtual Address
    Spaces", pp. 29-31
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00091-2B-MIPS64PRA-AFP-06.03.pdf

[2] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Document Number: MD00087,
    Revision 6.06, December 15, 2016, Section 3.2 "Alphabetical
    List of Instructions", pp. 321
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-6.06.pdf

[3] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64
    Instruction Set Reference Manual", Document Number: MD00087,
    Revision 6.06, December 15, 2016, Section 3.2 "Alphabetical
    List of Instructions", pp. 56
https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS64BIS-AFP-6.06.pdf

2021-04-23  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/mips/ChangeLog:
	* interp.c (sim_create_inferior): Only truncate sign extension
	bits for 32-bit target models
.
2021-05-22 11:30:57 +05:30
Mike Frysinger
f4fdd84587 sim: fully merge sim_state_base into sim_state
Now that all ports have migrated to the new framework, drop support
for the old sim_state_base layout.
2021-05-17 01:05:08 -04:00
Mike Frysinger
8ea7241cf3 sim: mips: invert sim_state storage 2021-05-17 01:00:08 -04:00
Mike Frysinger
6df01ab8ab sim: switch config.h usage to defs.h
The defs.h header will take care of including the various config.h
headers.  For now, it's just config.h, but we'll add more when we
integrate gnulib in.

This header should be used instead of config.h, and should be the
first include in every .c file.  We won't rely on the old behavior
where we expected files to include the port's sim-main.h which then
includes the common sim-basics.h which then includes config.h.  We
have a ton of code that includes things before sim-main.h, and it
sometimes needs to be that way.  Creating a dedicated header avoids
the ordering mess and implicit inclusion that shows up otherwise.
2021-05-16 22:38:41 -04:00
Mike Frysinger
79633c125e sim: riscv: move __int128 check to configure 2021-05-16 00:04:17 -04:00
Mike Frysinger
df68e12b3b sim: create header namespace
The gdb/callback.h & gdb/remote-sim.h headers have nothing to do with
gdb and are really definitions for the libsim API under the sim/ tree.
While gdb uses those headers as a client, it's not specific to it.  So
create a new sim/ namespace and move the headers there.
2021-05-14 00:41:05 -04:00
Mike Frysinger
77c0fdb7ff sim: mips: include stdlib.h for memory prototypes
This file uses free() and friends, so include it to fix missing
prototype warnings.
2021-05-04 22:04:01 -04:00
Mike Frysinger
9b1af85c78 sim: mips: always enable device models
There's no need to restrict these to only specific targets as the user
can select them at runtime if they want them.  Always build them so we
can improve build coverage too.
2021-05-04 22:02:37 -04:00