2010-12-10 19:36:02 +01:00
|
|
|
//===-- llvm/CodeGen/AllocationOrder.cpp - Allocation Order ---------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements an allocation order for virtual registers.
|
|
|
|
//
|
|
|
|
// The preferred allocation order for a virtual register depends on allocation
|
|
|
|
// hints and target hooks. The AllocationOrder class encapsulates all of that.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-03 23:51:04 +01:00
|
|
|
#define DEBUG_TYPE "regalloc"
|
2010-12-10 19:36:02 +01:00
|
|
|
#include "AllocationOrder.h"
|
2012-12-03 23:51:04 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2010-12-10 19:36:02 +01:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2012-06-06 22:29:31 +02:00
|
|
|
#include "llvm/CodeGen/RegisterClassInfo.h"
|
2012-11-28 20:13:06 +01:00
|
|
|
#include "llvm/CodeGen/VirtRegMap.h"
|
2012-12-03 23:51:04 +01:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2012-12-04 08:12:27 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2010-12-10 19:36:02 +01:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
// Compare VirtRegMap::getRegAllocPref().
|
|
|
|
AllocationOrder::AllocationOrder(unsigned VirtReg,
|
|
|
|
const VirtRegMap &VRM,
|
2011-06-03 22:34:53 +02:00
|
|
|
const RegisterClassInfo &RegClassInfo)
|
2012-12-03 23:51:04 +01:00
|
|
|
: 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);
|
2012-12-04 23:25:16 +01:00
|
|
|
rewind();
|
2010-12-10 19:36:02 +01:00
|
|
|
|
2012-12-03 23:51:04 +01:00
|
|
|
DEBUG({
|
|
|
|
if (!Hints.empty()) {
|
|
|
|
dbgs() << "hints:";
|
|
|
|
for (unsigned I = 0, E = Hints.size(); I != E; ++I)
|
|
|
|
dbgs() << ' ' << PrintReg(Hints[I], TRI);
|
|
|
|
dbgs() << '\n';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|