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