From 63d25773e166e2e3babe626a5800e70939844754 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 14 Oct 2019 08:06:06 +0000 Subject: 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 gcc/ * function-abi.h (expr_callee_abi): Declare. * function-abi.cc (expr_callee_abi): New function. From-SVN: r276952 --- gcc/function-abi.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'gcc/function-abi.cc') diff --git a/gcc/function-abi.cc b/gcc/function-abi.cc index eee789a..b4a1839 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); +} -- cgit v1.1