mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Switch AllocationOrder to using RegisterClassInfo instead of a BitVector
of reserved registers. Use RegisterClassInfo in RABasic as well. This slightly changes som allocation orders because RegisterClassInfo puts CSR aliases last. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132581 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d365fa9415
commit
5f2316a3b5
@ -15,6 +15,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "AllocationOrder.h"
|
||||
#include "RegisterClassInfo.h"
|
||||
#include "VirtRegMap.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
|
||||
@ -23,8 +24,8 @@ using namespace llvm;
|
||||
// Compare VirtRegMap::getRegAllocPref().
|
||||
AllocationOrder::AllocationOrder(unsigned VirtReg,
|
||||
const VirtRegMap &VRM,
|
||||
const BitVector &ReservedRegs)
|
||||
: Pos(0), Reserved(ReservedRegs) {
|
||||
const RegisterClassInfo &RegClassInfo)
|
||||
: Pos(0), RCI(RegClassInfo) {
|
||||
const TargetRegisterClass *RC = VRM.getRegInfo().getRegClass(VirtReg);
|
||||
std::pair<unsigned, unsigned> HintPair =
|
||||
VRM.getRegInfo().getRegAllocationHint(VirtReg);
|
||||
@ -47,7 +48,7 @@ AllocationOrder::AllocationOrder(unsigned VirtReg,
|
||||
|
||||
// The hint must be a valid physreg for allocation.
|
||||
if (Hint && (!TargetRegisterInfo::isPhysicalRegister(Hint) ||
|
||||
!RC->contains(Hint) || ReservedRegs.test(Hint)))
|
||||
!RC->contains(Hint) || RCI.isReserved(Hint)))
|
||||
Hint = 0;
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@ unsigned AllocationOrder::next() {
|
||||
// Then look at the order from TRI.
|
||||
while(Pos != End) {
|
||||
unsigned Reg = *Pos++;
|
||||
if (Reg != Hint && !Reserved.test(Reg))
|
||||
if (Reg != Hint && !RCI.isReserved(Reg))
|
||||
return Reg;
|
||||
}
|
||||
return 0;
|
||||
|
@ -19,14 +19,14 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BitVector;
|
||||
class RegisterClassInfo;
|
||||
class VirtRegMap;
|
||||
|
||||
class AllocationOrder {
|
||||
const unsigned *Begin;
|
||||
const unsigned *End;
|
||||
const unsigned *Pos;
|
||||
const BitVector &Reserved;
|
||||
const RegisterClassInfo &RCI;
|
||||
unsigned Hint;
|
||||
public:
|
||||
|
||||
@ -37,7 +37,7 @@ public:
|
||||
/// TargetRegisterInfo::getReservedRegs().
|
||||
AllocationOrder(unsigned VirtReg,
|
||||
const VirtRegMap &VRM,
|
||||
const BitVector &ReservedRegs);
|
||||
const RegisterClassInfo &RegClassInfo);
|
||||
|
||||
/// next - Return the next physical register in the allocation order, or 0.
|
||||
/// It is safe to call next again after it returned 0.
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "LiveIntervalUnion.h"
|
||||
#include "RegisterClassInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -91,6 +92,7 @@ protected:
|
||||
MachineRegisterInfo *MRI;
|
||||
VirtRegMap *VRM;
|
||||
LiveIntervals *LIS;
|
||||
RegisterClassInfo RegClassInfo;
|
||||
LiveUnionArray PhysReg2LiveUnion;
|
||||
|
||||
// Current queries, one per physreg. They must be reinitialized each time we
|
||||
|
@ -13,10 +13,10 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DEBUG_TYPE "regalloc"
|
||||
#include "RegAllocBase.h"
|
||||
#include "LiveDebugVariables.h"
|
||||
#include "LiveIntervalUnion.h"
|
||||
#include "LiveRangeEdit.h"
|
||||
#include "RegAllocBase.h"
|
||||
#include "RenderMachineFunction.h"
|
||||
#include "Spiller.h"
|
||||
#include "VirtRegMap.h"
|
||||
@ -85,7 +85,6 @@ class RABasic : public MachineFunctionPass, public RegAllocBase
|
||||
{
|
||||
// context
|
||||
MachineFunction *MF;
|
||||
BitVector ReservedRegs;
|
||||
|
||||
// analyses
|
||||
LiveStacks *LS;
|
||||
@ -235,6 +234,8 @@ void RegAllocBase::init(VirtRegMap &vrm, LiveIntervals &lis) {
|
||||
MRI = &vrm.getRegInfo();
|
||||
VRM = &vrm;
|
||||
LIS = &lis;
|
||||
RegClassInfo.runOnMachineFunction(vrm.getMachineFunction());
|
||||
|
||||
const unsigned NumRegs = TRI->getNumRegs();
|
||||
if (NumRegs != PhysReg2LiveUnion.numRegs()) {
|
||||
PhysReg2LiveUnion.init(UnionAllocator, NumRegs);
|
||||
@ -479,14 +480,11 @@ unsigned RABasic::selectOrSplit(LiveInterval &VirtReg,
|
||||
SmallVector<unsigned, 8> PhysRegSpillCands;
|
||||
|
||||
// Check for an available register in this class.
|
||||
const TargetRegisterClass *TRC = MRI->getRegClass(VirtReg.reg);
|
||||
|
||||
for (TargetRegisterClass::iterator I = TRC->allocation_order_begin(*MF),
|
||||
E = TRC->allocation_order_end(*MF);
|
||||
I != E; ++I) {
|
||||
|
||||
ArrayRef<unsigned> Order =
|
||||
RegClassInfo.getOrder(MRI->getRegClass(VirtReg.reg));
|
||||
for (ArrayRef<unsigned>::iterator I = Order.begin(), E = Order.end(); I != E;
|
||||
++I) {
|
||||
unsigned PhysReg = *I;
|
||||
if (ReservedRegs.test(PhysReg)) continue;
|
||||
|
||||
// Check interference and as a side effect, intialize queries for this
|
||||
// VirtReg and its aliases.
|
||||
@ -537,9 +535,6 @@ bool RABasic::runOnMachineFunction(MachineFunction &mf) {
|
||||
DEBUG(RMF = &getAnalysis<RenderMachineFunction>());
|
||||
|
||||
RegAllocBase::init(getAnalysis<VirtRegMap>(), getAnalysis<LiveIntervals>());
|
||||
|
||||
ReservedRegs = TRI->getReservedRegs(*MF);
|
||||
|
||||
SpillerInstance.reset(createInlineSpiller(*this, *MF, *VRM));
|
||||
|
||||
allocatePhysRegs();
|
||||
|
@ -62,7 +62,6 @@ class RAGreedy : public MachineFunctionPass,
|
||||
|
||||
// context
|
||||
MachineFunction *MF;
|
||||
BitVector ReservedRegs;
|
||||
|
||||
// analyses
|
||||
SlotIndexes *Indexes;
|
||||
@ -1410,7 +1409,7 @@ unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order,
|
||||
unsigned RAGreedy::selectOrSplit(LiveInterval &VirtReg,
|
||||
SmallVectorImpl<LiveInterval*> &NewVRegs) {
|
||||
// First try assigning a free register.
|
||||
AllocationOrder Order(VirtReg.reg, *VRM, ReservedRegs);
|
||||
AllocationOrder Order(VirtReg.reg, *VRM, RegClassInfo);
|
||||
if (unsigned PhysReg = tryAssign(VirtReg, Order, NewVRegs))
|
||||
return PhysReg;
|
||||
|
||||
@ -1472,7 +1471,6 @@ bool RAGreedy::runOnMachineFunction(MachineFunction &mf) {
|
||||
RegAllocBase::init(getAnalysis<VirtRegMap>(), getAnalysis<LiveIntervals>());
|
||||
Indexes = &getAnalysis<SlotIndexes>();
|
||||
DomTree = &getAnalysis<MachineDominatorTree>();
|
||||
ReservedRegs = TRI->getReservedRegs(*MF);
|
||||
SpillerInstance.reset(createInlineSpiller(*this, *MF, *VRM));
|
||||
Loops = &getAnalysis<MachineLoopInfo>();
|
||||
LoopRanges = &getAnalysis<MachineLoopRanges>();
|
||||
|
@ -12,7 +12,7 @@
|
||||
define weak arm_aapcs_vfpcc i32 @_ZNKSs7compareERKSs(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* %this, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* %__str) {
|
||||
; CHECK: _ZNKSs7compareERKSs:
|
||||
; CHECK: it eq
|
||||
; CHECK-NEXT: subeq r0, r{{[0-9]+}}, r{{[0-9]+}}
|
||||
; CHECK-NEXT: subeq{{(.w)?}} r0, r{{[0-9]+}}, r{{[0-9]+}}
|
||||
; CHECK-NEXT: ldmia.w sp!,
|
||||
entry:
|
||||
%0 = tail call arm_aapcs_vfpcc i32 @_ZNKSs4sizeEv(%"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* %this) ; <i32> [#uses=3]
|
||||
|
Loading…
Reference in New Issue
Block a user