]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp
MFV 316905
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Sparc / SparcTargetObjectFile.cpp
1 //===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===//
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 "SparcTargetObjectFile.h"
11 #include "MCTargetDesc/SparcMCExpr.h"
12 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
13 #include "llvm/Support/Dwarf.h"
14 #include "llvm/Target/TargetLowering.h"
15
16 using namespace llvm;
17
18 const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
19     const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
20     MachineModuleInfo *MMI, MCStreamer &Streamer) const {
21
22   if (Encoding & dwarf::DW_EH_PE_pcrel) {
23     MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
24
25     MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
26
27     // Add information about the stub reference to ELFMMI so that the stub
28     // gets emitted by the asmprinter.
29     MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
30     if (!StubSym.getPointer()) {
31       MCSymbol *Sym = TM.getSymbol(GV);
32       StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
33     }
34
35     MCContext &Ctx = getContext();
36     return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
37                                MCSymbolRefExpr::create(SSym, Ctx), Ctx);
38   }
39
40   return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM,
41                                                               MMI, Streamer);
42 }