[llvm-commits] [PATCH] Refactor llvm-mc to improve -disassemble

Richard Barton richard.barton at arm.com
Wed Apr 4 11:38:51 PDT 2012


Hello Reviewers

The attached patch is a refactoring of llvm-mc.

The initial motivation was to allow --show-inst and --show-encoding to work for
-disassemble in the same way as for -assemble. The solution was to use an
MCAsmStreamer to produce the output for -disassemble, rather than use the
InstPrinter directly. 

As part of this change I have moved all the duplicated creation of MC Objects
into the main function.

There was one problem with this refactoring. -assemble setup the InstPrinter so
that the assembly syntax variant was altered by the command line argument
--output-asm-syntax. -disassemble ignored this argument altogether and always
used MCAsmInfo::getAssemblerDialect to set this. 

I propose that -disassemble change to use the command line option like the
-assemble. This causes one X86 disassembly test to fail as it relied on the old
behaviour. The second patch changes the test to specify the correct assembly
syntax in the new way. 

The alternative would be to switch the default assembly syntax behaviour based
on whether disassemble or assemble is chosen. I don't think this is very nice,
but I'm happy to change the patch if people want.

I have split the patch down:

Patch 01: Refactoring - move all the MC Object creation into main
Patch 02: Test Change to make X86 disassemble test pass
Patch 03: Have -disassemble use an AsmStreamer instead of an InstPrinter

Please review.

Regards,

Richard Barton
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01_llvm_mc_refactor.patch
Type: application/octet-stream
Size: 12559 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120404/3aa83c30/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 02_llvm_mc_test_change.patch
Type: application/octet-stream
Size: 482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120404/3aa83c30/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 03_llvm_mc_show_inst_encoding.patch
Type: application/octet-stream
Size: 4000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120404/3aa83c30/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm_mc_all.patch
Type: application/octet-stream
Size: 12604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120404/3aa83c30/attachment-0003.obj>


More information about the llvm-commits mailing list