LLZK 2.1.1
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// Include the generated CAPI
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
38
39//===----------------------------------------------------------------------===//
40// FuncDefOp
41//===----------------------------------------------------------------------===//
42
45MLIR_CAPI_EXPORTED MlirOperation llzkFunction_FuncDefOpCreateWithAttrsAndArgAttrs(
46 MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nAttrs,
47 MlirNamedAttribute const *attrs, intptr_t nArgAttrs, MlirAttribute const *argAttrs
48);
49
51static inline MlirOperation llzkFunction_FuncDefOpCreateWithAttrs(
52 MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nAttrs,
53 MlirNamedAttribute const *attrs
54) {
56 loc, name, type, nAttrs, attrs, /*nArgAttrs=*/0, /*argAttrs=*/NULL
57 );
58}
59
62static inline MlirOperation llzkFunction_FuncDefOpCreateWithArgAttrs(
63 MlirLocation loc, MlirStringRef name, MlirType type, intptr_t nArgAttrs,
64 MlirAttribute const *argAttrs
65) {
67 loc, name, type, /*nAttrs=*/0, /*attrs=*/NULL, nArgAttrs, argAttrs
68 );
69}
70
72static inline MlirOperation
73llzkFunction_FuncDefOpCreateWithoutAttrs(MlirLocation loc, MlirStringRef name, MlirType type) {
74 return llzkFunction_FuncDefOpCreateWithAttrs(loc, name, type, /*nAttrs=*/0, /*attrs=*/NULL);
75}
76
78MLIR_CAPI_EXPORTED bool llzkFunction_FuncDefOpHasArgNameAttr(MlirOperation op, unsigned index);
79
82MLIR_CAPI_EXPORTED MlirAttribute
83llzkFunction_FuncDefOpGetArgNameAttr(MlirOperation op, unsigned index);
84
89MLIR_CAPI_EXPORTED void
90llzkFunction_FuncDefOpSetArgNameAttr(MlirOperation op, unsigned index, MlirAttribute attr);
91
95MLIR_CAPI_EXPORTED void
96llzkFunction_FuncDefOpSetArgName(MlirOperation op, unsigned index, MlirStringRef name);
97
98//===----------------------------------------------------------------------===//
99// CallOp
100//===----------------------------------------------------------------------===//
101
104 Function, CallOp, intptr_t numResults, MlirType const *results, MlirAttribute name,
105 intptr_t numOperands, MlirValue const *operands
106);
107
110 Function, CallOp, ToCallee, MlirOperation callee, intptr_t numOperands,
111 MlirValue const *operands
112);
113
116 Function, CallOp, WithMapOperands, intptr_t numResults, MlirType const *results,
117 MlirAttribute name, LlzkAffineMapOperandsBuilder mapOperands, intptr_t numArgOperands,
118 MlirValue const *argOperands
119);
120
123 Function, CallOp, ToCalleeWithMapOperands, MlirOperation callee,
124 LlzkAffineMapOperandsBuilder mapOperands, intptr_t numArgOperands, MlirValue const *argOperands
125);
126
129 Function, CallOp, WithTemplateParams, intptr_t numResults, MlirType const *results,
130 MlirAttribute name, intptr_t numTemplateParams, MlirAttribute const *templateParams,
131 intptr_t numArgOperands, MlirValue const *argOperands
132);
133
136 Function, CallOp, ToCalleeWithTemplateParams, MlirOperation callee, intptr_t numTemplateParams,
137 MlirAttribute const *templateParams, intptr_t numArgOperands, MlirValue const *argOperands
138);
139
140#ifdef __cplusplus
141}
142#endif
143
144#endif // LLZK_C_DIALECT_FUNCTION_H
MLIR_CAPI_EXPORTED MlirOperation llzkFunction_FuncDefOpCreateWithAttrsAndArgAttrs(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:48
MLIR_CAPI_EXPORTED bool llzkFunction_FuncDefOpHasArgNameAttr(MlirOperation op, unsigned index)
Returns true iff the argument at the given index has a function.arg_name attribute.
Definition Function.cpp:66
MLIR_CAPI_EXPORTED void llzkFunction_FuncDefOpSetArgName(MlirOperation op, unsigned index, MlirStringRef name)
Sets the function.arg_name attribute for the argument at the given index from a string value.
Definition Function.cpp:79
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Function, llzk__function)
Get reference to the LLZK function dialect.
MLIR_CAPI_EXPORTED MlirAttribute llzkFunction_FuncDefOpGetArgNameAttr(MlirOperation op, unsigned index)
Returns the function.arg_name StringAttr for the argument at the given index, or null if the argument...
Definition Function.cpp:70
MLIR_CAPI_EXPORTED void llzkFunction_FuncDefOpSetArgNameAttr(MlirOperation op, unsigned index, MlirAttribute attr)
Sets the function.arg_name attribute for the argument at the given index.
Definition Function.cpp:75
#define LLZK_DECLARE_SUFFIX_OP_BUILD_METHOD(dialect, op, suffix,...)
Definition Support.h:33
#define LLZK_DECLARE_OP_BUILD_METHOD(dialect, op,...)
Definition Support.h:38
Encapsulates the arguments related to affine maps that are common in operation constructors that supp...
Definition Support.h:103