Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/opcodes/ppc-dis.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* ppc-dis.c -- Disassemble PowerPC instructions
    2    Copyright 1994, 1995, 2000 Free Software Foundation, Inc.
     2   Copyright 1994, 1995, 2000, 2001, 2002 Free Software Foundation, Inc.
    33   Written by Ian Lance Taylor, Cygnus Support
    44
     
    3333                                       int bigendian, int dialect));
    3434
    35 /* Print a big endian PowerPC instruction.  For convenience, also
    36    disassemble instructions supported by the Motorola PowerPC 601
    37    and the Altivec vector unit.  */
     35static int powerpc_dialect PARAMS ((struct disassemble_info *));
     36
     37/* Determine which set of machines to disassemble for.  PPC403/601 or
     38   BookE.  For convenience, also disassemble instructions supported
     39   by the AltiVec vector unit.  */
     40
     41int
     42powerpc_dialect(info)
     43     struct disassemble_info *info;
     44{
     45  int dialect = PPC_OPCODE_PPC | PPC_OPCODE_ALTIVEC;
     46
     47  if (BFD_DEFAULT_TARGET_SIZE == 64)
     48    dialect |= PPC_OPCODE_64;
     49
     50  if (info->disassembler_options
     51      && (strcmp (info->disassembler_options, "booke") == 0
     52          || strcmp (info->disassembler_options, "booke32") == 0
     53          || strcmp (info->disassembler_options, "booke64") == 0))
     54    dialect |= PPC_OPCODE_BOOKE | PPC_OPCODE_BOOKE64;
     55  else
     56    if ((info->mach == bfd_mach_ppc_e500)
     57        || (info->disassembler_options
     58        && (   strcmp (info->disassembler_options, "e500") == 0
     59            || strcmp (info->disassembler_options, "e500x2") == 0)))
     60      {
     61        dialect |= PPC_OPCODE_BOOKE
     62          | PPC_OPCODE_SPE | PPC_OPCODE_ISEL
     63          | PPC_OPCODE_EFS | PPC_OPCODE_BRLOCK
     64          | PPC_OPCODE_PMR | PPC_OPCODE_CACHELCK
     65          | PPC_OPCODE_RFMCI;
     66        /* efs* and AltiVec conflict.  */
     67        dialect &= ~PPC_OPCODE_ALTIVEC;
     68      }
     69  else
     70    if (info->disassembler_options
     71        && (strcmp (info->disassembler_options, "efs") == 0))
     72      {
     73        dialect |= PPC_OPCODE_EFS;
     74        /* efs* and AltiVec conflict.  */
     75        dialect &= ~PPC_OPCODE_ALTIVEC;
     76      }
     77  else
     78    dialect |= (PPC_OPCODE_403 | PPC_OPCODE_601 | PPC_OPCODE_CLASSIC
     79                | PPC_OPCODE_COMMON);
     80
     81  if (info->disassembler_options
     82      && strcmp (info->disassembler_options, "power4") == 0)
     83    dialect |= PPC_OPCODE_POWER4;
     84
     85  if (info->disassembler_options)
     86    {
     87      if (strstr (info->disassembler_options, "32") != NULL)
     88        dialect &= ~PPC_OPCODE_64;
     89      else if (strstr (info->disassembler_options, "64") != NULL)
     90        dialect |= PPC_OPCODE_64;
     91    }
     92
     93  return dialect;
     94}
     95
     96/* Print a big endian PowerPC instruction.  */
    3897
    3998int
     
    42101     struct disassemble_info *info;
    43102{
    44   return print_insn_powerpc (memaddr, info, 1,
    45                              PPC_OPCODE_PPC | PPC_OPCODE_601 |
    46                              PPC_OPCODE_ALTIVEC);
    47 }
    48 
    49 /* Print a little endian PowerPC instruction.  For convenience, also
    50    disassemble instructions supported by the Motorola PowerPC 601
    51    and the Altivec vector unit.  */
     103  return print_insn_powerpc (memaddr, info, 1, powerpc_dialect(info));
     104}
     105
     106/* Print a little endian PowerPC instruction.  */
    52107
    53108int
     
    56111     struct disassemble_info *info;
    57112{
    58   return print_insn_powerpc (memaddr, info, 0,
    59                              PPC_OPCODE_PPC | PPC_OPCODE_601 |
    60                              PPC_OPCODE_ALTIVEC);
     113  return print_insn_powerpc (memaddr, info, 0, powerpc_dialect(info));
    61114}
    62115
     
    124177        continue;
    125178
     179      if ((dialect & PPC_OPCODE_EFS) && (opcode->flags & PPC_OPCODE_ALTIVEC))
     180        continue;
     181
    126182      /* Make two passes over the operands.  First see if any of them
    127183         have extraction functions, and, if they do, make sure the
     
    132188          operand = powerpc_operands + *opindex;
    133189          if (operand->extract)
    134             (*operand->extract) (insn, &invalid);
     190            (*operand->extract) (insn, dialect, &invalid);
    135191        }
    136192      if (invalid)
     
    159215          /* Extract the value from the instruction.  */
    160216          if (operand->extract)
    161             value = (*operand->extract) (insn, (int *) NULL);
     217            value = (*operand->extract) (insn, dialect, (int *) NULL);
    162218          else
    163219            {
     
    207263                  cr = value >> 2;
    208264                  if (cr != 0)
    209                     (*info->fprintf_func) (info->stream, "4*cr%d", cr);
     265                    (*info->fprintf_func) (info->stream, "4*cr%d+", cr);
    210266                  cc = value & 3;
    211                   if (cc != 0)
    212                     {
    213                       if (cr != 0)
    214                         (*info->fprintf_func) (info->stream, "+");
    215                       (*info->fprintf_func) (info->stream, "%s", cbnames[cc]);
    216                     }
     267                  (*info->fprintf_func) (info->stream, "%s", cbnames[cc]);
    217268                }
    218269            }
     
    242293  return 4;
    243294}
     295
     296void
     297print_ppc_disassembler_options (FILE * stream)
     298{
     299  fprintf (stream, "\n\
     300The following PPC specific disassembler options are supported for use with\n\
     301the -M switch:\n");
     302
     303  fprintf (stream, "  booke|booke32|booke64    Disassemble the BookE instructions\n");
     304  fprintf (stream, "  e500|e500x2              Disassemble the e500 instructions\n");
     305  fprintf (stream, "  efs                      Disassemble the EFS instructions\n");
     306  fprintf (stream, "  power4                   Disassemble the Power4 instructions\n");
     307  fprintf (stream, "  32                       Do not disassemble 64-bit instructions\n");
     308  fprintf (stream, "  64                       Allow disassembly of 64-bit instructions\n");
     309}
Note: See TracChangeset for help on using the changeset viewer.