LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Struct.cpp File Reference
#include "llzk-c/Dialect/Struct.h"
#include "llzk/CAPI/Builder.h"
#include "llzk/CAPI/Support.h"
#include "llzk/Dialect/Function/IR/Ops.h"
#include "llzk/Dialect/Struct/IR/Dialect.h"
#include "llzk/Dialect/Struct/IR/Ops.h"
#include "llzk/Dialect/Struct/IR/Types.h"
#include "llzk/Util/Compare.h"
#include "llzk/Util/SymbolLookup.h"
#include "llzk/Util/TypeHelper.h"
#include <mlir-c/Support.h>
#include <mlir/CAPI/AffineMap.h>
#include <mlir/CAPI/Registration.h>
#include <mlir/CAPI/Support.h>
#include <mlir/CAPI/Wrap.h>
#include <mlir/IR/BuiltinAttributes.h>
#include <mlir/IR/SymbolTable.h>
#include <llvm/ADT/STLExtras.h>
#include "llzk/Dialect/Struct/IR/Ops.capi.cpp.inc"
#include "llzk/Dialect/Struct/IR/Types.capi.cpp.inc"
Include dependency graph for Struct.cpp:

Go to the source code of this file.

Functions

MlirType llzkStruct_StructTypeGet (MlirAttribute name)
 Creates a llzk::component::StructType.
MlirType llzkStruct_StructTypeGetWithArrayAttr (MlirAttribute name, MlirAttribute params)
 Creates a llzk::component::StructType with an ArrayAttr as parameters.
MlirType llzkStruct_StructTypeGetWithAttrs (MlirAttribute name, intptr_t numParams, MlirAttribute const *params)
 Creates a llzk::component::StructType with an array of parameters.
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.
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.
MlirBlock llzkStruct_StructDefOpGetBody (MlirOperation op)
 Returns the single body Block within the StructDefOp's Region.
MlirType llzkStruct_StructDefOpGetType (MlirOperation op)
 Returns the associated StructType to this op using the const params defined by the op.
MlirType llzkStruct_StructDefOpGetTypeWithParams (MlirOperation op, MlirAttribute attr)
 Returns the associated StructType to this op using the given const params instead of the parameters defined by the op.
void llzkStruct_StructDefOpGetMemberDefs (MlirOperation op, MlirOperation *dst)
 Fills the given array with the MemberDefOp operations inside this struct.
intptr_t llzkStruct_StructDefOpGetNumMemberDefs (MlirOperation op)
 Returns the number of MemberDefOp operations defined in this struct.
const char * llzkStruct_StructDefOpGetHeaderString (MlirOperation op, intptr_t *strSize, char *(*alloc_string)(size_t))
 Returns the header string of the struct.
void llzkStruct_StructDefOpGetTemplateParamOpNames (MlirOperation op, MlirAttribute *dst)
 If this struct.def is within a poly.template, add names of all poly.param within the poly.template in the order they are defined.
intptr_t llzkStruct_StructDefOpGetNumTemplateParamOpNames (MlirOperation op)
 Returns the number of poly.param operations defined within this template.
void llzkStruct_StructDefOpGetTemplateExprOpNames (MlirOperation op, MlirAttribute *dst)
 If this struct.def is within a poly.template, add names of all poly.expr within the poly.template in the order they are defined.
intptr_t llzkStruct_StructDefOpGetNumTemplateExprOpNames (MlirOperation op)
 Returns the number of poly.expr operations defined within this template.
 LLZK_DEFINE_OP_BUILD_METHOD (Struct, MemberReadOp, MlirType memberType, MlirValue component, MlirIdentifier memberName)
 LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD (Struct, MemberReadOp, WithAffineMapDistance, MlirType memberType, MlirValue component, MlirIdentifier memberName, MlirAffineMap map, MlirValueRange mapOperands)
 LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD (Struct, MemberReadOp, WithTemplateSymbolDistance, MlirType memberType, MlirValue component, MlirIdentifier memberName, MlirStringRef symbol)
 LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD (Struct, MemberReadOp, WithLiteralDistance, MlirType memberType, MlirValue component, MlirIdentifier memberName, int64_t distance)

Function Documentation

◆ LLZK_DEFINE_OP_BUILD_METHOD()

