[PowerPC/RTEMS] Add 64-bit support using ELFv2 ABI
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Fri, 28 Jul 2017 07:17:10 +0000 (07:17 +0000)
committerSebastian Huber <sh@gcc.gnu.org>
Fri, 28 Jul 2017 07:17:10 +0000 (07:17 +0000)
Add 64-bit support for RTEMS using the ELFv2 ABI with 64-bit long
double.

gcc/
* config.gcc (powerpc-*-rtems*): Remove rs6000/eabi.h.  Add
rs6000/biarch64.h.
* config/rs6000/rtems.h (ASM_DECLARE_FUNCTION_SIZE): New macro.
(ASM_OUTPUT_SPECIAL_POOL_ENTRY_P): Likewise.
(CRT_CALL_STATIC_FUNCTION): Likewise.
(ASM_DEFAULT_SPEC): New define.
(ASM_SPEC32): Likewise.
(ASM_SPEC64): Likewise.
(ASM_SPEC_COMMON): Likewise.
(ASM_SPEC): Likewise.
(INVALID_64BIT): Likewise.
(LINK_OS_DEFAULT_SPEC): Likewise.
(LINK_OS_SPEC32): Likewise.
(LINK_OS_SPEC64): Likewise.
(POWERPC_LINUX): Likewise.
(PTRDIFF_TYPE): Likewise.
(RESTORE_FP_PREFIX): Likewise.
(RESTORE_FP_SUFFIX): Likewise.
(SAVE_FP_PREFIX): Likewise.
(SAVE_FP_SUFFIX): Likewise.
(SIZE_TYPE): Likewise.
(SUBSUBTARGET_OVERRIDE_OPTIONS): Likewise.
(TARGET_64BIT): Likewise.
(TARGET_64BIT): Likewise.
(TARGET_AIX): Likewise.
(WCHAR_TYPE_SIZE): Likewise.
(WCHAR_TYPE): Undefine.
(TARGET_OS_CPP_BUILTINS): Add 64-bit PowerPC defines.
(CPP_OS_DEFAULT_SPEC): Use previous CPP_OS_RTEMS_SPEC.
(CPP_OS_RTEMS_SPEC): Delete.
(SUBSUBTARGET_EXTRA_SPECS): Remove cpp_os_rtems.  Add
asm_spec_common, asm_spec32, asm_spec64, link_os_spec32, and
link_os_spec64.
* config/rs6000/t-rtems: Add mcpu=e6500/m64 multilibs.

libgcc/
* config/rs6000/ibm-ldouble.c: Disable if defined __rtems__.

From-SVN: r250652

gcc/ChangeLog
gcc/config.gcc
gcc/config/rs6000/rtems.h
gcc/config/rs6000/t-rtems
libgcc/ChangeLog
libgcc/config/rs6000/ibm-ldouble.c

index b2aec1afa54f3d45ff42d15de4c991fa64992c46..6b9a588ec43a1a7c814f1402b17e76f9ef6170b7 100644 (file)
@@ -1,3 +1,40 @@
+2017-07-28  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * config.gcc (powerpc-*-rtems*): Remove rs6000/eabi.h.  Add
+       rs6000/biarch64.h.
+       * config/rs6000/rtems.h (ASM_DECLARE_FUNCTION_SIZE): New macro.
+       (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P): Likewise.
+       (CRT_CALL_STATIC_FUNCTION): Likewise.
+       (ASM_DEFAULT_SPEC): New define.
+       (ASM_SPEC32): Likewise.
+       (ASM_SPEC64): Likewise.
+       (ASM_SPEC_COMMON): Likewise.
+       (ASM_SPEC): Likewise.
+       (INVALID_64BIT): Likewise.
+       (LINK_OS_DEFAULT_SPEC): Likewise.
+       (LINK_OS_SPEC32): Likewise.
+       (LINK_OS_SPEC64): Likewise.
+       (POWERPC_LINUX): Likewise.
+       (PTRDIFF_TYPE): Likewise.
+       (RESTORE_FP_PREFIX): Likewise.
+       (RESTORE_FP_SUFFIX): Likewise.
+       (SAVE_FP_PREFIX): Likewise.
+       (SAVE_FP_SUFFIX): Likewise.
+       (SIZE_TYPE): Likewise.
+       (SUBSUBTARGET_OVERRIDE_OPTIONS): Likewise.
+       (TARGET_64BIT): Likewise.
+       (TARGET_64BIT): Likewise.
+       (TARGET_AIX): Likewise.
+       (WCHAR_TYPE_SIZE): Likewise.
+       (WCHAR_TYPE): Undefine.
+       (TARGET_OS_CPP_BUILTINS): Add 64-bit PowerPC defines.
+       (CPP_OS_DEFAULT_SPEC): Use previous CPP_OS_RTEMS_SPEC.
+       (CPP_OS_RTEMS_SPEC): Delete.
+       (SUBSUBTARGET_EXTRA_SPECS): Remove cpp_os_rtems.  Add
+       asm_spec_common, asm_spec32, asm_spec64, link_os_spec32, and
+       link_os_spec64.
+       * config/rs6000/t-rtems: Add mcpu=e6500/m64 multilibs.
+
 2017-07-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/81578
