From a8c84865fa678cd5baf55122388937fe5ebcad38 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 25 Nov 2013 12:39:46 -0800 Subject: sign/unsign constants --- lib/Target/CppBackend/CPPBackend.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/Target/CppBackend/CPPBackend.cpp') 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(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(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(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(V)) { - return getConstant(CV); + return getConstant(CV, sign); } else { return "(" + getCast(getCppName(V), V->getType(), sign) + ")"; } -- cgit v1.2.3-18-g5258