static_inst.cc revision 56
15347Ssaidi@eecs.umich.edu/* 23395Shsul@eecs.umich.edu * Copyright (c) 2003 The Regents of The University of Michigan 33395Shsul@eecs.umich.edu * All rights reserved. 43395Shsul@eecs.umich.edu * 53395Shsul@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 63395Shsul@eecs.umich.edu * modification, are permitted provided that the following conditions are 73395Shsul@eecs.umich.edu * met: redistributions of source code must retain the above copyright 83395Shsul@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 93395Shsul@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 103395Shsul@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 113395Shsul@eecs.umich.edu * documentation and/or other materials provided with the distribution; 123395Shsul@eecs.umich.edu * neither the name of the copyright holders nor the names of its 133395Shsul@eecs.umich.edu * contributors may be used to endorse or promote products derived from 143395Shsul@eecs.umich.edu * this software without specific prior written permission. 153395Shsul@eecs.umich.edu * 163395Shsul@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173395Shsul@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183395Shsul@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193395Shsul@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203395Shsul@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213395Shsul@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223395Shsul@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233395Shsul@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243395Shsul@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253395Shsul@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263395Shsul@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273395Shsul@eecs.umich.edu */ 283395Shsul@eecs.umich.edu 293395Shsul@eecs.umich.edu#include <iostream> 303509Shsul@eecs.umich.edu#include "cpu/static_inst.hh" 313395Shsul@eecs.umich.edu#include "sim/universe.hh" 323395Shsul@eecs.umich.edu 333395Shsul@eecs.umich.edutemplate <class ISA> 343448Shsul@eecs.umich.eduStaticInstPtr<ISA> StaticInst<ISA>::nullStaticInstPtr; 353395Shsul@eecs.umich.edu 363481Shsul@eecs.umich.edutemplate <class ISA> 373481Shsul@eecs.umich.edutypename StaticInst<ISA>::DecodeCache StaticInst<ISA>::decodeCache; 383481Shsul@eecs.umich.edu 393481Shsul@eecs.umich.edu// Define the decode cache hash map. 405347Ssaidi@eecs.umich.edutemplate StaticInst<AlphaISA>::DecodeCache 413481Shsul@eecs.umich.eduStaticInst<AlphaISA>::decodeCache; 423681Sktlim@umich.edu 433681Sktlim@umich.edutemplate <class ISA> 443681Sktlim@umich.eduvoid 455347Ssaidi@eecs.umich.eduStaticInst<ISA>::dumpDecodeCacheStats() 463481Shsul@eecs.umich.edu{ 475347Ssaidi@eecs.umich.edu using namespace std; 483481Shsul@eecs.umich.edu 493481Shsul@eecs.umich.edu cerr << "Decode hash table stats @ " << curTick << ":" << endl; 503481Shsul@eecs.umich.edu cerr << "\tnum entries = " << decodeCache.size() << endl; 513481Shsul@eecs.umich.edu cerr << "\tnum buckets = " << decodeCache.bucket_count() << endl; 523481Shsul@eecs.umich.edu vector<int> hist(100, 0); 533481Shsul@eecs.umich.edu int max_hist = 0; 543481Shsul@eecs.umich.edu for (int i = 0; i < decodeCache.bucket_count(); ++i) { 553481Shsul@eecs.umich.edu int count = decodeCache.elems_in_bucket(i); 565347Ssaidi@eecs.umich.edu if (count > max_hist) 573481Shsul@eecs.umich.edu max_hist = count; 583481Shsul@eecs.umich.edu hist[count]++; 593481Shsul@eecs.umich.edu } 603481Shsul@eecs.umich.edu for (int i = 0; i <= max_hist; ++i) { 613481Shsul@eecs.umich.edu cerr << "\tbuckets of size " << i << " = " << hist[i] << endl; 623481Shsul@eecs.umich.edu } 633481Shsul@eecs.umich.edu} 643395Shsul@eecs.umich.edu 653395Shsul@eecs.umich.edu 663395Shsul@eecs.umich.edutemplate StaticInstPtr<AlphaISA> 674167Sbinkertn@umich.eduStaticInst<AlphaISA>::nullStaticInstPtr; 683395Shsul@eecs.umich.edu 693395Shsul@eecs.umich.edutemplate <class ISA> 703395Shsul@eecs.umich.edubool 713511Shsul@eecs.umich.eduStaticInst<ISA>::hasBranchTarget(Addr pc, ExecContext *xc, Addr &tgt) 723395Shsul@eecs.umich.edu{ 733395Shsul@eecs.umich.edu if (isDirectCtrl()) { 743395Shsul@eecs.umich.edu tgt = branchTarget(pc); 755211Ssaidi@eecs.umich.edu return true; 765211Ssaidi@eecs.umich.edu } 773395Shsul@eecs.umich.edu 783395Shsul@eecs.umich.edu if (isIndirectCtrl()) { 793395Shsul@eecs.umich.edu tgt = branchTarget(xc); 803395Shsul@eecs.umich.edu return true; 813395Shsul@eecs.umich.edu } 823481Shsul@eecs.umich.edu 833481Shsul@eecs.umich.edu return false; 843481Shsul@eecs.umich.edu} 853481Shsul@eecs.umich.edu 863481Shsul@eecs.umich.edu 873481Shsul@eecs.umich.edu// force instantiation of template function(s) above 883481Shsul@eecs.umich.edutemplate StaticInst<AlphaISA>; 893481Shsul@eecs.umich.edu