113454Spau.cabre@metempsy.com/* 213454Spau.cabre@metempsy.com * Copyright (c) 2014 The University of Wisconsin 313454Spau.cabre@metempsy.com * 413454Spau.cabre@metempsy.com * Copyright (c) 2006 INRIA (Institut National de Recherche en 513454Spau.cabre@metempsy.com * Informatique et en Automatique / French National Research Institute 613454Spau.cabre@metempsy.com * for Computer Science and Applied Mathematics) 713454Spau.cabre@metempsy.com * 813454Spau.cabre@metempsy.com * All rights reserved. 913454Spau.cabre@metempsy.com * 1013454Spau.cabre@metempsy.com * Redistribution and use in source and binary forms, with or without 1113454Spau.cabre@metempsy.com * modification, are permitted provided that the following conditions are 1213454Spau.cabre@metempsy.com * met: redistributions of source code must retain the above copyright 1313454Spau.cabre@metempsy.com * notice, this list of conditions and the following disclaimer; 1413454Spau.cabre@metempsy.com * redistributions in binary form must reproduce the above copyright 1513454Spau.cabre@metempsy.com * notice, this list of conditions and the following disclaimer in the 1613454Spau.cabre@metempsy.com * documentation and/or other materials provided with the distribution; 1713454Spau.cabre@metempsy.com * neither the name of the copyright holders nor the names of its 1813454Spau.cabre@metempsy.com * contributors may be used to endorse or promote products derived from 1913454Spau.cabre@metempsy.com * this software without specific prior written permission. 2013454Spau.cabre@metempsy.com * 2113454Spau.cabre@metempsy.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2213454Spau.cabre@metempsy.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2313454Spau.cabre@metempsy.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2413454Spau.cabre@metempsy.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2513454Spau.cabre@metempsy.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2613454Spau.cabre@metempsy.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2713454Spau.cabre@metempsy.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2813454Spau.cabre@metempsy.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2913454Spau.cabre@metempsy.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3013454Spau.cabre@metempsy.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3113454Spau.cabre@metempsy.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3213454Spau.cabre@metempsy.com * 3313454Spau.cabre@metempsy.com * Authors: Vignyan Reddy, Dibakar Gope and Arthur Perais, 3413454Spau.cabre@metempsy.com * from André Seznec's code. 3513454Spau.cabre@metempsy.com */ 3613454Spau.cabre@metempsy.com 3713454Spau.cabre@metempsy.com/* @file 3813454Spau.cabre@metempsy.com * Implementation of a TAGE branch predictor. TAGE is a global-history based 3913454Spau.cabre@metempsy.com * branch predictor. It features a PC-indexed bimodal predictor and N 4013454Spau.cabre@metempsy.com * partially tagged tables, indexed with a hash of the PC and the global 4113454Spau.cabre@metempsy.com * branch history. The different lengths of global branch history used to 4213454Spau.cabre@metempsy.com * index the partially tagged tables grow geometrically. A small path history 4313454Spau.cabre@metempsy.com * is also used in the hash. 4413454Spau.cabre@metempsy.com * 4513454Spau.cabre@metempsy.com * All TAGE tables are accessed in parallel, and the one using the longest 4613454Spau.cabre@metempsy.com * history that matches provides the prediction (some exceptions apply). 4713454Spau.cabre@metempsy.com * Entries are allocated in components using a longer history than the 4813454Spau.cabre@metempsy.com * one that predicted when the prediction is incorrect. 4913454Spau.cabre@metempsy.com */ 5013454Spau.cabre@metempsy.com 5113454Spau.cabre@metempsy.com#ifndef __CPU_PRED_TAGE 5213454Spau.cabre@metempsy.com#define __CPU_PRED_TAGE 5313454Spau.cabre@metempsy.com 5413454Spau.cabre@metempsy.com#include <vector> 5513454Spau.cabre@metempsy.com 5613454Spau.cabre@metempsy.com#include "base/types.hh" 5713454Spau.cabre@metempsy.com#include "cpu/pred/bpred_unit.hh" 5813626Sjairo.balart@metempsy.com#include "cpu/pred/tage_base.hh" 5913454Spau.cabre@metempsy.com#include "params/TAGE.hh" 6013454Spau.cabre@metempsy.com 6113454Spau.cabre@metempsy.comclass TAGE: public BPredUnit 6213454Spau.cabre@metempsy.com{ 6313626Sjairo.balart@metempsy.com protected: 6413626Sjairo.balart@metempsy.com TAGEBase *tage; 6513626Sjairo.balart@metempsy.com 6613626Sjairo.balart@metempsy.com struct TageBranchInfo { 6713626Sjairo.balart@metempsy.com TAGEBase::BranchInfo *tageBranchInfo; 6813626Sjairo.balart@metempsy.com 6913626Sjairo.balart@metempsy.com TageBranchInfo(TAGEBase &tage) : tageBranchInfo(tage.makeBranchInfo()) 7013626Sjairo.balart@metempsy.com {} 7113626Sjairo.balart@metempsy.com 7213626Sjairo.balart@metempsy.com virtual ~TageBranchInfo() 7313626Sjairo.balart@metempsy.com { 7413626Sjairo.balart@metempsy.com delete tageBranchInfo; 7513626Sjairo.balart@metempsy.com } 7613626Sjairo.balart@metempsy.com }; 7713626Sjairo.balart@metempsy.com 7813626Sjairo.balart@metempsy.com virtual bool predict(ThreadID tid, Addr branch_pc, bool cond_branch, 7913626Sjairo.balart@metempsy.com void* &b); 8013685Sjavier.bueno@metempsy.com 8113454Spau.cabre@metempsy.com public: 8213626Sjairo.balart@metempsy.com 8313454Spau.cabre@metempsy.com TAGE(const TAGEParams *params); 8413454Spau.cabre@metempsy.com 8513454Spau.cabre@metempsy.com // Base class methods. 8613454Spau.cabre@metempsy.com void uncondBranch(ThreadID tid, Addr br_pc, void* &bp_history) override; 8713454Spau.cabre@metempsy.com bool lookup(ThreadID tid, Addr branch_addr, void* &bp_history) override; 8813454Spau.cabre@metempsy.com void btbUpdate(ThreadID tid, Addr branch_addr, void* &bp_history) override; 8913454Spau.cabre@metempsy.com void update(ThreadID tid, Addr branch_addr, bool taken, void *bp_history, 9013626Sjairo.balart@metempsy.com bool squashed, const StaticInstPtr & inst, 9113685Sjavier.bueno@metempsy.com Addr corrTarget = MaxAddr) override; 9213454Spau.cabre@metempsy.com virtual void squash(ThreadID tid, void *bp_history) override; 9313454Spau.cabre@metempsy.com}; 9413454Spau.cabre@metempsy.com 9513454Spau.cabre@metempsy.com#endif // __CPU_PRED_TAGE 96