reg_class.hh (12857:6fc1b2a47d76) | reg_class.hh (12858:07c81183e089) |
---|---|
1/* 2 * Copyright (c) 2016 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 68 unchanged lines hidden (view full) --- 77 */ 78class RegId { 79 private: 80 static const char* regClassStrings[]; 81 RegClass regClass; 82 RegIndex regIdx; 83 ElemIndex elemIdx; 84 static constexpr size_t Scale = TheISA::NumVecElemPerVecReg; | 1/* 2 * Copyright (c) 2016 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 68 unchanged lines hidden (view full) --- 77 */ 78class RegId { 79 private: 80 static const char* regClassStrings[]; 81 RegClass regClass; 82 RegIndex regIdx; 83 ElemIndex elemIdx; 84 static constexpr size_t Scale = TheISA::NumVecElemPerVecReg; |
85 friend struct std::hash<RegId>; |
|
85 public: 86 RegId() {}; 87 RegId(RegClass reg_class, RegIndex reg_idx) 88 : regClass(reg_class), regIdx(reg_idx), elemIdx(-1) 89 { 90 panic_if(regClass == VecElemClass, 91 "Creating vector physical index w/o element index"); 92 } --- 103 unchanged lines hidden (view full) --- 196 /** Return a const char* with the register class name. */ 197 const char* className() const { return regClassStrings[regClass]; } 198 199 friend std::ostream& 200 operator<<(std::ostream& os, const RegId& rid) { 201 return os << rid.className() << "{" << rid.index() << "}"; 202 } 203}; | 86 public: 87 RegId() {}; 88 RegId(RegClass reg_class, RegIndex reg_idx) 89 : regClass(reg_class), regIdx(reg_idx), elemIdx(-1) 90 { 91 panic_if(regClass == VecElemClass, 92 "Creating vector physical index w/o element index"); 93 } --- 103 unchanged lines hidden (view full) --- 197 /** Return a const char* with the register class name. */ 198 const char* className() const { return regClassStrings[regClass]; } 199 200 friend std::ostream& 201 operator<<(std::ostream& os, const RegId& rid) { 202 return os << rid.className() << "{" << rid.index() << "}"; 203 } 204}; |
205 206namespace std 207{ 208template<> 209struct hash<RegId> 210{ 211 size_t operator()(const RegId& reg_id) const 212 { 213 // Extract unique integral values for the effective fields of a RegId. 214 const size_t flat_index = static_cast<size_t>(reg_id.flatIndex()); 215 const size_t class_num = static_cast<size_t>(reg_id.regClass); 216 217 const size_t shifted_class_num = class_num << (sizeof(RegIndex) << 3); 218 219 // Concatenate the class_num to the end of the flat_index, in order to 220 // maximize information retained. 221 const size_t concatenated_hash = flat_index | shifted_class_num; 222 223 // If RegIndex is larger than size_t, then class_num will not be 224 // considered by this hash function, so we may wish to perform a 225 // different operation to include that information in the hash. 226 static_assert(sizeof(RegIndex) < sizeof(size_t), 227 "sizeof(RegIndex) should be less than sizeof(size_t)"); 228 229 return concatenated_hash; 230 } 231}; 232} 233 |
|
204#endif // __CPU__REG_CLASS_HH__ | 234#endif // __CPU__REG_CLASS_HH__ |