[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)
via cfe-commits
cfe-commits at lists.llvm.org
Sun May 25 20:28:33 PDT 2025
================
@@ -388,6 +388,76 @@ bool LoongArchTargetInfo::handleTargetFeatures(
return true;
}
+enum class AttrFeatureKind { Arch, Tune, NoFeature, Feature, Invalid };
+
+static std::pair<AttrFeatureKind, llvm::StringRef>
+getAttrFeatureTypeAndValue(llvm::StringRef AttrFeature) {
+ if (auto Split = AttrFeature.split("="); !Split.second.empty()) {
+ if (Split.first.trim() == "arch")
+ return {AttrFeatureKind::Arch, Split.second.trim()};
+ if (Split.first.trim() == "tune")
+ return {AttrFeatureKind::Tune, Split.second.trim()};
+ }
+ if (AttrFeature.starts_with("no-"))
+ return {AttrFeatureKind::NoFeature, AttrFeature.drop_front(3).trim()};
+ return {AttrFeatureKind::Feature, AttrFeature.trim()};
----------------
heiher wrote:
The caller has already performed `trim()`, so it's unnecessary here, just like `starts_with()` above doesn't use it either.
```suggestion
return {AttrFeatureKind::Feature, AttrFeature};
```
https://github.com/llvm/llvm-project/pull/140700
More information about the cfe-commits
mailing list