]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Update PowerPC compiler for pc-relative support.
authorMichael Meissner <meissner@linux.ibm.com>
Thu, 18 Jul 2019 18:16:43 +0000 (18:16 +0000)
committerMichael Meissner <meissner@gcc.gnu.org>
Thu, 18 Jul 2019 18:16:43 +0000 (18:16 +0000)
2019-07-18  Michael Meissner  <meissner@linux.ibm.com>

* config/rs6000/aix.h (TARGET_HAS_TOC): Rename TARGET_TOC to
TARGET_HAS_TOC.
(TARGET_TOC): Likewise.
(TARGET_NO_TOC): Delete here, define TARGET_NO_TOC_OR_PCREL in
rs6000.h.
* config/rs6000/darwin.h (TARGET_HAS_TOC): Rename TARGET_TOC to
TARGET_HAS_TOC.
(TARGET_TOC): Likewise.
(TARGET_NO_TOC): Delete here, define TARGET_NO_TOC_OR_PCREL in
rs6000.h.
* config/rs6000/linux64.h (TARGET_HAS_TOC): Rename TARGET_TOC to
TARGET_HAS_TOC.
(TARGET_TOC): Likewise.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Add
check to require -mcmodel=medium for pc-relative addressing.
(create_TOC_reference): Add assertion for TARGET_TOC.
(rs6000_legitimize_address): Use TARGET_NO_TOC_OR_PCREL instead of
TARGET_NO_TOC.
(rs6000_emit_move): Likewise.
(TOC_alias_set): Rename TOC alias set static variable from 'set'
to 'TOC_alias_set'.
(get_TOC_alias_set): Likewise.
(output_toc): Use TARGET_NO_TOC_OR_PCREL instead of
TARGET_NO_TOC.
(rs6000_can_eliminate): Likewise.
* config/rs6000/rs6000.h (TARGET_TOC): Define in terms of
TARGET_HAS_TOC and not pc-relative.
(TARGET_NO_TOC_OR_PCREL): New macro to replace TARGET_NO_TOC.
* config/rs6000/sysv4.h (TARGET_HAS_TOC): Rename TARGET_TOC to
TARGET_HAS_TOC.
(TARGET_TOC): Likewise.
(TARGET_NO_TOC): Delete here, define TARGET_NO_TOC_OR_PCREL in
rs6000.h.

From-SVN: r273579

gcc/ChangeLog
gcc/config/rs6000/aix.h
gcc/config/rs6000/darwin.h
gcc/config/rs6000/linux64.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.h
gcc/config/rs6000/sysv4.h

index 4a64253a3c039616d01ff23f85e0193d7fce2441..151297aab74c63fd7181a0f11be07ce1fc82df7b 100644 (file)
@@ -1,3 +1,39 @@
+2019-07-18  Michael Meissner  <meissner@linux.ibm.com>
+
+       * config/rs6000/aix.h (TARGET_HAS_TOC): Rename TARGET_TOC to
+       TARGET_HAS_TOC.
+       (TARGET_TOC): Likewise.
+       (TARGET_NO_TOC): Delete here, define TARGET_NO_TOC_OR_PCREL in
+       rs6000.h.
+       * config/rs6000/darwin.h (TARGET_HAS_TOC): Rename TARGET_TOC to
+       TARGET_HAS_TOC.
+       (TARGET_TOC): Likewise.
+       (TARGET_NO_TOC): Delete here, define TARGET_NO_TOC_OR_PCREL in
+       rs6000.h.
+       * config/rs6000/linux64.h (TARGET_HAS_TOC): Rename TARGET_TOC to
+       TARGET_HAS_TOC.
+       (TARGET_TOC): Likewise.
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Add
+       check to require -mcmodel=medium for pc-relative addressing.
+       (create_TOC_reference): Add assertion for TARGET_TOC.
+       (rs6000_legitimize_address): Use TARGET_NO_TOC_OR_PCREL instead of
+       TARGET_NO_TOC.
+       (rs6000_emit_move): Likewise.
+       (TOC_alias_set): Rename TOC alias set static variable from 'set'
+       to 'TOC_alias_set'.
+       (get_TOC_alias_set): Likewise.
+       (output_toc): Use TARGET_NO_TOC_OR_PCREL instead of
+       TARGET_NO_TOC.
+       (rs6000_can_eliminate): Likewise.
+       * config/rs6000/rs6000.h (TARGET_TOC): Define in terms of
+       TARGET_HAS_TOC and not pc-relative.
+       (TARGET_NO_TOC_OR_PCREL): New macro to replace TARGET_NO_TOC.
+       * config/rs6000/sysv4.h (TARGET_HAS_TOC): Rename TARGET_TOC to
+       TARGET_HAS_TOC.
+       (TARGET_TOC): Likewise.
+       (TARGET_NO_TOC): Delete here, define TARGET_NO_TOC_OR_PCREL in
+       rs6000.h.
+
 2019-07-18  Uroš Bizjak  <ubizjak@gmail.com>
 
        PR target/91188
