OSDN Git Service

* (REG_CLASS_FROM_CONSTRAINT): Only define if not already defined.
[pf3gnuchains/gcc-fork.git] / gcc / mips-tfile.c
index 2d364fd..c7b7840 100644 (file)
@@ -611,6 +611,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #define saber_stop()
 #endif
 
+/* Include getopt.h for the sake of getopt_long.  */
+#include "getopt.h"
+
 #ifndef __LINE__
 #define __LINE__ 0
 #endif
@@ -895,13 +898,10 @@ enum alloc_type {
    pages.  On systems with a BSD malloc that define USE_MALLOC, the
    MAX_CLUSTER_PAGES should be 1 less than a power of two, since malloc
    adds its overhead, and rounds up to the next power of 2.  Pages are
-   linked together via a linked list.
-
-   If PAGE_SIZE is > 4096, the string length in the shash_t structure
-   can't be represented (assuming there are strings > 4096 bytes).  */
+   linked together via a linked list.  */
 
 #ifndef PAGE_SIZE
-#define PAGE_SIZE 4096         /* size of varray pages */
+#define PAGE_SIZE 32768                /* size of varray pages */
 #endif
 
 #define PAGE_USIZE ((Size_t) PAGE_SIZE)
@@ -950,6 +950,13 @@ typedef struct varray {
   OBJECTS_PER_PAGE (type),     /* objects_last_page */                 \
 }
 
+#define INITIALIZE_VARRAY(x,type)                      \
+do {                                                   \
+  (x)->object_size = sizeof (type);                    \
+  (x)->objects_per_page = OBJECTS_PER_PAGE (type);     \
+  (x)->objects_last_page = OBJECTS_PER_PAGE (type);    \
+} while (0)
+
 /* Master type for indexes within the symbol table.  */
 typedef unsigned long symint_t;
 
@@ -1066,92 +1073,8 @@ typedef struct efdr {
 } efdr_t;
 
 /* Pre-initialized extended file structure.  */
-static efdr_t init_file = 
-{
-  {                    /* FDR structure */
-#ifdef __alpha
-    0,                 /* adr:         memory address of beginning of file */
-    0,                 /* cbLineOffset: byte offset from header for this file ln's */
-    0,                 /* cbLine:      size of lines for this file */
-    0,                 /* cbSs:        number of bytes in the ss */
-    0,                 /* rss:         file name (of source, if known) */
-    0,                 /* issBase:     file's string space */
-    0,                 /* isymBase:    beginning of symbols */
-    0,                 /* csym:        count file's of symbols */
-    0,                 /* ilineBase:   file's line symbols */
-    0,                 /* cline:       count of file's line symbols */
-    0,                 /* ioptBase:    file's optimization entries */
-    0,                 /* copt:        count of file's optimization entries */
-    0,                 /* ipdFirst:    start of procedures for this file */
-    0,                 /* cpd:         count of procedures for this file */
-    0,                 /* iauxBase:    file's auxiliary entries */
-    0,                 /* caux:        count of file's auxiliary entries */
-    0,                 /* rfdBase:     index into the file indirect table */
-    0,                 /* crfd:        count file indirect entries */
-    langC,             /* lang:        language for this file */
-    1,                 /* fMerge:      whether this file can be merged */
-    0,                 /* fReadin:     true if read in (not just created) */
-#ifdef HOST_WORDS_BIG_ENDIAN
-    1,                 /* fBigendian:  if 1, compiled on big endian machine */
-#else
-    0,                 /* fBigendian:  if 1, compiled on big endian machine */
-#endif
-    0,                 /* fTrim:       whether the symbol table was trimmed */
-    GLEVEL_2,          /* glevel:      level this file was compiled with */
-    0,                 /* reserved:    reserved for future use */
-    0,                 /* cbLineOffset: byte offset from header for this file ln's */
-    0,                 /* cbLine:      size of lines for this file */
-#else
-    0,                 /* adr:         memory address of beginning of file */
-    0,                 /* rss:         file name (of source, if known) */
-    0,                 /* issBase:     file's string space */
-    0,                 /* cbSs:        number of bytes in the ss */
-    0,                 /* isymBase:    beginning of symbols */
-    0,                 /* csym:        count file's of symbols */
-    0,                 /* ilineBase:   file's line symbols */
-    0,                 /* cline:       count of file's line symbols */
-    0,                 /* ioptBase:    file's optimization entries */
-    0,                 /* copt:        count of file's optimization entries */
-    0,                 /* ipdFirst:    start of procedures for this file */
-    0,                 /* cpd:         count of procedures for this file */
-    0,                 /* iauxBase:    file's auxiliary entries */
-    0,                 /* caux:        count of file's auxiliary entries */
-    0,                 /* rfdBase:     index into the file indirect table */
-    0,                 /* crfd:        count file indirect entries */
-    langC,             /* lang:        language for this file */
-    1,                 /* fMerge:      whether this file can be merged */
-    0,                 /* fReadin:     true if read in (not just created) */
-#ifdef HOST_WORDS_BIG_ENDIAN
-    1,                 /* fBigendian:  if 1, compiled on big endian machine */
-#else
-    0,                 /* fBigendian:  if 1, compiled on big endian machine */
-#endif
-    GLEVEL_2,          /* glevel:      level this file was compiled with */
-    0,                 /* reserved:    reserved for future use */
-    0,                 /* cbLineOffset: byte offset from header for this file ln's */
-    0,                 /* cbLine:      size of lines for this file */
-#endif
-  },
-
-  (FDR *) 0,           /* orig_fdr:    original file header pointer */
-  (char *) 0,          /* name:        pointer to filename */
-  0,                   /* name_len:    length of filename */
-  0,                   /* void_type:   ptr to aux node for void type */
-  0,                   /* int_type:    ptr to aux node for int type */
-  (scope_t *) 0,       /* cur_scope:   current scope being processed */
-  0,                   /* file_index:  current file # */
-  0,                   /* nested_scopes: # nested scopes */
-  INIT_VARRAY (char),  /* strings:     local string varray */
-  INIT_VARRAY (SYMR),  /* symbols:     local symbols varray */
-  INIT_VARRAY (PDR),   /* procs:       procedure varray */
-  INIT_VARRAY (AUXU),  /* aux_syms:    auxiliary symbols varray */
-
-  (struct efdr *) 0,   /* next_file:   next file structure */
-
-  (shash_t **) 0,      /* shash_head:  string hash table */
-  { 0 },               /* thash_head:  type hash table */
-};
-
+static int init_file_initialized = 0;
+static efdr_t init_file;
 
 static efdr_t *first_file;                     /* first file descriptor */
 static efdr_t **last_file_ptr = &first_file;   /* file descriptor tail */
@@ -1587,6 +1510,7 @@ static unsigned   cur_line_alloc  = 0;            /* # bytes total in buffer */
 static long    line_number     = 0;            /* current input line number */
 static int     debug           = 0;            /* trace functions */
 static int     version         = 0;            /* print version # */
+static int     verbose         = 0;
 static int     had_errors      = 0;            /* != 0 if errors were found */
 static int     rename_output   = 0;            /* != 0 if rename output file*/
 static int     delete_input    = 0;            /* != 0 if delete input after done */
@@ -1651,6 +1575,8 @@ STATIC void       add_unknown_tag PARAMS ((tag_t *));
 STATIC void    add_procedure   PARAMS ((const char *,
                                         const char *));
 
+STATIC void    initialize_init_file    PARAMS ((void));
+
 STATIC void    add_file        PARAMS ((const char *,
                                         const char *));
 
@@ -1739,6 +1665,15 @@ static const pseudo_ops_t pseudo_ops[] = {
 };
 
 \f
+/* Command line options for getopt_long.  */
+
+static const struct option options[] =
+{
+  { "version", 0, 0, 'V' },
+  { "verbose", 0, 0, 'v' },
+  { 0, 0, 0, 0 }
+};
+\f
 /* Add a page to a varray object.  */
 
 STATIC void
@@ -2475,6 +2410,29 @@ add_procedure (func_start, func_end_p1)
 }
 
 \f
