LLZK 0.1.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Struct.h
Go to the documentation of this file.
1//===-- Struct.h - C API for Struct dialect -----------------------*- C -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9//
10// This header declares the C interface for registering and accessing the
11// Struct dialect. A dialect should be registered with a context to make it
12// available to users of the context. These users must load the dialect
13// before using any of its attributes, operations, or types. Parser and pass
14// manager can load registered dialects automatically.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLZK_C_DIALECT_STRUCT_H
19#define LLZK_C_DIALECT_STRUCT_H
20
21#include "llzk-c/Support.h"
22
23#include <mlir-c/AffineMap.h>
24#include <mlir-c/IR.h>
25#include <mlir-c/Support.h>
26
27#include <stdint.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
34
35//===----------------------------------------------------------------------===//
36// StructType
37//===----------------------------------------------------------------------===//
38
41MLIR_CAPI_EXPORTED MlirType llzkStructTypeGet(MlirAttribute name);
42
45MLIR_CAPI_EXPORTED
46MlirType llzkStructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params);
47
50MLIR_CAPI_EXPORTED MlirType
51llzkStructTypeGetWithAttrs(MlirAttribute name, intptr_t numParams, MlirAttribute const *params);
52
55
57MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetName(MlirType type);
58
60MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetParams(MlirType type);
61
71MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinition(
72 MlirType type, MlirOperation root, LlzkSymbolLookupResult *result
73);
74
82MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinitionFromModule(
83 MlirType type, MlirModule root, LlzkSymbolLookupResult *result
84);
85
86//===----------------------------------------------------------------------===//
87// StructDefOp
88//===----------------------------------------------------------------------===//
89
92
94MLIR_CAPI_EXPORTED MlirRegion llzkStructDefOpGetBodyRegion(MlirOperation op);
95
97MLIR_CAPI_EXPORTED MlirBlock llzkStructDefOpGetBody(MlirOperation op);
98
100MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetType(MlirOperation op);
101
105MLIR_CAPI_EXPORTED MlirType
106llzkStructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute params);
107
109MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetMemberDef(MlirOperation op, MlirStringRef name);
110
114MLIR_CAPI_EXPORTED void llzkStructDefOpGetMemberDefs(MlirOperation op, MlirOperation *dst);
115
117MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumMemberDefs(MlirOperation op);
118
120MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op);
121
123MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetComputeFuncOp(MlirOperation op);
124
126MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op);
127
130MLIR_CAPI_EXPORTED const char *
131llzkStructDefOpGetHeaderString(MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t));
132
134LLZK_DECLARE_NARY_OP_PREDICATE(StructDefOp, HasParamName, MlirStringRef name);
135
137MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op);
138
140LLZK_DECLARE_OP_PREDICATE(StructDefOp, IsMainComponent);
141
142//===----------------------------------------------------------------------===//
143// MemberDefOp
144//===----------------------------------------------------------------------===//
145
148
150LLZK_DECLARE_OP_PREDICATE(MemberDefOp, HasPublicAttr);
151
153MLIR_CAPI_EXPORTED void llzkMemberDefOpSetPublicAttr(MlirOperation op, bool value);
154
155//===----------------------------------------------------------------------===//
156// MemberReadOp
157//===----------------------------------------------------------------------===//
158
161 MemberReadOp, MlirType type, MlirValue component, MlirStringRef memberName
162);
163
168 MemberReadOp, WithAffineMapDistance, MlirType type, MlirValue component,
169 MlirStringRef memberName, MlirAffineMap affineMap, MlirValueRange mapOperands
170);
171
175 MemberReadOp, WithConstParamDistance, MlirType type, MlirValue component,
176 MlirStringRef memberName, MlirStringRef paramName
177);
178
181 MemberReadOp, WithLiteralDistance, MlirType type, MlirValue component, MlirStringRef memberName,
182 int64_t distance
183);
184
185#ifdef __cplusplus
186}
187#endif
188
189#endif
MLIR_CAPI_EXPORTED const char * llzkStructDefOpGetHeaderString(MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t))
Returns the header string of the struct.
Definition Struct.cpp:149
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params)
Creates a llzk::component::StructType with an ArrayAttr as parameters.
Definition Struct.cpp:46
MLIR_CAPI_EXPORTED MlirRegion llzkStructDefOpGetBodyRegion(MlirOperation op)
Returns the single body Region of the StructDefOp.
Definition Struct.cpp:102
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithAttrs(MlirAttribute name, intptr_t numParams, MlirAttribute const *params)
Creates a llzk::component::StructType with an array of parameters.
Definition Struct.cpp:55
MLIR_CAPI_EXPORTED void llzkStructDefOpGetMemberDefs(MlirOperation op, MlirOperation *dst)
Fills the given array with the MemberDefOp operations inside this struct.
Definition Struct.cpp:125
MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op)
Returns a StringAttr with the fully qualified name of the struct.
Definition Struct.cpp:163
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetMemberDef(MlirOperation op, MlirStringRef name)
Returns the operation that defines the member with the given name, if present.
Definition Struct.cpp:118
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Struct, llzk__component)
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetComputeFuncOp(MlirOperation op)
Returns the FuncDefOp operation that defines the witness computation of the struct.
Definition Struct.cpp:140
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 lo...
Definition Struct.cpp:74
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetName(MlirType type)
Returns the fully qualified name of a llzk::component::StructType.
Definition Struct.cpp:66
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGet(MlirAttribute name)
Creates a llzk::component::StructType.
Definition Struct.cpp:42
MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetType(MlirOperation op)
Returns the associated StructType to this op using the const params defined by the op.
Definition Struct.cpp:110
MLIR_CAPI_EXPORTED MlirBlock llzkStructDefOpGetBody(MlirOperation op)
Returns the single body Block within the StructDefOp's Region.
Definition Struct.cpp:106
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 looku...
Definition Struct.cpp:90
MLIR_CAPI_EXPORTED void llzkMemberDefOpSetPublicAttr(MlirOperation op, bool value)
Sets the public attribute in the given member.
Definition Struct.cpp:181
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 d...
Definition Struct.cpp:114
MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op)
Returns true if the struct has members marked as columns.
Definition Struct.cpp:136
MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumMemberDefs(MlirOperation op)
Returns the number of MemberDefOp operations defined in this struct.
Definition Struct.cpp:132
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op)
Returns the FuncDefOp operation that defines the constraints of the struct.
Definition Struct.cpp:144
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetParams(MlirType type)
Returns the parameter of a llzk::component::StructType as an ArrayAttr.
Definition Struct.cpp:70
#define LLZK_DECLARE_OP_ISA(what)
Definition Support.h:49
#define LLZK_DECLARE_OP_PREDICATE(op, name)
Definition Support.h:42
#define LLZK_DECLARE_OP_BUILD_METHOD(op,...)
Definition Support.h:38
#define LLZK_DECLARE_TYPE_ISA(what)
Definition Support.h:48
#define LLZK_DECLARE_NARY_OP_PREDICATE(op, name,...)
Definition Support.h:44
#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(op, suffix,...)
Definition Support.h:33