Index: src/IceGlobalContext.cpp |
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp |
index ab63b4cda6bd878b4bcc89fd0eae600fa92fcbb9..f8b1145daa43c4a331a1bf6968e41267e3da7d25 100644 |
--- a/src/IceGlobalContext.cpp |
+++ b/src/IceGlobalContext.cpp |
@@ -34,16 +34,26 @@ class TypePool { |
TypePool &operator=(const TypePool &) LLVM_DELETED_FUNCTION; |
public: |
- TypePool() {} |
+ TypePool() : NextPoolID(0) {} |
ValueType *getOrAdd(GlobalContext *Ctx, Type Ty, KeyType Key) { |
TupleType TupleKey = std::make_pair(Ty, Key); |
typename ContainerType::const_iterator Iter = Pool.find(TupleKey); |
if (Iter != Pool.end()) |
return Iter->second; |
- ValueType *Result = ValueType::create(Ctx, Ty, Key); |
+ ValueType *Result = ValueType::create(Ctx, Ty, Key, NextPoolID++); |
Pool[TupleKey] = Result; |
return Result; |
} |
+ ConstantList getConstantPool() const { |
+ ConstantList Constants; |
+ Constants.reserve(Pool.size()); |
+ for (typename ContainerType::const_iterator I = Pool.begin(), |
+ E = Pool.end(); |
+ I != E; ++I) { |
+ Constants.push_back((*I).second); |
JF
2014/05/22 21:39:47
I->second ?
Also, C++11 lambdas would be nice her
Jim Stichnoth
2014/05/22 23:48:28
Done.
|
+ } |
+ return Constants; |
+ } |
private: |
typedef std::pair<Type, KeyType> TupleType; |
@@ -58,6 +68,7 @@ private: |
}; |
typedef std::map<const TupleType, ValueType *, TupleCompare> ContainerType; |
ContainerType Pool; |
+ uint32_t NextPoolID; |
}; |
// The global constant pool bundles individual pools of each type of |
@@ -171,6 +182,14 @@ Constant *GlobalContext::getConstantSym(Type Ty, int64_t Offset, |
this, Ty, RelocatableTuple(Offset, Name, SuppressMangling)); |
} |
+ConstantList GlobalContext::getConstantPool(Type Ty) const { |
+ if (Ty == IceType_f32) |
+ return ConstPool->Floats.getConstantPool(); |
+ if (Ty == IceType_f64) |
+ return ConstPool->Doubles.getConstantPool(); |
+ return ConstPool->Integers.getConstantPool(); |
JF
2014/05/22 21:39:47
A switch would be nice, so that if you add types y
Jim Stichnoth
2014/05/22 23:48:28
Done.
|
+} |
+ |
void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const { |
if (Ctx->isVerbose(IceV_Timing)) { |
// Prefixing with '#' allows timing strings to be included |