Commit Graph

4679 Commits

Author SHA1 Message Date
Dimitar Dimitrov
7bee555bb7 sim: pru: Fix behaviour when loop count is zero
If the counter for LOOP instruction is provided by a register with
value zero, then the instruction must cause a PC jump directly to the
loop end.  But in that particular case simulator must not initialize
its internal loop variables, because loop body will not be executed.
Instead, simulator must obtain the loop's end address directly from
the LOOP instruction.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-11-12 15:10:07 +02:00
Mike Frysinger
36895e5335 sim: igen: cleanup archaic pointer-to-long printf casts
Use proper %p to printf a pointer instead of casting it to long and
using 0x%lx.  It's cleaner, more correct, and doesn't break on LLP64.
2022-11-11 22:08:14 +07:00
Mike Frysinger
897fc27b25 sim: v850: rename v850.dc to align with other ports
Other arches use the .dc extension for the instruction decode table.
2022-11-11 01:42:29 +07:00
Mike Frysinger
ef7c5fd15d sim: igen: fix hang when decoding boolean rule constants
The parser for boolean rules fails to skip over the , separator in
the options which makes it hang forever.  No dc files in the tree
use boolean rules atm which is why no one noticed.
2022-11-11 01:40:53 +07:00
Mike Frysinger
16cceb84be sim: igen: mark error func as noreturn since it exits 2022-11-11 01:40:35 +07:00
Mike Frysinger
c0c7e6ce2a sim: igen: mark output funcs with printf attribute
... and fix the legitimate bug that it catches.
2022-11-11 01:40:13 +07:00
Mike Frysinger
fa654e74f2 sim: igen: constify various func arguments 2022-11-11 01:39:49 +07:00
Mike Frysinger
689c2b4b65 sim: ppc: rename ppc-instructions to powerpc.igen
To make it clear this is an input to the igen tool, rename it with an
igen extension.  This matches the other files in the ppc dir (altivec
& e500 igen files), and the other igen ports (mips, mn10300, v850).
2022-11-11 01:38:42 +07:00
Mike Frysinger
64713044a4 sim: ppc: drop old makefile fragment
Support for these files was dropped almost 30 years ago, but the ppc
arch was missed.  Clean that up now too.
2022-11-10 14:45:47 +07:00
Mike Frysinger
7d95d825b3 sim: ppc: drop support for dgen -L option
Nothing passes this to dgen, and even if it did, nothing would happen
because the generated spreg.[ch] files don't include any references
back to the original data table.  So drop it to simplify.
2022-11-10 14:27:41 +07:00
Mike Frysinger
40466c48e8 sim: ppc: collapse is_readonly & length switch tables heavily
Since we know we'll return 0 by default, we don't have to output case
statements for readonly or length fields whose values are also zero.
This is the most common case by far and thus generates a much smaller
switch table in the end.
2022-11-10 14:27:41 +07:00
Mike Frysinger
1eff12f75a sim: ppc: collapse is_valid switch table more
Instead of writing:
  case 1:
    return 1;
  case 2:
    return 1;
  ...etc...

Output a single return so we get:
  case 1:
  case 2:
  case ...
    return 1;

This saves ~100 lines of code.  Hopefully the compiler was already
smart enough to optimize to the same code, but if not, this probably
helps there too :).
2022-11-10 14:27:40 +07:00
Mike Frysinger
99961e814f sim: ppc: pull default switch return out
This saves a single line for the same result.  By itself, it's not
interesting, but we can further optimize the generated output and
completely omit the switch table in some cases.  Which we'll do in
follow up commits.
2022-11-10 14:27:40 +07:00
Mike Frysinger
23af236b63 sim: ppc: constify spreg table
This internal table is only ever read, so constify it.
2022-11-10 14:27:40 +07:00
Mike Frysinger
3abad2f6a6 sim: igen: add missing newline to various error messages
The error() function expects a trailing newline in its message.
Most callers do this already, so adding it to the few that don't.
2022-11-10 00:29:27 +07:00
Mike Frysinger
959550953e sim: restore lstat & mkdir func checks
When merging ppc configure checks into the top-level, these 2 funcs
were accidentally dropped (probably due to incorrect resolution of
conflicts).  Restore them since the ppc code utilizes them both.
2022-11-10 00:19:45 +07:00
Mike Frysinger
31b40f11f1 sim: ppc: drop obsolete USE_WIN32API check
This controls only one thing: how to call mkdir().  The gnulib code
already has a mkdir module that provides this exact logic for us, so
punt the code entirely.
2022-11-10 00:13:36 +07:00
Mike Frysinger
c2264c8f78 sim: ppc: add missing parens with e500 macro
This macro expansion was missing a set of outer-most parenthesis which
some compilers would complain about depending on how the macro is used.
This is just standard good macro hygiene too.
2022-11-09 22:34:16 +07:00
Mike Frysinger
adcc07b94f sim: ppc: drop useless linking of helper tools
We've never run these helper programs directly.  The igen program
includes the relevant source files directly and runs the code that
way.  So stop wasting developer CPU time linking programs that are
never run.  We leave the rules in place for people who need to test
and debug the specific bits of code every now & then.
2022-11-09 22:34:16 +07:00
Mike Frysinger
2756004fe7 sim: mips: call Unpredictable instead of setting bogus values [PR sim/29276]
The intention of this code seems to be to indicate that this insn
should not be used and produces undefined behavior, so instead of
setting registers to bogus values, call Unpredictable.  This fixes
build warnings due to 32-bit/64-bit type conversions, and outputs
a log message for users at runtime instead of silent corruption.

