From 011f1b1c1ffb6bbd57a3b7abaf6f07859a10ccbd Mon Sep 17 00:00:00 2001 From: Matthias Springer Date: Thu, 12 May 2022 09:17:04 +0200 Subject: [PATCH] [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 --- .../IR/BufferizableOpInterface.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h index 421db92543f0..70c0f00fac43 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(), 0)...}; } + /// Deny the given dialects in the filter. + /// + /// This function adds one or multiple DENY filters. + template void denyDialectInFilter() { + // FIXME: In c++17 this can be simplified by using 'fold expressions'. + (void)std::initializer_list{ + 0, (denyDialectInFilterImpl(), 0)...}; + } + /// Allow the given dialect in the filter. /// /// This function adds an ALLOW filter. @@ -114,6 +123,15 @@ struct BufferizationOptions { 0, (allowOperationInFilterImpl(), 0)...}; } + /// Deny the given ops in the filter. + /// + /// This function adds one or multiple DENY filters. + template void denyOperationInFilter() { + // FIXME: In c++17 this can be simplified by using 'fold expressions'. + (void)std::initializer_list{ + 0, (denyOperationInFilterImpl(), 0)...}; + } + /// Allow the given op in the filter. /// /// This function adds an ALLOW filter. @@ -249,11 +267,21 @@ private: allowDialectInFilter(DialectT::getDialectNamespace()); } + /// Deny a dialect. + template void denyDialectInFilterImpl() { + denyDialectInFilter(DialectT::getDialectNamespace()); + } + /// Allow an op. template void allowOperationInFilterImpl() { allowOperationInFilter(OpTy::getOperationName()); } + + /// Deny an op. + template void denyOperationInFilterImpl() { + denyOperationInFilter(OpTy::getOperationName()); + } }; /// Specify fine-grain relationship between buffers to enable more analysis.