gem5 v24.0.0.0
Loading...
Searching...
No Matches
gpu_static_inst.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Advanced Micro Devices, Inc.
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 met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
33
34#include "debug/GPUInst.hh"
35
36namespace gem5
37{
38
40 : executed_as(enums::SC_NONE), _opcode(opcode),
41 _instNum(0), _instAddr(0), srcVecDWords(-1), dstVecDWords(-1),
42 srcScalarDWords(-1), dstScalarDWords(-1), maxOpSize(-1)
43{
44}
45
46const std::string&
48{
49 if (disassembly.empty()) {
51 assert(!disassembly.empty());
52 }
53
54 return disassembly;
55}
56
57
58void
62 OpType opType)
63{
64 std::vector<int> virt_idxs;
65 std::vector<int> phys_idxs;
66
67 int num_dwords = op.sizeInDWords();
68 int virt_idx = op.registerIndex(wf->reservedScalarRegs);
69
70 int phys_idx = -1;
71 for (int i = 0; i < num_dwords; i++) {
72 if (opType == OpType::SRC_VEC || opType == OpType::DST_VEC) {
73 phys_idx = cu->registerManager->mapVgpr(wf, virt_idx + i);
74 } else {
75 assert(opType == OpType::SRC_SCALAR ||
76 opType == OpType::DST_SCALAR);
77 phys_idx = cu->registerManager->mapSgpr(wf, virt_idx + i);
78 }
79 virt_idxs.push_back(virt_idx + i);
80 phys_idxs.push_back(phys_idx);
81 }
82 DPRINTF(GPUInst, "%s adding %s %s (%d->%d) operand that uses "
83 "%d registers.\n", disassemble(),
84 (opType == OpType::SRC_VEC || opType == OpType::DST_VEC) ?
85 "vector" : "scalar",
86 (opType == OpType::SRC_VEC || opType == OpType::SRC_SCALAR) ?
87 "src" : "dst", virt_idxs[0], phys_idxs[0], num_dwords);
88
89 op.setVirtToPhysMapping(virt_idxs, phys_idxs);
90
91 opVec.emplace_back(op);
92}
93
94void
96{
97 for (auto& srcOp : srcOps) {
98 if (srcOp.isVectorReg()) {
101 } else if (srcOp.isScalarReg()) {
104 }
105 }
106
107 for (auto& dstOp : dstOps) {
108 if (dstOp.isVectorReg()) {
109 generateVirtToPhysMap(wf, cu, dstOp, dstVecRegOps,
111 } else if (dstOp.isScalarReg()) {
114 }
115 }
116}
117
118int
120{
121 return srcVecRegOps.size();
122}
123
124int
126{
127 return dstVecRegOps.size();
128}
129
130int
132{
133 if (srcVecDWords != -1) {
134 return srcVecDWords;
135 }
136
137 srcVecDWords = 0;
138
139 for (const auto& srcOp : srcOps)
140 if (srcOp.isVectorReg())
141 srcVecDWords += srcOp.sizeInDWords();
142
143 return srcVecDWords;
144}
145
146int
148{
149 if (dstVecDWords != -1) {
150 return dstVecDWords;
151 }
152
153 dstVecDWords = 0;
154
155 for (const auto& dstOp : dstOps)
156 if (dstOp.isVectorReg())
157 dstVecDWords += dstOp.sizeInDWords();
158
159 return dstVecDWords;
160}
161
162int
167
168int
173
174int
176{
177 if (srcScalarDWords != -1)
178 return srcScalarDWords;
179
180 srcScalarDWords = 0;
181
182 for (const auto& srcOp : srcOps)
183 if (srcOp.isScalarReg())
184 srcScalarDWords += srcOp.sizeInDWords();
185
186 return srcScalarDWords;
187}
188
189int
191{
192 if (dstScalarDWords != -1)
193 return dstScalarDWords;
194
195 dstScalarDWords = 0;
196
197 for (const auto& dstOp : dstOps)
198 if (dstOp.isScalarReg())
199 dstScalarDWords += dstOp.sizeInDWords();
200
201 return dstScalarDWords;
202}
203
204int
206{
207 if (maxOpSize != -1)
208 return maxOpSize;
209
210 maxOpSize = 0;
211
212 for (const auto& dstOp : dstOps)
213 if (dstOp.size() > maxOpSize)
214 maxOpSize = dstOp.size();
215
216 for (const auto& srcOp : srcOps)
217 if (srcOp.size() > maxOpSize)
218 maxOpSize = srcOp.size();
219
220 return maxOpSize;
221}
222
223} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
RegisterManager * registerManager
std::vector< OperandInfo > srcOps
const std::string & disassemble()
std::vector< OperandInfo > dstScalarRegOps
virtual void generateDisassembly()=0
GPUStaticInst(const std::string &opcode)
std::vector< OperandInfo > dstVecRegOps
std::vector< OperandInfo > dstOps
std::vector< OperandInfo > srcVecRegOps
void generateVirtToPhysMap(Wavefront *wf, ComputeUnit *cu, OperandInfo &op, std::vector< OperandInfo > &opVec, OpType opType)
std::vector< OperandInfo > srcScalarRegOps
void initDynOperandInfo(Wavefront *wf, ComputeUnit *cu)
int mapVgpr(Wavefront *w, int vgprIndex)
int mapSgpr(Wavefront *w, int sgprIndex)
STL vector class.
Definition stl.hh:37
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 24, 21 > opcode
Definition types.hh:92
Bitfield< 4 > op
Definition types.hh:83
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:24:04 for gem5 by doxygen 1.11.0