Refactor the addPassesToEmitAssembly interface into a addPassesToEmitFile
interface.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22282 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp
index 83e95a7..2c3be3d 100644
--- a/lib/Target/Alpha/AlphaTargetMachine.cpp
+++ b/lib/Target/Alpha/AlphaTargetMachine.cpp
@@ -54,11 +54,13 @@
     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());
diff --git a/lib/Target/Alpha/AlphaTargetMachine.h b/lib/Target/Alpha/AlphaTargetMachine.h
index 883efe2..9ff9ecd 100644
--- a/lib/Target/Alpha/AlphaTargetMachine.h
+++ b/lib/Target/Alpha/AlphaTargetMachine.h
@@ -37,7 +37,8 @@
     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);
 };
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index c30b306..f821a77 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -1725,7 +1725,10 @@
 //                       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 @@
   PM.add(new CWriter(o, getIntrinsicLowering()));
   return false;
 }
-
-// vim: sw=2
diff --git a/lib/Target/CBackend/CTargetMachine.h b/lib/Target/CBackend/CTargetMachine.h
index 80dc3c4..56c5367 100644
--- a/lib/Target/CBackend/CTargetMachine.h
+++ b/lib/Target/CBackend/CTargetMachine.h
@@ -24,7 +24,8 @@
     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; }
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index c30b306..f821a77 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -1725,7 +1725,10 @@
 //                       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 @@
   PM.add(new CWriter(o, getIntrinsicLowering()));
   return false;
 }
-
-// vim: sw=2
diff --git a/lib/Target/IA64/IA64TargetMachine.cpp b/lib/Target/IA64/IA64TargetMachine.cpp
index 57f9272..6a7ae6e 100644
--- a/lib/Target/IA64/IA64TargetMachine.cpp
+++ b/lib/Target/IA64/IA64TargetMachine.cpp
@@ -77,10 +77,13 @@
     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());
 
diff --git a/lib/Target/IA64/IA64TargetMachine.h b/lib/Target/IA64/IA64TargetMachine.h
index 3f1968d..ed80828 100644
--- a/lib/Target/IA64/IA64TargetMachine.h
+++ b/lib/Target/IA64/IA64TargetMachine.h
@@ -35,7 +35,8 @@
     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);
diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
index b4f6fa4..3232b9e 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -73,11 +73,14 @@
 #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) {
diff --git a/lib/Target/PowerPC/PowerPCTargetMachine.h b/lib/Target/PowerPC/PowerPCTargetMachine.h
index 34699c8..da85051 100644
--- a/lib/Target/PowerPC/PowerPCTargetMachine.h
+++ b/lib/Target/PowerPC/PowerPCTargetMachine.h
@@ -32,7 +32,8 @@
 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
diff --git a/lib/Target/Skeleton/SkeletonTargetMachine.cpp b/lib/Target/Skeleton/SkeletonTargetMachine.cpp
index 765d455..8b7a8db 100644
--- a/lib/Target/Skeleton/SkeletonTargetMachine.cpp
+++ b/lib/Target/Skeleton/SkeletonTargetMachine.cpp
@@ -34,11 +34,13 @@
     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());
diff --git a/lib/Target/Skeleton/SkeletonTargetMachine.h b/lib/Target/Skeleton/SkeletonTargetMachine.h
index aea3605..0480a6e 100644
--- a/lib/Target/Skeleton/SkeletonTargetMachine.h
+++ b/lib/Target/Skeleton/SkeletonTargetMachine.h
@@ -42,7 +42,8 @@
     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
diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp
index 21f86a0..75c095c 100644
--- a/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -59,11 +59,14 @@
   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());
 
diff --git a/lib/Target/Sparc/SparcTargetMachine.h b/lib/Target/Sparc/SparcTargetMachine.h
index 71c57aa..47218e7 100644
--- a/lib/Target/Sparc/SparcTargetMachine.h
+++ b/lib/Target/Sparc/SparcTargetMachine.h
@@ -53,7 +53,8 @@
   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
diff --git a/lib/Target/SparcV8/SparcV8TargetMachine.cpp b/lib/Target/SparcV8/SparcV8TargetMachine.cpp
index 21f86a0..75c095c 100644
--- a/lib/Target/SparcV8/SparcV8TargetMachine.cpp
+++ b/lib/Target/SparcV8/SparcV8TargetMachine.cpp
@@ -59,11 +59,14 @@
   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());
 
diff --git a/lib/Target/SparcV8/SparcV8TargetMachine.h b/lib/Target/SparcV8/SparcV8TargetMachine.h
index 71c57aa..47218e7 100644
--- a/lib/Target/SparcV8/SparcV8TargetMachine.h
+++ b/lib/Target/SparcV8/SparcV8TargetMachine.h
@@ -53,7 +53,8 @@
   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
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
index 155d4d5..287bf3d 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
@@ -156,12 +156,14 @@
     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());
 
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.h b/lib/Target/SparcV9/SparcV9TargetMachine.h
index 36bb26b..cde7199 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.h
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.h
@@ -43,7 +43,8 @@
     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);
 
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index fd5bcb2..dcf27ac 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -94,10 +94,12 @@
 }
 
 
-// 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());
 
diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h
index 60e782a..70b111c 100644
--- a/lib/Target/X86/X86TargetMachine.h
+++ b/lib/Target/X86/X86TargetMachine.h
@@ -46,7 +46,8 @@
   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();