TBETable.hh (10441:5377550e1e15) | TBETable.hh (11025:4872dbdea907) |
---|---|
1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 29 unchanged lines hidden (view full) --- 38class TBETable 39{ 40 public: 41 TBETable(int number_of_TBEs) 42 : m_number_of_TBEs(number_of_TBEs) 43 { 44 } 45 | 1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 29 unchanged lines hidden (view full) --- 38class TBETable 39{ 40 public: 41 TBETable(int number_of_TBEs) 42 : m_number_of_TBEs(number_of_TBEs) 43 { 44 } 45 |
46 bool isPresent(const Address& address) const; 47 void allocate(const Address& address); 48 void deallocate(const Address& address); | 46 bool isPresent(Addr address) const; 47 void allocate(Addr address); 48 void deallocate(Addr address); |
49 bool 50 areNSlotsAvailable(int n) const 51 { 52 return (m_number_of_TBEs - m_map.size()) >= n; 53 } 54 | 49 bool 50 areNSlotsAvailable(int n) const 51 { 52 return (m_number_of_TBEs - m_map.size()) >= n; 53 } 54 |
55 ENTRY* lookup(const Address& address); | 55 ENTRY* lookup(Addr address); |
56 57 // Print cache contents 58 void print(std::ostream& out) const; 59 60 private: 61 // Private copy constructor and assignment operator 62 TBETable(const TBETable& obj); 63 TBETable& operator=(const TBETable& obj); 64 65 // Data Members (m_prefix) | 56 57 // Print cache contents 58 void print(std::ostream& out) const; 59 60 private: 61 // Private copy constructor and assignment operator 62 TBETable(const TBETable& obj); 63 TBETable& operator=(const TBETable& obj); 64 65 // Data Members (m_prefix) |
66 m5::hash_map<Address, ENTRY> m_map; | 66 m5::hash_map |
67 68 private: 69 int m_number_of_TBEs; 70}; 71 72template<class ENTRY> 73inline std::ostream& 74operator<<(std::ostream& out, const TBETable<ENTRY>& obj) 75{ 76 obj.print(out); 77 out << std::flush; 78 return out; 79} 80 81template<class ENTRY> 82inline bool | 67 68 private: 69 int m_number_of_TBEs; 70}; 71 72template<class ENTRY> 73inline std::ostream& 74operator<<(std::ostream& out, const TBETable<ENTRY>& obj) 75{ 76 obj.print(out); 77 out << std::flush; 78 return out; 79} 80 81template<class ENTRY> 82inline bool |
83TBETable<ENTRY>::isPresent(const Address& address) const | 83TBETable<ENTRY>::isPresent(Addr address) const |
84{ | 84{ |
85 assert(address == line_address(address)); | 85 assert(address == makeLineAddress(address)); |
86 assert(m_map.size() <= m_number_of_TBEs); 87 return !!m_map.count(address); 88} 89 90template<class ENTRY> 91inline void | 86 assert(m_map.size() <= m_number_of_TBEs); 87 return !!m_map.count(address); 88} 89 90template<class ENTRY> 91inline void |
92TBETable<ENTRY>::allocate(const Address& address) | 92TBETable<ENTRY>::allocate(Addr address) |
93{ 94 assert(!isPresent(address)); 95 assert(m_map.size() < m_number_of_TBEs); 96 m_map[address] = ENTRY(); 97} 98 99template<class ENTRY> 100inline void | 93{ 94 assert(!isPresent(address)); 95 assert(m_map.size() < m_number_of_TBEs); 96 m_map[address] = ENTRY(); 97} 98 99template<class ENTRY> 100inline void |
101TBETable<ENTRY>::deallocate(const Address& address) | 101TBETable<ENTRY>::deallocate(Addr address) |
102{ 103 assert(isPresent(address)); 104 assert(m_map.size() > 0); 105 m_map.erase(address); 106} 107 108// looks an address up in the cache 109template<class ENTRY> 110inline ENTRY* | 102{ 103 assert(isPresent(address)); 104 assert(m_map.size() > 0); 105 m_map.erase(address); 106} 107 108// looks an address up in the cache 109template<class ENTRY> 110inline ENTRY* |
111TBETable<ENTRY>::lookup(const Address& address) | 111TBETable<ENTRY>::lookup(Addr address) |
112{ 113 if(m_map.find(address) != m_map.end()) return &(m_map.find(address)->second); 114 return NULL; 115} 116 117 118template<class ENTRY> 119inline void 120TBETable<ENTRY>::print(std::ostream& out) const 121{ 122} 123 124#endif // __MEM_RUBY_STRUCTURES_TBETABLE_HH__ | 112{ 113 if(m_map.find(address) != m_map.end()) return &(m_map.find(address)->second); 114 return NULL; 115} 116 117 118template<class ENTRY> 119inline void 120TBETable<ENTRY>::print(std::ostream& out) const 121{ 122} 123 124#endif // __MEM_RUBY_STRUCTURES_TBETABLE_HH__ |