Move createVirtualRegister out-of-line.

llvm-svn: 60684
This commit is contained in:
Dan Gohman 2008-12-08 04:54:11 +00:00
parent 7954facae5
commit e4b1a93573
2 changed files with 19 additions and 13 deletions

View File

@ -164,19 +164,7 @@ public:
/// createVirtualRegister - Create and return a new virtual register in the /// createVirtualRegister - Create and return a new virtual register in the
/// function with the specified register class. /// function with the specified register class.
/// ///
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) { unsigned createVirtualRegister(const TargetRegisterClass *RegClass);
assert(RegClass && "Cannot create register without RegClass!");
// Add a reg, but keep track of whether the vector reallocated or not.
void *ArrayBase = VRegInfo.empty() ? 0 : &VRegInfo[0];
VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0));
if (!((&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1)))
// The vector reallocated, handle this now.
HandleVRegListReallocation();
unsigned VR = getLastVirtReg();
RegClass2VRegMap[RegClass->getID()].push_back(VR);
return VR;
}
/// getLastVirtReg - Return the highest currently assigned virtual register. /// getLastVirtReg - Return the highest currently assigned virtual register.
/// ///

View File

@ -35,6 +35,24 @@ MachineRegisterInfo::~MachineRegisterInfo() {
delete [] PhysRegUseDefLists; delete [] PhysRegUseDefLists;
} }
/// createVirtualRegister - Create and return a new virtual register in the
/// function with the specified register class.
///
unsigned
MachineRegisterInfo::createVirtualRegister(const TargetRegisterClass *RegClass){
assert(RegClass && "Cannot create register without RegClass!");
// Add a reg, but keep track of whether the vector reallocated or not.
void *ArrayBase = VRegInfo.empty() ? 0 : &VRegInfo[0];
VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0));
if (!((&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1)))
// The vector reallocated, handle this now.
HandleVRegListReallocation();
unsigned VR = getLastVirtReg();
RegClass2VRegMap[RegClass->getID()].push_back(VR);
return VR;
}
/// HandleVRegListReallocation - We just added a virtual register to the /// HandleVRegListReallocation - We just added a virtual register to the
/// VRegInfo info list and it reallocated. Update the use/def lists info /// VRegInfo info list and it reallocated. Update the use/def lists info
/// pointers. /// pointers.