LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
llzk::ConstrainRef Class Reference

Defines a reference to a llzk object within a constrain function call. More...

#include <ConstrainRef.h>

Classes

struct  Hash
 

Public Member Functions

 ConstrainRef (mlir::BlockArgument b)
 
 ConstrainRef (mlir::BlockArgument b, std::vector< ConstrainRefIndex > f)
 
 ConstrainRef (component::CreateStructOp createOp)
 
 ConstrainRef (component::CreateStructOp createOp, std::vector< ConstrainRefIndex > f)
 
 ConstrainRef (felt::FeltConstantOp c)
 
 ConstrainRef (mlir::arith::ConstantIndexOp c)
 
 ConstrainRef (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
 
mlir::APInt getConstantFeltValue () const
 
mlir::APInt getConstantIndexValue () const
 
mlir::APInt getConstantValue () const
 
bool isValidPrefix (const ConstrainRef &prefix) const
 Returns true iff prefix is a valid prefix of this reference.
 
mlir::FailureOr< std::vector< ConstrainRefIndex > > getSuffix (const ConstrainRef &prefix) const
 If prefix is a valid prefix of this reference, return the suffix that remains after removing the prefix.
 
mlir::FailureOr< ConstrainReftranslate (const ConstrainRef &prefix, const ConstrainRef &other) const
 Create a new reference with prefix replaced with other iff prefix is a valid prefix for this reference.
 
mlir::FailureOr< ConstrainRefgetParentPrefix () const
 Create a new reference that is the immediate prefix of this reference if possible.
 
std::vector< ConstrainRefgetAllChildren (mlir::SymbolTableCollection &tables, mlir::ModuleOp mod) const
 Get all direct children of this ConstrainRef, assuming this ref is not a scalar.
 
ConstrainRef createChild (ConstrainRefIndex r) const
 
ConstrainRef createChild (ConstrainRef other) const
 
const std::vector< ConstrainRefIndex > & getPieces () const
 
void print (mlir::raw_ostream &os) const
 
void dump () const
 
bool operator== (const ConstrainRef &rhs) const
 
bool operator!= (const ConstrainRef &rhs) const
 
bool operator< (const ConstrainRef &rhs) const
 
bool operator> (const ConstrainRef &rhs) const
 

Static Public Member Functions

static std::vector< ConstrainRefgetAllConstrainRefs (mlir::SymbolTableCollection &tables, mlir::ModuleOp mod, ConstrainRef root)
 Produce all possible ConstraintRefs that are present starting from the given root.
 
static std::vector< ConstrainRefgetAllConstrainRefs (component::StructDefOp structDef, function::FuncDefOp fnOp)
 Produce all possible ConstrainRefs that are present from given struct function.
 
static std::vector< ConstrainRefgetAllConstrainRefs (component::StructDefOp structDef, component::FieldDefOp fieldDef)
 Produce all possible ConstrainRefs from a specific field in a struct.
 

Detailed Description

Defines a reference to a llzk object within a constrain function call.

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

  • ConstrainRefs 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 constrain call, so they are either (1) constants, or (2) rooted at a block argument (which is either "self" 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 121 of file ConstrainRef.h.

Constructor & Destructor Documentation

◆ ConstrainRef() [1/7]

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

Definition at line 137 of file ConstrainRef.h.

◆ ConstrainRef() [2/7]

llzk::ConstrainRef::ConstrainRef ( mlir::BlockArgument b,
std::vector< ConstrainRefIndex > f )
inline

Definition at line 138 of file ConstrainRef.h.

◆ ConstrainRef() [3/7]

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

Definition at line 141 of file ConstrainRef.h.

◆ ConstrainRef() [4/7]

llzk::ConstrainRef::ConstrainRef ( component::CreateStructOp createOp,
std::vector< ConstrainRefIndex > f )
inline

Definition at line 143 of file ConstrainRef.h.

◆ ConstrainRef() [5/7]

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

Definition at line 146 of file ConstrainRef.h.

◆ ConstrainRef() [6/7]

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

Definition at line 147 of file ConstrainRef.h.

◆ ConstrainRef() [7/7]

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

Definition at line 149 of file ConstrainRef.h.

Member Function Documentation

◆ createChild() [1/2]

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

Definition at line 248 of file ConstrainRef.h.

◆ createChild() [2/2]

ConstrainRef llzk::ConstrainRef::createChild ( ConstrainRefIndex r) const
inline

Definition at line 242 of file ConstrainRef.h.

◆ dump()

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

Definition at line 256 of file ConstrainRef.h.

◆ getAllChildren()

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

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

Definition at line 282 of file ConstrainRef.cpp.

◆ getAllConstrainRefs() [1/3]

std::vector< ConstrainRef > llzk::ConstrainRef::getAllConstrainRefs ( component::StructDefOp structDef,
component::FieldDefOp fieldDef )
static

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

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

Definition at line 151 of file ConstrainRef.cpp.

◆ getAllConstrainRefs() [2/3]

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

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

Definition at line 121 of file ConstrainRef.cpp.

◆ getAllConstrainRefs() [3/3]

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

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

◆ getBlockArgument()

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

Definition at line 180 of file ConstrainRef.h.

◆ getConstantFeltValue()

mlir::APInt llzk::ConstrainRef::getConstantFeltValue ( ) const
inline

Definition at line 194 of file ConstrainRef.h.

◆ getConstantIndexValue()

mlir::APInt llzk::ConstrainRef::getConstantIndexValue ( ) const
inline

Definition at line 198 of file ConstrainRef.h.

◆ getConstantValue()

mlir::APInt llzk::ConstrainRef::getConstantValue ( ) const
inline

Definition at line 202 of file ConstrainRef.h.

◆ getCreateStructOp()

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

Definition at line 189 of file ConstrainRef.h.

◆ getInputNum()

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

Definition at line 184 of file ConstrainRef.h.

◆ getParentPrefix()

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

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

Definition at line 229 of file ConstrainRef.h.

◆ getPieces()

const std::vector< ConstrainRefIndex > & llzk::ConstrainRef::getPieces ( ) const
inline

Definition at line 253 of file ConstrainRef.h.

◆ getSuffix()

FailureOr< std::vector< ConstrainRefIndex > > llzk::ConstrainRef::getSuffix ( const ConstrainRef & 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 216 of file ConstrainRef.cpp.

◆ getType()

Type llzk::ConstrainRef::getType ( ) const

Definition at line 170 of file ConstrainRef.cpp.

◆ isBlockArgument()

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

Definition at line 177 of file ConstrainRef.h.

◆ isConstant()

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

Definition at line 165 of file ConstrainRef.h.

◆ isConstantFelt()

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

Definition at line 154 of file ConstrainRef.h.

◆ isConstantIndex()

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

Definition at line 157 of file ConstrainRef.h.

◆ isConstantInt()

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

Definition at line 166 of file ConstrainRef.h.

◆ isCreateStructOp()

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

Definition at line 186 of file ConstrainRef.h.

◆ isFeltVal()

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

Definition at line 168 of file ConstrainRef.h.

◆ isIndexVal()

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

Definition at line 169 of file ConstrainRef.h.

◆ isIntegerVal()

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

Definition at line 170 of file ConstrainRef.h.

◆ isScalar()

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

Definition at line 172 of file ConstrainRef.h.

◆ isSignal()

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

Definition at line 175 of file ConstrainRef.h.

◆ isTemplateConstant()

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

Definition at line 161 of file ConstrainRef.h.

◆ isTypeVarVal()

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

Definition at line 171 of file ConstrainRef.h.

◆ isValidPrefix()

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

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

Definition at line 200 of file ConstrainRef.cpp.

◆ operator!=()

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

Definition at line 260 of file ConstrainRef.h.

◆ operator<()

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

Definition at line 327 of file ConstrainRef.cpp.

◆ operator==()

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

Definition at line 317 of file ConstrainRef.cpp.

◆ operator>()

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

Definition at line 265 of file ConstrainRef.h.

◆ print()

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

Definition at line 293 of file ConstrainRef.cpp.

◆ translate()

FailureOr< ConstrainRef > llzk::ConstrainRef::translate ( const ConstrainRef & prefix,
const ConstrainRef & 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 229 of file ConstrainRef.cpp.


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