Fix the x86 disassembler to at least print the lock prefix if it is the first
[oota-llvm.git] / lib / Target / X86 / Disassembler / X86DisassemblerDecoder.c
index b0e66f00c71f194dba8abf0bd65d804c5f532269..6f7e8f234660022cb921fc658fa2a8499e068f0f 100644 (file)
@@ -312,6 +312,13 @@ static int readPrefixes(struct InternalInstruction* insn) {
     
     if (consumeByte(insn, &byte))
       return -1;
+
+    // If the the first byte is a LOCK prefix break and let it be disassembled
+    // as a lock "instruction", by creating an <MCInst #xxxx LOCK_PREFIX>.
+    // FIXME there is currently no way to get the disassembler to print the
+    // lock prefix if it is not the first byte.
+    if (insn->readerCursor - 1 == insn->startLocation && byte == 0xf0)
+      break;
     
     switch (byte) {
     case 0xf0:  /* LOCK */