aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorPiyou Chen <piyou.chen@sifive.com>2024-10-04 11:02:45 +0800
committerGitHub <noreply@github.com>2024-10-04 11:02:45 +0800
commit7ab488e92c39c813a50cb4fd6587e7afc161c7d5 (patch)
tree45d7a6c914b34804890c1fcccfc498d40a5457e1 /clang/lib/CodeGen/CodeGenModule.cpp
parenteaff3a743406ff1636e6328e1ba1bc66318d53cb (diff)
downloadllvm-7ab488e92c39c813a50cb4fd6587e7afc161c7d5.zip
llvm-7ab488e92c39c813a50cb4fd6587e7afc161c7d5.tar.gz
llvm-7ab488e92c39c813a50cb4fd6587e7afc161c7d5.tar.bz2
[RISCV][FMV] Support target_version (#99040)
This patch enable `target_version` attribute for RISC-V target. The proposal of `target_version` syntax can be found at the https://github.com/riscv-non-isa/riscv-c-api-doc/pull/48 (which has landed), as modified by the proposed https://github.com/riscv-non-isa/riscv-c-api-doc/pull/85 (which adds the priority syntax). `target_version` attribute will trigger the function multi-versioning feature and act like `target_clones` attribute. See https://github.com/llvm/llvm-project/pull/85786 for the implementation of `target_clones`.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 25c1c49..5ba0981 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4287,8 +4287,13 @@ void CodeGenModule::emitMultiVersionFunctions() {
} else if (const auto *TVA = CurFD->getAttr<TargetVersionAttr>()) {
if (TVA->isDefaultVersion() && IsDefined)
ShouldEmitResolver = true;
- TVA->getFeatures(Feats);
llvm::Function *Func = createFunction(CurFD);
+ if (getTarget().getTriple().isRISCV()) {
+ Feats.push_back(TVA->getName());
+ } else {
+ assert(getTarget().getTriple().isAArch64());
+ TVA->getFeatures(Feats);
+ }
Options.emplace_back(Func, /*Architecture*/ "", Feats);
} else if (const auto *TC = CurFD->getAttr<TargetClonesAttr>()) {
if (IsDefined)