LLZK 0.1.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Struct.h File Reference
#include "llzk-c/Support.h"
#include <mlir-c/AffineMap.h>
#include <mlir-c/IR.h>
#include <mlir-c/Support.h>
#include <stdint.h>
Include dependency graph for Struct.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 MLIR_DECLARE_CAPI_DIALECT_REGISTRATION (Struct, llzk__component)
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGet (MlirAttribute name)
 Creates a llzk::component::StructType.
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithArrayAttr (MlirAttribute name, MlirAttribute params)
 Creates a llzk::component::StructType with an ArrayAttr as parameters.
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithAttrs (MlirAttribute name, intptr_t numParams, MlirAttribute const *params)
 Creates a llzk::component::StructType with an array of parameters.
 LLZK_DECLARE_TYPE_ISA (StructType)
 Returns true if the type is a StructType.
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetName (MlirType type)
 Returns the fully qualified name of a llzk::component::StructType.
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetParams (MlirType type)
 Returns the parameter of a llzk::component::StructType as an ArrayAttr.
MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinition (MlirType type, MlirOperation root, LlzkSymbolLookupResult *result)
 Lookups the definition Operation of the given StructType using the given Operation as root for the lookup.
MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinitionFromModule (MlirType type, MlirModule root, LlzkSymbolLookupResult *result)
 Lookups the definition Operation of the given StructType using the given Module as root for the lookup.
 LLZK_DECLARE_OP_ISA (StructDefOp)
 Returns true if the op is a StructDefOp.
MLIR_CAPI_EXPORTED MlirRegion llzkStructDefOpGetBodyRegion (MlirOperation op)
 Returns the single body Region of the StructDefOp.
MLIR_CAPI_EXPORTED MlirBlock llzkStructDefOpGetBody (MlirOperation op)
 Returns the single body Block within the StructDefOp's Region.
MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetType (MlirOperation op)
 Returns the associated StructType to this op using the const params defined by the op.
MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetTypeWithParams (MlirOperation op, MlirAttribute params)
 Returns the associated StructType to this op using the given const params instead of the parameters defined by the op.
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetMemberDef (MlirOperation op, MlirStringRef name)
 Returns the operation that defines the member with the given name, if present.
MLIR_CAPI_EXPORTED void llzkStructDefOpGetMemberDefs (MlirOperation op, MlirOperation *dst)
 Fills the given array with the MemberDefOp operations inside this struct.
MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumMemberDefs (MlirOperation op)
 Returns the number of MemberDefOp operations defined in this struct.
MlirLogicalResult llzkStructDefOpGetHasColumns (MlirOperation op)
 Returns true if the struct has members marked as columns.
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetComputeFuncOp (MlirOperation op)
 Returns the FuncDefOp operation that defines the witness computation of the struct.
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp (MlirOperation op)
 Returns the FuncDefOp operation that defines the constraints of the struct.
MLIR_CAPI_EXPORTED const char * llzkStructDefOpGetHeaderString (MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t))
 Returns the header string of the struct.
 LLZK_DECLARE_NARY_OP_PREDICATE (StructDefOp, HasParamName, MlirStringRef name)
 Returns true if the struct has a parameter that with the given name.
MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName (MlirOperation op)
 Returns a StringAttr with the fully qualified name of the struct.
 LLZK_DECLARE_OP_PREDICATE (StructDefOp, IsMainComponent)
 Returns true if the struct is the main entry point of the circuit.
 LLZK_DECLARE_OP_ISA (MemberDefOp)
 Returns true if the op is a MemberDefOp.
 LLZK_DECLARE_OP_PREDICATE (MemberDefOp, HasPublicAttr)
 Returns true if the member has been marked public with a PublicAttr.
MLIR_CAPI_EXPORTED void llzkMemberDefOpSetPublicAttr (MlirOperation op, bool value)
 Sets the public attribute in the given member.
 LLZK_DECLARE_OP_BUILD_METHOD (MemberReadOp, MlirType type, MlirValue component, MlirStringRef memberName)
 Creates a MemberReadOp.
 LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD (MemberReadOp, WithAffineMapDistance, MlirType type, MlirValue component, MlirStringRef memberName, MlirAffineMap affineMap, MlirValueRange mapOperands)
 Creates a MemberReadOp to a column offset by the given distance affine map.
 LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD (MemberReadOp, WithConstParamDistance, MlirType type, MlirValue component, MlirStringRef memberName, MlirStringRef paramName)
 Creates a MemberReadOp to a column offset by the given distance defined by a name to a constant parameter in the struct.
 LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD (MemberReadOp, WithLiteralDistance, MlirType type, MlirValue component, MlirStringRef memberName, int64_t distance)
 Creates a MemberReadOp to a column offset by the given distance defined by an integer value.

