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-02-15 22:36:15 +00:00
|
|
|
#include "llvm/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"
|
2012-02-15 22:36:15 +00:00
|
|
|
#include "llvm/ADT/ArrayRef.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;
|
2009-07-31 18:48:30 +00:00
|
|
|
class GlobalValue;
|
|
|
|
class TargetMachine;
|
|
|
|
|
2011-07-20 05:58:47 +00:00
|
|
|
class TargetLoweringObjectFile : public MCObjectFileInfo {
|
2009-07-31 18:48:30 +00:00
|
|
|
MCContext *Ctx;
|
2012-09-17 06:59:23 +00:00
|
|
|
|
|
|
|
TargetLoweringObjectFile(
|
|
|
|
const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
|
|
|
|
void operator=(const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
|
|
|
|
|
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
|
|
|
|
|
|
|
TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0) {}
|
2009-08-08 20:14:13 +00:00
|
|
|
|
2009-07-28 03:13:23 +00:00
|
|
|
virtual ~TargetLoweringObjectFile();
|
|
|
|
|
2009-07-31 17:42:42 +00: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 05:58:47 +00:00
|
|
|
virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
|
2009-07-31 17:42:42 +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
|
|
|
|
|
|
|
/// emitModuleFlags - Emit the module flags that the platform cares about.
|
2012-02-15 22:36:15 +00:00
|
|
|
virtual void emitModuleFlags(MCStreamer &,
|
|
|
|
ArrayRef<Module::ModuleFlagEntry>,
|
|
|
|
Mangler *, const TargetMachine &) const {
|
2012-02-14 21:28:13 +00:00
|
|
|
}
|
|
|
|
|
2009-07-31 20:52:39 +00: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 21:56:13 +00:00
|
|
|
return GV != 0;
|
2009-07-31 20:52:39 +00:00
|
|
|
}
|
2009-07-28 03:13:23 +00:00
|
|
|
|
2009-08-01 23:46:12 +00: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 03:13:23 +00:00
|
|
|
|
2009-08-05 04:25:40 +00: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 03:13:23 +00: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 18:48:30 +00:00
|
|
|
const MCSection *SectionForGlobal(const GlobalValue *GV,
|
2009-08-05 04:25:40 +00:00
|
|
|
SectionKind Kind, Mangler *Mang,
|
2009-07-31 18:48:30 +00:00
|
|
|
const TargetMachine &TM) const;
|
2009-07-28 03:13:23 +00:00
|
|
|
|
2009-08-05 04:25:40 +00: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 21:28:13 +00:00
|
|
|
|
2009-08-06 16:39:58 +00: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 03:13:23 +00:00
|
|
|
/// getSpecialCasedSectionGlobals - Allow the target to completely override
|
|
|
|
/// section assignment of a global.
|
2009-07-31 18:48:30 +00:00
|
|
|
virtual const MCSection *
|
2009-07-29 05:09:30 +00:00
|
|
|
getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
|
2009-08-01 21:46:23 +00:00
|
|
|
SectionKind Kind) const {
|
2009-07-28 03:13:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-14 01:47:00 +00:00
|
|
|
/// getTTypeGlobalReference - Return an MCExpr to use for a reference
|
2010-02-15 22:35:59 +00:00
|
|
|
/// to the specified global variable from exception handling information.
|
2009-09-16 01:46:41 +00:00
|
|
|
///
|
|
|
|
virtual const MCExpr *
|
2012-11-14 01:47:00 +00:00
|
|
|
getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
|
|
|
MachineModuleInfo *MMI, unsigned Encoding,
|
|
|
|
MCStreamer &Streamer) const;
|
2010-02-15 22:35:59 +00:00
|
|
|
|
2011-04-27 23:08:15 +00:00
|
|
|
// getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
|
|
|
|
virtual MCSymbol *
|
2011-04-27 23:17:57 +00:00
|
|
|
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
|
|
|
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
|
|
|
|
|
|
|
virtual const MCSection *
|
|
|
|
getStaticCtorSection(unsigned Priority = 65535) const {
|
|
|
|
(void)Priority;
|
|
|
|
return StaticCtorSection;
|
|
|
|
}
|
|
|
|
virtual const MCSection *
|
|
|
|
getStaticDtorSection(unsigned Priority = 65535) const {
|
|
|
|
(void)Priority;
|
|
|
|
return StaticDtorSection;
|
|
|
|
}
|
|
|
|
|
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,
|
2009-07-29 05:09:30 +00:00
|
|
|
Mangler *Mang, const TargetMachine &TM) const;
|
2009-07-28 03:13:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|