[llvm-branch-commits] [clang] [clang][bytecode][HLSL][Matrix] Support `ConstantMatrixType` and more HLSL casts in the new constant interpreter for basic matrix constexpr evaluation in HLSL (PR #183424)

Deric C. via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 26 08:14:30 PST 2026


================
@@ -2129,6 +2328,25 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
     return true;
   }
 
+  if (const auto *MT = QT->getAs<ConstantMatrixType>()) {
+    unsigned NumElems = MT->getNumElementsFlattened();
+    assert(Inits.size() == NumElems);
+
+    QualType ElemQT = MT->getElementType();
+    PrimType ElemT = classifyPrim(ElemQT);
+
+    // InitListExpr elements are in column-major order.
+    // Store in row-major order to match APValue convention.
+    for (unsigned I = 0; I != NumElems; ++I) {
+      if (!this->visit(Inits[I]))
+        return false;
+      if (!this->emitInitElem(ElemT,
+                              MT->mapColumnMajorToRowMajorFlattenedIndex(I), E))
----------------
Icohedron wrote:

It is a new helper function introduced in PR  #178762, which this PR builds on top of.

https://github.com/llvm/llvm-project/pull/178762/changes#diff-9a220334d4bd4424ff69011a957b9c25e6fcbca3d95db917e590fa23381c45b2R4439

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


More information about the llvm-branch-commits mailing list