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