gem5  v21.1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
operand_info.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2021 Advanced Micro Devices, Inc.
3  * All rights reserved.
4  *
5  * For use for simulation and test purposes only
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  * this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __GPU_COMPUTE_OPERAND_INFO_HH__
35 #define __GPU_COMPUTE_OPERAND_INFO_HH__
36 
37 #include "arch/gpu_registers.hh"
38 #include "base/flags.hh"
39 #include "config/the_gpu_isa.hh"
40 
41 namespace gem5
42 {
43 
45 {
46  public:
47  OperandInfo() = delete;
48  OperandInfo(int opSelectorVal, int size, bool src, bool scalar_reg,
49  bool vector_reg, bool imm)
50  : _opSelectorVal(opSelectorVal), _size(size),
51  _numDWords(size <= 4 ? 1 : size / 4)
52  {
53  if (src)
54  flags.set(SRC);
55  if (scalar_reg)
57  if (vector_reg)
59  if (imm)
61  if (TheGpuISA::isVccReg(opSelectorVal))
62  flags.set(VCC);
63  if (TheGpuISA::isExecMask(opSelectorVal))
64  flags.set(EXEC);
65  if (TheGpuISA::isFlatScratchReg(opSelectorVal))
66  flags.set(FLAT);
67  if (TheGpuISA::isLiteral(opSelectorVal))
68  flags.set(LITERAL);
69  if (TheGpuISA::isConstVal(opSelectorVal))
71  if (TheGpuISA::isPosConstVal(opSelectorVal))
73  }
74 
76  int sizeInDWords() const { return _numDWords; }
77 
78  int size() const { return _size; }
79  // Certain opIdx's get changed in calls to opSelectorToRegIdx
80  // This avoids that by returning the exact value
81  int rawRegisterIndex() const { return _opSelectorVal; }
82 
83  int
84  registerIndex(int numScalarRegs) const
85  {
86  // Some regs (i.e. VSRC, VDST) are explicitly declared as vectors
87  // as opposed to checking if it's a vector through a function call, so
88  // they don't have an offset applied and can be returned immediately
90  return _opSelectorVal;
91  return TheGpuISA::opSelectorToRegIdx(_opSelectorVal, numScalarRegs);
92  }
93  bool isSrc() const { return flags.isSet(SRC); }
94  bool isDst() const { return !flags.isSet(SRC); }
95  bool isImm() const { return flags.isSet(IMMEDIATE); }
96  bool isScalarReg() const { return flags.isSet(SCALAR_REG); }
97  bool isVectorReg() const { return flags.isSet(VECTOR_REG); }
98  bool isVcc() const { return flags.isSet(VCC); }
99  bool isExec() const { return flags.isSet(EXEC); }
100  bool isFlatScratch() const { return flags.isSet(FLAT); }
101 
102  void
104  {
105  _virtIndices = v;
106  _physIndices = p;
107 
108  assert(_virtIndices.size() == _physIndices.size());
109  assert(_numDWords == _physIndices.size());
110  }
111 
116  int virtIdx(int reg_num=0) const { return _virtIndices.at(reg_num); }
117  int physIdx(int reg_num=0) const { return _physIndices.at(reg_num); }
118 
119  const std::vector<int>&
120  virtIndices() const
121  {
122  return _virtIndices;
123  }
124 
125  const std::vector<int>&
126  physIndices() const
127  {
128  return _physIndices;
129  }
130 
133  {
134  return _bankReadCounts;
135  }
136 
137  typedef uint32_t FlagsType;
139 
140  private:
141 
142  enum : FlagsType {
143  // If the operand is a src or not
144  SRC = 0x00000001,
145 
146  // If the operand is a scalar or not
147  SCALAR_REG = 0x00000002,
148 
149  // If the operand is a vector or not
150  VECTOR_REG = 0x00000004,
151 
152  // If the operand is an immediate or not
153  IMMEDIATE = 0x00000008,
154 
155  // If the operand is a VCC register
156  VCC = 0x00000010,
157 
158  // If the operand is an EXEC register
159  EXEC = 0x00000020,
160 
161  // If the operand is a FLAT/SCRATCH register
162  FLAT = 0x00000040,
163 
164  // If the operand is a literal
165  LITERAL = 0x00000080,
166 
167  // If the operand is a constant value
168  CONSTANT = 0x00000100,
169 
170  // If the constant is positive or negative
171  POS_CONST = 0x00000200
172  };
173 
175 
179  const int _opSelectorVal;
180 
184  const int _size;
185 
189  const int _numDWords;
190 
193 
198 };
199 
200 } // namespace gem5
201 
202 #endif // __GPU_COMPUTE_OPERAND_INFO_H__
gem5::OperandInfo::POS_CONST
@ POS_CONST
Definition: operand_info.hh:171
gem5::OperandInfo::SCALAR_REG
@ SCALAR_REG
Definition: operand_info.hh:147
gem5::OperandInfo::LITERAL
@ LITERAL
Definition: operand_info.hh:165
gem5::OperandInfo::FLAT
@ FLAT
Definition: operand_info.hh:162
gem5::OperandInfo::EXEC
@ EXEC
Definition: operand_info.hh:159
gem5::Gcn3ISA::isPosConstVal
bool isPosConstVal(int opIdx)
Definition: registers.cc:169
gem5::Gcn3ISA::REG_VGPR_MIN
@ REG_VGPR_MIN
Definition: gpu_registers.hh:133
gem5::OperandInfo
Definition: operand_info.hh:44
gem5::Flags::set
void set(Type mask)
Set all flag's bits matching the given mask.
Definition: flags.hh:116
gem5::OperandInfo::Flags
gem5::Flags< FlagsType > Flags
Definition: operand_info.hh:138
gem5::OperandInfo::_size
const int _size
Size of the operand in bytes.
Definition: operand_info.hh:184
gem5::OperandInfo::OperandInfo
OperandInfo(int opSelectorVal, int size, bool src, bool scalar_reg, bool vector_reg, bool imm)
Definition: operand_info.hh:48
std::vector< int >
gem5::Gcn3ISA::isVccReg
bool isVccReg(int opIdx)
Definition: registers.cc:206
gem5::OperandInfo::virtIndices
const std::vector< int > & virtIndices() const
Definition: operand_info.hh:120
gem5::OperandInfo::isVcc
bool isVcc() const
Definition: operand_info.hh:98
gem5::OperandInfo::VCC
@ VCC
Definition: operand_info.hh:156
gem5::OperandInfo::IMMEDIATE
@ IMMEDIATE
Definition: operand_info.hh:153
gem5::Gcn3ISA::isExecMask
bool isExecMask(int opIdx)
Definition: registers.cc:200
gem5::OperandInfo::_physIndices
std::vector< int > _physIndices
Definition: operand_info.hh:192
gem5::OperandInfo::isImm
bool isImm() const
Definition: operand_info.hh:95
gem5::Flags< FlagsType >
gem5::Gcn3ISA::isLiteral
bool isLiteral(int opIdx)
Definition: registers.cc:194
gem5::Flags::isSet
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
Definition: flags.hh:83
gem5::OperandInfo::FlagsType
uint32_t FlagsType
Definition: operand_info.hh:137
gem5::Gcn3ISA::opSelectorToRegIdx
int opSelectorToRegIdx(int opIdx, int numScalarRegs)
Definition: registers.cc:124
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::OperandInfo::isVectorReg
bool isVectorReg() const
Definition: operand_info.hh:97
gem5::ArmISA::v
Bitfield< 28 > v
Definition: misc_types.hh:54
gem5::OperandInfo::setVirtToPhysMapping
void setVirtToPhysMapping(std::vector< int > v, std::vector< int > p)
Definition: operand_info.hh:103
gem5::OperandInfo::CONSTANT
@ CONSTANT
Definition: operand_info.hh:168
gem5::OperandInfo::isExec
bool isExec() const
Definition: operand_info.hh:99
gem5::OperandInfo::isFlatScratch
bool isFlatScratch() const
Definition: operand_info.hh:100
gem5::Gcn3ISA::RegSizeDWords
const int RegSizeDWords
Size of a single-precision register in DWords.
Definition: gpu_registers.hh:178
gem5::OperandInfo::sizeInDWords
int sizeInDWords() const
Definition: operand_info.hh:76
gem5::OperandInfo::size
int size() const
Definition: operand_info.hh:78
gem5::OperandInfo::registerIndex
int registerIndex(int numScalarRegs) const
Definition: operand_info.hh:84
gem5::OperandInfo::_opSelectorVal
const int _opSelectorVal
Value of the operand as used in registers.cc functions.
Definition: operand_info.hh:179
flags.hh
gem5::OperandInfo::_virtIndices
std::vector< int > _virtIndices
Definition: operand_info.hh:191
gem5::ArmISA::imm
Bitfield< 7, 0 > imm
Definition: types.hh:132
gem5::OperandInfo::flags
Flags flags
Definition: operand_info.hh:174
gem5::OperandInfo::isSrc
bool isSrc() const
Definition: operand_info.hh:93
gem5::OperandInfo::_bankReadCounts
std::vector< int > _bankReadCounts
The number of reads this operand will make to each bank.
Definition: operand_info.hh:197
gem5::OperandInfo::isScalarReg
bool isScalarReg() const
Definition: operand_info.hh:96
gem5::OperandInfo::rawRegisterIndex
int rawRegisterIndex() const
Definition: operand_info.hh:81
gem5::OperandInfo::SRC
@ SRC
Definition: operand_info.hh:144
gem5::OperandInfo::_numDWords
const int _numDWords
Size of operand in DWords.
Definition: operand_info.hh:189
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::OperandInfo::virtIdx
int virtIdx(int reg_num=0) const
We typically only need the first virtual register for the operand regardless of its size.
Definition: operand_info.hh:116
gem5::OperandInfo::physIndices
const std::vector< int > & physIndices() const
Definition: operand_info.hh:126
gem5::OperandInfo::bankReadCounts
std::vector< int > & bankReadCounts() const
Definition: operand_info.hh:132
gem5::OperandInfo::isDst
bool isDst() const
Definition: operand_info.hh:94
gem5::OperandInfo::physIdx
int physIdx(int reg_num=0) const
Definition: operand_info.hh:117
gem5::OperandInfo::numRegisters
int numRegisters() const
Definition: operand_info.hh:75
gem5::Gcn3ISA::isConstVal
bool isConstVal(int opIdx)
Definition: registers.cc:187
gem5::OperandInfo::OperandInfo
OperandInfo()=delete
gem5::Gcn3ISA::isFlatScratchReg
bool isFlatScratchReg(int opIdx)
Definition: registers.cc:212
gem5::OperandInfo::VECTOR_REG
@ VECTOR_REG
Definition: operand_info.hh:150

Generated on Wed Jul 28 2021 12:10:27 for gem5 by doxygen 1.8.17