OSDN Git Service

* config/i386/i386.c (ix86_expand_setcc): Don't use method 0
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / win32.h
1 /* Operating system specific defines to be used when targeting GCC for
2    hosting on Windows NT 3.x, using a Unix style C library and tools,
3    as distinct from winnt.h, which is used to build GCC for use with a
4    windows style library and tool set and uses the Microsoft tools.
5    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
6    Free Software Foundation, Inc.
7
8 This file is part of GNU CC.
9
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING.  If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 #define YES_UNDERSCORES
26
27 /* Enable parsing of #pragma pack(push,<n>) and #pragma pack(pop).  */
28 #define HANDLE_PRAGMA_PACK_PUSH_POP 1
29
30 #define DBX_DEBUGGING_INFO 
31 #define SDB_DEBUGGING_INFO 
32 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
33
34 #include "i386/gas.h"
35 #include "dbxcoff.h"
36
37 /* Augment TARGET_SWITCHES with the cygwin/win32 options. */
38 #define MASK_WIN32 0x40000000 /* Use -lming32 interface */
39 #define MASK_CYGWIN  0x20000000 /* Use -lcygwin interface */
40 #define MASK_WINDOWS 0x10000000 /* Use windows interface */
41 #define MASK_DLL     0x08000000 /* Use dll interface    */
42 #define MASK_NOP_FUN_DLLIMPORT 0x20000 /* Ignore dllimport for functions */
43
44 #define TARGET_WIN32             (target_flags & MASK_WIN32)
45 #define TARGET_CYGWIN            (target_flags & MASK_CYGWIN)
46 #define TARGET_WINDOWS           (target_flags & MASK_WINDOWS)
47 #define TARGET_DLL               (target_flags & MASK_DLL)
48 #define TARGET_NOP_FUN_DLLIMPORT (target_flags & MASK_NOP_FUN_DLLIMPORT)
49
50 #undef  SUBTARGET_SWITCHES
51 #define SUBTARGET_SWITCHES                                              \
52     { "win32",                  MASK_WIN32,                             \
53       N_("Use Mingw32 interface") },                                    \
54     { "cygwin",                 MASK_CYGWIN,                            \
55       N_("Use Cygwin interface")  },                                    \
56     { "windows",                MASK_WINDOWS,                           \
57       N_("Use bare Windows interface") },                               \
58     { "dll",                    MASK_DLL,                               \
59       N_("Generate code for a DLL") },                                  \
60     { "nop-fun-dllimport",      MASK_NOP_FUN_DLLIMPORT,                 \
61       N_("Ignore dllimport for functions") },                           \
62     { "no-nop-fun-dllimport",   MASK_NOP_FUN_DLLIMPORT, "" },
63
64
65 #undef CPP_PREDEFINES
66 #define CPP_PREDEFINES "-D_WIN32 -DWINNT -D_X86_=1 \
67   -D__stdcall=__attribute__((__stdcall__)) \
68   -D__cdecl=__attribute__((__cdecl__)) \
69   -Asystem=winnt"
70
71 #undef STARTFILE_SPEC
72
73 #define STARTFILE_SPEC "%{mdll:dllcrt0%O%s} %{!mdll: %{!mcygwin:mcrt0%O%s} \
74                         %{mcygwin:crt0%O%s} %{pg:gcrt0%O%s}}"
75
76 #undef CPP_SPEC
77 #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
78   %{!mcygwin:-iwithprefixbefore include/mingw32 -D__MINGW32__}    \
79   %{mcygwin:-D__CYGWIN32__ -D__CYGWIN__}"
80
81 /* We have to dynamic link to get to the system DLLs.  All of libc, libm and
82    the Unix stuff is in cygwin.dll.  The import library is called
83    'libcygwin.a'.  For Windows applications, include more libraries, but
84    always include kernel32.  We'd like to specific subsystem windows to
85    ld, but that doesn't work just yet.  */
86
87 #undef LIB_SPEC
88 #define LIB_SPEC "%{pg:-lgmon}                                          \
89                   %{!mcygwin:-lmingw32 -lmoldname -lmsvcrt -lcrtdll}    \
90                   %{mcygwin:-lcygwin} %{mwindows:-luser32 -lgdi32 -lcomdlg32} \
91                   -lkernel32 -ladvapi32 -lshell32"
92
93 #define LINK_SPEC "%{mwindows:--subsystem windows} \
94   %{mdll:--dll -e _DllMainCRTStartup@12}"
95
96 #define SIZE_TYPE "unsigned int"
97 #define PTRDIFF_TYPE "int"
98 #define WCHAR_UNSIGNED 1
99 #define WCHAR_TYPE_SIZE 16
100 #define WCHAR_TYPE "short unsigned int"
101 /* Currently we do not have the atexit() function,
102    so take that from libgcc2.c */
103
104 #define NEED_ATEXIT 1
105
106 #undef EXTRA_SECTIONS
107 #define EXTRA_SECTIONS in_ctor, in_dtor
108
109 #undef EXTRA_SECTION_FUNCTIONS
110 #define EXTRA_SECTION_FUNCTIONS                                 \
111   CTOR_SECTION_FUNCTION                                         \
112   DTOR_SECTION_FUNCTION
113
114 #define CTOR_SECTION_FUNCTION                                   \
115 void                                                            \
116 ctor_section ()                                                 \
117 {                                                               \
118   if (in_section != in_ctor)                                    \
119     {                                                           \
120       fprintf (asm_out_file, "\t.section .ctor\n");             \
121       in_section = in_ctor;                                     \
122     }                                                           \
123 }
124
125 #define DTOR_SECTION_FUNCTION                                   \
126 void                                                            \
127 dtor_section ()                                                 \
128 {                                                               \
129   if (in_section != in_dtor)                                    \
130     {                                                           \
131       fprintf (asm_out_file, "\t.section .dtor\n");             \
132       in_section = in_dtor;                                     \
133     }                                                           \
134 }
135
136 #define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)       \
137   do {                                          \
138     ctor_section ();                            \
139     fputs (ASM_LONG, FILE);                     \
140     assemble_name (FILE, NAME);                 \
141     fprintf (FILE, "\n");                       \
142   } while (0)
143
144 #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)        \
145   do {                                          \
146     dtor_section ();                            \
147     fputs (ASM_LONG, FILE);                     \
148     assemble_name (FILE, NAME);                 \
149     fprintf (FILE, "\n");                       \
150   } while (0)
151
152 /* Define this macro if references to a symbol must be treated
153    differently depending on something about the variable or
154    function named by the symbol (such as what section it is in).
155
156    On i386, if using PIC, mark a SYMBOL_REF for a non-global symbol
157    so that we may access it directly in the GOT.
158
159    On i386 running Windows NT, modify the assembler name with a suffix 
160    consisting of an atsign (@) followed by string of digits that represents
161    the number of bytes of arguments passed to the function, if it has the 
162    attribute STDCALL. */
163
164 #ifdef ENCODE_SECTION_INFO
165 #undef ENCODE_SECTION_INFO
166 #define ENCODE_SECTION_INFO(DECL)                                       \
167 do                                                                      \
168   {                                                                     \
169     if (flag_pic)                                                       \
170       {                                                                 \
171         rtx rtl = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'            \
172                    ? TREE_CST_RTL (DECL) : DECL_RTL (DECL));            \
173         SYMBOL_REF_FLAG (XEXP (rtl, 0))                                 \
174           = (TREE_CODE_CLASS (TREE_CODE (DECL)) != 'd'                  \
175              || ! TREE_PUBLIC (DECL));                                  \
176       }                                                                 \
177     if (TREE_CODE (DECL) == FUNCTION_DECL)                              \
178       if (lookup_attribute ("stdcall",                                  \
179                             TYPE_ATTRIBUTES (TREE_TYPE (DECL))))        \
180         XEXP (DECL_RTL (DECL), 0) =                                     \
181           gen_rtx (SYMBOL_REF, Pmode, gen_stdcall_suffix (DECL));       \
182   }                                                                     \
183 while (0)
184 #endif
185
186 /* This macro gets just the user-specified name
187    out of the string in a SYMBOL_REF.  Discard
188    trailing @[NUM] encoded by ENCODE_SECTION_INFO. 
189    Do we need the stripping of leading '*'?  */
190 #undef  STRIP_NAME_ENCODING
191 #define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME)                            \
192 do {                                                                    \
193   const char *_p;                                                       \
194   const char *_name = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'));      \
195   for (_p = _name; *_p && *_p != '@'; ++_p)                             \
196     ;                                                                   \
197   if (*_p == '@')                                                       \
198     {                                                                   \
199       int _len = _p - _name;                                            \
200       char *_new_name = (char *) alloca (_len + 1);                     \
201       strncpy (_new_name, _name, _len);                                 \
202       _new_name[_len] = '\0';                                           \
203       (VAR) = _new_name;                                                \
204     }                                                                   \
205   else                                                                  \
206     (VAR) = _name;                                                      \
207 } while (0)
208       
209
210 /* Emit code to check the stack when allocating more that 4000
211    bytes in one go. */
212
213 #define CHECK_STACK_LIMIT 4000
214
215 /* By default, target has a 80387, uses IEEE compatible arithmetic,
216    and returns float values in the 387 and needs stack probes */
217 #undef TARGET_SUBTARGET_DEFAULT
218
219 #define TARGET_SUBTARGET_DEFAULT \
220    (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_STACK_PROBE) 
221
222 /* This is how to output an assembler line
223    that says to advance the location counter
224    to a multiple of 2**LOG bytes.  */
225
226 #undef ASM_OUTPUT_ALIGN
227 #define ASM_OUTPUT_ALIGN(FILE,LOG)      \
228     if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1<<(LOG))
229
230 /* Define this macro if in some cases global symbols from one translation
231    unit may not be bound to undefined symbols in another translation unit
232    without user intervention.  For instance, under Microsoft Windows
233    symbols must be explicitly imported from shared libraries (DLLs).  */
234 #define MULTIPLE_SYMBOL_SPACES
235
236 #define UNIQUE_SECTION_P(DECL) DECL_ONE_ONLY (DECL)
237 extern void i386_pe_unique_section ();
238 #define UNIQUE_SECTION(DECL,RELOC) i386_pe_unique_section (DECL, RELOC)
239
240 #define SUPPORTS_ONE_ONLY 1
241
242 /* A C statement to output something to the assembler file to switch to section
243    NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
244    NULL_TREE.  Some target formats do not support arbitrary sections.  Do not
245    define this macro in such cases.  */
246 #undef ASM_OUTPUT_SECTION_NAME
247 #define ASM_OUTPUT_SECTION_NAME(STREAM, DECL, NAME, RELOC)      \
248 do {                                                            \
249   if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL)              \
250     fprintf (STREAM, "\t.section %s,\"x\"\n", (NAME));          \
251   else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC))       \
252     fprintf (STREAM, "\t.section %s,\"\"\n", (NAME));           \
253   else                                                          \
254     fprintf (STREAM, "\t.section %s,\"w\"\n", (NAME));          \
255   /* Functions may have been compiled at various levels of      \
256      optimization so we can't use `same_size' here.  Instead,   \
257      have the linker pick one.  */                              \
258   if ((DECL) && DECL_ONE_ONLY (DECL))                           \
259     fprintf (STREAM, "\t.linkonce %s\n",                        \
260              TREE_CODE (DECL) == FUNCTION_DECL                  \
261              ? "discard" : "same_size");                        \
262 } while (0)
263
264 #undef ASM_COMMENT_START
265 #define ASM_COMMENT_START " #"
266
267 /* DWARF2 Unwinding doesn't work with exception handling yet. */
268 #define DWARF2_UNWIND_INFO 0
269
270 /* Don't assume anything about the header files. */
271 #define NO_IMPLICIT_EXTERN_C
272
273 #define SUBTARGET_PROLOGUE                                              \
274   if (profile_flag                                                      \
275       && MAIN_NAME_P (DECL_NAME (current_function_decl))                \
276      {                                                                  \
277       rtx xops[1];                                                      \
278       xops[0] = gen_rtx_MEM (FUNCTION_MODE,                             \
279                          gen_rtx (SYMBOL_REF, Pmode, "_monstartup"));   \
280       emit_call_insn (gen_rtx (CALL, VOIDmode, xops[0], const0_rtx));   \
281      }