Deleted Added
sdiff udiff text old ( 13762:36d5a1d9f5e6 ) new ( 14025:3a133070aa2e )
full compact
1/*
2 * Copyright (c) 2016-2017 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
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

--- 61 unchanged lines hidden (view full) ---

72const int NumRegClasses = MiscRegClass + 1;
73
74/** Register ID: describe an architectural register with its class and index.
75 * This structure is used instead of just the register index to disambiguate
76 * between different classes of registers. For example, a integer register with
77 * index 3 is represented by Regid(IntRegClass, 3).
78 */
79class RegId {
80 private:
81 static const char* regClassStrings[];
82 RegClass regClass;
83 RegIndex regIdx;
84 ElemIndex elemIdx;
85 static constexpr size_t Scale = TheISA::NumVecElemPerVecReg;
86 friend struct std::hash<RegId>;
87 public:
88 RegId() : regClass(IntRegClass), regIdx(0), elemIdx(-1) {}
89 RegId(RegClass reg_class, RegIndex reg_idx)
90 : regClass(reg_class), regIdx(reg_idx), elemIdx(-1)
91 {
92 panic_if(regClass == VecElemClass,
93 "Creating vector physical index w/o element index");
94 }
95
96 explicit RegId(RegClass reg_class, RegIndex reg_idx, ElemIndex elem_idx)
97 : regClass(reg_class), regIdx(reg_idx), elemIdx(elem_idx)
98 {
99 panic_if(regClass != VecElemClass,
100 "Creating non-vector physical index w/ element index");
101 }
102
103 bool operator==(const RegId& that) const {
104 return regClass == that.classValue() && regIdx == that.index()
105 && elemIdx == that.elemIndex();

--- 91 unchanged lines hidden (view full) ---

197
198 /** Elem accessor */
199 const RegIndex& elemIndex() const { return elemIdx; }
200 /** Class accessor */
201 const RegClass& classValue() const { return regClass; }
202 /** Return a const char* with the register class name. */
203 const char* className() const { return regClassStrings[regClass]; }
204
205 friend std::ostream&
206 operator<<(std::ostream& os, const RegId& rid) {
207 return os << rid.className() << "{" << rid.index() << "}";
208 }
209};
210
211/** Physical register index type.
212 * Although the Impl might be a better for this, but there are a few classes
213 * that need this typedef yet are not templated on the Impl.
214 */
215using PhysRegIndex = short int;
216
217/** Physical register ID.
218 * Like a register ID but physical. The inheritance is private because the
219 * only relationship between this types is functional, and it is done to
220 * prevent code replication. */
221class PhysRegId : private RegId {
222 private:
223 PhysRegIndex flatIdx;
224
225 public:
226 explicit PhysRegId() : RegId(IntRegClass, -1), flatIdx(-1) {}
227
228 /** Scalar PhysRegId constructor. */
229 explicit PhysRegId(RegClass _regClass, PhysRegIndex _regIdx,
230 PhysRegIndex _flatIdx)
231 : RegId(_regClass, _regIdx), flatIdx(_flatIdx)
232 {}
233
234 /** Vector PhysRegId constructor (w/ elemIndex). */
235 explicit PhysRegId(RegClass _regClass, PhysRegIndex _regIdx,
236 ElemIndex elem_idx, PhysRegIndex flat_idx)
237 : RegId(_regClass, _regIdx, elem_idx), flatIdx(flat_idx) { }
238
239 /** Visible RegId methods */
240 /** @{ */
241 using RegId::index;
242 using RegId::classValue;
243 using RegId::isZeroReg;
244 using RegId::className;
245 using RegId::elemIndex;

--- 44 unchanged lines hidden (view full) ---

290 bool isFixedMapping() const
291 {
292 return !isRenameable();
293 }
294
295 /** Flat index accessor */
296 const PhysRegIndex& flatIndex() const { return flatIdx; }
297
298 static PhysRegId elemId(const PhysRegId* vid, ElemIndex elem)
299 {
300 assert(vid->isVectorPhysReg());
301 return PhysRegId(VecElemClass, vid->index(), elem);
302 }
303};
304
305/** Constant pointer definition.
306 * PhysRegIds only need to be created once and then we can just share
307 * pointers */
308using PhysRegIdPtr = const PhysRegId*;
309
310namespace std
311{
312template<>
313struct hash<RegId>
314{
315 size_t operator()(const RegId& reg_id) const
316 {

--- 22 unchanged lines hidden ---