LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
llzk::SourceRefLatticeValue Class Reference

A value at a given point of the SourceRefLattice. More...

#include <SourceRefLattice.h>

Inheritance diagram for llzk::SourceRefLatticeValue:
[legend]
Collaboration diagram for llzk::SourceRefLatticeValue:
[legend]

Public Member Functions

 SourceRefLatticeValue (ScalarTy s)
 SourceRefLatticeValue (SourceRef r)
 SourceRefLatticeValue ()
 SourceRefLatticeValue (const SourceRefLatticeValue &)=default
 SourceRefLatticeValue (SourceRefLatticeValue &&)=default
SourceRefLatticeValueoperator= (const SourceRefLatticeValue &)=default
SourceRefLatticeValueoperator= (SourceRefLatticeValue &&)=default
virtual ~SourceRefLatticeValue ()=default
 SourceRefLatticeValue (mlir::ArrayRef< int64_t > shape)
const SourceRefgetSingleValue () const
mlir::ChangeResult insert (const SourceRef &rhs)
 Directly insert the ref into this value.
mlir::ChangeResult remove (const SourceRef &ref)
 Remove ref from this value's reference set or, for an array, from every element.
std::pair< SourceRefLatticeValue, mlir::ChangeResult > translate (const TranslationMap &translation) const
 Translate contained references using translation and return the transformed value.
std::pair< SourceRefLatticeValue, mlir::ChangeResult > replacePrefixes (const TranslationMap &translation) const
 Replace matching SourceRef prefixes and leave unmatched references unchanged.
mlir::ChangeResult write (const std::vector< SourceRefIndex > &indices, const SourceRefLatticeValue &rhs, bool joinWithExisting=false)
 Update the element or subarray selected by indices.
mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > referenceMember (SymbolLookupResult< component::MemberDefOp > memberRef) const
 Add the given memberRef to the SourceRefs contained within this value.
mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > referencePodRecord (mlir::StringAttr recordName) const
 Add the given pod recordName to the SourceRefs contained within this value.
mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > extract (const std::vector< SourceRefIndex > &indices) const
 Perform an array.extract or array.read operation, depending on how many indices are provided.
const std::vector< int64_t > & getArrayShape () const
 Return the dimensions of this array-shaped value.
Public Member Functions inherited from llzk::dataflow::AbstractLatticeValue< SourceRefLatticeValue, SourceRefSet >
bool isScalar () const
bool isSingleValue () const
bool isArray () const
bool isDynamicArray () const
const ScalarTy & getScalarValue () const
ScalarTy & getScalarValue ()
const ArrayTy & getArrayValue () const
ArrayTy & getArrayValue ()
const SourceRefLatticeValuegetElemFlatIdx (size_t i) const
 Directly index into the flattened array using a single index.
SourceRefLatticeValuegetElemFlatIdx (size_t i)
size_t getArraySize () const
size_t getNumArrayDims () const
void print (mlir::raw_ostream &os) const
ScalarTy foldToScalar () const
 If this is an array value, combine all elements into a single scalar value and return it.
mlir::ChangeResult setValue (const AbstractLatticeValue &rhs)
 Sets this value to be equal to rhs.
mlir::ChangeResult update (const SourceRefLatticeValue &rhs)
 Union this value with that of rhs.
bool operator== (const AbstractLatticeValue &rhs) const

Protected Member Functions

mlir::ChangeResult translateScalar (const TranslationMap &translation)
 Translate this value using the translation map, assuming this value is a scalar.
mlir::ChangeResult replacePrefixesScalar (const TranslationMap &translation)
 Replace matching prefixes in a scalar value without dropping unmatched references.
virtual mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > elementwiseTransform (llvm::function_ref< mlir::FailureOr< SourceRef >(const SourceRef &)> transform) const
 Perform a recursive transformation over all elements of this value and return a new value with the modifications.
Protected Member Functions inherited from llzk::dataflow::AbstractLatticeValue< SourceRefLatticeValue, SourceRefSet >
std::variant< ScalarTy, ArrayTy > & getValue ()
const std::vector< int64_t > & getArrayShape () const
int64_t getArrayDim (unsigned i) const
void copyArrayShape (const AbstractLatticeValue &rhs)
mlir::ChangeResult updateScalar (const ScalarTy &rhs)
 Union this value with the given scalar.
mlir::ChangeResult updateArray (const ArrayTy &rhs)
 Union this value with the given array.
mlir::ChangeResult foldAndUpdate (const SourceRefLatticeValue &rhs)
 Folds the current value into a scalar and folds rhs to a scalar and updates the current value to the union of the two scalars.

Detailed Description

A value at a given point of the SourceRefLattice.

Definition at line 27 of file SourceRefLattice.h.

Constructor & Destructor Documentation

◆ SourceRefLatticeValue() [1/6]

llzk::SourceRefLatticeValue::SourceRefLatticeValue ( ScalarTy s)
inlineexplicit

Definition at line 42 of file SourceRefLattice.h.

◆ SourceRefLatticeValue() [2/6]

llzk::SourceRefLatticeValue::SourceRefLatticeValue ( SourceRef r)
inlineexplicit

Definition at line 43 of file SourceRefLattice.h.

◆ SourceRefLatticeValue() [3/6]

llzk::SourceRefLatticeValue::SourceRefLatticeValue ( )
inline

