LLZK 0.1.0
An open-source IR for Zero Knowledge (ZK) circuits
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_OP_PREDICATE(FuncDefOp, HasAllowNonNativeFieldOpsAttr);
89
91MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowNonNativeFieldOpsAttr(MlirOperation op, bool value);
92
94LLZK_DECLARE_NARY_OP_PREDICATE(FuncDefOp, HasArgIsPub, unsigned arg);
95
97MLIR_CAPI_EXPORTED MlirAttribute llzkFuncDefOpGetFullyQualifiedName(MlirOperation op);
98
100LLZK_DECLARE_OP_PREDICATE(FuncDefOp, NameIsCompute);
101
103LLZK_DECLARE_OP_PREDICATE(FuncDefOp, NameIsConstrain);
104
106LLZK_DECLARE_OP_PREDICATE(FuncDefOp, IsInStruct);
107
109LLZK_DECLARE_OP_PREDICATE(FuncDefOp, IsStructCompute);
110
112LLZK_DECLARE_OP_PREDICATE(FuncDefOp, IsStructConstrain);
113
116MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromCompute(MlirOperation op);
117
120MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromConstrain(MlirOperation op);
121
123MLIR_CAPI_EXPORTED MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op);
124
125//===----------------------------------------------------------------------===//
126// CallOp
127//===----------------------------------------------------------------------===//
128
131 CallOp, intptr_t numResults, MlirType const *results, MlirAttribute name, intptr_t numOperands,
132 MlirValue const *operands
133);
134
137 CallOp, ToCallee, MlirOperation callee, intptr_t numOperands, MlirValue const *operands
138);
139
142 CallOp, WithMapOperands, intptr_t numResults, MlirType const *results, MlirAttribute name,
143 LlzkAffineMapOperandsBuilder mapOperands, intptr_t numArgOperands, MlirValue const *argOperands
144);
145
148 CallOp, ToCalleeWithMapOperands, MlirOperation callee, LlzkAffineMapOperandsBuilder mapOperands,
149 intptr_t numArgOperands, MlirValue const *argOperands
150);
151
154
156MLIR_CAPI_EXPORTED MlirType llzkCallOpGetCalleeType(MlirOperation op);
157
159LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsCompute);
160
162LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsConstrain);
163
165LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsStructCompute);
166
168LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsStructConstrain);
169
172MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromCompute(MlirOperation op);
173
176MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromConstrain(MlirOperation op);
177
179MLIR_CAPI_EXPORTED MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op);
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif
MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromCompute(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:120
MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowConstraintAttr(MlirOperation op, bool value)
Sets the allow_constraint attribute in the FuncDefOp operation.
Definition Function.cpp:70
MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromConstrain(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:234
MLIR_CAPI_EXPORTED MlirAttribute llzkFuncDefOpGetFullyQualifiedName(MlirOperation op)
Returns the fully qualified name of the function.
Definition Function.cpp:94
MLIR_CAPI_EXPORTED MlirValue llzkCallOpGetSelfValueFromCompute(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:228
MLIR_CAPI_EXPORTED MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the callee is the compute function, returns its StructType result.
Definition Function.cpp:238
MLIR_CAPI_EXPORTED MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the function is the compute function, returns its StructType result.
Definition Function.cpp:131
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Function, llzk__function)
MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowNonNativeFieldOpsAttr(MlirOperation op, bool value)
Sets the allow_non_native_field_ops attribute in the FuncDefOp operation.
Definition Function.cpp:86
MLIR_CAPI_EXPORTED MlirType llzkCallOpGetCalleeType(MlirOperation op)
Returns the FunctionType of the callee.
Definition Function.cpp:206
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:46
MLIR_CAPI_EXPORTED void llzkFuncDefOpSetAllowWitnessAttr(MlirOperation op, bool value)
Sets the allow_witness attribute in the FuncDefOp operation.
Definition Function.cpp:78
MLIR_CAPI_EXPORTED MlirValue llzkFuncDefOpGetSelfValueFromConstrain(MlirOperation op)
Return the "self" value (i.e.
Definition Function.cpp:126
#define LLZK_DECLARE_OP_ISA(what)
Definition Support.h:49
#define LLZK_DECLARE_OP_PREDICATE(op, name)
Definition Support.h:42
#define LLZK_DECLARE_OP_BUILD_METHOD(op,...)
Definition Support.h:38
#define LLZK_DECLARE_NARY_OP_PREDICATE(op, name,...)
Definition Support.h:44
#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(op, suffix,...)
Definition Support.h:33
Encapsulates the arguments related to affine maps that are common in operation constructors that supp...
Definition Support.h:105