9#ifndef MLIR_CONVERSION_LLVMCOMMON_VECTORPATTERN_H
10#define MLIR_CONVERSION_LLVMCOMMON_VECTORPATTERN_H
45 unsigned linearIndex);
55 ConversionPatternRewriter &rewriter);
62 ConversionPatternRewriter &rewriter);
70template <
typename SourceOp,
typename TargetOp>
91template <
typename SourceOp,
typename TargetOp,
92 template <
typename,
typename>
typename AttrConvert =
93 AttrConvertPassThrough,
94 bool FailOnUnsupportedFP =
false>
103 if (
auto floatType = dyn_cast<FloatType>(type))
105 if (
auto vecType = dyn_cast<VectorType>(type))
106 return dyn_cast<FloatType>(vecType.getElementType());
112 ConversionPatternRewriter &rewriter)
const override {
114 std::is_base_of<OpTrait::OneResult<SourceOp>, SourceOp>::value,
115 "expected single result op");
121 auto checkType = [&](
Value v) -> LogicalResult {
126 if (!isa_and_nonnull<FloatType>(convertedType))
127 return rewriter.notifyMatchFailure(op,
128 "unsupported floating point type");
131 if (FailOnUnsupportedFP) {
132 for (
Value operand : op->getOperands())
133 if (failed(checkType(operand)))
135 if (failed(checkType(op->getResult(0))))
140 AttrConvert<SourceOp, TargetOp> attrConvert(op);
143 op, TargetOp::getOperationName(), adaptor.getOperands(),
144 attrConvert.getAttrs(), attrConvert.getPropAttr(),
145 *this->getTypeConverter(), rewriter);
AttrConvertPassThrough(SourceOp srcOp)
ArrayRef< NamedAttribute > getAttrs() const
Attribute getPropAttr() const
Attributes are known-constant values of operations.
ConvertOpToLLVMPattern(const LLVMTypeConverter &typeConverter, PatternBenefit benefit=1)
const LLVMTypeConverter * getTypeConverter() const
Conversion from types to the LLVM IR dialect.
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
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.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Basic lowering implementation to rewrite Ops with just one result to the LLVM Dialect.
VectorConvertToLLVMPattern< SourceOp, TargetOp > Super
LogicalResult matchAndRewrite(SourceOp op, typename SourceOp::Adaptor adaptor, ConversionPatternRewriter &rewriter) const override
Methods that operate on the SourceOp type.
static FloatType getFloatingPointType(Type type)
Return the given type if it's a floating point type.
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)
NDVectorTypeInfo extractNDVectorTypeInfo(VectorType vectorType, const LLVMTypeConverter &converter)
SmallVector< int64_t, 4 > getCoordinates(ArrayRef< int64_t > basis, unsigned linearIndex)
Include the generated interface declarations.
llvm::function_ref< Fn > function_ref
SmallVector< int64_t, 4 > arraySizes