This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/5] stop using ROUND_TYPE_ALIGN in libobjc/


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
-- 
2.6.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]