From e4b1a935739b609929b78f064aaf7f30494ddc9e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 8 Dec 2008 04:54:11 +0000 Subject: [PATCH] Move createVirtualRegister out-of-line. llvm-svn: 60684 --- include/llvm/CodeGen/MachineRegisterInfo.h | 14 +------------- lib/CodeGen/MachineRegisterInfo.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index 2f25a5e140b..f477e86554e 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -164,19 +164,7 @@ public: /// createVirtualRegister - Create and return a new virtual register in the /// function with the specified register class. /// - 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; - } + unsigned createVirtualRegister(const TargetRegisterClass *RegClass); /// getLastVirtReg - Return the highest currently assigned virtual register. /// diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp index 5e20689e0f6..e5148e74be8 100644 --- a/lib/CodeGen/MachineRegisterInfo.cpp +++ b/lib/CodeGen/MachineRegisterInfo.cpp @@ -35,6 +35,24 @@ MachineRegisterInfo::~MachineRegisterInfo() { 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 /// VRegInfo info list and it reallocated. Update the use/def lists info /// pointers.