1//===-- OpInterfaces.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//===----------------------------------------------------------------------===//
10#ifndef LLZK_POD_OP_INTERFACES
11#define LLZK_POD_OP_INTERFACES
13include "llzk/Dialect/POD/IR/Types.td"
15include "mlir/IR/Interfaces.td"
16include "mlir/Interfaces/MemorySlotInterfaces.td"
17include "mlir/Interfaces/SideEffectInterfaces.td"
19def PodRefOpInterface : OpInterface<"PodRefOpInterface"> {
21 Common interface for operations that reference a plain-old-data struct value.
23 let cppNamespace = "::llzk::pod";
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",
31 [{Gets the mutable operand slot holding the SSA Value for the referenced pod.}],
32 "::mlir::OpOperand &", "getPodRefMutable", (ins)>,
35 let extraClassDeclaration = [{
36 /// Gets the type of the referenced pod.
37 inline ::llzk::pod::PodType getPodRefType() { return getPodRef().getType(); }
41def PodAccessOpInterface
42 : OpInterface<"PodAccessOpInterface", [PodRefOpInterface]> {
44 Common interface for operations that read or write from a pod record.
46 let cppNamespace = "::llzk::pod";
49 // Requires implementors to have a '$record_name' attribute.
51 [{Gets the record name attribute from the pod access op.}],
52 "::mlir::FlatSymbolRefAttr", "getRecordNameAttr", (ins)>,
54 [{Return `true` if the op is a read, `false` if it's a write.}],
55 "bool", "isRead", (ins)>,
58 let extraClassDeclaration = [{
59 /// Gets the record name as an attribute suitable for destructuring indices.
60 inline ::mlir::StringAttr getRecordNameAsStringAttr() {
61 return getRecordNameAttr().getLeafReference();
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);
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);
77#endif // LLZK_POD_OP_INTERFACES