LLZK 0.1.0
Veridise's ZK Language IR
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
62//===----------------------------------------------------------------------===//
63// StructDefOp
64//===----------------------------------------------------------------------===//
65
68
70MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetType(MlirOperation op);
71
75MLIR_CAPI_EXPORTED MlirType
76llzkStructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute params);
77
79MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetFieldDef(MlirOperation op, MlirStringRef name);
80
84MLIR_CAPI_EXPORTED void llzkStructDefOpGetFieldDefs(MlirOperation op, MlirOperation *dst);
85
87MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumFieldDefs(MlirOperation op);
88
90MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op);
91
93MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetComputeFuncOp(MlirOperation op);
94
96MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op);
97
100MLIR_CAPI_EXPORTED const char *
101llzkStructDefOpGetHeaderString(MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t));
102
104LLZK_DECLARE_NARY_OP_PREDICATE(StructDefOp, HasParamName, MlirStringRef name);
105
107MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op);
108
110LLZK_DECLARE_OP_PREDICATE(StructDefOp, IsMainComponent);
111
112//===----------------------------------------------------------------------===//
113// FieldDefOp
114//===----------------------------------------------------------------------===//
115
118
120LLZK_DECLARE_OP_PREDICATE(FieldDefOp, HasPublicAttr);
121
123MLIR_CAPI_EXPORTED void llzkFieldDefOpSetPublicAttr(MlirOperation op, bool value);
124
125//===----------------------------------------------------------------------===//
126// FieldReadOp
127//===----------------------------------------------------------------------===//
128
131 FieldReadOp, MlirType type, MlirValue component, MlirStringRef fieldName
132);
133
138 FieldReadOp, WithAffineMapDistance, MlirType type, MlirValue component, MlirStringRef fieldName,
139 MlirAffineMap affineMap, MlirValueRange mapOperands, int32_t nDimensions
140);
141
145 FieldReadOp, WithConstParamDistance, MlirType type, MlirValue component,
146 MlirStringRef fieldName, MlirStringRef paramName
147);
148
151 FieldReadOp, WithLiteralDistance, MlirType type, MlirValue component, MlirStringRef fieldName,
152 int64_t distance
153);
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif
MlirStringRef name
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:111
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGetWithArrayAttr(MlirAttribute name, MlirAttribute params)
Creates a llzk::component::StructType with an ArrayAttr as parameters.
Definition Struct.cpp:44
MLIR_CAPI_EXPORTED void llzkStructDefOpGetFieldDefs(MlirOperation op, MlirOperation *dst)
Fills the given array with the FieldDefOp operations inside this struct.
Definition Struct.cpp:88
MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumFieldDefs(MlirOperation op)
Returns the number of FieldDefOp operations defined in this struct.
Definition Struct.cpp:94
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:51
MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op)
Returns a StringAttr with the fully qualified name of the struct.
Definition Struct.cpp:125
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:102
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetName(MlirType type)
Returns the fully qualified name of a llzk::component::StructType.
Definition Struct.cpp:60
MLIR_CAPI_EXPORTED MlirType llzkStructTypeGet(MlirAttribute name)
Creates a llzk::component::StructType.
Definition Struct.cpp:40
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:74
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:78
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetFieldDef(MlirOperation op, MlirStringRef name)
Returns the operation that defines the field with the given name, if present.
Definition Struct.cpp:83
MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op)
Returns true if the struct has fields marked as columns.
Definition Struct.cpp:98
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op)
Returns the FuncDefOp operation that defines the constraints of the struct.
Definition Struct.cpp:106
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetParams(MlirType type)
Returns the parameter of a llzk::component::StructType as an ArrayAttr.
Definition Struct.cpp:64
MLIR_CAPI_EXPORTED void llzkFieldDefOpSetPublicAttr(MlirOperation op, bool value)
Sets the public attribute in the given field.
Definition Struct.cpp:143
#define LLZK_DECLARE_OP_ISA(what)
Definition Support.h:48
#define LLZK_DECLARE_OP_PREDICATE(op, name)
Definition Support.h:41
#define LLZK_DECLARE_OP_BUILD_METHOD(op,...)
Definition Support.h:37
#define LLZK_DECLARE_TYPE_ISA(what)
Definition Support.h:47
#define LLZK_DECLARE_NARY_OP_PREDICATE(op, name,...)
Definition Support.h:43
#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(op, suffix,...)
Definition Support.h:32