diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-27 15:36:50 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-27 15:36:50 -0800 |
commit | 9e010fadc279bf93533781c5bffba928301a16d6 (patch) | |
tree | d0b7cc77d1381f7dd32075eda951c1a25cb64525 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 0e55d239c3133a675a1d740f132beaa0489f689c (diff) |
simplify getPtrUse
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 57ab36f9f7..0d11b9af6c 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -212,7 +212,7 @@ namespace { } std::string getPtrLoad(const Value* Ptr); - std::string getPtrUse(const Value* Ptr, unsigned Offset=0, unsigned Bytes=0); + std::string getPtrUse(const Value* Ptr); std::string getPtr(const Value* Ptr); std::string getConstant(const Constant*, Signedness sign=ASM_SIGNED); std::string getValueAsStr(const Value*); @@ -1178,12 +1178,12 @@ std::string CppWriter::getPtrLoad(const Value* Ptr) { return getCast(getPtrUse(Ptr), t); } -std::string CppWriter::getPtrUse(const Value* Ptr, unsigned Offset, unsigned Bytes) { +std::string CppWriter::getPtrUse(const Value* Ptr) { Type *t = cast<PointerType>(Ptr->getType())->getElementType(); - if (Bytes == 0) Bytes = t->getPrimitiveSizeInBits()/8; + unsigned Bytes = t->getPrimitiveSizeInBits()/8; if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) { std::string text = ""; - unsigned Addr = getGlobalAddress(GV->getName().str()) + Offset; + unsigned Addr = getGlobalAddress(GV->getName().str()); switch (Bytes) { default: assert(false && "Unsupported type"); case 8: return "HEAPF64[" + utostr(Addr >> 3) + "]"; @@ -1199,10 +1199,6 @@ std::string CppWriter::getPtrUse(const Value* Ptr, unsigned Offset, unsigned Byt } } else { std::string Name = getOpName(Ptr); - if (Offset) { - Name += "+" + Offset; - if (Bytes == 1) Name = "(" + Name + ")|0"; - } switch (Bytes) { default: assert(false && "Unsupported type"); case 8: return "HEAPF64[" + Name + ">>3]"; |