All remaining uses of TARGET_SUN_TLS refer to either

* a feature missing in Solaris as:

  Lack of support for R_SPARC_TLS_DTPOFF{32,64}: while Solaris ld
  supports those just fine, I know of no Solaris as syntax for them.

* workarounds for bugs in Solaris as in sparc_tls_got,
  sparc_legitimize_tls_address, and the tls_delay_slot attribute

Therefor this patch replaces all uses of TARGET_SUN_TLS with
!HAVE_GNU_AS.

Bootstrapped without regressions on sparc-sun-solaris2.11,
sparcv9-sun-solaris2.11 (as and gas), and sparc64-unknown-linux-gnu.

Ok for trunk?

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2026-01-14  Rainer Orth  <[email protected]>

        gcc:
        * config/sparc/sparc.h (TARGET_SUN_TLS): Remove.
        * config/sparc/sol2.h (TARGET_SUN_TLS): Likewise.

        * config/sparc/sparc.cc (TARGET_ASM_OUTPUT_DWARF_DTPREL): Guard
        with HAVE_GNU_AS.
        (sparc_tls_got): Guard with !HAVE_GNU_AS.
        (sparc_legitimize_tls_address): Likewise.
        * config/sparc/sparc.md ("tls_delay_slot"): Likewise.
        ("@tie_add<P:mode>"): Likewise.

# HG changeset patch
# Parent  8e46d1362cc4a0821ab098c1937424d49bebc666
sparc: Remove TARGET_SUN_TLS

diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h
--- a/gcc/config/sparc/sol2.h
+++ b/gcc/config/sparc/sol2.h
@@ -315,11 +315,6 @@ extern const char *host_detect_local_cpu
 /* Register the Solaris-specific #pragma directives.  */
 #define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas ()
 
-#if HAVE_AS_TLS && !HAVE_GNU_AS
-#undef	TARGET_SUN_TLS
-#define TARGET_SUN_TLS 1
-#endif
-
 #undef  LOCAL_LABEL_PREFIX
 #define LOCAL_LABEL_PREFIX  "."
 
diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc
--- a/gcc/config/sparc/sparc.cc
+++ b/gcc/config/sparc/sparc.cc
@@ -877,7 +877,7 @@ char sparc_hard_reg_printed[8];
 #define TARGET_STACK_PROTECT_GUARD hook_tree_void_null
 #endif
 
-#if !TARGET_SUN_TLS
+#if HAVE_GNU_AS
 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
 #define TARGET_ASM_OUTPUT_DWARF_DTPREL sparc_output_dwarf_dtprel
 #endif
@@ -4701,7 +4701,7 @@ sparc_tls_got (void)
 
   /* In non-PIC mode, Sun as (unlike GNU as) emits PC-relative relocations for
      the GOT symbol with the 32-bit ABI, so we reload the GOT register.  */
-  if (TARGET_SUN_TLS && TARGET_ARCH32)
+  if (!HAVE_GNU_AS && TARGET_ARCH32)
     {
       load_got_register ();
       return got_register_rtx;
@@ -4805,7 +4805,7 @@ sparc_legitimize_tls_address (rtx addr)
 	  emit_insn (gen_tie_ld32 (temp3, got, temp2, addr));
 	else
 	  emit_insn (gen_tie_ld64 (temp3, got, temp2, addr));
-        if (TARGET_SUN_TLS)
+        if (!HAVE_GNU_AS)
 	  {
 	    ret = gen_reg_rtx (Pmode);
 	    emit_insn (gen_tie_add (Pmode, ret, gen_rtx_REG (Pmode, 7),
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -1623,7 +1623,6 @@ extern int sparc_indent_opcode;
 /* TLS support defaults to GNU extensions.  The original Sun flavor must be
    activated in separate configuration files.  */
 #define TARGET_TLS HAVE_AS_TLS
-#define TARGET_SUN_TLS 0
 
 #ifdef HAVE_AS_FMAF_HPC_VIS3
 #define AS_NIAGARA3_FLAG "d"
diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md
--- a/gcc/config/sparc/sparc.md
+++ b/gcc/config/sparc/sparc.md
@@ -557,7 +557,7 @@
 
 ;; Attributes for branch scheduling
 (define_attr "tls_delay_slot" "false,true"
-  (symbol_ref "((!TARGET_SUN_TLS && HAVE_GNU_LD) != 0
+  (symbol_ref "((HAVE_GNU_AS && HAVE_GNU_LD) != 0
 		? TLS_DELAY_SLOT_TRUE : TLS_DELAY_SLOT_FALSE)"))
 
 (define_attr "in_sibcall_delay" "false,true"
@@ -8070,7 +8070,7 @@
 		(unspec:P [(match_operand:P 2 "register_operand" "r")
 			   (match_operand 3 "tie_symbolic_operand" "")]
 			  UNSPEC_TLSIE)))]
-  "TARGET_SUN_TLS"
+  "!HAVE_GNU_AS"
   "add\\t%1, %2, %0, %%tie_add(%a3)")
 
 (define_insn "@tle_hix22<P:mode>"

Reply via email to