Re: [PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-06-07 Thread Jonathan Yong

On 6/6/24 09:23, Evgeny Karpov wrote:

Thursday, June 6, 2024 1:42 AM
Jonathan Yong <10wa...@gmail.com> wrote:


Where is HAVE_64BIT_POINTERS used?



Sorry, it was missed in the posted changes for review.

Regards,
Evgeny

diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h
index 8a6f0e8e8a5..0c9d5424942 100644
--- a/gcc/config/mingw/mingw32.h
+++ b/gcc/config/mingw/mingw32.h
@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3.  If not see
  #endif

  #undef SUB_LINK_ENTRY
-#if TARGET_64BIT_DEFAULT || defined (TARGET_AARCH64_MS_ABI)
+#if HAVE_64BIT_POINTERS
  #define SUB_LINK_ENTRY SUB_LINK_ENTRY64
  #else
  #define SUB_LINK_ENTRY SUB_LINK_ENTRY32



Looks OK to me.


Re: [PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-06-06 Thread Evgeny Karpov
Thursday, June 6, 2024 1:42 AM
Jonathan Yong <10wa...@gmail.com> wrote:
>
> Where is HAVE_64BIT_POINTERS used?
> 

Sorry, it was missed in the posted changes for review.

Regards,
Evgeny

diff --git a/gcc/config/mingw/mingw32.h b/gcc/config/mingw/mingw32.h
index 8a6f0e8e8a5..0c9d5424942 100644
--- a/gcc/config/mingw/mingw32.h
+++ b/gcc/config/mingw/mingw32.h
@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3.  If not see
 #endif

 #undef SUB_LINK_ENTRY
-#if TARGET_64BIT_DEFAULT || defined (TARGET_AARCH64_MS_ABI)
+#if HAVE_64BIT_POINTERS
 #define SUB_LINK_ENTRY SUB_LINK_ENTRY64
 #else
 #define SUB_LINK_ENTRY SUB_LINK_ENTRY32



Re: [PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-06-05 Thread Jonathan Yong

On 6/5/24 06:01, Uros Bizjak wrote:

On Tue, Jun 4, 2024 at 10:10 PM Evgeny Karpov
 wrote:


Richard and Uros, could you please review the changes for v2?


LGTM for the generic x86 part, OS-specific part (cygming) should also
be reviewed by OS port maintainer (CC'd).

Thanks,
Uros.



Where is HAVE_64BIT_POINTERS used?


Additionally, we have detected an issue with GCC GC in winnt-dll.cc. The fix 
will be included in v2.


-ix86_handle_selectany_attribute (tree *node, tree name, tree, int,
+mingw_handle_selectany_attribute (tree *node, tree name, tree, int,
   bool *no_add_attrs)



please reindent the parameters for the new name length.


Richard, could you please clarify how it should be done?
Thanks!

Regards,
Evgeny


---
  gcc/config/aarch64/cygming.h   |  6 +
  gcc/config/i386/cygming.h  |  6 +
  gcc/config/i386/i386-expand.cc |  6 +++--
  gcc/config/i386/i386-expand.h  |  2 --
  gcc/config/i386/i386.cc| 42 ++
  gcc/config/i386/i386.h |  2 ++
  gcc/config/mingw/winnt-dll.cc  |  8 ++-
  gcc/config/mingw/winnt-dll.h   |  2 +-
  8 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h
index 4beebf9e093..0ff475754e0 100644
--- a/gcc/config/aarch64/cygming.h
+++ b/gcc/config/aarch64/cygming.h
@@ -183,4 +183,10 @@ still needed for compilation.  */
  #undef MAX_OFILE_ALIGNMENT
  #define MAX_OFILE_ALIGNMENT (8192 * 8)

+#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC 0
+
+#define HAVE_64BIT_POINTERS 1
+
+#define GOT_ALIAS_SET mingw_GOT_alias_set ()
+
  #endif
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index ee01e6bb6ce..cd240533dbc 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -469,3 +469,9 @@ do {\
  #ifndef HAVE_GAS_ALIGNED_COMM
  # define HAVE_GAS_ALIGNED_COMM 0
  #endif
+
+#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC ix86_cmodel != CM_LARGE_PIC && 
ix86_cmodel != CM_MEDIUM_PIC
+
+#define HAVE_64BIT_POINTERS TARGET_64BIT_DEFAULT
+
+#define GOT_ALIAS_SET mingw_GOT_alias_set ()
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index fb460e30d0a..267d0ba257b 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -408,11 +408,12 @@ ix86_expand_move (machine_mode mode, rtx operands[])
  : UNSPEC_GOT));
   op1 = gen_rtx_CONST (Pmode, op1);
   op1 = gen_const_mem (Pmode, op1);
- set_mem_alias_set (op1, ix86_GOT_alias_set ());
+ set_mem_alias_set (op1, GOT_ALIAS_SET);
 }
else
 {
- tmp = ix86_legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
+#if TARGET_PECOFF
+ tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
   if (tmp)
 {
   op1 = tmp;
@@ -424,6 +425,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])
   op1 = operands[1];
   break;
 }
+#endif
 }

if (addend)
diff --git a/gcc/config/i386/i386-expand.h b/gcc/config/i386/i386-expand.h
index a8c20993954..5e02df1706d 100644
--- a/gcc/config/i386/i386-expand.h
+++ b/gcc/config/i386/i386-expand.h
@@ -34,9 +34,7 @@ struct expand_vec_perm_d
  };

  rtx legitimize_tls_address (rtx x, enum tls_model model, bool for_mov);
