Venkatraman Govindaraju | fd5c1f9 | 2014-01-29 04:51:35 +0000 | [diff] [blame^] | 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 | |
| 15 | using namespace llvm; |
| 16 | |
| 17 | |
| 18 | const MCExpr *SparcELFTargetObjectFile:: |
| 19 | getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang, |
| 20 | MachineModuleInfo *MMI, unsigned Encoding, |
| 21 | MCStreamer &Streamer) const { |
| 22 | |
| 23 | if (Encoding & dwarf::DW_EH_PE_pcrel) { |
| 24 | MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>(); |
| 25 | |
| 26 | MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, ".DW.stub"); |
| 27 | |
| 28 | // Add information about the stub reference to ELFMMI so that the stub |
| 29 | // gets emitted by the asmprinter. |
| 30 | MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); |
| 31 | if (StubSym.getPointer() == 0) { |
| 32 | MCSymbol *Sym = getSymbol(*Mang, GV); |
| 33 | StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); |
| 34 | } |
| 35 | |
| 36 | MCContext &Ctx = getContext(); |
| 37 | return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32, |
| 38 | MCSymbolRefExpr::Create(SSym, Ctx), Ctx); |
| 39 | } |
| 40 | |
| 41 | return TargetLoweringObjectFileELF:: |
| 42 | getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer); |
| 43 | } |