LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches

A reference to a "source", which is the base value from which other SSA values are derived. More...

#include <SourceRef.h>

Classes

struct  Hash

Public Types

using Path = std::vector<SourceRefIndex>

Public Member Functions

 SourceRef (mlir::BlockArgument b, Path p={})
 SourceRef (component::CreateStructOp createOp, Path p={})
 SourceRef (NonDetOp nondet, Path p={})
 SourceRef (mlir::OpResult rootResult, Path p={})
 SourceRef (felt::FeltConstantOp c)
 SourceRef (mlir::arith::ConstantIndexOp c)
 SourceRef (polymorphic::ConstReadOp c)
mlir::Type getType () const
bool isConstantFelt () const
bool isConstantIndex () const
bool isTemplateConstant () const
bool isConstant () const
bool isConstantInt () const
bool isFeltVal () const
bool isIndexVal () const
bool isIntegerVal () const
bool isTypeVarVal () const
bool isScalar () const
bool isRooted () const
bool isBlockArgument () const
mlir::FailureOr< mlir::Value > getRoot () const
mlir::FailureOr< mlir::Value > getConstant () const
mlir::FailureOr< mlir::BlockArgument > getBlockArgument () const
mlir::FailureOr< unsigned > getInputNum () const
bool isCreateStructOp () const
mlir::FailureOr< component::CreateStructOpgetCreateStructOp () const
bool isNonDetOp () const
mlir::FailureOr< NonDetOpgetNonDetOp () const
bool isCallResult () const
mlir::FailureOr< function::CallOpgetCallOp () const
mlir::FailureOr< llvm::DynamicAPInt > getConstantFeltValue () const
mlir::FailureOr< llvm::DynamicAPInt > getConstantIndexValue () const
mlir::FailureOr< llvm::DynamicAPInt > getConstantValue () const
bool isValidPrefix (const SourceRef &prefix) const
 Returns true iff prefix is a valid prefix of this reference.
bool overlaps (const SourceRef &rhs) const
 Return true when both references select overlapping storage at the same path depth.
mlir::FailureOr< std::vector< SourceRefIndex > > getSuffix (const SourceRef &prefix) const
 If prefix is a valid prefix of this reference, return the suffix that remains after removing the prefix.
mlir::FailureOr< SourceReftranslate (const SourceRef &prefix, const SourceRef &other) const
 Create a new reference with prefix replaced with other iff prefix is a valid prefix for this reference.
mlir::FailureOr< SourceRefgetParentPrefix () const
 Create a new reference that is the immediate prefix of this reference if possible.
std::vector< SourceRefgetAllChildren (mlir::SymbolTableCollection &tables, mlir::ModuleOp mod) const
 Get all direct children of this SourceRef, assuming this ref is not a scalar.
mlir::FailureOr< SourceRefcreateChild (const SourceRefIndex &r) const
mlir::FailureOr< SourceRefcreateChild (const SourceRef &other) const
llvm::ArrayRef< SourceRefIndexgetPieces () const
llvm::ArrayRef< SourceRefIndexgetPath () const
void print (mlir::raw_ostream &os) const
void dump () const
bool operator== (const SourceRef &rhs) const
bool operator!= (const SourceRef &rhs) const
std::strong_ordering operator<=> (const SourceRef &rhs) const

Static Public Member Functions

static std::vector< SourceRefgetAllSourceRefs (mlir::SymbolTableCollection &tables, mlir::ModuleOp mod, const SourceRef &root)
 Produce all possible SourceRefs that are present starting from the given root.
static std::vector< SourceRefgetAllSourceRefs (component::StructDefOp structDef, function::FuncDefOp fnOp)
 Produce all possible SourceRefs that are present from given struct function.
static std::vector< SourceRefgetAllSourceRefs (component::StructDefOp structDef, component::MemberDefOp memberDef)
 Produce all possible SourceRefs from a specific member in a struct.

Friends

struct llvm::DenseMapInfo< SourceRef >

Detailed Description

A reference to a "source", which is the base value from which other SSA values are derived.

The object may be a reference to an individual felt, felt.const, or a composite type, like an array or an entire struct.

  • SourceRefs are allowed to reference composite types so that references can be generated for intermediate operations (e.g., readm to read a nested struct).

These references are relative to a particular function call, so they are either (1) constants, or (2) rooted at a value (e.g., self, a nondet op, an external call result, an array.new result, an array.read result, or another block argument), and optionally contain indices into root (e.g., a member reference in a struct or a index into an array).

Definition at line 146 of file SourceRef.h.

Member Typedef Documentation

◆ Path

using llzk::SourceRef::Path = std::vector<SourceRefIndex>

Definition at line 148 of file SourceRef.h.

Constructor & Destructor Documentation

◆ SourceRef() [1/7]

llzk::SourceRef::SourceRef ( mlir::BlockArgument b,
Path p = {} )
inline

