OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [opcodes/] [ia64-gen.c] - Diff between revs 157 and 225

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 157 Rev 225
Line 1... Line 1...
/* ia64-gen.c -- Generate a shrunk set of opcode tables
/* ia64-gen.c -- Generate a shrunk set of opcode tables
   Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007
   Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009
   Free Software Foundation, Inc.
   Free Software Foundation, Inc.
   Written by Bob Manson, Cygnus Solutions, <manson@cygnus.com>
   Written by Bob Manson, Cygnus Solutions, <manson@cygnus.com>
 
 
   This file is part of the GNU opcodes library.
   This file is part of the GNU opcodes library.
 
 
Line 692... Line 692...
    printf ("%d classes\n", iclen);
    printf ("%d classes\n", iclen);
}
}
 
 
/* Extract the insn classes from the given line.  */
/* Extract the insn classes from the given line.  */
static void
static void
parse_resource_users (ref, usersp, nusersp, notesp)
parse_resource_users (const char *ref, int **usersp, int *nusersp,
  const char *ref;
                      int **notesp)
  int **usersp;
 
  int *nusersp;
 
  int **notesp;
 
{
{
  int c;
  int c;
  char *line = xstrdup (ref);
  char *line = xstrdup (ref);
  char *tmp = line;
  char *tmp = line;
  int *users = *usersp;
  int *users = *usersp;
Line 1435... Line 1432...
        return IA64_RS_AR;
        return IA64_RS_AR;
      if (strstr (name, "AR%, % in 48") != NULL)
      if (strstr (name, "AR%, % in 48") != NULL)
        return IA64_RS_ARb;
        return IA64_RS_ARb;
      if (strstr (name, "BR%") != NULL)
      if (strstr (name, "BR%") != NULL)
        return IA64_RS_BR;
        return IA64_RS_BR;
 
      if (strstr (name, "CR[IIB%]") != NULL)
 
        return IA64_RS_CR_IIB;
      if (strstr (name, "CR[IRR%]") != NULL)
      if (strstr (name, "CR[IRR%]") != NULL)
        return IA64_RS_CR_IRR;
        return IA64_RS_CR_IRR;
      if (strstr (name, "CR[LRR%]") != NULL)
      if (strstr (name, "CR[LRR%]") != NULL)
        return IA64_RS_CR_LRR;
        return IA64_RS_CR_LRR;
      if (strstr (name, "CR%") != NULL)
      if (strstr (name, "CR%") != NULL)
Line 1500... Line 1499...
 
 
  return IA64_RS_ANY;
  return IA64_RS_ANY;
}
}
 
 
static void
static void
print_dependency_table ()
print_dependency_table (void)
{
{
  int i, j;
  int i, j;
 
 
  if (debug)
  if (debug)
    {
    {
Line 1722... Line 1721...
  return res;
  return res;
}
}
 
 


static struct disent *
static struct disent *
add_dis_table_ent (which, insn, order, completer_index)
add_dis_table_ent (struct disent *which, int insn, int order,
     struct disent *which;
                   int completer_index)
     int insn;
 
     int order;
 
     int completer_index;
 
{
{
  int ci = 0;
  int ci = 0;
  struct disent *ent;
  struct disent *ent;
 
 
  if (which != NULL)
  if (which != NULL)
Line 1763... Line 1759...
  ent->completer_index = ci;
  ent->completer_index = ci;
  return which;
  return which;
}
}


static void
static void
finish_distable ()
finish_distable (void)
{
{
  struct disent *ent = disinsntable;
  struct disent *ent = disinsntable;
  struct disent *prev = ent;
  struct disent *prev = ent;
 
 
  ent->ournum = 32768;
  ent->ournum = 32768;
Line 1777... Line 1773...
      prev = ent;
      prev = ent;
    }
    }
}
}


static void
static void
insert_bit_table_ent (curr_ent, bit, opcode, mask,
insert_bit_table_ent (struct bittree *curr_ent, int bit, ia64_insn opcode,
                      opcodenum, order, completer_index)
                      ia64_insn mask, int opcodenum, int order,
     struct bittree *curr_ent;
                      int completer_index)
     int bit;
 
     ia64_insn opcode;
 
     ia64_insn mask;
 
     int opcodenum;
 
     int order;
 
     int completer_index;
 
