mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-20 10:30:17 +00:00
change addPassesToEmitFile to return true on failure instead of its input,
add -filetype=null for performance testing and remove -filetype=dynlib, which isn't planned to be implemented. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -199,8 +199,7 @@ public:
|
|||||||
enum CodeGenFileType {
|
enum CodeGenFileType {
|
||||||
CGFT_AssemblyFile,
|
CGFT_AssemblyFile,
|
||||||
CGFT_ObjectFile,
|
CGFT_ObjectFile,
|
||||||
CGFT_DynamicLibrary,
|
CGFT_Null // Do not emit any output.
|
||||||
CGFT_ErrorOccurred
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
/// getEnableTailMergeDefault - the default setting for -enable-tail-merge
|
||||||
@@ -209,15 +208,13 @@ public:
|
|||||||
|
|
||||||
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
||||||
/// specified file emitted. Typically this will involve several steps of code
|
/// specified file emitted. Typically this will involve several steps of code
|
||||||
/// generation.
|
/// generation. This method should return true if emission of this file type
|
||||||
/// This method should return InvalidFile if emission of this file type
|
/// is not supported, or false on success.
|
||||||
/// is not supported.
|
virtual bool addPassesToEmitFile(PassManagerBase &,
|
||||||
///
|
formatted_raw_ostream &,
|
||||||
virtual CodeGenFileType addPassesToEmitFile(PassManagerBase &,
|
CodeGenFileType Filetype,
|
||||||
formatted_raw_ostream &,
|
CodeGenOpt::Level) {
|
||||||
CodeGenFileType Filetype,
|
return true;
|
||||||
CodeGenOpt::Level) {
|
|
||||||
return CGFT_ErrorOccurred;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||||
@@ -264,18 +261,11 @@ public:
|
|||||||
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
/// addPassesToEmitFile - Add passes to the specified pass manager to get the
|
||||||
/// specified file emitted. Typically this will involve several steps of code
|
/// specified file emitted. Typically this will involve several steps of code
|
||||||
/// generation. If OptLevel is None, the code generator should emit code as
|
/// generation. If OptLevel is None, the code generator should emit code as
|
||||||
/// fast as possible, though the generated code may be less efficient. This
|
/// fast as possible, though the generated code may be less efficient.
|
||||||
/// method should return CGFT_ErrorOccurred if emission of this file type is
|
virtual bool addPassesToEmitFile(PassManagerBase &PM,
|
||||||
/// not supported.
|
formatted_raw_ostream &Out,
|
||||||
///
|
CodeGenFileType FileType,
|
||||||
/// The default implementation of this method adds components from the
|
CodeGenOpt::Level);
|
||||||
/// LLVM retargetable code generator, invoking the methods below to get
|
|
||||||
/// target-specific passes in standard locations.
|
|
||||||
///
|
|
||||||
virtual CodeGenFileType addPassesToEmitFile(PassManagerBase &PM,
|
|
||||||
formatted_raw_ostream &Out,
|
|
||||||
CodeGenFileType FileType,
|
|
||||||
CodeGenOpt::Level);
|
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||||
/// get machine code emitted. This uses a JITCodeEmitter object to handle
|
/// get machine code emitted. This uses a JITCodeEmitter object to handle
|
||||||
|
@@ -111,21 +111,20 @@ LLVMTargetMachine::setCodeModelForStatic() {
|
|||||||
setCodeModel(CodeModel::Small);
|
setCodeModel(CodeModel::Small);
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetMachine::CodeGenFileType
|
bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||||
LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
formatted_raw_ostream &Out,
|
||||||
formatted_raw_ostream &Out,
|
CodeGenFileType FileType,
|
||||||
CodeGenFileType FileType,
|
CodeGenOpt::Level OptLevel) {
|
||||||
CodeGenOpt::Level OptLevel) {
|
|
||||||
// Add common CodeGen passes.
|
// Add common CodeGen passes.
|
||||||
if (addCommonCodeGenPasses(PM, OptLevel))
|
if (addCommonCodeGenPasses(PM, OptLevel))
|
||||||
return CGFT_ErrorOccurred;
|
return true;
|
||||||
|
|
||||||
OwningPtr<MCContext> Context(new MCContext());
|
OwningPtr<MCContext> Context(new MCContext());
|
||||||
OwningPtr<MCStreamer> AsmStreamer;
|
OwningPtr<MCStreamer> AsmStreamer;
|
||||||
|
|
||||||
formatted_raw_ostream *LegacyOutput;
|
formatted_raw_ostream *LegacyOutput;
|
||||||
switch (FileType) {
|
switch (FileType) {
|
||||||
default: return CGFT_ErrorOccurred;
|
default: return true;
|
||||||
case CGFT_AssemblyFile: {
|
case CGFT_AssemblyFile: {
|
||||||
const MCAsmInfo &MAI = *getMCAsmInfo();
|
const MCAsmInfo &MAI = *getMCAsmInfo();
|
||||||
MCInstPrinter *InstPrinter =
|
MCInstPrinter *InstPrinter =
|
||||||
@@ -143,7 +142,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
// emission fails.
|
// emission fails.
|
||||||
MCCodeEmitter *MCE = getTarget().createCodeEmitter(*this);
|
MCCodeEmitter *MCE = getTarget().createCodeEmitter(*this);
|
||||||
if (MCE == 0)
|
if (MCE == 0)
|
||||||
return CGFT_ErrorOccurred;
|
return true;
|
||||||
|
|
||||||
AsmStreamer.reset(createMachOStreamer(*Context, Out, MCE));
|
AsmStreamer.reset(createMachOStreamer(*Context, Out, MCE));
|
||||||
|
|
||||||
@@ -154,6 +153,16 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
LegacyOutput = new formatted_raw_ostream(errs());
|
LegacyOutput = new formatted_raw_ostream(errs());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CGFT_Null:
|
||||||
|
// The Null output is intended for use for performance analysis and testing,
|
||||||
|
// not real users.
|
||||||
|
AsmStreamer.reset(createNullStreamer(*Context));
|
||||||
|
// Any output to the asmprinter's "O" stream is bad and needs to be fixed,
|
||||||
|
// force it to come out stderr.
|
||||||
|
// FIXME: this is horrible and leaks, eventually remove the raw_ostream from
|
||||||
|
// asmprinter.
|
||||||
|
LegacyOutput = new formatted_raw_ostream(errs());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the AsmPrinter, which takes ownership of Context and AsmStreamer
|
// Create the AsmPrinter, which takes ownership of Context and AsmStreamer
|
||||||
@@ -162,7 +171,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
getTarget().createAsmPrinter(*LegacyOutput, *this, *Context, *AsmStreamer,
|
getTarget().createAsmPrinter(*LegacyOutput, *this, *Context, *AsmStreamer,
|
||||||
getMCAsmInfo());
|
getMCAsmInfo());
|
||||||
if (Printer == 0)
|
if (Printer == 0)
|
||||||
return CGFT_ErrorOccurred;
|
return true;
|
||||||
|
|
||||||
// If successful, createAsmPrinter took ownership of AsmStreamer and Context.
|
// If successful, createAsmPrinter took ownership of AsmStreamer and Context.
|
||||||
Context.take(); AsmStreamer.take();
|
Context.take(); AsmStreamer.take();
|
||||||
@@ -172,7 +181,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
// Make sure the code model is set.
|
// Make sure the code model is set.
|
||||||
setCodeModelForStatic();
|
setCodeModelForStatic();
|
||||||
PM.add(createGCInfoDeleter());
|
PM.add(createGCInfoDeleter());
|
||||||
return FileType;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||||
|
@@ -91,9 +91,8 @@ FileType("filetype", cl::init(TargetMachine::CGFT_AssemblyFile),
|
|||||||
"Emit an assembly ('.s') file"),
|
"Emit an assembly ('.s') file"),
|
||||||
clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
|
clEnumValN(TargetMachine::CGFT_ObjectFile, "obj",
|
||||||
"Emit a native object ('.o') file [experimental]"),
|
"Emit a native object ('.o') file [experimental]"),
|
||||||
clEnumValN(TargetMachine::CGFT_DynamicLibrary, "dynlib",
|
clEnumValN(TargetMachine::CGFT_Null, "null",
|
||||||
"Emit a native dynamic library ('.so') file"
|
"Emit nothing, for performance testing"),
|
||||||
" [experimental]"),
|
|
||||||
clEnumValEnd));
|
clEnumValEnd));
|
||||||
|
|
||||||
cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
|
cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
|
||||||
@@ -177,8 +176,8 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
|
|||||||
OutputFilename += ".o";
|
OutputFilename += ".o";
|
||||||
Binary = true;
|
Binary = true;
|
||||||
break;
|
break;
|
||||||
case TargetMachine::CGFT_DynamicLibrary:
|
case TargetMachine::CGFT_Null:
|
||||||
OutputFilename += LTDL_SHLIB_EXT;
|
OutputFilename += ".null";
|
||||||
Binary = true;
|
Binary = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -348,20 +347,13 @@ int main(int argc, char **argv) {
|
|||||||
// Override default to generate verbose assembly.
|
// Override default to generate verbose assembly.
|
||||||
Target.setAsmVerbosityDefault(true);
|
Target.setAsmVerbosityDefault(true);
|
||||||
|
|
||||||
switch (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl)) {
|
if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl)) {
|
||||||
default:
|
|
||||||
assert(0 && "Invalid file model!");
|
|
||||||
return 1;
|
|
||||||
case TargetMachine::CGFT_ErrorOccurred:
|
|
||||||
errs() << argv[0] << ": target does not support generation of this"
|
errs() << argv[0] << ": target does not support generation of this"
|
||||||
<< " file type!\n";
|
<< " file type!\n";
|
||||||
if (Out != &fouts()) delete Out;
|
if (Out != &fouts()) delete Out;
|
||||||
// And the Out file is empty and useless, so remove it now.
|
// And the Out file is empty and useless, so remove it now.
|
||||||
sys::Path(OutputFilename).eraseFromDisk();
|
sys::Path(OutputFilename).eraseFromDisk();
|
||||||
return 1;
|
return 1;
|
||||||
case TargetMachine::CGFT_AssemblyFile:
|
|
||||||
case TargetMachine::CGFT_ObjectFile:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Passes.doInitialization();
|
Passes.doInitialization();
|
||||||
|
@@ -393,14 +393,11 @@ bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out,
|
|||||||
|
|
||||||
codeGenPasses->add(new TargetData(*_target->getTargetData()));
|
codeGenPasses->add(new TargetData(*_target->getTargetData()));
|
||||||
|
|
||||||
switch (_target->addPassesToEmitFile(*codeGenPasses, out,
|
if (_target->addPassesToEmitFile(*codeGenPasses, out,
|
||||||
TargetMachine::CGFT_AssemblyFile,
|
TargetMachine::CGFT_AssemblyFile,
|
||||||
CodeGenOpt::Aggressive)) {
|
CodeGenOpt::Aggressive)) {
|
||||||
case TargetMachine::CGFT_AssemblyFile:
|
errMsg = "target file type not supported";
|
||||||
break;
|
return true;
|
||||||
default:
|
|
||||||
errMsg = "target file type not supported";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run our queue of passes all at once now, efficiently.
|
// Run our queue of passes all at once now, efficiently.
|
||||||
|
Reference in New Issue
Block a user