aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorChristoph Müllner <christoph.muellner@vrull.eu>2023-04-24 23:54:16 +0200
committerKito Cheng <kito.cheng@sifive.com>2023-07-12 16:12:28 +0800
commit423604278ed550f07f80c9687a441c58a6cd6e85 (patch)
tree262a7869e76d9f01f006466587aa0d2aaee3ac2c /gcc
parent96ad6ab29b3d6d8646c97760cc87a17f405e09d2 (diff)
downloadgcc-423604278ed550f07f80c9687a441c58a6cd6e85.zip
gcc-423604278ed550f07f80c9687a441c58a6cd6e85.tar.gz
gcc-423604278ed550f07f80c9687a441c58a6cd6e85.tar.bz2
riscv: Prepare backend for index registers
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>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/riscv/riscv-protos.h2
-rw-r--r--gcc/config/riscv/riscv.cc20
-rw-r--r--gcc/config/riscv/riscv.h6
3 files changed, 26 insertions, 2 deletions
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 8f5a5ab..5ce0d47 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -84,6 +84,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 477b83c..af18231 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -846,6 +846,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 7d548ac..1968315 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -542,7 +542,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.) */
@@ -714,7 +714,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)