binutils-gdb/sim/common
Mike Frysinger b2ea48df92 sim: cgen: rework DI macros to avoid signed left shifts
The cgen code uses DI as int64_t and UDI as uint64_t.  The DI macros
are used to construct 64-bit values from 32-bit values (for the low
and high parts).  The MAKEDI macro casts the high 32-bit value to a
signed 32-bit value before shifting.  If this created a negative
value, this would be undefined behavior according to the C standard.
All we care about is shifting the 32-bits as they are to the high
32-bits, not caring about sign extension (since there's nothing left
to shift into), and the low 32-bits being empty.  This is what we
get from shifting an unsigned value, so cast it to unsigned 32-bit
to avoid undefined behavior.

While we're here, change the SETLODI macro to truncate the lower
value to 32-bits before we set it.  If it was passing in a 64-bit
value, those high bits would get included too, and that's not what
we want.

Similarly, tweak the SETHIDI macro to cast the value to an unsigned
64-bit instead of a signed 64-bit.  If the value was only 32-bits,
the behavior would be the same.  If it happened to be signed 64-bit,
it would trigger the undefined behavior too.
2024-01-08 20:01:05 -05:00
..
callback.c
cgen-accfp.c
cgen-cpu.h
cgen-defs.h
cgen-engine.h
cgen-fpu.c
cgen-fpu.h
cgen-mem.h
cgen-ops.h sim: cgen: mark cgen_rtx_error noreturn 2023-12-24 05:09:28 -05:00
cgen-par.c
cgen-par.h
cgen-run.c sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
cgen-scache.c sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
cgen-scache.h
cgen-sim.h
cgen-trace.c
cgen-trace.h
cgen-types.h sim: cgen: rework DI macros to avoid signed left shifts 2024-01-08 20:01:05 -05:00
cgen-utils.c
cgen.sh
ChangeLog-2021
create-version.sh
defs.h sim: add ATTRIBUTE_FALLTHROUGH for local code 2023-12-21 01:59:22 -05:00
dv-cfi.c sim: common: fix -Wimplicit-fallthrough warnings 2023-12-21 01:59:22 -05:00
dv-cfi.h
dv-core.c
dv-glue.c
dv-pal.c
dv-sockser.c
dv-sockser.h
gdbinit.in
genmloop.sh sim: mloop: add #line pragmas everywhere 2023-12-21 20:16:26 -05:00
gennltvals.py sim: common: pull in newlib extensions for Linux compatibility 2023-12-26 22:53:31 -05:00
hw-alloc.c
hw-alloc.h
hw-base.c
hw-base.h
hw-device.c
hw-device.h
hw-events.c
hw-events.h
hw-handles.c
hw-handles.h
hw-instances.c
hw-instances.h
hw-main.h
hw-ports.c sim: fix pervasive typo 2024-01-01 10:44:13 -05:00
hw-ports.h
hw-properties.c sim: fix pervasive typo 2024-01-01 10:44:13 -05:00
hw-properties.h
hw-tree.c sim: fix pervasive typo 2024-01-01 10:44:13 -05:00
hw-tree.h
lineno.sh sim: common: add $LINENO rewriting support to genmloop scripts 2023-12-21 20:16:26 -05:00
local.mk sim: common: add $LINENO rewriting support to genmloop scripts 2023-12-21 20:16:26 -05:00
nrun.c
portability.c
portability.h
run.1
sim-abort.c
sim-alu.h
sim-arange.c
sim-arange.h
sim-assert.h
sim-base.h
sim-basics.h sim: fix pervasive typo 2024-01-01 10:44:13 -05:00
sim-bits.c
sim-bits.h
sim-close.c
sim-command.c
sim-config.c
sim-config.h
sim-core.c sim: fix pervasive typo 2024-01-01 10:44:13 -05:00
sim-core.h sim: signal: mark signal callback funcs as noreturn since they don't return 2023-12-21 01:59:22 -05:00
sim-cpu.c
sim-cpu.h
sim-endian.c
sim-endian.h sim: common: include sim-types.h in the endian header directly 2024-01-03 02:15:54 -05:00
sim-engine.c
sim-engine.h sim: common: mark engine restart as noreturn 2023-12-21 01:23:00 -05:00
sim-events.c
sim-events.h
sim-fpu.c sim: common: fix -Wshadow=local warnings 2023-12-22 23:29:19 -05:00
sim-fpu.h
sim-hload.c
sim-hrw.c
sim-hw.c
sim-hw.h
sim-info.c
sim-inline.c
sim-inline.h
sim-io.c
sim-io.h
sim-load.c
sim-memopt.c sim: common: fix -Wimplicit-fallthrough warnings 2023-12-21 01:59:22 -05:00
sim-memopt.h
sim-model.c
sim-model.h
sim-module.c sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
sim-module.h
sim-n-bits.h
sim-n-core.h
sim-n-endian.h
sim-options.c sim: common: fix -Wshadow=local warnings 2023-12-22 23:29:19 -05:00
sim-options.h
sim-profile.c
sim-profile.h
sim-reason.c
sim-reg.c
sim-resume.c
sim-run.c
sim-signal.c
sim-signal.h
sim-stop.c
sim-syscall.c
sim-syscall.h
sim-trace.c
sim-trace.h
sim-types.h
sim-utils.c
sim-utils.h
sim-watch.c sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
sim-watch.h
syscall.c sim: common: fix -Wunused-variable warnings 2023-12-19 05:51:09 -05:00
target-newlib-errno.c sim: common: pull in newlib extensions for Linux compatibility 2023-12-26 22:53:31 -05:00
target-newlib-open.c
target-newlib-signal.c
target-newlib-syscall.c
target-newlib-syscall.h
version.h