Remove the "WantsWholeFile" concept, as it's no longer needed. CBE

and the others use the regular addPassesToEmitFile hook now, and
llc no longer needs a bunch of redundant code to handle the
whole-file case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2010-05-11 19:57:55 +00:00
parent 038df88e28
commit 99dca4fde7
7 changed files with 52 additions and 107 deletions

View File

@ -225,17 +225,6 @@ public:
bool = true) {
return true;
}
/// addPassesToEmitWholeFile - This method can be implemented by targets that
/// require having the entire module at once. This is not recommended, do not
/// use this.
virtual bool WantsWholeFile() const { return false; }
virtual bool addPassesToEmitWholeFile(PassManager &, formatted_raw_ostream &,
CodeGenFileType,
CodeGenOpt::Level,
bool = true) {
return true;
}
};
/// LLVMTargetMachine - This class describes a target machine that is

View File

@ -3554,7 +3554,7 @@ void CWriter::visitExtractValueInst(ExtractValueInst &EVI) {
// External Interface declaration
//===----------------------------------------------------------------------===//
bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
bool CTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel,

View File

@ -23,8 +23,7 @@ struct CTargetMachine : public TargetMachine {
CTargetMachine(const Target &T, const std::string &TT, const std::string &FS)
: TargetMachine(T) {}
virtual bool WantsWholeFile() const { return true; }
virtual bool addPassesToEmitWholeFile(PassManager &PM,
virtual bool addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel,

View File

@ -2007,7 +2007,7 @@ char CppWriter::ID = 0;
// External Interface declaration
//===----------------------------------------------------------------------===//
bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM,
bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel,

View File

@ -26,8 +26,7 @@ struct CPPTargetMachine : public TargetMachine {
const std::string &FS)
: TargetMachine(T) {}
virtual bool WantsWholeFile() const { return true; }
virtual bool addPassesToEmitWholeFile(PassManager &PM,
virtual bool addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel,

View File

@ -34,8 +34,7 @@ namespace llvm {
MSILTarget(const Target &T, const std::string &TT, const std::string &FS)
: TargetMachine(T) {}
virtual bool WantsWholeFile() const { return true; }
virtual bool addPassesToEmitWholeFile(PassManager &PM,
virtual bool addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &Out,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel,
@ -1686,7 +1685,7 @@ void MSILWriter::printExternals() {
// External Interface declaration
//===----------------------------------------------------------------------===//
bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM,
bool MSILTarget::addPassesToEmitFile(PassManagerBase &PM,
formatted_raw_ostream &o,
CodeGenFileType FileType,
CodeGenOpt::Level OptLevel,

View File

@ -312,9 +312,7 @@ int main(int argc, char **argv) {
bool DisableVerify = true;
#endif
// If this target requires addPassesToEmitWholeFile, do it now. This is
// used by strange things like the C backend.
if (Target.WantsWholeFile()) {
// Build up all of the passes that we want to do to the module.
PassManager PM;
// Add the target data from the target machine, if it exists, or the module.
@ -326,36 +324,11 @@ int main(int argc, char **argv) {
if (!NoVerify)
PM.add(createVerifierPass());
// Ask the target to add backend passes as necessary.
if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl,
DisableVerify)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
if (Out != &fouts()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
}
PM.run(mod);
} else {
// Build up all of the passes that we want to do to the module.
FunctionPassManager Passes(M.get());
// Add the target data from the target machine, if it exists, or the module.
if (const TargetData *TD = Target.getTargetData())
Passes.add(new TargetData(*TD));
else
Passes.add(new TargetData(&mod));
#ifndef NDEBUG
if (!NoVerify)
Passes.add(createVerifierPass());
#endif
// Override default to generate verbose assembly.
Target.setAsmVerbosityDefault(true);
if (Target.addPassesToEmitFile(Passes, *Out, FileType, OLvl,
// Ask the target to add backend passes as necessary.
if (Target.addPassesToEmitFile(PM, *Out, FileType, OLvl,
DisableVerify)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
@ -365,21 +338,7 @@ int main(int argc, char **argv) {
return 1;
}
Passes.doInitialization();
// Run our queue of passes all at once now, efficiently.
// TODO: this could lazily stream functions out of the module.
for (Module::iterator I = mod.begin(), E = mod.end(); I != E; ++I)
if (!I->isDeclaration()) {
if (DisableRedZone)
I->addFnAttr(Attribute::NoRedZone);
if (NoImplicitFloats)
I->addFnAttr(Attribute::NoImplicitFloat);
Passes.run(*I);
}
Passes.doFinalization();
}
PM.run(mod);
// Delete the ostream if it's not a stdout stream
if (Out != &fouts()) delete Out;