19 #include "llvm/Support/Debug.h"
21 #define DEBUG_TYPE "complex-to-spirv-pattern"
35 matchAndRewrite(complex::ConstantOp constOp, OpAdaptor adaptor,
38 getTypeConverter()->convertType<ShapedType>(constOp.getType());
41 "unable to convert result type");
54 matchAndRewrite(complex::CreateOp createOp, OpAdaptor adaptor,
56 Type spirvType = getTypeConverter()->convertType(createOp.getType());
59 "unable to convert result type");
62 createOp, spirvType, adaptor.getOperands());
71 matchAndRewrite(complex::ReOp reOp, OpAdaptor adaptor,
73 Type spirvType = getTypeConverter()->convertType(reOp.getType());
87 matchAndRewrite(complex::ImOp imOp, OpAdaptor adaptor,
89 Type spirvType = getTypeConverter()->convertType(imOp.getType());
109 patterns.
add<ConstantOpPattern, CreateOpPattern, ReOpPattern, ImOpPattern>(
110 typeConverter, context);
This class implements a pattern rewriter for use with ConversionPatterns.
static DenseElementsAttr get(ShapedType type, ArrayRef< Attribute > values)
Constructs a dense elements attribute from an array of element values.
MLIRContext is the top-level object for a collection of MLIR operations.
OpConversionPattern is a wrapper around ConversionPattern that allows for matching and rewriting agai...
OpConversionPattern(MLIRContext *context, PatternBenefit benefit=1)
MLIRContext * getContext() const
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
Type conversion from builtin types to SPIR-V types for shader interface.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Include the generated interface declarations.
void populateComplexToSPIRVPatterns(const SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns)
Appends to a pattern list additional patterns for translating Complex ops to SPIR-V ops.