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 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.
 
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 ConstrainRefs that are present from the struct's constrain 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 117 of file ConstrainRef.h.

Constructor & Destructor Documentation

◆ ConstrainRef() [1/5]

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

Definition at line 155 of file ConstrainRef.h.

◆ ConstrainRef() [2/5]

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

Definition at line 157 of file ConstrainRef.h.

◆ ConstrainRef() [3/5]

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

Definition at line 159 of file ConstrainRef.h.

◆ ConstrainRef() [4/5]

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

Definition at line 160 of file ConstrainRef.h.

◆ ConstrainRef() [5/5]

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

Definition at line 162 of file ConstrainRef.h.

Member Function Documentation

◆ createChild() [1/2]

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

Definition at line 247 of file ConstrainRef.h.

◆ createChild() [2/2]

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

Definition at line 241 of file ConstrainRef.h.

◆ dump()

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

Definition at line 257 of file ConstrainRef.h.

◆ getAllConstrainRefs() [1/2]

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

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

Definition at line 197 of file ConstrainRef.cpp.

◆ getAllConstrainRefs() [2/2]

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 217 of file ConstrainRef.cpp.

◆ getBlockArgument()

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

Definition at line 190 of file ConstrainRef.h.

◆ getConstantFeltValue()

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

Definition at line 196 of file ConstrainRef.h.

◆ getConstantIndexValue()

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

Definition at line 200 of file ConstrainRef.h.

◆ getConstantValue()

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

Definition at line 204 of file ConstrainRef.h.

◆ getInputNum()

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

Definition at line 194 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 232 of file ConstrainRef.h.

◆ getPieces()

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

Definition at line 254 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 282 of file ConstrainRef.cpp.

◆ getType()

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

Definition at line 238 of file ConstrainRef.cpp.

◆ isBlockArgument()

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

Definition at line 189 of file ConstrainRef.h.

◆ isConstant()

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

Definition at line 178 of file ConstrainRef.h.

◆ isConstantFelt()

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

Definition at line 167 of file ConstrainRef.h.

◆ isConstantIndex()

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

Definition at line 170 of file ConstrainRef.h.

◆ isFeltVal()

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

Definition at line 180 of file ConstrainRef.h.

◆ isIndexVal()

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

Definition at line 181 of file ConstrainRef.h.

◆ isIntegerVal()

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

Definition at line 182 of file ConstrainRef.h.

◆ isScalar()

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

Definition at line 184 of file ConstrainRef.h.

◆ isSignal()

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

Definition at line 187 of file ConstrainRef.h.

◆ isTemplateConstant()

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

Definition at line 174 of file ConstrainRef.h.

◆ isTypeVarVal()

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

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

◆ operator!=()

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

Definition at line 261 of file ConstrainRef.h.

◆ operator<()

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

Definition at line 334 of file ConstrainRef.cpp.

◆ operator==()

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

Definition at line 328 of file ConstrainRef.cpp.

◆ operator>()

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

Definition at line 266 of file ConstrainRef.h.

◆ print()

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

Definition at line 309 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 295 of file ConstrainRef.cpp.


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