OSDN Git Service

* config/alpha/osf.h (TARGET_OS_CPP_BUILTINS): Rename
[pf3gnuchains/gcc-fork.git] / gcc / config / alpha / osf.h
1 /* Definitions of target machine for GNU compiler, for DEC Alpha on OSF/1.
2    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2001, 2002, 2003
3    Free Software Foundation, Inc.
4    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
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 /* As of OSF 4.0, as can subtract adjacent labels.  */
24
25 #undef TARGET_AS_CAN_SUBTRACT_LABELS
26 #define TARGET_AS_CAN_SUBTRACT_LABELS 1
27
28 /* The GEM libraries for X_float are present, though not used by C.  */
29
30 #undef TARGET_HAS_XFLOATING_LIBS
31 #define TARGET_HAS_XFLOATING_LIBS 1
32
33 /* Names to predefine in the preprocessor for this target machine.  */
34
35 #define TARGET_OS_CPP_BUILTINS()                        \
36     do {                                                \
37         builtin_define_std ("unix");                    \
38         builtin_define_std ("SYSTYPE_BSD");             \
39         builtin_define ("_SYSTYPE_BSD");                \
40         builtin_define ("__osf__");                     \
41         builtin_define ("_LONGLONG");                   \
42         builtin_define ("__PRAGMA_EXTERN_PREFIX");      \
43         builtin_assert ("system=unix");                 \
44         builtin_assert ("system=xpg4");                 \
45         /* Tru64 UNIX V5 has a 16 byte long             \
46            double type and requires __X_FLOAT           \
47            to be defined for <math.h>.  */              \
48         if (LONG_DOUBLE_TYPE_SIZE == 128)               \
49           builtin_define ("__X_FLOAT");                 \
50     } while (0)
51
52 /* Accept DEC C flags for multithreaded programs.  We use _PTHREAD_USE_D4
53    instead of PTHREAD_USE_D4 since both have the same effect and the former
54    doesn't invade the users' namespace.  */
55
56 #undef CPP_SUBTARGET_SPEC
57 #define CPP_SUBTARGET_SPEC \
58 "%{pthread|threads:-D_REENTRANT} %{threads:-D_PTHREAD_USE_D4}"
59
60 /* Under OSF4, -p and -pg require -lprof1, and -lprof1 requires -lpdf.  */
61
62 #define LIB_SPEC \
63 "%{p|pg:-lprof1%{pthread|threads:_r} -lpdf} %{a:-lprof2} \
64  %{threads: -lpthreads} %{pthread|threads: -lpthread -lmach -lexc} -lc"
65
66 /* Pass "-G 8" to ld because Alpha's CC does.  Pass -O3 if we are
67    optimizing, -O1 if we are not.  Pass -S to silence `weak symbol
68    multiply defined' warnings.  Pass -shared, -non_shared or
69    -call_shared as appropriate.  Pass -hidden_symbol so that our
70    constructor and call-frame data structures are not accidentally
71    overridden.  */
72 #define LINK_SPEC  \
73   "-G 8 %{O*:-O3} %{!O*:-O1} -S %{static:-non_shared} \
74    %{!static:%{shared:-shared -hidden_symbol _GLOBAL_*} \
75    %{!shared:-call_shared}} %{pg} %{taso} %{rpath*}"
76
77 #define STARTFILE_SPEC  \
78   "%{!shared:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}"
79
80 #define ENDFILE_SPEC \
81   "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s}"
82
83 #define MD_STARTFILE_PREFIX "/usr/lib/cmplrs/cc/"
84
85 #define ASM_FILE_START(FILE)                                    \
86 {                                                               \
87   alpha_write_verstamp (FILE);                                  \
88   fprintf (FILE, "\t.set noreorder\n");                         \
89   fprintf (FILE, "\t.set volatile\n");                          \
90   fprintf (FILE, "\t.set noat\n");                              \
91   if (TARGET_SUPPORT_ARCH)                                      \
92     fprintf (FILE, "\t.arch %s\n",                              \
93              TARGET_CPU_EV6 ? "ev6"                             \
94              : (TARGET_CPU_EV5                                  \
95                 ? (TARGET_MAX ? "pca56" : TARGET_BWX ? "ev56" : "ev5") \
96                 : "ev4"));                                      \
97                                                                 \
98   ASM_OUTPUT_SOURCE_FILENAME (FILE, main_input_filename);       \
99 }
100
101 /* Tru64 UNIX V5.1 requires a special as flag.  Empty by default.  */
102
103 #define ASM_OLDAS_SPEC ""
104
105 /* In OSF/1 v3.2c, the assembler by default does not output file names which
106    causes mips-tfile to fail.  Passing -g to the assembler fixes this problem.
107    ??? Strictly speaking, we need -g only if the user specifies -g.  Passing
108    it always means that we get slightly larger than necessary object files
109    if the user does not specify -g.  If we don't pass -g, then mips-tfile
110    will need to be fixed to work in this case.  Pass -O0 since some
111    optimization are broken and don't help us anyway.  Pass -nocpp because
112    there's no point in running CPP on our assembler output.  */
113 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GAS) != 0
114 #define ASM_SPEC "%{malpha-as:-g %(asm_oldas) -nocpp %{pg} -O0}"
115 #else
116 #define ASM_SPEC "%{!mgas:-g %(asm_oldas) -nocpp %{pg} -O0}"
117 #endif
118
119 /* Specify to run a post-processor, mips-tfile after the assembler
120    has run to stuff the ecoff debug information into the object file.
121    This is needed because the Alpha assembler provides no way
122    of specifying such information in the assembly file.  */
123
124 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GAS) != 0
125
126 #define ASM_FINAL_SPEC "\
127 %{malpha-as: %{!mno-mips-tfile: \
128         \n mips-tfile %{v*: -v} \
129                 %{K: -I %b.o~} \
130                 %{!K: %{save-temps: -I %b.o~}} \
131                 %{c:%W{o*}%{!o*:-o %b.o}}%{!c:-o %U.o} \
132                 %{.s:%i} %{!.s:%g.s}}}"
133
134 #else
135 #define ASM_FINAL_SPEC "\
136 %{!mgas: %{!mno-mips-tfile: \
137         \n mips-tfile %{v*: -v} \
138                 %{K: -I %b.o~} \
139                 %{!K: %{save-temps: -I %b.o~}} \
140                 %{c:%W{o*}%{!o*:-o %b.o}}%{!c:-o %U.o} \
141                 %{.s:%i} %{!.s:%g.s}}}"
142
143 #endif
144
145 #undef SUBTARGET_EXTRA_SPECS
146 #define SUBTARGET_EXTRA_SPECS { "asm_oldas", ASM_OLDAS_SPEC }
147
148 /* Indicate that we have a stamp.h to use.  */
149 #ifndef CROSS_COMPILE
150 #define HAVE_STAMP_H 1
151 #endif
152
153 /* Attempt to turn on access permissions for the stack.  */
154
155 #define TRANSFER_FROM_TRAMPOLINE                                        \
156 extern void __enable_execute_stack PARAMS ((void *));                   \
157                                                                         \
158 void                                                                    \
159 __enable_execute_stack (addr)                                           \
160      void *addr;                                                        \
161 {                                                                       \
162   extern int mprotect PARAMS ((const void *, size_t, int));             \
163   long size = getpagesize ();                                           \
164   long mask = ~(size-1);                                                \
165   char *page = (char *) (((long) addr) & mask);                         \
166   char *end  = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
167                                                                         \
168   /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */                         \
169   if (mprotect (page, end - page, 7) < 0)                               \
170     perror ("mprotect of trampoline code");                             \
171 }
172
173 /* Digital UNIX V4.0E (1091)/usr/include/sys/types.h 4.3.49.9 1997/08/14 */
174 #define SIZE_TYPE       "long unsigned int"
175 #define PTRDIFF_TYPE    "long int"
176
177 /* The linker will stick __main into the .init section.  */
178 #define HAS_INIT_SECTION
179 #define LD_INIT_SWITCH "-init"
180 #define LD_FINI_SWITCH "-fini"
181
182 /* Select a format to encode pointers in exception handling data.  CODE
183    is 0 for data, 1 for code labels, 2 for function pointers.  GLOBAL is
184    true if the symbol may be affected by dynamic relocations.
185    
186    We really ought to be using the SREL32 relocations that ECOFF has,
187    but no version of the native assembler supports creating such things,
188    and Compaq has no plans to rectify this.  Worse, the dynamic loader
189    cannot handle unaligned relocations, so we have to make sure that
190    things get padded appropriately.  */
191 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)                            \
192   (TARGET_GAS                                                                \
193    ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) \
194    : DW_EH_PE_aligned)
195
196 /* This is how we tell the assembler that a symbol is weak.  */
197
198 #define ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, VALUE)        \
199   do                                                    \
200     {                                                   \
201       (*targetm.asm_out.globalize_label) (FILE, NAME);  \
202       fputs ("\t.weakext\t", FILE);                     \
203       assemble_name (FILE, NAME);                       \
204       if (VALUE)                                        \
205         {                                               \
206           fputc (' ', FILE);                            \
207           assemble_name (FILE, VALUE);                  \
208         }                                               \
209       fputc ('\n', FILE);                               \
210     }                                                   \
211   while (0)
212
213 #define ASM_WEAKEN_LABEL(FILE, NAME) ASM_OUTPUT_WEAK_ALIAS(FILE, NAME, 0)
214
215 /* Handle #pragma weak and #pragma pack.  */
216 #define HANDLE_SYSV_PRAGMA 1
217
218 /* Handle #pragma extern_prefix.  Technically only needed for Tru64 5.x,
219    but easier to manipulate preprocessor bits from here.  */
220 #define HANDLE_PRAGMA_EXTERN_PREFIX 1