2014-01-29 12:51:35 +08:00
|
|
|
//===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-01-29 12:51:35 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "SparcTargetObjectFile.h"
|
|
|
|
#include "MCTargetDesc/SparcMCExpr.h"
|
2017-06-07 11:48:56 +08:00
|
|
|
#include "llvm/BinaryFormat/Dwarf.h"
|
2014-01-29 12:51:35 +08:00
|
|
|
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2014-01-29 12:51:35 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2017-06-22 04:36:32 +08:00
|
|
|
void SparcELFTargetObjectFile::Initialize(MCContext &Ctx,
|
|
|
|
const TargetMachine &TM) {
|
|
|
|
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
|
|
|
|
}
|
|
|
|
|
2014-02-09 22:50:44 +08:00
|
|
|
const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
|
2016-09-16 15:33:15 +08:00
|
|
|
const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
|
|
|
|
MachineModuleInfo *MMI, MCStreamer &Streamer) const {
|
2014-01-29 12:51:35 +08:00
|
|
|
|
|
|
|
if (Encoding & dwarf::DW_EH_PE_pcrel) {
|
|
|
|
MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();
|
|
|
|
|
2016-09-16 15:33:15 +08:00
|
|
|
MCSymbol *SSym = getSymbolWithGlobalValueBase(GV, ".DW.stub", TM);
|
2014-01-29 12:51:35 +08:00
|
|
|
|
|
|
|
// Add information about the stub reference to ELFMMI so that the stub
|
|
|
|
// gets emitted by the asmprinter.
|
|
|
|
MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym);
|
2014-04-25 13:30:21 +08:00
|
|
|
if (!StubSym.getPointer()) {
|
2016-11-23 00:17:20 +08:00
|
|
|
MCSymbol *Sym = TM.getSymbol(GV);
|
2014-01-29 12:51:35 +08:00
|
|
|
StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage());
|
|
|
|
}
|
|
|
|
|
|
|
|
MCContext &Ctx = getContext();
|
2015-05-30 09:25:56 +08:00
|
|
|
return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
|
|
|
|
MCSymbolRefExpr::create(SSym, Ctx), Ctx);
|
2014-01-29 12:51:35 +08:00
|
|
|
}
|
|
|
|
|
2016-09-16 15:33:15 +08:00
|
|
|
return TargetLoweringObjectFileELF::getTTypeGlobalReference(GV, Encoding, TM,
|
|
|
|
MMI, Streamer);
|
2014-01-29 12:51:35 +08:00
|
|
|
}
|