1//===-- AllocationOpInterface.td - Allocation op interface -*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// Defines the interface with allocation-related methods. It is used by the 10// buffer deallocation pass. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef ALLOCATION_OP_INTERFACE 15#define ALLOCATION_OP_INTERFACE 16 17include "mlir/IR/OpBase.td" 18 19//===----------------------------------------------------------------------===// 20// AllocationOpInterface 21//===----------------------------------------------------------------------===// 22 23def AllocationOpInterface : OpInterface<"AllocationOpInterface"> { 24 let description = [{ 25 This interface provides general allocation-related methods that are 26 designed for allocation operations. For example, it offers the ability to 27 construct associated deallocation and clone operations that are compatible 28 with the current allocation operation. 29 }]; 30 let cppNamespace = "::mlir::bufferization"; 31 32 let methods = [ 33 StaticInterfaceMethod<[{ 34 Builds a deallocation operation using the provided builder and the 35 current allocation value (which refers to the current Op implementing 36 this interface). The allocation value is a result of the current 37 operation implementing this interface. If there is no compatible 38 deallocation operation, this method can return ::std::nullopt. 39 }], 40 "::std::optional<::mlir::Operation*>", "buildDealloc", 41 (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], 42 /*defaultImplementation=*/[{ return std::nullopt; }] 43 >, 44 StaticInterfaceMethod<[{ 45 Builds a clone operation using the provided builder and the current 46 allocation value (which refers to the current Op implementing this 47 interface). The allocation value is a result of the current operation 48 implementing this interface. If there is no compatible clone operation, 49 this method can return ::std::nullopt. 50 }], 51 "::std::optional<::mlir::Value>", "buildClone", 52 (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], 53 /*defaultImplementation=*/[{ return std::nullopt; }] 54 >, 55 StaticInterfaceMethod<[{ 56 Returns the kind of hoisting supported for the buffer allocated by this 57 operation. 58 }], 59 "::mlir::HoistingKind", "getHoistingKind", 60 (ins), [{}], 61 /*defaultImplementation=*/[{ return HoistingKind::None; }] 62 >, 63 StaticInterfaceMethod<[{ 64 Builds a stack allocation operation using the provided builder and the 65 current allocation value (which refers to the current Op implementing this 66 interface). The allocation value is a result of the current 67 operation implementing this interface. If there is no compatible 68 stack allocation operation, this method can return ::std::nullopt. 69 }], 70 "::std::optional<::mlir::Operation*>", "buildPromotedAlloc", 71 (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], 72 /*defaultImplementation=*/[{ return std::nullopt; }] 73 > 74 ]; 75} 76 77#endif // ALLOCATION_OP_INTERFACE 78