MLIR  20.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...
 
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 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 () override
 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 (Value value) const
 Determine which OpOperand* will alias with value if the op is bufferized in place. More...
 
AliasingValueList getAliasingValues (OpOperand &opOperand) const
 Determine which Value 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
 
RegiongetEnclosingRepetitiveRegion (Operation *op, const BufferizationOptions &options)
 Return the closest enclosing repetitive region around the given op. More...
 
RegiongetEnclosingRepetitiveRegion (Value value, const BufferizationOptions &options)
 Return the closest enclosing repetitive region around the place where the given value is defined. More...
 
RegiongetEnclosingRepetitiveRegion (Block *block, const BufferizationOptions &options)
 Return the closest enclosing repetitive region around the given block. More...
 

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 62 of file OneShotAnalysis.h.

Constructor & Destructor Documentation

◆ OneShotAnalysisState() [1/2]

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

◆ 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 198 of file OneShotAnalysis.h.

◆ analyzeOp()

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

◆ analyzeSingleOp()

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

Analyze a single op (without nested ops).

Definition at line 1024 of file OneShotAnalysis.cpp.

References bufferizableInPlaceAnalysisImpl(), and mlir::Operation::getOpOperands().

Referenced by analyzeOp().

◆ applyOnAliases()

void OneShotAnalysisState::applyOnAliases ( Value  v,
function_ref< void(Value)>  fun 
) const

Apply fun to all aliases of v.

Definition at line 147 of file OneShotAnalysis.cpp.

Referenced by isValueWritten().

◆ 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 138 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 160 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 155 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 165 of file OneShotAnalysis.cpp.

References mlir::IROperand< DerivedT, IRValueT >::get(), and mlir::bufferization::AnalysisState::getAliasingValues().

◆ bufferizeOutOfPlace()

void OneShotAnalysisState::bufferizeOutOfPlace ( OpOperand operand)

Mark the given OpOperand as out-of-place.

Definition at line 174 of file OneShotAnalysis.cpp.

◆ classof()

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

Definition at line 71 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 180 of file OneShotAnalysis.cpp.

Referenced by OneShotAnalysisState().

◆ 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 989 of file OneShotAnalysis.cpp.

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

Referenced by gatherUndefinedTensorUses().

◆ 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 185 of file OneShotAnalysis.cpp.

References mlir::WalkResult::advance(), mlir::bufferization::BufferizationOptions::dynCastBufferizableOp(), findDefinitionsCached(), mlir::Operation::getOpResults(), getOptions(), mlir::WalkResult::skip(), and mlir::Operation::walk().

◆ getExtension() [1/2]

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

Returns the extension of the specified type.

Definition at line 210 of file OneShotAnalysis.h.

◆ getExtension() [2/2]

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

Returns the extension of the specified type.

Definition at line 222 of file OneShotAnalysis.h.

◆ getOptions()

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

Return a reference to the BufferizationOptions.

Definition at line 76 of file OneShotAnalysis.h.

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

Referenced by analyzeOp(), gatherUndefinedTensorUses(), and isWritable().

◆ getStatNumTensorInPlace()

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

Definition at line 115 of file OneShotAnalysis.h.

◆ getStatNumTensorOutOfPlace()

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

Definition at line 114 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 208 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 212 of file OneShotAnalysis.cpp.

Referenced by isValueWritten().

◆ 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 216 of file OneShotAnalysis.cpp.

References applyOnAliases(), mlir::bufferization::AnalysisState::bufferizesToMemoryWrite(), mlir::Value::getUses(), and isInPlace().

◆ isWritable()

bool OneShotAnalysisState::isWritable ( Value  value) const

Return true if the buffer of the given tensor value is writable.

Definition at line 226 of file OneShotAnalysis.cpp.

References getOptions(), and mlir::bufferization::getOwnerOfValue().

◆ resetCache()

void OneShotAnalysisState::resetCache ( )
overridevirtual

Reset cached data structures.

Reimplemented from mlir::bufferization::AnalysisState.

Definition at line 995 of file OneShotAnalysis.cpp.

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

◆ unionAliasSets()

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

Union the alias sets of v1 and v2.

Definition at line 237 of file OneShotAnalysis.cpp.

◆ unionEquivalenceClasses()

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

Union the equivalence classes of v1 and v2.

Definition at line 241 of file OneShotAnalysis.cpp.


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