| 1 |
/*========================== begin_copyright_notice ============================ |
| 2 |
|
| 3 |
Copyright (C) 2020-2021 Intel Corporation |
| 4 |
|
| 5 |
SPDX-License-Identifier: MIT |
| 6 |
|
| 7 |
============================= end_copyright_notice ===========================*/ |
| 8 |
|
| 9 |
#ifndef IGA_MESSAGE_INFO_HPP |
| 10 |
#define IGA_MESSAGE_INFO_HPP |
| 11 |
|
| 12 |
#include "../Backend/Native/Field.hpp" |
| 13 |
#include "../IR/Instruction.hpp" |
| 14 |
#include "../api/iga_bxml_enums.hpp" |
| 15 |
|
| 16 |
#include <cstdint> |
| 17 |
#include <string> |
| 18 |
#include <tuple> |
| 19 |
#include <vector> |
| 20 |
|
| 21 |
namespace iga { |
| 22 |
struct DescField { |
| 23 |
DescField(int _off, int _len) : off(_off), len(_len) {} |
| 24 |
int off, len; |
| 25 |
}; |
| 26 |
|
| 27 |
using DiagnosticList = std::vector<std::pair<DescField, std::string>>; |
| 28 |
using DecodedDescFields = |
| 29 |
std::vector<std::tuple<Fragment, uint32_t, std::string>>; |
| 30 |
|
| 31 |
// This is generic list of send operations. One or more messages may map |
| 32 |
// to the same element (hence why "generic"). In other words, two |
| 33 |
// different units (maybe different hardware generate the same message). |
| 34 |
enum class SendOp { |
| 35 |
INVALID, |
| 36 |
#define DEFINE_SEND_OP(E, M, D, A) E, |
| 37 |
#include "EnumSendOpInfo.hpp" |
| 38 |
#undef DEFINE_SEND_OP |
| 39 |
}; |
| 40 |
|
| 41 |
struct SendOpDefinition { |
| 42 |
SendOp op; |
| 43 |
const char *mnemonic; // e.g. "load" for SendOp::LOAD |
| 44 |
const char *description; // a longer description |
| 45 |
|
| 46 |
// typesafe bitset of send op attributes |
| 47 |
enum class Attr { |
| 48 |
NONE = 0x0000, |
| 49 |
// |
| 50 |
// the may have a destination (e.g. loads or atomics) |
| 51 |
// certain control ops may or may not have destinations |
| 52 |
HAS_DST = 0x0001, |
| 53 |
// |
| 54 |
// is the address a scalar register (e.g. load_block) |
| 55 |
IS_SCALAR_ADDR = 0x0002, |
| 56 |
// |
| 57 |
// if the operation supports a ChMask (e.g. load_quad) |
| 58 |
HAS_CMASK = 0x0004, |
| 59 |
// |
| 60 |
// If the message is a sampler gather4 |
| 61 |
GATHER4 = 0x0008, |
| 62 |
// |
| 63 |
// the op is a load, store, or atomic |
| 64 |
GROUP_LOAD = 0x0010, |
| 65 |
GROUP_STORE = 0x0020, |
| 66 |
GROUP_ATOMIC = 0x0040, |
| 67 |
GROUP_SAMPLE = 0x0080, |
| 68 |
GROUP_OTHER = 0x0100, // e.g. fence, barrier, eot, etc... |
| 69 |
|
| 70 |
// for atomics, the number of data arguments in src1 |
| 71 |
ATOMIC_UNARY = 0x1000, // none (atomic_iinc) |
| 72 |
ATOMIC_BINARY = 0x2000, // one (atomic_fadd) |
| 73 |
ATOMIC_TERNARY = 0x4000, // two (atomic_icas) |
| 74 |
}; |
| 75 |
Attr attrs; |
| 76 |
|
| 77 |
constexpr SendOpDefinition(SendOp o, const char *mne, const char *desc, |
| 78 |
Attr _attrs = Attr::NONE) |
| 79 |
: op(o), mnemonic(mne), description(desc), attrs(_attrs) {} |
| 80 |
constexpr SendOpDefinition(const SendOpDefinition &) = delete; |
| 81 |
constexpr SendOpDefinition &operator=(const SendOpDefinition &) = delete; |
| 82 |
|
| 83 |
bool isValid() const { return op != SendOp::INVALID; } |
| 84 |
bool hasAttr(Attr a) const { return (((int)attrs & (int)a)) != 0; } |
| 85 |
|
| 86 |
bool hasDst() const { return hasAttr(Attr::HAS_DST); } |
| 87 |
bool hasChMask() const { return hasAttr(Attr::HAS_CMASK); } |
| 88 |
bool isAddressScalar() const { return hasAttr(Attr::IS_SCALAR_ADDR); } |
| 89 |
|
| 90 |
bool isCCtrl() const { return op == SendOp::EXTENDED_CACHE_CTRL; } |
| 91 |
bool isLoad() const { return hasAttr(Attr::GROUP_LOAD); } |
| 92 |
bool isStore() const { return hasAttr(Attr::GROUP_STORE); } |
| 93 |
bool isAtomic() const { return hasAttr(Attr::GROUP_ATOMIC); } |
| 94 |
bool isSample() const { return hasAttr(Attr::GROUP_SAMPLE); } |
| 95 |
bool isOther() const { return hasAttr(Attr::GROUP_OTHER); } |
| 96 |
|
| 97 |
int numAtomicArgs() const { |
| 98 |
return hasAttr(Attr::ATOMIC_UNARY) ? 0 |
| 99 |
: hasAttr(Attr::ATOMIC_BINARY) ? 1 |
| 100 |
: hasAttr(Attr::ATOMIC_TERNARY) ? 2 |
| 101 |
: -1; |
| 102 |
} |
| 103 |
}; // SendOpDefinition |
| 104 |
static inline constexpr SendOpDefinition::Attr |
| 105 |
operator|(SendOpDefinition::Attr a1, SendOpDefinition::Attr a2) { |
| 106 |
return SendOpDefinition::Attr(int(a1) | int(a2)); |
| 107 |
} |
| 108 |
|
| 109 |
const SendOpDefinition &lookupSendOp(SendOp op); |
| 110 |
const SendOpDefinition &lookupSendOp(const char *mnemonic); |
| 111 |
|
| 112 |
std::string ToSyntax(SendOp op); |
| 113 |
|
| 114 |
enum class AddrType { |
| 115 |
// the invalid value |
| 116 |
INVALID = 0, |
| 117 |
// stateless |
| 118 |
FLAT, |
| 119 |
// stateful: bindless surface state (UMD) |
| 120 |
BSS, |
| 121 |
// stateful: surface state (KMD) |
| 122 |
SS, |
| 123 |
// stateful: binding table interface |
| 124 |
BTI, |
| 125 |
// new generic stateful surface based address |
| 126 |
// (merger of BSS and SS) |
| 127 |
SURF, |
| 128 |
}; |
| 129 |
std::string ToSymbol(AddrType op); |
| 130 |
|
| 131 |
// documentation reference |
| 132 |
struct DocRef { |
| 133 |
enum Kind { |
| 134 |
INVALID = 0, |
| 135 |
// |
| 136 |
DST, // load or atomic payload |
| 137 |
SRC0, // headers/addresses etc... |
| 138 |
SRC1, // store/atomic payload |
| 139 |
// |
| 140 |
MSGOP, // the message opcode (always bits of the descriptor) |
| 141 |
DESC, // descriptor |
| 142 |
EXDESC, // extended descriptor (imm or reg) |
| 143 |
IND0, // indirect descriptor 0 |
| 144 |
IND1, // indirect descriptor 1 |
| 145 |
} kind; |
| 146 |
// the documentation symbol name corresponding to this |
| 147 |
const char *symbol; |
| 148 |
const char *link; |
| 149 |
constexpr DocRef() : DocRef(DocRef::INVALID, nullptr, nullptr) {} |
| 150 |
constexpr DocRef(Kind _kind, const char *sym, const char *lnk) |
| 151 |
: kind(_kind), symbol(sym), link(lnk) {} |
| 152 |
}; |
| 153 |
|
| 154 |
/////////////////////////////////////////////////////////////////////////// |
| 155 |
// Generic processing of basic buffer messages. This includes data port |
| 156 |
// vector reads and writes as well block and atomic messages. There may be |
| 157 |
// certain obscure or legacy operations that are unsupported. |
| 158 |
// |
| 159 |
struct MessageInfo { |
| 160 |
enum class Attr : uint32_t { |
| 161 |
NONE = 0x0, |
| 162 |
// |
| 163 |
// Set on atomic operations that return data. |
| 164 |
ATOMIC_RETURNS = 1 << 0, |
| 165 |
// |
| 166 |
// For messages that uncompress data, expand into the high unit |
| 167 |
// instead of the low. |
| 168 |
EXPAND_HIGH = 1 << 1, |
| 169 |
// |
| 170 |
// If the message supports a channel mask for vector size |
| 171 |
// (data elements) |
| 172 |
HAS_CHMASK = 1 << 2, |
| 173 |
// |
| 174 |
// Indicates the message is has U, V, R, and LOD coordinates |
| 175 |
// as part of the address payloads. |
| 176 |
// Otherw messages may have a different coordinate layout. |
| 177 |
HAS_UVRLOD = 1 << 3, |
| 178 |
// |
| 179 |
// Indicates a scratch message |
| 180 |
SCRATCH = 1 << 4, |
| 181 |
// |
| 182 |
// Indicates the message is to SLM (shared local memory) |
| 183 |
SLM = 1 << 5, |
| 184 |
// |
| 185 |
// Indicates the data is transposed during load or store. |
| 186 |
TRANSPOSED = 1 << 6, |
| 187 |
// |
| 188 |
// Indicates the message is a typed operation. |
| 189 |
// In later platforms this implies the operation is to SFID TGM. |
| 190 |
TYPED = 1 << 7, |
| 191 |
// |
| 192 |
// Indicates the message decode info is valid. |
| 193 |
VALID = 0x80000000, |
| 194 |
}; |
| 195 |
|
| 196 |
// |
| 197 |
// Queries a boolean property of this message. |
| 198 |
bool hasAttr(Attr attr) const; |
| 199 |
// Adds attributes to the attribute set. |
| 200 |
void addAttr(Attr attr); |
| 201 |
|
| 202 |
// The specific operation |
| 203 |
SendOp op = SendOp::INVALID; |
| 204 |
|
| 205 |
// A bitset of the above attributes |
| 206 |
Attr attributeSet = MessageInfo::Attr::NONE; |
| 207 |
|
| 208 |
// Size (in bits) of one address |
| 209 |
int addrSizeBits = 0; |
| 210 |
// |
| 211 |
// The size (in bits) of each element once stored in the register file. |
| 212 |
int elemSizeBitsRegFile = 0; |
| 213 |
// |
| 214 |
// The size (in bits) of each element in memory. |
| 215 |
// |
| 216 |
// This can differ from elemSizeRegisterFile if there's any compression |
| 217 |
// effects. For example, a byte gathering read will load one, two, |
| 218 |
// four bytes into each 32b slot leaving the upper bits for the one- |
| 219 |
// and two-byte case. |
| 220 |
// |
| 221 |
int elemSizeBitsMemory = 0; |
| 222 |
// |
| 223 |
// The number of vector elems or active channels in the cmask. |
| 224 |
// This is the number of elements each address loads. |
| 225 |
// |
| 226 |
// For example a legacy untyped load with a channel mask of XYZ |
| 227 |
// would be 3. Some scatter/gather messages have a SIMT vector |
| 228 |
// component similar in function. |
| 229 |
int elemsPerAddr = 0; |
| 230 |
// |
| 231 |
// For LOAD_QUAD and STORE_QUAD, this holds a bit mask of up to four |
| 232 |
// bits with which channels are *enabled* (not disabled). |
| 233 |
// |
| 234 |
// The elemsPerAddr field will still be set |
| 235 |
// (with the set cardinality here). |
| 236 |
int channelsEnabled = 0; |
| 237 |
// |
| 238 |
// The number of channels in the size of the operation. |
| 239 |
// (The "SIMD" size.) |
| 240 |
int execWidth = 0; |
| 241 |
|
| 242 |
// Caching options for the L1 cache (if supported) |
| 243 |
CacheOpt cachingL1 = CacheOpt::INVALID; |
| 244 |
// Caching option for L2 cache |
| 245 |
// Only supported for sendg (efficient64b feature) |
| 246 |
CacheOpt cachingL2 = CacheOpt::INVALID; |
| 247 |
// |
| 248 |
// Caching options for the L3 cache (if supported) |
| 249 |
// In some HDC messages this is bit 13. Some parts don't |
| 250 |
// implement it though. |
| 251 |
CacheOpt cachingL3 = CacheOpt::INVALID; |
| 252 |
// |
| 253 |
// The surface addressing model |
| 254 |
AddrType addrType = AddrType::INVALID; |
| 255 |
// |
| 256 |
// The surface identifier (if applicable). E.g. BTI. |
| 257 |
SendDesc surfaceId; |
| 258 |
// |
| 259 |
// The s0 surface registers; this subsumes surfaceId given |
| 260 |
// efficient64b (if present on this platform) |
| 261 |
RegRef surfaceState = REGREF_INVALID; |
| 262 |
// |
| 263 |
// SS_IDX (Surface State Index) enables a relative offset of |
| 264 |
// surface state elements to be added to the given surface state |
| 265 |
// address in IND0 |
| 266 |
int surfaceStateIndex = 0; |
| 267 |
// |
| 268 |
// The sampler state register (if present) |
| 269 |
RegRef samplerState = REGREF_INVALID; |
| 270 |
// |
| 271 |
// SMS_IDX - sampler state entry offset |
| 272 |
int samplerStateIndex = 0; |
| 273 |
// |
| 274 |
// only used in flat messages |
| 275 |
RegRef uniformBase = REGREF_INVALID; |
| 276 |
int uniformBaseAddrSizeBits = 0; |
| 277 |
bool signExtendIndices = false; |
| 278 |
// |
| 279 |
// Addresses are scaled by this amount (in bytes) |
| 280 |
// (must be 1x, 2x, 4x data type size and <=32) |
| 281 |
// (0 implies not applicable or disabled) |
| 282 |
int addrScaling = 0; |
| 283 |
// |
| 284 |
// Sampler and typed coordinate immediate offsets. |
| 285 |
int uvrImmediateOffsets[3]{0, 0, 0}; |
| 286 |
// |
| 287 |
// Returns the computed destination length (-1 if undefined or unknown) |
| 288 |
int dstLenBytes = -1; |
| 289 |
// Returns the computed source lengths (-1 if undefined or unknown) |
| 290 |
int src0LenBytes = -1; |
| 291 |
int src1LenBytes = -1; |
| 292 |
|
| 293 |
// |
| 294 |
// Possible immediate offset (if the encoding supports it) |
| 295 |
// This is in bytes not elements |
| 296 |
int immediateOffset = 0; |
| 297 |
// |
| 298 |
// same as the above but only for block2d (mutally exclusive with above) |
| 299 |
// This is in dataSize elements |
| 300 |
int immediateOffsetBlock2dX = 0, immediateOffsetBlock2dY = 0; |
| 301 |
// |
| 302 |
// A symbol value for this message (syntax). |
| 303 |
// The syntax is not complete and IGA will not consume it directly |
| 304 |
// (since some information isn't in necessarily in the descriptors). |
| 305 |
std::string symbol; |
| 306 |
// |
| 307 |
// |
| 308 |
// This may hold a useful string telling the user the exact message |
| 309 |
// matching this specification up decode (if it exists). This is |
| 310 |
// indended for for debugging only; the value and behavior are subject |
| 311 |
// to change at any time. The nullptr is a possible value. |
| 312 |
std::string description; |
| 313 |
|
| 314 |
// documentation references |
| 315 |
std::vector<DocRef> refs; |
| 316 |
// |
| 317 |
// A block message |
| 318 |
bool isBlock() const { return execWidth == 1 && (isLoad() || isStore()); } |
| 319 |
// |
| 320 |
bool isLoad() const { return lookupSendOp(op).isLoad(); } |
| 321 |
bool isStore() const { return lookupSendOp(op).isStore(); } |
| 322 |
bool isAtomic() const { return lookupSendOp(op).isAtomic(); } |
| 323 |
bool isSample() const { return lookupSendOp(op).isSample(); } |
| 324 |
bool isOther() const { return lookupSendOp(op).isOther(); } |
| 325 |
// |
| 326 |
// An atomic that returns a value |
| 327 |
bool isAtomicLoad() const { return hasAttr(Attr::ATOMIC_RETURNS); } |
| 328 |
// |
| 329 |
// A transpose data layout |
| 330 |
bool isTransposed() const { return hasAttr(Attr::TRANSPOSED); } |
| 331 |
|
| 332 |
// Enables the operation to be used within a predicate assignment. |
| 333 |
operator bool() const { return hasAttr(Attr::VALID); } |
| 334 |
}; // class MessageInfo |
| 335 |
|
| 336 |
static inline MessageInfo::Attr operator|(MessageInfo::Attr a, |
| 337 |
MessageInfo::Attr b) { |
| 338 |
return MessageInfo::Attr(int(a) | int(b)); |
| 339 |
} |
| 340 |
static inline MessageInfo::Attr &operator|=(MessageInfo::Attr &a, |
| 341 |
MessageInfo::Attr b) { |
| 342 |
return (a = a | b); |
| 343 |
} |
| 344 |
static inline bool operator&(MessageInfo::Attr a, MessageInfo::Attr b) { |
| 345 |
return (int(a) & int(b)) != 0; |
| 346 |
} |
| 347 |
inline bool MessageInfo::hasAttr(Attr attr) const { |
| 348 |
return attributeSet & attr; |
| 349 |
} |
| 350 |
inline void MessageInfo::addAttr(Attr attr) { |
| 351 |
attributeSet = attributeSet | attr; |
| 352 |
} |
| 353 |
|
| 354 |
// for legacy encodings where the SFID comes from bits |
| 355 |
SFID sfidFromEncoding(Platform p, uint32_t sfidBits); |
| 356 |
|
| 357 |
// The payload lengths for a given message. |
| 358 |
// Negative values indicate that the value is unknown or could be variable. |
| 359 |
struct PayloadLengths { |
| 360 |
int dstLen = -1; |
| 361 |
int src0Len = -1, src1Len = -1; |
| 362 |
bool uvrlod = false; |
| 363 |
|
| 364 |
PayloadLengths() {} |
| 365 |
|
| 366 |
// This attempts to deduce payload lengths from the given inputs. |
| 367 |
PayloadLengths(Platform p, SFID sfid, ExecSize execSize, uint32_t desc); |
| 368 |
|
| 369 |
// Same as above, but given a Op::SEND* |
| 370 |
// |
| 371 |
// For older platforms this will extract the SFID from exDesc |
| 372 |
PayloadLengths(Platform p, ExecSize execSize, uint32_t desc, uint32_t exDesc); |
| 373 |
}; |
| 374 |
|
| 375 |
// Organizes various parts of syntax during decoding. This enables |
| 376 |
// formatters to interleave real registers. |
| 377 |
// |
| 378 |
// LOAD: load, load_strided, load_cmask, fence |
| 379 |
// MNEMONIC SFID CONTROLS |
| 380 |
// $datareg DATATYPE |
| 381 |
// SURFACE [ SCALE $addrreg IMMOFFSET ] ADDRTYPE |
| 382 |
// ATOMIC: atomic_iinc |
| 383 |
// MNEMONIC SFID CONTROLS |
| 384 |
// $datareg DATATYPE |
| 385 |
// SURFACE [ SCALE $addrreg IMMOFFSET ] ADDRTYPE |
| 386 |
// $atomic-arg |
| 387 |
// STORE: store, store_strided |
| 388 |
// MNEMONIC SFID CONTROLS |
| 389 |
// SURFACE [ SCALE $addrreg IMMOFFSET ] ADDRTYPE |
| 390 |
// $datareg DATATYPE |
| 391 |
// CONTROL: e.g. barrier |
| 392 |
// MNEMONIC SFID CONTROLS |
| 393 |
// SURFACE [ SCALE $addrreg IMMOFFSET ] ADDRTYPE |
| 394 |
// $datareg DATATYPE |
| 395 |
// |
| 396 |
// Examples: |
| 397 |
// load.ugm.ca.ca (32) r10:d32x4 bti<0x02>[r20-0x40]:a32 |
| 398 |
// load.ugm.ca.ca (1) r10:d32x4t flat[r20+0x40]:a64 |
| 399 |
// load.slm (1) r10:d32x4t flat[r20+0x40]:a64 |
| 400 |
// store_strided.ugm.wt.wb (16) bss<a0.4>[r20+0x40]:a32 r10:d32x4 |
| 401 |
// atomic_iinc.ugm.un.un (32) r10:d32 flat[r20-0x40]:a64 null |
| 402 |
struct MessageSyntax { |
| 403 |
enum class Layout { |
| 404 |
// unset |
| 405 |
INVALID = 0, |
| 406 |
// e.g. load, load_strided, load_quad, load_blocks2d, ... |
| 407 |
LOAD, |
| 408 |
// e.g. store, store_quad, store_strided, ... |
| 409 |
STORE, |
| 410 |
// e.g. atomic_iinc, atomic_fadd |
| 411 |
ATOMIC, |
| 412 |
// e.g. barrier or eot |
| 413 |
CONTROL |
| 414 |
}; |
| 415 |
Layout layout = Layout::INVALID; |
| 416 |
|
| 417 |
bool isValid() const { return layout != Layout::INVALID; } |
| 418 |
// |
| 419 |
bool isLoad() const { return layout == Layout::LOAD; } |
| 420 |
bool isStore() const { return layout == Layout::STORE; } |
| 421 |
bool isAtomic() const { return layout == Layout::ATOMIC; } |
| 422 |
bool isControl() const { return layout == Layout::CONTROL; } |
| 423 |
|
| 424 |
std::string mnemonic; // e.g. "load" or "load_block" |
| 425 |
// SFID sfid; // e.g. "ugm" |
| 426 |
std::string controls; // e.g. ".ugm.d32.a64.ca.ca" |
| 427 |
|
| 428 |
// address stuff |
| 429 |
std::string surface; // e.g. "bti[0x2]", "bti[a0.4]", or "" (flat) |
| 430 |
std::string scale; // e.g. 4*... |
| 431 |
std::string immOffset; // e.g. -0x40 |
| 432 |
|
| 433 |
// emits rough syntax |
| 434 |
std::string str(std::string execInfo, std::string dataReg, |
| 435 |
std::string addrReg, std::string atmoicArgReg) const; |
| 436 |
|
| 437 |
// orders the operands in a symbolic form |
| 438 |
// (suffixes surface, scaling and offset) |
| 439 |
std::string sym() const; |
| 440 |
}; // MessageSyntax |
| 441 |
|
| 442 |
// |
| 443 |
// Returns the resulting information of a message decode |
| 444 |
struct DecodeResult { |
| 445 |
MessageInfo info; |
| 446 |
MessageSyntax syntax; |
| 447 |
DiagnosticList warnings; |
| 448 |
DiagnosticList errors; |
| 449 |
DecodedDescFields fields; |
| 450 |
|
| 451 |
operator bool() const { return errors.empty(); } |
| 452 |
}; |
| 453 |
|
| 454 |
// Attempts to decode the descriptor for send instructions |
| 455 |
DecodeResult tryDecode(const Instruction &inst, DecodedDescFields *fields); |
| 456 |
|
| 457 |
// Attempts to decode the descriptor for send instructions |
| 458 |
DecodeResult tryDecode(Platform p, SFID sfid, ExecSize execSize, |
| 459 |
uint32_t exImmOffDesc, |
| 460 |
SendDesc exDesc, SendDesc desc, |
| 461 |
DecodedDescFields *fields); |
| 462 |
|
| 463 |
static inline DecodeResult tryDecode(Platform p, SFID sfid, ExecSize execSize, |
| 464 |
SendDesc exDesc, SendDesc desc, |
| 465 |
DecodedDescFields *fields) { |
| 466 |
return tryDecode(p, sfid, execSize, 0, exDesc, desc, fields); |
| 467 |
} |
| 468 |
|
| 469 |
// For descriptors following efficient64b |
| 470 |
DecodeResult tryDecode(Platform p, SFID sfid, ExecSize execSize, int src0Len, |
| 471 |
int src1Len, RegRef id0, RegRef id1, uint64_t desc, |
| 472 |
DecodedDescFields *fields); |
| 473 |
|
| 474 |
// |
| 475 |
// returns true if the SFID on a given platform is eligible for symbolic |
| 476 |
// translate for load/store syntax; this function enables us to |
| 477 |
// incrementally enable load/store syntax |
| 478 |
bool sendOpSupportsSyntax(Platform p, SendOp op, SFID sfid); |
| 479 |
// |
| 480 |
bool isLscSFID(Platform p, SFID sfid); |
| 481 |
// |
| 482 |
struct VectorMessageArgs { |
| 483 |
SFID sfid = SFID::INVALID; |
| 484 |
SendOp op = SendOp::INVALID; |
| 485 |
int execSize = 0; |
| 486 |
CacheOpt cachingL1 = CacheOpt::DEFAULT; |
| 487 |
CacheOpt cachingL3 = CacheOpt::DEFAULT; |
| 488 |
// |
| 489 |
AddrType addrType = AddrType::FLAT; |
| 490 |
SendDesc addrSurface = 0; // a0 or imm |
| 491 |
int addrScale = 1; // must be 1x, V*D, 2*V*2, or 4*V*D |
| 492 |
int addrSize = 0; |
| 493 |
int addrOffset = 0; // imm only |
| 494 |
int addrOffsetX = 0; // block2d only |
| 495 |
int addrOffsetY = 0; // block2d only |
| 496 |
int dataSizeReg = 0; |
| 497 |
int dataSizeMem = 0; |
| 498 |
bool dataSizeExpandHigh = 0; // d8u32h |
| 499 |
union { |
| 500 |
struct { |
| 501 |
short dataVectorSize; |
| 502 |
bool dataTranspose; |
| 503 |
bool dataVnni; |
| 504 |
}; |
| 505 |
// |
| 506 |
// used for LOAD_QUAD, STORE_QUAD, ... |
| 507 |
// e.g. this might map to to dc1 untyped read/write ops |
| 508 |
uint32_t dataComponentMask = 0; // x,y,z,w (x-enabled is bit 0, ...) |
| 509 |
}; |
| 510 |
|
| 511 |
/////////////////////////////////////////////////////////////////////// |
| 512 |
// creates an initial empty message |
| 513 |
constexpr VectorMessageArgs() {} |
| 514 |
|
| 515 |
// returns the logical count of elements per address |
| 516 |
// for simple vector messages, it's dataVectorSize, but for |
| 517 |
// messages with a component mask, it's the number of enabled channels |
| 518 |
int elementsPerAddress() const { |
| 519 |
if (lookupSendOp(op).hasChMask()) { |
| 520 |
int n = 0; |
| 521 |
for (int i = 0; i < 4; i++) |
| 522 |
n += (((1 << i) & dataComponentMask) ? 1 : 0); |
| 523 |
return n; |
| 524 |
} else { |
| 525 |
return dataVectorSize; |
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
bool isLoad() const { return lookupSendOp(op).isLoad(); } |
| 530 |
bool isStore() const { return lookupSendOp(op).isStore(); } |
| 531 |
bool isAtomic() const { return lookupSendOp(op).isAtomic(); } |
| 532 |
bool hasCMask() const { return lookupSendOp(op).hasChMask(); } |
| 533 |
}; // VectorMessageArgs |
| 534 |
|
| 535 |
bool encodeDescriptors(Platform p, const VectorMessageArgs &vma, |
| 536 |
uint32_t &exImmOffDesc, SendDesc &exDesc, SendDesc &desc, |
| 537 |
std::string &err); |
| 538 |
} // namespace iga |
| 539 |
|
| 540 |
#endif |