+/* Initialize the init_file structure.  */
+
+STATIC void
+initialize_init_file ()
+{
+  memset ((void*) &init_file, 0, sizeof (init_file));
+
+  init_file.fdr.lang = langC;
+  init_file.fdr.fMerge = 1;
+  init_file.fdr.glevel = GLEVEL_2;
+
+#ifdef HOST_WORDS_BIG_ENDIAN
+  init_file.fdr.fBigendian = 1;
+#endif
+
+  INITIALIZE_VARRAY (&init_file.strings, char);
+  INITIALIZE_VARRAY (&init_file.symbols, SYMR);
+  INITIALIZE_VARRAY (&init_file.procs, PDR);
+  INITIALIZE_VARRAY (&init_file.aux_syms, AUXU);
+
+  init_file_initialized = 1;
+}
+
 /* Add a new filename, and set up all of the file relative
    virtual arrays (strings, symbols, aux syms, etc.).  Record
    where the current file structure lives.  */
@@ -2513,6 +2471,9 @@ add_file (file_start, file_end_p1)
       if (file_desc.objects_last_page == file_desc.objects_per_page)
        add_varray_page (&file_desc);
 
+      if (! init_file_initialized)
+       initialize_init_file ();
+
       file_ptr = cur_file_ptr
        = &file_desc.last->datum->file[ file_desc.objects_last_page++ ];
       *file_ptr = init_file;
