diff options
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/Makefile.in | 15 | ||||
-rw-r--r-- | gcc/gencfn-macros.c | 50 | ||||
-rw-r--r-- | gcc/genmatch.c | 7 | ||||
-rw-r--r-- | gcc/match.pd | 42 |
5 files changed, 79 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bd233a6..cc6f795 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,18 @@ 2015-11-17 Richard Sandiford <richard.sandiford@arm.com> + * Makefile.in (MOSTLYCLEANFILES): Add cfn-operators.pd. + (generated_files): Likewise. + (s-cfn-operators, cfn-operators.pd): New rules. + (s-match): Depend on cfn-operators.pd. + * gencfn-macros.c: Expand comment to describe -o behavior. + (print_define_operator_list): New function. + (main): Accept -o. Call print_define_operator_list. + * genmatch.c (main): Add the current directory to the include path. + * match.pd (DEFINE_MATH_FN): Delete. Include cfn-operators.pd + instead. + +2015-11-17 Richard Sandiford <richard.sandiford@arm.com> + * doc/match-and-simplify.texi: Document the "null" identifier. * genmatch.c (id_base::NULL_ID): New kind. (null_id): New variable. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index ba8108d..0fd8d99 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1570,7 +1570,7 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \ tm-preds.h tm-constrs.h checksum-options gimple-match.c generic-match.c \ tree-check.h min-insn-modes.c insn-modes.c insn-modes.h \ genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \ - case-cfn-macros.h \ + case-cfn-macros.h cfn-operators.pd \ xgcc$(exeext) cpp$(exeext) $(FULL_DRIVER_NAME) \ $(EXTRA_PROGRAMS) gcc-cross$(exeext) \ $(SPECS) collect2$(exeext) gcc-ar$(exeext) gcc-nm$(exeext) \ @@ -2256,6 +2256,14 @@ s-case-cfn-macros: build/gencfn-macros$(build_exeext) $(STAMP) s-case-cfn-macros case-cfn-macros.h: s-case-cfn-macros; @true +s-cfn-operators: build/gencfn-macros$(build_exeext) + $(RUN_GEN) build/gencfn-macros$(build_exeext) -o \ + > tmp-cfn-operators.pd + $(SHELL) $(srcdir)/../move-if-change tmp-cfn-operators.pd \ + cfn-operators.pd + $(STAMP) s-cfn-operators +cfn-operators.pd: s-cfn-operators; @true + target-hooks-def.h: s-target-hooks-def-h; @true # make sure that when we build info files, the used tm.texi is up to date. $(srcdir)/doc/tm.texi: s-tm-texi; @true @@ -2322,7 +2330,7 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in gimple-match.c: s-match gimple-match-head.c ; @true generic-match.c: s-match generic-match-head.c ; @true -s-match: build/genmatch$(build_exeext) $(srcdir)/match.pd +s-match: build/genmatch$(build_exeext) $(srcdir)/match.pd cfn-operators.pd $(RUN_GEN) build/genmatch$(build_exeext) --gimple $(srcdir)/match.pd \ > tmp-gimple-match.c $(RUN_GEN) build/genmatch$(build_exeext) --generic $(srcdir)/match.pd \ @@ -2443,7 +2451,8 @@ generated_files = config.h tm.h $(TM_P_H) $(TM_H) multilib.h \ $(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gcov-iov.h \ options.h target-hooks-def.h insn-opinit.h \ common/common-target-hooks-def.h pass-instances.def \ - c-family/c-target-hooks-def.h params.list case-cfn-macros.h + c-family/c-target-hooks-def.h params.list case-cfn-macros.h \ + cfn-operators.pd # # How to compile object files to run on the build machine. diff --git a/gcc/gencfn-macros.c b/gcc/gencfn-macros.c index 5ee3af0..401c429 100644 --- a/gcc/gencfn-macros.c +++ b/gcc/gencfn-macros.c @@ -40,7 +40,27 @@ along with GCC; see the file COPYING3. If not see case CFN_BUILT_IN_SQRTL: case CFN_SQRT: - The macros for groups with no internal function drop the last line. */ + The macros for groups with no internal function drop the last line. + + When run with -o, the generator prints a similar list of + define_operator_list directives, for use by match.pd. Each operator + list starts with the built-in functions, in order of ascending type width. + This is followed by an entry for the internal function, or "null" if there + is no internal function for the group. For example: + + (define_operator_list SQRT + BUILT_IN_SQRTF + BUILT_IN_SQRT + BUILT_IN_SQRTL + IFN_SQRT) + + and: + + (define_operator_list CABS + BUILT_IN_CABSF + BUILT_IN_CABS + BUILT_IN_CABSL + null) */ #include "bconfig.h" #include "system.h" @@ -89,6 +109,23 @@ print_case_cfn (const char *name, bool internal_p, printf ("\n"); } +/* Print an operator list for all combined functions related to NAME, + with the null-terminated list of suffixes in SUFFIXES. INTERNAL_P + says whether CFN_<NAME> also exists. */ + +static void +print_define_operator_list (const char *name, bool internal_p, + const char *const *suffixes) +{ + printf ("(define_operator_list %s\n", name); + for (unsigned int i = 0; suffixes[i]; ++i) + printf (" BUILT_IN_%s%s\n", name, suffixes[i]); + if (internal_p) + printf (" IFN_%s)\n", name); + else + printf (" null)\n"); +} + const char *const builtin_names[] = { #define DEF_BUILTIN(ENUM, N, C, T, LT, B, F, NA, AT, IM, COND) \ #ENUM, @@ -126,9 +163,10 @@ main (int argc, char **argv) progname = argv[0]; if (argc != 2 || argv[1][0] != '-' - || argv[1][1] != 'c' + || !strchr ("co", argv[1][1]) || argv[1][2]) - fatal ("usage: %s -c > file", progname); + fatal ("usage: %s [-c|-o] > file", progname); + int type = argv[1][1]; /* Collect the set of built-in and internal functions. */ string_set builtins; @@ -165,7 +203,11 @@ main (int argc, char **argv) if (is_group (&builtins, root, suffix_lists[j])) { bool internal_p = internal_fns.contains (root); - print_case_cfn (root, internal_p, suffix_lists[j]); + if (type == 'c') + print_case_cfn (root, internal_p, suffix_lists[j]); + else + print_define_operator_list (root, internal_p, + suffix_lists[j]); } } } diff --git a/gcc/genmatch.c b/gcc/genmatch.c index 4df5689..3a20a48 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -4638,6 +4638,13 @@ main (int argc, char **argv) cpp_callbacks *cb = cpp_get_callbacks (r); cb->error = error_cb; + /* Add the build directory to the #include "" search path. */ + cpp_dir *dir = XCNEW (cpp_dir); + dir->name = getpwd (); + if (!dir->name) + dir->name = ASTRDUP ("."); + cpp_set_include_chains (r, dir, NULL, false); + if (!cpp_read_main_file (r, input)) return 1; cpp_define (r, gimple ? "GIMPLE=1": "GENERIC=1"); diff --git a/gcc/match.pd b/gcc/match.pd index 15bf2c9..e86cc8b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -47,10 +47,7 @@ along with GCC; see the file COPYING3. If not see (define_operator_list simple_comparison lt le eq ne ge gt) (define_operator_list swapped_simple_comparison gt ge eq ne le lt) -/* Define an operand list for math function FN, with float, double and - long double variants (in that order). */ -#define DEFINE_MATH_FN(FN) \ - (define_operator_list FN BUILT_IN_##FN##F BUILT_IN_##FN BUILT_IN_##FN##L) +#include "cfn-operators.pd" /* Define operand lists for math rounding functions {,i,l,ll}FN, where the versions prefixed with "i" return an int, those prefixed with @@ -62,10 +59,6 @@ along with GCC; see the file COPYING3. If not see X<FN> for all double functions, in the same order X<FN>L for all long double functions, in the same order. */ #define DEFINE_INT_AND_FLOAT_ROUND_FN(FN) \ - DEFINE_MATH_FN (FN) \ - DEFINE_MATH_FN (I##FN) \ - DEFINE_MATH_FN (L##FN) \ - DEFINE_MATH_FN (LL##FN) \ (define_operator_list X##FN##F BUILT_IN_I##FN##F \ BUILT_IN_L##FN##F \ BUILT_IN_LL##FN##F) \ @@ -76,39 +69,6 @@ along with GCC; see the file COPYING3. If not see BUILT_IN_L##FN##L \ BUILT_IN_LL##FN##L) -DEFINE_MATH_FN (LOG) -DEFINE_MATH_FN (EXP) -DEFINE_MATH_FN (LOG2) -DEFINE_MATH_FN (EXP2) -DEFINE_MATH_FN (LOG10) -DEFINE_MATH_FN (EXP10) -DEFINE_MATH_FN (POW) -DEFINE_MATH_FN (POW10) -DEFINE_MATH_FN (POWI) -DEFINE_MATH_FN (SQRT) -DEFINE_MATH_FN (CBRT) -DEFINE_MATH_FN (SIN) -DEFINE_MATH_FN (COS) -DEFINE_MATH_FN (TAN) -DEFINE_MATH_FN (ATAN) -DEFINE_MATH_FN (COSH) -DEFINE_MATH_FN (CEXP) -DEFINE_MATH_FN (CEXPI) -DEFINE_MATH_FN (CPROJ) -DEFINE_MATH_FN (CCOS) -DEFINE_MATH_FN (CCOSH) -DEFINE_MATH_FN (HYPOT) -DEFINE_MATH_FN (COPYSIGN) -DEFINE_MATH_FN (CABS) -DEFINE_MATH_FN (TRUNC) -DEFINE_MATH_FN (NEARBYINT) -DEFINE_MATH_FN (SIGNBIT) -DEFINE_MATH_FN (FMIN) -DEFINE_MATH_FN (FMAX) -DEFINE_MATH_FN (LDEXP) -DEFINE_MATH_FN (SCALBN) -DEFINE_MATH_FN (SCALBLN) - DEFINE_INT_AND_FLOAT_ROUND_FN (FLOOR) DEFINE_INT_AND_FLOAT_ROUND_FN (CEIL) DEFINE_INT_AND_FLOAT_ROUND_FN (ROUND) |