[clang] [llvm] [TargetParser][clang] Parse and store Intel IGCA virtual architecture as an OffloadArch (PR #227468)

Ian Li via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 10:59:09 PDT 2026


================
@@ -63,3 +64,26 @@ std::string llvm::IntelGPU::getNumericArchName(uint32_t GPUIPVersion) {
   return ("xe_" + Twine(Major) + "." + Twine(Minor) + "." + Twine(Revision))
       .str();
 }
+
+IGCATarget llvm::IntelGPU::parseIGCATarget(StringRef MaybeTarget) {
+  return StringSwitch<IGCATarget>(MaybeTarget)
+#define INTEL_IGCA_TARGET(NAME, TARGET, FEATURE_SET)                           \
+  .Case(NAME, IGCATarget(TARGET, IGCAFeatureSet::FEATURE_SET))
+#include "llvm/TargetParser/IntelGPUTargetParser.def"
+      .Default(IGCATarget::invalid());
+}
+
+StringRef llvm::IntelGPU::getIGCATargetName(IGCATarget T) {
+  switch (T.pack()) {
+#define INTEL_IGCA_TARGET(NAME, TARGET, FEATURE_SET)                           \
+  case IGCATarget(TARGET, IGCAFeatureSet::FEATURE_SET).pack():                 \
+    return NAME;
+#include "llvm/TargetParser/IntelGPUTargetParser.def"
+  default:
+    return "";
+  }
+}
+
+// FIXME(IGCA): Make -fsycl --offload-arch provides a list of valid IGCA
+// targets upon a bad IGCA target, similar to how compiling for an nvptx triple
+// returns a list of valid GPU architectures.
----------------
ianayl wrote:

The easiest way to do this would be to add more diagnostics on top of the invalid IGCA diagnostic I introduced in this PR, but this is not what is done by AMD and NVIDIA, they instead relied on `TargetOptions` to produce a list of valid CPUs. To not break convention, I'd have to look into modifying that part of the code, which seems like it doesn't belong in this PR.

Conveniently, my other PR stacked on this for producing predefined IGCA macros touches `TargetOptions` and `TargetInfo`, so I was thinking of looking into it there.

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


More information about the cfe-commits mailing list