1//===-- BufferViewFlowOpInterface.td - Buffer View Flow ----*- 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 BUFFER_VIEW_FLOW_OP_INTERFACE 10#define BUFFER_VIEW_FLOW_OP_INTERFACE 11 12include "mlir/IR/OpBase.td" 13 14def BufferViewFlowOpInterface : 15 OpInterface<"BufferViewFlowOpInterface"> { 16 let description = [{ 17 An op interface for the buffer view flow analysis. This interface describes 18 buffer dependencies between operands and op results/region entry block 19 arguments. 20 }]; 21 let cppNamespace = "::mlir::bufferization"; 22 let methods = [ 23 InterfaceMethod< 24 /*desc=*/[{ 25 Populate buffer dependencies between operands and op results/region 26 entry block arguments. 27 28 Implementations should register dependencies between an operand ("X") 29 and an op result/region entry block argument ("Y") if Y may depend 30 on X. Y depends on X if Y and X are the same buffer or if Y is a 31 subview of X. 32 33 Example: 34 ``` 35 %r = arith.select %c, %m1, %m2 : memref<5xf32> 36 ``` 37 In the above example, %0 may depend on %m1 or %m2 and a correct 38 interface implementation should call: 39 - "registerDependenciesFn(%m1, %r)". 40 - "registerDependenciesFn(%m2, %r)" 41 }], 42 /*retType=*/"void", 43 /*methodName=*/"populateDependencies", 44 /*args=*/(ins 45 "::mlir::bufferization::RegisterDependenciesFn" 46 :$registerDependenciesFn) 47 >, 48 InterfaceMethod< 49 /*desc=*/[{ 50 Return "true" if the given value may be a terminal buffer. A buffer 51 value is "terminal" if it cannot be traced back any further in the 52 buffer view flow analysis. 53 54 Examples: A buffer could be terminal because: 55 - it is a newly allocated buffer (e.g., "memref.alloc"), 56 - or: because there is not enough compile-time information available 57 to make a definite decision (e.g., "memref.realloc" may reallocate 58 but we do not know for sure; another example are call ops where we 59 would have to analyze the body of the callee). 60 61 Implementations can assume that the given SSA value is an OpResult of 62 this operation or a region entry block argument of this operation. 63 }], 64 /*retType=*/"bool", 65 /*methodName=*/"mayBeTerminalBuffer", 66 /*args=*/(ins "Value":$value), 67 /*methodBody=*/"", 68 /*defaultImplementation=*/"return false;" 69 >, 70 ]; 71} 72 73#endif // BUFFER_VIEW_FLOW_OP_INTERFACE 74