From: Kito Cheng <kito.cheng@sifive.com>
To: Christoph Muellner <christoph.muellner@vrull.eu>
Cc: gcc-patches@gcc.gnu.org, Jim Wilson <jim.wilson.gcc@gmail.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Andrew Waterman <andrew@sifive.com>,
Philipp Tomsich <philipp.tomsich@vrull.eu>,
Cooper Qu <cooper.qu@linux.alibaba.com>,
Lifang Xia <lifang_xia@linux.alibaba.com>,
Yunhai Shang <yunhai@linux.alibaba.com>,
Zhiwei Liu <zhiwei_liu@linux.alibaba.com>
Subject: Re: [PATCH 08/11] riscv: Prepare backend for index registers
Date: Fri, 28 Apr 2023 16:34:40 +0800 [thread overview]
Message-ID: <CALLt3Tj=7ZrWtfbd0DH1K71_HOC0NF37tmRJtQSdNuhhqC9jKw@mail.gmail.com> (raw)
In-Reply-To: <20230428061210.2988035-9-christoph.muellner@vrull.eu>
OK
On Fri, Apr 28, 2023 at 2:12 PM Christoph Muellner
<christoph.muellner@vrull.eu> wrote:
>
> From: Christoph Müllner <christoph.muellner@vrull.eu>
>
> RISC-V does currently not support index registers.
> However, there are some vendor extensions that specify them.
> Let's do the necessary changes in the backend so that we can
> add support for such a vendor extension in the future.
>
> This is a non-functional change without any intended side-effects.
>
> gcc/ChangeLog:
>
> * config/riscv/riscv-protos.h (riscv_regno_ok_for_index_p):
> New prototype.
> (riscv_index_reg_class): Likewise.
> * config/riscv/riscv.cc (riscv_regno_ok_for_index_p): New function.
> (riscv_index_reg_class): New function.
> * config/riscv/riscv.h (INDEX_REG_CLASS): Call new function
> riscv_index_reg_class().
> (REGNO_OK_FOR_INDEX_P): Call new function
> riscv_regno_ok_for_index_p().
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
> gcc/config/riscv/riscv-protos.h | 2 ++
> gcc/config/riscv/riscv.cc | 20 ++++++++++++++++++++
> gcc/config/riscv/riscv.h | 6 ++++--
> 3 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
> index 628c64cf628..b7417e97d99 100644
> --- a/gcc/config/riscv/riscv-protos.h
> +++ b/gcc/config/riscv/riscv-protos.h
> @@ -82,6 +82,8 @@ struct riscv_address_info {
> extern enum riscv_symbol_type riscv_classify_symbolic_expression (rtx);
> extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *);
> extern int riscv_regno_mode_ok_for_base_p (int, machine_mode, bool);
> +extern enum reg_class riscv_index_reg_class ();
> +extern int riscv_regno_ok_for_index_p (int);
> extern int riscv_address_insns (rtx, machine_mode, bool);
> extern int riscv_const_insns (rtx);
> extern int riscv_split_const_insns (rtx);
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 8388235d8cc..a33f0fff8ea 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -827,6 +827,26 @@ riscv_regno_mode_ok_for_base_p (int regno,
> return GP_REG_P (regno);
> }
>
> +/* Get valid index register class.
> + The RISC-V base instructions don't support index registers,
> + but extensions might support that. */
> +
> +enum reg_class
> +riscv_index_reg_class ()
> +{
> + return NO_REGS;
> +}
> +
> +/* Return true if register REGNO is a valid index register.
> + The RISC-V base instructions don't support index registers,
> + but extensions might support that. */
> +
> +int
> +riscv_regno_ok_for_index_p (int regno)
> +{
> + return 0;
> +}
> +
> /* Return true if X is a valid base register for mode MODE.
> STRICT_P is true if REG_OK_STRICT is in effect. */
>
> diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
> index 90746fe14e3..21b81c22dea 100644
> --- a/gcc/config/riscv/riscv.h
> +++ b/gcc/config/riscv/riscv.h
> @@ -535,7 +535,7 @@ enum reg_class
> factor or added to another register (as well as added to a
> displacement). */
>
> -#define INDEX_REG_CLASS NO_REGS
> +#define INDEX_REG_CLASS riscv_index_reg_class()
>
> /* We generally want to put call-clobbered registers ahead of
> call-saved ones. (IRA expects this.) */
> @@ -705,7 +705,9 @@ typedef struct {
>
> /* Addressing modes, and classification of registers for them. */
>
> -#define REGNO_OK_FOR_INDEX_P(REGNO) 0
> +#define REGNO_OK_FOR_INDEX_P(REGNO) \
> + riscv_regno_ok_for_index_p (REGNO)
> +
> #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \
> riscv_regno_mode_ok_for_base_p (REGNO, MODE, 1)
>
> --
> 2.40.1
>
next prev parent reply other threads:[~2023-04-28 8:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 6:12 [PATCH 00/11] Improvements for XThead* support Christoph Muellner
2023-04-28 6:12 ` [PATCH 01/11] riscv: xtheadbb: Add sign/zero extension support for th.ext and th.extu Christoph Muellner
2023-04-28 7:17 ` Kito Cheng
2023-04-28 6:12 ` [PATCH 02/11] riscv: xtheadmempair: Fix CFA reg notes Christoph Muellner
2023-04-28 7:17 ` Kito Cheng
2024-03-17 20:22 ` Christoph Müllner
2024-03-18 3:25 ` Jeff Law
2023-04-28 6:12 ` [PATCH 03/11] riscv: xtheadmempair: Fix doc for th_mempair_order_operands() Christoph Muellner
2023-04-28 7:18 ` Kito Cheng
2023-04-28 6:12 ` [PATCH 04/11] riscv: thead: Adjust constraints of th_addsl INSN Christoph Muellner
2023-04-28 7:19 ` Kito Cheng
2023-04-28 6:12 ` [PATCH 05/11] riscv: Simplify output of MEM addresses Christoph Muellner
2023-04-28 7:21 ` Kito Cheng
2023-04-28 6:12 ` [PATCH 06/11] riscv: Define Xmode macro Christoph Muellner
2023-04-28 7:23 ` Kito Cheng
2023-04-28 6:12 ` [PATCH 07/11] riscv: Move address classification info types to riscv-protos.h Christoph Muellner
2023-04-28 7:23 ` Kito Cheng
2023-04-28 6:12 ` [PATCH 08/11] riscv: Prepare backend for index registers Christoph Muellner
2023-04-28 8:34 ` Kito Cheng [this message]
2023-04-28 6:12 ` [PATCH 09/11] riscv: thead: Factor out XThead*-specific peepholes Christoph Muellner
2023-04-28 8:37 ` Kito Cheng
2023-04-28 8:35 ` [PATCH 00/11] Improvements for XThead* support 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='CALLt3Tj=7ZrWtfbd0DH1K71_HOC0NF37tmRJtQSdNuhhqC9jKw@mail.gmail.com' \
--to=kito.cheng@sifive.com \
--cc=andrew@sifive.com \
--cc=christoph.muellner@vrull.eu \
--cc=cooper.qu@linux.alibaba.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jim.wilson.gcc@gmail.com \
--cc=lifang_xia@linux.alibaba.com \
--cc=palmer@dabbelt.com \
--cc=philipp.tomsich@vrull.eu \
--cc=yunhai@linux.alibaba.com \
--cc=zhiwei_liu@linux.alibaba.com \
/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).