diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2021-08-13 17:11:48 +0100 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2021-08-25 10:48:48 +0100 |
| commit | 95351aa76c8f68564c4be547c1d19d9cabffc147 (patch) | |
| tree | ca8ad3cfcfd691c991c587a32da4b0a9c0846d29 /scripts/qapi/parser.py | |
| parent | a5e59e8dcbbf7b1205370b3f4519749df5d0b726 (diff) | |
| download | focaccia-qemu-95351aa76c8f68564c4be547c1d19d9cabffc147.tar.gz focaccia-qemu-95351aa76c8f68564c4be547c1d19d9cabffc147.zip | |
target/arm: Fix 48-bit saturating shifts
In do_sqrshl48_d() and do_uqrshl48_d() we got some of the edge cases wrong and failed to saturate correctly: (1) In do_sqrshl48_d() we used the same code that do_shrshl_bhs() does to obtain the saturated most-negative and most-positive 48-bit signed values for the large-shift-left case. This gives (1 << 47) for saturate-to-most-negative, but we weren't sign-extending this value to the 64-bit output as the pseudocode requires. (2) For left shifts by less than 48, we copied the "8/16 bit" code from do_sqrshl_bhs() and do_uqrshl_bhs(). This doesn't do the right thing because it assumes the C type we're working with is at least twice the number of bits we're saturating to (so that a shift left by bits-1 can't shift anything off the top of the value). This isn't true for bits == 48, so we would incorrectly return 0 rather than the most-positive value for situations like "shift (1 << 44) right by 20". Instead check for saturation by doing the shift and signextend and then testing whether shifting back left again gives the original value. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'scripts/qapi/parser.py')
0 files changed, 0 insertions, 0 deletions