X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FAllocationOrder.cpp;h=94754a0d35a81785c4d06d49e166ce6149bb87ad;hb=aa7744d75fc1769ccc12c65c07bb5b82afa58330;hp=87f64311a655a2b282ad78c30e56929e1d907149;hpb=b6632ba380cf624e60fe16b03d6e21b05dd07724;p=oota-llvm.git diff --git a/lib/CodeGen/AllocationOrder.cpp b/lib/CodeGen/AllocationOrder.cpp index 87f64311a65..94754a0d35a 100644 --- a/lib/CodeGen/AllocationOrder.cpp +++ b/lib/CodeGen/AllocationOrder.cpp @@ -14,10 +14,15 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "regalloc" #include "AllocationOrder.h" -#include "RegisterClassInfo.h" -#include "VirtRegMap.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/RegisterClassInfo.h" +#include "llvm/CodeGen/VirtRegMap.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetMachine.h" using namespace llvm; @@ -25,55 +30,19 @@ using namespace llvm; AllocationOrder::AllocationOrder(unsigned VirtReg, const VirtRegMap &VRM, const RegisterClassInfo &RegClassInfo) - : Begin(0), End(0), Pos(0), RCI(RegClassInfo), OwnedBegin(false) { - const TargetRegisterClass *RC = VRM.getRegInfo().getRegClass(VirtReg); - std::pair HintPair = - VRM.getRegInfo().getRegAllocationHint(VirtReg); - - // HintPair.second is a register, phys or virt. - Hint = HintPair.second; - - // Translate to physreg, or 0 if not assigned yet. - if (TargetRegisterInfo::isVirtualRegister(Hint)) - Hint = VRM.getPhys(Hint); - - // The first hint pair component indicates a target-specific hint. - if (HintPair.first) { - const TargetRegisterInfo &TRI = VRM.getTargetRegInfo(); - // The remaining allocation order may depend on the hint. - ArrayRef Order = - TRI.getRawAllocationOrder(RC, HintPair.first, Hint, - VRM.getMachineFunction()); - if (Order.empty()) - return; - - // Copy the allocation order with reserved registers removed. - OwnedBegin = true; - unsigned *P = new unsigned[Order.size()]; - Begin = P; - for (unsigned i = 0; i != Order.size(); ++i) - if (!RCI.isReserved(Order[i])) - *P++ = Order[i]; - End = P; - - // Target-dependent hints require resolution. - Hint = TRI.ResolveRegAllocHint(HintPair.first, Hint, - VRM.getMachineFunction()); - } else { - // If there is no hint or just a normal hint, use the cached allocation - // order from RegisterClassInfo. - ArrayRef O = RCI.getOrder(RC); - Begin = O.begin(); - End = O.end(); - } - - // The hint must be a valid physreg for allocation. - if (Hint && (!TargetRegisterInfo::isPhysicalRegister(Hint) || - !RC->contains(Hint) || RCI.isReserved(Hint))) - Hint = 0; -} - -AllocationOrder::~AllocationOrder() { - if (OwnedBegin) - delete [] Begin; + : Pos(0) { + const MachineFunction &MF = VRM.getMachineFunction(); + const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo(); + Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg)); + TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM); + rewind(); + + DEBUG({ + if (!Hints.empty()) { + dbgs() << "hints:"; + for (unsigned I = 0, E = Hints.size(); I != E; ++I) + dbgs() << ' ' << PrintReg(Hints[I], TRI); + dbgs() << '\n'; + } + }); }