public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: mengqinggang <mengqinggang@loongson.cn>, gcc-patches@gcc.gnu.org
Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn,
	cailulu@loongson.cn,  i.swmail@xen0n.name, maskray@google.com,
	luweining@loongson.cn,  wanglei@loongson.cn,
	hejinyang@loongson.cn
Subject: Re: [PATCH v5] LoongArch: Add support for TLS descriptors
Date: Mon, 01 Apr 2024 21:51:08 +0800	[thread overview]
Message-ID: <84becac336d760701ec31f0f27e64c82efacc9f4.camel@xry111.site> (raw)
In-Reply-To: <20240319015415.351293-1-mengqinggang@loongson.cn>

Is this patch targeting GCC 14 or 15?  If 14 I guess we'd commit now...

Generally we don't add features in stage 4, but if we keep trad as the
default I think it'd be OK.  And RISC-V guys plan to push their TLS desc
implementation this week too.

On Tue, 2024-03-19 at 09:54 +0800, mengqinggang wrote:
> Add support for TLS descriptors on normal code model and extreme code model.
> 
> Normal code model instruction sequence:
>   -mno-explicit-relocs:
>     la.tls.desc	$r4, s
>     add.d	$r12, $r4, $r2
>   -mexplicit-relocs:
>     pcalau12i	$r4,%desc_pc_hi20(s)
>     addi.d	$r4,$r4,%desc_pc_lo12(s)
>     ld.d	$r1,$r4,%desc_ld(s)
>     jirl	$r1,$r1,%desc_call(s)
>     add.d	$r12, $r4, $r2
> 
> Extreme code model instruction sequence:
>   -mno-explicit-relocs:
>     la.tls.desc	$r4, $r12, s
>     add.d	$r12, $r4, $r2
>   -mexplicit-relocs:
>     pcalau12i	$r4,%desc_pc_hi20(s)
>     addi.d	$r12,$r0,%desc_pc_lo12(s)
>     lu32i.d	$r12,%desc64_pc_lo20(s)
>     lu52i.d	$r12,$r12,%desc64_pc_hi12(s)
>     add.d	$r4,$r4,$r12
>     ld.d	$r1,$r4,%desc_ld(s)
>     jirl	$r1,$r1,%desc_call(s)
>     add.d	$r12, $r4, $r2
> 
> The default is still traditional TLS model, but can be configured with
> --with-tls={trad,desc}. The default can change to TLS descriptors once
> libc and LLVM support this.
> 
> gcc/ChangeLog:
> 
> 	* config.gcc: Add --with-tls option to change TLS flavor.
> 	* config/loongarch/genopts/loongarch.opt.in: Add -mtls-dialect to
> 	configure TLS flavor.
> 	* config/loongarch/loongarch-def.h (struct loongarch_target): Add
> 	tls_dialect.
> 	* config/loongarch/loongarch-driver.cc (la_driver_init): Add tls
> 	flavor.
> 	* config/loongarch/loongarch-opts.cc (loongarch_init_target): Add
> 	tls_dialect.
> 	(loongarch_config_target): Ditto.
> 	(loongarch_update_gcc_opt_status): Ditto.
> 	* config/loongarch/loongarch-opts.h (loongarch_init_target):Ditto.
> 	(TARGET_TLS_DESC): New define.
> 	* config/loongarch/loongarch.cc (loongarch_symbol_insns): Add TLS DESC
> 	instructions sequence length.
> 	(loongarch_legitimize_tls_address): New TLS DESC instruction sequence.
> 	(loongarch_option_override_internal): Add la_opt_tls_dialect.
> 	(loongarch_option_restore): Add la_target.tls_dialect.
> 	* config/loongarch/loongarch.md (@got_load_tls_desc<mode>): Normal
> 	code model for TLS DESC.
> 	(got_load_tls_desc_off64): Extreme code model for TLS DESC.
> 	* config/loongarch/loongarch.opt: Regenerated.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/loongarch/cmodel-extreme-1.c: Add -mtls-dialect=trad.
> 	* gcc.target/loongarch/cmodel-extreme-2.c: Ditto.
> 	* gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c: Ditto.
> 	* gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c:
> 	Ditto.
> 	* gcc.target/loongarch/func-call-medium-1.c: Ditto.
> 	* gcc.target/loongarch/func-call-medium-2.c: Ditto.
> 	* gcc.target/loongarch/func-call-medium-3.c: Ditto.
> 	* gcc.target/loongarch/func-call-medium-4.c: Ditto.
> 	* gcc.target/loongarch/tls-extreme-macro.c: Ditto.
> 	* gcc.target/loongarch/tls-gd-noplt.c: Ditto.
> 	* gcc.target/loongarch/explicit-relocs-auto-extreme-tls-desc.c: New test.
> 	* gcc.target/loongarch/explicit-relocs-auto-tls-desc.c: New test.
> 	* gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c: New test.
> 	* gcc.target/loongarch/explicit-relocs-tls-desc.c: New test.
> 
> Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
> Co-authored-by: Xi Ruoyao <xry111@xry111.site>

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2024-04-01 13:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19  1:54 mengqinggang
2024-04-01 13:51 ` Xi Ruoyao [this message]
2024-04-02  1:09   ` chenglulu
2024-04-02  6:14 ` [pushed][PATCH " chenglulu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84becac336d760701ec31f0f27e64c82efacc9f4.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=cailulu@loongson.cn \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hejinyang@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=luweining@loongson.cn \
    --cc=maskray@google.com \
    --cc=mengqinggang@loongson.cn \
    --cc=wanglei@loongson.cn \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).