LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches

Builds out a LLZK-compliant module and provides utilities for populating that module. More...

#include <Builders.h>

Public Member Functions

 ModuleBuilder (mlir::ModuleOp m)
mlir::Location getUnknownLoc ()
ModuleBuilderinsertEmptyStruct (std::string_view structName, mlir::Location loc, int numStructParams=-1)
ModuleBuilderinsertEmptyStruct (std::string_view structName, int numStructParams=-1)
ModuleBuilderinsertComputeOnlyStruct (std::string_view structName, mlir::Location structLoc, mlir::Location computeLoc)
ModuleBuilderinsertComputeOnlyStruct (std::string_view structName)
ModuleBuilderinsertConstrainOnlyStruct (std::string_view structName, mlir::Location structLoc, mlir::Location constrainLoc)
ModuleBuilderinsertConstrainOnlyStruct (std::string_view structName)
ModuleBuilderinsertFullStruct (std::string_view structName, mlir::Location structLoc, mlir::Location computeLoc, mlir::Location constrainLoc, int numStructParams=-1)
ModuleBuilderinsertFullStruct (std::string_view structName, int numStructParams=-1)
 Inserts a struct with both compute and constrain functions.
ModuleBuilderinsertProductStruct (std::string_view structName, mlir::Location structLoc, mlir::Location productLoc)
ModuleBuilderinsertProductStruct (std::string_view structName)
ModuleBuilderinsertComputeFn (component::StructDefOp op, mlir::Location loc)
ModuleBuilderinsertComputeFn (std::string_view structName, mlir::Location loc)
ModuleBuilderinsertComputeFn (std::string_view structName)
ModuleBuilderinsertConstrainFn (component::StructDefOp op, mlir::Location loc)
ModuleBuilderinsertConstrainFn (std::string_view structName, mlir::Location loc)
ModuleBuilderinsertConstrainFn (std::string_view structName)
ModuleBuilderinsertProductFn (component::StructDefOp op, mlir::Location loc)
ModuleBuilderinsertProductFn (std::string_view structName, mlir::Location loc)
ModuleBuilderinsertProductFn (std::string_view structName)
ModuleBuilderinsertComputeCall (component::StructDefOp caller, component::StructDefOp callee, mlir::Location callLoc)
 Only requirement for compute is the call itself.
ModuleBuilderinsertComputeCall (std::string_view caller, std::string_view callee, mlir::Location callLoc)
ModuleBuilderinsertComputeCall (std::string_view caller, std::string_view callee)
ModuleBuilderinsertConstrainCall (component::StructDefOp caller, component::StructDefOp callee, mlir::Location callLoc, mlir::Location fieldDefLoc)
 To call a constraint function, you must:
ModuleBuilderinsertConstrainCall (std::string_view caller, std::string_view callee, mlir::Location callLoc, mlir::Location fieldDefLoc)
ModuleBuilderinsertConstrainCall (std::string_view caller, std::string_view callee)
ModuleBuilderinsertFreeFunc (std::string_view funcName, ::mlir::FunctionType type, mlir::Location loc)
ModuleBuilderinsertFreeFunc (std::string_view funcName, ::mlir::FunctionType type)
ModuleBuilderinsertFreeCall (function::FuncDefOp caller, std::string_view callee, mlir::Location callLoc)
ModuleBuilderinsertFreeCall (function::FuncDefOp caller, std::string_view callee)
mlir::ModuleOp & getRootModule ()
 Get the top-level LLZK module.
