Fix typos in comments.
[official-gcc.git] / gcc / config / arm / pe.h
blobd950abd32d1603cdba5677ef7987f9c6d3001ce3
1 /* Definitions of target machine for GNU compiler, for ARM with PE obj format.
2 Copyright (C) 1995, 1996, 1999, 2000 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 /* Enable PE specific code. */
23 #define ARM_PE 1
25 #define ARM_PE_FLAG_CHAR '@'
27 /* Ensure that @x. will be stripped from the function name. */
28 #define SUBTARGET_NAME_ENCODING_LENGTHS \
29 case ARM_PE_FLAG_CHAR: return 3;
31 #include "arm/coff.h"
33 #undef USER_LABEL_PREFIX
34 #define USER_LABEL_PREFIX "_"
37 /* Run-time Target Specification. */
38 #undef TARGET_VERSION
39 #define TARGET_VERSION fputs (" (ARM/pe)", stderr)
41 /* Support the __declspec keyword by turning them into attributes.
42 We currently only support: naked, dllimport, and dllexport.
43 Note that the current way we do this may result in a collision with
44 predefined attributes later on. This can be solved by using one attribute,
45 say __declspec__, and passing args to it. The problem with that approach
46 is that args are not accumulated: each new appearance would clobber any
47 existing args. */
48 #undef SUBTARGET_CPP_SPEC
49 #define SUBTARGET_CPP_SPEC "-D__pe__ -D__declspec(x)=__attribute__((x))"
52 /* Experimental addition for pr 7885.
53 Ignore dllimport for functions. */
54 #define TARGET_FLAG_NOP_FUN (1 << 24)
56 #undef TARGET_NOP_FUN_DLLIMPORT
57 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & TARGET_FLAG_NOP_FUN)
59 #undef SUBTARGET_SWITCHES
60 #define SUBTARGET_SWITCHES \
61 { "nop-fun-dllimport", TARGET_FLAG_NOP_FUN, "Ignore dllimport attribute for functions" }, \
62 { "no-nop-fun-dllimport", - TARGET_FLAG_NOP_FUN, "" },
64 #undef TARGET_DEFAULT
65 #define TARGET_DEFAULT (ARM_FLAG_SOFT_FLOAT | TARGET_FLAG_NOP_FUN)
68 #undef WCHAR_TYPE
69 #define WCHAR_TYPE "short unsigned int"
70 #undef WCHAR_TYPE_SIZE
71 #define WCHAR_TYPE_SIZE 16
73 /* Same as arm.h except r10 is call-saved, not fixed. */
74 #undef FIXED_REGISTERS
75 #define FIXED_REGISTERS \
76 { \
77 0,0,0,0,0,0,0,0, \
78 0,0,0,1,0,1,0,1, \
79 0,0,0,0,0,0,0,0, \
80 1,1,1 \
83 /* Same as arm.h except r10 is call-saved, not fixed. */
84 #undef CALL_USED_REGISTERS
85 #define CALL_USED_REGISTERS \
86 { \
87 1,1,1,1,0,0,0,0, \
88 0,0,0,1,1,1,1,1, \
89 1,1,1,1,0,0,0,0, \
90 1,1,1 \
93 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
94 is a valid machine specific attribute for DECL.
95 The attributes in ATTRIBUTES have previously been assigned to DECL. */
96 #undef VALID_MACHINE_DECL_ATTRIBUTE
97 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
98 arm_pe_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
100 #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \
101 arm_pe_merge_machine_decl_attributes ((OLD), (NEW))
103 /* In addition to the stuff done in arm.h, we must mark dll symbols specially.
104 Definitions of dllexport'd objects install some info in the .drectve
105 section. References to dllimport'd objects are fetched indirectly via
106 __imp_. If both are declared, dllexport overrides.
107 This is also needed to implement one-only vtables: they go into their own
108 section and we need to set DECL_SECTION_NAME so we do that here.
109 Note that we can be called twice on the same decl. */
110 #undef ENCODE_SECTION_INFO
111 #define ENCODE_SECTION_INFO(DECL) \
112 arm_pe_encode_section_info (DECL)
114 /* Used to implement dllexport overriding dllimport semantics. It's also used
115 to handle vtables - the first pass won't do anything because
116 DECL_CONTEXT (DECL) will be 0 so arm_dll{ex,im}port_p will return 0.
117 It's also used to handle dllimport override semantics. */
118 #define REDO_SECTION_INFO_P(DECL) 1
120 /* Define this macro if in some cases global symbols from one translation
121 unit may not be bound to undefined symbols in another translation unit
122 without user intervention. For instance, under Microsoft Windows
123 symbols must be explicitly imported from shared libraries (DLLs). */
124 #define MULTIPLE_SYMBOL_SPACES
126 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
128 #define UNIQUE_SECTION(DECL, RELOC) arm_pe_unique_section (DECL, RELOC)
130 #define SUPPORTS_ONE_ONLY 1
132 /* A C statement to output something to the assembler file to switch to section
133 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
134 NULL_TREE. Some target formats do not support arbitrary sections. Do not
135 define this macro in such cases. */
136 #undef ASM_OUTPUT_SECTION_NAME
137 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
138 do \
140 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
141 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
142 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
143 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
144 else \
145 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
146 /* Functions may have been compiled at various levels of \
147 optimization so we can't use `same_size' here. \
148 Instead, have the linker pick one. */ \
149 if ((DECL) && DECL_ONE_ONLY (DECL)) \
150 fprintf (STREAM, "\t.linkonce %s\n", \
151 TREE_CODE (DECL) == FUNCTION_DECL \
152 ? "discard" : "same_size"); \
154 while (0)
156 /* This outputs a lot of .req's to define alias for various registers.
157 Let's try to avoid this. */
158 #undef ASM_FILE_START
159 #define ASM_FILE_START(STREAM) \
160 do \
162 asm_fprintf (STREAM, "%@ Generated by gcc %s for ARM/pe\n",\
163 version_string); \
164 output_file_directive ((STREAM), main_input_filename); \
166 while (0)
168 /* Output a reference to a label. */
169 #undef ASM_OUTPUT_LABELREF
170 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
171 asm_fprintf (STREAM, "%U%s", arm_strip_name_encoding (NAME))
173 /* Output a function definition label. */
174 #undef ASM_DECLARE_FUNCTION_NAME
175 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
176 do \
178 if (arm_dllexport_name_p (NAME)) \
180 drectve_section (); \
181 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \
182 arm_strip_name_encoding (NAME)); \
183 function_section (DECL); \
185 ARM_DECLARE_FUNCTION_NAME (STREAM, NAME, DECL); \
186 if (TARGET_THUMB) \
187 fprintf (STREAM, "\t.code 16\n"); \
188 ASM_OUTPUT_LABEL (STREAM, NAME); \
190 while (0)
192 /* Output a common block. */
193 #undef ASM_OUTPUT_COMMON
194 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
195 do \
197 if (arm_dllexport_name_p (NAME)) \
199 drectve_section (); \
200 fprintf ((STREAM), "\t.ascii \" -export:%s\"\n",\
201 arm_strip_name_encoding (NAME)); \
203 if (! arm_dllimport_name_p (NAME)) \
205 fprintf ((STREAM), "\t.comm\t"); \
206 assemble_name ((STREAM), (NAME)); \
207 asm_fprintf ((STREAM), ", %d\t%@ %d\n", \
208 (ROUNDED), (SIZE)); \
211 while (0)
213 /* Output the label for an initialized variable. */
214 #undef ASM_DECLARE_OBJECT_NAME
215 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
216 do \
218 if (arm_dllexport_name_p (NAME)) \
220 enum in_section save_section = in_section; \
221 drectve_section (); \
222 fprintf (STREAM, "\t.ascii \" -export:%s\"\n",\
223 arm_strip_name_encoding (NAME)); \
224 switch_to_section (save_section, (DECL)); \
226 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
228 while (0)
230 /* Support the ctors/dtors and other sections. */
232 #define DRECTVE_SECTION_ASM_OP "\t.section .drectve"
234 /* A list of other sections which the compiler might be "in" at any
235 given time. */
237 #undef SUBTARGET_EXTRA_SECTIONS
238 #define SUBTARGET_EXTRA_SECTIONS in_drectve,
240 /* A list of extra section function definitions. */
242 #undef SUBTARGET_EXTRA_SECTION_FUNCTIONS
243 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS \
244 DRECTVE_SECTION_FUNCTION \
245 SWITCH_TO_SECTION_FUNCTION
247 #define DRECTVE_SECTION_FUNCTION \
248 void \
249 drectve_section () \
251 if (in_section != in_drectve) \
253 fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP); \
254 in_section = in_drectve; \
258 /* Switch to SECTION (an `enum in_section').
260 ??? This facility should be provided by GCC proper.
261 The problem is that we want to temporarily switch sections in
262 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
263 afterwards. */
264 #define SWITCH_TO_SECTION_FUNCTION \
265 void \
266 switch_to_section (section, decl) \
267 enum in_section section; \
268 tree decl; \
270 switch (section) \
272 case in_text: text_section (); break; \
273 case in_data: data_section (); break; \
274 case in_named: named_section (decl, NULL, 0); break; \
275 case in_rdata: rdata_section (); break; \
276 case in_ctors: ctors_section (); break; \
277 case in_dtors: dtors_section (); break; \
278 case in_drectve: drectve_section (); break; \
279 default: abort (); break; \