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());
87 auto result1DVectorTy = resultTypeInfo.llvm1DVectorTy;
88 auto resultNDVectoryTy = resultTypeInfo.llvmNDVectorTy;
90 Value desc = rewriter.
create<LLVM::UndefOp>(loc, resultNDVectoryTy);
96 extractedOperands.push_back(rewriter.
create<LLVM::ExtractValueOp>(
97 loc, operand.value(), position));
99 Value newVal = createOperand(result1DVectorTy, extractedOperands);
100 desc = rewriter.
create<LLVM::InsertValueOp>(loc, desc, newVal, position);
110 IntegerOverflowFlags overflowFlags) {
111 assert(!operands.empty());
117 auto llvmNDVectorTy = operands[0].
getType();
118 if (!isa<LLVM::LLVMArrayType>(llvmNDVectorTy))
119 return oneToOneRewrite(op, targetOp, operands, targetAttrs, typeConverter,
120 rewriter, overflowFlags);
122 auto callback = [op, targetOp, targetAttrs, overflowFlags,
126 operands, llvm1DVectorTy, targetAttrs);
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)
StringAttr getStringAttr(const Twine &bytes)
This class implements a pattern rewriter for use with ConversionPatterns.
void replaceOp(Operation *op, ValueRange newValues) override
Replace the given operation with the new values.
Conversion from types to the LLVM IR dialect.
LogicalResult convertType(Type t, SmallVectorImpl< Type > &results) const
Convert the given type.
This class helps build Operations.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
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 handleMultidimensionalVectors(Operation *op, ValueRange operands, const LLVMTypeConverter &typeConverter, std::function< Value(Type, ValueRange)> createOperand, ConversionPatternRewriter &rewriter)
LogicalResult oneToOneRewrite(Operation *op, StringRef targetOp, ValueRange operands, ArrayRef< NamedAttribute > targetAttrs, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter, IntegerOverflowFlags overflowFlags=IntegerOverflowFlags::none)
Replaces the given operation "op" with a new operation of type "targetOp" and given operands.
LogicalResult vectorOneToOneRewrite(Operation *op, StringRef targetOp, ValueRange operands, ArrayRef< NamedAttribute > targetAttrs, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter, IntegerOverflowFlags overflowFlags=IntegerOverflowFlags::none)
void setNativeProperties(Operation *op, IntegerOverflowFlags overflowFlags)
Handle generically setting flags as native properties on LLVM operations.
void nDVectorIterate(const NDVectorTypeInfo &info, OpBuilder &builder, function_ref< void(ArrayRef< int64_t >)> fun)
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.
constexpr void enumerate(std::tuple< Tys... > &tuple, CallbackT &&callback)
Include the generated interface declarations.
SmallVector< int64_t, 4 > arraySizes