X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCValue.cpp;h=495a2b6ea5bbff4393a432c21239806a7196a0fe;hb=4d0731f50589c740744edcbc8af5250988c3e0ef;hp=4393777211e80555e4bee1aec2fa16e6c7f1add1;hpb=286c4dc355b8be6806081b23c3097485821c7642;p=oota-llvm.git diff --git a/lib/MC/MCValue.cpp b/lib/MC/MCValue.cpp index 4393777211e..495a2b6ea5b 100644 --- a/lib/MC/MCValue.cpp +++ b/lib/MC/MCValue.cpp @@ -10,21 +10,27 @@ #include "llvm/MC/MCValue.h" #include "llvm/MC/MCExpr.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const { +void MCValue::print(raw_ostream &OS) const { if (isAbsolute()) { OS << getConstant(); return; } - getSymA()->print(OS); + // FIXME: prints as a number, which isn't ideal. But the meaning will be + // target-specific anyway. + if (getRefKind()) + OS << ':' << getRefKind() << ':'; + + OS << *getSymA(); if (getSymB()) { OS << " - "; - getSymB()->print(OS); + OS << *getSymB(); } if (getConstant()) @@ -33,6 +39,23 @@ void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const { #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) void MCValue::dump() const { - print(dbgs(), 0); + print(dbgs()); } #endif + +MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const { + const MCSymbolRefExpr *B = getSymB(); + if (B) { + if (B->getKind() != MCSymbolRefExpr::VK_None) + llvm_unreachable("unsupported"); + } + + const MCSymbolRefExpr *A = getSymA(); + if (!A) + return MCSymbolRefExpr::VK_None; + + MCSymbolRefExpr::VariantKind Kind = A->getKind(); + if (Kind == MCSymbolRefExpr::VK_WEAKREF) + return MCSymbolRefExpr::VK_None; + return Kind; +}