MLIR  19.0.0git
Public Member Functions | Static Public Member Functions | List of all members
mlir::bufferization::Ownership Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ Ownership() [1/2]

mlir::bufferization::Ownership::Ownership ( )
default

Constructor that creates an 'Uninitialized' ownership.

This is needed for default-construction when used in DenseMap.

Referenced by getUninitialized(), and getUnique().

◆ Ownership() [2/2]

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.

Member Function Documentation

◆ combine()

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

◆ getCombined()

Ownership Ownership::getCombined ( Ownership  other) const

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

◆ getIndicator()

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

◆ getUninitialized()

Ownership Ownership::getUninitialized ( )
static

Get an ownership value in 'Uninitialized' state.

Definition at line 58 of file BufferDeallocationOpInterface.cpp.

References Ownership().

Referenced by mlir::bufferization::DeallocationState::resetOwnerships().

◆ getUnique()

Ownership Ownership::getUnique ( Value  indicator)
static

Get an ownership value in 'Unique' state with 'indicator' as parameter.

Definition at line 57 of file BufferDeallocationOpInterface.cpp.

References Ownership().

◆ getUnknown()

Ownership Ownership::getUnknown ( )
static

Get an ownership value in 'Unknown' state.

Definition at line 51 of file BufferDeallocationOpInterface.cpp.

Referenced by getCombined().

◆ isUninitialized()

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

◆ isUnique()

bool Ownership::isUnique ( ) const

◆ isUnknown()

bool Ownership::isUnknown ( ) const

Check if this ownership value is in the 'Unknown' state.

Definition at line 64 of file BufferDeallocationOpInterface.cpp.


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