[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcTargetMachine.cpp SparcTargetMachine.h

Chris Lattner lattner at cs.uiuc.edu
Sun Sep 3 21:15:26 PDT 2006



Changes in directory llvm/lib/Target/Sparc:

SparcTargetMachine.cpp updated: 1.49 -> 1.50
SparcTargetMachine.h updated: 1.14 -> 1.15
---
Log message:

Completely rearchitect the interface between targets and the pass manager.
This pass:

1. Splits TargetMachine into TargetMachine (generic targets, can be implemented
any way, like the CBE) and LLVMTargetMachine (subclass of TM that is used by
things using libcodegen and other support).
2. Instead of having each target fully populate the passmgr for file or JIT
   output, move all this to common code, and give targets hooks they can
   implement.
3. Commonalize the target population stuff between file emission and JIT
   emission.
4. All (native code) codegen stuff now happens in a FunctionPassManager, which
   paves the way for "fast -O0" stuff in the CFE later, and now LLC could
   lazily stream .bc files from disk to use less memory.
5. There are now many fewer #includes and the targets don't depend on the 
   scalar xforms or libanalysis anymore (but codegen does).
6. Changing common code generator pass ordering stuff no longer requires 
   touching all targets.
7. The JIT now has the option of "-fast" codegen or normal optimized codegen,
   which is now orthogonal to the fact that JIT'ing is being done.


---
Diffs of the changes:  (+18 -54)

 SparcTargetMachine.cpp |   61 ++++++++-----------------------------------------
 SparcTargetMachine.h   |   11 +++++---
 2 files changed, 18 insertions(+), 54 deletions(-)


Index: llvm/lib/Target/Sparc/SparcTargetMachine.cpp
diff -u llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.49 llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.50
--- llvm/lib/Target/Sparc/SparcTargetMachine.cpp:1.49	Sun Sep  3 13:44:02 2006
+++ llvm/lib/Target/Sparc/SparcTargetMachine.cpp	Sun Sep  3 23:14:57 2006
@@ -12,14 +12,9 @@
 
 #include "SparcTargetMachine.h"
 #include "Sparc.h"
-#include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/Passes.h"
-#include "llvm/Target/TargetOptions.h"
 #include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Transforms/Scalar.h"
 #include <iostream>
 using namespace llvm;
 
@@ -55,57 +50,23 @@
   return 0;
 }
 
-/// addPassesToEmitFile - Add passes to the specified pass manager
-/// to implement a static compiler for this target.
-///
-bool SparcTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
-                                             CodeGenFileType FileType,
-                                             bool Fast) {
-  if (FileType != TargetMachine::AssemblyFile) return true;
-
-  // Run loop strength reduction before anything else.
-  if (!Fast) PM.add(createLoopStrengthReducePass());
-
-  // FIXME: Implement efficient support for garbage collection intrinsics.
-  PM.add(createLowerGCPass());
-
-  // FIXME: implement the invoke/unwind instructions!
-  PM.add(createLowerInvokePass());
-
-  // Print LLVM code input to instruction selector:
-  if (PrintMachineCode)
-    PM.add(new PrintFunctionPass());
-
-  // Make sure that no unreachable blocks are instruction selected.
-  PM.add(createUnreachableBlockEliminationPass());
-  
+bool SparcTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
   PM.add(createSparcISelDag(*this));
+  return false;
+}
 
-  // Print machine instructions as they were initially generated.
-  if (PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(&std::cerr));
-
-  PM.add(createRegisterAllocator());
-  PM.add(createPrologEpilogCodeInserter());
-
-  // Print machine instructions after register allocation and prolog/epilog
-  // insertion.
-  if (PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(&std::cerr));
-
+/// addPreEmitPass - This pass may be implemented by targets that want to run
+/// passes immediately before machine code is emitted.  This should return
+/// true if -print-machineinstrs should print out the code after the passes.
+bool SparcTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
   PM.add(createSparcFPMoverPass(*this));
-
   PM.add(createSparcDelaySlotFillerPass(*this));
+  return true;
+}
 
-  // Print machine instructions after filling delay slots.
-  if (PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(&std::cerr));
-
+bool SparcTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
+                                            std::ostream &Out) {
   // Output assembly language.
   PM.add(createSparcCodePrinterPass(Out, *this));
-
-  // Delete the MachineInstrs we generated, since they're no longer needed.
-  PM.add(createMachineCodeDeleter());
   return false;
 }
-


Index: llvm/lib/Target/Sparc/SparcTargetMachine.h
diff -u llvm/lib/Target/Sparc/SparcTargetMachine.h:1.14 llvm/lib/Target/Sparc/SparcTargetMachine.h:1.15
--- llvm/lib/Target/Sparc/SparcTargetMachine.h:1.14	Fri May 12 01:33:48 2006
+++ llvm/lib/Target/Sparc/SparcTargetMachine.h	Sun Sep  3 23:14:57 2006
@@ -17,7 +17,6 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetFrameInfo.h"
-#include "llvm/PassManager.h"
 #include "SparcInstrInfo.h"
 #include "SparcSubtarget.h"
 
@@ -25,7 +24,7 @@
 
 class Module;
 
-class SparcTargetMachine : public TargetMachine {
+class SparcTargetMachine : public LLVMTargetMachine {
   const TargetData DataLayout;       // Calculates type size & alignment
   SparcSubtarget Subtarget;
   SparcInstrInfo InstrInfo;
@@ -42,8 +41,12 @@
   virtual const TargetData       *getTargetData() const { return &DataLayout; }
   static unsigned getModuleMatchQuality(const Module &M);
 
-  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
-                                   CodeGenFileType FileType, bool Fast);
+  
+  // Pass Pipeline Configuration
+  virtual bool addInstSelector(FunctionPassManager &PM, bool Fast);
+  virtual bool addPreEmitPass(FunctionPassManager &PM, bool Fast);
+  virtual bool addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
+                                  std::ostream &Out);
 };
 
 } // end namespace llvm






More information about the llvm-commits mailing list