From 8fc493430c2265da5b7c46cf50ab93a75a00b2f3 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Fri, 24 Oct 2003 21:21:58 +0000 Subject: [PATCH] Publicize the type of FnAllocState. Prototype option to save state in a global instead of as a Constant in the Module. (Turned off, for now, with the on/off switch welded in the off position. You get the idea.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9500 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 11 +++++++++++ lib/CodeGen/RegAlloc/PhyRegAlloc.h | 6 ++++-- lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 11 +++++++++++ lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h | 6 ++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 82ba0cc693c..e70c90b0394 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -48,6 +48,12 @@ RegAllocDebugLevel_t DEBUG_RA; +/// The reoptimizer wants to be able to grovel through the register +/// allocator's state after it has done its job. This is a hack. +/// +PhyRegAlloc::SavedStateMapTy ExportedFnAllocState; +const bool SaveStateToModule = false; + static cl::opt DRA_opt("dregalloc", cl::Hidden, cl::location(DEBUG_RA), cl::desc("enable register allocation debugging information"), @@ -1184,6 +1190,11 @@ bool PhyRegAlloc::doFinalization (Module &M) { if (!SaveRegAllocState) return false; // Nothing to do here, unless we're saving state. + if (!SaveStateToModule) { + ExportedFnAllocState = FnAllocState; + return false; + } + // Convert FnAllocState to a single Constant array and add it // to the Module. ArrayType *AT = ArrayType::get (AllocInfo::getConstantType (), 0); diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.h b/lib/CodeGen/RegAlloc/PhyRegAlloc.h index db23f481615..5fdd60f7ee0 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.h +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.h @@ -85,11 +85,11 @@ class PhyRegAlloc : public FunctionPass { AddedInstrns AddedInstrAtEntry; // to store instrns added at entry const LoopInfo *LoopDepthCalc; // to calculate loop depths - std::map > FnAllocState; - PhyRegAlloc(const PhyRegAlloc&); // DO NOT IMPLEMENT void operator=(const PhyRegAlloc&); // DO NOT IMPLEMENT public: + typedef std::map > SavedStateMapTy; + inline PhyRegAlloc (const TargetMachine &TM_) : TM (TM_), MRI (TM.getRegInfo ()), NumOfRegClasses (MRI.getNumOfRegClasses ()) { } @@ -113,6 +113,8 @@ public: inline RegClass *getRegClassByID(unsigned id) { return RegClassList[id]; } private: + SavedStateMapTy FnAllocState; + void addInterference(const Value *Def, const ValueSet *LVSet, bool isCallInst); bool markAllocatedRegs(MachineInstr* MInst); diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 82ba0cc693c..e70c90b0394 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -48,6 +48,12 @@ RegAllocDebugLevel_t DEBUG_RA; +/// The reoptimizer wants to be able to grovel through the register +/// allocator's state after it has done its job. This is a hack. +/// +PhyRegAlloc::SavedStateMapTy ExportedFnAllocState; +const bool SaveStateToModule = false; + static cl::opt DRA_opt("dregalloc", cl::Hidden, cl::location(DEBUG_RA), cl::desc("enable register allocation debugging information"), @@ -1184,6 +1190,11 @@ bool PhyRegAlloc::doFinalization (Module &M) { if (!SaveRegAllocState) return false; // Nothing to do here, unless we're saving state. + if (!SaveStateToModule) { + ExportedFnAllocState = FnAllocState; + return false; + } + // Convert FnAllocState to a single Constant array and add it // to the Module. ArrayType *AT = ArrayType::get (AllocInfo::getConstantType (), 0); diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h index db23f481615..5fdd60f7ee0 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h @@ -85,11 +85,11 @@ class PhyRegAlloc : public FunctionPass { AddedInstrns AddedInstrAtEntry; // to store instrns added at entry const LoopInfo *LoopDepthCalc; // to calculate loop depths - std::map > FnAllocState; - PhyRegAlloc(const PhyRegAlloc&); // DO NOT IMPLEMENT void operator=(const PhyRegAlloc&); // DO NOT IMPLEMENT public: + typedef std::map > SavedStateMapTy; + inline PhyRegAlloc (const TargetMachine &TM_) : TM (TM_), MRI (TM.getRegInfo ()), NumOfRegClasses (MRI.getNumOfRegClasses ()) { } @@ -113,6 +113,8 @@ public: inline RegClass *getRegClassByID(unsigned id) { return RegClassList[id]; } private: + SavedStateMapTy FnAllocState; + void addInterference(const Value *Def, const ValueSet *LVSet, bool isCallInst); bool markAllocatedRegs(MachineInstr* MInst); -- 2.34.1