mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
refactor section construction in TLOF to be through an explicit
initialize method, which can be called when an MCContext is available. llvm-svn: 77687
This commit is contained in:
parent
d0e6352c97
commit
c156a00641
@ -19,6 +19,7 @@
|
|||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class MCContext;
|
||||||
|
|
||||||
/// SectionKind - This is a simple POD value that classifies the properties of
|
/// SectionKind - This is a simple POD value that classifies the properties of
|
||||||
/// a section. A global variable is classified into the deepest possible
|
/// a section. A global variable is classified into the deepest possible
|
||||||
@ -256,6 +257,12 @@ public:
|
|||||||
|
|
||||||
virtual ~TargetLoweringObjectFile();
|
virtual ~TargetLoweringObjectFile();
|
||||||
|
|
||||||
|
/// 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.
|
||||||
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM) {}
|
||||||
|
|
||||||
|
|
||||||
const Section *getTextSection() const { return TextSection; }
|
const Section *getTextSection() const { return TextSection; }
|
||||||
const Section *getDataSection() const { return DataSection; }
|
const Section *getDataSection() const { return DataSection; }
|
||||||
|
|
||||||
@ -310,12 +317,17 @@ protected:
|
|||||||
|
|
||||||
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
|
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
|
||||||
bool AtIsCommentChar; // True if @ is the comment character on this target.
|
bool AtIsCommentChar; // True if @ is the comment character on this target.
|
||||||
|
bool HasCrazyBSS;
|
||||||
public:
|
public:
|
||||||
/// ELF Constructor - AtIsCommentChar is true if the CommentCharacter from TAI
|
/// ELF Constructor - AtIsCommentChar is true if the CommentCharacter from TAI
|
||||||
/// is "@".
|
/// is "@".
|
||||||
TargetLoweringObjectFileELF(bool AtIsCommentChar = false,
|
TargetLoweringObjectFileELF(bool atIsCommentChar = false,
|
||||||
// FIXME: REMOVE AFTER UNIQUING IS FIXED.
|
// FIXME: REMOVE AFTER UNIQUING IS FIXED.
|
||||||
bool HasCrazyBSS = false);
|
bool hasCrazyBSS = false)
|
||||||
|
: AtIsCommentChar(atIsCommentChar), HasCrazyBSS(hasCrazyBSS) {}
|
||||||
|
|
||||||
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
|
|
||||||
/// getSectionForMergeableConstant - Given a mergeable constant with the
|
/// getSectionForMergeableConstant - Given a mergeable constant with the
|
||||||
/// specified size and relocation information, return a section that it
|
/// specified size and relocation information, return a section that it
|
||||||
@ -342,6 +354,8 @@ protected:
|
|||||||
const Section *MergeableConst16Section;
|
const Section *MergeableConst16Section;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
|
class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
|
||||||
const Section *TextCoalSection;
|
const Section *TextCoalSection;
|
||||||
const Section *ConstTextCoalSection;
|
const Section *ConstTextCoalSection;
|
||||||
@ -352,7 +366,9 @@ class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
|
|||||||
const Section *EightByteConstantSection;
|
const Section *EightByteConstantSection;
|
||||||
const Section *SixteenByteConstantSection;
|
const Section *SixteenByteConstantSection;
|
||||||
public:
|
public:
|
||||||
TargetLoweringObjectFileMachO(const TargetMachine &TM);
|
|
||||||
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual const Section *
|
virtual const Section *
|
||||||
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||||
Mangler *Mang, const TargetMachine &TM) const;
|
Mangler *Mang, const TargetMachine &TM) const;
|
||||||
@ -365,7 +381,8 @@ public:
|
|||||||
|
|
||||||
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
|
||||||
public:
|
public:
|
||||||
TargetLoweringObjectFileCOFF();
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual void getSectionFlagsAsString(SectionKind Kind,
|
virtual void getSectionFlagsAsString(SectionKind Kind,
|
||||||
SmallVectorImpl<char> &Str) const;
|
SmallVectorImpl<char> &Str) const;
|
||||||
|
|
||||||
|
@ -173,6 +173,10 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AsmPrinter::doInitialization(Module &M) {
|
bool AsmPrinter::doInitialization(Module &M) {
|
||||||
|
// Initialize TargetLoweringObjectFile.
|
||||||
|
const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
|
||||||
|
.Initialize(OutContext, TM);
|
||||||
|
|
||||||
Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix(),
|
Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix(),
|
||||||
TAI->getLinkerPrivateGlobalPrefix());
|
TAI->getLinkerPrivateGlobalPrefix());
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
||||||
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
||||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Target/TargetELFWriterInfo.h"
|
#include "llvm/Target/TargetELFWriterInfo.h"
|
||||||
@ -73,6 +74,7 @@ ObjectCodeEmitter *llvm::AddELFWriter(PassManagerBase &PM,
|
|||||||
|
|
||||||
ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
|
ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
|
||||||
: MachineFunctionPass(&ID), O(o), TM(tm),
|
: MachineFunctionPass(&ID), O(o), TM(tm),
|
||||||
|
OutContext(*new MCContext()),
|
||||||
is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64),
|
is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64),
|
||||||
isLittleEndian(TM.getTargetData()->isLittleEndian()),
|
isLittleEndian(TM.getTargetData()->isLittleEndian()),
|
||||||
ElfHdr(isLittleEndian, is64Bit) {
|
ElfHdr(isLittleEndian, is64Bit) {
|
||||||
@ -89,11 +91,17 @@ ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
|
|||||||
|
|
||||||
ELFWriter::~ELFWriter() {
|
ELFWriter::~ELFWriter() {
|
||||||
delete ElfCE;
|
delete ElfCE;
|
||||||
|
delete &OutContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// doInitialization - Emit the file header and all of the global variables for
|
// doInitialization - Emit the file header and all of the global variables for
|
||||||
// the module to the ELF file.
|
// the module to the ELF file.
|
||||||
bool ELFWriter::doInitialization(Module &M) {
|
bool ELFWriter::doInitialization(Module &M) {
|
||||||
|
// Initialize TargetLoweringObjectFile.
|
||||||
|
const TargetLoweringObjectFile &TLOF =
|
||||||
|
TM.getTargetLowering()->getObjFileLowering();
|
||||||
|
const_cast<TargetLoweringObjectFile&>(TLOF).Initialize(OutContext, TM);
|
||||||
|
|
||||||
Mang = new Mangler(M);
|
Mang = new Mangler(M);
|
||||||
|
|
||||||
// ELF Header
|
// ELF Header
|
||||||
|
@ -35,6 +35,7 @@ namespace llvm {
|
|||||||
class TargetELFWriterInfo;
|
class TargetELFWriterInfo;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
class SectionKind;
|
class SectionKind;
|
||||||
|
class MCContext;
|
||||||
|
|
||||||
typedef std::vector<ELFSym*>::iterator ELFSymIter;
|
typedef std::vector<ELFSym*>::iterator ELFSymIter;
|
||||||
typedef std::vector<ELFSection*>::iterator ELFSectionIter;
|
typedef std::vector<ELFSection*>::iterator ELFSectionIter;
|
||||||
@ -65,6 +66,8 @@ namespace llvm {
|
|||||||
/// Target machine description.
|
/// Target machine description.
|
||||||
TargetMachine &TM;
|
TargetMachine &TM;
|
||||||
|
|
||||||
|
MCContext &OutContext;
|
||||||
|
|
||||||
/// Target Elf Writer description.
|
/// Target Elf Writer description.
|
||||||
const TargetELFWriterInfo *TEW;
|
const TargetELFWriterInfo *TEW;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void ARMTargetLowering::addQRTypeForNEON(MVT VT) {
|
|||||||
|
|
||||||
static TargetLoweringObjectFile *createTLOF(TargetMachine &TM) {
|
static TargetLoweringObjectFile *createTLOF(TargetMachine &TM) {
|
||||||
if (TM.getSubtarget<ARMSubtarget>().isTargetDarwin())
|
if (TM.getSubtarget<ARMSubtarget>().isTargetDarwin())
|
||||||
return new TargetLoweringObjectFileMachO(TM);
|
return new TargetLoweringObjectFileMachO();
|
||||||
return new TargetLoweringObjectFileELF(true);
|
return new TargetLoweringObjectFileELF(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ cl::desc("enable preincrement load/store generation on PPC (experimental)"),
|
|||||||
|
|
||||||
static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) {
|
static TargetLoweringObjectFile *CreateTLOF(const PPCTargetMachine &TM) {
|
||||||
if (TM.getSubtargetImpl()->isDarwin())
|
if (TM.getSubtargetImpl()->isDarwin())
|
||||||
return new TargetLoweringObjectFileMachO(TM);
|
return new TargetLoweringObjectFileMachO();
|
||||||
return new TargetLoweringObjectFileELF(false, true);
|
return new TargetLoweringObjectFileELF(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,10 +261,8 @@ getOrCreateSection(const char *Name, bool isDirective,
|
|||||||
// ELF
|
// ELF
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
TargetLoweringObjectFileELF::TargetLoweringObjectFileELF(bool atIsCommentChar,
|
void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
|
||||||
bool HasCrazyBSS)
|
const TargetMachine &TM) {
|
||||||
: AtIsCommentChar(atIsCommentChar) {
|
|
||||||
|
|
||||||
if (!HasCrazyBSS)
|
if (!HasCrazyBSS)
|
||||||
BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
|
BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
|
||||||
else
|
else
|
||||||
@ -480,8 +478,8 @@ getSectionForMergeableConstant(SectionKind Kind) const {
|
|||||||
// MachO
|
// MachO
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
TargetLoweringObjectFileMachO::
|
void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx,
|
||||||
TargetLoweringObjectFileMachO(const TargetMachine &TM) {
|
const TargetMachine &TM) {
|
||||||
TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
|
TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
|
||||||
DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
|
DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
|
||||||
|
|
||||||
@ -592,7 +590,8 @@ getSectionForMergeableConstant(SectionKind Kind) const {
|
|||||||
// COFF
|
// COFF
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
TargetLoweringObjectFileCOFF::TargetLoweringObjectFileCOFF() {
|
void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx,
|
||||||
|
const TargetMachine &TM) {
|
||||||
TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
|
TextSection = getOrCreateSection("\t.text", true, SectionKind::Text);
|
||||||
DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
|
DataSection = getOrCreateSection("\t.data", true, SectionKind::DataRel);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
|||||||
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
|
switch (TM.getSubtarget<X86Subtarget>().TargetType) {
|
||||||
default: llvm_unreachable("unknown subtarget type");
|
default: llvm_unreachable("unknown subtarget type");
|
||||||
case X86Subtarget::isDarwin:
|
case X86Subtarget::isDarwin:
|
||||||
return new TargetLoweringObjectFileMachO(TM);
|
return new TargetLoweringObjectFileMachO();
|
||||||
case X86Subtarget::isELF:
|
case X86Subtarget::isELF:
|
||||||
return new TargetLoweringObjectFileELF();
|
return new TargetLoweringObjectFileELF();
|
||||||
case X86Subtarget::isMingw:
|
case X86Subtarget::isMingw:
|
||||||
|
Loading…
Reference in New Issue
Block a user