diff options
author | Jan Beulich <jbeulich@suse.com> | 2023-08-15 08:34:56 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2023-08-15 08:34:56 +0200 |
commit | 02a63525ef02bac47fa750e89db0996bc96697d3 (patch) | |
tree | 2d704013bbc897da397f9e90246e188e4e10e91b /include | |
parent | a2182c73d245530c5c5587bc47a6142e9738de84 (diff) | |
download | binutils-02a63525ef02bac47fa750e89db0996bc96697d3.zip binutils-02a63525ef02bac47fa750e89db0996bc96697d3.tar.gz binutils-02a63525ef02bac47fa750e89db0996bc96697d3.tar.bz2 |
RISC-V: remove indirection from register tables
The longest register name is 4 characters (plus a nul one), so using a
4- or 8-byte pointer to get at it is neither space nor time efficient.
Embed the names right into the array. For PIE this also reduces the
number of base relocations in the final image.
To avoid old gcc, when generating 32-bit code, bogusly warning about
bounds being exceeded in the code processing Cs/Cw, Ct/Cx, and CD,
an adjustment to EXTRACT_BITS() is needed: This macro shouldn't supply
a 64-bit value, and it also doesn't need to - all operand fields to
date are far more narrow than 32 bits. This in turn allows dropping a
number of casts elsewhere.
Diffstat (limited to 'include')
-rw-r--r-- | include/opcode/riscv.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/include/opcode/riscv.h b/include/opcode/riscv.h index 808f365..3ed365e 100644 --- a/include/opcode/riscv.h +++ b/include/opcode/riscv.h @@ -354,7 +354,7 @@ static inline unsigned int riscv_insn_length (insn_t insn) /* Extract the operand given by FIELD from integer INSN. */ #define EXTRACT_OPERAND(FIELD, INSN) \ - EXTRACT_BITS ((INSN), OP_MASK_##FIELD, OP_SH_##FIELD) + ((unsigned int) EXTRACT_BITS ((INSN), OP_MASK_##FIELD, OP_SH_##FIELD)) /* Extract an unsigned immediate operand on position s with n bits. */ #define EXTRACT_U_IMM(n, s, l) \ @@ -574,14 +574,16 @@ enum riscv_seg_mstate MAP_INSN, /* Instructions. */ }; -extern const char * const riscv_gpr_names_numeric[NGPR]; -extern const char * const riscv_gpr_names_abi[NGPR]; -extern const char * const riscv_fpr_names_numeric[NFPR]; -extern const char * const riscv_fpr_names_abi[NFPR]; +#define NRC (4 + 1) /* Max characters in register names, incl nul. */ + +extern const char riscv_gpr_names_numeric[NGPR][NRC]; +extern const char riscv_gpr_names_abi[NGPR][NRC]; +extern const char riscv_fpr_names_numeric[NFPR][NRC]; +extern const char riscv_fpr_names_abi[NFPR][NRC]; extern const char * const riscv_rm[8]; extern const char * const riscv_pred_succ[16]; -extern const char * const riscv_vecr_names_numeric[NVECR]; -extern const char * const riscv_vecm_names_numeric[NVECM]; +extern const char riscv_vecr_names_numeric[NVECR][NRC]; +extern const char riscv_vecm_names_numeric[NVECM][NRC]; extern const char * const riscv_vsew[8]; extern const char * const riscv_vlmul[8]; extern const char * const riscv_vta[2]; |