[clang] [llvm] [Clang][LoongArch] Support target attribute for function (PR #140700)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 28 02:17:54 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)};
+  return {AttrFeatureKind::Feature, AttrFeature};
----------------
Ami-zhang wrote:

Appreciate the review suggestion. The validation will be handled in isValidFeatureName(), with corresponding test cases added.Thanks!

https://github.com/llvm/llvm-project/pull/140700


More information about the cfe-commits mailing list