aboutsummaryrefslogtreecommitdiff
path: root/sim/mcore
diff options
context:
space:
mode:
authorJeff Law <jlaw@ventanamicro.com>2023-10-11 16:30:05 -0600
committerJeff Law <jlaw@ventanamicro.com>2023-10-11 16:31:11 -0600
commitc524b5f2f665d0bcdc0e98212d10e968c57762df (patch)
tree340dab92b44d12750172c87ae47be6e753ee11f9 /sim/mcore
parentf6ca448ab70c52e923b7010aecdf7be9c0d4d4fc (diff)
downloadgdb-c524b5f2f665d0bcdc0e98212d10e968c57762df.zip
gdb-c524b5f2f665d0bcdc0e98212d10e968c57762df.tar.gz
gdb-c524b5f2f665d0bcdc0e98212d10e968c57762df.tar.bz2
[RFA] Fix for mcore simulator
I was looking for cases where a GCC patch under evaluation would cause test results to change. Quite surprisingly the mcore-elf port showed test differences. After a fair amount of digging my conclusion was the sequences before/after the patch should have been semantically the same. Of course if the code is supposed to behave the same, then that points to problems elsewhere (assembler, linker, simulator). Sure enough the mcore simulator was mis-handling the sign extension instructions. The simulator implementation of sextb is via paired shift-by-24 operations. Similarly the simulator implements sexth via paired shift-by-16 operations. The temporary holding the value was declared as a "long" thus this approach worked fine for hosts with a 32 bit wide long and failed miserably for hosts with a 64 bit wide long. This patch makes the shift count automatically adjust based on the size of the temporary. It includes a simple test for sextb and sexth. I have _not_ done a full audit of the mcore simulator for more 32->64 bit issues. This also fixes 443 execution tests in the GCC testsuite
Diffstat (limited to 'sim/mcore')
-rw-r--r--sim/mcore/interp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index 53cfdad..48d9ff8 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -641,8 +641,8 @@ step_once (SIM_DESC sd, SIM_CPU *cpu)
{
long tmp;
tmp = gr[RD];
- tmp <<= 24;
- tmp >>= 24;
+ tmp <<= (sizeof (tmp) * 8) - 8;
+ tmp >>= (sizeof (tmp) * 8) - 8;
gr[RD] = tmp;
}
break;
@@ -653,8 +653,8 @@ step_once (SIM_DESC sd, SIM_CPU *cpu)
{
long tmp;
tmp = gr[RD];
- tmp <<= 16;
- tmp >>= 16;
+ tmp <<= (sizeof (tmp) * 8) - 16;
+ tmp >>= (sizeof (tmp) * 8) - 16;
gr[RD] = tmp;
}
break;