aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Bennett <mary.bennett@embecosm.com>2023-12-15 14:59:03 -0700
committerJeff Law <jlaw@ventanamicro.com>2023-12-15 15:00:52 -0700
commit14876d6aa73b9e9385313c857ab6f399e4823bf8 (patch)
tree7e16451b2a8d45c0e89709b3b1e4173a597c874b
parent723d62feae96fb528d5faf715fe2ff47233670a0 (diff)
downloadgcc-14876d6aa73b9e9385313c857ab6f399e4823bf8.zip
gcc-14876d6aa73b9e9385313c857ab6f399e4823bf8.tar.gz
gcc-14876d6aa73b9e9385313c857ab6f399e4823bf8.tar.bz2
[PATCH v4 1/3] RISC-V: Add support for XCVelw extension in CV32E40P
Spec: github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md Contributors: Mary Bennett <mary.bennett@embecosm.com> Nandni Jamnadas <nandni.jamnadas@embecosm.com> Pietra Ferreira <pietra.ferreira@embecosm.com> Charlie Keaney Jessica Mills Craig Blackmore <craig.blackmore@embecosm.com> Simon Cook <simon.cook@embecosm.com> Jeremy Bennett <jeremy.bennett@embecosm.com> Helene Chelin <helene.chelin@embecosm.com> gcc/ChangeLog: * common/config/riscv/riscv-common.cc: Add XCVelw. * config/riscv/corev.def: Likewise. * config/riscv/corev.md: Likewise. * config/riscv/riscv-builtins.cc (AVAIL): Likewise. * config/riscv/riscv-ftypes.def: Likewise. * config/riscv/riscv.opt: Likewise. * doc/extend.texi: Add XCVelw builtin documentation. * doc/sourcebuild.texi: Likewise. gcc/testsuite/ChangeLog: * gcc.target/riscv/cv-elw-elw-compile-1.c: Create test for cv.elw. * lib/target-supports.exp: Add proc for the XCVelw extension.
-rw-r--r--gcc/common/config/riscv/riscv-common.cc2
-rw-r--r--gcc/config/riscv/corev.def3
-rw-r--r--gcc/config/riscv/corev.md15
-rw-r--r--gcc/config/riscv/riscv-builtins.cc2
-rw-r--r--gcc/config/riscv/riscv-ftypes.def1
-rw-r--r--gcc/config/riscv/riscv.opt2
-rw-r--r--gcc/doc/extend.texi8
-rw-r--r--gcc/doc/sourcebuild.texi3
-rw-r--r--gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c11
-rw-r--r--gcc/testsuite/lib/target-supports.exp13
10 files changed, 60 insertions, 0 deletions
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 845fd01..f20d179 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -354,6 +354,7 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
{"xcvmac", ISA_SPEC_CLASS_NONE, 1, 0},
{"xcvalu", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"xcvelw", ISA_SPEC_CLASS_NONE, 1, 0},
{"xtheadba", ISA_SPEC_CLASS_NONE, 1, 0},
{"xtheadbb", ISA_SPEC_CLASS_NONE, 1, 0},
@@ -1728,6 +1729,7 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
{"xcvmac", &gcc_options::x_riscv_xcv_subext, MASK_XCVMAC},
{"xcvalu", &gcc_options::x_riscv_xcv_subext, MASK_XCVALU},
+ {"xcvelw", &gcc_options::x_riscv_xcv_subext, MASK_XCVELW},
{"xtheadba", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBA},
{"xtheadbb", &gcc_options::x_riscv_xthead_subext, MASK_XTHEADBB},
diff --git a/gcc/config/riscv/corev.def b/gcc/config/riscv/corev.def
index 17580df..3b9ec02 100644
--- a/gcc/config/riscv/corev.def
+++ b/gcc/config/riscv/corev.def
@@ -41,3 +41,6 @@ RISCV_BUILTIN (cv_alu_subN, "cv_alu_subN", RISCV_BUILTIN_DIRECT, RISCV_SI_FT
RISCV_BUILTIN (cv_alu_subuN, "cv_alu_subuN", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI_USI_UQI, cvalu),
RISCV_BUILTIN (cv_alu_subRN, "cv_alu_subRN", RISCV_BUILTIN_DIRECT, RISCV_SI_FTYPE_SI_SI_UQI, cvalu),
RISCV_BUILTIN (cv_alu_subuRN, "cv_alu_subuRN",RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_USI_USI_UQI, cvalu),
+
+// XCVELW
+RISCV_BUILTIN (cv_elw_elw_si, "cv_elw_elw", RISCV_BUILTIN_DIRECT, RISCV_USI_FTYPE_VOID_PTR, cvelw),
diff --git a/gcc/config/riscv/corev.md b/gcc/config/riscv/corev.md
index 1350bd4..c7a2ba0 100644
--- a/gcc/config/riscv/corev.md
+++ b/gcc/config/riscv/corev.md
@@ -24,6 +24,9 @@
UNSPEC_CV_ALU_CLIPR
UNSPEC_CV_ALU_CLIPU
UNSPEC_CV_ALU_CLIPUR
+
+ ;;CORE-V EVENT LOAD
+ UNSPECV_CV_ELW
])
;; XCVMAC extension.
@@ -691,3 +694,15 @@
cv.suburnr\t%0,%2,%3"
[(set_attr "type" "arith")
(set_attr "mode" "SI")])
+
+;; XCVELW builtins
+(define_insn "riscv_cv_elw_elw_si"
+ [(set (match_operand:SI 0 "register_operand" "=r")
+ (unspec_volatile [(match_operand:SI 1 "move_operand" "p")]
+ UNSPECV_CV_ELW))]
+
+ "TARGET_XCVELW && !TARGET_64BIT"
+ "cv.elw\t%0,%a1"
+
+ [(set_attr "type" "load")
+ (set_attr "mode" "SI")])
diff --git a/gcc/config/riscv/riscv-builtins.cc b/gcc/config/riscv/riscv-builtins.cc
index fc3976f..5ee11eb 100644
--- a/gcc/config/riscv/riscv-builtins.cc
+++ b/gcc/config/riscv/riscv-builtins.cc
@@ -128,6 +128,7 @@ AVAIL (hint_pause, (!0))
// CORE-V AVAIL
AVAIL (cvmac, TARGET_XCVMAC && !TARGET_64BIT)
AVAIL (cvalu, TARGET_XCVALU && !TARGET_64BIT)
+AVAIL (cvelw, TARGET_XCVELW && !TARGET_64BIT)
/* Construct a riscv_builtin_description from the given arguments.
@@ -168,6 +169,7 @@ AVAIL (cvalu, TARGET_XCVALU && !TARGET_64BIT)
#define RISCV_ATYPE_HI intHI_type_node
#define RISCV_ATYPE_SI intSI_type_node
#define RISCV_ATYPE_VOID_PTR ptr_type_node
+#define RISCV_ATYPE_INT_PTR integer_ptr_type_node
/* RISCV_FTYPE_ATYPESN takes N RISCV_FTYPES-like type codes and lists
their associated RISCV_ATYPEs. */
diff --git a/gcc/config/riscv/riscv-ftypes.def b/gcc/config/riscv/riscv-ftypes.def
index 0d1e4dd..3e7d5c6 100644
--- a/gcc/config/riscv/riscv-ftypes.def
+++ b/gcc/config/riscv/riscv-ftypes.def
@@ -30,6 +30,7 @@ DEF_RISCV_FTYPE (0, (USI))
DEF_RISCV_FTYPE (0, (VOID))
DEF_RISCV_FTYPE (1, (VOID, USI))
DEF_RISCV_FTYPE (1, (VOID, VOID_PTR))
+DEF_RISCV_FTYPE (1, (USI, VOID_PTR))
DEF_RISCV_FTYPE (1, (USI, USI))
DEF_RISCV_FTYPE (1, (UDI, UDI))
DEF_RISCV_FTYPE (1, (USI, UQI))
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index b7c0b72..ede2d65 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -420,6 +420,8 @@ Mask(XCVMAC) Var(riscv_xcv_subext)
Mask(XCVALU) Var(riscv_xcv_subext)
+Mask(XCVELW) Var(riscv_xcv_subext)
+
TargetVariable
int riscv_xthead_subext
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 72dd1de..766e033 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -24311,6 +24311,14 @@ Generated assembler @code{cv.subuRN} if the uint8_t operand is a constant and in
Generated assembler @code{cv.subuRNr} if the it is a register.
@end deftypefn
+These built-in functions are available for the CORE-V Event Load machine
+architecture. For more information on CORE-V ELW builtins, please see
+@uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-event-load-word-builtins-xcvelw}
+
+@deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_elw_elw (uint32_t *)
+Generated assembler @code{cv.elw}
+@end deftypefn
+
@node RX Built-in Functions
@subsection RX Built-in Functions
GCC supports some of the RX instructions which cannot be expressed in
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 26a7e9c..4be67da 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2485,6 +2485,9 @@ Test system has support for the CORE-V MAC extension.
@item cv_alu
Test system has support for the CORE-V ALU extension.
+@item cv_elw
+Test system has support for the CORE-V ELW extension.
+
@end table
@subsubsection Other hardware attributes
diff --git a/gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c b/gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c
new file mode 100644
index 0000000..30f951c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/cv-elw-elw-compile-1.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target cv_elw } */
+/* { dg-options "-march=rv32i_xcvelw -mabi=ilp32" } */
+
+int
+foo (void* b)
+{
+ return __builtin_riscv_cv_elw_elw (b + 8);
+}
+
+/* { dg-final { scan-assembler-times "cv\\.elw\t\[a-z\]\[0-99\],\[0-99\]\\(\[a-z\]\[0-99\]\\)" 1 } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 14e3e11..bd38d72 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -13144,6 +13144,19 @@ proc check_effective_target_cv_alu { } {
} "-march=rv32i_xcvalu" ]
}
+# Return 1 if the CORE-V ELW extension is available.
+proc check_effective_target_cv_elw { } {
+ if { !([istarget riscv*-*-*]) } {
+ return 0
+ }
+ return [check_no_compiler_messages cv_elw object {
+ void foo (void)
+ {
+ asm ("cv.elw x0, 0(x0)");
+ }
+ } "-march=rv32i_xcvelw" ]
+}
+
proc check_effective_target_loongarch_sx { } {
return [check_no_compiler_messages loongarch_lsx assembly {
#if !defined(__loongarch_sx)