190075Sobrien/* Definitions of target machine for GNU compiler, 290075Sobrien for IBM RS/6000 POWER running AIX. 3169689Skan Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 4169689Skan Free Software Foundation, Inc. 590075Sobrien 6132718Skan This file is part of GCC. 790075Sobrien 8132718Skan GCC is free software; you can redistribute it and/or modify it 9132718Skan under the terms of the GNU General Public License as published 10132718Skan by the Free Software Foundation; either version 2, or (at your 11132718Skan option) any later version. 1290075Sobrien 13132718Skan GCC is distributed in the hope that it will be useful, but WITHOUT 14132718Skan ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15132718Skan or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 16132718Skan License for more details. 1790075Sobrien 18132718Skan You should have received a copy of the GNU General Public License 19132718Skan along with GCC; see the file COPYING. If not, write to the 20169689Skan Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, 21169689Skan MA 02110-1301, USA. */ 2290075Sobrien 2390075Sobrien/* Yes! We are AIX! */ 2490075Sobrien#define DEFAULT_ABI ABI_AIX 25117395Skan#undef TARGET_AIX 2690075Sobrien#define TARGET_AIX 1 27117395Skan 28117395Skan/* AIX always has a TOC. */ 29117395Skan#define TARGET_NO_TOC 0 30117395Skan#define TARGET_TOC 1 31117395Skan#define FIXED_R2 1 32117395Skan 33117395Skan/* AIX allows r13 to be used in 32-bit mode. */ 34117395Skan#define FIXED_R13 0 35117395Skan 36169689Skan/* 32-bit and 64-bit AIX stack boundary is 128. */ 37169689Skan#undef STACK_BOUNDARY 38169689Skan#define STACK_BOUNDARY 128 39169689Skan 40117395Skan/* AIX does not support Altivec. */ 41117395Skan#undef TARGET_ALTIVEC 42117395Skan#define TARGET_ALTIVEC 0 43117395Skan#undef TARGET_ALTIVEC_ABI 44117395Skan#define TARGET_ALTIVEC_ABI 0 45169689Skan#undef TARGET_IEEEQUAD 46169689Skan#define TARGET_IEEEQUAD 0 47117395Skan 4890075Sobrien/* The AIX linker will discard static constructors in object files before 4990075Sobrien collect has a chance to see them, so scan the object files directly. */ 5090075Sobrien#define COLLECT_EXPORT_LIST 5190075Sobrien 5296263Sobrien/* Handle #pragma weak and #pragma pack. */ 53117395Skan#define HANDLE_SYSV_PRAGMA 1 5496263Sobrien 5590075Sobrien/* This is the only version of nm that collect2 can work with. */ 5690075Sobrien#define REAL_NM_FILE_NAME "/usr/ucb/nm" 5790075Sobrien 5890075Sobrien#define USER_LABEL_PREFIX "" 59169689Skan 6090075Sobrien/* Don't turn -B into -L if the argument specifies a relative file name. */ 6190075Sobrien#define RELATIVE_PREFIX_NOT_LINKDIR 6290075Sobrien 6390075Sobrien/* Because of the above, we must have gcc search itself to find libgcc.a. */ 6490075Sobrien#define LINK_LIBGCC_SPECIAL_1 6590075Sobrien 66169689Skan#define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \ 67169689Skan -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \ 68169689Skan -brename:free,__wrap_free -brename:__real_free,free \ 69169689Skan -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \ 70169689Skan -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \ 71169689Skan -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \ 72169689Skan -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \ 73169689Skan -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \ 74169689Skan} %{fmudflapth: \ 75169689Skan -brename:pthread_create,__wrap_pthread_create \ 76169689Skan -brename:__real_pthread_create,pthread_create \ 77169689Skan -brename:pthread_join,__wrap_pthread_join \ 78169689Skan -brename:__real_pthread_join,pthread_join \ 79169689Skan -brename:pthread_exit,__wrap_pthread_exit \ 80169689Skan -brename:__real_pthread_exit,pthread_exit \ 81169689Skan}} %{fmudflap|fmudflapth: \ 82169689Skan -brename:main,__wrap_main -brename:__real_main,main \ 83169689Skan}" 84169689Skan 85169689Skan#define MFLIB_SPEC " %{fmudflap: -lmudflap \ 86169689Skan %{static:%(link_gcc_c_sequence) -lmudflap}} \ 87169689Skan %{fmudflapth: -lmudflapth -lpthread \ 88169689Skan %{static:%(link_gcc_c_sequence) -lmudflapth}} " 89169689Skan 9090075Sobrien/* Names to predefine in the preprocessor for this target machine. */ 91169689Skan#define TARGET_OS_AIX_CPP_BUILTINS() \ 92169689Skan do \ 93169689Skan { \ 94169689Skan builtin_define ("_IBMR2"); \ 95169689Skan builtin_define ("_POWER"); \ 96169689Skan builtin_define ("_AIX"); \ 97169689Skan builtin_define ("_AIX32"); \ 98169689Skan builtin_define ("_AIX41"); \ 99169689Skan builtin_define ("_LONG_LONG"); \ 100169689Skan if (TARGET_LONG_DOUBLE_128) \ 101169689Skan builtin_define ("__LONGDOUBLE128"); \ 102169689Skan builtin_assert ("system=unix"); \ 103169689Skan builtin_assert ("system=aix"); \ 104169689Skan } \ 105117395Skan while (0) 10690075Sobrien 10790075Sobrien/* Define appropriate architecture macros for preprocessor depending on 10890075Sobrien target switches. */ 10990075Sobrien 11090075Sobrien#define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\ 111117395Skan %{ansi: -D_ANSI_C_SOURCE}" 11290075Sobrien 11390075Sobrien#undef ASM_DEFAULT_SPEC 11490075Sobrien#define ASM_DEFAULT_SPEC "" 11590075Sobrien 11690075Sobrien/* Tell the assembler to assume that all undefined names are external. 11790075Sobrien 11890075Sobrien Don't do this until the fixed IBM assembler is more generally available. 11990075Sobrien When this becomes permanently defined, the ASM_OUTPUT_EXTERNAL, 12090075Sobrien ASM_OUTPUT_EXTERNAL_LIBCALL, and RS6000_OUTPUT_BASENAME macros will no 121132718Skan longer be needed. Also, the extern declaration of mcount in 122132718Skan rs6000_xcoff_file_start will no longer be needed. */ 12390075Sobrien 12490075Sobrien/* #define ASM_SPEC "-u %(asm_cpu)" */ 12590075Sobrien 12690075Sobrien/* Default location of syscalls.exp under AIX */ 127259563Spfg#ifndef CROSS_DIRECTORY_STRUCTURE 12890075Sobrien#define LINK_SYSCALLS_SPEC "-bI:/lib/syscalls.exp" 12990075Sobrien#else 13090075Sobrien#define LINK_SYSCALLS_SPEC "" 13190075Sobrien#endif 13290075Sobrien 13390075Sobrien/* Default location of libg.exp under AIX */ 134259563Spfg#ifndef CROSS_DIRECTORY_STRUCTURE 13590075Sobrien#define LINK_LIBG_SPEC "-bexport:/usr/lib/libg.exp" 13690075Sobrien#else 13790075Sobrien#define LINK_LIBG_SPEC "" 13890075Sobrien#endif 13990075Sobrien 14090075Sobrien/* Define the options for the binder: Start text at 512, align all segments 14190075Sobrien to 512 bytes, and warn if there is text relocation. 14290075Sobrien 14390075Sobrien The -bhalt:4 option supposedly changes the level at which ld will abort, 14490075Sobrien but it also suppresses warnings about multiply defined symbols and is 14590075Sobrien used by the AIX cc command. So we use it here. 14690075Sobrien 14790075Sobrien -bnodelcsect undoes a poor choice of default relating to multiply-defined 14890075Sobrien csects. See AIX documentation for more information about this. 14990075Sobrien 15090075Sobrien -bM:SRE tells the linker that the output file is Shared REusable. Note 15190075Sobrien that to actually build a shared library you will also need to specify an 15290075Sobrien export list with the -Wl,-bE option. */ 15390075Sobrien 15490075Sobrien#define LINK_SPEC "-T512 -H512 %{!r:-btextro} -bhalt:4 -bnodelcsect\ 15590075Sobrien%{static:-bnso %(link_syscalls) } \ 15690075Sobrien%{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}" 15790075Sobrien 15890075Sobrien/* Profiled library versions are used by linking with special directories. */ 15990075Sobrien#define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\ 16090075Sobrien%{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc" 16190075Sobrien 162132718Skan/* This now supports a natural alignment mode. */ 16390075Sobrien/* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints. */ 16490075Sobrien#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ 165132718Skan (TARGET_ALIGN_NATURAL ? (COMPUTED) : \ 16690075Sobrien (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \ 16790075Sobrien ? get_inner_array_type (FIELD) \ 16890075Sobrien : TREE_TYPE (FIELD)) == DFmode \ 169132718Skan ? MIN ((COMPUTED), 32) : (COMPUTED))) 17090075Sobrien 17190075Sobrien/* AIX increases natural record alignment to doubleword if the first 17290075Sobrien field is an FP double while the FP fields remain word aligned. */ 173169689Skan#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ 174169689Skan ((TREE_CODE (STRUCT) == RECORD_TYPE \ 175169689Skan || TREE_CODE (STRUCT) == UNION_TYPE \ 176169689Skan || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ 177169689Skan && TARGET_ALIGN_NATURAL == 0 \ 178169689Skan ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ 17990075Sobrien : MAX ((COMPUTED), (SPECIFIED))) 18090075Sobrien 181132718Skan/* The AIX ABI isn't explicit on whether aggregates smaller than a 182132718Skan word/doubleword should be padded upward or downward. One could 183132718Skan reasonably assume that they follow the normal rules for structure 184132718Skan layout treating the parameter area as any other block of memory, 185132718Skan then map the reg param area to registers, i.e., pad upward, which 186132718Skan is the way IBM Compilers for AIX behave. 187132718Skan Setting both of the following defines results in this behavior. */ 188132718Skan#define AGGREGATE_PADDING_FIXED 1 189132718Skan#define AGGREGATES_PAD_UPWARD_ALWAYS 1 190132718Skan 191132718Skan/* Specify padding for the last element of a block move between 192132718Skan registers and memory. FIRST is nonzero if this is the only 193132718Skan element. */ 194132718Skan#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \ 195132718Skan (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE)) 196132718Skan 19790075Sobrien/* Indicate that jump tables go in the text section. */ 19890075Sobrien 19990075Sobrien#define JUMP_TABLES_IN_TEXT_SECTION 1 20090075Sobrien 20190075Sobrien/* Define any extra SPECS that the compiler needs to generate. */ 20290075Sobrien#undef SUBTARGET_EXTRA_SPECS 20390075Sobrien#define SUBTARGET_EXTRA_SPECS \ 20490075Sobrien { "link_syscalls", LINK_SYSCALLS_SPEC }, \ 20590075Sobrien { "link_libg", LINK_LIBG_SPEC } 20690075Sobrien 20790075Sobrien/* Define cutoff for using external functions to save floating point. */ 20890075Sobrien#define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63) 20990075Sobrien 210132718Skan/* __throw will restore its own return address to be the same as the 211132718Skan return address of the function that the throw is being made to. 212132718Skan This is unfortunate, because we want to check the original 213132718Skan return address to see if we need to restore the TOC. 214132718Skan So we have to squirrel it away with this. */ 215132718Skan#define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init () 21690075Sobrien 217132718Skan/* If the current unwind info (FS) does not contain explicit info 218132718Skan saving R2, then we have to do a minor amount of code reading to 219132718Skan figure out if it was saved. The big problem here is that the 220132718Skan code that does the save/restore is generated by the linker, so 221132718Skan we have no good way to determine at compile time what to do. */ 222132718Skan 223146895Skan#ifdef __64BIT__ 224132718Skan#define MD_FROB_UPDATE_CONTEXT(CTX, FS) \ 22590075Sobrien do { \ 226132718Skan if ((FS)->regs.reg[2].how == REG_UNSAVED) \ 22790075Sobrien { \ 228132718Skan unsigned int *insn \ 229132718Skan = (unsigned int *) \ 230132718Skan _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \ 231132718Skan if (*insn == 0xE8410028) \ 232132718Skan _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40); \ 23390075Sobrien } \ 234132718Skan } while (0) 235132718Skan#else 236132718Skan#define MD_FROB_UPDATE_CONTEXT(CTX, FS) \ 237132718Skan do { \ 238132718Skan if ((FS)->regs.reg[2].how == REG_UNSAVED) \ 23990075Sobrien { \ 240132718Skan unsigned int *insn \ 241132718Skan = (unsigned int *) \ 242132718Skan _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM); \ 243132718Skan if (*insn == 0x80410014) \ 244132718Skan _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 20); \ 24590075Sobrien } \ 24690075Sobrien } while (0) 247132718Skan#endif 24890075Sobrien 24990075Sobrien#define PROFILE_HOOK(LABEL) output_profile_hook (LABEL) 25090075Sobrien 25190075Sobrien/* Print subsidiary information on the compiler version in use. */ 25290075Sobrien#define TARGET_VERSION ; 253132718Skan 254132718Skan/* No version of AIX fully supports AltiVec or 64-bit instructions in 255132718Skan 32-bit mode. */ 256132718Skan#define OS_MISSING_POWERPC64 1 257132718Skan#define OS_MISSING_ALTIVEC 1 258169689Skan 259169689Skan/* WINT_TYPE */ 260169689Skan#define WINT_TYPE "int" 261