public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Lawrence <alan.lawrence@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: marcus.shawcroft@arm.com,	james.greenhalgh@arm.com,
	richard.earnshaw@arm.com,	charlet@adacore.com,
	ebotcazou@libertysurf.fr
Subject: [PATCH 1/2][AArch64] Implement AAPCS64 updates for alignment attribute
Date: Fri, 15 Jan 2016 14:18:00 -0000	[thread overview]
Message-ID: <1452867463-30768-2-git-send-email-alan.lawrence@arm.com> (raw)
In-Reply-To: <1452867463-30768-1-git-send-email-alan.lawrence@arm.com>

gcc/ChangeLog:

	* gcc/config/aarch64/aarch64.c (aarch64_function_arg_alignment):
	Rewrite, looking one level down for records and arrays.
---
 gcc/config/aarch64/aarch64.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ae4cfb3..8eb8c3e 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1925,22 +1925,24 @@ 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;
+  gcc_assert (TYPE_FIELDS (type));
+
+  for (tree field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
+    alignment = std::max (alignment, DECL_ALIGN (field));
 
   return alignment;
 }
-- 
1.9.1

  reply	other threads:[~2016-01-15 14:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-15 14:17 [PATCH 0/2][AArch64] " Alan Lawrence
2016-01-15 14:18 ` Alan Lawrence [this message]
2016-01-15 14:18 ` [PATCH 2/2][AArch64] Tests of " Alan Lawrence
2016-06-07 11:09   ` James Greenhalgh
2016-01-18 17:11 ` [PATCH 0/2][AArch64] Implement " Eric Botcazou
2016-01-21 17:23   ` Alan Lawrence
2016-01-22 17:16     ` [PATCH 1/2][AArch64] " Alan Lawrence
2016-01-22 18:49       ` Eric Botcazou
2016-02-22 15:07       ` Alan Lawrence
2016-02-26 14:52         ` James Greenhalgh
2016-03-04 17:24           ` Alan Lawrence
2016-03-11 10:18             ` Alan Lawrence
2016-06-07 11:07       ` James Greenhalgh
2016-06-08 17:04         ` James Greenhalgh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452867463-30768-2-git-send-email-alan.lawrence@arm.com \
    --to=alan.lawrence@arm.com \
    --cc=charlet@adacore.com \
    --cc=ebotcazou@libertysurf.fr \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.com \
    --cc=marcus.shawcroft@arm.com \
    --cc=richard.earnshaw@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).