OSDN Git Service

* config.gcc (with_cpu handling): Translate sparc64 in
[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 GNU CC.
7
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.
12
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.
17
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.  */
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 GNU CC 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 ()                                                      \
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 PARAMS ((void));
134
135 /* Switch to SECTION (an `enum in_section').
136
137    ??? This facility should be provided by GCC proper.
138    The problem is that we want to temporarily switch sections in
139    ASM_DECLARE_OBJECT_NAME and then switch back to the original section
140    afterwards.  */
141 #define SWITCH_TO_SECTION_FUNCTION                              \
142 void switch_to_section PARAMS ((enum in_section, tree));        \
143 void                                                            \
144 switch_to_section (section, decl)                               \
145      enum in_section section;                                   \
146      tree decl;                                                 \
147 {                                                               \
148   switch (section)                                              \
149     {                                                           \
150       case in_text: text_section (); break;                     \
151       case in_data: data_section (); break;                     \
152       case in_named: named_section (decl, NULL, 0); break;      \
153       case in_drectve: drectve_section (); break;               \
154       default: abort (); break;                                 \
155     }                                                           \
156 }
157
158 /* Don't allow flag_pic to propagate since gas may produce invalid code
159    otherwise.  */
160
161 #undef  SUBTARGET_OVERRIDE_OPTIONS
162 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
163 do {                                                                    \
164   if (flag_pic)                                                         \
165     {                                                                   \
166       warning ("-f%s ignored for target (all code is position independent)",\
167                (flag_pic > 1) ? "PIC" : "pic");                         \
168       flag_pic = 0;                                                     \
169     }                                                                   \
170 } while (0)                                                             \
171
172 /* Define this macro if references to a symbol must be treated
173    differently depending on something about the variable or
174    function named by the symbol (such as what section it is in).
175
176    On i386 running Windows NT, modify the assembler name with a suffix 
177    consisting of an atsign (@) followed by string of digits that represents
178    the number of bytes of arguments passed to the function, if it has the 
179    attribute STDCALL.
180
181    In addition, we must mark dll symbols specially. Definitions of 
182    dllexport'd objects install some info in the .drectve section.  
183    References to dllimport'd objects are fetched indirectly via
184    _imp__.  If both are declared, dllexport overrides.  This is also 
185    needed to implement one-only vtables: they go into their own
186    section and we need to set DECL_SECTION_NAME so we do that here.
187    Note that we can be called twice on the same decl.  */
188
189 #undef TARGET_ENCODE_SECTION_INFO
190 #define TARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
191 #undef  TARGET_STRIP_NAME_ENCODING
192 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
193 \f
194 /* Output a reference to a label.  */
195 #undef ASM_OUTPUT_LABELREF
196 #define ASM_OUTPUT_LABELREF  i386_pe_output_labelref
197
198 /* Output a common block.  */
199 #undef ASM_OUTPUT_COMMON
200 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)  \
201 do {                                                    \
202   if (i386_pe_dllexport_name_p (NAME))                  \
203     i386_pe_record_exported_symbol (NAME, 1);           \
204   if (! i386_pe_dllimport_name_p (NAME))                \
205     {                                                   \
206       fprintf ((STREAM), "\t.comm\t");                  \
207       assemble_name ((STREAM), (NAME));                 \
208       fprintf ((STREAM), ", %d\t%s %d\n",               \
209                (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)); \
210     }                                                   \
211 } while (0)
212
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 {                                                    \
217   if (i386_pe_dllexport_name_p (NAME))                  \
218     i386_pe_record_exported_symbol (NAME, 1);           \
219   ASM_OUTPUT_LABEL ((STREAM), (NAME));                  \
220 } while (0)
221
222 \f
223 /* Emit code to check the stack when allocating more that 4000
224    bytes in one go.  */
225
226 #define CHECK_STACK_LIMIT 4000
227
228 /* By default, target has a 80387, uses IEEE compatible arithmetic,
229    returns float values in the 387 and needs stack probes.
230    We also align doubles to 64-bits for MSVC default compatibility. */
231
232 #undef TARGET_SUBTARGET_DEFAULT
233 #define TARGET_SUBTARGET_DEFAULT \
234    (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE \
235     | MASK_ALIGN_DOUBLE)
236
237 /* This is how to output an assembler line
238    that says to advance the location counter
239    to a multiple of 2**LOG bytes.  */
240
241 #undef ASM_OUTPUT_ALIGN
242 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
243     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
244
245 /* Define this macro if in some cases global symbols from one translation
246    unit may not be bound to undefined symbols in another translation unit
247    without user intervention.  For instance, under Microsoft Windows
248    symbols must be explicitly imported from shared libraries (DLLs).  */
249 #define MULTIPLE_SYMBOL_SPACES
250
251 extern void i386_pe_unique_section PARAMS ((TREE, int));
252 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
253
254 #define SUPPORTS_ONE_ONLY 1
255
256 /* Switch into a generic section.  */
257 #define TARGET_ASM_NAMED_SECTION  i386_pe_asm_named_section
258
259 /* Select attributes for named sections.  */
260 #define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
261
262 /* Write the extra assembler code needed to declare a function
263    properly.  If we are generating SDB debugging information, this
264    will happen automatically, so we only need to handle other cases.  */
265 #undef ASM_DECLARE_FUNCTION_NAME
266 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
267   do                                                                    \
268     {                                                                   \
269       if (i386_pe_dllexport_name_p (NAME))                              \
270         i386_pe_record_exported_symbol (NAME, 0);                       \
271       if (write_symbols != SDB_DEBUG)                                   \
272         i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
273       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
274     }                                                                   \
275   while (0)
276
277 /* Add an external function to the list of functions to be declared at
278    the end of the file.  */
279 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)                           \
280   do                                                                    \
281     {                                                                   \
282       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
283         i386_pe_record_external_function (NAME);                        \
284     }                                                                   \
285   while (0)
286
287 /* Declare the type properly for any external libcall.  */
288 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
289   i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
290
291 /* This says out to put a global symbol in the BSS section.  */
292 #undef ASM_OUTPUT_ALIGNED_BSS
293 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
294   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
295
296 /* Output function declarations at the end of the file.  */
297 #undef TARGET_ASM_FILE_END
298 #define TARGET_ASM_FILE_END i386_pe_file_end
299
300 #undef ASM_COMMENT_START
301 #define ASM_COMMENT_START " #"
302
303 /* DWARF2 Unwinding doesn't work with exception handling yet.  To make
304    it work, we need to build a libgcc_s.dll, and dcrt0.o should be
305    changed to call __register_frame_info/__deregister_frame_info.  */
306 #define DWARF2_UNWIND_INFO 0
307
308 /* Don't assume anything about the header files.  */
309 #define NO_IMPLICIT_EXTERN_C
310
311 #undef PROFILE_HOOK
312 #define PROFILE_HOOK(LABEL)                                             \
313   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))                  \
314     {                                                                   \
315       emit_call_insn (gen_rtx (CALL, VOIDmode,                          \
316         gen_rtx_MEM (FUNCTION_MODE,                                     \
317                      gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),        \
318         const0_rtx));                                                   \
319     }
320
321 /* Java Native Interface (JNI) methods on Win32 are invoked using the
322    stdcall calling convention.  */
323 #undef MODIFY_JNI_METHOD_CALL
324 #define MODIFY_JNI_METHOD_CALL(MDECL)                                         \
325   build_type_attribute_variant ((MDECL),                                      \
326                                build_tree_list (get_identifier ("stdcall"),   \
327                                                 NULL))
328
329 /* External function declarations.  */
330
331 extern void i386_pe_record_external_function PARAMS ((const char *));
332 extern void i386_pe_declare_function_type PARAMS ((FILE *, const char *, int));
333 extern void i386_pe_record_exported_symbol PARAMS ((const char *, int));
334 extern void i386_pe_file_end PARAMS ((void));
335 extern int i386_pe_dllexport_name_p PARAMS ((const char *));
336 extern int i386_pe_dllimport_name_p PARAMS ((const char *));
337
338 /* For Win32 ABI compatibility */
339 #undef DEFAULT_PCC_STRUCT_RETURN
340 #define DEFAULT_PCC_STRUCT_RETURN 0
341
342 /* MSVC returns aggregate types of up to 8 bytes via registers.
343    See i386.c:ix86_return_in_memory.  */
344 #undef MS_AGGREGATE_RETURN
345 #define MS_AGGREGATE_RETURN 1
346
347 /* No data type wants to be aligned rounder than this.  */
348 #undef  BIGGEST_ALIGNMENT
349 #define BIGGEST_ALIGNMENT 128
350
351 /* Native complier aligns internal doubles in structures on dword boundaries.  */
352 #undef  BIGGEST_FIELD_ALIGNMENT
353 #define BIGGEST_FIELD_ALIGNMENT 64
354
355 /* A bit-field declared as `int' forces `int' alignment for the struct.  */
356 #undef PCC_BITFIELD_TYPE_MATTERS
357 #define PCC_BITFIELD_TYPE_MATTERS 1
358 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
359
360 /* Enable alias attribute support.  */
361 #ifndef SET_ASM_OP
362 #define SET_ASM_OP "\t.set\t"
363 #endif
364
365 #undef TREE
366
367 #ifndef BUFSIZ
368 # undef FILE
369 #endif