1 //===-- MipsMCSymbolRefExpr.cpp - Mips specific MC expression classes -----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #define DEBUG_TYPE "mipsmcsymbolrefexpr"
11 #include "MipsMCSymbolRefExpr.h"
12 #include "llvm/MC/MCAssembler.h"
13 #include "llvm/MC/MCContext.h"
14 #include "llvm/MC/MCSymbol.h"
17 const MipsMCSymbolRefExpr*
18 MipsMCSymbolRefExpr::Create(VariantKind Kind, const MCSymbol *Symbol,
19 int Offset, MCContext &Ctx) {
20 return new (Ctx) MipsMCSymbolRefExpr(Kind, Symbol, Offset);
23 void MipsMCSymbolRefExpr::PrintImpl(raw_ostream &OS) const {
25 default: assert(0 && "Invalid kind!");
26 case VK_Mips_None: break;
27 case VK_Mips_GPREL: OS << "%gp_rel("; break;
28 case VK_Mips_GOT_CALL: OS << "%call16("; break;
29 case VK_Mips_GOT: OS << "%got("; break;
30 case VK_Mips_ABS_HI: OS << "%hi("; break;
31 case VK_Mips_ABS_LO: OS << "%lo("; break;
32 case VK_Mips_TLSGD: OS << "%tlsgd("; break;
33 case VK_Mips_GOTTPREL: OS << "%gottprel("; break;
34 case VK_Mips_TPREL_HI: OS << "%tprel_hi("; break;
35 case VK_Mips_TPREL_LO: OS << "%tprel_lo("; break;
36 case VK_Mips_GPOFF_HI: OS << "%hi(%neg(%gp_rel("; break;
37 case VK_Mips_GPOFF_LO: OS << "%lo(%neg(%gp_rel("; break;
38 case VK_Mips_GOT_DISP: OS << "%got_disp("; break;
39 case VK_Mips_GOT_PAGE: OS << "%got_page("; break;
40 case VK_Mips_GOT_OFST: OS << "%got_ofst("; break;
51 if (Kind != VK_Mips_None)
56 MipsMCSymbolRefExpr::EvaluateAsRelocatableImpl(MCValue &Res,
57 const MCAsmLayout *Layout) const {
61 void MipsMCSymbolRefExpr::AddValueSymbols(MCAssembler *Asm) const {
62 Asm->getOrCreateSymbolData(*Symbol);
65 const MCSection *MipsMCSymbolRefExpr::FindAssociatedSection() const {
66 return Symbol->isDefined() ? &Symbol->getSection() : NULL;