static_inst.cc revision 8541:27aaee8ec7cc
12068SN/A/*
22068SN/A * Copyright (c) 2003-2005 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 *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
292665Ssaidi@eecs.umich.edu *          Nathan Binkert
302068SN/A */
312649Ssaidi@eecs.umich.edu
322649Ssaidi@eecs.umich.edu#include <iostream>
332649Ssaidi@eecs.umich.edu
342649Ssaidi@eecs.umich.edu#include "cpu/static_inst.hh"
352649Ssaidi@eecs.umich.edu#include "sim/core.hh"
362068SN/A
372068SN/AStaticInstPtr StaticInst::nullStaticInstPtr;
382068SN/A
392068SN/Ausing namespace std;
402068SN/A
412068SN/AStaticInst::~StaticInst()
422068SN/A{
432068SN/A    if (cachedDisassembly)
442068SN/A        delete cachedDisassembly;
452068SN/A}
462068SN/A
472068SN/Abool
482068SN/AStaticInst::hasBranchTarget(const TheISA::PCState &pc, ThreadContext *tc,
492068SN/A                            TheISA::PCState &tgt) const
502068SN/A{
512068SN/A    if (isDirectCtrl()) {
522068SN/A        tgt = branchTarget(pc);
532068SN/A        return true;
542068SN/A    }
552068SN/A
562227SN/A    if (isIndirectCtrl()) {
572068SN/A        tgt = branchTarget(tc);
582068SN/A        return true;
592068SN/A    }
602068SN/A
612068SN/A    return false;
622068SN/A}
632068SN/A
642068SN/AStaticInstPtr
652068SN/AStaticInst::fetchMicroop(MicroPC upc) const
662068SN/A{
672068SN/A    panic("StaticInst::fetchMicroop() called on instruction "
682068SN/A          "that is not microcoded.");
692068SN/A}
702068SN/A
712068SN/ATheISA::PCState
722068SN/AStaticInst::branchTarget(const TheISA::PCState &pc) const
732068SN/A{
742068SN/A    panic("StaticInst::branchTarget() called on instruction "
752068SN/A          "that is not a PC-relative branch.");
762068SN/A    M5_DUMMY_RETURN;
772068SN/A}
782227SN/A
792068SN/ATheISA::PCState
802068SN/AStaticInst::branchTarget(ThreadContext *tc) const
812068SN/A{
822068SN/A    panic("StaticInst::branchTarget() called on instruction "
832068SN/A          "that is not an indirect branch.");
8412616Sgabeblack@google.com    M5_DUMMY_RETURN;
8512616Sgabeblack@google.com}
862068SN/A
879552Sandreas.hansson@arm.comconst string &
889552Sandreas.hansson@arm.comStaticInst::disassemble(Addr pc, const SymbolTable *symtab) const
899552Sandreas.hansson@arm.com{
9012616Sgabeblack@google.com    if (!cachedDisassembly)
9112616Sgabeblack@google.com        cachedDisassembly = new string(generateDisassembly(pc, symtab));
922068SN/A
932068SN/A    return *cachedDisassembly;
942068SN/A}
952068SN/A