X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCValue.cpp;h=495a2b6ea5bbff4393a432c21239806a7196a0fe;hb=4d0731f50589c740744edcbc8af5250988c3e0ef;hp=a37149d78893f6f15b81c80dda2bf4cc734c7f06;hpb=cc77eece74c8db09acc2af425e7e6c88a5bb30d1;p=oota-llvm.git diff --git a/lib/MC/MCValue.cpp b/lib/MC/MCValue.cpp index a37149d7889..495a2b6ea5b 100644 --- a/lib/MC/MCValue.cpp +++ b/lib/MC/MCValue.cpp @@ -10,29 +10,52 @@ #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()) OS << " + " << getConstant(); } -#ifndef NDEBUG +#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; +}