gem5  v22.1.0.0
amo.hh
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 
30 #ifndef __ARCH_RISCV_INSTS_AMO_HH__
31 #define __ARCH_RISCV_INSTS_AMO_HH__
32 
33 #include <string>
34 
35 #include "arch/riscv/insts/mem.hh"
37 #include "cpu/static_inst.hh"
38 
39 namespace gem5
40 {
41 
42 namespace RiscvISA
43 {
44 
45 // memfence micro instruction
47 {
48  public:
49  MemFenceMicro(ExtMachInst _machInst, OpClass __opClass)
50  : RiscvMicroInst("fence", _machInst, __opClass)
51  { }
52  protected:
54 
55  Fault execute(ExecContext *, trace::InstRecord *) const override;
56  std::string generateDisassembly(
57  Addr pc, const loader::SymbolTable *symtab) const override;
58 };
59 
60 // load-reserved
62 {
63  protected:
65 
66  std::string generateDisassembly(
67  Addr pc, const loader::SymbolTable *symtab) const override;
68 };
69 
71 {
72  protected:
75 
76  std::string generateDisassembly(
77  Addr pc, const loader::SymbolTable *symtab) const override;
78 };
79 
80 // store-cond
81 class StoreCond : public RiscvMacroInst
82 {
83  protected:
85 
86  std::string generateDisassembly(
87  Addr pc, const loader::SymbolTable *symtab) const override;
88 };
89 
91 {
92  protected:
95 
96  std::string generateDisassembly(
97  Addr pc, const loader::SymbolTable *symtab) const override;
98 };
99 
100 // AMOs
102 {
103  protected:
105 
106  std::string generateDisassembly(
107  Addr pc, const loader::SymbolTable *symtab) const override;
108 };
109 
111 {
112  protected:
115 
116  std::string generateDisassembly(
117  Addr pc, const loader::SymbolTable *symtab) const override;
118 };
119 
124 template<typename T>
126 {
127  public:
128  AtomicGenericOp(T _a, std::function<void(T*,T)> _op)
129  : a(_a), op(_op) { }
130  AtomicOpFunctor* clone() { return new AtomicGenericOp<T>(*this); }
131  void execute(T *b) { op(b, a); }
132  private:
133  T a;
134  std::function<void(T*,T)> op;
135 };
136 
137 } // namespace RiscvISA
138 } // namespace gem5
139 
140 #endif // __ARCH_RISCV_INSTS_AMO_HH__
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition: exec_context.hh:72
A generic atomic op class.
Definition: amo.hh:126
AtomicOpFunctor * clone()
Definition: amo.hh:130
AtomicGenericOp(T _a, std::function< void(T *, T)> _op)
Definition: amo.hh:128
std::function< void(T *, T)> op
Definition: amo.hh:134
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:140
Request::Flags memAccessFlags
Definition: amo.hh:113
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:122
Request::Flags memAccessFlags
Definition: amo.hh:73
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:81
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:64
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:48
MemFenceMicro(ExtMachInst _machInst, OpClass __opClass)
Definition: amo.hh:49
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition: amo.cc:56
Base class for all RISC-V Macroops.
Definition: static_inst.hh:99
RiscvMacroInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:103
Base class for all RISC-V Microops.
Definition: static_inst.hh:142
RiscvMicroInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:144
Request::Flags memAccessFlags
Definition: amo.hh:93
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:110
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: amo.cc:92
Bitfield< 7 > b
Definition: misc_types.hh:388
uint64_t ExtMachInst
Definition: types.hh:54
Bitfield< 4 > pc
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
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