diff options
author | Alan Modra <amodra@gmail.com> | 2020-01-12 20:16:22 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-01-13 12:12:05 +1030 |
commit | 5496abe1c5c31aa6648e8fdb15e4122025bcabfe (patch) | |
tree | 5e682ab1be6b87f94493f7fa4a4506d45f2f8362 /include/opcode | |
parent | 202e762b322444344827acbf98162fcb2910e0dd (diff) | |
download | gdb-5496abe1c5c31aa6648e8fdb15e4122025bcabfe.zip gdb-5496abe1c5c31aa6648e8fdb15e4122025bcabfe.tar.gz gdb-5496abe1c5c31aa6648e8fdb15e4122025bcabfe.tar.bz2 |
tic4x: sign extension using shifts
Don't do that. Especially don't use shift counts that assume the type
being shifted is 32 bits when the type is long/unsigned long. Also
reverts part of a change I made on 2019-12-11 to tic4x_print_register
that on closer inspection turns out to be unnecessary.
include/
* opcode/tic4x.h (EXTR): Delete.
(EXTRU, EXTRS, INSERTU, INSERTS): Rewrite without zero/sign
extension using shifts. Do trim INSERTU value to specified bitfield.
opcodes/
* tic4x-dis.c (tic4x_print_register): Remove dead code.
gas/
* config/tc-tic4x.c (tic4x_operands_match): Correct tic3x trap
insertion.
Diffstat (limited to 'include/opcode')
-rw-r--r-- | include/opcode/tic4x.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/include/opcode/tic4x.h b/include/opcode/tic4x.h index 66b4ebf..04e3f08 100644 --- a/include/opcode/tic4x.h +++ b/include/opcode/tic4x.h @@ -23,11 +23,13 @@ #define IS_CPU_TIC4X(v) ((v) == 0 || (v) == 40 || (v) == 44) /* Define some bitfield extraction/insertion macros. */ -#define EXTR(inst, m, l) ((inst) << (31 - (m)) >> (31 - ((m) - (l)))) -#define EXTRU(inst, m, l) EXTR ((unsigned long)(inst), (m), (l)) -#define EXTRS(inst, m, l) EXTR ((long)(inst), (m), (l)) -#define INSERTU(inst, val, m, l) (inst |= ((val) << (l))) -#define INSERTS(inst, val, m, l) INSERTU (inst, ((val) & ((1 << ((m) - (l) + 1)) - 1)), m, l) +#define EXTRU(inst, m, l) \ + (((inst) >> (l)) & ((2u << ((m) - (l))) - 1)) +#define EXTRS(inst, m, l) \ + ((int) ((EXTRU (inst, m, l) ^ (1u << ((m) - (l)))) - (1u << ((m) - (l))))) +#define INSERTU(inst, val, m, l) \ + ((inst) |= ((val) & ((2u << ((m) - (l))) - 1)) << (l)) +#define INSERTS INSERTU /* Define register numbers. */ typedef enum |