[committed] Remove __seg_tls before first release

Richard Henderson rth@redhat.com
Tue Feb 23 18:18:00 GMT 2016


The addition of named address spaces to the i386 backend is new for gcc6.

I had invented __seg_tls while thinking about how it might be used within
glibc.  But during the last couple of weeks I've had occasion to attempt to use
the feature within the linux kernel.  There, things weren't quite so easy.

My conclusion is that __seg_tls is too specialized, and that what's really
needed is user-defined named address spaces, so that each project can define
its own mapping between segment base and the generic (flat) address space.

Therefore I have deleted __seg_tls before the first release, so that we don't
have to support this going forward.  The __seg_fs and __seg_gs namespaces are
still present in gcc6, and (with effort and casting) these can still be used to
produce memory references with segment overrides.


r~
-------------- next part --------------
	* config/i386/i386-c.c (ix86_target_macros): Remove __SEG_TLS.
	(ix86_register_pragmas): Remove __seg_tls.
	* config/i386/i386-protos.h (ADDR_SPACE_SEG_TLS): Remove.
	* config/i386/i386.c (ix86_print_operand_address_as): Don't handle it.
	(ix86_addr_space_subset_p, TARGET_ADDR_SPACE_SUBSET_P): Remove.
	(ix86_addr_space_convert, TARGET_ADDR_SPACE_CONVERT): Remove.
	(ix86_addr_space_debug, TARGET_ADDR_SPACE_DEBUG): Remove.
	* doc/extend.texi (__seg_tls): Remove item.
testsuite/
	* gcc.target/i386/addr-space-3.c: Remove test.


diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index ea0c5df..f93a09d 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -591,7 +591,6 @@ ix86_target_macros (void)
 
   cpp_define (parse_in, "__SEG_FS");
   cpp_define (parse_in, "__SEG_GS");
-  cpp_define (parse_in, "__SEG_TLS");
 }
 
 

@@ -608,7 +607,6 @@ ix86_register_pragmas (void)
 
   c_register_addr_space ("__seg_fs", ADDR_SPACE_SEG_FS);
   c_register_addr_space ("__seg_gs", ADDR_SPACE_SEG_GS);
-  c_register_addr_space ("__seg_tls", ADDR_SPACE_SEG_TLS);
 
 #ifdef REGISTER_SUBTARGET_PRAGMAS
   REGISTER_SUBTARGET_PRAGMAS ();
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 252bb19..e4652f3 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -332,4 +332,3 @@ struct ix86_first_cycle_multipass_data_
 
 const addr_space_t ADDR_SPACE_SEG_FS = 1;
 const addr_space_t ADDR_SPACE_SEG_GS = 2;
-const addr_space_t ADDR_SPACE_SEG_TLS = 3;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 29c73f6..d8a2909 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -17395,8 +17395,6 @@ ix86_print_operand_address_as (FILE *file, rtx addr,
     {
       const char *string;
 
-      if (as == ADDR_SPACE_SEG_TLS)
-	as = DEFAULT_TLS_SEG_REG;
       if (as == ADDR_SPACE_SEG_FS)
 	string = (ASSEMBLER_DIALECT == ASM_ATT ? "%fs:" : "fs:");
       else if (as == ADDR_SPACE_SEG_GS)
@@ -54256,54 +54254,8 @@ ix86_optab_supported_p (int op, machine_mode mode1, machine_mode,
         without resorting to a system call, we cannot convert a
         non-default address space to a default address space.
         Therefore we do not claim %fs or %gs are subsets of generic.
-    (e) However, __seg_tls uses UNSPEC_TP as the base (which itself is
-	stored at __seg_tls:0) so we can map between tls and generic.  */
 
-static bool
-ix86_addr_space_subset_p (addr_space_t subset, addr_space_t superset)
-{
-    return (subset == superset
-	    || (superset == ADDR_SPACE_GENERIC
-		&& subset == ADDR_SPACE_SEG_TLS));
-}
-#undef TARGET_ADDR_SPACE_SUBSET_P
-#define TARGET_ADDR_SPACE_SUBSET_P ix86_addr_space_subset_p
-
-static rtx
-ix86_addr_space_convert (rtx op, tree from_type, tree to_type)
-{
-  addr_space_t from_as = TYPE_ADDR_SPACE (TREE_TYPE (from_type));
-  addr_space_t to_as = TYPE_ADDR_SPACE (TREE_TYPE (to_type));
-
-  /* Conversion between SEG_TLS and GENERIC is handled by adding or
-     subtracting the thread pointer.  */
-  if ((from_as == ADDR_SPACE_GENERIC && to_as == ADDR_SPACE_SEG_TLS)
-      || (from_as == ADDR_SPACE_SEG_TLS && to_as == ADDR_SPACE_GENERIC))
-    {
-      machine_mode mode = GET_MODE (op);
-      if (mode == VOIDmode)
-	mode = ptr_mode;
-      rtx tp = get_thread_pointer (mode, optimize || mode != ptr_mode);
-      return expand_binop (mode, (to_as == ADDR_SPACE_GENERIC
-				  ? add_optab : sub_optab),
-			   op, tp, NULL, 1, OPTAB_WIDEN);
-    }
-
-  return op;
-}
-#undef TARGET_ADDR_SPACE_CONVERT
-#define TARGET_ADDR_SPACE_CONVERT ix86_addr_space_convert
-
-static int
-ix86_addr_space_debug (addr_space_t as)
-{
-  /* Fold __seg_tls to __seg_fs or __seg_gs for debugging.  */
-  if (as == ADDR_SPACE_SEG_TLS)
-    as = DEFAULT_TLS_SEG_REG;
-  return as;
-}
-#undef TARGET_ADDR_SPACE_DEBUG
-#define TARGET_ADDR_SPACE_DEBUG ix86_addr_space_debug
+   Therefore we can (mostly) use the default hooks.  */
 
 /* All use of segmentation is assumed to make address 0 valid.  */
 
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 476d089..4abb0df 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1473,23 +1473,6 @@ that it installed previously.
 
 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
 defined when these address spaces are supported.
-
-@item __seg_tls
-@cindex @code{__seg_tls} x86 named address space
-Some operating systems define either the @code{%fs} or @code{%gs}
-segment as the thread-local storage base for each thread.  Objects
-within this address space are accessed with the appropriate
-segment override prefix.
-
-The pointer located at address 0 within the segment contains the
-offset of the segment within the generic address space.  Thus this
-address space is considered a subspace of the generic address space,
-and the known segment offset is applied when converting addresses
-to and from the generic address space.
-
-The preprocessor symbol @code{__SEG_TLS} is defined when this
-address space is supported.
-
 @end table
 
 @node Zero Length
diff --git a/gcc/testsuite/gcc.target/i386/addr-space-3.c b/gcc/testsuite/gcc.target/i386/addr-space-3.c
deleted file mode 100644
index 2b6f47e..0000000
--- a/gcc/testsuite/gcc.target/i386/addr-space-3.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O" } */
-/* { dg-final { scan-assembler "\[fg]s:0" } } */
-
-void test(int *y)
-{
-  int *x = (int __seg_tls *)0;
-  if (x == y)
-    asm("");
-}


More information about the Gcc-patches mailing list