OSDN Git Service

Workaround for Itanium A/B step errata
[pf3gnuchains/gcc-fork.git] / gcc / genextract.c
index 52a615a..76cde0e 100644 (file)
@@ -1,5 +1,6 @@
 /* Generate code from machine description to extract operands from insn as rtl.
-   Copyright (C) 1987, 91-93, 97-98, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1987, 1991, 1992, 1993, 1997, 1998,
+   1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -22,15 +23,10 @@ Boston, MA 02111-1307, USA.  */
 #include "hconfig.h"
 #include "system.h"
 #include "rtl.h"
-#include "obstack.h"
 #include "errors.h"
 #include "insn-config.h"
+#include "gensupport.h"
 
-static struct obstack obstack;
-struct obstack *rtl_obstack = &obstack;
-
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
 
 /* This structure contains all the information needed to describe one
    set of extractions methods.  Each method may be used by more than 
@@ -97,10 +93,10 @@ static int dupnums[MAX_DUP_OPERANDS];
 
 static struct code_ptr *peepholes;
 
-static void gen_insn PROTO ((rtx));
-static void walk_rtx PROTO ((rtx, const char *));
-static void print_path PROTO ((const char *));
-static void record_insn_name PROTO((int, const char *));
+static void gen_insn PARAMS ((rtx));
+static void walk_rtx PARAMS ((rtx, const char *));
+static void print_path PARAMS ((const char *));
+static void record_insn_name PARAMS ((int, const char *));
 
 static void
 gen_insn (insn)
@@ -344,43 +340,7 @@ print_path (path)
     }
 }
 \f
-PTR
-xmalloc (size)
-  size_t size;
-{
-  register PTR val = (PTR) malloc (size);
-
-  if (val == 0)
-    fatal ("virtual memory exhausted");
-  return val;
-}
-
-PTR
-xrealloc (old, size)
-  PTR old;
-  size_t size;
-{
-  register PTR ptr;
-  if (old)
-    ptr = (PTR) realloc (old, size);
-  else
-    ptr = (PTR) malloc (size);
-  if (!ptr)
-    fatal ("virtual memory exhausted");
-  return ptr;
-}
-
-char *
-xstrdup (input)
-  const char *input;
-{
-  register size_t len = strlen (input) + 1;
-  register char *output = xmalloc (len);
-  memcpy (output, input, len);
-  return output;
-}
-\f
-extern int main PROTO ((int, char **));
+extern int main PARAMS ((int, char **));
 
 int
 main (argc, argv)
@@ -388,25 +348,18 @@ main (argc, argv)
      char **argv;
 {
   rtx desc;
-  FILE *infile;
-  int c, i;
+  int i;
   struct extraction *p;
   struct code_ptr *link;
   const char *name;
 
   progname = "genextract";
-  obstack_init (rtl_obstack);
 
   if (argc <= 1)
     fatal ("No input file name.");
 
-  infile = fopen (argv[1], "r");
-  if (infile == 0)
-    {
-      perror (argv[1]);
-      return (FATAL_EXIT_CODE);
-    }
-  read_rtx_filename = argv[1];
+  if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
+    return (FATAL_EXIT_CODE);
 
   /* Assign sequential codes to all entries in the machine description
      in parallel with the tables in insn-output.c.  */
@@ -445,17 +398,16 @@ from the machine description file `md'.  */\n\n");
 
   while (1)
     {
-      c = read_skip_spaces (infile);
-      if (c == EOF)
+      int line_no;
+
+      desc = read_md_rtx (&line_no, &insn_code_number);
+      if (desc == NULL)
        break;
-      ungetc (c, infile);
 
-      desc = read_rtx (infile);
-      if (GET_CODE (desc) == DEFINE_INSN)
+       if (GET_CODE (desc) == DEFINE_INSN)
        {
          record_insn_name (insn_code_number, XSTR (desc, 0));
          gen_insn (desc);
-         ++insn_code_number;
        }
 
       else if (GET_CODE (desc) == DEFINE_PEEPHOLE)
@@ -466,13 +418,7 @@ from the machine description file `md'.  */\n\n");
          link->insn_code = insn_code_number;
          link->next = peepholes;
          peepholes = link;
-         ++insn_code_number;
        }
-
-      else if (GET_CODE (desc) == DEFINE_EXPAND
-              || GET_CODE (desc) == DEFINE_PEEPHOLE2
-              || GET_CODE (desc) == DEFINE_SPLIT)
-       ++insn_code_number;
     }
 
   /* Write out code to handle peepholes and the insn_codes that it should