public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fix -march option parsing when `p` extension exists.
@ 2021-01-21 12:48 Xing GUO
  2021-01-22  6:26 ` Kito Cheng
  0 siblings, 1 reply; 12+ messages in thread
From: Xing GUO @ 2021-01-21 12:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: kito.cheng

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

This patch fixes -march option parsing when `p` extension exists,
e.g., -march=rv64imafdcp should produce

.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_p"

rather than

.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c_p"

---
gcc/ChangeLog:

        * common/config/riscv/riscv-common.c
(riscv_subset_list::parsing_subset_version):
        Fix -march option parsing when `p` extension exists.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/attribute-18.c: New test.
-- 

Cheers,
Xing

[-- Attachment #2: fix-riscv-march-parsing.patch --]
[-- Type: text/x-patch, Size: 985 bytes --]

diff --git a/gcc/common/config/riscv/riscv-common.c b/gcc/common/config/riscv/riscv-common.c
index b3f5c07c819..a034e218b75 100644
--- a/gcc/common/config/riscv/riscv-common.c
+++ b/gcc/common/config/riscv/riscv-common.c
@@ -527,8 +527,7 @@ riscv_subset_list::parsing_subset_version (const char *ext,
 	      /* Might be beginning of `p` extension.  */
 	      if (std_ext_p)
 		{
-		  *major_version = version;
-		  *minor_version = 0;
+		  get_default_version (ext, major_version, minor_version);
 		  *explicit_version_p = true;
 		  return p;
 		}
diff --git a/gcc/testsuite/gcc.target/riscv/attribute-18.c b/gcc/testsuite/gcc.target/riscv/attribute-18.c
new file mode 100644
index 00000000000..30a12543ed2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/attribute-18.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64imafdcp -mabi=lp64d" } */
+int foo() {}
+/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_p\"" } } */

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-04 23:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 12:48 [PATCH] RISC-V: Fix -march option parsing when `p` extension exists Xing GUO
2021-01-22  6:26 ` Kito Cheng
2021-01-22  6:44   ` Xing GUO
2021-01-22  6:48     ` Kito Cheng
2021-01-27  1:46       ` Xing GUO
2021-01-27  5:54         ` Xing GUO
2021-01-28  3:27           ` Kito Cheng
2021-01-31 18:38           ` Andreas Schwab
2021-02-01  0:59             ` Xing GUO
2021-02-01  8:58               ` Xing GUO
2021-02-01  9:36                 ` Kito Cheng
2021-02-04 23:48       ` Jim Wilson

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