[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC.h PPCJITInfo.h PPCMachOWriter.cpp PPCTargetMachine.cpp PPCTargetMachine.h

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



Changes in directory llvm/lib/Target/PowerPC:

PPC.h updated: 1.31 -> 1.32
PPCJITInfo.h updated: 1.13 -> 1.14
PPCMachOWriter.cpp updated: 1.2 -> 1.3
PPCTargetMachine.cpp updated: 1.102 -> 1.103
PPCTargetMachine.h updated: 1.22 -> 1.23
---
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:  (+45 -108)

 PPC.h                |   10 ++--
 PPCJITInfo.h         |    6 --
 PPCMachOWriter.cpp   |    2 
 PPCTargetMachine.cpp |  119 ++++++++++++---------------------------------------
 PPCTargetMachine.h   |   16 ++++--
 5 files changed, 45 insertions(+), 108 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC.h
diff -u llvm/lib/Target/PowerPC/PPC.h:1.31 llvm/lib/Target/PowerPC/PPC.h:1.32
--- llvm/lib/Target/PowerPC/PPC.h:1.31	Wed Aug 23 16:08:52 2006
+++ llvm/lib/Target/PowerPC/PPC.h	Sun Sep  3 23:14:57 2006
@@ -1,4 +1,4 @@
-//===-- PowerPC.h - Top-level interface for PowerPC representation -*- C++ -*-//
+//===-- PPC.h - Top-level interface for PowerPC Target ----------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -12,15 +12,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef TARGET_POWERPC_H
-#define TARGET_POWERPC_H
+#ifndef LLVM_TARGET_POWERPC_H
+#define LLVM_TARGET_POWERPC_H
 
 #include <iosfwd>
 
 namespace llvm {
 
 class PPCTargetMachine;
-class PassManager;
+class FunctionPassManager;
 class FunctionPass;
 class MachineCodeEmitter;
 
@@ -29,7 +29,7 @@
 FunctionPass *createDarwinAsmPrinter(std::ostream &OS, PPCTargetMachine &TM);
 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
                                        MachineCodeEmitter &MCE);
-void addPPCMachOObjectWriterPass(PassManager &FPM, std::ostream &o, 
+void addPPCMachOObjectWriterPass(FunctionPassManager &FPM, std::ostream &o, 
                                  PPCTargetMachine &tm);
 } // end namespace llvm;
 


Index: llvm/lib/Target/PowerPC/PPCJITInfo.h
diff -u llvm/lib/Target/PowerPC/PPCJITInfo.h:1.13 llvm/lib/Target/PowerPC/PPCJITInfo.h:1.14
--- llvm/lib/Target/PowerPC/PPCJITInfo.h:1.13	Mon Aug 28 21:30:59 2006
+++ llvm/lib/Target/PowerPC/PPCJITInfo.h	Sun Sep  3 23:14:57 2006
@@ -29,12 +29,6 @@
       is64Bit = tmIs64Bit;
     }
 
