This is the mail archive of the
mailing list for the GCC project.
[GSoC] user defined predicates
- From: Prathamesh Kulkarni <bilbotheelffriend at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>, gcc <gcc at gcc dot gnu dot org>, Maxim Kuvyrkov <maxim dot kuvyrkov at linaro dot org>
- Date: Fri, 8 Aug 2014 04:46:47 +0530
- Subject: [GSoC] user defined predicates
- Authentication-results: sourceware.org; auth=none
Currently, we treat predicates as "second-class" citizens:
- assume any identifier as a valid predicate
- cannot write more complex predicates than an identifier in match-op
I was wondering whether it would be a good idea
to ave user-defined predicates,
instead of hard-coding them as macros in gimple-match-head.c ?
A predicate is assumed to expect only one operand as input.
(define_predicate <name> (c_expr))
and use it the same way we do currently.
Example Use case:
Consider following pattern:
(foo @0 @1)
(if (TYPE_UNSIGNED (TREE_TYPE (@1)))
The second operand (@1) is only captured for sake of testing it's type
Instead, define a predicate:
(define_predicate type_unsigned_p (TYPE_UNSIGNED (TREE_TYPE (@@)))
@@ refers to the operand we use the predicate on.
(foo @0 type_unsigned)
in this case @@ would be op21 (one of the generated temporaries during
code-gen for match-op in decision tree).
We would generate predicates as macros in the generated file.
so in gimple-match.c, there would be
#define type_unsigned(op) (TYPE_UNSIGNED (TREE_TYPE (op)))
(we also need this for generic-match.c, so maybe generate macros in
separate file say genpreds.c and include it in both gimple-match.c and
and replace @@ by correct operand in the patterns the predicates
The current "predicates" in gimple-match-head.c can be written as:
(define_predicate INTEGER_CST_P (TREE_CODE (@@) == INTEGER_CST)))
(define_predicate integral_op_p (INTEGRAL_TYPE_P (TREE_TYPE (@@)))
Not sure if this would have real benefit, just an idea...