23 #define GEN_PASS_DEF_FUNCBUFFERIZE
24 #include "mlir/Dialect/Func/Transforms/Passes.h.inc"
31 struct FuncBufferizePass :
public impl::FuncBufferizeBase<FuncBufferizePass> {
32 using FuncBufferizeBase<FuncBufferizePass>::FuncBufferizeBase;
33 void runOnOperation()
override {
34 auto module = getOperation();
41 populateFunctionOpInterfaceTypeConversionPattern<FuncOp>(patterns,
45 typeConverter.
isLegal(&op.getBody());
49 [&](CallOp op) {
return typeConverter.
isLegal(op); });
53 target.
addLegalOp<ModuleOp, bufferization::ToTensorOp,
54 bufferization::ToMemrefOp>();
70 return std::make_unique<FuncBufferizePass>();
static MLIRContext * getContext(OpFoldResult val)
This class describes a specific conversion target.
void addLegalOp(OperationName op)
Register the given operations as legal.
void markUnknownOpDynamicallyLegal(const DynamicLegalityCallbackFn &fn)
Register unknown operations as dynamically legal.
void addDynamicallyLegalOp(OperationName op, const DynamicLegalityCallbackFn &callback)
Register the given operation as dynamically legal and set the dynamic legalization callback to the on...
Operation is the basic unit of execution within MLIR.
bool isLegal(Type type) const
Return true if the given type is legal for this type converter, i.e.
bool isSignatureLegal(FunctionType ty) const
Return true if the inputs and outputs of the given function type are legal.
A helper type converter class that automatically populates the relevant materializations and type con...
std::unique_ptr< Pass > createFuncBufferizePass()
Creates an instance of func bufferization pass.
Include the generated interface declarations.
bool isLegalForReturnOpTypeConversionPattern(Operation *op, const TypeConverter &converter, bool returnOpAlwaysLegal=false)
For ReturnLike ops (except return), return True.
LogicalResult applyFullConversion(ArrayRef< Operation * > ops, const ConversionTarget &target, const FrozenRewritePatternSet &patterns, ConversionConfig config=ConversionConfig())
Apply a complete conversion on the given operations, and all nested operations.
bool isNotBranchOpInterfaceOrReturnLikeOp(Operation *op)
Return true if op is neither BranchOpInterface nor ReturnLike.
void populateBranchOpInterfaceTypeConversionPattern(RewritePatternSet &patterns, const TypeConverter &converter, function_ref< bool(BranchOpInterface branchOp, int idx)> shouldConvertBranchOperand=nullptr)
Add a pattern to the given pattern list to rewrite branch operations to use operands that have been l...
void populateCallOpTypeConversionPattern(RewritePatternSet &patterns, const TypeConverter &converter)
Add a pattern to the given pattern list to convert the operand and result types of a CallOp with the ...
void populateReturnOpTypeConversionPattern(RewritePatternSet &patterns, const TypeConverter &converter)
Add a pattern to the given pattern list to rewrite return ops to use operands that have been legalize...
bool isLegalForBranchOpInterfaceTypeConversionPattern(Operation *op, const TypeConverter &converter)
Return true if op is a BranchOpInterface op whose operands are all legal according to converter.