LLZK 0.1.0
Veridise's ZK Language IR
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 Member Functions

 SourceRef (mlir::BlockArgument b)
 SourceRef (mlir::BlockArgument b, std::vector< SourceRefIndex > f)
 SourceRef (component::CreateStructOp createOp)
 SourceRef (component::CreateStructOp createOp, std::vector< SourceRefIndex > f)
 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 isSignal () const
bool isBlockArgument () const
mlir::BlockArgument getBlockArgument () const
unsigned getInputNum () const
bool isCreateStructOp () const
component::CreateStructOp getCreateStructOp () const
llvm::DynamicAPInt getConstantFeltValue () const
llvm::DynamicAPInt getConstantIndexValue () const
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.
SourceRef createChild (SourceRefIndex r) const
SourceRef createChild (SourceRef other) const
const std::vector< SourceRefIndex > & getPieces () const
void print (mlir::raw_ostream &os) const
void dump () const
bool operator== (const SourceRef &rhs) const
bool operator!= (const SourceRef &rhs) const
bool operator< (const SourceRef &rhs) const
bool operator> (const SourceRef &rhs) const

Static Public Member Functions

static std::vector< SourceRefgetAllSourceRefs (mlir::SymbolTableCollection &tables, mlir::ModuleOp mod, 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::FieldDefOp fieldDef)
 Produce all possible SourceRefs from a specific field in a struct.

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., readf 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 block argument (which is either "self" in @constrain functions or another input) and optionally contain indices into that block argument (e.g., a field reference in a struct or a index into an array).

Definition at line 127 of file SourceRef.h.

Constructor & Destructor Documentation

◆ SourceRef() [1/7]

llzk::SourceRef::SourceRef ( mlir::BlockArgument b)
inlineexplicit

Definition at line 143 of file SourceRef.h.

◆ SourceRef() [2/7]

llzk::SourceRef::SourceRef ( mlir::BlockArgument b,
std::vector< SourceRefIndex > f )
inline

Definition at line 144 of file SourceRef.h.

◆ SourceRef() [3/7]

llzk::SourceRef::SourceRef ( component::CreateStructOp createOp)
inlineexplicit

Definition at line 147 of file SourceRef.h.

◆ SourceRef() [4/7]

llzk::SourceRef::SourceRef ( component::CreateStructOp createOp,
std::vector< SourceRefIndex > f )
inline

Definition at line 149 of file SourceRef.h.

◆ SourceRef() [5/7]

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

Definition at line 152 of file SourceRef.h.

◆ SourceRef() [6/7]

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

Definition at line 153 of file SourceRef.h.

◆ SourceRef() [7/7]

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

Definition at line 155 of file SourceRef.h.

Member Function Documentation

◆ createChild() [1/2]

SourceRef llzk::SourceRef::createChild ( SourceRef other) const
inline

Definition at line 258 of file SourceRef.h.

◆ createChild() [2/2]

SourceRef llzk::SourceRef::createChild ( SourceRefIndex r) const
inline

Definition at line 252 of file SourceRef.h.

◆ dump()

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

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

◆ getAllSourceRefs() [1/3]

std::vector< SourceRef > llzk::SourceRef::getAllSourceRefs ( component::StructDefOp structDef,
component::FieldDefOp fieldDef )
static

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

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

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

◆ getAllSourceRefs() [3/3]

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

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

◆ getBlockArgument()

mlir::BlockArgument llzk::SourceRef::getBlockArgument ( ) const
inline

Definition at line 186 of file SourceRef.h.

◆ getConstantFeltValue()

llvm::DynamicAPInt llzk::SourceRef::getConstantFeltValue ( ) const
inline

Definition at line 200 of file SourceRef.h.

◆ getConstantIndexValue()

llvm::DynamicAPInt llzk::SourceRef::getConstantIndexValue ( ) const
inline

Definition at line 207 of file SourceRef.h.

◆ getConstantValue()

llvm::DynamicAPInt llzk::SourceRef::getConstantValue ( ) const
inline

Definition at line 213 of file SourceRef.h.

◆ getCreateStructOp()

component::CreateStructOp llzk::SourceRef::getCreateStructOp ( ) const
inline

Definition at line 195 of file SourceRef.h.

◆ getInputNum()

unsigned llzk::SourceRef::getInputNum ( ) const
inline

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

◆ getPieces()

const std::vector< SourceRefIndex > & llzk::SourceRef::getPieces ( ) const
inline

Definition at line 263 of file SourceRef.h.

◆ getSuffix()

FailureOr< std::vector< SourceRefIndex > > 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 214 of file SourceRef.cpp.

◆ getType()

Type llzk::SourceRef::getType ( ) const

Definition at line 168 of file SourceRef.cpp.

◆ isBlockArgument()

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

Definition at line 183 of file SourceRef.h.

◆ isConstant()

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

Definition at line 171 of file SourceRef.h.

◆ isConstantFelt()

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

Definition at line 160 of file SourceRef.h.

◆ isConstantIndex()

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

Definition at line 163 of file SourceRef.h.

◆ isConstantInt()

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

Definition at line 172 of file SourceRef.h.

◆ isCreateStructOp()

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

Definition at line 192 of file SourceRef.h.

◆ isFeltVal()

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

Definition at line 174 of file SourceRef.h.

◆ isIndexVal()

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

Definition at line 175 of file SourceRef.h.

◆ isIntegerVal()

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

Definition at line 176 of file SourceRef.h.

◆ isScalar()

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

Definition at line 178 of file SourceRef.h.

◆ isSignal()

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

Definition at line 181 of file SourceRef.h.

◆ isTemplateConstant()

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

Definition at line 167 of file SourceRef.h.

◆ isTypeVarVal()

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

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

◆ operator!=()

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

Definition at line 270 of file SourceRef.h.

◆ operator<()

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

Definition at line 323 of file SourceRef.cpp.

◆ operator==()

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

Definition at line 313 of file SourceRef.cpp.

◆ operator>()

bool llzk::SourceRef::operator> ( const SourceRef & rhs) const
inline

Definition at line 275 of file SourceRef.h.

◆ print()

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

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


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