cpu: Change literal integer constants to meaningful labels
fu_pool and inst_queue were using -1 for "no such FU" and -2 for "all those FUs are busy at the moment" when requesting for a FU and replying. This patch introduces new constants NoCapableFU and NoFreeFU respectively. In addition, the condition (idx == -2 || idx != -1) is equivalent to (idx != -1), so this patch also simplifies that. --HG-- extra : rebase_source : 4833717b9d1e09d7594d1f34f882e13fc4b86846
This commit is contained in:
parent
8faeec44a6
commit
21f8242430
2 changed files with 12 additions and 7 deletions
|
@ -134,12 +134,17 @@ class FUPool : public SimObject
|
||||||
FUPool(const Params *p);
|
FUPool(const Params *p);
|
||||||
~FUPool();
|
~FUPool();
|
||||||
|
|
||||||
|
static constexpr auto NoCapableFU = -2;
|
||||||
|
static constexpr auto NoFreeFU = -1;
|
||||||
/**
|
/**
|
||||||
* Gets a FU providing the requested capability. Will mark the unit as busy,
|
* Gets a FU providing the requested capability. Will mark the
|
||||||
* but leaves the freeing of the unit up to the IEW stage.
|
* unit as busy, but leaves the freeing of the unit up to the IEW
|
||||||
|
* stage.
|
||||||
|
*
|
||||||
* @param capability The capability requested.
|
* @param capability The capability requested.
|
||||||
* @return Returns -2 if the FU pool does not have the capability, -1 if
|
* @return Returns NoCapableFU if the FU pool does not have the
|
||||||
* there is no free FU, and the FU's index otherwise.
|
* capability, NoFreeFU if there is no free FU, and the FU's index
|
||||||
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
int getUnit(OpClass capability);
|
int getUnit(OpClass capability);
|
||||||
|
|
||||||
|
|
|
@ -801,21 +801,21 @@ InstructionQueue<Impl>::scheduleReadyInsts()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx = -2;
|
int idx = FUPool::NoCapableFU;
|
||||||
Cycles op_latency = Cycles(1);
|
Cycles op_latency = Cycles(1);
|
||||||
ThreadID tid = issuing_inst->threadNumber;
|
ThreadID tid = issuing_inst->threadNumber;
|
||||||
|
|
||||||
if (op_class != No_OpClass) {
|
if (op_class != No_OpClass) {
|
||||||
idx = fuPool->getUnit(op_class);
|
idx = fuPool->getUnit(op_class);
|
||||||
issuing_inst->isFloating() ? fpAluAccesses++ : intAluAccesses++;
|
issuing_inst->isFloating() ? fpAluAccesses++ : intAluAccesses++;
|
||||||
if (idx > -1) {
|
if (idx > FUPool::NoFreeFU) {
|
||||||
op_latency = fuPool->getOpLatency(op_class);
|
op_latency = fuPool->getOpLatency(op_class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have an instruction that doesn't require a FU, or a
|
// If we have an instruction that doesn't require a FU, or a
|
||||||
// valid FU, then schedule for execution.
|
// valid FU, then schedule for execution.
|
||||||
if (idx == -2 || idx != -1) {
|
if (idx != FUPool::NoFreeFU) {
|
||||||
if (op_latency == Cycles(1)) {
|
if (op_latency == Cycles(1)) {
|
||||||
i2e_info->size++;
|
i2e_info->size++;
|
||||||
instsToExecute.push_back(issuing_inst);
|
instsToExecute.push_back(issuing_inst);
|
||||||
|
|
Loading…
Reference in a new issue