aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/SparcV9/RegAlloc
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-10-30 21:21:33 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-10-30 21:21:33 +0000
commit3ceac85296b5b0d6dd40daa49d529a56021dd51a (patch)
treea7833c0b40c8bc5bae6f9c825ea6aace7cc69be9 /lib/Target/SparcV9/RegAlloc
parent82c5eb7bc8f0cfe77938bbe107cf926680fc8c4d (diff)
downloadexternal_llvm-3ceac85296b5b0d6dd40daa49d529a56021dd51a.zip
external_llvm-3ceac85296b5b0d6dd40daa49d529a56021dd51a.tar.gz
external_llvm-3ceac85296b5b0d6dd40daa49d529a56021dd51a.tar.bz2
Include llvm/CodeGen/MachineCodeForInstruction.h. Use it to start
implementing verifySavedState(). In saveState(), use the new AllocInfo::AllocStateTy enum, and increment Insn each time through the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9617 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SparcV9/RegAlloc')
-rw-r--r--lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
index e70c90b..f387d19 100644
--- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
@@ -33,6 +33,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/CodeGen/FunctionLiveVarInfo.h"
#include "llvm/CodeGen/InstrSelection.h"
+#include "llvm/CodeGen/MachineCodeForInstruction.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionInfo.h"
#include "llvm/CodeGen/MachineInstr.h"
@@ -1144,26 +1145,25 @@ void PhyRegAlloc::saveState () {
std::vector<AllocInfo> &state = FnAllocState[Fn];
unsigned Insn = 0;
LiveRangeMapType::const_iterator HMIEnd = LRI->getLiveRangeMap ()->end ();
- for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II != IE; ++II)
+ for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II!=IE; ++II){
for (unsigned i = 0; i < (*II)->getNumOperands (); ++i) {
const Value *V = (*II)->getOperand (i);
// Don't worry about it unless it's something whose reg. we'll need.
if (!isa<Argument> (V) && !isa<Instruction> (V))
continue;
LiveRangeMapType::const_iterator HMI = LRI->getLiveRangeMap ()->find (V);
- static const unsigned NotAllocated = 0, Allocated = 1, Spilled = 2;
- unsigned AllocState = NotAllocated;
+ AllocInfo::AllocStateTy AllocState = AllocInfo::NotAllocated;
int Placement = -1;
if ((HMI != HMIEnd) && HMI->second) {
LiveRange *L = HMI->second;
assert ((L->hasColor () || L->isMarkedForSpill ())
&& "Live range exists but not colored or spilled");
if (L->hasColor()) {
- AllocState = Allocated;
+ AllocState = AllocInfo::Allocated;
Placement = MRI.getUnifiedRegNum (L->getRegClassID (),
L->getColor ());
} else if (L->isMarkedForSpill ()) {
- AllocState = Spilled;
+ AllocState = AllocInfo::Spilled;
assert (L->hasSpillOffset ()
&& "Live range marked for spill but has no spill offset");
Placement = L->getSpillOffFromFP ();
@@ -1171,6 +1171,8 @@ void PhyRegAlloc::saveState () {
}
state.push_back (AllocInfo (Insn, i, AllocState, Placement));
}
+ ++Insn;
+ }
}
@@ -1178,7 +1180,28 @@ void PhyRegAlloc::saveState () {
/// wrong. Only used when debugging.
///
void PhyRegAlloc::verifySavedState () {
- /// not yet implemented
+ std::vector<AllocInfo> &state = FnAllocState[Fn];
+ unsigned Insn = 0;
+ for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II!=IE; ++II) {
+ const Instruction *I = *II;
+ MachineCodeForInstruction &Instrs = MachineCodeForInstruction::get (I);
+ std::cerr << "Instruction:\n" << " " << *I << "\n"
+ << "MachineCodeForInstruction:\n";
+ for (unsigned i = 0, n = Instrs.size (); i != n; ++i)
+ std::cerr << " " << *Instrs[i] << "\n";
+ std::cerr << "FnAllocState:\n";
+ for (unsigned i = 0; i < state.size (); ++i) {
+ AllocInfo &S = state[i];
+ if (Insn == S.Instruction) {
+ std::cerr << " (Instruction " << S.Instruction
+ << ", Operand " << S.Operand
+ << ", AllocState " << S.allocStateToString ()
+ << ", Placement " << S.Placement << ")\n";
+ }
+ }
+ std::cerr << "----------\n";
+ ++Insn;
+ }
}
/// Finish the job of saveState(), by collapsing FnAllocState into an LLVM