Back to index

cell-binutils  2.17cvs20070401
Classes | Defines | Functions | Variables
or32.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  or32_letter
struct  or32_opcode
struct  insn_op_struct

Defines

#define NUM_UNSIGNED   (0)
#define NUM_SIGNED   (1)
#define MAX_GPRS   32
#define PAGE_SIZE   4096
#define OPERAND_DELIM   (',')
#define OR32_IF_DELAY   (1)
#define OR32_W_FLAG   (2)
#define OR32_R_FLAG   (4)
#define OPTYPE_LAST   (0x80000000)
#define OPTYPE_OP   (0x40000000)
#define OPTYPE_REG   (0x20000000)
#define OPTYPE_SIG   (0x10000000)
#define OPTYPE_DIS   (0x08000000)
#define OPTYPE_DST   (0x04000000)
#define OPTYPE_SBIT   (0x00001F00)
#define OPTYPE_SHR   (0x0000001F)
#define OPTYPE_SBIT_SHR   (8)

Functions

void l_none (void)
int insn_len (int)
int letter_signed (char)
int letter_range (char)
int insn_index (char *)
const char * insn_name (int)
void build_automata (void)
void destruct_automata (void)
int insn_decode (unsigned int)
int disassemble_insn (unsigned long)

Variables

struct insn_op_struct ** op_start
const unsigned int or32_num_opcodes

Class Documentation

struct or32_letter

Definition at line 40 of file or32.h.

Class Members
char letter
int sign
struct insn_op_struct

Definition at line 85 of file or32.h.

Class Members
unsigned long data
unsigned long type

Define Documentation

#define MAX_GPRS   32

Definition at line 30 of file or32.h.

#define NUM_SIGNED   (1)

Definition at line 28 of file or32.h.

#define NUM_UNSIGNED   (0)

Definition at line 27 of file or32.h.

#define OPERAND_DELIM   (',')

Definition at line 34 of file or32.h.

#define OPTYPE_DIS   (0x08000000)

Definition at line 78 of file or32.h.

#define OPTYPE_DST   (0x04000000)

Definition at line 79 of file or32.h.

#define OPTYPE_LAST   (0x80000000)

Definition at line 74 of file or32.h.

#define OPTYPE_OP   (0x40000000)

Definition at line 75 of file or32.h.

#define OPTYPE_REG   (0x20000000)

Definition at line 76 of file or32.h.

#define OPTYPE_SBIT   (0x00001F00)

Definition at line 80 of file or32.h.

#define OPTYPE_SBIT_SHR   (8)

Definition at line 82 of file or32.h.

#define OPTYPE_SHR   (0x0000001F)

Definition at line 81 of file or32.h.

#define OPTYPE_SIG   (0x10000000)

Definition at line 77 of file or32.h.

#define OR32_IF_DELAY   (1)

Definition at line 36 of file or32.h.

#define OR32_R_FLAG   (4)

Definition at line 38 of file or32.h.

#define OR32_W_FLAG   (2)

Definition at line 37 of file or32.h.

#define PAGE_SIZE   4096

Definition at line 31 of file or32.h.


Function Documentation

void build_automata ( void  )

Definition at line 738 of file or32-opc.c.

{
  unsigned int i;
  unsigned long *end;
  struct insn_op_struct *cur;
  
  automata = malloc (MAX_AUTOMATA_SIZE * sizeof (unsigned long));
  ti = malloc (sizeof (struct temp_insn_struct) * or32_num_opcodes);

  nuncovered = or32_num_opcodes;
  printf ("Building automata... ");
  /* Build temporary information about instructions.  */
  for (i = 0; i < or32_num_opcodes; i++)
    {
      unsigned long ones, zeros;
      char *encoding = or32_opcodes[i].encoding;

      ones  = insn_extract('1', encoding);
      zeros = insn_extract('0', encoding);

      ti[i].insn_mask = ones | zeros;
      ti[i].insn = ones;
      ti[i].in_pass = curpass = 0;

      /*debug(9, "%s: %s %08X %08X\n", or32_opcodes[i].name,
       or32_opcodes[i].encoding, ti[i].insn_mask, ti[i].insn);*/
    }
  
  /* Until all are covered search for best criteria to separate them.  */
  end = cover_insn (automata, curpass, 0xFFFFFFFF);

  if (end - automata > MAX_AUTOMATA_SIZE)
    {
      fprintf (stderr, "Automata too large. Increase MAX_AUTOMATA_SIZE.");
      exit (1);
    }

  printf ("done, num uncovered: %i/%i.\n", nuncovered, or32_num_opcodes);
  printf ("Parsing operands data... ");

  op_data = malloc (MAX_OP_TABLE_SIZE * sizeof (struct insn_op_struct));
  op_start = malloc (or32_num_opcodes * sizeof (struct insn_op_struct *));
  cur = op_data;

  for (i = 0; i < or32_num_opcodes; i++)
    {
      op_start[i] = cur;
      cur = parse_params (&or32_opcodes[i], cur);

      if (cur - op_data > MAX_OP_TABLE_SIZE)
       {
         fprintf (stderr, "Operands table too small, increase MAX_OP_TABLE_SIZE.\n");
         exit (1);
       }
    }
  printf ("done.\n");
}

