From f48173a8751cb7d13db2a3fc7a128a246d45e39a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 4 Feb 2002 15:54:09 +0000 Subject: Convert RegisterAllocator interface to opaque pass type, so that users do not need to know _anything_ about RegAlloc to use it. Well in the end maybe. llvm-svn: 1681 --- llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 38 +++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp') diff --git a/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 7efb469b457..46f045c5e27 100644 --- a/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/llvm/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -32,21 +32,35 @@ cl::Enum 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. -- cgit v1.2.3