minor tls cleanup

Richard Henderson rth@redhat.com
Sat May 25 01:27:00 GMT 2002


Changing the tls_model enum to start at one means we can use it
directly as a truth value from predicates.  Which is handy since
we don't have to re-scan the rtl a second time to find out what
kind of tls transformation should be applied.


r~


        * flags.h (TLS_MODEL_GLOBAL_DYNAMIC): Set to 1.
        * toplev.c (flag_tls_default) Set to TLS_MODEL_GLOBAL_DYNAMIC.
        * config/i386/i386.c (tls_model_chars): Add leading space.
        (tls_symbolic_operand): Don't bias by 1.
        (legitimize_address): Don't unbias by 1.

Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.85
diff -c -p -d -u -r1.85 flags.h
--- flags.h	22 May 2002 01:11:16 -0000	1.85
+++ flags.h	25 May 2002 01:53:55 -0000
@@ -466,7 +466,7 @@ extern int flag_pic;
 /* Set to the default thread-local storage (tls) model to use.  */
 
 enum tls_model {
-  TLS_MODEL_GLOBAL_DYNAMIC,
+  TLS_MODEL_GLOBAL_DYNAMIC = 1,
   TLS_MODEL_LOCAL_DYNAMIC,
   TLS_MODEL_INITIAL_EXEC,
   TLS_MODEL_LOCAL_EXEC
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.634
diff -c -p -d -u -r1.634 toplev.c
--- toplev.c	23 May 2002 23:36:56 -0000	1.634
+++ toplev.c	25 May 2002 01:53:55 -0000
@@ -692,7 +692,7 @@ int flag_pic;
 
 /* Set to the default thread-local storage (tls) model to use.  */
 
-enum tls_model flag_tls_default;
+enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
 
 /* Nonzero means generate extra code for exception handling and enable
    exception handling.  */
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.408
diff -c -p -d -u -r1.408 i386.c
--- config/i386/i386.c	23 May 2002 21:55:27 -0000	1.408
+++ config/i386/i386.c	25 May 2002 01:53:55 -0000
@@ -546,7 +546,7 @@ rtx ix86_compare_op1 = NULL_RTX;
 
 /* The encoding characters for the four TLS models present in ELF.  */
 
-static char const tls_model_chars[] = "GLil";
+static char const tls_model_chars[] = " GLil";
 
 #define MAX_386_STACK_LOCALS 3
 /* Size of the register save area.  */
@@ -3007,7 +3007,7 @@ tls_symbolic_operand (op, mode)
 
   if (symbol_str[0] != '%')
     return 0;
-  return strchr (tls_model_chars, symbol_str[1]) - tls_model_chars + 1;
+  return strchr (tls_model_chars, symbol_str[1]) - tls_model_chars;
 }
 
 static int
@@ -5490,13 +5490,12 @@ legitimize_address (x, oldx, mode)
       debug_rtx (x);
     }
 
-  /* Note that tls_symbolic_operand return is biased by 1 to return true.  */
   log = tls_symbolic_operand (x, mode);
   if (log)
     {
       rtx dest, base, off, pic;
 
-      switch (log - 1)
+      switch (log)
         {
         case TLS_MODEL_GLOBAL_DYNAMIC:
 	  dest = gen_reg_rtx (Pmode);



More information about the Gcc-patches mailing list