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());
87 if (!isa<ModuleOp, FunctionOpInterface>(target))
88 return emitSilenceableError() <<
"expected module or function target";
89 auto moduleOp = dyn_cast<ModuleOp>(target);
90 if (
options.bufferizeFunctionBoundaries) {
92 return emitSilenceableError() <<
"expected module target";
94 return emitSilenceableError() <<
"bufferization failed";
97 return emitSilenceableError() <<
"bufferization failed";
103 transformResults.
set(cast<OpResult>(getTransformed()), payloadOps);
111 void transform::EliminateEmptyTensorsOp::getEffects(
120 for (
Operation *target : state.getPayloadOps(getTarget())) {
123 <<
"empty tensor elimination failed";
137 target, target.getType(), target.getDynamicSizes());
149 class BufferizationTransformDialectExtension
151 BufferizationTransformDialectExtension> {
154 BufferizationTransformDialectExtension)
159 declareGeneratedDialect<bufferization::BufferizationDialect>();
160 declareGeneratedDialect<memref::MemRefDialect>();
162 registerTransformOps<
164 #include "mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp.inc"
170 #define GET_OP_CLASSES
171 #include "mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.cpp.inc"
173 #include "mlir/Dialect/Bufferization/IR/BufferizationEnums.cpp.inc"
177 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...
Base class for extensions of the Transform dialect that supports injecting operations into the Transf...
LogicalResult runOneShotBufferize(Operation *op, const OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr)
Run One-Shot Bufferize on the given op: Analysis + Bufferization.
void registerTransformDialectExtension(DialectRegistry ®istry)
void hoistBuffersFromLoops(Operation *op)
Within the given operation, hoist buffers from loops where possible.
llvm::LogicalResult runOneShotModuleBufferize(ModuleOp moduleOp, const bufferization::OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr)
Run One-Shot Module Bufferization on the given module.
LogicalResult eliminateEmptyTensors(RewriterBase &rewriter, Operation *op)
Try to eliminate "tensor.empty" ops inside op.
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.