OSDN Git Service

* diagnostic.c (warning): Accept parameter to classify warning option.
[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, 2004
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 #ifdef HAVE_GAS_PE_SECREL32_RELOC
29 #define DWARF2_DEBUGGING_INFO 1
30
31 #undef DBX_REGISTER_NUMBER
32 #define DBX_REGISTER_NUMBER(n) (write_symbols == DWARF2_DEBUG   \
33                                 ? svr4_dbx_register_map[n]      \
34                                 : dbx_register_map[n])
35
36 /* Use section relative relocations for debugging offsets.  Unlike
37    other targets that fake this by putting the section VMA at 0, PE
38    won't allow it.  */
39 #define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL)    \
40   do {                                                \
41     if (SIZE != 4)                                    \
42       abort ();                                       \
43                                                       \
44     fputs ("\t.secrel32\t", FILE);                    \
45     assemble_name (FILE, LABEL);                      \
46   } while (0)
47 #endif
48
49 #define TARGET_EXECUTABLE_SUFFIX ".exe"
50
51 #include <stdio.h>
52
53 #define MAYBE_UWIN_CPP_BUILTINS() /* Nothing.  */
54
55 #define TARGET_OS_CPP_BUILTINS()                                        \
56   do                                                                    \
57     {                                                                   \
58         builtin_define ("_X86_=1");                                     \
59         builtin_assert ("system=winnt");                                \
60         builtin_define ("__stdcall=__attribute__((__stdcall__))");      \
61         builtin_define ("__fastcall=__attribute__((__fastcall__))");    \
62         builtin_define ("__cdecl=__attribute__((__cdecl__))");          \
63         if (!flag_iso)                                                  \
64           {                                                             \
65             builtin_define ("_stdcall=__attribute__((__stdcall__))");   \
66             builtin_define ("_fastcall=__attribute__((__fastcall__))"); \
67             builtin_define ("_cdecl=__attribute__((__cdecl__))");       \
68           }                                                             \
69         /* Even though linkonce works with static libs, this is needed  \
70             to compare typeinfo symbols across dll boundaries.  */      \
71         builtin_define ("__GXX_MERGED_TYPEINFO_NAMES=0");               \
72         MAYBE_UWIN_CPP_BUILTINS ();                                     \
73         EXTRA_OS_CPP_BUILTINS ();                                       \
74   }                                                                     \
75   while (0)
76
77 /* Get tree.c to declare a target-specific specialization of
78    merge_decl_attributes.  */
79 #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
80
81 /* This macro defines names of additional specifications to put in the specs
82    that can be used in various specifications like CC1_SPEC.  Its definition
83    is an initializer with a subgrouping for each command option.
84
85    Each subgrouping contains a string constant, that defines the
86    specification name, and a string constant that used by the GCC driver
87    program.
88
89    Do not define this macro if it does not need to do anything.  */
90
91 #undef  SUBTARGET_EXTRA_SPECS
92 #define SUBTARGET_EXTRA_SPECS                                           \
93   { "mingw_include_path", DEFAULT_TARGET_MACHINE }
94
95 #undef MATH_LIBRARY
96 #define MATH_LIBRARY ""
97
98 #define SIZE_TYPE "unsigned int"
99 #define PTRDIFF_TYPE "int"
100 #define WCHAR_TYPE_SIZE 16
101 #define WCHAR_TYPE "short unsigned int"
102
103 \f
104 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop).  */
105 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
106
107 union tree_node;
108 #define TREE union tree_node *
109 \f
110 #undef EXTRA_SECTIONS
111 #define EXTRA_SECTIONS in_drectve
112
113 #undef EXTRA_SECTION_FUNCTIONS
114 #define EXTRA_SECTION_FUNCTIONS                                 \
115   DRECTVE_SECTION_FUNCTION                                      \
116   SWITCH_TO_SECTION_FUNCTION
117
118 #define DRECTVE_SECTION_FUNCTION \
119 void                                                                    \
120 drectve_section (void)                                                  \
121 {                                                                       \
122   if (in_section != in_drectve)                                         \
123     {                                                                   \
124       fprintf (asm_out_file, "%s\n", "\t.section .drectve\n");          \
125       in_section = in_drectve;                                          \
126     }                                                                   \
127 }
128 void drectve_section (void);
129
130 /* Older versions of gas don't handle 'r' as data.
131    Explicitly set data flag with 'd'.  */  
132 #define READONLY_DATA_SECTION_ASM_OP "\t.section .rdata,\"dr\""
133
134 /* Switch to SECTION (an `enum in_section').
135
136    ??? This facility should be provided by GCC proper.
137    The problem is that we want to temporarily switch sections in
138    ASM_DECLARE_OBJECT_NAME and then switch back to the original section
139    afterwards.  */
140 #define SWITCH_TO_SECTION_FUNCTION                              \
141 void switch_to_section (enum in_section, tree);                 \
142 void                                                            \
143 switch_to_section (enum in_section section, tree decl)          \
144 {                                                               \
145   switch (section)                                              \
146     {                                                           \
147       case in_text: text_section (); break;                     \
148       case in_unlikely_executed_text: unlikely_text_section (); break; \
149       case in_data: data_section (); break;                     \
150       case in_readonly_data: readonly_data_section (); break;   \
151       case in_named: named_section (decl, NULL, 0); break;      \
152       case in_drectve: drectve_section (); break;               \
153       default: abort (); break;                         \
154     }                                                           \
155 }
156
157 /* Don't allow flag_pic to propagate since gas may produce invalid code
158    otherwise.  */
159
160 #undef  SUBTARGET_OVERRIDE_OPTIONS
161 #define SUBTARGET_OVERRIDE_OPTIONS                                      \
162 do {                                                                    \
163   if (flag_pic)                                                         \
164     {                                                                   \
165       warning (0, "-f%s ignored for target (all code is position independent)",\
166                (flag_pic > 1) ? "PIC" : "pic");                         \
167       flag_pic = 0;                                                     \
168     }                                                                   \
169 } while (0)                                                             \
170
171 /* Define this macro if references to a symbol must be treated
172    differently depending on something about the variable or
173    function named by the symbol (such as what section it is in).
174
175    On i386 running Windows NT, modify the assembler name with a suffix
176    consisting of an atsign (@) followed by string of digits that represents
177    the number of bytes of arguments passed to the function, if it has the
178    attribute STDCALL.
179
180    In addition, we must mark dll symbols specially. Definitions of
181    dllexport'd objects install some info in the .drectve section.
182    References to dllimport'd objects are fetched indirectly via
183    _imp__.  If both are declared, dllexport overrides.  This is also
184    needed to implement one-only vtables: they go into their own
185    section and we need to set DECL_SECTION_NAME so we do that here.
186    Note that we can be called twice on the same decl.  */
187
188 #undef TARGET_ENCODE_SECTION_INFO
189 #define TARGET_ENCODE_SECTION_INFO  i386_pe_encode_section_info
190 #undef  TARGET_STRIP_NAME_ENCODING
191 #define TARGET_STRIP_NAME_ENCODING  i386_pe_strip_name_encoding_full
192 \f
193 /* Output a reference to a label.  */
194 #undef ASM_OUTPUT_LABELREF
195 #define ASM_OUTPUT_LABELREF  i386_pe_output_labelref
196
197 /* Output a common block.  */
198 #undef ASM_OUTPUT_COMMON
199 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)  \
200 do {                                                    \
201   if (i386_pe_dllexport_name_p (NAME))                  \
202     i386_pe_record_exported_symbol (NAME, 1);           \
203   if (! i386_pe_dllimport_name_p (NAME))                \
204     {                                                   \
205       fprintf ((STREAM), "\t.comm\t");                  \
206       assemble_name ((STREAM), (NAME));                 \
207       fprintf ((STREAM), ", %d\t%s %d\n",               \
208                (int)(ROUNDED), ASM_COMMENT_START, (int)(SIZE)); \
209     }                                                   \
210 } while (0)
211
212 /* Output the label for an initialized variable.  */
213 #undef ASM_DECLARE_OBJECT_NAME
214 #define ASM_DECLARE_OBJECT_NAME(STREAM, NAME, DECL)     \
215 do {                                                    \
216   if (i386_pe_dllexport_name_p (NAME))                  \
217     i386_pe_record_exported_symbol (NAME, 1);           \
218   ASM_OUTPUT_LABEL ((STREAM), (NAME));                  \
219 } while (0)
220
221 \f
222 /* Emit code to check the stack when allocating more that 4000
223    bytes in one go.  */
224
225 #define CHECK_STACK_LIMIT 4000
226
227 /* By default, target has a 80387, uses IEEE compatible arithmetic,
228    returns float values in the 387 and needs stack probes.
229    We also align doubles to 64-bits for MSVC default compatibility.  */
230
231 #undef TARGET_SUBTARGET_DEFAULT
232 #define TARGET_SUBTARGET_DEFAULT \
233    (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE \
234     | MASK_ALIGN_DOUBLE)
235
236 /* This is how to output an assembler line
237    that says to advance the location counter
238    to a multiple of 2**LOG bytes.  */
239
240 #undef ASM_OUTPUT_ALIGN
241 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
242     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
243
244 /* Windows uses explicit import from shared libraries.  */
245 #define MULTIPLE_SYMBOL_SPACES 1
246
247 extern void i386_pe_unique_section (TREE, int);
248 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
249 #define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
250
251 #define SUPPORTS_ONE_ONLY 1
252
253 /* Switch into a generic section.  */
254 #define TARGET_ASM_NAMED_SECTION  i386_pe_asm_named_section
255
256 /* Select attributes for named sections.  */
257 #define TARGET_SECTION_TYPE_FLAGS  i386_pe_section_type_flags
258
259 /* Write the extra assembler code needed to declare a function
260    properly.  If we are generating SDB debugging information, this
261    will happen automatically, so we only need to handle other cases.  */
262 #undef ASM_DECLARE_FUNCTION_NAME
263 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
264   do                                                                    \
265     {                                                                   \
266       if (i386_pe_dllexport_name_p (NAME))                              \
267         i386_pe_record_exported_symbol (NAME, 0);                       \
268       if (write_symbols != SDB_DEBUG)                                   \
269         i386_pe_declare_function_type (FILE, NAME, TREE_PUBLIC (DECL)); \
270       ASM_OUTPUT_LABEL (FILE, NAME);                                    \
271     }                                                                   \
272   while (0)
273
274 /* Add an external function to the list of functions to be declared at
275    the end of the file.  */
276 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)                           \
277   do                                                                    \
278     {                                                                   \
279       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
280         i386_pe_record_external_function ((DECL), (NAME));              \
281     }                                                                   \
282   while (0)
283
284 /* Declare the type properly for any external libcall.  */
285 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
286   i386_pe_declare_function_type (FILE, XSTR (FUN, 0), 1)
287
288 /* This says out to put a global symbol in the BSS section.  */
289 #undef ASM_OUTPUT_ALIGNED_BSS
290 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
291   asm_output_aligned_bss ((FILE), (DECL), (NAME), (SIZE), (ALIGN))
292
293 /* Output function declarations at the end of the file.  */
294 #undef TARGET_ASM_FILE_END
295 #define TARGET_ASM_FILE_END i386_pe_file_end
296
297 #undef ASM_COMMENT_START
298 #define ASM_COMMENT_START " #"
299
300 /* DWARF2 Unwinding doesn't work with exception handling yet.  To make
301    it work, we need to build a libgcc_s.dll, and dcrt0.o should be
302    changed to call __register_frame_info/__deregister_frame_info.  */
303 #define DWARF2_UNWIND_INFO 0
304
305 /* Don't assume anything about the header files.  */
306 #define NO_IMPLICIT_EXTERN_C
307
308 #undef PROFILE_HOOK
309 #define PROFILE_HOOK(LABEL)                                             \
310   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))                  \
311     {                                                                   \
312       emit_call_insn (gen_rtx_CALL (VOIDmode,                           \
313         gen_rtx_MEM (FUNCTION_MODE,                                     \
314                      gen_rtx_SYMBOL_REF (Pmode, "_monstartup")),        \
315         const0_rtx));                                                   \
316     }
317
318 /* Java Native Interface (JNI) methods on Win32 are invoked using the
319    stdcall calling convention.  */
320 #undef MODIFY_JNI_METHOD_CALL
321 #define MODIFY_JNI_METHOD_CALL(MDECL)                                         \
322   build_type_attribute_variant ((MDECL),                                      \
323                                build_tree_list (get_identifier ("stdcall"),   \
324                                                 NULL))
325
326 /* External function declarations.  */
327
328 extern void i386_pe_record_external_function (tree, const char *);
329 extern void i386_pe_declare_function_type (FILE *, const char *, int);
330 extern void i386_pe_record_exported_symbol (const char *, int);
331 extern void i386_pe_file_end (void);
332 extern int i386_pe_dllexport_name_p (const char *);
333 extern int i386_pe_dllimport_name_p (const char *);
334
335 /* For Win32 ABI compatibility */
336 #undef DEFAULT_PCC_STRUCT_RETURN
337 #define DEFAULT_PCC_STRUCT_RETURN 0
338
339 /* MSVC returns aggregate types of up to 8 bytes via registers.
340    See i386.c:ix86_return_in_memory.  */
341 #undef MS_AGGREGATE_RETURN
342 #define MS_AGGREGATE_RETURN 1
343
344 /* No data type wants to be aligned rounder than this.  */
345 #undef  BIGGEST_ALIGNMENT
346 #define BIGGEST_ALIGNMENT 128
347
348 /* Native complier aligns internal doubles in structures on dword boundaries.  */
349 #undef  BIGGEST_FIELD_ALIGNMENT
350 #define BIGGEST_FIELD_ALIGNMENT 64
351
352 /* A bit-field declared as `int' forces `int' alignment for the struct.  */
353 #undef PCC_BITFIELD_TYPE_MATTERS
354 #define PCC_BITFIELD_TYPE_MATTERS 1
355 #define GROUP_BITFIELDS_BY_ALIGN TYPE_NATIVE(rec)
356
357 /* Enable alias attribute support.  */
358 #ifndef SET_ASM_OP
359 #define SET_ASM_OP "\t.set\t"
360 #endif
361 /* This implements the `alias' attribute, keeping any stdcall or
362    fastcall decoration.  */
363 #undef  ASM_OUTPUT_DEF_FROM_DECLS
364 #define ASM_OUTPUT_DEF_FROM_DECLS(STREAM, DECL, TARGET)                 \
365   do                                                                    \
366     {                                                                   \
367       const char *alias;                                                \
368       rtx rtlname = XEXP (DECL_RTL (DECL), 0);                          \
369       if (GET_CODE (rtlname) == SYMBOL_REF)                             \
370         alias = XSTR (rtlname, 0);                                      \
371       else                                                              \
372         abort ();                                                       \
373       if (TREE_CODE (DECL) == FUNCTION_DECL)                            \
374         i386_pe_declare_function_type (STREAM, alias,                   \
375                                        TREE_PUBLIC (DECL));             \
376       ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET));      \
377     } while (0)
378
379 /* GNU as supports weak symbols on PECOFF. */
380 #ifdef HAVE_GAS_WEAK
381 #define ASM_WEAKEN_LABEL(FILE, NAME)  \
382   do                                  \
383     {                                 \
384       fputs ("\t.weak\t", (FILE));    \
385       assemble_name ((FILE), (NAME)); \
386       fputc ('\n', (FILE));           \
387     }                                 \
388   while (0)
389 #endif /* HAVE_GAS_WEAK */
390
391 /* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,
392    but for .jcr section to work we also need crtbegin and crtend
393    objects.  */
394 #define TARGET_USE_JCR_SECTION 0
395
396 /* Decide whether it is safe to use a local alias for a virtual function
397    when constructing thunks.  */
398 #undef TARGET_USE_LOCAL_THUNK_ALIAS_P
399 #define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL))
400
401 #define SUBTARGET_ATTRIBUTE_TABLE \
402   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ \
403   { "selectany", 0, 0, true, false, false, ix86_handle_selectany_attribute }
404
405 #undef TREE
406
407 #ifndef BUFSIZ
408 # undef FILE
409 #endif