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;
30 "type", [DeclareTypeInterfaceMethods<DestructurableTypeInterface>]> {
31 let summary = "plain-old-data struct";
33 Contains a list of `RecordAttr` defining structure of a pod.
34 The order of records in the pod matters and each record must have a unique name.
35 It is possible to have a pod with no records.
37 Two `PODType` types unify if they have the same record names, defined in the
38 same order, and if the types of corresponding records unify.
40 This type can be used in the `struct.member` op, and it can be declared as a column,
41 in which case that annotation is also implied on the inner records (except those that
42 cannot be column such as `string.type` records).
45 // Type with no records.
48 // Type with two records of felt type.
49 !pod.type<[@a: !felt.type, @b: !felt.type]>
54 (ins ArrayRefParameter<"::llzk::pod::RecordAttr",
55 "List of records in the pod">:$records);
57 let genVerifyDecl = 1;
58 let assemblyFormat = "`<` custom<PodType>($records) `>`";
60 let extraClassDeclaration = [{
61 /// Creates a new type from a set of initialized records.
63 /// The records are derived from the names and the types of the values.
64 static PodType fromInitialValues(::mlir::MLIRContext *ctx, InitializedRecords init);
66 /// Searches a record by name.
68 /// If you plan to make several queries to this type, it's better to generate the map
69 /// once via `getRecordMap()` and query it instead of repeatedly calling `getRecord()`.
70 ::llvm::FailureOr<::mlir::Type> getRecord(::llvm::StringRef name, ::llvm::function_ref<::mlir::InFlightDiagnostic()>) const;
72 /// Returns the records in map form.
74 /// If you plan to make several queries to this type, it's better to generate the map
75 /// once via `getRecordMap()` and query it instead of repeatedly calling `getRecord()`.
76 ::llvm::StringMap<::mlir::Type> getRecordMap() const;
78 /// Creates a PodType containing only the requested record.
79 ::mlir::Type getSingleRecordType(::mlir::StringAttr name) const;
83#endif // LLZK_POD_TYPES