Definition at line 215 of file SourceRef.h.

◆ SourceRef() [2/7]

llzk::SourceRef::SourceRef ( component::CreateStructOp createOp,
Path p = {} )
inline

Definition at line 217 of file SourceRef.h.

◆ SourceRef() [3/7]

llzk::SourceRef::SourceRef ( NonDetOp nondet,
Path p = {} )
inline

Definition at line 219 of file SourceRef.h.

◆ SourceRef() [4/7]

llzk::SourceRef::SourceRef ( mlir::OpResult rootResult,
Path p = {} )
inline

Definition at line 221 of file SourceRef.h.

◆ SourceRef() [5/7]

llzk::SourceRef::SourceRef ( felt::FeltConstantOp c)
inlineexplicit

Definition at line 226 of file SourceRef.h.

◆ SourceRef() [6/7]

llzk::SourceRef::SourceRef ( mlir::arith::ConstantIndexOp c)
inlineexplicit

Definition at line 228 of file SourceRef.h.

◆ SourceRef() [7/7]

llzk::SourceRef::SourceRef ( polymorphic::ConstReadOp c)
inlineexplicit

Definition at line 230 of file SourceRef.h.

Member Function Documentation

◆ createChild() [1/2]

mlir::FailureOr< SourceRef > llzk::SourceRef::createChild ( const SourceRef & other) const
inline

Definition at line 366 of file SourceRef.h.

◆ createChild() [2/2]

mlir::FailureOr< SourceRef > llzk::SourceRef::createChild ( const SourceRefIndex & r) const
inline

Definition at line 357 of file SourceRef.h.

◆ dump()

void llzk::SourceRef::dump ( ) const
inline

Definition at line 382 of file SourceRef.h.

◆ getAllChildren()

std::vector< SourceRef > llzk::SourceRef::getAllChildren ( mlir::SymbolTableCollection & tables,
mlir::ModuleOp mod ) const

Get all direct children of this SourceRef, assuming this ref is not a scalar.

Definition at line 480 of file SourceRef.cpp.

◆ getAllSourceRefs() [1/3]

std::vector< SourceRef > llzk::SourceRef::getAllSourceRefs ( component::StructDefOp structDef,
component::MemberDefOp memberDef )
static

Produce all possible SourceRefs from a specific member in a struct.

May produce multiple if the given member is of an aggregate type.

Definition at line 323 of file SourceRef.cpp.

◆ getAllSourceRefs() [2/3]

std::vector< SourceRef > llzk::SourceRef::getAllSourceRefs ( component::StructDefOp structDef,
function::FuncDefOp fnOp )
static

Produce all possible SourceRefs that are present from given struct function.

Definition at line 294 of file SourceRef.cpp.

◆ getAllSourceRefs() [3/3]

std::vector< SourceRef > llzk::SourceRef::getAllSourceRefs ( mlir::SymbolTableCollection & tables,
mlir::ModuleOp mod,
const SourceRef & root )
static

Produce all possible SourceRefs that are present starting from the given root.

◆ getBlockArgument()

mlir::FailureOr< mlir::BlockArgument > llzk::SourceRef::getBlockArgument ( ) const
inline

Definition at line 271 of file SourceRef.h.

◆ getCallOp()

mlir::FailureOr< function::CallOp > llzk::SourceRef::getCallOp ( ) const
inline

Definition at line 294 of file SourceRef.h.

◆ getConstant()

mlir::FailureOr< mlir::Value > llzk::SourceRef::getConstant ( ) const
inline

Definition at line 265 of file SourceRef.h.

◆ getConstantFeltValue()

mlir::FailureOr< llvm::DynamicAPInt > llzk::SourceRef::getConstantFeltValue ( ) const
inline

Definition at line 296 of file SourceRef.h.

◆ getConstantIndexValue()

mlir::FailureOr< llvm::DynamicAPInt > llzk::SourceRef::getConstantIndexValue ( ) const
inline

Definition at line 304 of file SourceRef.h.

◆ getConstantValue()

mlir::FailureOr< llvm::DynamicAPInt > llzk::SourceRef::getConstantValue ( ) const
inline

Definition at line 311 of file SourceRef.h.

◆ getCreateStructOp()

mlir::FailureOr< component::CreateStructOp > llzk::SourceRef::getCreateStructOp ( ) const
inline

Definition at line 286 of file SourceRef.h.

◆ getInputNum()

mlir::FailureOr< unsigned > llzk::SourceRef::getInputNum ( ) const
inline

Definition at line 277 of file SourceRef.h.

◆ getNonDetOp()

mlir::FailureOr< NonDetOp > llzk::SourceRef::getNonDetOp ( ) const
inline

Definition at line 291 of file SourceRef.h.

◆ getParentPrefix()

mlir::FailureOr< SourceRef > llzk::SourceRef::getParentPrefix ( ) const
inline