index 01e1e74379a4e4a447cd83ef8b0fe6c75cf9481c..75e080e93a7c2ab70a2336cda25a0794b193db96 100644 (file)
@@ -32,8 +32,7 @@
 #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.  */
index 272cd4541897420b962563c93aeb2de539c3b8ab..1bfb577750e105875257d2472f462d77cef909ee 100644 (file)
@@ -43,8 +43,7 @@
 
 /* We're not ever going to do TOCs.  */
 
-#define TARGET_TOC 0
-#define TARGET_NO_TOC 1
+#define TARGET_HAS_TOC 0
 
 /* Override the default rs6000 definition.  */
 #undef  PTRDIFF_TYPE
index 5380f6a6a6f1cb3e8d9734f5037646ecafa02fee..bd197492cc2bc48570e807ef0be7150c0930827a 100644 (file)
@@ -277,8 +277,8 @@ extern int dot_symbols;
 #ifndef RS6000_BI_ARCH
 
 /* 64-bit PowerPC Linux always has a TOC.  */
-#undef  TARGET_TOC
-#define        TARGET_TOC              1
+#undef  TARGET_HAS_TOC
+#define TARGET_HAS_TOC         1
 
 /* Some things from sysv4.h we don't do when 64 bit.  */
 #undef OPTION_RELOCATABLE
index 63f3075a98d45110b37323204c25233b337c4060..3f641042c52a28a3f2c791347225d7fada27e2d6 100644 (file)
@@ -4333,6 +4333,16 @@ rs6000_option_override_internal (bool global_init_p)
   SUB3TARGET_OVERRIDE_OPTIONS;
 #endif
 
+  /* -mpcrel requires -mcmodel=medium, but we can't check TARGET_CMODEL until
+      after the subtarget override options are done.  */
+  if (TARGET_PCREL && TARGET_CMODEL != CMODEL_MEDIUM)
+    {
+      if ((rs6000_isa_flags_explicit & OPTION_MASK_PCREL) != 0)
+       error ("%qs requires %qs", "-mpcrel", "-mcmodel=medium");
+
+      rs6000_isa_flags &= ~OPTION_MASK_PCREL;
+    }
+
   if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
     rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
 
