]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/config/rs6000/aix.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / rs6000 / aix.h
index 475f1432e06de57a2b6b3d40d9c5560523340232..69db93ef47b8be1fb7a1aa86b65010cb5d8d779a 100644 (file)
@@ -1,13 +1,13 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
 /* Definitions of target machine for GNU compiler,
    for IBM RS/6000 POWER running AIX.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005
-   Free Software Foundation, Inc.
+   Copyright (C) 2000-2023 Free Software Foundation, Inc.
 
    This file is part of GCC.
 
    GCC is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
-   by the Free Software Foundation; either version 2, or (at your
+   by the Free Software Foundation; either version 3, or (at your
    option) any later version.
 
    GCC is distributed in the hope that it will be useful, but WITHOUT
    License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GCC; see the file COPYING.  If not, write to the
-   Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.  */
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
 
 /* Yes!  We are AIX!  */
 #define DEFAULT_ABI ABI_AIX
 #undef  TARGET_AIX
 #define TARGET_AIX 1
 
+/* Linux64.h wants to redefine TARGET_AIX based on -m64, but it can't be used
+   in the #if conditional in options-default.h, so provide another macro.  */
+#undef  TARGET_AIX_OS
+#define TARGET_AIX_OS 1
+
 /* AIX always has a TOC.  */
-#define TARGET_NO_TOC 0
-#define TARGET_TOC 1
+#define TARGET_HAS_TOC 1
 #define FIXED_R2 1
 
 /* AIX allows r13 to be used in 32-bit mode.  */
 #define FIXED_R13 0
 
-/* AIX does not support Altivec.  */
-#undef  TARGET_ALTIVEC
-#define TARGET_ALTIVEC 0
-#undef  TARGET_ALTIVEC_ABI
-#define TARGET_ALTIVEC_ABI 0
+/* 32-bit and 64-bit AIX stack boundary is 128.  */
+#undef  STACK_BOUNDARY
+#define STACK_BOUNDARY 128
+
+/* Offset within stack frame to start allocating local variables at.
+   If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
+   first local allocated.  Otherwise, it is the offset to the BEGINNING
+   of the first local allocated.
+
+   On the RS/6000, the frame pointer is the same as the stack pointer,
+   except for dynamic allocations.  So we start after the fixed area and
+   outgoing parameter area.
+
+   If the function uses dynamic stack space (CALLS_ALLOCA is set), that
+   space needs to be aligned to STACK_BOUNDARY, i.e. the sum of the
+   sizes of the fixed area and the parameter area must be a multiple of
+   STACK_BOUNDARY.  */
+
+#undef RS6000_STARTING_FRAME_OFFSET
+#define RS6000_STARTING_FRAME_OFFSET                                   \
+  (cfun->calls_alloca                                                  \
+   ? RS6000_ALIGN (crtl->outgoing_args_size + RS6000_SAVE_AREA, 16)    \
+   : (RS6000_ALIGN (crtl->outgoing_args_size, 16) + RS6000_SAVE_AREA))
+
+/* Offset from the stack pointer register to an item dynamically
+   allocated on the stack, e.g., by `alloca'.
+
+   The default value for this macro is `STACK_POINTER_OFFSET' plus the
+   length of the outgoing arguments.  The default is correct for most
+   machines.  See `function.cc' for details.
+
+   This value must be a multiple of STACK_BOUNDARY (hard coded in
+   `emit-rtl.cc').  */
+#undef STACK_DYNAMIC_OFFSET
+#define STACK_DYNAMIC_OFFSET(FUNDECL)                                  \
+   RS6000_ALIGN (crtl->outgoing_args_size.to_constant ()               \
+                + STACK_POINTER_OFFSET, 16)
+
+#undef  TARGET_IEEEQUAD
+#define TARGET_IEEEQUAD 0
+
+#undef  TARGET_IEEEQUAD_DEFAULT
+#define TARGET_IEEEQUAD_DEFAULT 0
 
 /* The AIX linker will discard static constructors in object files before
    collect has a chance to see them, so scan the object files directly.  */
 #define COLLECT_EXPORT_LIST
 
