simple_indirect.hh revision 13957
113957Sjairo.balart@metempsy.com/* 213957Sjairo.balart@metempsy.com * Copyright (c) 2014 ARM Limited 313957Sjairo.balart@metempsy.com * All rights reserved. 413957Sjairo.balart@metempsy.com * 513957Sjairo.balart@metempsy.com * Redistribution and use in source and binary forms, with or without 613957Sjairo.balart@metempsy.com * modification, are permitted provided that the following conditions are 713957Sjairo.balart@metempsy.com * met: redistributions of source code must retain the above copyright 813957Sjairo.balart@metempsy.com * notice, this list of conditions and the following disclaimer; 913957Sjairo.balart@metempsy.com * redistributions in binary form must reproduce the above copyright 1013957Sjairo.balart@metempsy.com * notice, this list of conditions and the following disclaimer in the 1113957Sjairo.balart@metempsy.com * documentation and/or other materials provided with the distribution; 1213957Sjairo.balart@metempsy.com * neither the name of the copyright holders nor the names of its 1313957Sjairo.balart@metempsy.com * contributors may be used to endorse or promote products derived from 1413957Sjairo.balart@metempsy.com * this software without specific prior written permission. 1513957Sjairo.balart@metempsy.com * 1613957Sjairo.balart@metempsy.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1713957Sjairo.balart@metempsy.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1813957Sjairo.balart@metempsy.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1913957Sjairo.balart@metempsy.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2013957Sjairo.balart@metempsy.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2113957Sjairo.balart@metempsy.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2213957Sjairo.balart@metempsy.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2313957Sjairo.balart@metempsy.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2413957Sjairo.balart@metempsy.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2513957Sjairo.balart@metempsy.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2613957Sjairo.balart@metempsy.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2713957Sjairo.balart@metempsy.com * 2813957Sjairo.balart@metempsy.com * Authors: Mitch Hayenga 2913957Sjairo.balart@metempsy.com */ 3013957Sjairo.balart@metempsy.com 3113957Sjairo.balart@metempsy.com#ifndef __CPU_PRED_INDIRECT_HH__ 3213957Sjairo.balart@metempsy.com#define __CPU_PRED_INDIRECT_HH__ 3313957Sjairo.balart@metempsy.com 3413957Sjairo.balart@metempsy.com#include <deque> 3513957Sjairo.balart@metempsy.com 3613957Sjairo.balart@metempsy.com#include "arch/isa_traits.hh" 3713957Sjairo.balart@metempsy.com#include "config/the_isa.hh" 3813957Sjairo.balart@metempsy.com#include "cpu/inst_seq.hh" 3913957Sjairo.balart@metempsy.com#include "cpu/pred/indirect.hh" 4013957Sjairo.balart@metempsy.com#include "params/SimpleIndirectPredictor.hh" 4113957Sjairo.balart@metempsy.com 4213957Sjairo.balart@metempsy.comclass SimpleIndirectPredictor : public IndirectPredictor 4313957Sjairo.balart@metempsy.com{ 4413957Sjairo.balart@metempsy.com public: 4513957Sjairo.balart@metempsy.com SimpleIndirectPredictor(const SimpleIndirectPredictorParams * params); 4613957Sjairo.balart@metempsy.com 4713957Sjairo.balart@metempsy.com bool lookup(Addr br_addr, TheISA::PCState& br_target, ThreadID tid); 4813957Sjairo.balart@metempsy.com void recordIndirect(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num, 4913957Sjairo.balart@metempsy.com ThreadID tid); 5013957Sjairo.balart@metempsy.com void commit(InstSeqNum seq_num, ThreadID tid, void * indirect_history); 5113957Sjairo.balart@metempsy.com void squash(InstSeqNum seq_num, ThreadID tid); 5213957Sjairo.balart@metempsy.com void recordTarget(InstSeqNum seq_num, void * indirect_history, 5313957Sjairo.balart@metempsy.com const TheISA::PCState& target, ThreadID tid); 5413957Sjairo.balart@metempsy.com void genIndirectInfo(ThreadID tid, void* & indirect_history); 5513957Sjairo.balart@metempsy.com void updateDirectionInfo(ThreadID tid, bool actually_taken); 5613957Sjairo.balart@metempsy.com void deleteIndirectInfo(ThreadID tid, void * indirect_history); 5713957Sjairo.balart@metempsy.com void changeDirectionPrediction(ThreadID tid, void * indirect_history, 5813957Sjairo.balart@metempsy.com bool actually_taken); 5913957Sjairo.balart@metempsy.com 6013957Sjairo.balart@metempsy.com private: 6113957Sjairo.balart@metempsy.com const bool hashGHR; 6213957Sjairo.balart@metempsy.com const bool hashTargets; 6313957Sjairo.balart@metempsy.com const unsigned numSets; 6413957Sjairo.balart@metempsy.com const unsigned numWays; 6513957Sjairo.balart@metempsy.com const unsigned tagBits; 6613957Sjairo.balart@metempsy.com const unsigned pathLength; 6713957Sjairo.balart@metempsy.com const unsigned instShift; 6813957Sjairo.balart@metempsy.com const unsigned ghrNumBits; 6913957Sjairo.balart@metempsy.com const unsigned ghrMask; 7013957Sjairo.balart@metempsy.com 7113957Sjairo.balart@metempsy.com struct IPredEntry 7213957Sjairo.balart@metempsy.com { 7313957Sjairo.balart@metempsy.com IPredEntry() : tag(0), target(0) { } 7413957Sjairo.balart@metempsy.com Addr tag; 7513957Sjairo.balart@metempsy.com TheISA::PCState target; 7613957Sjairo.balart@metempsy.com }; 7713957Sjairo.balart@metempsy.com 7813957Sjairo.balart@metempsy.com std::vector<std::vector<IPredEntry> > targetCache; 7913957Sjairo.balart@metempsy.com 8013957Sjairo.balart@metempsy.com Addr getSetIndex(Addr br_addr, unsigned ghr, ThreadID tid); 8113957Sjairo.balart@metempsy.com Addr getTag(Addr br_addr); 8213957Sjairo.balart@metempsy.com 8313957Sjairo.balart@metempsy.com struct HistoryEntry 8413957Sjairo.balart@metempsy.com { 8513957Sjairo.balart@metempsy.com HistoryEntry(Addr br_addr, Addr tgt_addr, InstSeqNum seq_num) 8613957Sjairo.balart@metempsy.com : pcAddr(br_addr), targetAddr(tgt_addr), seqNum(seq_num) { } 8713957Sjairo.balart@metempsy.com Addr pcAddr; 8813957Sjairo.balart@metempsy.com Addr targetAddr; 8913957Sjairo.balart@metempsy.com InstSeqNum seqNum; 9013957Sjairo.balart@metempsy.com }; 9113957Sjairo.balart@metempsy.com 9213957Sjairo.balart@metempsy.com 9313957Sjairo.balart@metempsy.com struct ThreadInfo { 9413957Sjairo.balart@metempsy.com ThreadInfo() : headHistEntry(0), ghr(0) { } 9513957Sjairo.balart@metempsy.com 9613957Sjairo.balart@metempsy.com std::deque<HistoryEntry> pathHist; 9713957Sjairo.balart@metempsy.com unsigned headHistEntry; 9813957Sjairo.balart@metempsy.com unsigned ghr; 9913957Sjairo.balart@metempsy.com }; 10013957Sjairo.balart@metempsy.com 10113957Sjairo.balart@metempsy.com std::vector<ThreadInfo> threadInfo; 10213957Sjairo.balart@metempsy.com}; 10313957Sjairo.balart@metempsy.com 10413957Sjairo.balart@metempsy.com#endif // __CPU_PRED_INDIRECT_HH__ 105