diff options
Diffstat (limited to 'gcc/gimple.h')
-rw-r--r-- | gcc/gimple.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/gcc/gimple.h b/gcc/gimple.h index f32600d..3799e06 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1905,7 +1905,7 @@ gimple_call_set_lhs (gimple gs, tree lhs) /* Return the tree node representing the function called by call - statement GS. This may or may not be a FUNCTION_DECL node. */ + statement GS. */ static inline tree gimple_call_fn (const_gimple gs) @@ -1937,6 +1937,17 @@ gimple_call_set_fn (gimple gs, tree fn) } +/* Set FNDECL to be the function called by call statement GS. */ + +static inline void +gimple_call_set_fndecl (gimple gs, tree decl) +{ + GIMPLE_CHECK (gs, GIMPLE_CALL); + gcc_assert (TREE_CODE (decl) == FUNCTION_DECL); + gimple_set_op (gs, 1, build_fold_addr_expr (decl)); +} + + /* If a given GIMPLE_CALL's callee is a FUNCTION_DECL, return it. Otherwise return NULL. This function is analogous to get_callee_fndecl in tree land. */ @@ -1944,8 +1955,13 @@ gimple_call_set_fn (gimple gs, tree fn) static inline tree gimple_call_fndecl (const_gimple gs) { - tree decl = gimple_call_fn (gs); - return (TREE_CODE (decl) == FUNCTION_DECL) ? decl : NULL_TREE; + tree addr = gimple_call_fn (gs); + if (TREE_CODE (addr) == ADDR_EXPR) + { + gcc_assert (TREE_CODE (TREE_OPERAND (addr, 0)) == FUNCTION_DECL); + return TREE_OPERAND (addr, 0); + } + return NULL_TREE; } @@ -1957,9 +1973,9 @@ gimple_call_return_type (const_gimple gs) tree fn = gimple_call_fn (gs); tree type = TREE_TYPE (fn); - /* See through pointers. */ - if (POINTER_TYPE_P (type)) - type = TREE_TYPE (type); + /* See through the pointer. */ + gcc_assert (POINTER_TYPE_P (type)); + type = TREE_TYPE (type); gcc_assert (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE); |