return !use_old_attr;
}
+/* Get the PCS for a strcut function and store the result to avoid needing to
+ do too many calls to fndecl_abi which can be expensive. */
+
+static arm_pcs
+aarch64_function_abi (struct function *fun)
+{
+ gcc_assert (fun);
+ if (fun->machine->pcs == ARM_PCS_UNKNOWN)
+ fun->machine->pcs = arm_pcs (fndecl_abi (fun->decl).id ());
+
+ return fun->machine->pcs;
+}
+
+/* Get the PCS for a decl and store the result to avoid needing to do
+ too many calls to fndecl_abi which can be expensive. */
+
+static arm_pcs
+aarch64_fndecl_abi (tree fn)
+{
+ gcc_assert (TREE_CODE (fn) == FUNCTION_DECL);
+ struct function *fun = DECL_STRUCT_FUNCTION (fn);
+ if (!fun)
+ return arm_pcs (fndecl_abi (fn).id ());
+
+ return aarch64_function_abi (fun);
+}
+
/* Check whether an 'aarch64_vector_pcs' attribute is valid. */
static tree
bool
aarch64_function_arg_regno_p (unsigned regno)
{
- enum arm_pcs pcs
- = cfun ? (arm_pcs) fndecl_abi (cfun->decl).id () : ARM_PCS_AAPCS64;
+ enum arm_pcs pcs = cfun ? aarch64_function_abi (cfun) : ARM_PCS_AAPCS64;
switch (pcs)
{
funexp = XEXP (DECL_RTL (function), 0);
funexp = gen_rtx_MEM (FUNCTION_MODE, funexp);
auto isa_mode = aarch64_fntype_isa_mode (TREE_TYPE (function));
- auto pcs_variant = arm_pcs (fndecl_abi (function).id ());
+ auto pcs_variant = aarch64_fndecl_abi (function);
bool ir = lookup_attribute ("indirect_return",
TYPE_ATTRIBUTES (TREE_TYPE (function)));
rtx callee_abi = aarch64_gen_callee_cookie (isa_mode, pcs_variant, ir);
{
struct machine_function *machine;
machine = ggc_cleared_alloc<machine_function> ();
+ machine->pcs = ARM_PCS_UNKNOWN;
return machine;
}
aarch64_previous_fndecl = fndecl;
+ /* Initialize the PCS value to UNKNOWN. */
+ if (fndecl && TREE_CODE (fndecl) == FUNCTION_DECL)
+ if (function *fn = DECL_STRUCT_FUNCTION (fndecl))
+ fn->machine->pcs = ARM_PCS_UNKNOWN;
+
/* First set the target options. */
cl_target_option_restore (&global_options, &global_options_set,
TREE_TARGET_OPTION (new_tree));
aarch64_is_variant_pcs (tree fndecl)
{
/* Check for ABIs that preserve more registers than usual. */
- arm_pcs pcs = (arm_pcs) fndecl_abi (fndecl).id ();
+ arm_pcs pcs = aarch64_fndecl_abi (fndecl);
if (pcs == ARM_PCS_SIMD || pcs == ARM_PCS_SVE || pcs == ARM_PCS_PRESERVE_NONE)
return true;
#define DEFAULT_PCC_STRUCT_RETURN 0
+/* The set of available Procedure Call Stardards. */
+
+enum arm_pcs
+{
+ ARM_PCS_AAPCS64, /* Base standard AAPCS for 64 bit. */
+ ARM_PCS_SIMD, /* For aarch64_vector_pcs functions. */
+ ARM_PCS_SVE, /* For functions that pass or return
+ values in SVE registers. */
+ ARM_PCS_TLSDESC, /* For targets of tlsdesc calls. */
+ ARM_PCS_PRESERVE_NONE, /* PCS variant with no call-preserved
+ registers except X29. */
+ ARM_PCS_MS_VARIADIC, /* PCS variant with no call-preserved
+ differently.
+ All composites are treated alike.
+ SIMD and floating-point registers
+ aren't used. */
+ ARM_PCS_UNKNOWN
+};
+
#if defined(HAVE_POLY_INT_H) && defined(GCC_VEC_H)
struct GTY (()) aarch64_frame
{
/* During SEH output, this is non-null. */
struct seh_frame_state * GTY ((skip (""))) seh;
+
+ /* The Procedure Call Standard for the function. */
+ enum arm_pcs pcs;
} machine_function;
#endif
#endif
#define TARGET_ILP32 (aarch64_abi & AARCH64_ABI_ILP32)
-enum arm_pcs
-{
- ARM_PCS_AAPCS64, /* Base standard AAPCS for 64 bit. */
- ARM_PCS_SIMD, /* For aarch64_vector_pcs functions. */
- ARM_PCS_SVE, /* For functions that pass or return
- values in SVE registers. */
- ARM_PCS_TLSDESC, /* For targets of tlsdesc calls. */
- ARM_PCS_PRESERVE_NONE, /* PCS variant with no call-preserved
- registers except X29. */
- ARM_PCS_MS_VARIADIC, /* PCS variant with no call-preserved
- differently.
- All composites are treated alike.
- SIMD and floating-point registers
- aren't used. */
- ARM_PCS_UNKNOWN
-};
-
-
-
-
/* We can't use machine_mode inside a generator file because it
hasn't been created yet; we shouldn't be using any code that
needs the real definition though, so this ought to be safe. */