gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
standard.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  * 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 
31 #ifndef __ARCH_RISCV_STANDARD_INST_HH__
32 #define __ARCH_RISCV_STANDARD_INST_HH__
33 
34 #include <string>
35 
37 #include "arch/riscv/regs/misc.hh"
38 #include "cpu/exec_context.hh"
39 #include "cpu/static_inst.hh"
40 
41 namespace gem5
42 {
43 
44 namespace RiscvISA
45 {
46 
50 class RegOp : public RiscvStaticInst
51 {
52  protected:
54 
55  std::string generateDisassembly(
56  Addr pc, const loader::SymbolTable *symtab) const override;
57 };
58 
62 template<typename I>
63 class ImmOp : public RiscvStaticInst
64 {
65  protected:
66  I imm;
67 
68  ImmOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
69  : RiscvStaticInst(mnem, _machInst, __opClass), imm(0)
70  {}
71 };
72 
76 class SystemOp : public RiscvStaticInst
77 {
78  protected:
80 
81  std::string generateDisassembly(
82  Addr pc, const loader::SymbolTable *symtab) const override;
83 };
84 
88 class CSROp : public RiscvStaticInst
89 {
90  protected:
91  uint64_t csr;
92  uint64_t uimm;
93 
95  CSROp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
96  : RiscvStaticInst(mnem, _machInst, __opClass),
97  csr(_machInst.funct12), uimm(_machInst.csrimm)
98  {
99  if (csr == CSR_SATP) {
100  flags[IsSquashAfter] = true;
101  }
102  }
103 
104  std::string generateDisassembly(
105  Addr pc, const loader::SymbolTable *symtab) const override;
106 };
107 
108 } // namespace RiscvISA
109 } // namespace gem5
110 
111 #endif // __ARCH_RISCV_STANDARD_INST_HH__
gem5::RiscvISA::csrimm
Bitfield< 19, 15 > csrimm
Definition: types.hh:108
gem5::RiscvISA::SystemOp::generateDisassembly
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:78
gem5::RiscvISA::RiscvStaticInst
Base class for all RISC-V static instructions.
Definition: static_inst.hh:51
gem5::RiscvISA::RiscvStaticInst::RiscvStaticInst
RiscvStaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:54
gem5::loader::SymbolTable
Definition: symtab.hh:64
gem5::RiscvISA::CSROp::uimm
uint64_t uimm
Definition: standard.hh:92
gem5::RiscvISA::SystemOp
Base class for system operations.
Definition: standard.hh:76
misc.hh
gem5::RiscvISA::CSROp
Base class for CSR operations.
Definition: standard.hh:88
gem5::RiscvISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:243
gem5::StaticInst::flags
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition: static_inst.hh:102
static_inst.hh
gem5::RiscvISA::ImmOp
Base class for operations with immediates (I is the type of immediate)
Definition: standard.hh:63
gem5::RiscvISA::CSR_SATP
@ CSR_SATP
Definition: misc.hh:338
static_inst.hh
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::RiscvISA::funct12
Bitfield< 31, 20 > funct12
Definition: types.hh:107
gem5::RiscvISA::CSROp::CSROp
CSROp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Constructor.
Definition: standard.hh:95
gem5::X86ISA::ExtMachInst
Definition: types.hh:212
gem5::RiscvISA::RegOp::generateDisassembly
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:48
exec_context.hh
gem5::RiscvISA::CSROp::generateDisassembly
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:61
gem5::RiscvISA::ImmOp::ImmOp
ImmOp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: standard.hh:68
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::RiscvISA::RegOp
Base class for operations that work only on registers.
Definition: standard.hh:50
gem5::RiscvISA::CSROp::csr
uint64_t csr
Definition: standard.hh:91
gem5::RiscvISA::ImmOp::imm
I imm
Definition: standard.hh:66

Generated on Sun Jul 30 2023 01:56:50 for gem5 by doxygen 1.8.17