static_inst.cc revision 56
12068SN/A/* 22068SN/A * Copyright (c) 2003 The Regents of The University of Michigan 32068SN/A * All rights reserved. 42068SN/A * 52068SN/A * Redistribution and use in source and binary forms, with or without 62068SN/A * modification, are permitted provided that the following conditions are 72068SN/A * met: redistributions of source code must retain the above copyright 82068SN/A * notice, this list of conditions and the following disclaimer; 92068SN/A * redistributions in binary form must reproduce the above copyright 102068SN/A * notice, this list of conditions and the following disclaimer in the 112068SN/A * documentation and/or other materials provided with the distribution; 122068SN/A * neither the name of the copyright holders nor the names of its 132068SN/A * contributors may be used to endorse or promote products derived from 142068SN/A * this software without specific prior written permission. 152068SN/A * 162068SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172068SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182068SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192068SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202068SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212068SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222068SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232068SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242068SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252068SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262068SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272068SN/A */ 282068SN/A 292649Ssaidi@eecs.umich.edu#include <iostream> 302649Ssaidi@eecs.umich.edu#include "cpu/static_inst.hh" 312649Ssaidi@eecs.umich.edu#include "sim/universe.hh" 322649Ssaidi@eecs.umich.edu 332649Ssaidi@eecs.umich.edutemplate <class ISA> 342068SN/AStaticInstPtr<ISA> StaticInst<ISA>::nullStaticInstPtr; 352068SN/A 362068SN/Atemplate <class ISA> 372068SN/Atypename StaticInst<ISA>::DecodeCache StaticInst<ISA>::decodeCache; 382068SN/A 392068SN/A// Define the decode cache hash map. 402068SN/Atemplate StaticInst<AlphaISA>::DecodeCache 412068SN/AStaticInst<AlphaISA>::decodeCache; 422068SN/A 432068SN/Atemplate <class ISA> 442227SN/Avoid 452068SN/AStaticInst<ISA>::dumpDecodeCacheStats() 462068SN/A{ 472068SN/A using namespace std; 482068SN/A 492068SN/A cerr << "Decode hash table stats @ " << curTick << ":" << endl; 502068SN/A cerr << "\tnum entries = " << decodeCache.size() << endl; 512068SN/A cerr << "\tnum buckets = " << decodeCache.bucket_count() << endl; 522068SN/A vector<int> hist(100, 0); 532068SN/A int max_hist = 0; 542068SN/A for (int i = 0; i < decodeCache.bucket_count(); ++i) { 552068SN/A int count = decodeCache.elems_in_bucket(i); 562068SN/A if (count > max_hist) 572068SN/A max_hist = count; 582068SN/A hist[count]++; 592068SN/A } 602068SN/A for (int i = 0; i <= max_hist; ++i) { 612068SN/A cerr << "\tbuckets of size " << i << " = " << hist[i] << endl; 622068SN/A } 632068SN/A} 642068SN/A 652068SN/A 662068SN/Atemplate StaticInstPtr<AlphaISA> 672068SN/AStaticInst<AlphaISA>::nullStaticInstPtr; 682068SN/A 692068SN/Atemplate <class ISA> 702068SN/Abool 712068SN/AStaticInst<ISA>::hasBranchTarget(Addr pc, ExecContext *xc, Addr &tgt) 722068SN/A{ 732068SN/A if (isDirectCtrl()) { 742068SN/A tgt = branchTarget(pc); 752068SN/A return true; 762068SN/A } 772068SN/A 782068SN/A if (isIndirectCtrl()) { 792068SN/A tgt = branchTarget(xc); 802068SN/A return true; 812068SN/A } 822068SN/A 832068SN/A return false; 842068SN/A} 852068SN/A 862068SN/A 872068SN/A// force instantiation of template function(s) above 882068SN/Atemplate StaticInst<AlphaISA>; 892068SN/A