aboutsummaryrefslogtreecommitdiff
path: root/sim
AgeCommit message (Collapse)AuthorFilesLines
2024-01-01sim: use gnulib to set nonblocking modeusers/vapier/sim/gnulibMike Frysinger4-33/+19
Replace various custom ad-hoc fcntl/O_NONBLOCK implementations with the gnulib nonblocking module. This makes our code much tidier and portable to other systems (e.g. Windows).
2024-01-01sim: ppc: merge misc igen APIsMike Frysinger10-292/+82
The common igen code provides the same misc APIs as the ppc version, so delete the ppc code and pull in the common one. There is one minor difference: the ppc code has a unique dumpf function. The common code switched to lf_printf for the same functionality, but since that requires changes throughout the igen codebase, delay that cleanup for now so we can merge the rest.
2024-01-01sim: ppc: rework igen error to match commonMike Frysinger10-22/+25
Switch to an ERROR macro and tweak the error signature to match the common igen version in preparation for merging the two implementations.
2024-01-01sim: igen: extend error to take argumentsMike Frysinger1-2/+2
The ppc igen error helper allows arbitrary printf calls, so extend the common one to do the same.
2024-01-01sim: ppc: rename igen max_insn_bit_sizeMike Frysinger3-5/+5
We want to avoid conflicts with the common igen enums. This should get migrated over to the common parsing logic, but for now, switch the name to avoid redefinition.
2024-01-01sim: igen: minor constify logicMike Frysinger1-2/+2
Copy some improvements from the ppc igen code.
2024-01-01sim: ppc: unify igen filter_filename implementationsMike Frysinger7-91/+8
Now that both igen implementations are in the top-level, we can unify the filter_filename implementation between them since they're the same (literally the same code).
2024-01-01sim: ppc: replace filter_filename with lbasenameMike Frysinger2-15/+8
The lbasename function from libiberty provides the same API as this custom function. The common/ code already made the switch, so make the same change to the ppc code to avoid target duplication.
2024-01-01sim: ppc: hoist igen compilation into top-levelMike Frysinger3-153/+325
This simplifies the build a bit (especially for deps in port subdirs), and avoids recursive make. This in turn speeds up the build, and lets us reuse existing build-time vs host-time logic from Makefile.am.
2024-01-01sim: ppc: drop build-config.h usageMike Frysinger8-73/+0
This header is only used by the igen tool, and none of the igen code depends on the configure-time checks. Delete the logic to simplify to prepare for moving it to the local.mk code.
2024-01-01sim: ppc: simplify filter_host.c logicMike Frysinger2-7/+19
Switch this from a build-time generation to a static include. This makes the build rules a bit simpler, especially as we move them to Automake from hand-written makefiles.
2024-01-01sim: igen: remove libigen.a when cleaningMike Frysinger2-8/+8
2024-01-01sim: ppc: drop unused host bitsize settingsMike Frysinger3-5/+0
This is never set anywhere, so it's always empty. Scrub it.
2024-01-01sim: frv: fix cmpb uninitialized variable usageMike Frysinger1-0/+1
This code sets up the cc variable based on the comparison of other registers, but it does so incrementally with bit operations, and it never initializes the cc variable. Initialize it to 0 which the cmpba insn is already doing.
2024-01-01sim: arm: mark local read-only arrays as static constMike Frysinger1-2/+2
Move it into read-only data sections to avoid constructing them on the stack at runtime.
2024-01-01sim: warnings: enable -Wunused-variableMike Frysinger2-2/+2
2024-01-01cpu: or1k: drop unused l.swa flagMike Frysinger2-2/+0
The "flag" argument isn't set/used in this insn, so drop it. This fixes an unused variable warning in the generated sim.
2024-01-01sim: fix pervasive typoTom Tromey9-42/+42
I noticed a typo in a sim constant. This patch fixes it. permenant -> permanent
2023-12-28sim: pru: Fix emulation of carry bitDimitar Dimitrov2-4/+424
The PRU architecture documentation [1] was used for the initial GNU simulator implementation. But recently [2] TI confirmed the carry behaviour was wrongly documented. In reality, the PRU carry behaves like the carry in ARM processors. This patch fixes simulator to align with latest recommendations from TI. The new carry.s test was also validated to pass on real hardware - a BeaglePlay board [3]. That test is a bit long because TI still has not released official updates for the PRU documents. And I wanted to ensure simulator handles all edge cases exactly as the real hardware does. [1] https://www.ti.com/lit/pdf/spruij2 [2] https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1244359/sk-am64b-am64x-pru-assembler-how-works-this-bloody-carry [3] https://www.beagleboard.org/boards/beagleplay Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2023-12-26sim: common: pull in newlib extensions for Linux compatibilityMike Frysinger2-1/+122
Since newlib allows people to opt-in to extra errno names, pull them into our table too. The values don't conflict with each other -- the newlib names & values are distinct from newlib's Linux compatibility.
2023-12-24sim: cris: rvdummy: delete unused variableMike Frysinger1-1/+0
2023-12-24sim: cgen: mark cgen_rtx_error noreturnMike Frysinger1-1/+1
Since this function never returns, mark it as such to fix some unused variable warnings in error code paths. For example, cris triggers: sim/cris/semcrisv10f-switch.c:3558:11: error: variable 'tmp_newval' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] Even though it has an "else" path that calls this error function.
2023-12-24sim: cgen: regenerate decode tablesMike Frysinger9-5827/+5827
Integrate some changes from upstream cgen that tightened up the generated output. Shouldn't be any functional changes here.
2023-12-24sim: sh: refine pwsb & pwad nopsMike Frysinger1-0/+2
Since these insns don't do anything and are effectively ignored, return early to avoid doing any common processing at the end as that requires initializing variables like "res" with something.
2023-12-24sim: sh: fix plds Dz,MACL implementationMike Frysinger1-1/+1
The plds Dz,MACL insn stores the Dz bit into MACL. The current code was storing the "res" variable into Dz and then into MACL, but not setting "res" to anything. Delete that logic and make it match the existing plds Dz,MACH insn.
2023-12-23sim: warnings: rework individual flag disable into dedicated varsMike Frysinger4-51/+157
The -Wshadow=local is too new for some compilers, so move it to a var that we test at configure time.
2023-12-22sim: sh: fix -Wshadow=local warningsMike Frysinger1-2/+2
Rename the var to avoid shadowing & clobbering the higher context.
2023-12-22sim: riscv: fix -Wshadow=local warningsMike Frysinger1-6/+4
Inline the one usage of sd in these macros to avoid possible shadowing.
2023-12-22sim: ppc: fix -Wshadow=local warningsMike Frysinger1-3/+3
Use a local name in the macro to avoid shadowing wherever it's used.
2023-12-22sim: mips: fix -Wshadow=local warningsMike Frysinger1-5/+2
Delete redundant decls when the existing scope has the same var and type available for use.
2023-12-22sim: m68hc11: fix -Wshadow=local warningsMike Frysinger3-4/+3
Delete redundant decls when the existing scope has the same var and type available for use.
2023-12-22sim: m32c: fix -Wshadow=local warningsMike Frysinger2-12/+9
These decoders declare a lot of common variables for use by substeps, and then shadows a few because of how the opc generator is implemented. Easiest way around it is to rename the per-substep vars as needed as anything more would require substantial changes to the opc logic.
2023-12-22sim: iq2000: fix -Wshadow=local warningsMike Frysinger1-1/+1
Delete redundant decls.
2023-12-22sim: h8300: fix -Wshadow=local warningsMike Frysinger1-2/+2
Delete conflicting decls when the existing scope has vars of the same name & type for this exact use.
2023-12-22sim: frv: fix -Wshadow=local warningsMike Frysinger2-4/+3
Delete redundant decls, and rename conflicting vars.
2023-12-22sim: erc32: fix -Wshadow=local warningsMike Frysinger1-32/+31
Rename shadowed vars with different types to avoid confusion.
2023-12-22sim: cris: disable -Wshadow=local in generated mloop filesMike Frysinger2-1/+5
The mloop files include CGEN generated switch files which have some nested assignments that expand into repeated shadowed variables. Fixing this looks fairly non-trivial as it appears to be interplay between the common CGEN code and how this particular set of cris insns are defined. Disable the warning instead. In file included from sim/cris/mloop.in:286: sim/cris/semcrisv10f-switch.c: In function ‘crisv10f_engine_run_full’: sim/cris/semcrisv10f-switch.c:12383:8: error: declaration of ‘opval’ shadows a previous local [-Werror=shadow=local] 12383 | SI opval = tmp_addr; | ^~~~~ sim/cris/semcrisv10f-switch.c:12371:9: note: shadowed declaration is here 12371 | USI opval = ({ SI tmp_addr; | ^~~~~ And the code looks like: USI opval = ({ ... { SI opval = tmp_addr; ... } ... }); Since the CGEN code treats "opval" as an internal variable that the cpu definitions don't have direct access to, the likelihood of this being a real bug is low, so leave it be. The warning is suppressed for more code that is hand written (e.g. the mloop logic), but disabling for the entire file is the easiest way to suppress while keeping it on everywhere else in the sim.
2023-12-22sim: cris: fix -Wshadow=local warningsMike Frysinger2-2/+0
Delete redundant local decls.
2023-12-22sim: common: fix -Wshadow=local warningsMike Frysinger2-3/+3
Rename shadowed vars with different types, and delete redundant decls.
2023-12-22sim: bfin: fix -Wshadow=local warningsMike Frysinger1-3/+3
Rename the shadowed var to avoid confusion with the function argument as to which address this code is using.
2023-12-22sim: arm: fix -Wshadow=local warningsMike Frysinger3-46/+30
Remove duplicate nested variable declarations, rename some to avoid confusion when the type is different or the original value should be retained, and fix some weirdness with nested enums in structs.
2023-12-22sim: aarch64: fix -Wshadow=local warningsMike Frysinger1-21/+21
These functions have local vars named "val" of type float, and then create nested vars named "val" of type double. This is a bit confusing and causes build time warnings.
2023-12-22sim: cgen: regenerate decode tables to avoid shadow warningsMike Frysinger9-548/+548
Use latest cgen to regenerate the decode tables which has some shadow warning fixes with "val" variables.
2023-12-22sim: cris: regen cgen decoders to fix build warnings [PR sim/31181]Mike Frysinger2-211/+211
Bug: https://sourceware.org/PR31181
2023-12-21sim: ppc: igen: fix -G handlingMike Frysinger1-2/+9
We weren't using the enable_p flag to see whether the option should be enabled or disabled, and we weren't breaking out when done parsing.
2023-12-21sim: warnings: enable -Wreturn-typeMike Frysinger2-0/+2
Older versions of gcc support this warning flag. We're already clean.
2023-12-21sim: warnings: fix -Wreturn-mismatch typoMike Frysinger2-2/+2
2023-12-21sim: m32c: fix initial #line number in generated codeMike Frysinger1-1/+1
This emits #line 2 for the first line in the output when it should be 1.
2023-12-21sim: mloop: add #line pragmas everywhereMike Frysinger9-0/+63
This will make compiler diagnostics much better with generated code so people can understand the original source file.
2023-12-21sim: common: add $LINENO rewriting support to genmloop scriptsMike Frysinger4-22/+83
The generated mloop files can trigger compile time warnings. It can be difficult to see/understand where the original code is coming from as all the diagnostics point to the generated output. Using #line pragmas, we can point people to the original source files. Unfortunately, this code is written in POSIX shell, and that lacks support for line number tracking. The $LINENO variable, even when available, can just be plain wrong. For example, when using dash and subshells, $LINENO can end up having negative values. Add a wrapper script that will uses awk to rewrite the $LINENO variable to the right value to avoid all that. Basically lineno.sh takes an input script, rewrites all uses of $LINENO into the actual line number (and $0 into the original file name), and then executes the temporary script. This commit doesn't actually add #line pragmas to any files. That comes next.