9#ifndef MLIR_CONVERSION_SPIRVCOMMON_PATTERN_H
10#define MLIR_CONVERSION_SPIRVCOMMON_PATTERN_H
15#include "llvm/Support/FormatVariadic.h"
22template <
typename Op,
typename SPIRVOp>
24 using OpConversionPattern<
Op>::OpConversionPattern;
28 ConversionPatternRewriter &rewriter)
const override {
29 assert(adaptor.getOperands().size() <= 3);
30 Type dstType = this->getTypeConverter()->convertType(op.getType());
32 return rewriter.notifyMatchFailure(
34 llvm::formatv(
"failed to convert type {0} for SPIR-V", op.getType()));
37 if (SPIRVOp::template hasTrait<OpTrait::spirv::UnsignedOp>() &&
39 dstType != op.getType()) {
41 return op.
emitError(
"bitwidth emulation is not implemented yet on "
42 "unsigned op pattern version");
44 rewriter.template replaceOpWithNewOp<SPIRVOp>(op, dstType,
45 adaptor.getOperands());
void dump()
Dump this operation.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
Location getLoc()
The source location the operation was defined or derived from.
This provides public APIs that all operations should have.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Include the generated interface declarations.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
Converts elementwise unary, binary and ternary standard operations to SPIR-V operations.
LogicalResult matchAndRewrite(Op op, typename Op::Adaptor adaptor, ConversionPatternRewriter &rewriter) const override