diff options
author | Chris Lattner <sabre@nondot.org> | 2002-01-21 07:31:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-01-21 07:31:50 +0000 |
commit | f4de63f65fa995e68e3cd268117ab065068be413 (patch) | |
tree | 2fd8cd44af0f23dafd94102c1c0152b1cd82fe4d /tools/llc | |
parent | aff5bcebb7fb9880e0a3518a8e7c999e738d531c (diff) | |
download | llvm-f4de63f65fa995e68e3cd268117ab065068be413.tar.gz llvm-f4de63f65fa995e68e3cd268117ab065068be413.tar.bz2 llvm-f4de63f65fa995e68e3cd268117ab065068be413.tar.xz |
Implement a more powerful, simpler, pass system. This pass system can figure
out how to run a collection of passes optimially given their behaviors and
charactaristics.
Convert code to use it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llc')
-rw-r--r-- | tools/llc/llc.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 6b51f79b38..3cc8a723f3 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -52,21 +52,20 @@ static inline string GetFileNameRoot(const string &InputFilename) { // Native code generation for a specified target. //===---------------------------------------------------------------------===// -class GenerateCodeForTarget : public Pass { +class GenerateCodeForTarget : public MethodPass { TargetMachine &Target; public: inline GenerateCodeForTarget(TargetMachine &T) : Target(T) {} - // doPerMethodWork - This method does the actual work of generating code for + // runOnMethod - This method does the actual work of generating code for // the specified method. // - bool doPerMethodWork(Method *M) { + bool runOnMethod(Method *M) { if (!M->isExternal() && Target.compileMethod(M)) { cerr << "Error compiling " << InputFilename << "!\n"; - return true; } - return false; + return true; } }; @@ -85,8 +84,7 @@ public: inline EmitAssembly(const TargetMachine &T, std::ostream *O, bool D) : Target(T), Out(O), DeleteStream(D) {} - - virtual bool doPassFinalization(Module *M) { + virtual bool run(Module *M) { Target.emitAssembly(M, *Out); if (DeleteStream) delete Out; @@ -95,6 +93,7 @@ public: }; + //===---------------------------------------------------------------------===// // Function main() // @@ -119,18 +118,18 @@ int main(int argc, char **argv) { } // Build up all of the passes that we want to do to the module... - std::vector<Pass*> Passes; + PassManager Passes; // Hoist constants out of PHI nodes into predecessor BB's - Passes.push_back(new HoistPHIConstants()); + Passes.add(new HoistPHIConstants()); if (TraceBBValues || TraceMethodValues) { // If tracing enabled... // Insert trace code in all methods in the module - Passes.push_back(new InsertTraceCode(TraceBBValues, - TraceBBValues ||TraceMethodValues)); + Passes.add(new InsertTraceCode(TraceBBValues, + TraceBBValues ||TraceMethodValues)); // Eliminate duplication in constant pool - Passes.push_back(new DynamicConstantMerge()); + Passes.add(new DynamicConstantMerge()); // Then write out the module with tracing code before code generation assert(InputFilename != "-" && @@ -152,20 +151,20 @@ int main(int argc, char **argv) { return 1; } - Passes.push_back(new WriteBytecodePass(os, true)); + Passes.add(new WriteBytecodePass(os, true)); } // Replace malloc and free instructions with library calls. // Do this after tracing until lli implements these lib calls. // For now, it will emulate malloc and free internally. - Passes.push_back(new LowerAllocations(Target.DataLayout)); + Passes.add(new LowerAllocations(Target.DataLayout)); // If LLVM dumping after transformations is requested, add it to the pipeline if (DumpAsm) - Passes.push_back(new PrintModulePass("Code after xformations: \n",&cerr)); + Passes.add(new PrintMethodPass("Code after xformations: \n",&cerr)); // Generate Target code... - Passes.push_back(new GenerateCodeForTarget(Target)); + Passes.add(new GenerateCodeForTarget(Target)); if (!DoNotEmitAssembly) { // If asm output is enabled... // Figure out where we are going to send the output... @@ -203,12 +202,11 @@ int main(int argc, char **argv) { } // Output assembly language to the .s file - Passes.push_back(new EmitAssembly(Target, Out, Out != &std::cout)); + Passes.add(new EmitAssembly(Target, Out, Out != &std::cout)); } - // Run our queue of passes all at once now, efficiently. This form of - // runAllPasses frees the Pass objects after runAllPasses completes. - Pass::runAllPassesAndFree(M.get(), Passes); + // Run our queue of passes all at once now, efficiently. + Passes.run(M.get()); return 0; } |