Enable streaming of bitcode
[oota-llvm.git] / tools / llvm-mc / Disassembler.cpp
index 60384f6c63ac3e341cdc703e393492c2af8a0efc..32fc2ba57d3713c315fcac56b0feba19b8ce1554 100644 (file)
@@ -42,9 +42,9 @@ public:
   VectorMemoryObject(const ByteArrayTy &bytes) : Bytes(bytes) {}
 
   uint64_t getBase() const { return 0; }
-  uint64_t getExtent() const { return Bytes.size(); }
+  uint64_t getExtent() { return Bytes.size(); }
 
-  int readByte(uint64_t Addr, uint8_t *Byte) const {
+  int readByte(uint64_t Addr, uint8_t *Byte) {
     if (Addr >= getExtent())
       return -1;
     *Byte = Bytes[Addr].first;
@@ -68,22 +68,24 @@ static bool PrintInsts(const MCDisassembler &DisAsm,
 
     MCDisassembler::DecodeStatus S;
     S = DisAsm.getInstruction(Inst, Size, memoryObject, Index,
-                              /*REMOVE*/ nulls());
+                              /*REMOVE*/ nulls(), nulls());
     switch (S) {
     case MCDisassembler::Fail:
       SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
-                      "invalid instruction encoding", "warning");
+                      SourceMgr::DK_Warning,
+                      "invalid instruction encoding");
       if (Size == 0)
         Size = 1; // skip illegible bytes
       break;
 
     case MCDisassembler::SoftFail:
       SM.PrintMessage(SMLoc::getFromPointer(Bytes[Index].second),
-                      "potentially undefined instruction encoding", "warning");
+                      SourceMgr::DK_Warning,
+                      "potentially undefined instruction encoding");
       // Fall through
 
     case MCDisassembler::Success:
-      Printer.printInst(&Inst, Out);
+      Printer.printInst(&Inst, Out, "");
       Out << "\n";
       break;
     }
@@ -125,8 +127,8 @@ static bool ByteArrayFromString(ByteArrayTy &ByteArray,
     unsigned ByteVal;
     if (Value.getAsInteger(0, ByteVal) || ByteVal > 255) {
       // If we have an error, print it and skip to the end of line.
-      SM.PrintMessage(SMLoc::getFromPointer(Value.data()),
-                      "invalid input token", "error");
+      SM.PrintMessage(SMLoc::getFromPointer(Value.data()), SourceMgr::DK_Error,
+                      "invalid input token");
       Str = Str.substr(Str.find('\n'));
       ByteArray.clear();
       continue;
@@ -247,7 +249,6 @@ int Disassembler::disassembleEnhanced(const std::string &TS,
     break;
   }
 
-  EDDisassembler::initialize();
   OwningPtr<EDDisassembler>
     disassembler(EDDisassembler::getDisassembler(TS.c_str(), AS));
 
@@ -294,7 +295,6 @@ int Disassembler::disassembleEnhanced(const std::string &TS,
         Out << operandIndex << "-";
 
       switch (token->type()) {
-      default: Out << "?"; break;
       case EDToken::kTokenWhitespace: Out << "w"; break;
       case EDToken::kTokenPunctuation: Out << "p"; break;
       case EDToken::kTokenOpcode: Out << "o"; break;