[Mlir-commits] [mlir] 6163fa7 - [mlir] DialectConversion: remove vtable from TypeConverter

Alex Zinenko llvmlistbot at llvm.org
Wed Jun 3 06:31:11 PDT 2020


Author: Alex Zinenko
Date: 2020-06-03T15:31:02+02:00
New Revision: 6163fa79268dcdcb7131d2b2f28d49a2c574f29a

URL: https://github.com/llvm/llvm-project/commit/6163fa79268dcdcb7131d2b2f28d49a2c574f29a
DIFF: https://github.com/llvm/llvm-project/commit/6163fa79268dcdcb7131d2b2f28d49a2c574f29a.diff

LOG: [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

Added: 
    

Modified: 
    mlir/include/mlir/Transforms/DialectConversion.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index 029c38f6a1c7..bdb61d1a409a 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -34,12 +34,10 @@ class Value;
 // Type Conversion
 //===----------------------------------------------------------------------===//
 
-/// Base class for type conversion interface. Specific converters must
-/// derive this class and implement the pure virtual functions.
+/// Type conversion class. Specific conversions and materializations can be
+/// registered using addConversion and addMaterialization, respectively.
 class TypeConverter {
 public:
-  virtual ~TypeConverter() = default;
-
   /// This class provides all of the information necessary to convert a type
   /// signature.
   class SignatureConversion {
@@ -156,11 +154,11 @@ class TypeConverter {
   /// legal.
   bool isSignatureLegal(FunctionType funcType);
 
-  /// This hook allows for converting a specific argument of a signature. It
+  /// This method allows for converting a specific argument of a signature. It
   /// takes as inputs the original argument input number, type.
-  /// On success, this function should populate 'result' with any new mappings.
-  virtual LogicalResult convertSignatureArg(unsigned inputNo, Type type,
-                                            SignatureConversion &result);
+  /// On success, it populates 'result' with any new mappings.
+  LogicalResult convertSignatureArg(unsigned inputNo, Type type,
+                                    SignatureConversion &result);
 
   /// This function converts the type signature of the given block, by invoking
   /// 'convertSignatureArg' for each argument. This function should return a


        


More information about the Mlir-commits mailing list