MLIR
20.0.0git
|
This class is used to track the ownership of values. More...
#include "mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h"
Public Member Functions | |
Ownership ()=default | |
Constructor that creates an 'Uninitialized' ownership. More... | |
Ownership (Value indicator) | |
Constructor that creates an 'Unique' ownership. More... | |
bool | isUninitialized () const |
Check if this ownership value is in the 'Uninitialized' state. More... | |
bool | isUnique () const |
Check if this ownership value is in the 'Unique' state. More... | |
bool | isUnknown () const |
Check if this ownership value is in the 'Unknown' state. More... | |
Value | getIndicator () const |
If this ownership value is in 'Unique' state, this function can be used to get the indicator parameter. More... | |
Ownership | getCombined (Ownership other) const |
Get the join of the two-element subset {this,other}. More... | |
void | combine (Ownership other) |
Modify 'this' ownership to be the join of the current 'this' and 'other'. More... | |
Static Public Member Functions | |
static Ownership | getUnknown () |
Get an ownership value in 'Unknown' state. More... | |
static Ownership | getUnique (Value indicator) |
Get an ownership value in 'Unique' state with 'indicator' as parameter. More... | |
static Ownership | getUninitialized () |
Get an ownership value in 'Uninitialized' state. More... | |
This class is used to track the ownership of values.
The ownership can either be not initialized yet ('Uninitialized' state), set to a unique SSA value which indicates the ownership at runtime (or statically if it is a constant value) ('Unique' state), or it cannot be represented in a single SSA value ('Unknown' state). An artificial example of a case where ownership cannot be represented in a single i1 SSA value could be the following: %0 = test.non_deterministic_select arg0, arg1 : i32
Since the operation does not provide us a separate boolean indicator on which of the two operands was selected, we would need to either insert an alias check at runtime to determine if %0
aliases with arg0
or arg1
, or insert a bufferization.clone
operation to get a fresh buffer which we could assign ownership to.
The three states this class can represent form a lattice on a partial order: forall X in SSA values. uninitialized < unique(X) < unknown forall X, Y in SSA values. unique(X) == unique(Y) iff X and Y always evaluate to the same value unique(X) != unique(Y) otherwise
Definition at line 46 of file BufferDeallocationOpInterface.h.
|
default |
Constructor that creates an 'Uninitialized' ownership.
This is needed for default-construction when used in DenseMap.
Referenced by getUninitialized(), and getUnique().
Ownership::Ownership | ( | Value | indicator | ) |
Constructor that creates an 'Unique' ownership.
This is a non-explicit constructor to allow implicit conversion from 'Value'.
Definition at line 48 of file BufferDeallocationOpInterface.cpp.
void Ownership::combine | ( | Ownership | other | ) |
Modify 'this' ownership to be the join of the current 'this' and 'other'.
Definition at line 91 of file BufferDeallocationOpInterface.cpp.
References getCombined().
Get the join of the two-element subset {this,other}.
Does not modify 'this'.
Definition at line 71 of file BufferDeallocationOpInterface.cpp.
References getUnknown(), mlir::isEqualConstantIntOrValue(), isUninitialized(), and isUnique().
Referenced by combine().
Value Ownership::getIndicator | ( | ) | const |
If this ownership value is in 'Unique' state, this function can be used to get the indicator parameter.
Using this function in any other state is UB.
Definition at line 66 of file BufferDeallocationOpInterface.cpp.
References isUnique().
Referenced by mlir::bufferization::DeallocationState::getMemrefsAndConditionsToDeallocate(), and mlir::bufferization::DeallocationState::getMemrefWithUniqueOwnership().
|
static |
Get an ownership value in 'Uninitialized' state.
Definition at line 58 of file BufferDeallocationOpInterface.cpp.
References Ownership().
Referenced by mlir::bufferization::DeallocationState::resetOwnerships().
Get an ownership value in 'Unique' state with 'indicator' as parameter.
Definition at line 57 of file BufferDeallocationOpInterface.cpp.
References Ownership().
|
static |
Get an ownership value in 'Unknown' state.
Definition at line 51 of file BufferDeallocationOpInterface.cpp.
Referenced by getCombined().
bool Ownership::isUninitialized | ( | ) | const |
Check if this ownership value is in the 'Uninitialized' state.
Definition at line 60 of file BufferDeallocationOpInterface.cpp.
Referenced by getCombined().
bool Ownership::isUnique | ( | ) | const |
Check if this ownership value is in the 'Unique' state.
Definition at line 63 of file BufferDeallocationOpInterface.cpp.
Referenced by getCombined(), getIndicator(), mlir::bufferization::DeallocationState::getMemrefsAndConditionsToDeallocate(), and mlir::bufferization::DeallocationState::getMemrefWithUniqueOwnership().
bool Ownership::isUnknown | ( | ) | const |
Check if this ownership value is in the 'Unknown' state.
Definition at line 64 of file BufferDeallocationOpInterface.cpp.