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