LLZK 2.1.1
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
OpInterfaces.td
Go to the documentation of this file.
1//===-- OpInterfaces.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_OP_INTERFACES
11#define LLZK_POD_OP_INTERFACES
12
13include "llzk/Dialect/POD/IR/Types.td"
14
15include "mlir/IR/Interfaces.td"
16include "mlir/Interfaces/MemorySlotInterfaces.td"
17include "mlir/Interfaces/SideEffectInterfaces.td"
18
19def PodRefOpInterface : OpInterface<"PodRefOpInterface"> {
20 let description = [{
21 Common interface for operations that reference a plain-old-data struct value.
22 }];
23 let cppNamespace = "::llzk::pod";
24
25 let methods = [
26 // Requires implementors to have a '$pod_ref' argument.
27 InterfaceMethod<[{Gets the SSA Value for the referenced pod.}],
28 "::mlir::TypedValue<::llzk::pod::PodType>", "getPodRef",
29 (ins)>,
30 InterfaceMethod<
31 [{Gets the mutable operand slot holding the SSA Value for the referenced pod.}],
32 "::mlir::OpOperand &", "getPodRefMutable", (ins)>,
33 ];
34
35 let extraClassDeclaration = [{
36 /// Gets the type of the referenced pod.
37 inline ::llzk::pod::PodType getPodRefType() { return getPodRef().getType(); }
38 }];
39}
40
41def PodAccessOpInterface
42 : OpInterface<"PodAccessOpInterface", [PodRefOpInterface]> {
43 let description = [{
44 Common interface for operations that read or write from a pod record.
45 }];
46 let cppNamespace = "::llzk::pod";
47
48 let methods = [
49 // Requires implementors to have a '$record_name' attribute.
50 InterfaceMethod<
51 [{Gets the record name attribute from the pod access op.}],
52 "::mlir::FlatSymbolRefAttr", "getRecordNameAttr", (ins)>,
53 InterfaceMethod<
54 [{Return `true` if the op is a read, `false` if it's a write.}],
55 "bool", "isRead", (ins)>,
56 ];
57
58 let extraClassDeclaration = [{
59 /// Gets the record name as an attribute suitable for destructuring indices.
60 inline ::mlir::StringAttr getRecordNameAsStringAttr() {
61 return getRecordNameAttr().getLeafReference();
62 }
63
64 /// Required by companion interface DestructurableAccessorOpInterface / SROA pass
65 bool canRewire(const ::mlir::DestructurableMemorySlot &slot,
66 ::llvm::SmallPtrSetImpl<::mlir::Attribute> &usedIndices,
67 ::mlir::SmallVectorImpl<::mlir::MemorySlot> &mustBeSafelyUsed,
68 const ::mlir::DataLayout &dataLayout);
69
70 /// Required by companion interface DestructurableAccessorOpInterface / SROA pass
71 ::mlir::DeletionKind rewire(const ::mlir::DestructurableMemorySlot &slot,
72 ::llvm::DenseMap<::mlir::Attribute, ::mlir::MemorySlot> &subslots,
73 ::mlir::OpBuilder &builder, const ::mlir::DataLayout &dataLayout);
74 }];
75}
76
77#endif // LLZK_POD_OP_INTERFACES