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"
3211793Sbrandon.potter@amd.com
339022SN/A#include "arch/decoder.hh"
349022SN/A#include "arch/types.hh"
359022SN/A#include "config/the_isa.hh"
369022SN/A#include "cpu/static_inst.hh"
379022SN/A
389024Sgblack@eecs.umich.edunamespace GenericISA
399022SN/A{
409022SN/A
419022SN/AStaticInstPtr
429024Sgblack@eecs.umich.eduBasicDecodeCache::decode(TheISA::Decoder *decoder,
439024Sgblack@eecs.umich.edu        TheISA::ExtMachInst mach_inst, Addr addr)
449022SN/A{
459024Sgblack@eecs.umich.edu    StaticInstPtr &si = decodePages.lookup(addr);
469022SN/A    if (si && (si->machInst == mach_inst))
479022SN/A        return si;
489022SN/A
4912621Sgabeblack@google.com    auto iter = instMap.find(mach_inst);
509022SN/A    if (iter != instMap.end()) {
519022SN/A        si = iter->second;
529022SN/A        return si;
539022SN/A    }
549022SN/A
559022SN/A    si = decoder->decodeInst(mach_inst);
569022SN/A    instMap[mach_inst] = si;
579022SN/A    return si;
589022SN/A}
599024Sgblack@eecs.umich.edu
609024Sgblack@eecs.umich.edu} // namespace GenericISA
61