LCOV - code coverage report
Current view: top level - lib/Target/AArch64 - AArch64TargetObjectFile.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 28 30 93.3 %
Date: 2018-10-20 13:21:21 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- AArch64TargetObjectFile.cpp - AArch64 Object Info -----------------===//
       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 "AArch64TargetObjectFile.h"
      11             : #include "AArch64TargetMachine.h"
      12             : #include "llvm/BinaryFormat/Dwarf.h"
      13             : #include "llvm/IR/Mangler.h"
      14             : #include "llvm/MC/MCContext.h"
      15             : #include "llvm/MC/MCExpr.h"
      16             : #include "llvm/MC/MCStreamer.h"
      17             : #include "llvm/MC/MCValue.h"
      18             : using namespace llvm;
      19             : using namespace dwarf;
      20             : 
      21         866 : void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
      22             :                                              const TargetMachine &TM) {
      23         866 :   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
      24         866 :   InitializeELF(TM.Options.UseInitArray);
      25             :   // AARCH64 ELF ABI does not define static relocation type for TLS offset
      26             :   // within a module.  Do not generate AT_location for TLS variables.
      27         866 :   SupportDebugThreadLocalLocation = false;
      28         866 : }
      29             : 
      30         431 : AArch64_MachoTargetObjectFile::AArch64_MachoTargetObjectFile()
      31         431 :   : TargetLoweringObjectFileMachO() {
      32         431 :   SupportGOTPCRelWithOffset = false;
      33         431 : }
      34             : 
      35           2 : const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference(
      36             :     const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
      37             :     MachineModuleInfo *MMI, MCStreamer &Streamer) const {
      38             :   // On Darwin, we can reference dwarf symbols with foo@GOT-., which
      39             :   // is an indirect pc-relative reference. The default implementation
      40             :   // won't reference using the GOT, so we need this target-specific
      41             :   // version.
      42           2 :   if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
      43           2 :     const MCSymbol *Sym = TM.getSymbol(GV);
      44             :     const MCExpr *Res =
      45           2 :         MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
      46           2 :     MCSymbol *PCSym = getContext().createTempSymbol();
      47           2 :     Streamer.EmitLabel(PCSym);
      48           2 :     const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
      49           2 :     return MCBinaryExpr::createSub(Res, PC, getContext());
      50             :   }
      51             : 
      52           0 :   return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
      53           0 :       GV, Encoding, TM, MMI, Streamer);
      54             : }
      55             : 
      56           2 : MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol(
      57             :     const GlobalValue *GV, const TargetMachine &TM,
      58             :     MachineModuleInfo *MMI) const {
      59           2 :   return TM.getSymbol(GV);
      60             : }
      61             : 
      62           3 : const MCExpr *AArch64_MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
      63             :     const MCSymbol *Sym, const MCValue &MV, int64_t Offset,
      64             :     MachineModuleInfo *MMI, MCStreamer &Streamer) const {
      65             :   assert((Offset+MV.getConstant() == 0) &&
      66             :          "Arch64 does not support GOT PC rel with extra offset");
      67             :   // On ARM64 Darwin, we can reference symbols with foo@GOT-., which
      68             :   // is an indirect pc-relative reference.
      69             :   const MCExpr *Res =
      70           3 :       MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
      71           3 :   MCSymbol *PCSym = getContext().createTempSymbol();
      72           3 :   Streamer.EmitLabel(PCSym);
      73           3 :   const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
      74           3 :   return MCBinaryExpr::createSub(Res, PC, getContext());
      75             : }
      76             : 
      77          97 : void AArch64_MachoTargetObjectFile::getNameWithPrefix(
      78             :     SmallVectorImpl<char> &OutName, const GlobalValue *GV,
      79             :     const TargetMachine &TM) const {
      80             :   // AArch64 does not use section-relative relocations so any global symbol must
      81             :   // be accessed via at least a linker-private symbol.
      82          97 :   getMangler().getNameWithPrefix(OutName, GV, /* CannotUsePrivateLabel */ true);
      83          97 : }

Generated by: LCOV version 1.13