*/
bool _readySrcRegIdx[MaxInstSrcRegs];
+ /** Flattened register index of the destination registers of this
+ * instruction.
+ */
+ TheISA::RegIndex _flatDestRegIdx[TheISA::MaxInstDestRegs];
+
+ /** Flattened register index of the source registers of this
+ * instruction.
+ */
+ TheISA::RegIndex _flatSrcRegIdx[TheISA::MaxInstSrcRegs];
+
/** Physical register index of the destination registers of this
* instruction.
*/
return _srcRegIdx[idx];
}
+ /** Flattens a source architectural register index into a logical index.
+ */
+ void flattenSrcReg(int idx, TheISA::RegIndex flattened_src)
+ {
+ _flatSrcRegIdx[idx] = flattened_src;
+ }
+
+ /** Flattens a destination architectural register index into a logical
+ * index.
+ */
+ void flattenDestReg(int idx, TheISA::RegIndex flattened_dest)
+ {
+ _flatDestRegIdx[idx] = flattened_dest;
+ }
+
+ /** Returns the flattened register index of the i'th destination
+ * register.
+ */
+ TheISA::RegIndex flattenedDestRegIdx(int idx) const
+ {
+ return _flatDestRegIdx[idx];
+ }
+
+ /** Returns the flattened register index of the i'th source register */
+ TheISA::RegIndex flattenedSrcRegIdx(int idx) const
+ {
+ return _flatSrcRegIdx[idx];
+ }
+
/** Returns the physical register index of the previous physical register
* that remapped to the same logical register index.
*/
int getDestIdxNum(PhysRegIndex dest_idx)
{
for (int i=0; i < staticInst->numDestRegs(); i++) {
- if (_destRegIdx[i] == dest_idx)
+ if (_flatDestRegIdx[i] == dest_idx)
return i;
}
inst->staticInst->getName(),
dest_regs);
- for (int i = 0; i < dest_regs; i++)
- insert(inst->destRegIdx(i), inst);
+ for (int i = 0; i < dest_regs; i++) {
+ InOrderCPU::RegType reg_type;
+ TheISA::RegIndex raw_idx = inst->destRegIdx(i);
+ TheISA::RegIndex flat_idx = cpu->flattenRegIdx(raw_idx,
+ reg_type,
+ inst->threadNumber);
+ inst->flattenDestReg(i, flat_idx);
+ insert(reg_type, flat_idx, inst);
+ }
}
void
-RegDepMap::insert(RegIndex idx, DynInstPtr inst)
+RegDepMap::insert(uint8_t reg_type, RegIndex idx, DynInstPtr inst)
{
- InOrderCPU::RegType reg_type;
- TheISA::RegIndex flat_idx = cpu->flattenRegIdx(idx, reg_type,
- inst->threadNumber);
-
DPRINTF(RegDepMap, "Inserting [sn:%i] onto %s dep. list for "
- "reg. idx %i (%i).\n", inst->seqNum, mapNames[reg_type],
- idx, flat_idx);
+ "reg. idx %i.\n", inst->seqNum, mapNames[reg_type],
+ idx);
- regMap[reg_type][flat_idx].push_back(inst);
+ regMap[reg_type][idx].push_back(inst);
inst->setRegDepEntry();
}
}
ThePipeline::DynInstPtr
-RegDepMap::canForward(uint8_t reg_type, unsigned reg_idx, DynInstPtr inst,
- unsigned clean_idx)
+RegDepMap::canForward(uint8_t reg_type, unsigned reg_idx, DynInstPtr inst)
{
std::list<DynInstPtr>::iterator list_it = regMap[reg_type][reg_idx].begin();
std::list<DynInstPtr>::iterator list_end = regMap[reg_type][reg_idx].end();
DynInstPtr forward_inst = NULL;
- // Look for first/oldest instruction
+ // Look for instruction immediately in front of requestor to supply
+ // data
while (list_it != list_end &&
(*list_it)->seqNum < inst->seqNum) {
forward_inst = (*list_it);
list_it++;
}
- DPRINTF(RegDepMap, "[sn:%i] Found potential forwarding value for reg %i (%i)"
- " w/ [sn:%i]\n",
- inst->seqNum, reg_idx, clean_idx, inst->seqNum);
if (forward_inst) {
- int dest_reg_idx = forward_inst->getDestIdxNum(clean_idx);
+ int dest_reg_idx = forward_inst->getDestIdxNum(reg_idx);
assert(dest_reg_idx != -1);
+ DPRINTF(RegDepMap, "[sn:%i] Found potential forwarding value for reg %i "
+ " w/ [sn:%i] dest. reg. #%i\n",
+ inst->seqNum, reg_idx, forward_inst->seqNum, dest_reg_idx);
+
if (forward_inst->isExecuted() &&
forward_inst->readResultTime(dest_reg_idx) < curTick()) {
return forward_inst;
} else {
if (!forward_inst->isExecuted()) {
DPRINTF(RegDepMap, "[sn:%i] Can't get value through "
- "forwarding, [sn:%i] has not been executed yet.\n",
- inst->seqNum, forward_inst->seqNum);
+ "forwarding, [sn:%i] %s has not been executed yet.\n",
+ inst->seqNum, forward_inst->seqNum, forward_inst->instName());
} else if (forward_inst->readResultTime(dest_reg_idx) >= curTick()) {
DPRINTF(RegDepMap, "[sn:%i] Can't get value through "
"forwarding, [sn:%i] executed on tick:%i.\n",
* another instruction for this destination register?
*/
DynInstPtr canForward(uint8_t reg_type, unsigned reg_idx,
- DynInstPtr inst, unsigned clean_idx);
+ DynInstPtr inst);
/** find an instruction to forward/bypass a value from */
DynInstPtr findBypassInst(RegIndex idx);
private:
/** Insert an instruction into a specific destination register index
- * onto map. This must be called w/the unflattened registered index
+ * onto map.
*/
- void insert(RegIndex idx, DynInstPtr inst);
+ void insert(uint8_t reg_type, RegIndex idx, DynInstPtr inst);
/** Remove a specific instruction and dest. register index from map
* This must be called w/the unflattened registered index
InOrderCPU::RegType reg_type;
RegIndex reg_idx = inst->_srcRegIdx[ud_idx];
RegIndex flat_idx = cpu->flattenRegIdx(reg_idx, reg_type, tid);
+ inst->flattenSrcReg(ud_idx, flat_idx);
DPRINTF(InOrderUseDef, "[tid:%i]: [sn:%i]: Attempting to read source "
"register idx %i (reg #%i, flat#%i).\n",
// Look for forwarding opportunities
DynInstPtr forward_inst = regDepMap[tid]->canForward(reg_type,
flat_idx,
- inst,
- reg_idx);
+ inst);
if (forward_inst) {
int dest_reg_idx =
- forward_inst->getDestIdxNum(reg_idx);
+ forward_inst->getDestIdxNum(flat_idx);
switch (reg_type)
{