mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-13 03:21:07 +00:00
Add a register class -> virtual registers map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f89cfaea7a
commit
11a26f3697
@ -33,6 +33,11 @@ class MachineRegisterInfo {
|
|||||||
/// start of the use/def list for the register.
|
/// start of the use/def list for the register.
|
||||||
std::vector<std::pair<const TargetRegisterClass*, MachineOperand*> > VRegInfo;
|
std::vector<std::pair<const TargetRegisterClass*, MachineOperand*> > VRegInfo;
|
||||||
|
|
||||||
|
/// RegClassVRegMap - This vector acts as a map from TargetRegisterClass to
|
||||||
|
/// virtual registers. For each target register class, it keeps a list of
|
||||||
|
/// virtual registers belonging to the class.
|
||||||
|
std::vector<std::vector<unsigned> > RegClass2VRegMap;
|
||||||
|
|
||||||
/// PhysRegUseDefLists - This is an array of the head of the use/def list for
|
/// PhysRegUseDefLists - This is an array of the head of the use/def list for
|
||||||
/// physical registers.
|
/// physical registers.
|
||||||
MachineOperand **PhysRegUseDefLists;
|
MachineOperand **PhysRegUseDefLists;
|
||||||
@ -130,6 +135,7 @@ public:
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// getRegClass - Return the register class of the specified virtual register.
|
/// getRegClass - Return the register class of the specified virtual register.
|
||||||
|
///
|
||||||
const TargetRegisterClass *getRegClass(unsigned Reg) const {
|
const TargetRegisterClass *getRegClass(unsigned Reg) const {
|
||||||
Reg -= TargetRegisterInfo::FirstVirtualRegister;
|
Reg -= TargetRegisterInfo::FirstVirtualRegister;
|
||||||
assert(Reg < VRegInfo.size() && "Invalid vreg!");
|
assert(Reg < VRegInfo.size() && "Invalid vreg!");
|
||||||
@ -137,10 +143,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// setRegClass - Set the register class of the specified virtual register.
|
/// setRegClass - Set the register class of the specified virtual register.
|
||||||
|
///
|
||||||
void setRegClass(unsigned Reg, const TargetRegisterClass *RC) {
|
void setRegClass(unsigned Reg, const TargetRegisterClass *RC) {
|
||||||
|
unsigned VR = Reg;
|
||||||
Reg -= TargetRegisterInfo::FirstVirtualRegister;
|
Reg -= TargetRegisterInfo::FirstVirtualRegister;
|
||||||
assert(Reg < VRegInfo.size() && "Invalid vreg!");
|
assert(Reg < VRegInfo.size() && "Invalid vreg!");
|
||||||
|
const TargetRegisterClass *OldRC = VRegInfo[Reg].first;
|
||||||
VRegInfo[Reg].first = RC;
|
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
|
/// createVirtualRegister - Create and return a new virtual register in the
|
||||||
@ -152,12 +170,12 @@ public:
|
|||||||
void *ArrayBase = VRegInfo.empty() ? 0 : &VRegInfo[0];
|
void *ArrayBase = VRegInfo.empty() ? 0 : &VRegInfo[0];
|
||||||
VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0));
|
VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0));
|
||||||
|
|
||||||
if (&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1)
|
if (!((&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1)))
|
||||||
return getLastVirtReg();
|
// The vector reallocated, handle this now.
|
||||||
|
|
||||||
// Otherwise, the vector reallocated, handle this now.
|
|
||||||
HandleVRegListReallocation();
|
HandleVRegListReallocation();
|
||||||
return getLastVirtReg();
|
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.
|
||||||
@ -166,6 +184,11 @@ public:
|
|||||||
return (unsigned)VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1;
|
return (unsigned)VRegInfo.size()+TargetRegisterInfo::FirstVirtualRegister-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getRegClassVirtRegs - Return the list of virtual registers of the given
|
||||||
|
/// target register class.
|
||||||
|
std::vector<unsigned> &getRegClassVirtRegs(const TargetRegisterClass *RC) {
|
||||||
|
return RegClass2VRegMap[RC->getID()];
|
||||||
|
}
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Physical Register Use Info
|
// Physical Register Use Info
|
||||||
|
@ -16,6 +16,7 @@ using namespace llvm;
|
|||||||
|
|
||||||
MachineRegisterInfo::MachineRegisterInfo(const TargetRegisterInfo &TRI) {
|
MachineRegisterInfo::MachineRegisterInfo(const TargetRegisterInfo &TRI) {
|
||||||
VRegInfo.reserve(256);
|
VRegInfo.reserve(256);
|
||||||
|
RegClass2VRegMap.resize(TRI.getNumRegClasses()+1); // RC ID starts at 1.
|
||||||
UsedPhysRegs.resize(TRI.getNumRegs());
|
UsedPhysRegs.resize(TRI.getNumRegs());
|
||||||
|
|
||||||
// Create the physreg use/def lists.
|
// Create the physreg use/def lists.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user