2009-07-28 05:13:23 +02: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 18:02:12 +01:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2013-01-02 12:36:10 +01:00
|
|
|
#include "llvm/IR/Module.h"
|
2011-07-20 07:58:47 +02:00
|
|
|
#include "llvm/MC/MCObjectFileInfo.h"
|
2009-08-01 23:30:49 +02:00
|
|
|
#include "llvm/MC/SectionKind.h"
|
2009-07-28 05:13:23 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
2009-09-17 20:49:52 +02:00
|
|
|
class MachineModuleInfo;
|
2009-08-13 01:34:27 +02:00
|
|
|
class Mangler;
|
2010-03-11 20:41:58 +01:00
|
|
|
class MCContext;
|
2009-09-17 20:49:52 +02:00
|
|
|
class MCExpr;
|
2009-07-31 20:48:30 +02:00
|
|
|
class MCSection;
|
2010-02-15 23:35:59 +01:00
|
|
|
class MCSymbol;
|
2012-11-14 02:47:00 +01:00
|
|
|
class MCSymbolRefExpr;
|
2010-03-11 20:41:58 +01:00
|
|
|
class MCStreamer;
|
2014-01-15 10:16:42 +01:00
|
|
|
class ConstantExpr;
|
2009-07-31 20:48:30 +02:00
|
|
|
class GlobalValue;
|
|
|
|
class TargetMachine;
|
|
|
|
|
2011-07-20 07:58:47 +02:00
|
|
|
class TargetLoweringObjectFile : public MCObjectFileInfo {
|
2009-07-31 20:48:30 +02:00
|
|
|
MCContext *Ctx;
|
2014-01-03 20:21:54 +01:00
|
|
|
const DataLayout *DL;
|
2012-09-17 08:59:23 +02:00
|
|
|
|
|
|
|
TargetLoweringObjectFile(
|
|
|
|
const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
|
|
|
|
void operator=(const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
|
|
|
|
|
2009-07-28 05:13:23 +02:00
|
|
|
public:
|
2009-08-08 22:14:13 +02:00
|
|
|
MCContext &getContext() const { return *Ctx; }
|
2011-07-20 07:58:47 +02:00
|
|
|
|
2014-01-03 20:21:54 +01:00
|
|
|
TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0), DL(0) {}
|
2009-08-08 22:14:13 +02:00
|
|
|
|
2009-07-28 05:13:23 +02:00
|
|
|
virtual ~TargetLoweringObjectFile();
|
|
|
|
|
2009-07-31 19:42:42 +02:00
|
|
|
/// Initialize - 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 07:58:47 +02:00
|
|
|
virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
|
2009-07-31 19:42:42 +02:00
|
|
|
|
2011-04-16 05:51:21 +02:00
|
|
|
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
|
|
|
const TargetMachine &TM,
|
|
|
|
const MCSymbol *Sym) const;
|
2012-02-14 22:28:13 +01:00
|
|
|
|
|
|
|
/// emitModuleFlags - Emit the module flags that the platform cares about.
|
2012-02-15 23:36:15 +01:00
|
|
|
virtual void emitModuleFlags(MCStreamer &,
|
|
|
|
ArrayRef<Module::ModuleFlagEntry>,
|
|
|
|
Mangler *, const TargetMachine &) const {
|
2012-02-14 22:28:13 +01:00
|
|
|
}
|
|
|
|
|
2009-07-31 22:52:39 +02:00
|
|
|
/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
|
|
|
|
/// decide not to emit the UsedDirective for some symbols in llvm.used.
|
|
|
|
/// FIXME: REMOVE this (rdar://7071300)
|
|
|
|
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
|
|
|
|
Mangler *) const {
|
2009-08-01 23:56:13 +02:00
|
|
|
return GV != 0;
|
2009-07-31 22:52:39 +02:00
|
|
|
}
|
2009-07-28 05:13:23 +02:00
|
|
|
|
2009-08-02 01:46:12 +02:00
|
|
|
/// getSectionForConstant - Given a constant with the SectionKind, return a
|
|
|
|
/// section that it should be placed in.
|
|
|
|
virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
|
2009-07-28 05:13:23 +02:00
|
|
|
|
2009-08-05 06:25:40 +02:00
|
|
|
/// getKindForGlobal - Classify the specified global variable into a set of
|
|
|
|
/// target independent categories embodied in SectionKind.
|
|
|
|
static SectionKind getKindForGlobal(const GlobalValue *GV,
|
|
|
|
const TargetMachine &TM);
|
|
|
|
|
2009-07-28 05:13:23 +02:00
|
|
|
/// SectionForGlobal - 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 20:48:30 +02:00
|
|
|
const MCSection *SectionForGlobal(const GlobalValue *GV,
|
2009-08-05 06:25:40 +02:00
|
|
|
SectionKind Kind, Mangler *Mang,
|
2009-07-31 20:48:30 +02:00
|
|
|
const TargetMachine &TM) const;
|
2009-07-28 05:13:23 +02:00
|
|
|
|
2009-08-05 06:25:40 +02:00
|
|
|
/// SectionForGlobal - 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.
|
|
|
|
const MCSection *SectionForGlobal(const GlobalValue *GV,
|
|
|
|
Mangler *Mang,
|
|
|
|
const TargetMachine &TM) const {
|
|
|
|
return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
|
|
|
|
}
|
2012-02-14 22:28:13 +01:00
|
|
|
|
2009-08-06 18:39:58 +02:00
|
|
|
/// getExplicitSectionGlobal - 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.
|
|
|
|
virtual const MCSection *
|
|
|
|
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
|
|
|
|
Mangler *Mang, const TargetMachine &TM) const = 0;
|
|
|
|
|
2009-07-28 05:13:23 +02:00
|
|
|
/// getSpecialCasedSectionGlobals - Allow the target to completely override
|
|
|
|
/// section assignment of a global.
|
2009-07-31 20:48:30 +02:00
|
|
|
virtual const MCSection *
|
2009-07-29 07:09:30 +02:00
|
|
|
getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
|
2009-08-01 23:46:23 +02:00
|
|
|
SectionKind Kind) const {
|
2009-07-28 05:13:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-14 02:47:00 +01:00
|
|
|
/// getTTypeGlobalReference - Return an MCExpr to use for a reference
|
2010-02-15 23:35:59 +01:00
|
|
|
/// to the specified global variable from exception handling information.
|
2009-09-16 03:46:41 +02:00
|
|
|
///
|
|
|
|
virtual const MCExpr *
|
2012-11-14 02:47:00 +01:00
|
|
|
getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
|
|
|
MachineModuleInfo *MMI, unsigned Encoding,
|
|
|
|
MCStreamer &Streamer) const;
|
2010-02-15 23:35:59 +01:00
|
|
|
|
2013-10-29 18:28:26 +01:00
|
|
|
/// Return the MCSymbol for the specified global value. This symbol is the
|
|
|
|
/// main label that is the address of the global
|
|
|
|
MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const;
|
|
|
|
|
2013-12-02 17:25:47 +01:00
|
|
|
/// Return the MCSymbol for a private symbol with global value name as its
|
|
|
|
/// base, with the specified suffix.
|
|
|
|
MCSymbol *getSymbolWithGlobalValueBase(Mangler &M, const GlobalValue *GV,
|
|
|
|
StringRef Suffix) const;
|
|
|
|
|
2011-04-28 01:08:15 +02:00
|
|
|
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
|
|
|
|
virtual MCSymbol *
|
2011-04-28 01:17:57 +02:00
|
|
|
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
|
|
|
MachineModuleInfo *MMI) const;
|
2011-04-28 01:08:15 +02:00
|
|
|
|
2010-03-11 20:41:58 +01:00
|
|
|
///
|
|
|
|
const MCExpr *
|
2012-11-14 02:47:00 +01:00
|
|
|
getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
|
|
|
|
MCStreamer &Streamer) const;
|
2012-01-25 23:24:19 +01:00
|
|
|
|
|
|
|
virtual const MCSection *
|
|
|
|
getStaticCtorSection(unsigned Priority = 65535) const {
|
|
|
|
(void)Priority;
|
|
|
|
return StaticCtorSection;
|
|
|
|
}
|
|
|
|
virtual const MCSection *
|
|
|
|
getStaticDtorSection(unsigned Priority = 65535) const {
|
|
|
|
(void)Priority;
|
|
|
|
return StaticDtorSection;
|
|
|
|
}
|
|
|
|
|
2013-06-28 22:05:11 +02:00
|
|
|
/// \brief Create a symbol reference to describe the given TLS variable when
|
|
|
|
/// emitting the address in debug info.
|
2013-07-02 20:47:09 +02:00
|
|
|
virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
|
2013-06-28 22:05:11 +02:00
|
|
|
|
2014-01-15 10:16:42 +01:00
|
|
|
virtual const MCExpr *
|
|
|
|
getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler *Mang) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-28 05:13:23 +02:00
|
|
|
protected:
|
2009-07-31 20:48:30 +02:00
|
|
|
virtual const MCSection *
|
2009-08-01 23:46:23 +02:00
|
|
|
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
2009-07-29 07:09:30 +02:00
|
|
|
Mangler *Mang, const TargetMachine &TM) const;
|
2009-07-28 05:13:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|