This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[i386] Use symbol_ref flags


First cleanup enabled by the previous symbol_ref patch.
We no longer need to frob the symbol string to support TLS.


r~

        * config/i386/i386.c (tls_model_chars): Remove.
        (ix86_encode_section_info, ix86_strip_name_encoding): Remove.
        (local_symbolic_operand): Use SYMBOL_REF_LOCAL_P.
        (tls_symbolic_operand): Use SYMBOL_REF_TLS_MODEL.
        (tls_symbolic_operand_1): Likewise.
        (legitimate_pic_address_disp_p): Use SYMBOL_REF_LOCAL_P.
        * config/i386/i386.h (TARGET_ENCODE_SECTION_INFO): Remove.
        (TARGET_STRIP_NAME_ENCODING, ASM_OUTPUT_LABELREF): Remove.
        * config/i386/winnt.c (i386_pe_encode_section_info): Replace
        bits "copied from i386.h" with default_encode_section_info.

Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.559
diff -c -p -d -r1.559 i386.c
*** config/i386/i386.c	10 Apr 2003 18:55:33 -0000	1.559
--- config/i386/i386.c	11 Apr 2003 21:23:17 -0000
*************** int const svr4_dbx_register_map[FIRST_PS
*** 668,677 ****
  rtx ix86_compare_op0 = NULL_RTX;
  rtx ix86_compare_op1 = NULL_RTX;
  
- /* The encoding characters for the four TLS models present in ELF.  */
- 
- static char const tls_model_chars[] = " GLil";
- 
  #define MAX_386_STACK_LOCALS 3
  /* Size of the register save area.  */
  #define X86_64_VARARGS_SIZE (REGPARM_MAX * UNITS_PER_WORD + SSE_REGPARM_MAX * 16)
--- 668,673 ----
*************** static int ix86_address_cost PARAMS ((rt
*** 845,854 ****
  static bool ix86_cannot_force_const_mem PARAMS ((rtx));
  static rtx ix86_delegitimize_address PARAMS ((rtx));
  
- static void ix86_encode_section_info PARAMS ((tree, int)) ATTRIBUTE_UNUSED;
- static const char *ix86_strip_name_encoding PARAMS ((const char *))
-      ATTRIBUTE_UNUSED;
- 
  struct builtin_description;
  static rtx ix86_expand_sse_comi PARAMS ((const struct builtin_description *,
  					 tree, rtx));
--- 841,846 ----
*************** local_symbolic_operand (op, mode)
*** 3497,3505 ****
    if (GET_CODE (op) != SYMBOL_REF)
      return 0;
  
!   /* These we've been told are local by varasm and encode_section_info
!      respectively.  */
!   if (CONSTANT_POOL_ADDRESS_P (op) || SYMBOL_REF_FLAG (op))
      return 1;
  
    /* There is, however, a not insubstantial body of code in the rest of
--- 3489,3495 ----
    if (GET_CODE (op) != SYMBOL_REF)
      return 0;
  
!   if (SYMBOL_REF_LOCAL_P (op))
      return 1;
  
    /* There is, however, a not insubstantial body of code in the rest of
*************** local_symbolic_operand (op, mode)
*** 3514,3549 ****
    return 0;
  }
  
! /* Test for various thread-local symbols.  See ix86_encode_section_info. */
  
  int
  tls_symbolic_operand (op, mode)
       register rtx op;
       enum machine_mode mode ATTRIBUTE_UNUSED;
  {
-   const char *symbol_str;
- 
    if (GET_CODE (op) != SYMBOL_REF)
      return 0;
!   symbol_str = XSTR (op, 0);
! 
!   if (symbol_str[0] != '%')
!     return 0;
!   return strchr (tls_model_chars, symbol_str[1]) - tls_model_chars;
  }
  
! static int
  tls_symbolic_operand_1 (op, kind)
       rtx op;
       enum tls_model kind;
  {
-   const char *symbol_str;
- 
    if (GET_CODE (op) != SYMBOL_REF)
      return 0;
!   symbol_str = XSTR (op, 0);
! 
!   return symbol_str[0] == '%' && symbol_str[1] == tls_model_chars[kind];
  }
  
  int
--- 3504,3529 ----
    return 0;
  }
  
! /* Test for various thread-local symbols.  */
  
  int
  tls_symbolic_operand (op, mode)
       register rtx op;
       enum machine_mode mode ATTRIBUTE_UNUSED;
  {
    if (GET_CODE (op) != SYMBOL_REF)
      return 0;
!   return SYMBOL_REF_TLS_MODEL (op);
  }
  
! static inline int
  tls_symbolic_operand_1 (op, kind)
       rtx op;
       enum tls_model kind;
  {
    if (GET_CODE (op) != SYMBOL_REF)
      return 0;
!   return SYMBOL_REF_TLS_MODEL (op) == kind;
  }
  
  int
*************** legitimate_pic_address_disp_p (disp)
*** 5773,5780 ****
  	return 0;
        if (GET_CODE (disp) == SYMBOL_REF
  	  && ix86_cmodel == CM_SMALL_PIC
! 	  && (CONSTANT_POOL_ADDRESS_P (disp)
! 	      || SYMBOL_REF_FLAG (disp)))
  	return 1;
        if (GET_CODE (disp) == LABEL_REF)
  	return 1;
--- 5753,5759 ----
  	return 0;
        if (GET_CODE (disp) == SYMBOL_REF
  	  && ix86_cmodel == CM_SMALL_PIC
! 	  && SYMBOL_REF_LOCAL_P (disp))
  	return 1;
        if (GET_CODE (disp) == LABEL_REF)
  	return 1;
*************** legitimate_pic_address_disp_p (disp)
*** 5782,5789 ****
  	  && GET_CODE (XEXP (disp, 0)) == PLUS
  	  && ((GET_CODE (XEXP (XEXP (disp, 0), 0)) == SYMBOL_REF
  	       && ix86_cmodel == CM_SMALL_PIC
! 	       && (CONSTANT_POOL_ADDRESS_P (XEXP (XEXP (disp, 0), 0))
! 		   || SYMBOL_REF_FLAG (XEXP (XEXP (disp, 0), 0))))
  	      || GET_CODE (XEXP (XEXP (disp, 0), 0)) == LABEL_REF)
  	  && GET_CODE (XEXP (XEXP (disp, 0), 1)) == CONST_INT
  	  && INTVAL (XEXP (XEXP (disp, 0), 1)) < 16*1024*1024
--- 5761,5767 ----
  	  && GET_CODE (XEXP (disp, 0)) == PLUS
  	  && ((GET_CODE (XEXP (XEXP (disp, 0), 0)) == SYMBOL_REF
  	       && ix86_cmodel == CM_SMALL_PIC
! 	       && SYMBOL_REF_LOCAL_P (XEXP (XEXP (disp, 0), 0)))
  	      || GET_CODE (XEXP (XEXP (disp, 0), 0)) == LABEL_REF)
  	  && GET_CODE (XEXP (XEXP (disp, 0), 1)) == CONST_INT
  	  && INTVAL (XEXP (XEXP (disp, 0), 1)) < 16*1024*1024
*************** ix86_GOT_alias_set ()
*** 6124,6130 ****
  
     2. Static data references, constant pool addresses, and code labels
        compute the address as an offset from the GOT, whose base is in
!       the PIC reg.  Static data objects have SYMBOL_REF_FLAG set to
        differentiate them from global data objects.  The returned
        address is the PIC reg + an unspec constant.
  
--- 6102,6108 ----
  
     2. Static data references, constant pool addresses, and code labels
        compute the address as an offset from the GOT, whose base is in
!       the PIC reg.  Static data objects have SYMBOL_FLAG_LOCAL set to
        differentiate them from global data objects.  The returned
        address is the PIC reg + an unspec constant.
  
*************** legitimize_pic_address (orig, reg)
*** 6281,6365 ****
  	}
      }
    return new;
