Commit f9942f4e by Zack Weinberg

gensupport.c (init_md_reader_args_cb): Renamed from init_md_reader_args.

	* gensupport.c (init_md_reader_args_cb): Renamed from
	init_md_reader_args.  Add third option, callback function for
	parsing program-specific options.  Add diagnosis of incorrect
	number of input files.
	(init_md_reader): Fold into init_md_reader_args_cb.
	(init_md_reader_args): Now a thin wrapper around
	init_md_reader_args_cb.
	* gensupport.h: Update prototypes.

	* genattr.c, genattrtab.c, gencodes.c, genconfig.c, genemit.c
	* genextract.c, genflags.c, genopinit.c, genoutput.c, genpeep.c
	* genrecog.c: No need to diagnose lack of an input file;
	init_md_reader_args will handle it.
	* genconditions.c: Likewise, and use init_md_reader_args.
	* genconstants.c: Likewise, and no need to call read_md_rtx.

From-SVN: r85511
parent 9cbe78fb
2004-08-03 Zack Weinberg <zack@codesourcery.com>
* gensupport.c (init_md_reader_args_cb): Renamed from
init_md_reader_args. Add third option, callback function for
parsing program-specific options. Add diagnosis of incorrect
number of input files.
(init_md_reader): Fold into init_md_reader_args_cb.
(init_md_reader_args): Now a thin wrapper around
init_md_reader_args_cb.
* gensupport.h: Update prototypes.
* genattr.c, genattrtab.c, gencodes.c, genconfig.c, genemit.c
* genextract.c, genflags.c, genopinit.c, genoutput.c, genpeep.c
* genrecog.c: No need to diagnose lack of an input file;
init_md_reader_args will handle it.
* genconditions.c: Likewise, and use init_md_reader_args.
* genconstants.c: Likewise, and no need to call read_md_rtx.
2004-08-03 Joseph S. Myers <jsm@polyomino.org.uk> 2004-08-03 Joseph S. Myers <jsm@polyomino.org.uk>
* c-decl.c (implicitly_declare): Diagnose incompatible implicit * c-decl.c (implicitly_declare): Diagnose incompatible implicit
...@@ -26,8 +44,8 @@ ...@@ -26,8 +44,8 @@
2004-08-03 Maciej W. Rozycki <macro@linux-mips.org> 2004-08-03 Maciej W. Rozycki <macro@linux-mips.org>
* aclocal.m4 (gcc_AC_FUNC_MMAP_BLACKLIST): Check for <sys/mman.h> * aclocal.m4 (gcc_AC_FUNC_MMAP_BLACKLIST): Check for <sys/mman.h>
and mmap() explicitly instead of relying on preset autoconf cache and mmap() explicitly instead of relying on preset autoconf cache
variables. variables.
* configure: Regenerate. * configure: Regenerate.
...@@ -42,7 +60,7 @@ ...@@ -42,7 +60,7 @@
* config/i386/t-gmm_malloc: New file. * config/i386/t-gmm_malloc: New file.
* config/i386/t-pmm_malloc: Likewise. * config/i386/t-pmm_malloc: Likewise.
* config/i386/xmmintrin.h: Include <mm_malloc.h>. * config/i386/xmmintrin.h: Include <mm_malloc.h>.
2004-08-03 H.J. Lu <hongjiu.lu@intel.com> 2004-08-03 H.J. Lu <hongjiu.lu@intel.com>
...@@ -58,7 +76,7 @@ ...@@ -58,7 +76,7 @@
* config/rs6000/rs6000.c (machopic_output_stub): Align Darwin stubs. * config/rs6000/rs6000.c (machopic_output_stub): Align Darwin stubs.
* c-common.c: Include opts.h. * c-common.c: Include opts.h.
(c_common_get_alias_set): Fix check for a single input file. (c_common_get_alias_set): Fix check for a single input file.
* toplev.c: Remove current_file_decl. * toplev.c: Remove current_file_decl.
* tree.h: Ditto. * tree.h: Ditto.
...@@ -144,9 +162,9 @@ ...@@ -144,9 +162,9 @@
(warn_B, warn_std_ptr): Remove. (warn_B, warn_std_ptr): Remove.
2004-08-03 Yossi Markovich <yossim@il.ibm.com> 2004-08-03 Yossi Markovich <yossim@il.ibm.com>
Mostafa Hagog <mustafa@il.ibm.com> Mostafa Hagog <mustafa@il.ibm.com>
* config/rs6000/altivec.md (altivec_vnmsubfp): Fix wrong pattern. * config/rs6000/altivec.md (altivec_vnmsubfp): Fix wrong pattern.
2004-08-02 Geoffrey Keating <geoffk@apple.com> 2004-08-02 Geoffrey Keating <geoffk@apple.com>
...@@ -168,7 +186,7 @@ ...@@ -168,7 +186,7 @@
2004-08-02 Gabriel Dos Reis <gdr@integrable-solutions.net> 2004-08-02 Gabriel Dos Reis <gdr@integrable-solutions.net>
* vec.h (DEF_VEC_P): Add proper cast to uses of vec_o_reserve and * vec.h (DEF_VEC_P): Add proper cast to uses of vec_o_reserve and
vec_p_reserve. vec_p_reserve.
* langhooks.h (lang_hooks::builtin_function): Rename parameter * langhooks.h (lang_hooks::builtin_function): Rename parameter
from "class" to "bt_class". from "class" to "bt_class".
...@@ -184,7 +202,7 @@ ...@@ -184,7 +202,7 @@
* gengtype.c (create_option): Convert initializer for option::info to * gengtype.c (create_option): Convert initializer for option::info to
appropiate type. appropiate type.
(adjust_field_type, walk_type, write_func_for_structure, (adjust_field_type, walk_type, write_func_for_structure,
write_root, write_roots): Remove pointless cast. write_root, write_roots): Remove pointless cast.
2004-08-02 J"orn Rennecke <joern.rennecke@superh.com> 2004-08-02 J"orn Rennecke <joern.rennecke@superh.com>
...@@ -195,10 +213,10 @@ ...@@ -195,10 +213,10 @@
* rtl.h (union rtunion_def): Have all members start with the * rtl.h (union rtunion_def): Have all members start with the
prefix "rt_". prefix "rt_".
(XINT, XSTR, XEXP, XVEC, XMODE, XBITMAP, XTREE, XBBDEF, XTMPL, (XINT, XSTR, XEXP, XVEC, XMODE, XBITMAP, XTREE, XBBDEF, XTMPL,
X0INT, X0UINT, X0STR, X0EXP, X0VEC, X0MODE, X0BITMAP, X0TREE, X0INT, X0UINT, X0STR, X0EXP, X0VEC, X0MODE, X0BITMAP, X0TREE,
X0MEMATTR, X0BBDEF, X0REGATTR, XCINT, XCUINT, XCSTR, XCEXP, X0MEMATTR, X0BBDEF, X0REGATTR, XCINT, XCUINT, XCSTR, XCEXP,
XCVEC, XCMODE, XCBITMAP, XCTREE, XCBBDEF, XC2EXP): Adjust members XCVEC, XCMODE, XCBITMAP, XCTREE, XCBBDEF, XC2EXP): Adjust members
access. access.
* gengtype.c (adjust_field_rtx_def): Likewise. * gengtype.c (adjust_field_rtx_def): Likewise.
* rtlanal.c (loc_mentioned_in_p): Likewise. * rtlanal.c (loc_mentioned_in_p): Likewise.
......
...@@ -97,9 +97,6 @@ main (int argc, char **argv) ...@@ -97,9 +97,6 @@ main (int argc, char **argv)
progname = "genattr"; progname = "genattr";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -4407,9 +4407,6 @@ main (int argc, char **argv) ...@@ -4407,9 +4407,6 @@ main (int argc, char **argv)
progname = "genattrtab"; progname = "genattrtab";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -59,9 +59,6 @@ main (int argc, char **argv) ...@@ -59,9 +59,6 @@ main (int argc, char **argv)
direct references to CODE_FOR_xxx in C code. */ direct references to CODE_FOR_xxx in C code. */
insn_elision = 0; insn_elision = 0;
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -188,10 +188,7 @@ main (int argc, char **argv) ...@@ -188,10 +188,7 @@ main (int argc, char **argv)
progname = "genconditions"; progname = "genconditions";
if (argc <= 1) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
fatal ("No input file name.");
if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
condition_table = htab_create (1000, hash_c_test, cmp_c_test, NULL); condition_table = htab_create (1000, hash_c_test, cmp_c_test, NULL);
......
...@@ -264,9 +264,6 @@ main (int argc, char **argv) ...@@ -264,9 +264,6 @@ main (int argc, char **argv)
progname = "genconfig"; progname = "genconfig";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -34,8 +34,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -34,8 +34,6 @@ Boston, MA 02111-1307, USA. */
#include "errors.h" #include "errors.h"
#include "gensupport.h" #include "gensupport.h"
static int print_md_constant (void **, void *);
/* Called via traverse_md_constants; emit a #define for /* Called via traverse_md_constants; emit a #define for
the current constant definition. */ the current constant definition. */
...@@ -52,22 +50,13 @@ print_md_constant (void **slot, void *info) ...@@ -52,22 +50,13 @@ print_md_constant (void **slot, void *info)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int dummy1, dummy2;
rtx desc;
progname = "genconstants"; progname = "genconstants";
if (argc <= 1) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
fatal ("no input file name");
if (init_md_reader (argv[1]) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
/* Scan and discard the entire file. This has the side effect /* Initializing the MD reader has the side effect of loading up
of loading up the constants table that we wish to scan. */ the constants table that we wish to scan. */
do
desc = read_md_rtx (&dummy1, &dummy2);
while (desc);
puts ("/* Generated automatically by the program `genconstants'"); puts ("/* Generated automatically by the program `genconstants'");
puts (" from the machine description file `md'. */\n"); puts (" from the machine description file `md'. */\n");
...@@ -83,4 +72,3 @@ main (int argc, char **argv) ...@@ -83,4 +72,3 @@ main (int argc, char **argv)
return SUCCESS_EXIT_CODE; return SUCCESS_EXIT_CODE;
} }
...@@ -799,9 +799,6 @@ main (int argc, char **argv) ...@@ -799,9 +799,6 @@ main (int argc, char **argv)
progname = "genemit"; progname = "genemit";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -354,9 +354,6 @@ main (int argc, char **argv) ...@@ -354,9 +354,6 @@ main (int argc, char **argv)
progname = "genextract"; progname = "genextract";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -245,9 +245,6 @@ main (int argc, char **argv) ...@@ -245,9 +245,6 @@ main (int argc, char **argv)
direct calls to their generators in C code. */ direct calls to their generators in C code. */
insn_elision = 0; insn_elision = 0;
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -352,9 +352,6 @@ main (int argc, char **argv) ...@@ -352,9 +352,6 @@ main (int argc, char **argv)
progname = "genopinit"; progname = "genopinit";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -982,9 +982,6 @@ main (int argc, char **argv) ...@@ -982,9 +982,6 @@ main (int argc, char **argv)
progname = "genoutput"; progname = "genoutput";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -359,9 +359,6 @@ main (int argc, char **argv) ...@@ -359,9 +359,6 @@ main (int argc, char **argv)
progname = "genpeep"; progname = "genpeep";
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -2636,9 +2636,6 @@ main (int argc, char **argv) ...@@ -2636,9 +2636,6 @@ main (int argc, char **argv)
memset (&split_tree, 0, sizeof split_tree); memset (&split_tree, 0, sizeof split_tree);
memset (&peephole2_tree, 0, sizeof peephole2_tree); memset (&peephole2_tree, 0, sizeof peephole2_tree);
if (argc <= 1)
fatal ("no input file name");
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE); return (FATAL_EXIT_CODE);
......
...@@ -898,9 +898,12 @@ save_string (const char *s, int len) ...@@ -898,9 +898,12 @@ save_string (const char *s, int len)
/* The entry point for initializing the reader. */ /* The entry point for initializing the reader. */
int int
init_md_reader_args (int argc, char **argv) init_md_reader_args_cb (int argc, char **argv, bool (*parse_opt)(const char *))
{ {
FILE *input_file;
int i; int i;
size_t ix;
char *lastsl;
const char *in_fname; const char *in_fname;
max_include_len = 0; max_include_len = 0;
...@@ -909,8 +912,10 @@ init_md_reader_args (int argc, char **argv) ...@@ -909,8 +912,10 @@ init_md_reader_args (int argc, char **argv)
{ {
if (argv[i][0] != '-') if (argv[i][0] != '-')
{ {
if (in_fname == NULL) if (in_fname)
in_fname = argv[i]; fatal ("too many input files");
in_fname = argv[i];
} }
else else
{ {
...@@ -939,33 +944,28 @@ init_md_reader_args (int argc, char **argv) ...@@ -939,33 +944,28 @@ init_md_reader_args (int argc, char **argv)
} }
break; break;
default: default:
fatal ("invalid option `%s'", argv[i]); /* The program may have provided a callback so it can
accept its own options. */
if (parse_opt && parse_opt (argv[i]))
break;
fatal ("invalid option `%s'", argv[i]);
} }
} }
} }
return init_md_reader (in_fname);
}
/* The entry point for initializing the reader. */
int if (!in_fname)
init_md_reader (const char *filename) fatal ("no input file name");
{
FILE *input_file;
int c;
size_t i;
char *lastsl;
lastsl = strrchr (filename, '/'); lastsl = strrchr (in_fname, '/');
if (lastsl != NULL) if (lastsl != NULL)
base_dir = save_string (filename, lastsl - filename + 1 ); base_dir = save_string (in_fname, lastsl - in_fname + 1 );
read_rtx_filename = filename; read_rtx_filename = in_fname;
input_file = fopen (filename, "r"); input_file = fopen (in_fname, "r");
if (input_file == 0) if (input_file == 0)
{ {
perror (filename); perror (in_fname);
return FATAL_EXIT_CODE; return FATAL_EXIT_CODE;
} }
...@@ -973,9 +973,9 @@ init_md_reader (const char *filename) ...@@ -973,9 +973,9 @@ init_md_reader (const char *filename)
condition_table = htab_create (n_insn_conditions, condition_table = htab_create (n_insn_conditions,
hash_c_test, cmp_c_test, NULL); hash_c_test, cmp_c_test, NULL);
for (i = 0; i < n_insn_conditions; i++) for (ix = 0; ix < n_insn_conditions; ix++)
*(htab_find_slot (condition_table, &insn_conditions[i], INSERT)) *(htab_find_slot (condition_table, &insn_conditions[ix], INSERT))
= (void *) &insn_conditions[i]; = (void *) &insn_conditions[ix];
obstack_init (rtl_obstack); obstack_init (rtl_obstack);
errors = 0; errors = 0;
...@@ -986,8 +986,7 @@ init_md_reader (const char *filename) ...@@ -986,8 +986,7 @@ init_md_reader (const char *filename)
{ {
rtx desc; rtx desc;
int lineno; int lineno;
int c = read_skip_spaces (input_file);
c = read_skip_spaces (input_file);
if (c == EOF) if (c == EOF)
break; break;
...@@ -1005,6 +1004,14 @@ init_md_reader (const char *filename) ...@@ -1005,6 +1004,14 @@ init_md_reader (const char *filename)
return errors ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE; return errors ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;
} }
/* Programs that don't have their own options can use this entry point
instead. */
int
init_md_reader_args (int argc, char **argv)
{
return init_md_reader_args_cb (argc, argv, 0);
}
/* The entry point for reading a single rtx from an md file. */ /* The entry point for reading a single rtx from an md file. */
rtx rtx
......
...@@ -24,8 +24,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -24,8 +24,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
struct obstack; struct obstack;
extern struct obstack *rtl_obstack; extern struct obstack *rtl_obstack;
extern int init_md_reader_args_cb (int, char **, bool (*)(const char *));
extern int init_md_reader_args (int, char **); extern int init_md_reader_args (int, char **);
extern int init_md_reader (const char *);
extern rtx read_md_rtx (int *, int *); extern rtx read_md_rtx (int *, int *);
extern void message_with_line (int, const char *, ...) extern void message_with_line (int, const char *, ...)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment