public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* RFC: generate TLS address arithmetic for back-end
@ 2004-11-23 20:04 Aldy Hernandez
  2004-11-23 21:45 ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Aldy Hernandez @ 2004-11-23 20:04 UTC (permalink / raw)
  To: gcc, rth, aoliva

Hi folks.

I've been working on adding TLS to the FR-V port.  My work is pretty
much complete, but I've (well Alex) found a possible optimization 
opportunity.

Currently, the back-end never sees address arithmetic of TLS variables
(ala (plus (symbol_ref) (const_int))), because the middle-end avoids
such RTL creation when the address is not a constant.

Since staticp() return FALSE for any TLS addresses, we never generate
the aforementioned RTL.

Some ports could benefit from getting the above RTL (FRV for instance).

Is there a reason for this restriction, or is something like the patch
below the right approach?

Obviously, the patch below would need some cleanups (the predicate
should go in tree.c, and a hook should be added for back-ends wishing
to override this type of arithmetic).

Comments?

	* expr.c (expand_expr): case PLUS_EXPR: Treat TLS address
	arithmetic as a constant.
	(tree_tls_address_p): New.

Index: expr.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/expr.c,v
retrieving revision 1.500.2.1
diff -c -p -r1.500.2.1 expr.c
*** expr.c	28 Nov 2003 21:12:37 -0000	1.500.2.1
--- expr.c	23 Nov 2004 19:02:22 -0000
*************** expand_operands (tree exp0, tree exp1, r
*** 6204,6209 ****
--- 6204,6219 ----
      }
  }
  
+ 
+ /* Return TRUE if ``t'' is an ADDR_EXPR of a thread-local variable.  */
+ bool
+ tree_tls_address_p (tree t)
+ {
+   if (TREE_CODE (t) != ADDR_EXPR)
+     return false;
+   t = TREE_OPERAND (t, 0);
+   return TREE_CODE (t) == VAR_DECL && DECL_THREAD_LOCAL (t);
+ }
  \f
  /* expand_expr: generate code for computing expression EXP.
     An rtx for the computed value is returned.  The value is never null.
*************** expand_expr (tree exp, rtx target, enum 
*** 7808,7814 ****
  
  	  else if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  		   && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
! 		   && TREE_CONSTANT (TREE_OPERAND (exp, 0)))
  	    {
  	      rtx constant_part;
  
--- 7818,7825 ----
  
  	  else if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  		   && GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT
! 		   && (TREE_CONSTANT (TREE_OPERAND (exp, 0))
! 		       || tree_tls_address_p (TREE_OPERAND (exp, 0))))
  	    {
  	      rtx constant_part;
  

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-11-24 16:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-23 20:04 RFC: generate TLS address arithmetic for back-end Aldy Hernandez
2004-11-23 21:45 ` Richard Henderson
2004-11-24  0:37   ` Aldy Hernandez
2004-11-24  8:49   ` Aldy Hernandez
2004-11-24  9:31     ` Richard Henderson
2004-11-24 17:13       ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).