diff options
author | Jim Wilson <jim.wilson@linaro.org> | 2016-12-13 08:35:31 -0800 |
---|---|---|
committer | Jim Wilson <jim.wilson@linaro.org> | 2016-12-13 08:44:31 -0800 |
commit | 963201cf5d29c4dc718b5fb3507e085b302ff896 (patch) | |
tree | 399bbe473e1c5cbd0ea5d16902081b6e8ac82eed /sim/aarch64 | |
parent | 9282b95ab7bfe1cdf471e9dd609ae0ea7bbed925 (diff) | |
download | gdb-963201cf5d29c4dc718b5fb3507e085b302ff896.zip gdb-963201cf5d29c4dc718b5fb3507e085b302ff896.tar.gz gdb-963201cf5d29c4dc718b5fb3507e085b302ff896.tar.bz2 |
Fix aarch64 sim bug with adds64, and add testcases for last 3 bug fixes.
sim/aarch64
* simulator.c (NEG, POS): Move before set_flags_for_add64.
(set_flags_for_add64): Replace with a modified copy of
set_flags_for_sub64.
sim/testsuite/sim/aarch64
* testutils.inc (pass): Move .Lpass to start.
(fail): Move .Lfail to start. Return 1 instead of 0.
(start): Moved .Lpass and .Lfail to here.
* adds.s: New.
* fstur.s: New.
* tbnz.s: New.
Diffstat (limited to 'sim/aarch64')
-rw-r--r-- | sim/aarch64/ChangeLog | 6 | ||||
-rw-r--r-- | sim/aarch64/simulator.c | 51 |
2 files changed, 21 insertions, 36 deletions
diff --git a/sim/aarch64/ChangeLog b/sim/aarch64/ChangeLog index 2eca54d..2346a49 100644 --- a/sim/aarch64/ChangeLog +++ b/sim/aarch64/ChangeLog @@ -1,3 +1,9 @@ +2016-12-13 Jim Wilson <jim.wilson@linaro.org> + + * simulator.c (NEG, POS): Move before set_flags_for_add64. + (set_flags_for_add64): Replace with a modified copy of + set_flags_for_sub64. + 2016-12-03 Jim Wilson <jim.wilson@linaro.org> * simulator.c (tbnz, tbz): Cast 1 to uint64_t before shifting. diff --git a/sim/aarch64/simulator.c b/sim/aarch64/simulator.c index 34fd17d..e6406dc 100644 --- a/sim/aarch64/simulator.c +++ b/sim/aarch64/simulator.c @@ -1659,55 +1659,34 @@ set_flags_for_add32 (sim_cpu *cpu, int32_t value1, int32_t value2) aarch64_set_CPSR (cpu, flags); } +#define NEG(a) (((a) & signbit) == signbit) +#define POS(a) (((a) & signbit) == 0) + static void set_flags_for_add64 (sim_cpu *cpu, uint64_t value1, uint64_t value2) { - int64_t sval1 = value1; - int64_t sval2 = value2; - uint64_t result = value1 + value2; - int64_t sresult = sval1 + sval2; - uint32_t flags = 0; + uint64_t result = value1 + value2; + uint32_t flags = 0; + uint64_t signbit = 1ULL << 63; if (result == 0) flags |= Z; - if (result & (1ULL << 63)) + if (NEG (result)) flags |= N; - if (sval1 < 0) - { - if (sval2 < 0) - { - /* Negative plus a negative. Overflow happens if - the result is greater than either of the operands. */ - if (sresult > sval1 || sresult > sval2) - flags |= V; - } - /* else Negative plus a positive. Overflow cannot happen. */ - } - else /* value1 is +ve. */ - { - if (sval2 < 0) - { - /* Overflow can only occur if we computed "0 - MININT". */ - if (sval1 == 0 && sval2 == (1LL << 63)) - flags |= V; - } - else - { - /* Postive plus positive - overflow has happened if the - result is smaller than either of the operands. */ - if (result < value1 || result < value2) - flags |= V | C; - } - } + if ( (NEG (value1) && NEG (value2)) + || (NEG (value1) && POS (result)) + || (NEG (value2) && POS (result))) + flags |= C; + + if ( (NEG (value1) && NEG (value2) && POS (result)) + || (POS (value1) && POS (value2) && NEG (result))) + flags |= V; aarch64_set_CPSR (cpu, flags); } -#define NEG(a) (((a) & signbit) == signbit) -#define POS(a) (((a) & signbit) == 0) - static void set_flags_for_sub32 (sim_cpu *cpu, uint32_t value1, uint32_t value2) { |