index 0224339cfb57fef67f75fb454a186160fccf1955..f28164646c3b7998d16dfa9c279972ccf15ee1b2 100644 (file)
@@ -2429,7 +2429,7 @@ powerpc-*-rtems*spe*)
        tmake_file="${tmake_file} powerpcspe/t-fprules powerpcspe/t-rtems powerpcspe/t-ppccomm"
        ;;
 powerpc-*-rtems*)
-       tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/rtems.h rtems.h"
+       tm_file="rs6000/biarch64.h ${tm_file} dbxelf.h elfos.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/rtems.h rtems.h"
        extra_options="${extra_options} rs6000/sysv4.opt"
        tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-rtems rs6000/t-ppccomm"
        ;;
index 1ab4e313fdbc3560c18630e98fa57958d8677225..8a62fdcbaf321d616021c4c396619b7f56cf5ed2 100644 (file)
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* Specify predefined symbols in preprocessor.  */
+/* Copy and paste from linux64.h and freebsd64.h */
+#ifdef IN_LIBGCC2
+#undef TARGET_64BIT
+#ifdef __powerpc64__
+#define TARGET_64BIT 1
+#else
+#define TARGET_64BIT 0
+#endif
+#endif
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef TARGET_AIX
+#define        TARGET_AIX TARGET_64BIT
 
 #undef TARGET_OS_CPP_BUILTINS
-#define TARGET_OS_CPP_BUILTINS()          \
-  do                                      \
-    {                                     \
-      builtin_define_std ("PPC");         \
-      builtin_define ("__rtems__");       \
-      builtin_define ("__USE_INIT_FINI__"); \
-      builtin_assert ("system=rtems");    \
-      builtin_assert ("cpu=powerpc");     \
-      builtin_assert ("machine=powerpc"); \
-      TARGET_OS_SYSV_CPP_BUILTINS ();     \
-    }                                     \
+#define TARGET_OS_CPP_BUILTINS()                       \
+  do                                                   \
+    {                                                  \
+      builtin_define ("__rtems__");                    \
+      builtin_define ("__USE_INIT_FINI__");            \
+      builtin_assert ("system=rtems");                 \
+      if (TARGET_64BIT)                                        \
+       {                                               \
+         builtin_define ("__PPC__");                   \
+         builtin_define ("__PPC64__");                 \
+         builtin_define ("__powerpc64__");             \
+         builtin_assert ("cpu=powerpc64");             \
+         builtin_assert ("machine=powerpc64");         \
+       }                                               \
+      else                                             \
+       {                                               \
+         builtin_define_std ("PPC");                   \
+         builtin_define_std ("powerpc");               \
+         builtin_assert ("cpu=powerpc");               \
+         builtin_assert ("machine=powerpc");           \
+         TARGET_OS_SYSV_CPP_BUILTINS ();               \
+       }                                               \
+    }                                                  \
+  while (0)
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#define INVALID_64BIT "-m%s not supported in this configuration"
+
+/* A lot of copy and paste from linux64.h and freebsd64.h */
+#undef SUBSUBTARGET_OVERRIDE_OPTIONS
+#define        SUBSUBTARGET_OVERRIDE_OPTIONS                           \
+  do                                                           \
+    {                                                          \
+      if (rs6000_isa_flags & OPTION_MASK_64BIT)                        \
+       {                                                       \
+         rs6000_elf_abi = 2;                                   \
+         rs6000_current_abi = ABI_ELFv2;                       \
+         if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE)       \
+           {                                                   \
+             rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE;     \
+             error (INVALID_64BIT, "relocatable");             \
+           }                                                   \
+         if (rs6000_isa_flags & OPTION_MASK_EABI)              \
+           {                                                   \
+             rs6000_isa_flags &= ~OPTION_MASK_EABI;            \
+             error (INVALID_64BIT, "eabi");                    \
+           }                                                   \
+         if (TARGET_PROTOTYPE)                                 \
+           {                                                   \
+             target_prototype = 0;                             \
+             error (INVALID_64BIT, "prototype");               \
+           }                                                   \
+         if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0)  \
+           {                                                   \
+             rs6000_isa_flags |= OPTION_MASK_POWERPC64;        \
+             error ("-m64 requires a PowerPC64 cpu");          \
+           }                                                   \
+       }                                                       \
+    }                                                          \
   while (0)
 
 #undef TARGET_LIBGCC_SDATA_SECTION
 #define TARGET_LIBGCC_SDATA_SECTION ".sdata"
 
