LLZK 0.1.0
Veridise's ZK Language IR
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>

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.
 
ModuleBuilderinsertComputeFn (llzk::component::StructDefOp op, mlir::Location loc)
 compute returns the type of the struct that defines it.
 
ModuleBuilderinsertComputeFn (std::string_view structName, mlir::Location loc)
 
ModuleBuilderinsertComputeFn (std::string_view structName)
 
ModuleBuilderinsertConstrainFn (llzk::component::StructDefOp op, mlir::Location loc)
 constrain accepts the struct type as the first argument.
 
ModuleBuilderinsertConstrainFn (std::string_view structName, mlir::Location loc)
 
ModuleBuilderinsertConstrainFn (std::string_view structName)
 
ModuleBuilderinsertComputeCall (llzk::component::StructDefOp caller, llzk::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 (llzk::component::StructDefOp caller, llzk::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)
 
ModuleBuilderinsertGlobalFunc (std::string_view funcName, ::mlir::FunctionType type, mlir::Location loc)
 
ModuleBuilderinsertGlobalFunc (std::string_view funcName, ::mlir::FunctionType type)
 
ModuleBuilderinsertGlobalCall (function::FuncDefOp caller, std::string_view callee, mlir::Location callLoc)
 
ModuleBuilderinsertGlobalCall (function::FuncDefOp caller, std::string_view callee)
 
mlir::ModuleOp & getRootModule ()
 Get the top-level LLZK module.
 
mlir::FailureOr< llzk::component::StructDefOpgetStruct (std::string_view structName) const
 
mlir::FailureOr< function::FuncDefOpgetComputeFn (std::string_view structName) const
 
mlir::FailureOr< function::FuncDefOpgetComputeFn (llzk::component::StructDefOp op) const
 
mlir::FailureOr< function::FuncDefOpgetConstrainFn (std::string_view structName)
 
mlir::FailureOr< function::FuncDefOpgetConstrainFn (llzk::component::StructDefOp op)
 
mlir::FailureOr< function::FuncDefOpgetGlobalFunc (std::string_view funcName) const
 
bool computeReachable (llzk::component::StructDefOp caller, llzk::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 (llzk::component::StructDefOp caller, llzk::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)
 

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

◆ computeReachable() [1/2]

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

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

Definition at line 213 of file Builders.h.

◆ computeReachable() [2/2]

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

Definition at line 216 of file Builders.h.

◆ constrainReachable() [1/2]

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

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

Definition at line 224 of file Builders.h.

◆ constrainReachable() [2/2]

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

Definition at line 227 of file Builders.h.

◆ getComputeFn() [1/2]

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

Definition at line 187 of file Builders.h.

◆ getComputeFn() [2/2]

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

Definition at line 181 of file Builders.h.

◆ getConstrainFn() [1/2]

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

Definition at line 197 of file Builders.h.

◆ getConstrainFn() [2/2]

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

Definition at line 191 of file Builders.h.

◆ getGlobalFunc()

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

Definition at line 201 of file Builders.h.

◆ getRootModule()

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

Get the top-level LLZK module.

Definition at line 172 of file Builders.h.

◆ getStruct()

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

Definition at line 174 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 ( llzk::component::StructDefOp caller,
llzk::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 133 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 130 of file Builders.h.

◆ insertComputeFn() [1/3]

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

compute returns the type of the struct that defines it.

Since this is for testing, we accept no arguments.

◆ insertComputeFn() [2/3]

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

Definition at line 105 of file Builders.h.

◆ insertComputeFn() [3/3]

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

Definition at line 102 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 ( llzk::component::StructDefOp caller,
llzk::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 153 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 147 of file Builders.h.

◆ insertConstrainFn() [1/3]

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

constrain accepts the struct type as the first argument.

◆ insertConstrainFn() [2/3]

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

Definition at line 116 of file Builders.h.

◆ insertConstrainFn() [3/3]

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

Definition at line 113 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 )

◆ 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.

◆ insertGlobalCall() [1/2]

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

Definition at line 165 of file Builders.h.

◆ insertGlobalCall() [2/2]

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

◆ insertGlobalFunc() [1/2]

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

Definition at line 159 of file Builders.h.

◆ insertGlobalFunc() [2/2]

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

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