[Mlir-commits] [mlir] c161084 - [mlir] Make OpResult usable with DenseSet etc.

Matthias Springer llvmlistbot at llvm.org
Wed Oct 13 00:03:44 PDT 2021


Author: Matthias Springer
Date: 2021-10-13T15:58:08+09:00
New Revision: c1610847232d2c7b03f6dcc51d5fefb8f72ad5f9

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

LOG: [mlir] Make OpResult usable with DenseSet etc.

`DenseSet<Value>` works but `DenseSet<OpResult>` currently results in a compile error.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index 7ea8b265705fa..8b83905475513 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -489,6 +489,17 @@ struct DenseMapInfo<mlir::BlockArgument> : public DenseMapInfo<mlir::Value> {
     return reinterpret_cast<mlir::detail::BlockArgumentImpl *>(pointer);
   }
 };
+template <>
+struct DenseMapInfo<mlir::OpResult> : public DenseMapInfo<mlir::Value> {
+  static mlir::OpResult getEmptyKey() {
+    void *pointer = llvm::DenseMapInfo<void *>::getEmptyKey();
+    return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
+  }
+  static mlir::OpResult getTombstoneKey() {
+    void *pointer = llvm::DenseMapInfo<void *>::getTombstoneKey();
+    return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
+  }
+};
 
 /// Allow stealing the low bits of a value.
 template <>
@@ -513,6 +524,14 @@ struct PointerLikeTypeTraits<mlir::BlockArgument>
     return reinterpret_cast<mlir::detail::BlockArgumentImpl *>(pointer);
   }
 };
+template <>
+struct PointerLikeTypeTraits<mlir::OpResult>
+    : public PointerLikeTypeTraits<mlir::Value> {
+public:
+  static inline mlir::OpResult getFromVoidPointer(void *pointer) {
+    return reinterpret_cast<mlir::detail::OpResultImpl *>(pointer);
+  }
+};
 
 } // end namespace llvm
 


        


More information about the Mlir-commits mailing list