================
@@ -198,6 +199,22 @@ StringRef llvm::IntelGPU::getIGCATargetName(IGCATarget T) {
   return "";
 }
 
+void llvm::IntelGPU::fillValidIGCATargetList(
+    SmallVectorImpl<StringRef> &Values) {
+  // fillValidIGCATargetList is currently only used for diagnostics, similar to
+  // how other fillValid* functions are used. We can thus afford to generate
+  // this list here:
+  SmallVector<IGCATarget> Targets;
+  for (const IGCATargetNameEntry &E : IGCATargetNames)
+    if (IGCATarget T(E.Target, E.FeatureSet); T.isValid())
+      Targets.push_back(T);
+  llvm::sort(Targets,
+             [](IGCATarget A, IGCATarget B) { return A.pack() < B.pack(); });
+  Targets.erase(llvm::unique(Targets), Targets.end());
+  for (IGCATarget T : Targets)
+    Values.push_back(getIGCATargetName(T));
+}
----------------
tahonermann wrote:

This is all information that is known at compile-time; no run-time processing 
should be necessary. It looks like it should be possible to return a (possibly 
constexpr) view into `IGCATargetNames`.

Why would `T.isValid()` ever be false? Wouldn't that imply an invalid entry in 
`llvm/TargetParser/IntelGPUTargetParser.def`? Such invalid entries should cause 
an error somewhere; preferably at compile-time. `assert(T.isValid())` should 
suffice if a run-time check is warranted.

https://github.com/llvm/llvm-project/pull/227877
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to