aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-match.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2021-11-30 09:52:24 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2021-11-30 09:52:24 +0000
commit33973fa754de1f95d459bfca66c0d80deec36537 (patch)
treebabdf829fa3b7a95f2e444ae0418240d4dc06727 /gcc/gimple-match.h
parentbc8d6c60137f8bbf173b86ddf31b15d7ba2a33dd (diff)
downloadgcc-33973fa754de1f95d459bfca66c0d80deec36537.zip
gcc-33973fa754de1f95d459bfca66c0d80deec36537.tar.gz
gcc-33973fa754de1f95d459bfca66c0d80deec36537.tar.bz2
gimple-match: Add a gimple_extract_op function
code_helper and gimple_match_op seem like generally useful ways of summing up a gimple_assign or gimple_call (or gimple_cond). This patch adds a gimple_extract_op function that can be used for that. gcc/ * gimple-match.h (code_helper): Add functions for querying whether the code represents an internal_fn or a built_in_function. Provide explicit conversion operators for both cases. (gimple_extract_op): Declare. * gimple-match-head.c (gimple_extract): New function, extracted from... (gimple_simplify): ...here. (gimple_extract_op): New function.
Diffstat (limited to 'gcc/gimple-match.h')
-rw-r--r--gcc/gimple-match.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/gimple-match.h b/gcc/gimple-match.h
index 2d4ea47..8abeafe 100644
--- a/gcc/gimple-match.h
+++ b/gcc/gimple-match.h
@@ -33,13 +33,39 @@ public:
code_helper (combined_fn fn) : rep (-(int) fn) {}
operator tree_code () const { return (tree_code) rep; }
operator combined_fn () const { return (combined_fn) -rep; }
+ explicit operator internal_fn () const;
+ explicit operator built_in_function () const;
bool is_tree_code () const { return rep > 0; }
bool is_fn_code () const { return rep < 0; }
+ bool is_internal_fn () const;
+ bool is_builtin_fn () const;
int get_rep () const { return rep; }
private:
int rep;
};
+inline code_helper::operator internal_fn () const
+{
+ return as_internal_fn (combined_fn (*this));
+}
+
+inline code_helper::operator built_in_function () const
+{
+ return as_builtin_fn (combined_fn (*this));
+}
+
+inline bool
+code_helper::is_internal_fn () const
+{
+ return is_fn_code () && internal_fn_p (combined_fn (*this));
+}
+
+inline bool
+code_helper::is_builtin_fn () const
+{
+ return is_fn_code () && builtin_fn_p (combined_fn (*this));
+}
+
/* Represents the condition under which an operation should happen,
and the value to use otherwise. The condition applies elementwise
(as for VEC_COND_EXPR) if the values are vectors. */
@@ -333,6 +359,7 @@ gimple_simplified_result_is_gimple_val (const gimple_match_op *op)
extern tree (*mprts_hook) (gimple_match_op *);
+bool gimple_extract_op (gimple *, gimple_match_op *);
bool gimple_simplify (gimple *, gimple_match_op *, gimple_seq *,
tree (*)(tree), tree (*)(tree));
tree maybe_push_res_to_seq (gimple_match_op *, gimple_seq *,