diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-03 23:30:45 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-03 23:30:45 +0000 |
commit | ba08da2c50d6a9089afa00750d0c676c740582a8 (patch) | |
tree | 21207c8bff549bcb22ce42b1506218236d280593 /gcc/gensupport.c | |
parent | 0568d4eade0cb7402f52c74a7a05cbf8f385dd59 (diff) | |
download | gcc-ba08da2c50d6a9089afa00750d0c676c740582a8.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85511 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gensupport.c')
-rw-r--r-- | gcc/gensupport.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/gcc/gensupport.c b/gcc/gensupport.c index 37535d18a5d..2acfc8a3efd 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -898,9 +898,12 @@ save_string (const char *s, int len) /* The entry point for initializing the reader. */ 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; + size_t ix; + char *lastsl; const char *in_fname; max_include_len = 0; @@ -909,8 +912,10 @@ init_md_reader_args (int argc, char **argv) { if (argv[i][0] != '-') { - if (in_fname == NULL) - in_fname = argv[i]; + if (in_fname) + fatal ("too many input files"); + + in_fname = argv[i]; } else { @@ -939,33 +944,28 @@ init_md_reader_args (int argc, char **argv) } break; 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 -init_md_reader (const char *filename) -{ - FILE *input_file; - int c; - size_t i; - char *lastsl; + if (!in_fname) + fatal ("no input file name"); - lastsl = strrchr (filename, '/'); + lastsl = strrchr (in_fname, '/'); 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; - input_file = fopen (filename, "r"); + read_rtx_filename = in_fname; + input_file = fopen (in_fname, "r"); if (input_file == 0) { - perror (filename); + perror (in_fname); return FATAL_EXIT_CODE; } @@ -973,9 +973,9 @@ init_md_reader (const char *filename) condition_table = htab_create (n_insn_conditions, hash_c_test, cmp_c_test, NULL); - for (i = 0; i < n_insn_conditions; i++) - *(htab_find_slot (condition_table, &insn_conditions[i], INSERT)) - = (void *) &insn_conditions[i]; + for (ix = 0; ix < n_insn_conditions; ix++) + *(htab_find_slot (condition_table, &insn_conditions[ix], INSERT)) + = (void *) &insn_conditions[ix]; obstack_init (rtl_obstack); errors = 0; @@ -986,8 +986,7 @@ init_md_reader (const char *filename) { rtx desc; int lineno; - - c = read_skip_spaces (input_file); + int c = read_skip_spaces (input_file); if (c == EOF) break; @@ -1005,6 +1004,14 @@ init_md_reader (const char *filename) 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. */ rtx |