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

Unified Diff: src/PNaClTranslator.cpp

Issue 737513008: Subzero: Simplify the constant pools. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More cleanup Created 6 years, 1 month 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
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 0f4feacafe5d2768bd8edae99a2ab2f6c5a65087..37ba5eef059ba673dc8acf4fc17a7ac15dec383f 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -325,8 +325,8 @@ public:
SuppressMangling = false;
}
const Ice::RelocOffsetT Offset = 0;
- C = getTranslator().getContext()->getConstantSym(
- getIcePointerType(), Offset, Name, SuppressMangling);
+ C = getTranslator().getContext()->getConstantSym(Offset, Name,
+ SuppressMangling);
ValueIDConstants[ID] = C;
return C;
}
@@ -1440,7 +1440,7 @@ private:
const auto *C = dyn_cast<Ice::ConstantInteger32>(Index);
if (C == nullptr)
return VectorIndexNotConstant;
- if (C->getValue() >= typeNumElements(VecType))
+ if (static_cast<size_t>(C->getValue()) >= typeNumElements(VecType))
return VectorIndexNotInRange;
if (Index->getType() != Ice::IceType_i32)
return VectorIndexNotI32;
@@ -2499,13 +2499,31 @@ void ConstantsParser::ProcessRecord() {
if (IntegerType *IType = dyn_cast<IntegerType>(
Context->convertToLLVMType(NextConstantType))) {
APInt Value(IType->getBitWidth(), NaClDecodeSignRotatedValue(Values[0]));
- Ice::Constant *C = (NextConstantType == Ice::IceType_i64)
- ? getContext()->getConstantInt64(
- NextConstantType, Value.getSExtValue())
- : getContext()->getConstantInt32(
- NextConstantType, Value.getSExtValue());
- FuncParser->setNextConstantID(C);
- return;
+ Ice::Constant *C = nullptr;
+ switch (NextConstantType) {
Karl 2014/11/19 18:45:28 Why not provide a helper function (in IceGlobalCon
Jim Stichnoth 2014/11/20 00:08:57 Done.
+ default:
+ assert(0);
+ break;
+ case Ice::IceType_i1:
+ C = getContext()->getConstantInt1(Value.getSExtValue());
+ break;
+ case Ice::IceType_i8:
+ C = getContext()->getConstantInt8(Value.getSExtValue());
+ break;
+ case Ice::IceType_i16:
+ C = getContext()->getConstantInt16(Value.getSExtValue());
+ break;
+ case Ice::IceType_i32:
+ C = getContext()->getConstantInt32(Value.getSExtValue());
+ break;
+ case Ice::IceType_i64:
+ C = getContext()->getConstantInt64(Value.getSExtValue());
+ break;
+ }
+ if (C) {
+ FuncParser->setNextConstantID(C);
+ return;
+ }
}
std::string Buffer;
raw_string_ostream StrBuf(Buffer);

Powered by Google App Engine
This is Rietveld 408576698