diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-23 15:15:05 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-23 15:15:05 +0000 |
commit | af908c02d4c893024a3ccfa73244b96a10caeb2f (patch) | |
tree | 4239faf09e39683b3cf8286950be3b1832fd451b /gcc/genconditions.c | |
parent | 0a1039d0a6d67e2b6c303ceb4079deead1e6b108 (diff) | |
download | gcc-af908c02d4c893024a3ccfa73244b96a10caeb2f.tar.gz |
r110123@banpei: zack | 2006-01-22 14:44:34 -0800
* genconditions.c (condition_table, add_condition): Delete.
(write_conditions): Don't emit n_insn_conditions nor
insn_elision_unavailable. Issue the gcc version #ifdef here,
inside the table, with no #else clause ...
(write_header): ...not here.
(write_writer): New function.
(main): Don't initialize condition_table. Use add_c_test.
Call write_writer.
* gensupport.c (init_md_reader_args_cb): Handle multiple input
files on the command line.
(maybe_eval_c_test): Don't check insn_elision_unavailable.
Return -1 if there is no entry in the table, don't abort.
(add_c_test, traverse_c_tests): New functions.
* gensupport.h (insn_elision_unavailable, insn_conditions)
(n_insn_conditions): Delete declarations.
(add_c_test, traverse_c_tests): Declare.
* read-rtl.c: Include gensupport.h.
(read_conditions): New function.
(read_rtx): If read_rtx_1 returns 0, treat as EOF.
(read_rtx_1): If we get EOF when we were looking for an initial
open paren, return 0. Call read_conditions when appropriate.
* Makefile.in: Kill BUILD_EARLY_SUPPORT and all references to
dummy-conditions.o. Eliminate references to insn-conditions.o,
or change them to build/gencondmd.o, as appropriate. Remove
insn-constants.h from $(simple_generated_h) and insn-conditions.c
from $(simple_generated_c). For all files remaining in those
two lists, add insn-conditions.md to the generator command line.
Give insn-constants.h/s-constants their own rules. Add rules
for build/gencondmd.c, s-conditions, insn-conditions.md, s-condmd.
(build/read-rtl.o): Depend on gensupport.h.
(genprognormal): Include preds.
(genprogearly): Rename genprognoprint; only difference is now that
they don't link with $(BUILD_PRINT).
* dummy-conditions.c: Delete.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110119 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/genconditions.c')
-rw-r--r-- | gcc/genconditions.c | 68 |
1 files changed, 29 insertions, 39 deletions
diff --git a/gcc/genconditions.c b/gcc/genconditions.c index bdb3d30e27a..10dfc5896b4 100644 --- a/gcc/genconditions.c +++ b/gcc/genconditions.c @@ -38,31 +38,10 @@ /* so we can include except.h in the generated file. */ static int saw_eh_return; -static htab_t condition_table; - -static void add_condition (const char *); static void write_header (void); static void write_conditions (void); static int write_one_condition (void **, void *); -/* Record the C test expression EXPR in the condition_table. - Duplicates clobber previous entries, which leaks memory, but - we don't care for this application. */ - -static void -add_condition (const char *expr) -{ - struct c_test *test; - - if (expr[0] == 0) - return; - - test = XNEW (struct c_test); - test->expr = expr; - - *(htab_find_slot (condition_table, test, INSERT)) = test; -} - /* Generate the header for insn-conditions.c. */ static void @@ -86,13 +65,6 @@ write_header (void) puts ("\ #include \"system.h\"\n\ -/* If we don't have __builtin_constant_p, or it's not acceptable in array\n\ - initializers, fall back to assuming that all conditions potentially\n\ - vary at run time. It works in 3.0.1 and later; 3.0 only when not\n\ - optimizing. */\n\ -#if GCC_VERSION < 3001\n\ -#include \"dummy-conditions.c\"\n\ -#else\n\ #include \"coretypes.h\"\n\ #include \"tm.h\"\n\ #include \"rtl.h\"\n\ @@ -172,15 +144,35 @@ write_conditions (void) Each condition is mapped to its truth value (0 or 1), or -1 if that\n\ cannot be calculated at compile time. */\n\ \n\ -const struct c_test insn_conditions[] = {"); +static const struct c_test insn_conditions[] = {\n \ +/* If we don't have __builtin_constant_p, or it's not acceptable in array\n\ + initializers, fall back to assuming that all conditions potentially\n\ + vary at run time. It works in 3.0.1 and later; 3.0 only when not\n\ + optimizing. */\n\ +#if GCC_VERSION >= 3001"); - htab_traverse (condition_table, write_one_condition, 0); + traverse_c_tests (write_one_condition, 0); - puts ("};\n"); + puts ("#endif\n};\n"); +} - printf ("const size_t n_insn_conditions = %lu;\n", - (unsigned long) htab_elements (condition_table)); - puts ("const int insn_elision_unavailable = 0;\n#endif"); +/* Emit code which will convert the C-format table to a + (define_conditions) form, which the MD reader can understand. + The result will be added to the set of files scanned by + 'downstream' generators. */ +static void +write_writer (void) +{ + puts ("int\nmain(void)\n{\n\ + unsigned int i;\n\ +\n\ + puts (\"(define_conditions [\");\n\ + for (i = 0; i < ARRAY_SIZE (insn_conditions); i++)\n\ + printf (\" (%d \\\"%s\\\")\\n\",\n\ + insn_conditions[i].value, insn_conditions[i].expr);\n\ + puts (\"])\");\n\ + fflush (stdout);\n\ + return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);\n}"); } int @@ -195,10 +187,7 @@ main (int argc, char **argv) if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE) return (FATAL_EXIT_CODE); - condition_table = htab_create (1000, hash_c_test, cmp_c_test, NULL); - /* Read the machine description. */ - while (1) { desc = read_md_rtx (&pattern_lineno, &code); @@ -214,7 +203,7 @@ main (int argc, char **argv) case DEFINE_INSN: case DEFINE_EXPAND: - add_condition (XSTR (desc, 2)); + add_c_test (XSTR (desc, 2), -1); /* except.h needs to know whether there is an eh_return pattern in the machine description. */ if (!strcmp (XSTR (desc, 0), "eh_return")) @@ -224,13 +213,14 @@ main (int argc, char **argv) case DEFINE_SPLIT: case DEFINE_PEEPHOLE: case DEFINE_PEEPHOLE2: - add_condition (XSTR (desc, 1)); + add_c_test (XSTR (desc, 1), -1); break; } } write_header (); write_conditions (); + write_writer (); fflush (stdout); return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); |