Bug: https://sourceware.org/PR29276
2022-11-08 14:55:50 +07:00
Mike Frysinger
4faede6126 sim: riscv: add missing AC_MSG_RESULT call
Previous commit in here forgot to include this.
2022-11-07 23:44:36 +07:00
Mike Frysinger
871aa3b9ee sim: v850: drop subdir configure logic
We've been using this only to set the default word size to 32.  We
can easily move this into the makefile via a -D compiler flag and
clean up the build logic quite a bit.
2022-11-07 23:26:07 +07:00
Mike Frysinger
4cf83930c1 sim: mn10300: drop subdir configure logic
We've been using this only to set the default word size to 32.  We
can easily move this into the makefile via a -D compiler flag and
clean up the build logic quite a bit.
2022-11-07 23:25:48 +07:00
Mike Frysinger
763b20abcb sim: or1k: drop subdir configure logic
We've been using this only to set the default word size to 32.  We
can easily move this into the makefile via a -D compiler flag and
clean up the build logic quite a bit.
2022-11-07 23:25:27 +07:00
Mike Frysinger
ee79c7df30 sim: bpf: drop subdir configure logic
We've been using this only to set the default word size to 64.  We
can easily move this into the makefile via a -D compiler flag and
clean up the build logic quite a bit.
2022-11-07 23:25:01 +07:00
Mike Frysinger
1787fcc45a sim: riscv: drop subdir configure logic
We've been using this only to set the default word size to 32-vs-64
based on the $target.  We can easily merge this with the top-level
configure script to clean things up a bit.
2022-11-07 23:24:46 +07:00
Mike Frysinger
23912acd40 sim: .gdbinit: generate for all arch subdirs
This was being skipped for ports that had a recursive configure,
but we want it for them too.
2022-11-07 21:52:47 +07:00
Mike Frysinger
2ba09f42f1 sim: build: add a proper var for enabled arches
The install code was using $SUBDIRS to track all enabled arches.  This
works, but isn't great if we want to add a subdir that isn't an arch
port, or as we merge the subdirs into the top-level.  Create a new var
explicitly to track the list of enabled arches instead.
2022-11-07 21:51:11 +07:00
Mike Frysinger
93e0ec910a sim: build: respect AM_MAKEFLAGS when entering subdirs
This doesn't matter right now, but it will as we add more flags to
the recursive make step to pass state down.
2022-11-06 21:48:42 +07:00
Mike Frysinger
1e5482d568 sim: build: stop passing down SIM_PRIMARY_TARGET
This was needed when the install step was run in subdirs, but now
that we process that entirely in the top-level, we don't need to
pass this down, so drop it.
2022-11-06 21:44:58 +07:00
Mike Frysinger
5a9886170b sim: fix readline linkage
Now that we link programs in the top dir instead of the arch subdir,
update the readline library path to be relative to the top dir.
2022-11-05 21:21:31 +07:00
Mike Frysinger
c95bd9111e sim: use libtool to install programs
Now that we use libtool to link, we have to use it to install instead
of keeping the manual logic so we don't install wrapper shell scripts.
2022-11-05 20:28:14 +07:00
Mike Frysinger
e5f7bc2935 sim: bfin: move linux-fixed-code.h to top-level 2022-11-05 20:02:15 +07:00
Mike Frysinger
c0c25232da sim: run: move linking into top-level
Automake will run each subdir individually before moving on to the next
one.  This means that the linking phase, a single threaded process, will
not run in parallel with anything else.  When we have to link ~32 ports,
that's 32 link steps that don't take advantage of parallel systems.  On
my really old 4-core system, this cuts a multi-target build from ~60 sec
to ~30 sec.  We eventually want to move all compile+link steps to this
common dir anyways, so might as well move linking now for a nice speedup.

