public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Evgeny Karpov <Evgeny.Karpov@microsoft.com>
To: Evgeny Karpov <Evgeny.Karpov@microsoft.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: "richard.sandiford@arm.com" <richard.sandiford@arm.com>,
	"Richard Earnshaw (lists)" <Richard.Earnshaw@arm.com>,
	Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org>,
	Radek Barton <radek.barton@microsoft.com>
Subject: [PATCH v3 07/12] aarch64: Add Cygwin and MinGW environments for AArch64
Date: Thu, 11 Apr 2024 13:56:49 +0000	[thread overview]
Message-ID: <VI1PR83MB043133CFECE384E04B1F0F08F8052@VI1PR83MB0431.EURPRD83.prod.outlook.com> (raw)
In-Reply-To: <VI1PR83MB0431D9D41D59FC495D4E7CA0F8052@VI1PR83MB0431.EURPRD83.prod.outlook.com>

From: Zac Walker <zacwalker@microsoft.com>
Date: Thu, 11 Apr 2024 13:41:51 +0200
Subject: [PATCH v3 07/12] aarch64: Add Cygwin and MinGW environments for
 AArch64

Define Cygwin and MinGW environment such as types, SEH definitions,
shared libraries, etc.

gcc/ChangeLog:

	* config.gcc: Add Cygwin and MinGW difinitions.
	* config/aarch64/aarch64-protos.h
	(mingw_pe_maybe_record_exported_symbol): Declare functions
	which are used in Cygwin and MinGW environment.
	(mingw_pe_section_type_flags): Likewise.
	(mingw_pe_unique_section): Likewise.
	(mingw_pe_encode_section_info): Likewise.
	* config/aarch64/cygming.h: New file.
---
 gcc/config.gcc                      |   4 +
 gcc/config/aarch64/aarch64-protos.h |   5 +
 gcc/config/aarch64/cygming.h        | 172 ++++++++++++++++++++++++++++
 3 files changed, 181 insertions(+)
 create mode 100644 gcc/config/aarch64/cygming.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 3bc4982850b..d2f92e0fc50 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1274,7 +1274,11 @@ aarch64*-*-gnu*)
 aarch64-*-mingw*)
 	tm_file="${tm_file} aarch64/aarch64-abi-ms.h"
 	tm_file="${tm_file} aarch64/aarch64-coff.h"
+	tm_file="${tm_file} aarch64/cygming.h"
+	tm_file="${tm_file} mingw/mingw32.h"
+	tm_file="${tm_file} mingw/mingw-stdint.h"
 	tmake_file="${tmake_file} aarch64/t-aarch64"
+	target_gtfiles="$target_gtfiles \$(srcdir)/config/mingw/winnt.cc"
 	case ${enable_threads} in
 	  "" | yes | win32)
 	    thread_file='win32'
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 42639e9efcf..1d3f94c813e 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -1110,6 +1110,11 @@ extern void aarch64_output_patchable_area (unsigned int, bool);
 
 extern void aarch64_adjust_reg_alloc_order ();
 
+extern void mingw_pe_maybe_record_exported_symbol (tree, const char *, int);
+extern unsigned int mingw_pe_section_type_flags (tree, const char *, int);
+extern void mingw_pe_unique_section (tree, int);
+extern void mingw_pe_encode_section_info (tree, rtx, int);
+
 bool aarch64_optimize_mode_switching (aarch64_mode_entity);
 void aarch64_restore_za (rtx);
 
