gem5  v20.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/utility.hh"
38 #include "cpu/static_inst.hh"
39 
40 using namespace std;
41 
42 namespace RiscvISA
43 {
44 
45 string
47 {
48  stringstream ss;
49  ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", " <<
50  registerName(_srcRegIdx[0]);
51  if (_numSrcRegs >= 2)
52  ss << ", " << registerName(_srcRegIdx[1]);
53  if (_numSrcRegs >= 3)
54  ss << ", " << registerName(_srcRegIdx[2]);
55  return ss.str();
56 }
57 
58 string
59 CSROp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const
60 {
61  stringstream ss;
62  ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", ";
63  auto data = CSRData.find(csr);
64  if (data != CSRData.end())
65  ss << data->second.name;
66  else
67  ss << "?? (" << hex << "0x" << csr << dec << ")";
68  if (_numSrcRegs > 0)
69  ss << ", " << registerName(_srcRegIdx[0]);
70  else
71  ss << uimm;
72  return ss.str();
73 }
74 
75 string
76 SystemOp::generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const
77 {
78  if (strcmp(mnemonic, "fence_vma") == 0) {
79  stringstream ss;
80  ss << mnemonic << ' ' << registerName(_srcRegIdx[0]) << ", " <<
81  registerName(_srcRegIdx[1]);
82  return ss.str();
83  }
84 
85  return mnemonic;
86 }
87 
88 }
RegOp::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: misc.cc:204
data
const char data[]
Definition: circlebuf.test.cc:42
Loader::SymbolTable
Definition: symtab.hh:59
RiscvISA
Definition: fs_workload.cc:36
ArmISA::ss
Bitfield< 21 > ss
Definition: miscregs_types.hh:56
standard.hh
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
static_inst.hh
static_inst.hh
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
RiscvISA::registerName
std::string registerName(RegId reg)
Definition: utility.hh:139
utility.hh
RiscvISA::CSRData
const std::map< int, CSRMetadata > CSRData
Definition: registers.hh:430

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17