2010-02-15 22:37:53 +00:00
|
|
|
//==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements classes used to handle lowerings specific to common
|
|
|
|
// object file formats.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
|
|
|
|
#define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
|
|
|
|
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2010-02-15 22:37:53 +00:00
|
|
|
#include "llvm/MC/SectionKind.h"
|
|
|
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class MachineModuleInfo;
|
|
|
|
class Mangler;
|
|
|
|
class MCAsmInfo;
|
|
|
|
class MCExpr;
|
|
|
|
class MCSection;
|
|
|
|
class MCSectionMachO;
|
|
|
|
class MCSymbol;
|
|
|
|
class MCContext;
|
|
|
|
class GlobalValue;
|
|
|
|
class TargetMachine;
|
|
|
|
|
|
|
|
|
|
|
|
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
|
2012-06-19 00:48:28 +00:00
|
|
|
bool UseInitArray;
|
2015-04-04 18:02:01 +00:00
|
|
|
mutable unsigned NextUniqueID = 0;
|
2012-06-19 00:48:28 +00:00
|
|
|
|
2010-02-15 22:37:53 +00:00
|
|
|
public:
|
2015-02-10 15:30:02 +00:00
|
|
|
TargetLoweringObjectFileELF() : UseInitArray(false) {}
|
|
|
|
|
2015-04-11 02:11:45 +00:00
|
|
|
~TargetLoweringObjectFileELF() override {}
|
2011-04-16 03:51:21 +00:00
|
|
|
|
2014-02-08 06:07:27 +00:00
|
|
|
void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
|
2014-03-02 09:09:27 +00:00
|
|
|
const MCSymbol *Sym) const override;
|
2011-01-23 05:43:40 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// Given a constant with the SectionKind, return a section that it should be
|
|
|
|
/// placed in.
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getSectionForConstant(SectionKind Kind,
|
|
|
|
const Constant *C) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getSectionForJumpTable(const Function &F, Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2015-02-12 17:16:46 +00:00
|
|
|
|
2015-02-17 23:34:51 +00:00
|
|
|
bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
|
|
|
|
const Function &F) const override;
|
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// Return an MCExpr to use for a reference to the specified type info global
|
|
|
|
/// variable from exception handling information.
|
2014-02-19 17:23:20 +00:00
|
|
|
const MCExpr *
|
|
|
|
getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
|
|
|
|
Mangler &Mang, const TargetMachine &TM,
|
2014-03-02 09:09:27 +00:00
|
|
|
MachineModuleInfo *MMI,
|
|
|
|
MCStreamer &Streamer) const override;
|
2011-04-27 23:08:15 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
// The symbol that gets passed to .cfi_personality.
|
2014-02-08 14:53:28 +00:00
|
|
|
MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
|
2014-02-19 17:23:20 +00:00
|
|
|
const TargetMachine &TM,
|
2014-03-02 09:09:27 +00:00
|
|
|
MachineModuleInfo *MMI) const override;
|
2012-01-25 22:24:19 +00:00
|
|
|
|
2012-06-19 00:48:28 +00:00
|
|
|
void InitializeELF(bool UseInitArray_);
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getStaticCtorSection(unsigned Priority,
|
|
|
|
const MCSymbol *KeySym) const override;
|
|
|
|
MCSection *getStaticDtorSection(unsigned Priority,
|
|
|
|
const MCSymbol *KeySym) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
|
|
|
|
public:
|
2015-04-11 02:11:45 +00:00
|
|
|
~TargetLoweringObjectFileMachO() override {}
|
2015-03-06 13:49:05 +00:00
|
|
|
TargetLoweringObjectFileMachO();
|
2011-01-23 05:43:40 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// Extract the dependent library name from a linker option string. Returns
|
|
|
|
/// StringRef() if the option does not specify a library.
|
2014-03-02 09:09:27 +00:00
|
|
|
StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
|
2014-01-21 18:31:27 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// Emit the module flags that specify the garbage collection information.
|
2014-02-08 06:07:27 +00:00
|
|
|
void emitModuleFlags(MCStreamer &Streamer,
|
|
|
|
ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
|
2014-03-02 09:09:27 +00:00
|
|
|
Mangler &Mang, const TargetMachine &TM) const override;
|
2012-02-14 21:28:13 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getSectionForConstant(SectionKind Kind,
|
|
|
|
const Constant *C) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// The mach-o version of this method defaults to returning a stub reference.
|
2014-02-19 17:23:20 +00:00
|
|
|
const MCExpr *
|
|
|
|
getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
|
|
|
|
Mangler &Mang, const TargetMachine &TM,
|
2014-03-02 09:09:27 +00:00
|
|
|
MachineModuleInfo *MMI,
|
|
|
|
MCStreamer &Streamer) const override;
|
2010-02-21 20:28:15 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
// The symbol that gets passed to .cfi_personality.
|
2014-02-08 14:53:28 +00:00
|
|
|
MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
|
2014-02-19 17:23:20 +00:00
|
|
|
const TargetMachine &TM,
|
2014-03-02 09:09:27 +00:00
|
|
|
MachineModuleInfo *MMI) const override;
|
2015-03-06 13:49:05 +00:00
|
|
|
|
|
|
|
/// Get MachO PC relative GOT entry relocation
|
|
|
|
const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
|
|
|
|
const MCValue &MV, int64_t Offset,
|
|
|
|
MachineModuleInfo *MMI,
|
|
|
|
MCStreamer &Streamer) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
|
|
|
public:
|
2015-04-11 02:11:45 +00:00
|
|
|
~TargetLoweringObjectFileCOFF() override {}
|
2010-05-07 17:17:41 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2015-03-17 23:54:51 +00:00
|
|
|
|
|
|
|
void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
|
|
|
|
bool CannotUsePrivateLabel, Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2013-04-25 19:34:41 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getSectionForJumpTable(const Function &F, Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const override;
|
2015-03-11 19:58:37 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// Extract the dependent library name from a linker option string. Returns
|
|
|
|
/// StringRef() if the option does not specify a library.
|
2014-03-02 09:09:27 +00:00
|
|
|
StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
|
2014-01-21 18:31:27 +00:00
|
|
|
|
2014-02-07 22:45:13 +00:00
|
|
|
/// Emit Obj-C garbage collection and linker options. Only linker option
|
|
|
|
/// emission is implemented for COFF.
|
2014-02-08 06:07:27 +00:00
|
|
|
void emitModuleFlags(MCStreamer &Streamer,
|
|
|
|
ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
|
2014-03-02 09:09:27 +00:00
|
|
|
Mangler &Mang, const TargetMachine &TM) const override;
|
2014-05-16 20:39:27 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSection *getStaticCtorSection(unsigned Priority,
|
|
|
|
const MCSymbol *KeySym) const override;
|
|
|
|
MCSection *getStaticDtorSection(unsigned Priority,
|
|
|
|
const MCSymbol *KeySym) const override;
|
2010-02-15 22:37:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|