Deleted Added
sdiff udiff text old ( 9919:803903a8dac1 ) new ( 9920:028e4da64b42 )
full compact
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

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

50 */
51class PhysRegFile
52{
53 private:
54
55 typedef TheISA::IntReg IntReg;
56 typedef TheISA::FloatReg FloatReg;
57 typedef TheISA::FloatRegBits FloatRegBits;
58
59 typedef union {
60 FloatReg d;
61 FloatRegBits q;
62 } PhysFloatReg;
63
64 /** Integer register file. */
65 std::vector<IntReg> intRegFile;
66
67 /** Floating point register file. */
68 std::vector<PhysFloatReg> floatRegFile;
69
70 /**
71 * The first floating-point physical register index. The physical
72 * register file has a single continuous index space, with the
73 * initial indices mapping to the integer registers, followed
74 * immediately by the floating-point registers. Thus the first
75 * floating-point index is equal to the number of integer
76 * registers.
77 *
78 * Note that this internal organizational detail on how physical
79 * register file indices are ordered should *NOT* be exposed
80 * outside of this class. Other classes can use the is*PhysReg()
81 * methods to map from a physical register index to a class
82 * without knowing the internal structure of the index map.
83 */
84 unsigned baseFloatRegIndex;
85
86 /** Total number of physical registers. */
87 unsigned totalNumRegs;
88
89 public:
90 /**
91 * Constructs a physical register file with the specified amount of
92 * integer and floating point registers.
93 */
94 PhysRegFile(unsigned _numPhysicalIntRegs,
95 unsigned _numPhysicalFloatRegs);
96
97 /**
98 * Destructor to free resources
99 */
100 ~PhysRegFile() {}
101
102 /** Initialize the free list */
103 void initFreeList(UnifiedFreeList *freeList);
104
105 /** @return the number of integer physical registers. */
106 unsigned numIntPhysRegs() const { return baseFloatRegIndex; }
107
108 /** @return the number of floating-point physical registers. */
109 unsigned numFloatPhysRegs() const
110 { return totalNumRegs - baseFloatRegIndex; }
111
112 /** @return the total number of physical registers. */
113 unsigned totalNumPhysRegs() const { return totalNumRegs; }
114
115 /**
116 * @return true if the specified physical register index
117 * corresponds to an integer physical register.
118 */
119 bool isIntPhysReg(PhysRegIndex reg_idx) const
120 {
121 return 0 <= reg_idx && reg_idx < baseFloatRegIndex;
122 }
123
124 /**
125 * @return true if the specified physical register index
126 * corresponds to a floating-point physical register.
127 */
128 bool isFloatPhysReg(PhysRegIndex reg_idx) const
129 {
130 return (baseFloatRegIndex <= reg_idx && reg_idx < totalNumRegs);
131 }
132
133 /** Reads an integer register. */
134 uint64_t readIntReg(PhysRegIndex reg_idx) const
135 {
136 assert(isIntPhysReg(reg_idx));
137
138 DPRINTF(IEW, "RegFile: Access to int register %i, has data "
139 "%#x\n", int(reg_idx), intRegFile[reg_idx]);
140 return intRegFile[reg_idx];

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

164 FloatRegBits floatRegBits = floatRegFile[reg_offset].q;
165
166 DPRINTF(IEW, "RegFile: Access to float register %i as int, "
167 "has data %#x\n", int(reg_idx), (uint64_t)floatRegBits);
168
169 return floatRegBits;
170 }
171
172 /** Sets an integer register to the given value. */
173 void setIntReg(PhysRegIndex reg_idx, uint64_t val)
174 {
175 assert(isIntPhysReg(reg_idx));
176
177 DPRINTF(IEW, "RegFile: Setting int register %i to %#x\n",
178 int(reg_idx), val);
179

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

206 PhysRegIndex reg_offset = reg_idx - baseFloatRegIndex;
207
208 DPRINTF(IEW, "RegFile: Setting float register %i to %#x\n",
209 int(reg_idx), (uint64_t)val);
210
211 floatRegFile[reg_offset].q = val;
212 }
213
214};
215
216
217#endif //__CPU_O3_REGFILE_HH__