[Mlir-commits] [mlir] [mlir][vector] Add `vector.from_elements` op (PR #95938)
Diego Caballero
llvmlistbot at llvm.org
Tue Jun 18 09:54:57 PDT 2024
================
@@ -1836,6 +1836,34 @@ struct VectorDeinterleaveOpLowering
}
};
+/// Conversion pattern for a `vector.from_elements`.
+struct VectorFromElementsLowering
+ : public ConvertOpToLLVMPattern<vector::FromElementsOp> {
+ using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
+
+ LogicalResult
+ matchAndRewrite(vector::FromElementsOp fromElementsOp, OpAdaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ Location loc = fromElementsOp.getLoc();
+ VectorType vectorType = fromElementsOp.getType();
+ // TODO: Multi-dimensional vectors lower to !llvm.array<... x vector<>>.
+ // Such ops should be handled in the same way as vector.insert.
+ if (vectorType.getRank() > 1)
+ return rewriter.notifyMatchFailure(fromElementsOp,
+ "rank > 1 vectors are not supported");
+ Type llvmType = typeConverter->convertType(vectorType);
+ Value result = rewriter.create<LLVM::UndefOp>(loc, llvmType);
+ for (auto it : llvm::enumerate(adaptor.getElements())) {
----------------
dcaballe wrote:
use structured bindings?
https://github.com/llvm/llvm-project/pull/95938
More information about the Mlir-commits
mailing list