MLIR  17.0.0git
Classes | Public Member Functions | Static Public Member Functions | List of all members
mlir::bufferization::OneShotAnalysisState Class Reference

State for analysis-enabled bufferization. More...

#include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h"

+ Inheritance diagram for mlir::bufferization::OneShotAnalysisState:

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 OneShotBufferizationOptionsgetOptions () 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...
 
- Public Member Functions inherited from mlir::bufferization::AnalysisState
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< ValuefindValueInReverseUseDefChain (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< ValuefindDefinitions (Value value) const
 Find the values that may define the contents of the given value at runtime. More...
 
const BufferizationOptionsgetOptions () 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 Public Member Functions inherited from mlir::bufferization::AnalysisState
static bool classof (const AnalysisState *base)
 

Additional Inherited Members

- Protected Member Functions inherited from mlir::bufferization::AnalysisState
 AnalysisState (const BufferizationOptions &options, TypeID type)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ OneShotAnalysisState() [1/2]

OneShotAnalysisState::OneShotAnalysisState ( Operation op,
const OneShotBufferizationOptions options 
)

Definition at line 106 of file OneShotAnalysis.cpp.

◆ OneShotAnalysisState() [2/2]

mlir::bufferization::OneShotAnalysisState::OneShotAnalysisState ( const OneShotAnalysisState )
delete

◆ ~OneShotAnalysisState()

mlir::bufferization::OneShotAnalysisState::~OneShotAnalysisState ( )
overridedefault

Member Function Documentation

◆ addExtension()

template<typename Ty , typename... Args>
Ty& mlir::bufferization::OneShotAnalysisState::addExtension ( Args &&...  args)
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().

◆ analyzeOp()

LogicalResult OneShotAnalysisState::analyzeOp ( Operation op,
const DominanceInfo domInfo 
)

Analyze the given op and its nested ops.

Definition at line 891 of file OneShotAnalysis.cpp.

◆ analyzeSingleOp()

LogicalResult OneShotAnalysisState::analyzeSingleOp ( Operation op,
const DominanceInfo domInfo 
)

Analyze a single op (without nested ops).

Definition at line 811 of file OneShotAnalysis.cpp.

◆ applyOnAliases()

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().

◆ applyOnEquivalenceClass()

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.

◆ areAliasingBufferizedValues()

bool OneShotAnalysisState::areAliasingBufferizedValues ( Value  v1,
Value  v2 
) const
overridevirtual

Return true if v1 and v2 may bufferize to aliasing buffers.

Reimplemented from mlir::bufferization::AnalysisState.

Definition at line 155 of file OneShotAnalysis.cpp.

◆ areEquivalentBufferizedValues()

bool OneShotAnalysisState::areEquivalentBufferizedValues ( Value  v1,
Value  v2 
) const
overridevirtual

Return true if v1 and v2 bufferize to equivalent buffers.

Reimplemented from mlir::bufferization::AnalysisState.

Definition at line 150 of file OneShotAnalysis.cpp.

◆ bufferizeInPlace()

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().

◆ bufferizeOutOfPlace()

void OneShotAnalysisState::bufferizeOutOfPlace ( OpOperand operand)

Mark the given OpOperand as out-of-place.

Definition at line 169 of file OneShotAnalysis.cpp.

Referenced by bufferizableInPlaceAnalysisImpl().

◆ classof()

static bool mlir::bufferization::OneShotAnalysisState::classof ( const AnalysisState base)
inlinestatic

Definition at line 61 of file OneShotAnalysis.h.

References mlir::bufferization::AnalysisState::getType().

◆ createAliasInfoEntry()

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.

◆ findDefinitionsCached()

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().

◆ gatherUndefinedTensorUses()

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.

◆ gatherYieldedTensors()

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.

◆ getExtension() [1/2]

template<typename Ty >
Ty* mlir::bufferization::OneShotAnalysisState::getExtension ( )
inline

Returns the extension of the specified type.

Definition at line 208 of file OneShotAnalysis.h.

Referenced by getOrCreateFuncAnalysisState().

◆ getExtension() [2/2]

template<typename Ty >
const Ty* mlir::bufferization::OneShotAnalysisState::getExtension ( ) const
inline

Returns the extension of the specified type.

Definition at line 220 of file OneShotAnalysis.h.

◆ getOptions()

const OneShotBufferizationOptions& mlir::bufferization::OneShotAnalysisState::getOptions ( ) const
inline

◆ getStatNumTensorInPlace()

int64_t mlir::bufferization::OneShotAnalysisState::getStatNumTensorInPlace ( ) const
inline

Definition at line 109 of file OneShotAnalysis.h.

◆ getStatNumTensorOutOfPlace()

int64_t mlir::bufferization::OneShotAnalysisState::getStatNumTensorOutOfPlace ( ) const
inline

Definition at line 108 of file OneShotAnalysis.h.

◆ hasUndefinedContents()

bool OneShotAnalysisState::hasUndefinedContents ( OpOperand opOperand) const
overridevirtual

Return true if the given tensor has undefined contents.

Reimplemented from mlir::bufferization::AnalysisState.

Definition at line 236 of file OneShotAnalysis.cpp.

◆ isInPlace()

bool OneShotAnalysisState::isInPlace ( OpOperand opOperand) const
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().

◆ isTensorYielded()

bool OneShotAnalysisState::isTensorYielded ( Value  tensor) const
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.

◆ isValueWritten()

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().

◆ isWritable()

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().

◆ resetCache()

void OneShotAnalysisState::resetCache ( )

Reset cached data structures.

Definition at line 785 of file OneShotAnalysis.cpp.

◆ unionAliasSets()

void OneShotAnalysisState::unionAliasSets ( Value  v1,
Value  v2 
)

Union the alias sets of v1 and v2.

Definition at line 273 of file OneShotAnalysis.cpp.

◆ unionEquivalenceClasses()

void OneShotAnalysisState::unionEquivalenceClasses ( Value  v1,
Value  v2 
)

Union the equivalence classes of v1 and v2.

Definition at line 277 of file OneShotAnalysis.cpp.

Referenced by equivalenceAnalysis().


The documentation for this class was generated from the following files: