OSDN Git Service

Refactor the addPassesToEmitAssembly interface into a addPassesToEmitFile
authorChris Lattner <sabre@nondot.org>
Sat, 25 Jun 2005 02:48:37 +0000 (02:48 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 25 Jun 2005 02:48:37 +0000 (02:48 +0000)
interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22282 91177308-0d34-0410-b5e6-96231b3b80d8

19 files changed:
lib/Target/Alpha/AlphaTargetMachine.cpp
lib/Target/Alpha/AlphaTargetMachine.h
lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/CTargetMachine.h
lib/Target/CBackend/Writer.cpp
lib/Target/IA64/IA64TargetMachine.cpp
lib/Target/IA64/IA64TargetMachine.h
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/PowerPC/PowerPCTargetMachine.h
lib/Target/Skeleton/SkeletonTargetMachine.cpp
lib/Target/Skeleton/SkeletonTargetMachine.h
lib/Target/Sparc/SparcTargetMachine.cpp
lib/Target/Sparc/SparcTargetMachine.h
lib/Target/SparcV8/SparcV8TargetMachine.cpp
lib/Target/SparcV8/SparcV8TargetMachine.h
lib/Target/SparcV9/SparcV9TargetMachine.cpp
lib/Target/SparcV9/SparcV9TargetMachine.h
lib/Target/X86/X86TargetMachine.cpp
lib/Target/X86/X86TargetMachine.h

index 83e95a7..2c3be3d 100644 (file)
@@ -54,11 +54,13 @@ AlphaTargetMachine::AlphaTargetMachine( const Module &M, IntrinsicLowering *IL)
     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) //TODO: check these
 {}
 
-/// addPassesToEmitAssembly - Add passes to the specified pass manager
-/// to implement a static compiler for this target.
+/// addPassesToEmitFile - Add passes to the specified pass manager to implement
+/// a static compiler for this target.
 ///
-bool AlphaTargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                                   std::ostream &Out) {
+bool AlphaTargetMachine::addPassesToEmitFile(PassManager &PM,
+                                             std::ostream &Out,
+                                             CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
 
   if (EnableAlphaLSR) {
     PM.add(createLoopStrengthReducePass());
index 883efe2..9ff9ecd 100644 (file)
@@ -37,7 +37,8 @@ public:
     return &InstrInfo.getRegisterInfo();
   }
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 
   static unsigned getModuleMatchQuality(const Module &M);
 };
index c30b306..f821a77 100644 (file)
@@ -1725,7 +1725,10 @@ void CWriter::visitVAArgInst(VAArgInst &I) {
 //                       External Interface declaration
 //===----------------------------------------------------------------------===//
 
-bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
+bool CTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &o,
+                                         CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   PM.add(createLowerGCPass());
   PM.add(createLowerAllocationsPass(true));
   PM.add(createLowerInvokePass());
@@ -1733,5 +1736,3 @@ bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
   PM.add(new CWriter(o, getIntrinsicLowering()));
   return false;
 }
-
-// vim: sw=2
index 80dc3c4..56c5367 100644 (file)
@@ -24,7 +24,8 @@ struct CTargetMachine : public TargetMachine {
     TargetMachine("CBackend", IL, M) {}
 
   // This is the only thing that actually does anything here.
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 
   // This class always works, but shouldn't be the default in most cases.
   static unsigned getModuleMatchQuality(const Module &M) { return 1; }
index c30b306..f821a77 100644 (file)
@@ -1725,7 +1725,10 @@ void CWriter::visitVAArgInst(VAArgInst &I) {
 //                       External Interface declaration
 //===----------------------------------------------------------------------===//
 
-bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
+bool CTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &o,
+                                         CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   PM.add(createLowerGCPass());
   PM.add(createLowerAllocationsPass(true));
   PM.add(createLowerInvokePass());
@@ -1733,5 +1736,3 @@ bool CTargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &o) {
   PM.add(new CWriter(o, getIntrinsicLowering()));
   return false;
 }
-
-// vim: sw=2
index 57f9272..6a7ae6e 100644 (file)
@@ -77,10 +77,13 @@ IA64TargetMachine::IA64TargetMachine(const Module &M, IntrinsicLowering *IL)
     FrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0) { // FIXME? check this stuff
 }
 
-// addPassesToEmitAssembly - We currently use all of the same passes as the JIT
+// addPassesToEmitFile - We currently use all of the same passes as the JIT
 // does to emit statically compiled machine code.
-bool IA64TargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                                std::ostream &Out) {
+bool IA64TargetMachine::addPassesToEmitFile(PassManager &PM,
+                                            std::ostream &Out,
+                                                CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
index 3f1968d..ed80828 100644 (file)
@@ -35,7 +35,8 @@ public:
     return &InstrInfo.getRegisterInfo();
   }
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 
   static unsigned getModuleMatchQuality(const Module &M);
   static unsigned compileTimeMatchQuality(void);
index b4f6fa4..3232b9e 100644 (file)
@@ -73,11 +73,14 @@ unsigned PPC32TargetMachine::getJITMatchQuality() {
 #endif
 }
 
-/// addPassesToEmitAssembly - Add passes to the specified pass manager
-/// to implement a static compiler for this target.
+/// addPassesToEmitFile - Add passes to the specified pass manager to implement
+/// a static compiler for this target.
 ///
-bool PowerPCTargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                                   std::ostream &Out) {
+bool PowerPCTargetMachine::addPassesToEmitFile(PassManager &PM,
+                                               std::ostream &Out,
+                                                CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   bool LP64 = (0 != dynamic_cast<PPC64TargetMachine *>(this));
 
   if (EnablePPCLSR) {
index 34699c8..da85051 100644 (file)
@@ -32,7 +32,8 @@ protected:
 public:
   virtual const TargetFrameInfo  *getFrameInfo() const { return &FrameInfo; }
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 };
 
 } // end namespace llvm
index 765d455..8b7a8db 100644 (file)
@@ -34,11 +34,13 @@ SkeletonTargetMachine::SkeletonTargetMachine(const Module &M,
     FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4), JITInfo(*this) {
 }
 
-/// addPassesToEmitAssembly - Add passes to the specified pass manager
+/// addPassesToEmitFile - Add passes to the specified pass manager
 /// to implement a static compiler for this target.
 ///
-bool SkeletonTargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                                    std::ostream &Out) {
+bool SkeletonTargetMachine::addPassesToEmitFile(PassManager &PM,
+                                                std::ostream &Out,
+                                                CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
   // <insert instruction selector passes here>
   PM.add(createRegisterAllocator());
   PM.add(createPrologEpilogCodeInserter());
index aea3605..0480a6e 100644 (file)
@@ -42,7 +42,8 @@ namespace llvm {
     virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                             MachineCodeEmitter &MCE);
 
-    virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+    virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                     CodeGenFileType FileType);
   };
 
 } // end namespace llvm
index 21f86a0..75c095c 100644 (file)
@@ -59,11 +59,14 @@ unsigned SparcV8TargetMachine::getModuleMatchQuality(const Module &M) {
   return getJITMatchQuality()/2;
 }
 
-/// addPassesToEmitAssembly - Add passes to the specified pass manager
+/// addPassesToEmitFile - Add passes to the specified pass manager
 /// to implement a static compiler for this target.
 ///
-bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                                   std::ostream &Out) {
+bool SparcV8TargetMachine::addPassesToEmitFile(PassManager &PM,
+                                               std::ostream &Out,
+                                               CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
index 71c57aa..47218e7 100644 (file)
@@ -53,7 +53,8 @@ public:
   virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                           MachineCodeEmitter &MCE);
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 };
 
 } // end namespace llvm
index 21f86a0..75c095c 100644 (file)
@@ -59,11 +59,14 @@ unsigned SparcV8TargetMachine::getModuleMatchQuality(const Module &M) {
   return getJITMatchQuality()/2;
 }
 
-/// addPassesToEmitAssembly - Add passes to the specified pass manager
+/// addPassesToEmitFile - Add passes to the specified pass manager
 /// to implement a static compiler for this target.
 ///
-bool SparcV8TargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                                   std::ostream &Out) {
+bool SparcV8TargetMachine::addPassesToEmitFile(PassManager &PM,
+                                               std::ostream &Out,
+                                               CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
index 71c57aa..47218e7 100644 (file)
@@ -53,7 +53,8 @@ public:
   virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                           MachineCodeEmitter &MCE);
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 };
 
 } // end namespace llvm
index 155d4d5..287bf3d 100644 (file)
@@ -156,12 +156,14 @@ SparcV9TargetMachine::SparcV9TargetMachine(const Module &M,
     jitInfo(*this) {
 }
 
-/// addPassesToEmitAssembly - This method controls the entire code generation
+/// addPassesToEmitFile - This method controls the entire code generation
 /// process for the ultra sparc.
 ///
 bool
-SparcV9TargetMachine::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out)
-{
+SparcV9TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                                CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
index 36bb26b..cde7199 100644 (file)
@@ -43,7 +43,8 @@ public:
     return &instrInfo.getRegisterInfo();
   }
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
   virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                           MachineCodeEmitter &MCE);
 
index fd5bcb2..dcf27ac 100644 (file)
@@ -94,10 +94,12 @@ X86TargetMachine::X86TargetMachine(const Module &M, IntrinsicLowering *IL)
 }
 
 
-// addPassesToEmitAssembly - We currently use all of the same passes as the JIT
+// addPassesToEmitFile - We currently use all of the same passes as the JIT
 // does to emit statically compiled machine code.
-bool X86TargetMachine::addPassesToEmitAssembly(PassManager &PM,
-                                              std::ostream &Out) {
+bool X86TargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                           CodeGenFileType FileType) {
+  if (FileType != TargetMachine::AssemblyFile) return true;
+
   // FIXME: Implement efficient support for garbage collection intrinsics.
   PM.add(createLowerGCPass());
 
index 60e782a..70b111c 100644 (file)
@@ -46,7 +46,8 @@ public:
   virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM,
                                           MachineCodeEmitter &MCE);
 
-  virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out);
+  virtual bool addPassesToEmitFile(PassManager &PM, std::ostream &Out,
+                                   CodeGenFileType FileType);
 
   static unsigned getModuleMatchQuality(const Module &M);
   static unsigned getJITMatchQuality();