LLZK 0.1.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
POD.h
Go to the documentation of this file.
1//===-- POD.h - C API for POD dialect -----------------------------*- C -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2026 Project LLZK
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9//
10// This header declares the C interface for registering and accessing the
11// POD 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_POD_H
19#define LLZK_C_DIALECT_POD_H
20
21#include "llzk-c/Support.h"
22
23#include <mlir-c/BuiltinAttributes.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// Auxiliary types
37//===----------------------------------------------------------------------===//
38
39typedef struct LlzkRecordValue {
40 MlirStringRef name;
41 MlirValue value;
43
44//===----------------------------------------------------------------------===//
45// RecordAttr
46//===----------------------------------------------------------------------===//
47
49MLIR_CAPI_EXPORTED MlirAttribute llzkRecordAttrGet(MlirStringRef name, MlirType type);
50
53
55MLIR_CAPI_EXPORTED MlirStringRef llzkRecordAttrGetName(MlirAttribute attr);
56
58MLIR_CAPI_EXPORTED MlirAttribute llzkRecordAttrGetNameSym(MlirAttribute attr);
59
61MLIR_CAPI_EXPORTED MlirType llzkRecordAttrGetType(MlirAttribute attr);
62
63//===----------------------------------------------------------------------===//
64// PodType
65//===----------------------------------------------------------------------===//
66
68MLIR_CAPI_EXPORTED MlirType
69llzkPodTypeGet(MlirContext context, intptr_t nRecords, MlirAttribute const *records);
70
72MLIR_CAPI_EXPORTED MlirType llzkPodTypeGetFromInitialValues(
73 MlirContext context, intptr_t nRecords, LlzkRecordValue const *records
74);
75
78
80MLIR_CAPI_EXPORTED intptr_t llzkPodTypeGetNumRecords(MlirType type);
81
86MLIR_CAPI_EXPORTED void llzkPodTypeGetRecords(MlirType type, MlirAttribute *dst);
87
89MLIR_CAPI_EXPORTED MlirAttribute llzkPodTypeGetNthRecord(MlirType type, intptr_t n);
90
95MLIR_CAPI_EXPORTED MlirType llzkPodTypeLookupRecord(MlirType type, MlirStringRef name);
96
101MLIR_CAPI_EXPORTED MlirType
102llzkPodTypeLookupRecordWithinLocation(MlirType type, MlirStringRef name, MlirLocation loc);
103
108MLIR_CAPI_EXPORTED MlirType
109llzkPodTypeLookupRecordWithinOperation(MlirType type, MlirStringRef name, MlirOperation op);
110
111//===----------------------------------------------------------------------===//
112// NewPodOp
113//===----------------------------------------------------------------------===//
114
119 NewPodOp, InferredFromInitialValues, intptr_t nValues, LlzkRecordValue const *values
120);
121
126 NewPodOp, MlirType type, intptr_t nValues, LlzkRecordValue const *values
127);
128
133 NewPodOp, WithMapOperands, MlirType type, intptr_t nValues, LlzkRecordValue const *values,
135);
136
139
140//===----------------------------------------------------------------------===//
141// ReadPodOp
142//===----------------------------------------------------------------------===//
143
146
147//===----------------------------------------------------------------------===//
148// WritePodOp
149//===----------------------------------------------------------------------===//
150
153
154#ifdef __cplusplus
155}
156#endif
157
158#endif
MLIR_CAPI_EXPORTED MlirType llzkPodTypeLookupRecordWithinOperation(MlirType type, MlirStringRef name, MlirOperation op)
Lookups a record type by name.
Definition POD.cpp:136
MLIR_CAPI_EXPORTED MlirType llzkRecordAttrGetType(MlirAttribute attr)
Returns the type of the record.
Definition POD.cpp:69
MLIR_CAPI_EXPORTED MlirType llzkPodTypeLookupRecord(MlirType type, MlirStringRef name)
Lookups a record type by name.
Definition POD.cpp:119
MLIR_CAPI_EXPORTED MlirAttribute llzkRecordAttrGet(MlirStringRef name, MlirType type)
Creates a new llzk::pod::RecordAttr.
Definition POD.cpp:54
MLIR_CAPI_EXPORTED void llzkPodTypeGetRecords(MlirType type, MlirAttribute *dst)
Writes the records into the given array that must have been previously allocated with enough space.
Definition POD.cpp:98
MLIR_CAPI_EXPORTED MlirStringRef llzkRecordAttrGetName(MlirAttribute attr)
Returns the name of the record.
Definition POD.cpp:61
MLIR_CAPI_EXPORTED MlirType llzkPodTypeLookupRecordWithinLocation(MlirType type, MlirStringRef name, MlirLocation loc)
Lookups a record type by name.
Definition POD.cpp:128
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(POD, llzk__pod)
MLIR_CAPI_EXPORTED MlirType llzkPodTypeGetFromInitialValues(MlirContext context, intptr_t nRecords, LlzkRecordValue const *records)
Creates an llzk::pod::PodType using a list of values for inferring the records.
Definition POD.cpp:85
MLIR_CAPI_EXPORTED MlirAttribute llzkPodTypeGetNthRecord(MlirType type, intptr_t n)
Returns the n-th record in the struct.
Definition POD.cpp:104
MLIR_CAPI_EXPORTED MlirAttribute llzkRecordAttrGetNameSym(MlirAttribute attr)
Returns the name of the record as a flat symbol attribute.
Definition POD.cpp:65
MLIR_CAPI_EXPORTED MlirType llzkPodTypeGet(MlirContext context, intptr_t nRecords, MlirAttribute const *records)
Creates an llzk::pod::PodType using a list of attributes as records.
Definition POD.cpp:77
MLIR_CAPI_EXPORTED intptr_t llzkPodTypeGetNumRecords(MlirType type)
Returns the number of records in the struct.
Definition POD.cpp:94
#define LLZK_DECLARE_OP_ISA(what)
Definition Support.h:49
#define LLZK_DECLARE_ATTR_ISA(what)
Definition Support.h:50
#define LLZK_DECLARE_OP_BUILD_METHOD(op,...)
Definition Support.h:38
#define LLZK_DECLARE_TYPE_ISA(what)
Definition Support.h:48
#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
MlirValue value
Definition POD.h:41
MlirStringRef name
Definition POD.h:40