aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLocal.cpp
diff options
context:
space:
mode:
authorAlkis Evlogimenos <alkis@evlogimenos.com>2003-12-18 13:08:52 +0000
committerAlkis Evlogimenos <alkis@evlogimenos.com>2003-12-18 13:08:52 +0000
commit9af9dbde7d8b7c1e8ba8548bc5dc44927857b9f3 (patch)
tree54e20e7ff1b3178829f283f8a957fb6efb5aecac /lib/CodeGen/RegAllocLocal.cpp
parent71499ded4d76233f3b605638b539548bea8bb2f1 (diff)
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
Diffstat (limited to 'lib/CodeGen/RegAllocLocal.cpp')
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp23
1 files changed, 5 insertions, 18 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index 425c9d42d4..d3e80e08e8 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -19,6 +19,7 @@
#include "llvm/CodeGen/SSARegMap.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/LiveVariables.h"
+#include "llvm/CodeGen/TwoAddressInstructionPass.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "Support/CommandLine.h"
@@ -112,6 +113,7 @@ namespace {
if (!DisableKill)
AU.addRequired<LiveVariables>();
AU.addRequiredID(PHIEliminationID);
+ AU.addRequired<TwoAddressInstructionPass>();
MachineFunctionPass::getAnalysisUsage(AU);
}
@@ -571,28 +573,13 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
unsigned DestVirtReg = MI->getOperand(i).getAllocatedRegNum();
unsigned DestPhysReg;
- // If DestVirtReg already has a value, forget about it. Why doesn't
- // getReg do this right?
+ // If DestVirtReg already has a value, use it.
std::map<unsigned, unsigned>::iterator DestI =
Virt2PhysRegMap.find(DestVirtReg);
if (DestI != Virt2PhysRegMap.end()) {
- unsigned PhysReg = DestI->second;
- Virt2PhysRegMap.erase(DestI);
- removePhysReg(PhysReg);
+ DestPhysReg = DestI->second;
}
-
- 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 {
+ else {
DestPhysReg = getReg(MBB, I, DestVirtReg);
}
markVirtRegModified(DestVirtReg);