src/cpu/pred/loop_predictor.cc
//loop prediction: only used if high confidence
loop prediction: only used if high confidence
loop prediction : only used if high confidence
bool
LoopPredictor::getLoop(Addr pc, BranchInfo* bi, bool speculative,
                       unsigned instShiftAmt) const
{
    bi->loopHit = -1;
    bi->loopPredValid = false;
    bi->loopIndex = lindex(pc, instShiftAmt);
    if (useHashing) {
        unsigned pcShift = logSizeLoopPred - logLoopTableAssoc;
        bi->loopIndexB = (pc >> pcShift) & loopSetMask;
        bi->loopTag = (pc >> pcShift) ^ (pc >> (pcShift + loopTableTagBits));
        bi->loopTag &= loopTagMask;
    } else {
        unsigned pcShift = instShiftAmt + logSizeLoopPred - logLoopTableAssoc;
        bi->loopTag = (pc >> pcShift) & loopTagMask;
    }
    for (int i = 0; i < (1 << logLoopTableAssoc); i++) {
        int idx = finallindex(bi->loopIndex, bi->loopIndexB, i);
        if (ltable[idx].tag == bi->loopTag) {
            bi->loopHit = i;
            bi->loopPredValid = calcConf(idx);
            uint16_t iter = speculative ? ltable[idx].currentIterSpec
                                        : ltable[idx].currentIter;
            if ((iter + 1) == ltable[idx].numIter) {
                return useDirectionBit ? !(ltable[idx].dir) : false;
            } else {
                return useDirectionBit ? (ltable[idx].dir) : true;
            }
        }
    }
    return false;
}
bool LoopPredictor :: getLoop ( Addr pc , BranchInfo * bi , bool speculative , unsigned instShiftAmt ) const { bi -> loopHit = -1 ; bi -> loopPredValid = false ; bi -> loopIndex = lindex ( pc , instShiftAmt ) ; if ( useHashing ) { unsigned pcShift = logSizeLoopPred - logLoopTableAssoc ; bi -> loopIndexB = ( pc >> pcShift ) & loopSetMask ; bi -> loopTag = ( pc >> pcShift ) ^ ( pc >> ( pcShift + loopTableTagBits ) ) ; bi -> loopTag &= loopTagMask ; } else { unsigned pcShift = instShiftAmt + logSizeLoopPred - logLoopTableAssoc ; bi -> loopTag = ( pc >> pcShift ) & loopTagMask ; } for ( int i = 0 ; i < ( 1 << logLoopTableAssoc ) ; i ++ ) { int idx = finallindex ( bi -> loopIndex , bi -> loopIndexB , i ) ; if ( ltable [ idx ] . tag == bi -> loopTag ) { bi -> loopHit = i ; bi -> loopPredValid = calcConf ( idx ) ; uint16_t iter = speculative ? ltable [ idx ] . currentIterSpec : ltable [ idx ] . currentIter ; if ( ( iter + 1 ) == ltable [ idx ] . numIter ) { return useDirectionBit ? ! ( ltable [ idx ] . dir ) : false ; } else { return useDirectionBit ? ( ltable [ idx ] . dir ) : true ; } } } return false ; }
loop prediction: only used if high confidence
loop prediction : only used if high confidence
// bi->loopIndexB is not used without hash