]>
Commit | Line | Data |
---|---|---|
9ebbca7d GK |
1 | /* Definitions of target machine for GNU compiler, |
2 | for IBM RS/6000 POWER running AIX. | |
85ec4feb | 3 | Copyright (C) 2000-2018 Free Software Foundation, Inc. |
9ebbca7d | 4 | |
5de601cf | 5 | This file is part of GCC. |
9ebbca7d | 6 | |
5de601cf NC |
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 | |
2f83c7d6 | 9 | by the Free Software Foundation; either version 3, or (at your |
5de601cf | 10 | option) any later version. |
9ebbca7d | 11 | |
5de601cf NC |
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. | |
9ebbca7d | 16 | |
5de601cf | 17 | You should have received a copy of the GNU General Public License |
2f83c7d6 NC |
18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
9ebbca7d GK |
20 | |
21 | /* Yes! We are AIX! */ | |
22 | #define DEFAULT_ABI ABI_AIX | |
774b5662 | 23 | #undef TARGET_AIX |
2bfcf297 | 24 | #define TARGET_AIX 1 |
774b5662 | 25 | |
09cff37b NS |
26 | /* System headers are not C++-aware. */ |
27 | #define SYSTEM_IMPLICIT_EXTERN_C 1 | |
28 | ||
78009d9f MM |
29 | /* Linux64.h wants to redefine TARGET_AIX based on -m64, but it can't be used |
30 | in the #if conditional in options-default.h, so provide another macro. */ | |
146d930b | 31 | #undef TARGET_AIX_OS |
78009d9f MM |
32 | #define TARGET_AIX_OS 1 |
33 | ||
774b5662 DE |
34 | /* AIX always has a TOC. */ |
35 | #define TARGET_NO_TOC 0 | |
36 | #define TARGET_TOC 1 | |
37 | #define FIXED_R2 1 | |
38 | ||
39 | /* AIX allows r13 to be used in 32-bit mode. */ | |
40 | #define FIXED_R13 0 | |
41 | ||
4e9d3943 DE |
42 | /* 32-bit and 64-bit AIX stack boundary is 128. */ |
43 | #undef STACK_BOUNDARY | |
44 | #define STACK_BOUNDARY 128 | |
45 | ||
a7790c71 DV |
46 | /* Offset within stack frame to start allocating local variables at. |
47 | If FRAME_GROWS_DOWNWARD, this is the offset to the END of the | |
48 | first local allocated. Otherwise, it is the offset to the BEGINNING | |
49 | of the first local allocated. | |
50 | ||
51 | On the RS/6000, the frame pointer is the same as the stack pointer, | |
52 | except for dynamic allocations. So we start after the fixed area and | |
53 | outgoing parameter area. | |
54 | ||
55 | If the function uses dynamic stack space (CALLS_ALLOCA is set), that | |
56 | space needs to be aligned to STACK_BOUNDARY, i.e. the sum of the | |
57 | sizes of the fixed area and the parameter area must be a multiple of | |
58 | STACK_BOUNDARY. */ | |
59 | ||
2a31c321 RS |
60 | #undef RS6000_STARTING_FRAME_OFFSET |
61 | #define RS6000_STARTING_FRAME_OFFSET \ | |
62 | (cfun->calls_alloca \ | |
63 | ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16) \ | |
64 | : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA)) | |
a7790c71 DV |
65 | |
66 | /* Offset from the stack pointer register to an item dynamically | |
67 | allocated on the stack, e.g., by `alloca'. | |
68 | ||
69 | The default value for this macro is `STACK_POINTER_OFFSET' plus the | |
70 | length of the outgoing arguments. The default is correct for most | |
71 | machines. See `function.c' for details. | |
72 | ||
73 | This value must be a multiple of STACK_BOUNDARY (hard coded in | |
74 | `emit-rtl.c'). */ | |
75 | #undef STACK_DYNAMIC_OFFSET | |
76 | #define STACK_DYNAMIC_OFFSET(FUNDECL) \ | |
a20c5714 RS |
77 | RS6000_ALIGN (crtl->outgoing_args_size.to_constant () \ |
78 | + STACK_POINTER_OFFSET, 16) | |
a7790c71 | 79 | |
602ea4d3 JJ |
80 | #undef TARGET_IEEEQUAD |
81 | #define TARGET_IEEEQUAD 0 | |
774b5662 | 82 | |
73b0ac0b MM |
83 | #undef TARGET_IEEEQUAD_DEFAULT |
84 | #define TARGET_IEEEQUAD_DEFAULT 0 | |
85 | ||
84c041a1 ZW |
86 | /* The AIX linker will discard static constructors in object files before |
87 | collect has a chance to see them, so scan the object files directly. */ | |
88 | #define COLLECT_EXPORT_LIST | |
9ebbca7d | 89 | |
44178879 DE |
90 | /* On AIX, initialisers specified with -binitfini are called in breadth-first |
91 | order. | |
92 | e.g. if a.out depends on lib1.so, the init function for a.out is called before | |
93 | the init function for lib1.so. | |
94 | ||
95 | To ensure global C++ constructors in linked libraries are run before global | |
96 | C++ constructors from the current module, there is additional symbol scanning | |
97 | logic in collect2. | |
98 | ||
99 | The global initialiser/finaliser functions are named __GLOBAL_AIXI_{libname} | |
100 | and __GLOBAL_AIXD_{libname} and are exported from each shared library. | |
101 | ||
102 | collect2 will detect these symbols when they exist in shared libraries that | |
103 | the current program is being linked against. All such initiliser functions | |
104 | will be called prior to the constructors of the current program, and | |
105 | finaliser functions called after destructors. | |
106 | ||
107 | Reference counting generated by collect2 will ensure that constructors are | |
108 | only invoked once in the case of multiple dependencies on a library. | |
109 | ||
110 | -binitfini is still used in parallel to this solution. | |
111 | This handles the case where a library is loaded through dlopen(), and also | |
112 | handles the option -blazy. | |
113 | */ | |
114 | #define COLLECT_SHARED_INIT_FUNC(STREAM, FUNC) \ | |
115 | fprintf ((STREAM), "void %s() {\n\t%s();\n}\n", aix_shared_initname, (FUNC)) | |
116 | #define COLLECT_SHARED_FINI_FUNC(STREAM, FUNC) \ | |
117 | fprintf ((STREAM), "void %s() {\n\t%s();\n}\n", aix_shared_fininame, (FUNC)) | |
118 | ||
636cf8b1 | 119 | #if HAVE_AS_REF |
7e49a4b3 OH |
120 | /* Issue assembly directives that create a reference to the given DWARF table |
121 | identifier label from the current function section. This is defined to | |
026c3cfd | 122 | ensure we drag frame tables associated with needed function bodies in |
7e49a4b3 OH |
123 | a link with garbage collection activated. */ |
124 | #define ASM_OUTPUT_DWARF_TABLE_REF rs6000_aix_asm_output_dwarf_table_ref | |
636cf8b1 | 125 | #endif |
7e49a4b3 | 126 | |
9ebbca7d GK |
127 | /* This is the only version of nm that collect2 can work with. */ |
128 | #define REAL_NM_FILE_NAME "/usr/ucb/nm" | |
129 | ||
2bfcf297 | 130 | #define USER_LABEL_PREFIX "" |
6de9cd9a | 131 | |
9ebbca7d GK |
132 | /* Don't turn -B into -L if the argument specifies a relative file name. */ |
133 | #define RELATIVE_PREFIX_NOT_LINKDIR | |
134 | ||
fc51424c RH |
135 | /* Because of the above, we must have gcc search itself to find libgcc.a. */ |
136 | #define LINK_LIBGCC_SPECIAL_1 | |
9ebbca7d | 137 | |
fc51424c | 138 | /* Names to predefine in the preprocessor for this target machine. */ |
bb904c1a DE |
139 | #define TARGET_OS_AIX_CPP_BUILTINS() \ |
140 | do \ | |
141 | { \ | |
142 | builtin_define ("_IBMR2"); \ | |
143 | builtin_define ("_POWER"); \ | |
7a9a6698 | 144 | builtin_define ("__unix__"); \ |
bb904c1a DE |
145 | builtin_define ("_AIX"); \ |
146 | builtin_define ("_AIX32"); \ | |
147 | builtin_define ("_AIX41"); \ | |
148 | builtin_define ("_LONG_LONG"); \ | |
149 | if (TARGET_LONG_DOUBLE_128) \ | |
150 | builtin_define ("__LONGDOUBLE128"); \ | |
151 | builtin_assert ("system=unix"); \ | |
152 | builtin_assert ("system=aix"); \ | |
f83cab84 DE |
153 | if (TARGET_64BIT) \ |
154 | { \ | |
155 | builtin_define ("__PPC__"); \ | |
156 | builtin_define ("__PPC64__"); \ | |
157 | builtin_define ("__powerpc__"); \ | |
158 | builtin_define ("__powerpc64__"); \ | |
159 | builtin_assert ("cpu=powerpc64"); \ | |
160 | builtin_assert ("machine=powerpc64"); \ | |
161 | } \ | |
162 | else \ | |
163 | { \ | |
164 | builtin_define ("__PPC__"); \ | |
165 | builtin_define ("__powerpc__"); \ | |
166 | builtin_assert ("cpu=powerpc"); \ | |
167 | builtin_assert ("machine=powerpc"); \ | |
168 | } \ | |
bb904c1a | 169 | } \ |
7990b46f | 170 | while (0) |
9ebbca7d | 171 | |
d6121128 AO |
172 | /* Define appropriate architecture macros for preprocessor depending on |
173 | target switches. */ | |
174 | ||
175 | #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\ | |
4c4eb375 | 176 | %{ansi: -D_ANSI_C_SOURCE}" |
2bfcf297 | 177 | |
0eab6840 DE |
178 | #define CC1_SPEC "%(cc1_cpu)" |
179 | ||
f984d8df | 180 | #undef ASM_DEFAULT_SPEC |
2bfcf297 DB |
181 | #define ASM_DEFAULT_SPEC "" |
182 | ||
9ebbca7d GK |
183 | /* Tell the assembler to assume that all undefined names are external. |
184 | ||
185 | Don't do this until the fixed IBM assembler is more generally available. | |
186 | When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL, | |
187 | ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no | |
1bc7c5b6 ZW |
188 | longer be needed. Also, the extern declaration of mcount in |
189 | rs6000_xcoff_file_start will no longer be needed. */ | |
9ebbca7d GK |
190 | |
191 | /* #define ASM_SPEC "-u %(asm_cpu)" */ | |
192 | ||
193 | /* Default location of syscalls.exp under AIX */ | |
7f142d33 | 194 | #define LINK_SYSCALLS_SPEC "-bI:%R/lib/syscalls.exp" |
9ebbca7d GK |
195 | |
196 | /* Default location of libg.exp under AIX */ | |
7f142d33 | 197 | #define LINK_LIBG_SPEC "-bexport:%R/usr/lib/libg.exp" |
9ebbca7d GK |
198 | |
199 | /* Define the options for the binder: Start text at 512, align all segments | |
200 | to 512 bytes, and warn if there is text relocation. | |
201 | ||
a9098fd0 | 202 | The -bhalt:4 option supposedly changes the level at which ld will abort, |
9ebbca7d GK |
203 | but it also suppresses warnings about multiply defined symbols and is |
204 | used by the AIX cc command. So we use it here. | |
205 | ||
206 | -bnodelcsect undoes a poor choice of default relating to multiply-defined | |
207 | csects. See AIX documentation for more information about this. | |
208 | ||
a9098fd0 | 209 | -bM:SRE tells the linker that the output file is Shared REusable. Note |
9ebbca7d GK |
210 | that to actually build a shared library you will also need to specify an |
211 | export list with the -Wl,-bE option. */ | |
212 | ||
213 | #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\ | |
214 | %{static:-bnso %(link_syscalls) } \ | |
215 | %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}" | |
216 | ||
217 | /* Profiled library versions are used by linking with special directories. */ | |
7f142d33 RS |
218 | #define LIB_SPEC "%{pg:-L%R/lib/profiled -L%R/usr/lib/profiled}\ |
219 | %{p:-L%R/lib/profiled -L%R/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc" | |
9ebbca7d | 220 | |
ce75e1dd | 221 | /* Static linking with shared libstdc++ requires libsupc++ as well. */ |
d9d16a19 | 222 | #define LIBSTDCXX_STATIC "supc++" |
ce75e1dd | 223 | |
a3c9585f | 224 | /* This now supports a natural alignment mode. */ |
3b85fe5f | 225 | /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ |
a4cf4b64 | 226 | #define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \ |
dd25a747 | 227 | ((TARGET_ALIGN_NATURAL == 0 \ |
a4cf4b64 | 228 | && TYPE_MODE (strip_array_types (TYPE)) == DFmode) \ |
dd25a747 AM |
229 | ? MIN ((COMPUTED), 32) \ |
230 | : (COMPUTED)) | |
3b85fe5f | 231 | |
2bfcf297 DB |
232 | /* AIX increases natural record alignment to doubleword if the first |
233 | field is an FP double while the FP fields remain word aligned. */ | |
4e9d3943 DE |
234 | #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ |
235 | ((TREE_CODE (STRUCT) == RECORD_TYPE \ | |
236 | || TREE_CODE (STRUCT) == UNION_TYPE \ | |
237 | || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ | |
238 | && TARGET_ALIGN_NATURAL == 0 \ | |
239 | ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ | |
2bfcf297 DB |
240 | : MAX ((COMPUTED), (SPECIFIED))) |
241 | ||
8d05ebaa DE |
242 | /* The AIX ABI isn't explicit on whether aggregates smaller than a |
243 | word/doubleword should be padded upward or downward. One could | |
244 | reasonably assume that they follow the normal rules for structure | |
245 | layout treating the parameter area as any other block of memory, | |
246 | then map the reg param area to registers, i.e., pad upward, which | |
247 | is the way IBM Compilers for AIX behave. | |
368ebcd6 | 248 | Setting both of the following defines results in this behavior. */ |
8d05ebaa DE |
249 | #define AGGREGATE_PADDING_FIXED 1 |
250 | #define AGGREGATES_PAD_UPWARD_ALWAYS 1 | |
251 | ||
8d05ebaa DE |
252 | /* Specify padding for the last element of a block move between |
253 | registers and memory. FIRST is nonzero if this is the only | |
254 | element. */ | |
255 | #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \ | |
76b0cbf8 | 256 | (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE)) |
8d05ebaa | 257 | |
9ebbca7d GK |
258 | /* Indicate that jump tables go in the text section. */ |
259 | ||
260 | #define JUMP_TABLES_IN_TEXT_SECTION 1 | |
261 | ||
9ebbca7d GK |
262 | /* Define any extra SPECS that the compiler needs to generate. */ |
263 | #undef SUBTARGET_EXTRA_SPECS | |
264 | #define SUBTARGET_EXTRA_SPECS \ | |
265 | { "link_syscalls", LINK_SYSCALLS_SPEC }, \ | |
266 | { "link_libg", LINK_LIBG_SPEC } | |
267 | ||
411707f4 | 268 | #define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) |
b91da81f | 269 | |
66188a7e GK |
270 | /* No version of AIX fully supports AltiVec or 64-bit instructions in |
271 | 32-bit mode. */ | |
272 | #define OS_MISSING_POWERPC64 1 | |
273 | #define OS_MISSING_ALTIVEC 1 | |
466db3c1 DE |
274 | |
275 | /* WINT_TYPE */ | |
276 | #define WINT_TYPE "int" | |
39acb18f EB |
277 | |
278 | /* Static stack checking is supported by means of probes. */ | |
279 | #define STACK_CHECK_STATIC_BUILTIN 1 | |
3d36d470 UW |
280 | |
281 | /* Use standard DWARF numbering for DWARF debugging information. */ | |
282 | #define RS6000_USE_DWARF_NUMBERING | |
283 |