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