mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-07 14:33:15 +00:00
Modify local register allocator to use the two-address instruction pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10513 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
71499ded4d
commit
9af9dbde7d
@ -19,6 +19,7 @@
|
|||||||
#include "llvm/CodeGen/SSARegMap.h"
|
#include "llvm/CodeGen/SSARegMap.h"
|
||||||
#include "llvm/CodeGen/MachineFrameInfo.h"
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
#include "llvm/CodeGen/LiveVariables.h"
|
#include "llvm/CodeGen/LiveVariables.h"
|
||||||
|
#include "llvm/CodeGen/TwoAddressInstructionPass.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "Support/CommandLine.h"
|
#include "Support/CommandLine.h"
|
||||||
@ -112,6 +113,7 @@ namespace {
|
|||||||
if (!DisableKill)
|
if (!DisableKill)
|
||||||
AU.addRequired<LiveVariables>();
|
AU.addRequired<LiveVariables>();
|
||||||
AU.addRequiredID(PHIEliminationID);
|
AU.addRequiredID(PHIEliminationID);
|
||||||
|
AU.addRequired<TwoAddressInstructionPass>();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,28 +573,13 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
unsigned DestVirtReg = MI->getOperand(i).getAllocatedRegNum();
|
unsigned DestVirtReg = MI->getOperand(i).getAllocatedRegNum();
|
||||||
unsigned DestPhysReg;
|
unsigned DestPhysReg;
|
||||||
|
|
||||||
// If DestVirtReg already has a value, forget about it. Why doesn't
|
// If DestVirtReg already has a value, use it.
|
||||||
// getReg do this right?
|
|
||||||
std::map<unsigned, unsigned>::iterator DestI =
|
std::map<unsigned, unsigned>::iterator DestI =
|
||||||
Virt2PhysRegMap.find(DestVirtReg);
|
Virt2PhysRegMap.find(DestVirtReg);
|
||||||
if (DestI != Virt2PhysRegMap.end()) {
|
if (DestI != Virt2PhysRegMap.end()) {
|
||||||
unsigned PhysReg = DestI->second;
|
DestPhysReg = DestI->second;
|
||||||
Virt2PhysRegMap.erase(DestI);
|
|
||||||
removePhysReg(PhysReg);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if (TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) && i == 0) {
|
|
||||||
// must be same register number as the first operand
|
|
||||||
// This maps a = b + c into b += c, and saves b into a's spot
|
|
||||||
assert(MI->getOperand(1).isPhysicalRegister() &&
|
|
||||||
MI->getOperand(1).getAllocatedRegNum() &&
|
|
||||||
MI->getOperand(1).isUse() &&
|
|
||||||
"Two address instruction invalid!");
|
|
||||||
DestPhysReg = MI->getOperand(1).getAllocatedRegNum();
|
|
||||||
|
|
||||||
liberatePhysReg(MBB, I, DestPhysReg);
|
|
||||||
assignVirtToPhysReg(DestVirtReg, DestPhysReg);
|
|
||||||
} else {
|
|
||||||
DestPhysReg = getReg(MBB, I, DestVirtReg);
|
DestPhysReg = getReg(MBB, I, DestVirtReg);
|
||||||
}
|
}
|
||||||
markVirtRegModified(DestVirtReg);
|
markVirtRegModified(DestVirtReg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user