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]

Re: [RFC] Add aarch64 support for ada


> Ah hah.
> 
>   /* Make sure we can put it into a register.  */
>   if (STRICT_ALIGNMENT)
>     TYPE_ALIGN (record_type) = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE);
> 
> AArch64 is not a STRICT_ALIGNMENT target, thus the mismatch.

I see.  Initially this alignment promotion had been universal, but someone 
recently complained about holes in structures on x86-64 because of it so we 
restricted it to the platforms where it is really necessary for the goal 
stated in the comment; we left types.h untouched because the alignment could 
not possibly change the calling convention for non-strict-alignment targets...

> If we were to make this alignment unconditional, would it be better to drop
> the code from here in finish_fat_pointer_type and instead record that in
> the Ada source, as we do with the C source?

We cannot really do that, the s-stratt.ads thing is a red herring, alignment 
of fat pointer types is entirely decided inside the compiler (layout.adb:3213 
and gcc-interface/utils.c:finish_fat_pointer_type)

I presume that the attached kludge is sufficient to make it work?


	* fe.h (Compiler_Abort): Replace Fat_Pointer by String.
	(Error_Msg_N): Likewise.
	(Error_Msg_NE): Likewise.
	(Get_External_Name_With_Suffix): Likewise.
	* types.h (Fat_Pointer): Delete.
	(String): New type.
	(DECLARE_STRING): New macro.
	* gcc-interface/decl.c (create_concat_name): Adjust.
	* gcc-interface/trans.c (post_error): Likewise.
	(post_error_ne): Likewise.
	* gcc-interface/misc.c (internal_error_function): Likewise.


-- 
Eric Botcazou
Index: fe.h
===================================================================
--- fe.h	(revision 209461)
+++ fe.h	(working copy)
@@ -39,7 +39,7 @@ extern "C" {
 /* comperr:  */
 
 #define Compiler_Abort comperr__compiler_abort
-extern int Compiler_Abort (Fat_Pointer, int, Fat_Pointer) ATTRIBUTE_NORETURN;
+extern int Compiler_Abort (String, int, String) ATTRIBUTE_NORETURN;
 
 /* csets: */
 
@@ -90,8 +90,8 @@ extern Node_Id Get_Attribute_Definition_
 #define Error_Msg_NE              errout__error_msg_ne
 #define Set_Identifier_Casing     errout__set_identifier_casing
 
-extern void Error_Msg_N	          (Fat_Pointer, Node_Id);
-extern void Error_Msg_NE          (Fat_Pointer, Node_Id, Entity_Id);
+extern void Error_Msg_N	          (String, Node_Id);
+extern void Error_Msg_NE          (String, Node_Id, Entity_Id);
 extern void Set_Identifier_Casing (Char *, const Char *);
 
 /* err_vars: */
@@ -151,7 +151,7 @@ extern void Setup_Asm_Outputs		(Node_Id)
 
 extern void Get_Encoded_Name			(Entity_Id);
 extern void Get_External_Name			(Entity_Id, Boolean);
-extern void Get_External_Name_With_Suffix	(Entity_Id, Fat_Pointer);
+extern void Get_External_Name_With_Suffix	(Entity_Id, String);
 
 /* exp_util: */
 
Index: types.h
===================================================================
--- types.h	(revision 209461)
+++ types.h	(working copy)
@@ -76,11 +76,14 @@ typedef Char *Str;
 /* Pointer to string of Chars */
 typedef Char *Str_Ptr;
 
-/* Types for the fat pointer used for strings and the template it
-   points to.  */
+/* Types for the fat pointer used for strings and the template it points to.
+   On most platforms the fat pointer is naturally aligned but, on the rest,
+   it is given twice the natural alignment.  For maximum portability, we do
+   not overalign the type but only the objects.  */
 typedef struct {int Low_Bound, High_Bound; } String_Template;
-typedef struct {const char *Array; String_Template *Bounds; }
-	__attribute ((aligned (sizeof (char *) * 2))) Fat_Pointer;
+typedef struct {const char *Array; String_Template *Bounds; } String;
+#define DECLARE_STRING(s, a, t) \
+  __attribute__ ((aligned (sizeof (char *) * 2))) String s = { a, &t }
 
 /* Types for Node/Entity Kinds:  */
 
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 209461)
+++ gcc-interface/decl.c	(working copy)
@@ -8861,8 +8861,8 @@ create_concat_name (Entity_Id gnat_entit
   if (suffix)
     {
       String_Template temp = {1, (int) strlen (suffix)};
-      Fat_Pointer fp = {suffix, &temp};
-      Get_External_Name_With_Suffix (gnat_entity, fp);
+      DECLARE_STRING (s, suffix, temp);
+      Get_External_Name_With_Suffix (gnat_entity, s);
     }
   else
     Get_External_Name (gnat_entity, 0);
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 209461)
+++ gcc-interface/trans.c	(working copy)
@@ -7833,7 +7833,6 @@ gnat_gimplify_stmt (tree *stmt_p)
 	      gnu_cond = build2 (ANNOTATE_EXPR, TREE_TYPE (gnu_cond), gnu_cond,
 				 build_int_cst (integer_type_node,
 						annot_expr_ivdep_kind));
