mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 23:32:58 +00:00
rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()
Add an APSInt::toString() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41309 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c00c2baf48
commit
9132a2b818
@ -116,6 +116,6 @@ int main(int argc, char **argv) {
|
|||||||
GenericValue GV = EE->runFunction(FibF, Args);
|
GenericValue GV = EE->runFunction(FibF, Args);
|
||||||
|
|
||||||
// import result of execution
|
// import result of execution
|
||||||
std::cout << "Result: " << GV.IntVal.toString(10) << "\n";
|
std::cout << "Result: " << GV.IntVal.toStringUnsigned(10) << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,6 @@ int main() {
|
|||||||
GenericValue gv = EE->runFunction(FooF, noargs);
|
GenericValue gv = EE->runFunction(FooF, noargs);
|
||||||
|
|
||||||
// Import result of execution:
|
// Import result of execution:
|
||||||
std::cout << "Result: " << gv.IntVal.toString(10) << "\n";
|
std::cout << "Result: " << gv.IntVal.toStringUnsigned(10) << "\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -932,7 +932,7 @@ public:
|
|||||||
/// radix given. The radix can be 2, 8, 10 or 16.
|
/// radix given. The radix can be 2, 8, 10 or 16.
|
||||||
/// @returns a character interpretation of the APInt
|
/// @returns a character interpretation of the APInt
|
||||||
/// @brief Convert unsigned APInt to string representation.
|
/// @brief Convert unsigned APInt to string representation.
|
||||||
inline std::string toString(uint8_t radix = 10) const {
|
inline std::string toStringUnsigned(uint8_t radix = 10) const {
|
||||||
return toString(radix, false);
|
return toString(radix, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,12 @@ public:
|
|||||||
void setIsUnsigned(bool Val) { IsUnsigned = Val; }
|
void setIsUnsigned(bool Val) { IsUnsigned = Val; }
|
||||||
void setIsSigned(bool Val) { IsUnsigned = !Val; }
|
void setIsSigned(bool Val) { IsUnsigned = !Val; }
|
||||||
|
|
||||||
|
/// This is used internally to convert an APInt to a string.
|
||||||
|
/// @brief Converts an APInt to a std::string
|
||||||
|
std::string toString(uint8_t Radix) const {
|
||||||
|
return toString(Radix, isSigned());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const APSInt &operator%=(const APSInt &RHS) {
|
const APSInt &operator%=(const APSInt &RHS) {
|
||||||
assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
|
assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");
|
||||||
|
@ -1346,8 +1346,9 @@ static void PrintGenericValue(const GenericValue &Val, const Type* Ty) {
|
|||||||
case Type::DoubleTyID: DOUT << "double " << Val.DoubleVal; break;
|
case Type::DoubleTyID: DOUT << "double " << Val.DoubleVal; break;
|
||||||
case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); break;
|
case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); break;
|
||||||
case Type::IntegerTyID:
|
case Type::IntegerTyID:
|
||||||
DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
|
DOUT << "i" << Val.IntVal.getBitWidth() << " "
|
||||||
<< " (0x" << Val.IntVal.toString(16) << ")\n";
|
<< Val.IntVal.toStringUnsigned(10)
|
||||||
|
<< " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2008,8 +2008,8 @@ void APInt::dump() const
|
|||||||
else for (unsigned i = getNumWords(); i > 0; i--) {
|
else for (unsigned i = getNumWords(); i > 0; i--) {
|
||||||
cerr << pVal[i-1] << " ";
|
cerr << pVal[i-1] << " ";
|
||||||
}
|
}
|
||||||
cerr << " U(" << this->toString(10) << ") S(" << this->toStringSigned(10)
|
cerr << " U(" << this->toStringUnsigned(10) << ") S("
|
||||||
<< ")\n" << std::setbase(10);
|
<< this->toStringSigned(10) << ")\n" << std::setbase(10);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
|
|||||||
std::string NewName = I->getName();
|
std::string NewName = I->getName();
|
||||||
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
||||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i]))
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i]))
|
||||||
NewName += "." + CI->getValue().toString(10);
|
NewName += "." + CI->getValue().toStringUnsigned(10);
|
||||||
else
|
else
|
||||||
NewName += ".x";
|
NewName += ".x";
|
||||||
TheArg->setName(NewName+".val");
|
TheArg->setName(NewName+".val");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user