From 8e5eb8e1b0cb2a408008a3e40e571f193917dcc8 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Thu, 12 May 2022 10:32:11 +0300 Subject: ppc: extend opindex to 16 bits With the upcoming SVP64 extension[0] to PowerPC architecture, it became evident that PowerPC operand indices no longer fit 8 bits. This patch switches the underlying type to uint16_t, also introducing a special typedef so that any future extension goes even smoother. [0] https://libre-soc.org include/ * opcode/ppc.h (ppc_opindex_t): New typedef. (struct powerpc_opcode): Use it. (PPC_OPINDEX_MAX): Define. gas/ * write.h (struct fix): Increase size of fx_pcrel_adjust. Reorganise. * config/tc-ppc.c (insn_validate): Use ppc_opindex_t for operands. (md_assemble): Likewise. (md_apply_fix): Likewise. Mask fx_pcrel_adjust with PPC_OPINDEX_MAX. (ppc_setup_opcodes): Adjust opcode index assertion. opcodes/ * ppc-dis.c (skip_optional_operands): Use ppc_opindex_t for operand pointer. (lookup_powerpc, lookup_prefix, lookup_vle, lookup_spe2): Likewise. (print_insn_powerpc): Likewise. --- include/opcode/ppc.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/opcode/ppc.h b/include/opcode/ppc.h index a9c2529..7bc6ee2 100644 --- a/include/opcode/ppc.h +++ b/include/opcode/ppc.h @@ -29,6 +29,12 @@ extern "C" { #endif typedef uint64_t ppc_cpu_t; +typedef uint16_t ppc_opindex_t; + +/* Smaller of ppc_opindex_t and fx_pcrel_adjust maximum. Note that + values extracted from fx_pcrel_adjust are masked with this constant, + effectively making the field unsigned. */ +#define PPC_OPINDEX_MAX 0xffff /* The opcode table is an array of struct powerpc_opcode. */ @@ -60,7 +66,7 @@ struct powerpc_opcode /* An array of operand codes. Each code is an index into the operand table. They appear in the order which the operands must appear in assembly code, and are terminated by a zero. */ - unsigned char operands[8]; + ppc_opindex_t operands[8]; }; /* The table itself is sorted by major opcode number, and is otherwise -- cgit v1.1