summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCDisassembler/Disassembler.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2012-12-05 18:13:19 +0000
committerKevin Enderby <enderby@apple.com>2012-12-05 18:13:19 +0000
commit168ffb36a5e14049aea7c0e2ca7e8cfc4a3f7a7d (patch)
tree96e0d745d9d51111aad75ed4868c7db668c82571 /llvm/lib/MC/MCDisassembler/Disassembler.cpp
parent86975ce3fb8b0cb7f1370663ecf26f9ebed49119 (diff)
downloadbcm5719-llvm-168ffb36a5e14049aea7c0e2ca7e8cfc4a3f7a7d.tar.gz
bcm5719-llvm-168ffb36a5e14049aea7c0e2ca7e8cfc4a3f7a7d.zip
Added a option to the disassembler to print immediates as hex.
This is for the lldb team so most of but not all of the values are to be printed as hex with this option. Some small values like the scale in an X86 address were requested to printed in decimal without the leading 0x. There may be some tweaks need to places that may still be in decimal that they want in hex. Specially for arm. I made my best guess. Any tweaks from here should be simple. I also did the best I know now with help from the C++ gurus creating the cleanest formatImm() utility function and containing the changes. But if someone has a better idea to make something cleaner I'm all ears and game for changing the implementation. rdar://8109283 llvm-svn: 169393
Diffstat (limited to 'llvm/lib/MC/MCDisassembler/Disassembler.cpp')
-rw-r--r--llvm/lib/MC/MCDisassembler/Disassembler.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
index 363518966e0..d10f543ae02 100644
--- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
@@ -182,5 +182,11 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){
IP->setUseMarkup(1);
Options &= ~LLVMDisassembler_Option_UseMarkup;
}
+ if (Options & LLVMDisassembler_Option_PrintImmHex){
+ LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR;
+ MCInstPrinter *IP = DC->getIP();
+ IP->setPrintImmHex(1);
+ Options &= ~LLVMDisassembler_Option_PrintImmHex;
+ }
return (Options == 0);
}
OpenPOWER on IntegriCloud