diff options
author | Kevin Enderby <enderby@apple.com> | 2012-12-05 18:13:19 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2012-12-05 18:13:19 +0000 |
commit | 14ccc9007a932a23201251ced4be4c898a62d6a5 (patch) | |
tree | e77baa1da1529b24ea4f7cc4a0b451b9481b8724 /tools/llvm-mc | |
parent | d1abec365aa89a8497d9b615ccb4b21c72da9447 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169393 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-mc')
-rw-r--r-- | tools/llvm-mc/llvm-mc.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 935a770365..15cacfabeb 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -162,7 +162,8 @@ enum ActionType { AC_Assemble, AC_Disassemble, AC_EDisassemble, - AC_MDisassemble + AC_MDisassemble, + AC_HDisassemble }; static cl::opt<ActionType> @@ -178,6 +179,9 @@ Action(cl::desc("Action to perform:"), "Enhanced disassembly of strings of hex bytes"), clEnumValN(AC_MDisassemble, "mdis", "Marked up disassembly of strings of hex bytes"), + clEnumValN(AC_HDisassemble, "hdis", + "Disassemble strings of hex bytes printing " + "immediates as hex"), clEnumValEnd)); static const Target *GetTarget(const char *ProgName) { @@ -437,6 +441,7 @@ int main(int argc, char **argv) { } int Res = 1; + bool disassemble = false; switch (Action) { case AC_AsLex: Res = AsLexInput(SrcMgr, *MAI, Out.get()); @@ -446,15 +451,22 @@ int main(int argc, char **argv) { break; case AC_MDisassemble: IP->setUseMarkup(1); - // Fall through to do disassembly. + disassemble = true; + break; + case AC_HDisassemble: + IP->setPrintImmHex(1); + disassemble = true; + break; case AC_Disassemble: - Res = Disassembler::disassemble(*TheTarget, TripleName, *STI, *Str, - *Buffer, SrcMgr, Out->os()); + disassemble = true; break; case AC_EDisassemble: Res = Disassembler::disassembleEnhanced(TripleName, *Buffer, SrcMgr, Out->os()); break; } + if (disassemble) + Res = Disassembler::disassemble(*TheTarget, TripleName, *STI, *Str, + *Buffer, SrcMgr, Out->os()); // Keep output if no errors. if (Res == 0) Out->keep(); |