OSDN Git Service

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