mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
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:
@@ -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.
|
||||
///
|
||||
|
Reference in New Issue
Block a user