Evgeny Karpov <evgeny.kar...@microsoft.com> writes: > This patch extracts the ix86 implementation for expanding a SYMBOL > into its corresponding dllimport, far-address, or refptr symbol. > It will be reused in the aarch64-w64-mingw32 target. > The implementation is copied as is from i386/i386.cc with > minor changes to follow to the code style. > > Also this patch replaces the original DLL import/export > implementation in ix86 with mingw. > > gcc/ChangeLog: > > * config.gcc: Add winnt-dll.o, which contains the DLL > import/export implementation. > * config/i386/cygming.h (SUB_TARGET_RECORD_STUB): Remove the > old implementation. Rename the required function to MinGW. > Rename it to a conditional function that will reuse the > MinGW implementation for COFF and nothing otherwise. > * config/i386/i386-expand.cc (ix86_expand_move): Likewise. > * config/i386/i386-expand.h (is_imported_p): Likewise. > (mingw_GOT_alias_set): Likewise. > (ix86_legitimize_pe_coff_symbol): Likewise. > * config/i386/i386-protos.h: Likewise. > * config/i386/i386.cc (is_imported_p): Likewise. > (ix86_legitimize_pe_coff_symbol): Likewise. > (ix86_GOT_alias_set): Likewise. > (legitimize_pic_address): Likewise. > (struct dllimport_hasher): > (GTY): Likewise. > (get_dllimport_decl): Likewise. > (legitimize_pe_coff_extern_decl): Likewise. > (legitimize_dllimport_symbol): Likewise. > (legitimize_pe_coff_symbol): Likewise. > (ix86_legitimize_address): Likewise. > * config/mingw/winnt.h (mingw_pe_record_stub): Likewise. > * config/mingw/winnt.cc (i386_pe_record_stub): Likewise. > (mingw_pe_record_stub): Likewise. > * config/mingw/t-cygming: Add the winnt-dll.o compilation. > * config/mingw/winnt-dll.cc: New file.
This looks good to me apart from a couple of very minor comments below, but please get approval from the x86 maintainers as well. In particular, they might prefer to handle ix86_legitimize_pe_coff_symbol in some other way. > [...] > diff --git a/gcc/config/mingw/winnt-dll.cc b/gcc/config/mingw/winnt-dll.cc > new file mode 100644 > index 00000000000..349ade6f5c0 > --- /dev/null > +++ b/gcc/config/mingw/winnt-dll.cc > @@ -0,0 +1,229 @@ > +/* Expand a SYMBOL into its corresponding dllimport, far-address, > +or refptr symbol. > +Copyright (C) 2024 Free Software Foundation, Inc. I suppose this should retain the range from the i386 file that the code is moving from: Copyright (C) 1988-2024 Free Software Foundation, Inc. > [...] > diff --git a/gcc/config/mingw/winnt-dll.h b/gcc/config/mingw/winnt-dll.h > new file mode 100644 > index 00000000000..19c16e747a2 > --- /dev/null > +++ b/gcc/config/mingw/winnt-dll.h > @@ -0,0 +1,26 @@ > +/* Expand a SYMBOL into its corresponding dllimport, far-address, > +or refptr symbol. > +Copyright (C) 2024 Free Software Foundation, Inc. > + > +GCC is free software; you can redistribute it and/or modify it under > +the terms of the GNU General Public License as published by the Free > +Software Foundation; either version 3, or (at your option) any later > +version. > + > +GCC is distributed in the hope that it will be useful, but WITHOUT ANY > +WARRANTY; without even the implied warranty of MERCHANTABILITY or > +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License > +for more details. > + > +You should have received a copy of the GNU General Public License > +along with GCC; see the file COPYING3. If not see > +http://www.gnu.org/licenses/. */ > + > +#ifndef GCC_MINGW_WINNT_DLL_H > +#define GCC_MINGW_WINNT_DLL_H > + > +extern bool is_imported_p (rtx x); > +extern alias_set_type mingw_GOT_alias_set (void); > +extern rtx legitimize_pe_coff_symbol (rtx addr, bool inreg); > + > +#endif > \ No newline at end of file Would be good to add the newlihe. Thanks, Richard