summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-02-06 23:09:15 +0000
committerDan Gohman <gohman@apple.com>2008-02-06 23:09:15 +0000
commit4f26eb727072d49c2699cc7fac20742f16eb75c1 (patch)
treee35d6649896669c7fa4505026567854ff6ce3ac0
parent4aa77cee1166b14de7008e0dad247c4c1db56f06 (diff)
downloadbcm5719-llvm-4f26eb727072d49c2699cc7fac20742f16eb75c1.tar.gz
bcm5719-llvm-4f26eb727072d49c2699cc7fac20742f16eb75c1.zip
Add support to FoldingSet for hashing APInt objects.
llvm-svn: 46833
-rw-r--r--llvm/include/llvm/ADT/FoldingSet.h2
-rw-r--r--llvm/lib/Support/FoldingSet.cpp4
2 files changed, 6 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h
index d0097613d68..ac7f428b3e7 100644
--- a/llvm/include/llvm/ADT/FoldingSet.h
+++ b/llvm/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/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp
index 774fbabc28e..b2d34834d22 100644
--- a/llvm/lib/Support/FoldingSet.cpp
+++ b/llvm/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++);
OpenPOWER on IntegriCloud