Commit Graph

5043 Commits

Author SHA1 Message Date
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