================
@@ -4874,6 +4936,35 @@ llvm::Value *CodeGenFunction::EmitMatrixIndexExpr(const
Expr *E) {
return Builder.CreateIntCast(Idx, IntPtrTy, IsSigned);
}
+LValue CodeGenFunction::EmitMatrixSingleSubscriptExpr(
+ const MatrixSingleSubscriptExpr *E) {
+ LValue Base = EmitLValue(E->getBase());
+ llvm::Value *RowIdx = EmitMatrixIndexExpr(E->getRowIdx());
+
+ if (auto *RowConst = llvm::dyn_cast<llvm::ConstantInt>(RowIdx)) {
+
+ // Extract matrix shape from the AST type
+ const auto *MatTy = E->getBase()->getType()->castAs<ConstantMatrixType>();
+ unsigned NumCols = MatTy->getNumColumns();
+ llvm::SmallVector<llvm::Constant *, 8> Indices;
+ Indices.reserve(NumCols);
+
+ unsigned Row = RowConst->getZExtValue();
+ unsigned Start = Row * NumCols;
+ for (unsigned C = 0; C < NumCols; ++C) {
+ Indices.push_back(llvm::ConstantInt::get(Int32Ty, Start + C));
+ }
----------------
hekota wrote:
```suggestion
for (unsigned C = 0; C < NumCols; ++C)
Indices.push_back(llvm::ConstantInt::get(Int32Ty, Start + C));
```
https://github.com/llvm/llvm-project/pull/170779
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits