================
@@ -63,3 +73,61 @@ std::string llvm::IntelGPU::getNumericArchName(uint32_t
GPUIPVersion) {
return ("xe_" + Twine(Major) + "." + Twine(Minor) + "." + Twine(Revision))
.str();
}
+
+StringRef llvm::IntelGPU::getArchName(GPUKind Kind) {
+ switch (Kind) {
+ case GK_NONE:
+ return "";
+#define INTEL_GPU(NAME, KIND, MAJOR, MINOR, IGCA_TARGET, IGCA_FEATURE_SETS)
\
+ case GK_##KIND:
\
+ return NAME;
+#define INTEL_GPU_COMPAT(NAME, KIND, IGCA_TARGET, IGCA_FEATURE_SETS)
\
+ case GK_##KIND:
\
+ return NAME;
+#include "llvm/TargetParser/IntelGPUTargetParser.def"
+ }
+ llvm_unreachable("invalid Intel GPU kind");
+}
+
+// Read a numeric name, e.g. "xe_12.60.7", into the GPU IP version it spells.
+// The revision may be omitted.
+static bool parseNumericArchName(StringRef Name, uint32_t &GPUIPVersion) {
+ if (!Name.consume_front("xe_"))
+ return false;
+
+ StringRef MajorStr, MinorStr, RevisionStr;
+ std::tie(MajorStr, Name) = Name.split('.');
+ // A separator with no revision after it is malformed.
+ const bool HasRevision = Name.contains('.');
+ std::tie(MinorStr, RevisionStr) = Name.split('.');
+ uint32_t Major, Minor, Revision = 0;
+ if (MajorStr.getAsInteger(10, Major) || MinorStr.getAsInteger(10, Minor))
+ return false;
+ if (HasRevision && RevisionStr.getAsInteger(10, Revision))
+ return false;
+
+ // Each field must fit its GPU IP version field.
+ if (Major > GPUIPMajorMask || Minor > GPUIPMinorMask ||
+ Revision > GPUIPRevisionMask)
+ return false;
+ GPUIPVersion = packDevice(Major, Minor) | Revision;
+ return true;
+}
+
+GPUKind llvm::IntelGPU::parseArch(StringRef Name) {
+ GPUKind Kind = StringSwitch<GPUKind>(Name)
+#define INTEL_GPU(NAME, KIND, MAJOR, MINOR, IGCA_TARGET, IGCA_FEATURE_SETS)
\
+ .Case(NAME, GK_##KIND)
----------------
gmlueck wrote:
> An optional revision is still checked, so xe_12.60. and xe_12.60.64 stay
> rejected.
In one of our conversations, I thought we agreed that the third numeric
component (what you call revision) should not be optional. Is that they way
you have implemented it?
https://github.com/llvm/llvm-project/pull/229247
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits