mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-13 06:34:24 +00:00
[RegBankSelect] Use RegisterBankInfo applyMapping method.
The RegBankSelect pass can now rely on the target to do the remapping of the instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272169 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8a025f711a
commit
75072bc260
@ -115,8 +115,6 @@ void RegBankSelect::repairReg(
|
|||||||
// the source of the repairing.
|
// the source of the repairing.
|
||||||
unsigned Src = MO.getReg();
|
unsigned Src = MO.getReg();
|
||||||
unsigned Dst = *NewVRegs.begin();
|
unsigned Dst = *NewVRegs.begin();
|
||||||
if (ValMapping.BreakDown.size() == 1)
|
|
||||||
MO.setReg(Dst);
|
|
||||||
|
|
||||||
// If we repair a definition, swap the source and destination for
|
// If we repair a definition, swap the source and destination for
|
||||||
// the repairing.
|
// the repairing.
|
||||||
@ -460,13 +458,10 @@ RegBankSelect::MappingCost RegBankSelect::computeMapping(
|
|||||||
void RegBankSelect::applyMapping(
|
void RegBankSelect::applyMapping(
|
||||||
MachineInstr &MI, const RegisterBankInfo::InstructionMapping &InstrMapping,
|
MachineInstr &MI, const RegisterBankInfo::InstructionMapping &InstrMapping,
|
||||||
SmallVectorImpl<RegBankSelect::RepairingPlacement> &RepairPts) {
|
SmallVectorImpl<RegBankSelect::RepairingPlacement> &RepairPts) {
|
||||||
assert(InstrMapping.getID() == RegisterBankInfo::DefaultMappingID &&
|
|
||||||
"Rewriting of MI not implemented yet");
|
|
||||||
// First, place the repairing code.
|
|
||||||
bool NeedRewrite = false;
|
|
||||||
// OpdMapper will hold all the information needed for the rewritting.
|
// OpdMapper will hold all the information needed for the rewritting.
|
||||||
RegisterBankInfo::OperandsMapper OpdMapper(MI, InstrMapping, *MRI);
|
RegisterBankInfo::OperandsMapper OpdMapper(MI, InstrMapping, *MRI);
|
||||||
|
|
||||||
|
// First, place the repairing code.
|
||||||
for (RepairingPlacement &RepairPt : RepairPts) {
|
for (RepairingPlacement &RepairPt : RepairPts) {
|
||||||
assert(RepairPt.canMaterialize() &&
|
assert(RepairPt.canMaterialize() &&
|
||||||
RepairPt.getKind() != RepairingPlacement::Impossible &&
|
RepairPt.getKind() != RepairingPlacement::Impossible &&
|
||||||
@ -479,7 +474,6 @@ void RegBankSelect::applyMapping(
|
|||||||
InstrMapping.getOperandMapping(OpIdx);
|
InstrMapping.getOperandMapping(OpIdx);
|
||||||
unsigned BreakDownSize = ValMapping.BreakDown.size();
|
unsigned BreakDownSize = ValMapping.BreakDown.size();
|
||||||
unsigned Reg = MO.getReg();
|
unsigned Reg = MO.getReg();
|
||||||
NeedRewrite = BreakDownSize != 1;
|
|
||||||
|
|
||||||
switch (RepairPt.getKind()) {
|
switch (RepairPt.getKind()) {
|
||||||
case RepairingPlacement::Reassign:
|
case RepairingPlacement::Reassign:
|
||||||
@ -496,8 +490,7 @@ void RegBankSelect::applyMapping(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Second, rewrite the instruction.
|
// Second, rewrite the instruction.
|
||||||
(void)NeedRewrite;
|
RBI->applyMapping(OpdMapper);
|
||||||
assert(!NeedRewrite && "Not implemented yet");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegBankSelect::assignInstr(MachineInstr &MI) {
|
void RegBankSelect::assignInstr(MachineInstr &MI) {
|
||||||
@ -544,8 +537,12 @@ bool RegBankSelect::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Set a sensible insertion point so that subsequent calls to
|
// Set a sensible insertion point so that subsequent calls to
|
||||||
// MIRBuilder.
|
// MIRBuilder.
|
||||||
MIRBuilder.setMBB(*MBB);
|
MIRBuilder.setMBB(*MBB);
|
||||||
for (MachineInstr &MI : *MBB)
|
for (MachineBasicBlock::iterator MII = MBB->begin(), End = MBB->end();
|
||||||
assignInstr(MI);
|
MII != End;) {
|
||||||
|
// MI might be invalidated by the assignment, so move the
|
||||||
|
// iterator before hand.
|
||||||
|
assignInstr(*MII++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OptMode = SaveOptMode;
|
OptMode = SaveOptMode;
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user