public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Cc: gcc-patches@gcc.gnu.org, rui314@gmail.com,
	ruiu@bluewhale.systems, kito.cheng@gmail.com
Subject: Re: [PATCH v2] RISC-V: Implement TLS Descriptors.
Date: Wed, 15 Nov 2023 18:07:31 -0700	[thread overview]
Message-ID: <54cba99d-fa53-4ecd-b850-f8f7e2c8a21a@gmail.com> (raw)
In-Reply-To: <20230908104923.31154-1-ishitatsuyuki@gmail.com>



On 9/8/23 04:49, Tatsuyuki Ishi via Gcc-patches wrote:
> This implements TLS Descriptors (TLSDESC) as specified in [1].
> 
> In TLSDESC instruction sequence, the first instruction relocates against
> the target TLS variable, while subsequent instructions relocates against
> the address of the first. Such usage of labels are not well-supported
> within GCC. Due to this, the 4-instruction sequence is implemented as a
> single RTX insn.
> 
> The default remains to be the traditional TLS model, but can be configured
> with --with_tls={trad,desc}. The choice can be revisited once toolchain
> and libc support ships.
> 
> [1]: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/373.
> 
> gcc/Changelog:
>      * config/riscv/riscv.opt: Add -mtls-dialect to configure TLS flavor.
>      * config.gcc: Add --with_tls configuration option to change the default
>      TLS flavor.
>      * config/riscv/riscv.h: Add TARGET_TLSDESC determined from
>      -mtls-dialect and with_tls defaults.
>      * config/riscv/riscv-opts.h: Define enum riscv_tls_type for the two TLS
>      flavors.
>      * config/riscv/riscv-protos.h: Define SYMBOL_TLSDESC symbol type.
>      * config/riscv/riscv.md: Add instruction sequence for TLSDESC.
>      * config/riscv/riscv.cc (riscv_symbol_insns): Add instruction sequence
>      length data for TLSDESC.
>      (riscv_legitimize_tls_address): Add lowering of TLSDESC.
> ---

> @@ -4694,6 +4696,17 @@ case "${target}" in
>   				;;
>   			esac
>   		fi
> +		# Handle --with-tls.
> +		case "$with_tls" in
> +        "" \
> +        | trad | desc)
> +            # OK
> +            ;;
> +        *)
> +            echo "Unknown TLS method used in --with-tls=$with_tls" 1>&2
> +            exit 1
> +            ;;
> +        esac
Is there a reason why this isn't formatted like the other cases?




> @@ -1869,6 +1870,24 @@
>     [(set_attr "got" "load")
>      (set_attr "mode" "<MODE>")])
>   
> +(define_insn "@tlsdesc<mode>"
> +  [(set (reg:P A0_REGNUM)
> +	    (unspec:P
> +			[(match_operand:P 0 "symbolic_operand" "")
> +			 (match_operand:P 1 "const_int_operand")]
> +			UNSPEC_TLSDESC))
> +   (clobber (reg:SI T0_REGNUM))]
> +  "TARGET_TLSDESC"
> +  {
> +    return ".LT%1: auipc\ta0, %%tlsdesc_hi(%0)\;"
> +           "<load>\tt0,%%tlsdesc_load_lo(.LT%1)(a0)\;"
> +           "addi\ta0,a0,%%tlsdesc_add_lo(.LT%1)\;"
> +           "jalr\tt0,t0,%%tlsdesc_call(.LT%1)";
> +  }
> +  [(set_attr "type" "multi")
> +   (set_attr "length" "16")
> +   (set_attr "mode" "<MODE>")])
Hmm, I would be a bit worried about explicitly using $a0 here.  That's 
generally frowned upon, but probably unavoidable in this case since this 
is a call under the hood.


This needs changes to invoke.texi since it introduces new options.  I 
don't think it has to be anything terribly verbose.  A one liner is 
probably sufficient and I wouldn't be surprised if other ports have 
suitable text we could copy.

So overall if Kito's OK, then I am with the trivial doc change and 
perhaps the formatting fix in config.guess.

jeff

  parent reply	other threads:[~2023-11-16  1:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 18:12 [PATCH] " Tatsuyuki Ishi
2023-08-29 13:40 ` Kito Cheng
2023-09-08 10:49 ` [PATCH v2] " Tatsuyuki Ishi
2023-10-02 14:10   ` Kito Cheng
2023-11-16  1:17     ` Fangrui Song
2023-11-16  1:39       ` Tatsuyuki Ishi
2023-11-16  5:21         ` Jeff Law
2023-11-16  5:18       ` Jeff Law
2023-11-16  1:07   ` Jeff Law [this message]
2023-11-16  1:51     ` Tatsuyuki Ishi
2023-11-16  5:23       ` Jeff Law
2023-11-16  5:33         ` Fangrui Song
2023-11-16  5:36           ` Jeff Law
2023-11-16  5:37           ` Tatsuyuki Ishi
2023-11-20 13:17 ` [PATCH v3] " Tatsuyuki Ishi
2023-11-21  6:59   ` Fangrui Song
2023-11-21  7:07     ` Tatsuyuki Ishi
2023-12-05 16:49     ` Tatsuyuki Ishi
2023-11-23 10:57   ` Florian Weimer
2023-11-23 11:34     ` Tatsuyuki Ishi
2023-11-23 11:40       ` Florian Weimer
2023-12-05  7:01 ` [PATCH v4] " Tatsuyuki Ishi
2024-01-27  3:24   ` Fangrui Song
2024-03-29  5:52 ` [PATCH v5] " Tatsuyuki Ishi
2024-03-29  6:32   ` Kito Cheng
2024-04-08 14:31     ` Kito Cheng

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=54cba99d-fa53-4ecd-b850-f8f7e2c8a21a@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ishitatsuyuki@gmail.com \
    --cc=kito.cheng@gmail.com \
    --cc=rui314@gmail.com \
    --cc=ruiu@bluewhale.systems \
    /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).