-    /// addPassesToJITCompile - Add passes to the specified pass manager to
-    /// implement a fast dynamic compiler for this target.  Return true if this
-    /// is not supported for this target.
-    ///
-    virtual void addPassesToJITCompile(FunctionPassManager &PM);
-
     virtual void *emitFunctionStub(void *Fn, MachineCodeEmitter &MCE);
     virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn);
     virtual void relocate(void *Function, MachineRelocation *MR,


Index: llvm/lib/Target/PowerPC/PPCMachOWriter.cpp
diff -u llvm/lib/Target/PowerPC/PPCMachOWriter.cpp:1.2 llvm/lib/Target/PowerPC/PPCMachOWriter.cpp:1.3
--- llvm/lib/Target/PowerPC/PPCMachOWriter.cpp:1.2	Sun Aug 27 07:54:01 2006
+++ llvm/lib/Target/PowerPC/PPCMachOWriter.cpp	Sun Sep  3 23:14:57 2006
@@ -33,7 +33,7 @@
 /// addPPCMachOObjectWriterPass - Returns a pass that outputs the generated code
 /// as a Mach-O object file.
 ///
-void llvm::addPPCMachOObjectWriterPass(PassManager &FPM,
+void llvm::addPPCMachOObjectWriterPass(FunctionPassManager &FPM,
                                        std::ostream &O, PPCTargetMachine &TM) {
   PPCMachOWriter *EW = new PPCMachOWriter(O, TM);
   FPM.add(EW);


Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.102 llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.103
--- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp:1.102	Sun Sep  3 13:44:02 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp	Sun Sep  3 23:14:57 2006
@@ -12,19 +12,10 @@
 //===----------------------------------------------------------------------===//
 
 #include "PPC.h"
-#include "PPCFrameInfo.h"
 #include "PPCTargetMachine.h"
-#include "PPCJITInfo.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Analysis/Verifier.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 "llvm/Support/CommandLine.h"
-#include <iostream>
 using namespace llvm;
 
 namespace {
@@ -106,99 +97,47 @@
   : PPCTargetMachine(M, FS, true) {
 }
 
-/// addPassesToEmitFile - Add passes to the specified pass manager to implement
-/// a static compiler for this target.
-///
-bool PPCTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
-                                           CodeGenFileType FileType,
-                                           bool Fast) {
-  if (FileType != TargetMachine::AssemblyFile &&
-      FileType != TargetMachine::ObjectFile) return true;
-  
-  // Run loop strength reduction before anything else.
-  if (!Fast) PM.add(createLoopStrengthReducePass(&TLInfo));
-
-  // FIXME: Implement efficient support for garbage collection intrinsics.
-  PM.add(createLowerGCPass());
 
-  // FIXME: Implement the invoke/unwind instructions!
-  PM.add(createLowerInvokePass());
-  
-  // Clean up after other passes, e.g. merging critical edges.
-  if (!Fast) PM.add(createCFGSimplificationPass());
-
-  // Make sure that no unreachable blocks are instruction selected.
-  PM.add(createUnreachableBlockEliminationPass());
+//===----------------------------------------------------------------------===//
+// Pass Pipeline Configuration
+//===----------------------------------------------------------------------===//
 
+bool PPCTargetMachine::addInstSelector(FunctionPassManager &PM, bool Fast) {
   // Install an instruction selector.
   PM.add(createPPCISelDag(*this));
+  return false;
+}
 
-  if (PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(&std::cerr));
-
-  PM.add(createRegisterAllocator());
-
-  if (PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(&std::cerr));
-
-  PM.add(createPrologEpilogCodeInserter());
-
-  // Must run branch selection immediately preceding the asm printer
+bool PPCTargetMachine::addPreEmitPass(FunctionPassManager &PM, bool Fast) {
+  
+  // Must run branch selection immediately preceding the asm printer.
   PM.add(createPPCBranchSelectionPass());
-
-  if (FileType == TargetMachine::AssemblyFile)
-    PM.add(createDarwinAsmPrinter(Out, *this));
-  else
-    // FIXME: support PPC ELF files at some point
-    addPPCMachOObjectWriterPass(PM, Out, *this);
-
-  PM.add(createMachineCodeDeleter());
   return false;
 }
 
-void PPCJITInfo::addPassesToJITCompile(FunctionPassManager &PM) {
-  // The JIT should use the static relocation model.
-  TM.setRelocationModel(Reloc::Static);
-
-  // Run loop strength reduction before anything else.
-  PM.add(createLoopStrengthReducePass(TM.getTargetLowering()));
-
-  // FIXME: Implement efficient support for garbage collection intrinsics.
-  PM.add(createLowerGCPass());
-
-  // FIXME: Implement the invoke/unwind instructions!
-  PM.add(createLowerInvokePass());
-
-  // Clean up after other passes, e.g. merging critical edges.
-  PM.add(createCFGSimplificationPass());
-
-  // Make sure that no unreachable blocks are instruction selected.
-  PM.add(createUnreachableBlockEliminationPass());
-
-  // Install an instruction selector.
-  PM.add(createPPCISelDag(TM));
-
-  PM.add(createRegisterAllocator());
-  PM.add(createPrologEpilogCodeInserter());
-
-  // Must run branch selection immediately preceding the asm printer
-  PM.add(createPPCBranchSelectionPass());
+bool PPCTargetMachine::addAssemblyEmitter(FunctionPassManager &PM, bool Fast, 
+                                          std::ostream &Out) {
+  PM.add(createDarwinAsmPrinter(Out, *this));
+  return false;
+}
 
-  if (PrintMachineCode)
-    PM.add(createMachineFunctionPrinterPass(&std::cerr));
+bool PPCTargetMachine::addObjectWriter(FunctionPassManager &PM, bool Fast,
+                                       std::ostream &Out) {
+  // FIXME: support PPC ELF files at some point
+  addPPCMachOObjectWriterPass(PM, Out, *this);
+  return true;
 }
 
-/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
-/// machine code emitted.  This uses a MachineCodeEmitter object to handle
-/// actually outputting the machine code and resolving things like the address
-/// of functions.  This method should returns true if machine code emission is
-/// not supported.
-///
-bool PPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
-                                                  MachineCodeEmitter &MCE) {
-  // Machine code emitter pass for PowerPC
+bool PPCTargetMachine::addCodeEmitter(FunctionPassManager &PM, bool Fast,
+                                      MachineCodeEmitter &MCE) {
+  // The JIT should use the static relocation model.
+  // FIXME: This should be moved to TargetJITInfo!!
+  setRelocationModel(Reloc::Static);
+
+  
+  
+  // Machine code emitter pass for PowerPC.
   PM.add(createPPCCodeEmitterPass(*this, MCE));
-  // Delete machine code for this function after emitting it
-  PM.add(createMachineCodeDeleter());
   return false;
 }
+


Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h
diff -u llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.22 llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.23
--- llvm/lib/Target/PowerPC/PPCTargetMachine.h:1.22	Thu Jun 15 20:37:27 2006
+++ llvm/lib/Target/PowerPC/PPCTargetMachine.h	Sun Sep  3 23:14:57 2006
@@ -28,7 +28,7 @@
 
 /// PPCTargetMachine - Common code between 32-bit and 64-bit PowerPC targets.
 ///
-class PPCTargetMachine : public TargetMachine {
+class PPCTargetMachine : public LLVMTargetMachine {
   PPCSubtarget        Subtarget;
   const TargetData    DataLayout;       // Calculates type size & alignment
   PPCInstrInfo        InstrInfo;
@@ -55,12 +55,16 @@
     return InstrItins;
   }
   
-
-  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
-                                   CodeGenFileType FileType, bool Fast);
   
-  bool addPassesToEmitMachineCode(FunctionPassManager &PM,
-                                  MachineCodeEmitter &MCE);
+  // 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);
+  virtual bool addObjectWriter(FunctionPassManager &PM, bool Fast,
+                               std::ostream &Out);
+  virtual bool addCodeEmitter(FunctionPassManager &PM, bool Fast,
+                              MachineCodeEmitter &MCE);
 };
 
 /// PPC32TargetMachine - PowerPC 32-bit target machine.






More information about the llvm-commits mailing list