Commit Graph

5177 Commits

Author SHA1 Message Date
Mike Frysinger
2363ba65d7 sim: igen: remove libigen.a when cleaning 2024-01-01 15:51:25 -05:00
Mike Frysinger
22a09a1a33 sim: ppc: drop unused host bitsize settings
This is never set anywhere, so it's always empty.  Scrub it.
2024-01-01 14:52:16 -05:00
Mike Frysinger
f793be444c sim: frv: fix cmpb uninitialized variable usage
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-01 10:56:08 -05:00
Mike Frysinger
361a6d49c6 sim: arm: mark local read-only arrays as static const
Move it into read-only data sections to avoid constructing them on the
stack at runtime.
2024-01-01 10:53:15 -05:00
Mike Frysinger
58d38850b6 sim: warnings: enable -Wunused-variable 2024-01-01 10:51:50 -05:00
Mike Frysinger
fa99355b56 cpu: or1k: drop unused l.swa flag
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-01 10:51:23 -05:00
Tom Tromey
cbbb73f4f9 sim: fix pervasive typo
I noticed a typo in a sim constant.  This patch fixes it.
	permenant -> permanent
2024-01-01 10:44:13 -05:00
Dimitar Dimitrov
fcd5cdd5ae sim: pru: Fix emulation of carry bit
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-28 09:09:13 +02:00
Mike Frysinger
a70dcdebbd sim: common: pull in newlib extensions for Linux compatibility
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-26 22:53:31 -05:00
Mike Frysinger
59b6dbff95 sim: cris: rvdummy: delete unused variable 2023-12-24 05:26:49 -05:00
Mike Frysinger
9e6855c7cb sim: cgen: mark cgen_rtx_error noreturn
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-24 05:09:28 -05:00
Mike Frysinger
aea0b94653 sim: cgen: regenerate decode tables
Integrate some changes from upstream cgen that tightened up the
generated output.  Shouldn't be any functional changes here.
2023-12-24 04:07:32 -05:00
Mike Frysinger
43fbcdcd03 sim: sh: refine pwsb & pwad nops
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-24 04:00:04 -05:00
Mike Frysinger
fed277fe15 sim: sh: fix plds Dz,MACL implementation
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-24 03:56:00 -05:00
Mike Frysinger
4da6be3f1a sim: warnings: rework individual flag disable into dedicated vars
The -Wshadow=local is too new for some compilers, so move it to a var
that we test at configure time.
2023-12-23 01:21:23 -05:00
Mike Frysinger
62544b0cf1 sim: sh: fix -Wshadow=local warnings
Rename the var to avoid shadowing & clobbering the higher context.
2023-12-22 23:29:19 -05:00
Mike Frysinger
f0fcc327e3 sim: riscv: fix -Wshadow=local warnings
Inline the one usage of sd in these macros to avoid possible shadowing.
2023-12-22 23:29:19 -05:00
Mike Frysinger
5cc45e2384 sim: ppc: fix -Wshadow=local warnings
Use a local name in the macro to avoid shadowing wherever it's used.
2023-12-22 23:29:19 -05:00
Mike Frysinger
d31fd3f617 sim: mips: fix -Wshadow=local warnings
Delete redundant decls when the existing scope has the same var and
type available for use.
2023-12-22 23:29:19 -05:00
Mike Frysinger
c6f30b8791 sim: m68hc11: fix -Wshadow=local warnings
Delete redundant decls when the existing scope has the same var and
type available for use.
2023-12-22 23:29:19 -05:00
Mike Frysinger
e4e3a80911 sim: m32c: fix -Wshadow=local warnings
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-22 23:29:19 -05:00
Mike Frysinger
2d351bda2f sim: iq2000: fix -Wshadow=local warnings
Delete redundant decls.
2023-12-22 23:29:19 -05:00
Mike Frysinger
a42661395e sim: h8300: fix -Wshadow=local warnings
Delete conflicting decls when the existing scope has vars of the same
name & type for this exact use.
2023-12-22 23:29:19 -05:00
Mike Frysinger
9b5e6c1e48 sim: frv: fix -Wshadow=local warnings
Delete redundant decls, and rename conflicting vars.
2023-12-22 23:29:19 -05:00
Mike Frysinger
a4531a4010 sim: erc32: fix -Wshadow=local warnings
Rename shadowed vars with different types to avoid confusion.
2023-12-22 23:29:19 -05:00
Mike Frysinger
87271996ea sim: cris: disable -Wshadow=local in generated mloop files
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-22 23:29:19 -05:00
Mike Frysinger
c99faa9291 sim: cris: fix -Wshadow=local warnings
Delete redundant local decls.
2023-12-22 23:29:19 -05:00
Mike Frysinger
ef382e84b7 sim: common: fix -Wshadow=local warnings
Rename shadowed vars with different types, and delete redundant decls.
2023-12-22 23:29:19 -05:00
Mike Frysinger
5f347a1106 sim: bfin: fix -Wshadow=local warnings
Rename the shadowed var to avoid confusion with the function argument
as to which address this code is using.
2023-12-22 23:29:19 -05:00
Mike Frysinger
8ce49cf102 sim: arm: fix -Wshadow=local warnings
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-22 23:29:19 -05:00
Mike Frysinger
2bf4edd2ea sim: aarch64: fix -Wshadow=local warnings
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-22 23:29:19 -05:00
Mike Frysinger
401b5b00ec sim: cgen: regenerate decode tables to avoid shadow warnings
Use latest cgen to regenerate the decode tables which has some shadow
warning fixes with "val" variables.
2023-12-22 10:53:49 -05:00
Mike Frysinger
4a517293bb sim: cris: regen cgen decoders to fix build warnings [PR sim/31181]
Bug: https://sourceware.org/PR31181
2023-12-22 10:44:39 -05:00
Mike Frysinger
866a2ad35b sim: ppc: igen: fix -G handling
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-21 21:04:44 -05:00
Mike Frysinger
3744b73e3b sim: warnings: enable -Wreturn-type
Older versions of gcc support this warning flag.  We're already clean.
2023-12-21 20:59:16 -05:00
Mike Frysinger
fa113bd940 sim: warnings: fix -Wreturn-mismatch typo 2023-12-21 20:58:51 -05:00
Mike Frysinger
06bc778c13 sim: m32c: fix initial #line number in generated code
This emits #line 2 for the first line in the output when it should be 1.
2023-12-21 20:17:38 -05:00
Mike Frysinger
6003fe166d sim: mloop: add #line pragmas everywhere
This will make compiler diagnostics much better with generated code
so people can understand the original source file.
2023-12-21 20:16:26 -05:00
Mike Frysinger
c0e97c8525 sim: common: add $LINENO rewriting support to genmloop scripts
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.
2023-12-21 20:16:26 -05:00
Mike Frysinger
3a4ee62868 sim: warnings: enable -Wimplicit-fallthrough=5
It caught some legitimate bugs, so clearly it's helpful.
2023-12-21 01:59:23 -05:00
Mike Frysinger
849bdf4ead sim: sh: fix -Wimplicit-fallthrough warnings
These generate conditional insns where it tests, then fallsthru.
2023-12-21 01:59:23 -05:00
Mike Frysinger
85433eb331 sim: rx: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:23 -05:00
Mike Frysinger
e8aaac5fe6 sim: rl78: fix -Wimplicit-fallthrough warnings
Seems like this code was meant to fallthru.
2023-12-21 01:59:23 -05:00
Mike Frysinger
05b9feffff sim: riscv: fix -Wimplicit-fallthrough warnings 2023-12-21 01:59:23 -05:00
Mike Frysinger
92a9d946da sim: ppc: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:23 -05:00
Mike Frysinger
77b3c4f666 sim: or1k: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:23 -05:00
Mike Frysinger
28c06ff1a1 sim: mips: fix -Wimplicit-fallthrough warnings
Seems like these cases were meant to fallthru.
2023-12-21 01:59:23 -05:00
Mike Frysinger
80200ef6b4 sim: mcore: fix Wimplicit-fallthrough warnings
Seems like these decodes were intended to fallthru.
2023-12-21 01:59:23 -05:00
Mike Frysinger
452bfb00b5 sim: m68hc11: fix -Wimplicit-fallthrough warnings
Seems like these register operations intended on falling thru.
2023-12-21 01:59:22 -05:00
Mike Frysinger
aab7152186 sim: frv: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:22 -05:00
Mike Frysinger
fcad8e6ba7 sim: erc32: fix -Wimplicit-fallthrough warnings
Add the attribute where it seems to make sense.
2023-12-21 01:59:22 -05:00
Mike Frysinger
b356d0c5a0 sim: cris: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:22 -05:00
Mike Frysinger
f0e2dc75ce sim: bfin: fix -Wimplicit-fallthrough warnings
Add the attribute to places where we want to fall thru.
2023-12-21 01:59:22 -05:00
Mike Frysinger
639bab3ca6 sim: avr: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:22 -05:00
Mike Frysinger
beb9aecf12 sim: arm: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:22 -05:00
Mike Frysinger
5e6951299a sim: aarch64: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute, and add some
default abort calls when the compiler can't figure out that the set
of values were already fully enumerated in the switch statement.
2023-12-21 01:59:22 -05:00
Mike Frysinger
9362022e95 sim: common: fix -Wimplicit-fallthrough warnings
Replace some fall through comments with the attribute.
2023-12-21 01:59:22 -05:00
Mike Frysinger
29f1ffea25 sim: add ATTRIBUTE_FALLTHROUGH for local code
We'll replace various /* fall through */ comments so compilers can
actually understand what the code is doing.
2023-12-21 01:59:22 -05:00
Mike Frysinger
d137b254d9 sim: signal: mark signal callback funcs as noreturn since they don't return
All funcs already call other funcs that don't return.  The mips port is
the only exception because its generic exception handler can return in
the case of normal exceptions.  So while the exceptions its signal handler
triggers doesn't return, we can't express that conditional logic.  So add
some useless abort calls to make the compiler happy.
2023-12-21 01:59:22 -05:00
Mike Frysinger
f184f3a224 sim: sh: add missing breaks to bit processing
Doesn't seem like we want to cascade in this section when bit processing.
2023-12-21 01:46:04 -05:00
Mike Frysinger
4675df34be sim: rx: mark abort func as noreturn since it doesn't 2023-12-21 01:45:15 -05:00
Mike Frysinger
c31d7253d2 sim: rx: add missing break to memory write
It doesn't seem like we want to keep executing the next block of code
after processing the request.
2023-12-21 01:44:13 -05:00
Mike Frysinger
4935610a57 sim: iq2000: add fallback for exit syscall
Make sure this syscall always exits regardless of the exit code.
2023-12-21 01:42:34 -05:00
Mike Frysinger
cc6aaa3149 sim: cr16: add missing break statement
Doesn't seem to make sense for this to fall through
(although I'm not an expert in this ISA).
2023-12-21 01:41:49 -05:00
Mike Frysinger
3cf7f9363d sim: arm: add missing breaks to SWI processing
Seems unlikely we want the remove syscall to fallthrough into the
rename syscall since we can't rename files that have been removed.
2023-12-21 01:41:07 -05:00
Mike Frysinger
c5190830db sim: common: mark engine restart as noreturn
This helps the compiler with optimization and fixes fallthru warnings.
2023-12-21 01:23:00 -05:00
Mike Frysinger
cbdfef872b sim: ppc: phb: add missing break to address decoder
I don't know what this emulation does exactly, but it missing a break
statement seems kind of obvious based on the 32-bit case above it.
2023-12-21 01:21:18 -05:00
Mike Frysinger
5eba9ae8d5 sim: ppc: mark halt & restart funcs as noreturn
This helps the compiler with optimization and fixes fallthru warnings.
2023-12-21 01:20:44 -05:00
Mike Frysinger
95cd009f5d sim: warnings: enable -Wduplicated-cond 2023-12-21 00:02:20 -05:00
Mike Frysinger
0960c785ac sim: mn10300: fix LAST_TIMER_REG typo
The compiler pointed out that we're testing LAST_TIMER_REG and
LAST_COUNTER which are the same value ... and that's because we
set LAST_TIMER_REG to the wrong register.  Fix the typo.
2023-12-21 00:02:18 -05:00
Mike Frysinger
2f84390fd4 sim: bfin: clean up astat reg name decode a little
The compiler pointed out we checked AZ twice.  Sort by name to avoid
that in the future, and to make it clearer that we have coverage of
all the bits.  And add the bits we were missing.

The order here doesn't matter as it's just turning a pointer into a
human readable string when store tracing is enabled.
2023-12-21 00:02:15 -05:00
Mike Frysinger
a4de6c88c9 sim: common: delete unused scache in some mloop paths
The scache vars aren't used by ports in the pbb & fast codepaths,
nor are they documented as inputs to the callbacks, so delete them
to avoid unused variable compiler warnings.
2023-12-20 22:13:28 -05:00
Mike Frysinger
09d4e6bb2f sim: cgen: unify the genmloop logic a bit
Pull out the common parts of the genmloop invocation into the common
code.  This will make it easier to add more, and make the per-port
differences a little more obvious.
2023-12-20 21:24:40 -05:00
Mike Frysinger
06f05f3585 sim: frv: enable warnings in memory.c
Fix one minor pointer-sign warning to enable warnings in general
for this file.  Reading the data as signed and then returning it
as unsigned should be functionally the same in this case.
2023-12-19 20:19:52 -05:00
Mike Frysinger
e875d98ee5 sim: common: delete unused argbuf in generated mloop code
This function only uses prev_abuf, not abuf, and doesn't inline code
from the various ports on the fly, so abuf will never be used.
2023-12-19 06:54:56 -05:00
Mike Frysinger
e7198a4305 sim: v850: fix -Wunused-variable warnings 2023-12-19 05:51:11 -05:00
Mike Frysinger
67df132b65 sim: sh: fix -Wunused-variable warnings 2023-12-19 05:51:11 -05:00
Mike Frysinger
5daeb7f67a sim: moxie: fix -Wunused-variable warnings 2023-12-19 05:51:11 -05:00
Mike Frysinger
eade758025 sim: msp430: fix -Wunused-variable warnings 2023-12-19 05:51:11 -05:00
Mike Frysinger
7704565d2f sim: mn10300: fix -Wunused-variable warnings 2023-12-19 05:51:11 -05:00
Mike Frysinger
bb2f91823f sim: mips: fix -Wunused-variable warnings 2023-12-19 05:51:11 -05:00
Mike Frysinger
96967be368 sim: microblaze: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
2705c08342 sim: mcore: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
568b2f90c7 sim: m32r: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
9340c17241 sim: lm32: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
ef2022265b sim: iq2000: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
04a33b24eb sim: h8300: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
8bc2893fb4 sim: ft32: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
cd3f716d9a sim: frv: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
c6ce030ba9 sim: erc32: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
1857c9f587 sim: cris: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
303dc26d24 sim: cr16: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
4b75ed1797 sim: bpf: fix -Wunused-variable warnings 2023-12-19 05:51:10 -05:00
Mike Frysinger
4ff93a08ab sim: bfin: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
Mike Frysinger
91669a0537 sim: aarch64: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
Mike Frysinger
715dd70c29 sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
Mike Frysinger
e9026cfbcf cpu: cris: drop some unused vars
These fix unused variable warnings in the generated sim.
2023-12-19 05:45:01 -05:00
Jeff Law
b3fa92f12a Yet another fix for mcore-sim (rotli)
This came up testing the CRC optimization work from Mariam@RAU.
Basically to optimize some CRC loops into table lookups or carryless
multiplies, we may need to do a bit reflection, which on the mcore
processor is done using a rotate instruction.

Unfortunately the simulator implementation of rotates has the exact same
problem as we saw with right shifts.  The input value may have been sign
extended from 32 to 64 bits.  When we rotate the extended value, we get
those sign extension bits and thus the wrong result.

The fix is the same.  Rather than using a "long", use a uint32_t for the
type of the temporary.  This fixes a handful of tests in the GCC testsuite:
2023-12-18 22:04:25 -07:00
Mike Frysinger
2757c1c65f sim: warnings: add more flags
We already build cleanly with these.
2023-12-17 00:15:49 -05:00
Mike Frysinger
9846e9c110 sim: cr16: clean up unused insn operands
The push/pop insns only have 2 operands, so delete unused "c".

The pushret/popret insns use 2 operands, but they don't implement the
logic directly, they call the push/pop implementations.  So delete the
unused "a" & "b".
2023-12-16 00:31:01 -05:00
Mike Frysinger
82a398adb8 sim: sh: adjust some dsp insn masks
The pmuls encoding is incorrect -- it looks like a copy & paste error
from the padd pmuls variant.  The SuperH software manual covers this.

On the flip side, the manual lists pwsb & pwad as insns that exist,
but no description of what they do, what the insn name means, or the
actual encoding.  Our sim implementation stubs them both out as nops.
Let's mark the fields to avoid unused variable warnings.
2023-12-15 23:59:00 -05:00
Mike Frysinger
0fd9d0cec0 sim: sh: tidy up gencode slightly
Mark a few things static/const, and clean up trailing whitespace.
2023-12-15 23:59:00 -05:00
Mike Frysinger
302bd5bf18 sim: bfin: fix typo in bf52x ports
These should be using the BF52x set of ports, not BF51x.
2023-12-15 21:41:07 -05:00
Mike Frysinger
00383ba6b4 sim: warnings: enable -Wunused-but-set-variable 2023-12-15 21:14:13 -05:00
Mike Frysinger
81a3befa0a sim: mn10300: fix incorrect implementation of a few insns
Fix a few problems caught by compiler warnings:
* Some of the asr & lsr insns were setting up the c state flag,
  but then forgetting to set it in the PSW.  Add it like the other
  asr & lsr variants.
* Some of the dmulh insns were multiplying one of the source regs
  against itself instead of against the other source reg.
* The sat16_cmp parallel insn was using the wrong register in the
  compare -- the reg1 src/dst pair are used in the sat16 op, and
  the reg2 src/dst pair are used in the add op.
2023-12-15 21:14:13 -05:00
Mike Frysinger
10802d9ac0 sim: m32r: fix mloop.in variant stamp deps
The migration to local.mk in commit 0a129eb19a
accidentally listed the deps for all mloop steps as mloop.in instead of the
various variants that m32r uses.

Reported-by: Simon Marchi <simon.marchi@polymtl.ca>
2023-12-14 22:45:22 -05:00
Mike Frysinger
2f1de74501 sim: m32r: use @cpu@_fill_argbuf_tp to set trace & profile state
The mloop.in code does this, but these variants do not.  Use it to
avoid unused function warnings.  The fast_p logic in these files
also looks off, but that'll require a bit more work to fixup.

  CC       m32r/mloopx.o
m32r/mloopx.c:37:1: error: ‘m32rxf_fill_argbuf_tp’ defined but not used [-Werror=unused-function]
   37 | m32rxf_fill_argbuf_tp (const SIM_CPU *cpu, ARGBUF *abuf,
      | ^~~~~~~~~~~~~~~~~~~~~

  CC       m32r/mloop2.o
m32r/mloop2.c:37:1: error: ‘m32r2f_fill_argbuf_tp’ defined but not used [-Werror=unused-function]
   37 | m32r2f_fill_argbuf_tp (const SIM_CPU *cpu, ARGBUF *abuf,
      | ^~~~~~~~~~~~~~~~~~~~~

Reported-by: Simon Marchi <simon.marchi@polymtl.ca>
Tested-By: Simon Marchi <simon.marchi@polymtl.ca>
2023-12-14 22:34:28 -05:00
Mike Frysinger
880530b71f sim: igen: do not reindent literal semantics output
When generating semantics.c from .igen source files, indenting the code
makes it more readable, but confuses compiler diagnostics.  The latter
is a bit more important than the former, so bias towards that.

For example, with an introduced error, we can see w/gcc-13:

(before this change)
  CC       mn10300/semantics.o
../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
../../../sim/mn10300/am33-2.igen:11:5: error: ‘srcreg’ undeclared (first use in this function)
   11 |   srcreg = translate_rreg (SD_, RN2);
      |     ^~~~~~

(with this change)
  CC       mn10300/semantics.o
../../../sim/mn10300/am33-2.igen: In function ‘semantic_dcpf_D1a’:
../../../sim/mn10300/am33-2.igen:11:3: error: ‘srcreg’ undeclared (first use in this function)
   11 |   srcreg = translate_rreg (SD_, RN2);
      |   ^~~~~~
2023-12-14 22:33:47 -05:00
Jeff Law
76c51bed59 Improve performance of the H8 simulator
Running the H8 port through the GCC testsuite currently takes 4h 30m on my
fastest server -- that's roughly 1.5hrs per multilib tested and many tests are
disabled for various reasons.

To put that 1.5hr/multilib in perspective, that's roughly 3X the time for other
embedded targets.  Clearly something isn't working as well as it should.

A bit of digging with perf shows that we're spending a crazy amount of time
decoding instructions in the H8 simulator.  It's not hard to see why --
basically we take a blob of instruction data, then try to match it to every
instruction in the H8 opcode table starting at the beginning.  That table has
~8000 entries (each different addressing mode is considered a different
instruction in the table).

Naturally my first thought was to sort the table and use a binary search to
find the right entry.  That's made excessively complex due to the encoding on
the H8.  Just getting the sort right would be much more complex than I'd
consider advisable.

Another thought was to build a mapping to the right entry for all the
instructions that can be disambiguated based on the first nibble (4 bits) of
instruction data and a mapping for those which can be disambiguated based on
the first byte of instruction data.

That seemed feasible until I realized that the H8/SX did some truly horrid
things with encoding branches in the 0x4XYY opcode space.  It uses an "always
zero" bit in the offset to encode new semantic information.  So we can't select
on just 0x4X.  Ugh!

We could always to a custom decoder.  I've done several through the years, they
can be very fast.  But no way I can justify the time to do that.

So what I settled on was to first sort the opcode table by the first nibble,
then find the index of the first instruction for each nibble. Decoding uses
that index to start its search.  This cuts the overall build/test by more than
half.

Next I adjusted the sort so that instructions that are not available on the
current sub architecture are put at the end of the table.   This shaves another
~15% off the total cycle time.

The net of the two changes is on my fastest server we've gone from 4:30 to 1:40
running the GCC testsuite.  Same test results before/after, of course.  It's
still not fast, but it's a hell of a lot better.
2023-12-10 13:26:03 -07:00
Mike Frysinger
c64ec6d082 sim: aarch64: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Mike Frysinger
3762437ead sim: common: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Mike Frysinger
8958a91714 sim: ppc: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Mike Frysinger
bbe7b93875 sim: v850: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Mike Frysinger
49b556efb5 sim: sh: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Mike Frysinger
0e12bb132e sim: msp430: fix -Wunused-but-set-variable warnings 2023-12-07 22:31:21 -07:00
Mike Frysinger
5dda1cd28a sim: mips: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
2a04b8c908 sim: mcore: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
fca8f1a3dc sim: m68hc11: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
7368a2cf73 sim: h8300: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
ab46df15a0 sim: ft32: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
0dabdc69c7 sim: frv: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
89d7fc2ab0 sim: erc32: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
a886474a62 sim: d10v: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
4125d64738 sim: cris: fix -Wunused-but-set-variable warnings
We suppress the warning in the generated switch file because the cris
cpu file has a hack to workaround a cgen bug, but that generates a set
but unused variable which makes the compiler upset.
2023-12-07 21:41:27 -07:00
Mike Frysinger
ee45e43358 sim: bfin: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
058d0bf5f0 sim: bfin: gui: fix -Wunused-but-set-variable warnings
Rework the code to use static inline functions when it's disabled
rather than macros so the compiler knows the various function args
are always used.  The ifdef macros are a bit ugly, but get the job
done without duplicating the function prototypes.
2023-12-07 21:41:27 -07:00
Mike Frysinger
ad4106f8dd sim: arm: fix -Wunused-but-set-variable warnings 2023-12-07 21:41:27 -07:00
Mike Frysinger
c26f7543b2 sim: m32r: fix syslog call
The function returns void, not int.  We only pass one argument to
syslog (the format), so use %s as the static format instead since
the emulation layer doesn't handle passing additional arguments.
2023-12-07 21:41:27 -07:00
Mike Frysinger
9c80f001f0 sim: m32r: include more glibc headers for the funcs we use [PR sim/29752]
Not exactly portable, but doesn't make the situation worse here, and
fixes a lot of implicit function warnings.

Bug: https://sourceware.org/PR29752
2023-12-07 21:41:27 -07:00
Mike Frysinger
190fcd0d6c sim: m32r: add more cgen prototypes for traps
The traps file uses a bunch of functions directly without prototypes,
and we can't safely include the relevant cpu*.h files for them.
2023-12-07 21:41:27 -07:00
Mike Frysinger
5e43a46efc sim: m32r: add more cgen prototypes to enable -Werror in most files 2023-12-07 06:22:32 -07:00
Mike Frysinger
a729245526 sim: warnings: disable -Wenum-conversion fow now [PR sim/29752]
The cgen code mixes virtual insn enums with insn enums, and there isn't
an obvious (to me) way to unravel this atm, so disable the warning.

sim/lm32/decode.c:45:5: error:
	implicit conversion from enumeration type 'CGEN_INSN_VIRTUAL_TYPE'
	to different enumeration type 'CGEN_INSN_TYPE' (aka 'enum cgen_insn_type')
	[-Werror,-Wenum-conversion]
   45 |   { VIRTUAL_INSN_X_INVALID, LM32BF_INSN_X_INVALID, LM32BF_SFMT_EMPTY },
      |   ~ ^~~~~~~~~~~~~~~~~~~~~~

Bug: https://sourceware.org/PR29752
2023-12-07 06:00:25 -07:00
Mike Frysinger
708aee5ec6 sim: support dlopen in -lc
Stop assuming that dlopen is only available via -ldl.  Newer versions
of glibc have merged it into -lc which broke this configure test.
2023-12-06 20:56:29 -07:00
Mike Frysinger
d7befe04fa sim: cris: move generated file to right place
Not sure why this ended up in the topdir, but it belongs under cris/.
2023-12-06 20:11:05 -07:00
Mike Frysinger
b0c06375e1 sim: warnings: add more flags
Sync with the list of flags from gdbsupport, and add a few more of
our own to catch recent issues.  Comment out the C++-specific flags
as we don't build with C++.
2023-12-06 20:11:05 -07:00
Mike Frysinger
3c7666dca5 sim: warnings: sync some build logic from gdbsupport
This fixes testing of -Wno flags, and adds some more portable ones.
2023-12-05 23:12:16 -07:00
Mike Frysinger
de501587c2 sim: mips: fix sim_fpu usage
Fix some of the sim_fpu calls to use the right types.  While I'm
not familiar with the MIPS ISA in these cases, these look like
simple oversights due to the name/type mismatches.  This at least
fixes compiling with -Wenum-conversion.
2023-12-05 06:12:02 -07:00
Mike Frysinger
682ff29bfc sim: sh: trim trailing whitespace in generated code
No functional change here, but makes it a little easier to read the
generated code when editors aren't highlighting all the spurious
trailing whitespace on lines.
2023-12-05 06:05:19 -07:00
Mike Frysinger
cd1c74bec6 sim: mn10300: fix sim_engine_halt call
The sim_stop argument is an enum and should only be one of those
values, not a signal constant.  Fix the logic to pass the right
sim_xxx & SIM_xxx values in the right arguments.
2023-12-05 07:56:52 -05:00
Mike Frysinger
9d4a8c0a2e sim: m32c: use UTF-8 encoding
We only support UTF-8 nowadays, so stop using ISO-8859-1.

Maybe we should delete this logic entirely, but for now,
do the bare min conversion to keep it compiling.
2023-12-05 07:50:56 -05:00
Mike Frysinger
02b8b049a4 sim: rx: mark unused static var as unused
This seems like a useful utility func that mirrors the int2float
helper, so mark it as unused rather than delete.
2023-12-04 23:49:48 -05:00
Mike Frysinger
be3701ba8c sim: rx: constify some read-only global vars 2023-12-04 23:49:35 -05:00
Mike Frysinger
ab18008ed1 sim: warnings: enable only for development builds
Reuse the bfd/development.sh script like most other project to
determine whether the current source tree is a dev build (e.g.
git) or a release build, and disable the warnings for releases.
2023-12-04 23:45:27 -05:00
Mike Frysinger
9a9205a0c7 sim: ppc: fix implicit enum conversion
This code tries to use attach_type enums as hw_phb_decode, and while
they're setup to have compatible values, the compiler doesn't like it
when the cast is missing.  So cast it explicitly and then use that.

sim/ppc/hw_phb.c:322:28: error:
	implicit conversion from enumeration type 'attach_type'
	(aka 'enum _attach_type') to different enumeration type
	'hw_phb_decode' [-Werror,-Wenum-conversion]
2023-12-04 23:41:31 -05:00
Mike Frysinger
c96b63a2e9 sim: ppc: fix -Wmisleading-indentation warnings
Fix building with -Wmisleading-indentation.
2023-12-04 23:38:55 -05:00
Mike Frysinger
a3d3d9a7d9 sim: ppc: cleanup getrusage decls
Don't conflate HAVE_GETRUSAGE & HAVE_SYS_RESOURCE_H.  Use the latter
to include the header and nothing else.  Use the former to determine
whether to use the function and nothing else.  If we find a system
that doesn't follow POSIX and provides only one of these, we can
figure out how to support it then.  The manual local definition is
clashing with the system ones and leading to build failures with
newer C standards.

sim/ppc/emul_netbsd.c:51:5: error: a function declaration without a
	prototype is deprecated in all versions of C and is treated as a
	zero-parameter prototype in C2x, conflicting with a previous
	declaration [-Werror,-Wdeprecated-non-prototype]
2023-12-04 23:36:20 -05:00
Jeff Law
37d6ee9350 Fix right shifts in mcore simulator on 64 bit hosts.
If the value to be shifted has the sign bit set, the sign
bit would get copied into bits 32..63 of the temporary.  Those
would then be right shifted into the final value giving an
incorrect final result.

This was observed with upcoming GCC improvements which eliminate
unnecessary extensions.
2023-12-01 07:19:50 -07:00
Jose E. Marchesi
9d4db627b2 sim: bpf: do not use semicolon to begin comments
The BPF assembler has been updated to follow the clang convention in
the interpretation of semicolons: they separate statements and
directives, and do not start line comments.
2023-11-28 15:01:18 +01:00
Ying Huang
27c22a4c76 sim: mips: Change E_MIPS_* to EF_MIPS_*
According to we have changed all E_MIPS_* to EF_MIPS_* in binutils
and glibc, we also need to change it here to keep same style.
We can refer to this commit record:
https://sourceware.org/pipermail/binutils/2023-October/129904.html

Approved-By: Pedro Alves <pedro@palves.net>
2023-11-16 10:21:55 +08:00
Jaydeep Patil
1c37b30945 sim/riscv: fix JALR instruction simulation
Fix 32bit 'jalr rd,ra,imm' integer instruction, where RD was written
before using it to calculate destination address.

This commit also improves testutils.inc for riscv; make use of
pushsection and popsection when adding things to .data, and setup the
%gp global pointer register within the 'start' macro.

Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-10-18 17:55:31 +01:00