OSDN Git Service

* config/i386/cygming.h (READONLY_DATA_SECTION_ASM_OP): Define.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / cygming.h
1 /* Operating system specific defines to be used when targeting GCC for
2    hosting on Windows32, using a Unix style C library and tools.
3    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4    Free Software Foundation, Inc.
5
6 This file is part of GCC.
7
8 GCC 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.
12
13 GCC 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.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING.  If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA.  */
22
23 #define DBX_DEBUGGING_INFO 1
24 #define SDB_DEBUGGING_INFO 1
25 #undef PREFERRED_DEBUGGING_TYPE
26 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
27
28 #define TARGET_EXECUTABLE_SUFFIX ".exe"
29
30 #include <stdio.h>
31
32 /* Masks for subtarget switches used by other files.  */
33 #define MASK_NOP_FUN_DLLIMPORT 0x08000000 /* Ignore dllimport for functions */
34
35 /* Used in winnt.c.  */
36 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT)
37
38 #undef  SUBTARGET_SWITCHES
39 #define SUBTARGET_SWITCHES \
40 { "cygwin",               0, N_("Use the Cygwin interface") },  \
41 { "no-cygwin",            0, N_("Use the Mingw32 interface") }, \
42 { "windows",              0, N_("Create GUI application") },    \
43 { "no-win32",             0, N_("Don't set Windows defines") }, \
44 { "win32",                0, N_("Set Windows defines") },       \
45 { "console",              0, N_("Create console application") },\
46 { "dll",                  0, N_("Generate code for a DLL") },   \
47 { "nop-fun-dllimport",    MASK_NOP_FUN_DLLIMPORT,               \
48   N_("Ignore dllimport for functions") },                       \
49 { "no-nop-fun-dllimport", -MASK_NOP_FUN_DLLIMPORT, "" },        \
50 { "threads",              0, N_("Use Mingw-specific thread support") },
51
52 #define MAYBE_UWIN_CPP_BUILTINS() /* Nothing.  */
53
54 /* Support the __declspec keyword by turning them into attributes.
55    We currently only support: dllimport and dllexport.
56    Note that the current way we do this may result in a collision with
57    predefined attributes later on.  This can be solved by using one attribute,
58    say __declspec__, and passing args to it.  The problem with that approach
59    is that args are not accumulated: each new appearance would clobber any
60    existing args.  */
61
62 #define TARGET_OS_CPP_BUILTINS()                                        \
63   do                                                                    \
64     {                                                                   \
65         builtin_define ("_X86_=1");                                     \
66         builtin_assert ("system=winnt");                                \
67         builtin_define ("__stdcall=__attribute__((__stdcall__))");      \
68         builtin_define ("__fastcall=__attribute__((__fastcall__))");    \
69         builtin_define ("__cdecl=__attribute__((__cdecl__))");          \
70         builtin_define ("__declspec(x)=__attribute__((x))");            \
71         if (!flag_iso)                                                  \
72           {                                                             \
73             builtin_define ("_stdcall=__attribute__((__stdcall__))");   \
74             builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
75             builtin_define ("_cdecl=__attribute__((__cdecl__))");       \
76           }                                                             \
77         MAYBE_UWIN_CPP_BUILTINS ();                                     \
78         EXTRA_OS_CPP_BUILTINS ();                                       \
79   }                                                                     \
80   while (0)
81
82 /* Get tree.c to declare a target-specific specialization of
83    merge_decl_attributes.  */
84 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES
85
86 /* This macro defines names of additional specifications to put in the specs
87    that can be used in various specifications like CC1_SPEC.  Its definition
88    is an initializer with a subgrouping for each command option.
89
90    Each subgrouping contains a string constant, that defines the
91    specification name, and a string constant that used by the GCC driver
92    program.
93
94    Do not define this macro if it does not need to do anything.  */
95
96 #undef  SUBTARGET_EXTRA_SPECS
97 #define SUBTARGET_EXTRA_SPECS                                           \
98   { "mingw_include_path", DEFAULT_TARGET_MACHINE }
99
100 #undef MATH_LIBRARY
101 #define MATH_LIBRARY ""
102
103 #define SIZE_TYPE "unsigned int"
104 #define PTRDIFF_TYPE "int"
105 #define WCHAR_TYPE_SIZE 16
106 #define WCHAR_TYPE "short unsigned int"
107
108 \f
109 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop).  */
110 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
111
112 union tree_node;
113 #define TREE union tree_node *
114 \f
115 #undef EXTRA_SECTIONS
116 #define EXTRA_SECTIONS in_drectve
117
118 #undef EXTRA_SECTION_FUNCTIONS
119 #define EXTRA_SECTION_FUNCTIONS                                 \
120   DRECTVE_SECTION_FUNCTION                                      \
121   SWITCH_TO_SECTION_FUNCTION
122
123 #define DRECTVE_SECTION_FUNCTION \
124 void                                                                    \
125 drectve_section (void)                                                  \
126 {                                                                       \
127   if (in_section != in_drectve)                                         \
128     {                                                                   \
129       fprintf (asm_out_file, "%s\n", "\t.section .drectve\n");          \
130       in_section = in_drectve;                                          \
131     }                                                                   \
132 }
133 void drectve_section (void);
134
135 /* Older versions of gas don't handle 'r' as data.
136    Explicitly set data flag with 'd'.  */  
137 #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\""
138
139 /* Switch to SECTION (an `enum in_section').
140
141    ??? This facility should be provided by GCC proper.
142    The problem is that we want to temporarily switch sections in
143    ASM_DECLARE_OBJECT_NAME and then switch back to the original section
144    afterwards.  */
145 #define SWITCH_TO_SECTION_FUNCTION                              \
146 void switch_to_section (enum in_section, tree);                 \
147 void                                                            \
148 switch_to_section (enum in_section section, tree decl)          \
149 {                                                               \
150   switch (section)                                              \
151     {                                                           \
152       case in_text: text_section (); break;                     \
153       case in_data: data_section (); break;                     \
154       case in_readonly_data: readonly_data_section (); break;   \
155       case in_named: named_section (decl, NULL, 0); break;      \
156       case in_drectve: drectve_section (); break;               \
157       default: abort (); break;                         \
158     }                                                           \
159 }
160
161 /* Don't allow flag_pic to propagate since gas may produce invalid code
162    otherwise.  */
163
164 #undef  SUBTARGET_OVERRIDE_OPTIONS
165 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
166 do {                                                                    \
167   if (flag_pic)                                                         \
168     {                                                                   \
169       warning ("-f%s ignored for target (all code is position independent)",\
170                (flag_pic > 1) ? "PIC" : "pic");                         \
171       flag_pic = 0;                                                     \
172     }                                                                   \
173 } while (0)                                                             \
174
175 /* Define this macro if references to a symbol must be treated
176    differently depending on something about the variable or
177    function named by the symbol (such as what section it is in).
178
179    On i386 running Windows NT, modify the assembler name with a suffix
180    consisting of an atsign (@) followed by string of digits that represents
181    the number of bytes of arguments passed to the function, if it has the
182    attribute STDCALL.
183
184    In addition, we must mark dll symbols specially. Definitions of
185    dllexport'd objects install some info in the .drectve section.
186    References to dllimport'd objects are fetched indirectly via
187    _imp__.  If both are declared, dllexport overrides.  This is also
188    needed to implement one-only vtables: they go into their own
189    section and we need to set DECL_SECTION_NAME so we do that here.
190    Note that we can be called twice on the same decl.  */
191
192 #undef TARGET_ENCODE_SECTION_INFO
193 #define TARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
194 #undef  TARGET_STRIP_NAME_ENCODING
195 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
196 \f
197 /* Output a reference to a label.  */
198 #undef ASM_OUTPUT_LABELREF
199 #define ASM_OUTPUT_LABELREF  i386_pe_output_labelref
200
201 /* Output a common block.  */
202 #undef ASM_OUTPUT_COMMON
203 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)  \
204 do {                                                    \
205   if (i386_pe_dllexport_name_p (NAME))                  \
206     i386_pe_record_exported_symbol (NAME, 1);           \
207   if (! i386_pe_dllimport_name_p (NAME))                \
208     {                                                   \
209       fprintf ((STREAM), "\t.comm\t");                  \
210       assemble_name ((STREAM), (NAME));                 \
211       fprintf ((STREAM), ", %d\t%s %d\n",               \
212                (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)); \
213     }                                                   \
214 } while (0)
215
216 /* Output the label for an initialized variable.  */
217 #undef ASM_DECLARE_OBJECT_NAME
218 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)     \
219 do {                                                    \
220   if (i386_pe_dllexport_name_p (NAME))                  \
221     i386_pe_record_exported_symbol (NAME, 1);           \
222   ASM_OUTPUT_LABEL ((STREAM), (NAME));                  \
223 } while (0)
224
225 \f
226 /* Emit code to check the stack when allocating more that 4000
227    bytes in one go.  */
228
229 #define CHECK_STACK_LIMIT 4000
230
231 /* By default, target has a 80387, uses IEEE compatible arithmetic,
232    returns float values in the 387 and needs stack probes.
233    We also align doubles to 64-bits for MSVC default compatibility. */
234
235 #undef TARGET_SUBTARGET_DEFAULT
236 #define TARGET_SUBTARGET_DEFAULT \
237    (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE \
238     | MASK_ALIGN_DOUBLE)
239
240 /* This is how to output an assembler line
241    that says to advance the location counter
242    to a multiple of 2**LOG bytes.  */
243
244 #undef ASM_OUTPUT_ALIGN
245 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
246     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
247
248 /* Define this macro if in some cases global symbols from one translation
249    unit may not be bound to undefined symbols in another translation unit
250    without user intervention.  For instance, under Microsoft Windows
251    symbols must be explicitly imported from shared libraries (DLLs).  */
252 #define MULTIPLE_SYMBOL_SPACES
253
254 extern void i386_pe_unique_section (TREE, int);
255 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
256
257 #define SUPPORTS_ONE_ONLY 1
258
259 /* Switch into a generic section.  */
260 #define TARGET_ASM_NAMED_SECTION  i386_pe_asm_named_section
261
262 /* Select attributes for named sections.  */
263 #define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
264
265 /* Write the extra assembler code needed to declare a function
266    properly.  If we are generating SDB debugging information, this
267    will happen automatically, so we only need to handle other cases.  */
268 #undef ASM_DECLARE_FUNCTION_NAME
269 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
270   do                                                                    \
271     {                                                                   \
272       if (i386_pe_dllexport_name_p (NAME))                              \
273         i386_pe_record_exported_symbol (NAME, 0);                       \
274       if (write_symbols != SDB_DEBUG)                                   \
275         i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
276       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
277     }                                                                   \
278   while (0)
279
280 /* Add an external function to the list of functions to be declared at
281    the end of the file.  */
282 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)                           \
283   do                                                                    \
284     {                                                                   \
285       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
286         i386_pe_record_external_function (NAME);                        \
287     }                                                                   \
288   while (0)
289
290 /* Declare the type properly for any external libcall.  */
291 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
292   i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
293
294 /* This says out to put a global symbol in the BSS section.  */
295 #undef ASM_OUTPUT_ALIGNED_BSS
296 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
297   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
298
299 /* Output function declarations at the end of the file.  */
300 #undef TARGET_ASM_FILE_END
301 #define TARGET_ASM_FILE_END i386_pe_file_end
302
303 #undef ASM_COMMENT_START
304 #define ASM_COMMENT_START " #"
305
306 /* DWARF2 Unwinding doesn't work with exception handling yet.  To make
307    it work, we need to build a libgcc_s.dll, and dcrt0.o should be
308    changed to call __register_frame_info/__deregister_frame_info.  */
309 #define DWARF2_UNWIND_INFO 0
310
311 /* Don't assume anything about the header files.  */
312 #define NO_IMPLICIT_EXTERN_C
313
314 #undef PROFILE_HOOK
315 #define PROFILE_HOOK(LABEL)                                             \
316   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))                  \
317     {                                                                   \
318       emit_call_insn (gen_rtx (CALL, VOIDmode,                          \
319         gen_rtx_MEM (FUNCTION_MODE,                                     \
320                      gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),        \
321         const0_rtx));                                                   \
322     }
323
324 /* Java Native Interface (JNI) methods on Win32 are invoked using the
325    stdcall calling convention.  */
326 #undef MODIFY_JNI_METHOD_CALL
327 #define MODIFY_JNI_METHOD_CALL(MDECL)                                         \
328   build_type_attribute_variant ((MDECL),                                      \
329                                build_tree_list (get_identifier ("stdcall"),   \
330                                                 NULL))
331
332 /* External function declarations.  */
333
334 extern void i386_pe_record_external_function (const char *);
335 extern void i386_pe_declare_function_type (FILE *, const char *, int);
336 extern void i386_pe_record_exported_symbol (const char *, int);
337 extern void i386_pe_file_end (void);
338 extern int i386_pe_dllexport_name_p (const char *);
339 extern int i386_pe_dllimport_name_p (const char *);
340
341 /* For Win32 ABI compatibility */
342 #undef DEFAULT_PCC_STRUCT_RETURN
343 #define DEFAULT_PCC_STRUCT_RETURN 0
344
345 /* MSVC returns aggregate types of up to 8 bytes via registers.
346    See i386.c:ix86_return_in_memory.  */
347 #undef MS_AGGREGATE_RETURN
348 #define MS_AGGREGATE_RETURN 1
349
350 /* No data type wants to be aligned rounder than this.  */
351 #undef  BIGGEST_ALIGNMENT
352 #define BIGGEST_ALIGNMENT 128
353
354 /* Native complier aligns internal doubles in structures on dword boundaries.  */
355 #undef  BIGGEST_FIELD_ALIGNMENT
356 #define BIGGEST_FIELD_ALIGNMENT 64
357
358 /* A bit-field declared as `int' forces `int' alignment for the struct.  */
359 #undef PCC_BITFIELD_TYPE_MATTERS
360 #define PCC_BITFIELD_TYPE_MATTERS 1
361 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
362
363 /* Enable alias attribute support.  */
364 #ifndef SET_ASM_OP
365 #define SET_ASM_OP "\t.set\t"
366 #endif
367
368 #undef TREE
369
370 #ifndef BUFSIZ
371 # undef FILE
372 #endif