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 ::llvm::None.
39      }],
40      "::mlir::Optional<::mlir::Operation*>", "buildDealloc",
41      (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
42      /*defaultImplementation=*/[{ return llvm::None; }]
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 ::llvm::None.
50      }],
51      "::mlir::Optional<::mlir::Value>", "buildClone",
52      (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
53      /*defaultImplementation=*/[{ return llvm::None; }]
54    >
55  ];
56}
57
58#endif  // ALLOCATION_OP_INTERFACE
59