- }
- 
- static void
- ix86_encode_section_info (decl, first)
-      tree decl;
-      int first ATTRIBUTE_UNUSED;
- {
-   bool local_p = (*targetm.binds_local_p) (decl);
-   rtx rtl, symbol;
- 
-   rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl);
-   if (GET_CODE (rtl) != MEM)
-     return;
-   symbol = XEXP (rtl, 0);
-   if (GET_CODE (symbol) != SYMBOL_REF)
-     return;
- 
-   /* For basic x86, if using PIC, mark a SYMBOL_REF for a non-global
-      symbol so that we may access it directly in the GOT.  */
- 
-   if (flag_pic)
-     SYMBOL_REF_FLAG (symbol) = local_p;
- 
-   /* For ELF, encode thread-local data with %[GLil] for "global dynamic",
-      "local dynamic", "initial exec" or "local exec" TLS models
-      respectively.  */
- 
-   if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
-     {
-       const char *symbol_str;
-       char *newstr;
-       size_t len;
-       enum tls_model kind = decl_tls_model (decl);
- 
-       if (TARGET_64BIT && ! flag_pic)
- 	{
- 	  /* x86-64 doesn't allow non-pic code for shared libraries,
- 	     so don't generate GD/LD TLS models for non-pic code.  */
- 	  switch (kind)
- 	    {
- 	    case TLS_MODEL_GLOBAL_DYNAMIC:
- 	      kind = TLS_MODEL_INITIAL_EXEC; break;
- 	    case TLS_MODEL_LOCAL_DYNAMIC:
- 	      kind = TLS_MODEL_LOCAL_EXEC; break;
- 	    default:
- 	      break;
- 	    }
- 	}
- 
-       symbol_str = XSTR (symbol, 0);
- 
-       if (symbol_str[0] == '%')
- 	{
- 	  if (symbol_str[1] == tls_model_chars[kind])
- 	    return;
- 	  symbol_str += 2;
- 	}
-       len = strlen (symbol_str) + 1;
-       newstr = alloca (len + 2);
- 
-       newstr[0] = '%';
-       newstr[1] = tls_model_chars[kind];
-       memcpy (newstr + 2, symbol_str, len);
- 
-       XSTR (symbol, 0) = ggc_alloc_string (newstr, len + 2 - 1);
-     }
- }
- 
- /* Undo the above when printing symbol names.  */
- 
- static const char *
- ix86_strip_name_encoding (str)
-      const char *str;
- {
-   if (str[0] == '%')
-     str += 2;
-   if (str [0] == '*')
-     str += 1;
-   return str;
  }
  
  /* Load the thread pointer into a register.  */
