gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
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
30
31#include <string>
32
33#include "arch/riscv/pcstate.hh"
35#include "arch/riscv/utility.hh"
36
37namespace gem5
38{
39
40namespace RiscvISA
41{
42
44 : RiscvStaticInst("cm.jalt", machInst, IntAluOp), jvtEntry(entry)
45{
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
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
70std::string
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
80std::unique_ptr<PCStateBase>
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
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual const PCStateBase & pcState() const =0
Target & as()
Definition pcstate.hh:73
void zcmtPc(Addr a)
Definition pcstate.hh:123
void zcmtSecondFetch(bool z)
Definition pcstate.hh:120
int64_t rvSext(int64_t x) const
RiscvStaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition zcmt.cc:71
std::unique_ptr< PCStateBase > branchTarget(const PCStateBase &branch_pc) const override
Return the target address for a PC-relative branch.
Definition zcmt.cc:81
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition zcmt.cc:58
ZcmtSecondFetchInst(ExtMachInst machInst, Addr entry)
Constructor.
Definition zcmt.cc:43
void setRegIdxArrays(RegIdArrayPtr src, RegIdArrayPtr dest)
Set the pointers which point to the arrays of source and destination register indices.
RegId(StaticInst::*)[] RegIdArrayPtr
const char * mnemonic
Base mnemonic (e.g., "add").
std::bitset< Num_Flags > flags
Flag values for this instruction.
Bitfield< 12, 11 > set
Bitfield< 11, 8 > ss
Bitfield< 4 > pc
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
static const OpClass IntAluOp
Definition op_class.hh:56
constexpr decltype(nullptr) NoFault
Definition types.hh:253

Generated on Mon May 26 2025 09:19:06 for gem5 by doxygen 1.13.2