summaryrefslogtreecommitdiff
path: root/gcc/gencfn-macros.c
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-17 18:49:10 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2015-11-17 18:49:10 +0000
commitff690865f1bd81b60e0479701db3ac0303d2fef2 (patch)
treef6a69b77920259ec90eb2b68484d7e14ca6135ff /gcc/gencfn-macros.c
parent9bac11b75df2ea37ee667b39bef3015aef857332 (diff)
downloadgcc-ff690865f1bd81b60e0479701db3ac0303d2fef2.tar.gz
Replace match.pd DEFINE_MATH_FNs with auto-generated lists
This patch autogenerates the operator lists for maths functions like SQRT, adding an additional entry for internal functions. E.g.: (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) (since there's no internal function for CABS). Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230486 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gencfn-macros.c')
-rw-r--r--gcc/gencfn-macros.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/gcc/gencfn-macros.c b/gcc/gencfn-macros.c
index 5ee3af0eb5c..401c429606c 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]);
}
}
}