From 99dca4fde746eb76253e737cca166261c767412d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 11 May 2010 19:57:55 +0000 Subject: [PATCH] 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 --- include/llvm/Target/TargetMachine.h | 11 ---- lib/Target/CBackend/CBackend.cpp | 10 ++-- lib/Target/CBackend/CTargetMachine.h | 11 ++-- lib/Target/CppBackend/CPPBackend.cpp | 10 ++-- lib/Target/CppBackend/CPPTargetMachine.h | 11 ++-- lib/Target/MSIL/MSILWriter.cpp | 21 ++++---- tools/llc/llc.cpp | 93 +++++++++----------------------- 7 files changed, 56 insertions(+), 111 deletions(-) diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index c734cf4ee06..580998f2bf1 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -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 diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 67f513b0986..cc9e1d74654 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -3554,11 +3554,11 @@ void CWriter::visitExtractValueInst(ExtractValueInst &EVI) { // External Interface declaration //===----------------------------------------------------------------------===// -bool CTargetMachine::addPassesToEmitWholeFile(PassManager &PM, - formatted_raw_ostream &o, - CodeGenFileType FileType, - CodeGenOpt::Level OptLevel, - bool DisableVerify) { +bool CTargetMachine::addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &o, + CodeGenFileType FileType, + CodeGenOpt::Level OptLevel, + bool DisableVerify) { if (FileType != TargetMachine::CGFT_AssemblyFile) return true; PM.add(createGCLoweringPass()); diff --git a/lib/Target/CBackend/CTargetMachine.h b/lib/Target/CBackend/CTargetMachine.h index d178e7f2d01..6fed1959ff6 100644 --- a/lib/Target/CBackend/CTargetMachine.h +++ b/lib/Target/CBackend/CTargetMachine.h @@ -23,12 +23,11 @@ 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, - formatted_raw_ostream &Out, - CodeGenFileType FileType, - CodeGenOpt::Level OptLevel, - bool DisableVerify); + virtual bool addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &Out, + CodeGenFileType FileType, + CodeGenOpt::Level OptLevel, + bool DisableVerify); virtual const TargetData *getTargetData() const { return 0; } }; diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index e739b26bc5c..28345b29379 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -2007,11 +2007,11 @@ char CppWriter::ID = 0; // External Interface declaration //===----------------------------------------------------------------------===// -bool CPPTargetMachine::addPassesToEmitWholeFile(PassManager &PM, - formatted_raw_ostream &o, - CodeGenFileType FileType, - CodeGenOpt::Level OptLevel, - bool DisableVerify) { +bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &o, + CodeGenFileType FileType, + CodeGenOpt::Level OptLevel, + bool DisableVerify) { if (FileType != TargetMachine::CGFT_AssemblyFile) return true; PM.add(new CppWriter(o)); return false; diff --git a/lib/Target/CppBackend/CPPTargetMachine.h b/lib/Target/CppBackend/CPPTargetMachine.h index b7aae917ace..e42166e0558 100644 --- a/lib/Target/CppBackend/CPPTargetMachine.h +++ b/lib/Target/CppBackend/CPPTargetMachine.h @@ -26,12 +26,11 @@ struct CPPTargetMachine : public TargetMachine { const std::string &FS) : TargetMachine(T) {} - virtual bool WantsWholeFile() const { return true; } - virtual bool addPassesToEmitWholeFile(PassManager &PM, - formatted_raw_ostream &Out, - CodeGenFileType FileType, - CodeGenOpt::Level OptLevel, - bool DisableVerify); + virtual bool addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &Out, + CodeGenFileType FileType, + CodeGenOpt::Level OptLevel, + bool DisableVerify); virtual const TargetData *getTargetData() const { return 0; } }; diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index 15d16ecfe9d..332a150e6c4 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -34,12 +34,11 @@ 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, - formatted_raw_ostream &Out, - CodeGenFileType FileType, - CodeGenOpt::Level OptLevel, - bool DisableVerify); + virtual bool addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &Out, + CodeGenFileType FileType, + CodeGenOpt::Level OptLevel, + bool DisableVerify); virtual const TargetData *getTargetData() const { return 0; } }; @@ -1686,11 +1685,11 @@ void MSILWriter::printExternals() { // External Interface declaration //===----------------------------------------------------------------------===// -bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM, - formatted_raw_ostream &o, - CodeGenFileType FileType, - CodeGenOpt::Level OptLevel, - bool DisableVerify) +bool MSILTarget::addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &o, + CodeGenFileType FileType, + CodeGenOpt::Level OptLevel, + bool DisableVerify) { if (FileType != TargetMachine::CGFT_AssemblyFile) return true; MSILWriter* Writer = new MSILWriter(o); diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 82cea946455..f3eed56accd 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -312,75 +312,34 @@ 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()) { - PassManager PM; - - // Add the target data from the target machine, if it exists, or the module. - if (const TargetData *TD = Target.getTargetData()) - PM.add(new TargetData(*TD)); - else - PM.add(new TargetData(&mod)); - - 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, - 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; - } - - 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(); + // 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. + if (const TargetData *TD = Target.getTargetData()) + PM.add(new TargetData(*TD)); + else + PM.add(new TargetData(&mod)); + + if (!NoVerify) + PM.add(createVerifierPass()); + + // Override default to generate verbose assembly. + Target.setAsmVerbosityDefault(true); + + // 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"; + 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); + // Delete the ostream if it's not a stdout stream if (Out != &fouts()) delete Out; -- 2.11.0