Stephen Hines | 36b5688 | 2014-04-23 16:57:46 -0700 | [diff] [blame] | 1 | //===- MCFixup.cpp - Assembly Fixup Implementation ------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/MC/MCFixup.h" |
| 11 | using namespace llvm; |
| 12 | |
| 13 | static MCSymbolRefExpr::VariantKind getAccessVariant(const MCExpr *Expr) { |
| 14 | switch (Expr->getKind()) { |
| 15 | case MCExpr::Unary: |
| 16 | case MCExpr::Target: |
| 17 | llvm_unreachable("unsupported"); |
| 18 | |
| 19 | case MCExpr::Constant: |
| 20 | return MCSymbolRefExpr::VK_None; |
| 21 | |
| 22 | case MCExpr::SymbolRef: { |
| 23 | const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(Expr); |
| 24 | return SRE->getKind(); |
| 25 | } |
| 26 | case MCExpr::Binary: { |
| 27 | const MCBinaryExpr *ABE = cast<MCBinaryExpr>(Expr); |
| 28 | assert(getAccessVariant(ABE->getRHS()) == MCSymbolRefExpr::VK_None); |
| 29 | return getAccessVariant(ABE->getLHS()); |
| 30 | } |
| 31 | } |
| 32 | llvm_unreachable("unknown MCExpr kind"); |
| 33 | } |
| 34 | |
| 35 | MCSymbolRefExpr::VariantKind MCFixup::getAccessVariant() const { |
| 36 | return ::getAccessVariant(getValue()); |
| 37 | } |