On Wed, Jul 27, 2011 at 11:52 PM, Uros Bizjak <[email protected]> wrote:
> On Thu, Jul 28, 2011 at 4:55 AM, H.J. Lu <[email protected]> wrote:
>> TLS on X32 is almost identical to TLS on x86-64. The only difference is
>> x32 address space is 32bit. That means TLS symbols can be in either
>> SImode or DImode with upper 32bit zero. This patch updates
>> tls_global_dynamic_64 to support x32. OK for trunk?
>
>> 2011-07-27 H.J. Lu <[email protected]>
>>
>> PR target/47715
>> * config/i386/i386.md (PTR64): New.
>> (*tls_global_dynamic_64): Rename to ...
>> (*tls_global_dynamic_64_<mode>): This. Put PTR64 on operand 1.
>> (tls_global_dynamic_64): Rename to ...
>> (tls_global_dynamic_64_<mode>): This. Put PTR64 on operand 1.
>> * config/i386/i386.c (legitimize_tls_address): Updated.
>
> Just remove mode check, so:
>
> (unspec:DI [(match_operand 1 "tls_symbolic_operand" "")]
>
> at both sites.
>
> - fputs (ASM_BYTE "0x66\n", asm_out_file);
> + if (!TARGET_X32)
> + fputs (ASM_BYTE "0x66\n", asm_out_file);
>
> Are you sure? There are some scary comments in binutils that these
> sequences have to be written _exactly_ as shown to enable certain
> linker relaxations w.r.t. TLS relocs.
That is true. I updated those scary comments in binutils for x32 :-).
Since x32 is 32bit, we can use 32bit move instructions instead 64bit.
We don't need REX prefix in x32. Now those scary comments read:
/* Check transition from GD access model. For 64bit, only
.byte 0x66; leaq foo@tlsgd(%rip), %rdi
.word 0x6666; rex64; call __tls_get_addr
can transit to different access model. For 32bit, only
leaq foo@tlsgd(%rip), %rdi
.word 0x6666; rex64; call __tls_get_addr
can transit to different access model. */
The difference is one less 0x66 byte.
--
H.J.