[gcc r16-3901] RISC-V: Allow profiles input in '--with-arch' option.
Jeff Law
law@gcc.gnu.org
Tue Sep 16 03:56:32 GMT 2025
https://gcc.gnu.org/g:41d8c4e150f21a256e2e0553d715f12f48e78636
commit r16-3901-g41d8c4e150f21a256e2e0553d715f12f48e78636
Author: Jiawei <jiawei@iscas.ac.cn>
Date: Mon Sep 15 21:56:05 2025 -0600
RISC-V: Allow profiles input in '--with-arch' option.
Allows profiles input in '--with-arch'. Check profiles with
'riscv-profiles.def'.
gcc/ChangeLog:
* config.gcc: Accept RISC-V profiles in `--with-arch`.
* config/riscv/arch-canonicalize: Add profile detection and
skip canonicalization for profiles.
Diff:
---
gcc/config.gcc | 13 ++++++++++---
gcc/config/riscv/arch-canonicalize | 23 ++++++++++++++++++++++-
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 9da9ac51eccd..9251b10ac897 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4775,7 +4775,8 @@ case "${target}" in
# Infer arch from --with-arch, --target, and --with-abi.
case "${with_arch}" in
- rv32e* | rv32i* | rv32g* | rv64e* | rv64i* | rv64g*)
+ rv32e* | rv32i* | rv32g* | rv64e* | rv64i* | rv64g* \
+ | rvi20* | rva20* | rva22* | rva23* | rvb23*)
# OK.
;;
"")
@@ -4789,7 +4790,7 @@ case "${target}" in
esac
;;
*)
- echo "--with-arch=${with_arch} is not supported. The argument must begin with rv32e, rv32i, rv32g, rv64e, rv64i, or rv64g." 1>&2
+ echo "--with-arch=${with_arch} is not supported. The argument must begin with rv32e, rv32i, rv32g, rv64e, rv64i, rv64g, or a profile." 1>&2
exit 1
;;
esac
@@ -4827,9 +4828,15 @@ case "${target}" in
ilp32,rv32* | ilp32e,rv32e* \
| ilp32f,rv32*f* | ilp32f,rv32g* \
| ilp32d,rv32*d* | ilp32d,rv32g* \
+ | ilp32,rvi20u32* | ilp32f,rvi20u32* \
+ | ilp32d,rvi20u32* \
| lp64,rv64* | lp64e,rv64e* \
| lp64f,rv64*f* | lp64f,rv64g* \
- | lp64d,rv64*d* | lp64d,rv64g*)
+ | lp64d,rv64*d* | lp64d,rv64g* \
+ | lp64,rvi20u64* | lp64f,rvi20u64* \
+ | lp64d,rva20u64* | lp64d,rva22u64* \
+ | lp64d,rva23u64* | lp64d,rva23s64* \
+ | lp64d,rvb23u64* | lp64d,rvb23s64)
;;
*)
echo "--with-abi=${with_abi} is not supported for ISA ${with_arch}" 1>&2
diff --git a/gcc/config/riscv/arch-canonicalize b/gcc/config/riscv/arch-canonicalize
index 15a398502b38..78c8b25d17e5 100755
--- a/gcc/config/riscv/arch-canonicalize
+++ b/gcc/config/riscv/arch-canonicalize
@@ -341,6 +341,24 @@ def get_all_extensions():
#
IMPLIED_EXT = parse_def_files()
+def load_profiles():
+ profiles = set()
+ def_path = os.path.join(os.path.dirname(__file__), "riscv-profiles.def")
+ with open(def_path) as f:
+ for line in f:
+ line = line.strip()
+ if line.startswith("RISCV_PROFILE"):
+ # Format: RISCV_PROFILE("rva20u64", "rv64imafd...")
+ parts = line.split('"')
+ if len(parts) >= 2:
+ profiles.add(parts[1]) # Compare PROFILE_NAME
+ return profiles
+
+SUPPORTED_PROFILES = load_profiles()
+
+def is_profile_arch(arch):
+ return arch in SUPPORTED_PROFILES
+
def arch_canonicalize(arch, isa_spec):
# TODO: Support extension version.
is_isa_spec_2p2 = isa_spec == '2.2'
@@ -608,7 +626,10 @@ if __name__ == "__main__":
sys.exit(run_unit_tests())
elif args.arch_strs:
for arch in args.arch_strs:
- print (arch_canonicalize(arch, args.misa_spec))
+ if is_profile_arch(arch):
+ print(arch)
+ else:
+ print(arch_canonicalize(arch, args.misa_spec))
else:
parser.print_help()
sys.exit(1)
More information about the Gcc-cvs
mailing list