================ @@ -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}; ---------------- wangleiat wrote:
The default return may cause us to miss the check for invalid strings. (like this: "+lasx", here will be two plus signs in the generated IR) . Perhaps we can perform the check inside `isValidFeature()`?" https://github.com/llvm/llvm-project/pull/140700 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits