Convert RegisterAllocator interface to opaque pass type, so that users do not
authorChris Lattner <sabre@nondot.org>
Mon, 4 Feb 2002 15:54:09 +0000 (15:54 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 4 Feb 2002 15:54:09 +0000 (15:54 +0000)
need to know _anything_ about RegAlloc to use it.  Well in the end maybe.

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

include/llvm/CodeGen/RegisterAllocation.h
lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9TargetMachine.cpp

index 161be18498bf7d997c69772f387d022c479b9d49..e552fbe887ab793b31ec8fc505cbe55bf0c04b47 100644 (file)
@@ -9,16 +9,12 @@
 
 #include "llvm/Pass.h"
 class TargetMachine;
+class MethodPass;
 
 //----------------------------------------------------------------------------
 // Entry point for register allocation for a module
 //----------------------------------------------------------------------------
 
-class RegisterAllocation : public MethodPass {
-  TargetMachine &Target;
-public:
-  inline RegisterAllocation(TargetMachine &T) : Target(T) {}
-  bool runOnMethod(Method *M);
-};
+MethodPass *getRegisterAllocator(TargetMachine &T);
 
 #endif
index 7efb469b457796043983740a8f72da825e83a107..46f045c5e276222a45c2d81c9d1e1c4e70dbd056 100644 (file)
@@ -32,21 +32,35 @@ cl::Enum<RegAllocDebugLevel_t> DEBUG_RA("dregalloc", cl::NoFlags,
   clEnumValN(RA_DEBUG_Verbose, "v", "enable extra debug output"), 0);
 
 
-bool RegisterAllocation::runOnMethod(Method *M) {
-  if (DEBUG_RA)
-    cerr << "\n******************** Method "<< M->getName()
-         << " ********************\n";
-    
-  MethodLiveVarInfo LVI(M);   // Analyze live varaibles
-  LVI.analyze();
+//----------------------------------------------------------------------------
+// RegisterAllocation pass front end...
+//----------------------------------------------------------------------------
+namespace {
+  class RegisterAllocator : public MethodPass {
+    TargetMachine &Target;
+  public:
+    inline RegisterAllocator(TargetMachine &T) : Target(T) {}
     
-  PhyRegAlloc PRA(M, Target, &LVI); // allocate registers
-  PRA.allocateRegisters();
-
-  if (DEBUG_RA) cerr << "\nRegister allocation complete!\n";
-  return false;
+    bool runOnMethod(Method *M) {
+      if (DEBUG_RA)
+        cerr << "\n******************** Method "<< M->getName()
+             << " ********************\n";
+      
+      MethodLiveVarInfo LVI(M);   // Analyze live varaibles
+      LVI.analyze();
+      
+      PhyRegAlloc PRA(M, Target, &LVI); // allocate registers
+      PRA.allocateRegisters();
+      
+      if (DEBUG_RA) cerr << "\nRegister allocation complete!\n";
+      return false;
+    }
+  };
 }
 
+MethodPass *getRegisterAllocator(TargetMachine &T) {
+  return new RegisterAllocator(T);
+}
 
 //----------------------------------------------------------------------------
 // Constructor: Init local composite objects and create register classes.
index 7efb469b457796043983740a8f72da825e83a107..46f045c5e276222a45c2d81c9d1e1c4e70dbd056 100644 (file)
@@ -32,21 +32,35 @@ cl::Enum<RegAllocDebugLevel_t> DEBUG_RA("dregalloc", cl::NoFlags,
   clEnumValN(RA_DEBUG_Verbose, "v", "enable extra debug output"), 0);
 
 
-bool RegisterAllocation::runOnMethod(Method *M) {
-  if (DEBUG_RA)
-    cerr << "\n******************** Method "<< M->getName()
-         << " ********************\n";
-    
-  MethodLiveVarInfo LVI(M);   // Analyze live varaibles
-  LVI.analyze();
+//----------------------------------------------------------------------------
+// RegisterAllocation pass front end...
+//----------------------------------------------------------------------------
+namespace {
+  class RegisterAllocator : public MethodPass {
+    TargetMachine &Target;
+  public:
+    inline RegisterAllocator(TargetMachine &T) : Target(T) {}
     
-  PhyRegAlloc PRA(M, Target, &LVI); // allocate registers
-  PRA.allocateRegisters();
-
-  if (DEBUG_RA) cerr << "\nRegister allocation complete!\n";
-  return false;
+    bool runOnMethod(Method *M) {
+      if (DEBUG_RA)
+        cerr << "\n******************** Method "<< M->getName()
+             << " ********************\n";
+      
+      MethodLiveVarInfo LVI(M);   // Analyze live varaibles
+      LVI.analyze();
+      
+      PhyRegAlloc PRA(M, Target, &LVI); // allocate registers
+      PRA.allocateRegisters();
+      
+      if (DEBUG_RA) cerr << "\nRegister allocation complete!\n";
+      return false;
+    }
+  };
 }
 
+MethodPass *getRegisterAllocator(TargetMachine &T) {
+  return new RegisterAllocator(T);
+}
 
 //----------------------------------------------------------------------------
 // Constructor: Init local composite objects and create register classes.
index b4e069453cc43f1a183736359b3c9fde5643967c..91e51d88d2840cc2a61b2d751d0a29751dd0e659 100644 (file)
@@ -260,7 +260,7 @@ void UltraSparc::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
 
   //PM.add(new InstructionScheduling(*this));
 
-  PM.add(new RegisterAllocation(*this));
+  PM.add(getRegisterAllocator(*this));
   
   //PM.add(new OptimizeLeafProcedures());
   //PM.add(new DeleteFallThroughBranches());