We use noinst_PROGRAMS instead of bin_PROGRAMS because we're taking care
of the install ourselves rather than letting automake process it.
2022-11-05 20:00:56 +07:00
Mike Frysinger
59d8576e4f sim: build: add uninstall support
This never worked before, but adding it to the common top-level dir
is pretty easy to do now that we're unified.
2022-11-05 16:26:15 +07:00
Mike Frysinger
63bf33ff90 sim: build: move install steps to the top-level
We still have to maintain custom install rules due to how we rename
arch-specific files with an arch prefix in their name, but we can at
least unify the logic in the common dir.
2022-11-05 16:26:08 +07:00
Mike Frysinger
cb9bdc02fd sim: cris: move rvdummy linking to top-level
This is only used by `make check`, so we can move it out of the
default build too.
2022-11-05 11:22:38 +07:00
Mike Frysinger
bfc96c1039 sim: build: add SIM_HW_CFLAGS to top-level build too
This matches what we do with targets already.
2022-11-05 10:33:37 +07:00
Mike Frysinger
fc9c0bdce0 sim: drop unused SIM_HARDWARE variable
This hasn't been used since the refactor way back in commit
f872d0d643 ("Only enable H/W
on some mips targets."), so punt it.
2022-11-05 10:31:15 +07:00
Mike Frysinger
682a2a82e4 sim: adjust sim_hw options style
We use uppercase for other variables, and are already turning it to
uppercase in the arch-subdir.mk, so convert it in the configure step.
2022-11-05 10:23:28 +07:00
Mike Frysinger
0fa7ad4eb4 sim: ppc: drop unused /dev/zero logic
Nothing in the tree checks this option, or has checked for decades.
The pre-cvs-import ChangeLog suggests this was added & removed back
then, but can't be sure as that history doesn't exist in the VCS.
2022-11-05 10:04:30 +07:00
Mike Frysinger
1b2af6a41e sim: ppc: delete unused host bitsize settings
Nothing checks this define anywhere, so drop all the logic.  We don't
want this to be a configure option in the first place as all such usage
should be automatic & following proper types.
2022-11-05 10:04:23 +07:00
Mike Frysinger
319e41e83a sim: ppc: inline the sim-packages option
This has only ever had a single option that's enabled by default.
The objects it adds are pretty small and don't add overhead at
runtime if it isn't used, so just enable it all the time to make
the build code simpler.
2022-11-05 10:04:22 +07:00
Mike Frysinger
b0119424d1 sim: rx: drop unused $arch setting
This is only needed for CGEN ports which RX isn't, so drop it.
2022-11-04 14:23:50 +07:00
Mike Frysinger
9146585a05 sim: build: remove various obsolete generation dep variables
These manual settings were necessary when we weren't doing automatic
header dependency tracking.  That was changed a while ago, and we use
automake now to do it all for us.  As a result, many of these vars
aren't even referenced anymore.

Further, some of the source file generation (e.g. .c files, or igen,
or cgen outputs) were moved to the common automake build, and it takes
care of dependency tracking for us with the object files.
2022-11-04 13:58:42 +07:00
Mike Frysinger
c55c1f6e9d sim: don't hardcode -ldl for SDL support
Since we use AC_SEARCH_LIBS to find dlopen, we don't need to hardcode
-ldl when using SDL ourselves.
2022-11-04 13:50:37 +07:00
Mike Frysinger
0dea8b8d9f sim: drop -lm from SIM_EXTRA_LIBS
We have configure tests for this in the top-level configure script
to link this when necessary, so we don't need to explicitly list it
for specific ports.
2022-11-04 07:42:31 +07:00
Mike Frysinger
051081585e sim: build: change AC_CHECK_LIB to AC_SEARCH_LIBS
With more C libraries moving functions entirely into the main -lc,
change the AC_CHECK_LIB calls to AC_SEARCH_LIBS so we look in there
first and avoid extra linkage when possible.
2022-11-04 07:42:31 +07:00
Mike Frysinger
49ea4303bf sim: build: drop duplicate $(LIBS) usage
COMMON_LIBS is set to $(LIBS), and CONFIG_LIBS is set to that plus
@LIBS@.  This leds to the values being used twice.  Inline the
CONFIG_LIBS variable without @LIBS@ since it's used only once.
2022-11-04 07:42:31 +07:00
Mike Frysinger
89cf99a910 sim: build: switch to bfd & opcodes libtool linker scripts
Now that we use libtool to link, we don't need to duplicate all the
libs that bfd itself uses.  This simplifies the configure & Makefile.
2022-11-04 07:42:31 +07:00