public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: mengqinggang <mengqinggang@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, 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 v4] LoongArch: Add support for TLS descriptors
Date: Wed, 13 Mar 2024 11:06:21 +0800	[thread overview]
Message-ID: <98ac81d9-8c33-b12d-a341-c65a5a3924a8@loongson.cn> (raw)
In-Reply-To: <c88611bf11126aac92fbff4b50f89061d3e944bb.camel@xry111.site>


在 2024/3/13 上午6:15, Xi Ruoyao 写道:
> On Tue, 2024-03-12 at 17:20 +0800, mengqinggang wrote:
>> +(define_insn "@got_load_tls_desc<mode>"
>> +  [(set (match_operand:P 0 "register_operand" "=r")
>> +	(unspec:P
>> +	    [(match_operand:P 1 "symbolic_operand" "")]
>> +	    UNSPEC_TLS_DESC))
>> +    (clobber (reg:SI FCC0_REGNUM))
>> +    (clobber (reg:SI FCC1_REGNUM))
>> +    (clobber (reg:SI FCC2_REGNUM))
>> +    (clobber (reg:SI FCC3_REGNUM))
>> +    (clobber (reg:SI FCC4_REGNUM))
>> +    (clobber (reg:SI FCC5_REGNUM))
>> +    (clobber (reg:SI FCC6_REGNUM))
>> +    (clobber (reg:SI FCC7_REGNUM))
>> +    (clobber (reg:SI RETURN_ADDR_REGNUM))]
>> +  "TARGET_TLS_DESC"
>> +{
>> +  return TARGET_EXPLICIT_RELOCS
>> +    ? "pcalau12i\t$r4,%%desc_pc_hi20(%1)\n\
>> +      \taddi.d\t$r4,$r4,%%desc_pc_lo12(%1)\n\
>> +      \tld.d\t$r1,$r4,%%desc_ld(%1)\n\
>> +      \tjirl\t$r1,$r1,%%desc_call(%1)"
> Use something like
>
>      ? "pcalau12i\t$r4,%%desc_pc_hi20(%1)\n\t"
>        "addi.d\t$r4,$r4,%%desc_pc_lo12(%1)\n\t"
>        "ld.d\t$r1,$r4,%%desc_ld(%1)\n\t"
>        "jirl\t$r1,$r1,%%desc_call(%1)"
>      : "la.tls.desc\t%0,%1";
>
> to prevent additional white spaces in the output asm before tabs.
>
>> +    : "la.tls.desc\t%0,%1";
>> +}
>> +  [(set_attr "got" "load")
>> +   (set_attr "mode" "<MODE>")
>> +   (set_attr "length" "16")])
>> +
>> +(define_insn "got_load_tls_desc_off64"
>> +  [(set (match_operand:DI 0 "register_operand" "=r")
>> +	(unspec:DI
>> +	    [(match_operand:DI 1 "symbolic_operand" "")]
>> +	    UNSPEC_TLS_DESC_OFF64))
>> +    (clobber (reg:SI FCC0_REGNUM))
>> +    (clobber (reg:SI FCC1_REGNUM))
>> +    (clobber (reg:SI FCC2_REGNUM))
>> +    (clobber (reg:SI FCC3_REGNUM))
>> +    (clobber (reg:SI FCC4_REGNUM))
>> +    (clobber (reg:SI FCC5_REGNUM))
>> +    (clobber (reg:SI FCC6_REGNUM))
>> +    (clobber (reg:SI FCC7_REGNUM))
>> +    (clobber (reg:SI RETURN_ADDR_REGNUM))
>> +    (clobber (match_operand:DI 2 "register_operand" "=&r"))]
>> +  "TARGET_TLS_DESC && TARGET_CMODEL_EXTREME"
>> +{
>> +  return TARGET_EXPLICIT_RELOCS
>> +    ? "pcalau12i\t$r4,%%desc_pc_hi20(%1)\n\
>> +      \taddi.d\t%2,$r0,%%desc_pc_lo12(%1)\n\
>> +      \tlu32i.d\t%2,%%desc64_pc_lo20(%1)\n\
>> +      \tlu52i.d\t%2,%2,%%desc64_pc_hi12(%1)\n\
>> +      \tadd.d\t$r4,$r4,%2\n\
>> +      \tld.d\t$r1,$r4,%%desc_ld(%1)\n\
>> +      \tjirl\t$r1,$r1,%%desc_call(%1)"
>> +    : "la.tls.desc\t%0,%2,%1";
> Likewise.
>
>> +}
>> +  [(set_attr "got" "load")
>> +   (set_attr "length" "28")])
> Otherwise OK.
>
> It's better to allow splitting these two instructions but we can do it
> in another patch.  And IMO it's better to enable TLS desc by default if
> supported by both the assembler and the libc, but we'll have to defer it
> until Glibc 2.40 release.


Do we need to wait until LLVM also supports TLS DESC  before setting it 
as default?


>


  parent reply	other threads:[~2024-03-13  3:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  9:20 mengqinggang
2024-03-12 22:15 ` Xi Ruoyao
2024-03-12 22:56   ` Xi Ruoyao
2024-03-13  2:24     ` Xi Ruoyao
2024-03-13  9:19       ` Xi Ruoyao
2024-03-13  3:06   ` mengqinggang [this message]
2024-03-13  9:16     ` Xi Ruoyao

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=98ac81d9-8c33-b12d-a341-c65a5a3924a8@loongson.cn \
    --to=mengqinggang@loongson.cn \
    --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=wanglei@loongson.cn \
    --cc=xry111@xry111.site \
    --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).