1 /* Windows support needed only by D front-end.
2    Copyright (C) 2021 Free Software Foundation, Inc.
3 
4 GCC is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
8 
9 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3.  If not see
16 <http://www.gnu.org/licenses/>.  */
17 
18 #define IN_TARGET_CODE 1
19 
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "target.h"
24 #include "d/d-target.h"
25 #include "d/d-target-def.h"
26 #include "tm_p.h"
27 
28 /* Implement TARGET_D_OS_VERSIONS for Windows targets.  */
29 
30 static void
winnt_d_os_builtins(void)31 winnt_d_os_builtins (void)
32 {
33   d_add_builtin_version ("Windows");
34 
35 #define builtin_version(TXT) d_add_builtin_version (TXT)
36 
37 #ifdef EXTRA_TARGET_D_OS_VERSIONS
38   EXTRA_TARGET_D_OS_VERSIONS ();
39 #endif
40 }
41 
42 /* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
43 
44 static tree
winnt_d_handle_target_object_format(void)45 winnt_d_handle_target_object_format (void)
46 {
47   const char *objfmt = "coff";
48 
49   return build_string_literal (strlen (objfmt) + 1, objfmt);
50 }
51 
52 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Windows targets.  */
53 
54 static void
winnt_d_register_target_info(void)55 winnt_d_register_target_info (void)
56 {
57   const struct d_target_info_spec handlers[] = {
58     { "objectFormat", winnt_d_handle_target_object_format },
59     { NULL, NULL },
60   };
61 
62   d_add_target_info_handlers (handlers);
63 }
64 #undef TARGET_D_OS_VERSIONS
65 #define TARGET_D_OS_VERSIONS winnt_d_os_builtins
66 
67 #undef TARGET_D_REGISTER_OS_TARGET_INFO
68 #define TARGET_D_REGISTER_OS_TARGET_INFO winnt_d_register_target_info
69 
70 /* Define TARGET_D_MINFO_SECTION for Windows targets.  */
71 
72 #undef TARGET_D_MINFO_SECTION
73 #define TARGET_D_MINFO_SECTION "minfo"
74 
75 #undef TARGET_D_MINFO_START_NAME
76 #define TARGET_D_MINFO_START_NAME "__start_minfo"
77 
78 #undef TARGET_D_MINFO_END_NAME
79 #define TARGET_D_MINFO_END_NAME "__stop_minfo"
80 
81 /* Define TARGET_D_TEMPLATES_ALWAYS_COMDAT for Windows targets.  */
82 
83 #undef TARGET_D_TEMPLATES_ALWAYS_COMDAT
84 #define TARGET_D_TEMPLATES_ALWAYS_COMDAT true
85 
86 struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
87