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