Changes to display code view debug info type records in hex format
llvm-svn: 366390
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 7e8f02e..7a2b0b8 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -188,6 +188,7 @@
void EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;
void EmitIntValue(uint64_t Value, unsigned Size) override;
+ void EmitIntValueInHex(uint64_t Value, unsigned Size) override;
void EmitULEB128Value(const MCExpr *Value) override;
@@ -923,6 +924,10 @@
EmitValue(MCConstantExpr::create(Value, getContext()), Size);
}
+void MCAsmStreamer::EmitIntValueInHex(uint64_t Value, unsigned Size) {
+ EmitValue(MCConstantExpr::create(Value, getContext(), true), Size);
+}
+
void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc) {
assert(Size <= 8 && "Invalid size");
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index b338459..ab53ed4 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -8,6 +8,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/MC/MCAsmBackend.h"
@@ -42,10 +43,15 @@
switch (getKind()) {
case MCExpr::Target:
return cast<MCTargetExpr>(this)->printImpl(OS, MAI);
- case MCExpr::Constant:
- OS << cast<MCConstantExpr>(*this).getValue();
+ case MCExpr::Constant: {
+ auto Value = cast<MCConstantExpr>(*this).getValue();
+ auto PrintInHex = cast<MCConstantExpr>(*this).useHexFormat();
+ if (PrintInHex)
+ OS << "0x" << Twine::utohexstr(Value);
+ else
+ OS << Value;
return;
-
+ }
case MCExpr::SymbolRef: {
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*this);
const MCSymbol &Sym = SRE.getSymbol();
@@ -160,8 +166,9 @@
return new (Ctx) MCUnaryExpr(Opc, Expr, Loc);
}
-const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx) {
- return new (Ctx) MCConstantExpr(Value);
+const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx,
+ bool PrintInHex) {
+ return new (Ctx) MCConstantExpr(Value, PrintInHex);
}
/* *** */