|
17 | 17 |
|
18 | 18 | include "mlir/IR/OpBase.td" |
19 | 19 |
|
| 20 | + |
| 21 | +/// Interface for operations with arguments attributes (both call-like |
| 22 | +/// and callable operations). |
| 23 | +def OpWithArgumentAttributesInterface : OpInterface<"OpWithArgumentAttributesInterface"> { |
| 24 | + let description = [{ |
| 25 | + A call-like or callable operation that may define attributes for its arguments. |
| 26 | + }]; |
| 27 | + let cppNamespace = "::mlir"; |
| 28 | + let methods = [ |
| 29 | + InterfaceMethod<[{ |
| 30 | + Get the array of argument attribute dictionaries. The method should |
| 31 | + return an array attribute containing only dictionary attributes equal in |
| 32 | + number to the number of arguments. Alternatively, the method can |
| 33 | + return null to indicate that the region has no argument attributes. |
| 34 | + }], |
| 35 | + "::mlir::ArrayAttr", "getArgAttrsAttr", (ins), |
| 36 | + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
| 37 | + InterfaceMethod<[{ |
| 38 | + Get the array of result attribute dictionaries. The method should return |
| 39 | + an array attribute containing only dictionary attributes equal in number |
| 40 | + to the number of results. Alternatively, the method can return |
| 41 | + null to indicate that the region has no result attributes. |
| 42 | + }], |
| 43 | + "::mlir::ArrayAttr", "getResAttrsAttr", (ins), |
| 44 | + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
| 45 | + InterfaceMethod<[{ |
| 46 | + Set the array of argument attribute dictionaries. |
| 47 | + }], |
| 48 | + "void", "setArgAttrsAttr", (ins "::mlir::ArrayAttr":$attrs), |
| 49 | + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return; }]>, |
| 50 | + InterfaceMethod<[{ |
| 51 | + Set the array of result attribute dictionaries. |
| 52 | + }], |
| 53 | + "void", "setResAttrsAttr", (ins "::mlir::ArrayAttr":$attrs), |
| 54 | + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return; }]>, |
| 55 | + InterfaceMethod<[{ |
| 56 | + Remove the array of argument attribute dictionaries. This is the same as |
| 57 | + setting all argument attributes to an empty dictionary. The method should |
| 58 | + return the removed attribute. |
| 59 | + }], |
| 60 | + "::mlir::Attribute", "removeArgAttrsAttr", (ins), |
| 61 | + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
| 62 | + InterfaceMethod<[{ |
| 63 | + Remove the array of result attribute dictionaries. This is the same as |
| 64 | + setting all result attributes to an empty dictionary. The method should |
| 65 | + return the removed attribute. |
| 66 | + }], |
| 67 | + "::mlir::Attribute", "removeResAttrsAttr", (ins), |
| 68 | + /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
| 69 | + ]; |
| 70 | +} |
| 71 | + |
20 | 72 | // `CallInterfaceCallable`: This is a type used to represent a single callable |
21 | 73 | // region. A callable is either a symbol, or an SSA value, that is referenced by |
22 | 74 | // a call-like operation. This represents the destination of the call. |
23 | 75 |
|
24 | 76 | /// Interface for call-like operations. |
25 | | -def CallOpInterface : OpInterface<"CallOpInterface"> { |
| 77 | +def CallOpInterface : OpInterface<"CallOpInterface", |
| 78 | + [OpWithArgumentAttributesInterface]> { |
26 | 79 | let description = [{ |
27 | 80 | A call-like operation is one that transfers control from one sub-routine to |
28 | 81 | another. These operations may be traditional direct calls `call @foo`, or |
@@ -85,7 +138,8 @@ def CallOpInterface : OpInterface<"CallOpInterface"> { |
85 | 138 | } |
86 | 139 |
|
87 | 140 | /// Interface for callable operations. |
88 | | -def CallableOpInterface : OpInterface<"CallableOpInterface"> { |
| 141 | +def CallableOpInterface : OpInterface<"CallableOpInterface", |
| 142 | + [OpWithArgumentAttributesInterface]> { |
89 | 143 | let description = [{ |
90 | 144 | A callable operation is one who represents a potential sub-routine, and may |
91 | 145 | be a target for a call-like operation (those providing the CallOpInterface |
@@ -113,47 +167,6 @@ def CallableOpInterface : OpInterface<"CallableOpInterface"> { |
113 | 167 | allow for this method may be called on function declarations). |
114 | 168 | }], |
115 | 169 | "::llvm::ArrayRef<::mlir::Type>", "getResultTypes">, |
116 | | - |
117 | | - InterfaceMethod<[{ |
118 | | - Get the array of argument attribute dictionaries. The method should |
119 | | - return an array attribute containing only dictionary attributes equal in |
120 | | - number to the number of region arguments. Alternatively, the method can |
121 | | - return null to indicate that the region has no argument attributes. |
122 | | - }], |
123 | | - "::mlir::ArrayAttr", "getArgAttrsAttr", (ins), |
124 | | - /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
125 | | - InterfaceMethod<[{ |
126 | | - Get the array of result attribute dictionaries. The method should return |
127 | | - an array attribute containing only dictionary attributes equal in number |
128 | | - to the number of region results. Alternatively, the method can return |
129 | | - null to indicate that the region has no result attributes. |
130 | | - }], |
131 | | - "::mlir::ArrayAttr", "getResAttrsAttr", (ins), |
132 | | - /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
133 | | - InterfaceMethod<[{ |
134 | | - Set the array of argument attribute dictionaries. |
135 | | - }], |
136 | | - "void", "setArgAttrsAttr", (ins "::mlir::ArrayAttr":$attrs), |
137 | | - /*methodBody=*/[{}], /*defaultImplementation=*/[{ return; }]>, |
138 | | - InterfaceMethod<[{ |
139 | | - Set the array of result attribute dictionaries. |
140 | | - }], |
141 | | - "void", "setResAttrsAttr", (ins "::mlir::ArrayAttr":$attrs), |
142 | | - /*methodBody=*/[{}], /*defaultImplementation=*/[{ return; }]>, |
143 | | - InterfaceMethod<[{ |
144 | | - Remove the array of argument attribute dictionaries. This is the same as |
145 | | - setting all argument attributes to an empty dictionary. The method should |
146 | | - return the removed attribute. |
147 | | - }], |
148 | | - "::mlir::Attribute", "removeArgAttrsAttr", (ins), |
149 | | - /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
150 | | - InterfaceMethod<[{ |
151 | | - Remove the array of result attribute dictionaries. This is the same as |
152 | | - setting all result attributes to an empty dictionary. The method should |
153 | | - return the removed attribute. |
154 | | - }], |
155 | | - "::mlir::Attribute", "removeResAttrsAttr", (ins), |
156 | | - /*methodBody=*/[{}], /*defaultImplementation=*/[{ return nullptr; }]>, |
157 | 170 | ]; |
158 | 171 | } |
159 | 172 |
|
|
0 commit comments