From 5ab13e2deb8f904ef2a233749193fa09ea7013c4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 22 Mar 2010 18:43:53 -0700 Subject: ruby: style pass --- src/mem/ruby/system/PerfectCacheMemory.hh | 216 +++++++++++++----------------- 1 file changed, 94 insertions(+), 122 deletions(-) (limited to 'src/mem/ruby/system/PerfectCacheMemory.hh') diff --git a/src/mem/ruby/system/PerfectCacheMemory.hh b/src/mem/ruby/system/PerfectCacheMemory.hh index 6561d028b..f1fb8b2e9 100644 --- a/src/mem/ruby/system/PerfectCacheMemory.hh +++ b/src/mem/ruby/system/PerfectCacheMemory.hh @@ -1,4 +1,3 @@ - /* * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * All rights reserved. @@ -27,215 +26,188 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - * PerfectCacheMemory.hh - * - * Description: - * - * $Id$ - * - */ - -#ifndef PERFECTCACHEMEMORY_H -#define PERFECTCACHEMEMORY_H +#ifndef __MEM_RUBY_SYSTEM_PERFECTCACHEMEMORY_HH__ +#define __MEM_RUBY_SYSTEM_PERFECTCACHEMEMORY_HH__ -#include "mem/ruby/common/Global.hh" #include "mem/gems_common/Map.hh" #include "mem/protocol/AccessPermission.hh" #include "mem/ruby/common/Address.hh" +#include "mem/ruby/common/Global.hh" template -class PerfectCacheLineState { -public: - PerfectCacheLineState() { m_permission = AccessPermission_NUM; } - AccessPermission m_permission; - ENTRY m_entry; +struct PerfectCacheLineState +{ + PerfectCacheLineState() { m_permission = AccessPermission_NUM; } + AccessPermission m_permission; + ENTRY m_entry; }; template -extern inline -ostream& operator<<(ostream& out, const PerfectCacheLineState& obj) +inline ostream& +operator<<(ostream& out, const PerfectCacheLineState& obj) { - return out; + return out; } template -class PerfectCacheMemory { -public: - - // Constructors - PerfectCacheMemory(); - - // Destructor - //~PerfectCacheMemory(); - - // Public Methods +class PerfectCacheMemory +{ + public: + PerfectCacheMemory(); - static void printConfig(ostream& out); + static void printConfig(ostream& out); - // perform a cache access and see if we hit or not. Return true on - // a hit. - bool tryCacheAccess(const CacheMsg& msg, bool& block_stc, ENTRY*& entry); + // perform a cache access and see if we hit or not. Return true + // on a hit. + bool tryCacheAccess(const CacheMsg& msg, bool& block_stc, ENTRY*& entry); - // tests to see if an address is present in the cache - bool isTagPresent(const Address& address) const; + // tests to see if an address is present in the cache + bool isTagPresent(const Address& address) const; - // Returns true if there is: - // a) a tag match on this address or there is - // b) an Invalid line in the same cache "way" - bool cacheAvail(const Address& address) const; + // Returns true if there is: + // a) a tag match on this address or there is + // b) an Invalid line in the same cache "way" + bool cacheAvail(const Address& address) const; - // find an Invalid entry and sets the tag appropriate for the address - void allocate(const Address& address); + // find an Invalid entry and sets the tag appropriate for the address + void allocate(const Address& address); - void deallocate(const Address& address); + void deallocate(const Address& address); - // Returns with the physical address of the conflicting cache line - Address cacheProbe(const Address& newAddress) const; + // Returns with the physical address of the conflicting cache line + Address cacheProbe(const Address& newAddress) const; - // looks an address up in the cache - ENTRY& lookup(const Address& address); - const ENTRY& lookup(const Address& address) const; + // looks an address up in the cache + ENTRY& lookup(const Address& address); + const ENTRY& lookup(const Address& address) const; - // Get/Set permission of cache block - AccessPermission getPermission(const Address& address) const; - void changePermission(const Address& address, AccessPermission new_perm); + // Get/Set permission of cache block + AccessPermission getPermission(const Address& address) const; + void changePermission(const Address& address, AccessPermission new_perm); - // Print cache contents - void print(ostream& out) const; -private: - // Private Methods + // Print cache contents + void print(ostream& out) const; - // Private copy constructor and assignment operator - PerfectCacheMemory(const PerfectCacheMemory& obj); - PerfectCacheMemory& operator=(const PerfectCacheMemory& obj); + private: + // Private copy constructor and assignment operator + PerfectCacheMemory(const PerfectCacheMemory& obj); + PerfectCacheMemory& operator=(const PerfectCacheMemory& obj); - // Data Members (m_prefix) - Map > m_map; + // Data Members (m_prefix) + Map > m_map; }; -// Output operator declaration -//ostream& operator<<(ostream& out, const PerfectCacheMemory& obj); - -// ******************* Definitions ******************* - -// Output operator definition template -extern inline -ostream& operator<<(ostream& out, const PerfectCacheMemory& obj) +inline ostream& +operator<<(ostream& out, const PerfectCacheMemory& obj) { - obj.print(out); - out << flush; - return out; + obj.print(out); + out << flush; + return out; } - -// **************************************************************** - template -extern inline +inline PerfectCacheMemory::PerfectCacheMemory() { } -// STATIC METHODS - template -extern inline -void PerfectCacheMemory::printConfig(ostream& out) +inline void +PerfectCacheMemory::printConfig(ostream& out) { } -// PUBLIC METHODS - template -extern inline -bool PerfectCacheMemory::tryCacheAccess(const CacheMsg& msg, bool& block_stc, ENTRY*& entry) +inline bool +PerfectCacheMemory::tryCacheAccess(const CacheMsg& msg, + bool& block_stc, ENTRY*& entry) { - ERROR_MSG("not implemented"); + ERROR_MSG("not implemented"); } // tests to see if an address is present in the cache template -extern inline -bool PerfectCacheMemory::isTagPresent(const Address& address) const +inline bool +PerfectCacheMemory::isTagPresent(const Address& address) const { - return m_map.exist(line_address(address)); + return m_map.exist(line_address(address)); } template -extern inline -bool PerfectCacheMemory::cacheAvail(const Address& address) const +inline bool +PerfectCacheMemory::cacheAvail(const Address& address) const { - return true; + return true; } // find an Invalid or already allocated entry and sets the tag // appropriate for the address template -extern inline -void PerfectCacheMemory::allocate(const Address& address) +inline void +PerfectCacheMemory::allocate(const Address& address) { - PerfectCacheLineState line_state; - line_state.m_permission = AccessPermission_Busy; - line_state.m_entry = ENTRY(); - m_map.add(line_address(address), line_state); + PerfectCacheLineState line_state; + line_state.m_permission = AccessPermission_Busy; + line_state.m_entry = ENTRY(); + m_map.add(line_address(address), line_state); } // deallocate entry template -extern inline -void PerfectCacheMemory::deallocate(const Address& address) +inline void +PerfectCacheMemory::deallocate(const Address& address) { - m_map.erase(line_address(address)); + m_map.erase(line_address(address)); } // Returns with the physical address of the conflicting cache line template -extern inline -Address PerfectCacheMemory::cacheProbe(const Address& newAddress) const +inline Address +PerfectCacheMemory::cacheProbe(const Address& newAddress) const { - ERROR_MSG("cacheProbe called in perfect cache"); + ERROR_MSG("cacheProbe called in perfect cache"); } // looks an address up in the cache template -extern inline -ENTRY& PerfectCacheMemory::lookup(const Address& address) +inline ENTRY& +PerfectCacheMemory::lookup(const Address& address) { - return m_map.lookup(line_address(address)).m_entry; + return m_map.lookup(line_address(address)).m_entry; } // looks an address up in the cache template -extern inline -const ENTRY& PerfectCacheMemory::lookup(const Address& address) const +inline const ENTRY& +PerfectCacheMemory::lookup(const Address& address) const { - return m_map.lookup(line_address(address)).m_entry; + return m_map.lookup(line_address(address)).m_entry; } template -extern inline -AccessPermission PerfectCacheMemory::getPermission(const Address& address) const +inline AccessPermission +PerfectCacheMemory::getPermission(const Address& address) const { - return m_map.lookup(line_address(address)).m_permission; + return m_map.lookup(line_address(address)).m_permission; } template -extern inline -void PerfectCacheMemory::changePermission(const Address& address, AccessPermission new_perm) +inline void +PerfectCacheMemory::changePermission(const Address& address, + AccessPermission new_perm) { - Address line_address = address; - line_address.makeLineAddress(); - PerfectCacheLineState& line_state = m_map.lookup(line_address); - AccessPermission old_perm = line_state.m_permission; - line_state.m_permission = new_perm; + Address line_address = address; + line_address.makeLineAddress(); + PerfectCacheLineState& line_state = m_map.lookup(line_address); + AccessPermission old_perm = line_state.m_permission; + line_state.m_permission = new_perm; } template -extern inline -void PerfectCacheMemory::print(ostream& out) const +inline void +PerfectCacheMemory::print(ostream& out) const { } -#endif //PERFECTCACHEMEMORY_H +#endif // __MEM_RUBY_SYSTEM_PERFECTCACHEMEMORY_HH__ -- cgit v1.2.3