LLZK 3.0.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// Include the generated CAPI
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
40
41//===----------------------------------------------------------------------===//
42// StructType
43//===----------------------------------------------------------------------===//
44
47MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGet(MlirAttribute name);
48
51MLIR_CAPI_EXPORTED
52MlirType llzkStruct_StructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params);
53
56MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGetWithAttrs(
57 MlirAttribute name, intptr_t numParams, MlirAttribute const *params
58);
59
69MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinition(
70 MlirType type, MlirOperation root, LlzkSymbolLookupResult *result
71);
72
80MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinitionFromModule(
81 MlirType type, MlirModule root, LlzkSymbolLookupResult *result
82);
83
84//===----------------------------------------------------------------------===//
85// StructDefOp
86//===----------------------------------------------------------------------===//
87
89MLIR_CAPI_EXPORTED MlirBlock llzkStruct_StructDefOpGetBody(MlirOperation op);
90
92MLIR_CAPI_EXPORTED MlirType llzkStruct_StructDefOpGetType(MlirOperation op);
93
97MLIR_CAPI_EXPORTED MlirType
98llzkStruct_StructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute params);
99
103MLIR_CAPI_EXPORTED void llzkStruct_StructDefOpGetMemberDefs(MlirOperation op, MlirOperation *dst);
104
106MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumMemberDefs(MlirOperation op);
107
110MLIR_CAPI_EXPORTED const char *llzkStruct_StructDefOpGetHeaderString(
111 MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t)
112);
113
121MLIR_CAPI_EXPORTED void
122llzkStruct_StructDefOpGetTemplateParamOpNames(MlirOperation op, MlirAttribute *dst);
123
125MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateParamOpNames(MlirOperation op);
126
134MLIR_CAPI_EXPORTED void
135llzkStruct_StructDefOpGetTemplateExprOpNames(MlirOperation op, MlirAttribute *dst);
136
138MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateExprOpNames(MlirOperation op);
139
140//===----------------------------------------------------------------------===//
141// MemberDefOp
142//===----------------------------------------------------------------------===//
143
146 Struct, MemberDefOp, MlirStringRef name, MlirType type, bool isSignal, bool isColumn
147);
148
151 Struct, MemberDefOp, WithAttrs, MlirAttribute name, MlirAttribute type, bool isSignal,
152 bool isColumn
153);
154
158 Struct, MemberDefOp, WithNamedAttrs, intptr_t numAttrs, MlirNamedAttribute const *attrs,
159 bool isSignal, bool isColumn
160);
161
163MLIR_CAPI_EXPORTED bool llzkStruct_MemberDefOpGetColumnValue(MlirOperation op);
164
166MLIR_CAPI_EXPORTED void llzkStruct_MemberDefOpSetColumnValue(MlirOperation op, bool newValue);
167
169MLIR_CAPI_EXPORTED bool llzkStruct_MemberDefOpGetSignalValue(MlirOperation op);
170
172MLIR_CAPI_EXPORTED void llzkStruct_MemberDefOpSetSignalValue(MlirOperation op, bool newValue);
173
174//===----------------------------------------------------------------------===//
175// MemberReadOp
176//===----------------------------------------------------------------------===//
177
180 Struct, MemberReadOp, MlirType type, MlirValue component, MlirIdentifier memberName
181);
182
187 Struct, MemberReadOp, WithAffineMapDistance, MlirType type, MlirValue component,
188 MlirIdentifier memberName, MlirAffineMap affineMap, MlirValueRange mapOperands
189);
190
194 Struct, MemberReadOp, WithTemplateSymbolDistance, MlirType type, MlirValue component,
195 MlirIdentifier memberName, MlirStringRef paramName
196);
197
200 Struct, MemberReadOp, WithLiteralDistance, MlirType type, MlirValue component,
201 MlirIdentifier memberName, int64_t distance
202);
203
204#ifdef __cplusplus
205}
206#endif
207
208#endif // LLZK_C_DIALECT_STRUCT_H
MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params)
Creates a llzk::component::StructType with an ArrayAttr as parameters.
Definition Struct.cpp:58
MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGetWithAttrs(MlirAttribute name, intptr_t numParams, MlirAttribute const *params)
Creates a llzk::component::StructType with an array of parameters.
Definition Struct.cpp:66
MLIR_CAPI_EXPORTED MlirType llzkStruct_StructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute params)
Returns the associated StructType to this op using the given const params instead of the parameters d...
Definition Struct.cpp:110
MLIR_CAPI_EXPORTED 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....
Definition Struct.cpp:136
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Struct, llzk__component)
Get reference to the LLZK struct dialect.
MLIR_CAPI_EXPORTED bool llzkStruct_MemberDefOpGetSignalValue(MlirOperation op)
Returns whether this member is stored as a witness signal.
Definition Struct.cpp:211
MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumMemberDefs(MlirOperation op)
Returns the number of MemberDefOp operations defined in this struct.
Definition Struct.cpp:121
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:76
MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateExprOpNames(MlirOperation op)
Returns the number of poly.expr operations defined within this template.
Definition Struct.cpp:156
MLIR_CAPI_EXPORTED MlirType llzkStruct_StructDefOpGetType(MlirOperation op)
Returns the associated StructType to this op using the const params defined by the op.
Definition Struct.cpp:106
MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGet(MlirAttribute name)
Creates a llzk::component::StructType.
Definition Struct.cpp:54
MLIR_CAPI_EXPORTED 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....
Definition Struct.cpp:149
MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateParamOpNames(MlirOperation op)
Returns the number of poly.param operations defined within this template.
Definition Struct.cpp:143
MLIR_CAPI_EXPORTED void llzkStruct_MemberDefOpSetColumnValue(MlirOperation op, bool newValue)
Adds or removes the unit column attribute according to newValue.
Definition Struct.cpp:207
MLIR_CAPI_EXPORTED MlirBlock llzkStruct_StructDefOpGetBody(MlirOperation op)
Returns the single body Block within the StructDefOp's Region.
Definition Struct.cpp:102
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:92
MLIR_CAPI_EXPORTED void llzkStruct_StructDefOpGetMemberDefs(MlirOperation op, MlirOperation *dst)
Fills the given array with the MemberDefOp operations inside this struct.
Definition Struct.cpp:114
MLIR_CAPI_EXPORTED bool llzkStruct_MemberDefOpGetColumnValue(MlirOperation op)
Returns whether this member supports offset table accesses.
Definition Struct.cpp:203
MLIR_CAPI_EXPORTED void llzkStruct_MemberDefOpSetSignalValue(MlirOperation op, bool newValue)
Adds or removes the unit signal attribute according to newValue.
Definition Struct.cpp:215
MLIR_CAPI_EXPORTED const char * llzkStruct_StructDefOpGetHeaderString(MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t))
Returns the header string of the struct.
Definition Struct.cpp:125
#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(dialect, op, suffix,...)
Definition Support.h:33
#define LLZK_DECLARE_OP_BUILD_METHOD(dialect, op,...)
Definition Support.h:38
Owned result of an LLZK symbol lookup.
Definition Support.h:56
Representation of an mlir::ValueRange
Definition Support.h:47