1 //===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "SparcTargetObjectFile.h" 10 #include "MCTargetDesc/SparcMCExpr.h" 11 #include "llvm/BinaryFormat/Dwarf.h" 12 #include "llvm/CodeGen/MachineModuleInfoImpls.h" 13 #include "llvm/CodeGen/TargetLowering.h" 14 15 using namespace llvm; 16 17 void SparcELFTargetObjectFile::Initialize(MCContext &Ctx, 18 const TargetMachine &TM) { 19 TargetLoweringObjectFileELF::Initialize(Ctx, TM); 20 } 21 22 const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference( 23 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM, 24 MachineModuleInfo *MMI, MCStreamer &Streamer) const { 25 26 if (Encoding & dwarf::DW_EH_PE_pcrel) { 27 MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>(); 28 29 MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM); 30 31 // Add information about the stub reference to ELFMMI so that the stub 32 // gets emitted by the asmprinter. 33 MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); 34 if (!StubSym.getPointer()) { 35 MCSymbol *Sym = TM.getSymbol(GV); 36 StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); 37 } 38 39 MCContext &Ctx = getContext(); 40 return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32, 41 MCSymbolRefExpr::create(SSym, Ctx), Ctx); 42 } 43 44 return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM, 45 MMI, Streamer); 46 } 47