x32: Add x32 support to -mtls-dialect=gnu2
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 20 Jan 2020 13:02:14 +0000 (05:02 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 20 Jan 2020 13:14:16 +0000 (05:14 -0800)
commit1a2b60b581c373e4ebcee9ee37c0ab2866f98950
treeabf170318cad1e0ce65b2ae090a4a59788ef57c2
parent35e58efb7a86a66c6e93dac3d197eef95963582d
x32: Add x32 support to -mtls-dialect=gnu2

To add x32 support to -mtls-dialect=gnu2, we need to replace DI with
P in GNU2 TLS patterns.  Since DEST set by tls_dynamic_gnu2_64 is in
ptr_mode, PLUS in GNU2 TLS address computation must be done in ptr_mode
to support -maddress-mode=long.  Also replace the "{q}" suffix on lea
with "%z0" to support both 32-bit and 64-bit destination register.

Tested on Linux/x86-64.

gcc/

PR target/93319
* config/i386/i386.c (legitimize_tls_address): Pass Pmode to
gen_tls_dynamic_gnu2_64.  Compute GNU2 TLS address in ptr_mode.
* config/i386/i386.md (tls_dynamic_gnu2_64): Renamed to ...
(@tls_dynamic_gnu2_64_<mode>): This.  Replace DI with P.
(*tls_dynamic_gnu2_lea_64): Renamed to ...
(*tls_dynamic_gnu2_lea_64_<mode>): This.  Replace DI with P.
Remove the {q} suffix from lea.
(*tls_dynamic_gnu2_call_64): Renamed to ...
(*tls_dynamic_gnu2_call_64_<mode>): This.  Replace DI with P.
(*tls_dynamic_gnu2_combine_64): Renamed to ...
(*tls_dynamic_gnu2_combine_64_<mode>): This.  Replace DI with P.
Pass Pmode to gen_tls_dynamic_gnu2_64.

gcc/testsuite/

PR target/93319
* gcc.target/i386/pr93319-1a.c: New test.
* gcc.target/i386/pr93319-1b.c: Likewise.
* gcc.target/i386/pr93319-1c.c: Likewise.
* gcc.target/i386/pr93319-1d.c: Likewise.
gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr93319-1a.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr93319-1b.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr93319-1c.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr93319-1d.c [new file with mode: 0644]