+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.
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) \
$(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
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 \
$(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
#\f
# How to compile object files to run on the build machine.
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"
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,
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;
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]);
}
}
}
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");
(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
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) \
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)