public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Add stub support for existing extensions (unprivileged)
@ 2023-09-11 13:33 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-09-11 13:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9253e6f6799adc51a9759243116707fd239e2b65

commit 9253e6f6799adc51a9759243116707fd239e2b65
Author: Tsukasa OI <research_trasio@irq.a4lg.com>
Date:   Sat Aug 12 00:38:18 2023 +0000

    RISC-V: Add stub support for existing extensions (unprivileged)
    
    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.
    
    This commit adds stub supported standard unprivileged extensions to
    riscv_ext_version_table and its implications to riscv_implied_info
    (all information is copied from Binutils' bfd/elfxx-riscv.c except not yet
    merged 'Zce', 'Zcmp' and 'Zcmt' support).
    
    gcc/ChangeLog:
    
            * common/config/riscv/riscv-common.cc
            (riscv_implied_info): Add implications from unprivileged extensions.
            (riscv_ext_version_table): Add stub support for all unprivileged
            extensions supported by Binutils as well as 'Zce', 'Zcmp', 'Zcmt'.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/predef-31.c: New test for a stub unprivileged
            extension 'Zcb' with some implications.
    
    (cherry picked from commit f30d6a48635b5b180e46c51138d0938d33abd942)

Diff:
---
 gcc/common/config/riscv/riscv-common.cc    |  1 +
 gcc/testsuite/gcc.target/riscv/predef-31.c | 31 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 8e2b3ba6d621..f142212f2edc 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -142,6 +142,7 @@ static const riscv_implied_info_t riscv_implied_info[] =
   {"zcb",  "zca"},
   {"zcmp", "zca"},
   {"zcmt", "zca"},
+  {"zcmt", "zicsr"},
 
   {"smaia", "ssaia"},
   {"smstateen", "ssstateen"},
diff --git a/gcc/testsuite/gcc.target/riscv/predef-31.c b/gcc/testsuite/gcc.target/riscv/predef-31.c
new file mode 100644
index 000000000000..4ea11442f995
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/predef-31.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64i_zcb -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_zca)
+#error "__riscv_zca"
+#endif
+
+#if !defined(__riscv_zcb)
+#error "__riscv_zcb"
+#endif
+
+  return 0;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-11 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-11 13:33 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Add stub support for existing extensions (unprivileged) Jeff Law

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).