Finegrainify namespacification, use new MRegisterInfo::isVirtualRegister

method

llvm-svn: 11037
This commit is contained in:
Chris Lattner 2004-01-31 21:27:19 +00:00
parent a2ef296994
commit c330b98c1c
2 changed files with 7 additions and 9 deletions

View File

@ -58,7 +58,7 @@ MachineBasicBlock *LiveVariables::getIndexMachineBasicBlock(unsigned Idx) {
} }
LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) { LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) {
assert(RegIdx >= MRegisterInfo::FirstVirtualRegister && assert(MRegisterInfo::isVirtualRegister(RegIdx) &&
"getVarInfo: not a virtual register!"); "getVarInfo: not a virtual register!");
RegIdx -= MRegisterInfo::FirstVirtualRegister; RegIdx -= MRegisterInfo::FirstVirtualRegister;
if (RegIdx >= VirtRegInfo.size()) { if (RegIdx >= VirtRegInfo.size()) {

View File

@ -25,8 +25,7 @@
#include "Support/Debug.h" #include "Support/Debug.h"
#include "Support/Statistic.h" #include "Support/Statistic.h"
#include <iostream> #include <iostream>
using namespace llvm;
namespace llvm {
namespace { namespace {
Statistic<> NumSpilled ("ra-local", "Number of registers spilled"); Statistic<> NumSpilled ("ra-local", "Number of registers spilled");
@ -75,14 +74,14 @@ namespace {
std::vector<bool> VirtRegModified; std::vector<bool> VirtRegModified;
void markVirtRegModified(unsigned Reg, bool Val = true) { void markVirtRegModified(unsigned Reg, bool Val = true) {
assert(Reg >= MRegisterInfo::FirstVirtualRegister && "Illegal VirtReg!"); assert(MRegisterInfo::isVirtualRegister(Reg) && "Illegal VirtReg!");
Reg -= MRegisterInfo::FirstVirtualRegister; Reg -= MRegisterInfo::FirstVirtualRegister;
if (VirtRegModified.size() <= Reg) VirtRegModified.resize(Reg+1); if (VirtRegModified.size() <= Reg) VirtRegModified.resize(Reg+1);
VirtRegModified[Reg] = Val; VirtRegModified[Reg] = Val;
} }
bool isVirtRegModified(unsigned Reg) const { bool isVirtRegModified(unsigned Reg) const {
assert(Reg >= MRegisterInfo::FirstVirtualRegister && "Illegal VirtReg!"); assert(MRegisterInfo::isVirtualRegister(Reg) && "Illegal VirtReg!");
assert(Reg - MRegisterInfo::FirstVirtualRegister < VirtRegModified.size() assert(Reg - MRegisterInfo::FirstVirtualRegister < VirtRegModified.size()
&& "Illegal virtual register!"); && "Illegal virtual register!");
return VirtRegModified[Reg - MRegisterInfo::FirstVirtualRegister]; return VirtRegModified[Reg - MRegisterInfo::FirstVirtualRegister];
@ -524,7 +523,7 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
KE = LV->killed_end(MI); KI != KE; ++KI) { KE = LV->killed_end(MI); KI != KE; ++KI) {
unsigned VirtReg = KI->second; unsigned VirtReg = KI->second;
unsigned PhysReg = VirtReg; unsigned PhysReg = VirtReg;
if (VirtReg >= MRegisterInfo::FirstVirtualRegister) { if (MRegisterInfo::isVirtualRegister(VirtReg)) {
std::map<unsigned, unsigned>::iterator I = std::map<unsigned, unsigned>::iterator I =
Virt2PhysRegMap.find(VirtReg); Virt2PhysRegMap.find(VirtReg);
assert(I != Virt2PhysRegMap.end()); assert(I != Virt2PhysRegMap.end());
@ -602,7 +601,7 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
KE = LV->dead_end(MI); KI != KE; ++KI) { KE = LV->dead_end(MI); KI != KE; ++KI) {
unsigned VirtReg = KI->second; unsigned VirtReg = KI->second;
unsigned PhysReg = VirtReg; unsigned PhysReg = VirtReg;
if (VirtReg >= MRegisterInfo::FirstVirtualRegister) { if (MRegisterInfo::isVirtualRegister(VirtReg)) {
std::map<unsigned, unsigned>::iterator I = std::map<unsigned, unsigned>::iterator I =
Virt2PhysRegMap.find(VirtReg); Virt2PhysRegMap.find(VirtReg);
assert(I != Virt2PhysRegMap.end()); assert(I != Virt2PhysRegMap.end());
@ -668,8 +667,7 @@ bool RA::runOnMachineFunction(MachineFunction &Fn) {
return true; return true;
} }
FunctionPass *createLocalRegisterAllocator() { FunctionPass *llvm::createLocalRegisterAllocator() {
return new RA(); return new RA();
} }
} // End llvm namespace