OSDN Git Service

* config/i386/freebsd.h (HANDLE_PRAGMA_PACK_PUSH_POP): Define.
[pf3gnuchains/gcc-fork.git] / gcc / config / i386 / freebsd.h
1 /* Definitions of target machine for GNU compiler for Intel 80386
2    running FreeBSD.
3    Copyright (C) 1988, 1992, 1994, 1996, 1997, 1999 Free Software
4    Foundation, Inc.
5    Contributed by Poul-Henning Kamp <phk@login.dkuug.dk>
6
7 This file is part of GNU CC.
8
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
12 any later version.
13
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING.  If not, write to
21 the Free Software Foundation, 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA.  */
23
24 /* This is tested by i386gas.h.  */
25 #define YES_UNDERSCORES
26
27 /* Don't assume anything about the header files. */
28 #define NO_IMPLICIT_EXTERN_C
29
30 #include "i386/gstabs.h"
31
32 /* Get perform_* macros to build libgcc.a.  */
33 #include "i386/perform.h"
34
35 /* This goes away when the math-emulator is fixed */
36 #undef TARGET_DEFAULT
37 #define TARGET_DEFAULT \
38   (MASK_80387 | MASK_IEEE_FP | MASK_FLOAT_RETURNS | MASK_NO_FANCY_MATH_387)
39
40 #undef CPP_PREDEFINES
41 #define CPP_PREDEFINES "-Dunix -Di386 -D__FreeBSD__ -Asystem(unix) -Asystem(FreeBSD) -Acpu(i386) -Amachine(i386)"
42
43 /* Like the default, except no -lg.  */
44 #define LIB_SPEC "%{!shared:%{!pg:-lc}%{pg:-lc_p}}"
45
46 #undef SIZE_TYPE
47 #define SIZE_TYPE "unsigned int"
48
49 #undef PTRDIFF_TYPE
50 #define PTRDIFF_TYPE "int"
51
52 #undef WCHAR_TYPE
53 #define WCHAR_TYPE "int"
54
55 #define WCHAR_UNSIGNED 0
56
57 #undef WCHAR_TYPE_SIZE
58 #define WCHAR_TYPE_SIZE BITS_PER_WORD
59
60 #define HAVE_ATEXIT
61
62 /* Override the default comment-starter of "/".  */
63
64 #undef ASM_COMMENT_START
65 #define ASM_COMMENT_START "#"
66
67 #undef ASM_APP_ON
68 #define ASM_APP_ON "#APP\n"
69
70 #undef ASM_APP_OFF
71 #define ASM_APP_OFF "#NO_APP\n"
72
73 /* FreeBSD using a.out does not support DWARF2 unwinding mechanisms.  */
74 #define DWARF2_UNWIND_INFO 0
75 \f
76 /* The following macros are stolen from i386v4.h */
77 /* These have to be defined to get PIC code correct */
78
79 /* This is how to output an element of a case-vector that is relative.
80    This is only used for PIC code.  See comments by the `casesi' insn in
81    i386.md for an explanation of the expression this outputs. */
82
83 #undef ASM_OUTPUT_ADDR_DIFF_ELT
84 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
85   fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
86
87 /* Indicate that jump tables go in the text section.  This is
88    necessary when compiling PIC code.  */
89
90 #define JUMP_TABLES_IN_TEXT_SECTION 1
91
92 /* Don't default to pcc-struct-return, because in FreeBSD we prefer the
93    superior nature of the older gcc way.  */
94 #define DEFAULT_PCC_STRUCT_RETURN 0
95
96 /* Ensure we the configuration knows our system correctly so we can link with
97    libraries compiled with the native cc. */
98 #undef NO_DOLLAR_IN_LABEL
99 \f
100 /* i386 freebsd still uses old binutils that don't insert nops by default
101    when the .align directive demands to insert extra space in the text
102    segment.  */
103 #undef ASM_OUTPUT_ALIGN
104 #define ASM_OUTPUT_ALIGN(FILE,LOG) \
105   if ((LOG)!=0) fprintf ((FILE), "\t.align %d,0x90\n", (LOG))
106 \f
107 /* Profiling routines, partially copied from i386/osfrose.h.  */
108
109 /* Redefine this to use %eax instead of %edx.  */
110 #undef FUNCTION_PROFILER
111 #define FUNCTION_PROFILER(FILE, LABELNO)  \
112 {                                                                       \
113   if (flag_pic)                                                         \
114     {                                                                   \
115       fprintf (FILE, "\tleal %sP%d@GOTOFF(%%ebx),%%eax\n",              \
116                LPREFIX, (LABELNO));                                     \
117       fprintf (FILE, "\tcall *mcount@GOT(%%ebx)\n");                    \
118     }                                                                   \
119   else                                                                  \
120     {                                                                   \
121       fprintf (FILE, "\tmovl $%sP%d,%%eax\n", LPREFIX, (LABELNO));      \
122       fprintf (FILE, "\tcall mcount\n");                                \
123     }                                                                   \
124 }
125
126 /*
127  * Some imports from svr4.h in support of shared libraries.
128  * Currently, we need the DECLARE_OBJECT_SIZE stuff.
129  */
130
131 /* Define the strings used for the special svr4 .type and .size directives.
132    These strings generally do not vary from one system running svr4 to
133    another, but if a given system (e.g. m88k running svr) needs to use
134    different pseudo-op names for these, they may be overridden in the
135    file which includes this one.  */
136
137 #define TYPE_ASM_OP     ".type"
138 #define SIZE_ASM_OP     ".size"
139
140 /* The following macro defines the format used to output the second
141    operand of the .type assembler directive.  Different svr4 assemblers
142    expect various different forms for this operand.  The one given here
143    is just a default.  You may need to override it in your machine-
144    specific tm.h file (depending upon the particulars of your assembler).  */
145
146 #define TYPE_OPERAND_FMT        "@%s"
147
148 /* Write the extra assembler code needed to declare a function's result.
149    Most svr4 assemblers don't require any special declaration of the
150    result value, but there are exceptions.  */
151
152 #ifndef ASM_DECLARE_RESULT
153 #define ASM_DECLARE_RESULT(FILE, RESULT)
154 #endif
155
156 /* These macros generate the special .type and .size directives which
157    are used to set the corresponding fields of the linker symbol table
158    entries in an ELF object file under SVR4.  These macros also output
159    the starting labels for the relevant functions/objects.  */
160
161 /* Write the extra assembler code needed to declare a function properly.
162    Some svr4 assemblers need to also have something extra said about the
163    function's return value.  We allow for that here.  */
164
165 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)                     \
166   do {                                                                  \
167     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                             \
168     assemble_name (FILE, NAME);                                         \
169     putc (',', FILE);                                                   \
170     fprintf (FILE, TYPE_OPERAND_FMT, "function");                       \
171     putc ('\n', FILE);                                                  \
172     ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL));                      \
173     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
174   } while (0)
175
176 /* Write the extra assembler code needed to declare an object properly.  */
177
178 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)                       \
179   do {                                                                  \
180     fprintf (FILE, "\t%s\t ", TYPE_ASM_OP);                             \
181     assemble_name (FILE, NAME);                                         \
182     putc (',', FILE);                                                   \
183     fprintf (FILE, TYPE_OPERAND_FMT, "object");                         \
184     putc ('\n', FILE);                                                  \
185     size_directive_output = 0;                                          \
186     if (!flag_inhibit_size_directive && DECL_SIZE (DECL))               \
187       {                                                                 \
188         size_directive_output = 1;                                      \
189         fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
190         assemble_name (FILE, NAME);                                     \
191         fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL))); \
192       }                                                                 \
193     ASM_OUTPUT_LABEL(FILE, NAME);                                       \
194   } while (0)
195
196 /* Output the size directive for a decl in rest_of_decl_compilation
197    in the case where we did not do so before the initializer.
198    Once we find the error_mark_node, we know that the value of
199    size_directive_output was set
200    by ASM_DECLARE_OBJECT_NAME when it was run for the same decl.  */
201
202 #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END)        \
203 do {                                                                    \
204      char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0);                  \
205      if (!flag_inhibit_size_directive && DECL_SIZE (DECL)               \
206          && ! AT_END && TOP_LEVEL                                       \
207          && DECL_INITIAL (DECL) == error_mark_node                      \
208          && !size_directive_output)                                     \
209        {                                                                \
210          fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                        \
211          assemble_name (FILE, name);                                    \
212          fprintf (FILE, ",%d\n",  int_size_in_bytes (TREE_TYPE (DECL)));\
213         }                                                               \
214    } while (0)
215
216
217 /* This is how to declare the size of a function.  */
218
219 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
220   do {                                                                  \
221     if (!flag_inhibit_size_directive)                                   \
222       {                                                                 \
223         char label[256];                                                \
224         static int labelno;                                             \
225         labelno++;                                                      \
226         ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno);            \
227         ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno);               \
228         fprintf (FILE, "\t%s\t ", SIZE_ASM_OP);                         \
229         assemble_name (FILE, (FNAME));                                  \
230         fprintf (FILE, ",");                                            \
231         assemble_name (FILE, label);                                    \
232         fprintf (FILE, "-");                                            \
233         assemble_name (FILE, (FNAME));                                  \
234         putc ('\n', FILE);                                              \
235       }                                                                 \
236   } while (0)
237
238 #define ASM_SPEC   " %| %{fpic:-k} %{fPIC:-k}"
239 #define LINK_SPEC \
240   "%{p:%e`-p' not supported; use `-pg' and gprof(1)} \
241    %{shared:-Bshareable} \
242    %{!shared:%{!nostdlib:%{!r:%{!e*:-e start}}} -dc -dp %{static:-Bstatic} \
243    %{pg:-Bstatic} %{Z}} \
244    %{assert*} %{R*}"
245
246 #define STARTFILE_SPEC  \
247   "%{shared:c++rt0.o%s} \
248    %{!shared:%{pg:gcrt0.o%s}%{!pg:%{static:scrt0.o%s}%{!static:crt0.o%s}}}"
249
250 /* Define this so we can compile MS code for use with WINE.  */
251 #define HANDLE_PRAGMA_PACK_PUSH_POP