[Mlir-commits] [mlir] 011f1b1 - [mlir][bufferize] Add helpers for templatized DENY filters

Matthias Springer llvmlistbot at llvm.org
Thu May 12 00:23:05 PDT 2022


Author: Matthias Springer
Date: 2022-05-12T09:18:21+02:00
New Revision: 011f1b1c1ffb6bbd57a3b7abaf6f07859a10ccbd

URL: https://github.com/llvm/llvm-project/commit/011f1b1c1ffb6bbd57a3b7abaf6f07859a10ccbd
DIFF: https://github.com/llvm/llvm-project/commit/011f1b1c1ffb6bbd57a3b7abaf6f07859a10ccbd.diff

LOG: [mlir][bufferize] Add helpers for templatized DENY filters

We already have templatized ALLOW filters but the DENY filters were missing.

Differential Revision: https://reviews.llvm.org/D125358

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
index 421db92543f02..70c0f00fac433 100644
--- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
+++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
@@ -93,6 +93,15 @@ struct BufferizationOptions {
         0, (allowDialectInFilterImpl<DialectTs>(), 0)...};
   }
 
+  /// Deny the given dialects in the filter.
+  ///
+  /// This function adds one or multiple DENY filters.
+  template <typename... DialectTs> void denyDialectInFilter() {
+    // FIXME: In c++17 this can be simplified by using 'fold expressions'.
+    (void)std::initializer_list<int>{
+        0, (denyDialectInFilterImpl<DialectTs>(), 0)...};
+  }
+
   /// Allow the given dialect in the filter.
   ///
   /// This function adds an ALLOW filter.
@@ -114,6 +123,15 @@ struct BufferizationOptions {
         0, (allowOperationInFilterImpl<OpTys>(), 0)...};
   }
 
+  /// Deny the given ops in the filter.
+  ///
+  /// This function adds one or multiple DENY filters.
+  template <typename... OpTys> void denyOperationInFilter() {
+    // FIXME: In c++17 this can be simplified by using 'fold expressions'.
+    (void)std::initializer_list<int>{
+        0, (denyOperationInFilterImpl<OpTys>(), 0)...};
+  }
+
   /// Allow the given op in the filter.
   ///
   /// This function adds an ALLOW filter.
@@ -249,11 +267,21 @@ struct BufferizationOptions {
     allowDialectInFilter(DialectT::getDialectNamespace());
   }
 
+  /// Deny a dialect.
+  template <typename DialectT> void denyDialectInFilterImpl() {
+    denyDialectInFilter(DialectT::getDialectNamespace());
+  }
+
   /// Allow an op.
   template <typename OpTy>
   void allowOperationInFilterImpl() {
     allowOperationInFilter(OpTy::getOperationName());
   }
+
+  /// Deny an op.
+  template <typename OpTy> void denyOperationInFilterImpl() {
+    denyOperationInFilter(OpTy::getOperationName());
+  }
 };
 
 /// Specify fine-grain relationship between buffers to enable more analysis.


        


More information about the Mlir-commits mailing list