diff mbox

[3/5] stop using ROUND_TYPE_ALIGN in libobjc/

Message ID 1446205692-22412-4-git-send-email-tbsaunde+gcc@tbsaunde.org
State New
Headers show

Commit Message

tbsaunde+gcc@tbsaunde.org Oct. 30, 2015, 11:48 a.m. UTC
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Given the layering violation that using ROUND_TYPE_ALIGN in target libs
is, and the hacks needed to make it work just coppying the relevant code
into encoding.c seems to make sense as an incremental improvement.  The
epiphany version of this macro called a function that doesn't exist in
target libs, so libobjc must not build on that target and not coppying
that macro definition doesn't make anything worse.  We already
explicitly prefered the default version to the macro for sparc so we
don't need to copy that version either.  On ppc linux64 and freebsd64
after constant folding values of other target macros used for libobjc
the macro turned out to be the same as the default version so we can
just use the default for them.  Which means the only version of the
macro we actually need to copy are for ppc-darwin and AIX.

libobjc/ChangeLog:

2015-10-30  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	PR libobjc/24775
	* encoding.c (objc_layout_finish_structure): Remove usage of
	ROUND_TYPE_ALIGN.
---
 libobjc/encoding.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Comments

Andrew Pinski Oct. 31, 2015, 5:18 a.m. UTC | #1
On Fri, Oct 30, 2015 at 7:48 PM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> Given the layering violation that using ROUND_TYPE_ALIGN in target libs
> is, and the hacks needed to make it work just coppying the relevant code
> into encoding.c seems to make sense as an incremental improvement.  The
> epiphany version of this macro called a function that doesn't exist in
> target libs, so libobjc must not build on that target and not coppying
> that macro definition doesn't make anything worse.  We already
> explicitly prefered the default version to the macro for sparc so we
> don't need to copy that version either.  On ppc linux64 and freebsd64
> after constant folding values of other target macros used for libobjc
> the macro turned out to be the same as the default version so we can
> just use the default for them.  Which means the only version of the
> macro we actually need to copy are for ppc-darwin and AIX.
>
> libobjc/ChangeLog:
>
> 2015-10-30  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
>         PR libobjc/24775
>         * encoding.c (objc_layout_finish_structure): Remove usage of
>         ROUND_TYPE_ALIGN.
> ---
>  libobjc/encoding.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/libobjc/encoding.c b/libobjc/encoding.c
> index 7de768f..867372d 100644
> --- a/libobjc/encoding.c
> +++ b/libobjc/encoding.c
> @@ -1237,10 +1237,22 @@ void objc_layout_finish_structure (struct objc_struct_layout *layout,
>        /* Work out the alignment of the record as one expression and store
>           in the record type.  Round it up to a multiple of the record's
>           alignment. */
> -#if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
> -      layout->record_align = ROUND_TYPE_ALIGN (layout->original_type-1,
> -                                               1,
> -                                               layout->record_align);
> +#if _AIX
> +      char type = layout->original_type[-1];
> +      if (type == '{' || type == '(')
> +       layout->record_align =
> +         rs6000_special_round_type_align (layout->original_type-1, 1,
> +                                          layout->record_align);
> +      else
> +       layout->record_align = MAX (1, layout->record_align);
> +#elif __POWERPC__ && __APPLE__
> +      char type = layout->original_type[-1];
> +      if (type == '{' || type == '(')
> +       layout->record_align
> +         = darwin_rs6000_special_round_type_align (layout->original_type - 1,
> +                                                   1, layout->record_align);
> +      else
> +       layout->record_align = MAX (1, layout->record_align);
>  #else
>        layout->record_align = MAX (1, layout->record_align);
>  #endif

I rather not have a special defines in the source but rather a header
that gets included for these special cases instead.

Thanks,
Andrew


> --
> 2.6.2
>
diff mbox

Patch

diff --git a/libobjc/encoding.c b/libobjc/encoding.c
index 7de768f..867372d 100644
--- a/libobjc/encoding.c
+++ b/libobjc/encoding.c
@@ -1237,10 +1237,22 @@  void objc_layout_finish_structure (struct objc_struct_layout *layout,
       /* Work out the alignment of the record as one expression and store
          in the record type.  Round it up to a multiple of the record's
          alignment. */
-#if defined (ROUND_TYPE_ALIGN) && ! defined (__sparc__)
-      layout->record_align = ROUND_TYPE_ALIGN (layout->original_type-1,
-                                               1,
-                                               layout->record_align);
+#if _AIX
+      char type = layout->original_type[-1];
+      if (type == '{' || type == '(')
+	layout->record_align =
+	  rs6000_special_round_type_align (layout->original_type-1, 1,
+					   layout->record_align);
+      else
+	layout->record_align = MAX (1, layout->record_align);
+#elif __POWERPC__ && __APPLE__
+      char type = layout->original_type[-1];
+      if (type == '{' || type == '(')
+	layout->record_align
+	  = darwin_rs6000_special_round_type_align (layout->original_type - 1,
+						    1, layout->record_align);
+      else
+	layout->record_align = MAX (1, layout->record_align);
 #else
       layout->record_align = MAX (1, layout->record_align);
 #endif