From 00175cb22a6ec9029f64044a9665c7390d53e5f6 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 17 Nov 2015 18:34:47 +0000 Subject: Add a combined_fn enum I'm working on a patch series that needs to be able to treat built-in functions and internal functions in a similar way. This patch adds a new enum, combined_fn, that combines the two together. It also adds utility functions for seeing which combined_fn (if any) is called by a given CALL_EXPR or gcall. Tested on x86_64-linux-gnu, aarch64-linux-gnu and arm-linux-gnueabi. gcc/ * tree-core.h (internal_fn): Move immediately after the definition of built_in_function. (combined_fn): New enum. * tree.h (as_combined_fn, builtin_fn_p, as_builtin_fn) (internal_fn_p, as_internal_fn): New functions. (get_call_combined_fn, combined_fn_name): Declare. * tree.c (get_call_combined_fn): New function. (combined_fn_name): Likewise. * gimple.h (gimple_call_combined_fn): Declare. * gimple.c (gimple_call_combined_fn): New function. From-SVN: r230472 --- gcc/gimple.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gcc/gimple.c') diff --git a/gcc/gimple.c b/gcc/gimple.c index 706b126..2764df8 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -2531,6 +2531,27 @@ gimple_call_builtin_p (const gimple *stmt, enum built_in_function code) return false; } +/* If CALL is a call to a combined_fn (i.e. an internal function or + a normal built-in function), return its code, otherwise return + CFN_LAST. */ + +combined_fn +gimple_call_combined_fn (const gimple *stmt) +{ + if (const gcall *call = dyn_cast (stmt)) + { + if (gimple_call_internal_p (call)) + return as_combined_fn (gimple_call_internal_fn (call)); + + tree fndecl = gimple_call_fndecl (stmt); + if (fndecl + && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL + && gimple_builtin_call_types_compatible_p (stmt, fndecl)) + return as_combined_fn (DECL_FUNCTION_CODE (fndecl)); + } + return CFN_LAST; +} + /* Return true if STMT clobbers memory. STMT is required to be a GIMPLE_ASM. */ -- cgit v1.1