gem5  v22.1.0.0
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 
35 namespace gem5
36 {
37 
40 {
41  panic("StaticInst::fetchMicroop() called on instruction "
42  "that is not microcoded.");
43 }
44 
45 std::unique_ptr<PCStateBase>
47 {
48  panic("StaticInst::branchTarget() called on instruction "
49  "that is not a PC-relative branch.");
50 }
51 
52 std::unique_ptr<PCStateBase>
54 {
55  panic("StaticInst::branchTarget() called on instruction "
56  "that is not an indirect branch.");
57 }
58 
59 const std::string &
61 {
62  if (!cachedDisassembly) {
64  std::make_unique<std::string>(generateDisassembly(pc, symtab));
65  }
66 
67  return *cachedDisassembly;
68 }
69 
70 void
71 StaticInst::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 
87 void
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.
Definition: static_inst.cc:71
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
Definition: static_inst.cc:60
virtual StaticInstPtr fetchMicroop(MicroPC upc) const
Return the microop that goes with a particular micropc.
Definition: static_inst.cc:39
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()).
Definition: static_inst.hh:265
virtual std::unique_ptr< PCStateBase > branchTarget(const PCStateBase &pc) const
Return the target address for a PC-relative branch.
Definition: static_inst.cc:46
virtual void advancePC(PCStateBase &pc_state) const =0
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition: static_inst.hh:103
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:178
Bitfield< 4 > pc
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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 Wed Dec 21 2022 10:22:26 for gem5 by doxygen 1.9.1