OSDN Git Service

* config/i386/i386-protos.h (x86_maybe_negate_const_int): Declare.
[pf3gnuchains/gcc-fork.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, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010
4    Free Software Foundation, Inc.
5
6    This file is part of GCC.
7
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 3, or (at your
11    option) any later version.
12
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.
17
18    You should have received a copy of the GNU General Public License
19    along with GCC; see the file COPYING3.  If not see
20    <http://www.gnu.org/licenses/>.  */
21
22 /* Yes!  We are AIX!  */
23 #define DEFAULT_ABI ABI_AIX
24 #undef  TARGET_AIX
25 #define TARGET_AIX 1
26
27 /* AIX always has a TOC.  */
28 #define TARGET_NO_TOC 0
29 #define TARGET_TOC 1
30 #define FIXED_R2 1
31
32 /* AIX allows r13 to be used in 32-bit mode.  */
33 #define FIXED_R13 0
34
35 /* 32-bit and 64-bit AIX stack boundary is 128.  */
36 #undef  STACK_BOUNDARY
37 #define STACK_BOUNDARY 128
38
39 #undef  TARGET_IEEEQUAD
40 #define TARGET_IEEEQUAD 0
41
42 /* The AIX linker will discard static constructors in object files before
43    collect has a chance to see them, so scan the object files directly.  */
44 #define COLLECT_EXPORT_LIST
45
46 #if HAVE_AS_REF
47 /* Issue assembly directives that create a reference to the given DWARF table
48    identifier label from the current function section.  This is defined to
49    ensure we drag frame frame tables associated with needed function bodies in
50    a link with garbage collection activated.  */
51 #define ASM_OUTPUT_DWARF_TABLE_REF rs6000_aix_asm_output_dwarf_table_ref
52 #endif
53
54 /* Handle #pragma weak and #pragma pack.  */
55 #define HANDLE_SYSV_PRAGMA 1
56
57 /* This is the only version of nm that collect2 can work with.  */
58 #define REAL_NM_FILE_NAME "/usr/ucb/nm"
59
60 #define USER_LABEL_PREFIX  ""
61
62 /* Don't turn -B into -L if the argument specifies a relative file name.  */
63 #define RELATIVE_PREFIX_NOT_LINKDIR
64
65 /* Because of the above, we must have gcc search itself to find libgcc.a.  */
66 #define LINK_LIBGCC_SPECIAL_1
67
68 #define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
69  -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \
70  -brename:free,__wrap_free -brename:__real_free,free \
71  -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \
72  -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \
73  -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \
74  -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \
75  -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \
76 } %{fmudflapth: \
77  -brename:pthread_create,__wrap_pthread_create \
78  -brename:__real_pthread_create,pthread_create \
79  -brename:pthread_join,__wrap_pthread_join \
80  -brename:__real_pthread_join,pthread_join \
81  -brename:pthread_exit,__wrap_pthread_exit \
82  -brename:__real_pthread_exit,pthread_exit \
83 }} %{fmudflap|fmudflapth: \
84  -brename:main,__wrap_main -brename:__real_main,main \
85 }"
86
87 #define MFLIB_SPEC " %{fmudflap: -lmudflap \
88  %{static:%(link_gcc_c_sequence) -lmudflap}} \
89  %{fmudflapth: -lmudflapth -lpthread \
90  %{static:%(link_gcc_c_sequence) -lmudflapth}} "
91
92 /* Names to predefine in the preprocessor for this target machine.  */
93 #define TARGET_OS_AIX_CPP_BUILTINS()            \
94   do                                            \
95     {                                           \
96       builtin_define ("_IBMR2");                \
97       builtin_define ("_POWER");                \
98       builtin_define ("_AIX");                  \
99       builtin_define ("_AIX32");                \
100       builtin_define ("_AIX41");                \
101       builtin_define ("_LONG_LONG");            \
102       if (TARGET_LONG_DOUBLE_128)               \
103         builtin_define ("__LONGDOUBLE128");     \
104       builtin_assert ("system=unix");           \
105       builtin_assert ("system=aix");            \
106     }                                           \
107   while (0)
108
109 /* Define appropriate architecture macros for preprocessor depending on
110    target switches.  */
111
112 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
113    %{ansi: -D_ANSI_C_SOURCE}"
114
115 #define CC1_SPEC "%(cc1_cpu)"
116
117 #undef ASM_DEFAULT_SPEC
118 #define ASM_DEFAULT_SPEC ""
119
120 /* Tell the assembler to assume that all undefined names are external.
121
122    Don't do this until the fixed IBM assembler is more generally available.
123    When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL,
124    ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no
125    longer be needed.  Also, the extern declaration of mcount in 
126    rs6000_xcoff_file_start will no longer be needed.  */
127
128 /* #define ASM_SPEC "-u %(asm_cpu)" */
129
130 /* Default location of syscalls.exp under AIX */
131 #define LINK_SYSCALLS_SPEC "-bI:%R/lib/syscalls.exp"
132
133 /* Default location of libg.exp under AIX */
134 #define LINK_LIBG_SPEC "-bexport:%R/usr/lib/libg.exp"
135
136 /* Define the options for the binder: Start text at 512, align all segments
137    to 512 bytes, and warn if there is text relocation.
138
139    The -bhalt:4 option supposedly changes the level at which ld will abort,
140    but it also suppresses warnings about multiply defined symbols and is
141    used by the AIX cc command.  So we use it here.
142
143    -bnodelcsect undoes a poor choice of default relating to multiply-defined
144    csects.  See AIX documentation for more information about this.
145
146    -bM:SRE tells the linker that the output file is Shared REusable.  Note
147    that to actually build a shared library you will also need to specify an
148    export list with the -Wl,-bE option.  */
149
150 #define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\
151 %{static:-bnso %(link_syscalls) } \
152 %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}"
153
154 /* Profiled library versions are used by linking with special directories.  */
155 #define LIB_SPEC "%{pg:-L%R/lib/profiled -L%R/usr/lib/profiled}\
156 %{p:-L%R/lib/profiled -L%R/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
157
158 /* Static linking with shared libstdc++ requires libsupc++ as well.  */
159 #define LIBSTDCXX_STATIC "-lsupc++"
160
161 /* This now supports a natural alignment mode.  */
162 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
163 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
164   ((TARGET_ALIGN_NATURAL == 0                                           \
165     && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode)     \
166    ? MIN ((COMPUTED), 32)                                               \
167    : (COMPUTED))
168
169 /* AIX increases natural record alignment to doubleword if the first
170    field is an FP double while the FP fields remain word aligned.  */
171 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                   \
172   ((TREE_CODE (STRUCT) == RECORD_TYPE                                   \
173     || TREE_CODE (STRUCT) == UNION_TYPE                                 \
174     || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                           \
175    && TARGET_ALIGN_NATURAL == 0                                         \
176    ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED)      \
177    : MAX ((COMPUTED), (SPECIFIED)))
178
179 /* The AIX ABI isn't explicit on whether aggregates smaller than a
180    word/doubleword should be padded upward or downward.  One could
181    reasonably assume that they follow the normal rules for structure
182    layout treating the parameter area as any other block of memory,
183    then map the reg param area to registers, i.e., pad upward, which
184    is the way IBM Compilers for AIX behave.
185    Setting both of the following defines results in this behavior.  */
186 #define AGGREGATE_PADDING_FIXED 1
187 #define AGGREGATES_PAD_UPWARD_ALWAYS 1
188
189 /* Specify padding for the last element of a block move between
190    registers and memory.  FIRST is nonzero if this is the only
191    element.  */
192 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
193   (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
194
195 /* Indicate that jump tables go in the text section.  */
196
197 #define JUMP_TABLES_IN_TEXT_SECTION 1
198
199 /* Define any extra SPECS that the compiler needs to generate.  */
200 #undef  SUBTARGET_EXTRA_SPECS
201 #define SUBTARGET_EXTRA_SPECS                                           \
202   { "link_syscalls",            LINK_SYSCALLS_SPEC },                   \
203   { "link_libg",                LINK_LIBG_SPEC }
204
205 /* Define cutoff for using external functions to save floating point.  */
206 #define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
207 /* And similarly for general purpose registers.  */
208 #define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32)
209
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
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
223 #define R_LR 65
224
225 #ifdef __64BIT__
226 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                 \
227   do {                                                                  \
228     if ((FS)->regs.reg[2].how == REG_UNSAVED)                           \
229       {                                                                 \
230         unsigned int *insn                                              \
231           = (unsigned int *)                                            \
232             _Unwind_GetGR ((CTX), R_LR);                                \
233         if (*insn == 0xE8410028)                                        \
234           _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40);                 \
235       }                                                                 \
236   } while (0)
237 #else
238 #define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                 \
239   do {                                                                  \
240     if ((FS)->regs.reg[2].how == REG_UNSAVED)                           \
241       {                                                                 \
242         unsigned int *insn                                              \
243           = (unsigned int *)                                            \
244             _Unwind_GetGR ((CTX), R_LR);                                \
245         if (*insn == 0x80410014)                                        \
246           _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 20);                 \
247       }                                                                 \
248   } while (0)
249 #endif
250
251 #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
252
253 /* Print subsidiary information on the compiler version in use.  */
254 #define TARGET_VERSION ;
255
256 /* No version of AIX fully supports AltiVec or 64-bit instructions in
257    32-bit mode.  */
258 #define OS_MISSING_POWERPC64 1
259 #define OS_MISSING_ALTIVEC 1
260
261 /* WINT_TYPE */
262 #define WINT_TYPE "int"