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