Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: src/IceGlobalContext.cpp

Issue 291213003: Subzero: Fix x86 floating-point constant emission (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: "Fix" static casting Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceOperand.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.cpp
diff --git a/src/IceGlobalContext.cpp b/src/IceGlobalContext.cpp
index ab63b4cda6bd878b4bcc89fd0eae600fa92fcbb9..7a21b401f36f2c5098bddecd0aa102504842a248 100644
--- a/src/IceGlobalContext.cpp
+++ b/src/IceGlobalContext.cpp
@@ -34,16 +34,27 @@ 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());
+ // TODO: replace the loop with std::transform + lambdas.
+ for (typename ContainerType::const_iterator I = Pool.begin(),
+ E = Pool.end();
+ I != E; ++I) {
+ Constants.push_back(I->second);
+ }
+ return Constants;
+ }
private:
typedef std::pair<Type, KeyType> TupleType;
@@ -58,6 +69,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 +183,25 @@ Constant *GlobalContext::getConstantSym(Type Ty, int64_t Offset,
this, Ty, RelocatableTuple(Offset, Name, SuppressMangling));
}
+ConstantList GlobalContext::getConstantPool(Type Ty) const {
+ switch (Ty) {
+ case IceType_i1:
+ case IceType_i8:
+ case IceType_i16:
+ case IceType_i32:
+ case IceType_i64:
+ return ConstPool->Integers.getConstantPool();
+ case IceType_f32:
+ return ConstPool->Floats.getConstantPool();
+ case IceType_f64:
+ return ConstPool->Doubles.getConstantPool();
+ case IceType_void:
+ case IceType_NUM:
+ break;
+ }
+ llvm_unreachable("Unknown type");
+}
+
void Timer::printElapsedUs(GlobalContext *Ctx, const IceString &Tag) const {
if (Ctx->isVerbose(IceV_Timing)) {
// Prefixing with '#' allows timing strings to be included
« no previous file with comments | « src/IceGlobalContext.h ('k') | src/IceOperand.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698