[Mlir-commits] [mlir] 548757b - [mlir] Move InterfaceMap::InterfaceMap to the cpp file

Benjamin Kramer llvmlistbot at llvm.org
Thu Mar 17 12:28:07 PDT 2022


Author: Benjamin Kramer
Date: 2022-03-17T20:14:24+01:00
New Revision: 548757ba86f60ceb62ea465c3f4f9b9c0c42b89f

URL: https://github.com/llvm/llvm-project/commit/548757ba86f60ceb62ea465c3f4f9b9c0c42b89f
DIFF: https://github.com/llvm/llvm-project/commit/548757ba86f60ceb62ea465c3f4f9b9c0c42b89f.diff

LOG: [mlir] Move InterfaceMap::InterfaceMap to the cpp file

So we don't end up with a copy of std::sort in every dialect definition.
NFCI.

Added: 
    

Modified: 
    mlir/include/mlir/Support/InterfaceSupport.h
    mlir/lib/Support/InterfaceSupport.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Support/InterfaceSupport.h b/mlir/include/mlir/Support/InterfaceSupport.h
index 53caebcaee69f..e0f5dd39305b6 100644
--- a/mlir/include/mlir/Support/InterfaceSupport.h
+++ b/mlir/include/mlir/Support/InterfaceSupport.h
@@ -220,12 +220,7 @@ class InterfaceMap {
   /// Create an InterfaceMap given with the implementation of the interfaces.
   /// The use of this constructor is in general discouraged in favor of
   /// 'InterfaceMap::get<InterfaceA, ...>()'.
-  InterfaceMap(MutableArrayRef<std::pair<TypeID, void *>> elements)
-      : interfaces(elements.begin(), elements.end()) {
-    llvm::sort(interfaces, [](const auto &lhs, const auto &rhs) {
-      return compare(lhs.first, rhs.first);
-    });
-  }
+  InterfaceMap(MutableArrayRef<std::pair<TypeID, void *>> elements);
 
   /// Insert the given models as implementations of the corresponding interfaces
   /// for the concrete attribute class.

diff  --git a/mlir/lib/Support/InterfaceSupport.cpp b/mlir/lib/Support/InterfaceSupport.cpp
index 5287dd0fe4497..4b8dd58801e23 100644
--- a/mlir/lib/Support/InterfaceSupport.cpp
+++ b/mlir/lib/Support/InterfaceSupport.cpp
@@ -18,6 +18,14 @@
 
 using namespace mlir;
 
+detail::InterfaceMap::InterfaceMap(
+    MutableArrayRef<std::pair<TypeID, void *>> elements)
+    : interfaces(elements.begin(), elements.end()) {
+  llvm::sort(interfaces, [](const auto &lhs, const auto &rhs) {
+    return compare(lhs.first, rhs.first);
+  });
+}
+
 void detail::InterfaceMap::insert(
     ArrayRef<std::pair<TypeID, void *>> elements) {
   // Insert directly into the right position to keep the interfaces sorted.


        


More information about the Mlir-commits mailing list