diff options
Diffstat (limited to 'lib/MC/MCInstPrinter.cpp')
-rw-r--r-- | lib/MC/MCInstPrinter.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/MC/MCInstPrinter.cpp b/lib/MC/MCInstPrinter.cpp index 83d0dd3558..7efb3f0ef3 100644 --- a/lib/MC/MCInstPrinter.cpp +++ b/lib/MC/MCInstPrinter.cpp @@ -12,6 +12,7 @@ #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -50,3 +51,11 @@ StringRef MCInstPrinter::markup(StringRef a, StringRef b) const { else return b; } + +/// Utility function to print immediates in decimal or hex. +format_object1<int64_t> MCInstPrinter::formatImm(const int64_t Value) const { + if (getPrintImmHex()) + return format("0x%llx", Value); + else + return format("%lld", Value); +} |