Index: src/IceOperand.cpp |
diff --git a/src/IceOperand.cpp b/src/IceOperand.cpp |
index 02e85c76854df1ade16f3f62de2a317209822e19..7f69648a17fded7ce27b7ff0023955b5c98cb2b7 100644 |
--- a/src/IceOperand.cpp |
+++ b/src/IceOperand.cpp |
@@ -237,6 +237,82 @@ void ConstantRelocatable::dump(GlobalContext *Ctx) const { |
Str << "+" << Offset; |
} |
+namespace { |
+ |
+// Read an item of type T and return it. Advance the buffer pointer |
+// by the size of T. |
+template <typename T> T convertAndAdvance(const char *&Src) { |
+ T Dest; |
+ std::memcpy(&Dest, Src, sizeof(T)); |
+ Src += sizeof(T); |
+ return Dest; |
+} |
+ |
+// Convert a vector to a list of strings. |
+StringList getVectorRepr(const Vect128 &Vector, const Type Ty) { |
+ StringList Repr; |
+ const char *Window = Vector.data(); |
+ |
+ Type ElementType = typeElementType(Ty); |
+ size_t NumElements = typeNumElements(Ty); |
+ |
+ assert(Vector.size() == 16); |
jvoung (off chromium)
2014/06/26 00:45:41
I think there are places in other files where you
wala
2014/06/26 17:32:42
That's a good idea. I will add it to IceDefs.h.
T
|
+ assert(typeElementType(Ty) != IceType_i1); |
+ |
+ for (unsigned I = 0; I < NumElements; ++I) { |
+ IceString Result; |
+ llvm::raw_string_ostream OS(Result); |
+ switch (ElementType) { |
+ default: |
+ llvm_unreachable("Unknown element type"); |
+ break; |
+ case IceType_i8: |
+ OS << (unsigned)convertAndAdvance<uint8_t>(Window); |
+ break; |
+ case IceType_i16: |
+ OS << convertAndAdvance<uint16_t>(Window); |
+ break; |
+ case IceType_i32: |
+ OS << convertAndAdvance<uint32_t>(Window); |
+ break; |
+ case IceType_f32: |
+ OS << convertAndAdvance<float>(Window); |
+ break; |
+ } |
+ Repr.push_back(OS.str()); |
+ } |
+ |
+ assert(Window == Vector.data() + 16); |
+ return Repr; |
+} |
+} |
+ |
+template <> void ConstantVector::dump(GlobalContext *Ctx) const { |
+ Ostream &Str = Ctx->getStrDump(); |
+ Type Ty = getType(); |
+ StringList Elements = getVectorRepr(Value, Ty); |
+ Str << "<"; |
+ for (StringList::const_iterator I = Elements.begin(), E = Elements.end(); |
+ I != E;) { |
+ Str << typeElementType(Ty) << " " << *I; |
+ ++I; |
+ Str << (I != E ? ", " : ""); |
+ } |
+ Str << ">"; |
+} |
+ |
+template <> void ConstantBitVector::dump(GlobalContext *Ctx) const { |
+ Ostream &Str = Ctx->getStrDump(); |
+ unsigned NumElements = typeNumElements(getType()); |
+ Str << "<"; |
+ for (unsigned I = 0; I != NumElements;) { |
+ Str << "i1 " << (Value[I] ? "1" : "0"); |
+ ++I; |
+ Str << (I != NumElements ? ", " : ""); |
+ } |
+ Str << ">"; |
+} |
+ |
void LiveRange::dump(Ostream &Str) const { |
Str << "(weight=" << Weight << ") "; |
for (RangeType::const_iterator I = Range.begin(), E = Range.end(); I != E; |