-alias_set_type ix86_GOT_alias_set (void);
  rtx legitimize_pic_address (rtx orig, rtx reg);
-rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg);

  bool insn_defines_reg (unsigned int regno1, unsigned int regno2,
rtx_insn *insn);
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 66845b30446..ee3a59ed498 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -11807,30 +11807,6 @@ constant_address_p (rtx x)
  }



-#if TARGET_PECOFF
-rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
-{
-  return legitimize_pe_coff_symbol (addr, inreg);
-}
-
-alias_set_type
-ix86_GOT_alias_set (void)
-{
-  return mingw_GOT_alias_set ();
-}
-#else
-rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
-{
-  return NULL_RTX;
-}
-
-alias_set_type
-ix86_GOT_alias_set (void)
-{
-  return -1;
-}
-#endif
-
  /* Return a legitimate reference for ORIG (an address) using the
 register REG.  If REG is 0, a new pseudo is generated.

@@ -11867,9 +11843,11 @@ legitimize_pic_address (rtx orig, rtx reg)

if (TARGET_64BIT && TARGET_DLLIMPORT_DECL_ATTRIBUTES)
  {
-  rtx tmp = ix86_legitimize_pe_coff_symbol (addr, true);
+#if TARGET_PECOFF
+  rtx tmp = legitimize_pe_coff_symbol (addr, true);
if (tmp)
  return tmp;
+#endif
  }

if (TARGET_64BIT && legitimate_pic_address_disp_p (addr))
@@ -11912,9 +11890,11 @@ legitimize_pic_address (rtx orig, rtx reg)
   on VxWorks, see gotoff_operand.  */
|| (TARGET_VXWORKS_RTP && GET_CODE (addr) == LABEL_REF)

