Since the last patch untangled inline PLT and TLS marker support there
now isn't a way of requesting the older long call sequences on a
compiler built with inline PLT support.  This patch adds support for
a new -mno-pltseq option.

Bootstrapped etc. powerpc64le-linux and powerpc64-linux.  OK?

        * config/rs6000/rs6000.opt (mpltseq): New option.
        * config/rs6000/rs6000.h (TARGET_PLTSEQ): Define.
        * config/rs6000/rs6000.c (rs6000_option_override_internal): Error
        if given -mpltseq when assembler support is lacking.
        (rs6000_indirect_call_template_1, rs6000_longcall_ref),
        (rs6000_call_aix, rs6000_call_sysv, rs6000_sibcall_sysv): Replace
        uses of HAVE_AS_PLTSEQ with TARGET_PLTSEQ.
        * config/rs6000/rs6000.md (pltseq_tocsave_<mode>),
        (pltseq_plt16_ha_<mode>, pltseq_plt16_lo_<mode>),
        (pltseq_mtctr_<mode>): Likewise.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index c126734d3e6..e846e676810 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -4513,6 +4513,9 @@ rs6000_option_override_internal (bool global_init_p)
   if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
     rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
 
+  if (global_options_set.x_rs6000_pltseq && TARGET_PLTSEQ != rs6000_pltseq)
+    error ("%qs not supported by your assembler", "-mpltseq");
+
   rs6000_always_hint = (rs6000_tune != PROCESSOR_POWER4
                        && rs6000_tune != PROCESSOR_POWER5
                        && rs6000_tune != PROCESSOR_POWER6
@@ -21613,7 +21616,7 @@ rs6000_indirect_call_template_1 (rtx *operands, 
unsigned int funop,
                    || (REG_P (operands[funop])
                        && REGNO (operands[funop]) == LR_REGNO));
 
-  if (!TARGET_MACHO && HAVE_AS_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC)
+  if (!TARGET_MACHO && TARGET_PLTSEQ && GET_CODE (operands[funop]) == UNSPEC)
     {
       const char *rel64 = TARGET_64BIT ? "64" : "";
       char tls[29];
@@ -32767,7 +32770,7 @@ rs6000_longcall_ref (rtx call_ref, rtx arg)
       call_ref = gen_rtx_SYMBOL_REF (VOIDmode, IDENTIFIER_POINTER (node));
     }
 
-  if (HAVE_AS_PLTSEQ
+  if (TARGET_PLTSEQ
       && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4))
     {
       rtx base = const0_rtx;
@@ -37765,7 +37768,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
                                             gen_rtx_PLUS (Pmode, stack_ptr,
                                                           stack_toc_offset));
          MEM_VOLATILE_P (stack_toc_mem) = 1;
-         if (HAVE_AS_PLTSEQ
+         if (TARGET_PLTSEQ
              && DEFAULT_ABI == ABI_ELFv2
              && GET_CODE (func_desc) == SYMBOL_REF)
            {
@@ -37789,7 +37792,7 @@ rs6000_call_aix (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
             calls via LR, so move the address there.  Needed to mark
             this insn for linker plt sequence editing too.  */
          func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
-         if (HAVE_AS_PLTSEQ
+         if (TARGET_PLTSEQ
              && GET_CODE (func_desc) == SYMBOL_REF)
            {
              rtvec v = gen_rtvec (3, abi_reg, func_desc, tlsarg);
@@ -37930,7 +37933,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
       func = rs6000_longcall_ref (func_desc, tlsarg);
       /* If the longcall was implemented using PLT16 relocs, then r11
         needs to be valid at the call for lazy linking.  */
-      if (HAVE_AS_PLTSEQ)
+      if (TARGET_PLTSEQ)
        abi_reg = func;
     }
 
@@ -37943,7 +37946,7 @@ rs6000_call_sysv (rtx value, rtx func_desc, rtx tlsarg, 
rtx cookie)
         calls via LR, so move the address there.  Needed to mark
         this insn for linker plt sequence editing too.  */
       func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
-      if (HAVE_AS_PLTSEQ
+      if (TARGET_PLTSEQ
          && GET_CODE (func_desc) == SYMBOL_REF)
        {
          rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
@@ -38000,7 +38003,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx 
tlsarg, rtx cookie)
       func = rs6000_longcall_ref (func_desc, tlsarg);
       /* If the longcall was implemented using PLT16 relocs, then r11
         needs to be valid at the call for lazy linking.  */
-      if (HAVE_AS_PLTSEQ)
+      if (TARGET_PLTSEQ)
        abi_reg = func;
     }
 
@@ -38012,7 +38015,7 @@ rs6000_sibcall_sysv (rtx value, rtx func_desc, rtx 
tlsarg, rtx cookie)
       /* Indirect sibcalls must go via CTR.  Needed to mark
         this insn for linker plt sequence editing too.  */
       func_addr = gen_rtx_REG (Pmode, CTR_REGNO);
-      if (HAVE_AS_PLTSEQ
+      if (TARGET_PLTSEQ
          && GET_CODE (func_desc) == SYMBOL_REF)
        {
          rtvec v = gen_rtvec (3, func, func_desc, tlsarg);
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 9c0cc8de2b6..5ffa55e562c 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -226,6 +226,12 @@ extern const char *host_detect_local_cpu (int argc, const 
char **argv);
 #define HAVE_AS_PLTSEQ 0
 #endif
 
+#if !HAVE_AS_PLTSEQ
+#define TARGET_PLTSEQ 0
+#else
+#define TARGET_PLTSEQ rs6000_pltseq
+#endif
+
 #ifndef TARGET_LINK_STACK
 #define TARGET_LINK_STACK 0
 #endif
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 58070447639..b028b48aacc 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -10250,7 +10250,7 @@ (define_insn "*pltseq_tocsave_<mode>"
                   (match_operand:P 2 "symbol_ref_operand" "s")
                   (match_operand:P 3 "" "")]
                  UNSPEC_PLTSEQ))]
-  "HAVE_AS_PLTSEQ
+  "TARGET_PLTSEQ
    && DEFAULT_ABI == ABI_ELFv2"
 {
   return rs6000_pltseq_template (operands, 0);
@@ -10262,7 +10262,7 @@ (define_insn "*pltseq_plt16_ha_<mode>"
                   (match_operand:P 2 "symbol_ref_operand" "s")
                   (match_operand:P 3 "" "")]
                  UNSPEC_PLT16_HA))]
-  "HAVE_AS_PLTSEQ
+  "TARGET_PLTSEQ
    && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)"
 {
   return rs6000_pltseq_template (operands, 1);
@@ -10274,7 +10274,7 @@ (define_insn "*pltseq_plt16_lo_<mode>"
                   (match_operand:P 2 "symbol_ref_operand" "s")
                   (match_operand:P 3 "" "")]
                  UNSPEC_PLT16_LO))]
