Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / gcc / config / alpha / osf.h
1 /* Definitions of target machine for GNU compiler, for DEC Alpha on OSF/1.
2    Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
3    Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 /* As of OSF 4.0, as can subtract adjacent labels.  */
23
24 #undef TARGET_AS_CAN_SUBTRACT_LABELS
25 #define TARGET_AS_CAN_SUBTRACT_LABELS 1
26
27 /* Names to predefine in the preprocessor for this target machine.  */
28
29 #define CPP_PREDEFINES "\
30 -Dunix -D__osf__ -D_LONGLONG -DSYSTYPE_BSD \
31 -D_SYSTYPE_BSD -Asystem(unix) -Asystem(xpg4)"
32
33 /* Accept DEC C flags for multithreaded programs.  We use _PTHREAD_USE_D4
34    instead of PTHREAD_USE_D4 since both have the same effect and the former
35    doesn't invade the users' namespace.  */
36
37 #undef CPP_SUBTARGET_SPEC
38 #define CPP_SUBTARGET_SPEC \
39 "%{pthread|threads:-D_REENTRANT} %{threads:-D_PTHREAD_USE_D4}"
40
41 /* Under OSF4, -p and -pg require -lprof1, and -lprof1 requires -lpdf.  */
42
43 #define LIB_SPEC \
44 "%{p|pg:-lprof1%{pthread|threads:_r} -lpdf} %{a:-lprof2} \
45  %{threads: -lpthreads} %{pthread|threads: -lpthread -lmach -lexc} -lc"
46
47 /* Pass "-G 8" to ld because Alpha's CC does.  Pass -O3 if we are
48    optimizing, -O1 if we are not.  Pass -shared, -non_shared or
49    -call_shared as appropriate.  Also pass -pg.  */
50 #define LINK_SPEC  \
51   "-G 8 %{O*:-O3} %{!O*:-O1} %{static:-non_shared} \
52    %{!static:%{shared:-shared} %{!shared:-call_shared}} %{pg} %{taso} \
53    %{rpath*}"
54
55 #define STARTFILE_SPEC  \
56   "%{!shared:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}"
57
58 #define MD_STARTFILE_PREFIX "/usr/lib/cmplrs/cc/"
59
60 #define ASM_FILE_START(FILE)                                    \
61 {                                                               \
62   alpha_write_verstamp (FILE);                                  \
63   fprintf (FILE, "\t.set noreorder\n");                         \
64   fprintf (FILE, "\t.set volatile\n");                          \
65   fprintf (FILE, "\t.set noat\n");                              \
66   if (TARGET_SUPPORT_ARCH)                                      \
67     fprintf (FILE, "\t.arch %s\n",                              \
68              alpha_cpu == PROCESSOR_EV6 ? "ev6"                 \
69              : (alpha_cpu == PROCESSOR_EV5                      \
70                 ? (TARGET_MAX ? "pca56" : TARGET_BWX ? "ev56" : "ev5") \
71                 : "ev4"));                                      \
72                                                                 \
73   ASM_OUTPUT_SOURCE_FILENAME (FILE, main_input_filename);       \
74 }
75
76 /* No point in running CPP on our assembler output.  */
77 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GAS) != 0
78 /* Don't pass -g to GNU as, because some versions don't accept this option.  */
79 #define ASM_SPEC "%{malpha-as:-g} -nocpp %{pg}"
80 #else
81 /* In OSF/1 v3.2c, the assembler by default does not output file names which
82    causes mips-tfile to fail.  Passing -g to the assembler fixes this problem.
83    ??? Strictly speaking, we need -g only if the user specifies -g.  Passing
84    it always means that we get slightly larger than necessary object files
85    if the user does not specify -g.  If we don't pass -g, then mips-tfile
86    will need to be fixed to work in this case.  Pass -O0 since some
87    optimization are broken and don't help us anyway.  */
88 #define ASM_SPEC "%{!mgas:-g} -nocpp %{pg} -O0"
89 #endif
90
91 /* Specify to run a post-processor, mips-tfile after the assembler
92    has run to stuff the ecoff debug information into the object file.
93    This is needed because the Alpha assembler provides no way
94    of specifying such information in the assembly file.  */
95
96 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GAS) != 0
97
98 #define ASM_FINAL_SPEC "\
99 %{malpha-as: %{!mno-mips-tfile: \
100         \n mips-tfile %{v*: -v} \
101                 %{K: -I %b.o~} \
102                 %{!K: %{save-temps: -I %b.o~}} \
103                 %{c:%W{o*}%{!o*:-o %b.o}}%{!c:-o %U.o} \
104                 %{.s:%i} %{!.s:%g.s}}}"
105
106 #else
107 #define ASM_FINAL_SPEC "\
108 %{!mgas: %{!mno-mips-tfile: \
109         \n mips-tfile %{v*: -v} \
110                 %{K: -I %b.o~} \
111                 %{!K: %{save-temps: -I %b.o~}} \
112                 %{c:%W{o*}%{!o*:-o %b.o}}%{!c:-o %U.o} \
113                 %{.s:%i} %{!.s:%g.s}}}"
114
115 #endif
116
117 /* Indicate that we have a stamp.h to use.  */
118 #ifndef CROSS_COMPILE
119 #define HAVE_STAMP_H 1
120 #endif
121
122 /* Attempt to turn on access permissions for the stack.  */
123
124 #define TRANSFER_FROM_TRAMPOLINE                                        \
125 void                                                                    \
126 __enable_execute_stack (addr)                                           \
127      void *addr;                                                        \
128 {                                                                       \
129   long size = getpagesize ();                                           \
130   long mask = ~(size-1);                                                \
131   char *page = (char *) (((long) addr) & mask);                         \
132   char *end  = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
133                                                                         \
134   /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */                         \
135   if (mprotect (page, end - page, 7) < 0)                               \
136     perror ("mprotect of trampoline code");                             \
137 }