[LLVMdev] X86 Disassembler

Sean Callanan scallanan at apple.com
Mon Aug 17 19:38:10 PDT 2009


Dear mailing list:

the attached diff implements a table-driven disassembler for the X86  
architecture (16-, 32-, and 64-bit incarnations), integrated into the  
MC framework.  The disassembler is table-driven, using a custom  
TableGen backend to generate hierarchical tables optimized for fast  
decode.  The disassembler consumes MemoryObjects and produces arrays  
of MCInsts, adhering to the abstract base class MCDisassembler (llvm/ 
MC/MCDisassembler.h).

The disassembler is documented in detail in
–
- lib/Target/X86/X86Disassembler.h (disassembler runtime)
- utils/TableGen/X86DisassemblerEmitter.h (table emitter)
–
as well as in the individual files, functions, and classes.

I implemented a use case in tools/llvm-mc/HexDisassembler.cpp, which  
implements an interactive disassembler for sequences of bytes entered  
in hex on standard input.  Example output:
–
localhost:llvm spyffe$ ./Debug/bin/llvm-mc -disassemble
74 22 <-- user input
…
1 instructions:
74 22 	je	34
–
The disassembler is currently fully implemented, and testing is  
ongoing.  I still need to handle LEA correctly, and of course the  
instruction tables (lib/Target/X86/X86InstrInfo.td and friends) always  
need expanding.  However, because this is a non-invasive patch  
implementing largely independent functionality but its size makes  
maintaining it outside LLVM is a heavy burden, I am submitting it for  
consideration now.

The patch is tested against SVN revision 79306.  Please let me know if  
there are any problems, and tell me what I can fix to make this worthy  
of inclusion.  Thanks for your time.

Sincerely,
Sean Callanan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090817/60622028/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm.diff
Type: application/octet-stream
Size: 222213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090817/60622028/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090817/60622028/attachment-0001.html>


More information about the llvm-dev mailing list