Add MachineRegisterInfo::constrainRegClass and use it in MachineCSE.

This function is intended to be used when inserting a machine instruction that
trivially restricts the legal registers, like LEA requiring a GR32_NOSP
argument.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115875 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen
2010-10-06 23:54:39 +00:00
parent 893ab5d701
commit bf4699c561
3 changed files with 24 additions and 7 deletions

View File

@@ -60,6 +60,20 @@ MachineRegisterInfo::setRegClass(unsigned Reg, const TargetRegisterClass *RC) {
RegClass2VRegMap[RC->getID()].push_back(VR);
}
const TargetRegisterClass *
MachineRegisterInfo::constrainRegClass(unsigned Reg,
const TargetRegisterClass *RC) {
const TargetRegisterClass *OldRC = getRegClass(Reg);
if (OldRC == RC)
return RC;
const TargetRegisterClass *NewRC = getCommonSubClass(OldRC, RC);
if (!NewRC)
return 0;
if (NewRC != OldRC)
setRegClass(Reg, NewRC);
return NewRC;
}
/// createVirtualRegister - Create and return a new virtual register in the
/// function with the specified register class.
///