X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FRegAllocBigBlock.cpp;h=91e4099d0c45761fea7ca9849b6d062d2984104b;hb=236aa8a5032282d8793b537c0f3f7ffb381a83d4;hp=f29b45eb142ec8be56c353bc4e4b4a3fbd1b6abc;hpb=63e3cd4e0f3731d6801ac24199652e4d7b4b3729;p=oota-llvm.git diff --git a/lib/CodeGen/RegAllocBigBlock.cpp b/lib/CodeGen/RegAllocBigBlock.cpp index f29b45eb142..91e4099d0c4 100644 --- a/lib/CodeGen/RegAllocBigBlock.cpp +++ b/lib/CodeGen/RegAllocBigBlock.cpp @@ -52,11 +52,11 @@ STATISTIC(NumStores, "Number of stores added"); STATISTIC(NumLoads , "Number of loads added"); STATISTIC(NumFolded, "Number of loads/stores folded into instructions"); -namespace { - static RegisterRegAlloc - bigBlockRegAlloc("bigblock", " Big-block register allocator", - createBigBlockRegisterAllocator); +static RegisterRegAlloc + bigBlockRegAlloc("bigblock", "Big-block register allocator", + createBigBlockRegisterAllocator); +namespace { /// VRegKeyInfo - Defines magic values required to use VirtRegs as DenseMap /// keys. struct VRegKeyInfo { @@ -82,7 +82,7 @@ namespace { class VISIBILITY_HIDDEN RABigBlock : public MachineFunctionPass { public: static char ID; - RABigBlock() : MachineFunctionPass((intptr_t)&ID) {} + RABigBlock() : MachineFunctionPass(&ID) {} private: /// TM - For getting at TargetMachine info /// @@ -385,7 +385,7 @@ bool RABigBlock::isPhysRegAvailable(unsigned PhysReg) const { // not free! for (const unsigned *AliasSet = RegInfo->getAliasSet(PhysReg); *AliasSet; ++AliasSet) - if (PhysRegsUsed[*AliasSet] != -1) // Aliased register in use? + if (PhysRegsUsed[*AliasSet] >= 0) // Aliased register in use? return false; // Can't use this reg then. return true; } @@ -518,7 +518,7 @@ MachineInstr *RABigBlock::reloadVirtReg(MachineBasicBlock &MBB, MachineInstr *MI assignVirtToPhysReg(VirtReg, PhysReg); } else { // no free registers available. // try to fold the spill into the instruction - SmallVector Ops; + SmallVector Ops; Ops.push_back(OpNum); if(MachineInstr* FMI = TII->foldMemoryOperand(*MF, MI, Ops, FrameIndex)) { ++NumFolded; @@ -560,7 +560,7 @@ void RABigBlock::FillVRegReadTable(MachineBasicBlock &MBB) { for (unsigned i = 0; i != MI->getNumOperands(); ++i) { MachineOperand& MO = MI->getOperand(i); // look for vreg reads.. - if (MO.isRegister() && !MO.isDef() && MO.getReg() && + if (MO.isReg() && !MO.isDef() && MO.getReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg())) { // ..and add them to the read table. VRegTimes* &Times = VRegReadTable[MO.getReg()]; @@ -589,7 +589,7 @@ void RABigBlock::FillVRegReadTable(MachineBasicBlock &MBB) { static bool isReadModWriteImplicitKill(MachineInstr *MI, unsigned Reg) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand& MO = MI->getOperand(i); - if (MO.isRegister() && MO.getReg() == Reg && MO.isImplicit() && + if (MO.isReg() && MO.getReg() == Reg && MO.isImplicit() && MO.isDef() && !MO.isDead()) return true; } @@ -601,7 +601,7 @@ static bool isReadModWriteImplicitKill(MachineInstr *MI, unsigned Reg) { static bool isReadModWriteImplicitDef(MachineInstr *MI, unsigned Reg) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand& MO = MI->getOperand(i); - if (MO.isRegister() && MO.getReg() == Reg && MO.isImplicit() && + if (MO.isReg() && MO.getReg() == Reg && MO.isImplicit() && !MO.isDef() && MO.isKill()) return true; } @@ -653,7 +653,7 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { SmallVector Kills; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand& MO = MI->getOperand(i); - if (MO.isRegister() && MO.isKill()) { + if (MO.isReg() && MO.isKill()) { if (!MO.isImplicit()) Kills.push_back(MO.getReg()); else if (!isReadModWriteImplicitKill(MI, MO.getReg())) @@ -673,7 +673,7 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { for (unsigned i = 0; i != MI->getNumOperands(); ++i) { MachineOperand& MO = MI->getOperand(i); // here we are looking for only used operands (never def&use) - if (MO.isRegister() && !MO.isDef() && MO.getReg() && !MO.isImplicit() && + if (MO.isReg() && !MO.isDef() && MO.getReg() && !MO.isImplicit() && TargetRegisterInfo::isVirtualRegister(MO.getReg())) MI = reloadVirtReg(MBB, MI, i); } @@ -695,7 +695,7 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { // Unallocatable register dead, ignore. continue; } else { - assert(!PhysRegsUsed[PhysReg] || PhysRegsUsed[PhysReg] == -1 && + assert((!PhysRegsUsed[PhysReg] || PhysRegsUsed[PhysReg] == -1) && "Silently clearing a virtual register?"); } @@ -719,7 +719,7 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { // are defined, and marking explicit destinations in the PhysRegsUsed map. for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand& MO = MI->getOperand(i); - if (MO.isRegister() && MO.isDef() && !MO.isImplicit() && MO.getReg() && + if (MO.isReg() && MO.isDef() && !MO.isImplicit() && MO.getReg() && TargetRegisterInfo::isPhysicalRegister(MO.getReg())) { unsigned Reg = MO.getReg(); if (PhysRegsUsed[Reg] == -2) continue; // Something like ESP. @@ -764,7 +764,7 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { SmallVector DeadDefs; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand& MO = MI->getOperand(i); - if (MO.isRegister() && MO.isDead()) + if (MO.isReg() && MO.isDead()) DeadDefs.push_back(MO.getReg()); } @@ -775,7 +775,7 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { // for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { MachineOperand& MO = MI->getOperand(i); - if (MO.isRegister() && MO.isDef() && MO.getReg() && + if (MO.isReg() && MO.isDef() && MO.getReg() && TargetRegisterInfo::isVirtualRegister(MO.getReg())) { unsigned DestVirtReg = MO.getReg(); unsigned DestPhysReg; @@ -808,14 +808,14 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { if (PhysReg) { DOUT << " Register " << RegInfo->getName(PhysReg) << " [%reg" << VirtReg - << "] is never used, removing it frame live list\n"; + << "] is never used, removing it from live set\n"; removePhysReg(PhysReg); for (const unsigned *AliasSet = RegInfo->getAliasSet(PhysReg); *AliasSet; ++AliasSet) { if (PhysRegsUsed[*AliasSet] != -2) { DOUT << " Register " << RegInfo->getName(*AliasSet) << " [%reg" << *AliasSet - << "] is never used, removing it frame live list\n"; + << "] is never used, removing it from live set\n"; removePhysReg(*AliasSet); } } @@ -823,8 +823,9 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { } // Finally, if this is a noop copy instruction, zap it. - unsigned SrcReg, DstReg; - if (TII.isMoveInstr(*MI, SrcReg, DstReg) && SrcReg == DstReg) + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; + if (TII.isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) && + SrcReg == DstReg) MBB.erase(MI); } @@ -832,11 +833,12 @@ void RABigBlock::AllocateBasicBlock(MachineBasicBlock &MBB) { // Spill all physical registers holding virtual registers now. for (unsigned i = 0, e = RegInfo->getNumRegs(); i != e; ++i) - if (PhysRegsUsed[i] != -1 && PhysRegsUsed[i] != -2) + if (PhysRegsUsed[i] != -1 && PhysRegsUsed[i] != -2) { if (unsigned VirtReg = PhysRegsUsed[i]) spillVirtReg(MBB, MI, VirtReg, i); else removePhysReg(i); + } } /// runOnMachineFunction - Register allocate the whole function