21 assert(vectorType.getRank() > 1 &&
"expected >1D vector type");
28 info.
arraySizes.reserve(vectorType.getRank() - 1);
30 while (isa<LLVM::LLVMArrayType>(llvmTy)) {
33 llvmTy = cast<LLVM::LLVMArrayType>(llvmTy).getElementType();
49 unsigned linearIndex) {
51 res.reserve(basis.size());
52 for (
unsigned basisElement : llvm::reverse(basis)) {
53 res.push_back(linearIndex % basisElement);
54 linearIndex = linearIndex / basisElement;
58 std::reverse(res.begin(), res.end());
70 for (
unsigned linearIndex = 0; linearIndex <
ub; ++linearIndex) {
75 assert(coords.size() == info.
arraySizes.size());
83 ConversionPatternRewriter &rewriter) {
87 auto result1DVectorTy = resultTypeInfo.llvm1DVectorTy;
88 auto resultNDVectoryTy = resultTypeInfo.llvmNDVectorTy;
90 Value desc = LLVM::PoisonOp::create(rewriter, loc, resultNDVectoryTy);
95 for (
const auto &operand : llvm::enumerate(operands)) {
96 extractedOperands.push_back(LLVM::ExtractValueOp::create(
97 rewriter, loc, operand.value(), position));
99 Value newVal = createOperand(result1DVectorTy, extractedOperands);
100 desc = LLVM::InsertValueOp::create(rewriter, loc, desc, newVal, position);
102 rewriter.replaceOp(op, desc);
110 ConversionPatternRewriter &rewriter) {
111 assert(!operands.empty());
117 auto llvmNDVectorTy = operands[0].
getType();
118 if (!isa<LLVM::LLVMArrayType>(llvmNDVectorTy))
119 return oneToOneRewrite(op, targetOp, operands, targetAttrs, propertiesAttr,
120 typeConverter, rewriter);
121 auto callback = [op, targetOp, targetAttrs, propertiesAttr,
124 operands, llvm1DVectorTy, targetAttrs);
126 Operation *newOp = rewriter.create(state);
static int64_t getNumElements(Type t)
Compute the total number of elements in the given type, also taking into account nested types.
static Value handleMultidimensionalVectors(ImplicitLocOpBuilder &builder, ValueRange operands, int64_t vectorWidth, llvm::function_ref< Value(ValueRange)> compute)
Attributes are known-constant values of operations.
Conversion from types to the LLVM IR dialect.
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Location getLoc()
The source location the operation was defined or derived from.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class provides an abstraction over the different types of ranges over Values.
type_range getType() const
type_range getTypes() const
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
LogicalResult vectorOneToOneRewrite(Operation *op, StringRef targetOp, ValueRange operands, ArrayRef< NamedAttribute > targetAttrs, Attribute propertiesAttr, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter)
LogicalResult handleMultidimensionalVectors(Operation *op, ValueRange operands, const LLVMTypeConverter &typeConverter, std::function< Value(Type, ValueRange)> createOperand, ConversionPatternRewriter &rewriter)
void nDVectorIterate(const NDVectorTypeInfo &info, OpBuilder &builder, function_ref< void(ArrayRef< int64_t >)> fun)
LogicalResult oneToOneRewrite(Operation *op, StringRef targetOp, ValueRange operands, ArrayRef< NamedAttribute > targetAttrs, Attribute propertiesAttr, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter)
Replaces the given operation "op" with a new operation of type "targetOp" and given operands.
NDVectorTypeInfo extractNDVectorTypeInfo(VectorType vectorType, const LLVMTypeConverter &converter)
SmallVector< int64_t, 4 > getCoordinates(ArrayRef< int64_t > basis, unsigned linearIndex)
bool isCompatibleVectorType(Type type)
Returns true if the given type is a vector type compatible with the LLVM dialect.
bool isCompatibleType(Type type)
Returns true if the given type is compatible with the LLVM dialect.
Include the generated interface declarations.
llvm::function_ref< Fn > function_ref
SmallVector< int64_t, 4 > arraySizes
This represents an operation in an abstracted form, suitable for use with the builder APIs.
Attribute propertiesAttr
This Attribute is used to opaquely construct the properties of the operation.