From ba9e3e2fb13996ef568ee5688d9846b5271192a2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Feb 2004 04:08:37 +0000 Subject: [PATCH] Once we have a way to fold spill code reloads into instructions, we have a way to use it. :) llvm-svn: 11517 --- llvm/lib/CodeGen/RegAllocLocal.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/RegAllocLocal.cpp b/llvm/lib/CodeGen/RegAllocLocal.cpp index de12c6a57327..dc375cc54e69 100644 --- a/llvm/lib/CodeGen/RegAllocLocal.cpp +++ b/llvm/lib/CodeGen/RegAllocLocal.cpp @@ -487,9 +487,24 @@ MachineInstr *RA::reloadVirtReg(MachineBasicBlock &MBB, MachineInstr *MI, return MI; } - unsigned PhysReg = getReg(MBB, MI, VirtReg); - + // Otherwise, we need to fold it into the current instruction, or reload it. + // If we have registers available to hold the value, use them. const TargetRegisterClass *RC = MF->getSSARegMap()->getRegClass(VirtReg); + unsigned PhysReg = getFreeReg(RC); + + if (PhysReg == 0) { // No registers available... + /// If we can fold this spill into this instruction, do so now. + if (0) { + // TODO + return MI; + } + + // It looks like we can't fold this virtual register load into this + // instruction. Force some poor hapless value out of the register file to + // make room for the new register, and reload it. + PhysReg = getReg(MBB, MI, VirtReg); + } + int FrameIndex = getStackSpaceFor(VirtReg, RC); markVirtRegModified(VirtReg, false); // Note that this reg was just reloaded