From 956480ca73dbd6f3403dfaaeac8cd143eb4a68eb Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Mon, 15 Aug 2022 16:34:22 +0300 Subject: [PATCH] ppc/svp64: obtain SVP64 disassembly context --- opcodes/ppc-dis.c | 11 ++++++++--- opcodes/ppc-svp64-dis.c | 14 +++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c index 2a7c6488452..16af4eb1ff7 100644 --- a/opcodes/ppc-dis.c +++ b/opcodes/ppc-dis.c @@ -869,7 +869,8 @@ print_got_plt (struct sec_buf *sb, uint64_t vma, struct disassemble_info *info) static void print_insn_powerpc_opcode (struct disassemble_info *info, bfd_vma memaddr, uint64_t insn, ppc_cpu_t dialect, - const struct powerpc_opcode *opcode) + const struct powerpc_opcode *opcode, + const struct svp64_ctx *svp64) { const ppc_opindex_t *opindex; const struct powerpc_operand *operand; @@ -1056,6 +1057,8 @@ print_insn_powerpc (bfd_vma memaddr, bfd_byte buffer[4]; int status; uint64_t insn; + struct svp64_ctx svp64_ctx; + const struct svp64_ctx *svp64; const struct powerpc_opcode *opcode; int insn_length = 4; /* Assume we have a normal 4-byte instruction. */ @@ -1082,6 +1085,7 @@ print_insn_powerpc (bfd_vma memaddr, insn = bfd_getl32 (buffer); /* Get the major opcode of the insn. */ + svp64 = NULL; opcode = NULL; if ((dialect & (PPC_OPCODE_POWER10 | PPC_OPCODE_SVP64)) != 0 && PPC_OP (insn) == 0x1) @@ -1099,9 +1103,10 @@ print_insn_powerpc (bfd_vma memaddr, if ((dialect & PPC_OPCODE_SVP64) != 0) { - opcode = svp64_lookup (temp_insn, dialect); + opcode = svp64_lookup (temp_insn, dialect, &svp64_ctx); if (opcode != NULL) { + svp64 = &svp64_ctx; insn = temp_insn; insn_length = 8; } @@ -1156,7 +1161,7 @@ print_insn_powerpc (bfd_vma memaddr, (unsigned int) insn); } else - print_insn_powerpc_opcode (info, memaddr, insn, dialect, opcode); + print_insn_powerpc_opcode (info, memaddr, insn, dialect, opcode, svp64); return insn_length; } diff --git a/opcodes/ppc-svp64-dis.c b/opcodes/ppc-svp64-dis.c index b339cd887e5..90e37726d88 100644 --- a/opcodes/ppc-svp64-dis.c +++ b/opcodes/ppc-svp64-dis.c @@ -84,7 +84,8 @@ svp64_lookup_record (uint32_t insn, } static const struct powerpc_opcode * -svp64_lookup (uint64_t insn, ppc_cpu_t dialect) +svp64_lookup (uint64_t insn, ppc_cpu_t dialect, + struct svp64_ctx *svp64) { uint32_t suffix; unsigned long op; @@ -92,13 +93,14 @@ svp64_lookup (uint64_t insn, ppc_cpu_t dialect) const struct svp64_record *record; const struct svp64_record *record_start; const struct svp64_record *record_end; - struct svp64_insn svp64_insn = {insn}; - if ((svp64_insn_get_prefix_po (&svp64_insn) != 0x1) || - (svp64_insn_get_prefix_id (&svp64_insn) != 0x3)) + svp64_insn_set (&svp64->insn, insn); + + if ((svp64_insn_get_prefix_po (&svp64->insn) != 0x1) || + (svp64_insn_get_prefix_id (&svp64->insn) != 0x3)) return NULL; - suffix = (uint32_t)svp64_insn_get_suffix (&svp64_insn); + suffix = (uint32_t)svp64_insn_get_suffix (&svp64->insn); opcode = lookup_powerpc (suffix, dialect & ~PPC_OPCODE_ANY); if (opcode == NULL && (dialect & PPC_OPCODE_ANY) != 0) opcode = lookup_powerpc (suffix, dialect); @@ -112,5 +114,7 @@ svp64_lookup (uint64_t insn, ppc_cpu_t dialect) if (record == record_end) return NULL; + svp64->desc = &record->desc; + return opcode; } -- 2.30.2