-  "HAVE_AS_PLTSEQ
+  "TARGET_PLTSEQ
    && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)"
 {
   return rs6000_pltseq_template (operands, 2);
@@ -10287,7 +10287,7 @@ (define_insn "*pltseq_mtctr_<mode>"
                   (match_operand:P 2 "symbol_ref_operand" "s")
                   (match_operand:P 3 "" "")]
                  UNSPEC_PLTSEQ))]
-  "HAVE_AS_PLTSEQ
+  "TARGET_PLTSEQ
    && (DEFAULT_ABI == ABI_ELFv2 || DEFAULT_ABI == ABI_V4)"
 {
   return rs6000_pltseq_template (operands, 3);
diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
index 2e90bf37747..3f94bb7671c 100644
--- a/gcc/config/rs6000/rs6000.opt
+++ b/gcc/config/rs6000/rs6000.opt
@@ -405,6 +405,10 @@ mlongcall
 Target Report Var(rs6000_default_long_calls) Save
 Avoid all range limits on call instructions.
 
+mpltseq
+Target Report Var(rs6000_pltseq) Init(1) Save
+Use inline plt sequences to implement long calls.
+
 ; This option existed in the past, but now is always on.
 mgen-cell-microcode
 Target RejectNegative Undocumented Ignore

-- 
Alan Modra
Australia Development Lab, IBM

Reply via email to