2009-07-28 03:13:23 +00:00
|
|
|
//===-- llvm/Target/TargetLoweringObjectFile.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_TARGET_TARGETLOWERINGOBJECTFILE_H
|
|
|
|
#define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
|
|
|
|
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Module.h"
|
2011-07-20 05:58:47 +00:00
|
|
|
#include "llvm/MC/MCObjectFileInfo.h"
|
2009-08-01 21:30:49 +00:00
|
|
|
#include "llvm/MC/SectionKind.h"
|
2009-07-28 03:13:23 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2009-09-17 18:49:52 +00:00
|
|
|
class MachineModuleInfo;
|
2009-08-12 23:34:27 +00:00
|
|
|
class Mangler;
|
2010-03-11 19:41:58 +00:00
|
|
|
class MCContext;
|
2009-09-17 18:49:52 +00:00
|
|
|
class MCExpr;
|
2009-07-31 18:48:30 +00:00
|
|
|
class MCSection;
|
2010-02-15 22:35:59 +00:00
|
|
|
class MCSymbol;
|
2012-11-14 01:47:00 +00:00
|
|
|
class MCSymbolRefExpr;
|
2010-03-11 19:41:58 +00:00
|
|
|
class MCStreamer;
|
2014-01-15 09:16:42 +00:00
|
|
|
class ConstantExpr;
|
2009-07-31 18:48:30 +00:00
|
|
|
class GlobalValue;
|
|
|
|
class TargetMachine;
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2011-07-20 05:58:47 +00:00
|
|
|
class TargetLoweringObjectFile : public MCObjectFileInfo {
|
2009-07-31 18:48:30 +00:00
|
|
|
MCContext *Ctx;
|
2014-01-03 19:21:54 +00:00
|
|
|
const DataLayout *DL;
|
2012-09-17 06:59:23 +00:00
|
|
|
|
|
|
|
TargetLoweringObjectFile(
|
2015-02-15 22:54:22 +00:00
|
|
|
const TargetLoweringObjectFile&) = delete;
|
|
|
|
void operator=(const TargetLoweringObjectFile&) = delete;
|
2012-09-17 06:59:23 +00:00
|
|
|
|
2009-07-28 03:13:23 +00:00
|
|
|
public:
|
2009-08-08 20:14:13 +00:00
|
|
|
MCContext &getContext() const { return *Ctx; }
|
2011-07-20 05:58:47 +00:00
|
|
|
|
2014-04-14 00:51:57 +00:00
|
|
|
TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(nullptr), DL(nullptr) {}
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2009-07-28 03:13:23 +00:00
|
|
|
virtual ~TargetLoweringObjectFile();
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// This method must be called before any actual lowering is done. This
|
|
|
|
/// specifies the current context for codegen, and gives the lowering
|
|
|
|
/// implementations a chance to set up their default sections.
|
2011-07-20 05:58:47 +00:00
|
|
|
virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2011-04-16 03:51:21 +00:00
|
|
|
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
|
|
|
const TargetMachine &TM,
|
|
|
|
const MCSymbol *Sym) const;
|
2012-02-14 21:28:13 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Extract the dependent library name from a linker option string. Returns
|
|
|
|
/// StringRef() if the option does not specify a library.
|
2014-01-21 18:31:27 +00:00
|
|
|
virtual StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const {
|
|
|
|
return StringRef();
|
|
|
|
}
|
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Emit the module flags that the platform cares about.
|
2014-02-08 14:53:28 +00:00
|
|
|
virtual void emitModuleFlags(MCStreamer &Streamer,
|
|
|
|
ArrayRef<Module::ModuleFlagEntry> Flags,
|
|
|
|
Mangler &Mang, const TargetMachine &TM) const {}
|
2012-02-14 21:28:13 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Given a constant with the SectionKind, return a section that it should be
|
|
|
|
/// placed in.
|
2014-07-14 22:57:27 +00:00
|
|
|
virtual const MCSection *getSectionForConstant(SectionKind Kind,
|
|
|
|
const Constant *C) const;
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Classify the specified global variable into a set of target independent
|
|
|
|
/// categories embodied in SectionKind.
|
2009-08-05 04:25:40 +00:00
|
|
|
static SectionKind getKindForGlobal(const GlobalValue *GV,
|
|
|
|
const TargetMachine &TM);
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// This method computes the appropriate section to emit the specified global
|
|
|
|
/// variable or function definition. This should not be passed external (or
|
|
|
|
/// available externally) globals.
|
2009-07-31 18:48:30 +00:00
|
|
|
const MCSection *SectionForGlobal(const GlobalValue *GV,
|
2014-02-08 14:53:28 +00:00
|
|
|
SectionKind Kind, Mangler &Mang,
|
2014-01-28 00:49:26 +00:00
|
|
|
const TargetMachine &TM) const;
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// This method computes the appropriate section to emit the specified global
|
|
|
|
/// variable or function definition. This should not be passed external (or
|
|
|
|
/// available externally) globals.
|
2009-08-05 04:25:40 +00:00
|
|
|
const MCSection *SectionForGlobal(const GlobalValue *GV,
|
2014-02-08 14:53:28 +00:00
|
|
|
Mangler &Mang,
|
2014-01-28 00:49:26 +00:00
|
|
|
const TargetMachine &TM) const {
|
2009-08-05 04:25:40 +00:00
|
|
|
return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
|
|
|
|
}
|
2012-02-14 21:28:13 +00:00
|
|
|
|
2015-02-12 17:16:46 +00:00
|
|
|
virtual const MCSection *
|
|
|
|
getSectionForJumpTable(const Function &F, Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const;
|
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Targets should implement this method to assign a section to globals with
|
|
|
|
/// an explicit section specfied. The implementation of this method can
|
|
|
|
/// assume that GV->hasSection() is true.
|
2009-08-06 16:39:58 +00:00
|
|
|
virtual const MCSection *
|
2014-02-07 22:33:56 +00:00
|
|
|
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
2014-02-08 14:53:28 +00:00
|
|
|
Mangler &Mang, const TargetMachine &TM) const = 0;
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Allow the target to completely override section assignment of a global.
|
2014-02-09 14:50:44 +00:00
|
|
|
virtual const MCSection *getSpecialCasedSectionGlobals(const GlobalValue *GV,
|
|
|
|
SectionKind Kind,
|
|
|
|
Mangler &Mang) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2009-07-28 03:13:23 +00:00
|
|
|
}
|
2014-02-07 22:33:56 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
/// Return an MCExpr to use for a reference to the specified global variable
|
|
|
|
/// from exception handling information.
|
2014-02-19 17:23:20 +00:00
|
|
|
virtual const MCExpr *
|
|
|
|
getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
|
|
|
|
Mangler &Mang, const TargetMachine &TM,
|
|
|
|
MachineModuleInfo *MMI, MCStreamer &Streamer) const;
|
2013-10-29 17:28:26 +00:00
|
|
|
|
2013-12-02 16:25:47 +00:00
|
|
|
/// Return the MCSymbol for a private symbol with global value name as its
|
|
|
|
/// base, with the specified suffix.
|
2014-02-09 14:50:44 +00:00
|
|
|
MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
|
2014-02-19 17:23:20 +00:00
|
|
|
StringRef Suffix, Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const;
|
2013-12-02 16:25:47 +00:00
|
|
|
|
2014-02-07 22:39:17 +00:00
|
|
|
// The symbol that gets passed to .cfi_personality.
|
2014-02-19 17:23:20 +00:00
|
|
|
virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
|
|
|
|
Mangler &Mang,
|
|
|
|
const TargetMachine &TM,
|
|
|
|
MachineModuleInfo *MMI) const;
|
2011-04-27 23:08:15 +00:00
|
|
|
|
2010-03-11 19:41:58 +00:00
|
|
|
const MCExpr *
|
2012-11-14 01:47:00 +00:00
|
|
|
getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
|
|
|
|
MCStreamer &Streamer) const;
|
2012-01-25 22:24:19 +00:00
|
|
|
|
2014-05-16 20:39:27 +00:00
|
|
|
virtual const MCSection *getStaticCtorSection(unsigned Priority,
|
2014-06-06 19:26:12 +00:00
|
|
|
const MCSymbol *KeySym) const {
|
2012-01-25 22:24:19 +00:00
|
|
|
return StaticCtorSection;
|
|
|
|
}
|
2014-05-16 20:39:27 +00:00
|
|
|
|
|
|
|
virtual const MCSection *getStaticDtorSection(unsigned Priority,
|
2014-06-06 19:26:12 +00:00
|
|
|
const MCSymbol *KeySym) const {
|
2012-01-25 22:24:19 +00:00
|
|
|
return StaticDtorSection;
|
|
|
|
}
|
|
|
|
|
2013-06-28 20:05:11 +00:00
|
|
|
/// \brief Create a symbol reference to describe the given TLS variable when
|
|
|
|
/// emitting the address in debug info.
|
2013-07-02 18:47:09 +00:00
|
|
|
virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
|
2013-06-28 20:05:11 +00:00
|
|
|
|
2014-01-15 09:16:42 +00:00
|
|
|
virtual const MCExpr *
|
2014-02-19 17:23:20 +00:00
|
|
|
getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang,
|
|
|
|
const TargetMachine &TM) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2014-01-15 09:16:42 +00:00
|
|
|
}
|
|
|
|
|
2009-07-28 03:13:23 +00:00
|
|
|
protected:
|
2009-07-31 18:48:30 +00:00
|
|
|
virtual const MCSection *
|
2009-08-01 21:46:23 +00:00
|
|
|
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
2014-11-12 01:27:22 +00:00
|
|
|
Mangler &Mang, const TargetMachine &TM) const = 0;
|
2009-07-28 03:13:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|