/* 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.
#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
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)
}
}
\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)
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. */
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)
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