Create a new reference that is the immediate prefix of this reference if possible.

Definition at line 344 of file SourceRef.h.

◆ getPath()

llvm::ArrayRef< SourceRefIndex > llzk::SourceRef::getPath ( ) const
inline

Definition at line 379 of file SourceRef.h.

◆ getPieces()

llvm::ArrayRef< SourceRefIndex > llzk::SourceRef::getPieces ( ) const
inline

Definition at line 376 of file SourceRef.h.

◆ getRoot()

mlir::FailureOr< mlir::Value > llzk::SourceRef::getRoot ( ) const
inline

Definition at line 259 of file SourceRef.h.

◆ getSuffix()

FailureOr< SourceRef::Path > llzk::SourceRef::getSuffix ( const SourceRef & prefix) const

If prefix is a valid prefix of this reference, return the suffix that remains after removing the prefix.

I.e., this = prefix + suffix

Parameters
prefix
Returns
the suffix

Definition at line 396 of file SourceRef.cpp.

◆ getType()

Type llzk::SourceRef::getType ( ) const

Definition at line 342 of file SourceRef.cpp.

◆ isBlockArgument()

bool llzk::SourceRef::isBlockArgument ( ) const
inline

Definition at line 258 of file SourceRef.h.

◆ isCallResult()

bool llzk::SourceRef::isCallResult ( ) const
inline

Definition at line 293 of file SourceRef.h.

◆ isConstant()

bool llzk::SourceRef::isConstant ( ) const
inline

Definition at line 246 of file SourceRef.h.

◆ isConstantFelt()

bool llzk::SourceRef::isConstantFelt ( ) const
inline

Definition at line 235 of file SourceRef.h.

◆ isConstantIndex()

bool llzk::SourceRef::isConstantIndex ( ) const
inline

Definition at line 238 of file SourceRef.h.

◆ isConstantInt()

bool llzk::SourceRef::isConstantInt ( ) const
inline

Definition at line 247 of file SourceRef.h.

◆ isCreateStructOp()

bool llzk::SourceRef::isCreateStructOp ( ) const
inline

Definition at line 285 of file SourceRef.h.

◆ isFeltVal()

bool llzk::SourceRef::isFeltVal ( ) const
inline

Definition at line 249 of file SourceRef.h.

◆ isIndexVal()

bool llzk::SourceRef::isIndexVal ( ) const
inline

Definition at line 250 of file SourceRef.h.

◆ isIntegerVal()

bool llzk::SourceRef::isIntegerVal ( ) const
inline

Definition at line 251 of file SourceRef.h.

◆ isNonDetOp()

bool llzk::SourceRef::isNonDetOp ( ) const
inline

Definition at line 290 of file SourceRef.h.

◆ isRooted()

bool llzk::SourceRef::isRooted ( ) const
inline

Definition at line 257 of file SourceRef.h.

◆ isScalar()

bool llzk::SourceRef::isScalar ( ) const
inline

Definition at line 253 of file SourceRef.h.

◆ isTemplateConstant()

bool llzk::SourceRef::isTemplateConstant ( ) const
inline

Definition at line 242 of file SourceRef.h.

◆ isTypeVarVal()

bool llzk::SourceRef::isTypeVarVal ( ) const
inline

Definition at line 252 of file SourceRef.h.

◆ isValidPrefix()

bool llzk::SourceRef::isValidPrefix ( const SourceRef & prefix) const

Returns true iff prefix is a valid prefix of this reference.

Definition at line 369 of file SourceRef.cpp.

◆ operator!=()

bool llzk::SourceRef::operator!= ( const SourceRef & rhs) const
inline

Definition at line 386 of file SourceRef.h.

◆ operator<=>()

std::strong_ordering llzk::SourceRef::operator<=> ( const SourceRef & rhs) const

Definition at line 611 of file SourceRef.cpp.

◆ operator==()

bool llzk::SourceRef::operator== ( const SourceRef & rhs) const

Definition at line 601 of file SourceRef.cpp.

◆ overlaps()

bool llzk::SourceRef::overlaps ( const SourceRef & rhs) const

Return true when both references select overlapping storage at the same path depth.

Definition at line 387 of file SourceRef.cpp.

◆ print()

void llzk::SourceRef::print ( mlir::raw_ostream & os) const

Definition at line 550 of file SourceRef.cpp.

◆ translate()

FailureOr< SourceRef > llzk::SourceRef::translate ( const SourceRef & prefix,
const SourceRef & other ) const

Create a new reference with prefix replaced with other iff prefix is a valid prefix for this reference.

If this reference is a felt.const, the translation will always succeed and return the felt.const unchanged.

Parameters
prefix
other
Returns

Definition at line 410 of file SourceRef.cpp.

◆ llvm::DenseMapInfo< SourceRef >

friend struct llvm::DenseMapInfo< SourceRef >
friend

Definition at line 389 of file SourceRef.h.


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