gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
amo.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  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Authors: Alec Roelke
30  */
31 
32 #include "arch/riscv/insts/amo.hh"
33 
34 #include <sstream>
35 #include <string>
36 
38 #include "arch/riscv/utility.hh"
39 #include "cpu/exec_context.hh"
40 #include "cpu/static_inst.hh"
41 
42 using namespace std;
43 
44 namespace RiscvISA
45 {
46 
47 // memfence micro instruction
48 string MemFenceMicro::generateDisassembly(Addr pc,
49  const SymbolTable *symtab) const
50 {
51  stringstream ss;
52  ss << csprintf("0x%08x", machInst) << ' ' << mnemonic;
53  return ss.str();
54 }
55 
56 Fault MemFenceMicro::execute(ExecContext *xc,
57  Trace::InstRecord *traceData) const
58 {
59  return NoFault;
60 }
61 
62 // load-reserved
63 string LoadReserved::generateDisassembly(Addr pc,
64  const SymbolTable *symtab) const
65 {
66  stringstream ss;
67  ss << mnemonic;
68  if (AQ || RL)
69  ss << '_';
70  if (AQ)
71  ss << "aq";
72  if (RL)
73  ss << "rl";
74  ss << ' ' << registerName(RegId(IntRegClass, RD)) << ", ("
75  << registerName(RegId(IntRegClass, RS1)) << ')';
76  return ss.str();
77 }
78 
79 string LoadReservedMicro::generateDisassembly(Addr pc,
80  const SymbolTable *symtab) const
81 {
82  stringstream ss;
83  ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", ("
84  << registerName(_srcRegIdx[0]) << ')';
85  return ss.str();
86 }
87 
88 // store-conditional
89 string StoreCond::generateDisassembly(Addr pc,
90  const SymbolTable *symtab) const
91 {
92  stringstream ss;
93  ss << mnemonic;
94  if (AQ || RL)
95  ss << '_';
96  if (AQ)
97  ss << "aq";
98  if (RL)
99  ss << "rl";
100  ss << ' ' << registerName(RegId(IntRegClass, RD)) << ", "
101  << registerName(RegId(IntRegClass, RS2)) << ", ("
102  << registerName(RegId(IntRegClass, RS1)) << ')';
103  return ss.str();
104 }
105 
106 string StoreCondMicro::generateDisassembly(Addr pc,
107  const SymbolTable *symtab) const
108 {
109  stringstream ss;
110  ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "
111  << registerName(_srcRegIdx[1]) << ", ("
112  << registerName(_srcRegIdx[0]) << ')';
113  return ss.str();
114 }
115 
116 // AMOs
117 string AtomicMemOp::generateDisassembly(Addr pc,
118  const SymbolTable *symtab) const
119 {
120  stringstream ss;
121  ss << mnemonic;
122  if (AQ || RL)
123  ss << '_';
124  if (AQ)
125  ss << "aq";
126  if (RL)
127  ss << "rl";
128  ss << ' ' << registerName(RegId(IntRegClass, RD)) << ", "
129  << registerName(RegId(IntRegClass, RS2)) << ", ("
130  << registerName(RegId(IntRegClass, RS1)) << ')';
131  return ss.str();
132 }
133 
134 string AtomicMemOpMicro::generateDisassembly(Addr pc,
135  const SymbolTable *symtab) const
136 {
137  stringstream ss;
138  ss << mnemonic << ' ' << registerName(_destRegIdx[0]) << ", "
139  << registerName(_srcRegIdx[1]) << ", ("
140  << registerName(_srcRegIdx[0]) << ')';
141  return ss.str();
142 }
143 
144 }
decltype(nullptr) constexpr NoFault
Definition: types.hh:245
#define RS1
Definition: bitfields.hh:16
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:73
std::string registerName(RegId reg)
Definition: utility.hh:132
Bitfield< 4 > pc
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:162
#define RD
Definition: bitfields.hh:14
Bitfield< 21 > ss
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
#define RL
Definition: bitfields.hh:15
#define RS2
Definition: bitfields.hh:17
#define AQ
Definition: bitfields.hh:13
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:79
Integer register.
Definition: reg_class.hh:57
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240

Generated on Fri Feb 28 2020 16:26:57 for gem5 by doxygen 1.8.13