sparc/sparc.h currently defaults to TARGET_SUN_TLS. All other SPARC
targets and Solaris with GNU as have to override this, although this is
only needed on Solaris/SPARC with the native assembler.
To simplify the code, this patch switches the default to TARGET_SUN_TLS
set to 0, removing the need for all the overrides.
TARGET_GNU_TLS is only used in two places and can be replaced by
!TARGET_SUN_TLS, too.
Bootstrapped without regressions on sparc-sun-solaris2.11 (as and gas)
and sparc64-unknown-linux-gnu.
Ok for trunk?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2026-01-13 Rainer Orth <[email protected]>
gcc:
* config/sparc/sparc.h (TARGET_TLS): Define as HAVE_AS_TLS.
Update comment.
(TARGET_SUN_TLS): Define as 0.
(TARGET_GNU_TLS): Remove.
* config/sparc/freebsd.h (TARGET_SUN_TLS): Remove.
(TARGET_GNU_TLS): Remove.
* config/sparc/linux.h: Likewise.
* config/sparc/linux64.h: Likewise.
* config/sparc/sol2.h (TARGET_SUN_TLS): Redefine as 1.
Guard with HAVE_AS_TLS && !HAVE_GNU_AS.
(TARGET_GNU_TLS): Remove.
* config/sparc/sparc.cc (TARGET_ASM_OUTPUT_DWARF_DTPREL): Use
!TARGET_SUN_TLS in guard.
with !TARGET_SUN_TLS only.
* config/sparc/sparc.md ("tls_delay_slot"): Guard with
!TARGET_SUN_TLS.
# HG changeset patch
# Parent ab02b660468d6f7d286639a5d7a9fce4f2fd2857
sparc: Switch TARGET_GNU_TLS default
diff --git a/gcc/config/sparc/freebsd.h b/gcc/config/sparc/freebsd.h
--- a/gcc/config/sparc/freebsd.h
+++ b/gcc/config/sparc/freebsd.h
@@ -118,13 +118,6 @@ along with GCC; see the file COPYING3.
/* #define DWARF_OFFSET_SIZE PTR_SIZE */
-#ifdef HAVE_AS_TLS
-#undef TARGET_SUN_TLS
-#undef TARGET_GNU_TLS
-#define TARGET_SUN_TLS 0
-#define TARGET_GNU_TLS 1
-#endif
-
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
"%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}} " \
diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
--- a/gcc/config/sparc/linux.h
+++ b/gcc/config/sparc/linux.h
@@ -120,13 +120,6 @@ do { \
#undef DITF_CONVERSION_LIBFUNCS
#define DITF_CONVERSION_LIBFUNCS 1
-#ifdef HAVE_AS_TLS
-#undef TARGET_SUN_TLS
-#undef TARGET_GNU_TLS
-#define TARGET_SUN_TLS 0
-#define TARGET_GNU_TLS 1
-#endif
-
/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
--- a/gcc/config/sparc/linux64.h
+++ b/gcc/config/sparc/linux64.h
@@ -264,13 +264,6 @@ do { \
#undef DITF_CONVERSION_LIBFUNCS
#define DITF_CONVERSION_LIBFUNCS 1
-#ifdef HAVE_AS_TLS
-#undef TARGET_SUN_TLS
-#undef TARGET_GNU_TLS
-#define TARGET_SUN_TLS 0
-#define TARGET_GNU_TLS 1
-#endif
-
/* We use GNU ld so undefine this so that attribute((init_priority)) works. */
#undef CTORS_SECTION_ASM_OP
#undef DTORS_SECTION_ASM_OP
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
@@ -326,12 +326,8 @@ extern const char *host_detect_local_cpu
/* Register the Solaris-specific #pragma directives. */
#define REGISTER_TARGET_PRAGMAS() solaris_register_pragmas ()
-#if HAVE_GNU_AS && defined(HAVE_AS_TLS)
-/* Use GNU extensions to TLS support. */
-#undef TARGET_SUN_TLS
-#undef TARGET_GNU_TLS
-#define TARGET_SUN_TLS 0
-#define TARGET_GNU_TLS 1
+#if HAVE_AS_TLS && !HAVE_GNU_AS
+#define TARGET_SUN_TLS 1
#endif
#undef 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_GNU_TLS && defined(HAVE_AS_SPARC_UA_PCREL)
+#if !TARGET_SUN_TLS && defined(HAVE_AS_SPARC_UA_PCREL)
#undef TARGET_ASM_OUTPUT_DWARF_DTPREL
#define TARGET_ASM_OUTPUT_DWARF_DTPREL sparc_output_dwarf_dtprel
#endif
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
@@ -1640,16 +1640,10 @@ extern int sparc_indent_opcode;
} \
} while (0)
-/* TLS support defaulting to original Sun flavor. GNU extensions
- must be activated in separate configuration files. */
-#ifdef HAVE_AS_TLS
-#define TARGET_TLS 1
-#else
-#define TARGET_TLS 0
-#endif
-
-#define TARGET_SUN_TLS TARGET_TLS
-#define TARGET_GNU_TLS 0
+/* 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_GNU_TLS && HAVE_GNU_LD) != 0
+ (symbol_ref "((!TARGET_SUN_TLS && HAVE_GNU_LD) != 0
? TLS_DELAY_SLOT_TRUE : TLS_DELAY_SLOT_FALSE)"))
(define_attr "in_sibcall_delay" "false,true"