gem5  v22.1.0.0
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 
38 #include "arch/riscv/regs/misc.hh"
39 #include "cpu/exec_context.hh"
40 #include "cpu/static_inst.hh"
41 
42 namespace gem5
43 {
44 
45 namespace RiscvISA
46 {
47 
51 class RegOp : public RiscvStaticInst
52 {
53  protected:
55 
56  std::string generateDisassembly(
57  Addr pc, const loader::SymbolTable *symtab) const override;
58 };
59 
63 template<typename I>
64 class ImmOp : public RiscvStaticInst
65 {
66  protected:
67  I imm;
68 
69  ImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
70  : RiscvStaticInst(mnem, _machInst, __opClass), imm(0)
71  {}
72 };
73 
77 class SystemOp : public RiscvStaticInst
78 {
79  protected:
81 
82  std::string generateDisassembly(
83  Addr pc, const loader::SymbolTable *symtab) const override;
84 };
85 
89 class CSROp : public RiscvStaticInst
90 {
91  protected:
92  uint64_t csr;
93  uint64_t uimm;
94 
96  CSROp(const char *mnem, MachInst _machInst, OpClass __opClass)
97  : RiscvStaticInst(mnem, _machInst, __opClass),
99  {
100  if (csr == CSR_SATP) {
101  flags[IsSquashAfter] = true;
102  }
103  }
104 
105  std::string generateDisassembly(
106  Addr pc, const loader::SymbolTable *symtab) const override;
107 };
108 
109 } // namespace RiscvISA
110 } // namespace gem5
111 
112 #endif // __ARCH_RISCV_STANDARD_INST_HH__
#define FUNCT12
Definition: bitfields.hh:7
#define CSRIMM
Definition: bitfields.hh:6
Base class for CSR operations.
Definition: standard.hh:90
CSROp(const char *mnem, MachInst _machInst, OpClass __opClass)
Constructor.
Definition: standard.hh:96
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:61
Base class for operations with immediates (I is the type of immediate)
Definition: standard.hh:65
ImmOp(const char *mnem, MachInst _machInst, OpClass __opClass)
Definition: standard.hh:69
Base class for operations that work only on registers.
Definition: standard.hh:52
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:48
Base class for all RISC-V static instructions.
Definition: static_inst.hh:52
RiscvStaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:54
Base class for system operations.
Definition: standard.hh:78
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: standard.cc:78
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition: static_inst.hh:103
uint32_t MachInst
Definition: types.hh:53
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