gem5  v22.1.0.0
standard.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 RISC-V Foundation
3  * Copyright (c) 2017 The University of Virginia
4  * Copyright (c) 2020 Barkhausen Institut
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met: redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer;
11  * redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution;
14  * neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
32 
33 #include <sstream>
34 #include <string>
35 
37 #include "arch/riscv/regs/misc.hh"
38 #include "arch/riscv/utility.hh"
39 #include "cpu/static_inst.hh"
40 
41 namespace gem5
42 {
43 
44 namespace RiscvISA
45 {
46 
47 std::string
49 {
50  std::stringstream ss;
51  ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
53  if (_numSrcRegs >= 2)
54  ss << ", " << registerName(srcRegIdx(1));
55  if (_numSrcRegs >= 3)
56  ss << ", " << registerName(srcRegIdx(2));
57  return ss.str();
58 }
59 
60 std::string
62 {
63  std::stringstream ss;
64  ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
65  auto data = CSRData.find(csr);
66  if (data != CSRData.end())
67  ss << data->second.name;
68  else
69  ss << "?? (" << std::hex << "0x" << csr << std::dec << ")";
70  if (_numSrcRegs > 0)
71  ss << ", " << registerName(srcRegIdx(0));
72  else
73  ss << uimm;
74  return ss.str();
75 }
76 
77 std::string
79 {
80  if (strcmp(mnemonic, "fence_vma") == 0) {
81  std::stringstream ss;
82  ss << mnemonic << ' ' << registerName(srcRegIdx(0)) << ", " <<
84  return ss.str();
85  }
86 
87  return mnemonic;
88 }
89 
90 } // namespace RiscvISA
91 } // namespace gem5
const char data[]
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:61
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:48
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:78
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
Definition: static_inst.hh:225
uint8_t _numSrcRegs
See numSrcRegs().
Definition: static_inst.hh:109
const char * mnemonic
Base mnemonic (e.g., "add").
Definition: static_inst.hh:259
const RegId & destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
Definition: static_inst.hh:215
std::string registerName(RegId reg)
Definition: utility.hh:107
const std::unordered_map< int, CSRMetadata > CSRData
Definition: misc.hh:381
Bitfield< 11, 8 > ss
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

Generated on Wed Dec 21 2022 10:22:27 for gem5 by doxygen 1.9.1