Add support to FoldingSet for hashing APInt objects.
authorDan Gohman <gohman@apple.com>
Wed, 6 Feb 2008 23:09:15 +0000 (23:09 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 6 Feb 2008 23:09:15 +0000 (23:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46833 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/FoldingSet.h
lib/Support/FoldingSet.cpp

index d0097613d684ed0ff26f90ebd264bfbb16416efc..ac7f428b3e7479acf1bc1d8449b97f17ecfdcdc7 100644 (file)
@@ -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
index 774fbabc28e14c4293d3f15b143f303d1a9c2a9f..b2d34834d220b5651916d40e194d83519eb1c678 100644 (file)
@@ -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++);