================
@@ -2508,6 +2508,35 @@ ConstantEmitter::tryEmitPrivate(const APValue &Value, 
QualType DestType,
     }
     return llvm::ConstantVector::get(Inits);
   }
+  case APValue::Matrix: {
+    const auto *MT = DestType->castAs<ConstantMatrixType>();
+    unsigned NumRows = Value.getMatrixNumRows();
+    unsigned NumCols = Value.getMatrixNumColumns();
+    unsigned NumElts = NumRows * NumCols;
+    SmallVector<llvm::Constant *, 16> Inits(NumElts);
+
+    bool IsRowMajor = CGM.getLangOpts().getDefaultMatrixMemoryLayout() ==
+                      LangOptions::MatrixMemoryLayout::MatrixRowMajor;
+
+    for (unsigned Row = 0; Row != NumRows; ++Row) {
+      for (unsigned Col = 0; Col != NumCols; ++Col) {
+        const APValue &Elt = Value.getMatrixElt(Row, Col);
+        unsigned Idx = MT->getFlattenedIndex(Row, Col, IsRowMajor);
+        if (Elt.isInt())
+          Inits[Idx] =
+              llvm::ConstantInt::get(CGM.getLLVMContext(), Elt.getInt());
+        else if (Elt.isFloat())
+          Inits[Idx] =
+              llvm::ConstantFP::get(CGM.getLLVMContext(), Elt.getFloat());
+        else if (Elt.isIndeterminate())
+          Inits[Idx] = llvm::PoisonValue::get(
+              CGM.getTypes().ConvertType(MT->getElementType()));
+        else
+          llvm_unreachable("unsupported matrix element type");
----------------
Icohedron wrote:

Yes

https://github.com/llvm/llvm-project/pull/178762
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to