summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineRegisterInfo.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-12-08 04:54:11 +0000
committerDan Gohman <gohman@apple.com>2008-12-08 04:54:11 +0000
commit2e3e5bf42742a7421b513829101501f2de6d2b02 (patch)
tree91340e073919e4cf926b5c84b0872f1aa36aa744 /lib/CodeGen/MachineRegisterInfo.cpp
parentc93ced5b34b50a622ee8e49d90592f03ac7ff992 (diff)
downloadllvm-2e3e5bf42742a7421b513829101501f2de6d2b02.tar.gz
llvm-2e3e5bf42742a7421b513829101501f2de6d2b02.tar.bz2
llvm-2e3e5bf42742a7421b513829101501f2de6d2b02.tar.xz
Move createVirtualRegister out-of-line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r--lib/CodeGen/MachineRegisterInfo.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp
index 5e20689e0f..e5148e74be 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.