Skip to content

Commit 6163fa7

Browse files
committed
[mlir] DialectConversion: remove vtable from TypeConverter
The original design of TypeConverter expected specific converters to derive the class and override virtual functions for conversions and materializations. This did not scale well to multi-dialect conversions, so the design was changed to register a list of converter and materializer functions, removing the need for virtual functions. The only remaining virtual function, `convertSignatureArg` is never overridden in-tree. Make it non-virtual, drop the virtual destructor and thus remove vtable from TypeConverter. If there exist TypeConverter users that need custom `convertSignatureArg` behavior, it should be implemented using the callback registration mechanism similar to that of conversions and materializations. Differential Revision: https://reviews.llvm.org/D80993
1 parent 59e0987 commit 6163fa7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ class Value;
3434
// Type Conversion
3535
//===----------------------------------------------------------------------===//
3636

37-
/// Base class for type conversion interface. Specific converters must
38-
/// derive this class and implement the pure virtual functions.
37+
/// Type conversion class. Specific conversions and materializations can be
38+
/// registered using addConversion and addMaterialization, respectively.
3939
class TypeConverter {
4040
public:
41-
virtual ~TypeConverter() = default;
42-
4341
/// This class provides all of the information necessary to convert a type
4442
/// signature.
4543
class SignatureConversion {
@@ -156,11 +154,11 @@ class TypeConverter {
156154
/// legal.
157155
bool isSignatureLegal(FunctionType funcType);
158156

159-
/// This hook allows for converting a specific argument of a signature. It
157+
/// This method allows for converting a specific argument of a signature. It
160158
/// takes as inputs the original argument input number, type.
161-
/// On success, this function should populate 'result' with any new mappings.
162-
virtual LogicalResult convertSignatureArg(unsigned inputNo, Type type,
163-
SignatureConversion &result);
159+
/// On success, it populates 'result' with any new mappings.
160+
LogicalResult convertSignatureArg(unsigned inputNo, Type type,
161+
SignatureConversion &result);
164162

165163
/// This function converts the type signature of the given block, by invoking
166164
/// 'convertSignatureArg' for each argument. This function should return a

0 commit comments

Comments
 (0)