aboutsummaryrefslogtreecommitdiff
path: root/sim/sh
AgeCommit message (Collapse)AuthorFilesLines
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker3-3/+3
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-12-09sim: use ## for automake commentsMike Frysinger1-18/+18
The ## marker tells automake to not include the comment in its generated output, so use that in most places where the comment only makes sense in the inputs.
2021-11-28sim: sh: switch to new target-newlib-syscallMike Frysinger2-25/+23
Use the new target-newlib-syscall module. This is needed to merge all the architectures into a single build, and sh has a custom syscall table for its newlib/libgloss port.
2021-11-15sim: split program path out of argv vectorMike Frysinger1-4/+1
We use the program argv to both find the program to run (argv[0]) and to hold the arguments to the program. Most of the time this is fine, but if we want to let programs specify argv[0] independently (which is possible in standard *NIX programs), this double duty doesn't work. So let's split the path to the program to run out into a separate field by itself. This simplifies the various sim_open funcs too. By itself, this code is more of a logical cleanup than something that is super useful. But it will open up customization of argv[0] in a follow up commit. Split the changes to make it easier to review.
2021-11-13sim: sh: fix switch-bool warningsMike Frysinger1-51/+28
This code triggers -Werror=switch-bool warnings with <=gcc-5 versions. Rework it to use if statements instead as it also simplifies a bit.
2021-11-13sim: sh: rework carry checks to not rely on integer overflowsMike Frysinger1-4/+4
In <=gcc-7 versions, -fstrict-overflow is enabled by default, and that triggers warnings in this code that relies on integer overflows to test for carries. Change the logic to test against the limit directly.
2021-11-06sim: sh: fix conversion of PC to an integerMike Frysinger1-1/+1
On LLP64 targets where sizeof(long) != sizeof(void*), this code fails: sim/sh/interp.c:704:24: error: cast from pointer to integer of different size -Werror=pointer-to-int-cast] 704 | do { memstalls += ((((long) PC & 3) != 0) ? (n) : ((n) - 1)); } while (0) | ^ Since this code simply needs to check alignment, cast it using uintptr_t which is the right type for this.
2021-11-06sim: sh: clean up time(NULL) callMike Frysinger1-1/+1
Casting 0 to a pointer via (long *) doesn't work on LLP64 targets: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] It's also unnecessary here. We can simply pass NULL like every other bit of code does.
2021-11-06sim: sh: break utime logic out of _WIN32 checkMike Frysinger1-1/+8
Some _WIN32 targets provide utime (like mingw), so move the header include out from _WIN32 and under the specific HAVE_UTIME_H check.
2021-11-06sim: sh: drop errno externMike Frysinger1-1/+0
This isn't needed on any reasonable target nowadays, and no other source does this, and breaks with some mingw targets, so punt the extern entirely.
2021-11-06sim: sh: fix isnan redefinition with mingw targetsMike Frysinger1-0/+2
The code assumes that all _WIN32 targets are the same and can define isnan to _isnan. For mingw targets, they provide an isnan define already, so no need for the fallback here.
2021-11-06sim: sh: enable -Werror everywhereMike Frysinger1-3/+0
With most of the warnings fixed in interp.c, we can enable -Werror here too now. There are some -Wmaybe-uninitialized warnings still lurking that look legitimate, but we don't flag those are fatal, and I don't have the expertise to dive into each opcode to figure out the right way to clean them up.
2021-11-06sim: sh: fix uninitialized variable usage with pdmsbMike Frysinger1-1/+1
This block of code relies on i to control which bits to test and how many times to run through the loop, but it never actually initialized it. There is another chunk of code that handles the pdmsb instruction that sets i to 16, so use that here too assuming it's correct. The programming manual suggests this is the right value too, but I am by no means a SuperH DSP expert. The tests are still passing though ...
2021-11-06sim: sh: constify a few read-only lookup tablesMike Frysinger1-6/+6
2021-11-06sim: sh: fix various parentheses warningsMike Frysinger2-11/+11
Add parentheses to a bunch of places where the compiler suggests we do to avoid confusion to most readers.
2021-11-06sim: sh: fix unused-value warningsMike Frysinger1-3/+3
These macro expansions are deliberate in not using the computed value so that they trigger side-effects (possible invalid memory accesses) but while otherwise being noops. Add a (void) cast so the compiler knows these are intentional.
2021-11-06sim: sh: rework register layout with anonymous unions & structsMike Frysinger3-90/+82
Now that we require C11, we can leverage anonymous unions & structs to fix a long standing issue with the SH register layout. The use of sregs.i for sh-dsp has generated a lot of compiler warnings about the access being out of bounds -- it only has 7 elements declared, but code goes beyond that to reach into the fregs that follow. But now that we have anonymous unions, we can reduce the nested names and have sregs cover all of these registers.
2021-11-02sim: hoist gencode & opc2c build rules up to common buildsMike Frysinger2-21/+48
These rules don't depend on the target compiler settings, so hoist the build logic up to the common builds for better parallelization.
2021-11-01sim: sh: reduce -Wno-error scopeMike Frysinger1-2/+2
Only one file in here still generates warnings, so reduce the -Werror disable to that alone now that we require GNU make and can set variables on a per-object basis.
2021-10-31sim: tighten up gencode outputMike Frysinger1-5/+5
Update the gencode rules to use the silent build helpers.
2021-08-17sim: rename ChangeLog files to ChangeLog-2021Mike Frysinger1-0/+0
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-06-22sim: drop configure scripts for simple portsMike Frysinger4-2893/+6
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-21sim: unify hardware settingsMike Frysinger3-54/+5
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-21sim: hw: rework configure option & device selectionMike Frysinger2-38/+30
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-20sim: delete SIM_AC_COMMON macroMike Frysinger4-5/+5
Now that we've moved all content out to the common file, this is empty and can be deleted it entirely.
2021-06-20sim: unify general maintainer settingsMike Frysinger2-124/+0
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-20sim: move sim-inline to the common codeMike Frysinger3-36/+5
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-19sim: unify gettext/intl probing logicMike Frysinger2-85/+0
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-19sim: unify toolchain dependency logicMike Frysinger2-1109/+1
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-19sim: unify toolchain probing logicMike Frysinger2-1360/+26
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-19sim: unify bfd library dependency testing logicMike Frysinger3-7691/+6
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-19sim: unify various library testing logicMike Frysinger2-141/+6
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-18sim: unify -Werror build settingsMike Frysinger3-112/+6
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-18sim: move -Werror disabling to MakefileMike Frysinger4-5/+13
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-17sim: overhaul & unify endian settings managementMike Frysinger4-57/+8
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-16sim: drop obsolete AC_EXEEXT callMike Frysinger2-2/+4
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-16sim: drop arch-specific config.hMike Frysinger3-280/+47
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-15sim: move dv-sockser define to CPPFLAGSMike Frysinger3-8/+5
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-12sim: overhaul alignment settings managementMike Frysinger5-56/+12
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-12sim: unify bug & package settingsMike Frysinger3-87/+2
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-12sim: unify debug/stdio/trace/profile build settingsMike Frysinger2-150/+2
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-12sim: unify environment build settingsMike Frysinger3-32/+2
Move the --sim-enable-environment option up to the common dir so we only test & export it once across all ports.
2021-06-12sim: unify assert build settingsMike Frysinger4-28/+6
Move the --sim-enable-assert option up to the common dir so we only test & export it once across all ports.
2021-06-12sim: unify platform function & header testsMike Frysinger3-552/+6
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-05-29sim: sh: fix a few compiler warningsMike Frysinger2-2/+7
2021-05-17sim: fully merge sim_state_base into sim_stateMike Frysinger2-2/+4
Now that all ports have migrated to the new framework, drop support for the old sim_state_base layout.
2021-05-17sim: invert sim_state storageMike Frysinger2-7/+7
Currently all ports have to declare sim_state themselves in their sim-main.h and then embed the common sim_state_base & sim_cpu in it. This dynamic makes it impossible to share common object code among multiple ports because the core data structure is always different. Let's invert this relationship: common code declares sim_state, and if the port actually needs state on a per-instance basis, it can use the new arch_data field for it. Most ports don't actually use it, so they don't need to declare anything at all. This is the first in a series of changes: it adds a define to select between the old & new layouts, then converts all the ports that don't need custom state over to the new layout.
2021-05-16sim: switch config.h usage to defs.hMike Frysinger2-1/+6
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-16sim: riscv: move __int128 check to configureMike Frysinger3-2/+19
2021-05-14sim: create header namespaceMike Frysinger2-2/+6
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.