--- 6259,6264 ----
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.331
diff -c -p -d -r1.331 i386.h
*** config/i386/i386.h	31 Mar 2003 18:33:23 -0000	1.331
--- config/i386/i386.h	11 Apr 2003 21:23:18 -0000
*************** enum ix86_builtins
*** 2496,2516 ****
    IX86_BUILTIN_MAX
  };
  
- #define TARGET_ENCODE_SECTION_INFO  ix86_encode_section_info
- #define TARGET_STRIP_NAME_ENCODING  ix86_strip_name_encoding
- 
- #define ASM_OUTPUT_LABELREF(FILE,NAME)		\
-   do {						\
-     const char *xname = (NAME);			\
-     if (xname[0] == '%')			\
-       xname += 2;				\
-     if (xname[0] == '*')			\
-       xname += 1;				\
-     else					\
-       fputs (user_label_prefix, FILE);		\
-     fputs (xname, FILE);			\
-   } while (0)
- 
  /* Max number of args passed in registers.  If this is more than 3, we will
     have problems with ebx (register #4), since it is a caller save register and
     is also used as the pic register in ELF.  So for now, don't allow more than
--- 2496,2501 ----
Index: config/i386/winnt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/winnt.c,v
retrieving revision 1.41
diff -c -p -d -r1.41 winnt.c
*** config/i386/winnt.c	12 Mar 2003 08:59:29 -0000	1.41
--- config/i386/winnt.c	11 Apr 2003 21:23:18 -0000
*************** i386_pe_encode_section_info (decl, first
*** 429,442 ****
    if (!first)
      return;
  
!   /* This bit is copied from i386.h.  */
!   if (optimize > 0 && TREE_CONSTANT (decl)
!       && (!flag_writable_strings || TREE_CODE (decl) != STRING_CST))
!     {
!       rtx rtl = (TREE_CODE_CLASS (TREE_CODE (decl)) != 'd'
!                  ? TREE_CST_RTL (decl) : DECL_RTL (decl));
!       SYMBOL_REF_FLAG (XEXP (rtl, 0)) = 1;
!     }
  
    if (TREE_CODE (decl) == FUNCTION_DECL)
      {
--- 429,435 ----
    if (!first)
      return;
  
!   default_encode_section_info (decl, first);
  
    if (TREE_CODE (decl) == FUNCTION_DECL)
      {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]