LLZK_DEFINE_OP_BUILD_METHOD ( Struct ,
MemberReadOp ,
MlirType memberType,
MlirValue component,
MlirIdentifier memberName )

Definition at line 159 of file Struct.cpp.

◆ LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD() [1/3]

LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD ( Struct ,
MemberReadOp ,
WithAffineMapDistance ,
MlirType memberType,
MlirValue component,
MlirIdentifier memberName,
MlirAffineMap map,
MlirValueRange mapOperands )

Definition at line 169 of file Struct.cpp.

◆ LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD() [2/3]

LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD ( Struct ,
MemberReadOp ,
WithLiteralDistance ,
MlirType memberType,
MlirValue component,
MlirIdentifier memberName,
int64_t distance )

Definition at line 196 of file Struct.cpp.

◆ LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD() [3/3]

LLZK_DEFINE_SUFFIX_OP_BUILD_METHOD ( Struct ,
MemberReadOp ,
WithTemplateSymbolDistance ,
MlirType memberType,
MlirValue component,
MlirIdentifier memberName,
MlirStringRef symbol )

Definition at line 184 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetBody()

MlirBlock llzkStruct_StructDefOpGetBody ( MlirOperation op)

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

Definition at line 95 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetHeaderString()

const char * llzkStruct_StructDefOpGetHeaderString ( 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 118 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetMemberDefs()

void llzkStruct_StructDefOpGetMemberDefs ( 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 llzkStruct_StructDefOpGetNumMemberDefs for obtaining the required size of the array.

Definition at line 107 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetNumMemberDefs()

intptr_t llzkStruct_StructDefOpGetNumMemberDefs ( MlirOperation op)

Returns the number of MemberDefOp operations defined in this struct.

Definition at line 114 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetNumTemplateExprOpNames()

intptr_t llzkStruct_StructDefOpGetNumTemplateExprOpNames ( MlirOperation op)

Returns the number of poly.expr operations defined within this template.

Definition at line 149 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetNumTemplateParamOpNames()

intptr_t llzkStruct_StructDefOpGetNumTemplateParamOpNames ( MlirOperation op)

Returns the number of poly.param operations defined within this template.

Definition at line 136 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetTemplateExprOpNames()

void llzkStruct_StructDefOpGetTemplateExprOpNames ( MlirOperation op,
MlirAttribute * dst )

If this struct.def is within a poly.template, add names of all poly.expr within the poly.template in the order they are defined.

Otherwise, do nothing. The names are added as FlatSymbolRefAttr but the more general Attribute type is used in the type since that's usually what's needed.

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

Definition at line 142 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetTemplateParamOpNames()

void llzkStruct_StructDefOpGetTemplateParamOpNames ( MlirOperation op,
MlirAttribute * dst )

If this struct.def is within a poly.template, add names of all poly.param within the poly.template in the order they are defined.

Otherwise, do nothing. The names are added as FlatSymbolRefAttr but the more general Attribute type is used in the type since that's usually what's needed.

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

Definition at line 129 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetType()

MlirType llzkStruct_StructDefOpGetType ( MlirOperation op)

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

Definition at line 99 of file Struct.cpp.

◆ llzkStruct_StructDefOpGetTypeWithParams()

MlirType llzkStruct_StructDefOpGetTypeWithParams ( 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 103 of file Struct.cpp.

◆ llzkStruct_StructTypeGet()

MlirType llzkStruct_StructTypeGet ( MlirAttribute name)

Creates a llzk::component::StructType.

The name attribute must be a SymbolRefAttr.

Definition at line 47 of file Struct.cpp.

◆ llzkStruct_StructTypeGetWithArrayAttr()

MlirType llzkStruct_StructTypeGetWithArrayAttr ( MlirAttribute name,
MlirAttribute params )

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

The name attribute must be a SymbolRefAttr.

Definition at line 51 of file Struct.cpp.

◆ llzkStruct_StructTypeGetWithAttrs()

MlirType llzkStruct_StructTypeGetWithAttrs ( 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 59 of file Struct.cpp.

◆ llzkStructStructTypeGetDefinition()

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 69 of file Struct.cpp.

◆ llzkStructStructTypeGetDefinitionFromModule()

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 85 of file Struct.cpp.