Skip to content

Commit

Permalink
Move MachineRegisterInfo::setRegClass out of line.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69126 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Dan Gohman committed Apr 15, 2009
1 parent 352406d commit 6cfe4b0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
17 changes: 1 addition & 16 deletions include/llvm/CodeGen/MachineRegisterInfo.h
Expand Up @@ -152,23 +152,8 @@ class MachineRegisterInfo {

/// setRegClass - Set the register class of the specified virtual register.
///
void setRegClass(unsigned Reg, const TargetRegisterClass *RC) {
unsigned VR = Reg;
Reg -= TargetRegisterInfo::FirstVirtualRegister;
assert(Reg < VRegInfo.size() && "Invalid vreg!");
const TargetRegisterClass *OldRC = VRegInfo[Reg].first;
VRegInfo[Reg].first = RC;

// Remove from old register class's vregs list. This may be slow but
// fortunately this operation is rarely needed.
std::vector<unsigned> &VRegs = RegClass2VRegMap[OldRC->getID()];
std::vector<unsigned>::iterator I=std::find(VRegs.begin(), VRegs.end(), VR);
VRegs.erase(I);
void setRegClass(unsigned Reg, const TargetRegisterClass *RC);

// Add to new register class's vregs list.
RegClass2VRegMap[RC->getID()].push_back(VR);
}

/// createVirtualRegister - Create and return a new virtual register in the
/// function with the specified register class.
///
Expand Down
20 changes: 20 additions & 0 deletions lib/CodeGen/MachineRegisterInfo.cpp
Expand Up @@ -35,6 +35,26 @@ MachineRegisterInfo::~MachineRegisterInfo() {
delete [] PhysRegUseDefLists;
}

/// setRegClass - Set the register class of the specified virtual register.
///
void
MachineRegisterInfo::setRegClass(unsigned Reg, const TargetRegisterClass *RC) {
unsigned VR = Reg;
Reg -= TargetRegisterInfo::FirstVirtualRegister;
assert(Reg < VRegInfo.size() && "Invalid vreg!");
const TargetRegisterClass *OldRC = VRegInfo[Reg].first;
VRegInfo[Reg].first = RC;

// Remove from old register class's vregs list. This may be slow but
// fortunately this operation is rarely needed.
std::vector<unsigned> &VRegs = RegClass2VRegMap[OldRC->getID()];
std::vector<unsigned>::iterator I=std::find(VRegs.begin(), VRegs.end(), VR);
VRegs.erase(I);

// Add to new register class's vregs list.
RegClass2VRegMap[RC->getID()].push_back(VR);
}

/// createVirtualRegister - Create and return a new virtual register in the
/// function with the specified register class.
///
Expand Down

0 comments on commit 6cfe4b0

Please sign in to comment.