//===----------------------------------------------------------------------===//
#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/APFloat.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
+#include <cstring>
using namespace llvm;
//===----------------------------------------------------------------------===//
void FoldingSetNodeID::AddDouble(double D) {
AddInteger(DoubleToBits(D));
}
-void FoldingSetNodeID::AddAPFloat(const APFloat& apf) {
- APInt api = apf.convertToAPInt();
- const uint64_t *p = api.getRawData();
- for (unsigned i=0; i<api.getNumWords(); i++)
- AddInteger(*p++);
-}
void FoldingSetNodeID::AddString(const std::string &String) {
unsigned Size = String.size();
Bits.push_back(Size);
return static_cast<FoldingSetImpl::Node*>(NextInBucketPtr);
}
-/// GetBucketPtr - Provides a casting of a bucket pointer for isNode
+
/// testing.
static void **GetBucketPtr(void *NextInBucketPtr) {
intptr_t Ptr = reinterpret_cast<intptr_t>(NextInBucketPtr);
/// FindNodeOrInsertPos - Look up the node specified by ID. If it exists,
/// return it. If not, return the insertion token that will make insertion
/// faster.
-FoldingSetImpl::Node *FoldingSetImpl::FindNodeOrInsertPos(const FoldingSetNodeID &ID,
- void *&InsertPos) {
+FoldingSetImpl::Node
+*FoldingSetImpl::FindNodeOrInsertPos(const FoldingSetNodeID &ID,
+ void *&InsertPos) {
+
void **Bucket = GetBucketFor(ID, Buckets, NumBuckets);
void *Probe = *Bucket;
FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
// Skip to the first non-null non-self-cycle bucket.
- while (*Bucket == 0 || GetNextPtr(*Bucket) == 0)
+ while (*Bucket != reinterpret_cast<void*>(-1) &&
+ (*Bucket == 0 || GetNextPtr(*Bucket) == 0))
++Bucket;
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
// Skip to the next non-null non-self-cycle bucket.
do {
++Bucket;
- } while (*Bucket == 0 || GetNextPtr(*Bucket) == 0);
+ } while (*Bucket != reinterpret_cast<void*>(-1) &&
+ (*Bucket == 0 || GetNextPtr(*Bucket) == 0));
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
}
}
+//===----------------------------------------------------------------------===//
+// FoldingSetBucketIteratorImpl Implementation
+
+FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(void **Bucket) {
+ Ptr = (*Bucket == 0 || GetNextPtr(*Bucket) == 0) ? (void*) Bucket : *Bucket;
+}