[PATCH] D119541: [RISCV] Fix RISCVTargetInfo::initFeatureMap, add non-ISA features back after implication
Yueh-Ting Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 11 05:31:20 PST 2022
eopXD updated this revision to Diff 407852.
eopXD added a comment.
Add testcase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119541/new/
https://reviews.llvm.org/D119541
Files:
clang/lib/Basic/Targets/RISCV.cpp
clang/test/Driver/riscv-default-features.c
Index: clang/test/Driver/riscv-default-features.c
===================================================================
--- /dev/null
+++ clang/test/Driver/riscv-default-features.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target riscv32-unknown-elf -S -emit-llvm %s -o - | FileCheck %s -check-prefix=RV32
+
+// RV32: "target-features"="+a,+c,+m,+relax,-save-restore"
+// RV64: "target-features"="+64bit,+a,+c,+m,+relax,-save-restore"
+
+// Dummy function
+int foo(){
+ return 3;
+}
Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -232,8 +232,16 @@
return false;
}
- return TargetInfo::initFeatureMap(Features, Diags, CPU,
- (*ParseResult)->toFeatureVector());
+ // RISCVISAInfo makes implications for ISA features
+ std::vector<std::string> ImpliedFeatures = (*ParseResult)->toFeatureVector();
+ // Add non-ISA features like `relax` and `save-restore` back
+ for (std::string Feature : FeaturesVec) {
+ if (std::find(begin(ImpliedFeatures), end(ImpliedFeatures), Feature) ==
+ end(ImpliedFeatures))
+ ImpliedFeatures.push_back(Feature);
+ }
+
+ return TargetInfo::initFeatureMap(Features, Diags, CPU, ImpliedFeatures);
}
/// Return true if has this feature, need to sync with handleTargetFeatures.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119541.407852.patch
Type: text/x-patch
Size: 1401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220211/9fc74dc7/attachment.bin>
More information about the cfe-commits
mailing list