{
{
  ia64_insn m;
  ia64_insn m;
  int b;
  int b;
  struct bittree *next;
  struct bittree *next;
 
 
Line 1818... Line 1808...
  insert_bit_table_ent (next, bit - 1, opcode, mask, opcodenum, order,
  insert_bit_table_ent (next, bit - 1, opcode, mask, opcodenum, order,
                        completer_index);
                        completer_index);
}
}


static void
static void
add_dis_entry (first, opcode, mask, opcodenum, ent, completer_index)
add_dis_entry (struct bittree *first, ia64_insn opcode, ia64_insn mask,
     struct bittree *first;
               int opcodenum, struct completer_entry *ent, int completer_index)
     ia64_insn opcode;
 
     ia64_insn mask;
 
     int opcodenum;
 
     struct completer_entry *ent;
 
     int completer_index;
 
{
{
  if (completer_index & (1 << 20))
  if (completer_index & (1 << 20))
    abort ();
    abort ();
 
 
  while (ent != NULL)
  while (ent != NULL)
Line 1848... Line 1833...
    }
    }
}
}


/* This optimization pass combines multiple "don't care" nodes.  */
/* This optimization pass combines multiple "don't care" nodes.  */
static void
static void
compact_distree (ent)
compact_distree (struct bittree *ent)
     struct bittree *ent;
 
