37 void transform::BufferLoopHoistingOp::getEffects(
48 if (getMemcpyOp() !=
"memref.copy" && getMemcpyOp() !=
"linalg.copy")
49 return emitOpError() <<
"unsupported memcpy op";
50 if (getPrintConflicts() && !getTestAnalysisOnly())
51 return emitOpError() <<
"'print_conflicts' requires 'test_analysis_only'";
52 if (getDumpAliasSets() && !getTestAnalysisOnly())
53 return emitOpError() <<
"'dump_alias_sets' requires 'test_analysis_only'";
62 options.allowReturnAllocsFromLoops = getAllowReturnAllocsFromLoops();
63 options.allowUnknownOps = getAllowUnknownOps();
64 options.bufferizeFunctionBoundaries = getBufferizeFunctionBoundaries();
65 options.dumpAliasSets = getDumpAliasSets();
66 options.testAnalysisOnly = getTestAnalysisOnly();
67 options.printConflicts = getPrintConflicts();
68 if (getFunctionBoundaryTypeConversion().has_value())
69 options.setFunctionBoundaryTypeConversion(
70 *getFunctionBoundaryTypeConversion());
71 if (getMemcpyOp() ==
"memref.copy") {
73 b.
create<memref::CopyOp>(loc, from, to);
76 }
else if (getMemcpyOp() ==
"linalg.copy") {
78 b.
create<linalg::CopyOp>(loc, from, to);
82 llvm_unreachable(
"invalid copy op");
85 auto payloadOps = state.getPayloadOps(getTarget());
89 if (!isa<ModuleOp, FunctionOpInterface>(target))
90 return emitSilenceableError() <<
"expected module or function target";
91 auto moduleOp = dyn_cast<ModuleOp>(target);
92 if (
options.bufferizeFunctionBoundaries) {
94 return emitSilenceableError() <<
"expected module target";
97 return emitSilenceableError() <<
"bufferization failed";
100 bufferizationState)))
101 return emitSilenceableError() <<
"bufferization failed";
107 transformResults.
set(cast<OpResult>(getTransformed()), payloadOps);
115 void transform::EliminateEmptyTensorsOp::getEffects(
124 for (
Operation *target : state.getPayloadOps(getTarget())) {
127 <<
"empty tensor elimination failed";
141 target, target.getType(), target.getDynamicSizes());
153 class BufferizationTransformDialectExtension
155 BufferizationTransformDialectExtension> {
158 BufferizationTransformDialectExtension)
163 declareGeneratedDialect<bufferization::BufferizationDialect>();
164 declareGeneratedDialect<memref::MemRefDialect>();
166 registerTransformOps<
168 #include "mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp.inc"
175 #define GET_OP_CLASSES
176 #include "mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp.inc"
178 #include "mlir/Dialect/Bufferization/IR/BufferizationEnums.cpp.inc"
182 registry.
addExtensions<BufferizationTransformDialectExtension>();
static llvm::ManagedStatic< PassManagerOptions > options
#define MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CLASS_NAME)
The result of a transform IR operation application.
static DiagnosedSilenceableFailure success()
Constructs a DiagnosedSilenceableFailure in the success state.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
void addExtensions()
Add the given extensions to the registry.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
void setInsertionPoint(Block *block, Block::iterator insertPoint)
Set the insertion point to the specified location.
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
Operation is the basic unit of execution within MLIR.
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
BufferizationState provides information about the state of the IR during the bufferization process.
Base class for extensions of the Transform dialect that supports injecting operations into the Transf...
void registerTransformDialectExtension(DialectRegistry ®istry)
void hoistBuffersFromLoops(Operation *op)
Within the given operation, hoist buffers from loops where possible.
LogicalResult runOneShotBufferize(Operation *op, const OneShotBufferizationOptions &options, BufferizationState &state, BufferizationStatistics *statistics=nullptr)
Run One-Shot Bufferize on the given op: Analysis + Bufferization.
LogicalResult eliminateEmptyTensors(RewriterBase &rewriter, Operation *op)
Try to eliminate "tensor.empty" ops inside op.
llvm::LogicalResult runOneShotModuleBufferize(ModuleOp moduleOp, const bufferization::OneShotBufferizationOptions &options, BufferizationState &state, BufferizationStatistics *statistics=nullptr)
Run One-Shot Module Bufferization on the given module.
Include the generated interface declarations.
DiagnosedSilenceableFailure emitSilenceableFailure(Location loc, const Twine &message={})
Emits a silenceable failure with the given message.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...
Options for analysis-enabled bufferization.