diff --git a/gcc/config/aarch64/cygming.h b/gcc/config/aarch64/cygming.h
new file mode 100644
index 00000000000..2e7b01feb76
--- /dev/null
+++ b/gcc/config/aarch64/cygming.h
@@ -0,0 +1,172 @@
+/* Operating system specific defines to be used when targeting GCC for
+   hosting on Windows32, using a Unix style C library and tools.
+   Copyright (C) 1995-2024 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+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_AARCH64_CYGMING_H
+#define GCC_AARCH64_CYGMING_H
+
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DINFO_TYPE_NONE
+
+#define FASTCALL_PREFIX '@'
+
+#define print_reg(rtx, code, file) (gcc_unreachable ())
+
+#define SYMBOL_FLAG_DLLIMPORT 0
+#define SYMBOL_FLAG_DLLEXPORT 0
+
+#define SYMBOL_REF_DLLEXPORT_P(X) \
+	((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_DLLEXPORT) != 0)
+
+/* Disable SEH and declare the required SEH-related macros that are
+still needed for compilation.  */
+#undef TARGET_SEH
+#define TARGET_SEH 0
+
+#define SSE_REGNO_P(N) (gcc_unreachable (), 0)
+#define GENERAL_REGNO_P(N) (gcc_unreachable (), 0)
+#define SEH_MAX_FRAME_SIZE (gcc_unreachable (), 0)
+
+#undef TARGET_PECOFF
+#define TARGET_PECOFF 1
+
+#include <stdbool.h>
+#ifdef __MINGW32__
+#include <stdio.h>
+#endif
+
+extern void mingw_pe_asm_named_section (const char *, unsigned int, tree);
+extern void mingw_pe_declare_function_type (FILE *file, const char *name,
+	int pub);
+
+#define TARGET_ASM_NAMED_SECTION  mingw_pe_asm_named_section
+
+/* Select attributes for named sections.  */
+#define TARGET_SECTION_TYPE_FLAGS  mingw_pe_section_type_flags
+
+#define TARGET_ASM_UNIQUE_SECTION mingw_pe_unique_section
+#define TARGET_ENCODE_SECTION_INFO  mingw_pe_encode_section_info
+
+/* Declare the type properly for any external libcall.  */
+#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
+  mingw_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
+
+#define TARGET_OS_CPP_BUILTINS()					\
+  do									\
+    {									\
+      builtin_define ("__MSVCRT__");					\
+      builtin_define ("__MINGW32__");					\
+      builtin_define ("_WIN32");					\
+      builtin_define_std ("WIN32");					\
+      builtin_define_std ("WINNT");					\
+      builtin_define_with_int_value ("_INTEGRAL_MAX_BITS",		\
+				TYPE_PRECISION (intmax_type_node));	\
+      builtin_define ("__MINGW64__");					\
+      builtin_define_std ("WIN64");					\
+      builtin_define ("_WIN64");					\
+      builtin_define ("__stdcall=__attribute__((__stdcall__))");	\
+      builtin_define ("__fastcall=__attribute__((__fastcall__))");	\
+      builtin_define ("__thiscall=__attribute__((__thiscall__))");	\
+      builtin_define ("__cdecl=__attribute__((__cdecl__))");		\
+    }									\
+  while (0)
+
+/* Windows64 continues to use a 32-bit long type.  */
+#undef LONG_TYPE_SIZE
+#define LONG_TYPE_SIZE 32
+
+#undef DEFAULT_SIGNED_CHAR
+#define DEFAULT_SIGNED_CHAR 1
+
+#undef SIZE_TYPE
+#undef PTRDIFF_TYPE
+#define SIZE_TYPE "long long unsigned int"
+#define PTRDIFF_TYPE "long long int"
+
+#undef WCHAR_TYPE_SIZE
+#undef WCHAR_TYPE
+#define WCHAR_TYPE_SIZE 16
+#define WCHAR_TYPE "short unsigned int"
+
+#define drectve_section() \
+  (fprintf (asm_out_file, "\t.section\t.drectve\n"), \
+   in_section = NULL)
+
+
+/* Enable alias attribute support.  */
+#ifndef SET_ASM_OP
+#define SET_ASM_OP "\t.set\t"
+#endif
+
+/* GNU as supports weak symbols on PECOFF.  */
+#define ASM_WEAKEN_LABEL(FILE, NAME)	\
+  do					\
+    {					\
+      fputs ("\t.weak\t", (FILE));	\
+      assemble_name ((FILE), (NAME));	\
+      fputc ('\n', (FILE));		\
+    }					\
+  while (0)
+
+/* Get tree.cc to declare a target-specific specialization of
+   merge_decl_attributes.  */
+#define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
+
+#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL)		\
+  do {									\
+    switch (GET_MODE (BODY))						\
+      {									\
+      case E_QImode:							\
+	asm_fprintf (STREAM, "\t.byte\t(%LL%d - %LLrtx%d) / 4\n",	\
+		     VALUE, REL);					\
+	break;								\
+      case E_HImode:							\
+	asm_fprintf (STREAM, "\t.2byte\t(%LL%d - %LLrtx%d) / 4\n",	\
+		     VALUE, REL);					\
+	break;								\
+      case E_SImode:							\
+      case E_DImode: /* See comment in aarch64_output_casesi.  */	\
+	asm_fprintf (STREAM, "\t.word\t(%LL%d - %LLrtx%d) / 4\n",	\
+		     VALUE, REL);					\
+	break;								\
+      default:								\
+	gcc_unreachable ();						\
+      }									\
+  } while (0)
+
+#define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rdata,\"dr\""
+
+#undef  SUBTARGET_OVERRIDE_OPTIONS
+#define SUBTARGET_OVERRIDE_OPTIONS			\
+  do {							\
+    flag_stack_check = STATIC_BUILTIN_STACK_CHECK;	\
+  } while (0)
+
+
+#define SUPPORTS_ONE_ONLY 1
+
+/* Define this to be nonzero if static stack checking is supported.  */
+#define STACK_CHECK_STATIC_BUILTIN 1
+
+#define HAVE_GAS_ALIGNED_COMM 1
+
+#undef MAX_OFILE_ALIGNMENT
+#define MAX_OFILE_ALIGNMENT (8192 * 8)
+
+#endif
-- 
2.25.1


  parent reply	other threads:[~2024-04-11 13:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 13:38 [PATCH v3 00/12] Add aarch64-w64-mingw32 target Evgeny Karpov
2024-04-11 13:45 ` [PATCH v3 01/12] Introduce " Evgeny Karpov
2024-04-11 13:48 ` [PATCH v3 02/12] aarch64: Mark x18 register as a fixed register for MS ABI Evgeny Karpov
2024-04-11 13:50 ` [PATCH v3 03/12] aarch64: Add aarch64-w64-mingw32 COFF Evgeny Karpov
2024-04-11 13:51 ` [PATCH v3 04/12] Reuse MinGW from i386 for AArch64 Evgeny Karpov
2024-04-11 13:53 ` [PATCH v3 05/12] Rename section and encoding functions from i386 which will be used in aarch64 Evgeny Karpov
2024-04-11 13:54 ` [PATCH v3 06/12] Exclude i386 functionality from aarch64 build Evgeny Karpov
2024-04-11 13:56 ` Evgeny Karpov [this message]
2024-04-11 13:58 ` [PATCH v3 08/12] aarch64: Add SEH to machine_function Evgeny Karpov
2024-04-11 13:59 ` [PATCH v3 09/12] Rename "x86 Windows Options" to "Cygwin and MinGW Options" Evgeny Karpov
2024-04-11 14:00 ` [PATCH v3 10/12] aarch64: Build and add objects for Cygwin and MinGW for AArch64 Evgeny Karpov
2024-04-11 14:01 ` [PATCH v3 11/12] aarch64: Add aarch64-w64-mingw32 target to libatomic Evgeny Karpov
2024-04-11 14:03 ` [PATCH v3 12/12] Add aarch64-w64-mingw32 target to libgcc Evgeny Karpov
2024-05-07 16:05 ` [PATCH v3 00/12] Add aarch64-w64-mingw32 target Christophe Lyon
2024-05-07 16:31   ` [EXTERNAL] " Zac Walker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1PR83MB043133CFECE384E04B1F0F08F8052@VI1PR83MB0431.EURPRD83.prod.outlook.com \
    --to=evgeny.karpov@microsoft.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=maxim.kuvyrkov@linaro.org \
    --cc=radek.barton@microsoft.com \
    --cc=richard.sandiford@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).