void RegAlloc::reset() { TRACE(1, ">>> regalloc reset! <<<\n"); m_epoch = 0; m_contToRegMap.clear(); // m_info is sparse. for (int i = 0; i < kMaxRegs; ++i) { m_info[i].m_epoch = 0; m_info[i].m_pReg = PhysReg(i); m_info[i].m_cont = RegContent(); m_info[i].m_type = KindOfInvalid; m_info[i].m_state = RegInfo::INVALID; } RegSet all = m_allRegs; PhysReg pr; for (int i = 0; all.findFirst(pr); i++) { all.remove(pr); physRegToInfo(pr)->m_pReg = PhysReg(pr); stateTransition(physRegToInfo(pr), RegInfo::FREE); // Put the most favorable register last, so it is picked first. m_lru[(m_numRegs - 1) - i] = pr; } m_branchSynced = false; verify(); }
void RegAlloc::invalidate(const Location& loc) { ContToRegMap::iterator i = m_contToRegMap.find(RegContent(loc)); if (i != m_contToRegMap.end()) { freeRegInfo(physRegToInfo(i->second)); } }
void RegAlloc::markAsClean(const Location& loc) { PhysReg pr = mapGet(m_contToRegMap, RegContent(loc), InvalidReg); if (pr != InvalidReg) { stateTransition(physRegToInfo(pr), RegInfo::CLEAN); } }
PhysReg RegAlloc::getReg(const Location& loc) { PhysReg reg = mapGet(m_contToRegMap, RegContent(loc), InvalidReg); lruFront(physRegToInfo(reg)); ASSERT(reg != InvalidReg); // Usage error; didn't call allocInputRegs()? return reg; }
void RegAlloc::cleanReg(PhysReg reg) { RegInfo* r = physRegToInfo(reg); if (r->m_state == RegInfo::DIRTY) { spill(r); stateTransition(r, RegInfo::CLEAN); } }