diff options
author | Daniel Dunbar <daniel@zuster.org> | 2012-03-08 02:52:00 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2012-03-08 02:52:00 +0000 |
commit | 3f778c2241dcf44d66245bf4a7d13d1228b5b96e (patch) | |
tree | 140e51fb54ed0cb4544072e91ec04da26e1f9e19 /include/llvm/ADT | |
parent | e2bdf7fc935008dda6fba3d6fdd0a12193fd7b18 (diff) | |
download | external_llvm-3f778c2241dcf44d66245bf4a7d13d1228b5b96e.zip external_llvm-3f778c2241dcf44d66245bf4a7d13d1228b5b96e.tar.gz external_llvm-3f778c2241dcf44d66245bf4a7d13d1228b5b96e.tar.bz2 |
[ADT] Change the trivial FoldingSetNodeID::Add* methods to be inline.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r-- | include/llvm/ADT/FoldingSet.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index d2e0b8f..bda54e2 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -17,6 +17,7 @@ #define LLVM_ADT_FOLDINGSET_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -310,6 +311,7 @@ public: void AddInteger(unsigned long long I); void AddBoolean(bool B) { AddInteger(B ? 1U : 0U); } void AddString(StringRef String); + /// AddNodeID - Adds the Bit data of another ID to *this. void AddNodeID(const FoldingSetNodeID &ID); template <typename T> @@ -675,6 +677,50 @@ template<typename T> struct FoldingSetTrait<T*> { ID.AddPointer(X); } }; + +//===----------------------------------------------------------------------===// +// FoldingSetNodeID Inline function definitions + +/// Add* - Add various data types to Bit data. +/// +inline void FoldingSetNodeID::AddPointer(const void *Ptr) { + // Note: this adds pointers to the hash using sizes and endianness that + // depend on the host. It doesn't matter however, because hashing on + // pointer values in inherently unstable. Nothing should depend on the + // ordering of nodes in the folding set. + Bits.append(reinterpret_cast<unsigned *>(&Ptr), + reinterpret_cast<unsigned *>(&Ptr+1)); +} +inline void FoldingSetNodeID::AddInteger(signed I) { + Bits.push_back(I); +} +inline void FoldingSetNodeID::AddInteger(unsigned I) { + Bits.push_back(I); +} +inline void FoldingSetNodeID::AddInteger(long I) { + AddInteger((unsigned long)I); +} +inline void FoldingSetNodeID::AddInteger(unsigned long I) { + if (sizeof(long) == sizeof(int)) + AddInteger(unsigned(I)); + else if (sizeof(long) == sizeof(long long)) { + AddInteger((unsigned long long)I); + } else { + llvm_unreachable("unexpected sizeof(long)"); + } +} +inline void FoldingSetNodeID::AddInteger(long long I) { + AddInteger((unsigned long long)I); +} +inline void FoldingSetNodeID::AddInteger(unsigned long long I) { + AddInteger(unsigned(I)); + if ((uint64_t)(unsigned)I != I) + Bits.push_back(unsigned(I >> 32)); +} +inline void FoldingSetNodeID::AddNodeID(const FoldingSetNodeID &ID) { + Bits.append(ID.Bits.begin(), ID.Bits.end()); +} + } // End of namespace llvm. #endif |