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 MlirRegion llzkStructDefOpGetBodyRegion(MlirOperation op);
71
73MLIR_CAPI_EXPORTED MlirBlock llzkStructDefOpGetBody(MlirOperation op);
74
76MLIR_CAPI_EXPORTED MlirType llzkStructDefOpGetType(MlirOperation op);
77
81MLIR_CAPI_EXPORTED MlirType
82llzkStructDefOpGetTypeWithParams(MlirOperation op, MlirAttribute params);
83
85MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetFieldDef(MlirOperation op, MlirStringRef name);
86
90MLIR_CAPI_EXPORTED void llzkStructDefOpGetFieldDefs(MlirOperation op, MlirOperation *dst);
91
93MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumFieldDefs(MlirOperation op);
94
96MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op);
97
99MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetComputeFuncOp(MlirOperation op);
100
102MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op);
103
106MLIR_CAPI_EXPORTED const char *
107llzkStructDefOpGetHeaderString(MlirOperation op, intptr_t *dstSize, char *(*alloc_string)(size_t));
108
110LLZK_DECLARE_NARY_OP_PREDICATE(StructDefOp, HasParamName, MlirStringRef name);
111
113MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op);
114
116LLZK_DECLARE_OP_PREDICATE(StructDefOp, IsMainComponent);
117
118//===----------------------------------------------------------------------===//
119// FieldDefOp
120//===----------------------------------------------------------------------===//
121
124
126LLZK_DECLARE_OP_PREDICATE(FieldDefOp, HasPublicAttr);
127
129MLIR_CAPI_EXPORTED void llzkFieldDefOpSetPublicAttr(MlirOperation op, bool value);
130
131//===----------------------------------------------------------------------===//
132// FieldReadOp
133//===----------------------------------------------------------------------===//
134
137 FieldReadOp, MlirType type, MlirValue component, MlirStringRef fieldName
138);
139
144 FieldReadOp, WithAffineMapDistance, MlirType type, MlirValue component, MlirStringRef fieldName,
145 MlirAffineMap affineMap, MlirValueRange mapOperands, int32_t nDimensions
146);
147
151 FieldReadOp, WithConstParamDistance, MlirType type, MlirValue component,
152 MlirStringRef fieldName, MlirStringRef paramName
153);
154
157 FieldReadOp, WithLiteralDistance, MlirType type, MlirValue component, MlirStringRef fieldName,
158 int64_t distance
159);
160
161#ifdef __cplusplus
162}
163#endif
164
165#endif
MlirStringRef name
Definition Poly.cpp:48
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:122
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:99
MLIR_CAPI_EXPORTED MlirRegion llzkStructDefOpGetBodyRegion(MlirOperation op)
Returns the single body Region of the StructDefOp.
Definition Struct.cpp:78
MLIR_CAPI_EXPORTED intptr_t llzkStructDefOpGetNumFieldDefs(MlirOperation op)
Returns the number of FieldDefOp operations defined in this struct.
Definition Struct.cpp:105
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:53
MLIR_CAPI_EXPORTED MlirAttribute llzkStructDefOpGetFullyQualifiedName(MlirOperation op)
Returns a StringAttr with the fully qualified name of the struct.
Definition Struct.cpp:136
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:113
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetName(MlirType type)
Returns the fully qualified name of a llzk::component::StructType.
Definition Struct.cpp:64
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:86
MLIR_CAPI_EXPORTED MlirBlock llzkStructDefOpGetBody(MlirOperation op)
Returns the single body Block within the StructDefOp's Region.
Definition Struct.cpp:82
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:90
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:94
MlirLogicalResult llzkStructDefOpGetHasColumns(MlirOperation op)
Returns true if the struct has fields marked as columns.
Definition Struct.cpp:109
MLIR_CAPI_EXPORTED MlirOperation llzkStructDefOpGetConstrainFuncOp(MlirOperation op)
Returns the FuncDefOp operation that defines the constraints of the struct.
Definition Struct.cpp:117
MLIR_CAPI_EXPORTED MlirAttribute llzkStructTypeGetParams(MlirType type)
Returns the parameter of a llzk::component::StructType as an ArrayAttr.
Definition Struct.cpp:68
MLIR_CAPI_EXPORTED void llzkFieldDefOpSetPublicAttr(MlirOperation op, bool value)
Sets the public attribute in the given field.
Definition Struct.cpp:154
#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