Add facility for pre-RA passes
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 23 Apr 2008 18:22:28 +0000 (18:22 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 23 Apr 2008 18:22:28 +0000 (18:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50165 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetMachine.h
lib/CodeGen/LLVMTargetMachine.cpp

index 5c721a685cfd0037655c6cae9c5088cb7482d3d2..7c86a8d7dbe4476e968cf80d2dee0b0c686cb9ff 100644 (file)
@@ -280,7 +280,14 @@ public:
   virtual bool addInstSelector(PassManagerBase &PM, bool Fast) {
     return true;
   }
-  
+
+  /// addPreRegAllocPasses - This method may be implemented by targets that want
+  /// to run passes immediately before register allocation. This should return
+  /// true if -print-machineinstrs should print after these passes.
+  virtual bool addPreRegAlloc(PassManagerBase &PM, bool Fast) {
+    return false;
+  }
+
   /// addPostRegAllocPasses - This method may be implemented by targets that
   /// want to run passes after register allocation but before prolog-epilog
   /// insertion.  This should return true if -print-machineinstrs should print
index c65a6b9a795278a32878deb54d7a262e7908f9ed..3927eee5035ba3a7e17917ebd0bc14f0232827ee 100644 (file)
@@ -94,6 +94,10 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
   if (EnableSinking)
     PM.add(createMachineSinkingPass());
 
+  // Run pre-ra passes.
+  if (addPreRegAlloc(PM, Fast) && PrintMachineCode)
+    PM.add(createMachineFunctionPrinterPass(cerr));
+
   // Perform register allocation to convert to a concrete x86 representation
   PM.add(createRegisterAllocator());