-/* Handle #pragma weak and #pragma pack.  */
-#define HANDLE_SYSV_PRAGMA 1
+/* On AIX, initialisers specified with -binitfini are called in breadth-first
+   order.
+   e.g. if a.out depends on lib1.so, the init function for a.out is called before
+   the init function for lib1.so.
+
+   To ensure global C++ constructors in linked libraries are run before global
+   C++ constructors from the current module, there is additional symbol scanning
+   logic in collect2.
+
+   The global initialiser/finaliser functions are named __GLOBAL_AIXI_{libname}
+   and __GLOBAL_AIXD_{libname} and are exported from each shared library.
+
+   collect2 will detect these symbols when they exist in shared libraries that
+   the current program is being linked against.  All such initiliser functions
+   will be called prior to the constructors of the current program, and
+   finaliser functions called after destructors.
+
+   Reference counting generated by collect2 will ensure that constructors are
+   only invoked once in the case of multiple dependencies on a library.
+
+   -binitfini is still used in parallel to this solution.
+   This handles the case where a library is loaded through dlopen(), and also
+   handles the option -blazy.
+*/
+#define COLLECT_SHARED_INIT_FUNC(STREAM, FUNC) \
+         fprintf ((STREAM), "void %s() {\n\t%s();\n}\n", aix_shared_initname, (FUNC))
+#define COLLECT_SHARED_FINI_FUNC(STREAM, FUNC) \
+         fprintf ((STREAM), "void %s() {\n\t%s();\n}\n", aix_shared_fininame, (FUNC))
+
+#if HAVE_AS_REF
+/* Issue assembly directives that create a reference to the given DWARF table
+   identifier label from the current function section.  This is defined to
+   ensure we drag frame tables associated with needed function bodies in
+   a link with garbage collection activated.  */
+#define ASM_OUTPUT_DWARF_TABLE_REF rs6000_aix_asm_output_dwarf_table_ref
+#endif
 
 /* This is the only version of nm that collect2 can work with.  */
 #define REAL_NM_FILE_NAME "/usr/ucb/nm"
 /* Because of the above, we must have gcc search itself to find libgcc.a.  */
 #define LINK_LIBGCC_SPECIAL_1
 
-#define MFWRAP_SPEC " %{static: %{fmudflap|fmudflapth: \
- -brename:malloc,__wrap_malloc -brename:__real_malloc,malloc \
- -brename:free,__wrap_free -brename:__real_free,free \
- -brename:calloc,__wrap_calloc -brename:__real_calloc,calloc \
- -brename:realloc,__wrap_realloc -brename:__real_realloc,realloc \
- -brename:mmap,__wrap_mmap -brename:__real_mmap,mmap \
- -brename:munmap,__wrap_munmap -brename:__real_munmap,munmap \
- -brename:alloca,__wrap_alloca -brename:__real_alloca,alloca \
-} %{fmudflapth: \
- -brename:pthread_create,__wrap_pthread_create \
- -brename:__real_pthread_create,pthread_create \
- -brename:pthread_join,__wrap_pthread_join \
- -brename:__real_pthread_join,pthread_join \
- -brename:pthread_exit,__wrap_pthread_exit \
- -brename:__real_pthread_exit,pthread_exit \
-}} %{fmudflap|fmudflapth: \
- -brename:main,__wrap_main -brename:__real_main,main \
-}"
-
-#define MFLIB_SPEC " %{fmudflap: -lmudflap \
- %{static:%(link_gcc_c_sequence) -lmudflap}} \
- %{fmudflapth: -lmudflapth -lpthread \
- %{static:%(link_gcc_c_sequence) -lmudflapth}} "
-
 /* Names to predefine in the preprocessor for this target machine.  */
 #define TARGET_OS_AIX_CPP_BUILTINS()           \
   do                                           \
     {                                          \
       builtin_define ("_IBMR2");               \
       builtin_define ("_POWER");               \
+      builtin_define ("__unix__");              \
       builtin_define ("_AIX");                 \
       builtin_define ("_AIX32");               \
       builtin_define ("_AIX41");               \
         builtin_define ("__LONGDOUBLE128");    \
       builtin_assert ("system=unix");          \
       builtin_assert ("system=aix");           \
+      if (TARGET_64BIT)                                \
+       {                                       \
+         builtin_define ("__PPC__");           \
+         builtin_define ("__PPC64__");         \
+         builtin_define ("__powerpc__");       \
+         builtin_define ("__powerpc64__");     \
+         builtin_assert ("cpu=powerpc64");     \
+         builtin_assert ("machine=powerpc64"); \
+       }                                       \
+      else                                     \
+       {                                       \
+         builtin_define ("__PPC__");           \
+         builtin_define ("__powerpc__");       \
+         builtin_assert ("cpu=powerpc");       \
+         builtin_assert ("machine=powerpc");   \
+       }                                       \
     }                                          \
   while (0)
 
 #define CPP_SPEC "%{posix: -D_POSIX_SOURCE}\
    %{ansi: -D_ANSI_C_SOURCE}"
 
