diff options
author | Kito Cheng <kito.cheng@sifive.com> | 2022-10-14 17:34:02 +0800 |
---|---|---|
committer | Kito Cheng <kito.cheng@sifive.com> | 2022-10-26 08:59:45 +0800 |
commit | 0cd11d301013af50a3fae0694c909952e94e20d5 (patch) | |
tree | 308a8f19b2c6ee58a6bc27e1ddeaeb4e58fc0ad9 /gcc | |
parent | a9f339d86f8e26e3a4b3ad169e1937a254d19cf7 (diff) | |
download | gcc-0cd11d301013af50a3fae0694c909952e94e20d5.zip gcc-0cd11d301013af50a3fae0694c909952e94e20d5.tar.gz gcc-0cd11d301013af50a3fae0694c909952e94e20d5.tar.bz2 |
RISC-V: Add h extension support
`h` was the prefix of multi-letter extension name, but it become a
extension in later RISC-V isa spec.
Fortunately we don't have any extension really defined is prefixed
with `h`, so we can just change that.
gcc/ChangeLog:
* common/config/riscv/riscv-common.cc (riscv_ext_version_table):
Add `h`.
(riscv_supported_std_ext): Ditto.
(multi_letter_subset_rank): Remove `h`.
(riscv_subset_list::parse_std_ext): Handle `h` as single letter
extension.
(riscv_subset_list::parse): Ditto.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/arch-18.c: New.
* gcc.target/riscv/arch-5.c: Remove test for prefixed
with `h`.
* gcc.target/riscv/predef-23.c: New.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/common/config/riscv/riscv-common.cc | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/arch-18.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/arch-5.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/riscv/predef-23.c | 63 |
4 files changed, 77 insertions, 16 deletions
diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index dead3802..d77020b 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -145,6 +145,8 @@ static const struct riscv_ext_version riscv_ext_version_table[] = {"c", ISA_SPEC_CLASS_20190608, 2, 0}, {"c", ISA_SPEC_CLASS_2P2, 2, 0}, + {"h", ISA_SPEC_CLASS_NONE, 1, 0}, + {"v", ISA_SPEC_CLASS_NONE, 1, 0}, {"zicsr", ISA_SPEC_CLASS_20191213, 2, 0}, @@ -361,21 +363,18 @@ multi_letter_subset_rank (const std::string &subset) gcc_assert (subset.length () >= 2); int high_order = -1; int low_order = 0; - /* The order between multi-char extensions: s -> h -> z -> x. */ + /* The order between multi-char extensions: s -> z -> x. */ char multiletter_class = subset[0]; switch (multiletter_class) { case 's': high_order = 0; break; - case 'h': - high_order = 1; - break; case 'z': - high_order = 2; + high_order = 1; break; case 'x': - high_order = 3; + high_order = 2; break; default: gcc_unreachable (); @@ -671,7 +670,7 @@ riscv_subset_list::lookup (const char *subset, int major_version, static const char * riscv_supported_std_ext (void) { - return "mafdqlcbkjtpvn"; + return "mafdqlcbkjtpvnh"; } /* Parsing subset version. @@ -830,7 +829,7 @@ riscv_subset_list::parse_std_ext (const char *p) { char subset[2] = {0, 0}; - if (*p == 'x' || *p == 's' || *p == 'h' || *p == 'z') + if (*p == 'x' || *p == 's' || *p == 'z') break; if (*p == '_') @@ -955,7 +954,7 @@ riscv_subset_list::handle_combine_ext () Arguments: `p`: Current parsing position. - `ext_type`: What kind of extensions, 's', 'h', 'z' or 'x'. + `ext_type`: What kind of extensions, 's', 'z' or 'x'. `ext_type_str`: Full name for kind of extension. */ const char * @@ -1097,12 +1096,6 @@ riscv_subset_list::parse (const char *arch, location_t loc) if (p == NULL) goto fail; - /* Parsing hypervisor extension. */ - p = subset_list->parse_multiletter_ext (p, "h", "hypervisor extension"); - - if (p == NULL) - goto fail; - /* Parsing sub-extensions. */ p = subset_list->parse_multiletter_ext (p, "z", "sub-extension"); diff --git a/gcc/testsuite/gcc.target/riscv/arch-18.c b/gcc/testsuite/gcc.target/riscv/arch-18.c new file mode 100644 index 0000000..bb04536 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-18.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv32gcvh -mabi=ilp32 -mcmodel=medlow" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/arch-5.c b/gcc/testsuite/gcc.target/riscv/arch-5.c index 2a0f3b78..b945a64 100644 --- a/gcc/testsuite/gcc.target/riscv/arch-5.c +++ b/gcc/testsuite/gcc.target/riscv/arch-5.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-march=rv32isabc_hghi_zfoo_xbar -mabi=ilp32" } */ +/* { dg-options "-march=rv32isabc_zfoo_xbar -mabi=ilp32" } */ int foo() { } diff --git a/gcc/testsuite/gcc.target/riscv/predef-23.c b/gcc/testsuite/gcc.target/riscv/predef-23.c new file mode 100644 index 0000000..676023f2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/predef-23.c @@ -0,0 +1,63 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv64ih_zfhmin -mabi=lp64f -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) +#error "__riscv_i" +#endif + +#if defined(__riscv_c) +#error "__riscv_c" +#endif + +#if defined(__riscv_e) +#error "__riscv_e" +#endif + +#if defined(__riscv_a) +#error "__riscv_a" +#endif + +#if defined(__riscv_m) +#error "__riscv_m" +#endif + +#if !defined(__riscv_f) +#error "__riscv_f" +#endif + +#if defined(__riscv_d) +#error "__riscv_d" +#endif + +#if defined(__riscv_v) +#error "__riscv_v" +#endif + +#if defined(__riscv_zfh) +#error "__riscv_zfh" +#endif + +#if !defined(__riscv_zfhmin) +#error "__riscv_zfhmin" +#endif + +#if !defined(__riscv_zicsr) +#error "__riscv_zicsr" +#endif + +#if !defined(__riscv_h) +#error "__riscv_h" +#endif + + return 0; +} |