Back to index

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

Go to the source code of this file.

Defines

#define ITBL_NUMBER_OF_PROCESSORS   1
#define ITBL_MAX_BITPOS   31
#define ITBL_TYPE   unsigned long
#define ITBL_IS_INSN(insn)   1
#define ITBL_DECODE_PNUM(insn)   0
#define ITBL_ENCODE_PNUM(pnum)   0

Typedefs

typedef ITBL_TYPE t_insn

Enumerations

enum  e_type {
  e_insn, e_dreg, e_regtype0 = e_dreg, e_creg,
  e_greg, e_addr, e_nregtypes = e_greg + 1, e_immed,
  e_ntypes, e_invtype
}
enum  e_processor { e_p0, e_nprocs = ITBL_NUMBER_OF_PROCESSORS, e_invproc }

Functions

int itbl_parse (char *insntbl)
void itbl_init (void)
char * itbl_get_field (char **s)
unsigned long itbl_assemble (char *name, char *operands)
int itbl_disassemble (char *str, unsigned long insn)
int itbl_get_reg_val (char *name, unsigned long *pval)
int itbl_get_val (e_processor processor, e_type type, char *name, unsigned long *pval)
char * itbl_get_name (e_processor processor, e_type type, unsigned long val)
struct itbl_entryitbl_add_reg (int yyproc, int yytype, char *regname, int regnum)
struct itbl_entryitbl_add_insn (int yyproc, char *name, unsigned long value, int sbit, int ebit, unsigned long flags)
struct itbl_fielditbl_add_operand (struct itbl_entry *e, int yytype, int sbit, int ebit, unsigned long flags)

Variables

int itbl_have_entries

Define Documentation

#define ITBL_DECODE_PNUM (   insn)    0

Definition at line 45 of file itbl-ops.h.

#define ITBL_ENCODE_PNUM (   pnum)    0

Definition at line 49 of file itbl-ops.h.

#define ITBL_IS_INSN (   insn)    1

Definition at line 41 of file itbl-ops.h.

#define ITBL_MAX_BITPOS   31

Definition at line 33 of file itbl-ops.h.

#define ITBL_NUMBER_OF_PROCESSORS   1

Definition at line 29 of file itbl-ops.h.

#define ITBL_TYPE   unsigned long

Definition at line 37 of file itbl-ops.h.


Typedef Documentation

typedef ITBL_TYPE t_insn

Definition at line 52 of file itbl-ops.h.


Enumeration Type Documentation

Enumerator:
e_p0 
e_nprocs 
e_invproc 

Definition at line 69 of file itbl-ops.h.

  {
    e_p0,
    e_nprocs = ITBL_NUMBER_OF_PROCESSORS,
    e_invproc               /* invalid processor */
  } e_processor;
enum e_type
Enumerator:
e_insn 
e_dreg 
e_regtype0 
e_creg 
e_greg 
e_addr 
e_nregtypes 
e_immed 
e_ntypes 
e_invtype 

Definition at line 55 of file itbl-ops.h.

  {
    e_insn,
    e_dreg,
    e_regtype0 = e_dreg,
    e_creg,
    e_greg,
    e_addr,
    e_nregtypes = e_greg + 1,
    e_immed,
    e_ntypes,
    e_invtype               /* invalid type */
  } e_type;

Function Documentation

struct itbl_entry* itbl_add_insn ( int  yyproc,
char *  name,
unsigned long  value,
int  sbit,
int  ebit,
unsigned long  flags 
) [read]

Definition at line 208 of file itbl-ops.c.

{
  struct itbl_entry *e;
  e = alloc_entry (get_processor (yyprocessor), e_insn, name, value);
  if (e)
    {
      e->range.sbit = sbit;
      e->range.ebit = ebit;
      e->flags = flags;
      itbl_num_opcodes++;
    }
  return e;
}

Here is the call graph for this function:

struct itbl_field* itbl_add_operand ( struct itbl_entry e,
int  yytype,
int  sbit,
int  ebit,
unsigned long  flags 
) [read]

Definition at line 226 of file itbl-ops.c.

