RISC-V: Fix -march option parsing when extension exists.

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.
This commit is contained in:
Xing GUO 2021-01-28 11:22:40 +08:00 committed by Kito Cheng
parent aa69f0a820
commit f76d0d8645
2 changed files with 5 additions and 3 deletions

View file

@ -527,9 +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;
*explicit_version_p = true;
get_default_version (ext, major_version, minor_version);
return p;
}
else

View file

@ -0,0 +1,4 @@
/* { dg-do compile } */
/* { dg-options "-march=rv64imafdcp -mabi=lp64d -misa-spec=2.2" } */
int foo() {}
/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_p\"" } } */