LLZK 2.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.
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 132 of file SourceRef.h.

Member Typedef Documentation

◆ Path

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

Definition at line 134 of file SourceRef.h.

Constructor & Destructor Documentation

◆ SourceRef() [1/7]

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

Definition at line 201 of file SourceRef.h.

◆ SourceRef() [2/7]

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

Definition at line 202 of file SourceRef.h.

◆ SourceRef() [3/7]

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

Definition at line 204 of file SourceRef.h.

◆ SourceRef() [4/7]

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

Definition at line 206 of file SourceRef.h.

◆ SourceRef() [5/7]

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

Definition at line 211 of file SourceRef.h.

◆ SourceRef() [6/7]

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

Definition at line 213 of file SourceRef.h.

◆ SourceRef() [7/7]

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

Definition at line 215 of file SourceRef.h.

Member Function Documentation

◆ createChild() [1/2]

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

Definition at line 348 of file SourceRef.h.

◆ createChild() [2/2]

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

Definition at line 339 of file SourceRef.h.

◆ dump()

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

Definition at line 364 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 411 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 272 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 243 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 256 of file SourceRef.h.

◆ getCallOp()

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

Definition at line 279 of file SourceRef.h.

◆ getConstant()

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

Definition at line 250 of file SourceRef.h.

◆ getConstantFeltValue()

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

Definition at line 281 of file SourceRef.h.

◆ getConstantIndexValue()

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

Definition at line 289 of file SourceRef.h.

◆ getConstantValue()

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

Definition at line 296 of file SourceRef.h.

◆ getCreateStructOp()

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

Definition at line 271 of file SourceRef.h.

◆ getInputNum()

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

Definition at line 262 of file SourceRef.h.

◆ getNonDetOp()

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

Definition at line 276 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 326 of file SourceRef.h.

◆ getPath()

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

Definition at line 361 of file SourceRef.h.

◆ getPieces()

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

Definition at line 358 of file SourceRef.h.

◆ getRoot()

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

Definition at line 244 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 337 of file SourceRef.cpp.

◆ getType()

Type llzk::SourceRef::getType ( ) const

Definition at line 291 of file SourceRef.cpp.

◆ isBlockArgument()

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

Definition at line 243 of file SourceRef.h.

◆ isCallResult()

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

Definition at line 278 of file SourceRef.h.

◆ isConstant()

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

Definition at line 231 of file SourceRef.h.

◆ isConstantFelt()

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

Definition at line 220 of file SourceRef.h.

◆ isConstantIndex()

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

Definition at line 223 of file SourceRef.h.

◆ isConstantInt()

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

Definition at line 232 of file SourceRef.h.

◆ isCreateStructOp()

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

Definition at line 270 of file SourceRef.h.

◆ isFeltVal()

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

Definition at line 234 of file SourceRef.h.

◆ isIndexVal()

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

Definition at line 235 of file SourceRef.h.

◆ isIntegerVal()

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

Definition at line 236 of file SourceRef.h.

◆ isNonDetOp()

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

Definition at line 275 of file SourceRef.h.

◆ isRooted()

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

Definition at line 242 of file SourceRef.h.

◆ isScalar()

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

Definition at line 238 of file SourceRef.h.

◆ isTemplateConstant()

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

Definition at line 227 of file SourceRef.h.

◆ isTypeVarVal()

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

Definition at line 237 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 319 of file SourceRef.cpp.

◆ operator!=()

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

Definition at line 368 of file SourceRef.h.

◆ operator<=>()

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

Definition at line 475 of file SourceRef.cpp.

◆ operator==()

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

Definition at line 465 of file SourceRef.cpp.

◆ print()

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

Definition at line 422 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 351 of file SourceRef.cpp.

◆ llvm::DenseMapInfo< SourceRef >

friend struct llvm::DenseMapInfo< SourceRef >
friend

Definition at line 371 of file SourceRef.h.


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