MLIR
17.0.0git
|
State for analysis-enabled bufferization. More...
#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"
Classes | |
class | Extension |
Base class for OneShotAnalysisState extensions that allow OneShotAnalysisState to contain user-specified information in the state object. More... | |
Public Member Functions | |
OneShotAnalysisState (Operation *op, const OneShotBufferizationOptions &options) | |
OneShotAnalysisState (const OneShotAnalysisState &)=delete | |
~OneShotAnalysisState () override=default | |
const OneShotBufferizationOptions & | getOptions () const |
Return a reference to the BufferizationOptions. More... | |
LogicalResult | analyzeOp (Operation *op, const DominanceInfo &domInfo) |
Analyze the given op and its nested ops. More... | |
LogicalResult | analyzeSingleOp (Operation *op, const DominanceInfo &domInfo) |
Analyze a single op (without nested ops). More... | |
void | applyOnEquivalenceClass (Value v, function_ref< void(Value)> fun) const |
Apply fun to all the members of the equivalence class of v . More... | |
void | applyOnAliases (Value v, function_ref< void(Value)> fun) const |
Apply fun to all aliases of v . More... | |
bool | areEquivalentBufferizedValues (Value v1, Value v2) const override |
Return true if v1 and v2 bufferize to equivalent buffers. More... | |
bool | areAliasingBufferizedValues (Value v1, Value v2) const override |
Return true if v1 and v2 may bufferize to aliasing buffers. More... | |
void | bufferizeInPlace (OpOperand &operand) |
Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets. More... | |
void | bufferizeOutOfPlace (OpOperand &operand) |
Mark the given OpOperand as out-of-place. More... | |
void | createAliasInfoEntry (Value v) |
Add a new entry for v in the aliasInfo and equivalentInfo . More... | |
void | gatherUndefinedTensorUses (Operation *op) |
Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses . More... | |
void | gatherYieldedTensors (Operation *op) |
Find all tensors that are yielded/returned from a block and store them in yieldedTensors . More... | |
int64_t | getStatNumTensorOutOfPlace () const |
int64_t | getStatNumTensorInPlace () const |
bool | hasUndefinedContents (OpOperand *opOperand) const override |
Return true if the given tensor has undefined contents. More... | |
bool | isInPlace (OpOperand &opOperand) const override |
Return true if the given OpResult has been decided to bufferize inplace. More... | |
bool | isTensorYielded (Value tensor) const override |
Return true if the given tensor (or an aliasing tensor) is yielded from the containing block. More... | |
bool | isValueWritten (Value value) const |
Return true if the buffer of the given tensor value is written to. More... | |
bool | isWritable (Value value) const |
Return true if the buffer of the given tensor value is writable. More... | |
const SetVector< Value > & | findDefinitionsCached (Value value) |
Find the definitions of the given tensor value or retrieve them from the cache. More... | |
void | resetCache () |
Reset cached data structures. More... | |
void | unionAliasSets (Value v1, Value v2) |
Union the alias sets of v1 and v2 . More... | |
void | unionEquivalenceClasses (Value v1, Value v2) |
Union the equivalence classes of v1 and v2 . More... | |
template<typename Ty , typename... Args> | |
Ty & | addExtension (Args &&...args) |
Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided. More... | |
template<typename Ty > | |
Ty * | getExtension () |
Returns the extension of the specified type. More... | |
template<typename Ty > | |
const Ty * | getExtension () const |
Returns the extension of the specified type. More... | |
![]() | |
AliasingOpOperandList | getAliasingOpOperands (OpResult result) const |
Determine which OpOperand* will alias with result if the op is bufferized in place. More... | |
AliasingOpResultList | getAliasingOpResults (OpOperand &opOperand) const |
Determine which OpResult will alias with opOperand if the op is bufferized in place. More... | |
bool | bufferizesToMemoryRead (OpOperand &opOperand) const |
Return true if opOperand bufferizes to a memory read. More... | |
bool | bufferizesToMemoryWrite (OpOperand &opOperand) const |
Return true if opOperand bufferizes to a memory write. More... | |
bool | bufferizesToMemoryWrite (Value value) const |
Return true if the given value bufferizes to a memory write. More... | |
bool | bufferizesToAliasOnly (OpOperand &opOperand) const |
Return true if opOperand does neither read nor write but bufferizes to an alias. More... | |
bool | canOmitTensorCopy (OpOperand &opOperand) const |
Return true if a copy can always be avoided when allocating a new tensor for the given OpOperand. More... | |
bool | isValueRead (Value value) const |
Return true if the given value is read by an op that bufferizes to a memory read. More... | |
SetVector< Value > | findValueInReverseUseDefChain (Value value, llvm::function_ref< bool(Value)> condition, TraversalConfig config=TraversalConfig()) const |
Starting from value , follow the use-def chain in reverse, always selecting the aliasing OpOperands. More... | |
SetVector< Value > | findDefinitions (Value value) const |
Find the values that may define the contents of the given value at runtime. More... | |
const BufferizationOptions & | getOptions () const |
Return a reference to the BufferizationOptions. More... | |
AnalysisState (const BufferizationOptions &options) | |
AnalysisState (const AnalysisState &)=delete | |
virtual | ~AnalysisState ()=default |
TypeID | getType () const |
Static Public Member Functions | |
static bool | classof (const AnalysisState *base) |
![]() | |
static bool | classof (const AnalysisState *base) |
Additional Inherited Members | |
![]() | |
AnalysisState (const BufferizationOptions &options, TypeID type) | |
State for analysis-enabled bufferization.
This class keeps track of alias sets, equivalence sets, in-place OpOperands and other things.
Note: Modifying the IR generally invalidates the result of the analysis. Adding new operations is safe if they are analyzed subsequently.
Definition at line 52 of file OneShotAnalysis.h.
OneShotAnalysisState::OneShotAnalysisState | ( | Operation * | op, |
const OneShotBufferizationOptions & | options | ||
) |
Definition at line 106 of file OneShotAnalysis.cpp.
|
delete |
|
overridedefault |
|
inline |
Adds a new Extension of the type specified as template parameter, constructing it with the arguments provided.
The extension is owned by the OneShotAnalysisState. It is expected that the state does not already have an extension of the same type. Extension constructors are expected to take a reference to OneShotAnalysisState as first argument, automatically supplied by this call.
Definition at line 196 of file OneShotAnalysis.h.
Referenced by getOrCreateFuncAnalysisState().
LogicalResult OneShotAnalysisState::analyzeOp | ( | Operation * | op, |
const DominanceInfo & | domInfo | ||
) |
Analyze the given op and its nested ops.
Definition at line 891 of file OneShotAnalysis.cpp.
LogicalResult OneShotAnalysisState::analyzeSingleOp | ( | Operation * | op, |
const DominanceInfo & | domInfo | ||
) |
Analyze a single op (without nested ops).
Definition at line 811 of file OneShotAnalysis.cpp.
void OneShotAnalysisState::applyOnAliases | ( | Value | v, |
function_ref< void(Value)> | fun | ||
) | const |
Apply fun
to all aliases of v
.
Definition at line 142 of file OneShotAnalysis.cpp.
Referenced by getAliasingInplaceWrites(), getAliasingReads(), and wouldCreateWriteToNonWritableBuffer().
void OneShotAnalysisState::applyOnEquivalenceClass | ( | Value | v, |
function_ref< void(Value)> | fun | ||
) | const |
Apply fun
to all the members of the equivalence class of v
.
Definition at line 133 of file OneShotAnalysis.cpp.
Return true if v1
and v2
may bufferize to aliasing buffers.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 155 of file OneShotAnalysis.cpp.
|
overridevirtual |
Return true if v1
and v2
bufferize to equivalent buffers.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 150 of file OneShotAnalysis.cpp.
void OneShotAnalysisState::bufferizeInPlace | ( | OpOperand & | operand | ) |
Mark the given OpOperand as in-place and merge the results' and operand's aliasing sets.
Definition at line 160 of file OneShotAnalysis.cpp.
References mlir::IROperand< DerivedT, IRValueT >::get(), and mlir::bufferization::AnalysisState::getAliasingOpResults().
Referenced by bufferizableInPlaceAnalysisImpl().
void OneShotAnalysisState::bufferizeOutOfPlace | ( | OpOperand & | operand | ) |
Mark the given OpOperand as out-of-place.
Definition at line 169 of file OneShotAnalysis.cpp.
Referenced by bufferizableInPlaceAnalysisImpl().
|
inlinestatic |
Definition at line 61 of file OneShotAnalysis.h.
References mlir::bufferization::AnalysisState::getType().
void OneShotAnalysisState::createAliasInfoEntry | ( | Value | v | ) |
Add a new entry for v
in the aliasInfo
and equivalentInfo
.
In the beginning the alias and equivalence sets only contain v
itself.
Definition at line 175 of file OneShotAnalysis.cpp.
const llvm::SetVector< Value > & OneShotAnalysisState::findDefinitionsCached | ( | Value | value | ) |
Find the definitions of the given tensor value or retrieve them from the cache.
Definition at line 779 of file OneShotAnalysis.cpp.
References mlir::bufferization::AnalysisState::findDefinitions().
Referenced by hasReadAfterWriteInterference().
void OneShotAnalysisState::gatherUndefinedTensorUses | ( | Operation * | op | ) |
Find all tensor values in the given operation that have undefined contents and store them in undefinedTensorUses
.
Definition at line 213 of file OneShotAnalysis.cpp.
void OneShotAnalysisState::gatherYieldedTensors | ( | Operation * | op | ) |
Find all tensors that are yielded/returned from a block and store them in yieldedTensors
.
Also include all aliasing tensors in the same block.
Definition at line 184 of file OneShotAnalysis.cpp.
|
inline |
Returns the extension of the specified type.
Definition at line 208 of file OneShotAnalysis.h.
Referenced by getOrCreateFuncAnalysisState().
|
inline |
Returns the extension of the specified type.
Definition at line 220 of file OneShotAnalysis.h.
|
inline |
Return a reference to the BufferizationOptions.
Definition at line 66 of file OneShotAnalysis.h.
References mlir::bufferization::AnalysisState::getOptions().
Referenced by mlir::bufferization::analyzeModuleOp(), hasReadAfterWriteInterference(), and wouldCreateWriteToNonWritableBuffer().
|
inline |
Definition at line 109 of file OneShotAnalysis.h.
|
inline |
Definition at line 108 of file OneShotAnalysis.h.
|
overridevirtual |
Return true
if the given tensor has undefined contents.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 236 of file OneShotAnalysis.cpp.
|
overridevirtual |
Return true
if the given OpResult has been decided to bufferize inplace.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 240 of file OneShotAnalysis.cpp.
Referenced by equivalenceAnalysis(), and isInplaceMemoryWrite().
|
overridevirtual |
Return true if the given tensor (or an aliasing tensor) is yielded from the containing block.
Also include all aliasing tensors in the same block.
Reimplemented from mlir::bufferization::AnalysisState.
Definition at line 244 of file OneShotAnalysis.cpp.
bool OneShotAnalysisState::isValueWritten | ( | Value | value | ) | const |
Return true if the buffer of the given tensor value is written to.
Must not be called for values inside not yet analyzed functions.
Definition at line 248 of file OneShotAnalysis.cpp.
References mlir::Value::getUses().
bool OneShotAnalysisState::isWritable | ( | Value | value | ) | const |
Return true if the buffer of the given tensor value is writable.
Definition at line 258 of file OneShotAnalysis.cpp.
Referenced by wouldCreateWriteToNonWritableBuffer().
void OneShotAnalysisState::resetCache | ( | ) |
Reset cached data structures.
Definition at line 785 of file OneShotAnalysis.cpp.
Union the alias sets of v1
and v2
.
Definition at line 273 of file OneShotAnalysis.cpp.
Union the equivalence classes of v1
and v2
.
Definition at line 277 of file OneShotAnalysis.cpp.
Referenced by equivalenceAnalysis().