[Mlir-commits] [mlir] 56299b1 - [MLIR] Use `llvm::is_one_of` in walk templates

Frederik Gossen llvmlistbot at llvm.org
Fri Oct 30 07:42:56 PDT 2020


Author: Frederik Gossen
Date: 2020-10-30T14:42:34Z
New Revision: 56299b1e58bf3720dff2fe60163739ee1554a371

URL: https://github.com/llvm/llvm-project/commit/56299b1e58bf3720dff2fe60163739ee1554a371
DIFF: https://github.com/llvm/llvm-project/commit/56299b1e58bf3720dff2fe60163739ee1554a371.diff

LOG: [MLIR] Use `llvm::is_one_of` in walk templates

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/Visitors.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Visitors.h b/mlir/include/mlir/IR/Visitors.h
index cf7b3fa5db1c..74aabbdebe3e 100644
--- a/mlir/include/mlir/IR/Visitors.h
+++ b/mlir/include/mlir/IR/Visitors.h
@@ -92,10 +92,8 @@ WalkResult walk(Operation *op, function_ref<WalkResult(Operation *)> callback);
 template <
     typename FuncTy, typename ArgT = detail::first_argument<FuncTy>,
     typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
-typename std::enable_if<std::is_same<ArgT, Operation *>::value ||
-                            std::is_same<ArgT, Region *>::value ||
-                            std::is_same<ArgT, Block *>::value,
-                        RetT>::type
+typename std::enable_if<
+    llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value, RetT>::type
 walk(Operation *op, FuncTy &&callback) {
   return walk(op, function_ref<RetT(ArgT)>(callback));
 }
@@ -109,11 +107,10 @@ walk(Operation *op, FuncTy &&callback) {
 template <
     typename FuncTy, typename ArgT = detail::first_argument<FuncTy>,
     typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
-typename std::enable_if<!std::is_same<ArgT, Operation *>::value &&
-                            !std::is_same<ArgT, Region *>::value &&
-                            !std::is_same<ArgT, Block *>::value &&
-                            std::is_same<RetT, void>::value,
-                        RetT>::type
+typename std::enable_if<
+    !llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value &&
+        std::is_same<RetT, void>::value,
+    RetT>::type
 walk(Operation *op, FuncTy &&callback) {
   auto wrapperFn = [&](Operation *op) {
     if (auto derivedOp = dyn_cast<ArgT>(op))
@@ -135,11 +132,10 @@ walk(Operation *op, FuncTy &&callback) {
 template <
     typename FuncTy, typename ArgT = detail::first_argument<FuncTy>,
     typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
-typename std::enable_if<!std::is_same<ArgT, Operation *>::value &&
-                            !std::is_same<ArgT, Region *>::value &&
-                            !std::is_same<ArgT, Block *>::value &&
-                            std::is_same<RetT, WalkResult>::value,
-                        RetT>::type
+typename std::enable_if<
+    !llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value &&
+        std::is_same<RetT, WalkResult>::value,
+    RetT>::type
 walk(Operation *op, FuncTy &&callback) {
   auto wrapperFn = [&](Operation *op) {
     if (auto derivedOp = dyn_cast<ArgT>(op))


        


More information about the Mlir-commits mailing list