-
 	    if (LOOP_STMT_NO_VECTOR (stmt))
 	      gnu_cond = build2 (ANNOTATE_EXPR, TREE_TYPE (gnu_cond), gnu_cond,
 				 build_int_cst (integer_type_node,
@@ -9357,16 +9356,14 @@ void
 post_error (const char *msg, Node_Id node)
 {
   String_Template temp;
-  Fat_Pointer fp;
+  DECLARE_STRING (s, msg, temp);
 
   if (No (node))
     return;
 
   temp.Low_Bound = 1;
   temp.High_Bound = strlen (msg);
-  fp.Bounds = &temp;
-  fp.Array = msg;
-  Error_Msg_N (fp, node);
+  Error_Msg_N (s, node);
 }
 
 /* Similar to post_error, but NODE is the node at which to post the error and
@@ -9376,16 +9373,14 @@ void
 post_error_ne (const char *msg, Node_Id node, Entity_Id ent)
 {
   String_Template temp;
-  Fat_Pointer fp;
+  DECLARE_STRING (s, msg, temp);
 
   if (No (node))
     return;
 
   temp.Low_Bound = 1;
   temp.High_Bound = strlen (msg);
-  fp.Bounds = &temp;
-  fp.Array = msg;
-  Error_Msg_NE (fp, node, ent);
+  Error_Msg_NE (s, node, ent);
 }
 
 /* Similar to post_error_ne, but NUM is the number to use for the '^'.  */
Index: gcc-interface/misc.c
===================================================================
--- gcc-interface/misc.c	(revision 209461)
+++ gcc-interface/misc.c	(working copy)
@@ -281,10 +281,11 @@ internal_error_function (diagnostic_cont
 			 const char *msgid, va_list *ap)
 {
   text_info tinfo;
-  char *buffer, *p, *loc;
+  char *buffer = NULL, *loc = NULL, *p;
   String_Template temp, temp_loc;
-  Fat_Pointer fp, fp_loc;
-  expanded_location s;
+  DECLARE_STRING (s, buffer, temp);
+  DECLARE_STRING (s_loc, loc, temp_loc);
+  expanded_location xloc;
 
   /* Warn if plugins present.  */
   warn_if_plugins ();
@@ -311,21 +312,17 @@ internal_error_function (diagnostic_cont
 
   temp.Low_Bound = 1;
   temp.High_Bound = p - buffer;
-  fp.Bounds = &temp;
-  fp.Array = buffer;
 
-  s = expand_location (input_location);
-  if (context->show_column && s.column != 0)
-    asprintf (&loc, "%s:%d:%d", s.file, s.line, s.column);
+  xloc = expand_location (input_location);
+  if (context->show_column && xloc.column != 0)
+    asprintf (&loc, "%s:%d:%d", xloc.file, xloc.line, xloc.column);
   else
-    asprintf (&loc, "%s:%d", s.file, s.line);
+    asprintf (&loc, "%s:%d", xloc.file, xloc.line);
   temp_loc.Low_Bound = 1;
   temp_loc.High_Bound = strlen (loc);
-  fp_loc.Bounds = &temp_loc;
-  fp_loc.Array = loc;
 
   Current_Error_Node = error_gnat_node;
-  Compiler_Abort (fp, -1, fp_loc);
+  Compiler_Abort (s, -1, s_loc);
 }
 
 /* Perform all the initialization steps that are language-specific.  */

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