[PowerPC/RTEMS] Enable -mcmodel option
authorSebastian Huber <sebastian.huber@embedded-brains.de>
Tue, 22 Aug 2017 13:43:27 +0000 (13:43 +0000)
committerSebastian Huber <sh@gcc.gnu.org>
Tue, 22 Aug 2017 13:43:27 +0000 (13:43 +0000)
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
gcc/config.gcc
gcc/config/rs6000/rtems.h

index bcd868462fcd558de36f84a034c5cf9865d9a3d5..ab85c074f24241bc0bc359c013bc40d346a91b47 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-22  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+       * 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  <rguenther@suse.de>
 
        * tree-inline.c (remap_type_1): Change asserts on TYPE_SIZE[_UNIT]
index 7e0244331602738f04fb58aa6285954eb31b0a5f..446cab3e257fcdd84526473ae1ddeb2912ee9045 100644 (file)
@@ -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*)
index 8a62fdcbaf321d616021c4c396619b7f56cf5ed2..7ea9ebdb77b6a9b7060ad2362318e0e12b9058ae 100644 (file)
 #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                                                   \
     }                                                  \
   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"
 
              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)
 #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)                    \