Function Documentation

◆ LLZK_DECLARE_NARY_OP_PREDICATE()

LLZK_DECLARE_NARY_OP_PREDICATE ( StructDefOp ,
HasParamName ,
MlirStringRef name )

Returns true if the struct has a parameter that with the given name.

◆ LLZK_DECLARE_OP_BUILD_METHOD()

LLZK_DECLARE_OP_BUILD_METHOD ( MemberReadOp ,
MlirType type,
MlirValue component,
MlirStringRef memberName )

Creates a MemberReadOp.

◆ LLZK_DECLARE_OP_ISA() [1/2]

LLZK_DECLARE_OP_ISA ( MemberDefOp )

Returns true if the op is a MemberDefOp.

◆ LLZK_DECLARE_OP_ISA() [2/2]

LLZK_DECLARE_OP_ISA ( StructDefOp )

Returns true if the op is a StructDefOp.

◆ LLZK_DECLARE_OP_PREDICATE() [1/2]

LLZK_DECLARE_OP_PREDICATE ( MemberDefOp ,
HasPublicAttr  )

Returns true if the member has been marked public with a PublicAttr.

◆ LLZK_DECLARE_OP_PREDICATE() [2/2]

LLZK_DECLARE_OP_PREDICATE ( StructDefOp ,
IsMainComponent  )

Returns true if the struct is the main entry point of the circuit.

◆ LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD() [1/3]

LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD ( MemberReadOp ,
WithAffineMapDistance ,
MlirType type,
MlirValue component,
MlirStringRef memberName,
MlirAffineMap affineMap,
MlirValueRange mapOperands )

Creates a MemberReadOp to a column offset by the given distance affine map.

The values in the ValueRange are operands representing the arguments to the affine map. The integer value is the number of arguments in the map that are dimensions.

◆ LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD() [2/3]

LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD ( MemberReadOp ,
WithConstParamDistance ,
MlirType type,
MlirValue component,
MlirStringRef memberName,
MlirStringRef paramName )

Creates a MemberReadOp to a column offset by the given distance defined by a name to a constant parameter in the struct.

◆ LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD() [3/3]

LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD ( MemberReadOp ,
WithLiteralDistance ,
MlirType type,
MlirValue component,
MlirStringRef memberName,
int64_t distance )

Creates a MemberReadOp to a column offset by the given distance defined by an integer value.

◆ LLZK_DECLARE_TYPE_ISA()

LLZK_DECLARE_TYPE_ISA ( StructType )

Returns true if the type is a StructType.

◆ llzkMemberDefOpSetPublicAttr()

MLIR_CAPI_EXPORTED void llzkMemberDefOpSetPublicAttr ( MlirOperation op,
bool value )

Sets the public attribute in the given member.

Definition at line 181 of file Struct.cpp.

◆ llzkStructDefOpGetBody()

MLIR_CAPI_EXPORTED MlirBlock llzkStructDefOpGetBody ( MlirOperation op)

Returns the single body Block within the StructDefOp's Region.

Definition at line 106 of file Struct.cpp.

◆ llzkStructDefOpGetBodyRegion()

MLIR_CAPI_EXPORTED MlirRegion llzkStructDefOpGetBodyRegion ( MlirOperation op)

Returns the single body Region of the StructDefOp.

Definition at line 102 of file Struct.cpp.

◆ llzkStructDefOpGetComputeFuncOp()

MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetComputeFuncOp ( MlirOperation op)

Returns the FuncDefOp operation that defines the witness computation of the struct.

Definition at line 140 of file Struct.cpp.

◆ llzkStructDefOpGetConstrainFuncOp()

MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp ( MlirOperation op)

Returns the FuncDefOp operation that defines the constraints of the struct.

Definition at line 144 of file Struct.cpp.

◆ llzkStructDefOpGetFullyQualifiedName()

MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName ( MlirOperation op)

Returns a StringAttr with the fully qualified name of the struct.

Definition at line 163 of file Struct.cpp.

◆ llzkStructDefOpGetHasColumns()

MlirLogicalResult llzkStructDefOpGetHasColumns ( MlirOperation op)

