[llvm] [DXIL] Model DXIL Class and Shader Model association of DXIL Ops in DXIL.td (PR #87803)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 17:10:33 PDT 2024


================
@@ -72,10 +73,26 @@ static SmallVector<Value *> argVectorFlatten(CallInst *Orig,
   return NewOperands;
 }
 
+static uint32_t getModuleShaderModelVersion(Module &M) {
+  std::string TTStr = M.getTargetTriple();
+  std::string Error;
+  auto Target = TargetRegistry::lookupTarget(TTStr, Error);
+  if (!Target) {
+    if (TTStr.empty()) {
+      report_fatal_error(StringRef(Error), /*gen_crash_diag*/ false);
+    }
+  }
+  auto Major = Triple(TTStr).getOSVersion().getMajor();
+  auto MinorOrErr = Triple(TTStr).getOSVersion().getMinor();
+  uint32_t Minor = MinorOrErr.has_value() ? *MinorOrErr : 0;
+  return COMPUTE_SM_VERSION_VALUE(Major, Minor);
+}
----------------
bogner wrote:

Why does this do math to munge the version into a single number rather than returning something more structured (either a simple `struct SMVersion` or even just `std::pair`? I feel like that would be simpler, less error prone, and easier to understand in the various places we're currently passing a "special" uint32_t around now.

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


More information about the llvm-commits mailing list