Re: [PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-06-05 Thread Richard Sandiford
Evgeny Karpov  writes:
> Richard and Uros, could you please review the changes for v2?
> Additionally, we have detected an issue with GCC GC in winnt-dll.cc. The fix 
> will be included in v2.

Would it be possible to have a more "purposeful" name than
CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC?  What's the property of
large and medium PIC that needs to be handled differently?

It'd be good to have the macro be a positive test rather than a negative
test, so that we don't end up with !IS_NOT_FOO when testing for FOO.

Otherwise it looks good to me.

I never fully reviewed 1/6 or 6/6, sorry.  My main comment there is
that it would be good to avoid including config/mingw/winnt.h and
config/mingw/winnt-dll.h in config/aarch64/aarch64-protos.h (or in
other common AArch64 code).  It's OK for common AArch64 code to
have hooks that can be filled in by OS-specific headers, but there
shouldn't be OS-specific includes or code in the common files themselves.

>>> -ix86_handle_selectany_attribute (tree *node, tree name, tree, int,
>>> +mingw_handle_selectany_attribute (tree *node, tree name, tree, int,
>>>  bool *no_add_attrs)
>
>> please reindent the parameters for the new name length.
>
> Richard, could you please clarify how it should be done?

The "bool" on the second line should be directly under the "tree"
on the first line (so one extra space before "bool").

Thanks,
Richard


> Thanks!
>
> Regards,
> Evgeny
>
>
> ---
>  gcc/config/aarch64/cygming.h   |  6 +
>  gcc/config/i386/cygming.h  |  6 +
>  gcc/config/i386/i386-expand.cc |  6 +++--
>  gcc/config/i386/i386-expand.h  |  2 --
>  gcc/config/i386/i386.cc| 42 ++
>  gcc/config/i386/i386.h |  2 ++
>  gcc/config/mingw/winnt-dll.cc  |  8 ++-
>  gcc/config/mingw/winnt-dll.h   |  2 +-
>  8 files changed, 33 insertions(+), 41 deletions(-)
>
> diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h
> index 4beebf9e093..0ff475754e0 100644
> --- a/gcc/config/aarch64/cygming.h
> +++ b/gcc/config/aarch64/cygming.h
> @@ -183,4 +183,10 @@ still needed for compilation.  */
>  #undef MAX_OFILE_ALIGNMENT
>  #define MAX_OFILE_ALIGNMENT (8192 * 8)
>  
> +#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC 0
> +
> +#define HAVE_64BIT_POINTERS 1
> +
> +#define GOT_ALIAS_SET mingw_GOT_alias_set ()
> +
>  #endif
> diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
> index ee01e6bb6ce..cd240533dbc 100644
> --- a/gcc/config/i386/cygming.h
> +++ b/gcc/config/i386/cygming.h
> @@ -469,3 +469,9 @@ do {  \
>  #ifndef HAVE_GAS_ALIGNED_COMM
>  # define HAVE_GAS_ALIGNED_COMM 0
>  #endif
> +
> +#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC ix86_cmodel != CM_LARGE_PIC && 
> ix86_cmodel != CM_MEDIUM_PIC
> +
> +#define HAVE_64BIT_POINTERS TARGET_64BIT_DEFAULT
> +
> +#define GOT_ALIAS_SET mingw_GOT_alias_set ()
> diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
> index fb460e30d0a..267d0ba257b 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -408,11 +408,12 @@ ix86_expand_move (machine_mode mode, rtx operands[])
>: UNSPEC_GOT));
> op1 = gen_rtx_CONST (Pmode, op1);
> op1 = gen_const_mem (Pmode, op1);
> -   set_mem_alias_set (op1, ix86_GOT_alias_set ());
> +   set_mem_alias_set (op1, GOT_ALIAS_SET);
>   }
>else
>   {
> -   tmp = ix86_legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
> +#if TARGET_PECOFF
> +   tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
> if (tmp)
>   {
> op1 = tmp;
> @@ -424,6 +425,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])
> op1 = operands[1];
> break;
>   }
> +#endif
>   }
>  
>if (addend)
> diff --git a/gcc/config/i386/i386-expand.h b/gcc/config/i386/i386-expand.h
> index a8c20993954..5e02df1706d 100644
> --- a/gcc/config/i386/i386-expand.h
> +++ b/gcc/config/i386/i386-expand.h
> @@ -34,9 +34,7 @@ struct expand_vec_perm_d
>  };
>  
>  rtx legitimize_tls_address (rtx x, enum tls_model model, bool for_mov);
> -alias_set_type ix86_GOT_alias_set (void);
>  rtx legitimize_pic_address (rtx orig, rtx reg);
> -rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg);
>  
>  bool insn_defines_reg (unsigned int regno1, unsigned int regno2,
>  rtx_insn *insn);
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
> index 66845b30446..ee3a59ed498 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -11807,30 +11807,6 @@ constant_address_p (rtx x)
>  }
>  
>
>  
> -#if TARGET_PECOFF
> -rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
> -{
> -  return legitimize_pe_coff_symbol (addr, inreg);
> -}
> -
> -alias_set_type
> -ix86_GOT_alias_set (void)
> -{
> -  return mingw_GOT_alias_set ();
> -}
> -#else
> -rtx ix86_legitimize_pe_coff_symbol 

