LLVM API Documentation

SparcTargetObjectFile.cpp
Go to the documentation of this file.
00001 //===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "SparcTargetObjectFile.h"
00011 #include "MCTargetDesc/SparcMCExpr.h"
00012 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
00013 #include "llvm/Support/Dwarf.h"
00014 #include "llvm/Target/TargetLowering.h"
00015 
00016 using namespace llvm;
00017 
00018 const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
00019     const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
00020     const TargetMachine &TM, MachineModuleInfo *MMI,
00021     MCStreamer &Streamer) const {
00022 
00023   if (Encoding & dwarf::DW_EH_PE_pcrel) {
00024     MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
00025 
00026     MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang, TM);
00027 
00028     // Add information about the stub reference to ELFMMI so that the stub
00029     // gets emitted by the asmprinter.
00030     MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
00031     if (!StubSym.getPointer()) {
00032       MCSymbol *Sym = TM.getSymbol(GV, Mang);
00033       StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
00034     }
00035 
00036     MCContext &Ctx = getContext();
00037     return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32,
00038                                MCSymbolRefExpr::Create(SSym, Ctx), Ctx);
00039   }
00040 
00041   return TargetLoweringObjectFileELF::getTTypeGlobalReference(
00042       GV, Encoding, Mang, TM, MMI, Streamer);
00043 }