@@ -4858,7 +4819,7 @@ main (argc, argv)
   void_type_info = type_info_init;
   void_type_info.basic_type = bt_Void;
 
-  while ((option = getopt (argc, argv, "d:i:I:o:v")) != EOF)
+  while ((option = getopt_long (argc, argv, "d:i:I:o:v", options, NULL)) != -1)
     switch (option)
       {
       default:
@@ -4898,10 +4859,24 @@ main (argc, argv)
        break;
 
       case 'v':
+       verbose++;
+       break;
+
+      case 'V':
        version++;
        break;
       }
 
+  if (version)
+    {
+      printf (_("mips-tfile (GCC) %s\n"), version_string);
+      fputs (_("Copyright (C) 2003 Free Software Foundation, Inc.\n"), stdout);
+      fputs (_("This is free software; see the source for copying conditions.  There is NO\n\
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
+            stdout);
+      exit (0);
+    }
+
   if (obj_in_name == (char *) 0 && optind <= argc - 2)
     obj_in_name = argv[--argc];
 
@@ -4917,7 +4892,19 @@ main (argc, argv)
       delete_input = 1;
     }
 
-  if (object_name == (char *) 0 || had_errors || optind != argc - 1)
+  if (optind != argc - 1)
+    had_errors++;
+
+  if (verbose || had_errors)
+    {
+      fprintf (stderr, _("mips-tfile (GCC) %s"), version_string);
+#ifdef TARGET_VERSION
+      TARGET_VERSION;
+#endif
+      fputc ('\n', stderr);
+    }
+
+  if (object_name == (char *) 0 || had_errors)
     {
       fprintf (stderr, _("Calling Sequence:\n"));
       fprintf (stderr, _("\tmips-tfile [-d <num>] [-v] [-i <o-in-file>] -o <o-out-file> <s-file> (or)\n"));
@@ -4932,16 +4919,6 @@ main (argc, argv)
       return 1;
     }
 
-
-  if (version)
-    {
-      fprintf (stderr, _("mips-tfile version %s"), version_string);
-#ifdef TARGET_VERSION
-      TARGET_VERSION;
-#endif
-      fputc ('\n', stderr);
-    }
-
   if (obj_in_name == (char *) 0)
     obj_in_name = object_name;
 
@@ -5561,12 +5538,12 @@ free_thead (ptr)
 \f
 /* Output an error message and exit */
 
-/*VARARGS*/
 void
-fatal VPARAMS ((const char *format, ...))
+fatal (const char *format, ...)
 {
-  VA_OPEN (ap, format);
-  VA_FIXEDARG (ap, const char *, format);
+  va_list ap;
+  
+  va_start (ap, format);
 
   if (line_number > 0)
     fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
@@ -5574,7 +5551,7 @@ fatal VPARAMS ((const char *format, ...))
     fprintf (stderr, "%s:", progname);
 
   vfprintf (stderr, format, ap);
-  VA_CLOSE (ap);
+  va_end (ap);
   fprintf (stderr, "\n");
   if (line_number > 0)
     fprintf (stderr, "line:\t%s\n", cur_line_start);
@@ -5583,12 +5560,12 @@ fatal VPARAMS ((const char *format, ...))
   exit (1);
 }
 
-/*VARARGS*/
 void
-error VPARAMS ((const char *format, ...))
+error (const char *format, ...)
 {
-  VA_OPEN (ap, format);
-  VA_FIXEDARG (ap, char *, format);
+  va_list ap;
+  
+  va_start (ap, format);
 
   if (line_number > 0)
     fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
@@ -5601,7 +5578,7 @@ error VPARAMS ((const char *format, ...))
     fprintf (stderr, "line:\t%s\n", cur_line_start);
 
   had_errors++;
-  VA_CLOSE (ap);
+  va_end (ap);
 
   saber_stop ();
 }