OSDN Git Service

Update FSF address.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / aix.h
1 /* Definitions of target machine for GNU compiler,
2    for IBM RS/6000 POWER running AIX.
3    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
4    Free Software Foundation, Inc.
5
6    This file is part of GCC.
7
8    GCC is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published
10    by the Free Software Foundation; either version 2, or (at your
11    option) any later version.
12
13    GCC is distributed in the hope that it will be useful, but WITHOUT
14    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16    License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with GCC; see the file COPYING.  If not, write to the
20    Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21    MA 02110-1301, USA.  */
22
23 /* Yes!  We are AIX!  */
24 #define DEFAULT_ABI ABI_AIX
25 #undef  TARGET_AIX
26 #define TARGET_AIX 1
27
28 /* AIX always has a TOC.  */
29 #define TARGET_NO_TOC 0
30 #define TARGET_TOC 1
31 #define FIXED_R2 1
32
33 /* AIX allows r13 to be used in 32-bit mode.  */
34 #define FIXED_R13 0
35
36 /* AIX does not support Altivec.  */
37 #undef  TARGET_ALTIVEC
38 #define TARGET_ALTIVEC 0
39 #undef  TARGET_ALTIVEC_ABI
40 #define TARGET_ALTIVEC_ABI 0
41
42 /* The AIX linker will discard static constructors in object files before
43    collect has a chance to see them, so scan the object files directly.  */
44 #define COLLECT_EXPORT_LIST
45
46 /* Handle #pragma weak and #pragma pack.  */
47 #define HANDLE_SYSV_PRAGMA 1
48
49 /* This is the only version of nm that collect2 can work with.  */
50 #define REAL_NM_FILE_NAME "/usr/ucb/nm"
51
52 #define USER_LABEL_PREFIX  ""
53
54 /* Don't turn -B into -L if the argument specifies a relative file name.  */
55 #define RELATIVE_PREFIX_NOT_LINKDIR
56
57 /* Because of the above, we must have gcc search itself to find libgcc.a.  */
58 #define LINK_LIBGCC_SPECIAL_1
59
60 #define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
61  -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \
62  -brename:free,__wrap_free -brename:__real_free,free \
63  -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \
64  -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \
65  -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \
66  -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \
67  -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \
68 } %{fmudflapth: \
69  -brename:pthread_create,__wrap_pthread_create \
70  -brename:__real_pthread_create,pthread_create \
71  -brename:pthread_join,__wrap_pthread_join \
72  -brename:__real_pthread_join,pthread_join \
73  -brename:pthread_exit,__wrap_pthread_exit \
74  -brename:__real_pthread_exit,pthread_exit \
75 }} %{fmudflap|fmudflapth: \
76  -brename:main,__wrap_main -brename:__real_main,main \
77 }"
78
79 #define MFLIB_SPEC " %{fmudflap: -lmudflap \
80  %{static:%(link_gcc_c_sequence) -lmudflap}} \
81  %{fmudflapth: -lmudflapth -lpthread \
82  %{static:%(link_gcc_c_sequence) -lmudflapth}} "
83
84 /* Names to predefine in the preprocessor for this target machine.  */
85 #define TARGET_OS_AIX_CPP_BUILTINS()            \
86   do                                            \
87     {                                           \
88       builtin_define ("_IBMR2");                \
89       builtin_define ("_POWER");                \
90       builtin_define ("_AIX");                  \
91       builtin_define ("_AIX32");                \
92       builtin_define ("_AIX41");                \
93       builtin_define ("_LONG_LONG");            \
94       if (TARGET_LONG_DOUBLE_128)               \
95         builtin_define ("__LONGDOUBLE128");     \
96       builtin_assert ("system=unix");           \
97       builtin_assert ("system=aix");            \
98     }                                           \
99   while (0)
100
101 /* Define appropriate architecture macros for preprocessor depending on
102    target switches.  */
103
104 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
105    %{ansi: -D_ANSI_C_SOURCE}"
106
107 #undef ASM_DEFAULT_SPEC
108 #define ASM_DEFAULT_SPEC ""
109
110 /* Tell the assembler to assume that all undefined names are external.
111
112    Don't do this until the fixed IBM assembler is more generally available.
113    When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL,
114    ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no
115    longer be needed.  Also, the extern declaration of mcount in 
116    rs6000_xcoff_file_start will no longer be needed.  */
117
118 /* #define ASM_SPEC "-u %(asm_cpu)" */
119
120 /* Default location of syscalls.exp under AIX */
121 #ifndef CROSS_COMPILE
122 #define LINK_SYSCALLS_SPEC "-bI:/lib/syscalls.exp"
123 #else
124 #define LINK_SYSCALLS_SPEC ""
125 #endif
126
127 /* Default location of libg.exp under AIX */
128 #ifndef CROSS_COMPILE
129 #define LINK_LIBG_SPEC "-bexport:/usr/lib/libg.exp"
130 #else
131 #define LINK_LIBG_SPEC ""
132 #endif
133
134 /* Define the options for the binder: Start text at 512, align all segments
135    to 512 bytes, and warn if there is text relocation.
136
137    The -bhalt:4 option supposedly changes the level at which ld will abort,
138    but it also suppresses warnings about multiply defined symbols and is
139    used by the AIX cc command.  So we use it here.
140
141    -bnodelcsect undoes a poor choice of default relating to multiply-defined
142    csects.  See AIX documentation for more information about this.
143
144    -bM:SRE tells the linker that the output file is Shared REusable.  Note
145    that to actually build a shared library you will also need to specify an
146    export list with the -Wl,-bE option.  */
147
148 #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\
149 %{static:-bnso %(link_syscalls) } \
150 %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}"
151
152 /* Profiled library versions are used by linking with special directories.  */
153 #define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\
154 %{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
155
156 /* This now supports a natural alignment mode.  */
157 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
158 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
159   (TARGET_ALIGN_NATURAL ? (COMPUTED) : \
160   (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
161               ? get_inner_array_type (FIELD) \
162               : TREE_TYPE (FIELD)) == DFmode \
163    ? MIN ((COMPUTED), 32) : (COMPUTED)))
164
165 /* AIX increases natural record alignment to doubleword if the first
166    field is an FP double while the FP fields remain word aligned.  */
167 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                           \
168   ((TREE_CODE (STRUCT) == RECORD_TYPE                                           \
169     || TREE_CODE (STRUCT) == UNION_TYPE                                         \
170     || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                                   \
171    && TARGET_ALIGN_NATURAL == 0                                                 \
172    ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED)              \
173    : MAX ((COMPUTED), (SPECIFIED)))
174
175 /* The AIX ABI isn't explicit on whether aggregates smaller than a
176    word/doubleword should be padded upward or downward.  One could
177    reasonably assume that they follow the normal rules for structure
178    layout treating the parameter area as any other block of memory,
179    then map the reg param area to registers, i.e., pad upward, which
180    is the way IBM Compilers for AIX behave.
181    Setting both of the following defines results in this behavior.  */
182 #define AGGREGATE_PADDING_FIXED 1
183 #define AGGREGATES_PAD_UPWARD_ALWAYS 1
184
185 /* Specify padding for the last element of a block move between
186    registers and memory.  FIRST is nonzero if this is the only
187    element.  */
188 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
189   (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
190
191 /* Indicate that jump tables go in the text section.  */
192
193 #define JUMP_TABLES_IN_TEXT_SECTION 1
194
195 /* Define any extra SPECS that the compiler needs to generate.  */
196 #undef  SUBTARGET_EXTRA_SPECS
197 #define SUBTARGET_EXTRA_SPECS                                           \
198   { "link_syscalls",            LINK_SYSCALLS_SPEC },                   \
199   { "link_libg",                LINK_LIBG_SPEC }
200
201 /* Define cutoff for using external functions to save floating point.  */
202 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
203
204 /* __throw will restore its own return address to be the same as the
205    return address of the function that the throw is being made to.
206    This is unfortunate, because we want to check the original
207    return address to see if we need to restore the TOC.
208    So we have to squirrel it away with this.  */
209 #define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
210
211 /* If the current unwind info (FS) does not contain explicit info
212    saving R2, then we have to do a minor amount of code reading to
213    figure out if it was saved.  The big problem here is that the
214    code that does the save/restore is generated by the linker, so
215    we have no good way to determine at compile time what to do.  */
216
217 #ifdef __64BIT__
218 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                 \
219   do {                                                                  \
220     if ((FS)->regs.reg[2].how == REG_UNSAVED)                           \
221       {                                                                 \
222         unsigned int *insn                                              \
223           = (unsigned int *)                                            \
224             _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);                \
225         if (*insn == 0xE8410028)                                        \
226           _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40);                 \
227       }                                                                 \
228   } while (0)
229 #else
230 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                 \
231   do {                                                                  \
232     if ((FS)->regs.reg[2].how == REG_UNSAVED)                           \
233       {                                                                 \
234         unsigned int *insn                                              \
235           = (unsigned int *)                                            \
236             _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);                \
237         if (*insn == 0x80410014)                                        \
238           _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 20);                 \
239       }                                                                 \
240   } while (0)
241 #endif
242
243 #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
244
245 /* Print subsidiary information on the compiler version in use.  */
246 #define TARGET_VERSION ;
247
248 /* No version of AIX fully supports AltiVec or 64-bit instructions in
249    32-bit mode.  */
250 #define OS_MISSING_POWERPC64 1
251 #define OS_MISSING_ALTIVEC 1
252
253 /* WINT_TYPE */
254 #define WINT_TYPE "int"