diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-10-14 08:06:06 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-10-14 08:06:06 +0000 |
commit | 63d25773e166e2e3babe626a5800e70939844754 (patch) | |
tree | a7b25b15fda1131aa9559922c8368de732728286 | |
parent | 56898e437a538c7edc0724a3650f5cb81c9d5721 (diff) |
Add expr_callee_abi
This turned out to be useful for the SVE PCS support, and is a natural
tree-level analogue of insn_callee_abi.
2019-10-14 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* function-abi.h (expr_callee_abi): Declare.
* function-abi.cc (expr_callee_abi): New function.
From-SVN: r276952
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/function-abi.cc | 29 | ||||
-rw-r--r-- | gcc/function-abi.h | 1 |
3 files changed, 35 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cf359bf5835..e755803b12c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-10-14 Richard Sandiford <richard.sandiford@arm.com> + + * function-abi.h (expr_callee_abi): Declare. + * function-abi.cc (expr_callee_abi): New function. + 2019-10-14 Aldy Hernandez <aldyh@redhat.com> * tree-vrp.c (value_range_base::set): Normalize unsigned ~[0,0] diff --git a/gcc/function-abi.cc b/gcc/function-abi.cc index eee789a29e8..b4a18396367 100644 --- a/gcc/function-abi.cc +++ b/gcc/function-abi.cc @@ -229,3 +229,32 @@ insn_callee_abi (const rtx_insn *insn) return default_function_abi; } + +/* Return the ABI of the function called by CALL_EXPR EXP. Return the + default ABI for erroneous calls. */ + +function_abi +expr_callee_abi (const_tree exp) +{ + gcc_assert (TREE_CODE (exp) == CALL_EXPR); + + if (tree fndecl = get_callee_fndecl (exp)) + return fndecl_abi (fndecl); + + tree callee = CALL_EXPR_FN (exp); + if (callee == error_mark_node) + return default_function_abi; + + tree type = TREE_TYPE (callee); + if (type == error_mark_node) + return default_function_abi; + + if (POINTER_TYPE_P (type)) + { + type = TREE_TYPE (type); + if (type == error_mark_node) + return default_function_abi; + } + + return fntype_abi (type); +} diff --git a/gcc/function-abi.h b/gcc/function-abi.h index 9bb4d1768b3..96a49dfbea6 100644 --- a/gcc/function-abi.h +++ b/gcc/function-abi.h @@ -315,5 +315,6 @@ call_clobbered_in_region_p (unsigned int abis, const_hard_reg_set mask, extern const predefined_function_abi &fntype_abi (const_tree); extern function_abi fndecl_abi (const_tree); extern function_abi insn_callee_abi (const rtx_insn *); +extern function_abi expr_callee_abi (const_tree); #endif |