From 75d6cc81939b5e5d0698f9ad559233ba8c65e657 Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Wed, 8 Jun 2016 17:00:23 +0000 Subject: [PATCH] [PATCH 1/2][AArch64] Implement AAPCS64 updates for alignment attribute gcc/ChangeLog: * config/aarch64/aarch64.c (aarch64_function_arg_alignment): Rewrite, looking one level down for records and arrays. From-SVN: r237224 --- gcc/ChangeLog | 5 +++++ gcc/config/aarch64/aarch64.c | 31 ++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c1a79cb90d..0634872332b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-06-08 Alan Lawrence + + * config/aarch64/aarch64.c (aarch64_function_arg_alignment): + Rewrite, looking one level down for records and arrays. + 2016-06-08 David Malcolm * pretty-print.c: Include "selftest.h". diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index b60e5c52df6..a0db3a4f632 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1961,22 +1961,23 @@ aarch64_vfp_is_call_candidate (cumulative_args_t pcum_v, machine_mode mode, static unsigned int aarch64_function_arg_alignment (machine_mode mode, const_tree type) { - unsigned int alignment; + if (!type) + return GET_MODE_ALIGNMENT (mode); + if (integer_zerop (TYPE_SIZE (type))) + return 0; - if (type) - { - if (!integer_zerop (TYPE_SIZE (type))) - { - if (TYPE_MODE (type) == mode) - alignment = TYPE_ALIGN (type); - else - alignment = GET_MODE_ALIGNMENT (mode); - } - else - alignment = 0; - } - else - alignment = GET_MODE_ALIGNMENT (mode); + gcc_assert (TYPE_MODE (type) == mode); + + if (!AGGREGATE_TYPE_P (type)) + return TYPE_ALIGN (TYPE_MAIN_VARIANT (type)); + + if (TREE_CODE (type) == ARRAY_TYPE) + return TYPE_ALIGN (TREE_TYPE (type)); + + unsigned int alignment = 0; + + for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) + alignment = std::max (alignment, DECL_ALIGN (field)); return alignment; } -- 2.30.2