MLIR  16.0.0git
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:
+ Collaboration diagram for mlir::bufferization::OneShotAnalysisState:

Public Member Functions

 OneShotAnalysisState (Operation *op, const OneShotBufferizationOptions &options)
 
 OneShotAnalysisState (const OneShotAnalysisState &)=delete
 
virtual ~OneShotAnalysisState ()=default
 
BufferizationAliasInfogetAliasInfo ()
 Return a reference to the BufferizationAliasInfo. More...
 
bool isInPlace (OpOperand &opOperand) const override
 Return true if the given OpResult has been decided to bufferize inplace. 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...
 
bool hasUndefinedContents (OpOperand *opOperand) const override
 Return true if the given tensor has undefined contents. More...
 
bool isTensorYielded (Value tensor) const override
 Return true if the given tensor (or an aliasing tensor) is yielded from the containing block. 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...
 
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...
 
- Public Member Functions inherited from mlir::bufferization::AnalysisState
SmallVector< OpOperand * > getAliasingOpOperand (OpResult result) const
 Determine which OpOperand* will alias with result if the op is bufferized in place. More...
 
SmallVector< OpResultgetAliasingOpResult (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 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) const
 Starting from value, follow the use-def chain in reverse, always selecting the aliasing OpOperands. More...
 
SetVector< ValuefindLastPrecedingWrite (Value value) const
 Find the Values of the last preceding write of a given Value. More...
 
bool hasDialectState (StringRef name) const
 Return true if the given dialect state exists. More...
 
template<typename StateT >
Optional< const StateT * > getDialectState (StringRef name) const
 Return dialect-specific bufferization state. More...
 
template<typename StateT >
StateT & getOrCreateDialectState (StringRef name)
 Return dialect-specific analysis state or create one if none exists. More...
 
void insertDialectState (StringRef name, std::unique_ptr< DialectAnalysisState > state)
 
const BufferizationOptionsgetOptions () const
 Return a reference to the BufferizationOptions. More...
 
 AnalysisState (const BufferizationOptions &options)
 
 AnalysisState (const AnalysisState &)=delete
 
virtual ~AnalysisState ()=default
 

Detailed Description

State for analysis-enabled bufferization.

This class keeps track of alias (via BufferizationAliasInfo) to decide if tensor OpOperands should bufferize in-place.

Definition at line 126 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()

virtual mlir::bufferization::OneShotAnalysisState::~OneShotAnalysisState ( )
virtualdefault

Member Function Documentation

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

References mlir::bufferization::BufferizationAliasInfo::areAliasingBufferizedValues().

Referenced by getAssumedUniqueReturnOp().

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

References mlir::bufferization::BufferizationAliasInfo::areEquivalentBufferizedValues().

Referenced by getAssumedUniqueReturnOp().

◆ gatherUndefinedTensorUses()

void OneShotAnalysisState::gatherUndefinedTensorUses ( Operation op)

◆ gatherYieldedTensors()

void OneShotAnalysisState::gatherYieldedTensors ( Operation op)

◆ getAliasInfo()

BufferizationAliasInfo& mlir::bufferization::OneShotAnalysisState::getAliasInfo ( )
inline

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

References mlir::bufferization::BufferizationAliasInfo::isInPlace().

Referenced by equivalenceAnalysis(), and isValueWritten().

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

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

Referenced by getAssumedUniqueReturnOp().

◆ isWritable()

bool OneShotAnalysisState::isWritable ( Value  value) const

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

Definition at line 309 of file OneShotAnalysis.cpp.

References mlir::Value::dyn_cast(), and mlir::bufferization::AnalysisState::getOptions().

Referenced by hasPrecedingAliasingNonWritableTensor().


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