|
22 | 22 | #include "llvm/ADT/SmallString.h" |
23 | 23 |
|
24 | 24 | namespace mlir { |
25 | | -class FunctionOpInterface; |
26 | 25 |
|
27 | 26 | namespace function_interface_impl { |
28 | 27 |
|
| 28 | +/// Return the name of the attribute used for function types. |
| 29 | +inline StringRef getTypeAttrName() { return "function_type"; } |
| 30 | + |
29 | 31 | /// Return the name of the attribute used for function argument attributes. |
30 | 32 | inline StringRef getArgDictAttrName() { return "arg_attrs"; } |
31 | 33 |
|
@@ -70,29 +72,28 @@ inline ArrayRef<NamedAttribute> getResultAttrs(Operation *op, unsigned index) { |
70 | 72 | } |
71 | 73 |
|
72 | 74 | /// Insert the specified arguments and update the function type attribute. |
73 | | -void insertFunctionArguments(FunctionOpInterface op, |
74 | | - ArrayRef<unsigned> argIndices, TypeRange argTypes, |
| 75 | +void insertFunctionArguments(Operation *op, ArrayRef<unsigned> argIndices, |
| 76 | + TypeRange argTypes, |
75 | 77 | ArrayRef<DictionaryAttr> argAttrs, |
76 | 78 | ArrayRef<Location> argLocs, |
77 | 79 | unsigned originalNumArgs, Type newType); |
78 | 80 |
|
79 | 81 | /// Insert the specified results and update the function type attribute. |
80 | | -void insertFunctionResults(FunctionOpInterface op, |
81 | | - ArrayRef<unsigned> resultIndices, |
| 82 | +void insertFunctionResults(Operation *op, ArrayRef<unsigned> resultIndices, |
82 | 83 | TypeRange resultTypes, |
83 | 84 | ArrayRef<DictionaryAttr> resultAttrs, |
84 | 85 | unsigned originalNumResults, Type newType); |
85 | 86 |
|
86 | 87 | /// Erase the specified arguments and update the function type attribute. |
87 | | -void eraseFunctionArguments(FunctionOpInterface op, const BitVector &argIndices, |
| 88 | +void eraseFunctionArguments(Operation *op, const BitVector &argIndices, |
88 | 89 | Type newType); |
89 | 90 |
|
90 | 91 | /// Erase the specified results and update the function type attribute. |
91 | | -void eraseFunctionResults(FunctionOpInterface op, |
92 | | - const BitVector &resultIndices, Type newType); |
| 92 | +void eraseFunctionResults(Operation *op, const BitVector &resultIndices, |
| 93 | + Type newType); |
93 | 94 |
|
94 | 95 | /// Set a FunctionOpInterface operation's type signature. |
95 | | -void setFunctionType(FunctionOpInterface op, Type newType); |
| 96 | +void setFunctionType(Operation *op, Type newType); |
96 | 97 |
|
97 | 98 | /// Insert a set of `newTypes` into `oldTypes` at the given `indices`. If any |
98 | 99 | /// types are inserted, `storage` is used to hold the new type list. The new |
@@ -206,6 +207,10 @@ Attribute removeResultAttr(ConcreteType op, unsigned index, StringAttr name) { |
206 | 207 | /// method on FunctionOpInterface::Trait. |
207 | 208 | template <typename ConcreteOp> |
208 | 209 | LogicalResult verifyTrait(ConcreteOp op) { |
| 210 | + if (!op.getFunctionTypeAttr()) |
| 211 | + return op.emitOpError("requires a type attribute '") |
| 212 | + << function_interface_impl::getTypeAttrName() << '\''; |
| 213 | + |
209 | 214 | if (failed(op.verifyType())) |
210 | 215 | return failure(); |
211 | 216 |
|
|
0 commit comments