xref: /llvm-project/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationBase.td (revision 2a4e61b342e7a19bcb229ef16dee083c58224a3f)
1//===- BufferizationBase.td - Bufferization dialect base ---*- 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#ifndef BUFFERIZATION_BASE
10#define BUFFERIZATION_BASE
11
12include "mlir/IR/OpBase.td"
13
14def Bufferization_Dialect : Dialect {
15  let name = "bufferization";
16  let cppNamespace = "::mlir::bufferization";
17  let description = [{
18    Bufferization in MLIR is the process of converting the `tensor` type to the
19    `memref` type.
20    Simply put, bufferization is the process of converting computations on the
21    mathematical tensor construct to computations on physical memory buffers.
22    The `bufferization` dialect contains operations/interfaces specific to the
23    bufferization passes.
24
25    An overview of the bufferization infrastructure and important conceptual
26    details related to using the MLIR dialect conversion infrastructure can be
27    found in [bufferization](/docs/Bufferization/) and [ownership-based buffer
28    deallocation](/docs/OwnershipBasedBufferDeallocation/).
29  }];
30  let dependentDialects = [
31    "affine::AffineDialect", "memref::MemRefDialect", "tensor::TensorDialect",
32    "arith::ArithDialect"
33  ];
34
35  let extraClassDeclaration = [{
36    /// Verify an attribute from this dialect on the argument at 'argIndex' for
37    /// the region at 'regionIndex' on the given operation. Returns failure if
38    /// the verification failed, success otherwise. This hook may optionally be
39    /// invoked from any operation containing a region.
40    LogicalResult verifyRegionArgAttribute(Operation *,
41                                           unsigned regionIndex,
42                                           unsigned argIndex,
43                                           NamedAttribute) override;
44
45    /// An attribute that can override writability of buffers of tensor function
46    /// arguments during One-Shot Module Bufferize.
47    constexpr const static ::llvm::StringLiteral
48        kWritableAttrName = "bufferization.writable";
49
50    /// An attribute for function arguments that describes how the function
51    /// accesses the buffer. Can be one "none", "read", "write" or "read-write".
52    ///
53    /// When no attribute is specified, the analysis tries to infer the access
54    /// behavior from its body. In case of external functions, for which no
55    /// function body is available, "read-write" is assumed by default.
56    constexpr const static ::llvm::StringLiteral
57        kBufferAccessAttrName = "bufferization.access";
58
59    /// Attribute name used to mark the bufferization layout for region
60    /// arguments during One-Shot Module Bufferize.
61    constexpr const static ::llvm::StringLiteral
62        kBufferLayoutAttrName = "bufferization.buffer_layout";
63
64    /// An attribute that can be attached to ops with an allocation and/or
65    /// deallocation side effect. It indicates that the op is under a "manual
66    /// deallocation" scheme. In the case of an allocation op, the returned
67    /// value is *not* an automatically managed allocation and assigned an
68    /// ownership of "false". Furthermore, only deallocation ops that are
69    /// guaranteed to deallocate a buffer under "manual deallocation" are
70    /// allowed to have this attribute. (Deallocation ops without this
71    /// attribute are rejected by the ownership-based buffer deallocation pass.)
72    constexpr const static ::llvm::StringLiteral
73        kManualDeallocation = "bufferization.manual_deallocation";
74  }];
75  let hasOperationAttrVerify = 1;
76}
77
78#endif // BUFFERIZATION_BASE
79