gem5 v23.0.0.1
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
57void
59{
60 // Lambda function, as this is only ever used here
61 auto generateVirtToPhysMap = [&](OperandInfo& op,
63 MapRegFn mapFn, OpType opType)
64 {
65 std::vector<int> virt_idxs;
66 std::vector<int> phys_idxs;
67
68 int num_dwords = op.sizeInDWords();
69 int virt_idx = op.registerIndex(wf->reservedScalarRegs);
70
71 int phys_idx = -1;
72 for (int i = 0; i < num_dwords; i++){
73 phys_idx = (cu->registerManager->*mapFn)(wf, virt_idx + i);
74 virt_idxs.push_back(virt_idx + i);
75 phys_idxs.push_back(phys_idx);
76 }
77 DPRINTF(GPUInst, "%s adding %s %s (%d->%d) operand that uses "
78 "%d registers.\n", disassemble(),
79 (opType == OpType::SRC_VEC || opType == OpType::DST_VEC) ?
80 "vector" : "scalar",
81 (opType == OpType::SRC_VEC || opType == OpType::SRC_SCALAR) ?
82 "src" : "dst", virt_idxs[0], phys_idxs[0], num_dwords);
83
84 op.setVirtToPhysMapping(virt_idxs, phys_idxs);
85
86 opVec.emplace_back(op);
87 };
88
89 for (auto& srcOp : srcOps) {
90 if (srcOp.isVectorReg()) {
91 generateVirtToPhysMap(srcOp, srcVecRegOps,
93 } else if (srcOp.isScalarReg()) {
94 generateVirtToPhysMap(srcOp, srcScalarRegOps,
96 }
97 }
98
99 for (auto& dstOp : dstOps) {
100 if (dstOp.isVectorReg()) {
101 generateVirtToPhysMap(dstOp, dstVecRegOps,
103 } else if (dstOp.isScalarReg()) {
104 generateVirtToPhysMap(dstOp, dstScalarRegOps,
106 }
107 }
108}
109
110int
112{
113 return srcVecRegOps.size();
114}
115
116int
118{
119 return dstVecRegOps.size();
120}
121
122int
124{
125 if (srcVecDWords != -1) {
126 return srcVecDWords;
127 }
128
129 srcVecDWords = 0;
130
131 for (const auto& srcOp : srcOps)
132 if (srcOp.isVectorReg())
133 srcVecDWords += srcOp.sizeInDWords();
134
135 return srcVecDWords;
136}
137
138int
140{
141 if (dstVecDWords != -1) {
142 return dstVecDWords;
143 }
144
145 dstVecDWords = 0;
146
147 for (const auto& dstOp : dstOps)
148 if (dstOp.isVectorReg())
149 dstVecDWords += dstOp.sizeInDWords();
150
151 return dstVecDWords;
152}
153
154int
156{
157 return srcScalarRegOps.size();
158}
159
160int
162{
163 return dstScalarRegOps.size();
164}
165
166int
168{
169 if (srcScalarDWords != -1)
170 return srcScalarDWords;
171
172 srcScalarDWords = 0;
173
174 for (const auto& srcOp : srcOps)
175 if (srcOp.isScalarReg())
176 srcScalarDWords += srcOp.sizeInDWords();
177
178 return srcScalarDWords;
179}
180
181int
183{
184 if (dstScalarDWords != -1)
185 return dstScalarDWords;
186
187 dstScalarDWords = 0;
188
189 for (const auto& dstOp : dstOps)
190 if (dstOp.isScalarReg())
191 dstScalarDWords += dstOp.sizeInDWords();
192
193 return dstScalarDWords;
194}
195
196int
198{
199 if (maxOpSize != -1)
200 return maxOpSize;
201
202 maxOpSize = 0;
203
204 for (const auto& dstOp : dstOps)
205 if (dstOp.size() > maxOpSize)
206 maxOpSize = dstOp.size();
207
208 for (const auto& srcOp : srcOps)
209 if (srcOp.size() > maxOpSize)
210 maxOpSize = srcOp.size();
211
212 return maxOpSize;
213}
214
215} // 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
std::vector< OperandInfo > srcScalarRegOps
void initDynOperandInfo(Wavefront *wf, ComputeUnit *cu)
int(RegisterManager::* MapRegFn)(Wavefront *, int)
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
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

Generated on Mon Jul 10 2023 15:32:03 for gem5 by doxygen 1.9.7