decode_cache.cc revision 9024
11156SN/A/* 21762SN/A * Copyright (c) 2011-2012 Google 31156SN/A * All rights reserved. 41156SN/A * 51156SN/A * Redistribution and use in source and binary forms, with or without 61156SN/A * modification, are permitted provided that the following conditions are 71156SN/A * met: redistributions of source code must retain the above copyright 81156SN/A * notice, this list of conditions and the following disclaimer; 91156SN/A * redistributions in binary form must reproduce the above copyright 101156SN/A * notice, this list of conditions and the following disclaimer in the 111156SN/A * documentation and/or other materials provided with the distribution; 121156SN/A * neither the name of the copyright holders nor the names of its 131156SN/A * contributors may be used to endorse or promote products derived from 141156SN/A * this software without specific prior written permission. 151156SN/A * 161156SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 171156SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 181156SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 191156SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 201156SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 211156SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 221156SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 231156SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 241156SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 251156SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 261156SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Authors: Gabe Black 291156SN/A */ 301156SN/A 3111263Sandreas.sandberg@arm.com#include "arch/generic/decode_cache.hh" 3211263Sandreas.sandberg@arm.com#include "arch/decoder.hh" 331156SN/A#include "arch/types.hh" 342566SN/A#include "config/the_isa.hh" 351156SN/A#include "cpu/static_inst.hh" 361156SN/A 379850SN/Anamespace GenericISA 384762SN/A{ 3911263Sandreas.sandberg@arm.com 409850SN/AStaticInstPtr 418641SN/ABasicDecodeCache::decode(TheISA::Decoder *decoder, 425882SN/A TheISA::ExtMachInst mach_inst, Addr addr) 431156SN/A{ 446216SN/A StaticInstPtr &si = decodePages.lookup(addr); 456658SN/A if (si && (si->machInst == mach_inst)) 468232SN/A return si; 4711263Sandreas.sandberg@arm.com 482566SN/A DecodeCache::InstMap::iterator iter = instMap.find(mach_inst); 493348SN/A if (iter != instMap.end()) { 501156SN/A si = iter->second; 511157SN/A return si; 521156SN/A } 535603SN/A 541156SN/A si = decoder->decodeInst(mach_inst); 552107SN/A instMap[mach_inst] = si; 561156SN/A return si; 571156SN/A} 581156SN/A 591156SN/A} // namespace GenericISA 601156SN/A