[Mlir-commits] [mlir] 983565a - [ADT] Move DenseMapInfo for ArrayRef/StringRef into respective headers (NFC)
Nikita Popov
llvmlistbot at llvm.org
Thu Jun 3 09:34:49 PDT 2021
Author: Nikita Popov
Date: 2021-06-03T18:34:36+02:00
New Revision: 983565a6fe4a9f40c7caf82b65c650c20dbcc104
URL: https://github.com/llvm/llvm-project/commit/983565a6fe4a9f40c7caf82b65c650c20dbcc104
DIFF: https://github.com/llvm/llvm-project/commit/983565a6fe4a9f40c7caf82b65c650c20dbcc104.diff
LOG: [ADT] Move DenseMapInfo for ArrayRef/StringRef into respective headers (NFC)
This is a followup to D103422. The DenseMapInfo implementations for
ArrayRef and StringRef are moved into the ArrayRef.h and StringRef.h
headers, which means that these two headers no longer need to be
included by DenseMapInfo.h.
This required adding a few additional includes, as many files were
relying on various things pulled in by ArrayRef.h.
Differential Revision: https://reviews.llvm.org/D103491
Added:
Modified:
clang/include/clang/AST/ComparisonCategories.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/DenseMapInfo.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/IR/PassInstrumentation.h
llvm/include/llvm/Support/Threading.h
llvm/lib/CodeGen/AsmPrinter/WinException.h
llvm/lib/CodeGen/MBFIWrapper.cpp
llvm/lib/MC/StringTableBuilder.cpp
llvm/lib/Support/SmallPtrSet.cpp
llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h
llvm/tools/llvm-c-test/echo.cpp
mlir/include/mlir/IR/AffineExpr.h
mlir/include/mlir/IR/DialectInterface.h
mlir/include/mlir/Support/InterfaceSupport.h
mlir/include/mlir/Support/StorageUniquer.h
Removed:
################################################################################
diff --git a/clang/include/clang/AST/ComparisonCategories.h b/clang/include/clang/AST/ComparisonCategories.h
index 70a78964b8a0c..b41e934142ee4 100644
--- a/clang/include/clang/AST/ComparisonCategories.h
+++ b/clang/include/clang/AST/ComparisonCategories.h
@@ -19,6 +19,7 @@
#include "llvm/ADT/DenseMap.h"
#include <array>
#include <cassert>
+#include <vector>
namespace llvm {
class StringRef;
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index bc656109c221e..2df49223c9879 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -26,6 +26,8 @@
namespace llvm {
+ template<typename T> struct DenseMapInfo;
+
/// ArrayRef - Represent a constant reference to an array (0 or more elements
/// consecutively in memory), i.e. a start pointer and a length. It allows
/// various APIs to take consecutive elements easily and conveniently.
@@ -569,6 +571,35 @@ namespace llvm {
return hash_combine_range(S.begin(), S.end());
}
+ // Provide DenseMapInfo for ArrayRefs.
+ template <typename T> struct DenseMapInfo<ArrayRef<T>> {
+ static inline ArrayRef<T> getEmptyKey() {
+ return ArrayRef<T>(
+ reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)), size_t(0));
+ }
+
+ static inline ArrayRef<T> getTombstoneKey() {
+ return ArrayRef<T>(
+ reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)), size_t(0));
+ }
+
+ static unsigned getHashValue(ArrayRef<T> Val) {
+ assert(Val.data() != getEmptyKey().data() &&
+ "Cannot hash the empty key!");
+ assert(Val.data() != getTombstoneKey().data() &&
+ "Cannot hash the tombstone key!");
+ return (unsigned)(hash_value(Val));
+ }
+
+ static bool isEqual(ArrayRef<T> LHS, ArrayRef<T> RHS) {
+ if (RHS.data() == getEmptyKey().data())
+ return LHS.data() == getEmptyKey().data();
+ if (RHS.data() == getTombstoneKey().data())
+ return LHS.data() == getTombstoneKey().data();
+ return LHS == RHS;
+ }
+ };
+
} // end namespace llvm
#endif // LLVM_ADT_ARRAYREF_H
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h
index 332208ae1ffb6..d276acbfa6a67 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -13,9 +13,7 @@
#ifndef LLVM_ADT_DENSEMAPINFO_H
#define LLVM_ADT_DENSEMAPINFO_H
-#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Hashing.h"
-#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
@@ -284,62 +282,6 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
}
};
-// Provide DenseMapInfo for StringRefs.
-template <> struct DenseMapInfo<StringRef> {
- static inline StringRef getEmptyKey() {
- return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(0)),
- 0);
- }
-
- static inline StringRef getTombstoneKey() {
- return StringRef(reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)),
- 0);
- }
-
- static unsigned getHashValue(StringRef Val) {
- assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
- assert(Val.data() != getTombstoneKey().data() &&
- "Cannot hash the tombstone key!");
- return (unsigned)(hash_value(Val));
- }
-
- static bool isEqual(StringRef LHS, StringRef RHS) {
- if (RHS.data() == getEmptyKey().data())
- return LHS.data() == getEmptyKey().data();
- if (RHS.data() == getTombstoneKey().data())
- return LHS.data() == getTombstoneKey().data();
- return LHS == RHS;
- }
-};
-
-// Provide DenseMapInfo for ArrayRefs.
-template <typename T> struct DenseMapInfo<ArrayRef<T>> {
- static inline ArrayRef<T> getEmptyKey() {
- return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(0)),
- size_t(0));
- }
-
- static inline ArrayRef<T> getTombstoneKey() {
- return ArrayRef<T>(reinterpret_cast<const T *>(~static_cast<uintptr_t>(1)),
- size_t(0));
- }
-
- static unsigned getHashValue(ArrayRef<T> Val) {
- assert(Val.data() != getEmptyKey().data() && "Cannot hash the empty key!");
- assert(Val.data() != getTombstoneKey().data() &&
- "Cannot hash the tombstone key!");
- return (unsigned)(hash_value(Val));
- }
-
- static bool isEqual(ArrayRef<T> LHS, ArrayRef<T> RHS) {
- if (RHS.data() == getEmptyKey().data())
- return LHS.data() == getEmptyKey().data();
- if (RHS.data() == getTombstoneKey().data())
- return LHS.data() == getTombstoneKey().data();
- return LHS == RHS;
- }
-};
-
template <> struct DenseMapInfo<hash_code> {
static inline hash_code getEmptyKey() { return hash_code(-1); }
static inline hash_code getTombstoneKey() { return hash_code(-2); }
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 5ba5239b21295..2279071064c33 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -35,6 +35,7 @@ namespace llvm {
class APInt;
class hash_code;
template <typename T> class SmallVectorImpl;
+ template <typename T> struct DenseMapInfo;
class StringRef;
/// Helper functions for StringRef::getAsInteger.
@@ -925,6 +926,35 @@ namespace llvm {
LLVM_NODISCARD
hash_code hash_value(StringRef S);
+ // Provide DenseMapInfo for StringRefs.
+ template <> struct DenseMapInfo<StringRef> {
+ static inline StringRef getEmptyKey() {
+ return StringRef(
+ reinterpret_cast<const char *>(~static_cast<uintptr_t>(0)), 0);
+ }
+
+ static inline StringRef getTombstoneKey() {
+ return StringRef(
+ reinterpret_cast<const char *>(~static_cast<uintptr_t>(1)), 0);
+ }
+
+ static unsigned getHashValue(StringRef Val) {
+ assert(Val.data() != getEmptyKey().data() &&
+ "Cannot hash the empty key!");
+ assert(Val.data() != getTombstoneKey().data() &&
+ "Cannot hash the tombstone key!");
+ return (unsigned)(hash_value(Val));
+ }
+
+ static bool isEqual(StringRef LHS, StringRef RHS) {
+ if (RHS.data() == getEmptyKey().data())
+ return LHS.data() == getEmptyKey().data();
+ if (RHS.data() == getTombstoneKey().data())
+ return LHS.data() == getTombstoneKey().data();
+ return LHS == RHS;
+ }
+ };
+
} // end namespace llvm
#endif // LLVM_ADT_STRINGREF_H
diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h
index b0ae1953361cb..8e81f30b22890 100644
--- a/llvm/include/llvm/IR/PassInstrumentation.h
+++ b/llvm/include/llvm/IR/PassInstrumentation.h
@@ -54,6 +54,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include <type_traits>
+#include <vector>
namespace llvm {
diff --git a/llvm/include/llvm/Support/Threading.h b/llvm/include/llvm/Support/Threading.h
index 46cf82524e575..e489caf47e9b1 100644
--- a/llvm/include/llvm/Support/Threading.h
+++ b/llvm/include/llvm/Support/Threading.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
#include "llvm/Support/Compiler.h"
#include <ciso646> // So we can check the C++ standard lib macros.
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.h b/llvm/lib/CodeGen/AsmPrinter/WinException.h
index d21b205685202..feea05ba63adb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.h
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.h
@@ -14,6 +14,7 @@
#define LLVM_LIB_CODEGEN_ASMPRINTER_WIN64EXCEPTION_H
#include "EHStreamer.h"
+#include <vector>
namespace llvm {
class GlobalValue;
diff --git a/llvm/lib/CodeGen/MBFIWrapper.cpp b/llvm/lib/CodeGen/MBFIWrapper.cpp
index 4755defec7932..efebb18c99080 100644
--- a/llvm/lib/CodeGen/MBFIWrapper.cpp
+++ b/llvm/lib/CodeGen/MBFIWrapper.cpp
@@ -11,8 +11,9 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/CodeGen/MBFIWrapper.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
+#include "llvm/CodeGen/MBFIWrapper.h"
using namespace llvm;
diff --git a/llvm/lib/MC/StringTableBuilder.cpp b/llvm/lib/MC/StringTableBuilder.cpp
index 973c59057cb5c..ec0f93d22e34c 100644
--- a/llvm/lib/MC/StringTableBuilder.cpp
+++ b/llvm/lib/MC/StringTableBuilder.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/MC/StringTableBuilder.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/CachedHashString.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp
index f60464c8e7561..f6e2dfb8a6c91 100644
--- a/llvm/lib/Support/SmallPtrSet.cpp
+++ b/llvm/lib/Support/SmallPtrSet.cpp
@@ -13,8 +13,9 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/DenseMapInfo.h"
-#include "llvm/Support/MathExtras.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/MemAlloc.h"
#include <algorithm>
#include <cassert>
#include <cstdlib>
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h
index 404e0fcd1166c..14d3a3fb7997a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUGLOBALISELUTILS_H
#define LLVM_LIB_TARGET_AMDGPU_AMDGPUGLOBALISELUTILS_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/CodeGen/Register.h"
#include <utility>
diff --git a/llvm/tools/llvm-c-test/echo.cpp b/llvm/tools/llvm-c-test/echo.cpp
index 539e87e866c69..d54adeb6c6898 100644
--- a/llvm/tools/llvm-c-test/echo.cpp
+++ b/llvm/tools/llvm-c-test/echo.cpp
@@ -18,6 +18,7 @@
#include "llvm-c/DebugInfo.h"
#include "llvm-c/Target.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ErrorHandling.h"
#include <stdio.h>
diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h
index 937efb945e4b4..6bd15789db335 100644
--- a/mlir/include/mlir/IR/AffineExpr.h
+++ b/mlir/include/mlir/IR/AffineExpr.h
@@ -17,6 +17,7 @@
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/Casting.h"
+#include <functional>
#include <type_traits>
namespace mlir {
diff --git a/mlir/include/mlir/IR/DialectInterface.h b/mlir/include/mlir/IR/DialectInterface.h
index 79826c2f6ffc3..da777e4aaa613 100644
--- a/mlir/include/mlir/IR/DialectInterface.h
+++ b/mlir/include/mlir/IR/DialectInterface.h
@@ -11,6 +11,7 @@
#include "mlir/Support/TypeID.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
namespace mlir {
class Dialect;
diff --git a/mlir/include/mlir/Support/InterfaceSupport.h b/mlir/include/mlir/Support/InterfaceSupport.h
index 6af36aa1e6223..1eed2bbf32477 100644
--- a/mlir/include/mlir/Support/InterfaceSupport.h
+++ b/mlir/include/mlir/Support/InterfaceSupport.h
@@ -14,6 +14,7 @@
#define MLIR_SUPPORT_INTERFACESUPPORT_H
#include "mlir/Support/TypeID.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/TypeName.h"
diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h
index 0b9a938b3383d..35ac619955b23 100644
--- a/mlir/include/mlir/Support/StorageUniquer.h
+++ b/mlir/include/mlir/Support/StorageUniquer.h
@@ -12,7 +12,9 @@
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Support/TypeID.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
namespace mlir {
More information about the Mlir-commits
mailing list