+#define CC1_SPEC "%(cc1_cpu)"
+
 #undef ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC ""
 
 /* #define ASM_SPEC "-u %(asm_cpu)" */
 
 /* Default location of syscalls.exp under AIX */
-#ifndef CROSS_COMPILE
-#define LINK_SYSCALLS_SPEC "-bI:/lib/syscalls.exp"
-#else
-#define LINK_SYSCALLS_SPEC ""
-#endif
+#define LINK_SYSCALLS_SPEC "-bI:%R/lib/syscalls.exp"
 
 /* Default location of libg.exp under AIX */
-#ifndef CROSS_COMPILE
-#define LINK_LIBG_SPEC "-bexport:/usr/lib/libg.exp"
-#else
-#define LINK_LIBG_SPEC ""
-#endif
+#define LINK_LIBG_SPEC "-bexport:%R/usr/lib/libg.exp"
 
 /* Define the options for the binder: Start text at 512, align all segments
    to 512 bytes, and warn if there is text relocation.
 %{!shared:%{g*: %(link_libg) }} %{shared:-bM:SRE}"
 
 /* Profiled library versions are used by linking with special directories.  */
-#define LIB_SPEC "%{pg:-L/lib/profiled -L/usr/lib/profiled}\
-%{p:-L/lib/profiled -L/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
+#define LIB_SPEC "%{pg:-L%R/lib/profiled -L%R/usr/lib/profiled}\
+%{p:-L%R/lib/profiled -L%R/usr/lib/profiled} %{!shared:%{g*:-lg}} -lc"
+
+/* Static linking with shared libstdc++ requires libsupc++ as well.  */
+#define LIBSTDCXX_STATIC "supc++"
 
 /* This now supports a natural alignment mode.  */
 /* AIX word-aligns FP doubles but doubleword-aligns 64-bit ints.  */
-#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
-  (TARGET_ALIGN_NATURAL ? (COMPUTED) : \
-  (TYPE_MODE (TREE_CODE (TREE_TYPE (FIELD)) == ARRAY_TYPE \
-             ? get_inner_array_type (FIELD) \
-             : TREE_TYPE (FIELD)) == DFmode \
-   ? MIN ((COMPUTED), 32) : (COMPUTED)))
+#define ADJUST_FIELD_ALIGN(FIELD, TYPE, COMPUTED) \
+  (TARGET_ALIGN_NATURAL == 0                                           \
+   ? rs6000_special_adjust_field_align (TYPE, COMPUTED)                        \
+   : (COMPUTED))
 
 /* AIX increases natural record alignment to doubleword if the first
    field is an FP double while the FP fields remain word aligned.  */
-#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                          \
-  ((TREE_CODE (STRUCT) == RECORD_TYPE                                          \
-    || TREE_CODE (STRUCT) == UNION_TYPE                                                \
-    || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                                  \
-   && TARGET_ALIGN_NATURAL == 0                                                        \
-   ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED)             \
+#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)                  \
+  ((TREE_CODE (STRUCT) == RECORD_TYPE                                  \
+    || TREE_CODE (STRUCT) == UNION_TYPE                                        \
+    || TREE_CODE (STRUCT) == QUAL_UNION_TYPE)                          \
+   && TARGET_ALIGN_NATURAL == 0                                                \
+   ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED)     \
    : MAX ((COMPUTED), (SPECIFIED)))
 
 /* The AIX ABI isn't explicit on whether aggregates smaller than a
    registers and memory.  FIRST is nonzero if this is the only
    element.  */
 #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
-  (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
+  (!(FIRST) ? PAD_UPWARD : targetm.calls.function_arg_padding (MODE, TYPE))
 
 /* Indicate that jump tables go in the text section.  */
 
   { "link_syscalls",            LINK_SYSCALLS_SPEC },                  \
   { "link_libg",                LINK_LIBG_SPEC }
 
-/* Define cutoff for using external functions to save floating point.  */
-#define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
-
-/* __throw will restore its own return address to be the same as the
-   return address of the function that the throw is being made to.
-   This is unfortunate, because we want to check the original
-   return address to see if we need to restore the TOC.
-   So we have to squirrel it away with this.  */
-#define SETUP_FRAME_ADDRESSES() rs6000_aix_emit_builtin_unwind_init ()
-
-/* If the current unwind info (FS) does not contain explicit info
-   saving R2, then we have to do a minor amount of code reading to
-   figure out if it was saved.  The big problem here is that the
-   code that does the save/restore is generated by the linker, so
-   we have no good way to determine at compile time what to do.  */
-
-#ifdef __64BIT__
-#define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                        \
-  do {                                                                 \
-    if ((FS)->regs.reg[2].how == REG_UNSAVED)                          \
-      {                                                                        \
-       unsigned int *insn                                              \
-         = (unsigned int *)                                            \
-           _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);                \
-       if (*insn == 0xE8410028)                                        \
-         _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 40);                 \
-      }                                                                        \
-  } while (0)
-#else
-#define MD_FROB_UPDATE_CONTEXT(CTX, FS)                                        \
-  do {                                                                 \
-    if ((FS)->regs.reg[2].how == REG_UNSAVED)                          \
-      {                                                                        \
-       unsigned int *insn                                              \
-         = (unsigned int *)                                            \
-           _Unwind_GetGR ((CTX), LINK_REGISTER_REGNUM);                \
-       if (*insn == 0x80410014)                                        \
-         _Unwind_SetGRPtr ((CTX), 2, (CTX)->cfa + 20);                 \
-      }                                                                        \
-  } while (0)
-#endif
-
 #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
 
-/* Print subsidiary information on the compiler version in use.  */
-#define TARGET_VERSION ;
-
 /* No version of AIX fully supports AltiVec or 64-bit instructions in
    32-bit mode.  */
 #define OS_MISSING_POWERPC64 1
 
 /* WINT_TYPE */
 #define WINT_TYPE "int"
+
+/* Static stack checking is supported by means of probes.  */
+#define STACK_CHECK_STATIC_BUILTIN 1
+
+/* Use standard DWARF numbering for DWARF debugging information.  */
+#define RS6000_USE_DWARF_NUMBERING
+
+#define TARGET_PRECOMPUTE_TLS_P rs6000_aix_precompute_tls_p
+
+/* Replace -m64 with -maix64 and -m32 with -maix32.  */
+#undef SUBTARGET_DRIVER_SELF_SPECS
+#define SUBTARGET_DRIVER_SELF_SPECS    \
+"%{m64:-maix64} %<m64",                        \
+"%{m32:-maix32} %<m32"