-#undef CPP_OS_DEFAULT_SPEC
-#define CPP_OS_DEFAULT_SPEC "%(cpp_os_rtems)"
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef SIZE_TYPE
+#define        SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef PTRDIFF_TYPE
+#define        PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
+
+/* Copy and paste from freebsd64.h */
+#undef WCHAR_TYPE
+
+/* Copy and paste from freebsd64.h */
+#undef  WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#ifdef __powerpc64__
+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)     \
+  asm (SECTION_OP "\n"                                 \
+"      bl " #FUNC "\n"                                 \
+"      nop\n"                                          \
+"      .previous");
+#endif
+
+/* This could be also POWERPC_FREEBSD.  It is related to the save/restore
+   defines below.  */
+#define POWERPC_LINUX
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef  SAVE_FP_PREFIX
+#define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
+#undef  SAVE_FP_SUFFIX
+#define SAVE_FP_SUFFIX ""
+#undef  RESTORE_FP_PREFIX
+#define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
+#undef  RESTORE_FP_SUFFIX
+#define RESTORE_FP_SUFFIX ""
 
-#define CPP_OS_RTEMS_SPEC "\
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef ASM_DECLARE_FUNCTION_SIZE
+#define        ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                    \
+  do                                                                   \
+    {                                                                  \
+      if (!flag_inhibit_size_directive)                                        \
+       {                                                               \
+         fputs ("\t.size\t", (FILE));                                  \
+         if (TARGET_64BIT && DOT_SYMBOLS)                              \
+           putc ('.', (FILE));                                         \
+         assemble_name ((FILE), (FNAME));                              \
+         fputs (",.-", (FILE));                                        \
+         rs6000_output_function_entry (FILE, FNAME);                   \
+         putc ('\n', (FILE));                                          \
+       }                                                               \
+    }                                                                  \
+  while (0)
+
+/* Copy and paste from linux64.h and freebsd64.h */
+#undef  ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
+#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE)                       \
+  (TARGET_TOC                                                          \
+   && (GET_CODE (X) == SYMBOL_REF                                      \
+       || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS     \
+          && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF)           \
+       || GET_CODE (X) == LABEL_REF                                    \
+       || (GET_CODE (X) == CONST_INT                                   \
+          && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode))      \
+       || (GET_CODE (X) == CONST_DOUBLE                                        \
+          && ((TARGET_64BIT                                            \
+               && (TARGET_MINIMAL_TOC                                  \
+                   || (SCALAR_FLOAT_MODE_P (GET_MODE (X))              \
+                       && ! TARGET_NO_FP_IN_TOC)))                     \
+              || (!TARGET_64BIT                                        \
+                  && !TARGET_NO_FP_IN_TOC                              \
+                  && SCALAR_FLOAT_MODE_P (GET_MODE (X))                \
+                  && BITS_PER_WORD == HOST_BITS_PER_INT)))))
+
+#undef CPP_OS_DEFAULT_SPEC
+#define CPP_OS_DEFAULT_SPEC "\
 %{!mcpu*:  %{!Dppc*: %{!Dmpc*: -Dmpc750} } }\
 %{mcpu=403:  %{!Dppc*: %{!Dmpc*: -Dppc403}  } } \
 %{mcpu=505:  %{!Dppc*: %{!Dmpc*: -Dmpc505}  } } \
 %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540}  } } \
 %{mcpu=e6500: -D__PPC_CPU_E6500__}"
 
