]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Allow profiles input in '--with-arch' option.
authorJiawei <jiawei@iscas.ac.cn>
Tue, 16 Sep 2025 03:56:05 +0000 (21:56 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Tue, 16 Sep 2025 03:56:05 +0000 (21:56 -0600)
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.

gcc/config.gcc
gcc/config/riscv/arch-canonicalize

index 9da9ac51eccd4f5c8dc88a5994c5173568e1cd63..9251b10ac897971ad2a5f0cedb6f89471dead83e 100644 (file)
@@ -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
index 15a398502b380fb90f9845432cef7b2cab0a224b..78c8b25d17e51feede6220dcde6a6ea6575d059f 100755 (executable)
@@ -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)