LLZK 2.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
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
39
40//===----------------------------------------------------------------------===//
41// StructType
42//===----------------------------------------------------------------------===//
43
46MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGet(MlirAttribute name);
47
50MLIR_CAPI_EXPORTED
51MlirType llzkStruct_StructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params);
52
55MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGetWithAttrs(
56 MlirAttribute name, intptr_t numParams, MlirAttribute const *params
57);
58
68MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinition(
69 MlirType type, MlirOperation root, LlzkSymbolLookupResult *result
70);
71
79MLIR_CAPI_EXPORTED MlirLogicalResult llzkStructStructTypeGetDefinitionFromModule(
80 MlirType type, MlirModule root, LlzkSymbolLookupResult *result
81);
82
83//===----------------------------------------------------------------------===//
84// StructDefOp
85//===----------------------------------------------------------------------===//
86
88MLIR_CAPI_EXPORTED MlirBlock llzkStruct_StructDefOpGetBody(MlirOperation op);
89
91MLIR_CAPI_EXPORTED MlirType llzkStruct_StructDefOpGetType(MlirOperation op);
92
96MLIR_CAPI_EXPORTED MlirType
97llzkStruct_StructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute params);
98
102MLIR_CAPI_EXPORTED void llzkStruct_StructDefOpGetMemberDefs(MlirOperation op, MlirOperation *dst);
103
105MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumMemberDefs(MlirOperation op);
106
109MLIR_CAPI_EXPORTED const char *llzkStruct_StructDefOpGetHeaderString(
110 MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t)
111);
112
120MLIR_CAPI_EXPORTED void
121llzkStruct_StructDefOpGetTemplateParamOpNames(MlirOperation op, MlirAttribute *dst);
122
124MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateParamOpNames(MlirOperation op);
125
133MLIR_CAPI_EXPORTED void
134llzkStruct_StructDefOpGetTemplateExprOpNames(MlirOperation op, MlirAttribute *dst);
135
137MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateExprOpNames(MlirOperation op);
138
139//===----------------------------------------------------------------------===//
140// MemberReadOp
141//===----------------------------------------------------------------------===//
142
145 Struct, MemberReadOp, MlirType type, MlirValue component, MlirIdentifier memberName
146);
147
152 Struct, MemberReadOp, WithAffineMapDistance, MlirType type, MlirValue component,
153 MlirIdentifier memberName, MlirAffineMap affineMap, MlirValueRange mapOperands
154);
155
159 Struct, MemberReadOp, WithTemplateSymbolDistance, MlirType type, MlirValue component,
160 MlirIdentifier memberName, MlirStringRef paramName
161);
162
165 Struct, MemberReadOp, WithLiteralDistance, MlirType type, MlirValue component,
166 MlirIdentifier memberName, int64_t distance
167);
168
169#ifdef __cplusplus
170}
171#endif
172
173#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:51
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:59
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:103
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:129
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Struct, llzk__component)
Get reference to the LLZK struct dialect.
MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumMemberDefs(MlirOperation op)
Returns the number of MemberDefOp operations defined in this struct.
Definition Struct.cpp:114
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:69
MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateExprOpNames(MlirOperation op)
Returns the number of poly.expr operations defined within this template.
Definition Struct.cpp:149
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:99
MLIR_CAPI_EXPORTED MlirType llzkStruct_StructTypeGet(MlirAttribute name)
Creates a llzk::component::StructType.
Definition Struct.cpp:47
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:142
MLIR_CAPI_EXPORTED intptr_t llzkStruct_StructDefOpGetNumTemplateParamOpNames(MlirOperation op)
Returns the number of poly.param operations defined within this template.
Definition Struct.cpp:136
MLIR_CAPI_EXPORTED MlirBlock llzkStruct_StructDefOpGetBody(MlirOperation op)
Returns the single body Block within the StructDefOp's Region.
Definition Struct.cpp:95
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:85
MLIR_CAPI_EXPORTED void llzkStruct_StructDefOpGetMemberDefs(MlirOperation op, MlirOperation *dst)
Fills the given array with the MemberDefOp operations inside this struct.
Definition Struct.cpp:107
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:118
#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