[clang] [llvm] [TargetParser][clang] Parse Intel IGCA targets from --offload-arch into OffloadArch (PR #227468)

Alexis Engelke via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 06:47:32 PST 2026


================
@@ -104,3 +104,96 @@ GPUKind llvm::IntelGPU::parseArch(StringRef Name) {
 #include "llvm/TargetParser/IntelGPUTargetParser.def"
       .Default(GK_NONE);
 }
+
+namespace {
+// The IGCA target of each row in IntelGPUTargetParser.def, e.g. {20,
+// ComputeExact} for xe-pvc. Several rows can have the same IGCA target, e.g.
+// the nine igca_10r devices, so entries repeat.
+struct DeviceIGCATarget {
+  uint16_t Target;
+  IGCAFeatureSet FeatureSet;
+};
+constexpr DeviceIGCATarget DeviceIGCATargets[] = {
+#define INTEL_GPU(NAME, KIND, MAJOR, MINOR, IGCA_TARGET, IGCA_FEATURE_SETS)    \
+  {IGCA_TARGET, IGCAFeatureSet::IGCA_FEATURE_SETS},
+#define INTEL_GPU_COMPAT(NAME, KIND, IGCA_TARGET, IGCA_FEATURE_SETS)           \
+  {IGCA_TARGET, IGCAFeatureSet::IGCA_FEATURE_SETS},
+#include "llvm/TargetParser/IntelGPUTargetParser.def"
+};
+
+// All five possible names for each device's numeric IGCA target, e.g. igca_20,
+// igca_20c, igca_20ca, igca_20r and igca_20ra for xe-pvc. Which of them are
+// valid is decided by the IGCATarget constructor, so the rule is in one place.
+// The names are string literals, so getIGCATargetName() can return them.
+struct IGCATargetNameEntry {
+  const char *Name;
----------------
aengelke wrote:

Please don't add global tables with non-null pointers, including string pointers, as per [our coding standards](https://llvm.org/docs/CodingStandards.html#avoid-pointers-in-global-static-constants). See #246982.

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


More information about the cfe-commits mailing list