Re: [PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-06-04 Thread Uros Bizjak
On Tue, Jun 4, 2024 at 10:10 PM Evgeny Karpov
 wrote:
>
> Richard and Uros, could you please review the changes for v2?

LGTM for the generic x86 part, OS-specific part (cygming) should also
be reviewed by OS port maintainer (CC'd).

Thanks,
Uros.

> Additionally, we have detected an issue with GCC GC in winnt-dll.cc. The fix 
> will be included in v2.
>
> >> -ix86_handle_selectany_attribute (tree *node, tree name, tree, int,
> >> +mingw_handle_selectany_attribute (tree *node, tree name, tree, int,
> >>   bool *no_add_attrs)
>
> > please reindent the parameters for the new name length.
>
> Richard, could you please clarify how it should be done?
> Thanks!
>
> Regards,
> Evgeny
>
>
> ---
>  gcc/config/aarch64/cygming.h   |  6 +
>  gcc/config/i386/cygming.h  |  6 +
>  gcc/config/i386/i386-expand.cc |  6 +++--
>  gcc/config/i386/i386-expand.h  |  2 --
>  gcc/config/i386/i386.cc| 42 ++
>  gcc/config/i386/i386.h |  2 ++
>  gcc/config/mingw/winnt-dll.cc  |  8 ++-
>  gcc/config/mingw/winnt-dll.h   |  2 +-
>  8 files changed, 33 insertions(+), 41 deletions(-)
>
> diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h
> index 4beebf9e093..0ff475754e0 100644
> --- a/gcc/config/aarch64/cygming.h
> +++ b/gcc/config/aarch64/cygming.h
> @@ -183,4 +183,10 @@ still needed for compilation.  */
>  #undef MAX_OFILE_ALIGNMENT
>  #define MAX_OFILE_ALIGNMENT (8192 * 8)
>
> +#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC 0
> +
> +#define HAVE_64BIT_POINTERS 1
> +
> +#define GOT_ALIAS_SET mingw_GOT_alias_set ()
> +
>  #endif
> diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
> index ee01e6bb6ce..cd240533dbc 100644
> --- a/gcc/config/i386/cygming.h
> +++ b/gcc/config/i386/cygming.h
> @@ -469,3 +469,9 @@ do {\
>  #ifndef HAVE_GAS_ALIGNED_COMM
>  # define HAVE_GAS_ALIGNED_COMM 0
>  #endif
> +
> +#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC ix86_cmodel != CM_LARGE_PIC && 
> ix86_cmodel != CM_MEDIUM_PIC
> +
> +#define HAVE_64BIT_POINTERS TARGET_64BIT_DEFAULT
> +
> +#define GOT_ALIAS_SET mingw_GOT_alias_set ()
> diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
> index fb460e30d0a..267d0ba257b 100644
> --- a/gcc/config/i386/i386-expand.cc
> +++ b/gcc/config/i386/i386-expand.cc
> @@ -408,11 +408,12 @@ ix86_expand_move (machine_mode mode, rtx operands[])
>  : UNSPEC_GOT));
>   op1 = gen_rtx_CONST (Pmode, op1);
>   op1 = gen_const_mem (Pmode, op1);
> - set_mem_alias_set (op1, ix86_GOT_alias_set ());
> + set_mem_alias_set (op1, GOT_ALIAS_SET);
> }
>else
> {
> - tmp = ix86_legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
> +#if TARGET_PECOFF
> + tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
>   if (tmp)
> {
>   op1 = tmp;
> @@ -424,6 +425,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])
>   op1 = operands[1];
>   break;
> }
> +#endif
> }
>
>if (addend)
> diff --git a/gcc/config/i386/i386-expand.h b/gcc/config/i386/i386-expand.h
> index a8c20993954..5e02df1706d 100644
> --- a/gcc/config/i386/i386-expand.h
> +++ b/gcc/config/i386/i386-expand.h
> @@ -34,9 +34,7 @@ struct expand_vec_perm_d
>  };
>
>  rtx legitimize_tls_address (rtx x, enum tls_model model, bool for_mov);
> -alias_set_type ix86_GOT_alias_set (void);
>  rtx legitimize_pic_address (rtx orig, rtx reg);
> -rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg);
>
>  bool insn_defines_reg (unsigned int regno1, unsigned int regno2,
>rtx_insn *insn);
> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
> index 66845b30446..ee3a59ed498 100644
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -11807,30 +11807,6 @@ constant_address_p (rtx x)
>  }
>
>
>
> -#if TARGET_PECOFF
> -rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
> -{
> -  return legitimize_pe_coff_symbol (addr, inreg);
> -}
> -
> -alias_set_type
> -ix86_GOT_alias_set (void)
> -{
> -  return mingw_GOT_alias_set ();
> -}
> -#else
> -rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
> -{
> -  return NULL_RTX;
> -}
> -
> -alias_set_type
> -ix86_GOT_alias_set (void)
> -{
> -  return -1;
> -}
> -#endif
> -
>  /* Return a legitimate reference for ORIG (an address) using the
> register REG.  If REG is 0, a new pseudo is generated.
>
> @@ -11867,9 +11843,11 @@ legitimize_pic_address (rtx orig, rtx reg)
>
>if (TARGET_64BIT && TARGET_DLLIMPORT_DECL_ATTRIBUTES)
>  {
> -  rtx tmp = ix86_legitimize_pe_coff_symbol (addr, true);
> +#if TARGET_PECOFF
> +  rtx tmp = legitimize_pe_coff_symbol (addr, true);
>if (tmp)
>  return tmp;
> +#endif
>  }
>
>if (TARGET_64BIT && legitimate_pic_address_disp_p (addr))
> @@ -11912,9 +11890,1

[PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-06-04 Thread Evgeny Karpov
Richard and Uros, could you please review the changes for v2?
Additionally, we have detected an issue with GCC GC in winnt-dll.cc. The fix 
will be included in v2.

>> -ix86_handle_selectany_attribute (tree *node, tree name, tree, int,
>> +mingw_handle_selectany_attribute (tree *node, tree name, tree, int,
>>   bool *no_add_attrs)

> please reindent the parameters for the new name length.

Richard, could you please clarify how it should be done?
Thanks!

Regards,
Evgeny


---
 gcc/config/aarch64/cygming.h   |  6 +
 gcc/config/i386/cygming.h  |  6 +
 gcc/config/i386/i386-expand.cc |  6 +++--
 gcc/config/i386/i386-expand.h  |  2 --
 gcc/config/i386/i386.cc| 42 ++
 gcc/config/i386/i386.h |  2 ++
 gcc/config/mingw/winnt-dll.cc  |  8 ++-
 gcc/config/mingw/winnt-dll.h   |  2 +-
 8 files changed, 33 insertions(+), 41 deletions(-)

diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h
index 4beebf9e093..0ff475754e0 100644
--- a/gcc/config/aarch64/cygming.h
+++ b/gcc/config/aarch64/cygming.h
@@ -183,4 +183,10 @@ still needed for compilation.  */
 #undef MAX_OFILE_ALIGNMENT
 #define MAX_OFILE_ALIGNMENT (8192 * 8)
 
