update copyrights in config dir.
[official-gcc.git] / gcc / config / arm / tpe.h
blob526cd36bb64d5b35d8b62c4c3b4537d6e3c45141
1 /* Definitions of target machine for GNU compiler,
2 for Thumb with PE object format.
3 Copyright (C) 1998, 1999 Free Software Foundation, Inc.
4 Derived from arm/coff.h and arm/pe.h originally by Doug Evans (evans@cygnus.com).
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #include "arm/thumb.h"
25 #define THUMB_PE 1
27 /* Run-time Target Specification. */
28 #undef TARGET_VERSION
29 #define TARGET_VERSION fputs (" (Thumb/pe)", stderr)
31 /* Support the __declspec keyword by turning them into attributes.
32 We currently only support: naked, dllimport, and dllexport.
33 Note that the current way we do this may result in a collision with
34 predefined attributes later on. This can be solved by using one attribute,
35 say __declspec__, and passing args to it. The problem with that approach
36 is that args are not accumulated: each new appearance would clobber any
37 existing args. */
38 #undef CPP_PREDEFINES
39 #define CPP_PREDEFINES "\
40 -Dthumb -D__thumb -D__pe__ -Acpu(arm) -Amachine(arm) \
41 -D__declspec(x)=__attribute__((x)) \
44 /* Experimental addition for pr 7885.
45 Ignore dllimport for functions. */
46 #define ARM_FLAG_NOP_FUN_IMPORT 0x20000
47 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & ARM_FLAG_NOP_FUN_IMPORT)
49 #undef SUBTARGET_SWITCHES
50 #define SUBTARGET_SWITCHES \
51 { "nop-fun-dllimport", ARM_FLAG_NOP_FUN_IMPORT, "Ignore dllimport attribute for functions" }, \
52 { "no-nop-fun-dllimport", -ARM_FLAG_NOP_FUN_IMPORT, "" },
54 #undef TARGET_DEFAULT
55 #define TARGET_DEFAULT ARM_FLAG_NOP_FUN_IMPORT
57 #undef WCHAR_TYPE
58 #define WCHAR_TYPE "short unsigned int"
59 #undef WCHAR_TYPE_SIZE
60 #define WCHAR_TYPE_SIZE 16
62 /* Setting this to 32 produces more efficient code, but the value set in previous
63 versions of this toolchain was 8, which produces more compact structures. The
64 command line option -mstructure_size_boundary=<n> can be used to change this
65 value. */
66 #undef STRUCTURE_SIZE_BOUNDARY
67 #define STRUCTURE_SIZE_BOUNDARY arm_structure_size_boundary
69 extern int arm_structure_size_boundary;
71 /* This is COFF, but prefer stabs. */
72 #define SDB_DEBUGGING_INFO
74 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
76 #include "dbxcoff.h"
78 /* Note - it is important that these definitions match those in semi.h for the ARM port. */
79 #undef LOCAL_LABEL_PREFIX
80 #define LOCAL_LABEL_PREFIX "."
82 #undef USER_LABEL_PREFIX
83 #define USER_LABEL_PREFIX "_"
85 /* A C statement to output assembler commands which will identify the
86 object file as having been compiled with GNU CC (or another GNU
87 compiler). */
88 #define ASM_IDENTIFY_GCC(STREAM) \
89 fprintf (STREAM, "%sgcc2_compiled.:\n%s", LOCAL_LABEL_PREFIX, ASM_APP_OFF )
91 #undef ASM_FILE_START
92 #define ASM_FILE_START(STREAM) \
93 do { \
94 extern char * version_string; \
95 fprintf ((STREAM), "%s Generated by gcc %s for Thumb/coff\n", \
96 ASM_COMMENT_START, version_string); \
97 fprintf ((STREAM), ASM_APP_OFF); \
98 } while (0)
100 /* A C statement to output something to the assembler file to switch to section
101 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
102 NULL_TREE. Some target formats do not support arbitrary sections. Do not
103 define this macro in such cases. */
104 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
105 do { \
106 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
107 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
108 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
109 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
110 else \
111 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
112 } while (0)
114 /* Support the ctors/dtors and other sections. */
116 #undef INIT_SECTION_ASM_OP
118 /* Define this macro if jump tables (for `tablejump' insns) should be
119 output in the text section, along with the assembler instructions.
120 Otherwise, the readonly data section is used. */
121 #define JUMP_TABLES_IN_TEXT_SECTION 1
123 #undef READONLY_DATA_SECTION
124 #define READONLY_DATA_SECTION rdata_section
125 #undef RDATA_SECTION_ASM_OP
126 #define RDATA_SECTION_ASM_OP "\t.section .rdata"
128 #undef CTORS_SECTION_ASM_OP
129 #define CTORS_SECTION_ASM_OP "\t.section .ctors,\"x\""
130 #undef DTORS_SECTION_ASM_OP
131 #define DTORS_SECTION_ASM_OP "\t.section .dtors,\"x\""
133 /* A list of other sections which the compiler might be "in" at any
134 given time. */
136 #undef EXTRA_SECTIONS
137 #define EXTRA_SECTIONS SUBTARGET_EXTRA_SECTIONS in_rdata, in_ctors, in_dtors
139 #define SUBTARGET_EXTRA_SECTIONS
141 /* A list of extra section function definitions. */
143 #undef EXTRA_SECTION_FUNCTIONS
144 #define EXTRA_SECTION_FUNCTIONS \
145 RDATA_SECTION_FUNCTION \
146 CTORS_SECTION_FUNCTION \
147 DTORS_SECTION_FUNCTION \
148 SUBTARGET_EXTRA_SECTION_FUNCTIONS
150 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS
152 #define RDATA_SECTION_FUNCTION \
153 void \
154 rdata_section () \
156 if (in_section != in_rdata) \
158 fprintf (asm_out_file, "%s\n", RDATA_SECTION_ASM_OP); \
159 in_section = in_rdata; \
163 #define CTORS_SECTION_FUNCTION \
164 void \
165 ctors_section () \
167 if (in_section != in_ctors) \
169 fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
170 in_section = in_ctors; \
174 #define DTORS_SECTION_FUNCTION \
175 void \
176 dtors_section () \
178 if (in_section != in_dtors) \
180 fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
181 in_section = in_dtors; \
185 /* Support the ctors/dtors sections for g++. */
187 #define INT_ASM_OP ".word"
189 /* A C statement (sans semicolon) to output an element in the table of
190 global constructors. */
191 #undef ASM_OUTPUT_CONSTRUCTOR
192 #define ASM_OUTPUT_CONSTRUCTOR(STREAM,NAME) \
193 do { \
194 ctors_section (); \
195 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
196 assemble_name (STREAM, NAME); \
197 fprintf (STREAM, "\n"); \
198 } while (0)
200 /* A C statement (sans semicolon) to output an element in the table of
201 global destructors. */
202 #undef ASM_OUTPUT_DESTRUCTOR
203 #define ASM_OUTPUT_DESTRUCTOR(STREAM,NAME) \
204 do { \
205 dtors_section (); \
206 fprintf (STREAM, "\t%s\t ", INT_ASM_OP); \
207 assemble_name (STREAM, NAME); \
208 fprintf (STREAM, "\n"); \
209 } while (0)
211 /* __CTOR_LIST__ and __DTOR_LIST__ must be defined by the linker script. */
212 #define CTOR_LISTS_DEFINED_EXTERNALLY
214 #undef DO_GLOBAL_CTORS_BODY
215 #undef DO_GLOBAL_DTORS_BODY
217 /* The ARM development system defines __main. */
218 #define NAME__MAIN "__gccmain"
219 #define SYMBOL__MAIN __gccmain
221 /* This is to better conform to the ARM PCS.
222 Richard Earnshaw hasn't put this into FSF sources yet so it's here. */
223 #undef RETURN_IN_MEMORY
224 #define RETURN_IN_MEMORY(TYPE) \
225 ((TYPE_MODE ((TYPE)) == BLKmode && ! TYPE_NO_FORCE_BLK (TYPE)) \
226 || (AGGREGATE_TYPE_P ((TYPE)) && arm_pe_return_in_memory ((TYPE))))
227 extern int arm_pe_return_in_memory ();
229 /* A C expression whose value is nonzero if IDENTIFIER with arguments ARGS
230 is a valid machine specific attribute for DECL.
231 The attributes in ATTRIBUTES have previously been assigned to DECL. */
232 extern int arm_pe_valid_machine_decl_attribute ();
233 #undef VALID_MACHINE_DECL_ATTRIBUTE
234 #define VALID_MACHINE_DECL_ATTRIBUTE(DECL, ATTRIBUTES, IDENTIFIER, ARGS) \
235 arm_pe_valid_machine_decl_attribute (DECL, ATTRIBUTES, IDENTIFIER, ARGS)
237 extern union tree_node * arm_pe_merge_machine_decl_attributes ();
238 #define MERGE_MACHINE_DECL_ATTRIBUTES(OLD, NEW) \
239 arm_pe_merge_machine_decl_attributes ((OLD), (NEW))
241 /* In addition to the stuff done in arm.h, we must mark dll symbols specially.
242 Definitions of dllexport'd objects install some info in the .drectve
243 section. References to dllimport'd objects are fetched indirectly via
244 __imp_. If both are declared, dllexport overrides.
245 This is also needed to implement one-only vtables: they go into their own
246 section and we need to set DECL_SECTION_NAME so we do that here.
247 Note that we can be called twice on the same decl. */
248 extern void arm_pe_encode_section_info ();
249 #undef ENCODE_SECTION_INFO
250 #define ENCODE_SECTION_INFO(DECL) \
251 arm_pe_encode_section_info (DECL)
253 #define REDO_SECTION_INFO_P(DECL) 1
255 /* Utility used only in this file. */
256 #define ARM_STRIP_NAME_ENCODING(SYM_NAME) \
257 ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0))
259 /* Strip any text from SYM_NAME added by ENCODE_SECTION_INFO and store
260 the result in VAR. */
261 #undef STRIP_NAME_ENCODING
262 #define STRIP_NAME_ENCODING(VAR, SYM_NAME) \
263 (VAR) = ARM_STRIP_NAME_ENCODING (SYM_NAME)
265 /* Define this macro if in some cases global symbols from one translation
266 unit may not be bound to undefined symbols in another translation unit
267 without user intervention. For instance, under Microsoft Windows
268 symbols must be explicitly imported from shared libraries (DLLs). */
269 #define MULTIPLE_SYMBOL_SPACES
271 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
272 extern void arm_pe_unique_section ();
273 #define UNIQUE_SECTION(DECL,RELOC) arm_pe_unique_section (DECL, RELOC)
275 #define SUPPORTS_ONE_ONLY 1
277 /* A C statement to output something to the assembler file to switch to section
278 NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
279 NULL_TREE. Some target formats do not support arbitrary sections. Do not
280 define this macro in such cases. */
281 #undef ASM_OUTPUT_SECTION_NAME
282 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC) \
283 do { \
284 if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
285 fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME)); \
286 else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
287 fprintf (STREAM, "\t.section %s,\"\"\n", (NAME)); \
288 else \
289 fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME)); \
290 /* Functions may have been compiled at various levels of \
291 optimization so we can't use `same_size' here. Instead, \
292 have the linker pick one. */ \
293 if ((DECL) && DECL_ONE_ONLY (DECL)) \
294 fprintf (STREAM, "\t.linkonce %s\n", \
295 TREE_CODE (DECL) == FUNCTION_DECL \
296 ? "discard" : "same_size"); \
297 } while (0)
299 /* This outputs a lot of .req's to define alias for various registers.
300 Let's try to avoid this. */
301 #undef ASM_FILE_START
302 #define ASM_FILE_START(STREAM) \
303 do { \
304 extern char * version_string; \
305 fprintf (STREAM, "%s Generated by gcc %s for ARM/pe\n", \
306 ASM_COMMENT_START, version_string); \
307 output_file_directive ((STREAM), main_input_filename); \
308 } while (0)
310 /* Output a reference to a label. */
311 #undef ASM_OUTPUT_LABELREF
312 #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
313 fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, ARM_STRIP_NAME_ENCODING (NAME))
315 /* Output a function definition label. */
316 #undef ASM_DECLARE_FUNCTION_NAME
317 #define ASM_DECLARE_FUNCTION_NAME(STREAM, NAME, DECL) \
318 do { \
319 if (arm_dllexport_name_p (NAME)) \
321 drectve_section (); \
322 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \
323 ARM_STRIP_NAME_ENCODING (NAME)); \
324 function_section (DECL); \
326 if (! is_called_in_ARM_mode (decl)) \
327 fprintf (STREAM, "\t.thumb_func\n") ; \
328 else \
329 fprintf (STREAM, "\t.code\t32\n") ; \
330 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
331 } while (0)
333 /* Output a common block. */
334 #undef ASM_OUTPUT_COMMON
335 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED) \
336 do { \
337 if (arm_dllexport_name_p (NAME)) \
339 drectve_section (); \
340 fprintf ((STREAM), "\t.ascii \" -export:%s\"\n", \
341 ARM_STRIP_NAME_ENCODING (NAME)); \
343 if (! arm_dllimport_name_p (NAME)) \
345 fprintf ((STREAM), "\t.comm\t"); \
346 assemble_name ((STREAM), (NAME)); \
347 fprintf ((STREAM), ", %d\t%s %d\n", \
348 (ROUNDED), ASM_COMMENT_START, (SIZE)); \
350 } while (0)
352 /* Output the label for an initialized variable. */
353 #undef ASM_DECLARE_OBJECT_NAME
354 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL) \
355 do { \
356 if (arm_dllexport_name_p (NAME)) \
358 enum in_section save_section = in_section; \
359 drectve_section (); \
360 fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \
361 ARM_STRIP_NAME_ENCODING (NAME)); \
362 switch_to_section (save_section, (DECL)); \
364 ASM_OUTPUT_LABEL ((STREAM), (NAME)); \
365 } while (0)
367 /* Support the ctors/dtors and other sections. */
369 #define DRECTVE_SECTION_ASM_OP "\t.section .drectve"
371 /* A list of other sections which the compiler might be "in" at any
372 given time. */
374 #undef SUBTARGET_EXTRA_SECTIONS
375 #define SUBTARGET_EXTRA_SECTIONS in_drectve,
377 /* A list of extra section function definitions. */
379 #undef SUBTARGET_EXTRA_SECTION_FUNCTIONS
380 #define SUBTARGET_EXTRA_SECTION_FUNCTIONS \
381 DRECTVE_SECTION_FUNCTION \
382 SWITCH_TO_SECTION_FUNCTION
384 #define DRECTVE_SECTION_FUNCTION \
385 void \
386 drectve_section () \
388 if (in_section != in_drectve) \
390 fprintf (asm_out_file, "%s\n", DRECTVE_SECTION_ASM_OP); \
391 in_section = in_drectve; \
395 /* Switch to SECTION (an `enum in_section').
397 ??? This facility should be provided by GCC proper.
398 The problem is that we want to temporarily switch sections in
399 ASM_DECLARE_OBJECT_NAME and then switch back to the original section
400 afterwards. */
401 #define SWITCH_TO_SECTION_FUNCTION \
402 void \
403 switch_to_section (section, decl) \
404 enum in_section section; \
405 tree decl; \
407 switch (section) \
409 case in_text: text_section (); break; \
410 case in_data: data_section (); break; \
411 case in_named: named_section (decl, NULL, 0); break; \
412 case in_rdata: rdata_section (); break; \
413 case in_ctors: ctors_section (); break; \
414 case in_dtors: dtors_section (); break; \
415 case in_drectve: drectve_section (); break; \
416 default: abort (); break; \
422 extern int thumb_pe_valid_machine_decl_attribute ();
423 extern int arm_dllexport_p ();
424 extern int arm_dllimport_p ();
425 extern int arm_dllexport_name_p ();
426 extern int arm_dllimport_name_p ();
427 extern int arm_pe_return_in_memory ();