[clang] [llvm] [RISCV] Support RISC-V Profiles in -march option (PR #76357)
Wang Pengcheng via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 10 22:15:00 PDT 2024
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/76357
>From 8dc42f5c90ba369a145868f8c1a9a8cb3e988cb0 Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Mon, 25 Dec 2023 18:52:36 +0800
Subject: [PATCH] [RISCV] Support RISC-V Profiles in -march option
This PR implements the draft
https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/36.
Currently, we replace specified profile in `-march` with standard
arch string.
---
clang/docs/ReleaseNotes.rst | 1 +
clang/test/Driver/riscv-profiles.c | 312 +++++++++++++++++++++++++++++
llvm/lib/Support/RISCVISAInfo.cpp | 65 ++++++
3 files changed, 378 insertions(+)
create mode 100644 clang/test/Driver/riscv-profiles.c
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index bce27dc8c4a996..a072bf4a5ff4b0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -408,6 +408,7 @@ RISC-V Support
^^^^^^^^^^^^^^
- ``__attribute__((rvv_vector_bits(N)))`` is now supported for RVV vbool*_t types.
+- Profile names in ``-march`` option is now supported.
CUDA/HIP Language Changes
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/test/Driver/riscv-profiles.c b/clang/test/Driver/riscv-profiles.c
new file mode 100644
index 00000000000000..904f0c371f4442
--- /dev/null
+++ b/clang/test/Driver/riscv-profiles.c
@@ -0,0 +1,312 @@
+// RUN: %clang -### -c %s 2>&1 -march=rvi20u32 | FileCheck -check-prefix=RVI20U32 %s
+// RVI20U32: "-target-feature" "-a"
+// RVI20U32: "-target-feature" "-c"
+// RVI20U32: "-target-feature" "-d"
+// RVI20U32: "-target-feature" "-f"
+// RVI20U32: "-target-feature" "-m"
+
+// RUN: %clang -### -c %s 2>&1 -march=rvi20u64 | FileCheck -check-prefix=RVI20U64 %s
+// RVI20U64: "-target-feature" "-a"
+// RVI20U64: "-target-feature" "-c"
+// RVI20U64: "-target-feature" "-d"
+// RVI20U64: "-target-feature" "-f"
+// RVI20U64: "-target-feature" "-m"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva20u64 | FileCheck -check-prefix=RVA20U64 %s
+// RVA20U64: "-target-feature" "+m"
+// RVA20U64: "-target-feature" "+a"
+// RVA20U64: "-target-feature" "+f"
+// RVA20U64: "-target-feature" "+d"
+// RVA20U64: "-target-feature" "+c"
+// RVA20U64: "-target-feature" "+ziccamoa"
+// RVA20U64: "-target-feature" "+ziccif"
+// RVA20U64: "-target-feature" "+zicclsm"
+// RVA20U64: "-target-feature" "+ziccrse"
+// RVA20U64: "-target-feature" "+zicntr"
+// RVA20U64: "-target-feature" "+zicsr"
+// RVA20U64: "-target-feature" "+za128rs"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva20s64 | FileCheck -check-prefix=RVA20S64 %s
+// RVA20S64: "-target-feature" "+m"
+// RVA20S64: "-target-feature" "+a"
+// RVA20S64: "-target-feature" "+f"
+// RVA20S64: "-target-feature" "+d"
+// RVA20S64: "-target-feature" "+c"
+// RVA20S64: "-target-feature" "+ziccamoa"
+// RVA20S64: "-target-feature" "+ziccif"
+// RVA20S64: "-target-feature" "+zicclsm"
+// RVA20S64: "-target-feature" "+ziccrse"
+// RVA20S64: "-target-feature" "+zicntr"
+// RVA20S64: "-target-feature" "+zicsr"
+// RVA20S64: "-target-feature" "+zifencei"
+// RVA20S64: "-target-feature" "+za128rs"
+// RVA20S64: "-target-feature" "+ssccptr"
+// RVA20S64: "-target-feature" "+sstvala"
+// RVA20S64: "-target-feature" "+sstvecd"
+// RVA20S64: "-target-feature" "+svade"
+// RVA20S64: "-target-feature" "+svbare"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva22u64 | FileCheck -check-prefix=RVA22U64 %s
+// RVA22U64: "-target-feature" "+m"
+// RVA22U64: "-target-feature" "+a"
+// RVA22U64: "-target-feature" "+f"
+// RVA22U64: "-target-feature" "+d"
+// RVA22U64: "-target-feature" "+c"
+// RVA22U64: "-target-feature" "+zic64b"
+// RVA22U64: "-target-feature" "+zicbom"
+// RVA22U64: "-target-feature" "+zicbop"
+// RVA22U64: "-target-feature" "+zicboz"
+// RVA22U64: "-target-feature" "+ziccamoa"
+// RVA22U64: "-target-feature" "+ziccif"
+// RVA22U64: "-target-feature" "+zicclsm"
+// RVA22U64: "-target-feature" "+ziccrse"
+// RVA22U64: "-target-feature" "+zicntr"
+// RVA22U64: "-target-feature" "+zicsr"
+// RVA22U64: "-target-feature" "+zihintpause"
+// RVA22U64: "-target-feature" "+zihpm"
+// RVA22U64: "-target-feature" "+za64rs"
+// RVA22U64: "-target-feature" "+zfhmin"
+// RVA22U64: "-target-feature" "+zba"
+// RVA22U64: "-target-feature" "+zbb"
+// RVA22U64: "-target-feature" "+zbs"
+// RVA22U64: "-target-feature" "+zkt"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva22s64 | FileCheck -check-prefix=RVA22S64 %s
+// RVA22S64: "-target-feature" "+m"
+// RVA22S64: "-target-feature" "+a"
+// RVA22S64: "-target-feature" "+f"
+// RVA22S64: "-target-feature" "+d"
+// RVA22S64: "-target-feature" "+c"
+// RVA22S64: "-target-feature" "+zic64b"
+// RVA22S64: "-target-feature" "+zicbom"
+// RVA22S64: "-target-feature" "+zicbop"
+// RVA22S64: "-target-feature" "+zicboz"
+// RVA22S64: "-target-feature" "+ziccamoa"
+// RVA22S64: "-target-feature" "+ziccif"
+// RVA22S64: "-target-feature" "+zicclsm"
+// RVA22S64: "-target-feature" "+ziccrse"
+// RVA22S64: "-target-feature" "+zicntr"
+// RVA22S64: "-target-feature" "+zicsr"
+// RVA22S64: "-target-feature" "+zifencei"
+// RVA22S64: "-target-feature" "+zihintpause"
+// RVA22S64: "-target-feature" "+zihpm"
+// RVA22S64: "-target-feature" "+za64rs"
+// RVA22S64: "-target-feature" "+zfhmin"
+// RVA22S64: "-target-feature" "+zba"
+// RVA22S64: "-target-feature" "+zbb"
+// RVA22S64: "-target-feature" "+zbs"
+// RVA22S64: "-target-feature" "+zkt"
+// RVA22S64: "-target-feature" "+ssccptr"
+// RVA22S64: "-target-feature" "+sscounterenw"
+// RVA22S64: "-target-feature" "+sstvala"
+// RVA22S64: "-target-feature" "+sstvecd"
+// RVA22S64: "-target-feature" "+svade"
+// RVA22S64: "-target-feature" "+svbare"
+// RVA22S64: "-target-feature" "+svinval"
+// RVA22S64: "-target-feature" "+svpbmt"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva23u64 -menable-experimental-extensions | FileCheck -check-prefix=RVA23U64 %s
+// RVA23U64: "-target-feature" "+m"
+// RVA23U64: "-target-feature" "+a"
+// RVA23U64: "-target-feature" "+f"
+// RVA23U64: "-target-feature" "+d"
+// RVA23U64: "-target-feature" "+c"
+// RVA23U64: "-target-feature" "+v"
+// RVA23U64: "-target-feature" "+zic64b"
+// RVA23U64: "-target-feature" "+zicbom"
+// RVA23U64: "-target-feature" "+zicbop"
+// RVA23U64: "-target-feature" "+zicboz"
+// RVA23U64: "-target-feature" "+ziccamoa"
+// RVA23U64: "-target-feature" "+ziccif"
+// RVA23U64: "-target-feature" "+zicclsm"
+// RVA23U64: "-target-feature" "+ziccrse"
+// RVA23U64: "-target-feature" "+zicntr"
+// RVA23U64: "-target-feature" "+zicond"
+// RVA23U64: "-target-feature" "+zicsr"
+// RVA23U64: "-target-feature" "+zihintntl"
+// RVA23U64: "-target-feature" "+zihintpause"
+// RVA23U64: "-target-feature" "+zihpm"
+// RVA23U64: "-target-feature" "+experimental-zimop"
+// RVA23U64: "-target-feature" "+za64rs"
+// RVA23U64: "-target-feature" "+zawrs"
+// RVA23U64: "-target-feature" "+zfa"
+// RVA23U64: "-target-feature" "+zfhmin"
+// RVA23U64: "-target-feature" "+zcb"
+// RVA23U64: "-target-feature" "+experimental-zcmop"
+// RVA23U64: "-target-feature" "+zba"
+// RVA23U64: "-target-feature" "+zbb"
+// RVA23U64: "-target-feature" "+zbs"
+// RVA23U64: "-target-feature" "+zkt"
+// RVA23U64: "-target-feature" "+zvbb"
+// RVA23U64: "-target-feature" "+zvfhmin"
+// RVA23U64: "-target-feature" "+zvkt"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva23s64 -menable-experimental-extensions | FileCheck -check-prefix=RVA23S64 %s
+// RVA23S64: "-target-feature" "+m"
+// RVA23S64: "-target-feature" "+a"
+// RVA23S64: "-target-feature" "+f"
+// RVA23S64: "-target-feature" "+d"
+// RVA23S64: "-target-feature" "+c"
+// RVA23S64: "-target-feature" "+v"
+// RVA23S64: "-target-feature" "+h"
+// RVA23S64: "-target-feature" "+zic64b"
+// RVA23S64: "-target-feature" "+zicbom"
+// RVA23S64: "-target-feature" "+zicbop"
+// RVA23S64: "-target-feature" "+zicboz"
+// RVA23S64: "-target-feature" "+ziccamoa"
+// RVA23S64: "-target-feature" "+ziccif"
+// RVA23S64: "-target-feature" "+zicclsm"
+// RVA23S64: "-target-feature" "+ziccrse"
+// RVA23S64: "-target-feature" "+zicntr"
+// RVA23S64: "-target-feature" "+zicond"
+// RVA23S64: "-target-feature" "+zicsr"
+// RVA23S64: "-target-feature" "+zifencei"
+// RVA23S64: "-target-feature" "+zihintntl"
+// RVA23S64: "-target-feature" "+zihintpause"
+// RVA23S64: "-target-feature" "+zihpm"
+// RVA23S64: "-target-feature" "+experimental-zimop"
+// RVA23S64: "-target-feature" "+za64rs"
+// RVA23S64: "-target-feature" "+zawrs"
+// RVA23S64: "-target-feature" "+zfa"
+// RVA23S64: "-target-feature" "+zfhmin"
+// RVA23S64: "-target-feature" "+zcb"
+// RVA23S64: "-target-feature" "+experimental-zcmop"
+// RVA23S64: "-target-feature" "+zba"
+// RVA23S64: "-target-feature" "+zbb"
+// RVA23S64: "-target-feature" "+zbs"
+// RVA23S64: "-target-feature" "+zkt"
+// RVA23S64: "-target-feature" "+zvbb"
+// RVA23S64: "-target-feature" "+zvfhmin"
+// RVA23S64: "-target-feature" "+zvkt"
+// RVA23S64: "-target-feature" "+shcounterenw"
+// RVA23S64: "-target-feature" "+shgatpa"
+// RVA23S64: "-target-feature" "+shtvala"
+// RVA23S64: "-target-feature" "+shvsatpa"
+// RVA23S64: "-target-feature" "+shvstvala"
+// RVA23S64: "-target-feature" "+shvstvecd"
+// RVA23S64: "-target-feature" "+ssccptr"
+// RVA23S64: "-target-feature" "+sscofpmf"
+// RVA23S64: "-target-feature" "+sscounterenw"
+// RVA23S64: "-target-feature" "+experimental-ssnpm"
+// RVA23S64: "-target-feature" "+ssstateen"
+// RVA23S64: "-target-feature" "+sstc"
+// RVA23S64: "-target-feature" "+sstvala"
+// RVA23S64: "-target-feature" "+sstvecd"
+// RVA23S64: "-target-feature" "+ssu64xl"
+// RVA23S64: "-target-feature" "+svade"
+// RVA23S64: "-target-feature" "+svbare"
+// RVA23S64: "-target-feature" "+svinval"
+// RVA23S64: "-target-feature" "+svnapot"
+// RVA23S64: "-target-feature" "+svpbmt"
+
+// RUN: %clang -### -c %s 2>&1 -march=rvb23u64 -menable-experimental-extensions | FileCheck -check-prefix=RVB23U64 %s
+// RVB23U64: "-target-feature" "+m"
+// RVB23U64: "-target-feature" "+a"
+// RVB23U64: "-target-feature" "+f"
+// RVB23U64: "-target-feature" "+d"
+// RVB23U64: "-target-feature" "+c"
+// RVB23U64: "-target-feature" "+zic64b"
+// RVB23U64: "-target-feature" "+zicbom"
+// RVB23U64: "-target-feature" "+zicbop"
+// RVB23U64: "-target-feature" "+zicboz"
+// RVB23U64: "-target-feature" "+ziccamoa"
+// RVB23U64: "-target-feature" "+ziccif"
+// RVB23U64: "-target-feature" "+zicclsm"
+// RVB23U64: "-target-feature" "+ziccrse"
+// RVB23U64: "-target-feature" "+zicntr"
+// RVB23U64: "-target-feature" "+zicond"
+// RVB23U64: "-target-feature" "+zicsr"
+// RVB23U64: "-target-feature" "+zihintntl"
+// RVB23U64: "-target-feature" "+zihintpause"
+// RVB23U64: "-target-feature" "+zihpm"
+// RVB23U64: "-target-feature" "+experimental-zimop"
+// RVB23U64: "-target-feature" "+za64rs"
+// RVB23U64: "-target-feature" "+zawrs"
+// RVB23U64: "-target-feature" "+zfa"
+// RVB23U64: "-target-feature" "+zcb"
+// RVB23U64: "-target-feature" "+experimental-zcmop"
+// RVB23U64: "-target-feature" "+zba"
+// RVB23U64: "-target-feature" "+zbb"
+// RVB23U64: "-target-feature" "+zbs"
+// RVB23U64: "-target-feature" "+zkt"
+
+// RUN: %clang -### -c %s 2>&1 -march=rvb23s64 -menable-experimental-extensions | FileCheck -check-prefix=RVB23S64 %s
+// RVB23S64: "-target-feature" "+m"
+// RVB23S64: "-target-feature" "+a"
+// RVB23S64: "-target-feature" "+f"
+// RVB23S64: "-target-feature" "+d"
+// RVB23S64: "-target-feature" "+c"
+// RVB23S64: "-target-feature" "+zic64b"
+// RVB23S64: "-target-feature" "+zicbom"
+// RVB23S64: "-target-feature" "+zicbop"
+// RVB23S64: "-target-feature" "+zicboz"
+// RVB23S64: "-target-feature" "+ziccamoa"
+// RVB23S64: "-target-feature" "+ziccif"
+// RVB23S64: "-target-feature" "+zicclsm"
+// RVB23S64: "-target-feature" "+ziccrse"
+// RVB23S64: "-target-feature" "+zicntr"
+// RVB23S64: "-target-feature" "+zicond"
+// RVB23S64: "-target-feature" "+zicsr"
+// RVB23S64: "-target-feature" "+zifencei"
+// RVB23S64: "-target-feature" "+zihintntl"
+// RVB23S64: "-target-feature" "+zihintpause"
+// RVB23S64: "-target-feature" "+zihpm"
+// RVB23S64: "-target-feature" "+experimental-zimop"
+// RVB23S64: "-target-feature" "+za64rs"
+// RVB23S64: "-target-feature" "+zawrs"
+// RVB23S64: "-target-feature" "+zfa"
+// RVB23S64: "-target-feature" "+zcb"
+// RVB23S64: "-target-feature" "+experimental-zcmop"
+// RVB23S64: "-target-feature" "+zba"
+// RVB23S64: "-target-feature" "+zbb"
+// RVB23S64: "-target-feature" "+zbs"
+// RVB23S64: "-target-feature" "+zkt"
+// RVB23S64: "-target-feature" "+ssccptr"
+// RVB23S64: "-target-feature" "+sscofpmf"
+// RVB23S64: "-target-feature" "+sscounterenw"
+// RVB23S64: "-target-feature" "+sstc"
+// RVB23S64: "-target-feature" "+sstvala"
+// RVB23S64: "-target-feature" "+sstvecd"
+// RVB23S64: "-target-feature" "+ssu64xl"
+// RVB23S64: "-target-feature" "+svade"
+// RVB23S64: "-target-feature" "+svbare"
+// RVB23S64: "-target-feature" "+svinval"
+// RVB23S64: "-target-feature" "+svnapot"
+// RVB23S64: "-target-feature" "+svpbmt"
+
+// RUN: %clang -### -c %s 2>&1 -march=rvm23u32 -menable-experimental-extensions | FileCheck -check-prefix=RVM23U32 %s
+// RVM23U32: "-target-feature" "+m"
+// RVM23U32: "-target-feature" "+zicbop"
+// RVM23U32: "-target-feature" "+zicond"
+// RVM23U32: "-target-feature" "+zicsr"
+// RVM23U32: "-target-feature" "+zihintntl"
+// RVM23U32: "-target-feature" "+zihintpause"
+// RVM23U32: "-target-feature" "+experimental-zimop"
+// RVM23U32: "-target-feature" "+zce"
+// RVM23U32: "-target-feature" "+experimental-zcmop"
+// RVM23U32: "-target-feature" "+zba"
+// RVM23U32: "-target-feature" "+zbb"
+// RVM23U32: "-target-feature" "+zbs"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva22u64_zfa | FileCheck -check-prefix=PROFILE-WITH-ADDITIONAL %s
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+m"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+a"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+f"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+d"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+c"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicbom"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicbop"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicboz"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zihintpause"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zfa"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zfhmin"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zba"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zbb"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zbs"
+// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zkt"
+
+// RUN: not %clang -### -c %s 2>&1 -march=rva19u64_zfa | FileCheck -check-prefix=INVALID-PROFILE %s
+// INVALID-PROFILE: error: invalid arch name 'rva19u64_zfa', unsupported profile
+
+// RUN: not %clang -### -c %s 2>&1 -march=rva22u64zfa | FileCheck -check-prefix=INVALID-ADDITIONAL %s
+// INVALID-ADDITIONAL: error: invalid arch name 'rva22u64zfa', additional extensions must be after separator '_'
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 6eec03fd6f7082..253893cb0babed 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -36,6 +36,11 @@ struct RISCVSupportedExtension {
}
};
+struct RISCVProfile {
+ const char *Name;
+ const char *MArch;
+};
+
} // end anonymous namespace
static constexpr StringLiteral AllStdExts = "mafdqlcbkjtpvnh";
@@ -241,6 +246,42 @@ static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
};
// clang-format on
+static const RISCVProfile SupportedProfiles[] = {
+ {"rvi20u32", "rv32i"},
+ {"rvi20u64", "rv64i"},
+ {"rva20u64", "rv64imafdc_ziccamoa_ziccif_zicclsm_ziccrse_zicntr_za128rs"},
+ {"rva20s64", "rv64imafdc_ziccamoa_ziccif_zicclsm_ziccrse_zicntr_zifencei_"
+ "za128rs_ssccptr_sstvala_sstvecd_svade_svbare"},
+ {"rva22u64",
+ "rv64imafdc_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_"
+ "zicntr_zihintpause_zihpm_za64rs_zfhmin_zba_zbb_zbs_zkt"},
+ {"rva22s64",
+ "rv64imafdc_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_"
+ "zicntr_zifencei_zihintpause_zihpm_za64rs_zfhmin_zba_zbb_zbs_zkt_ssccptr_"
+ "sscounterenw_sstvala_sstvecd_svade_svbare_svinval_svpbmt"},
+ {"rva23u64",
+ "rv64imafdcv_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_"
+ "zicntr_zicond_zihintntl_zihintpause_zihpm_zimop0p1_za64rs_zawrs_zfa_"
+ "zfhmin_zcb_zcmop0p2_zba_zbb_zbs_zkt_zvbb_zvfhmin_zvkt"},
+ {"rva23s64",
+ "rv64imafdcvh_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_"
+ "zicntr_zicond_zifencei_zihintntl_zihintpause_zihpm_zimop0p1_za64rs_zawrs_"
+ "zfa_zfhmin_zcb_zcmop0p2_zba_zbb_zbs_zkt_zvbb_zvfhmin_zvkt_shcounterenw_"
+ "shgatpa_shtvala_shvsatpa_shvstvala_shvstvecd_ssccptr_sscofpmf_"
+ "sscounterenw_ssnpm0p8_ssstateen_sstc_sstvala_sstvecd_ssu64xl_svade_"
+ "svbare_svinval_svnapot_svpbmt"},
+ {"rvb23u64", "rv64imafdc_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_"
+ "zicclsm_ziccrse_zicntr_zicond_zihintntl_zihintpause_zihpm_"
+ "zimop0p1_za64rs_zawrs_zfa_zcb_zcmop0p2_zba_zbb_zbs_zkt"},
+ {"rvb23s64",
+ "rv64imafdc_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_"
+ "zicntr_zicond_zifencei_zihintntl_zihintpause_zihpm_zimop0p1_za64rs_zawrs_"
+ "zfa_zcb_zcmop0p2_zba_zbb_zbs_zkt_ssccptr_sscofpmf_sscounterenw_sstc_"
+ "sstvala_sstvecd_ssu64xl_svade_svbare_svinval_svnapot_svpbmt"},
+ {"rvm23u32", "rv32im_zicbop_zicond_zicsr_zihintntl_zihintpause_zimop0p1_"
+ "zca_zcb_zce_zcmop0p2_zcmp_zcmt_zba_zbb_zbs"},
+};
+
static void verifyTables() {
#ifndef NDEBUG
static std::atomic<bool> TableChecked(false);
@@ -854,6 +895,30 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
"string must be lowercase");
}
+ bool IsProfile = Arch.starts_with("rvi") || Arch.starts_with("rva") ||
+ Arch.starts_with("rvb") || Arch.starts_with("rvm");
+ std::string NewArch;
+ if (IsProfile) {
+ const auto *FoundProfile =
+ llvm::find_if(SupportedProfiles, [&](const RISCVProfile &Profile) {
+ return Arch.starts_with(Profile.Name);
+ });
+
+ if (FoundProfile == std::end(SupportedProfiles))
+ return createStringError(errc::invalid_argument, "unsupported profile");
+
+ NewArch = FoundProfile->MArch;
+ StringRef ArchWithoutProfile = Arch.substr(strlen(FoundProfile->Name));
+ if (!ArchWithoutProfile.empty()) {
+ if (!ArchWithoutProfile.starts_with("_"))
+ return createStringError(
+ errc::invalid_argument,
+ "additional extensions must be after separator '_'");
+ NewArch = NewArch + ArchWithoutProfile.str();
+ }
+ Arch = NewArch;
+ }
+
bool HasRV64 = Arch.starts_with("rv64");
// ISA string must begin with rv32 or rv64.
if (!(Arch.starts_with("rv32") || HasRV64) || (Arch.size() < 5)) {
More information about the cfe-commits
mailing list