From 17691698c98255c459b7ad78e455596c14a94a9c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 22 Aug 2017 13:43:27 +0000 Subject: [PATCH] [PowerPC/RTEMS] Enable -mcmodel option gcc/ * config.gcc (powerpc-*-rtems*): Add rs6000/linux64.opt. * config/rs6000/rtems.h (ASM_PREFERRED_EH_DATA_FORMAT): New define. (DOT_SYMBOLS): Likewise. (MINIMAL_TOC_SECTION_ASM_OP): Likewise. (RELOCATABLE_NEEDS_FIXUP): Likewise. (RS6000_ABI_NAME): Likewise. (TARGET_CMODEL): Likewise. (TOC_SECTION_ASM_OP): Likewise. (SET_CMODEL): New macro. (SUBSUBTARGET_OVERRIDE_OPTIONS): Evaluate cmodel options. From-SVN: r251275 --- gcc/ChangeLog | 13 +++++++++ gcc/config.gcc | 2 +- gcc/config/rs6000/rtems.h | 60 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bcd868462fc..ab85c074f24 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2017-08-22 Sebastian Huber + + * config.gcc (powerpc-*-rtems*): Add rs6000/linux64.opt. + * config/rs6000/rtems.h (ASM_PREFERRED_EH_DATA_FORMAT): New define. + (DOT_SYMBOLS): Likewise. + (MINIMAL_TOC_SECTION_ASM_OP): Likewise. + (RELOCATABLE_NEEDS_FIXUP): Likewise. + (RS6000_ABI_NAME): Likewise. + (TARGET_CMODEL): Likewise. + (TOC_SECTION_ASM_OP): Likewise. + (SET_CMODEL): New macro. + (SUBSUBTARGET_OVERRIDE_OPTIONS): Evaluate cmodel options. + 2017-08-22 Richard Biener * tree-inline.c (remap_type_1): Change asserts on TYPE_SIZE[_UNIT] diff --git a/gcc/config.gcc b/gcc/config.gcc index 7e024433160..446cab3e257 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -2442,7 +2442,7 @@ powerpc-*-rtems*spe*) ;; powerpc-*-rtems*) 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 rs6000/linux64.opt" tmake_file="${tmake_file} rs6000/t-fprules rs6000/t-rtems rs6000/t-ppccomm" ;; powerpc*-*-linux*spe*) diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h index 8a62fdcbaf3..7ea9ebdb77b 100644 --- a/gcc/config/rs6000/rtems.h +++ b/gcc/config/rs6000/rtems.h @@ -37,6 +37,15 @@ #undef TARGET_AIX #define TARGET_AIX TARGET_64BIT +/* Simplified copy and paste from linux64.h and freebsd64.h */ +#undef DOT_SYMBOLS +#define DOT_SYMBOLS 0 + +/* Copy and paste from linux64.h and freebsd64.h */ +#undef TARGET_CMODEL +#define TARGET_CMODEL rs6000_current_cmodel +#define SET_CMODEL(opt) rs6000_current_cmodel = opt + #undef TARGET_OS_CPP_BUILTINS #define TARGET_OS_CPP_BUILTINS() \ do \ @@ -63,6 +72,15 @@ } \ while (0) +/* Copy and paste from linux64.h and freebsd64.h */ +#undef RELOCATABLE_NEEDS_FIXUP +#define RELOCATABLE_NEEDS_FIXUP \ + (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE) + +/* Copy and paste from linux64.h */ +#undef RS6000_ABI_NAME +#define RS6000_ABI_NAME "linux" + /* Copy and paste from linux64.h and freebsd64.h */ #define INVALID_64BIT "-m%s not supported in this configuration" @@ -95,6 +113,24 @@ rs6000_isa_flags |= OPTION_MASK_POWERPC64; \ error ("-m64 requires a PowerPC64 cpu"); \ } \ + if ((rs6000_isa_flags_explicit \ + & OPTION_MASK_MINIMAL_TOC) != 0) \ + { \ + if (global_options_set.x_rs6000_current_cmodel \ + && rs6000_current_cmodel != CMODEL_SMALL) \ + error ("-mcmodel incompatible with other toc options"); \ + SET_CMODEL (CMODEL_SMALL); \ + } \ + else \ + { \ + if (!global_options_set.x_rs6000_current_cmodel) \ + SET_CMODEL (CMODEL_MEDIUM); \ + if (rs6000_current_cmodel != CMODEL_SMALL) \ + { \ + TARGET_NO_FP_IN_TOC = 0; \ + TARGET_NO_SUM_IN_TOC = 0; \ + } \ + } \ } \ } \ while (0) @@ -140,6 +176,30 @@ #undef RESTORE_FP_SUFFIX #define RESTORE_FP_SUFFIX "" +/* Copy and paste from linux64.h and freebsd64.h */ +#undef ASM_PREFERRED_EH_DATA_FORMAT +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ + (TARGET_64BIT || flag_pic \ + ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ + | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ + : DW_EH_PE_absptr) + +/* Copy and paste from linux64.h and freebsd64.h */ +#undef TOC_SECTION_ASM_OP +#define TOC_SECTION_ASM_OP \ + (TARGET_64BIT \ + ? "\t.section\t\".toc\",\"aw\"" \ + : "\t.section\t\".got\",\"aw\"") + +/* Copy and paste from linux64.h and freebsd64.h */ +#undef MINIMAL_TOC_SECTION_ASM_OP +#define MINIMAL_TOC_SECTION_ASM_OP \ + (TARGET_64BIT \ + ? "\t.section\t\".toc1\",\"aw\"" \ + : (flag_pic \ + ? "\t.section\t\".got2\",\"aw\"" \ + : "\t.section\t\".got1\",\"aw\"")) + /* Copy and paste from linux64.h and freebsd64.h */ #undef ASM_DECLARE_FUNCTION_SIZE #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ -- 2.30.2