Re: [RFC] Add aarch64 support for ada
Bootstrap and test succeeded, thanks. Thanks, applied as such. You can re-apply the gcc-interface/Makefile.in hunk (I reverted it as well) but you first need to adjust it to the mainline. * exp_dbug.ads (Get_External_Name): Add 'False' default to Has_Suffix, add 'Suffix' parameter and adjust comment. (Get_External_Name_With_Suffix): Delete. * exp_dbug.adb (Get_External_Name_With_Suffix): Merge into... (Get_External_Name): ...here. Add 'False' default to Has_Suffix, add 'Suffix' parameter. (Get_Encoded_Name): Remove 2nd argument in call to Get_External_Name. Call Get_External_Name instead of Get_External_Name_With_Suffix. (Get_Secondary_DT_External_Name): Likewise. * exp_cg.adb (Write_Call_Info): Likewise. * exp_disp.adb (Export_DT): Likewise. (Import_DT): Likewise. * comperr.ads (Compiler_Abort): Remove Code parameter and add From_GCC parameter with False default. * comperr.adb (Compiler_Abort): Likewise. Adjust accordingly. * types.h (Fat_Pointer): Rename into... (String_Pointer): ...this. Add comment on interfacing rules. * fe.h (Compiler_Abort): Adjust for above renaming. (Error_Msg_N): Likewise. (Error_Msg_NE): Likewise. (Get_External_Name): Likewise. Add third parameter. (Get_External_Name_With_Suffix): Delete. * gcc-interface/decl.c (STDCALL_PREFIX): Define. (create_concat_name): Adjust call to Get_External_Name, remove call to Get_External_Name_With_Suffix, use STDCALL_PREFIX, adjust for renaming. * gcc-interface/trans.c (post_error): Likewise. (post_error_ne): Likewise. * gcc-interface/misc.c (internal_error_function): Likewise. -- Eric BotcazouIndex: comperr.adb === --- comperr.adb (revision 209859) +++ comperr.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -74,8 +74,8 @@ package body Comperr is procedure Compiler_Abort (X: String; - Code : Integer := 0; - Fallback_Loc : String := ) + Fallback_Loc : String := ; + From_GCC : Boolean := False) is -- The procedures below output a bug box with information about -- the cause of the compiler abort and about the preferred method @@ -206,7 +206,7 @@ package body Comperr is Write_Str () ); if X'Length + Column 76 then -if Code 0 then +if From_GCC then Write_Str (GCC error:); end if; @@ -235,11 +235,7 @@ package body Comperr is Write_Str (X); end if; - if Code 0 then -Write_Str (, Code=); -Write_Int (Int (Code)); - - elsif Code = 0 then + if not From_GCC then -- For exception case, get exception message from the TSD. Note -- that it would be neater and cleaner to pass the exception Index: comperr.ads === --- comperr.ads (revision 209859) +++ comperr.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -31,8 +31,8 @@ package Comperr is procedure Compiler_Abort (X: String; - Code : Integer := 0; - Fallback_Loc : String := ); + Fallback_Loc : String := ; + From_GCC : Boolean := False); pragma No_Return (Compiler_Abort); -- Signals an internal compiler error. Never returns control. Depending on -- processing may end up raising Unrecoverable_Error, or exiting directly. @@ -46,10 +46,9 @@ package Comperr is -- Note that this is only used at
Re: [RFC] Add aarch64 support for ada
On 04/28/2014 08:00 AM, Eric Botcazou wrote: You can re-apply the gcc-interface/Makefile.in hunk (I reverted it as well) but you first need to adjust it to the mainline. Done, after re-bootstrapping on aarch64 Just to Be Sure. r~
Re: [RFC] Add aarch64 support for ada
On 04/23/2014 01:37 PM, Eric Botcazou wrote: But it breaks on IA-64 for the same reason as on Aarch64 so we'll need to find something else. Tentative revised patch attached. Can you give it a try when you have some time? There is a rationale based on my understanding in types.h. TIA. Bootstrap and test succeeded, thanks. r~
Re: [RFC] Add aarch64 support for ada
diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index dc5e912..302d9a3 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -2123,6 +2123,44 @@ ifeq ($(strip $(filter-out alpha% linux%,$(arch) $(osys))),) LIBRARY_VERSION := $(LIB_VERSION) endif +# AArch64 Linux +ifeq ($(strip $(filter-out aarch64% linux%,$(arch) $(osys))),) + LIBGNAT_TARGET_PAIRS = \ + a-exetim.adba-exetim-posix.adb \ + a-exetim.adsa-exetim-default.ads \ + a-intnam.adsa-intnam-linux.ads \ + a-synbar.adba-synbar-posix.adb \ + a-synbar.adsa-synbar-posix.ads \ + s-inmaop.adbs-inmaop-posix.adb \ + s-intman.adbs-intman-posix.adb \ + s-linux.adss-linux.ads \ + s-mudido.adbs-mudido-affinity.adb \ + s-osinte.adss-osinte-linux.ads \ + s-osinte.adbs-osinte-posix.adb \ + s-osprim.adbs-osprim-posix.adb \ + s-taprop.adbs-taprop-linux.adb \ + s-tasinf.adss-tasinf-linux.ads \ + s-tasinf.adbs-tasinf-linux.adb \ + s-tpopsp.adbs-tpopsp-tls.adb \ + s-taspri.adss-taspri-posix.ads \ + g-sercom.adbg-sercom-linux.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.adssystem-linux-x86_64.ads + ## ^^ Note the above is a pretty-close placeholder. + + TOOLS_TARGET_PAIRS = \ +mlib-tgt-specific.adbmlib-tgt-specific-linux.adb \ +indepsw.adbindepsw-gnu.adb + + EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o + EH_MECHANISM=-gcc + THREADSLIB=-lpthread -lrt + GNATLIB_SHARED=gnatlib-shared-dual + GMEM_LIB = gmemlib + LIBRARY_VERSION := $(LIB_VERSION) +endif + # x86-64 Linux ifeq ($(strip $(filter-out %x86_64 linux%,$(arch) $(osys))),) LIBGNAT_TARGET_PAIRS = \ This patch was not made on the mainline but got nevertheless applied on the mainline, breaking the build on x86 and x86-64 at least as a result. -- Eric Botcazou
Re: [RFC] Add aarch64 support for ada
OK, I have installed a variant of the patch (it should not change anything). But it breaks on IA-64 for the same reason as on Aarch64 so we'll need to find something else. -- Eric Botcazou
Re: [RFC] Add aarch64 support for ada
But it breaks on IA-64 for the same reason as on Aarch64 so we'll need to find something else. Tentative revised patch attached. Can you give it a try when you have some time? There is a rationale based on my understanding in types.h. TIA. -- Eric BotcazouIndex: comperr.adb === --- comperr.adb (revision 209671) +++ comperr.adb (working copy) @@ -74,8 +74,8 @@ package body Comperr is procedure Compiler_Abort (X: String; - Code : Integer := 0; - Fallback_Loc : String := ) + Fallback_Loc : String := ; + Code : Integer := 0) is -- The procedures below output a bug box with information about -- the cause of the compiler abort and about the preferred method Index: comperr.ads === --- comperr.ads (revision 209671) +++ comperr.ads (working copy) @@ -31,8 +31,8 @@ package Comperr is procedure Compiler_Abort (X: String; - Code : Integer := 0; - Fallback_Loc : String := ); + Fallback_Loc : String := ; + Code : Integer := 0); pragma No_Return (Compiler_Abort); -- Signals an internal compiler error. Never returns control. Depending on -- processing may end up raising Unrecoverable_Error, or exiting directly. Index: fe.h === --- fe.h (revision 209684) +++ 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_Pointer, String_Pointer, int) 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_Pointer, Node_Id); +extern void Error_Msg_NE (String_Pointer, Node_Id, Entity_Id); extern void Set_Identifier_Casing (Char *, const Char *); /* err_vars: */ @@ -147,11 +147,9 @@ extern void Setup_Asm_Outputs (Node_Id) #define Get_Encoded_Name exp_dbug__get_encoded_name #define Get_External_Name exp_dbug__get_external_name -#define Get_External_Name_With_Suffix exp_dbug__get_external_name_with_suffix -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_Encoded_Name (Entity_Id); +extern void Get_External_Name (Entity_Id, Boolean, String_Pointer); /* exp_util: */ Index: types.h === --- types.h (revision 209684) +++ types.h (working copy) @@ -76,11 +76,19 @@ 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. */ -typedef struct {int Low_Bound, High_Bound; } String_Template; -typedef struct {const char *Array; String_Template *Bounds; } - __attribute ((aligned (sizeof (char *) * 2))) Fat_Pointer; +/* Types for the fat pointer used for strings and the template it points to. + The fat pointer is conceptually a couple of pointers, but it is wrapped + up in a special record type. On the Ada side, the record is naturally + aligned (i.e. given pointer alignment) on regular platforms, but it is + given twice this alignment on strict-alignment platforms for performance + reasons. On the C side, for the sake of portability and simplicity, we + overalign it on all platforms (so the machine mode is always the same as + on the Ada side) but arrange to pass it in an even scalar position as a + parameter to functions (so the scalar parameter alignment is always the + same as on the Ada side). */ +typedef struct { int Low_Bound, High_Bound; } String_Template; +typedef struct { const char *Array; String_Template *Bounds; } + __attribute ((aligned (sizeof (char *) * 2))) String_Pointer; /* Types for Node/Entity Kinds: */ Index: exp_dbug.adb === --- exp_dbug.adb (revision 209671) +++ exp_dbug.adb (working copy) @@ -507,8 +507,8 @@ package body Exp_Dbug is begin -- If not generating code, there is no need to create encoded names, and -- problems when the back-end is called to annotate types without full - -- code generation. See comments in Get_External_Name_With_Suffix for - -- additional details. + -- code generation. See comments in Get_External_Name for additional + -- details. -- However we do create encoded names if the back end
Re: [RFC] Add aarch64 support for ada
How about this? I added a check vs MINSIGSTKSZ just in case, and updated the commentary a bit. While 16K is 2*SIGSTKSIZE for i686, it certainly isn't for powerpc64. But since things are working as-is I thought the revision is clearer. Fine with me, thanks. -- Eric Botcazou
Re: [RFC] Add aarch64 support for ada
Yes, this bootstrapped. OK, I have installed a variant of the patch (it should not change anything). Thanks for working on this. -- Eric Botcazou
Re: [RFC] Add aarch64 support for ada
On 04/16/2014 12:55 AM, Eric Botcazou wrote: Similarly with the HAVE_GNAT_ALTERNATE_STACK stuff. There aren't any linux hosts that don't support sigaltstack, so why is this conditionalized? Hum, I didn't know that Android also used the alternate stack... OK, let's use it unconditionally on Linux then, except for IA-64 which is a totally different beast. Can you change the patch accordingly? How about this? I added a check vs MINSIGSTKSZ just in case, and updated the commentary a bit. While 16K is 2*SIGSTKSIZE for i686, it certainly isn't for powerpc64. But since things are working as-is I thought the revision is clearer. Ok? r~ * init.c [__linux__] (HAVE_GNAT_ALTERNATE_STACK): New define. (__gnat_alternate_stack): Enable for all linux except ia64. diff --git a/gcc/ada/init.c b/gcc/ada/init.c index c3824ab..48319d6 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -556,9 +556,14 @@ __gnat_error_handler (int sig, siginfo_t *si ATTRIBUTE_UNUSED, void *ucontext) Raise_From_Signal_Handler (exception, msg); } -#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) -/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */ -char __gnat_alternate_stack[16 * 1024]; /* 2 * SIGSTKSZ */ +#ifndef __ia64__ +#define HAVE_GNAT_ALTERNATE_STACK 1 +/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. + It must be larger than MINSIGSTKSZ and hopefully near 2 * SIGSTKSZ. */ +# if 16 * 1024 MINSIGSTKSZ +# error __gnat_alternate_stack too small +# endif +char __gnat_alternate_stack[16 * 1024]; #endif #ifdef __XENO__ @@ -612,7 +617,7 @@ __gnat_install_handler (void) sigaction (SIGBUS, act, NULL); if (__gnat_get_interrupt_state (SIGSEGV) != 's') { -#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) +#ifdef HAVE_GNAT_ALTERNATE_STACK /* Setup an alternate stack region for the handler execution so that stack overflows can be handled properly, avoiding a SEGV generation from stack usage by the handler itself. */
Re: [RFC] Add aarch64 support for ada
On 16 Apr 2014, at 17:36, Richard Henderson r...@redhat.com wrote: On 04/16/2014 12:39 AM, Eric Botcazou wrote: The primary bit of rfc here is the hunk that applies to ada/types.h with respect to Fat_Pointer. Given that the Ada type, as defined in s-stratt.ads, does not include alignment, I can't imagine why the C type should have it. See gcc-interface/utils.c:finish_fat_pointer_type. 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. As the align attribute in types.h is for the host, couldn't a configure test solve this issue ? 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? I presume for Fat_Pointer'Alignment use System.Address'Size * 2; or some such incantation would do that... One of the most common Fat_Pointer is for strings, which aren't declared in any source and is very commonly used. OTOH, I think this optimization mostly targets sparc. Tristan.
Re: [RFC] Add aarch64 support for ada
On 04/17/2014 02:00 AM, Tristan Gingold wrote: On 16 Apr 2014, at 17:36, Richard Henderson r...@redhat.com wrote: On 04/16/2014 12:39 AM, Eric Botcazou wrote: The primary bit of rfc here is the hunk that applies to ada/types.h with respect to Fat_Pointer. Given that the Ada type, as defined in s-stratt.ads, does not include alignment, I can't imagine why the C type should have it. See gcc-interface/utils.c:finish_fat_pointer_type. 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. As the align attribute in types.h is for the host, couldn't a configure test solve this issue ? I doubt it. I'm not sure what kind of configure test you could write that would determine the setting of STRICT_ALIGNMENT, since even non-strict-align targets prefer to align data for performance reasons. Be careful that the test couldn't be an execution test, lest you break host != build. One of the most common Fat_Pointer is for strings, which aren't declared in any source and is very commonly used. OTOH, I think this optimization mostly targets sparc. Indeed, 32-bit sparc wants 64-bit alignment for its ldd/std instructions. Perhaps the better optimization (supposing it's really worth keeping) is to DECL_ALIGN the static strings, rather than align the type? Presumably Ada strings are as with C string literals -- symbols private to the compilation unit which are normally passed by value. Thus functions within the compilation unit would see the extra alignment of the data and be able to use ldd to load the pair. On the receiving end being able to use std would remain a matter of luck. r~
Re: [RFC] Add aarch64 support for ada
On 17 Apr 2014, at 16:50, Richard Henderson r...@redhat.com wrote: On 04/17/2014 02:00 AM, Tristan Gingold wrote: On 16 Apr 2014, at 17:36, Richard Henderson r...@redhat.com wrote: On 04/16/2014 12:39 AM, Eric Botcazou wrote: The primary bit of rfc here is the hunk that applies to ada/types.h with respect to Fat_Pointer. Given that the Ada type, as defined in s-stratt.ads, does not include alignment, I can't imagine why the C type should have it. See gcc-interface/utils.c:finish_fat_pointer_type. 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. As the align attribute in types.h is for the host, couldn't a configure test solve this issue ? I doubt it. I'm not sure what kind of configure test you could write that would determine the setting of STRICT_ALIGNMENT, since even non-strict-align targets prefer to align data for performance reasons. Be careful that the test couldn't be an execution test, lest you break host != build. What about this compile-time check: package Fatptralign is type String_Acc is access String; type Integer_acc is access Integer; pragma Compile_Time_Error (String_Acc'Alignment = 1 * Integer_Acc'Alignment, Fat pointer are simply aligned); pragma Compile_Time_Error (String_Acc'Alignment = 2 * Integer_Acc'Alignment, Fat pointer are doubly aligned); end Fatptralign; One of the most common Fat_Pointer is for strings, which aren't declared in any source and is very commonly used. OTOH, I think this optimization mostly targets sparc. Indeed, 32-bit sparc wants 64-bit alignment for its ldd/std instructions. Perhaps the better optimization (supposing it's really worth keeping) That's a true question (worth keeping). I think this also affects powerpc (as an important target) Eric ? is to DECL_ALIGN the static strings, rather than align the type? [ Ada strings (and more generally Ada unconstrained array and Ada accesses to unconstrained arrays) are represented in GNAT by a fat pointer, ie a structure containing a pointer to the bounds and a pointer to the data. We are talking about the alignment of that structure. ] Presumably Ada strings are as with C string literals -- symbols private to the compilation unit which are normally passed by value. Thus functions within the compilation unit would see the extra alignment of the data and be able to use ldd to load the pair. On the receiving end being able to use std would remain a matter of luck. I think this will dismiss most of the gain. Fat pointers can be heavily used in some applications, and be present in structures. Gain with only private symbols might be tiny. Tristan.
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 BotcazouIndex: 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
Re: [RFC] Add aarch64 support for ada
On 04/17/2014 08:35 AM, Tristan Gingold wrote: What about this compile-time check: package Fatptralign is type String_Acc is access String; type Integer_acc is access Integer; pragma Compile_Time_Error (String_Acc'Alignment = 1 * Integer_Acc'Alignment, Fat pointer are simply aligned); pragma Compile_Time_Error (String_Acc'Alignment = 2 * Integer_Acc'Alignment, Fat pointer are doubly aligned); end Fatptralign; Yes, that seems to work, even with a cross-compiler. r~
Re: [RFC] Add aarch64 support for ada
On 04/17/2014 08:56 AM, Eric Botcazou wrote: 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. Yes, this bootstrapped. r~
[RFC] Add aarch64 support for ada
From: Richard Henderson r...@redhat.com The primary bit of rfc here is the hunk that applies to ada/types.h with respect to Fat_Pointer. Given that the Ada type, as defined in s-stratt.ads, does not include alignment, I can't imagine why the C type should have it. This causes problems with the AArch64 calling convention, which honors this alignment in the set of registers it chooses to pass the struct. One can see this difference in create_concat_name vs Exp_Dbug.Get_External_Name_With_Suffix. The secondary bit of rfc is in the Makefile change. In particular, + system.adssystem-linux-x86_64.ads IMO, this should really be called system-linux-lp64.ads, and should be usable for any 64-bit target that uses full ieee floating point, which is all of them. IMO basically all of the differences between x86 and the other linux targets is a bug in the other linux targets. I.e. missing functionality. There are rare exceptions, such as ARM32 and its AAPCS unwinding. Similarly with the HAVE_GNAT_ALTERNATE_STACK stuff. There aren't any linux hosts that don't support sigaltstack, so why is this conditionalized? Anyway, === gnat Summary === # of expected passes2308 # of expected failures 34 # of unsupported tests 22 I'll see about puting some rpms somewhere public so that no one else has to do the whole canadian-cross compile dance. r~ * gcc-interface/Makefile.in: Support aarch64-linux. * init.c (__gnat_alternate_stack): Use for aarch64. (__gnat_install_handler): Do sigaltstack for aarch64 too. * types.h (Fat_Pointer): Remove alignment attribute. diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in index dc5e912..302d9a3 100644 --- a/gcc/ada/gcc-interface/Makefile.in +++ b/gcc/ada/gcc-interface/Makefile.in @@ -2123,6 +2123,44 @@ ifeq ($(strip $(filter-out alpha% linux%,$(arch) $(osys))),) LIBRARY_VERSION := $(LIB_VERSION) endif +# AArch64 Linux +ifeq ($(strip $(filter-out aarch64% linux%,$(arch) $(osys))),) + LIBGNAT_TARGET_PAIRS = \ + a-exetim.adba-exetim-posix.adb \ + a-exetim.adsa-exetim-default.ads \ + a-intnam.adsa-intnam-linux.ads \ + a-synbar.adba-synbar-posix.adb \ + a-synbar.adsa-synbar-posix.ads \ + s-inmaop.adbs-inmaop-posix.adb \ + s-intman.adbs-intman-posix.adb \ + s-linux.adss-linux.ads \ + s-mudido.adbs-mudido-affinity.adb \ + s-osinte.adss-osinte-linux.ads \ + s-osinte.adbs-osinte-posix.adb \ + s-osprim.adbs-osprim-posix.adb \ + s-taprop.adbs-taprop-linux.adb \ + s-tasinf.adss-tasinf-linux.ads \ + s-tasinf.adbs-tasinf-linux.adb \ + s-tpopsp.adbs-tpopsp-tls.adb \ + s-taspri.adss-taspri-posix.ads \ + g-sercom.adbg-sercom-linux.adb \ + $(ATOMICS_TARGET_PAIRS) \ + $(ATOMICS_BUILTINS_TARGET_PAIRS) \ + system.adssystem-linux-x86_64.ads + ## ^^ Note the above is a pretty-close placeholder. + + TOOLS_TARGET_PAIRS = \ +mlib-tgt-specific.adbmlib-tgt-specific-linux.adb \ +indepsw.adbindepsw-gnu.adb + + EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o + EH_MECHANISM=-gcc + THREADSLIB=-lpthread -lrt + GNATLIB_SHARED=gnatlib-shared-dual + GMEM_LIB = gmemlib + LIBRARY_VERSION := $(LIB_VERSION) +endif + # x86-64 Linux ifeq ($(strip $(filter-out %x86_64 linux%,$(arch) $(osys))),) LIBGNAT_TARGET_PAIRS = \ diff --git a/gcc/ada/init.c b/gcc/ada/init.c index f5c3a81..0ac2398 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -562,7 +562,9 @@ __gnat_error_handler (int sig, siginfo_t *si ATTRIBUTE_UNUSED, void *ucontext) Raise_From_Signal_Handler (exception, msg); } -#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) +#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) \ +|| defined (__aarch64__) +#define HAVE_GNAT_ALTERNATE_STACK 1 /* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */ char __gnat_alternate_stack[16 * 1024]; /* 2 * SIGSTKSZ */ #endif @@ -603,7 +605,7 @@ __gnat_install_handler (void) handled properly, avoiding a SEGV generation from stack usage by the handler itself. */ -#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) +#ifdef HAVE_GNAT_ALTERNATE_STACK stack_t stack; stack.ss_sp = __gnat_alternate_stack; stack.ss_size = sizeof (__gnat_alternate_stack); @@ -624,7 +626,7 @@ __gnat_install_handler (void) sigaction (SIGILL, act, NULL); if (__gnat_get_interrupt_state (SIGBUS) != 's') sigaction (SIGBUS, act, NULL); -#if defined (i386) || defined (__x86_64__) || defined (__powerpc__) +#ifdef HAVE_GNAT_ALTERNATE_STACK act.sa_flags |= SA_ONSTACK; #endif if (__gnat_get_interrupt_state (SIGSEGV) != 's') diff --git a/gcc/ada/types.h b/gcc/ada/types.h index a0f2891..6b3db93 100644 --- a/gcc/ada/types.h +++ b/gcc/ada/types.h @@ -79,8 +79,7 @@ typedef Char *Str_Ptr; /* Types for the fat pointer used for strings and the template it points to. */ typedef struct {int Low_Bound, High_Bound; } String_Template;
Re: [RFC] Add aarch64 support for ada
The Makfile.in and init.c changes are OK. The types.h change is likely more controversial and may be problematic, I'll let Eric comment. + system.adssystem-linux-x86_64.ads IMO, this should really be called system-linux-lp64.ads, and should be usable for any 64-bit target that uses full ieee floating point, which is all of them. Well, in our experience, each time we've tried to share system files, this came back and bit us at some point. But I do not know the aarch64 architecture to comment on this specific case. Arno
Re: [RFC] Add aarch64 support for ada
The primary bit of rfc here is the hunk that applies to ada/types.h with respect to Fat_Pointer. Given that the Ada type, as defined in s-stratt.ads, does not include alignment, I can't imagine why the C type should have it. See gcc-interface/utils.c:finish_fat_pointer_type. This causes problems with the AArch64 calling convention, which honors this alignment in the set of registers it chooses to pass the struct. One can see this difference in create_concat_name vs Exp_Dbug.Get_External_Name_With_Suffix. This should not happen though, since String is passed as a fat pointer too. Similarly with the HAVE_GNAT_ALTERNATE_STACK stuff. There aren't any linux hosts that don't support sigaltstack, so why is this conditionalized? Because we don't want to use it if we can avoid it, as this generally makes things less robust. It's mandatory for x86 and x86-64, but I'm not sure why PowerPC is in the list. I'll try and remove it. Given that aarch32 works without it, I don't think that we should add it for aarch64. This may make some stack checking tests fail, but that's OK since there is no stack checking support in the aarch64 back-end AFAIK. -- Eric Botcazou
Re: [RFC] Add aarch64 support for ada
Similarly with the HAVE_GNAT_ALTERNATE_STACK stuff. There aren't any linux hosts that don't support sigaltstack, so why is this conditionalized? Hum, I didn't know that Android also used the alternate stack... OK, let's use it unconditionally on Linux then, except for IA-64 which is a totally different beast. Can you change the patch accordingly? -- Eric Botcazou
Re: [RFC] Add aarch64 support for ada
On 04/16/2014 12:39 AM, Eric Botcazou wrote: The primary bit of rfc here is the hunk that applies to ada/types.h with respect to Fat_Pointer. Given that the Ada type, as defined in s-stratt.ads, does not include alignment, I can't imagine why the C type should have it. See gcc-interface/utils.c:finish_fat_pointer_type. 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. 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? I presume for Fat_Pointer'Alignment use System.Address'Size * 2; or some such incantation would do that... r~