+#undef ASM_DEFAULT_SPEC
+#define        ASM_DEFAULT_SPEC "-mppc%{m64:64}"
+
+#undef ASM_SPEC
+#define        ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
+
+#define ASM_SPEC32 "-a32 \
+%{mrelocatable} %{mrelocatable-lib} %{" FPIE_OR_FPIC_SPEC ":-K PIC} \
+%{memb|msdata=eabi: -memb}"
+
+#define ASM_SPEC64 "-a64"
+
+#define ASM_SPEC_COMMON "%(asm_cpu) \
+%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \
+  ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
+
+#undef  LINK_OS_DEFAULT_SPEC
+#define LINK_OS_DEFAULT_SPEC \
+"%{!m64:%(link_os_spec32)}%{m64:%(link_os_spec64)}"
+
+#define LINK_OS_SPEC32 ENDIAN_SELECT(" -m elf32ppc",           \
+                                    " -m elf32lppc",           \
+                                    " -m elf32ppc")
+#define LINK_OS_SPEC64 ENDIAN_SELECT(" -m elf64ppc",           \
+                                    " -m elf64lppc",           \
+                                    " -m elf64ppc")
+
 #undef  SUBSUBTARGET_EXTRA_SPECS
 #define SUBSUBTARGET_EXTRA_SPECS \
-  { "cpp_os_rtems",            CPP_OS_RTEMS_SPEC }
+  { "asm_spec_common",         ASM_SPEC_COMMON },                      \
+  { "asm_spec32",              ASM_SPEC32 },                           \
+  { "asm_spec64",              ASM_SPEC64 },                           \
+  { "link_os_spec32",          LINK_OS_SPEC32 },                       \
+  { "link_os_spec64",          LINK_OS_SPEC64 },
index 8290f5c5bdd93bd723298f823cab7aa8c887e09d..0e39c6320c8db155dd3c07a7e980e7525e753879 100644 (file)
@@ -27,8 +27,8 @@ MULTILIB_REQUIRED =
 MULTILIB_OPTIONS += mcpu=403/mcpu=505/mcpu=603e/mcpu=604/mcpu=860/mcpu=7400/mcpu=8540/mcpu=e6500
 MULTILIB_DIRNAMES += m403 m505 m603e m604 m860 m7400 m8540 me6500
 
-MULTILIB_OPTIONS += m32
-MULTILIB_DIRNAMES += m32
+MULTILIB_OPTIONS += m32/m64
+MULTILIB_DIRNAMES += m32 m64
 
 MULTILIB_OPTIONS += msoft-float
 MULTILIB_DIRNAMES += nof
@@ -72,3 +72,5 @@ MULTILIB_REQUIRED += mcpu=8540/msoft-float
 MULTILIB_REQUIRED += mcpu=860
 MULTILIB_REQUIRED += mcpu=e6500/m32
 MULTILIB_REQUIRED += mcpu=e6500/m32/msoft-float/mno-altivec
+MULTILIB_REQUIRED += mcpu=e6500/m64
+MULTILIB_REQUIRED += mcpu=e6500/m64/msoft-float/mno-altivec
index cb25039b1a7f95c945f3e20fa0431e0461c03afc..fc7b878d95c0d838d6e339b89bee3d9d0048ff12 100644 (file)
@@ -1,3 +1,7 @@
+2017-07-28  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * config/rs6000/ibm-ldouble.c: Disable if defined __rtems__.
+
 2017-07-24  Daniel Santos  <daniel.santos@pobox.com>
 
        PR testsuite/80759
index 949b50c98caeab78f3030e1e8f3b33aab45db36a..e99652e523f4b65158ea5b5a3e87677f16fa7269 100644 (file)
@@ -45,7 +45,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    This code currently assumes the most significant double is in
    the lower numbered register or lower addressed memory.  */
 
-#if defined (__MACH__) || defined (__powerpc__) || defined (_AIX)
+#if (defined (__MACH__) || defined (__powerpc__) || defined (_AIX)) \
+    && !defined (__rtems__)
 
 #define fabs(x) __builtin_fabs(x)
 #define isless(x, y) __builtin_isless (x, y)