1*9880d681SAndroid Build Coastguard Worker //===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Worker #include "SparcTargetObjectFile.h"
11*9880d681SAndroid Build Coastguard Worker #include "MCTargetDesc/SparcMCExpr.h"
12*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineModuleInfoImpls.h"
13*9880d681SAndroid Build Coastguard Worker #include "llvm/Support/Dwarf.h"
14*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h"
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker using namespace llvm;
17*9880d681SAndroid Build Coastguard Worker
getTTypeGlobalReference(const GlobalValue * GV,unsigned Encoding,Mangler & Mang,const TargetMachine & TM,MachineModuleInfo * MMI,MCStreamer & Streamer) const18*9880d681SAndroid Build Coastguard Worker const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
19*9880d681SAndroid Build Coastguard Worker const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
20*9880d681SAndroid Build Coastguard Worker const TargetMachine &TM, MachineModuleInfo *MMI,
21*9880d681SAndroid Build Coastguard Worker MCStreamer &Streamer) const {
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker if (Encoding & dwarf::DW_EH_PE_pcrel) {
24*9880d681SAndroid Build Coastguard Worker MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", Mang, TM);
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker // Add information about the stub reference to ELFMMI so that the stub
29*9880d681SAndroid Build Coastguard Worker // gets emitted by the asmprinter.
30*9880d681SAndroid Build Coastguard Worker MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
31*9880d681SAndroid Build Coastguard Worker if (!StubSym.getPointer()) {
32*9880d681SAndroid Build Coastguard Worker MCSymbol *Sym = TM.getSymbol(GV, Mang);
33*9880d681SAndroid Build Coastguard Worker StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
34*9880d681SAndroid Build Coastguard Worker }
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker MCContext &Ctx = getContext();
37*9880d681SAndroid Build Coastguard Worker return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
38*9880d681SAndroid Build Coastguard Worker MCSymbolRefExpr::create(SSym, Ctx), Ctx);
39*9880d681SAndroid Build Coastguard Worker }
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker return TargetLoweringObjectFileELF::getTTypeGlobalReference(
42*9880d681SAndroid Build Coastguard Worker GV, Encoding, Mang, TM, MMI, Streamer);
43*9880d681SAndroid Build Coastguard Worker }
44