diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2015-11-17 18:34:47 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2015-11-17 18:34:47 +0000 |
commit | 00175cb22a6ec9029f64044a9665c7390d53e5f6 (patch) | |
tree | b256b1ce82752ff2bfe63d20fcfd0cc3bdde69f8 /gcc/tree.c | |
parent | 3e44547c936be9e741411e812fc1565f539641c1 (diff) | |
download | gcc-00175cb22a6ec9029f64044a9665c7390d53e5f6.zip gcc-00175cb22a6ec9029f64044a9665c7390d53e5f6.tar.gz gcc-00175cb22a6ec9029f64044a9665c7390d53e5f6.tar.bz2 |
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
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -9317,6 +9317,25 @@ get_callee_fndecl (const_tree call) return NULL_TREE; } +/* If CALL_EXPR CALL calls a normal built-in function or an internal function, + return the associated function code, otherwise return CFN_LAST. */ + +combined_fn +get_call_combined_fn (const_tree call) +{ + /* It's invalid to call this function with anything but a CALL_EXPR. */ + gcc_assert (TREE_CODE (call) == CALL_EXPR); + + if (!CALL_EXPR_FN (call)) + return as_combined_fn (CALL_EXPR_IFN (call)); + + tree fndecl = get_callee_fndecl (call); + if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) + return as_combined_fn (DECL_FUNCTION_CODE (fndecl)); + + return CFN_LAST; +} + #define TREE_MEM_USAGE_SPACES 40 /* Print debugging information about tree nodes generated during the compile, @@ -13866,4 +13885,18 @@ set_source_range (tree expr, source_range src_range) SET_EXPR_LOCATION (expr, adhoc); } +/* Return the name of combined function FN, for debugging purposes. */ + +const char * +combined_fn_name (combined_fn fn) +{ + if (builtin_fn_p (fn)) + { + tree fndecl = builtin_decl_explicit (as_builtin_fn (fn)); + return IDENTIFIER_POINTER (DECL_NAME (fndecl)); + } + else + return internal_fn_name (as_internal_fn (fn)); +} + #include "gt-tree.h" |