================
@@ -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:

I believe that the previous approach was essentially off-the-cuff, done 
whichever way was most convenient.

If someone were to implement the same functionality for other architectures as 
well, they would find three pieces of code with very poor style.

To leave behind code that is more ergonomic for future developers, at the very 
least, the logic for handling features should be separated and handled 
individually.

```c++
auto handleArch = [&](StringRef Feature) { ... }
auto handleTune = [&](StringRef Feature) { ... }

if(feature.startwith("arch=") handleArch(feature)
else (feature.startwith("tune=") handleTune(feature)
else if ( ... ) ...
else {

}

```



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