For fastcc on x86, let ECX be used as a return register after EAX and EDX
[oota-llvm.git] / lib / Support / Twine.cpp
index 2b0cf062ec875ddeecf55a270887a4a5d937ba3e..292c0c2b9e5e53772ab3a38240a311f2908aa898 100644 (file)
@@ -8,24 +8,17 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/Twine.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
 std::string Twine::str() const {
-  std::string Res;
-  raw_string_ostream OS(Res);
-  print(OS);
-  return Res;
+  SmallString<256> Vec;
+  toVector(Vec);
+  return std::string(Vec.begin(), Vec.end());
 }
 
 void Twine::toVector(SmallVectorImpl<char> &Out) const {
-  // FIXME: This is very inefficient, since we are creating a large raw_ostream
-  // buffer -- hitting malloc, which we were supposed to avoid -- all when we
-  // have this pretty little small vector available.
-  //
-  // The best way to fix this is to make raw_svector_ostream do the right thing
-  // and be efficient, by augmenting the base raw_ostream with the ability to
-  // have the buffer managed by a concrete implementation.
   raw_svector_ostream OS(Out);
   print(OS);
 }
@@ -47,21 +40,26 @@ void Twine::printOneChild(raw_ostream &OS, const void *Ptr,
   case Twine::StringRefKind:
     OS << *static_cast<const StringRef*>(Ptr); 
     break;
-  case Twine::UDec32Kind:
-    OS << *static_cast<const uint32_t*>(Ptr);
+  case Twine::DecUIKind:
+    OS << *static_cast<const unsigned int*>(Ptr);
+    break;
+  case Twine::DecIKind:
+    OS << *static_cast<const int*>(Ptr);
+    break;
+  case Twine::DecULKind:
+    OS << *static_cast<const unsigned long*>(Ptr);
     break;
-  case Twine::SDec32Kind:
-    OS << *static_cast<const int32_t*>(Ptr);
+  case Twine::DecLKind:
+    OS << *static_cast<const long*>(Ptr);
     break;
-  case Twine::UDec64Kind:
-    OS << *static_cast<const uint64_t*>(Ptr);
+  case Twine::DecULLKind:
+    OS << *static_cast<const unsigned long long*>(Ptr);
     break;
-  case Twine::SDec64Kind:
-    OS << *static_cast<const int64_t*>(Ptr);
+  case Twine::DecLLKind:
+    OS << *static_cast<const long long*>(Ptr);
     break;
   case Twine::UHexKind:
-    // FIXME: Add raw_ostream functionality for this.
-    OS << ::utohexstr(*static_cast<const uint64_t*>(Ptr));
+    OS.write_hex(*static_cast<const uint64_t*>(Ptr));
     break;
   }
 }
@@ -89,20 +87,26 @@ void Twine::printOneChildRepr(raw_ostream &OS, const void *Ptr,
     OS << "stringref:\""
        << static_cast<const StringRef*>(Ptr) << "\"";
     break;
-  case Twine::UDec32Kind:
-    OS << "udec32:" << static_cast<const uint64_t*>(Ptr) << "\"";
+  case Twine::DecUIKind:
+    OS << "decUI:\"" << *static_cast<const unsigned int*>(Ptr) << "\"";
+    break;
+  case Twine::DecIKind:
+    OS << "decI:\"" << *static_cast<const int*>(Ptr) << "\"";
+    break;
+  case Twine::DecULKind:
+    OS << "decUL:\"" << *static_cast<const unsigned long*>(Ptr) << "\"";
     break;
-  case Twine::SDec32Kind:
-    OS << "sdec32:" << static_cast<const int64_t*>(Ptr) << "\"";
+  case Twine::DecLKind:
+    OS << "decL:\"" << *static_cast<const long*>(Ptr) << "\"";
     break;
-  case Twine::UDec64Kind:
-    OS << "udec64:" << static_cast<const uint64_t*>(Ptr) << "\"";
+  case Twine::DecULLKind:
+    OS << "decULL:\"" << *static_cast<const unsigned long long*>(Ptr) << "\"";
     break;
-  case Twine::SDec64Kind:
-    OS << "sdec64:" << static_cast<const int64_t*>(Ptr) << "\"";
+  case Twine::DecLLKind:
+    OS << "decLL:\"" << *static_cast<const long long*>(Ptr) << "\"";
     break;
   case Twine::UHexKind:
-    OS << "uhex:" << static_cast<const uint64_t*>(Ptr) << "\"";
+    OS << "uhex:\"" << static_cast<const uint64_t*>(Ptr) << "\"";
     break;
   }
 }