aboutsummaryrefslogtreecommitdiff
path: root/opcodes/ppc-dis.c
diff options
context:
space:
mode:
authorPeter Bergner <bergner@vnet.ibm.com>2008-06-13 20:16:00 +0000
committerPeter Bergner <bergner@vnet.ibm.com>2008-06-13 20:16:00 +0000
commitfa452fa6833cbb3088361ac35f4c51716afde520 (patch)
tree6917de78cd81cfeb39fb48674abadb80a17239ec /opcodes/ppc-dis.c
parent6ae37fefeb44d97562e8ca67413e418893653a9b (diff)
downloadfsf-binutils-gdb-fa452fa6833cbb3088361ac35f4c51716afde520.zip
fsf-binutils-gdb-fa452fa6833cbb3088361ac35f4c51716afde520.tar.gz
fsf-binutils-gdb-fa452fa6833cbb3088361ac35f4c51716afde520.tar.bz2
include/opcode/
* ppc.h (ppc_cpu_t): New typedef. (struct powerpc_opcode <flags>): Use it. (struct powerpc_operand <insert, extract>): Likewise. (struct powerpc_macro <flags>): Likewise. gas/ * config/tc-ppc.c (ppc_cpu): Use ppc_cpu_t typedef. (ppc_insert_operand): Likewise. (ppc_machine): Likewise. * config/tc-ppc.h: #include "opcode/ppc.h" (struct _ppc_fix_extra <ppc_cpu>): Use ppc_cpu_t typedef. (ppc_cpu): Update extern decl. opcodes/ * ppc-dis.c (print_insn_powerpc): Update prototye to use new ppc_cpu_t typedef. (struct dis_private): New. (POWERPC_DIALECT): New define. (powerpc_dialect): Renamed to... (powerpc_init_dialect): This. Update to use ppc_cpu_t and struct dis_private. (print_insn_big_powerpc): Update for using structure in info->private_data. (print_insn_little_powerpc): Likewise. (operand_value_powerpc): Change type of dialect param to ppc_cpu_t. (skip_optional_operands): Likewise. (print_insn_powerpc): Likewise. Remove initialization of dialect. * ppc-opc.c (extract_bat, extract_bba, extract_bdm, extract_bdp, extract_bo, extract_boe, extract_fxm, extract_mb6, extract_mbe, extract_nb, extract_nsi, extract_rbs, extract_sh6, extract_spr, extract_sprg, extract_tbr insert_bat, insert_bba, insert_bdm, insert_bdp, insert_bo, insert_boe, insert_fxm, insert_mb6, insert_mbe, insert_nsi, insert_ral, insert_ram, insert_raq, insert_ras, insert_rbs, insert_sh6, insert_spr, insert_sprg, insert_tbr): Change the dialect param to be of type ppc_cpu_t. Update prototype.
Diffstat (limited to 'opcodes/ppc-dis.c')
-rw-r--r--opcodes/ppc-dis.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
index e5bae64..de586dc 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -30,17 +30,30 @@
are provided because this file handles disassembly for the PowerPC
in both big and little endian mode and also for the POWER (RS/6000)
chip. */
+static int print_insn_powerpc (bfd_vma, struct disassemble_info *, int,
+ ppc_cpu_t);
-static int print_insn_powerpc (bfd_vma, struct disassemble_info *, int, int);
+struct dis_private
+{
+ /* Stash the result of parsing disassembler_options here. */
+ ppc_cpu_t dialect;
+};
+
+#define POWERPC_DIALECT(INFO) \
+ (((struct dis_private *) ((INFO)->private_data))->dialect)
/* Determine which set of machines to disassemble for. PPC403/601 or
BookE. For convenience, also disassemble instructions supported
by the AltiVec vector unit. */
static int
-powerpc_dialect (struct disassemble_info *info)
+powerpc_init_dialect (struct disassemble_info *info)
{
- int dialect = PPC_OPCODE_PPC;
+ ppc_cpu_t dialect = PPC_OPCODE_PPC;
+ struct dis_private *priv = calloc (sizeof (*priv), 1);
+
+ if (priv == NULL)
+ return FALSE;
if (BFD_DEFAULT_TARGET_SIZE == 64)
dialect |= PPC_OPCODE_64;
@@ -107,8 +120,10 @@ powerpc_dialect (struct disassemble_info *info)
dialect |= PPC_OPCODE_64;
}
- info->private_data = (char *) 0 + dialect;
- return dialect;
+ info->private_data = priv;
+ POWERPC_DIALECT(info) = dialect;
+
+ return TRUE;
}
/* Print a big endian PowerPC instruction. */
@@ -116,8 +131,9 @@ powerpc_dialect (struct disassemble_info *info)
int
print_insn_big_powerpc (bfd_vma memaddr, struct disassemble_info *info)
{
- int dialect = (char *) info->private_data - (char *) 0;
- return print_insn_powerpc (memaddr, info, 1, dialect);
+ if (info->private_data == NULL && !powerpc_init_dialect (info))
+ return -1;
+ return print_insn_powerpc (memaddr, info, 1, POWERPC_DIALECT(info));
}
/* Print a little endian PowerPC instruction. */
@@ -125,8 +141,9 @@ print_insn_big_powerpc (bfd_vma memaddr, struct disassemble_info *info)
int
print_insn_little_powerpc (bfd_vma memaddr, struct disassemble_info *info)
{
- int dialect = (char *) info->private_data - (char *) 0;
- return print_insn_powerpc (memaddr, info, 0, dialect);
+ if (info->private_data == NULL && !powerpc_init_dialect (info))
+ return -1;
+ return print_insn_powerpc (memaddr, info, 0, POWERPC_DIALECT(info));
}
/* Print a POWER (RS/6000) instruction. */
@@ -141,7 +158,7 @@ print_insn_rs6000 (bfd_vma memaddr, struct disassemble_info *info)
static long
operand_value_powerpc (const struct powerpc_operand *operand,
- unsigned long insn, int dialect)
+ unsigned long insn, ppc_cpu_t dialect)
{
long value;
int invalid;
@@ -171,7 +188,7 @@ operand_value_powerpc (const struct powerpc_operand *operand,
static int
skip_optional_operands (const unsigned char *opindex,
- unsigned long insn, int dialect)
+ unsigned long insn, ppc_cpu_t dialect)
{
const struct powerpc_operand *operand;
@@ -193,7 +210,7 @@ static int
print_insn_powerpc (bfd_vma memaddr,
struct disassemble_info *info,
int bigendian,
- int dialect)
+ ppc_cpu_t dialect)
{
bfd_byte buffer[4];
int status;
@@ -202,9 +219,6 @@ print_insn_powerpc (bfd_vma memaddr,
const struct powerpc_opcode *opcode_end;
unsigned long op;
- if (dialect == 0)
- dialect = powerpc_dialect (info);
-
status = (*info->read_memory_func) (memaddr, buffer, 4, info);
if (status != 0)
{