[llvm-commits] [llvm] r41309 - in /llvm/trunk: examples/Fibonacci/fibonacci.cpp examples/HowToUseJIT/HowToUseJIT.cpp include/llvm/ADT/APInt.h include/llvm/ADT/APSInt.h lib/ExecutionEngine/Interpreter/Execution.cpp lib/Support/APInt.cpp lib/Transforms/IPO/ArgumentPromotion.cpp

Chris Lattner sabre at nondot.org
Wed Aug 22 22:15:33 PDT 2007


Author: lattner
Date: Thu Aug 23 00:15:32 2007
New Revision: 41309

URL: http://llvm.org/viewvc/llvm-project?rev=41309&view=rev
Log:
rename APInt::toString -> toStringUnsigned for symmetry with toStringSigned()

Add an APSInt::toString() method.


Modified:
    llvm/trunk/examples/Fibonacci/fibonacci.cpp
    llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
    llvm/trunk/include/llvm/ADT/APInt.h
    llvm/trunk/include/llvm/ADT/APSInt.h
    llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp
    llvm/trunk/lib/Support/APInt.cpp
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp

Modified: llvm/trunk/examples/Fibonacci/fibonacci.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Fibonacci/fibonacci.cpp?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/examples/Fibonacci/fibonacci.cpp (original)
+++ llvm/trunk/examples/Fibonacci/fibonacci.cpp Thu Aug 23 00:15:32 2007
@@ -116,6 +116,6 @@
   GenericValue GV = EE->runFunction(FibF, Args);
 
   // import result of execution
-  std::cout << "Result: " << GV.IntVal.toString(10) << "\n";
+  std::cout << "Result: " << GV.IntVal.toStringUnsigned(10) << "\n";
   return 0;
 }

Modified: llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp (original)
+++ llvm/trunk/examples/HowToUseJIT/HowToUseJIT.cpp Thu Aug 23 00:15:32 2007
@@ -107,6 +107,6 @@
   GenericValue gv = EE->runFunction(FooF, noargs);
 
   // Import result of execution:
-  std::cout << "Result: " << gv.IntVal.toString(10) << "\n";
+  std::cout << "Result: " << gv.IntVal.toStringUnsigned(10) << "\n";
   return 0;
 }

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Thu Aug 23 00:15:32 2007
@@ -932,7 +932,7 @@
   /// radix given. The radix can be 2, 8, 10 or 16.
   /// @returns a character interpretation of the APInt
   /// @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);
   }
 

Modified: llvm/trunk/include/llvm/ADT/APSInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APSInt.h?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/APSInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APSInt.h Thu Aug 23 00:15:32 2007
@@ -52,6 +52,12 @@
   void setIsUnsigned(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) {
     assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!");

Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp Thu Aug 23 00:15:32 2007
@@ -1346,8 +1346,9 @@
     case Type::DoubleTyID:  DOUT << "double " << Val.DoubleVal; break;
     case Type::PointerTyID: DOUT << "void* " << intptr_t(Val.PointerVal); break;
     case Type::IntegerTyID: 
-      DOUT << "i" << Val.IntVal.getBitWidth() << " " << Val.IntVal.toString(10)
-           << " (0x" << Val.IntVal.toString(16) << ")\n";
+      DOUT << "i" << Val.IntVal.getBitWidth() << " "
+           << Val.IntVal.toStringUnsigned(10)
+           << " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
       break;
   }
 }

Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Thu Aug 23 00:15:32 2007
@@ -2008,8 +2008,8 @@
   else for (unsigned i = getNumWords(); i > 0; i--) {
     cerr << pVal[i-1] << " ";
   }
-  cerr << " U(" << this->toString(10) << ") S(" << this->toStringSigned(10)
-       << ")\n" << std::setbase(10);
+  cerr << " U(" << this->toStringUnsigned(10) << ") S("
+       << this->toStringSigned(10) << ")\n" << std::setbase(10);
 }
 #endif
 

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=41309&r1=41308&r2=41309&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu Aug 23 00:15:32 2007
@@ -519,7 +519,7 @@
           std::string NewName = I->getName();
           for (unsigned i = 0, e = Operands.size(); i != e; ++i)
             if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i]))
-              NewName += "." + CI->getValue().toString(10);
+              NewName += "." + CI->getValue().toStringUnsigned(10);
             else
               NewName += ".x";
           TheArg->setName(NewName+".val");





More information about the llvm-commits mailing list