update copyrights in config dir.
[official-gcc.git] / gcc / config / arm / pe.h
blob978c296c40e274b9bcf4cc82499e256b05c7ba6e
1 /* Definitions of target machine for GNU compiler, for ARM with PE obj format.
2 Copyright (C) 1995, 1996, 1999 Free Software Foundation, Inc.
3 Contributed by Doug Evans (dje@cygnus.com).
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 #include "arm/coff.h"
24 #undef USER_LABEL_PREFIX
25 #define USER_LABEL_PREFIX "_"
28 /* Run-time Target Specification. */
29 #undef TARGET_VERSION
30 #define TARGET_VERSION fputs (" (ARM/pe)", stderr)
32 /* Support the __declspec keyword by turning them into attributes.
33 We currently only support: naked, dllimport, and dllexport.
34 Note that the current way we do this may result in a collision with
35 predefined attributes later on. This can be solved by using one attribute,
36 say __declspec__, and passing args to it. The problem with that approach
37 is that args are not accumulated: each new appearance would clobber any
38 existing args. */
39 #undef CPP_PREDEFINES
40 #define CPP_PREDEFINES "\
41 -Darm -D__pe__ -Acpu(arm) -Amachine(arm) \
42 -D__declspec(x)=__attribute__((x)) \
45 /* Experimental addition for pr 7885.
46 Ignore dllimport for functions. */
47 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & 0x20000)
49 #undef SUBTARGET_SWITCHES
50 #define SUBTARGET_SWITCHES \
51 { "nop-fun-dllimport", 0x20000, "Ignore dllimport attribute for functions" }, \
52 { "no-nop-fun-dllimport", -0x20000, "" },
54 #undef TARGET_DEFAULT
55 #define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT + 0x20000)
57 #undef WCHAR_TYPE
58 #define WCHAR_TYPE "short unsigned int"
59 #undef WCHAR_TYPE_SIZE
60 #define WCHAR_TYPE_SIZE 16
62 /* Same as arm.h except r10 is call-saved, not fixed. */
63 #undef FIXED_REGISTERS
64 #define FIXED_REGISTERS \
65 { \
66 0,0,0,0,0,0,0,0, \
67 0,0,0,1,0,1,0,1, \
68 0,0,0,0,0,0,0,0, \
69 1,1,1 \
72 /* Same as arm.h except r10 is call-saved, not fixed. */
73 #undef CALL_USED_REGISTERS
74 #define CALL_USED_REGISTERS \
75 { \
76 1,1,1,1,0,0,0,0, \
77 0,0,0,1,1,1,1,1, \
78 1,1,1,1,0,0,0,0, \
79 1,1,1 \
82 /* This is to better conform to the ARM PCS.
83 Richard Earnshaw hasn't put this into FSF sources yet so it's here. */
84 #undef RETURN_IN_MEMORY
85 #define RETURN_IN_MEMORY(TYPE) \
86 ((TYPE_MODE ((TYPE)) == BLKmode && ! TYPE_NO_FORCE_BLK (TYPE)) \
87 || (AGGREGATE_TYPE_P ((TYPE)) && arm_pe_return_in_memory ((TYPE))))
89 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
90 is a valid machine specific attribute for DECL.
91 The attributes in ATTRIBUTES have previously been assigned to DECL. */
92 #undef VALID_MACHINE_DECL_ATTRIBUTE
93 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
94 arm_pe_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
96 #if 0 /* Needed when we tried type attributes. */
97 /* A C expression whose value is zero if the attributes on
98 TYPE1 and TYPE2 are incompatible, one if they are compatible,
99 and two if they are nearly compatible (which causes a warning to be
100 generated). */
101 #define COMP_TYPE_ATTRIBUTES(TYPE1, TYPE2) \
102 arm_pe_comp_type_attributes ((TYPE1), (TYPE2))
103 #endif
105 #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \
106 arm_pe_merge_machine_decl_attributes ((OLD), (NEW))
108 /* In addition to the stuff done in arm.h, we must mark dll symbols specially.
109 Definitions of dllexport'd objects install some info in the .drectve
110 section. References to dllimport'd objects are fetched indirectly via
111 __imp_. If both are declared, dllexport overrides.
112 This is also needed to implement one-only vtables: they go into their own
113 section and we need to set DECL_SECTION_NAME so we do that here.
114 Note that we can be called twice on the same decl. */
115 #undef ENCODE_SECTION_INFO
116 #define ENCODE_SECTION_INFO(DECL) \
117 arm_pe_encode_section_info (DECL)
119 /* Used to implement dllexport overriding dllimport semantics. It's also used
120 to handle vtables - the first pass won't do anything because
121 DECL_CONTEXT (DECL) will be 0 so arm_dll{ex,im}port_p will return 0.
122 It's also used to handle dllimport override semantics. */
123 #if 0
124 #define REDO_SECTION_INFO_P(DECL) \
125 ((DECL_MACHINE_ATTRIBUTES (DECL) != NULL_TREE) \
126 || (TREE_CODE (DECL) == VAR_DECL && DECL_VIRTUAL_P (DECL)))
127 #else
128 #define REDO_SECTION_INFO_P(DECL) 1
129 #endif
131 /* Utility used only in this file. */
132 #define ARM_STRIP_NAME_ENCODING(SYM_NAME) \
133 ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0))
135 /* Strip any text from SYM_NAME added by ENCODE_SECTION_INFO and store
136 the result in VAR. */
137 #undef STRIP_NAME_ENCODING
138 #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \
139 (VAR) = ARM_STRIP_NAME_ENCODING (SYM_NAME)
141 /* Define this macro if in some cases global symbols from one translation
142 unit may not be bound to undefined symbols in another translation unit
143 without user intervention. For instance, under Microsoft Windows
144 symbols must be explicitly imported from shared libraries (DLLs). */
145 #define MULTIPLE_SYMBOL_SPACES
147 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
149 #define UNIQUE_SECTION(DECL,RELOC) arm_pe_unique_section (DECL, RELOC)
151 #define SUPPORTS_ONE_ONLY 1
153 /* A C statement to output something to the assembler file to switch to section
154 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
155 NULL_TREE. Some target formats do not support arbitrary sections. Do not
156 define this macro in such cases. */
157 #undef ASM_OUTPUT_SECTION_NAME
158 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
159 do { \
160 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
161 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
162 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
163 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
164 else \
165 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
166 /* Functions may have been compiled at various levels of \
167 optimization so we can't use `same_size' here. Instead, \
168 have the linker pick one. */ \
169 if ((DECL) && DECL_ONE_ONLY (DECL)) \
170 fprintf (STREAM, "\t.linkonce %s\n", \
171 TREE_CODE (DECL) == FUNCTION_DECL \
172 ? "discard" : "same_size"); \
173 } while (0)
175 /* This outputs a lot of .req's to define alias for various registers.
176 Let's try to avoid this. */
177 #undef ASM_FILE_START
178 #define ASM_FILE_START(STREAM) \
179 do { \
180 extern char * version_string; \
181 fprintf (STREAM, "%s Generated by gcc %s for ARM/pe\n", \
182 ASM_COMMENT_START, version_string); \
183 output_file_directive ((STREAM), main_input_filename); \
184 } while (0)
186 /* Output a reference to a label. */
187 #undef ASM_OUTPUT_LABELREF
188 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
189 fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, ARM_STRIP_NAME_ENCODING (NAME))
191 /* Output a function definition label. */
192 #undef ASM_DECLARE_FUNCTION_NAME
193 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
194 do { \
195 if (arm_dllexport_name_p (NAME)) \
197 drectve_section (); \
198 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \
199 ARM_STRIP_NAME_ENCODING (NAME)); \
200 function_section (DECL); \
202 if (TARGET_POKE_FUNCTION_NAME) \
203 arm_poke_function_name ((STREAM), (NAME)); \
204 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
205 } while (0)
207 /* Output a common block. */
208 #undef ASM_OUTPUT_COMMON
209 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
210 do { \
211 if (arm_dllexport_name_p (NAME)) \
213 drectve_section (); \
214 fprintf ((STREAM), "\t.ascii \" -export:%s\"\n", \
215 ARM_STRIP_NAME_ENCODING (NAME)); \
217 if (! arm_dllimport_name_p (NAME)) \
219 fprintf ((STREAM), "\t.comm\t"); \
220 assemble_name ((STREAM), (NAME)); \
221 fprintf ((STREAM), ", %d\t%s %d\n", \
222 (ROUNDED), ASM_COMMENT_START, (SIZE)); \
224 } while (0)
226 /* Output the label for an initialized variable. */
227 #undef ASM_DECLARE_OBJECT_NAME
228 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
229 do { \
230 if (arm_dllexport_name_p (NAME)) \
232 enum in_section save_section = in_section; \
233 drectve_section (); \
234 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \
235 ARM_STRIP_NAME_ENCODING (NAME)); \
236 switch_to_section (save_section, (DECL)); \
238 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
239 } while (0)
241 /* Support the ctors/dtors and other sections. */
243 #define DRECTVE_SECTION_ASM_OP "\t.section .drectve"
245 /* A list of other sections which the compiler might be "in" at any
246 given time. */
248 #undef SUBTARGET_EXTRA_SECTIONS
249 #define SUBTARGET_EXTRA_SECTIONS in_drectve,
251 /* A list of extra section function definitions. */
253 #undef SUBTARGET_EXTRA_SECTION_FUNCTIONS
254 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS \
255 DRECTVE_SECTION_FUNCTION \
256 SWITCH_TO_SECTION_FUNCTION
258 #define DRECTVE_SECTION_FUNCTION \
259 void \
260 drectve_section () \
262 if (in_section != in_drectve) \
264 fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP); \
265 in_section = in_drectve; \
269 /* Switch to SECTION (an `enum in_section').
271 ??? This facility should be provided by GCC proper.
272 The problem is that we want to temporarily switch sections in
273 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
274 afterwards. */
275 #define SWITCH_TO_SECTION_FUNCTION \
276 void \
277 switch_to_section (section, decl) \
278 enum in_section section; \
279 tree decl; \
281 switch (section) \
283 case in_text: text_section (); break; \
284 case in_data: data_section (); break; \
285 case in_named: named_section (decl, NULL, 0); break; \
286 case in_rdata: rdata_section (); break; \
287 case in_ctors: ctors_section (); break; \
288 case in_dtors: dtors_section (); break; \
289 case in_drectve: drectve_section (); break; \
290 default: abort (); break; \