+2015-10-16 Christian Bruel <christian.bruel@st.com>
+
+ PR target/67745
+ * config/arm/arm.h (FUNCTION_BOUNDARY): Use FUNCTION_BOUNDARY_P.
+ (FUNCTION_BOUNDARY_P): New macro:
+ * config/arm/arm.c (TARGET_RELAYOUT_FUNCTION, arm_relayout_function):
+ New hook.
+ * doc/tm.texi.in (TARGET_RELAYOUT_FUNCTION): Document.
+ * doc/tm.texi (TARGET_RELAYOUT_FUNCTION): New hook.
+ * gcc/target.def (TARGET_RELAYOUT_FUNCTION): Likewise.
+ * gcc/function.c (allocate_struct_function): Call relayout_function hook.
+ * gcc/passes.c (rest_of_decl_compilation): Likewise.
+
2015-10-16 Christian Bruel <christian.bruel@st.com>
PR target/67745
static void arm_option_print (FILE *, int, struct cl_target_option *);
static void arm_set_current_function (tree);
static bool arm_can_inline_p (tree, tree);
+static void arm_relayout_function (tree);
static bool arm_valid_target_attribute_p (tree, tree, tree, int);
static unsigned HOST_WIDE_INT arm_shift_truncation_mask (machine_mode);
static bool arm_macro_fusion_p (void);
#undef TARGET_CAN_INLINE_P
#define TARGET_CAN_INLINE_P arm_can_inline_p
+#undef TARGET_RELAYOUT_FUNCTION
+#define TARGET_RELAYOUT_FUNCTION arm_relayout_function
+
#undef TARGET_OPTION_OVERRIDE
#define TARGET_OPTION_OVERRIDE arm_option_override
return true;
}
+/* Hook to fix function's alignment affected by target attribute. */
+
+static void
+arm_relayout_function (tree fndecl)
+{
+ if (DECL_USER_ALIGN (fndecl))
+ return;
+
+ tree callee_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
+
+ if (!callee_tree)
+ callee_tree = target_option_default_node;
+
+ DECL_ALIGN (fndecl) =
+ FUNCTION_BOUNDARY_P (TREE_TARGET_OPTION (callee_tree)->x_target_flags);
+}
+
/* Inner function to process the attribute((target(...))), take an argument and
set the current options from the argument. If we have a list, recursively
go over the list. */
#define PREFERRED_STACK_BOUNDARY \
(arm_abi == ARM_ABI_ATPCS ? 64 : STACK_BOUNDARY)
-#define FUNCTION_BOUNDARY (TARGET_THUMB ? 16 : 32)
+#define FUNCTION_BOUNDARY_P(flags) (TARGET_THUMB_P (flags) ? 16 : 32)
+#define FUNCTION_BOUNDARY (FUNCTION_BOUNDARY_P (target_flags))
/* The lowest bit is used to indicate Thumb-mode functions, so the
vbit must go into the delta field of pointers to member
specific target options and the caller does not use the same options.
@end deftypefn
+@deftypefn {Target Hook} void TARGET_RELAYOUT_FUNCTION (tree @var{fndecl})
+This target hook fixes function @var{fndecl} after attributes are processed. Default does nothing. On ARM, the default function's alignment is updated with the attribute target.
+@end deftypefn
+
@node Emulated TLS
@section Emulating TLS
@cindex Emulated TLS
@hook TARGET_CAN_INLINE_P
+@hook TARGET_RELAYOUT_FUNCTION
+
@node Emulated TLS
@section Emulating TLS
@cindex Emulated TLS
for (tree parm = DECL_ARGUMENTS (fndecl); parm;
parm = DECL_CHAIN (parm))
relayout_decl (parm);
+
+ /* Similarly relayout the function decl. */
+ targetm.target_option.relayout_function (fndecl);
}
if (!abstract_p && aggregate_value_p (result, fndecl))
}
#endif
+ /* Now that we have activated any function-specific attributes
+ that might affect function decl, particularly align, relayout it. */
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ targetm.target_option.relayout_function (decl);
+
timevar_pop (TV_VARCONST);
}
else if (TREE_CODE (decl) == TYPE_DECL
bool, (tree caller, tree callee),
default_target_can_inline_p)
+DEFHOOK
+(relayout_function,
+"This target hook fixes function @var{fndecl} after attributes are processed. Default does nothing. On ARM, the default function's alignment is updated with the attribute target.",
+ void, (tree fndecl),
+ hook_void_tree)
+
HOOK_VECTOR_END (target_option)
/* For targets that need to mark extra registers as live on entry to