mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-14 09:38:40 +00:00
Initial modifications to MCAssembler and TargetMachine for the MCJIT.
Patch by Olivier Meurant! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a4081238aa
commit
c96a82a534
@ -669,7 +669,9 @@ public:
|
|||||||
MCCodeEmitter &getEmitter() const { return Emitter; }
|
MCCodeEmitter &getEmitter() const { return Emitter; }
|
||||||
|
|
||||||
/// Finish - Do final processing and write the object to the output stream.
|
/// Finish - Do final processing and write the object to the output stream.
|
||||||
void Finish();
|
/// \arg Writer is used for custom object writer (as the MCJIT does),
|
||||||
|
/// if not specified it is automatically created from backend.
|
||||||
|
void Finish(MCObjectWriter *Writer = 0);
|
||||||
|
|
||||||
// FIXME: This does not belong here.
|
// FIXME: This does not belong here.
|
||||||
bool getSubsectionsViaSymbols() const {
|
bool getSubsectionsViaSymbols() const {
|
||||||
|
@ -244,6 +244,18 @@ public:
|
|||||||
bool = true) {
|
bool = true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
||||||
|
/// machine code emitted with the MCJIT. This method returns true if machine
|
||||||
|
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
||||||
|
/// used to build custom MCStreamer.
|
||||||
|
///
|
||||||
|
virtual bool addPassesToEmitMC(PassManagerBase &PM,
|
||||||
|
MCContext *&Ctx,
|
||||||
|
CodeGenOpt::Level OptLevel,
|
||||||
|
bool DisableVerify = true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// LLVMTargetMachine - This class describes a target machine that is
|
/// LLVMTargetMachine - This class describes a target machine that is
|
||||||
@ -287,6 +299,16 @@ public:
|
|||||||
JITCodeEmitter &MCE,
|
JITCodeEmitter &MCE,
|
||||||
CodeGenOpt::Level,
|
CodeGenOpt::Level,
|
||||||
bool DisableVerify = true);
|
bool DisableVerify = true);
|
||||||
|
|
||||||
|
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
||||||
|
/// machine code emitted with the MCJIT. This method returns true if machine
|
||||||
|
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
||||||
|
/// used to build custom MCStreamer.
|
||||||
|
///
|
||||||
|
virtual bool addPassesToEmitMC(PassManagerBase &PM,
|
||||||
|
MCContext *&Ctx,
|
||||||
|
CodeGenOpt::Level OptLevel,
|
||||||
|
bool DisableVerify = true);
|
||||||
|
|
||||||
/// Target-Independent Code Generator Pass Configuration Options.
|
/// Target-Independent Code Generator Pass Configuration Options.
|
||||||
|
|
||||||
|
@ -216,6 +216,24 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,
|
|||||||
return false; // success!
|
return false; // success!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
||||||
|
/// machine code emitted with the MCJIT. This method returns true if machine
|
||||||
|
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
||||||
|
/// used to build custom MCStreamer.
|
||||||
|
///
|
||||||
|
bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM,
|
||||||
|
MCContext *&Ctx,
|
||||||
|
CodeGenOpt::Level OptLevel,
|
||||||
|
bool DisableVerify) {
|
||||||
|
// Add common CodeGen passes.
|
||||||
|
if (addCommonCodeGenPasses(PM, OptLevel, DisableVerify, Ctx))
|
||||||
|
return true;
|
||||||
|
// Make sure the code model is set.
|
||||||
|
setCodeModelForJIT();
|
||||||
|
|
||||||
|
return false; // success!
|
||||||
|
}
|
||||||
|
|
||||||
static void printNoVerify(PassManagerBase &PM, const char *Banner) {
|
static void printNoVerify(PassManagerBase &PM, const char *Banner) {
|
||||||
if (PrintMachineCode)
|
if (PrintMachineCode)
|
||||||
PM.add(createMachineFunctionPrinterPass(dbgs(), Banner));
|
PM.add(createMachineFunctionPrinterPass(dbgs(), Banner));
|
||||||
|
@ -647,7 +647,7 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD,
|
|||||||
assert(OW->getStream().tell() - Start == Layout.getSectionFileSize(SD));
|
assert(OW->getStream().tell() - Start == Layout.getSectionFileSize(SD));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAssembler::Finish() {
|
void MCAssembler::Finish(MCObjectWriter *Writer) {
|
||||||
DEBUG_WITH_TYPE("mc-dump", {
|
DEBUG_WITH_TYPE("mc-dump", {
|
||||||
llvm::errs() << "assembler backend - pre-layout\n--\n";
|
llvm::errs() << "assembler backend - pre-layout\n--\n";
|
||||||
dump(); });
|
dump(); });
|
||||||
@ -717,9 +717,15 @@ void MCAssembler::Finish() {
|
|||||||
dump(); });
|
dump(); });
|
||||||
|
|
||||||
uint64_t StartOffset = OS.tell();
|
uint64_t StartOffset = OS.tell();
|
||||||
llvm::OwningPtr<MCObjectWriter> Writer(getBackend().createObjectWriter(OS));
|
|
||||||
if (!Writer)
|
llvm::OwningPtr<MCObjectWriter> OwnWriter(0);
|
||||||
report_fatal_error("unable to create object writer!");
|
if (Writer == 0) {
|
||||||
|
//no custom Writer_ : create the default one life-managed by OwningPtr
|
||||||
|
OwnWriter.reset(getBackend().createObjectWriter(OS));
|
||||||
|
Writer = OwnWriter.get();
|
||||||
|
if (!Writer)
|
||||||
|
report_fatal_error("unable to create object writer!");
|
||||||
|
}
|
||||||
|
|
||||||
// Allow the object writer a chance to perform post-layout binding (for
|
// Allow the object writer a chance to perform post-layout binding (for
|
||||||
// example, to set the index fields in the symbol data).
|
// example, to set the index fields in the symbol data).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user