gem5
[DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
arch
riscv
insts
zcmt.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024 Google LLC
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
7
* met: redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer;
9
* redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution;
12
* neither the name of the copyright holders nor the names of its
13
* contributors may be used to endorse or promote products derived from
14
* this software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#include "
arch/riscv/insts/zcmt.hh
"
30
31
#include <string>
32
33
#include "
arch/riscv/pcstate.hh
"
34
#include "
arch/riscv/regs/int.hh
"
35
#include "
arch/riscv/utility.hh
"
36
37
namespace
gem5
38
{
39
40
namespace
RiscvISA
41
{
42
43
ZcmtSecondFetchInst::ZcmtSecondFetchInst
(
ExtMachInst
machInst
,
Addr
entry)
44
:
RiscvStaticInst
(
"cm.jalt"
,
machInst
,
IntAluOp
),
jvtEntry
(entry)
45
{
46
setRegIdxArrays
(
47
reinterpret_cast<
RegIdArrayPtr
>
(
48
&std::remove_pointer_t<
decltype
(
this
)>
::srcRegIdxArr
),
49
reinterpret_cast<
RegIdArrayPtr
>
(
50
&std::remove_pointer_t<
decltype
(
this
)>
::destRegIdxArr
));
51
flags
[IsControl] =
true
;
52
flags
[IsDirectControl] =
true
;
53
flags
[IsInteger] =
true
;
54
flags
[IsUncondControl] =
true
;
55
}
56
57
Fault
58
ZcmtSecondFetchInst::execute
(
59
ExecContext
*xc,
trace::InstRecord
*traceData)
const
60
{
61
PCState
jvtPCState;
62
set
(jvtPCState, xc->
pcState
());
63
jvtPCState.
npc
(
rvSext
(
jvtEntry
& ~0x1));
64
jvtPCState.
zcmtSecondFetch
(
false
);
65
jvtPCState.
zcmtPc
(0);
66
xc->
pcState
(jvtPCState);
67
return
NoFault
;
68
}
69
70
std::string
71
ZcmtSecondFetchInst::generateDisassembly
(
72
Addr
pc
,
const
loader::SymbolTable
*symtab)
const
73
{
74
std::stringstream
ss
;
75
ss
<<
mnemonic
<<
" jvt entry ("
<< std::hex <<
rvSext
(
jvtEntry
& ~0x1)
76
<<
")"
;
77
return
ss
.str();
78
}
79
80
std::unique_ptr<PCStateBase>
81
ZcmtSecondFetchInst::branchTarget
(
82
const
PCStateBase
&branch_pc)
const
83
{
84
auto
&rpc = branch_pc.
as
<
RiscvISA::PCState
>();
85
std::unique_ptr<PCState> npc(
dynamic_cast<
PCState
*
>
(rpc.clone()));
86
npc->zcmtSecondFetch(
false
);
87
npc->zcmtPc(0);
88
npc->set(
rvSext
(
jvtEntry
& ~0x1));
89
return
npc;
90
}
91
92
}
// namespace RiscvISA
93
}
// namespace gem5
gem5::ExecContext
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
Definition
exec_context.hh:72
gem5::ExecContext::pcState
virtual const PCStateBase & pcState() const =0
gem5::GenericISA::PCStateWithNext::npc
Addr npc() const
Definition
pcstate.hh:274
gem5::PCStateBase
Definition
pcstate.hh:59
gem5::PCStateBase::as
Target & as()
Definition
pcstate.hh:73
gem5::RiscvISA::PCState
Definition
pcstate.hh:62
gem5::RiscvISA::PCState::zcmtPc
void zcmtPc(Addr a)
Definition
pcstate.hh:123
gem5::RiscvISA::PCState::zcmtSecondFetch
void zcmtSecondFetch(bool z)
Definition
pcstate.hh:120
gem5::RiscvISA::RiscvStaticInst::rvSext
int64_t rvSext(int64_t x) const
Definition
static_inst.hh:70
gem5::RiscvISA::RiscvStaticInst::RiscvStaticInst
RiscvStaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
Definition
static_inst.hh:55
gem5::RiscvISA::RiscvStaticInst::machInst
ExtMachInst machInst
Definition
static_inst.hh:73
gem5::RiscvISA::ZcmtSecondFetchInst::destRegIdxArr
RegId destRegIdxArr[0]
Definition
zcmt.hh:47
gem5::RiscvISA::ZcmtSecondFetchInst::jvtEntry
Addr jvtEntry
Definition
zcmt.hh:48
gem5::RiscvISA::ZcmtSecondFetchInst::generateDisassembly
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition
zcmt.cc:71
gem5::RiscvISA::ZcmtSecondFetchInst::branchTarget
std::unique_ptr< PCStateBase > branchTarget(const PCStateBase &branch_pc) const override
Return the target address for a PC-relative branch.
Definition
zcmt.cc:81
gem5::RiscvISA::ZcmtSecondFetchInst::execute
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition
zcmt.cc:58
gem5::RiscvISA::ZcmtSecondFetchInst::ZcmtSecondFetchInst
ZcmtSecondFetchInst(ExtMachInst machInst, Addr entry)
Constructor.
Definition
zcmt.cc:43
gem5::RiscvISA::ZcmtSecondFetchInst::srcRegIdxArr
RegId srcRegIdxArr[0]
Definition
zcmt.hh:46
gem5::StaticInst::setRegIdxArrays
void setRegIdxArrays(RegIdArrayPtr src, RegIdArrayPtr dest)
Set the pointers which point to the arrays of source and destination register indices.
Definition
static_inst.hh:251
gem5::StaticInst::RegIdArrayPtr
RegId(StaticInst::*)[] RegIdArrayPtr
Definition
static_inst.hh:91
gem5::StaticInst::mnemonic
const char * mnemonic
Base mnemonic (e.g., "add").
Definition
static_inst.hh:268
gem5::StaticInst::flags
std::bitset< Num_Flags > flags
Flag values for this instruction.
Definition
static_inst.hh:103
gem5::loader::SymbolTable
Definition
symtab.hh:152
gem5::trace::InstRecord
Definition
insttracer.hh:62
gem5::ArmISA::set
Bitfield< 12, 11 > set
Definition
misc_types.hh:805
gem5::RiscvISA
Definition
fs_workload.cc:41
gem5::RiscvISA::ss
Bitfield< 11, 8 > ss
Definition
pra_constants.hh:257
gem5::RiscvISA::pc
Bitfield< 4 > pc
Definition
pra_constants.hh:243
gem5
Copyright (c) 2024 Arm Limited All rights reserved.
Definition
binary32.hh:36
gem5::Fault
std::shared_ptr< FaultBase > Fault
Definition
types.hh:249
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition
types.hh:147
gem5::IntAluOp
static const OpClass IntAluOp
Definition
op_class.hh:56
gem5::NoFault
constexpr decltype(nullptr) NoFault
Definition
types.hh:253
pcstate.hh
int.hh
utility.hh
gem5::X86ISA::ExtMachInst
Definition
types.hh:213
zcmt.hh
Generated on Mon May 26 2025 09:19:06 for gem5 by
doxygen
1.13.2