@@ -7742,6 +7752,8 @@ create_TOC_reference (rtx symbol, rtx largetoc_reg)
 {
   rtx tocrel, tocreg, hi;
 
+  gcc_assert (TARGET_TOC);
+
   if (TARGET_DEBUG_ADDR)
     {
       if (SYMBOL_REF_P (symbol))
@@ -8121,7 +8133,7 @@ rs6000_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED,
 #endif
            )
           && TARGET_32BIT
-          && TARGET_NO_TOC
+          && TARGET_NO_TOC_OR_PCREL
           && !flag_pic
           && !CONST_INT_P (x)
           && !CONST_WIDE_INT_P (x)
@@ -9811,7 +9823,7 @@ rs6000_emit_move (rtx dest, rtx source, machine_mode mode)
        }
 
       if ((TARGET_ELF || DEFAULT_ABI == ABI_DARWIN)
-         && TARGET_NO_TOC
+         && TARGET_NO_TOC_OR_PCREL
          && ! flag_pic
          && mode == Pmode
          && CONSTANT_P (operands[1])
@@ -23725,14 +23737,14 @@ rs6000_split_multireg_move (rtx dst, rtx src)
     }
 }
 
-static GTY(()) alias_set_type set = -1;
+static GTY(()) alias_set_type TOC_alias_set = -1;
 
 alias_set_type
 get_TOC_alias_set (void)
 {
-  if (set == -1)
-    set = new_alias_set ();
-  return set;
+  if (TOC_alias_set == -1)
+    TOC_alias_set = new_alias_set ();
+  return TOC_alias_set;
 }
 
 /* Return the internal arg pointer used for function incoming
@@ -24103,7 +24115,7 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode)
   rtx base = x;
   HOST_WIDE_INT offset = 0;
 
-  gcc_assert (!TARGET_NO_TOC);
+  gcc_assert (!TARGET_NO_TOC_OR_PCREL);
 
   /* When the linker won't eliminate them, don't output duplicate
      TOC entries (this happens on AIX if there is any kind of TOC,
@@ -30469,7 +30481,7 @@ rs6000_can_eliminate (const int from, const int to)
   return (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM
          ? ! frame_pointer_needed
          : from == RS6000_PIC_OFFSET_TABLE_REGNUM
-           ? ! TARGET_MINIMAL_TOC || TARGET_NO_TOC
+           ? ! TARGET_MINIMAL_TOC || TARGET_NO_TOC_OR_PCREL
                || constant_pool_empty_p ()
            : true);
 }
index 5f3b9edd388071e0477dc290990f53c4a057a76a..70e0616ee85e7d4d0d22bead431af641ced466a2 100644 (file)
 #define TARGET_AIX_OS 0
 #endif
 
+/* Turn off TOC support if pc-relative addressing is used.  */
+#define TARGET_TOC             (TARGET_HAS_TOC && !TARGET_PCREL)
+
+/* On 32-bit systems without a TOC or pc-relative addressing, we need to use
+   ADDIS/ADDI to load up the address of a symbol.  */
+#define TARGET_NO_TOC_OR_PCREL (!TARGET_HAS_TOC && !TARGET_PCREL)
+
 /* Control whether function entry points use a "dot" symbol when
    ABI_AIX.  */
 #define DOT_SYMBOLS 1
index 3861efdfee6fcd95a9ff792f22c0134797c2ed74..17fea80a0a53d90782ce500a38172d8e40d58164 100644 (file)
@@ -41,7 +41,7 @@
 #undef ASM_DEFAULT_SPEC
 #define        ASM_DEFAULT_SPEC "-mppc"
 
-#define        TARGET_TOC              (TARGET_64BIT                           \
+#define        TARGET_HAS_TOC          (TARGET_64BIT                           \
                                 || (TARGET_MINIMAL_TOC                 \
                                     && flag_pic > 1)                   \
                                 || DEFAULT_ABI != ABI_V4)
@@ -50,7 +50,6 @@
 #define        TARGET_BIG_ENDIAN       (! TARGET_LITTLE_ENDIAN)
 #define        TARGET_PROTOTYPE        target_prototype
 #define        TARGET_NO_PROTOTYPE     (! TARGET_PROTOTYPE)
-#define        TARGET_NO_TOC           (! TARGET_TOC)
 #define        TARGET_NO_EABI          (! TARGET_EABI)
 #define        TARGET_REGNAMES         rs6000_regnames