PATCH: Fix 64-bit Solaris 2/x86 IE TLS code sequence

Jakub Jelinek jakub@redhat.com
Tue Mar 9 16:24:00 GMT 2010


On Tue, Mar 09, 2010 at 05:10:54PM +0100, Rainer Orth wrote:
> --- a/gcc/config/i386/i386.md	Sat Mar 06 11:43:18 2010 +0100
> +++ b/gcc/config/i386/i386.md	Sat Mar 06 17:55:44 2010 +0100
> @@ -5981,6 +5981,21 @@
>    [(set_attr "type" "lea")
>     (set_attr "mode" "SI")])
>  
> +(define_insn "*add<mode>_1_tls_sun"
> +  [(set (match_operand:SWI48 0 "register_operand" "=a")
> +	(plus:SWI48
> +	  (match_operand:SWI48 1 "register_operand" "0")
> +	  (match_operand:SWI48 2 "tls_symbolic_operand" "")))
> +   (clobber (reg:CC FLAGS_REG))]
> +  "ix86_binary_operator_ok (PLUS, <MODE>mode, operands)"
> +{
> +    gcc_assert (rtx_equal_p (operands[0], operands[1]));
> +    return "add{<imodesuffix>}\t{%2, %0|%0, %2}";
> +}
> +  [(set_attr "type" "alu")
> +   (set_attr "length_immediate" "*")
> +   (set_attr "mode" "<MODE>")])

This is a bad idea.  Please surround the tls_symbolic_operand into
some UNSPEC, having naked tls symbolic operands in the IL is a going to
cause problems earlier or later.

The following changes would then be unnecessary:

> @@ -6366,7 +6395,8 @@
>     && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)
>     /* Current assemblers are broken and do not allow @GOTOFF in
>        ought but a memory context.  */
> -   && ! pic_symbolic_operand (operands[2], VOIDmode)"
> +   && ! pic_symbolic_operand (operands[2], VOIDmode)
> +   && ! tls_symbolic_operand (operands[2], VOIDmode)"
>  {
>    switch (get_attr_type (insn))
>      {
> @@ -6424,7 +6454,8 @@
>     && ix86_binary_operator_ok (PLUS, SImode, operands)
>     /* Current assemblers are broken and do not allow @GOTOFF in
>        ought but a memory context.  */
> -   && ! pic_symbolic_operand (operands[2], VOIDmode)"
> +   && ! pic_symbolic_operand (operands[2], VOIDmode)
> +   && ! tls_symbolic_operand (operands[2], VOIDmode)"
>  {
>    switch (get_attr_type (insn))
>      {
> @@ -6560,7 +6591,8 @@
>     && !(MEM_P (operands[1]) && MEM_P (operands[2]))
>     /* Current assemblers are broken and do not allow @GOTOFF in
>        ought but a memory context.  */
> -   && ! pic_symbolic_operand (operands[2], VOIDmode)"
> +   && ! pic_symbolic_operand (operands[2], VOIDmode)
> +   && ! tls_symbolic_operand (operands[2], VOIDmode)"
>  {
>    switch (get_attr_type (insn))
>      {
> @@ -6617,7 +6649,8 @@
>     && ix86_binary_operator_ok (PLUS, SImode, operands)
>     /* Current assemblers are broken and do not allow @GOTOFF in
>        ought but a memory context.  */
> -   && ! pic_symbolic_operand (operands[2], VOIDmode)"
> +   && ! pic_symbolic_operand (operands[2], VOIDmode)
> +   && ! tls_symbolic_operand (operands[2], VOIDmode)"
>  {
>    switch (get_attr_type (insn))
>      {
> @@ -6942,7 +6975,8 @@
>     && !(MEM_P (operands[1]) && MEM_P (operands[2]))
>     /* Current assemblers are broken and do not allow @GOTOFF in
>        ought but a memory context.  */
> -   && ! pic_symbolic_operand (operands[2], VOIDmode)"
> +   && ! pic_symbolic_operand (operands[2], VOIDmode)
> +   && ! tls_symbolic_operand (operands[2], VOIDmode)"
>  {
>    switch (get_attr_type (insn))
>      {
> @@ -14664,6 +14698,17 @@
>     (set_attr "memory" "load")
>     (set_attr "imm_disp" "false")])
>  
> +(define_insn "*load_tp_di_sun"
> +   [(set (match_operand:DI 0 "register_operand" "=a")
> +     (unspec:DI [(const_int 0)] UNSPEC_TP))]
> +   "TARGET_64BIT && TARGET_SUN_TLS"
> +   "mov{q}\t{%%fs:0, %0|%0, QWORD PTR fs:0}"
> +   [(set_attr "type" "imov")
> +    (set_attr "modrm" "0")
> +    (set_attr "length" "7")
> +    (set_attr "memory" "load")
> +    (set_attr "imm_disp" "false")])
> +
>  (define_insn "*load_tp_di"
>    [(set (match_operand:DI 0 "register_operand" "=r")
>  	(unspec:DI [(const_int 0)] UNSPEC_TP))]

	Jakub



More information about the Gcc-patches mailing list