From 4911c357e14a6972e7614c52ed87302b280f7c30 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 4 Feb 2002 17:39:42 +0000 Subject: [PATCH] Make LoopDeptCalculator be an internal artifact of how RegAlloc is implemented, do not expose it. Additionally, have it be auto generated by the pass framework for us. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1695 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 17 +++++++++++++---- lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 422541c5845..946a1e9c1b5 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -15,6 +15,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForMethod.h" #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" +#include "llvm/Analysis/LoopDepth.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineFrameInfo.h" #include "llvm/Method.h" @@ -50,12 +51,19 @@ namespace { MethodLiveVarInfo LVI(M); // Analyze live varaibles LVI.analyze(); - PhyRegAlloc PRA(M, Target, &LVI); // allocate registers + PhyRegAlloc PRA(M, Target, &LVI, + &getAnalysis()); PRA.allocateRegisters(); if (DEBUG_RA) cerr << "\nRegister allocation complete!\n"; return false; } + + virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Requires.push_back(cfg::LoopDepthCalculator::ID); + } }; } @@ -68,13 +76,14 @@ MethodPass *getRegisterAllocator(TargetMachine &T) { //---------------------------------------------------------------------------- PhyRegAlloc::PhyRegAlloc(Method *M, const TargetMachine& tm, - MethodLiveVarInfo *const Lvi) + MethodLiveVarInfo *Lvi, + cfg::LoopDepthCalculator *LDC) : TM(tm), Meth(M), mcInfo(MachineCodeForMethod::get(M)), LVI(Lvi), LRI(M, tm, RegClassList), MRI( tm.getRegInfo() ), NumOfRegClasses(MRI.getNumOfRegClasses()), - LoopDepthCalc(M) { + LoopDepthCalc(LDC) { // create each RegisterClass and put in RegClassList // @@ -272,7 +281,7 @@ void PhyRegAlloc::buildInterferenceGraphs() // find the 10^(loop_depth) of this BB // - BBLoopDepthCost = (unsigned) pow( 10.0, LoopDepthCalc.getLoopDepth(*BBI)); + BBLoopDepthCost = (unsigned) pow( 10.0, LoopDepthCalc->getLoopDepth(*BBI)); // get the iterator for machine instructions // diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 422541c5845..946a1e9c1b5 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -15,6 +15,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForMethod.h" #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" +#include "llvm/Analysis/LoopDepth.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineFrameInfo.h" #include "llvm/Method.h" @@ -50,12 +51,19 @@ namespace { MethodLiveVarInfo LVI(M); // Analyze live varaibles LVI.analyze(); - PhyRegAlloc PRA(M, Target, &LVI); // allocate registers + PhyRegAlloc PRA(M, Target, &LVI, + &getAnalysis()); PRA.allocateRegisters(); if (DEBUG_RA) cerr << "\nRegister allocation complete!\n"; return false; } + + virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires, + Pass::AnalysisSet &Destroyed, + Pass::AnalysisSet &Provided) { + Requires.push_back(cfg::LoopDepthCalculator::ID); + } }; } @@ -68,13 +76,14 @@ MethodPass *getRegisterAllocator(TargetMachine &T) { //---------------------------------------------------------------------------- PhyRegAlloc::PhyRegAlloc(Method *M, const TargetMachine& tm, - MethodLiveVarInfo *const Lvi) + MethodLiveVarInfo *Lvi, + cfg::LoopDepthCalculator *LDC) : TM(tm), Meth(M), mcInfo(MachineCodeForMethod::get(M)), LVI(Lvi), LRI(M, tm, RegClassList), MRI( tm.getRegInfo() ), NumOfRegClasses(MRI.getNumOfRegClasses()), - LoopDepthCalc(M) { + LoopDepthCalc(LDC) { // create each RegisterClass and put in RegClassList // @@ -272,7 +281,7 @@ void PhyRegAlloc::buildInterferenceGraphs() // find the 10^(loop_depth) of this BB // - BBLoopDepthCost = (unsigned) pow( 10.0, LoopDepthCalc.getLoopDepth(*BBI)); + BBLoopDepthCost = (unsigned) pow( 10.0, LoopDepthCalc->getLoopDepth(*BBI)); // get the iterator for machine instructions //