Provide correct NEON encodings for vaddl.u* and vaddl.s*.
[oota-llvm.git] / lib / Support / Twine.cpp
index c9e5f2401eca40b36c71d3f4ec89c9e84f161342..b3ea0132e4aceb0454a5c4bb8c19443068a5dcc7 100644 (file)
@@ -8,28 +8,28 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/Twine.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Debug.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;
+  return toStringRef(Vec).str();
 }
 
 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);
 }
 
+StringRef Twine::toStringRef(SmallVectorImpl<char> &Out) const {
+  if (isSingleStringRef())
+    return getSingleStringRef();
+  toVector(Out);
+  return StringRef(Out.data(), Out.size());
+}
+
 void Twine::printOneChild(raw_ostream &OS, const void *Ptr, 
                           NodeKind Kind) const {
   switch (Kind) {
@@ -47,15 +47,26 @@ void Twine::printOneChild(raw_ostream &OS, const void *Ptr,
   case Twine::StringRefKind:
     OS << *static_cast<const StringRef*>(Ptr); 
     break;
-  case Twine::UDecKind:
-    OS << *static_cast<const uint64_t*>(Ptr);
+  case Twine::DecUIKind:
+    OS << (unsigned)(uintptr_t)Ptr;
+    break;
+  case Twine::DecIKind:
+    OS << (int)(intptr_t)Ptr;
+    break;
+  case Twine::DecULKind:
+    OS << *static_cast<const unsigned long*>(Ptr);
+    break;
+  case Twine::DecLKind:
+    OS << *static_cast<const long*>(Ptr);
     break;
-  case Twine::SDecKind:
-    OS << *static_cast<const int64_t*>(Ptr);
+  case Twine::DecULLKind:
+    OS << *static_cast<const unsigned long long*>(Ptr);
+    break;
+  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;
   }
 }
@@ -83,14 +94,26 @@ void Twine::printOneChildRepr(raw_ostream &OS, const void *Ptr,
     OS << "stringref:\""
        << static_cast<const StringRef*>(Ptr) << "\"";
     break;
-  case Twine::UDecKind:
-    OS << "udec:" << static_cast<const uint64_t*>(Ptr) << "\"";
+  case Twine::DecUIKind:
+    OS << "decUI:\"" << (unsigned)(uintptr_t)Ptr << "\"";
+    break;
+  case Twine::DecIKind:
+    OS << "decI:\"" << (int)(intptr_t)Ptr << "\"";
+    break;
+  case Twine::DecULKind:
+    OS << "decUL:\"" << *static_cast<const unsigned long*>(Ptr) << "\"";
+    break;
+  case Twine::DecLKind:
+    OS << "decL:\"" << *static_cast<const long*>(Ptr) << "\"";
+    break;
+  case Twine::DecULLKind:
+    OS << "decULL:\"" << *static_cast<const unsigned long long*>(Ptr) << "\"";
     break;
-  case Twine::SDecKind:
-    OS << "sdec:" << 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;
   }
 }
@@ -109,9 +132,9 @@ void Twine::printRepr(raw_ostream &OS) const {
 }
 
 void Twine::dump() const {
-  print(llvm::errs());
+  print(llvm::dbgs());
 }
 
 void Twine::dumpRepr() const {
-  printRepr(llvm::errs());
+  printRepr(llvm::dbgs());
 }