Here is the call graph for this function:

void destruct_automata ( void  )

Definition at line 797 of file or32-opc.c.

Here is the call graph for this function:

Definition at line 981 of file or32-opc.c.

{
  int index;
  index = insn_decode (insn);

  if (index >= 0)
    {
      struct or32_opcode const *opcode = &or32_opcodes[index];
      char *s;

      sprintf (disassembled, "%s ", opcode->name);
      for (s = opcode->args; *s != '\0'; ++s)
        {
          switch (*s)
            {
            case '\0':
              return 4;
  
            case 'r':
              or32_print_register (*++s, opcode->encoding, insn);
              break;
  
            default:
              if (strchr (opcode->encoding, *s))
                or32_print_immediate (*s, opcode->encoding, insn);
              else
                sprintf (disassembled, "%s%c", disassembled, *s);
            }
        }
    }
  else
    {
      /* This used to be %8x for binutils.  */
      sprintf (disassembled, "%s.word 0x%08lx", disassembled, insn);
    }

  return insn_len (insn);
}

Here is the call graph for this function:

Definition at line 808 of file or32-opc.c.

{
  unsigned long *a = automata;
  int i;

  while (!(*a & LEAF_FLAG))
    {
      unsigned int first = *a;

      debug (9, "%li ", (long)(a - automata));

      a++;
      i = (insn >> first) & *a;
      a++;
      if (!*(a + i))
       {
         /* Invalid instruction found?  */
         debug (9, "XXX\n");
         return -1;
       }
      a = automata + *(a + i);
    }

  i = *a & ~LEAF_FLAG;

  debug (9, "%i\n", i);

  /* Final check - do we have direct match?
     (based on or32_opcodes this should be the only possibility,
     but in case of invalid/missing instruction we must perform a check)  */
  if ((ti[i].insn_mask & insn) == ti[i].insn) 
    return i;
  else
    return -1;
}

Here is the caller graph for this function:

int insn_index ( char *  )

Definition at line 397 of file or32-opc.c.

{
  unsigned int i;
  int found = -1;

  for (i = 0; i < or32_num_opcodes; i++)
    if (!strcmp (or32_opcodes[i].name, insn))
      {
       found = i;
       break;
      }
  return found;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int insn_len ( int  )

Here is the caller graph for this function:

const char* insn_name ( int  )

Definition at line 412 of file or32-opc.c.

{
  if (index >= 0 && index < (int) or32_num_opcodes)
    return or32_opcodes[index].name;
  else
    return "???";
}

Here is the caller graph for this function:

void l_none ( void  )

Definition at line 421 of file or32-opc.c.

{
}
int letter_range ( char  )

Definition at line 371 of file or32-opc.c.

{
  const struct or32_opcode *pinsn;
  char *enc;
  int range = 0;
  
  for (pinsn = or32_opcodes; strlen (pinsn->name); pinsn ++)
    {
      if (strchr (pinsn->encoding,l))
       {
         for (enc = pinsn->encoding; *enc != '\0'; enc ++)
           if ((*enc == '0') && (*(enc + 1) == 'x'))
             enc += 2;
           else if (*enc == l)
             range++;
         return range;
       }
    }

  printf ("\nABORT: letter_range(%c): Never used letter.\n", l);
  exit (1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int letter_signed ( char  )

Definition at line 356 of file or32-opc.c.

{
  const struct or32_letter *pletter;
  
  for (pletter = or32_letters; pletter->letter != '\0'; pletter++)
    if (pletter->letter == l)
      return pletter->sign;
  
  printf ("letter_signed(%c): Unknown letter.\n", l);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 343 of file or32-opc.c.