Definition at line 44 of file SourceRefLattice.h.

◆ SourceRefLatticeValue() [4/6]

llzk::SourceRefLatticeValue::SourceRefLatticeValue ( const SourceRefLatticeValue & )
default

◆ SourceRefLatticeValue() [5/6]

llzk::SourceRefLatticeValue::SourceRefLatticeValue ( SourceRefLatticeValue && )
default

◆ ~SourceRefLatticeValue()

virtual llzk::SourceRefLatticeValue::~SourceRefLatticeValue ( )
virtualdefault

◆ SourceRefLatticeValue() [6/6]

llzk::SourceRefLatticeValue::SourceRefLatticeValue ( mlir::ArrayRef< int64_t > shape)
inlineexplicit

Definition at line 52 of file SourceRefLattice.h.

Member Function Documentation

◆ elementwiseTransform()

mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > llzk::SourceRefLatticeValue::elementwiseTransform ( llvm::function_ref< mlir::FailureOr< SourceRef >(const SourceRef &)> transform) const
protectedvirtual

Perform a recursive transformation over all elements of this value and return a new value with the modifications.

Definition at line 299 of file SourceRefLattice.cpp.

◆ extract()

mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > llzk::SourceRefLatticeValue::extract ( const std::vector< SourceRefIndex > & indices) const

Perform an array.extract or array.read operation, depending on how many indices are provided.

Definition at line 172 of file SourceRefLattice.cpp.

◆ getArrayShape()

const std::vector< int64_t > & llzk::dataflow::AbstractLatticeValue< SourceRefLatticeValue, ScalarTy >::getArrayShape ( ) const
inline

Return the dimensions of this array-shaped value.

Definition at line 222 of file AbstractLatticeValue.h.

◆ getSingleValue()

const SourceRef & llzk::SourceRefLatticeValue::getSingleValue ( ) const
inline

Definition at line 54 of file SourceRefLattice.h.

◆ insert()

mlir::ChangeResult llzk::SourceRefLatticeValue::insert ( const SourceRef & rhs)

Directly insert the ref into this value.

If this is a scalar value, insert the ref into the value's set. If this is an array value, the array is folded into a single scalar, then the ref is inserted.

Definition at line 43 of file SourceRefLattice.cpp.

◆ operator=() [1/2]

SourceRefLatticeValue & llzk::SourceRefLatticeValue::operator= ( const SourceRefLatticeValue & )
default

◆ operator=() [2/2]

SourceRefLatticeValue & llzk::SourceRefLatticeValue::operator= ( SourceRefLatticeValue && )
default

◆ referenceMember()

mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > llzk::SourceRefLatticeValue::referenceMember ( SymbolLookupResult< component::MemberDefOp > memberRef) const

Add the given memberRef to the SourceRefs contained within this value.

For example, if memberRef is a member reference @foo and this value represents self, the new value will represent self[@foo].

Parameters
memberRefThe member reference into the current value.
Returns
The new value and a change result indicating if the value is different than the original value.

Definition at line 154 of file SourceRefLattice.cpp.

◆ referencePodRecord()

mlir::FailureOr< std::pair< SourceRefLatticeValue, mlir::ChangeResult > > llzk::SourceRefLatticeValue::referencePodRecord ( mlir::StringAttr recordName) const

Add the given pod recordName to the SourceRefs contained within this value.

For example, if recordName is @foo and this value represents pod, the new value will represent pod[@foo].

Definition at line 163 of file SourceRefLattice.cpp.

◆ remove()

mlir::ChangeResult llzk::SourceRefLatticeValue::remove ( const SourceRef & ref)

Remove ref from this value's reference set or, for an array, from every element.

Definition at line 52 of file SourceRefLattice.cpp.

◆ replacePrefixes()

std::pair< SourceRefLatticeValue, mlir::ChangeResult > llzk::SourceRefLatticeValue::replacePrefixes ( const TranslationMap & translation) const

Replace matching SourceRef prefixes and leave unmatched references unchanged.

Definition at line 82 of file SourceRefLattice.cpp.

◆ replacePrefixesScalar()

mlir::ChangeResult llzk::SourceRefLatticeValue::replacePrefixesScalar ( const TranslationMap & translation)
protected

Replace matching prefixes in a scalar value without dropping unmatched references.

Definition at line 270 of file SourceRefLattice.cpp.

◆ translate()

std::pair< SourceRefLatticeValue, mlir::ChangeResult > llzk::SourceRefLatticeValue::translate ( const TranslationMap & translation) const

Translate contained references using translation and return the transformed value.

References that do not match a prefix in translation are discarded.

Definition at line 66 of file SourceRefLattice.cpp.

◆ translateScalar()

mlir::ChangeResult llzk::SourceRefLatticeValue::translateScalar ( const TranslationMap & translation)
protected

Translate this value using the translation map, assuming this value is a scalar.

Definition at line 246 of file SourceRefLattice.cpp.

◆ write()

mlir::ChangeResult llzk::SourceRefLatticeValue::write ( const std::vector< SourceRefIndex > & indices,
const SourceRefLatticeValue & rhs,
bool joinWithExisting = false )

Update the element or subarray selected by indices.

When joinWithExisting is true, the selected values are conservatively joined with rhs; otherwise they are replaced. A ranged index always joins because any individual selected element may retain its old value.

Definition at line 97 of file SourceRefLattice.cpp.


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