[Mlir-commits] [mlir] [mlir][mesh] Introduce `DialectInlinerInterface` for the Mesh dialect (PR #108297)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 11 14:38:43 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Matteo Franciolini (mfrancio)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/108297.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/Mesh/IR/MeshOps.cpp (+22) 


``````````diff
diff --git a/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp b/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
index c35020b4c20ccc..20dd271636a937 100644
--- a/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
+++ b/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
@@ -24,6 +24,7 @@
 #include "mlir/IR/Value.h"
 #include "mlir/Interfaces/ViewLikeInterface.h"
 #include "mlir/Support/LLVM.h"
+#include "mlir/Transforms/InliningUtils.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
@@ -74,6 +75,26 @@ static DimensionSize operator*(DimensionSize lhs, DimensionSize rhs) {
   return lhs.value() * rhs.value();
 }
 
+//===----------------------------------------------------------------------===//
+// Inliner 
+//===----------------------------------------------------------------------===//
+
+namespace {
+struct MeshInlinerInterface : public DialectInlinerInterface {
+  using DialectInlinerInterface::DialectInlinerInterface;
+  // Currently no restrictions are encoded for inlining.
+  bool isLegalToInline(Operation *, Operation *, bool) const final {
+    return true;
+  }
+  bool isLegalToInline(Region *, Region *, bool, IRMapping &) const final {
+    return true;
+  }
+  bool isLegalToInline(Operation *, Region *, bool, IRMapping &) const final {
+    return true;
+  }
+};
+} // namespace
+
 //===----------------------------------------------------------------------===//
 // Mesh dialect
 //===----------------------------------------------------------------------===//
@@ -91,6 +112,7 @@ void MeshDialect::initialize() {
 #define GET_TYPEDEF_LIST
 #include "mlir/Dialect/Mesh/IR/MeshTypes.cpp.inc"
       >();
+  addInterface<MeshInlinerInterface>();
 }
 
 Operation *MeshDialect::materializeConstant(OpBuilder &builder, Attribute value,

``````````

</details>


https://github.com/llvm/llvm-project/pull/108297


More information about the Mlir-commits mailing list