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