mlir::FailureOr< component::StructDefOpgetStruct (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetComputeFn (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetComputeFn (component::StructDefOp op) const
mlir::FailureOr< function::FuncDefOpgetConstrainFn (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetConstrainFn (component::StructDefOp op) const
mlir::FailureOr< function::FuncDefOpgetProductFn (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetProductFn (component::StructDefOp op) const
mlir::FailureOr< function::FuncDefOpgetFreeFunc (std::string_view funcName) const
mlir::FailureOr< function::FuncDefOpgetFunc (function::FunctionKind kind, std::string_view name) const
bool computeReachable (component::StructDefOp caller, component::StructDefOp callee)
 Returns if the callee compute function is reachable by the caller by construction.
bool computeReachable (std::string_view caller, std::string_view callee)
bool constrainReachable (component::StructDefOp caller, component::StructDefOp callee)
 Returns if the callee compute function is reachable by the caller by construction.
bool constrainReachable (std::string_view caller, std::string_view callee)

Static Public Member Functions

static function::FuncDefOp buildComputeFn (component::StructDefOp op, mlir::Location loc)
 compute returns the type of the struct that defines it.
static function::FuncDefOp buildConstrainFn (component::StructDefOp op, mlir::Location loc)
 constrain accepts the struct type as the first argument.
static function::FuncDefOp buildProductFn (component::StructDefOp op, mlir::Location loc)
 product returns the type of the struct that defines it.

Detailed Description

Builds out a LLZK-compliant module and provides utilities for populating that module.

This class is designed to be used by front-ends looking to generate LLZK IR programmatically and is also a useful unit testing facility. TODO: this is a WIP, flesh this class out as needed.

Definition at line 41 of file Builders.h.

Constructor & Destructor Documentation

◆ ModuleBuilder()

llzk::ModuleBuilder::ModuleBuilder ( mlir::ModuleOp m)
inline

Definition at line 43 of file Builders.h.

Member Function Documentation

◆ buildComputeFn()

FuncDefOp llzk::ModuleBuilder::buildComputeFn ( component::StructDefOp op,
mlir::Location loc )
static

compute returns the type of the struct that defines it.

Since this is for testing, we accept no arguments.

Definition at line 125 of file Builders.cpp.

◆ buildConstrainFn()

FuncDefOp llzk::ModuleBuilder::buildConstrainFn ( component::StructDefOp op,
mlir::Location loc )
static

constrain accepts the struct type as the first argument.

Definition at line 143 of file Builders.cpp.

◆ buildProductFn()

FuncDefOp llzk::ModuleBuilder::buildProductFn ( component::StructDefOp op,
mlir::Location loc )
static

product returns the type of the struct that defines it.

Since this is for testing, we accept no arguments.

Definition at line 161 of file Builders.cpp.

◆ computeReachable() [1/2]

bool llzk::ModuleBuilder::computeReachable ( component::StructDefOp caller,
component::StructDefOp callee )
inline

Returns if the callee compute function is reachable by the caller by construction.

Definition at line 265 of file Builders.h.

◆ computeReachable() [2/2]

bool llzk::ModuleBuilder::computeReachable ( std::string_view caller,
std::string_view callee )
inline

Definition at line 268 of file Builders.h.

◆ constrainReachable() [1/2]

bool llzk::ModuleBuilder::constrainReachable ( component::StructDefOp caller,
component::StructDefOp callee )
inline

Returns if the callee compute function is reachable by the caller by construction.

Definition at line 275 of file Builders.h.

◆ constrainReachable() [2/2]

bool llzk::ModuleBuilder::constrainReachable ( std::string_view caller,
std::string_view callee )
inline

Definition at line 278 of file Builders.h.

◆ getComputeFn() [1/2]

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getComputeFn ( component::StructDefOp op) const
inline

Definition at line 214 of file Builders.h.

◆ getComputeFn() [2/2]

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getComputeFn ( std::string_view structName) const
inline

Definition at line 208 of file Builders.h.

◆ getConstrainFn() [1/2]

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getConstrainFn ( component::StructDefOp op) const
inline

Definition at line 224 of file Builders.h.

◆ getConstrainFn() [2/2]

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getConstrainFn ( std::string_view structName) const
inline

Definition at line 218 of file Builders.h.

◆ getFreeFunc()

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getFreeFunc ( std::string_view funcName) const
inline

Definition at line 238 of file Builders.h.

◆ getFunc()

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getFunc ( function::FunctionKind kind,
std::string_view name ) const
inline

Definition at line 246 of file Builders.h.

◆ getProductFn() [1/2]

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getProductFn ( component::StructDefOp op) const
inline

Definition at line 234 of file Builders.h.

◆ getProductFn() [2/2]

mlir::FailureOr< function::FuncDefOp > llzk::ModuleBuilder::getProductFn ( std::string_view structName) const
inline

Definition at line 228 of file Builders.h.

◆ getRootModule()

mlir::ModuleOp & llzk::ModuleBuilder::getRootModule ( )
inline

Get the top-level LLZK module.

Definition at line 199 of file Builders.h.

◆ getStruct()

mlir::FailureOr< component::StructDefOp > llzk::ModuleBuilder::getStruct ( std::string_view structName) const
inline

Definition at line 201 of file Builders.h.

◆ getUnknownLoc()

mlir::Location llzk::ModuleBuilder::getUnknownLoc ( )
inline

Definition at line 47 of file Builders.h.

◆ insertComputeCall() [1/3]

ModuleBuilder & llzk::ModuleBuilder::insertComputeCall ( component::StructDefOp caller,
component::StructDefOp callee,
mlir::Location callLoc )

Only requirement for compute is the call itself.

It should also initialize the internal member, but we can ignore those ops for the sake of testing.

◆ insertComputeCall() [2/3]

ModuleBuilder & llzk::ModuleBuilder::insertComputeCall ( std::string_view caller,
std::string_view callee )
inline

Definition at line 160 of file Builders.h.

◆ insertComputeCall() [3/3]

ModuleBuilder & llzk::ModuleBuilder::insertComputeCall ( std::string_view caller,
std::string_view callee,
mlir::Location callLoc )
inline

Definition at line 157 of file Builders.h.

◆ insertComputeFn() [1/3]

ModuleBuilder & llzk::ModuleBuilder::insertComputeFn ( component::StructDefOp op,
mlir::Location loc )

◆ insertComputeFn() [2/3]

ModuleBuilder & llzk::ModuleBuilder::insertComputeFn ( std::string_view structName)
inline

Definition at line 119 of file Builders.h.

◆ insertComputeFn() [3/3]

ModuleBuilder & llzk::ModuleBuilder::insertComputeFn ( std::string_view structName,
mlir::Location loc )
inline

Definition at line 116 of file Builders.h.

◆ insertComputeOnlyStruct() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertComputeOnlyStruct ( std::string_view structName)
inline

Definition at line 63 of file Builders.h.

◆ insertComputeOnlyStruct() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertComputeOnlyStruct ( std::string_view structName,
mlir::Location structLoc,
mlir::Location computeLoc )
inline

Definition at line 55 of file Builders.h.

◆ insertConstrainCall() [1/3]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainCall ( component::StructDefOp caller,
component::StructDefOp callee,
mlir::Location callLoc,
mlir::Location fieldDefLoc )

To call a constraint function, you must:

  1. Add the callee as an internal member of the caller,
  2. Read the callee in the caller's constraint function,
  3. Call the callee's constraint function.

◆ insertConstrainCall() [2/3]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainCall ( std::string_view caller,
std::string_view callee )
inline

Definition at line 180 of file Builders.h.

◆ insertConstrainCall() [3/3]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainCall ( std::string_view caller,
std::string_view callee,
mlir::Location callLoc,
mlir::Location fieldDefLoc )
inline

Definition at line 174 of file Builders.h.

◆ insertConstrainFn() [1/3]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainFn ( component::StructDefOp op,
mlir::Location loc )

◆ insertConstrainFn() [2/3]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainFn ( std::string_view structName)
inline

Definition at line 131 of file Builders.h.

◆ insertConstrainFn() [3/3]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainFn ( std::string_view structName,
mlir::Location loc )
inline

Definition at line 128 of file Builders.h.

◆ insertConstrainOnlyStruct() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainOnlyStruct ( std::string_view structName)
inline

Definition at line 76 of file Builders.h.

◆ insertConstrainOnlyStruct() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertConstrainOnlyStruct ( std::string_view structName,
mlir::Location structLoc,
mlir::Location constrainLoc )
inline

Definition at line 68 of file Builders.h.

◆ insertEmptyStruct() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertEmptyStruct ( std::string_view structName,
int numStructParams = -1 )
inline

Definition at line 51 of file Builders.h.

◆ insertEmptyStruct() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertEmptyStruct ( std::string_view structName,
mlir::Location loc,
int numStructParams = -1 )

◆ insertFreeCall() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertFreeCall ( function::FuncDefOp caller,
std::string_view callee )
inline

Definition at line 192 of file Builders.h.

◆ insertFreeCall() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertFreeCall ( function::FuncDefOp caller,
std::string_view callee,
mlir::Location callLoc )

◆ insertFreeFunc() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertFreeFunc ( std::string_view funcName,
::mlir::FunctionType type )
inline

Definition at line 186 of file Builders.h.

◆ insertFreeFunc() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertFreeFunc ( std::string_view funcName,
::mlir::FunctionType type,
mlir::Location loc )

◆ insertFullStruct() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertFullStruct ( std::string_view structName,
int numStructParams = -1 )
inline

Inserts a struct with both compute and constrain functions.

Definition at line 92 of file Builders.h.

◆ insertFullStruct() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertFullStruct ( std::string_view structName,
mlir::Location structLoc,
mlir::Location computeLoc,
mlir::Location constrainLoc,
int numStructParams = -1 )
inline

Definition at line 81 of file Builders.h.

◆ insertProductFn() [1/3]

ModuleBuilder & llzk::ModuleBuilder::insertProductFn ( component::StructDefOp op,
mlir::Location loc )

◆ insertProductFn() [2/3]

ModuleBuilder & llzk::ModuleBuilder::insertProductFn ( std::string_view structName)
inline

Definition at line 144 of file Builders.h.

◆ insertProductFn() [3/3]

ModuleBuilder & llzk::ModuleBuilder::insertProductFn ( std::string_view structName,
mlir::Location loc )
inline

Definition at line 141 of file Builders.h.

◆ insertProductStruct() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertProductStruct ( std::string_view structName)
inline

Definition at line 105 of file Builders.h.

◆ insertProductStruct() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertProductStruct ( std::string_view structName,
mlir::Location structLoc,
mlir::Location productLoc )
inline

Definition at line 97 of file Builders.h.


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