From: Dmitry Selyutin Date: Sun, 28 May 2023 22:04:57 +0000 (+0300) Subject: ppc/svp64: obtain SVP64 disassembly context X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4cbfb0868ade81db80f76078f4dc1e15e7356e9a;p=binutils-gdb.git ppc/svp64: obtain SVP64 disassembly context --- diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c index 81b9f5bcb12..9cdc7e359f5 100644 --- a/opcodes/ppc-dis.c +++ b/opcodes/ppc-dis.c @@ -952,7 +952,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 ATTRIBUTE_UNUSED) { const ppc_opindex_t *opindex; const struct powerpc_operand *operand; @@ -1142,6 +1143,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. */ @@ -1168,6 +1171,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) @@ -1185,9 +1189,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; } @@ -1248,7 +1253,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 c6bda0a84b3..2ffecff825a 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,8 @@ svp64_lookup (uint64_t insn, ppc_cpu_t dialect) if (record == NULL) return NULL; + svp64->name = record->name; + svp64->desc = &record->desc; + return opcode; }