| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2017-2023 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#include "Models.hpp" |
| 10 |
|
| 11 |
// this must precede model*.hpp inclusion below |
| 12 |
#include "../strings.hpp" |
| 13 |
|
| 14 |
// for bxml/Model operand type mappings |
| 15 |
#define TYPE(T) ENUM_BITSET_VALUE(T, uint32_t) |
| 16 |
|
| 17 |
#include "bxml/ModelGen10.hpp" |
| 18 |
#include "bxml/ModelGen11.hpp" |
| 19 |
#include "bxml/ModelGen7p5.hpp" |
| 20 |
#include "bxml/ModelGen8.hpp" |
| 21 |
#include "bxml/ModelGen9.hpp" |
| 22 |
#include "bxml/ModelXe.hpp" |
| 23 |
#include "bxml/ModelXeHP.hpp" |
| 24 |
#include "bxml/ModelXeHPC.hpp" |
| 25 |
#include "bxml/ModelXeHPG.hpp" |
| 26 |
#include "bxml/ModelXe2.hpp" |
| 27 |
#include "bxml/ModelXe3.hpp" |
| 28 |
#include "bxml/ModelXe3pXPC.hpp" |
| 29 |
#include "../Backend/Native/MInst.hpp" |
| 30 |
#include "../asserts.hpp" |
| 31 |
#include "../bits.hpp" |
| 32 |
|
| 33 |
#include <iostream> |
| 34 |
#include <sstream> |
| 35 |
|
| 36 |
using namespace iga; |
| 37 |
|
| 38 |
// full "constructor" |
| 39 |
#define UNWRAP_TUPLE(...) \ |
| 40 |
{ __VA_ARGS__ } |
| 41 |
#define IGA_REGISTER_SPEC(PLAT_LO, PLAT_HI, REGNAME, SYNTAX, DESCRIPTION, \ |
| 42 |
REGNUM7_4, REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 43 |
NUM_BYTE_PER_REG) \ |
| 44 |
{ \ |
| 45 |
REGNAME, SYNTAX, DESCRIPTION, REGNUM7_4, REGNUM_BASE, PLAT_LO, PLAT_HI, \ |
| 46 |
ACC_GRAN, NUM_REGS, UNWRAP_TUPLE NUM_BYTE_PER_REG \ |
| 47 |
} |
| 48 |
// for <= some platform (whatever our lowest platform is |
| 49 |
#define IGA_REGISTER_SPEC_LE(PLAT_HI, REGNAME, SYNTAX, DESCRIPTION, REGNUM7_4, \ |
| 50 |
REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 51 |
NUM_BYTE_PER_REG) \ |
| 52 |
IGA_REGISTER_SPEC(Platform::GEN6, PLAT_HI, REGNAME, SYNTAX, DESCRIPTION, \ |
| 53 |
REGNUM7_4, REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 54 |
NUM_BYTE_PER_REG) |
| 55 |
// for >= some platform (up to the highest) |
| 56 |
#define IGA_REGISTER_SPEC_GE(PLAT_LO, REGNAME, SYNTAX, DESCRIPTION, REGNUM7_4, \ |
| 57 |
REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 58 |
NUM_BYTE_PER_REG) \ |
| 59 |
IGA_REGISTER_SPEC(PLAT_LO, Platform::FUTURE, REGNAME, SYNTAX, DESCRIPTION, \ |
| 60 |
REGNUM7_4, REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 61 |
NUM_BYTE_PER_REG) |
| 62 |
// a specification valid on all platforms |
| 63 |
#define IGA_REGISTER_SPEC_UNIFORM(REGNAME, SYNTAX, DESCRIPTION, REGNUM7_4, \ |
| 64 |
REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 65 |
NUM_BYTE_PER_REG) \ |
| 66 |
IGA_REGISTER_SPEC(Platform::GEN6, Platform::FUTURE, REGNAME, SYNTAX, \ |
| 67 |
DESCRIPTION, REGNUM7_4, REGNUM_BASE, ACC_GRAN, NUM_REGS, \ |
| 68 |
NUM_BYTE_PER_REG) |
| 69 |
|
| 70 |
// ordered by encoding of RegNum[7:4] |
| 71 |
// newest platforms first |
| 72 |
static const struct RegInfo REGISTER_SPECIFICATIONS[] = { |
| 73 |
IGA_REGISTER_SPEC_LE(Platform::GEN11, RegName::GRF_R, "r", "General", 0, 0, |
| 74 |
1, 128, (0)), |
| 75 |
|
| 76 |
IGA_REGISTER_SPEC_GE(Platform::XE, RegName::GRF_R, "r", "General", 0, |
| 77 |
0, // regNum7_4, regNumBase |
| 78 |
1, // accGran |
| 79 |
256, (0)), |
| 80 |
IGA_REGISTER_SPEC_GE(Platform::XE3P_XPC, RegName::GRF_R, "r", "General", 0, |
| 81 |
0, // regNum7_4, regNumBase |
| 82 |
1, // accGran |
| 83 |
512, (0)), |
| 84 |
IGA_REGISTER_SPEC_UNIFORM(RegName::ARF_NULL, "null", "Null", 0x0, 0, 0, 0, |
| 85 |
(32)), |
| 86 |
|
| 87 |
IGA_REGISTER_SPEC_LE(Platform::XE3, RegName::ARF_A, "a", "Index", 0x1, 0, 2, 1, (32)), |
| 88 |
IGA_REGISTER_SPEC_GE(Platform::XE3P_XPC, RegName::ARF_A, "a", "Index", 0x1, 0, 2, 1, (64)), |
| 89 |
|
| 90 |
// acc and mme share same RegNum[7:4], mme gets the high registers |
| 91 |
IGA_REGISTER_SPEC_LE(Platform::GEN11, RegName::ARF_ACC, "acc", |
| 92 |
"Accumulator", 0x2, 0, 1, 2, (32, 32)), |
| 93 |
IGA_REGISTER_SPEC(Platform::XE, Platform::XE, RegName::ARF_ACC, "acc", |
| 94 |
"Accumulator", 0x2, 0, 1, 8, |
| 95 |
(32, 32, 32, 32, 32, 32, 32, 32)), |
| 96 |
IGA_REGISTER_SPEC(Platform::XE_HP, Platform::XE_HP, RegName::ARF_ACC, "acc", |
| 97 |
"Accumulator", 0x2, 0, 1, 8, |
| 98 |
(32, 32, 32, 32, 32, 32, 32, 32)), |
| 99 |
IGA_REGISTER_SPEC(Platform::XE_HPG, Platform::XE_HPG, RegName::ARF_ACC, |
| 100 |
"acc", "Accumulator", 0x2, 0, 1, 8, |
| 101 |
(32, 32, 32, 32, 32, 32, 32, 32)), |
| 102 |
IGA_REGISTER_SPEC_GE( |
| 103 |
Platform::XE_HPC, RegName::ARF_ACC, "acc", "Accumulator", 0x2, 0, 1, 16, |
| 104 |
(64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64)), |
| 105 |
IGA_REGISTER_SPEC_LE(Platform::GEN11, RegName::ARF_MME, "mme", "Math Macro", |
| 106 |
0x2, 2, // offset by 2 "acc2-9" |
| 107 |
4, 8, (32, 32, 32, 32, 32, 32, 32, 32)), |
| 108 |
IGA_REGISTER_SPEC(Platform::XE, Platform::XE, RegName::ARF_MME, "mme", |
| 109 |
"Math Macro", 0x2, 8, // offset by 8 "acc8-15" |
| 110 |
4, 8, (32, 32, 32, 32, 32, 32, 32, 32)), |
| 111 |
IGA_REGISTER_SPEC(Platform::XE_HP, Platform::XE_HP, RegName::ARF_MME, "mme", |
| 112 |
"Math Macro", 0x2, 8, // offset by 8 "acc8-15" |
| 113 |
4, 8, (32, 32, 32, 32, 32, 32, 32, 32)), |
| 114 |
IGA_REGISTER_SPEC(Platform::XE_HPG, Platform::XE_HPG, RegName::ARF_MME, |
| 115 |
"mme", "Math Macro", 0x2, 8, // offset by 8 "acc8-15" |
| 116 |
4, 8, (32, 32, 32, 32, 32, 32, 32, 32)), |
| 117 |
IGA_REGISTER_SPEC_GE(Platform::XE_HPC, RegName::ARF_MME, "mme", |
| 118 |
"Math Macro", 0x2, 8, // offset by 8 "acc8-15" |
| 119 |
4, 8, (64, 64, 64, 64, 64, 64, 64, 64)), |
| 120 |
|
| 121 |
IGA_REGISTER_SPEC_LE(Platform::XE_HPG, RegName::ARF_F, "f", "Flag Register", |
| 122 |
0x3, 0, 2, 2, (4, 4)), |
| 123 |
IGA_REGISTER_SPEC_GE(Platform::XE_HPC, RegName::ARF_F, "f", "Flag Register", |
| 124 |
0x3, 0, 2, 4, (4, 4, 4, 4)), |
| 125 |
|
| 126 |
IGA_REGISTER_SPEC_GE(Platform::GEN7P5, RegName::ARF_CE, "ce", |
| 127 |
"Channel Enable", 0x4, 0, 4, 0, (4)), |
| 128 |
|
| 129 |
IGA_REGISTER_SPEC_LE(Platform::XE_HPC, RegName::ARF_MSG, "msg", |
| 130 |
"Message Control", 0x5, 0, 4, 8, |
| 131 |
(4, 4, 4, 4, 4, 4, 4, 4)), |
| 132 |
IGA_REGISTER_SPEC_GE(Platform::XE2, RegName::ARF_MSG, "msg", |
| 133 |
"Message Control", 0x5, 0, 4, 2, (12, 32)), |
| 134 |
|
| 135 |
IGA_REGISTER_SPEC(Platform::GEN7P5, Platform::GEN7P5, RegName::ARF_SP, "sp", |
| 136 |
"Stack Pointer", 0x6, 0, 4, 0, |
| 137 |
(2 * 4)), // two subregisters of 4 bytes each |
| 138 |
IGA_REGISTER_SPEC(Platform::GEN8, Platform::XE, RegName::ARF_SP, "sp", |
| 139 |
"Stack Pointer", 0x6, 0, 4, 0, |
| 140 |
(2 * 8)), // two subregisters of 8 bytes each |
| 141 |
IGA_REGISTER_SPEC(Platform::XE3, Platform::XE3, RegName::ARF_S, "s", |
| 142 |
"Scalar Register", 0x6, 0, 1, 1, (32)), |
| 143 |
// bigger s0 in XE3P |
| 144 |
IGA_REGISTER_SPEC_GE(Platform::XE3P_XPC, RegName::ARF_S, "s", |
| 145 |
"Scalar Register", 0x6, 0, 1, 1, (64)), |
| 146 |
|
| 147 |
IGA_REGISTER_SPEC(Platform::GEN7P5, Platform::GEN11, RegName::ARF_SR, "sr", |
| 148 |
"State Register", 0x7, 0, 1, 2, |
| 149 |
(16, 16)), // sr{0,1}.{0..3}:d |
| 150 |
IGA_REGISTER_SPEC(Platform::XE, Platform::XE2, RegName::ARF_SR, "sr", |
| 151 |
"State Register", 0x7, 0, 1, 1, |
| 152 |
(16)), // sr0.{0..3}:d |
| 153 |
IGA_REGISTER_SPEC_GE(Platform::XE3, RegName::ARF_SR, "sr", |
| 154 |
"State Register", 0x7, 0, 1, 1, |
| 155 |
(20)), // sr0.{0..4}:d |
| 156 |
|
| 157 |
IGA_REGISTER_SPEC_UNIFORM(RegName::ARF_CR, "cr", "Control Register", 0x8, 0, |
| 158 |
4, 1, (3 * 4)), // cr0.{0..2}:d |
| 159 |
IGA_REGISTER_SPEC_GE(Platform::XE3P_XPC, RegName::ARF_CR, "cr", |
| 160 |
"Control Register", 0x8, 0, |
| 161 |
4, 1, (4 * 4)), // cr0.{0..3}:d |
| 162 |
|
| 163 |
// with SWSB wait n{0,1} replaced by sync.{bar,host}, which |
| 164 |
// implicitly reference notification registers; |
| 165 |
// not sure if these are needed in CSR though, so leaving for now |
| 166 |
|
| 167 |
IGA_REGISTER_SPEC_UNIFORM(RegName::ARF_N, "n", "Notification Register", 0x9, |
| 168 |
0, 4, 1, (3 * 4)), // n0.{0..2}:d |
| 169 |
|
| 170 |
IGA_REGISTER_SPEC_UNIFORM(RegName::ARF_IP, "ip", "Instruction Pointer", 0xA, |
| 171 |
0, 4, 0, (4)), // ip |
| 172 |
|
| 173 |
IGA_REGISTER_SPEC_LE(Platform::XE2, RegName::ARF_TDR, |
| 174 |
"tdr", "Thread Dependency Register", 0xB, 0, 2, 1, |
| 175 |
(16)), // tdr0.* |
| 176 |
IGA_REGISTER_SPEC_GE(Platform::XE3, RegName::ARF_TDR, |
| 177 |
"tdr", "Thread Dependency Register", 0xB, 0, 2, 1, |
| 178 |
(20)), // tdr0.* |
| 179 |
|
| 180 |
IGA_REGISTER_SPEC_GE(Platform::GEN10, RegName::ARF_TM, "tm", |
| 181 |
"Timestamp Register", 0xC, 0, 4, 1, |
| 182 |
(5 * 4)), // tm0.{0..4}:d |
| 183 |
IGA_REGISTER_SPEC_LE(Platform::GEN9, RegName::ARF_TM, "tm", |
| 184 |
"Timestamp Register", 0xC, 0, 4, 1, |
| 185 |
(4 * 4)), // tm0.{0..3}:d |
| 186 |
|
| 187 |
// fc0.0-31 stack-entry 0-31 |
| 188 |
// fc1.0 global counts |
| 189 |
// fc2.0 top of stack pointers |
| 190 |
// fc3.0-3 per channel counts |
| 191 |
// fc4.0 call mask |
| 192 |
IGA_REGISTER_SPEC(Platform::GEN7P5, Platform::GEN11, RegName::ARF_FC, "fc", |
| 193 |
"Flow Control", 0xD, 0, 4, 5, |
| 194 |
(4 * 32, 4 * 1, 4 * 1, 4 * 4, 4 * 1)), |
| 195 |
// EU GOTO/JOIN instruction latency improvement HAS397165 removes two flow |
| 196 |
// control registers |
| 197 |
// fc0.0-31 per-channel IP |
| 198 |
// fc1.0 channel enables |
| 199 |
// fc2 call mask |
| 200 |
// fc3 JEU fused mask |
| 201 |
|
| 202 |
IGA_REGISTER_SPEC(Platform::XE, Platform::XE_HPC, RegName::ARF_FC, "fc", |
| 203 |
"Flow Control", 0xD, 0, 4, 4, |
| 204 |
(4 * 32, 4 * 1, 4 * 1, 4 * 1)), |
| 205 |
IGA_REGISTER_SPEC_GE(Platform::XE2, RegName::ARF_FC, "fc", "Flow Control", |
| 206 |
0xD, 0, 4, 3, (4 * 16, 4 * 16, 4 * 2)), |
| 207 |
|
| 208 |
IGA_REGISTER_SPEC(Platform::GEN7, Platform::GEN7P5, RegName::ARF_DBG, "dbg", |
| 209 |
"Debug", 0xF, 0, 4, 1, (4)), // dbg0.0:ud |
| 210 |
IGA_REGISTER_SPEC_GE(Platform::GEN8, RegName::ARF_DBG, "dbg", "Debug", 0xF, |
| 211 |
0, 4, 1, (2 * 4)), // dbg0.{0,1}:ud |
| 212 |
IGA_REGISTER_SPEC_GE(Platform::XE3P_XPC, RegName::ARF_DBG, "dbg", "Debug", 0xF, |
| 213 |
0, 4, 1, (5 * 4)), // dbg0.{0,1,2,3,4}:ud |
| 214 |
}; |
| 215 |
|
| 216 |
const OpSpec &Model::lookupOpSpec(Op op) const { |
| 217 |
if (op < Op::FIRST_OP || op > Op::LAST_OP) { |
| 218 |
// external opspec API can reach this |
| 219 |
// IGA_ASSERT_FALSE("op out of bounds"); |
| 220 |
return opsArray[(int)Op::INVALID]; // return invalid if assertions are off |
| 221 |
} |
| 222 |
return opsArray[(int)op]; |
| 223 |
} |
| 224 |
|
| 225 |
const OpSpec &Model::lookupOpSpecByCode(unsigned opcode) const { |
| 226 |
// if (!opsByCodeValid) { |
| 227 |
// for (int i = (int)Op::FIRST_OP; i <= (int)Op::LAST_OP; i++) { |
| 228 |
// const OpSpec &os = lookupOpSpec((Op)i); |
| 229 |
// if (!os.isSubop()) { |
| 230 |
// opsByCode[os.code] = &os; |
| 231 |
// } |
| 232 |
// } |
| 233 |
// opsByCodeValid = true; |
| 234 |
// } |
| 235 |
for (int i = (int)Op::FIRST_OP; i <= (int)Op::LAST_OP; i++) { |
| 236 |
if (opsArray[i].op != Op::INVALID && opsArray[i].opcode == opcode) { |
| 237 |
return opsArray[i]; |
| 238 |
} |
| 239 |
} |
| 240 |
return opsArray[static_cast<int>(Op::INVALID)]; |
| 241 |
} |
| 242 |
|
| 243 |
template <int N> |
| 244 |
static unsigned getBitsFromFragments(const uint64_t *qws, |
| 245 |
const Fragment ff[N]) { |
| 246 |
unsigned bits = 0; |
| 247 |
|
| 248 |
int off = 0; |
| 249 |
for (int i = 0; i < N; i++) { |
| 250 |
if (ff[i].length == 0) { |
| 251 |
break; |
| 252 |
} |
| 253 |
auto frag = (unsigned)getBits(qws, ff[i].offset, ff[i].length); |
| 254 |
bits |= frag << off; |
| 255 |
off += ff[i].length; |
| 256 |
} |
| 257 |
|
| 258 |
return bits; |
| 259 |
} |
| 260 |
|
| 261 |
const OpSpec &Model::lookupOpSpecFromBits(const void *bits, |
| 262 |
OpSpecMissInfo &missInfo) const { |
| 263 |
constexpr static Fragment F_OPCODE("Opcode", 0, 7); |
| 264 |
// |
| 265 |
const MInst *mi = (const MInst *)bits; |
| 266 |
auto opc = mi->getFragment(F_OPCODE); |
| 267 |
missInfo.opcode = opc; |
| 268 |
const OpSpec *os = &lookupOpSpecByCode((unsigned)opc); |
| 269 |
return *os; |
| 270 |
} |
| 271 |
|
| 272 |
const RegInfo *Model::lookupRegInfoByRegName(RegName name) const { |
| 273 |
// static tester should check this |
| 274 |
for (const RegInfo &ri : REGISTER_SPECIFICATIONS) { |
| 275 |
if (ri.regName == name && ri.supportedOn(platform)) { |
| 276 |
return &ri; |
| 277 |
} |
| 278 |
} |
| 279 |
return nullptr; |
| 280 |
} |
| 281 |
|
| 282 |
uint32_t Model::getNumGRF() const { return getRegCount(RegName::GRF_R); } |
| 283 |
|
| 284 |
uint32_t Model::getNumFlagReg() const { return getRegCount(RegName::ARF_F); } |
| 285 |
|
| 286 |
uint32_t Model::getGRFByteSize() const { |
| 287 |
return platform >= Platform::XE_HPC ? 64 : 32; |
| 288 |
} |
| 289 |
|
| 290 |
uint32_t Model::getRegCount(RegName rn) const { |
| 291 |
const RegInfo *ri = lookupRegInfoByRegName(rn); |
| 292 |
IGA_ASSERT(ri, "invalid register for platform"); |
| 293 |
// for getNumReg 0 means single register (like ce); bump to 1 |
| 294 |
int n = std::max(ri->getNumReg(), 1); |
| 295 |
return n; |
| 296 |
} |
| 297 |
|
| 298 |
uint32_t Model::getBytesPerReg(RegName rn) const { |
| 299 |
const RegInfo *ri = lookupRegInfoByRegName(rn); |
| 300 |
IGA_ASSERT(ri, "invalid register for platform"); |
| 301 |
if (rn == RegName::GRF_R) { |
| 302 |
// GRF has 0's in numBytesPerReg[..] |
| 303 |
if (platform >= Platform::XE_HPC) |
| 304 |
return 64; |
| 305 |
return 32; |
| 306 |
} |
| 307 |
// we assume they are all equal length |
| 308 |
return ri->numBytesPerReg[0]; |
| 309 |
} |
| 310 |
|
| 311 |
const RegInfo *iga::GetRegisterSpecificationTable(int &len) { |
| 312 |
len = sizeof(REGISTER_SPECIFICATIONS) / sizeof(REGISTER_SPECIFICATIONS[0]); |
| 313 |
return REGISTER_SPECIFICATIONS; |
| 314 |
} |
| 315 |
|
| 316 |
const RegInfo *Model::lookupArfRegInfoByRegNum(uint8_t regNum7_0) const { |
| 317 |
const RegInfo *arfAcc = nullptr; |
| 318 |
int regNum = (int)(regNum7_0 & 0xF); |
| 319 |
for (const RegInfo &ri : REGISTER_SPECIFICATIONS) { |
| 320 |
if (ri.regName == RegName::GRF_R) { |
| 321 |
continue; // GRF will be in the table as 0000b |
| 322 |
} else if (ri.regNum7_4 == |
| 323 |
((uint32_t)regNum7_0 >> 4) && // RegNum[7:4] matches AND |
| 324 |
ri.supportedOn(platform)) // platform matches |
| 325 |
{ |
| 326 |
int shiftedRegNum = regNum - ri.regNumBase; |
| 327 |
if (ri.regName == RegName::ARF_MME && |
| 328 |
!ri.isRegNumberValid(shiftedRegNum) && arfAcc != nullptr) { |
| 329 |
// they picked an invalid register in the acc# space |
| 330 |
// (which is shared with mme#) |
| 331 |
// since acc# is far more likely, favor that so the error |
| 332 |
// message about the register number being out of range |
| 333 |
// refers to acc# instead of mme# |
| 334 |
return arfAcc; |
| 335 |
} else if (ri.regName == RegName::ARF_ACC && |
| 336 |
!ri.isRegNumberValid(shiftedRegNum)) { |
| 337 |
// not really acc#, but mme#, continue the loop until we find |
| 338 |
// that one, but at least save acc# for the error case above |
| 339 |
arfAcc = &ri; |
| 340 |
} else { |
| 341 |
// - it's acc# (value reg) |
| 342 |
// - its mme# |
| 343 |
// - it's some other ARF |
| 344 |
return &ri; |
| 345 |
} |
| 346 |
} |
| 347 |
} |
| 348 |
// if we get here, we didn't find a matching register for this platform |
| 349 |
// it is possible we found and rejected acc# because the reg num was out |
| 350 |
// of bounds and we were hoping it was an mme# register, so we return |
| 351 |
// that reg specification so that the error message will favor |
| 352 |
// acc# over mme# (since the latter is far less likely) |
| 353 |
return arfAcc; |
| 354 |
} |
| 355 |
|
| 356 |
bool Model::srcHasReducedRegion(uint32_t srcIdx) const { |
| 357 |
// src region is in the format of "flat" or "scalar" only. |
| 358 |
// Other region cannot be encoded. Refer to the instructions |
| 359 |
// BitField: Src1.ScalarReg. |
| 360 |
if (platform >= Platform::XE3P_XPC && srcIdx == 1) |
| 361 |
return true; |
| 362 |
return false; |
| 363 |
} |
| 364 |
|
| 365 |
bool RegInfo::encode(int reg, uint16_t ®NumBits) const { |
| 366 |
if (!isRegNumberValid(reg)) |
| 367 |
return false; |
| 368 |
|
| 369 |
if (regName == RegName::GRF_R) |
| 370 |
regNumBits = (uint16_t)reg; |
| 371 |
else |
| 372 |
regNumBits = encodeARFRegNum(reg); |
| 373 |
return true; |
| 374 |
} |
| 375 |
|
| 376 |
uint8_t RegInfo::encodeARFRegNum(int reg) const { |
| 377 |
// ARF |
| 378 |
// RegNum[7:4] = high bits from the spec |
| 379 |
reg += regNumBase; |
| 380 |
// this assert would suggest that something is busted in |
| 381 |
// the RegInfo table |
| 382 |
IGA_ASSERT(reg <= 0xF, "ARF encoding overflowed"); |
| 383 |
uint8_t regNumBits = 0; |
| 384 |
regNumBits = (uint8_t)(regNum7_4 << 4); |
| 385 |
regNumBits |= (uint8_t)reg; |
| 386 |
return regNumBits; |
| 387 |
} |
| 388 |
|
| 389 |
bool RegInfo::decode(uint8_t regNumBits, int ®) const { |
| 390 |
if (regName == RegName::GRF_R) { |
| 391 |
reg = (int)regNumBits; |
| 392 |
} else { |
| 393 |
reg = (int)(regNumBits & 0xF) - regNumBase; // acc2 -> mme0 |
| 394 |
} |
| 395 |
return isRegNumberValid(reg); |
| 396 |
} |
| 397 |
|
| 398 |
// static const iga::Model MODEL_GEN7( |
| 399 |
// Platform::GEN7P5, &MODEL_GEN7_OPSPECS[0], "7", "ivb"); |
| 400 |
static constexpr Model MODEL_GEN7P5(Platform::GEN7P5, &MODEL_GEN7P5_OPSPECS[0], |
| 401 |
"7p5", "hsw"); |
| 402 |
static constexpr Model MODEL_GEN8(Platform::GEN8, &MODEL_GEN8_OPSPECS[0], "8", |
| 403 |
"bdw"); |
| 404 |
static constexpr Model MODEL_GEN9(Platform::GEN9, &MODEL_GEN9_OPSPECS[0], "9", |
| 405 |
"skl"); |
| 406 |
static constexpr Model MODEL_GEN10(Platform::GEN10, &MODEL_GEN10_OPSPECS[0], |
| 407 |
"10", "cnl"); |
| 408 |
static constexpr Model MODEL_GEN11(Platform::GEN11, &MODEL_GEN11_OPSPECS[0], |
| 409 |
"11", "icl"); |
| 410 |
static constexpr Model MODEL_XE(Platform::XE, &MODEL_XE_OPSPECS[0], "12p1", |
| 411 |
"xe", "xelp", "tgl", "tgllp", "dg1"); |
| 412 |
static constexpr Model |
| 413 |
MODEL_XE_HP(Platform::XE_HP, &MODEL_XE_HP_OPSPECS[0], "12p5", "xehp" |
| 414 |
); |
| 415 |
static constexpr Model MODEL_XE_HPG( |
| 416 |
Platform::XE_HPG, &MODEL_XE_HPG_OPSPECS[0], |
| 417 |
"12p71", // default file extension |
| 418 |
"xehpg" |
| 419 |
); |
| 420 |
static constexpr Model |
| 421 |
MODEL_XE_HPC(Platform::XE_HPC, &MODEL_XE_HPC_OPSPECS[0], "12p72", "xehpc" |
| 422 |
); |
| 423 |
|
| 424 |
|
| 425 |
static constexpr Model |
| 426 |
MODEL_XE2(Platform::XE2, &MODEL_XE2_OPSPECS[0], "2", "xe2", "lnl" |
| 427 |
); |
| 428 |
|
| 429 |
static constexpr Model |
| 430 |
MODEL_XE3(Platform::XE3, &MODEL_XE3_OPSPECS[0], "3", "xe3", "ptl" |
| 431 |
); |
| 432 |
static constexpr Model |
| 433 |
MODEL_XE3P_XPC(Platform::XE3P_XPC, &MODEL_XE3P_XPC_OPSPECS[0], "3pxpc", "xe3pxpc" |
| 434 |
); |
| 435 |
|
| 436 |
const Model *const iga::ALL_MODELS[] { |
| 437 |
&MODEL_GEN7P5, &MODEL_GEN8, &MODEL_GEN9, &MODEL_GEN10, &MODEL_GEN11, |
| 438 |
&MODEL_XE, &MODEL_XE_HP, &MODEL_XE_HPG, &MODEL_XE_HPC, |
| 439 |
&MODEL_XE2, |
| 440 |
&MODEL_XE3, |
| 441 |
&MODEL_XE3P_XPC, |
| 442 |
}; |
| 443 |
const size_t iga::ALL_MODELS_LEN = sizeof(ALL_MODELS) / sizeof(ALL_MODELS[0]); |
| 444 |
|
| 445 |
const Model *Model::LookupModel(Platform p) { |
| 446 |
switch (p) { |
| 447 |
case Platform::GEN7P5: |
| 448 |
return &MODEL_GEN7P5; |
| 449 |
case Platform::GEN8: |
| 450 |
case Platform::GEN8LP: |
| 451 |
return &MODEL_GEN8; |
| 452 |
case Platform::GEN9: |
| 453 |
case Platform::GEN9LP: |
| 454 |
case Platform::GEN9P5: |
| 455 |
return &MODEL_GEN9; |
| 456 |
case Platform::GEN10: |
| 457 |
return &MODEL_GEN10; |
| 458 |
case Platform::GEN11: |
| 459 |
return &MODEL_GEN11; |
| 460 |
case Platform::XE: |
| 461 |
return &MODEL_XE; |
| 462 |
case Platform::XE_HP: |
| 463 |
return &MODEL_XE_HP; |
| 464 |
case Platform::XE_HPG: |
| 465 |
return &MODEL_XE_HPG; |
| 466 |
case Platform::XE_HPC: |
| 467 |
return &MODEL_XE_HPC; |
| 468 |
case Platform::XE2: |
| 469 |
return &MODEL_XE2; |
| 470 |
case Platform::XE3: |
| 471 |
return &MODEL_XE3; |
| 472 |
case Platform::XE3P_XPC: |
| 473 |
return &MODEL_XE3P_XPC; |
| 474 |
default: |
| 475 |
return nullptr; |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
const Model &Model::LookupModelRef(Platform platform) { |
| 480 |
const Model *m = Model::LookupModel(platform); |
| 481 |
IGA_ASSERT(m, "invalid platform"); |
| 482 |
return *m; |
| 483 |
} |