LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Function.h
Go to the documentation of this file.
1//===-- Function.h - C API for Function 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// Function 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_FUNCTION_H
19#define LLZK_C_DIALECT_FUNCTION_H
20
21#include "llzk-c/Support.h"
22
23#include <mlir-c/IR.h>
24#include <mlir-c/Support.h>
25
26#include <stdint.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
33
34//===----------------------------------------------------------------------===//
35// FuncDefOp
36//===----------------------------------------------------------------------===//
37
40MLIR_CAPI_EXPORTED MlirOperation llzkFuncDefOpCreateWithAttrsAndArgAttrs(
41 MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nAttrs,
42 MlirNamedAttribute const *attrs, intptr_t nArgAttrs, MlirAttribute const *argAttrs
43);
44
46static inline MlirOperation llzkFuncDefOpCreateWithAttrs(
47 MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nAttrs,
48 MlirNamedAttribute const *attrs
49) {
51 loc, name, type, nAttrs, attrs, /*nArgAttrs=*/0, /*argAttrs=*/NULL
52 );
53}
54
56static inline MlirOperation
57llzkFuncDefOpCreate(MlirLocation loc, MlirStringRef name, MlirType type) {
58 return llzkFuncDefOpCreateWithAttrs(loc, name, type, /*nAttrs=*/0, /*attrs=*/NULL);
59}
60
63static inline MlirOperation llzkFuncDefOpCreateWithArgAttrs(
64 MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nArgAttrs,
65 MlirAttribute const *argAttrs
66) {
68 loc, name, type, /*nAttrs=*/0, /*attrs=*/NULL, nArgAttrs, argAttrs
69 );
70}
71
74
76LLZK_DECLARE_OP_PREDICATE(FuncDefOp, HasAllowConstraintAttr);
77
79MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowConstraintAttr(MlirOperation op, bool value);
80
82LLZK_DECLARE_OP_PREDICATE(FuncDefOp, HasAllowWitnessAttr);
83
85MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowWitnessAttr(MlirOperation op, bool value);
86
88LLZK_DECLARE_NARY_OP_PREDICATE(FuncDefOp, HasArgIsPub, unsigned arg);
89
91MLIR_CAPI_EXPORTED MlirAttribute llzkFuncDefOpGetFullyQualifiedName(MlirOperation op);
92
94LLZK_DECLARE_OP_PREDICATE(FuncDefOp, NameIsCompute);
95
97LLZK_DECLARE_OP_PREDICATE(FuncDefOp, NameIsConstrain);
98
100LLZK_DECLARE_OP_PREDICATE(FuncDefOp, IsInStruct);
101
103LLZK_DECLARE_OP_PREDICATE(FuncDefOp, IsStructCompute);
104
106LLZK_DECLARE_OP_PREDICATE(FuncDefOp, IsStructConstrain);
107
110MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromCompute(MlirOperation op);
111
114MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromConstrain(MlirOperation op);
115
117MLIR_CAPI_EXPORTED MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op);
118
119//===----------------------------------------------------------------------===//
120// CallOp
121//===----------------------------------------------------------------------===//
122
125 CallOp, intptr_t numResults, MlirType const *results, MlirAttribute name, intptr_t numOperands,
126 MlirValue const *operands
127);
128
131 CallOp, ToCallee, MlirOperation callee, intptr_t numOperands, MlirValue const *operands
132);
133
136 CallOp, WithMapOperands, intptr_t numResults, MlirType const *results, MlirAttribute name,
137 intptr_t numMapOperands, MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap,
138 intptr_t numArgOperands, MlirValue const *argOperands
139);
140
143 CallOp, WithMapOperandsAndDims, intptr_t numResults, MlirType const *results,
144 MlirAttribute name, intptr_t numMapOperands, MlirValueRange const *mapOperands,
145 intptr_t numDimsPermMapLength, int32_t const *numDimsPerMap, intptr_t numArgOperands,
146 MlirValue const *argOperands
147);
148
151 CallOp, ToCalleeWithMapOperands, MlirOperation callee, intptr_t numMapOperands,
152 MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap, intptr_t numArgOperands,
153 MlirValue const *argOperands
154);
155
158 CallOp, ToCalleeWithMapOperandsAndDims, MlirOperation callee, intptr_t numMapOperands,
159 MlirValueRange const *mapOperands, intptr_t numDimsPermMapLength, int32_t const *numDimsPerMap,
160 intptr_t numArgOperands, MlirValue const *argOperands
161);
162
165
167MLIR_CAPI_EXPORTED MlirType llzkCallOpGetCalleeType(MlirOperation op);
168
170LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsCompute);
171
173LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsConstrain);
174
176LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsStructCompute);
177
179LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsStructConstrain);
180
183MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromCompute(MlirOperation op);
184
187MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromConstrain(MlirOperation op);
188
190MLIR_CAPI_EXPORTED MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op);
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif
MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromCompute(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:109
MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowConstraintAttr(MlirOperation op, bool value)
Sets the allow_constraint attribute in the FuncDefOp operation.
Definition Function.cpp:67
MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromConstrain(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:243
MLIR_CAPI_EXPORTED MlirAttribute llzkFuncDefOpGetFullyQualifiedName(MlirOperation op)
Returns the fully qualified name of the function.
Definition Function.cpp:83
MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromCompute(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:237
MLIR_CAPI_EXPORTED MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the callee is the compute function, returns its StructType result.
Definition Function.cpp:247
MLIR_CAPI_EXPORTED MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the function is the compute function, returns its StructType result.
Definition Function.cpp:120
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Function, llzk__function)
MLIR_CAPI_EXPORTED MlirType llzkCallOpGetCalleeType(MlirOperation op)
Returns the FunctionType of the callee.
Definition Function.cpp:215
MLIR_CAPI_EXPORTED MlirOperation llzkFuncDefOpCreateWithAttrsAndArgAttrs(MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nAttrs, MlirNamedAttribute const *attrs, intptr_t nArgAttrs, MlirAttribute const *argAttrs)
Creates a FuncDefOp with the given attributes and argument attributes.
Definition Function.cpp:45
MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowWitnessAttr(MlirOperation op, bool value)
Sets the allow_witness attribute in the FuncDefOp operation.
Definition Function.cpp:75
MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromConstrain(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:115
MlirStringRef name
#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_NARY_OP_PREDICATE(op, name,...)
Definition Support.h:43
#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(op, suffix,...)
Definition Support.h:32