Commit 002ffd3c by Richard Sandiford Committed by Richard Sandiford

Add a target hook for getting an ABI from a function type

This patch adds a target hook that allows targets to return
the ABI associated with a particular function type.  Generally,
when multiple ABIs are in use, it must be possible to tell from
a function type and its attributes which ABI it is using.

2019-09-30  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* target.def (fntype_abi): New target hook.
	* doc/tm.texi.in (TARGET_FNTYPE_ABI): Likewise.
	* doc/tm.texi: Regenerate.
	* target.h (predefined_function_abi): Declare.
	* function-abi.cc (fntype_abi): Call targetm.calls.fntype_abi,
	if defined.
	* config/aarch64/aarch64.h (ARM_PCS_SIMD): New arm_pcs value.
	* config/aarch64/aarch64.c: Include function-abi.h.
	(aarch64_simd_abi, aarch64_fntype_abi): New functions.
	(TARGET_FNTYPE_ABI): Define.

From-SVN: r276308
parent bd785b44
2019-09-30 Richard Sandiford <richard.sandiford@arm.com> 2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
* target.def (fntype_abi): New target hook.
* doc/tm.texi.in (TARGET_FNTYPE_ABI): Likewise.
* doc/tm.texi: Regenerate.
* target.h (predefined_function_abi): Declare.
* function-abi.cc (fntype_abi): Call targetm.calls.fntype_abi,
if defined.
* config/aarch64/aarch64.h (ARM_PCS_SIMD): New arm_pcs value.
* config/aarch64/aarch64.c: Include function-abi.h.
(aarch64_simd_abi, aarch64_fntype_abi): New functions.
(TARGET_FNTYPE_ABI): Define.
2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
* Makefile.in (OBJS): Add function-abi.o. * Makefile.in (OBJS): Add function-abi.o.
(GTFILES): Add function-abi.h. (GTFILES): Add function-abi.h.
* function-abi.cc: New file. * function-abi.cc: New file.
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#include "rtx-vector-builder.h" #include "rtx-vector-builder.h"
#include "intl.h" #include "intl.h"
#include "expmed.h" #include "expmed.h"
#include "function-abi.h"
/* This file should be included last. */ /* This file should be included last. */
#include "target-def.h" #include "target-def.h"
...@@ -1365,6 +1366,24 @@ svpattern_token (enum aarch64_svpattern pattern) ...@@ -1365,6 +1366,24 @@ svpattern_token (enum aarch64_svpattern pattern)
gcc_unreachable (); gcc_unreachable ();
} }
/* Return the descriptor of the SIMD ABI. */
static const predefined_function_abi &
aarch64_simd_abi (void)
{
predefined_function_abi &simd_abi = function_abis[ARM_PCS_SIMD];
if (!simd_abi.initialized_p ())
{
HARD_REG_SET full_reg_clobbers
= default_function_abi.full_reg_clobbers ();
for (int regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
if (FP_SIMD_SAVED_REGNUM_P (regno))
CLEAR_HARD_REG_BIT (full_reg_clobbers, regno);
simd_abi.initialize (ARM_PCS_SIMD, full_reg_clobbers);
}
return simd_abi;
}
/* Generate code to enable conditional branches in functions over 1 MiB. */ /* Generate code to enable conditional branches in functions over 1 MiB. */
const char * const char *
aarch64_gen_far_branch (rtx * operands, int pos_label, const char * dest, aarch64_gen_far_branch (rtx * operands, int pos_label, const char * dest,
...@@ -1810,6 +1829,16 @@ aarch64_hard_regno_mode_ok (unsigned regno, machine_mode mode) ...@@ -1810,6 +1829,16 @@ aarch64_hard_regno_mode_ok (unsigned regno, machine_mode mode)
return false; return false;
} }
/* Implement TARGET_FNTYPE_ABI. */
static const predefined_function_abi &
aarch64_fntype_abi (const_tree fntype)
{
if (lookup_attribute ("aarch64_vector_pcs", TYPE_ATTRIBUTES (fntype)))
return aarch64_simd_abi ();
return default_function_abi;
}
/* Return true if this is a definition of a vectorized simd function. */ /* Return true if this is a definition of a vectorized simd function. */
static bool static bool
...@@ -21024,6 +21053,9 @@ aarch64_libgcc_floating_mode_supported_p ...@@ -21024,6 +21053,9 @@ aarch64_libgcc_floating_mode_supported_p
#undef TARGET_GET_MULTILIB_ABI_NAME #undef TARGET_GET_MULTILIB_ABI_NAME
#define TARGET_GET_MULTILIB_ABI_NAME aarch64_get_multilib_abi_name #define TARGET_GET_MULTILIB_ABI_NAME aarch64_get_multilib_abi_name
#undef TARGET_FNTYPE_ABI
#define TARGET_FNTYPE_ABI aarch64_fntype_abi
#if CHECKING_P #if CHECKING_P
#undef TARGET_RUN_TARGET_SELFTESTS #undef TARGET_RUN_TARGET_SELFTESTS
#define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests #define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests
......
...@@ -783,6 +783,7 @@ enum aarch64_abi_type ...@@ -783,6 +783,7 @@ enum aarch64_abi_type
enum arm_pcs enum arm_pcs
{ {
ARM_PCS_AAPCS64, /* Base standard AAPCS for 64 bit. */ ARM_PCS_AAPCS64, /* Base standard AAPCS for 64 bit. */
ARM_PCS_SIMD, /* For aarch64_vector_pcs functions. */
ARM_PCS_UNKNOWN ARM_PCS_UNKNOWN
}; };
......
...@@ -1898,6 +1898,16 @@ must be defined. Modern ports should define @code{CALL_REALLY_USED_REGISTERS}. ...@@ -1898,6 +1898,16 @@ must be defined. Modern ports should define @code{CALL_REALLY_USED_REGISTERS}.
@cindex call-used register @cindex call-used register
@cindex call-clobbered register @cindex call-clobbered register
@cindex call-saved register @cindex call-saved register
@deftypefn {Target Hook} {const predefined_function_abi &} TARGET_FNTYPE_ABI (const_tree @var{type})
Return the ABI used by a function with type @var{type}; see the
definition of @code{predefined_function_abi} for details of the ABI
descriptor. Targets only need to define this hook if they support
interoperability between several ABIs in the same translation unit.
@end deftypefn
@cindex call-used register
@cindex call-clobbered register
@cindex call-saved register
@deftypefn {Target Hook} bool TARGET_HARD_REGNO_CALL_PART_CLOBBERED (rtx_insn *@var{insn}, unsigned int @var{regno}, machine_mode @var{mode}) @deftypefn {Target Hook} bool TARGET_HARD_REGNO_CALL_PART_CLOBBERED (rtx_insn *@var{insn}, unsigned int @var{regno}, machine_mode @var{mode})
This hook should return true if @var{regno} is partly call-saved and This hook should return true if @var{regno} is partly call-saved and
partly call-clobbered, and if a value of mode @var{mode} would be partly partly call-clobbered, and if a value of mode @var{mode} would be partly
......
...@@ -1709,6 +1709,11 @@ must be defined. Modern ports should define @code{CALL_REALLY_USED_REGISTERS}. ...@@ -1709,6 +1709,11 @@ must be defined. Modern ports should define @code{CALL_REALLY_USED_REGISTERS}.
@cindex call-used register @cindex call-used register
@cindex call-clobbered register @cindex call-clobbered register
@cindex call-saved register @cindex call-saved register
@hook TARGET_FNTYPE_ABI
@cindex call-used register
@cindex call-clobbered register
@cindex call-saved register
@hook TARGET_HARD_REGNO_CALL_PART_CLOBBERED @hook TARGET_HARD_REGNO_CALL_PART_CLOBBERED
@hook TARGET_REMOVE_EXTRA_CALL_PRESERVED_REGS @hook TARGET_REMOVE_EXTRA_CALL_PRESERVED_REGS
......
...@@ -132,6 +132,8 @@ const predefined_function_abi & ...@@ -132,6 +132,8 @@ const predefined_function_abi &
fntype_abi (const_tree type) fntype_abi (const_tree type)
{ {
gcc_assert (FUNC_OR_METHOD_TYPE_P (type)); gcc_assert (FUNC_OR_METHOD_TYPE_P (type));
if (targetm.calls.fntype_abi)
return targetm.calls.fntype_abi (type);
return default_function_abi; return default_function_abi;
} }
......
...@@ -4943,6 +4943,15 @@ If this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used.", ...@@ -4943,6 +4943,15 @@ If this hook is not defined, then FUNCTION_VALUE_REGNO_P will be used.",
bool, (const unsigned int regno), bool, (const unsigned int regno),
default_function_value_regno_p) default_function_value_regno_p)
DEFHOOK
(fntype_abi,
"Return the ABI used by a function with type @var{type}; see the\n\
definition of @code{predefined_function_abi} for details of the ABI\n\
descriptor. Targets only need to define this hook if they support\n\
interoperability between several ABIs in the same translation unit.",
const predefined_function_abi &, (const_tree type),
NULL)
/* ??? Documenting this hook requires a GFDL license grant. */ /* ??? Documenting this hook requires a GFDL license grant. */
DEFHOOK_UNDOC DEFHOOK_UNDOC
(internal_arg_pointer, (internal_arg_pointer,
......
...@@ -152,6 +152,9 @@ class _stmt_vec_info; ...@@ -152,6 +152,9 @@ class _stmt_vec_info;
/* This is defined in calls.h. */ /* This is defined in calls.h. */
class function_arg_info; class function_arg_info;
/* This is defined in function-abi.h. */
class predefined_function_abi;
/* These are defined in tree-vect-stmts.c. */ /* These are defined in tree-vect-stmts.c. */
extern tree stmt_vectype (class _stmt_vec_info *); extern tree stmt_vectype (class _stmt_vec_info *);
extern bool stmt_in_inner_loop_p (class _stmt_vec_info *); extern bool stmt_in_inner_loop_p (class _stmt_vec_info *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment