From faf72ffda3bf83b08769428129ee4755787ee6cf Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Fri, 9 Mar 2012 17:52:49 +0000 Subject: [PATCH] Fix the x86 disassembler to at least print the lock prefix if it is the first prefix. Added a FIXME to remind us this still does not work when it is not the first prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152414 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/Disassembler/X86DisassemblerDecoder.c | 7 +++++++ test/MC/Disassembler/X86/simple-tests.txt | 5 +++++ utils/TableGen/X86RecognizableInstr.cpp | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c index b0e66f00c71..6f7e8f23466 100644 --- a/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c +++ b/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c @@ -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 . + // 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 */ diff --git a/test/MC/Disassembler/X86/simple-tests.txt b/test/MC/Disassembler/X86/simple-tests.txt index 840d5fab2dc..414c5d5fe9e 100644 --- a/test/MC/Disassembler/X86/simple-tests.txt +++ b/test/MC/Disassembler/X86/simple-tests.txt @@ -724,3 +724,8 @@ # CHECK: vpermil2ps $1, 4(%rax), %xmm2, %xmm3, %xmm0 0xc4 0xe3 0xe1 0x48 0x40 0x04 0x21 + +# rdar://8812056 lldb doesn't print the x86 lock prefix when disassembling +# CHECK: lock +# CHECK: xaddq %rcx, %rbx +0xf0 0x48 0x0f 0xc1 0xcb diff --git a/utils/TableGen/X86RecognizableInstr.cpp b/utils/TableGen/X86RecognizableInstr.cpp index 5bf473d95e0..6bbc929d26d 100644 --- a/utils/TableGen/X86RecognizableInstr.cpp +++ b/utils/TableGen/X86RecognizableInstr.cpp @@ -405,13 +405,13 @@ RecognizableInstr::filter_ret RecognizableInstr::filter() const { return FILTER_STRONG; - // Filter out artificial instructions + // Filter out artificial instructions but leave in the LOCK_PREFIX so it is + // printed as a separate "instruction". if (Name.find("_Int") != Name.npos || Name.find("Int_") != Name.npos || Name.find("_NOREX") != Name.npos || - Name.find("2SDL") != Name.npos || - Name == "LOCK_PREFIX") + Name.find("2SDL") != Name.npos) return FILTER_STRONG; // Filter out instructions with segment override prefixes.