LLZK 0.1.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Types.td
Go to the documentation of this file.
1//===-- Types.td -------------------------------------------*- tablegen -*-===//
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#ifndef LLZK_POD_TYPES
11#define LLZK_POD_TYPES
12
13include "llzk/Dialect/Shared/Types.td"
14include "llzk/Dialect/POD/IR/Dialect.td"
15include "llzk/Dialect/POD/IR/Attrs.td"
16
17include "mlir/IR/AttrTypeBase.td"
18include "mlir/IR/BuiltinTypes.td"
19include "mlir/Interfaces/MemorySlotInterfaces.td"
20include "mlir/IR/BuiltinTypeInterfaces.td"
21
22class PODDialectType<string name, string typeMnemonic, list<Trait> traits = []>
23 : TypeDef<PODDialect, name, traits> {
24 let mnemonic = typeMnemonic;
25}
26
27def LLZK_PODType : PODDialectType<"Pod", "type"> {
28 let summary = "plain-old-data struct";
29 let description = [{
30 Contains a list of `RecordAttr` defining structure of a pod.
31 The order of records in the pod matters and each record must have a unique name.
32 It is possible to have a pod with no records.
33
34 Two `PODType` types unify if they have the same record names, defined in the
35 same order, and if the types of corresponding records unify.
36
37 This type can be used in the `struct.member` op, and it can be declared as a column,
38 in which case that annotation is also implied on the inner records (except those that
39 cannot be column such as `string.type` records).
40
41 ```llzk
42 // Type with no records.
43 !pod.type
44
45 // Type with two records of felt type.
46 !pod.type<[@a: !felt.type, @b: !felt.type]>
47 ```
48 }];
49
50 let parameters =
51 (ins ArrayRefParameter<"::llzk::pod::RecordAttr",
52 "List of records in the pod">:$records);
53
54 let genVerifyDecl = 1;
55 let assemblyFormat = "`<` custom<PodType>($records) `>`";
56
57 let extraClassDeclaration = [{
58 /// Creates a new type from a set of initialized records.
59 ///
60 /// The records are derived from the names and the types of the values.
61 static PodType fromInitialValues(::mlir::MLIRContext *ctx, InitializedRecords init);
62
63 /// Searches a record by name.
64 ///
65 /// If you plan to make several queries to this type, it's better to generate the map
66 /// once via `getRecordMap()` and query it instead of repeatedly calling `getRecord()`.
67 ::llvm::FailureOr<::mlir::Type> getRecord(::llvm::StringRef name, ::llvm::function_ref<::mlir::InFlightDiagnostic()>) const;
68
69 /// Returns the records in map form.
70 ///
71 /// If you plan to make several queries to this type, it's better to generate the map
72 /// once via `getRecordMap()` and query it instead of repeatedly calling `getRecord()`.
73 ::llvm::StringMap<::mlir::Type> getRecordMap() const;
74 }];
75}
76
77#endif // LLZK_POD_TYPES