gem5
v21.0.1.0
arch
riscv
insts
static_inst.hh
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 RISC-V Foundation
3
* Copyright (c) 2016 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_STATIC_INST_HH__
31
#define __ARCH_RISCV_STATIC_INST_HH__
32
33
#include <string>
34
35
#include "
arch/riscv/types.hh
"
36
#include "
cpu/exec_context.hh
"
37
#include "
cpu/static_inst.hh
"
38
#include "
mem/packet.hh
"
39
40
namespace
RiscvISA
41
{
42
46
class
RiscvStaticInst
:
public
StaticInst
47
{
48
protected
:
49
using
StaticInst::StaticInst
;
50
51
public
:
52
void
advancePC
(
PCState
&
pc
)
const override
{
pc
.advance(); }
53
54
size_t
55
asBytes
(
void
*buf,
size_t
size)
override
56
{
57
return
simpleAsBytes
(buf, size,
machInst
);
58
}
59
};
60
64
class
RiscvMacroInst
:
public
RiscvStaticInst
65
{
66
protected
:
67
std::vector<StaticInstPtr>
microops
;
68
69
RiscvMacroInst
(
const
char
*mnem,
ExtMachInst
_machInst,
70
OpClass __opClass) :
71
RiscvStaticInst
(mnem, _machInst, __opClass)
72
{
73
flags
[IsMacroop] =
true
;
74
}
75
76
~RiscvMacroInst
() {
microops
.clear(); }
77
78
StaticInstPtr
79
fetchMicroop
(
MicroPC
upc)
const override
80
{
81
return
microops
[upc];
82
}
83
84
Fault
85
initiateAcc
(
ExecContext
*xc,
Trace::InstRecord
*traceData)
const override
86
{
87
panic
(
"Tried to execute a macroop directly!\n"
);
88
}
89
90
Fault
91
completeAcc
(
PacketPtr
pkt,
ExecContext
*xc,
92
Trace::InstRecord
*traceData)
const override
93
{
94
panic
(
"Tried to execute a macroop directly!\n"
);
95
}
96
97
Fault
98
execute
(
ExecContext
*xc,
Trace::InstRecord
*traceData)
const override
99
{
100
panic
(
"Tried to execute a macroop directly!\n"
);
101
}
102
};
103
107
class
RiscvMicroInst
:
public
RiscvStaticInst
108
{
109
protected
:
110
RiscvMicroInst
(
const
char
*mnem,
ExtMachInst
_machInst,
111
OpClass __opClass) :
112
RiscvStaticInst
(mnem, _machInst, __opClass)
113
{
114
flags
[IsMicroop] =
true
;
115
}
116
117
void
advancePC
(
PCState
&pcState)
const override
;
118
};
119
120
}
121
122
#endif // __ARCH_RISCV_STATIC_INST_HH__
RiscvISA::RiscvMacroInst::RiscvMacroInst
RiscvMacroInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition:
static_inst.hh:69
RiscvISA::RiscvMacroInst::microops
std::vector< StaticInstPtr > microops
Definition:
static_inst.hh:67
StaticInst::flags
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition:
static_inst.hh:100
RiscvISA::PCState
Definition:
types.hh:53
RiscvISA::RiscvMacroInst
Base class for all RISC-V Macroops.
Definition:
static_inst.hh:64
RiscvISA::RiscvMicroInst::advancePC
void advancePC(PCState &pcState) const override
Definition:
static_inst.cc:39
StaticInst
Base, ISA-independent static instruction class.
Definition:
static_inst.hh:85
RiscvISA::pc
Bitfield< 4 > pc
Definition:
pra_constants.hh:240
Trace::InstRecord
Definition:
insttracer.hh:55
StaticInst::StaticInst
StaticInst(const char *_mnemonic, TheISA::ExtMachInst _machInst, OpClass __opClass)
Constructor.
Definition:
static_inst.hh:303
StaticInst::machInst
const TheISA::ExtMachInst machInst
The binary machine instruction.
Definition:
static_inst.hh:259
std::vector
STL vector class.
Definition:
stl.hh:37
RiscvISA
Definition:
fs_workload.cc:37
packet.hh
RiscvISA::RiscvMacroInst::initiateAcc
Fault initiateAcc(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition:
static_inst.hh:85
RiscvISA::RiscvStaticInst::asBytes
size_t asBytes(void *buf, size_t size) override
Instruction classes can override this function to return a a representation of themselves as a blob o...
Definition:
static_inst.hh:55
Fault
std::shared_ptr< FaultBase > Fault
Definition:
types.hh:246
types.hh
ExecContext
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition:
exec_context.hh:70
static_inst.hh
RiscvISA::ExtMachInst
uint64_t ExtMachInst
Definition:
types.hh:51
RiscvISA::RiscvStaticInst::advancePC
void advancePC(PCState &pc) const override
Definition:
static_inst.hh:52
RiscvISA::RiscvStaticInst
Base class for all RISC-V static instructions.
Definition:
static_inst.hh:46
StaticInst::simpleAsBytes
size_t simpleAsBytes(void *buf, size_t max_size, const T &t)
Definition:
static_inst.hh:383
RiscvISA::RiscvMicroInst
Base class for all RISC-V Microops.
Definition:
static_inst.hh:107
RiscvISA::RiscvMacroInst::~RiscvMacroInst
~RiscvMacroInst()
Definition:
static_inst.hh:76
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition:
packet.hh:258
RiscvISA::RiscvMacroInst::execute
Fault execute(ExecContext *xc, Trace::InstRecord *traceData) const override
Definition:
static_inst.hh:98
exec_context.hh
RefCountingPtr< StaticInst >
RiscvISA::RiscvMacroInst::fetchMicroop
StaticInstPtr fetchMicroop(MicroPC upc) const override
Return the microop that goes with a particular micropc.
Definition:
static_inst.hh:79
MicroPC
uint16_t MicroPC
Definition:
types.hh:150
RiscvISA::RiscvMacroInst::completeAcc
Fault completeAcc(PacketPtr pkt, ExecContext *xc, Trace::InstRecord *traceData) const override
Definition:
static_inst.hh:91
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition:
logging.hh:171
RiscvISA::RiscvMicroInst::RiscvMicroInst
RiscvMicroInst(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition:
static_inst.hh:110
Generated on Tue Jun 22 2021 15:28:20 for gem5 by
doxygen
1.8.17