read-md.h (read_md_file): Declare.
gcc/ * read-md.h (read_md_file): Declare. (read_char, unread_char): New functions. (fatal_with_file_and_line, fatal_expected_char, read_skip_spaces) (read_quoted_string, read_string): Remove FILE * argument. * read-md.c (read_md_file): New variable. (read_md_filename, read_md_lineno): Update comments and remove unnecessary initialization. (fatal_with_file_and_line, fatal_expected_char, read_skip_spaces) (read_escape, read_quoted_string, read_braced_string, read_string): Remove FILE * argument. Update calls accordingly, using read_char and unread_char instead of getc and ungetc. * rtl.h (read_rtx): Remove FILE * argument. * read-rtl.c (iterator_group): Remove FILE * argument from "find_builtin". (iterator_traverse_data): Remove "infile" field. (find_mode, find_code, apply_mode_maps, apply_iterator_to_rtx) (add_mapping, read_name, read_constants, read_conditions) (validate_const_int, find_iterator, read_mapping, check_code_iterator) (read_rtx, read_rtx_1, read_rtx_variadic): Remove FILE * argument. Remove file arguments from all calls, using read_char and unread_char instead of getc and ungetc. * gensupport.c (process_include): Preserve read_md_file around the include. Set read_md_file to the handle of the included file. Update call to read_rtx. (init_md_reader_args_cb): Set read_md_file to the handle of the file and remove local FILE *. Update calls to read_rtx. From-SVN: r160572
This commit is contained in:
parent
d2a3ce4e33
commit
c5e88b399c
@ -1,3 +1,32 @@
|
||||
2010-06-10 Richard Sandiford <rdsandiford@googlemail.com>
|
||||
|
||||
* read-md.h (read_md_file): Declare.
|
||||
(read_char, unread_char): New functions.
|
||||
(fatal_with_file_and_line, fatal_expected_char, read_skip_spaces)
|
||||
(read_quoted_string, read_string): Remove FILE * argument.
|
||||
* read-md.c (read_md_file): New variable.
|
||||
(read_md_filename, read_md_lineno): Update comments and remove
|
||||
unnecessary initialization.
|
||||
(fatal_with_file_and_line, fatal_expected_char, read_skip_spaces)
|
||||
(read_escape, read_quoted_string, read_braced_string, read_string):
|
||||
Remove FILE * argument. Update calls accordingly, using read_char
|
||||
and unread_char instead of getc and ungetc.
|
||||
* rtl.h (read_rtx): Remove FILE * argument.
|
||||
* read-rtl.c (iterator_group): Remove FILE * argument from
|
||||
"find_builtin".
|
||||
(iterator_traverse_data): Remove "infile" field.
|
||||
(find_mode, find_code, apply_mode_maps, apply_iterator_to_rtx)
|
||||
(add_mapping, read_name, read_constants, read_conditions)
|
||||
(validate_const_int, find_iterator, read_mapping, check_code_iterator)
|
||||
(read_rtx, read_rtx_1, read_rtx_variadic): Remove FILE * argument.
|
||||
Remove file arguments from all calls, using read_char and unread_char
|
||||
instead of getc and ungetc.
|
||||
* gensupport.c (process_include): Preserve read_md_file around
|
||||
the include. Set read_md_file to the handle of the included file.
|
||||
Update call to read_rtx.
|
||||
(init_md_reader_args_cb): Set read_md_file to the handle of the file
|
||||
and remove local FILE *. Update calls to read_rtx.
|
||||
|
||||
2010-06-10 Richard Sandiford <rdsandiford@googlemail.com>
|
||||
|
||||
* read-md.h (read_rtx_lineno): Rename to...
|
||||
|
@ -194,7 +194,7 @@ process_include (rtx desc, int lineno)
|
||||
const char *old_filename;
|
||||
int old_lineno;
|
||||
char *pathname;
|
||||
FILE *input_file;
|
||||
FILE *input_file, *old_file;
|
||||
|
||||
/* If specified file name is absolute, skip the include stack. */
|
||||
if (! IS_ABSOLUTE_PATH (filename))
|
||||
@ -231,8 +231,10 @@ process_include (rtx desc, int lineno)
|
||||
/* Save old cursor; setup new for the new file. Note that "lineno" the
|
||||
argument to this function is the beginning of the include statement,
|
||||
while read_md_lineno has already been advanced. */
|
||||
old_file = read_md_file;
|
||||
old_filename = read_md_filename;
|
||||
old_lineno = read_md_lineno;
|
||||
read_md_file = input_file;
|
||||
read_md_filename = pathname;
|
||||
read_md_lineno = 1;
|
||||
|
||||
@ -240,12 +242,13 @@ process_include (rtx desc, int lineno)
|
||||
include_callback (pathname);
|
||||
|
||||
/* Read the entire file. */
|
||||
while (read_rtx (input_file, &desc, &lineno))
|
||||
while (read_rtx (&desc, &lineno))
|
||||
process_rtx (desc, lineno);
|
||||
|
||||
/* Do not free pathname. It is attached to the various rtx queue
|
||||
elements. */
|
||||
|
||||
read_md_file = old_file;
|
||||
read_md_filename = old_filename;
|
||||
read_md_lineno = old_lineno;
|
||||
|
||||
@ -902,7 +905,6 @@ save_string (const char *s, int len)
|
||||
int
|
||||
init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
|
||||
{
|
||||
FILE *input_file;
|
||||
int c, i, lineno;
|
||||
char *lastsl;
|
||||
rtx desc;
|
||||
@ -988,14 +990,14 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
|
||||
fatal ("cannot read standard input twice");
|
||||
|
||||
base_dir = NULL;
|
||||
read_md_file = stdin;
|
||||
read_md_filename = in_fname = "<stdin>";
|
||||
read_md_lineno = 1;
|
||||
input_file = stdin;
|
||||
already_read_stdin = true;
|
||||
|
||||
while (read_rtx (input_file, &desc, &lineno))
|
||||
while (read_rtx (&desc, &lineno))
|
||||
process_rtx (desc, lineno);
|
||||
fclose (input_file);
|
||||
fclose (read_md_file);
|
||||
continue;
|
||||
}
|
||||
else if (argv[i][1] == '-' && argv[i][2] == '\0')
|
||||
@ -1018,18 +1020,18 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
|
||||
else
|
||||
base_dir = NULL;
|
||||
|
||||
read_md_filename = in_fname;
|
||||
read_md_lineno = 1;
|
||||
input_file = fopen (in_fname, "r");
|
||||
if (input_file == 0)
|
||||
read_md_file = fopen (in_fname, "r");
|
||||
if (read_md_file == 0)
|
||||
{
|
||||
perror (in_fname);
|
||||
return FATAL_EXIT_CODE;
|
||||
}
|
||||
read_md_filename = in_fname;
|
||||
read_md_lineno = 1;
|
||||
|
||||
while (read_rtx (input_file, &desc, &lineno))
|
||||
while (read_rtx (&desc, &lineno))
|
||||
process_rtx (desc, lineno);
|
||||
fclose (input_file);
|
||||
fclose (read_md_file);
|
||||
}
|
||||
|
||||
/* If we get to this point without having seen any files to process,
|
||||
@ -1037,13 +1039,13 @@ init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
|
||||
if (!in_fname)
|
||||
{
|
||||
base_dir = NULL;
|
||||
read_md_file = stdin;
|
||||
read_md_filename = in_fname = "<stdin>";
|
||||
read_md_lineno = 1;
|
||||
input_file = stdin;
|
||||
|
||||
while (read_rtx (input_file, &desc, &lineno))
|
||||
while (read_rtx (&desc, &lineno))
|
||||
process_rtx (desc, lineno);
|
||||
fclose (input_file);
|
||||
fclose (read_md_file);
|
||||
}
|
||||
|
||||
/* Process define_cond_exec patterns. */
|
||||
|
@ -52,11 +52,14 @@ static htab_t joined_conditions;
|
||||
/* An obstack for allocating joined_conditions entries. */
|
||||
static struct obstack joined_conditions_obstack;
|
||||
|
||||
/* The current line number for the file. */
|
||||
int read_md_lineno = 1;
|
||||
/* The file we are reading. */
|
||||
FILE *read_md_file;
|
||||
|
||||
/* The filename for error reporting. */
|
||||
const char *read_md_filename = "<unknown>";
|
||||
/* The filename of READ_MD_FILE. */
|
||||
const char *read_md_filename;
|
||||
|
||||
/* The current line number in READ_MD_FILE. */
|
||||
int read_md_lineno;
|
||||
|
||||
/* Return a hash value for the pointer pointed to by DEF. */
|
||||
|
||||
@ -189,10 +192,10 @@ message_with_line (int lineno, const char *msg, ...)
|
||||
}
|
||||
|
||||
/* A printf-like function for reporting an error against the current
|
||||
position in the MD file, which is associated with INFILE. */
|
||||
position in the MD file. */
|
||||
|
||||
void
|
||||
fatal_with_file_and_line (FILE *infile, const char *msg, ...)
|
||||
fatal_with_file_and_line (const char *msg, ...)
|
||||
{
|
||||
char context[64];
|
||||
size_t i;
|
||||
@ -208,7 +211,7 @@ fatal_with_file_and_line (FILE *infile, const char *msg, ...)
|
||||
/* Gather some following context. */
|
||||
for (i = 0; i < sizeof (context)-1; ++i)
|
||||
{
|
||||
c = getc (infile);
|
||||
c = read_char ();
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (c == '\r' || c == '\n')
|
||||
@ -225,31 +228,30 @@ fatal_with_file_and_line (FILE *infile, const char *msg, ...)
|
||||
}
|
||||
|
||||
/* Report that we found character ACTUAL when we expected to find
|
||||
character EXPECTED. INFILE is the file handle associated
|
||||
with the current file. */
|
||||
character EXPECTED. */
|
||||
|
||||
void
|
||||
fatal_expected_char (FILE *infile, int expected, int actual)
|
||||
fatal_expected_char (int expected, int actual)
|
||||
{
|
||||
if (actual == EOF)
|
||||
fatal_with_file_and_line (infile, "expected character `%c', found EOF",
|
||||
fatal_with_file_and_line ("expected character `%c', found EOF",
|
||||
expected);
|
||||
else
|
||||
fatal_with_file_and_line (infile, "expected character `%c', found `%c'",
|
||||
fatal_with_file_and_line ("expected character `%c', found `%c'",
|
||||
expected, actual);
|
||||
}
|
||||
|
||||
/* Read chars from INFILE until a non-whitespace char and return that.
|
||||
/* Read chars from the MD file until a non-whitespace char and return that.
|
||||
Comments, both Lisp style and C style, are treated as whitespace. */
|
||||
|
||||
int
|
||||
read_skip_spaces (FILE *infile)
|
||||
read_skip_spaces (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
while (1)
|
||||
{
|
||||
c = getc (infile);
|
||||
c = read_char ();
|
||||
switch (c)
|
||||
{
|
||||
case '\n':
|
||||
@ -261,7 +263,7 @@ read_skip_spaces (FILE *infile)
|
||||
|
||||
case ';':
|
||||
do
|
||||
c = getc (infile);
|
||||
c = read_char ();
|
||||
while (c != '\n' && c != EOF);
|
||||
read_md_lineno++;
|
||||
break;
|
||||
@ -269,12 +271,12 @@ read_skip_spaces (FILE *infile)
|
||||
case '/':
|
||||
{
|
||||
int prevc;
|
||||
c = getc (infile);
|
||||
c = read_char ();
|
||||
if (c != '*')
|
||||
fatal_expected_char (infile, '*', c);
|
||||
fatal_expected_char ('*', c);
|
||||
|
||||
prevc = 0;
|
||||
while ((c = getc (infile)) && c != EOF)
|
||||
while ((c = read_char ()) && c != EOF)
|
||||
{
|
||||
if (c == '\n')
|
||||
read_md_lineno++;
|
||||
@ -295,9 +297,9 @@ read_skip_spaces (FILE *infile)
|
||||
Caller has read the backslash, but not placed it into the obstack. */
|
||||
|
||||
static void
|
||||
read_escape (FILE *infile)
|
||||
read_escape (void)
|
||||
{
|
||||
int c = getc (infile);
|
||||
int c = read_char ();
|
||||
|
||||
switch (c)
|
||||
{
|
||||
@ -348,18 +350,18 @@ read_escape (FILE *infile)
|
||||
the leading quote. */
|
||||
|
||||
char *
|
||||
read_quoted_string (FILE *infile)
|
||||
read_quoted_string (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
while (1)
|
||||
{
|
||||
c = getc (infile); /* Read the string */
|
||||
c = read_char (); /* Read the string */
|
||||
if (c == '\n')
|
||||
read_md_lineno++;
|
||||
else if (c == '\\')
|
||||
{
|
||||
read_escape (infile);
|
||||
read_escape ();
|
||||
continue;
|
||||
}
|
||||
else if (c == '"' || c == EOF)
|
||||
@ -377,7 +379,7 @@ read_quoted_string (FILE *infile)
|
||||
the outermost braces _are_ included in the string constant. */
|
||||
|
||||
static char *
|
||||
read_braced_string (FILE *infile)
|
||||
read_braced_string (void)
|
||||
{
|
||||
int c;
|
||||
int brace_depth = 1; /* caller-processed */
|
||||
@ -386,7 +388,7 @@ read_braced_string (FILE *infile)
|
||||
obstack_1grow (&string_obstack, '{');
|
||||
while (brace_depth)
|
||||
{
|
||||
c = getc (infile); /* Read the string */
|
||||
c = read_char (); /* Read the string */
|
||||
|
||||
if (c == '\n')
|
||||
read_md_lineno++;
|
||||
@ -396,12 +398,12 @@ read_braced_string (FILE *infile)
|
||||
brace_depth--;
|
||||
else if (c == '\\')
|
||||
{
|
||||
read_escape (infile);
|
||||
read_escape ();
|
||||
continue;
|
||||
}
|
||||
else if (c == EOF)
|
||||
fatal_with_file_and_line
|
||||
(infile, "missing closing } for opening brace on line %lu",
|
||||
("missing closing } for opening brace on line %lu",
|
||||
starting_read_md_lineno);
|
||||
|
||||
obstack_1grow (&string_obstack, c);
|
||||
@ -416,36 +418,36 @@ read_braced_string (FILE *infile)
|
||||
and dispatch to the appropriate string constant reader. */
|
||||
|
||||
char *
|
||||
read_string (FILE *infile, int star_if_braced)
|
||||
read_string (int star_if_braced)
|
||||
{
|
||||
char *stringbuf;
|
||||
int saw_paren = 0;
|
||||
int c, old_lineno;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c == '(')
|
||||
{
|
||||
saw_paren = 1;
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
}
|
||||
|
||||
old_lineno = read_md_lineno;
|
||||
if (c == '"')
|
||||
stringbuf = read_quoted_string (infile);
|
||||
stringbuf = read_quoted_string ();
|
||||
else if (c == '{')
|
||||
{
|
||||
if (star_if_braced)
|
||||
obstack_1grow (&string_obstack, '*');
|
||||
stringbuf = read_braced_string (infile);
|
||||
stringbuf = read_braced_string ();
|
||||
}
|
||||
else
|
||||
fatal_with_file_and_line (infile, "expected `\"' or `{', found `%c'", c);
|
||||
fatal_with_file_and_line ("expected `\"' or `{', found `%c'", c);
|
||||
|
||||
if (saw_paren)
|
||||
{
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
}
|
||||
|
||||
set_md_ptr_loc (stringbuf, read_md_filename, old_lineno);
|
||||
|
@ -21,21 +21,38 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
#include "obstack.h"
|
||||
|
||||
extern FILE *read_md_file;
|
||||
extern int read_md_lineno;
|
||||
extern const char *read_md_filename;
|
||||
extern struct obstack string_obstack;
|
||||
|
||||
/* Read the next character from the MD file. */
|
||||
|
||||
static inline int
|
||||
read_char (void)
|
||||
{
|
||||
return getc (read_md_file);
|
||||
}
|
||||
|
||||
/* Put back CH, which was the last character read from the MD file. */
|
||||
|
||||
static inline void
|
||||
unread_char (int ch)
|
||||
{
|
||||
ungetc (ch, read_md_file);
|
||||
}
|
||||
|
||||
extern void copy_md_ptr_loc (const void *, const void *);
|
||||
extern void print_md_ptr_loc (const void *);
|
||||
extern const char *join_c_conditions (const char *, const char *);
|
||||
extern void print_c_condition (const char *);
|
||||
extern void message_with_line (int, const char *, ...) ATTRIBUTE_PRINTF_2;
|
||||
extern void fatal_with_file_and_line (FILE *, const char *, ...)
|
||||
ATTRIBUTE_PRINTF_2 ATTRIBUTE_NORETURN;
|
||||
extern void fatal_expected_char (FILE *, int, int) ATTRIBUTE_NORETURN;
|
||||
extern int read_skip_spaces (FILE *);
|
||||
extern char *read_quoted_string (FILE *);
|
||||
extern char *read_string (FILE *, int);
|
||||
extern void fatal_with_file_and_line (const char *, ...)
|
||||
ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
|
||||
extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN;
|
||||
extern int read_skip_spaces (void);
|
||||
extern char *read_quoted_string (void);
|
||||
extern char *read_string (int);
|
||||
extern int n_comma_elts (const char *);
|
||||
extern const char *scan_comma_elt (const char **);
|
||||
extern void init_md_reader (void);
|
||||
|
310
gcc/read-rtl.c
310
gcc/read-rtl.c
@ -70,8 +70,8 @@ struct iterator_group {
|
||||
int num_builtins;
|
||||
|
||||
/* Treat the given string as the name of a standard mode or code and
|
||||
return its integer value. Use the given file for error reporting. */
|
||||
int (*find_builtin) (const char *, FILE *);
|
||||
return its integer value. */
|
||||
int (*find_builtin) (const char *);
|
||||
|
||||
/* Return true if the given rtx uses the given mode or code. */
|
||||
bool (*uses_iterator_p) (rtx, int);
|
||||
@ -87,8 +87,6 @@ struct iterator_traverse_data {
|
||||
rtx queue;
|
||||
/* Attributes seen for modes. */
|
||||
struct map_value *mode_maps;
|
||||
/* Input file. */
|
||||
FILE *infile;
|
||||
/* The last unknown attribute used as a mode. */
|
||||
const char *unknown_mode_attr;
|
||||
};
|
||||
@ -98,35 +96,35 @@ struct iterator_traverse_data {
|
||||
#define BELLWETHER_CODE(CODE) \
|
||||
((CODE) < NUM_RTX_CODE ? CODE : bellwether_codes[CODE - NUM_RTX_CODE])
|
||||
|
||||
static int find_mode (const char *, FILE *);
|
||||
static int find_mode (const char *);
|
||||
static bool uses_mode_iterator_p (rtx, int);
|
||||
static void apply_mode_iterator (rtx, int);
|
||||
static int find_code (const char *, FILE *);
|
||||
static int find_code (const char *);
|
||||
static bool uses_code_iterator_p (rtx, int);
|
||||
static void apply_code_iterator (rtx, int);
|
||||
static const char *apply_iterator_to_string (const char *, struct mapping *, int);
|
||||
static rtx apply_iterator_to_rtx (rtx, struct mapping *, int,
|
||||
struct map_value *, FILE *, const char **);
|
||||
struct map_value *, const char **);
|
||||
static bool uses_iterator_p (rtx, struct mapping *);
|
||||
static const char *add_condition_to_string (const char *, const char *);
|
||||
static void add_condition_to_rtx (rtx, const char *);
|
||||
static int apply_iterator_traverse (void **, void *);
|
||||
static struct mapping *add_mapping (struct iterator_group *, htab_t t,
|
||||
const char *, FILE *);
|
||||
const char *);
|
||||
static struct map_value **add_map_value (struct map_value **,
|
||||
int, const char *);
|
||||
static void initialize_iterators (void);
|
||||
static void read_name (char *, FILE *);
|
||||
static void read_name (char *);
|
||||
static hashval_t def_hash (const void *);
|
||||
static int def_name_eq_p (const void *, const void *);
|
||||
static void read_constants (FILE *infile, char *tmp_char);
|
||||
static void read_conditions (FILE *infile, char *tmp_char);
|
||||
static void validate_const_int (FILE *, const char *);
|
||||
static int find_iterator (struct iterator_group *, const char *, FILE *);
|
||||
static struct mapping *read_mapping (struct iterator_group *, htab_t, FILE *);
|
||||
static void check_code_iterator (struct mapping *, FILE *);
|
||||
static rtx read_rtx_1 (FILE *, struct map_value **);
|
||||
static rtx read_rtx_variadic (FILE *, struct map_value **, rtx);
|
||||
static void read_constants (char *tmp_char);
|
||||
static void read_conditions (char *tmp_char);
|
||||
static void validate_const_int (const char *);
|
||||
static int find_iterator (struct iterator_group *, const char *);
|
||||
static struct mapping *read_mapping (struct iterator_group *, htab_t);
|
||||
static void check_code_iterator (struct mapping *);
|
||||
static rtx read_rtx_1 (struct map_value **);
|
||||
static rtx read_rtx_variadic (struct map_value **, rtx);
|
||||
|
||||
/* The mode and code iterator structures. */
|
||||
static struct iterator_group modes, codes;
|
||||
@ -137,7 +135,7 @@ static enum rtx_code *bellwether_codes;
|
||||
/* Implementations of the iterator_group callbacks for modes. */
|
||||
|
||||
static int
|
||||
find_mode (const char *name, FILE *infile)
|
||||
find_mode (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -145,7 +143,7 @@ find_mode (const char *name, FILE *infile)
|
||||
if (strcmp (GET_MODE_NAME (i), name) == 0)
|
||||
return i;
|
||||
|
||||
fatal_with_file_and_line (infile, "unknown mode `%s'", name);
|
||||
fatal_with_file_and_line ("unknown mode `%s'", name);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -163,7 +161,7 @@ apply_mode_iterator (rtx x, int mode)
|
||||
/* Implementations of the iterator_group callbacks for codes. */
|
||||
|
||||
static int
|
||||
find_code (const char *name, FILE *infile)
|
||||
find_code (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -171,7 +169,7 @@ find_code (const char *name, FILE *infile)
|
||||
if (strcmp (GET_RTX_NAME (i), name) == 0)
|
||||
return i;
|
||||
|
||||
fatal_with_file_and_line (infile, "unknown rtx code `%s'", name);
|
||||
fatal_with_file_and_line ("unknown rtx code `%s'", name);
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -252,13 +250,12 @@ mode_attr_index (struct map_value **mode_maps, const char *string)
|
||||
/* Apply MODE_MAPS to the top level of X, expanding cases where an
|
||||
attribute is used for a mode. ITERATOR is the current iterator we are
|
||||
expanding, and VALUE is the value to which we are expanding it.
|
||||
INFILE is used for error messages. This sets *UNKNOWN to true if
|
||||
we find a mode attribute which has not yet been defined, and does
|
||||
not change it otherwise. */
|
||||
This sets *UNKNOWN to true if we find a mode attribute which has not
|
||||
yet been defined, and does not change it otherwise. */
|
||||
|
||||
static void
|
||||
apply_mode_maps (rtx x, struct map_value *mode_maps, struct mapping *iterator,
|
||||
int value, FILE *infile, const char **unknown)
|
||||
int value, const char **unknown)
|
||||
{
|
||||
unsigned int offset;
|
||||
int indx;
|
||||
@ -277,7 +274,7 @@ apply_mode_maps (rtx x, struct map_value *mode_maps, struct mapping *iterator,
|
||||
|
||||
v = map_attr_string (pm->string, iterator, value);
|
||||
if (v)
|
||||
PUT_MODE (x, (enum machine_mode) find_mode (v->string, infile));
|
||||
PUT_MODE (x, (enum machine_mode) find_mode (v->string));
|
||||
else
|
||||
*unknown = pm->string;
|
||||
return;
|
||||
@ -327,13 +324,12 @@ apply_iterator_to_string (const char *string, struct mapping *iterator, int valu
|
||||
|
||||
/* Return a copy of ORIGINAL in which all uses of ITERATOR have been
|
||||
replaced by VALUE. MODE_MAPS holds information about attribute
|
||||
strings used for modes. INFILE is used for error messages. This
|
||||
sets *UNKNOWN_MODE_ATTR to the value of an unknown mode attribute,
|
||||
and does not change it otherwise. */
|
||||
strings used for modes. This sets *UNKNOWN_MODE_ATTR to the value of
|
||||
an unknown mode attribute, and does not change it otherwise. */
|
||||
|
||||
static rtx
|
||||
apply_iterator_to_rtx (rtx original, struct mapping *iterator, int value,
|
||||
struct map_value *mode_maps, FILE *infile,
|
||||
struct map_value *mode_maps,
|
||||
const char **unknown_mode_attr)
|
||||
{
|
||||
struct iterator_group *group;
|
||||
@ -356,7 +352,7 @@ apply_iterator_to_rtx (rtx original, struct mapping *iterator, int value,
|
||||
group->apply_iterator (x, value);
|
||||
|
||||
if (mode_maps)
|
||||
apply_mode_maps (x, mode_maps, iterator, value, infile, unknown_mode_attr);
|
||||
apply_mode_maps (x, mode_maps, iterator, value, unknown_mode_attr);
|
||||
|
||||
/* Change each string and recursively change each rtx. */
|
||||
format_ptr = GET_RTX_FORMAT (bellwether_code);
|
||||
@ -374,8 +370,7 @@ apply_iterator_to_rtx (rtx original, struct mapping *iterator, int value,
|
||||
|
||||
case 'e':
|
||||
XEXP (x, i) = apply_iterator_to_rtx (XEXP (x, i), iterator, value,
|
||||
mode_maps, infile,
|
||||
unknown_mode_attr);
|
||||
mode_maps, unknown_mode_attr);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
@ -386,7 +381,6 @@ apply_iterator_to_rtx (rtx original, struct mapping *iterator, int value,
|
||||
for (j = 0; j < XVECLEN (x, i); j++)
|
||||
XVECEXP (x, i, j) = apply_iterator_to_rtx (XVECEXP (original, i, j),
|
||||
iterator, value, mode_maps,
|
||||
infile,
|
||||
unknown_mode_attr);
|
||||
}
|
||||
break;
|
||||
@ -505,7 +499,7 @@ apply_iterator_traverse (void **slot, void *data)
|
||||
for (v = iterator->values; v != 0; v = v->next)
|
||||
{
|
||||
x = apply_iterator_to_rtx (original, iterator, v->number,
|
||||
mtd->mode_maps, mtd->infile,
|
||||
mtd->mode_maps,
|
||||
&mtd->unknown_mode_attr);
|
||||
add_condition_to_rtx (x, v->string);
|
||||
if (v != iterator->values)
|
||||
@ -524,12 +518,10 @@ apply_iterator_traverse (void **slot, void *data)
|
||||
}
|
||||
|
||||
/* Add a new "mapping" structure to hashtable TABLE. NAME is the name
|
||||
of the mapping, GROUP is the group to which it belongs, and INFILE
|
||||
is the file that defined the mapping. */
|
||||
of the mapping and GROUP is the group to which it belongs. */
|
||||
|
||||
static struct mapping *
|
||||
add_mapping (struct iterator_group *group, htab_t table,
|
||||
const char *name, FILE *infile)
|
||||
add_mapping (struct iterator_group *group, htab_t table, const char *name)
|
||||
{
|
||||
struct mapping *m;
|
||||
void **slot;
|
||||
@ -542,7 +534,7 @@ add_mapping (struct iterator_group *group, htab_t table,
|
||||
|
||||
slot = htab_find_slot (table, m, INSERT);
|
||||
if (*slot != 0)
|
||||
fatal_with_file_and_line (infile, "`%s' already defined", name);
|
||||
fatal_with_file_and_line ("`%s' already defined", name);
|
||||
|
||||
*slot = m;
|
||||
return m;
|
||||
@ -590,8 +582,8 @@ initialize_iterators (void)
|
||||
codes.uses_iterator_p = uses_code_iterator_p;
|
||||
codes.apply_iterator = apply_code_iterator;
|
||||
|
||||
lower = add_mapping (&modes, modes.attrs, "mode", 0);
|
||||
upper = add_mapping (&modes, modes.attrs, "MODE", 0);
|
||||
lower = add_mapping (&modes, modes.attrs, "mode");
|
||||
upper = add_mapping (&modes, modes.attrs, "MODE");
|
||||
lower_ptr = &lower->values;
|
||||
upper_ptr = &upper->values;
|
||||
for (i = 0; i < MAX_MACHINE_MODE; i++)
|
||||
@ -604,8 +596,8 @@ initialize_iterators (void)
|
||||
lower_ptr = add_map_value (lower_ptr, i, copy);
|
||||
}
|
||||
|
||||
lower = add_mapping (&codes, codes.attrs, "code", 0);
|
||||
upper = add_mapping (&codes, codes.attrs, "CODE", 0);
|
||||
lower = add_mapping (&codes, codes.attrs, "code");
|
||||
upper = add_mapping (&codes, codes.attrs, "CODE");
|
||||
lower_ptr = &lower->values;
|
||||
upper_ptr = &upper->values;
|
||||
for (i = 0; i < NUM_RTX_CODE; i++)
|
||||
@ -623,12 +615,12 @@ initialize_iterators (void)
|
||||
It is terminated by any of the punctuation chars of rtx printed syntax. */
|
||||
|
||||
static void
|
||||
read_name (char *str, FILE *infile)
|
||||
read_name (char *str)
|
||||
{
|
||||
char *p;
|
||||
int c;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
|
||||
p = str;
|
||||
while (1)
|
||||
@ -638,14 +630,14 @@ read_name (char *str, FILE *infile)
|
||||
if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
|
||||
|| c == '(' || c == '[')
|
||||
{
|
||||
ungetc (c, infile);
|
||||
unread_char (c);
|
||||
break;
|
||||
}
|
||||
*p++ = c;
|
||||
c = getc (infile);
|
||||
c = read_char ();
|
||||
}
|
||||
if (p == str)
|
||||
fatal_with_file_and_line (infile, "missing name or number");
|
||||
fatal_with_file_and_line ("missing name or number");
|
||||
if (c == '\n')
|
||||
read_md_lineno++;
|
||||
|
||||
@ -731,39 +723,37 @@ def_name_eq_p (const void *def1, const void *def2)
|
||||
*(const char *const *) def2);
|
||||
}
|
||||
|
||||
/* INFILE is a FILE pointer to read text from. TMP_CHAR is a buffer suitable
|
||||
to read a name or number into. Process a define_constants directive,
|
||||
starting with the optional space after the "define_constants". */
|
||||
/* TMP_CHAR is a buffer suitable to read a name or number into. Process
|
||||
a define_constants directive, starting with the optional space after
|
||||
the "define_constants". */
|
||||
static void
|
||||
read_constants (FILE *infile, char *tmp_char)
|
||||
read_constants (char *tmp_char)
|
||||
{
|
||||
int c;
|
||||
htab_t defs;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != '[')
|
||||
fatal_expected_char (infile, '[', c);
|
||||
fatal_expected_char ('[', c);
|
||||
defs = md_constants;
|
||||
if (! defs)
|
||||
defs = htab_create (32, def_hash, def_name_eq_p, (htab_del) 0);
|
||||
/* Disable constant expansion during definition processing. */
|
||||
md_constants = 0;
|
||||
while ( (c = read_skip_spaces (infile)) != ']')
|
||||
while ( (c = read_skip_spaces ()) != ']')
|
||||
{
|
||||
struct md_constant *def;
|
||||
void **entry_ptr;
|
||||
|
||||
if (c != '(')
|
||||
fatal_expected_char (infile, '(', c);
|
||||
fatal_expected_char ('(', c);
|
||||
def = XNEW (struct md_constant);
|
||||
def->name = tmp_char;
|
||||
read_name (tmp_char, infile);
|
||||
read_name (tmp_char);
|
||||
entry_ptr = htab_find_slot (defs, def, INSERT);
|
||||
if (! *entry_ptr)
|
||||
def->name = xstrdup (tmp_char);
|
||||
c = read_skip_spaces (infile);
|
||||
ungetc (c, infile);
|
||||
read_name (tmp_char, infile);
|
||||
read_name (tmp_char);
|
||||
if (! *entry_ptr)
|
||||
{
|
||||
def->value = xstrdup (tmp_char);
|
||||
@ -773,18 +763,17 @@ read_constants (FILE *infile, char *tmp_char)
|
||||
{
|
||||
def = (struct md_constant *) *entry_ptr;
|
||||
if (strcmp (def->value, tmp_char))
|
||||
fatal_with_file_and_line (infile,
|
||||
"redefinition of %s, was %s, now %s",
|
||||
fatal_with_file_and_line ("redefinition of %s, was %s, now %s",
|
||||
def->name, def->value, tmp_char);
|
||||
}
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
}
|
||||
md_constants = defs;
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
}
|
||||
|
||||
/* For every constant definition, call CALLBACK with two arguments:
|
||||
@ -797,9 +786,8 @@ traverse_md_constants (htab_trav callback, void *info)
|
||||
htab_traverse (md_constants, callback, info);
|
||||
}
|
||||
|
||||
/* INFILE is a FILE pointer to read text from. TMP_CHAR is a buffer
|
||||
suitable to read a name or number into. Process a
|
||||
define_conditions directive, starting with the optional space after
|
||||
/* TMP_CHAR is a buffer suitable to read a name or number into. Process
|
||||
a define_conditions directive, starting with the optional space after
|
||||
the "define_conditions". The directive looks like this:
|
||||
|
||||
(define_conditions [
|
||||
@ -813,44 +801,44 @@ traverse_md_constants (htab_trav callback, void *info)
|
||||
slipped in at the beginning of the sequence of MD files read by
|
||||
most of the other generators. */
|
||||
static void
|
||||
read_conditions (FILE *infile, char *tmp_char)
|
||||
read_conditions (char *tmp_char)
|
||||
{
|
||||
int c;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != '[')
|
||||
fatal_expected_char (infile, '[', c);
|
||||
fatal_expected_char ('[', c);
|
||||
|
||||
while ( (c = read_skip_spaces (infile)) != ']')
|
||||
while ( (c = read_skip_spaces ()) != ']')
|
||||
{
|
||||
char *expr;
|
||||
int value;
|
||||
|
||||
if (c != '(')
|
||||
fatal_expected_char (infile, '(', c);
|
||||
fatal_expected_char ('(', c);
|
||||
|
||||
read_name (tmp_char, infile);
|
||||
validate_const_int (infile, tmp_char);
|
||||
read_name (tmp_char);
|
||||
validate_const_int (tmp_char);
|
||||
value = atoi (tmp_char);
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != '"')
|
||||
fatal_expected_char (infile, '"', c);
|
||||
expr = read_quoted_string (infile);
|
||||
fatal_expected_char ('"', c);
|
||||
expr = read_quoted_string ();
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
|
||||
add_c_test (expr, value);
|
||||
}
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
}
|
||||
|
||||
static void
|
||||
validate_const_int (FILE *infile, const char *string)
|
||||
validate_const_int (const char *string)
|
||||
{
|
||||
const char *cp;
|
||||
int valid = 1;
|
||||
@ -866,35 +854,35 @@ validate_const_int (FILE *infile, const char *string)
|
||||
if (! ISDIGIT (*cp))
|
||||
valid = 0;
|
||||
if (!valid)
|
||||
fatal_with_file_and_line (infile, "invalid decimal constant \"%s\"\n", string);
|
||||
fatal_with_file_and_line ("invalid decimal constant \"%s\"\n", string);
|
||||
}
|
||||
|
||||
/* Search GROUP for a mode or code called NAME and return its numerical
|
||||
identifier. INFILE is the file that contained NAME. */
|
||||
identifier. */
|
||||
|
||||
static int
|
||||
find_iterator (struct iterator_group *group, const char *name, FILE *infile)
|
||||
find_iterator (struct iterator_group *group, const char *name)
|
||||
{
|
||||
struct mapping *m;
|
||||
|
||||
m = (struct mapping *) htab_find (group->iterators, &name);
|
||||
if (m != 0)
|
||||
return m->index + group->num_builtins;
|
||||
return group->find_builtin (name, infile);
|
||||
return group->find_builtin (name);
|
||||
}
|
||||
|
||||
/* Finish reading a declaration of the form:
|
||||
|
||||
(define... <name> [<value1> ... <valuen>])
|
||||
|
||||
from INFILE, where each <valuei> is either a bare symbol name or a
|
||||
from the MD file, where each <valuei> is either a bare symbol name or a
|
||||
"(<name> <string>)" pair. The "(define..." part has already been read.
|
||||
|
||||
Represent the declaration as a "mapping" structure; add it to TABLE
|
||||
(which belongs to GROUP) and return it. */
|
||||
|
||||
static struct mapping *
|
||||
read_mapping (struct iterator_group *group, htab_t table, FILE *infile)
|
||||
read_mapping (struct iterator_group *group, htab_t table)
|
||||
{
|
||||
char tmp_char[256];
|
||||
struct mapping *m;
|
||||
@ -903,44 +891,44 @@ read_mapping (struct iterator_group *group, htab_t table, FILE *infile)
|
||||
int number, c;
|
||||
|
||||
/* Read the mapping name and create a structure for it. */
|
||||
read_name (tmp_char, infile);
|
||||
m = add_mapping (group, table, tmp_char, infile);
|
||||
read_name (tmp_char);
|
||||
m = add_mapping (group, table, tmp_char);
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != '[')
|
||||
fatal_expected_char (infile, '[', c);
|
||||
fatal_expected_char ('[', c);
|
||||
|
||||
/* Read each value. */
|
||||
end_ptr = &m->values;
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
do
|
||||
{
|
||||
if (c != '(')
|
||||
{
|
||||
/* A bare symbol name that is implicitly paired to an
|
||||
empty string. */
|
||||
ungetc (c, infile);
|
||||
read_name (tmp_char, infile);
|
||||
unread_char (c);
|
||||
read_name (tmp_char);
|
||||
string = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A "(name string)" pair. */
|
||||
read_name (tmp_char, infile);
|
||||
string = read_string (infile, false);
|
||||
c = read_skip_spaces (infile);
|
||||
read_name (tmp_char);
|
||||
string = read_string (false);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
}
|
||||
number = group->find_builtin (tmp_char, infile);
|
||||
number = group->find_builtin (tmp_char);
|
||||
end_ptr = add_map_value (end_ptr, number, string);
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
}
|
||||
while (c != ']');
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
|
||||
return m;
|
||||
}
|
||||
@ -949,7 +937,7 @@ read_mapping (struct iterator_group *group, htab_t table, FILE *infile)
|
||||
same format. Initialize the iterator's entry in bellwether_codes. */
|
||||
|
||||
static void
|
||||
check_code_iterator (struct mapping *iterator, FILE *infile)
|
||||
check_code_iterator (struct mapping *iterator)
|
||||
{
|
||||
struct map_value *v;
|
||||
enum rtx_code bellwether;
|
||||
@ -957,7 +945,7 @@ check_code_iterator (struct mapping *iterator, FILE *infile)
|
||||
bellwether = (enum rtx_code) iterator->values->number;
|
||||
for (v = iterator->values->next; v != 0; v = v->next)
|
||||
if (strcmp (GET_RTX_FORMAT (bellwether), GET_RTX_FORMAT (v->number)) != 0)
|
||||
fatal_with_file_and_line (infile, "code iterator `%s' combines "
|
||||
fatal_with_file_and_line ("code iterator `%s' combines "
|
||||
"different rtx formats", iterator->name);
|
||||
|
||||
bellwether_codes = XRESIZEVEC (enum rtx_code, bellwether_codes,
|
||||
@ -965,8 +953,8 @@ check_code_iterator (struct mapping *iterator, FILE *infile)
|
||||
bellwether_codes[iterator->index] = bellwether;
|
||||
}
|
||||
|
||||
/* Read an rtx in printed representation from INFILE and store its
|
||||
core representation in *X. Also store the line number of the
|
||||
/* Read an rtx in printed representation from the MD file and store
|
||||
its core representation in *X. Also store the line number of the
|
||||
opening '(' in *LINENO. Return true on success or false if the
|
||||
end of file has been reached.
|
||||
|
||||
@ -974,7 +962,7 @@ check_code_iterator (struct mapping *iterator, FILE *infile)
|
||||
the utilities gen*.c that construct C code from machine descriptions. */
|
||||
|
||||
bool
|
||||
read_rtx (FILE *infile, rtx *x, int *lineno)
|
||||
read_rtx (rtx *x, int *lineno)
|
||||
{
|
||||
static rtx queue_head, queue_next;
|
||||
static int queue_lineno;
|
||||
@ -994,14 +982,14 @@ read_rtx (FILE *infile, rtx *x, int *lineno)
|
||||
struct iterator_traverse_data mtd;
|
||||
rtx from_file;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c == EOF)
|
||||
return false;
|
||||
ungetc (c, infile);
|
||||
unread_char (c);
|
||||
|
||||
queue_lineno = read_md_lineno;
|
||||
mode_maps = 0;
|
||||
from_file = read_rtx_1 (infile, &mode_maps);
|
||||
from_file = read_rtx_1 (&mode_maps);
|
||||
if (from_file == 0)
|
||||
return false; /* This confuses a top level (nil) with end of
|
||||
file, but a top level (nil) would have
|
||||
@ -1013,13 +1001,11 @@ read_rtx (FILE *infile, rtx *x, int *lineno)
|
||||
|
||||
mtd.queue = queue_next;
|
||||
mtd.mode_maps = mode_maps;
|
||||
mtd.infile = infile;
|
||||
mtd.unknown_mode_attr = mode_maps ? mode_maps->string : NULL;
|
||||
htab_traverse (modes.iterators, apply_iterator_traverse, &mtd);
|
||||
htab_traverse (codes.iterators, apply_iterator_traverse, &mtd);
|
||||
if (mtd.unknown_mode_attr)
|
||||
fatal_with_file_and_line (infile,
|
||||
"undefined attribute '%s' used for mode",
|
||||
fatal_with_file_and_line ("undefined attribute '%s' used for mode",
|
||||
mtd.unknown_mode_attr);
|
||||
}
|
||||
|
||||
@ -1030,11 +1016,11 @@ read_rtx (FILE *infile, rtx *x, int *lineno)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Subroutine of read_rtx that reads one construct from INFILE but
|
||||
/* Subroutine of read_rtx that reads one construct from the MD file but
|
||||
doesn't apply any iterators. */
|
||||
|
||||
static rtx
|
||||
read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
read_rtx_1 (struct map_value **mode_maps)
|
||||
{
|
||||
int i;
|
||||
RTX_CODE real_code, bellwether_code;
|
||||
@ -1056,55 +1042,54 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
};
|
||||
|
||||
again:
|
||||
c = read_skip_spaces (infile); /* Should be open paren. */
|
||||
c = read_skip_spaces (); /* Should be open paren. */
|
||||
|
||||
if (c == EOF)
|
||||
return 0;
|
||||
|
||||
if (c != '(')
|
||||
fatal_expected_char (infile, '(', c);
|
||||
fatal_expected_char ('(', c);
|
||||
|
||||
read_name (tmp_char, infile);
|
||||
read_name (tmp_char);
|
||||
if (strcmp (tmp_char, "nil") == 0)
|
||||
{
|
||||
/* (nil) stands for an expression that isn't there. */
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
return 0;
|
||||
}
|
||||
if (strcmp (tmp_char, "define_constants") == 0)
|
||||
{
|
||||
read_constants (infile, tmp_char);
|
||||
read_constants (tmp_char);
|
||||
goto again;
|
||||
}
|
||||
if (strcmp (tmp_char, "define_conditions") == 0)
|
||||
{
|
||||
read_conditions (infile, tmp_char);
|
||||
read_conditions (tmp_char);
|
||||
goto again;
|
||||
}
|
||||
if (strcmp (tmp_char, "define_mode_attr") == 0)
|
||||
{
|
||||
read_mapping (&modes, modes.attrs, infile);
|
||||
read_mapping (&modes, modes.attrs);
|
||||
goto again;
|
||||
}
|
||||
if (strcmp (tmp_char, "define_mode_iterator") == 0)
|
||||
{
|
||||
read_mapping (&modes, modes.iterators, infile);
|
||||
read_mapping (&modes, modes.iterators);
|
||||
goto again;
|
||||
}
|
||||
if (strcmp (tmp_char, "define_code_attr") == 0)
|
||||
{
|
||||
read_mapping (&codes, codes.attrs, infile);
|
||||
read_mapping (&codes, codes.attrs);
|
||||
goto again;
|
||||
}
|
||||
if (strcmp (tmp_char, "define_code_iterator") == 0)
|
||||
{
|
||||
check_code_iterator (read_mapping (&codes, codes.iterators, infile),
|
||||
infile);
|
||||
check_code_iterator (read_mapping (&codes, codes.iterators));
|
||||
goto again;
|
||||
}
|
||||
real_code = (enum rtx_code) find_iterator (&codes, tmp_char, infile);
|
||||
real_code = (enum rtx_code) find_iterator (&codes, tmp_char);
|
||||
bellwether_code = BELLWETHER_CODE (real_code);
|
||||
|
||||
/* If we end up with an insn expression then we free this space below. */
|
||||
@ -1115,22 +1100,22 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
/* If what follows is `: mode ', read it and
|
||||
store the mode in the rtx. */
|
||||
|
||||
i = read_skip_spaces (infile);
|
||||
i = read_skip_spaces ();
|
||||
if (i == ':')
|
||||
{
|
||||
unsigned int mode;
|
||||
|
||||
read_name (tmp_char, infile);
|
||||
read_name (tmp_char);
|
||||
if (tmp_char[0] != '<' || tmp_char[strlen (tmp_char) - 1] != '>')
|
||||
mode = find_iterator (&modes, tmp_char, infile);
|
||||
mode = find_iterator (&modes, tmp_char);
|
||||
else
|
||||
mode = mode_attr_index (mode_maps, tmp_char);
|
||||
PUT_MODE (return_rtx, (enum machine_mode) mode);
|
||||
if (GET_MODE (return_rtx) != mode)
|
||||
fatal_with_file_and_line (infile, "mode too large");
|
||||
fatal_with_file_and_line ("mode too large");
|
||||
}
|
||||
else
|
||||
ungetc (i, infile);
|
||||
unread_char (i);
|
||||
|
||||
for (i = 0; format_ptr[i] != 0; i++)
|
||||
switch (format_ptr[i])
|
||||
@ -1142,14 +1127,14 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
|
||||
case 'e':
|
||||
case 'u':
|
||||
XEXP (return_rtx, i) = read_rtx_1 (infile, mode_maps);
|
||||
XEXP (return_rtx, i) = read_rtx_1 (mode_maps);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
/* 'V' is an optional vector: if a closeparen follows,
|
||||
just store NULL for this element. */
|
||||
c = read_skip_spaces (infile);
|
||||
ungetc (c, infile);
|
||||
c = read_skip_spaces ();
|
||||
unread_char (c);
|
||||
if (c == ')')
|
||||
{
|
||||
XVEC (return_rtx, i) = 0;
|
||||
@ -1164,19 +1149,19 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
int list_counter = 0;
|
||||
rtvec return_vec = NULL_RTVEC;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != '[')
|
||||
fatal_expected_char (infile, '[', c);
|
||||
fatal_expected_char ('[', c);
|
||||
|
||||
/* Add expressions to a list, while keeping a count. */
|
||||
obstack_init (&vector_stack);
|
||||
while ((c = read_skip_spaces (infile)) && c != ']')
|
||||
while ((c = read_skip_spaces ()) && c != ']')
|
||||
{
|
||||
if (c == EOF)
|
||||
fatal_expected_char (infile, ']', c);
|
||||
ungetc (c, infile);
|
||||
fatal_expected_char (']', c);
|
||||
unread_char (c);
|
||||
list_counter++;
|
||||
obstack_ptr_grow (&vector_stack, read_rtx_1 (infile, mode_maps));
|
||||
obstack_ptr_grow (&vector_stack, read_rtx_1 (mode_maps));
|
||||
}
|
||||
if (list_counter > 0)
|
||||
{
|
||||
@ -1185,8 +1170,7 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
list_counter * sizeof (rtx));
|
||||
}
|
||||
else if (format_ptr[i] == 'E')
|
||||
fatal_with_file_and_line (infile,
|
||||
"vector must have at least one element");
|
||||
fatal_with_file_and_line ("vector must have at least one element");
|
||||
XVEC (return_rtx, i) = return_vec;
|
||||
obstack_free (&vector_stack, NULL);
|
||||
/* close bracket gotten */
|
||||
@ -1200,8 +1184,8 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
char *stringbuf;
|
||||
int star_if_braced;
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
ungetc (c, infile);
|
||||
c = read_skip_spaces ();
|
||||
unread_char (c);
|
||||
if (c == ')')
|
||||
{
|
||||
/* 'S' fields are optional and should be NULL if no string
|
||||
@ -1217,7 +1201,7 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
written with a brace block instead of a string constant. */
|
||||
star_if_braced = (format_ptr[i] == 'T');
|
||||
|
||||
stringbuf = read_string (infile, star_if_braced);
|
||||
stringbuf = read_string (star_if_braced);
|
||||
|
||||
/* For insn patterns, we want to provide a default name
|
||||
based on the file and line, like "*foo.md:12", if the
|
||||
@ -1249,8 +1233,8 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
read_name (tmp_char, infile);
|
||||
validate_const_int (infile, tmp_char);
|
||||
read_name (tmp_char);
|
||||
validate_const_int (tmp_char);
|
||||
#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
|
||||
tmp_wide = atoi (tmp_char);
|
||||
#else
|
||||
@ -1271,8 +1255,8 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
|
||||
case 'i':
|
||||
case 'n':
|
||||
read_name (tmp_char, infile);
|
||||
validate_const_int (infile, tmp_char);
|
||||
read_name (tmp_char);
|
||||
validate_const_int (tmp_char);
|
||||
tmp_int = atoi (tmp_char);
|
||||
XINT (return_rtx, i) = tmp_int;
|
||||
break;
|
||||
@ -1281,16 +1265,16 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
gcc_unreachable ();
|
||||
}
|
||||
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
if (c != ')')
|
||||
{
|
||||
/* Syntactic sugar for AND and IOR, allowing Lisp-like
|
||||
arbitrary number of arguments for them. */
|
||||
if (c == '(' && (GET_CODE (return_rtx) == AND
|
||||
|| GET_CODE (return_rtx) == IOR))
|
||||
return read_rtx_variadic (infile, mode_maps, return_rtx);
|
||||
return read_rtx_variadic (mode_maps, return_rtx);
|
||||
else
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
}
|
||||
|
||||
return return_rtx;
|
||||
@ -1303,29 +1287,29 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps)
|
||||
is just past the leading parenthesis of x3. Only works
|
||||
for THINGs which are dyadic expressions, e.g. AND, IOR. */
|
||||
static rtx
|
||||
read_rtx_variadic (FILE *infile, struct map_value **mode_maps, rtx form)
|
||||
read_rtx_variadic (struct map_value **mode_maps, rtx form)
|
||||
{
|
||||
char c = '(';
|
||||
rtx p = form, q;
|
||||
|
||||
do
|
||||
{
|
||||
ungetc (c, infile);
|
||||
unread_char (c);
|
||||
|
||||
q = rtx_alloc (GET_CODE (p));
|
||||
PUT_MODE (q, GET_MODE (p));
|
||||
|
||||
XEXP (q, 0) = XEXP (p, 1);
|
||||
XEXP (q, 1) = read_rtx_1 (infile, mode_maps);
|
||||
XEXP (q, 1) = read_rtx_1 (mode_maps);
|
||||
|
||||
XEXP (p, 1) = q;
|
||||
p = q;
|
||||
c = read_skip_spaces (infile);
|
||||
c = read_skip_spaces ();
|
||||
}
|
||||
while (c == '(');
|
||||
|
||||
if (c != ')')
|
||||
fatal_expected_char (infile, ')', c);
|
||||
fatal_expected_char (')', c);
|
||||
|
||||
return form;
|
||||
}
|
||||
|
@ -2361,7 +2361,7 @@ extern void traverse_md_constants (int (*) (void **, void *), void *);
|
||||
struct md_constant { char *name, *value; };
|
||||
|
||||
/* In read-rtl.c */
|
||||
extern bool read_rtx (FILE *, rtx *, int *);
|
||||
extern bool read_rtx (rtx *, int *);
|
||||
|
||||
/* In alias.c */
|
||||
extern rtx canon_rtx (rtx);
|
||||
|
Loading…
Reference in New Issue
Block a user