Returns true if the struct has members marked as columns.

Definition at line 136 of file Struct.cpp.

◆ llzkStructDefOpGetHeaderString()

MLIR_CAPI_EXPORTED const char * llzkStructDefOpGetHeaderString ( MlirOperation op,
intptr_t * dstSize,
char *(* alloc_string )(size_t) )

Returns the header string of the struct.

The size of the string is written into the given size pointer. The caller is responsible of freeing the string and of providing an allocator.

Definition at line 149 of file Struct.cpp.

◆ llzkStructDefOpGetMemberDef()

MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetMemberDef ( MlirOperation op,
MlirStringRef name )

Returns the operation that defines the member with the given name, if present.

Definition at line 118 of file Struct.cpp.

◆ llzkStructDefOpGetMemberDefs()

MLIR_CAPI_EXPORTED void llzkStructDefOpGetMemberDefs ( MlirOperation op,
MlirOperation * dst )

Fills the given array with the MemberDefOp operations inside this struct.

The pointer to the operations must have been preallocated. See llzkStructDefOpGetNumMemberDefs for obtaining the required size of the array.

Definition at line 125 of file Struct.cpp.

◆ llzkStructDefOpGetNumMemberDefs()

MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumMemberDefs ( MlirOperation op)

Returns the number of MemberDefOp operations defined in this struct.

Definition at line 132 of file Struct.cpp.

◆ llzkStructDefOpGetType()

MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetType ( MlirOperation op)

Returns the associated StructType to this op using the const params defined by the op.

Definition at line 110 of file Struct.cpp.

◆ llzkStructDefOpGetTypeWithParams()

MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetTypeWithParams ( MlirOperation op,
MlirAttribute params )

Returns the associated StructType to this op using the given const params instead of the parameters defined by the op.

The const params are defined in the given attribute which has to be of type ArrayAttr.

Definition at line 114 of file Struct.cpp.

◆ llzkStructStructTypeGetDefinition()

MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinition ( MlirType type,
MlirOperation root,
LlzkSymbolLookupResult * result )

Lookups the definition Operation of the given StructType using the given Operation as root for the lookup.

The definition Operation is wrapped in a LlzkSymbolLookupResult that the caller is responsible for cleaning up.

If the function returns 'success' the lookup result will be stored in the given pointer. Accessing the lookup result if the function returns 'failure' is undefined behavior.

Requires that the given Operation implements the SymbolTable op interface.

Definition at line 74 of file Struct.cpp.

◆ llzkStructStructTypeGetDefinitionFromModule()

MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinitionFromModule ( MlirType type,
MlirModule root,
LlzkSymbolLookupResult * result )

Lookups the definition Operation of the given StructType using the given Module as root for the lookup.

The definition Operation is wrapped in a LlzkSymbolLookupResult that the caller is responsible for cleaning up.

If the function returns 'success' the lookup result will be stored in the given pointer. Accessing the lookup result if the function returns 'failure' is undefined behavior.

Definition at line 90 of file Struct.cpp.

◆ llzkStructTypeGet()

MLIR_CAPI_EXPORTED MlirType llzkStructTypeGet ( MlirAttribute name)

Creates a llzk::component::StructType.

The name attribute must be a SymbolRefAttr.

Definition at line 42 of file Struct.cpp.

◆ llzkStructTypeGetName()

MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetName ( MlirType type)

Returns the fully qualified name of a llzk::component::StructType.

Definition at line 66 of file Struct.cpp.

◆ llzkStructTypeGetParams()

MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetParams ( MlirType type)

Returns the parameter of a llzk::component::StructType as an ArrayAttr.

Definition at line 70 of file Struct.cpp.

◆ llzkStructTypeGetWithArrayAttr()

MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithArrayAttr ( MlirAttribute name,
MlirAttribute params )

Creates a llzk::component::StructType with an ArrayAttr as parameters.

The name attribute must be a SymbolRefAttr.

Definition at line 46 of file Struct.cpp.

◆ llzkStructTypeGetWithAttrs()

MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithAttrs ( MlirAttribute name,
intptr_t numParams,
MlirAttribute const * params )

Creates a llzk::component::StructType with an array of parameters.

The name attribute must be a SymbolRefAttr.

Definition at line 55 of file Struct.cpp.

◆ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION()

MLIR_DECLARE_CAPI_DIALECT_REGISTRATION ( Struct ,
llzk__component  )