================
@@ -388,6 +388,51 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   return true;
 }
 
+ParsedTargetAttr
+LoongArchTargetInfo::parseTargetAttr(StringRef Features) const {
+  ParsedTargetAttr Ret;
+  if (Features == "default")
+    return Ret;
+  SmallVector<StringRef, 1> AttrFeatures;
+  Features.split(AttrFeatures, ",");
+
+  for (auto &Feature : AttrFeatures) {
+    Feature = Feature.trim();
+
+    if (Feature.starts_with("arch=")) {
----------------
tangaac wrote:

It's recommended to use use a helper function to handle the types of features. 
Like below.
If it's ok to define a FeatureKind enum, that would be even better.
~~~c++
static std::pair<llvm::StringRef, llvm::StringRef> 
getFeatureTypeAndValue(llvm::StringRef Feature) {
  auto Split = Feature.split("=");
  if (!Split.second.empty())
    return {Split.first.trim(), Split.second.trim()};
  if (Feature.starts_with("no-"))
    return {"no", Feature.drop_front(3).trim()};
  return {"feature", Feature.trim()};
}
~~~

~~~c++
  for (auto &Feature : AttrFeatures) {
    Feature = Feature.trim();
    auto [Kind, Value] = getFeatureTypeAndValue(Feature);

    if (Kind == "arch") {
    } else if (Kind == "tune") {
    } ..
}
~~~



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

Reply via email to