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/ia64-gen.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* ia64-gen.c -- Generate a shrunk set of opcode tables
    2    Copyright 1999, 2000 Free Software Foundation, Inc.
     2   Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    33   Written by Bob Manson, Cygnus Solutions, <manson@cygnus.com>
    44
     
    3131
    3232   The resource table is constructed based on some text dependency tables,
    33    which are also easier to maintain than the final representation.
    34 
    35 */
     33   which are also easier to maintain than the final representation.  */
    3634
    3735#include <stdio.h>
    38 #include <ctype.h>
     36#include <stdarg.h>
     37#include <errno.h>
    3938
    4039#include "ansidecl.h"
    4140#include "libiberty.h"
     41#include "safe-ctype.h"
    4242#include "sysdep.h"
     43#include "getopt.h"
    4344#include "ia64-opc.h"
    4445#include "ia64-opc-a.c"
     
    5051#include "ia64-opc-d.c"
    5152
     53#include <libintl.h>
     54#define _(String) gettext (String)
     55
     56const char * program_name = NULL;
    5257int debug = 0;
    5358
     
    5661/* The main opcode table entry.  Each entry is a unique combination of
    5762   name and flags (no two entries in the table compare as being equal
    58    via opcodes_eq). */
     63   via opcodes_eq).  */
    5964struct main_entry
    6065{
    6166  /* The base name of this opcode.  The names of its completers are
    62      appended to it to generate the full instruction name. */
     67     appended to it to generate the full instruction name.  */
    6368  struct string_entry *name;
    6469  /* The base opcode entry.  Which one to use is a fairly arbitrary choice;
    65      it uses the first one passed to add_opcode_entry. */
     70     it uses the first one passed to add_opcode_entry.  */
    6671  struct ia64_opcode *opcode;
    67   /* The list of completers that can be applied to this opcode. */
     72  /* The list of completers that can be applied to this opcode.  */
    6873  struct completer_entry *completers;
    69   /* Next entry in the chain. */
     74  /* Next entry in the chain.  */
    7075  struct main_entry *next;
    71   /* Index in the  main table. */
     76  /* Index in the  main table.  */
    7277  int main_index;
    7378} *maintable, **ordered_table;
     79
    7480int otlen = 0;
    7581int ottotlen = 0;
    7682int opcode_count = 0;
    7783
    78 /* The set of possible completers for an opcode. */
     84/* The set of possible completers for an opcode.  */
    7985struct completer_entry
    8086{
    81   /* This entry's index in the ia64_completer_table[] array. */
     87  /* This entry's index in the ia64_completer_table[] array.  */
    8288  int num;
    8389
    84   /* The name of the completer. */
     90  /* The name of the completer.  */
    8591  struct string_entry *name;
    8692
    87   /* This entry's parent. */
     93  /* This entry's parent.  */
    8894  struct completer_entry *parent;
    8995
    9096  /* Set if this is a terminal completer (occurs at the end of an
    91      opcode). */
     97     opcode).  */
    9298  int is_terminal;
    9399
    94   /* An alternative completer. */
     100  /* An alternative completer.  */
    95101  struct completer_entry *alternative;
    96102
     
    101107     instruction opcode for this combination of opcode and completers.
    102108     Afterwards, it contains those bits that are different from its
    103      parent opcode. */
     109     parent opcode.  */
    104110  ia64_insn bits;
    105111
     
    107113     that are different from its parent completer's opcode (or from
    108114     the base opcode if the entry is the root of the opcode's completer
    109      list).  This field is filled in by compute_completer_bits (). */
     115     list).  This field is filled in by compute_completer_bits ().  */
    110116  ia64_insn mask;
    111117
    112   /* Index into the opcode dependency list, or -1 if none. */
     118  /* Index into the opcode dependency list, or -1 if none.  */
    113119  int dependencies;
    114120
     
    117123};
    118124
    119 /* One entry in the disassembler name table. */
     125/* One entry in the disassembler name table.  */
    120126struct disent
    121127{
    122   /* The index into the ia64_name_dis array for this entry. */
     128  /* The index into the ia64_name_dis array for this entry.  */
    123129  int ournum;
    124130
    125   /* The index into the main_table[] array. */
     131  /* The index into the main_table[] array.  */
    126132  int insn;
    127133
    128   /* The disassmbly priority of this entry. */
     134  /* The disassmbly priority of this entry.  */
    129135  int priority;
    130136
    131   /* The completer_index value for this entry. */
     137  /* The completer_index value for this entry.  */
    132138  int completer_index;
    133139
    134   /* How many other entries share this decode. */
     140  /* How many other entries share this decode.  */
    135141  int nextcnt;
    136142
    137   /* The next entry sharing the same decode. */
     143  /* The next entry sharing the same decode.  */
    138144  struct disent *nexte;
    139145
    140   /* The next entry in the name list. */
     146  /* The next entry in the name list.  */
    141147  struct disent *next_ent;
    142148} *disinsntable = NULL;
    143149
    144150/* A state machine that will eventually be used to generate the
    145    disassembler table. */
     151   disassembler table.  */
    146152struct bittree
    147153{
    148154  struct disent *disent;
    149   struct bittree *bits[3]; /* 0, 1, and X (don't care) */
     155  struct bittree *bits[3]; /* 0, 1, and X (don't care). */
    150156  int bits_to_skip;
    151157  int skip_flag;
     
    155161   alphabetical order.  */
    156162
    157 /* One entry in the string table. */
     163/* One entry in the string table.  */
    158164struct string_entry
    159165{
    160   /* The index in the ia64_strings[] array for this entry. */
     166  /* The index in the ia64_strings[] array for this entry.  */
    161167  int num;
    162   /* And the string. */
     168  /* And the string.  */
    163169  char *s;
    164170} **string_table = NULL;
     171
    165172int strtablen = 0;
    166173int strtabtotlen = 0;
     
    168175
    169176
    170 /* resource dependency entries */
     177/* Resource dependency entries. */
    171178struct rdep
    172179{
    173   char *name;                       /* resource name */
     180  char *name;                       /* Resource name. */
    174181  unsigned
    175     mode:2,                         /* RAW, WAW, or WAR */
    176     semantics:3;                    /* dependency semantics */
    177   char *extra;                      /* additional semantics info */
     182    mode:2,                         /* RAW, WAW, or WAR. */
     183    semantics:3;                    /* Dependency semantics. */
     184  char *extra;                      /* Additional semantics info. */
    178185  int nchks;                   
    179   int total_chks;                   /* total #of terminal insns */
    180   int *chks;                        /* insn classes which read (RAW), write
    181                                        (WAW), or write (WAR) this rsrc */
    182   int *chknotes;                    /* dependency notes for each class */
     186  int total_chks;                   /* Total #of terminal insns. */
     187  int *chks;                        /* Insn classes which read (RAW), write
     188                                       (WAW), or write (WAR) this rsrc. */
     189  int *chknotes;                    /* Dependency notes for each class. */
    183190  int nregs;
    184   int total_regs;                   /* total #of terminal insns */
    185   int *regs;                        /* insn class which write (RAW), write2
    186                                        (WAW), or read (WAR) this rsrc */
    187   int *regnotes;                    /* dependency notes for each class */
    188 
    189   int waw_special;                  /* special WAW dependency note */
     191  int total_regs;                   /* Total #of terminal insns. */
     192  int *regs;                        /* Insn class which write (RAW), write2
     193                                       (WAW), or read (WAR) this rsrc. */
     194  int *regnotes;                    /* Dependency notes for each class. */
     195
     196  int waw_special;                  /* Special WAW dependency note. */
    190197} **rdeps = NULL;
    191198
     
    193200static int rdepstotlen = 0;
    194201
    195 /* array of all instruction classes */
     202/* Array of all instruction classes. */
    196203struct iclass
    197204{
    198   char *name;                       /* instruction class name */
    199   int is_class;                     /* is a class, not a terminal */
     205  char *name;                       /* Instruction class name. */
     206  int is_class;                     /* Is a class, not a terminal. */
    200207  int nsubs;                       
    201   int *subs;                        /* other classes within this class */
     208  int *subs;                        /* Other classes within this class. */
    202209  int nxsubs;                       
    203   int xsubs[4];                     /* exclusions */
    204   char *comment;                    /* optional comment */
    205   int note;                         /* optional note */
    206   int terminal_resolved;            /* did we match this with anything? */
    207   int orphan;                       /* detect class orphans */
     210  int xsubs[4];                     /* Exclusions. */
     211  char *comment;                    /* Optional comment. */
     212  int note;                         /* Optional note. */
     213  int terminal_resolved;            /* Did we match this with anything? */
     214  int orphan;                       /* Detect class orphans. */
    208215} **ics = NULL;
    209216
     
    211218static int ictotlen = 0;
    212219
    213 /* an opcode dependency (chk/reg pair of dependency lists) */
     220/* An opcode dependency (chk/reg pair of dependency lists). */
    214221struct opdep
    215222{
     
    221228static int opdeptotlen = 0;
    222229
    223 /* a generic list of dependencies w/notes encoded.  these may be shared. */
     230/* A generic list of dependencies w/notes encoded.  These may be shared. */
    224231struct deplist
    225232{
     
    231238static int dlisttotlen = 0;
    232239
    233 /* add NAME to the resource table, where TYPE is RAW or WAW */
     240
     241static void fail (const char *, ...);
     242static void warn (const char *, ...);
     243static struct rdep * insert_resource (const char *, enum ia64_dependency_mode);
     244static int  deplist_equals (struct deplist *, struct deplist *);
     245static short insert_deplist (int, unsigned short *);
     246static short insert_dependencies (int, unsigned short *, int, unsigned short *);
     247static void  mark_used (struct iclass *, int);
     248static int  fetch_insn_class (const char *, int);
     249static int  sub_compare (const void *, const void *);
     250static void load_insn_classes (void);
     251static void parse_resource_users (const char *, int **, int *, int **);
     252static int  parse_semantics (char *);
     253static void add_dep (const char *, const char *, const char *, int, int, char *, int);
     254static void load_depfile (const char *, enum ia64_dependency_mode);
     255static void load_dependencies (void);
     256static int  irf_operand (int, const char *);
     257static int  in_iclass_mov_x (struct ia64_opcode *, struct iclass *, const char *, const char *);
     258static int  in_iclass (struct ia64_opcode *, struct iclass *, const char *, const char *, int *);
     259static int  lookup_regindex (const char *, int);
     260static int  lookup_specifier (const char *);
     261static void print_dependency_table (void);
     262static struct string_entry * insert_string (char *);
     263static void gen_dis_table (struct bittree *);
     264static void print_dis_table (void);
     265static void generate_disassembler (void);
     266static void print_string_table (void);
     267static int  completer_entries_eq (struct completer_entry *, struct completer_entry *);
     268static struct completer_entry * insert_gclist (struct completer_entry *);
     269static int  get_prefix_len (const char *);
     270static void compute_completer_bits (struct main_entry *, struct completer_entry *);
     271static void collapse_redundant_completers (void);
     272static int  insert_opcode_dependencies (struct ia64_opcode *, struct completer_entry *);
     273static void insert_completer_entry (struct ia64_opcode *, struct main_entry *, int);
     274static void print_completer_entry (struct completer_entry *);
     275static void print_completer_table (void);
     276static int  opcodes_eq (struct ia64_opcode *, struct ia64_opcode *);
     277static void add_opcode_entry (struct ia64_opcode *);
     278static void print_main_table (void);
     279static void shrink (struct ia64_opcode *);
     280static void print_version (void);
     281static void usage (FILE *, int);
     282static void finish_distable (void);
     283static void insert_bit_table_ent (struct bittree *, int, ia64_insn, ia64_insn, int, int, int);
     284static void add_dis_entry (struct bittree *, ia64_insn, ia64_insn, int, struct completer_entry *, int);
     285static void compact_distree (struct bittree *);
     286static struct bittree * make_bittree_entry (void);
     287static struct disent * add_dis_table_ent (struct disent *, int, int, int);
     288
     289
     290
     291static void
     292fail (const char *message, ...)
     293{
     294  va_list args;
     295 
     296  va_start (args, message);
     297  fprintf (stderr, _("%s: Error: "), program_name);
     298  vfprintf (stderr, message, args);
     299  va_end (args);
     300  xexit (1);
     301}
     302
     303static void
     304warn (const char *message, ...)
     305{
     306  va_list args;
     307
     308  va_start (args, message);
     309
     310  fprintf (stderr, _("%s: Warning: "), program_name);
     311  vfprintf (stderr, message, args);
     312  va_end (args);
     313}
     314
     315/* Add NAME to the resource table, where TYPE is RAW or WAW.  */
    234316static struct rdep *
    235317insert_resource (const char *name, enum ia64_dependency_mode type)
     
    250332}
    251333
    252 /* are the lists of dependency indexes equivalent? */
     334/* Are the lists of dependency indexes equivalent? */
    253335static int
    254336deplist_equals (struct deplist *d1, struct deplist *d2)
     
    259341    return 0;
    260342
    261   for (i=0;i < d1->len;i++)
    262     {
    263       if (d1->deps[i] != d2->deps[i])
    264         return 0;
    265     }
     343  for (i = 0; i < d1->len; i++)
     344    if (d1->deps[i] != d2->deps[i])
     345      return 0;
    266346
    267347  return 1;
    268348}
    269349
    270 /* add the list of dependencies to the list of dependency lists */
     350/* Add the list of dependencies to the list of dependency lists. */
    271351static short
    272 insert_deplist(int count, unsigned short *deps)
    273 {
    274   /* sort the list, then see if an equivalent list exists already.
    275      this results in a much smaller set of dependency lists
    276    */
     352insert_deplist (int count, unsigned short *deps)
     353{
     354  /* Sort the list, then see if an equivalent list exists already.
     355     this results in a much smaller set of dependency lists.  */
    277356  struct deplist *list;
    278357  char set[0x10000];
    279358  int i;
    280359
    281   memset ((void *)set, 0, sizeof(set));
    282   for (i=0;i < count;i++)
     360  memset ((void *)set, 0, sizeof (set));
     361  for (i = 0; i < count; i++)
    283362    set[deps[i]] = 1;
     363
    284364  count = 0;
    285   for (i=0;i < (int)sizeof(set);i++)
     365  for (i = 0; i < (int) sizeof (set); i++)
    286366    if (set[i])
    287367      ++count;
    288368
    289   list = tmalloc(struct deplist);
     369  list = tmalloc (struct deplist);
    290370  list->len = count;
    291   list->deps = (unsigned short *)malloc (sizeof(unsigned short) * count);
    292   for (i=0, count=0;i < (int)sizeof(set);i++)
    293     {
    294       if (set[i])
    295         {
    296           list->deps[count++] = i;
    297         }
    298     }
    299 
    300   /* does this list exist already? */
    301   for (i=0;i < dlistlen;i++)
    302     {
    303       if (deplist_equals (list, dlists[i]))
    304         {
    305           free (list->deps);
    306           free (list);
    307           return i;
    308         }
    309     }
     371  list->deps = (unsigned short *) malloc (sizeof (unsigned short) * count);
     372
     373  for (i = 0, count = 0; i < (int) sizeof (set); i++)
     374    if (set[i])
     375      list->deps[count++] = i;
     376
     377  /* Does this list exist already?  */
     378  for (i = 0; i < dlistlen; i++)
     379    if (deplist_equals (list, dlists[i]))
     380      {
     381        free (list->deps);
     382        free (list);
     383        return i;
     384      }
    310385
    311386  if (dlistlen == dlisttotlen)
     
    320395}
    321396
    322 /* add the given pair of dependency lists to the opcode dependency list */
     397/* Add the given pair of dependency lists to the opcode dependency list. */
    323398static short
    324399insert_dependencies (int nchks, unsigned short *chks,
     
    335410    chkind = insert_deplist (nchks, chks);
    336411
    337   for (i=0;i < opdeplen;i++)
    338     {
    339       if (opdeps[i]->chk == chkind
    340           && opdeps[i]->reg == regind)
    341         return i;
    342     }
    343   pair = tmalloc(struct opdep);
     412  for (i = 0; i < opdeplen; i++)
     413    if (opdeps[i]->chk == chkind
     414        && opdeps[i]->reg == regind)
     415      return i;
     416
     417  pair = tmalloc (struct opdep);
    344418  pair->chk = chkind;
    345419  pair->reg = regind;
     
    365439    ic->terminal_resolved = 1;
    366440
    367   for (i=0;i < ic->nsubs;i++)
    368     {
    369       mark_used (ics[ic->subs[i]], clear_terminals);
    370     }
    371   for (i=0;i < ic->nxsubs;i++)
    372     {
    373       mark_used (ics[ic->xsubs[i]], clear_terminals);
    374     }
    375 }
    376 
    377 /* look up an instruction class; if CREATE make a new one if none found;
    378    returns the index into the insn class array */
     441  for (i = 0; i < ic->nsubs; i++)
     442    mark_used (ics[ic->subs[i]], clear_terminals);
     443
     444  for (i = 0; i < ic->nxsubs; i++)
     445    mark_used (ics[ic->xsubs[i]], clear_terminals);
     446}
     447
     448/* Look up an instruction class; if CREATE make a new one if none found;
     449   returns the index into the insn class array.  */
    379450static int
    380 fetch_insn_class(const char *full_name, int create)
     451fetch_insn_class (const char *full_name, int create)
    381452{
    382453  char *name;
     
    416487    {
    417488      char *nextnotestr;
     489
    418490      note = atoi (notestr + 1);
    419491      if ((nextnotestr = strchr (notestr + 1, '+')) != NULL)
     
    422494            note = 13;
    423495          else if (!xsect || nextnotestr < xsect)
    424             fprintf (stderr, "Warning: multiple note %s not handled\n",
    425                      notestr);
     496            warn (_("multiple note %s not handled\n"), notestr);
    426497        }
    427498    }
     
    438509    }
    439510
    440   for (i=0;i < iclen;i++)
    441     if (strcmp(name, ics[i]->name) == 0
     511  for (i = 0; i < iclen; i++)
     512    if (strcmp (name, ics[i]->name) == 0
    442513        && ((comment == NULL && ics[i]->comment == NULL)
    443514            || (comment != NULL && ics[i]->comment != NULL
     
    450521    return -1;
    451522
    452   /* doesn't exist, so make a new one */
     523  /* Doesn't exist, so make a new one. */
    453524  if (iclen == ictotlen)
    454525    {
    455526      ictotlen += 20;
    456527      ics = (struct iclass **)
    457         xrealloc(ics, (ictotlen)*sizeof(struct iclass *));
    458     }
     528        xrealloc (ics, (ictotlen) * sizeof (struct iclass *));
     529    }
     530
    459531  ind = iclen++;
    460   ics[ind] = tmalloc(struct iclass);
    461   memset((void *)ics[ind], 0, sizeof(struct iclass));
    462   ics[ind]->name = xstrdup(name);
     532  ics[ind] = tmalloc (struct iclass);
     533  memset ((void *)ics[ind], 0, sizeof (struct iclass));
     534  ics[ind]->name = xstrdup (name);
    463535  ics[ind]->is_class = is_class;
    464536  ics[ind]->orphan = 1;
     
    467539    {
    468540      ics[ind]->comment = xstrdup (comment + 1);
    469       ics[ind]->comment[strlen(ics[ind]->comment)-1] = 0;
    470     }
     541      ics[ind]->comment[strlen (ics[ind]->comment)-1] = 0;
     542    }
     543
    471544  if (notestr)
    472545    ics[ind]->note = note;
    473546
    474   /* if it's a composite class, there's a comment or note, look for an
    475      existing class or terminal with the same name. */
     547  /* If it's a composite class, there's a comment or note, look for an
     548     existing class or terminal with the same name.  */
    476549  if ((xsect || comment || notestr) && is_class)
    477550    {
    478551      /* First, populate with the class we're based on.  */
    479552      char *subname = name;
     553
    480554      if (xsect)
    481555        *xsect = 0;
     
    484558      else if (notestr)
    485559        *notestr = 0;
     560
    486561      ics[ind]->nsubs = 1;
    487562      ics[ind]->subs = tmalloc(int);
     
    492567    {
    493568      char *subname = xsect + 1;
     569
    494570      xsect = strchr (subname, '\\');
    495571      if (xsect)
     
    503579}
    504580
    505 /* for sorting a class's sub-class list only; make sure classes appear before
    506    terminals  */
     581/* For sorting a class's sub-class list only; make sure classes appear before
     582   terminals.  */
    507583static int
    508584sub_compare (const void *e1, const void *e2)
     
    523599
    524600static void
    525 load_insn_classes()
    526 {
    527   FILE *fp = fopen("ia64-ic.tbl", "r");
     601load_insn_classes (void)
     602{
     603  FILE *fp = fopen ("ia64-ic.tbl", "r");
    528604  char buf[2048];
    529605
    530   if (fp == NULL){
    531     fprintf (stderr, "Can't find ia64-ic.tbl for reading\n");
    532     exit(1);
    533   }
    534 
    535   /* discard first line */
     606  if (fp == NULL)
     607    fail (_("can't find ia64-ic.tbl for reading\n"));
     608
     609  /* Discard first line.  */
    536610  fgets (buf, sizeof(buf), fp);
    537611
    538   while (!feof(fp))
     612  while (!feof (fp))
    539613    {
    540614      int iclass;
     
    542616      char *tmp;
    543617     
    544       if (fgets (buf, sizeof(buf), fp) == NULL)
     618      if (fgets (buf, sizeof (buf), fp) == NULL)
    545619        break;
    546620     
    547       while (isspace(buf[strlen(buf)-1]))
    548         buf[strlen(buf)-1] = '\0';
     621      while (ISSPACE (buf[strlen (buf) - 1]))
     622        buf[strlen (buf) - 1] = '\0';
    549623
    550624      name = tmp = buf;
     
    552626        {
    553627          ++tmp;
    554           if (tmp == buf + sizeof(buf))
     628          if (tmp == buf + sizeof (buf))
    555629            abort ();
    556630        }
    557631      *tmp++ = '\0';
    558632
    559       iclass = fetch_insn_class(name, 1);
     633      iclass = fetch_insn_class (name, 1);
    560634      ics[iclass]->is_class = 1;
    561635
     
    567641        }
    568642
    569       /* for this class, record all sub-classes */
     643      /* For this class, record all sub-classes. */
    570644      while (*tmp)
    571645        {
     
    573647          int sub;
    574648
    575           while (*tmp && isspace(*tmp))
     649          while (*tmp && ISSPACE (*tmp))
    576650            {
    577651              ++tmp;
    578               if (tmp == buf + sizeof(buf))
    579                 abort();
     652              if (tmp == buf + sizeof (buf))
     653                abort ();
    580654            }
    581655          subname = tmp;
     
    583657            {
    584658              ++tmp;
    585               if (tmp == buf + sizeof(buf))
    586                 abort();
     659              if (tmp == buf + sizeof (buf))
     660                abort ();
    587661            }
    588662          if (*tmp == ',')
     
    590664         
    591665          ics[iclass]->subs = (int *)
    592             xrealloc((void *)ics[iclass]->subs,
    593                      (ics[iclass]->nsubs+1)*sizeof(int));
    594 
    595           sub = fetch_insn_class(subname, 1);
     666            xrealloc ((void *)ics[iclass]->subs,
     667                      (ics[iclass]->nsubs + 1) * sizeof (int));
     668
     669          sub = fetch_insn_class (subname, 1);
    596670          ics[iclass]->subs = (int *)
    597             xrealloc(ics[iclass]->subs, (ics[iclass]->nsubs+1)*sizeof(int));
     671            xrealloc (ics[iclass]->subs, (ics[iclass]->nsubs + 1) * sizeof (int));
    598672          ics[iclass]->subs[ics[iclass]->nsubs++] = sub;
    599673        }
    600       /* make sure classes come before terminals */
     674
     675      /* Make sure classes come before terminals.  */
    601676      qsort ((void *)ics[iclass]->subs,
    602677             ics[iclass]->nsubs, sizeof(int), sub_compare);
    603678    }
    604   fclose(fp);
     679  fclose (fp);
    605680
    606681  if (debug)
    607     {
    608       printf ("%d classes\n", iclen);
    609     }
    610 }
    611 
    612 /* extract the insn classes from the given line */
     682    printf ("%d classes\n", iclen);
     683}
     684
     685/* Extract the insn classes from the given line.  */
    613686static void
    614 parse_resource_users(ref, usersp, nusersp, notesp)
    615   char *ref;
     687parse_resource_users (ref, usersp, nusersp, notesp)
     688  const char *ref;
    616689  int **usersp;
    617690  int *nusersp;
     
    635708      char *name;
    636709     
    637       while (isspace(*tmp))
     710      while (ISSPACE (*tmp))
    638711        ++tmp;
    639712      name = tmp;
     
    643716      *tmp++ = '\0';
    644717     
    645       xsect = strchr(name, '\\');
    646       if ((notestr = strstr(name, "+")) != NULL)
     718      xsect = strchr (name, '\\');
     719      if ((notestr = strstr (name, "+")) != NULL)
    647720        {
    648721          char *nextnotestr;
     722
    649723          note = atoi (notestr + 1);
    650724          if ((nextnotestr = strchr (notestr + 1, '+')) != NULL)
    651725            {
    652               /* note 13 always implies note 1 */
     726              /* Note 13 always implies note 1. */
    653727              if (strcmp (notestr, "+1+13") == 0)
    654728                note = 13;
    655729              else if (!xsect || nextnotestr < xsect)
    656                 fprintf (stderr, "Warning: multiple note %s not handled\n",
    657                          notestr);
     730                warn (_("multiple note %s not handled\n"), notestr);
    658731            }
    659732          if (!xsect)
     
    662735      else
    663736        note = 0;
    664      
     737
    665738      /* All classes are created when the insn class table is parsed;
    666739         Individual instructions might not appear until the dependency tables
    667740         are read.  Only create new classes if it's *not* an insn class,
    668741         or if it's a composite class (which wouldn't necessarily be in the IC
    669          table).
    670       */
    671       if (strncmp(name, "IC:", 3) != 0 || xsect != NULL)
     742         table).  */
     743      if (strncmp (name, "IC:", 3) != 0 || xsect != NULL)
    672744        create = 1;
    673745     
    674       iclass = fetch_insn_class(name, create);
     746      iclass = fetch_insn_class (name, create);
    675747      if (iclass != -1)
    676748        {
    677749          users = (int *)
    678             xrealloc ((void *)users,(count+1)*sizeof(int));
     750            xrealloc ((void *) users,(count + 1) * sizeof (int));
    679751          notes = (int *)
    680             xrealloc ((void *)notes,(count+1)*sizeof(int));
     752            xrealloc ((void *) notes,(count + 1) * sizeof (int));
    681753          notes[count] = note;
    682754          users[count++] = iclass;
    683755          mark_used (ics[iclass], 0);
    684756        }
    685       else
    686         {
    687           if (debug)
    688             printf("Class %s not found\n", name);
    689         }
    690     }
    691   /* update the return values */
     757      else if (debug)
     758        printf("Class %s not found\n", name);
     759    }
     760  /* Update the return values.  */
    692761  *usersp = users;
    693762  *nusersp = count;
     
    725794
    726795  rs = insert_resource (name, mode);
    727   parse_resource_users (chk, &rs->chks, &rs->nchks,
    728                         &rs->chknotes);
    729   parse_resource_users (reg, &rs->regs, &rs->nregs,
    730                         &rs->regnotes);
     796
     797  parse_resource_users (chk, &rs->chks, &rs->nchks, &rs->chknotes);
     798  parse_resource_users (reg, &rs->regs, &rs->nregs, &rs->regnotes);
     799
    731800  rs->semantics = semantics;
    732801  rs->extra = extra;
     
    737806load_depfile (const char *filename, enum ia64_dependency_mode mode)
    738807{
    739   FILE *fp = fopen(filename, "r");
     808  FILE *fp = fopen (filename, "r");
    740809  char buf[1024];
    741810
    742   if (fp == NULL){
    743     fprintf (stderr, "Can't find %s for reading\n", filename);
    744     exit(1);
    745   }
    746 
    747   fgets(buf, sizeof(buf), fp);
    748   while (!feof(fp))
     811  if (fp == NULL)
     812    fail (_("can't find %s for reading\n"), filename);
     813
     814  fgets (buf, sizeof(buf), fp);
     815  while (!feof (fp))
    749816    {
    750817      char *name, *tmp;
     
    756823        break;
    757824
    758       while (isspace(buf[strlen(buf)-1]))
    759         buf[strlen(buf)-1] = '\0';
     825      while (ISSPACE (buf[strlen (buf) - 1]))
     826        buf[strlen (buf) - 1] = '\0';
    760827
    761828      name = tmp = buf;
     
    764831      *tmp++ = '\0';
    765832     
    766       while (isspace (*tmp))
     833      while (ISSPACE (*tmp))
    767834        ++tmp;
    768835      regp = tmp;
     
    771838        abort ();
    772839      *tmp++ = 0;
    773       while (isspace (*tmp))
     840      while (ISSPACE (*tmp))
    774841        ++tmp;
    775842      chkp = tmp;
     
    778845        abort ();
    779846      *tmp++ = 0;
    780       while (isspace (*tmp))
     847      while (ISSPACE (*tmp))
    781848        ++tmp;
    782849      semantics = parse_semantics (tmp);
     
    785852      /* For WAW entries, if the chks and regs differ, we need to enter the
    786853         entries in both positions so that the tables will be parsed properly,
    787          without a lot of extra work */
     854         without a lot of extra work. */
    788855      if (mode == IA64_DV_WAW && strcmp (regp, chkp) != 0)
    789856        {
     
    796863        }
    797864    }
    798   fclose(fp);
     865  fclose (fp);
    799866}
    800867
    801868static void
    802 load_dependencies()
     869load_dependencies (void)
    803870{
    804871  load_depfile ("ia64-raw.tbl", IA64_DV_RAW);
     
    807874
    808875  if (debug)
    809       printf ("%d RAW/WAW/WAR dependencies\n", rdepslen);
    810 }
    811 
    812 /* is the given operand an indirect register file operand? */
     876    printf ("%d RAW/WAW/WAR dependencies\n", rdepslen);
     877}
     878
     879/* Is the given operand an indirect register file operand? */
    813880static int
    814881irf_operand (int op, const char *field)
     
    834901}
    835902
    836 /* handle mov_ar, mov_br, mov_cr, mov_indirect, mov_ip, mov_pr, mov_psr, and
    837    mov_um insn classes */
     903/* Handle mov_ar, mov_br, mov_cr, mov_indirect, mov_ip, mov_pr, mov_psr, and
     904   mov_um insn classes. */
    838905static int
    839906in_iclass_mov_x (struct ia64_opcode *idesc, struct iclass *ic,
     
    9491016}
    9501017
    951 
    952 /* is the given opcode in the given insn class? */
     1018/* Is the given opcode in the given insn class?  */
    9531019static int
    954 in_iclass(struct ia64_opcode *idesc, struct iclass *ic,
    955           const char *format, const char *field, int *notep)
     1020in_iclass (struct ia64_opcode *idesc, struct iclass *ic,
     1021           const char *format, const char *field, int *notep)
    9561022{
    9571023  int i;
     
    9621028      if (!strncmp (ic->comment, "Format", 6))
    9631029        {
    964           /* assume that the first format seen is the most restrictive, and
    965              only keep a later one if it looks like it's more restrictive. */
     1030          /* Assume that the first format seen is the most restrictive, and
     1031             only keep a later one if it looks like it's more restrictive.  */
    9661032          if (format)
    9671033            {
    9681034              if (strlen (ic->comment) < strlen (format))
    9691035                {
    970                   fprintf (stderr, "Warning: most recent format '%s'\n"
    971                            "appears more restrictive than '%s'\n",
    972                            ic->comment, format);
     1036                  warn (_("most recent format '%s'\nappears more restrictive than '%s'\n"),
     1037                        ic->comment, format);
    9731038                  format = ic->comment;
    9741039                }
     
    9801045        {
    9811046          if (field)
    982             fprintf (stderr, "Overlapping field %s->%s\n",
    983                      ic->comment, field);
     1047            warn (_("overlapping field %s->%s\n"),
     1048                  ic->comment, field);
    9841049          field = ic->comment;
    9851050        }
    9861051    }
    9871052
    988   /* an insn class matches anything that is the same followed by completers,
     1053  /* An insn class matches anything that is the same followed by completers,
    9891054     except when the absence and presence of completers constitutes different
    990      instructions */
     1055     instructions. */
    9911056  if (ic->nsubs == 0 && ic->nxsubs == 0)
    9921057    {
     
    9991064                      || idesc->name[len] == '.'));
    10001065
    1001       /* all break and nop variations must match exactly */
     1066      /* All break, nop, and hint variations must match exactly. */
    10021067      if (resolved &&
    10031068          (strcmp (ic->name, "break") == 0
    1004            || strcmp (ic->name, "nop") == 0))
     1069           || strcmp (ic->name, "nop") == 0
     1070           || strcmp (ic->name, "hint") == 0))
    10051071        resolved = strcmp (ic->name, idesc->name) == 0;
    10061072
    1007       /* assume restrictions in the FORMAT/FIELD negate resolution,
    1008          unless specifically allowed by clauses in this block */
     1073      /* Assume restrictions in the FORMAT/FIELD negate resolution,
     1074         unless specifically allowed by clauses in this block. */
    10091075      if (resolved && field)
    10101076        {
    1011           /* check Field(sf)==sN against opcode sN */
     1077          /* Check Field(sf)==sN against opcode sN. */
    10121078          if (strstr(field, "(sf)==") != NULL)
    10131079            {
    10141080              char *sf;
     1081
    10151082              if ((sf = strstr (idesc->name, ".s")) != 0)
    1016                 {
    1017                   resolved = strcmp (sf + 1, strstr (field, "==") + 2) == 0;
    1018                 }
     1083                resolved = strcmp (sf + 1, strstr (field, "==") + 2) == 0;
    10191084            }
    1020           /* check Field(lftype)==XXX */
     1085          /* Check Field(lftype)==XXX. */
    10211086          else if (strstr (field, "(lftype)") != NULL)
    10221087            {
     
    10261091                resolved = strstr (field, "fault") == NULL;
    10271092            }
    1028           /* handle Field(ctype)==XXX */
     1093          /* Handle Field(ctype)==XXX. */
    10291094          else if (strstr (field, "(ctype)") != NULL)
    10301095            {
     
    10471112            }
    10481113        }
     1114
    10491115      if (resolved && format)
    10501116        {
     
    10771143        }
    10781144
    1079       /* misc brl variations ('.cond' is optional);
    1080          plain brl matches brl.cond */
     1145      /* Misc brl variations ('.cond' is optional);
     1146         plain brl matches brl.cond. */
    10811147      if (!resolved
    10821148          && (strcmp (idesc->name, "brl") == 0
     
    10871153        }
    10881154
    1089       /* misc br variations ('.cond' is optional) */
     1155      /* Misc br variations ('.cond' is optional). */
    10901156      if (!resolved
    10911157          && (strcmp (idesc->name, "br") == 0
     
    11021168        }
    11031169
    1104       /* probe variations */
     1170      /* probe variations. */
    11051171      if (!resolved && strncmp (idesc->name, "probe", 5) == 0)
    11061172        {
     
    11091175                 ^ (format && strstr (format, "M40") != NULL));
    11101176        }
    1111       /* mov variations */
     1177
     1178      /* mov variations.  */
    11121179      if (!resolved && is_mov)
    11131180        {
    11141181          if (plain_mov)
    11151182            {
    1116               /* mov alias for fmerge */
     1183              /* mov alias for fmerge. */
    11171184              if (strcmp (ic->name, "fmerge") == 0)
    11181185                {
     
    11201187                    && idesc->operands[1] == IA64_OPND_F3;
    11211188                }
    1122               /* mov alias for adds (r3 or imm14) */
     1189              /* mov alias for adds (r3 or imm14). */
    11231190              else if (strcmp (ic->name, "adds") == 0)
    11241191                {
     
    11271194                                  || (idesc->operands[1] == IA64_OPND_IMM14)));
    11281195                }
    1129               /* mov alias for addl */
     1196              /* mov alias for addl. */
    11301197              else if (strcmp (ic->name, "addl") == 0)
    11311198                {
     
    11341201                }
    11351202            }
    1136           /* some variants of mov and mov.[im] */
     1203
     1204          /* Some variants of mov and mov.[im].  */
    11371205          if (!resolved && strncmp (ic->name, "mov_", 4) == 0)
    1138             {
    1139               resolved = in_iclass_mov_x (idesc, ic, format, field);
    1140             }
     1206            resolved = in_iclass_mov_x (idesc, ic, format, field);
    11411207        }
    11421208
    1143       /* keep track of this so we can flag any insn classes which aren't
    1144          mapped onto at least one real insn */
     1209      /* Keep track of this so we can flag any insn classes which aren't
     1210         mapped onto at least one real insn. */
    11451211      if (resolved)
    1146         {
    1147           ic->terminal_resolved = 1;
    1148         }
    1149     }
    1150   else for (i=0;i < ic->nsubs;i++)
    1151     {
    1152       if (in_iclass(idesc, ics[ic->subs[i]], format, field, notep))
     1212        ic->terminal_resolved = 1;
     1213    }
     1214  else for (i = 0; i < ic->nsubs; i++)
     1215    {
     1216      if (in_iclass (idesc, ics[ic->subs[i]], format, field, notep))
    11531217        {
    11541218          int j;
    1155           for (j=0;j < ic->nxsubs;j++)
    1156             {
    1157               if (in_iclass(idesc, ics[ic->xsubs[j]], NULL, NULL, NULL))
    1158                 return 0;
    1159             }
     1219
     1220          for (j = 0; j < ic->nxsubs; j++)
     1221            if (in_iclass (idesc, ics[ic->xsubs[j]], NULL, NULL, NULL))
     1222              return 0;
     1223
    11601224          if (debug > 1)
    1161             printf ("%s is in IC %s\n",
    1162                     idesc->name, ic->name);
     1225            printf ("%s is in IC %s\n", idesc->name, ic->name);
     1226
    11631227          resolved = 1;
    11641228          break;
     
    11661230    }
    11671231 
    1168   /* If it's in this IC, add the IC note (if any) to the insn */
     1232  /* If it's in this IC, add the IC note (if any) to the insn. */
    11691233  if (resolved)
    11701234    {
     
    11721236        {
    11731237          if (*notep && *notep != ic->note)
    1174             {
    1175               fprintf (stderr, "Warning: overwriting note %d with note %d"
    1176                        "(IC:%s)\n",
    1177                        *notep, ic->note, ic->name);
    1178             }
     1238            warn (_("overwriting note %d with note %d (IC:%s)\n"),
     1239                  *notep, ic->note, ic->name);
     1240
    11791241          *notep = ic->note;
    11801242        }
     
    12001262      else if (strstr (name, "[RNAT]"))
    12011263        return 19;
     1264      else if (strstr (name, "[FCR]"))
     1265        return 21;
     1266      else if (strstr (name, "[EFLAG]"))
     1267        return 24;
     1268      else if (strstr (name, "[CSD]"))
     1269        return 25;
     1270      else if (strstr (name, "[SSD]"))
     1271        return 26;
     1272      else if (strstr (name, "[CFLG]"))
     1273        return 27;
     1274      else if (strstr (name, "[FSR]"))
     1275        return 28;
     1276      else if (strstr (name, "[FIR]"))
     1277        return 29;
     1278      else if (strstr (name, "[FDR]"))
     1279        return 30;
    12021280      else if (strstr (name, "[CCV]"))
    12031281        return 32;
     
    13581436        return IA64_RS_PRr;
    13591437
    1360       fprintf (stderr, "Warning! Don't know how to specify %% dependency %s\n",
    1361                name);
     1438      warn (_("don't know how to specify %% dependency %s\n"),
     1439            name);
    13621440    }
    13631441  else if (strchr (name, '#'))
     
    13801458        return IA64_RS_RR;
    13811459     
    1382       fprintf (stderr, "Warning! Don't know how to specify # dependency %s\n",
    1383                name);
     1460      warn (_("Don't know how to specify # dependency %s\n"),
     1461            name);
    13841462    }
    13851463  else if (strncmp (name, "AR[FPSR]", 8) == 0)
     
    14051483}
    14061484
    1407 void
     1485static void
    14081486print_dependency_table ()
    14091487{
     
    14181496              if (!ics[i]->nsubs)
    14191497                {
    1420                   fprintf (stderr, "Warning: IC:%s", ics[i]->name);
    14211498                  if (ics[i]->comment)
    1422                     fprintf (stderr, "[%s]", ics[i]->comment);
    1423                   fprintf (stderr, " has no terminals or sub-classes\n");
     1499                    warn (_("IC:%s [%s] has no terminals or sub-classes\n"),
     1500                          ics[i]->name, ics[i]->comment);
     1501                  else
     1502                    warn (_("IC:%s has no terminals or sub-classes\n"),
     1503                          ics[i]->name);
    14241504                }
    14251505            }
     
    14281508              if (!ics[i]->terminal_resolved && !ics[i]->orphan)
    14291509                {
    1430                   fprintf(stderr, "Warning: no insns mapped directly to "
    1431                           "terminal IC %s", ics[i]->name);
    14321510                  if (ics[i]->comment)
    1433                     fprintf(stderr, "[%s] ", ics[i]->comment);
    1434                   fprintf(stderr, "\n");
     1511                    warn (_("no insns mapped directly to terminal IC %s [%s]"),
     1512                          ics[i]->name, ics[i]->comment);
     1513                  else
     1514                    warn (_("no insns mapped directly to terminal IC %s\n"),
     1515                          ics[i]->name);
    14351516                }
    14361517            }
    14371518        }
    14381519
    1439       for (i=0;i < iclen;i++)
     1520      for (i = 0; i < iclen; i++)
    14401521        {
    14411522          if (ics[i]->orphan)
    14421523            {
    14431524              mark_used (ics[i], 1);
    1444               fprintf (stderr, "Warning: class %s is defined but not used\n",
    1445                        ics[i]->name);
     1525              warn (_("class %s is defined but not used\n"),
     1526                    ics[i]->name);
    14461527            }
    14471528        }
    14481529
    1449       if (debug > 1) for (i=0;i < rdepslen;i++)
    1450         { 
    1451           static const char *mode_str[] = { "RAW", "WAW", "WAR" };
    1452           if (rdeps[i]->total_chks == 0)
    1453             {
    1454               fprintf (stderr, "Warning: rsrc %s (%s) has no chks%s\n",
    1455                        rdeps[i]->name, mode_str[rdeps[i]->mode],
    1456                        rdeps[i]->total_regs ? "" : " or regs");
    1457             }
    1458           else if (rdeps[i]->total_regs == 0)
    1459             {
    1460               fprintf (stderr, "Warning: rsrc %s (%s) has no regs\n",
    1461                        rdeps[i]->name, mode_str[rdeps[i]->mode]);
    1462             }
    1463         }
    1464     }
    1465 
    1466   /* the dependencies themselves */
     1530      if (debug > 1)
     1531        for (i = 0; i < rdepslen; i++)
     1532          { 
     1533            static const char *mode_str[] = { "RAW", "WAW", "WAR" };
     1534
     1535            if (rdeps[i]->total_chks == 0)
     1536              warn (_("Warning: rsrc %s (%s) has no chks%s\n"),
     1537                    rdeps[i]->name, mode_str[rdeps[i]->mode],
     1538                    rdeps[i]->total_regs ? "" : " or regs");
     1539            else if (rdeps[i]->total_regs == 0)
     1540              warn (_("rsrc %s (%s) has no regs\n"),
     1541                    rdeps[i]->name, mode_str[rdeps[i]->mode]);
     1542          }
     1543    }
     1544
     1545  /* The dependencies themselves.  */
    14671546  printf ("static const struct ia64_dependency\ndependencies[] = {\n");
    1468   for (i=0;i < rdepslen;i++)
     1547  for (i = 0; i < rdepslen; i++)
    14691548    {
    14701549      /* '%', '#', AR[], CR[], or PSR. indicates we need to specify the actual
    1471          resource used */
     1550         resource used. */
    14721551      int specifier = lookup_specifier (rdeps[i]->name);
    14731552      int regindex = lookup_regindex (rdeps[i]->name, specifier);
     
    14841563  printf ("};\n\n");
    14851564
    1486   /* and dependency lists */
     1565  /* And dependency lists. */
    14871566  for (i=0;i < dlistlen;i++)
    14881567    {
     
    15011580    }
    15021581
    1503   /* and opcode dependency list */
     1582  /* And opcode dependency list. */
    15041583  printf ("#define NELS(X) (sizeof(X)/sizeof(X[0]))\n");
    15051584  printf ("static const struct ia64_opcode_dependency\n");
    15061585  printf ("op_dependencies[] = {\n");
    1507   for (i=0;i < opdeplen;i++)
     1586  for (i = 0; i < opdeplen; i++)
    15081587    {
    15091588      printf ("  { ");
     
    15231602
    15241603
    1525 /* Add STR to the string table. */
    1526 
     1604/* Add STR to the string table.  */
    15271605static struct string_entry *
    1528 insert_string (str)
    1529      char *str;
     1606insert_string (char *str)
    15301607{
    15311608  int start = 0, end = strtablen;
     
    15501627
    15511628  if (strcmp (str, string_table[strtablen - 1]->s) > 0)
    1552     {
    1553       i = end;
    1554     }
     1629    i = end;
    15551630  else if (strcmp (str, string_table[0]->s) < 0)
    1556     {
    1557       i = 0;
    1558     }
     1631    i = 0;
    15591632  else
    15601633    {
     
    15651638          i = (start + end) / 2;
    15661639          c = strcmp (str, string_table[i]->s);
     1640
    15671641          if (c < 0)
    1568             {
    1569               end = i - 1;
    1570             }
     1642            end = i - 1;
    15711643          else if (c == 0)
    1572             {
    1573               return string_table[i];
    1574             }
     1644            return string_table[i];
    15751645          else
    1576             {
    1577               start = i + 1;
    1578             }
     1646            start = i + 1;
     1647
    15791648          if (start > end)
    1580             {
    1581               break;
    1582             }
     1649            break;
    15831650        }
    15841651    }
     1652
    15851653  for (; i > 0 && i < strtablen; i--)
    1586     {
    1587       if (strcmp (str, string_table[i - 1]->s) > 0)
    1588         {
    1589           break;
    1590         }
    1591     }
     1654    if (strcmp (str, string_table[i - 1]->s) > 0)
     1655      break;
     1656
    15921657  for (; i < strtablen; i++)
    1593     {
    1594       if (strcmp (str, string_table[i]->s) < 0)
    1595         {
    1596           break;
    1597         }
    1598     }
     1658    if (strcmp (str, string_table[i]->s) < 0)
     1659      break;
     1660
    15991661  for (x = strtablen - 1; x >= i; x--)
    16001662    {
     
    16021664      string_table[x + 1]->num = x + 1;
    16031665    }
     1666
    16041667  string_table[i] = tmalloc (struct string_entry);
    16051668  string_table[i]->s = xstrdup (str);
    16061669  string_table[i]->num = i;
    16071670  strtablen++;
     1671
    16081672  return string_table[i];
    16091673}
    16101674
    16111675
    1612 struct bittree *
    1613 make_bittree_entry ()
     1676static struct bittree *
     1677make_bittree_entry (void)
    16141678{
    16151679  struct bittree *res = tmalloc (struct bittree);
     
    16231687  return res;
    16241688}
    1625 
    1626 
    1627 struct disent *
     1689 
     1690
     1691
     1692static struct disent *
    16281693add_dis_table_ent (which, insn, order, completer_index)
    16291694     struct disent *which;
     
    16411706      ent->nextcnt++;
    16421707      while (ent->nexte != NULL)
    1643         {
    1644           ent = ent->nexte;
    1645         }
     1708        ent = ent->nexte;
     1709
    16461710      ent = (ent->nexte = tmalloc (struct disent));
    16471711    }
     
    16681732
    16691733
    1670 void
     1734static void
    16711735finish_distable ()
    16721736{
     
    16831747
    16841748
    1685 void
     1749static void
    16861750insert_bit_table_ent (curr_ent, bit, opcode, mask,
    16871751                      opcodenum, order, completer_index)
     
    17101774
    17111775  if (mask & m)
    1712     {
    1713       b = (opcode & m) ? 1 : 0;
    1714     }
     1776    b = (opcode & m) ? 1 : 0;
    17151777  else
    1716     {
    1717       b = 2;
    1718     }
     1778    b = 2;
     1779
    17191780  next = curr_ent->bits[b];
    17201781  if (next == NULL)
     
    17281789
    17291790
    1730 void
     1791static void
    17311792add_dis_entry (first, opcode, mask, opcodenum, ent, completer_index)
    17321793     struct bittree *first;
     
    17381799{
    17391800  if (completer_index & (1 << 20))
    1740     {
    1741       abort ();
    1742     }
     1801    abort ();
    17431802
    17441803  while (ent != NULL)
     
    17471806      add_dis_entry (first, newopcode, mask, opcodenum, ent->addl_entries,
    17481807                     (completer_index << 1) | 1);
     1808
    17491809      if (ent->is_terminal)
    17501810        {
     
    17591819
    17601820
    1761 /* This optimization pass combines multiple "don't care" nodes. */
    1762 void
     1821/* This optimization pass combines multiple "don't care" nodes.  */
     1822static void
    17631823compact_distree (ent)
    17641824     struct bittree *ent;
     
    18001860    {
    18011861      struct bittree *i = ent->bits[x];
     1862
    18021863      if (i != NULL)
    1803         {
    1804           compact_distree (i);
    1805         }
     1864        compact_distree (i);
    18061865    }
    18071866}
     
    18141873/* Generate the disassembler state machine corresponding to the tree
    18151874   in ENT.  */
    1816 void
     1875static void
    18171876gen_dis_table (ent)
    18181877     struct bittree *ent;
     
    18241883  int needed_bytes;
    18251884  int zero_count = 0;
    1826   int zero_dest = 0;    /* initialize this with 0 to keep gcc quiet... */
     1885  int zero_dest = 0;    /* Initialize this with 0 to keep gcc quiet... */
    18271886
    18281887  /* If this is a terminal entry, there's no point in skipping any
    1829      bits. */
     1888     bits.  */
    18301889  if (ent->skip_flag && ent->bits[0] == NULL && ent->bits[1] == NULL &&
    18311890      ent->bits[2] == NULL)
    18321891    {
    18331892      if (ent->disent == NULL)
    1834         {
    1835           abort ();
    1836         }
     1893        abort ();
    18371894      else
    1838         {
    1839           ent->skip_flag = 0;
    1840         }
     1895        ent->skip_flag = 0;
    18411896    }
    18421897
    18431898  /* Calculate the amount of space needed for this entry, or at least
    1844      a conservatively large approximation. */
     1899     a conservatively large approximation.  */
    18451900  if (ent->skip_flag)
    1846     {
    1847       totbits += 5;
    1848     }
     1901    totbits += 5;
     1902
    18491903  for (x = 1; x < 3; x++)
    1850     {
    1851       if (ent->bits[x] != NULL)
    1852         {
    1853           totbits += 16;
    1854         }
    1855     }
     1904    if (ent->bits[x] != NULL)
     1905      totbits += 16;
    18561906
    18571907  if (ent->disent != NULL)
    18581908    {
    18591909      if (ent->bits[2] != NULL)
    1860         {
    1861           abort ();
    1862         }
     1910        abort ();
     1911
    18631912      totbits += 16;
    18641913    }
    18651914
    1866   /* Now allocate the space. */
     1915  /* Now allocate the space.  */
    18671916  needed_bytes = (totbits + 7) / 8;
    18681917  if ((needed_bytes + insn_list_len) > tot_insn_list_len)
     
    18761925
    18771926  /* Encode the skip entry by setting bit 6 set in the state op field,
    1878      and store the # of bits to skip immediately after. */
     1927     and store the # of bits to skip immediately after.  */
    18791928  if (ent->skip_flag)
    18801929    {
     
    18891938
    18901939  /* Store an "if (bit is zero)" instruction by setting bit 7 in the
    1891      state op field. */
    1892 
     1940     state op field.  */
    18931941  if (ent->bits[0] != NULL)
    18941942    {
     
    19401988                }
    19411989              else
    1942                 {
    1943                   idest = insn_list_len - our_offset;
    1944                 }
     1990                idest = insn_list_len - our_offset;
    19451991            }
    19461992          else
    1947             {
    1948               idest = ent->disent->ournum;
    1949             }
     1993            idest = ent->disent->ournum;
    19501994
    19511995          /* If the destination offset for the if (bit is 1) test is less
     
    19572001             Note that branchings within the table are relative, and
    19582002             there are no branches that branch past our instruction yet
    1959              so we do not need to adjust any other offsets. */
    1960 
     2003             so we do not need to adjust any other offsets.  */
    19612004          if (x == 1)
    19622005            {
     
    19762019                }
    19772020              else
    1978                 {
    1979                   insn_list[our_offset] |= 0x20;
    1980                 }
     2021                insn_list[our_offset] |= 0x20;
    19812022            }
    19822023          else
     
    20072048                }
    20082049              else
    2009                 {
    2010                   insn_list[our_offset] |= 0x08;
    2011                 }
     2050                insn_list[our_offset] |= 0x08;
    20122051            }
     2052
    20132053          if (debug)
    20142054            {
     
    20162056
    20172057              if (i == NULL)
    2018                 {
    2019                   id |= 32768;
    2020                 }
     2058                id |= 32768;
    20212059              else if (! (id & 32768))
    2022                 {
    2023                   id += our_offset;
    2024                 }
     2060                id += our_offset;
     2061
    20252062              if (x == 1)
    2026                 {
    2027                   printf ("%d: if (1) goto %d\n", our_offset, id);
    2028                 }
     2063                printf ("%d: if (1) goto %d\n", our_offset, id);
    20292064              else
    2030                 {
    2031                   printf ("%d: try %d\n", our_offset, id);
    2032                 }
     2065                printf ("%d: try %d\n", our_offset, id);
    20332066            }
    20342067
    2035           /* Store the address of the entry being branched to. */
     2068          /* Store the address of the entry being branched to.  */
    20362069          while (currbits >= 0)
    20372070            {
     
    20392072
    20402073              if (idest & (1 << currbits))
    2041                 {
    2042                   *byte |= (1 << (7 - (bitsused % 8)));
    2043                 }
     2074                *byte |= (1 << (7 - (bitsused % 8)));
     2075
    20442076              bitsused++;
    20452077              currbits--;
    20462078            }
    20472079
    2048           /* Now generate the states for the entry being branched to. */
     2080          /* Now generate the states for the entry being branched to.  */
    20492081          if (i != NULL)
    2050             {
    2051               gen_dis_table (i);
    2052             }
    2053 
     2082            gen_dis_table (i);
    20542083        }
    20552084    }
     2085
    20562086  if (debug)
    20572087    {
    20582088      if (ent->skip_flag)
    2059         {
    2060           printf ("%d: skipping %d\n", our_offset, ent->bits_to_skip);
    2061         }
     2089        printf ("%d: skipping %d\n", our_offset, ent->bits_to_skip);
    20622090 
    20632091      if (ent->bits[0] != NULL)
    2064         {
    2065           printf ("%d: if (0:%d) goto %d\n", our_offset, zero_count + 1,
    2066                   zero_dest);
    2067         }
    2068     }
     2092        printf ("%d: if (0:%d) goto %d\n", our_offset, zero_count + 1,
     2093                zero_dest);
     2094    }
     2095
    20692096  if (bitsused != totbits)
    2070     {
    2071       abort ();
    2072     }
    2073 }
    2074 
    2075 
    2076 void
    2077 print_dis_table ()
     2097    abort ();
     2098}
     2099
     2100
     2101static void
     2102print_dis_table (void)
    20782103{
    20792104  int x;
     
    20842109    {
    20852110      if ((x > 0) && ((x % 12) == 0))
    2086         {
    2087           printf ("\n");
    2088         }
     2111        printf ("\n");
     2112
    20892113      printf ("0x%02x, ", insn_list[x]);
    20902114    }
     
    21092133
    21102134
    2111 void
    2112 generate_disassembler ()
     2135static void
     2136generate_disassembler (void)
    21132137{
    21142138  int i;
     
    21162140  bittree = make_bittree_entry ();
    21172141
    2118   for (i=0; i < otlen;i++)
     2142  for (i = 0; i < otlen; i++)
    21192143    {
    21202144      struct main_entry *ptr = ordered_table[i];
    21212145
    21222146      if (ptr->opcode->type != IA64_TYPE_DYN)
    2123         {
    2124           add_dis_entry (bittree,
    2125                          ptr->opcode->opcode, ptr->opcode->mask,
    2126                          ptr->main_index,
    2127                          ptr->completers, 1);
    2128         }
     2147        add_dis_entry (bittree,
     2148                       ptr->opcode->opcode, ptr->opcode->mask,
     2149                       ptr->main_index,
     2150                       ptr->completers, 1);
    21292151    }
    21302152
     
    21372159
    21382160
    2139 void
    2140 print_string_table ()
     2161static void
     2162print_string_table (void)
    21412163{
    21422164  int x;
     
    21442166  int blen = 0;
    21452167
    2146   printf ("static const char *ia64_strings[] = {\n");
     2168  printf ("static const char * const ia64_strings[] = {\n");
    21472169  lbuf[0] = '\0';
     2170
    21482171  for (x = 0; x < strtablen; x++)
    21492172    {
     
    21512174     
    21522175      if (strlen (string_table[x]->s) > 75)
    2153         {
    2154           abort ();
    2155         }
     2176        abort ();
     2177
    21562178      sprintf (buf, " \"%s\",", string_table[x]->s);
    21572179      len = strlen (buf);
     2180
    21582181      if ((blen + len) > 75)
    21592182        {
     
    21652188      blen += len;
    21662189    }
     2190
    21672191  if (blen > 0)
    2168     {
    2169       printf (" %s\n", lbuf);
    2170     }
     2192    printf (" %s\n", lbuf);
     2193
    21712194  printf ("};\n\n");
    21722195}
     
    21772200static int glisttotlen = 0;
    21782201
    2179 /* If the completer trees ENT1 and ENT2 are equal, return 1. */
    2180 
    2181 int
     2202/* If the completer trees ENT1 and ENT2 are equal, return 1.  */
     2203
     2204static int
    21822205completer_entries_eq (ent1, ent2)
    21832206     struct completer_entry *ent1, *ent2;
     
    21912214          || ent1->dependencies != ent2->dependencies
    21922215          || ent1->order != ent2->order)
    2193         {
    2194           return 0;
    2195         }
     2216        return 0;
     2217
    21962218      if (! completer_entries_eq (ent1->addl_entries, ent2->addl_entries))
    2197         {
    2198           return 0;
    2199         }
     2219        return 0;
     2220
    22002221      ent1 = ent1->alternative;
    22012222      ent2 = ent2->alternative;
    22022223    }
     2224
    22032225  return ent1 == ent2;
    22042226}
     
    22072229/* Insert ENT into the global list of completers and return it.  If an
    22082230   equivalent entry (according to completer_entries_eq) already exists,
    2209    it is returned instead. */
    2210 struct completer_entry *
    2211 insert_gclist (ent)
    2212      struct completer_entry *ent;
     2231   it is returned instead.  */
     2232static struct completer_entry *
     2233insert_gclist (struct completer_entry *ent)
    22132234{
    22142235  if (ent != NULL)
     
    22392260
    22402261      if (ent->name->num < glist[0]->name->num)
    2241         {
    2242           i = 0;
    2243         }
     2262        i = 0;
    22442263      else if (ent->name->num > glist[end - 1]->name->num)
    2245         {
    2246           i = end;
    2247         }
     2264        i = end;
    22482265      else
    22492266        {
     
    22542271              i = (start + end) / 2;
    22552272              c = ent->name->num - glist[i]->name->num;
     2273
    22562274              if (c < 0)
    2257                 {
    2258                   end = i - 1;
    2259                 }
     2275                end = i - 1;
    22602276              else if (c == 0)
    22612277                {
    22622278                  while (i > 0
    22632279                         && ent->name->num == glist[i - 1]->name->num)
    2264                     {
    2265                       i--;
    2266                     }
     2280                    i--;
     2281
    22672282                  break;
    22682283                }
    22692284              else
    2270                 {
    2271                   start = i + 1;
    2272                 }
     2285                start = i + 1;
     2286
    22732287              if (start > end)
    2274                 {
    2275                   break;
    2276                 }
     2288                break;
    22772289            }
     2290
    22782291          if (c == 0)
    22792292            {
     
    22812294                {
    22822295                  if (ent->name->num != glist[i]->name->num)
    2283                     {
    2284                       break;
    2285                     }
     2296                    break;
     2297
    22862298                  if (completer_entries_eq (ent, glist[i]))
    2287                     {
    2288                       return glist[i];
    2289                     }
     2299                    return glist[i];
     2300
    22902301                  i++;
    22912302                }
    22922303            }
    22932304        }
     2305
    22942306      for (; i > 0 && i < glistlen; i--)
    2295         {
    2296           if (ent->name->num >= glist[i - 1]->name->num)
    2297             {
    2298               break;
    2299             }
    2300         }
     2307        if (ent->name->num >= glist[i - 1]->name->num)
     2308          break;
     2309
    23012310      for (; i < glistlen; i++)
    2302         {
    2303           if (ent->name->num < glist[i]->name->num)
    2304             {
    2305               break;
    2306             }
    2307         }
     2311        if (ent->name->num < glist[i]->name->num)
     2312          break;
     2313
    23082314      for (x = glistlen - 1; x >= i; x--)
    2309         {
    2310           glist[x + 1] = glist[x];
    2311         }
     2315        glist[x + 1] = glist[x];
     2316
    23122317      glist[i] = ent;
    23132318      glistlen++;
     
    23242329
    23252330  if (name[0] == '\0')
    2326     {
    2327       return 0;
    2328     }
     2331    return 0;
    23292332
    23302333  c = strchr (name, '.');
    23312334  if (c != NULL)
    2332     {
    2333       return c - name;
    2334     }
     2335    return c - name;
    23352336  else
    2336     {
    2337       return strlen (name);
    2338     }
     2337    return strlen (name);
    23392338}
    23402339
     
    23582357
    23592358          while (p != NULL && ! p->is_terminal)
    2360             {
    2361               p = p->parent;
    2362             }
     2359            p = p->parent;
    23632360     
    23642361          if (p != NULL)
    2365             {
    2366               p_bits = p->bits;
    2367             }
     2362            p_bits = p->bits;
    23682363          else
    2369             {
    2370               p_bits = ment->opcode->opcode;
    2371             }
     2364            p_bits = ment->opcode->opcode;
    23722365
    23732366          for (x = 0; x < 64; x++)
    23742367            {
    23752368              ia64_insn m = ((ia64_insn) 1) << x;
     2369
    23762370              if ((p_bits & m) != (our_bits & m))
    2377                 {
    2378                   mask |= m;
    2379                 }
     2371                mask |= m;
    23802372              else
    2381                 {
    2382                   our_bits &= ~m;
    2383                 }
     2373                our_bits &= ~m;
    23842374            }
    23852375          ent->bits = our_bits;
     
    23982388
    23992389/* Find identical completer trees that are used in different
    2400    instructions and collapse their entries. */
    2401 void
    2402 collapse_redundant_completers ()
     2390   instructions and collapse their entries.  */
     2391static void
     2392collapse_redundant_completers (void)
    24032393{
    24042394  struct main_entry *ptr;
     
    24082398    {
    24092399      if (ptr->completers == NULL)
    2410         {
    2411           abort ();
    2412         }
     2400        abort ();
     2401
    24132402      compute_completer_bits (ptr, ptr->completers);
    24142403      ptr->completers = insert_gclist (ptr->completers);
     
    24172406  /* The table has been finalized, now number the indexes.  */
    24182407  for (x = 0; x < glistlen; x++)
    2419     {
    2420       glist[x]->num = x;
    2421     }
    2422 }
    2423 
    2424 
    2425 
    2426 /* attach two lists of dependencies to each opcode.
     2408    glist[x]->num = x;
     2409}
     2410
     2411
     2412
     2413/* Attach two lists of dependencies to each opcode.
    24272414   1) all resources which, when already marked in use, conflict with this
    24282415   opcode (chks)
    24292416   2) all resources which must be marked in use when this opcode is used
    2430    (regs)
    2431 */
    2432 int
     2417   (regs).  */
     2418static int
    24332419insert_opcode_dependencies (opc, cmp)
    24342420     struct ia64_opcode *opc;
    24352421     struct completer_entry *cmp ATTRIBUTE_UNUSED;
    24362422{
    2437   /* note all resources which point to this opcode.  rfi has the most chks
    2438      (79) and cmpxchng has the most regs (54) so 100 here should be enough */
     2423  /* Note all resources which point to this opcode.  rfi has the most chks
     2424     (79) and cmpxchng has the most regs (54) so 100 here should be enough. */
    24392425  int i;
    24402426  int nregs = 0;
     
    24422428  int nchks = 0;
    24432429  unsigned short chks[256];
    2444   /* flag insns for which no class matched; there should be none */
     2430  /* Flag insns for which no class matched; there should be none. */
    24452431  int no_class_found = 1;
    24462432
    2447   for (i=0;i < rdepslen;i++)
     2433  for (i = 0; i < rdepslen; i++)
    24482434    {
    24492435      struct rdep *rs = rdeps[i];
     
    24612447          if (in_iclass (opc, ics[rs->regs[j]], NULL, NULL, &ic_note))
    24622448            {
    2463               /* We can ignore ic_note 11 for non PR resources */
     2449              /* We can ignore ic_note 11 for non PR resources. */
    24642450              if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0)
    24652451                ic_note = 0;
     
    24682454                  && ic_note != rs->regnotes[j]
    24692455                  && !(ic_note == 11 && rs->regnotes[j] == 1))
    2470                 fprintf (stderr, "Warning: IC note %d in opcode %s (IC:%s)"
    2471                          " conflicts with resource %s note %d\n",
    2472                          ic_note, opc->name, ics[rs->regs[j]]->name,
    2473                          rs->name, rs->regnotes[j]);
     2456                warn (_("IC note %d in opcode %s (IC:%s) conflicts with resource %s note %d\n"),
     2457                      ic_note, opc->name, ics[rs->regs[j]]->name,
     2458                      rs->name, rs->regnotes[j]);
    24742459              /* Instruction class notes override resource notes.
    24752460                 So far, only note 11 applies to an IC instead of a resource,
    2476                  and note 11 implies note 1.
    2477                */
     2461                 and note 11 implies note 1.  */
    24782462              if (ic_note)
    24792463                regs[nregs++] = RDEP(ic_note, i);
     
    24842468            }
    24852469        }
    2486       for (j=0;j < rs->nchks;j++)
     2470
     2471      for (j = 0; j < rs->nchks; j++)
    24872472        {
    24882473          int ic_note = 0;
     
    24902475          if (in_iclass (opc, ics[rs->chks[j]], NULL, NULL, &ic_note))
    24912476            {
    2492               /* We can ignore ic_note 11 for non PR resources */
     2477              /* We can ignore ic_note 11 for non PR resources. */
    24932478              if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0)
    24942479                ic_note = 0;
     
    24972482                  && ic_note != rs->chknotes[j]
    24982483                  && !(ic_note == 11 && rs->chknotes[j] == 1))
    2499                 fprintf (stderr, "Warning: IC note %d for opcode %s (IC:%s)"
    2500                          " conflicts with resource %s note %d\n",
    2501                          ic_note, opc->name, ics[rs->chks[j]]->name,
    2502                          rs->name, rs->chknotes[j]);
     2484                warn (_("IC note %d for opcode %s (IC:%s) conflicts with resource %s note %d\n"),
     2485                      ic_note, opc->name, ics[rs->chks[j]]->name,
     2486                      rs->name, rs->chknotes[j]);
    25032487              if (ic_note)
    25042488                chks[nchks++] = RDEP(ic_note, i);
     
    25122496
    25132497  if (no_class_found)
    2514     fprintf (stderr, "Warning: opcode %s has no class (ops %d %d %d)\n",
    2515              opc->name,
    2516              opc->operands[0], opc->operands[1], opc->operands[2]);
     2498    warn (_("opcode %s has no class (ops %d %d %d)\n"),
     2499          opc->name,
     2500          opc->operands[0], opc->operands[1], opc->operands[2]);
    25172501
    25182502  return insert_dependencies (nchks, chks, nregs, regs);
     
    25202504
    25212505
    2522 void
     2506static void
    25232507insert_completer_entry (opc, tabent, order)
    25242508     struct ia64_opcode *opc;
     
    25322516
    25332517  if (strlen (opc->name) > 128)
    2534     {
    2535       abort ();
    2536     }
     2518    abort ();
     2519
    25372520  strcpy (pcopy, opc->name);
    25382521  prefix = pcopy + get_prefix_len (pcopy);
     2522
    25392523  if (prefix[0] != '\0')
    2540     {
    2541       prefix++;
    2542     }
     2524    prefix++;
    25432525
    25442526  while (! at_end)
     
    25622544            }
    25632545          else
    2564             {
    2565               ptr = &((*ptr)->alternative);
    2566             }
     2546            ptr = &((*ptr)->alternative);
    25672547        }
     2548
    25682549      if (need_new_ent)
    25692550        {
    25702551          struct completer_entry *nent = tmalloc (struct completer_entry);
     2552
    25712553          nent->name = sent;
    25722554          nent->parent = parent;
     
    25872569
    25882570  if ((*ptr)->is_terminal)
    2589     {
    2590       abort ();
    2591     }
     2571    abort ();
    25922572
    25932573  (*ptr)->is_terminal = 1;
     
    25992579
    26002580
    2601 void
     2581static void
    26022582print_completer_entry (ent)
    26032583     struct completer_entry *ent;
     
    26142594          bits = bits >> 1;
    26152595        }
     2596
    26162597      if (bits & 0xffffffff00000000LL)
    2617         {
    2618           abort ();
    2619         }
     2598        abort ();
    26202599    }
    26212600 
     
    26322611
    26332612
    2634 void
     2613static void
    26352614print_completer_table ()
    26362615{
     
    26392618  printf ("static const struct ia64_completer_table\ncompleter_table[] = {\n");
    26402619  for (x = 0; x < glistlen; x++)
    2641     {
    2642       print_completer_entry (glist[x]);
    2643     }
     2620    print_completer_entry (glist[x]);
    26442621  printf ("};\n\n");
    26452622}
    26462623
    26472624
    2648 int
     2625static int
    26492626opcodes_eq (opc1, opc2)
    26502627     struct ia64_opcode *opc1;
     
    26572634      || (opc1->num_outputs != opc2->num_outputs)
    26582635      || (opc1->flags != opc2->flags))
    2659     {
     2636    return 0;
     2637
     2638  for (x = 0; x < 5; x++)
     2639    if (opc1->operands[x] != opc2->operands[x])
    26602640      return 0;
    2661     }
    2662   for (x = 0; x < 5; x++)
    2663     {
    2664       if (opc1->operands[x] != opc2->operands[x])
    2665         {
    2666           return 0;
    2667         }
    2668     }
     2641
    26692642  plen1 = get_prefix_len (opc1->name);
    26702643  plen2 = get_prefix_len (opc2->name);
     2644
    26712645  if (plen1 == plen2 && (memcmp (opc1->name, opc2->name, plen1) == 0))
    2672     {
    2673       return 1;
    2674     }
     2646    return 1;
     2647
    26752648  return 0;
    26762649}
    26772650
    26782651
    2679 void
     2652static void
    26802653add_opcode_entry (opc)
    26812654     struct ia64_opcode *opc;
     
    26872660
    26882661  if (strlen (opc->name) > 128)
    2689     {
    2690       abort ();
    2691     }
     2662    abort ();
     2663
    26922664  place = &maintable;
    26932665  strcpy (prefix, opc->name);
     
    26972669  /* Walk the list of opcode table entries.  If it's a new
    26982670     instruction, allocate and fill in a new entry.  Note
    2699      the main table is alphabetical by opcode name. */
     2671     the main table is alphabetical by opcode name.  */
    27002672
    27012673  while (*place != NULL)
     
    27082680        }
    27092681      if ((*place)->name->num > name->num)
    2710         {
    2711           break;
    2712         }
     2682        break;
     2683
    27132684      place = &((*place)->next);
    27142685    }
     
    27362707
    27372708
    2738 void
    2739 print_main_table ()
     2709static void
     2710print_main_table (void)
    27402711{
    27412712  struct main_entry *ptr = maintable;
     
    27692740
    27702741
    2771 void
     2742static void
    27722743shrink (table)
    27732744     struct ia64_opcode *table;
     
    27762747
    27772748  for (curr_opcode = 0; table[curr_opcode].name != NULL; curr_opcode++)
    2778     {
    2779       add_opcode_entry (table + curr_opcode);
    2780     }
    2781 }
    2782 
     2749    add_opcode_entry (table + curr_opcode);
     2750}
     2751
     2752
     2753
     2754/* Program options.  */
     2755#define OPTION_SRCDIR   200
     2756
     2757struct option long_options[] =
     2758{
     2759  {"srcdir",  required_argument, NULL, OPTION_SRCDIR},
     2760  {"debug",   no_argument,       NULL, 'd'},
     2761  {"version", no_argument,       NULL, 'V'},
     2762  {"help",    no_argument,       NULL, 'h'},
     2763  {0,         no_argument,       NULL, 0}
     2764};
     2765
     2766static void
     2767print_version (void)
     2768{
     2769  printf ("%s: version 1.0\n", program_name);
     2770  xexit (0);
     2771}
     2772
     2773static void
     2774usage (FILE * stream, int status)
     2775{
     2776  fprintf (stream, "Usage: %s [-V | --version] [-d | --debug] [--srcdir=dirname] [--help]\n",
     2777           program_name);
     2778  xexit (status);
     2779}
    27832780
    27842781int
    2785 main (argc, argv)
    2786      int argc;
    2787      char **argv ATTRIBUTE_UNUSED;
    2788 {
    2789   if (argc > 1)
    2790     {
    2791       debug = 1;
    2792     }
    2793 
    2794   load_insn_classes();
    2795   load_dependencies();
     2782main (int argc, char **argv)
     2783{
     2784  extern int chdir (char *);
     2785  char *srcdir = NULL;
     2786  int c;
     2787 
     2788  program_name = *argv;
     2789  xmalloc_set_program_name (program_name);
     2790
     2791  while ((c = getopt_long (argc, argv, "vVdh", long_options, 0)) != EOF)
     2792    switch (c)
     2793      {
     2794      case OPTION_SRCDIR:
     2795        srcdir = optarg;
     2796        break;
     2797      case 'V':
     2798      case 'v':
     2799        print_version ();
     2800        break;
     2801      case 'd':
     2802        debug = 1;
     2803        break;
     2804      case 'h':
     2805      case '?':
     2806        usage (stderr, 0);
     2807      default:
     2808      case 0:
     2809        break;
     2810      }
     2811
     2812  if (optind != argc)
     2813    usage (stdout, 1);
     2814
     2815  if (srcdir != NULL)
     2816    if (chdir (srcdir) != 0)
     2817      fail (_("unable to change directory to \"%s\", errno = %s\n"),
     2818            srcdir, strerror (errno));
     2819
     2820  load_insn_classes ();
     2821  load_dependencies ();
    27962822
    27972823  shrink (ia64_opcodes_a);
     
    28052831  collapse_redundant_completers ();
    28062832
    2807   printf ("/* This file is automatically generated by ia64-gen.  Do not edit! */\n");
     2833  printf ("/* This file is automatically generated by ia64-gen.  Do not edit!  */\n");
    28082834  print_string_table ();
    28092835  print_dependency_table ();
Note: See TracChangeset for help on using the changeset viewer.