LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
llzk::ModuleBuilder Class Reference

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

#include <Builders.h>

Inheritance diagram for llzk::ModuleBuilder:
[legend]
Collaboration diagram for llzk::ModuleBuilder:
[legend]

Public Member Functions

 ModuleBuilder (mlir::ModuleOp m)
mlir::Region & getBodyRegion ()
mlir::ModuleOp & getModule ()
 Get the associated module of this builder.
mlir::FailureOr< TemplateBuilder * > getTemplate (std::string_view templateName) const
mlir::FailureOr< ModuleBuilder * > getNestedModule (std::string_view moduleName) const
ModuleBuilderinsertTemplate (std::string_view templateName, mlir::Location loc, unsigned numParams=0)
ModuleBuilderinsertTemplate (std::string_view templateName, unsigned numParams=0)
ModuleBuilderinsertNestedModule (std::string_view moduleName, mlir::Location loc)
ModuleBuilderinsertNestedModule (std::string_view moduleName)
Public Member Functions inherited from llzk::ModuleLikeBuilder< ModuleBuilder >
 ModuleLikeBuilder (mlir::MLIRContext *ctx)
mlir::Region & getBodyRegion ()
mlir::FailureOr< component::StructDefOpgetStruct (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetComputeFn (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetConstrainFn (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetProductFn (std::string_view structName) const
mlir::FailureOr< function::FuncDefOpgetFreeFunc (std::string_view funcName) const
ModuleBuilderinsertEmptyStruct (std::string_view structName, mlir::Location loc)
ModuleBuilderinsertComputeOnlyStruct (std::string_view structName, mlir::Location structLoc, mlir::Location computeLoc)
ModuleBuilderinsertConstrainOnlyStruct (std::string_view structName, mlir::Location structLoc, mlir::Location constrainLoc)
ModuleBuilderinsertFullStruct (std::string_view structName, mlir::Location structLoc, mlir::Location computeLoc, mlir::Location constrainLoc)
ModuleBuilderinsertProductStruct (std::string_view structName, mlir::Location structLoc, mlir::Location productLoc)
ModuleBuilderinsertComputeFn (component::StructDefOp op, mlir::Location loc)
ModuleBuilderinsertConstrainFn (component::StructDefOp op, mlir::Location loc)
ModuleBuilderinsertProductFn (component::StructDefOp op, mlir::Location loc)
ModuleBuilderinsertComputeCall (component::StructDefOp caller, component::StructDefOp callee, mlir::Location callLoc)
 Only requirement for compute is the call itself.
ModuleBuilderinsertConstrainCall (component::StructDefOp caller, component::StructDefOp callee, mlir::Location callLoc, mlir::Location memberDefLoc)
 To call a constraint function, you must:
ModuleBuilderinsertFreeFunc (std::string_view funcName, ::mlir::FunctionType type, mlir::Location loc)
ModuleBuilderinsertFreeCall (function::FuncDefOp caller, std::string_view callee, mlir::Location callLoc)
Public Member Functions inherited from llzk::BaseBuilder
 BaseBuilder (mlir::MLIRContext *ctx)
mlir::Location getUnknownLoc ()

Additional Inherited Members

Static Public Member Functions inherited from llzk::ModuleLikeBuilder< ModuleBuilder >
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.
Protected Member Functions inherited from llzk::ModuleLikeBuilder< ModuleBuilder >
void ensureNoSuchFreeFunc (std::string_view funcName)
 Ensure that a global function with the given funcName has not been added, reporting a fatal error otherwise.
void ensureFreeFnExists (std::string_view funcName)
 Ensure that a global function with the given funcName has been added, reporting a fatal error otherwise.
void ensureNoSuchStruct (std::string_view structName)
 Ensure that a struct with the given structName has not been added, reporting a fatal error otherwise.
void ensureStructExists (std::string_view structName)
 Ensure that a struct with the given structName exists, reporting a fatal error otherwise.
void ensureNoSuchComputeFn (std::string_view structName)
 Ensure that the given struct does not have a compute function, reporting a fatal error otherwise.
void ensureComputeFnExists (std::string_view structName)
 Ensure that the given struct has a compute function, reporting a fatal error otherwise.
void ensureNoSuchConstrainFn (std::string_view structName)
 Ensure that the given struct does not have a constrain function, reporting a fatal error otherwise.
void ensureConstrainFnExists (std::string_view structName)
 Ensure that the given struct has a constrain function, reporting a fatal error otherwise.
void ensureNoSuchProductFn (std::string_view structName)
 Ensure that the given struct does not have a product function, reporting a fatal error otherwise.
void ensureProductFnExists (std::string_view structName)
 Ensure that the given struct has a product function, reporting a fatal error otherwise.
Protected Attributes inherited from llzk::ModuleLikeBuilder< ModuleBuilder >
std::unordered_map< std::string_view, function::FuncDefOpfreeFuncMap
std::unordered_map< std::string_view, component::StructDefOpstructMap
std::unordered_map< std::string_view, function::FuncDefOpcomputeFnMap
std::unordered_map< std::string_view, function::FuncDefOpconstrainFnMap
std::unordered_map< std::string_view, function::FuncDefOpproductFnMap
Protected Attributes inherited from llzk::BaseBuilder
mlir::MLIRContext * context

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.

Definition at line 323 of file Builders.h.

Constructor & Destructor Documentation

◆ ModuleBuilder()

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

Definition at line 352 of file Builders.h.

Member Function Documentation

◆ getBodyRegion()

mlir::Region & llzk::ModuleBuilder::getBodyRegion ( )
inline

Definition at line 356 of file Builders.h.

◆ getModule()

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

Get the associated module of this builder.

Definition at line 359 of file Builders.h.

◆ getNestedModule()

mlir::FailureOr< ModuleBuilder * > llzk::ModuleBuilder::getNestedModule ( std::string_view moduleName) const
inline

Definition at line 369 of file Builders.h.

◆ getTemplate()

mlir::FailureOr< TemplateBuilder * > llzk::ModuleBuilder::getTemplate ( std::string_view templateName) const
inline

Definition at line 361 of file Builders.h.

◆ insertNestedModule() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertNestedModule ( std::string_view moduleName)
inline

Definition at line 386 of file Builders.h.

◆ insertNestedModule() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertNestedModule ( std::string_view moduleName,
mlir::Location loc )

◆ insertTemplate() [1/2]

ModuleBuilder & llzk::ModuleBuilder::insertTemplate ( std::string_view templateName,
mlir::Location loc,
unsigned numParams = 0 )

◆ insertTemplate() [2/2]

ModuleBuilder & llzk::ModuleBuilder::insertTemplate ( std::string_view templateName,
unsigned numParams = 0 )
inline

Definition at line 381 of file Builders.h.


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