Patchwork PATCH: Call gen_tls_global_dynamic_64_<mode> and en_tls_local_dynamic_base_64_<mode>

login
register
mail settings
Submitter Uros Bizjak
Date March 13, 2012, 3:52 p.m.
Message ID <CAFULd4ZBXVG1twsVZE-RpRQqHf4tZ97C=aMs4zZFXctu6xbh9g@mail.gmail.com>
Download mbox | patch
Permalink /patch/146435/
State New
Headers show

Comments

Uros Bizjak - March 13, 2012, 3:52 p.m.
On Mon, Mar 12, 2012 at 10:35 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>>> 2012-03-12  H.J. Lu  <hongjiu.lu@intel.com>
>>>>
>>>>        * config/i386/i386.c (ix86_gen_tls_global_dynamic_64): New.
>>>>        (ix86_gen_tls_local_dynamic_base_64): Likewise.
>>>>        (ix86_option_override_internal): Set ix86_gen_tls_global_dynamic_64
>>>>        and ix86_gen_tls_local_dynamic_base_64.
>>>>        (legitimize_tls_address): Use ix86_gen_tls_global_dynamic_64 and
>>>>        ix86_gen_tls_local_dynamic_base_64.
>>>>
>>>>        * config/i386/i386.md (*tls_global_dynamic_64): Renamed to ...
>>>>        (*tls_global_dynamic_64_<mode>): This.
>>>>        (tls_global_dynamic_64): Renamed to ...
>>>>        (tls_global_dynamic_64_<mode>): This.
>>>>        (*tls_local_dynamic_base_64): Renamed to ...
>>>>        (*tls_local_dynamic_base_64_<mode>): This.
>>>>        (tls_local_dynamic_base_64): Renamed to ...
>>>>        (tls_local_dynamic_base_64_<mode>): This.
>>>
>>> This patch caused x32 libgcc build failure:
>>>
>>> ../../../../src-trunk/libgcc/generic-morestack-thread.c: In function
>>> 'stack_split_initialize_thread':
>>> ../../../../src-trunk/libgcc/generic-morestack-thread.c:128:1: error:
>>> unrecognizable insn:
>>> (call_insn/u 8 7 9 3 (parallel [
>>>            (set (reg:DI 0 ax)
>>>                (call:DI (mem:QI (symbol_ref:DI ("__tls_get_addr")) [0 S1 A8])
>>>                    (const_int 0 [0])))
>>>            (unspec:DI [
>>>                    (symbol_ref:SI ("__morestack_segments") [flags
>>> 0x50] <var_decl 0x7ffff7725780 __morestack_segments>)
>>>                ] UNSPEC_TLS_GD)
>>>        ]) ../../../../src-trunk/libgcc/generic-morestack-thread.c:117 -1
>>>     (expr_list:REG_EH_REGION (const_int -2147483648 [0xffffffff80000000])
>>>        (nil))
>>>    (nil))
>>> ../../../../src-trunk/libgcc/generic-morestack-thread.c:128:1:
>>> internal compiler error: in extract_insn, at recog.c:2123
>>> Please submit a full bug report,
>>> with preprocessed source if appropriate.
>>> See <http://gcc.gnu.org/bugs.html> for instructions.
>>> make[8]: *** [generic-morestack-thread.o] Error 1
>>> make[8]: *** Waiting for unfinished jobs....
>>>
>>> __morestack_segments is always in SImode for x32.  Adding
>>> :P to
>>>
>>>  (unspec:P [(match_operand 1 "tls_symbolic_operand" "")]
>>>
>>> causes it to fail when Pmode == DImode  I checked in this patch
>>> to revert the part of that change.
>>
>> Please better declare tls_symbolic_operand as special predicate, as in
>> attached patch.

2012-03-13  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/predicates.md (tls_symbolic_operand): Declare as
	special predicate.
	(tls_modbase_operand): Ditto.
	* config/i386/i386.md: Remove mode from tls_symbolic_operand and
	tls_modbase_operand predicates.

There is no point to pass mode of special predicate operands, so I
remove these from i386.md.

Tested on x86_64-pc-linux-gnu, committed to mainline SVN.

Uros.

Patch

Index: i386.md
===================================================================
--- i386.md	(revision 185277)
+++ i386.md	(working copy)
@@ -12591,7 +12591,7 @@ 
   [(set (match_operand:SI 0 "register_operand" "=a")
 	(unspec:SI
 	 [(match_operand:SI 1 "register_operand" "b")
-	  (match_operand:SI 2 "tls_symbolic_operand" "")
+	  (match_operand 2 "tls_symbolic_operand" "")
 	  (match_operand:SI 3 "constant_call_address_operand" "z")]
 	 UNSPEC_TLS_GD))
    (clobber (match_scratch:SI 4 "=d"))
@@ -12616,7 +12616,7 @@ 
   [(parallel
     [(set (match_operand:SI 0 "register_operand" "")
 	  (unspec:SI [(match_operand:SI 2 "register_operand" "")
-		      (match_operand:SI 1 "tls_symbolic_operand" "")
+		      (match_operand 1 "tls_symbolic_operand" "")
 		      (match_operand:SI 3 "constant_call_address_operand" "")]
 		     UNSPEC_TLS_GD))
      (clobber (match_scratch:SI 4 ""))
@@ -12727,7 +12727,7 @@ 
 		     (match_operand:SI 2 "constant_call_address_operand" "z")]
 		    UNSPEC_TLS_LD_BASE)
 	 (const:SI (unspec:SI
-		    [(match_operand:SI 3 "tls_symbolic_operand" "")]
+		    [(match_operand 3 "tls_symbolic_operand" "")]
 		    UNSPEC_DTPOFF))))
    (clobber (match_scratch:SI 4 "=d"))
    (clobber (match_scratch:SI 5 "=c"))
@@ -12825,7 +12825,7 @@ 
 (define_insn "tls_initial_exec_64_sun"
   [(set (match_operand:DI 0 "register_operand" "=a")
 	(unspec:DI
-	 [(match_operand:DI 1 "tls_symbolic_operand" "")]
+	 [(match_operand 1 "tls_symbolic_operand" "")]
 	 UNSPEC_TLS_IE_SUN))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_64BIT && TARGET_SUN_TLS"
@@ -12847,7 +12847,7 @@ 
 (define_insn "tls_initial_exec_x32"
   [(set (match_operand:SI 0 "register_operand" "=r")
 	(unspec:SI
-	 [(match_operand:SI 1 "tls_symbolic_operand" "")]
+	 [(match_operand 1 "tls_symbolic_operand" "")]
 	 UNSPEC_TLS_IE_X32))
    (clobber (reg:CC FLAGS_REG))]
   "TARGET_X32"
@@ -12864,7 +12864,7 @@ 
   [(set (match_dup 3)
 	(plus:SI (match_operand:SI 2 "register_operand" "")
 		 (const:SI
-		  (unspec:SI [(match_operand:SI 1 "tls_symbolic_operand" "")]
+		  (unspec:SI [(match_operand 1 "tls_symbolic_operand" "")]
 			     UNSPEC_TLSDESC))))
    (parallel
     [(set (match_operand:SI 0 "register_operand" "")
@@ -12882,7 +12882,7 @@ 
   [(set (match_operand:SI 0 "register_operand" "=r")
 	(plus:SI (match_operand:SI 1 "register_operand" "b")
 		 (const:SI
-		  (unspec:SI [(match_operand:SI 2 "tls_symbolic_operand" "")]
+		  (unspec:SI [(match_operand 2 "tls_symbolic_operand" "")]
 			      UNSPEC_TLSDESC))))]
   "!TARGET_64BIT && TARGET_GNU2_TLS"
   "lea{l}\t{%E2@TLSDESC(%1), %0|%0, %E2@TLSDESC[%1]}"
@@ -12893,7 +12893,7 @@ 
 
 (define_insn "*tls_dynamic_gnu2_call_32"
   [(set (match_operand:SI 0 "register_operand" "=a")
-	(unspec:SI [(match_operand:SI 1 "tls_symbolic_operand" "")
+	(unspec:SI [(match_operand 1 "tls_symbolic_operand" "")
 		    (match_operand:SI 2 "register_operand" "0")
 		    ;; we have to make sure %ebx still points to the GOT
 		    (match_operand:SI 3 "register_operand" "b")
@@ -12909,13 +12909,13 @@ 
 (define_insn_and_split "*tls_dynamic_gnu2_combine_32"
   [(set (match_operand:SI 0 "register_operand" "=&a")
 	(plus:SI
-	 (unspec:SI [(match_operand:SI 3 "tls_modbase_operand" "")
+	 (unspec:SI [(match_operand 3 "tls_modbase_operand" "")
 		     (match_operand:SI 4 "" "")
 		     (match_operand:SI 2 "register_operand" "b")
 		     (reg:SI SP_REG)]
 		    UNSPEC_TLSDESC)
 	 (const:SI (unspec:SI
-		    [(match_operand:SI 1 "tls_symbolic_operand" "")]
+		    [(match_operand 1 "tls_symbolic_operand" "")]
 		    UNSPEC_DTPOFF))))
    (clobber (reg:CC FLAGS_REG))]
   "!TARGET_64BIT && TARGET_GNU2_TLS"
@@ -12969,7 +12969,7 @@ 
 (define_insn_and_split "*tls_dynamic_gnu2_combine_64"
   [(set (match_operand:DI 0 "register_operand" "=&a")
 	(plus:DI
-	 (unspec:DI [(match_operand:DI 2 "tls_modbase_operand" "")
+	 (unspec:DI [(match_operand 2 "tls_modbase_operand" "")
 		     (match_operand:DI 3 "" "")
 		     (reg:DI SP_REG)]
 		    UNSPEC_TLSDESC)
Index: predicates.md
===================================================================
--- predicates.md	(revision 185277)
+++ predicates.md	(working copy)
@@ -491,11 +491,11 @@ 
        (match_operand 0 "local_symbolic_operand")))
 
 ;; Test for various thread-local symbols.
-(define_predicate "tls_symbolic_operand"
+(define_special_predicate "tls_symbolic_operand"
   (and (match_code "symbol_ref")
        (match_test "SYMBOL_REF_TLS_MODEL (op)")))
 
-(define_predicate "tls_modbase_operand"
+(define_special_predicate "tls_modbase_operand"
   (and (match_code "symbol_ref")
        (match_test "op == ix86_tls_module_base ()")))