aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/decl.c
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2008-06-13 22:07:28 +0000
committerOlivier Hainque <hainque@gcc.gnu.org>2008-06-13 22:07:28 +0000
commitd8612af2ce55574685f370c438431d3c0881553f (patch)
tree791e14f9e7ddcb75fa91e32178b0ce5a940da33a /gcc/ada/decl.c
parent7f7e76a4ee4bf15404cdd73840c30566a39460bb (diff)
downloadgcc-d8612af2ce55574685f370c438431d3c0881553f.zip
gcc-d8612af2ce55574685f370c438431d3c0881553f.tar.gz
gcc-d8612af2ce55574685f370c438431d3c0881553f.tar.bz2
decl.c (FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN): Define to 0 if undefined.
2008-06-13 Olivier Hainque <hainque@adacore.com> ada/ * decl.c (FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN): Define to 0 if undefined. (gnat_to_gnu_entity) <case E_Function/Procedure>: Request stack realignment with force_align_arg_pointer attribute on foreign convention subprograms if FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN. testsuite/ * gnat.dg/task_stack_align.adb: New test. From-SVN: r136768
Diffstat (limited to 'gcc/ada/decl.c')
-rw-r--r--gcc/ada/decl.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index dbd7970..ff2927f 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -67,6 +67,29 @@
#define Has_Stdcall_Convention(E) (0)
#endif
+/* Stack realignment for functions with foreign conventions is provided on a
+ per back-end basis now, as it is handled by the prologue expanders and not
+ as part of the function's body any more. It might be requested by way of a
+ dedicated function type attribute on the targets that support it.
+
+ We need a way to avoid setting the attribute on the targets that don't
+ support it and use FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN for this purpose.
+
+ It is defined on targets where the circuitry is available, and indicates
+ whether the realignment is needed for 'main'. We use this to decide for
+ foreign subprograms as well.
+
+ It is not defined on targets where the circuitry is not implemented, and
+ we just never set the attribute in these cases.
+
+ Whether it is defined on all targets that would need it in theory is
+ not entirely clear. We currently trust the base GCC settings for this
+ purpose. */
+
+#ifndef FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
+#define FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN 0
+#endif
+
struct incomplete
{
struct incomplete *next;
@@ -3951,6 +3974,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
get_identifier ("stdcall"), NULL_TREE,
gnat_entity);
+ /* If we are on a target where stack realignment is needed for 'main'
+ to honor GCC's implicit expectations (stack alignment greater than
+ what the base ABI guarantees), ensure we do the same for foreign
+ convention subprograms as they might be used as callbacks from code
+ breaking such expectations. Note that this applies to task entry
+ points in particular. */
+ if (FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
+ && Has_Foreign_Convention (gnat_entity))
+ prepend_one_attribute_to
+ (&attr_list, ATTR_MACHINE_ATTRIBUTE,
+ get_identifier ("force_align_arg_pointer"), NULL_TREE,
+ gnat_entity);
+
/* The lists have been built in reverse. */
gnu_param_list = nreverse (gnu_param_list);
if (has_stub)