{
{
#define IS_SKIP(ent) \
#define IS_SKIP(ent) \
    ((ent->bits[2] !=NULL) \
    ((ent->bits[2] !=NULL) \
     && (ent->bits[0] == NULL && ent->bits[1] == NULL && ent->skip_flag == 0))
     && (ent->bits[0] == NULL && ent->bits[1] == NULL && ent->skip_flag == 0))
 
 
Line 1900... Line 1884...
static int tot_insn_list_len = 0;
static int tot_insn_list_len = 0;
 
 
/* Generate the disassembler state machine corresponding to the tree
/* Generate the disassembler state machine corresponding to the tree
   in ENT.  */
   in ENT.  */
static void
static void
gen_dis_table (ent)
gen_dis_table (struct bittree *ent)
     struct bittree *ent;
 
{
{
  int x;
  int x;
  int our_offset = insn_list_len;
  int our_offset = insn_list_len;
  int bitsused = 5;
  int bitsused = 5;
  int totbits = bitsused;
  int totbits = bitsused;
Line 2225... Line 2208...
static int glisttotlen = 0;
static int glisttotlen = 0;
 
 
/* If the completer trees ENT1 and ENT2 are equal, return 1.  */
/* If the completer trees ENT1 and ENT2 are equal, return 1.  */
 
 
static int
static int
completer_entries_eq (ent1, ent2)
completer_entries_eq (struct completer_entry *ent1,
     struct completer_entry *ent1, *ent2;
                      struct completer_entry *ent2)
{
{
  while (ent1 != NULL && ent2 != NULL)
  while (ent1 != NULL && ent2 != NULL)
    {
    {
      if (ent1->name->num != ent2->name->num
      if (ent1->name->num != ent2->name->num
          || ent1->bits != ent2->bits
          || ent1->bits != ent2->bits
Line 2343... Line 2326...
    }
    }
  return ent;
  return ent;
}
}


static int
static int
get_prefix_len (name)
get_prefix_len (const char *name)
     const char *name;
 
{
{
  char *c;
  char *c;
 
 
  if (name[0] == '\0')
  if (name[0] == '\0')
    return 0;
    return 0;
Line 2359... Line 2341...
  else
  else
    return strlen (name);
    return strlen (name);
}
}


static void
static void
compute_completer_bits (ment, ent)
compute_completer_bits (struct main_entry *ment, struct completer_entry *ent)
     struct main_entry *ment;
 
     struct completer_entry *ent;
 
{
{
  while (ent != NULL)
  while (ent != NULL)
    {
    {
      compute_completer_bits (ment, ent->addl_entries);
      compute_completer_bits (ment, ent->addl_entries);
 
 
Line 2434... Line 2414...
   1) all resources which, when already marked in use, conflict with this
   1) all resources which, when already marked in use, conflict with this
   opcode (chks)
   opcode (chks)
   2) all resources which must be marked in use when this opcode is used
   2) all resources which must be marked in use when this opcode is used
   (regs).  */
   (regs).  */
static int
static int
insert_opcode_dependencies (opc, cmp)
insert_opcode_dependencies (struct ia64_opcode *opc,
     struct ia64_opcode *opc;
                            struct completer_entry *cmp ATTRIBUTE_UNUSED)
     struct completer_entry *cmp ATTRIBUTE_UNUSED;
 
{
{
  /* Note all resources which point to this opcode.  rfi has the most chks
  /* Note all resources which point to this opcode.  rfi has the most chks
     (79) and cmpxchng has the most regs (54) so 100 here should be enough.  */
     (79) and cmpxchng has the most regs (54) so 100 here should be enough.  */
  int i;
  int i;
  int nregs = 0;
  int nregs = 0;
Line 2521... Line 2500...
 
 
  return insert_dependencies (nchks, chks, nregs, regs);
  return insert_dependencies (nchks, chks, nregs, regs);
}
}


static void
static void
insert_completer_entry (opc, tabent, order)
insert_completer_entry (struct ia64_opcode *opc, struct main_entry *tabent,
     struct ia64_opcode *opc;
                        int order)
     struct main_entry *tabent;
 
     int order;
 
{
{
  struct completer_entry **ptr = &tabent->completers;
  struct completer_entry **ptr = &tabent->completers;
  struct completer_entry *parent = NULL;
  struct completer_entry *parent = NULL;
  char pcopy[129], *prefix;
  char pcopy[129], *prefix;
  int at_end = 0;
  int at_end = 0;
Line 2595... Line 2572...
  (*ptr)->dependencies = insert_opcode_dependencies (opc, *ptr);
  (*ptr)->dependencies = insert_opcode_dependencies (opc, *ptr);
  (*ptr)->order = order;
  (*ptr)->order = order;
}
}


static void
static void
print_completer_entry (ent)
print_completer_entry (struct completer_entry *ent)
     struct completer_entry *ent;
 
{
{
  int moffset = 0;
  int moffset = 0;
  ia64_insn mask = ent->mask, bits = ent->bits;
  ia64_insn mask = ent->mask, bits = ent->bits;
 
 
  if (mask != 0)
  if (mask != 0)
Line 2626... Line 2602...
          ent->is_terminal ? 1 : 0,
          ent->is_terminal ? 1 : 0,
          ent->dependencies);
          ent->dependencies);
}
}


static void
static void
print_completer_table ()
print_completer_table (void)
{
{
  int x;
  int x;
 
 
  printf ("static const struct ia64_completer_table\ncompleter_table[] = {\n");
  printf ("static const struct ia64_completer_table\ncompleter_table[] = {\n");
  for (x = 0; x < glistlen; x++)
  for (x = 0; x < glistlen; x++)
    print_completer_entry (glist[x]);
    print_completer_entry (glist[x]);
  printf ("};\n\n");
  printf ("};\n\n");
}
}


static int
static int
opcodes_eq (opc1, opc2)
opcodes_eq (struct ia64_opcode *opc1, struct ia64_opcode *opc2)
     struct ia64_opcode *opc1;
 
     struct ia64_opcode *opc2;
 
{
{
  int x;
  int x;
  int plen1, plen2;
  int plen1, plen2;
 
 
  if ((opc1->mask != opc2->mask) || (opc1->type != opc2->type)
  if ((opc1->mask != opc2->mask) || (opc1->type != opc2->type)
Line 2663... Line 2637...
 
 
  return 0;
  return 0;
}
}


static void
static void
add_opcode_entry (opc)
add_opcode_entry (struct ia64_opcode *opc)
     struct ia64_opcode *opc;
 
{
{
  struct main_entry **place;
  struct main_entry **place;
  struct string_entry *name;
  struct string_entry *name;
  char prefix[129];
  char prefix[129];
  int found_it = 0;
  int found_it = 0;
Line 2751... Line 2724...
    }
    }
  printf ("};\n\n");
  printf ("};\n\n");
}
}


static void
static void
shrink (table)
shrink (struct ia64_opcode *table)
     struct ia64_opcode *table;
 
{
{
  int curr_opcode;
  int curr_opcode;
 
 
  for (curr_opcode = 0; table[curr_opcode].name != NULL; curr_opcode++)
  for (curr_opcode = 0; table[curr_opcode].name != NULL; curr_opcode++)
    {
    {

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.