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