[llvm] [DXIL] Add DXIL version-specific TableGen specification and implementation of DXIL Ops (PR #97593)

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 09:59:18 PDT 2024


================
@@ -249,17 +309,95 @@ static FunctionType *getDXILOpFunctionType(const OpCodeProperty *Prop,
       ArgTys[0], ArrayRef<Type *>(&ArgTys[1], ArgTys.size() - 1), false);
 }
 
+/// Get index of the property from PropList valid for the most recent
+/// DXIL version not greater than DXILVer.
+/// PropList is expected to be sorted in ascending order of DXIL version.
+template <typename T>
+static int getPropIndex(const std::vector<T> PropList,
+                        const VersionTuple DXILVer) {
+  auto Size = PropList.size();
+  for (int I = Size - 1; I >= 0; I--) {
+    auto OL = PropList[I];
+    if (VersionTuple(OL.DXILVersion.Major, OL.DXILVersion.Minor) <= DXILVer) {
+      return I;
+    }
+  }
+  report_fatal_error(Twine(DXILVer.getAsString()) + ": Unknown DXIL Version",
----------------
bharadwajy wrote:

> Is this really the right place to throw this error? It seems like a getter is an odd place to report an error as opposed to the caller.
> 
> Also since `report_fatal_error` is `[[noreturn]]` there shouldn't be any code after it.

Moved error out of getter to callsite.

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


More information about the llvm-commits mailing list