[llvm] r210700 - llvm-mc: Add option for prefering hex format disassembly.

Jim Grosbach grosbach at apple.com
Wed Jun 11 13:26:41 PDT 2014


Author: grosbach
Date: Wed Jun 11 15:26:40 2014
New Revision: 210700

URL: http://llvm.org/viewvc/llvm-project?rev=210700&view=rev
Log:
llvm-mc: Add option for prefering hex format disassembly.

Previously there was a separate mode entirely (--hdis vs.
--disassemble). It makes a bit more sense for the immediate printing
style to be a flag for --disassmeble rather than an entirely different
thing.

Modified:
    llvm/trunk/test/MC/Disassembler/ARM/hex-immediates.txt
    llvm/trunk/test/MC/Disassembler/X86/hex-immediates.txt
    llvm/trunk/test/MC/Disassembler/X86/moffs.txt
    llvm/trunk/tools/llvm-mc/llvm-mc.cpp

Modified: llvm/trunk/test/MC/Disassembler/ARM/hex-immediates.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/hex-immediates.txt?rev=210700&r1=210699&r2=210700&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/ARM/hex-immediates.txt (original)
+++ llvm/trunk/test/MC/Disassembler/ARM/hex-immediates.txt Wed Jun 11 15:26:40 2014
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -hdis < %s | FileCheck %s
+# RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 --disassemble --print-imm-hex < %s | FileCheck %s
 # CHECK: ldr	r4, [pc, #0x20]
 0x08 0x4c
 # CHECK: sub	sp, #0x84

Modified: llvm/trunk/test/MC/Disassembler/X86/hex-immediates.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/hex-immediates.txt?rev=210700&r1=210699&r2=210700&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/X86/hex-immediates.txt (original)
+++ llvm/trunk/test/MC/Disassembler/X86/hex-immediates.txt Wed Jun 11 15:26:40 2014
@@ -1,4 +1,4 @@
-# RUN: llvm-mc --hdis %s -triple=x86_64-apple-darwin9 2>&1 | FileCheck %s
+# RUN: llvm-mc --print-imm-hex --disassemble %s -triple=x86_64-apple-darwin9 2>&1 | FileCheck %s
 
 # CHECK: movabsq	$0x7fffffffffffffff, %rcx
 0x48 0xb9 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x7f

Modified: llvm/trunk/test/MC/Disassembler/X86/moffs.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/moffs.txt?rev=210700&r1=210699&r2=210700&view=diff
==============================================================================
--- llvm/trunk/test/MC/Disassembler/X86/moffs.txt (original)
+++ llvm/trunk/test/MC/Disassembler/X86/moffs.txt Wed Jun 11 15:26:40 2014
@@ -1,6 +1,6 @@
-# RUN: llvm-mc --hdis %s -triple=i686-linux-gnu-code16 | FileCheck --check-prefix=16 %s
-# RUN: llvm-mc --hdis %s -triple=i686-linux-gnu | FileCheck --check-prefix=32 %s
-# RUN: llvm-mc --hdis %s -triple=x86_64-linux-gnu | FileCheck --check-prefix=64 %s
+# RUN: llvm-mc --disassemble --print-imm-hex %s -triple=i686-linux-gnu-code16 | FileCheck --check-prefix=16 %s
+# RUN: llvm-mc --disassemble --print-imm-hex %s -triple=i686-linux-gnu | FileCheck --check-prefix=32 %s
+# RUN: llvm-mc --disassemble --print-imm-hex %s -triple=x86_64-linux-gnu | FileCheck --check-prefix=64 %s
 
 # 16: movb 0x5a5a, %al
 # 32: movb 0x5a5a5a5a, %al

Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=210700&r1=210699&r2=210700&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Wed Jun 11 15:26:40 2014
@@ -65,6 +65,10 @@ static cl::opt<unsigned>
 OutputAsmVariant("output-asm-variant",
                  cl::desc("Syntax variant to use for output printing"));
 
+static cl::opt<bool>
+PrintImmHex("print-imm-hex", cl::init(false),
+            cl::desc("Prefer hex format for immediate values"));
+
 enum OutputFileType {
   OFT_Null,
   OFT_AssemblyFile,
@@ -167,7 +171,6 @@ enum ActionType {
   AC_Assemble,
   AC_Disassemble,
   AC_MDisassemble,
-  AC_HDisassemble
 };
 
 static cl::opt<ActionType>
@@ -181,9 +184,6 @@ Action(cl::desc("Action to perform:"),
                              "Disassemble 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) {
@@ -445,6 +445,11 @@ int main(int argc, char **argv) {
   if (FileType == OFT_AssemblyFile) {
     IP =
       TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI);
+
+    // Set the display preference for hex vs. decimal immediates.
+    IP->setPrintImmHex(PrintImmHex);
+
+    // Set up the AsmStreamer.
     MCCodeEmitter *CE = nullptr;
     MCAsmBackend *MAB = nullptr;
     if (ShowEncoding) {
@@ -480,11 +485,6 @@ int main(int argc, char **argv) {
     IP->setUseMarkup(1);
     disassemble = true;
     break;
-  case AC_HDisassemble:
-    assert(IP && "Expected assembly output");
-    IP->setPrintImmHex(1);
-    disassemble = true;
-    break;
   case AC_Disassemble:
     disassemble = true;
     break;





More information about the llvm-commits mailing list