gem5 v24.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
zcmp.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
34#include "arch/riscv/utility.hh"
35
36namespace gem5
37{
38
39namespace RiscvISA
40{
41
43 const char* mnem, ExtMachInst machInst, OpClass opClass)
44 : RiscvMacroInst(mnem, machInst, opClass), rlist(machInst.rlist)
45{
46}
47
48// Ref: https://github.com/riscv-software-src/riscv-isa-sim/blob/f7d0dba60/
49// riscv/decode.h#L168
50uint64_t
52{
53 uint64_t stack_adj_base = 0;
54 switch (machInst.rlist) {
55 case 15:
56 stack_adj_base += 16;
57 [[fallthrough]];
58 case 14:
59 if (machInst.rv_type == RV64) {
60 stack_adj_base += 16;
61 }
62 [[fallthrough]];
63 case 13:
64 case 12:
65 stack_adj_base += 16;
66 [[fallthrough]];
67 case 11:
68 case 10:
69 if (machInst.rv_type == RV64) {
70 stack_adj_base += 16;
71 }
72 [[fallthrough]];
73 case 9:
74 case 8:
75 stack_adj_base += 16;
76 [[fallthrough]];
77 case 7:
78 case 6:
79 if (machInst.rv_type == RV64) {
80 stack_adj_base += 16;
81 }
82 [[fallthrough]];
83 case 5:
84 case 4:
85 stack_adj_base += 16;
86 break;
87 }
88
89 return stack_adj_base + machInst.spimm * 16;
90}
91
92std::string
94{
95 std::string s = "";
96 switch (machInst.rlist) {
97 case 15:
98 s = csprintf("{%s, %s-%s}", registerName(ReturnAddrReg),
101 break;
102 case 14:
103 case 13:
104 case 12:
105 case 11:
106 case 10:
107 case 9:
108 case 8:
109 case 7:
110 case 6:
111 s = csprintf("{%s, %s-%s}", registerName(ReturnAddrReg),
114 break;
115 case 5:
116 s = csprintf("{%s, %s}", registerName(ReturnAddrReg),
118 break;
119 case 4:
121 break;
122 default:
123 break;
124 }
125
126 return s;
127}
128
129} // namespace RiscvISA
130} // namespace gem5
std::string getRlistStr() const
Definition zcmp.cc:93
uint64_t stackAdj() const
Definition zcmp.cc:51
CmMacroInst(const char *mnem, ExtMachInst machInst, OpClass opClass)
Definition zcmp.cc:42
Base class for all RISC-V Macroops.
constexpr RegId S0
Definition int.hh:99
Bitfield< 7, 4 > rlist
Definition types.hh:150
std::string registerName(RegId reg)
Definition utility.hh:130
const std::vector< RegId > PushPopRegList
Definition int.hh:152
constexpr auto & ReturnAddrReg
Definition int.hh:140
Bitfield< 2 > s
constexpr enums::RiscvType RV64
Definition pcstate.hh:57
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
std::string csprintf(const char *format, const Args &...args)
Definition cprintf.hh:161

Generated on Mon Jan 13 2025 04:28:28 for gem5 by doxygen 1.9.8