aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTsukasa OI <research_trasio@irq.a4lg.com>2023-08-12 00:38:18 +0000
committerTsukasa OI <research_trasio@irq.a4lg.com>2023-08-29 13:48:19 +0000
commit4053d295fdd81d3e05c4977e3cd9c647e8cc6bc2 (patch)
tree3d1c48fe6927a15b167e94e6751483e4a9e1a98c
parent8b0662254cdac3e0b670c1c54752e1d43113b0f4 (diff)
downloadgcc-4053d295fdd81d3e05c4977e3cd9c647e8cc6bc2.zip
gcc-4053d295fdd81d3e05c4977e3cd9c647e8cc6bc2.tar.gz
gcc-4053d295fdd81d3e05c4977e3cd9c647e8cc6bc2.tar.bz2
RISC-V: Add stub support for existing extensions (privileged)
After commit c283c4774d1c ("RISC-V: Throw compilation error for unknown extensions") changed how do we handle unknown extensions, we have no guarantee that we can share the same architectural string with Binutils (specifically, the assembler). To avoid compilation errors on shared Assembler-C/C++ projects or programs with inline assembler, GCC should support almost all extensions that Binutils support, even if the GCC itself does not touch a thing. As a start, this commit adds stub supported *privileged* extensions to riscv_ext_version_table and its implications to riscv_implied_info (all information is copied from Binutils' bfd/elfxx-riscv.c). gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_implied_info): Add implications from privileged extensions. (riscv_ext_version_table): Add stub support for all privileged extensions supported by Binutils. gcc/testsuite/ChangeLog: * gcc.target/riscv/predef-29.c: New test for a stub privileged extension 'Smstateen' with some implications.
-rw-r--r--gcc/common/config/riscv/riscv-common.cc18
-rw-r--r--gcc/testsuite/gcc.target/riscv/predef-29.c35
2 files changed, 53 insertions, 0 deletions
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index a5b62cd..3502993 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -143,6 +143,14 @@ static const riscv_implied_info_t riscv_implied_info[] =
{"zcmp", "zca"},
{"zcmt", "zca"},
+ {"smaia", "ssaia"},
+ {"smstateen", "ssstateen"},
+ {"smepmp", "zicsr"},
+ {"ssaia", "zicsr"},
+ {"sscofpmf", "zicsr"},
+ {"ssstateen", "zicsr"},
+ {"sstc", "zicsr"},
+
{NULL, NULL}
};
@@ -288,8 +296,18 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
{"zcmp", ISA_SPEC_CLASS_NONE, 1, 0},
{"zcmt", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"smaia", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"smepmp", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"smstateen", ISA_SPEC_CLASS_NONE, 1, 0},
+
+ {"ssaia", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"sscofpmf", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"ssstateen", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"sstc", ISA_SPEC_CLASS_NONE, 1, 0},
+
{"svinval", ISA_SPEC_CLASS_NONE, 1, 0},
{"svnapot", ISA_SPEC_CLASS_NONE, 1, 0},
+ {"svpbmt", ISA_SPEC_CLASS_NONE, 1, 0},
{"xtheadba", ISA_SPEC_CLASS_NONE, 1, 0},
{"xtheadbb", ISA_SPEC_CLASS_NONE, 1, 0},
diff --git a/gcc/testsuite/gcc.target/riscv/predef-29.c b/gcc/testsuite/gcc.target/riscv/predef-29.c
new file mode 100644
index 0000000..61c6429
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/predef-29.c
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64i_smstateen -mabi=lp64 -mcmodel=medlow -misa-spec=20191213" } */
+
+int main () {
+
+#ifndef __riscv_arch_test
+#error "__riscv_arch_test"
+#endif
+
+#if __riscv_xlen != 64
+#error "__riscv_xlen"
+#endif
+
+#if !defined(__riscv_i) || (__riscv_i != (2 * 1000 * 1000 + 1 * 1000))
+#error "__riscv_i"
+#endif
+
+#if defined(__riscv_e)
+#error "__riscv_e"
+#endif
+
+#if !defined(__riscv_zicsr)
+#error "__riscv_zicsr"
+#endif
+
+#if !defined(__riscv_smstateen)
+#error "__riscv_smstateen"
+#endif
+
+#if !defined(__riscv_ssstateen)
+#error "__riscv_ssstateen"
+#endif
+
+ return 0;
+}