{
  struct itbl_field *f, **last_f;
  if (!e)
    return 0;
  /* Add to end of fields' list.  */
  f = alloc_field (get_type (yytype), sbit, ebit, flags);
  if (f)
    {
      last_f = &e->fields;
      while (*last_f)
       last_f = &(*last_f)->next;
      *last_f = f;
      f->next = 0;
    }
  return f;
}

Here is the call graph for this function:

struct itbl_entry* itbl_add_reg ( int  yyproc,
int  yytype,
char *  regname,
int  regnum 
) [read]

Definition at line 198 of file itbl-ops.c.

{
  return alloc_entry (get_processor (yyprocessor), get_type (yytype), regname,
                    (unsigned long) regnum);
}

Here is the call graph for this function:

unsigned long itbl_assemble ( char *  name,
char *  operands 
)

Definition at line 479 of file itbl-ops.c.

{
  unsigned long opcode;
  struct itbl_entry *e = NULL;
  struct itbl_field *f;
  char *n;
  int processor;

  if (!name || !*name)
    return 0;               /* error!  must have an opcode name/expr */

  /* find entry in list of instructions for all processors */
  for (processor = 0; processor < e_nprocs; processor++)
    {
      e = find_entry_byname (processor, e_insn, name);
      if (e)
       break;
    }
  if (!e)
    return 0;               /* opcode not in table; invalid instruction */
  opcode = build_opcode (e);

  /* parse opcode's args (if any) */
  for (f = e->fields; f; f = f->next)     /* for each arg, ...  */
    {
      struct itbl_entry *r;
      unsigned long value;
      if (!s || !*s)
       return 0;            /* error - not enough operands */
      n = itbl_get_field (&s);
      /* n should be in form $n or 0xhhh (are symbol names valid?? */
      switch (f->type)
       {
       case e_dreg:
       case e_creg:
       case e_greg:
         /* Accept either a string name
                      * or '$' followed by the register number */
         if (*n == '$')
           {
             n++;
             value = strtol (n, 0, 10);
             /* FIXME! could have "0l"... then what?? */
             if (value == 0 && *n != '0')
              return 0;     /* error; invalid operand */
           }
         else
           {
             r = find_entry_byname (e->processor, f->type, n);
             if (r)
              value = r->value;
             else
              return 0;     /* error; invalid operand */
           }
         break;
       case e_addr:
         /* use assembler's symbol table to find symbol */
         /* FIXME!! Do we need this?
                            if so, what about relocs??
                            my_getExpression (&imm_expr, s);
                            return 0;     /-* error; invalid operand *-/
                            break;
                     */
         /* If not a symbol, fall thru to IMMED */
       case e_immed:
         if (*n == '0' && *(n + 1) == 'x')       /* hex begins 0x...  */
           {
             n += 2;
             value = strtol (n, 0, 16);
             /* FIXME! could have "0xl"... then what?? */
           }
         else
           {
             value = strtol (n, 0, 10);
             /* FIXME! could have "0l"... then what?? */
             if (value == 0 && *n != '0')
              return 0;     /* error; invalid operand */
           }
         break;
       default:
         return 0;          /* error; invalid field spec */
       }
      opcode |= apply_range (value, f->range);
    }
  if (s && *s)
    return 0;               /* error - too many operands */
  return opcode;            /* done! */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int itbl_disassemble ( char *  str,
unsigned long  insn 
)

Definition at line 575 of file itbl-ops.c.

{
  e_processor processor;
  struct itbl_entry *e;
  struct itbl_field *f;

  if (!ITBL_IS_INSN (insn))
    return 0;               /* error */
  processor = get_processor (ITBL_DECODE_PNUM (insn));

  /* find entry in list */
  e = find_entry_byval (processor, e_insn, insn, 0);
  if (!e)
    return 0;               /* opcode not in table; invalid instruction */
  strcpy (s, e->name);

  /* Parse insn's args (if any).  */
  for (f = e->fields; f; f = f->next)     /* for each arg, ...  */
    {
      struct itbl_entry *r;
      unsigned long value;

      if (f == e->fields)   /* First operand is preceded by tab.  */
       strcat (s, "\t");
      else                  /* ','s separate following operands.  */
       strcat (s, ",");
      value = extract_range (insn, f->range);
      /* n should be in form $n or 0xhhh (are symbol names valid?? */
      switch (f->type)
       {
       case e_dreg:
       case e_creg:
       case e_greg:
         /* Accept either a string name
            or '$' followed by the register number.  */
         r = find_entry_byval (e->processor, f->type, value, &f->range);
         if (r)
           strcat (s, r->name);
         else
           sprintf (s, "%s$%lu", s, value);
         break;
       case e_addr:
         /* Use assembler's symbol table to find symbol.  */
         /* FIXME!! Do we need this?  If so, what about relocs??  */
         /* If not a symbol, fall through to IMMED.  */
       case e_immed:
         sprintf (s, "%s0x%lx", s, value);
         break;
       default:
         return 0;          /* error; invalid field spec */
       }
    }
  return 1;                 /* Done!  */
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* itbl_get_field ( char **  s)

Definition at line 707 of file itbl-ops.c.

{
  static char n[128];
  char *s;
  int len;

  s = *S;
  if (!s || !*s)
    return 0;
  /* FIXME: This is a weird set of delimiters.  */
  len = strcspn (s, " \t,()");
  ASSERT (128 > len + 1);
  strncpy (n, s, len);
  n[len] = 0;
  if (s[len] == '\0')
    s = 0;                  /* no more args */
  else
    s += len + 1;           /* advance to next arg */

  *S = s;
  return n;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* itbl_get_name ( e_processor  processor,
e_type  type,
unsigned long  val 
)

Definition at line 447 of file itbl-ops.c.

{
  struct itbl_entry *r;
  /* type depends on instruction passed */
  r = find_entry_byval (processor, type, val, 0);
  if (r)
    return r->name;
  else
    return 0;               /* error; invalid operand */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int itbl_get_reg_val ( char *  name,
unsigned long pval 
)

Definition at line 430 of file itbl-ops.c.

{
  e_type t;
  e_processor p;

  for (p = e_p0; p < e_nprocs; p++)
    {
      for (t = e_regtype0; t < e_nregtypes; t++)
       {
         if (itbl_get_val (p, t, name, pval))
           return 1;
       }
    }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int itbl_get_val ( e_processor  processor,
e_type  type,
char *  name,
unsigned long pval 
)

Definition at line 461 of file itbl-ops.c.

{
  struct itbl_entry *r;
  /* type depends on instruction passed */
  r = find_entry_byname (processor, type, name);
  if (r == NULL)
    return 0;
  *pval = r->value;
  return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void itbl_init ( void  )

Definition at line 254 of file itbl-ops.c.

{
  struct itbl_entry *e, **es;
  e_processor procn;
  e_type type;

  if (!itbl_have_entries)
    return;

  /* Since register names don't have a prefix, put them in the symbol table so
     they can't be used as symbols.  This simplifies argument parsing as
     we can let gas parse registers for us.  */
  /* Use symbol_create instead of symbol_new so we don't try to
     output registers into the object file's symbol table.  */

  for (type = e_regtype0; type < e_nregtypes; type++)
    for (procn = e_p0; procn < e_nprocs; procn++)
      {
       es = get_entries (procn, type);
       for (e = *es; e; e = e->next)
         {
           symbol_table_insert (symbol_create (e->name, reg_section,
                                          e->value, &zero_address_frag));
         }
      }
  append_insns_as_macros ();
}

Here is the call graph for this function:

int itbl_parse ( char *  insntbl)

Definition at line 174 of file itbl-ops.c.

{
  extern FILE *yyin;
  extern int yyparse (void);

  yyin = fopen (insntbl, FOPEN_RT);
  if (yyin == 0)
    {
      printf ("Can't open processor instruction specification file \"%s\"\n",
             insntbl);
      return 1;
    }

  while (yyparse ())
    ;

  fclose (yyin);
  itbl_have_entries = 1;
  return 0;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 111 of file itbl-ops.c.