diff options
author | Dan Gohman <gohman@apple.com> | 2008-02-06 23:09:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-02-06 23:09:15 +0000 |
commit | 167b8bc24d4cc2789c682962b123877a73ad0568 (patch) | |
tree | ba2a844a56860b1290012c53cdbd52daa2c0d3f2 | |
parent | 69de1932b350d7cdfc0ed1f4198d6f78c7822a02 (diff) | |
download | llvm-167b8bc24d4cc2789c682962b123877a73ad0568.tar.gz llvm-167b8bc24d4cc2789c682962b123877a73ad0568.tar.bz2 llvm-167b8bc24d4cc2789c682962b123877a73ad0568.tar.xz |
Add support to FoldingSet for hashing APInt objects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46833 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/FoldingSet.h | 2 | ||||
-rw-r--r-- | lib/Support/FoldingSet.cpp | 4 |
2 files changed, 6 insertions, 0 deletions
diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index d0097613d6..ac7f428b3e 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -22,6 +22,7 @@ namespace llvm { class APFloat; + class APInt; /// This folding set used for two purposes: /// 1. Given information about a node we want to create, look up the unique @@ -206,6 +207,7 @@ public: void AddFloat(float F); void AddDouble(double D); void AddAPFloat(const APFloat& apf); + void AddAPInt(const APInt& api); void AddString(const std::string &String); /// clear - Clear the accumulated profile, allowing this FoldingSetNodeID diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 774fbabc28..b2d34834d2 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/APInt.h" #include "llvm/Support/MathExtras.h" #include <cassert> using namespace llvm; @@ -59,6 +60,9 @@ void FoldingSetNodeID::AddDouble(double D) { } void FoldingSetNodeID::AddAPFloat(const APFloat& apf) { APInt api = apf.convertToAPInt(); + AddAPInt(api); +} +void FoldingSetNodeID::AddAPInt(const APInt& api) { const uint64_t *p = api.getRawData(); for (unsigned i=0; i<api.getNumWords(); i++) AddInteger(*p++); |