LLVM API Documentation

AArch64TargetObjectFile.cpp
Go to the documentation of this file.
00001 //===-- AArch64TargetObjectFile.cpp - AArch64 Object Info -----------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "AArch64TargetObjectFile.h"
00011 #include "AArch64TargetMachine.h"
00012 #include "llvm/IR/Mangler.h"
00013 #include "llvm/MC/MCContext.h"
00014 #include "llvm/MC/MCExpr.h"
00015 #include "llvm/MC/MCStreamer.h"
00016 #include "llvm/Support/Dwarf.h"
00017 using namespace llvm;
00018 using namespace dwarf;
00019 
00020 void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
00021                                              const TargetMachine &TM) {
00022   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
00023   InitializeELF(TM.Options.UseInitArray);
00024 }
00025 
00026 const MCExpr *AArch64_MachoTargetObjectFile::getTTypeGlobalReference(
00027     const GlobalValue *GV, unsigned Encoding, Mangler &Mang,
00028     const TargetMachine &TM, MachineModuleInfo *MMI,
00029     MCStreamer &Streamer) const {
00030   // On Darwin, we can reference dwarf symbols with foo@GOT-., which
00031   // is an indirect pc-relative reference. The default implementation
00032   // won't reference using the GOT, so we need this target-specific
00033   // version.
00034   if (Encoding & (DW_EH_PE_indirect | DW_EH_PE_pcrel)) {
00035     const MCSymbol *Sym = TM.getSymbol(GV, Mang);
00036     const MCExpr *Res =
00037         MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOT, getContext());
00038     MCSymbol *PCSym = getContext().CreateTempSymbol();
00039     Streamer.EmitLabel(PCSym);
00040     const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext());
00041     return MCBinaryExpr::CreateSub(Res, PC, getContext());
00042   }
00043 
00044   return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
00045       GV, Encoding, Mang, TM, MMI, Streamer);
00046 }
00047 
00048 MCSymbol *AArch64_MachoTargetObjectFile::getCFIPersonalitySymbol(
00049     const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM,
00050     MachineModuleInfo *MMI) const {
00051   return TM.getSymbol(GV, Mang);
00052 }