diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-25 12:39:46 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-25 12:39:46 -0800 |
commit | a8c84865fa678cd5baf55122388937fe5ebcad38 (patch) | |
tree | 57f46e8db8b96b0e45d308910d8bff5e8aa489b5 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | c3c135704cc59d67cad533c0f0468906dd6a5f25 (diff) |
sign/unsign constants
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 2cd4b2d95e..f847ba1469 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -193,7 +193,7 @@ namespace { std::string getPtrLoad(const Value* Ptr); std::string getPtrUse(const Value* Ptr, unsigned Offset=0, unsigned Bytes=0); std::string getPtr(const Value* Ptr); - std::string getConstant(const Constant*); + std::string getConstant(const Constant*, Signedness sign=ASM_SIGNED); std::string getValueAsStr(const Value*); std::string getValueAsCastStr(const Value*, Signedness sign=ASM_SIGNED); std::string getValueAsParenStr(const Value*); @@ -1200,7 +1200,7 @@ std::string CppWriter::getPtr(const Value* Ptr) { } } -std::string CppWriter::getConstant(const Constant* CV) { +std::string CppWriter::getConstant(const Constant* CV, Signedness sign) { if (isa<PointerType>(CV->getType())) { return getPtr(CV); } else { @@ -1210,7 +1210,7 @@ std::string CppWriter::getConstant(const Constant* CV) { // if (S.find('.') == S.npos) { TODO: do this when necessary, but it is necessary even for 0.0001 return S; } else if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { - return CI->getValue().toString(10, true); + return CI->getValue().toString(10, sign == ASM_SIGNED); } else { assert(false); } @@ -1227,7 +1227,7 @@ std::string CppWriter::getValueAsStr(const Value* V) { std::string CppWriter::getValueAsCastStr(const Value* V, Signedness sign) { if (const Constant *CV = dyn_cast<Constant>(V)) { - return getConstant(CV); + return getConstant(CV, sign); } else { return getCast(getCppName(V), V->getType(), sign); } @@ -1243,7 +1243,7 @@ std::string CppWriter::getValueAsParenStr(const Value* V) { std::string CppWriter::getValueAsCastParenStr(const Value* V, Signedness sign) { if (const Constant *CV = dyn_cast<Constant>(V)) { - return getConstant(CV); + return getConstant(CV, sign); } else { return "(" + getCast(getCppName(V), V->getType(), sign) + ")"; } |