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 83e95a7cb30ff0cb00cfbf9f218253ae01f904be..2c3be3dbcd656ade01cc2df6ae5056695679fe90 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 883efe2c1bab1ee54e16aa2026e19d736d25dbee..9ff9ecdab669020770cbc67ba89afe40a7eb4ad8 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 c30b306483e4b2a9bbf8dbb3b4d8cabca2283c1f..f821a77caa57408973ac5a1e7f7448b21d5149a7 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 80dc3c4a94ccbc1db05b26edee3bd50682fcd9a9..56c5367231248ca7de7a4fe32186011b15097716 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 c30b306483e4b2a9bbf8dbb3b4d8cabca2283c1f..f821a77caa57408973ac5a1e7f7448b21d5149a7 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 57f9272863c19c156d1622926f27819b0d8e333a..6a7ae6eabd78fb2f0261a425539efea52832bf83 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 3f1968de94d4504a22cc5690d18395ad65c96c7d..ed80828412f074c4a5c190ef8c8b684710d64312 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 b4f6fa497fbb901fd8adfd2d8068e43ef546d539..3232b9e613448e61b8fe3778121aa99fe5b3312c 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 34699c82f862fa1b881f41fb10cb24769286e635..da8505104d2ee7d6aefe520404c8f63c0954c713 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 765d455ab52f6c30e4396199f7594984a570176c..8b7a8db30033c24d661d9570c130a456d864a84c 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 aea36051b96dfe81d5eacd9072a462963efee663..0480a6ed8c02d11bb3b59a0168b71eea46af5e92 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 21f86a080a8c5ac8f7e57f1349b921aedfd80892..75c095c7a50d579963cd595622f1f3215f9630d9 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 71c57aab1001ad115ad2444396c6debeb3244188..47218e7488aee5599d9b83deaf3a012a389ffdf2 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 21f86a080a8c5ac8f7e57f1349b921aedfd80892..75c095c7a50d579963cd595622f1f3215f9630d9 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 71c57aab1001ad115ad2444396c6debeb3244188..47218e7488aee5599d9b83deaf3a012a389ffdf2 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 155d4d59ef152c781af86373d98ecc62991a7c86..287bf3d997dce915471127aea6ab0d681673e6ef 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 36bb26bb6f94b64d6111a30ca6122c9184ae2e1a..cde71992865ec9b6f1823f953b7cfd3c70ee54e9 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 fd5bcb268e323101056b298f68821b7b32275b40..dcf27ac17509cbefa8feb05b8bd3b8b61b0c9a30 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 60e782a0d65ef06c4ebe79d1762eef25a7151d0b..70b111c38bf3af57c0b5f9531b775b9e67025a41 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();