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
109MLIR_CAPI_EXPORTED MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op);
110
111//===----------------------------------------------------------------------===//
112// CallOp
113//===----------------------------------------------------------------------===//
114
117 CallOp, intptr_t numResults, MlirType const *results, MlirAttribute name, intptr_t numOperands,
118 MlirValue const *operands
119);
120
123 CallOp, ToCallee, MlirOperation callee, intptr_t numOperands, MlirValue const *operands
124);
125
128 CallOp, WithMapOperands, intptr_t numResults, MlirType const *results, MlirAttribute name,
129 intptr_t numMapOperands, MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap,
130 intptr_t numArgOperands, MlirValue const *argOperands
131);
132
135 CallOp, WithMapOperandsAndDims, intptr_t numResults, MlirType const *results,
136 MlirAttribute name, intptr_t numMapOperands, MlirValueRange const *mapOperands,
137 intptr_t numDimsPermMapLength, int32_t const *numDimsPerMap, intptr_t numArgOperands,
138 MlirValue const *argOperands
139);
140
143 CallOp, ToCalleeWithMapOperands, MlirOperation callee, intptr_t numMapOperands,
144 MlirValueRange const *mapOperands, MlirAttribute numDimsPerMap, intptr_t numArgOperands,
145 MlirValue const *argOperands
146);
147
150 CallOp, ToCalleeWithMapOperandsAndDims, MlirOperation callee, intptr_t numMapOperands,
151 MlirValueRange const *mapOperands, intptr_t numDimsPermMapLength, int32_t const *numDimsPerMap,
152 intptr_t numArgOperands, MlirValue const *argOperands
153);
154
157
159MLIR_CAPI_EXPORTED MlirType llzkCallOpGetCalleeType(MlirOperation op);
160
162LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsCompute);
163
165LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsConstrain);
166
168LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsStructCompute);
169
171LLZK_DECLARE_OP_PREDICATE(CallOp, CalleeIsStructConstrain);
172
174MLIR_CAPI_EXPORTED MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op);
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif
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 MlirAttribute llzkFuncDefOpGetFullyQualifiedName(MlirOperation op)
Returns the fully qualified name of the function.
Definition Function.cpp:83
MLIR_CAPI_EXPORTED MlirType llzkCallOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the callee is the compute function, returns its StructType result.
Definition Function.cpp:223
MLIR_CAPI_EXPORTED MlirType llzkFuncDefOpGetSingleResultTypeOfCompute(MlirOperation op)
Assuming the function is the compute function, returns its StructType result.
Definition Function.cpp:108
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Function, llzk__function)
MLIR_CAPI_EXPORTED MlirType llzkCallOpGetCalleeType(MlirOperation op)
Returns the FunctionType of the callee.
Definition Function.cpp:203
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
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