+#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC 0
+
+#define HAVE_64BIT_POINTERS 1
+
+#define GOT_ALIAS_SET mingw_GOT_alias_set ()
+
 #endif
diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index ee01e6bb6ce..cd240533dbc 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -469,3 +469,9 @@ do {\
 #ifndef HAVE_GAS_ALIGNED_COMM
 # define HAVE_GAS_ALIGNED_COMM 0
 #endif
+
+#define CMODEL_IS_NOT_LARGE_OR_MEDIUM_PIC ix86_cmodel != CM_LARGE_PIC && 
ix86_cmodel != CM_MEDIUM_PIC
+
+#define HAVE_64BIT_POINTERS TARGET_64BIT_DEFAULT
+
+#define GOT_ALIAS_SET mingw_GOT_alias_set ()
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index fb460e30d0a..267d0ba257b 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -408,11 +408,12 @@ ix86_expand_move (machine_mode mode, rtx operands[])
 : UNSPEC_GOT));
  op1 = gen_rtx_CONST (Pmode, op1);
  op1 = gen_const_mem (Pmode, op1);
- set_mem_alias_set (op1, ix86_GOT_alias_set ());
+ set_mem_alias_set (op1, GOT_ALIAS_SET);
}
   else
{
- tmp = ix86_legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
+#if TARGET_PECOFF
+ tmp = legitimize_pe_coff_symbol (op1, addend != NULL_RTX);
  if (tmp)
{
  op1 = tmp;
@@ -424,6 +425,7 @@ ix86_expand_move (machine_mode mode, rtx operands[])
  op1 = operands[1];
  break;
}
+#endif
}
 
   if (addend)
