aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/MC/MCInstPrinter.h
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
commit14ccc9007a932a23201251ced4be4c898a62d6a5 (patch)
treee77baa1da1529b24ea4f7cc4a0b451b9481b8724 /include/llvm/MC/MCInstPrinter.h
parentd1abec365aa89a8497d9b615ccb4b21c72da9447 (diff)
downloadexternal_llvm-14ccc9007a932a23201251ced4be4c898a62d6a5.zip
external_llvm-14ccc9007a932a23201251ced4be4c898a62d6a5.tar.gz
external_llvm-14ccc9007a932a23201251ced4be4c898a62d6a5.tar.bz2
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 'include/llvm/MC/MCInstPrinter.h')
-rw-r--r--include/llvm/MC/MCInstPrinter.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/include/llvm/MC/MCInstPrinter.h b/include/llvm/MC/MCInstPrinter.h
index 3b9420a..d20d8d2 100644
--- a/include/llvm/MC/MCInstPrinter.h
+++ b/include/llvm/MC/MCInstPrinter.h
@@ -10,6 +10,8 @@
#ifndef LLVM_MC_MCINSTPRINTER_H
#define LLVM_MC_MCINSTPRINTER_H
+#include "llvm/Support/Format.h"
+
namespace llvm {
class MCInst;
class raw_ostream;
@@ -36,13 +38,16 @@ protected:
/// True if we are printing marked up assembly.
bool UseMarkup;
+ /// True if we are printing immediates as hex.
+ bool PrintImmHex;
+
/// Utility function for printing annotations.
void printAnnotation(raw_ostream &OS, StringRef Annot);
public:
MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
const MCRegisterInfo &mri)
: CommentStream(0), MAI(mai), MII(mii), MRI(mri), AvailableFeatures(0),
- UseMarkup(0) {}
+ UseMarkup(0), PrintImmHex(0) {}
virtual ~MCInstPrinter();
@@ -70,6 +75,12 @@ public:
/// Utility functions to make adding mark ups simpler.
StringRef markup(StringRef s) const;
StringRef markup(StringRef a, StringRef b) const;
+
+ bool getPrintImmHex() const { return PrintImmHex; }
+ void setPrintImmHex(bool Value) { PrintImmHex = Value; }
+
+ /// Utility function to print immediates in decimal or hex.
+ format_object1<int64_t> formatImm(const int64_t Value) const;
};
} // namespace llvm