================ @@ -1584,6 +1586,47 @@ mlir::Value ScalarExprEmitter::VisitMemberExpr(MemberExpr *e) { return emitLoadOfLValue(e); } +mlir::Value ScalarExprEmitter::VisitInitListExpr(InitListExpr *e) { + const unsigned numInitElements = e->getNumInits(); + + if (e->hadArrayRangeDesignator()) { + cgf.cgm.errorNYI(e->getSourceRange(), "ArrayRangeDesignator"); + return {}; + } + + if (numInitElements == 0) { + cgf.cgm.errorNYI(e->getSourceRange(), "InitListExpr with 0 init elements"); + return {}; + } + + if (e->getType()->isVectorType()) { + const auto vectorType = + mlir::cast<cir::VectorType>(cgf.convertType(e->getType())); + + SmallVector<mlir::Value, 16> elements; + for (Expr *init : e->inits()) { + elements.push_back(Visit(init)); + } + + // Zero-initialize any remaining values. + if (numInitElements < vectorType.getSize()) { + mlir::TypedAttr zeroInitAttr = + cgf.getBuilder().getZeroInitAttr(vectorType.getElementType()); + cir::ConstantOp zeroValue = cgf.getBuilder().getConstant( + cgf.getLoc(e->getSourceRange()), zeroInitAttr); + + for (uint64_t i = numInitElements; i < vectorType.getSize(); ++i) { ---------------- andykaylor wrote:
You're right. I had forgotten this vector already had entries from above. What about this? `std::fill_n(std::back_inserter(elements), vectorType.getSize(), zeroValue);` https://github.com/llvm/llvm-project/pull/138107 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits