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 (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 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
 
mlir::APInt getConstantFeltValue () const
 
mlir::APInt getConstantIndexValue () const
 
mlir::APInt getConstantInt () 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.
 
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 (component::StructDefOp structDef)
 Produce all possible ConstraintRefs that are present from the struct's constrain function.
 

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 111 of file ConstrainRef.h.

Constructor & Destructor Documentation

◆ ConstrainRef() [1/5]

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

Definition at line 142 of file ConstrainRef.h.

◆ ConstrainRef() [2/5]

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

Definition at line 144 of file ConstrainRef.h.

◆ ConstrainRef() [3/5]

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

Definition at line 146 of file ConstrainRef.h.

◆ ConstrainRef() [4/5]

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

Definition at line 147 of file ConstrainRef.h.

◆ ConstrainRef() [5/5]

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 234 of file ConstrainRef.h.

◆ createChild() [2/2]

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

Definition at line 228 of file ConstrainRef.h.

◆ dump()

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

Definition at line 244 of file ConstrainRef.h.

◆ getAllConstrainRefs()

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

Produce all possible ConstraintRefs that are present from the struct's constrain function.

Definition at line 183 of file ConstrainRef.cpp.

◆ getBlockArgument()

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

Definition at line 177 of file ConstrainRef.h.

◆ getConstantFeltValue()

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

Definition at line 183 of file ConstrainRef.h.

◆ getConstantIndexValue()

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

Definition at line 187 of file ConstrainRef.h.

◆ getConstantInt()

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

Definition at line 191 of file ConstrainRef.h.

◆ getInputNum()

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

Definition at line 181 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.

Returns

Definition at line 219 of file ConstrainRef.h.

◆ getPieces()

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

Definition at line 241 of file ConstrainRef.h.

◆ getSuffix()

mlir::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 249 of file ConstrainRef.cpp.

◆ getType()

mlir::Type llzk::ConstrainRef::getType ( ) const

Definition at line 205 of file ConstrainRef.cpp.

◆ isBlockArgument()

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

Definition at line 176 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.

◆ isFeltVal()

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

Definition at line 167 of file ConstrainRef.h.

◆ isIndexVal()

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

Definition at line 168 of file ConstrainRef.h.

◆ isIntegerVal()

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

Definition at line 169 of file ConstrainRef.h.

◆ isScalar()

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

Definition at line 171 of file ConstrainRef.h.

◆ isSignal()

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

Definition at line 174 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 170 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 233 of file ConstrainRef.cpp.

◆ operator!=()

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

Definition at line 248 of file ConstrainRef.h.

◆ operator<()

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

Definition at line 301 of file ConstrainRef.cpp.

◆ operator==()

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

Definition at line 295 of file ConstrainRef.cpp.

◆ operator>()

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

Definition at line 253 of file ConstrainRef.h.

◆ print()

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

Definition at line 276 of file ConstrainRef.cpp.

◆ translate()

mlir::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 262 of file ConstrainRef.cpp.


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