gem5 v24.0.0.0
Loading...
Searching...
No Matches
static_inst.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include "cpu/static_inst.hh"
30
31#include <iostream>
32
33#include "cpu/thread_context.hh"
34
35namespace gem5
36{
37
40{
41 panic("StaticInst::fetchMicroop() called on instruction "
42 "that is not microcoded.");
43}
44
45std::unique_ptr<PCStateBase>
47{
48 panic("StaticInst::branchTarget() called on instruction "
49 "that is not a PC-relative branch.");
50}
51
52std::unique_ptr<PCStateBase>
54{
55 panic("StaticInst::branchTarget() called on instruction "
56 "that is not an indirect branch.");
57}
58
59const std::string &
61{
62 if (!cachedDisassembly) {
64 std::make_unique<std::string>(generateDisassembly(pc, symtab));
65 }
66
67 return *cachedDisassembly;
68}
69
70void
71StaticInst::printFlags(std::ostream &outs,
72 const std::string &separator) const
73{
74 bool printed_a_flag = false;
75
76 for (unsigned int flag = IsNop; flag < Num_Flags; flag++) {
77 if (flags[flag]) {
78 if (printed_a_flag)
79 outs << separator;
80
81 outs << FlagsStrings[flag];
82 printed_a_flag = true;
83 }
84 }
85}
86
87void
89{
90 std::unique_ptr<PCStateBase> pc(tc->pcState().clone());
91 advancePC(*pc);
92 tc->pcState(*pc);
93}
94
95} // namespace gem5
virtual PCStateBase * clone() const =0
void printFlags(std::ostream &outs, const std::string &separator) const
Print a separator separated list of this instruction's set flag names on the given stream.
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
virtual StaticInstPtr fetchMicroop(MicroPC upc) const
Return the microop that goes with a particular micropc.
virtual std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const =0
Internal function to generate disassembly string.
std::unique_ptr< std::string > cachedDisassembly
String representation of disassembly (lazily evaluated via disassemble()).
virtual std::unique_ptr< PCStateBase > branchTarget(const PCStateBase &pc) const
Return the target address for a PC-relative branch.
virtual void advancePC(PCStateBase &pc_state) const =0
std::bitset< Num_Flags > flags
Flag values for this instruction.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual const PCStateBase & pcState() const =0
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 4 > pc
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
RefCountingPtr< StaticInst > StaticInstPtr
uint16_t MicroPC
Definition types.hh:149

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0