decode_cache.cc revision 9024
19022SN/A/* 29022SN/A * Copyright (c) 2011-2012 Google 39022SN/A * All rights reserved. 49022SN/A * 59022SN/A * Redistribution and use in source and binary forms, with or without 69022SN/A * modification, are permitted provided that the following conditions are 79022SN/A * met: redistributions of source code must retain the above copyright 89022SN/A * notice, this list of conditions and the following disclaimer; 99022SN/A * redistributions in binary form must reproduce the above copyright 109022SN/A * notice, this list of conditions and the following disclaimer in the 119022SN/A * documentation and/or other materials provided with the distribution; 129022SN/A * neither the name of the copyright holders nor the names of its 139022SN/A * contributors may be used to endorse or promote products derived from 149022SN/A * this software without specific prior written permission. 159022SN/A * 169022SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179022SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189022SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199022SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209022SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219022SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229022SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239022SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249022SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259022SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269022SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279022SN/A * 289022SN/A * Authors: Gabe Black 299022SN/A */ 309022SN/A 319024Sgblack@eecs.umich.edu#include "arch/generic/decode_cache.hh" 329022SN/A#include "arch/decoder.hh" 339022SN/A#include "arch/types.hh" 349022SN/A#include "config/the_isa.hh" 359022SN/A#include "cpu/static_inst.hh" 369022SN/A 379024Sgblack@eecs.umich.edunamespace GenericISA 389022SN/A{ 399022SN/A 409022SN/AStaticInstPtr 419024Sgblack@eecs.umich.eduBasicDecodeCache::decode(TheISA::Decoder *decoder, 429024Sgblack@eecs.umich.edu TheISA::ExtMachInst mach_inst, Addr addr) 439022SN/A{ 449024Sgblack@eecs.umich.edu StaticInstPtr &si = decodePages.lookup(addr); 459022SN/A if (si && (si->machInst == mach_inst)) 469022SN/A return si; 479022SN/A 489024Sgblack@eecs.umich.edu DecodeCache::InstMap::iterator iter = instMap.find(mach_inst); 499022SN/A if (iter != instMap.end()) { 509022SN/A si = iter->second; 519022SN/A return si; 529022SN/A } 539022SN/A 549022SN/A si = decoder->decodeInst(mach_inst); 559022SN/A instMap[mach_inst] = si; 569022SN/A return si; 579022SN/A} 589024Sgblack@eecs.umich.edu 599024Sgblack@eecs.umich.edu} // namespace GenericISA 60