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]

[PATCH][rs6000] mode-macroize TLS GOT referencing insns


Hello,

This patch just merges all the tls_*_32 and tls_*_64 define_insns.

The reason for this patch is that I hope it simplifies my next job:
Keeping the GOT references and the __tls_get_addr calls together
without libcall notes (in a way similar to x86, with
define_insn_and_split).

Bootstrapped and tested on powerpc64-linux-gnu (multilib).  OK for trunk?

Gr.
Steven
	* config/rs6000/rs6000.md (TLSmode, tls_abi_suffix, tls_insn_suffix):
	New mode and mode attribute iterators.
	(tls_*_32, tls_*_64): Merge patterns with aforementioned iterators.

Index: config/rs6000/rs6000.md
===================================================================
*** config/rs6000/rs6000.md	(revision 135496)
--- config/rs6000/rs6000.md	(working copy)
***************
*** 10199,10381 ****
  
  ;; TLS support.
  
! ;; "b" output constraint here and on tls_ld to support tls linker optimization.
! (define_insn "tls_gd_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSGD))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addi %0,%1,%2@got@tlsgd")
  
! (define_insn "tls_gd_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSGD))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addi %0,%1,%2@got@tlsgd")
  
! (define_insn "tls_ld_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")]
! 		   UNSPEC_TLSLD))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addi %0,%1,%&@got@tlsld")
! 
! (define_insn "tls_ld_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")]
! 		   UNSPEC_TLSLD))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addi %0,%1,%&@got@tlsld")
  
! (define_insn "tls_dtprel_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSDTPREL))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addi %0,%1,%2@dtprel")
! 
! (define_insn "tls_dtprel_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSDTPREL))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addi %0,%1,%2@dtprel")
  
! (define_insn "tls_dtprel_ha_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSDTPRELHA))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addis %0,%1,%2@dtprel@ha")
! 
! (define_insn "tls_dtprel_ha_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSDTPRELHA))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addis %0,%1,%2@dtprel@ha")
  
! (define_insn "tls_dtprel_lo_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSDTPRELLO))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
    "addi %0,%1,%2@dtprel@l")
  
! (define_insn "tls_dtprel_lo_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSDTPRELLO))]
!   "HAVE_AS_TLS && TARGET_64BIT"
!   "addi %0,%1,%2@dtprel@l")
! 
! (define_insn "tls_got_dtprel_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSGOTDTPREL))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "lwz %0,%2@got@dtprel(%1)")
! 
! (define_insn "tls_got_dtprel_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSGOTDTPREL))]
!   "HAVE_AS_TLS && TARGET_64BIT"
!   "ld %0,%2@got@dtprel(%1)")
! 
! (define_insn "tls_tprel_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTPREL))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addi %0,%1,%2@tprel")
! 
! (define_insn "tls_tprel_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTPREL))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addi %0,%1,%2@tprel")
  
! (define_insn "tls_tprel_ha_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTPRELHA))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addis %0,%1,%2@tprel@ha")
! 
! (define_insn "tls_tprel_ha_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTPRELHA))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addis %0,%1,%2@tprel@ha")
  
! (define_insn "tls_tprel_lo_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTPRELLO))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "addi %0,%1,%2@tprel@l")
! 
! (define_insn "tls_tprel_lo_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTPRELLO))]
!   "HAVE_AS_TLS && TARGET_64BIT"
    "addi %0,%1,%2@tprel@l")
  
  ;; "b" output constraint here and on tls_tls input to support linker tls
  ;; optimization.  The linker may edit the instructions emitted by a
  ;; tls_got_tprel/tls_tls pair to addis,addi.
! (define_insn "tls_got_tprel_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSGOTTPREL))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
!   "lwz %0,%2@got@tprel(%1)")
! 
! (define_insn "tls_got_tprel_64"
!   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
! 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
! 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSGOTTPREL))]
!   "HAVE_AS_TLS && TARGET_64BIT"
!   "ld %0,%2@got@tprel(%1)")
! 
! (define_insn "tls_tls_32"
!   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
! 	(unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
! 		    (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
! 		   UNSPEC_TLSTLS))]
!   "HAVE_AS_TLS && !TARGET_64BIT"
    "add %0,%1,%2@tls")
  
- (define_insn "tls_tls_64"
-   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
- 	(unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
- 		    (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
- 		   UNSPEC_TLSTLS))]
-   "HAVE_AS_TLS && TARGET_64BIT"
-   "add %0,%1,%2@tls")
  
  ;; Next come insns related to the calling sequence.
  ;;
--- 10199,10300 ----
  
  ;; TLS support.
  
! ;; Mode attributes for different ABIs.
! (define_mode_iterator TLSmode [(SI "! TARGET_64BIT") (DI "TARGET_64BIT")])
! (define_mode_attr tls_abi_suffix [(SI "32") (DI "64")])
! (define_mode_attr tls_insn_suffix [(SI "wz") (DI "d")])
  
! ;; "b" output constraint here and on tls_ld to support tls linker optimization.
! (define_insn "tls_gd_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSGD))]
!   "HAVE_AS_TLS"
    "addi %0,%1,%2@got@tlsgd")
  
! (define_insn "tls_ld_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
! 			UNSPEC_TLSLD))]
!   "HAVE_AS_TLS"
    "addi %0,%1,%&@got@tlsld")
  
! (define_insn "tls_dtprel_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSDTPREL))]
!   "HAVE_AS_TLS"
    "addi %0,%1,%2@dtprel")
  
! (define_insn "tls_dtprel_ha_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSDTPRELHA))]
!   "HAVE_AS_TLS"
    "addis %0,%1,%2@dtprel@ha")
  
! (define_insn "tls_dtprel_lo_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSDTPRELLO))]
!   "HAVE_AS_TLS"
    "addi %0,%1,%2@dtprel@l")
  
! (define_insn "tls_got_dtprel_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSGOTDTPREL))]
!   "HAVE_AS_TLS"
!   "l<TLSmode:tls_insn_suffix> %0,%2@got@dtprel(%1)")
! 
! (define_insn "tls_tprel_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSTPREL))]
!   "HAVE_AS_TLS"
    "addi %0,%1,%2@tprel")
  
! (define_insn "tls_tprel_ha_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSTPRELHA))]
!   "HAVE_AS_TLS"
    "addis %0,%1,%2@tprel@ha")
  
! (define_insn "tls_tprel_lo_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSTPRELLO))]
!   "HAVE_AS_TLS"
    "addi %0,%1,%2@tprel@l")
  
  ;; "b" output constraint here and on tls_tls input to support linker tls
  ;; optimization.  The linker may edit the instructions emitted by a
  ;; tls_got_tprel/tls_tls pair to addis,addi.
! (define_insn "tls_got_tprel_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=b")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSGOTTPREL))]
!   "HAVE_AS_TLS"
!   "l<TLSmode:tls_insn_suffix> %0,%2@got@tprel(%1)")
! 
! (define_insn "tls_tls_<TLSmode:tls_abi_suffix>"
!   [(set (match_operand:TLSmode 0 "gpc_reg_operand" "=r")
! 	(unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")
! 			 (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
! 			UNSPEC_TLSTLS))]
!   "HAVE_AS_TLS"
    "add %0,%1,%2@tls")
  
  
  ;; Next come insns related to the calling sequence.
  ;;

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