//===- VectorPattern.cpp - Vector conversion pattern to the LLVM dialect --===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "mlir/Conversion/LLVMCommon/VectorPattern.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" usingnamespacemlir; // For >1-D vector types, extracts the necessary information to iterate over all // 1-D subvectors in the underlying llrepresentation of the n-D vector // Iterates on the llvm array type until we hit a non-array type (which is // asserted to be an llvm vector type). LLVM::detail::NDVectorTypeInfo LLVM::detail::extractNDVectorTypeInfo(VectorType vectorType, const LLVMTypeConverter &converter) { … } // Express `linearIndex` in terms of coordinates of `basis`. // Returns the empty vector when linearIndex is out of the range [0, P] where // P is the product of all the basis coordinates. // // Prerequisites: // Basis is an array of nonnegative integers (signed type inherited from // vector shape type). SmallVector<int64_t, 4> LLVM::detail::getCoordinates(ArrayRef<int64_t> basis, unsigned linearIndex) { … } // Iterate of linear index, convert to coords space and insert splatted 1-D // vector in each position. void LLVM::detail::nDVectorIterate(const LLVM::detail::NDVectorTypeInfo &info, OpBuilder &builder, function_ref<void(ArrayRef<int64_t>)> fun) { … } LogicalResult LLVM::detail::handleMultidimensionalVectors( Operation *op, ValueRange operands, const LLVMTypeConverter &typeConverter, std::function<Value(Type, ValueRange)> createOperand, ConversionPatternRewriter &rewriter) { … } LogicalResult LLVM::detail::vectorOneToOneRewrite( Operation *op, StringRef targetOp, ValueRange operands, ArrayRef<NamedAttribute> targetAttrs, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter, IntegerOverflowFlags overflowFlags) { … }