diff --git a/gcc/config/i386/i386-expand.h b/gcc/config/i386/i386-expand.h
index a8c20993954..5e02df1706d 100644
--- a/gcc/config/i386/i386-expand.h
+++ b/gcc/config/i386/i386-expand.h
@@ -34,9 +34,7 @@ struct expand_vec_perm_d
 };
 
 rtx legitimize_tls_address (rtx x, enum tls_model model, bool for_mov);
-alias_set_type ix86_GOT_alias_set (void);
 rtx legitimize_pic_address (rtx orig, rtx reg);
-rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg);
 
 bool insn_defines_reg (unsigned int regno1, unsigned int regno2,
   rtx_insn *insn);
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 66845b30446..ee3a59ed498 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -11807,30 +11807,6 @@ constant_address_p (rtx x)
 }
 

 
-#if TARGET_PECOFF
-rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
-{
-  return legitimize_pe_coff_symbol (addr, inreg);
-}
-
-alias_set_type
-ix86_GOT_alias_set (void)
-{
-  return mingw_GOT_alias_set ();
-}
-#else
-rtx ix86_legitimize_pe_coff_symbol (rtx addr, bool inreg)
-{
-  return NULL_RTX;
-}
-
-alias_set_type
-ix86_GOT_alias_set (void)
-{
-  return -1;
-}
-#endif
-
 /* Return a legitimate reference for ORIG (an address) using the
register REG.  If REG is 0, a new pseudo is generated.
 
@@ -11867,9 +11843,11 @@ legitimize_pic_address (rtx orig, rtx reg)
 
   if (TARGET_64BIT && TARGET_DLLIMPORT_DECL_ATTRIBUTES)
 {
-  rtx tmp = ix86_legitimize_pe_coff_symbol (addr, true);
+#if TARGET_PECOFF
+  rtx tmp = legitimize_pe_coff_symbol (addr, true);
   if (tmp)
 return tmp;
+#endif
 }
 
   if (TARGET_64BIT && legitimate_pic_address_disp_p (addr))
@@ -11912,9 +11890,11 @@ legitimize_pic_address (rtx orig, rtx reg)
  on VxWorks, see gotoff_operand.  */
   || (TARGET_VXWORKS_RTP && GET_CODE (addr) == LABEL_REF))
 {
-  rtx tmp = ix86_legitimize_pe_coff_symbol (addr, true);
+#if TARGET_PECOFF
+  rtx tmp = legitimize_pe_coff_symbol (addr, true);
   if (tmp)
 return tmp;
+#endif
 
   /* For x64 PE-COFF there is no GOT table,
 so we use address directly.  */
@@ -11929

[PATCH v1 0/6] Add DLL import/export implementation to AArch64

2024-04-18 Thread Evgeny Karpov
Hello,

This is the second patch series, following the first patch series which
introduced the aarch64-w64-mingw32 target.
https://gcc.gnu.org/pipermail/gcc-patches/2024-February/thread.html#646203
https://gcc.gnu.org/pipermail/gcc-patches/2024-March/thread.html#647128
https://gcc.gnu.org/pipermail/gcc-patches/2024-April/thread.html#649261

The patch series aims at the goal:
Extend the aarch64-w64-mingw32 C implementation to
cross-compile OpenSSL, OpenBLAS, FFmpeg, and libjpeg-turbo. All
packages successfully pass tests.

The changes in this patch series are focused on reusing functionality
for DLL import/export from ix86 in aarch64. The ix86 implementation
for expanding a SYMBOL into its corresponding dllimport symbol has
been moved to the mingw folder. Functions related to
dllimport/dllexport functionality have been renamed for reuse in the
AArch64 target.

This patch series is implemented on top of the first patch series which
has not been merged yet. It is currently awaiting the opening of GCC Stage1.
https://gcc.gnu.org/pipermail/gcc-patches/2024-April/thread.html#649261

Patchwork cannot verify this patch series. However, a link to Linaro CI will
be provided once the testing is complete.
A minimal regression test for building main targets can be found here:
https://github.com/Windows-on-ARM-Experiments/mingw-woarm64-build/actions/runs/8739609732

Regression test for all languages on x86_86-w64-mingw32 is in progress and 
will be also provided.

Known issues:
In order to compile FFmpeg, the optimization level should be reduced
from -O3 to -O2. The fix for this issue is planned to be delivered
in the third patch series.

Thank you for your review!

Coauthors: Zac Walker ,
Mark Harmstone   and
Ron Riddle 

Refactored, prepared, and validated by
Radek Barton  and
Evgeny Karpov 

Regards,
Evgeny


Evgeny Karpov (6):
  Move mingw_* declarations to the mingw folder
  Extract ix86 dllimport implementation to mingw
  Rename functions for reuse in AArch64
  aarch64: Add selectany attribute handling
  Adjust DLL import/export implementation for AArch64
  aarch64: Add DLL import/export to AArch64 target

 gcc/config.gcc  |   8 +-
 gcc/config/aarch64/aarch64-protos.h |   7 +-
 gcc/config/aarch64/aarch64.cc   |  42 -
 gcc/config/aarch64/cygming.h|  26 +++-
 gcc/config/i386/cygming.h   |   8 +-
 gcc/config/i386/i386-expand.cc  |   2 +-
 gcc/config/i386/i386-expand.h   |   2 +-
 gcc/config/i386/i386-protos.h   |  13 +-
 gcc/config/i386/i386.cc | 211 +++--
 gcc/config/mingw/mingw32.h  |   2 +-
 gcc/config/mingw/t-cygming  |   6 +
 gcc/config/mingw/winnt-dll.cc   | 233 
 gcc/config/mingw/winnt-dll.h|  26 
 gcc/config/mingw/winnt.cc   |   8 +-
 gcc/config/mingw/winnt.h|  34 
 15 files changed, 402 insertions(+), 226 deletions(-)
 create mode 100644 gcc/config/mingw/winnt-dll.cc
 create mode 100644 gcc/config/mingw/winnt-dll.h
 create mode 100644 gcc/config/mingw/winnt.h

-- 
2.25.1