[PowerPC/RTEMS] Add 64-bit support using ELFv2 ABI

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
This commit is contained in:
Sebastian Huber 2017-07-28 07:17:10 +00:00 committed by Sebastian Huber
parent d0ee55a1f7
commit 16bab95a79
6 changed files with 229 additions and 20 deletions

View 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> 2017-07-28 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/81578 PR tree-optimization/81578

View File

@ -2429,7 +2429,7 @@ powerpc-*-rtems*spe*)
tmake_file="${tmake_file} powerpcspe/t-fprules powerpcspe/t-rtems powerpcspe/t-ppccomm" tmake_file="${tmake_file} powerpcspe/t-fprules powerpcspe/t-rtems powerpcspe/t-ppccomm"
;; ;;
powerpc-*-rtems*) 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" extra_options="${extra_options} rs6000/sysv4.opt"
tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-rtems rs6000/t-ppccomm" tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-rtems rs6000/t-ppccomm"
;; ;;

View File

@ -23,29 +23,163 @@
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */ <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 #undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() \ #define TARGET_OS_CPP_BUILTINS() \
do \ do \
{ \ { \
builtin_define_std ("PPC"); \
builtin_define ("__rtems__"); \ builtin_define ("__rtems__"); \
builtin_define ("__USE_INIT_FINI__"); \ builtin_define ("__USE_INIT_FINI__"); \
builtin_assert ("system=rtems"); \ 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 ("cpu=powerpc"); \
builtin_assert ("machine=powerpc"); \ builtin_assert ("machine=powerpc"); \
TARGET_OS_SYSV_CPP_BUILTINS (); \ 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) while (0)
#undef TARGET_LIBGCC_SDATA_SECTION #undef TARGET_LIBGCC_SDATA_SECTION
#define TARGET_LIBGCC_SDATA_SECTION ".sdata" #define TARGET_LIBGCC_SDATA_SECTION ".sdata"
#undef CPP_OS_DEFAULT_SPEC /* Copy and paste from linux64.h and freebsd64.h */
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_rtems)" #undef SIZE_TYPE
#define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
#define CPP_OS_RTEMS_SPEC "\ /* 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 ""
/* 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*: %{!Dppc*: %{!Dmpc*: -Dmpc750} } }\
%{mcpu=403: %{!Dppc*: %{!Dmpc*: -Dppc403} } } \ %{mcpu=403: %{!Dppc*: %{!Dmpc*: -Dppc403} } } \
%{mcpu=505: %{!Dppc*: %{!Dmpc*: -Dmpc505} } } \ %{mcpu=505: %{!Dppc*: %{!Dmpc*: -Dmpc505} } } \
@ -60,6 +194,37 @@
%{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540} } } \ %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540} } } \
%{mcpu=e6500: -D__PPC_CPU_E6500__}" %{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 #undef SUBSUBTARGET_EXTRA_SPECS
#define 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 },

View 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_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_DIRNAMES += m403 m505 m603e m604 m860 m7400 m8540 me6500
MULTILIB_OPTIONS += m32 MULTILIB_OPTIONS += m32/m64
MULTILIB_DIRNAMES += m32 MULTILIB_DIRNAMES += m32 m64
MULTILIB_OPTIONS += msoft-float MULTILIB_OPTIONS += msoft-float
MULTILIB_DIRNAMES += nof MULTILIB_DIRNAMES += nof
@ -72,3 +72,5 @@ MULTILIB_REQUIRED += mcpu=8540/msoft-float
MULTILIB_REQUIRED += mcpu=860 MULTILIB_REQUIRED += mcpu=860
MULTILIB_REQUIRED += mcpu=e6500/m32 MULTILIB_REQUIRED += mcpu=e6500/m32
MULTILIB_REQUIRED += mcpu=e6500/m32/msoft-float/mno-altivec MULTILIB_REQUIRED += mcpu=e6500/m32/msoft-float/mno-altivec
MULTILIB_REQUIRED += mcpu=e6500/m64
MULTILIB_REQUIRED += mcpu=e6500/m64/msoft-float/mno-altivec

View 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> 2017-07-24 Daniel Santos <daniel.santos@pobox.com>
PR testsuite/80759 PR testsuite/80759

View 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 This code currently assumes the most significant double is in
the lower numbered register or lower addressed memory. */ 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 fabs(x) __builtin_fabs(x)
#define isless(x, y) __builtin_isless (x, y) #define isless(x, y) __builtin_isless (x, y)