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
|
|
|
|
|
2009-11-06 11:58:06 +01:00
|
|
|
#include "llvm/ADT/StringRef.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;
|
2009-09-17 20:49:52 +02:00
|
|
|
class MCAsmInfo;
|
|
|
|
class MCExpr;
|
2009-07-31 20:48:30 +02:00
|
|
|
class MCSection;
|
2009-08-13 01:55:02 +02:00
|
|
|
class MCSectionMachO;
|
2010-02-15 23:35:59 +01:00
|
|
|
class MCSymbol;
|
2009-07-31 19:42:42 +02:00
|
|
|
class MCContext;
|
2009-07-31 20:48:30 +02:00
|
|
|
class GlobalValue;
|
|
|
|
class TargetMachine;
|
|
|
|
|
2009-07-28 05:13:23 +02:00
|
|
|
class TargetLoweringObjectFile {
|
2009-07-31 20:48:30 +02:00
|
|
|
MCContext *Ctx;
|
2009-08-13 01:55:02 +02:00
|
|
|
|
|
|
|
TargetLoweringObjectFile(const TargetLoweringObjectFile&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const TargetLoweringObjectFile&); // DO NOT IMPLEMENT
|
2009-07-28 05:13:23 +02:00
|
|
|
protected:
|
|
|
|
|
|
|
|
TargetLoweringObjectFile();
|
|
|
|
|
|
|
|
/// TextSection - Section directive for standard text.
|
|
|
|
///
|
2009-08-01 23:56:13 +02:00
|
|
|
const MCSection *TextSection;
|
2009-07-28 05:13:23 +02:00
|
|
|
|
|
|
|
/// DataSection - Section directive for standard data.
|
|
|
|
///
|
2009-08-01 23:56:13 +02:00
|
|
|
const MCSection *DataSection;
|
2009-07-28 05:13:23 +02:00
|
|
|
|
2009-08-01 23:56:13 +02:00
|
|
|
/// BSSSection - Section that is default initialized to zero.
|
|
|
|
const MCSection *BSSSection;
|
2009-07-28 05:13:23 +02:00
|
|
|
|
2009-08-01 23:56:13 +02:00
|
|
|
/// ReadOnlySection - Section that is readonly and can contain arbitrary
|
2009-08-02 01:46:12 +02:00
|
|
|
/// initialized data. Targets are not required to have a readonly section.
|
|
|
|
/// If they don't, various bits of code will fall back to using the data
|
|
|
|
/// section for constants.
|
2009-08-01 23:56:13 +02:00
|
|
|
const MCSection *ReadOnlySection;
|
2009-07-28 05:13:23 +02:00
|
|
|
|
2009-08-02 02:34:36 +02:00
|
|
|
/// StaticCtorSection - This section contains the static constructor pointer
|
|
|
|
/// list.
|
|
|
|
const MCSection *StaticCtorSection;
|
|
|
|
|
|
|
|
/// StaticDtorSection - This section contains the static destructor pointer
|
|
|
|
/// list.
|
|
|
|
const MCSection *StaticDtorSection;
|
|
|
|
|
2009-08-02 03:34:32 +02:00
|
|
|
/// LSDASection - If exception handling is supported by the target, this is
|
|
|
|
/// the section the Language Specific Data Area information is emitted to.
|
|
|
|
const MCSection *LSDASection;
|
|
|
|
|
2009-08-02 08:52:36 +02:00
|
|
|
/// EHFrameSection - If exception handling is supported by the target, this is
|
|
|
|
/// the section the EH Frame is emitted to.
|
|
|
|
const MCSection *EHFrameSection;
|
|
|
|
|
2009-08-02 09:24:22 +02:00
|
|
|
// Dwarf sections for debug info. If a target supports debug info, these must
|
|
|
|
// be set.
|
|
|
|
const MCSection *DwarfAbbrevSection;
|
|
|
|
const MCSection *DwarfInfoSection;
|
|
|
|
const MCSection *DwarfLineSection;
|
|
|
|
const MCSection *DwarfFrameSection;
|
|
|
|
const MCSection *DwarfPubNamesSection;
|
|
|
|
const MCSection *DwarfPubTypesSection;
|
|
|
|
const MCSection *DwarfDebugInlineSection;
|
|
|
|
const MCSection *DwarfStrSection;
|
|
|
|
const MCSection *DwarfLocSection;
|
|
|
|
const MCSection *DwarfARangesSection;
|
|
|
|
const MCSection *DwarfRangesSection;
|
|
|
|
const MCSection *DwarfMacroInfoSection;
|
2009-08-02 08:52:36 +02:00
|
|
|
|
2010-03-10 08:20:42 +01:00
|
|
|
/// SupportsWeakEmptyEHFrame - True if target object file supports a
|
|
|
|
/// weak_definition of constant 0 for an omitted EH frame.
|
|
|
|
bool SupportsWeakOmittedEHFrame;
|
|
|
|
|
|
|
|
/// IsFunctionEHSymbolGlobal - This flag is set to true if the ".eh" symbol
|
|
|
|
/// for a function should be marked .globl.
|
|
|
|
bool IsFunctionEHSymbolGlobal;
|
|
|
|
|
|
|
|
/// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
|
|
|
|
/// "EH_frame" symbol for EH information should be an assembler temporary (aka
|
|
|
|
/// private linkage, aka an L or .L label) or false if it should be a normal
|
|
|
|
/// non-.globl label. This defaults to true.
|
|
|
|
bool IsFunctionEHFrameSymbolPrivate;
|
2009-07-28 05:13:23 +02:00
|
|
|
public:
|
|
|
|
|
2009-08-08 22:14:13 +02:00
|
|
|
MCContext &getContext() const { return *Ctx; }
|
|
|
|
|
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.
|
2009-07-31 20:48:30 +02:00
|
|
|
virtual void Initialize(MCContext &ctx, const TargetMachine &TM) {
|
|
|
|
Ctx = &ctx;
|
|
|
|
}
|
2009-07-31 19:42:42 +02:00
|
|
|
|
2010-03-10 08:20:42 +01:00
|
|
|
bool isFunctionEHSymbolGlobal() const {
|
|
|
|
return IsFunctionEHSymbolGlobal;
|
|
|
|
}
|
|
|
|
bool isFunctionEHFrameSymbolPrivate() const {
|
|
|
|
return IsFunctionEHFrameSymbolPrivate;
|
|
|
|
}
|
|
|
|
bool getSupportsWeakOmittedEHFrame() const {
|
|
|
|
return SupportsWeakOmittedEHFrame;
|
|
|
|
}
|
2009-07-31 19:42:42 +02:00
|
|
|
|
2009-07-31 20:48:30 +02:00
|
|
|
const MCSection *getTextSection() const { return TextSection; }
|
|
|
|
const MCSection *getDataSection() const { return DataSection; }
|
2009-08-13 23:10:28 +02:00
|
|
|
const MCSection *getBSSSection() const { return BSSSection; }
|
2009-08-02 02:34:36 +02:00
|
|
|
const MCSection *getStaticCtorSection() const { return StaticCtorSection; }
|
|
|
|
const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
|
2009-08-02 03:34:32 +02:00
|
|
|
const MCSection *getLSDASection() const { return LSDASection; }
|
2009-08-02 08:52:36 +02:00
|
|
|
const MCSection *getEHFrameSection() const { return EHFrameSection; }
|
2009-08-02 09:24:22 +02:00
|
|
|
const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
|
|
|
|
const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
|
|
|
|
const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
|
|
|
|
const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
|
|
|
|
const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
|
|
|
|
const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
|
|
|
|
const MCSection *getDwarfDebugInlineSection() const {
|
|
|
|
return DwarfDebugInlineSection;
|
|
|
|
}
|
|
|
|
const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
|
|
|
|
const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
|
|
|
|
const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
|
|
|
|
const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
|
|
|
|
const MCSection *getDwarfMacroInfoSection() const {
|
|
|
|
return DwarfMacroInfoSection;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-15 23:35:59 +01:00
|
|
|
/// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a reference
|
|
|
|
/// to the specified global variable from exception handling information.
|
2009-09-16 03:46:41 +02:00
|
|
|
///
|
|
|
|
virtual const MCExpr *
|
|
|
|
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
|
2010-02-15 23:35:59 +01:00
|
|
|
MachineModuleInfo *MMI, unsigned Encoding) const;
|
|
|
|
|
|
|
|
virtual const MCExpr *
|
|
|
|
getSymbolForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI,
|
|
|
|
unsigned Encoding) const;
|
|
|
|
|
|
|
|
virtual unsigned getPersonalityEncoding() const;
|
|
|
|
virtual unsigned getLSDAEncoding() const;
|
|
|
|
virtual unsigned getFDEEncoding() const;
|
|
|
|
virtual unsigned getTTypeEncoding() const;
|
|
|
|
|
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
|