1//===-- Types.td -------------------------------------------*- tablegen -*-===//
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
8//===----------------------------------------------------------------------===//
13include "llzk/Dialect/Shared/Types.td"
14include "llzk/Dialect/POD/IR/Dialect.td"
15include "llzk/Dialect/POD/IR/Attrs.td"
17include "mlir/IR/AttrTypeBase.td"
18include "mlir/IR/BuiltinTypes.td"
19include "mlir/Interfaces/MemorySlotInterfaces.td"
20include "mlir/IR/BuiltinTypeInterfaces.td"
22class PODDialectType<string name, string typeMnemonic, list<Trait> traits = []>
23 : TypeDef<PODDialect, name, traits> {
24 let mnemonic = typeMnemonic;
27def LLZK_PODType : PODDialectType<"Pod", "type"> {
28 let summary = "plain-old-data struct";
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.
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.
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).
42 // Type with no records.
45 // Type with two records of felt type.
46 !pod.type<[@a: !felt.type, @b: !felt.type]>
51 (ins ArrayRefParameter<"::llzk::pod::RecordAttr",
52 "List of records in the pod">:$records);
54 let genVerifyDecl = 1;
55 let assemblyFormat = "`<` custom<PodType>($records) `>`";
57 let extraClassDeclaration = [{
58 /// Creates a new type from a set of initialized records.
60 /// The records are derived from the names and the types of the values.
61 static PodType fromInitialValues(::mlir::MLIRContext *ctx, InitializedRecords init);
63 /// Searches a record by name.
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;
69 /// Returns the records in map form.
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;
77#endif // LLZK_POD_TYPES