1//===-- DiscardableAllocationOpInterfaces.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_DISCARDABLE_ALLOCATION_OP_INTERFACES
11#define LLZK_DISCARDABLE_ALLOCATION_OP_INTERFACES
13include "mlir/IR/Interfaces.td"
14include "mlir/Interfaces/MemorySlotInterfaces.td"
15include "mlir/Interfaces/SideEffectInterfaces.td"
17def DiscardableAllocationResource
18 : Resource<"::llzk::DiscardableAllocationResource">;
20def DiscardableAllocationAccessorOpInterface
21 : OpInterface<"DiscardableAllocationAccessorOpInterface"> {
23 Provides the necessary information to the `RemoveUnusedDiscardableAllocations` pass about
24 operations that load or store values from the result of an allocator op marked with the
25 `MemAlloc<DiscardableAllocationResource>` memory effect so unused allocators and stores can be
28 let cppNamespace = "::llzk";
32 [{Returns true if this op reads from the allocation represented by `ptr`.}],
33 "bool", "loadsFromDiscardableAllocation",
34 (ins "::mlir::Value":$ptr)>,
36 [{Returns true if this op writes to the allocation represented by `ptr`.}],
37 "bool", "storesToDiscardableAllocation", (ins "::mlir::Value":$ptr)>,
39 [{Returns true if this op can be erased as a dead store to `ptr`.}],
40 "bool", "canEraseAsDeadStoreTo",
41 (ins "::mlir::Value":$ptr,
42 "const ::mlir::DataLayout &":$dataLayout)>,
46#endif // LLZK_DISCARDABLE_ALLOCATION_OP_INTERFACES