Debian Codegraph @

visa/iga/IGALibrary/Backend/Messages/MessageDecoderHDC.cpp

raw
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 #include "MessageDecoder.hpp"
10
11 using namespace iga;
12
13 static const char *MDC_DS_MEANINGS[]{
14 "DE1 (1 data element per address)",
15 "DE2 (2 data elements per address)",
16 "DE4 (4 data elements per address)",
17 "DE8 (8 data elements per address)",
18 };
19
20 using HDCOpcode = uint32_t;
21 enum DC0 : uint32_t {
22 /////////////////////////////////////////
23 MSD0R_OWB = 0x00, // oword block read (unaligned)
24 MSD0R_OWAB = 0x01, // oword/hword block read (aligned)
25 MSD0W_OWB = 0x08, // oword block write
26 MSD0W_HWAB = 0x09, // hword block write (aligned)
27 MSD0R_OWDB = 0x02, // dual block read
28 MSD0W_OWDB = 0x0A, // dual block write
29 //
30 MSD0R_BS = 0x04, // byte gathered read
31 MSD0W_BS = 0x0C, // byte scattered write
32 //
33 MSD0R_DWS = 0x03, // dword gathered read
34 MSD0W_DWS = 0x0B, // dword scattered write
35 //
36 MSD0R_QWS = 0x05, // qword gathered write
37 MSD0W_QWS = 0x0D, // qword scattered write
38 //
39 MSD_MEMFENCE = 0x07,
40 //
41 };
42 enum DC1 : uint32_t {
43 /////////////////////////////////////////
44 MSD1R_US = 0x01, // untyped read
45 MSD1W_US = 0x09, // untyped write
46 //
47 MSD1R_A64_US = 0x11, // a64 untyped read
48 MSD1W_A64_US = 0x19, // a64 untyped write
49 //
50 MSD1R_A64_BS = 0x10, // byte gathered read
51 MSD1W_A64_BS = 0x1A, // byte scattered write
52 MSD1R_A64_DWS = (0x1 << 8) | MSD1R_A64_BS,
53 MSD1W_A64_DWS = (0x1 << 8) | MSD1W_A64_BS,
54 MSD1R_A64_QWS = (0x2 << 8) | MSD1R_A64_BS,
55 MSD1W_A64_QWS = (0x2 << 8) | MSD1W_A64_BS,
56 MSD1RS_A64_BS = (0x3 << 8) | MSD1R_A64_BS,
57 //
58 MSD1R_A64_HWB = 0x14,
59 MSD1W_A64_HWB = 0x15,
60 //
61 MSD1W_A64_DWAF = 0x1D,
62 MSD1W_DWAF = 0x1B,
63 // MSD1W_A64_QWAI = (1 << 12) | 0x12,
64 // MSD1W_A64_DWAI = (0 << 12) | 0x12,
65 MSD1W_A64_AI = 0x12,
66 //
67 MSD1W_DWAI = 0x02,
68 //
69 MSD1R_MB = 0x04,
70 MSD1W_MB = 0x0A,
71 //
72 MSD1R_TS = 0x05,
73 MSD1W_TS = 0x0D,
74 MSD1RS_TS = 0x0E,
75 //
76 MSD1A_DWAC = 0x0B,
77 MSD1A_DWTAI = 0x06,
78 //
79 // XE+
80 // e.g. MSD1R_WAC MSD1W_WAC => MSD1A_WAC (use "a" for atomic)
81 MSD1A_WAC = 0x0C, // typed atomic 16b int counter
82 MSD1A_WTAI = 0x07, // typed atomic 16b int op
83 MSD1A_A64_WAF = 0x1E, // typed atomic 16b float
84 MSD1A_WAF = 0x1C,
85 MSD1A_A64_WAI = 0x13,
86 MSD1A_WAI = 0x03,
87 };
88
89 struct MessageDecoderHDC : MessageDecoderLegacy {
90 MessageDecoderHDC(Platform _platform, SFID _sfid, ExecSize execSize,
91 uint32_t exImmOffDesc, SendDesc _exDesc, SendDesc _desc,
92 DecodeResult &_result)
93 : MessageDecoderLegacy(_platform, _sfid, execSize, exImmOffDesc, _exDesc,
94 _desc, _result) {}
95
96 void ensurePlatformLT(Platform removed) {
97 if (platform() >= removed) {
98 error(14, 5, "operation not supported on this platform");
99 }
100 }
101 void ensurePlatformLE(Platform removed) {
102 if (platform() > removed) {
103 error(14, 5, "operation not supported on this platform");
104 }
105 }
106 void ensurePlatformGE(Platform introduced) {
107 if (platform() < introduced) {
108 error(14, 5, "operation not supported on this platform");
109 }
110 }
111 void ensurePlatformIn(Platform first, Platform last) {
112 if (platform() < first || platform() > last) {
113 error(14, 5, "operation not supported on this platform");
114 }
115 }
116
117 ///////////////////////////////////////////////////////////////////////////
118 // decoder helpers
119 int decodeXXX_HW(int off, int len, const char *fieldName) {
120 // scratch's use of DataElements:MDC_DB_HW uses 2 bits
121 // DataElements:MDC_DB_HW for A32 uses 3 bits (starting at bit 8)
122 // the A64 version is always [10:8]
123 auto bits = getDescBits(off, len);
124 // 0 -> 1 block, 1 -> 2 blocks, 2 -> 4 blocks, 3 -> 8 blocks
125 int val = (int)(1 << bits);
126 std::stringstream ss;
127 ss << val << " 256b blocks";
128 addField(fieldName, off, len, getDescBits(off, len), ss.str());
129 return val;
130 }
131 int decodeMDC_A64_DB_HW(int off) {
132 return decodeXXX_HW(off, 3, "DataElements:MDC_A64_DB_HW");
133 }
134 int decodeMDC_DB_HW(int off, int len) {
135 return decodeXXX_HW(off, len, "DataElements:MDC_DB_HW");
136 }
137 //
138 int decodeXXX_OW(int off, const char *fieldName) {
139 int bits = getDescBits(off, 3);
140 int ows = 0;
141 const char *descs = "???";
142 // MDC_DB_OW and MDC_64_DB_OW
143 // 1L, 1H, 2, 4, 8, 16
144 switch (bits) {
145 case 0:
146 ows = 1;
147 descs = "1L (accesses low OWord of GRF)";
148 break;
149 case 1:
150 ows = 1;
151 descs = "1H (accesses second OWord of GRF)";
152 break;
153 case 2:
154 ows = 2;
155 descs = "2 OWords";
156 break;
157 case 3:
158 ows = 4;
159 descs = "4 OWords";
160 break;
161 case 4:
162 ows = 8;
163 descs = "8 OWords";
164 break;
165 case 5:
166 ensurePlatformGE(Platform::XE_HPG);
167 ows = 16;
168 descs = "16 OWords";
169 break;
170 default:
171 break;
172 }
173 addField(fieldName, off, 3, bits, descs);
174 return ows;
175 }
176 int decodeMDC_A64_DB_OW(int off) {
177 return decodeXXX_OW(off, "DataElements:MDC_A64_DB_OW");
178 }
179 int decodeMDC_DB_OW(int off) {
180 return decodeXXX_OW(off, "DataElements:MDC_DB_OW");
181 }
182
183 int decodeMDC_DS(int off) {
184 auto bits = getDescBits(off, 2);
185 addField("DataElements:MDC_DS", off, 2, bits, MDC_DS_MEANINGS[bits]);
186 return (1 << (int)bits);
187 }
188 int MDC_A64_DS(int off) {
189 auto bits = getDescBits(off, 2);
190 addField("DataElements:MDC_A64_DS", off, 2, bits, MDC_DS_MEANINGS[bits]);
191 return (1 << (int)bits);
192 }
193 int decodeMDC_DWS_DS(int off) {
194 auto bits = getDescBits(off, 2);
195 static const char *meanings[]{"Fill low 1 byte per DW",
196 "Fill low 2 bytes per DW",
197 "Fill all 4 bytes per DW", "???"};
198 addField("DataElements:MDC_DWS_DS", off, 2, bits, meanings[bits]);
199 return (1 << (int)bits);
200 }
201
202 int decodeMDC_SM2X(int off, bool reversed) {
203
204 int simd = 0;
205 if (reversed) {
206 int bits =
207 decodeDescBitField("SimdMode:MDC_SM2R", off, "SIMD8", "SIMD16");
208 simd = bits ? 8 : 16;
209 } else {
210 int bits =
211 decodeDescBitField("SimdMode:MDC_SM2R", off, "SIMD16", "SIMD8");
212 simd = bits ? 16 : 8;
213 }
214
215 if (platform() >= Platform::XE_HPC) {
216 if (simd == 16) {
217 error(off, 1, "invalid value for this platform");
218 }
219 simd *= 2;
220 }
221 return simd;
222 }
223 int decodeMDC_SM2R(int off) { return decodeMDC_SM2X(off, true); }
224 int decodeMDC_SM2S(int off) { return decodeMDC_SM2X(off, false); }
225 int decodeMDC_SM3(int off) {
226 auto bits = getDescBits(off, 2);
227 int simd = 0;
228 const char *simdStr = "?";
229 switch (bits) {
230 case 1:
231 simd = 16;
232 simdStr = "SIMD16";
233 break;
234 case 2:
235 simd = 8;
236 simdStr = "SIMD8";
237 break;
238 default:
239 error(off, 2, "invalid value");
240 break;
241 }
242 if (platform() >= Platform::XE_HPC) {
243 if (bits == 2) {
244 // illegal on XeHPC+
245 error(off, 1, "invalid value for this platform");
246 }
247 }
248 addField("SimdMode:MDC_SM3", off, 2, bits, simdStr);
249 return simd;
250 }
251 int decodeMDC_CMASK() {
252 auto bits = getDescBits(8, 4);
253 std::stringstream ss;
254 int vecLen = 0;
255 if (bits == 0xF) {
256 error(8, 4, "channel mask must have one element not disabled");
257 }
258 for (int i = 0; i < 4; i++) {
259 if (((1 << i) & bits) == 0) {
260 if (vecLen > 0)
261 ss << ", ";
262 ss << "XYZW"[i];
263 vecLen++;
264 }
265 }
266 if (vecLen == 0)
267 ss << "no channels enabled";
268 else
269 ss << " enabled";
270 addField("ChannelDisableMask:MDC_CMASK", 8, 4, bits, ss.str());
271 return vecLen;
272 }
273
274 // returns true if high slot group
275 bool decodeMDC_SG3() {
276 auto bits = getDescBits(12, 2);
277 const char *sym = "??";
278 switch (bits) {
279 case 0:
280 sym = "SG4x2";
281 break;
282 case 1:
283 sym = "SG8L";
284 // in XeHPC this becomes the default
285 if (platform() >= Platform::XE_HPC)
286 sym = "SIMD16";
287 break;
288 case 2:
289 sym = "SG8U";
290 break;
291 default:
292 error(12, 2, "invalid slot group value");
293 }
294 addField("SlotGroup:MDC_SG3", 12, 2, bits, sym);
295 return bits == 2;
296 }
297
298 bool decodeMDC_SG2() {
299 auto bits = getDescBits(12, 1);
300 const char *sym = "??";
301 switch (bits) {
302 case 0:
303 sym = "SG8L";
304 // in XeHPC this becomes the default
305 if (platform() >= Platform::XE_HPC)
306 sym = "SIMD16";
307 break;
308 case 1:
309 sym = "SG8U";
310 break;
311 default:
312 break;
313 }
314 addField("SlotGroup:MDC_SG2", 12, 1, bits, sym);
315 return bits == 1;
316 }
317
318 CacheOpt decodeMDC_IAR() {
319 int bits = decodeDescBitField("MDC_IAR", 13, "disabled", "enabled");
320 return bits ? CacheOpt::READINVALIDATE : CacheOpt::DEFAULT;
321 }
322
323 ///////////////////////////////////////////////////////////////////////////
324 //
325
326 // allows different data sizes in mem and reg
327 void setHdcMessageX(const std::string &msgSym, const std::string &msgDesc, SendOp op,
328 int addrSizeBits, int bitsPerElemReg, int bitsPerElemMem,
329 int elemsPerAddr, int execSize,
330 MessageInfo::Attr extraAttrs) {
331 CacheOpt caching = CacheOpt::DEFAULT;
332 const SendOpDefinition &opInfo = lookupSendOp(op);
333 std::stringstream ss;
334 ss << "hdc_";
335 ss << msgSym; // e.g. "load"
336 if (execSize == 8 || execSize == 16)
337 ss << "_simd" << execSize;
338
339 if (instExecSize != ExecSize::INVALID) {
340 // e.g. a SIMD4 message will mask out the top bits
341 execSize = std::min(execSize, int(instExecSize));
342 }
343
344 ss << ".";
345 int bti = 0;
346 if (!(extraAttrs & MessageInfo::Attr::SCRATCH)) {
347 bti = decodeBTI(addrSizeBits);
348 }
349 AddrType addrType = AddrType::BTI;
350 uint32_t surfaceId = 0;
351 if (addrSizeBits == 32) {
352 if (extraAttrs & MessageInfo::Attr::SCRATCH) {
353 ss << "scratch";
354 ss << "+" << 32 * getDescBits(0, 12);
355 } else if (bti == SLM_BTI) {
356 ss << "slm";
357 addrType = AddrType::FLAT;
358 surfaceId = 0;
359 extraAttrs |= MessageInfo::Attr::SLM;
360 } else if (bti == COHERENT_BTI || bti == NONCOHERENT_BTI) {
361 ss << "stateless";
362 if (bti != COHERENT_BTI) {
363 ss << "_incoherent";
364 caching = CacheOpt::CACHED;
365 } else {
366 caching = CacheOpt::UNCACHED;
367 }
368 addrType = AddrType::FLAT;
369 } else {
370 addrType = AddrType::BTI;
371 surfaceId = bti;
372 ss << "bti[" << bti << "]";
373 }
374 } else if (addrSizeBits == 64) {
375 ss << "stateless";
376 if (bti != COHERENT_BTI) {
377 ss << "_incoherent";
378 caching = CacheOpt::CACHED;
379 } else {
380 caching = CacheOpt::UNCACHED;
381 }
382 addrType = AddrType::FLAT;
383 if (bti != COHERENT_BTI && bti != NONCOHERENT_BTI)
384 error(0, 8, "must have 0xFF or 0xFD BTI");
385 }
386 ss << ".a" << addrSizeBits;
387 if (bitsPerElemReg == bitsPerElemMem) {
388 ss << ".d" << bitsPerElemReg;
389 } else {
390 ss << ".d" << bitsPerElemMem << "u" << bitsPerElemReg;
391 }
392 int chEnMask = 0;
393 if (opInfo.hasChMask()) {
394 ss << ".";
395 // in legacy HDC messages, this is a channel disable mask
396 auto chDisabled = getDescBits(8, 4);
397 chEnMask = ~chDisabled & 0xF;
398 if ((chDisabled & 0x1) == 0) {
399 ss << 'x';
400 }
401 if ((chDisabled & 0x2) == 0) {
402 ss << 'y';
403 }
404 if ((chDisabled & 0x4) == 0) {
405 ss << 'z';
406 }
407 if ((chDisabled & 0x8) == 0) {
408 ss << 'w';
409 }
410 } else {
411 if (elemsPerAddr > 1 || (extraAttrs & MessageInfo::Attr::TRANSPOSED)) {
412 ss << "x" << elemsPerAddr;
413 }
414 }
415
416 // if DC2, ExDesc[31:16] is immediate offset
417 if (sfid == SFID::DC2 && exDesc.isImm())
418 result.info.immediateOffset = exDesc.imm >> 16;
419 setScatterGatherOpX(ss.str(), msgDesc, op, addrType, SendDesc(surfaceId),
420 caching, caching, addrSizeBits, bitsPerElemReg,
421 bitsPerElemMem, elemsPerAddr, execSize, extraAttrs);
422 result.info.channelsEnabled = chEnMask;
423 }
424 // data size is same in mem and reg (typical case)
425 void setHdcMessage(const std::string& msgSym, const std::string& msgDesc, SendOp op,
426 int addrSize, int bitsPerElem, int elemsPerAddr,
427 int execSize, MessageInfo::Attr extraAttrs) {
428 setHdcMessageX(msgSym, msgDesc, op, addrSize, bitsPerElem, bitsPerElem,
429 elemsPerAddr, execSize, extraAttrs);
430 }
431
432 void setHdcOwBlock(const std::string &msgSym, const std::string &msgDesc, SendOp op,
433 int addrSize, MessageInfo::Attr extraAttrs) {
434 enum MDC_A64_DB_OW {
435 OW1L = 0x0,
436 OW1H = 0x1,
437 OW2 = 0x2,
438 OW4 = 0x3,
439 OW8 = 0x4,
440 };
441
442 auto owBits = getDescBits(8, 3);
443 if (owBits == OW1H) {
444 extraAttrs |= MessageInfo::Attr::EXPAND_HIGH;
445 }
446 extraAttrs |= MessageInfo::Attr::TRANSPOSED;
447
448 int elems = addrSize == 64 ? decodeMDC_A64_DB_OW(8) : decodeMDC_DB_OW(8);
449 std::stringstream ss;
450 ss << msgDesc << " x" << elems;
451 if (owBits == OW1H)
452 ss << "H";
453
454 setHdcMessageX(msgSym, ss.str(), op, addrSize, 128, 128, elems,
455 1, // SIMD
456 extraAttrs);
457 }
458
459 void setHdcHwBlock(const std::string& msgSym, const std::string& msgDesc, SendOp op,
460 int addrSize, int blockCountOffset, int blockCountLen,
461 MessageInfo::Attr extraAttrs) {
462 extraAttrs |= MessageInfo::Attr::TRANSPOSED;
463
464 int elems = addrSize == 64
465 ? decodeMDC_A64_DB_HW(blockCountOffset)
466 : decodeMDC_DB_HW(blockCountOffset, blockCountLen);
467 std::stringstream ss;
468 ss << msgDesc << " x" << elems;
469
470 setHdcMessageX(msgSym, ss.str(), op, addrSize, 256, 256, elems,
471 1, // SIMD
472 extraAttrs);
473 }
474
475 void setHdcUntypedSurfaceMessage(std::string msgDesc, bool isRead,
476 int addrSizeBits,
477 MessageInfo::Attr extraAttrs) {
478 std::string msgSym = isRead ? "untyped_load" : "untyped_store";
479 extraAttrs |= MessageInfo::Attr::HAS_CHMASK;
480 //
481 appendCMask(msgDesc);
482 //
483 setHdcMessage(msgSym, msgDesc,
484 isRead ? SendOp::LOAD_QUAD : SendOp::STORE_QUAD, addrSizeBits,
485 32, decodeMDC_CMASK(), decodeMDC_SM3(12), extraAttrs);
486 }
487
488 void appendCMask(std::string &msgDesc) {
489 auto cMaskBits = getDescBits(8, 4);
490 msgDesc += " with ";
491 for (int i = 0; i < 4; i++) {
492 if ((cMaskBits & (1 << i)) == 0) {
493 // NOTE: legacy untyped message channel masks are a
494 // disable bit
495 msgDesc += "xyzw"[i];
496 }
497 }
498 }
499
500 void setHdcTypedSurfaceMessage(bool isRead, const char *doc,
501 const char *docXe,
502 bool returnsStatus = false) {
503 std::string msgDesc = isRead ? "typed surface read" : "typed surface write";
504 addField("MessageType", 14, 5, getDescBits(14, 5), msgDesc);
505
506 std::string msgSym = isRead ? "typed_load" : "typed_store";
507 if (decodeMDC_SG3()) {
508 msgDesc += " (high slot group)";
509 msgSym += "_sgh";
510 }
511 if (returnsStatus) {
512 msgDesc += " returning status";
513 msgSym += "_wstatus";
514 }
515 //
516 appendCMask(msgDesc);
517 //
518 setHdcMessage(
519 msgSym, msgDesc, isRead ? SendOp::LOAD_QUAD : SendOp::STORE_QUAD,
520 32, // addrSize
521 32, // dataSize
522 decodeMDC_CMASK(),
523 DEFAULT_EXEC_SIZE / 2, // HDC typed is always SIMD8
524 MessageInfo::Attr::HAS_CHMASK | MessageInfo::Attr::HAS_UVRLOD);
525 setDoc(doc, docXe, nullptr);
526 }
527
528 void setHdcFloatAtomicMessage(const char *msgNameDesc, int addrSize,
529 int dataSize, const char *docNoRet,
530 const char *docWiRet, const char *docNoRetXe,
531 const char *docWiRetXe) {
532 addField("MessageType", 14, 5, getDescBits(14, 5), msgNameDesc);
533
534 std::string msgSym = "atomic_float?";
535 std::string msgDesc;
536 SendOp op = SendOp::INVALID;
537 auto atBits = getDescBits(8, 3);
538 switch (atBits) {
539 case 0x1:
540 op = SendOp::ATOMIC_FMAX;
541 msgSym = "atomic_fmax";
542 msgDesc = "max";
543 break;
544 case 0x2:
545 op = SendOp::ATOMIC_FMIN;
546 msgSym = "atomic_fmin";
547 msgDesc = "min";
548 break;
549 case 0x3:
550 op = SendOp::ATOMIC_FCAS;
551 msgSym = "atomic_fcas";
552 msgDesc = "fp-compare and swap ";
553 break;
554 // XeHP+
555 case 0x4:
556 op = SendOp::ATOMIC_FADD;
557 msgSym = "atomic_fadd";
558 msgDesc = "add";
559 break;
560 case 0x5:
561 op = SendOp::ATOMIC_FSUB;
562 msgSym = "atomic_fsub";
563 msgDesc = "subtract";
564 break;
565 // they just wedged in 64b as part of the 32b float atomic message
566 case 0x6:
567 op = SendOp::ATOMIC_FADD;
568 msgSym = "atomic_fadd";
569 msgDesc = "64b add";
570 dataSize = 64;
571 break;
572 case 0x7:
573 op = SendOp::ATOMIC_FSUB;
574 msgSym = "atomic_fsub";
575 msgDesc = "64b subtract";
576 dataSize = 64;
577 break;
578 default:
579 error(8, 3, " (unknown float op)"); // fallthrough
580 }
581 std::stringstream ssDesc;
582 ssDesc << msgNameDesc << " " << msgDesc << " (" << dataSize << "b)";
583 addField("AtomicOp:MDC_AOP", 8, 3, atBits, ssDesc.str());
584
585 MessageInfo::Attr extraAttrs = MessageInfo::Attr::NONE;
586 if (decodeDescBitField("ReturnDataControl", 13, "no return value",
587 "returns new value")) {
588 extraAttrs |= MessageInfo::Attr::ATOMIC_RETURNS;
589 msgSym += "_ret";
590 ssDesc << " with return";
591 setDoc(docWiRet, docWiRetXe, nullptr);
592 } else {
593 setDoc(docNoRet, docNoRetXe, nullptr);
594 }
595 if (op != SendOp::INVALID) {
596 setHdcMessage(msgSym, ssDesc.str(), op, addrSize, dataSize, 1,
597 addrSize == 64 ? decodeMDC_SM2S(12) : decodeMDC_SM2R(12),
598 extraAttrs);
599 }
600 } // setHdcFloatAtomicMessage
601
602 void setHdcIntAtomicMessage(const char *typedUntyped, // "typed" or "untyped"
603 const char *msgDesc0, int addrSize, int dataSize,
604 int simdSize, const char *docNoRet,
605 const char *docWiRet, const char *docNoRet12,
606 const char *docWiRet12) {
607 std::stringstream msgSym;
608 msgSym << typedUntyped << "_";
609 std::stringstream msgDesc;
610 msgDesc << typedUntyped << " " << msgDesc0;
611
612 addField("MessageType", 14, 5, getDescBits(14, 5), msgDesc.str());
613
614 std::string mOpName;
615 SendOp op = SendOp::INVALID;
616 auto aopBits = getDescBits(8, 4);
617 std::string opDesc;
618 switch (aopBits) {
619 // again with case 0x0 they wedged in a 64b CAS as part of the
620 // 32b message (note there's also a QW atomic message)
621 case 0x0:
622 op = SendOp::ATOMIC_ICAS;
623 mOpName = "atomic_icas";
624 opDesc = "64b integer compare and swap";
625 dataSize = 64;
626 break;
627 // The rest are 32b (or 16b)
628 case 0x1:
629 op = SendOp::ATOMIC_AND;
630 mOpName = "atomic_and";
631 opDesc = "logical AND";
632 break;
633 case 0x2:
634 op = SendOp::ATOMIC_OR;
635 mOpName = "atomic_or";
636 opDesc = "logical OR";
637 break;
638 case 0x3:
639 op = SendOp::ATOMIC_XOR;
640 mOpName = "atomic_xor";
641 opDesc = "logical XOR";
642 break;
643 case 0x4:
644 op = SendOp::ATOMIC_STORE;
645 mOpName = "atomic_store";
646 opDesc = "store";
647 break;
648 case 0x5:
649 op = SendOp::ATOMIC_IINC;
650 mOpName = "atomic_iinc";
651 opDesc = "integer increment";
652 break;
653 case 0x6:
654 op = SendOp::ATOMIC_IDEC;
655 mOpName = "atomic_idec";
656 opDesc = "integer decrement";
657 break;
658 case 0xF:
659 op = SendOp::ATOMIC_IPDEC;
660 mOpName = "atomic_iipdec";
661 opDesc = "integer pre-decrement (returns pre-decrement value)";
662 break;
663 case 0x7:
664 op = SendOp::ATOMIC_IADD;
665 mOpName = "atomic_iadd";
666 opDesc = "integer add";
667 break;
668 case 0x8:
669 op = SendOp::ATOMIC_ISUB;
670 mOpName = "atomic_isub";
671 opDesc = "integer subtract";
672 break;
673 case 0x9:
674 op = SendOp::ATOMIC_IRSUB;
675 mOpName = "atomic_irsub";
676 opDesc = "commuted integer subtract";
677 break;
678 case 0xA:
679 op = SendOp::ATOMIC_SMAX;
680 mOpName = "atomic_smax";
681 opDesc = "signed-integer max";
682 break;
683 case 0xB:
684 op = SendOp::ATOMIC_SMIN;
685 mOpName = "atomic_smin";
686 opDesc = "signed-integer min";
687 break;
688 case 0xC:
689 op = SendOp::ATOMIC_UMAX;
690 mOpName = "atomic_umax";
691 opDesc = "unsigned-integer max";
692 break;
693 case 0xD:
694 op = SendOp::ATOMIC_UMIN;
695 mOpName = "atomic_umin";
696 opDesc = "unsigned-integer min";
697 break;
698 case 0xE:
699 op = SendOp::ATOMIC_ICAS;
700 mOpName = "atomic_icas";
701 opDesc = "integer compare and swap";
702 break;
703 //
704 default: {
705 std::stringstream ss;
706 ss << "0x" << std::uppercase << std::hex << getDescBits(8, 4) << "?";
707 mOpName = ss.str();
708 opDesc = mOpName;
709 error(8, 4, " unknown int atomic op");
710 }
711 }
712 msgSym << mOpName;
713 //
714 addField("AtomicIntegerOp", 8, 4, aopBits, opDesc);
715 //
716 MessageInfo::Attr extraAttrs = MessageInfo::Attr::NONE;
717 if (decodeDescBitField("ReturnDataControl", 13, "no return value",
718 "returns new value")) {
719 extraAttrs |= MessageInfo::Attr::ATOMIC_RETURNS;
720 msgSym << "_ret";
721 setDoc(docWiRet, docWiRet12, nullptr);
722 } else {
723 setDoc(docNoRet, docNoRet12, nullptr);
724 }
725 if (op != SendOp::INVALID) {
726 msgDesc << " " << opDesc;
727 setHdcMessage(msgSym.str(), msgDesc.str(), op, addrSize, dataSize, 1,
728 simdSize, extraAttrs);
729 }
730 } // setHdcIntAtomicMessage
731
732 ///////////////////////////////////////////////////////////////////////////
733 void tryDecode() {
734 switch (sfid) {
735 case SFID::DCRO:
736 tryDecodeDCRO();
737 break;
738 case SFID::DC0:
739 tryDecodeDC0();
740 break;
741 case SFID::DC1:
742 tryDecodeDC1();
743 break;
744 //////////////////////////////////////////////////////////////
745 // DC2 shouldn't be used after SKL
746 case SFID::DC2:
747 error(0, 32, "unsupported DC2 op");
748 break;
749 default:
750 error(0, 0, "unsupported sfid");
751 return;
752 }
753 }
754
755 void tryDecodeDCRO();
756 void tryDecodeDC0();
757 void tryDecodeDC0BSRW(bool isRead);
758 void tryDecodeDC0AlignedBlock();
759 void tryDecodeDC0Memfence();
760 void tryDecodeDC0ScratchBlock();
761 void tryDecodeDC1();
762 }; // MessageDecoderHDC
763
764 // Enum of all DCRO ops
765 enum DCRO_MT {
766 MT_CC_OWB = 0x00,
767 MT_CC_OWAB = 0x01,
768 MT_CC_DWS = 0x03,
769 // these are XeHP only
770 MT_US_CCS_OP = 0x08, // cannot find BXML page
771 MT_A64_US_CCS_OP = 0x18,
772 MT_A64_US_UCW = 0x19,
773 // XeHPG+
774 MT_TS_UCW = 0x0D,
775 MT_TS_CCS_OP = 0x0C,
776 MT_US_UCW = 0x09,
777 MT_A64_CCS_PG_OP = 0x17,
778 };
779
780 void MessageDecoderHDC::tryDecodeDCRO() {
781 const int msgType = getDescBits(14, 5);
782 const char *desc = "???";
783
784 auto setMessageTypeDesc = [&](const char *d) {
785 desc = d;
786 addField("MessageType", 14, 5, msgType, d);
787 };
788 switch (msgType) {
789 case MT_CC_OWB: // constant oword block read
790 case MT_CC_OWAB: // constant unaligned oword block read
791 setMessageTypeDesc(msgType == MT_CC_OWB
792 ? "constant "
793 "oword block read"
794 : "constant aligned oword block read");
795 setHdcOwBlock(msgType == MT_CC_OWB ? "const_load_block"
796 : "aligned_const_load_block",
797 desc, SendOp::LOAD,
798 32, // 32b address
799 MessageInfo::Attr::NONE);
800 result.info.cachingL3 = decodeMDC_IAR();
801 decodeMDC_HR();
802 setDoc(msgType == MT_CC_OWB ? "7041" : "7043",
803 msgType == MT_CC_OWB ? "44767" : "44766", nullptr);
804 break;
805 case MT_CC_DWS:
806 setMessageTypeDesc("constant dword gathering read");
807 result.info.cachingL3 = decodeMDC_IAR();
808 setHdcMessage("const_load", "constant dword gathering read", SendOp::LOAD,
809 32, 32, decodeMDC_DWS_DS(10), decodeMDC_SM2(8),
810 MessageInfo::Attr::NONE);
811 decodeExpected(9, 1, "LegacySimdMode", 1);
812 decodeMDC_H();
813 setDoc("7084", "44765", nullptr);
814 break;
815 // case MT_US_CCS_OP: // TODO: find BXML page
816 case MT_A64_US_CCS_OP: {
817 setMessageTypeDesc("A64 untyped surface CCS operation");
818 decodeMDC_HF();
819 auto ccsOp = decodeDescField("SectorUpdateOpcode", 8, 4,
820 [](std::stringstream &ss, uint32_t val) {
821 switch (val) {
822 case 0x1:
823 ss << "Slow Clear";
824 break;
825 case 0x3:
826 ss << "Slow Uncompress";
827 break;
828 default:
829 ss << "?";
830 }
831 });
832 setHdcMessage("a64_untyped_ccs_op", desc,
833 ccsOp == 0x1 ? SendOp::CCS_SC : SendOp::CCS_SU,
834 64, // addr size
835 0, // data
836 1, // vec elems
837 decodeMDC_SM3(12), MessageInfo::Attr::NONE);
838 setDoc("44763");
839 ensurePlatformGE(Platform::XE_HP);
840 break;
841 }
842 case MT_A64_US_UCW:
843 setMessageTypeDesc("A64 untyped surface uncompressed write");
844 setHdcMessage("a64_untyped_uncompressed_store_quad", desc,
845 SendOp::STORE_UNCOMPRESSED_QUAD,
846 64, // addr size
847 32, // data size
848 decodeMDC_CMASK(), decodeMDC_SM3(12),
849 MessageInfo::Attr::NONE);
850 decodeMDC_HF();
851 setDoc("44764");
852 ensurePlatformGE(Platform::XE_HP);
853 break;
854 case MT_A64_CCS_PG_OP: {
855 setMessageTypeDesc("A64 page CCS update operation");
856 auto ccsOp = decodeDescField("PageUpdateOpcode", 8, 2,
857 [](std::stringstream &ss, uint32_t val) {
858 switch (val) {
859 case 0:
860 ss << "Fast Clear";
861 break;
862 case 2:
863 ss << "Fast Uncompress";
864 break;
865 default:
866 ss << "?";
867 }
868 });
869 int surfId = decodeBTI(64);
870 setSpecialOpX("a64_ccs_update", desc,
871 ccsOp == 0x0 ? SendOp::CCS_PC : SendOp::CCS_PU, AddrType::BTI,
872 SendDesc(surfId), 1, 0, MessageInfo::Attr::NONE);
873 decodeMDC_HR();
874 setDoc("44762");
875 ensurePlatformGE(Platform::XE_HPG);
876 break;
877 }
878 case MT_TS_UCW:
879 setMessageTypeDesc("typed surface uncompressed write");
880 setHdcMessage("typed_uncompressed_store_quad", desc,
881 SendOp::STORE_UNCOMPRESSED_QUAD,
882 32, // addr size
883 32, // data size
884 decodeMDC_CMASK(), decodeMDC_SG3(), MessageInfo::Attr::NONE);
885 decodeMDC_H();
886 setDoc("44773");
887 ensurePlatformGE(Platform::XE_HPG);
888 break;
889 case MT_TS_CCS_OP: {
890 setMessageTypeDesc("typed surface CCS update message");
891 auto ccsOp = decodeDescField("SectorUpdateOpcode", 8, 4,
892 [](std::stringstream &ss, uint32_t val) {
893 switch (val) {
894 case 1:
895 ss << "Slow Clear";
896 break;
897 case 3:
898 ss << "Slow Uncompress";
899 break;
900 default:
901 ss << "?";
902 }
903 });
904 setHdcMessage("a64_typed_ccs_op", desc,
905 ccsOp == 0x1 ? SendOp::CCS_SC : SendOp::CCS_SU,
906 32, // addr size
907 32, // data
908 1, // vec elems
909 decodeMDC_SG3(), MessageInfo::Attr::NONE);
910 decodeMDC_H();
911 setDoc("44763");
912 break;
913 }
914 case MT_US_UCW:
915 setMessageTypeDesc("untyped surface uncompressed write");
916 setHdcMessage("untyped_uncompressed_store_quad", desc,
917 SendOp::STORE_UNCOMPRESSED_QUAD,
918 32, // addr size
919 32, // data size
920 decodeMDC_CMASK(), decodeMDC_SM3(12),
921 MessageInfo::Attr::NONE);
922 decodeMDC_H();
923 setDoc("44775");
924 ensurePlatformGE(Platform::XE_HPG);
925 break;
926 default:
927 setMessageTypeDesc("unknown DCRO message");
928 decodeMDC_H();
929 (void)decodeBTI(32);
930 error(14, 5, "unsupported DCRO op");
931 return;
932 }
933 }
934
935 void MessageDecoderHDC::tryDecodeDC0() {
936 const int msgType = getDescBits(14, 5);
937 const char *desc = "???";
938 auto addMessageType = [&](const char *d) {
939 addField("MessageType", 14, 5, msgType, d);
940 desc = d;
941 };
942 switch (msgType) {
943 case MSD0R_OWB: // oword block read (unaligned)
944 addMessageType("oword block read");
945 setHdcOwBlock("load_block", desc, SendOp::LOAD,
946 32, // all 32b addresses
947 MessageInfo::Attr::NONE);
948 setDoc("7028", "44722", nullptr);
949 decodeMDC_HR();
950 break;
951 case MSD0R_OWAB: // aligned hword/oword block read
952 tryDecodeDC0AlignedBlock();
953 break;
954 case MSD0W_OWB: // hword/oword block write
955 addMessageType("oword block write");
956 setHdcOwBlock("store_block", desc, SendOp::STORE,
957 32, // all 32b addresses
958 MessageInfo::Attr::NONE);
959 setDoc("7032", "44730", nullptr);
960 decodeMDC_HR();
961 break;
962 case MSD0W_HWAB: // hword aligned block write
963 addMessageType("hword aligned block write");
964 setHdcOwBlock("aligned_store_block", desc, SendOp::STORE,
965 32, // all 32b addresses
966 MessageInfo::Attr::NONE);
967 setDoc("20862", "44727", nullptr);
968 decodeMDC_HR();
969 break;
970 //
971 case MSD0R_OWDB: // oword dual block read
972 addMessageType("oword dual block read");
973 setDoc("7029", nullptr, nullptr);
974 result.info.description = desc;
975 decodeMDC_HR();
976 error(14, 5, "oword dual block read decode not supported");
977 return;
978 case MSD0W_OWDB: // oword dual block write
979 addMessageType("oword dual block write");
980 result.info.description = desc;
981 setDoc("7033", nullptr, nullptr);
982 decodeMDC_HR();
983 error(14, 5, "oword dual block write decode not supported");
984 return;
985 //
986 case MSD0R_BS: // byte gathered read
987 case MSD0W_BS: // byte scattered write
988 tryDecodeDC0BSRW(msgType == MSD0R_BS);
989 break;
990 //
991 case MSD0R_DWS: // dword gathered read
992 case MSD0W_DWS: // dword scattered write
993 {
994 bool isRead = msgType == MSD0R_DWS;
995 const char *msgName =
996 isRead ? "dword gathering read" : "dword scattering write";
997 addMessageType(msgName);
998 //
999 int elemsPerAddr = decodeMDC_DWS_DS(10);
1000 std::stringstream ss;
1001 ss << msgName;
1002 if (elemsPerAddr != 1)
1003 ss << " x" << elemsPerAddr;
1004 //
1005 setHdcMessage(isRead ? "load" : "store", ss.str(),
1006 isRead ? SendOp::LOAD : SendOp::STORE, 32, 32, elemsPerAddr,
1007 decodeMDC_SM2(8), MessageInfo::Attr::NONE);
1008 result.info.cachingL3 = decodeMDC_IAR();
1009 setDoc(isRead ? "7067" : "7069", isRead ? "44718" : "44726", nullptr);
1010 decodeExpected(9, 1, "LegacySimdMode", 1);
1011 decodeMDC_H();
1012 break;
1013 }
1014 case MSD0R_QWS: // qword gather
1015 case MSD0W_QWS: // qword scatter
1016 {
1017 auto isRead = msgType == MSD0R_QWS;
1018 const char *msgName =
1019 isRead ? "qword gathering read" : "qword scattering write";
1020 addMessageType(msgName);
1021 //
1022 setHdcMessage(isRead ? "load" : "store", msgName,
1023 isRead ? SendOp::LOAD : SendOp::STORE,
1024 32, // addrs
1025 64, // data
1026 decodeMDC_DWS_DS(10), decodeMDC_SM2(8),
1027 MessageInfo::Attr::NONE);
1028 setDoc(isRead ? "33652" : "33653", isRead ? "44723" : "44731", nullptr);
1029 decodeExpected(9, 1, "LegacySimdMode", 1);
1030 decodeMDC_H();
1031 break;
1032 }
1033 case MSD_MEMFENCE:
1034 tryDecodeDC0Memfence();
1035 break;
1036 default:
1037 if (getDescBit(18) == 1) {
1038 tryDecodeDC0ScratchBlock();
1039 } else {
1040 addField("MessageType", 14, 5, msgType, "???");
1041 error(14, 5, "unsupported dc0 op");
1042 return;
1043 }
1044 } // end switch legacy DC0
1045 }
1046
1047 void MessageDecoderHDC::tryDecodeDC0BSRW(bool isRead) {
1048 const uint32_t msgType = getDescBits(14, 5);
1049 const char *msgName =
1050 isRead ? "byte gathering read" : "byte scattering write";
1051
1052 addField("MessageType", 14, 5, msgType, msgName);
1053
1054 std::stringstream descs;
1055 descs << msgName;
1056 int memBytes = decodeMDC_DS(10);
1057 if (memBytes == 1)
1058 descs << " 8b";
1059 else if (memBytes == 2)
1060 descs << " 16b";
1061 else if (memBytes == 4)
1062 descs << " 32b";
1063
1064 //
1065 // "byte" scattered always consumes a DW of GRF per channel,
1066 // but DWS_DS controls how many bytes are loaded per address
1067 // that might be 1, 2, 4 all packed into one DW.
1068 // So think of:
1069 // DWS_DS == 0 (byte) as u8 aligned to u32 (upper bits undefined)
1070 // DWS_DS == 1 (word) as u16 aligned to u32 (upper bits undefined)
1071 // DWS_DS == 2 (dword) as u32
1072 setHdcMessageX(isRead ? "load" : "store", descs.str(),
1073 isRead ? SendOp::LOAD : SendOp::STORE,
1074 32, // 32b addrs
1075 32, // each channel occupies a DW in the reg file
1076 8 * memBytes, // in memory it can be 1, 2, or 4 bytes
1077 1, // vector size always 1
1078 decodeMDC_SM2(8), MessageInfo::Attr::NONE);
1079 result.info.cachingL3 = decodeMDC_IAR();
1080 setDoc(isRead ? "7066" : "7068", isRead ? "44717" : "44725", nullptr);
1081 decodeMDC_H();
1082 }
1083
1084 void MessageDecoderHDC::tryDecodeDC0AlignedBlock() {
1085 const int msgType = getDescBits(14, 5);
1086 const char *descs = "aligned block read";
1087 const char *doc = "7030";
1088 bool isHw = false;
1089 if (platform() >= Platform::XE_HPG) {
1090 isHw = getDescBit(13);
1091 addField("BlockMessageSubtype", 13, 1, isHw, isHw ? "HWord" : "OWord");
1092 if (isHw) {
1093 descs = "aligned block read";
1094 doc = "44719";
1095 } else {
1096 doc = "44721";
1097 }
1098 } // else: [13] is reserved
1099 addField("MessageType", 14, 5, msgType, descs);
1100 if (isHw) {
1101 setHdcHwBlock("aligned_load_block256", "hword aligned block read",
1102 SendOp::LOAD,
1103 32, // all 32b addresses
1104 8, 3, // [10:8]
1105 MessageInfo::Attr::NONE);
1106 } else {
1107 setHdcOwBlock("aligned_load_block128", "oword aligned block read",
1108 SendOp::LOAD,
1109 32, // all 32b addresses
1110 MessageInfo::Attr::NONE);
1111 }
1112 setDoc(doc);
1113 decodeMDC_HR();
1114 }
1115
1116 void MessageDecoderHDC::tryDecodeDC0Memfence() {
1117 const int msgType = getDescBits(14, 5);
1118 // memory fence
1119 addField("MessageType", 14, 5, msgType, "fence");
1120 //
1121 std::stringstream sym, descs;
1122 uint32_t surfId = getDescBits(0, 8);
1123 MessageInfo::Attr extraAttrs = MessageInfo::Attr::NONE;
1124 if (decodeDescBitField("Commit", 13, "off (return immediately)",
1125 "on (wait for fence commit)")) {
1126 sym << "sync_";
1127 descs << "synchronized ";
1128 }
1129 if (surfId == SLM_BTI) {
1130 (void)decodeBTI(32); // add the field
1131 sym << "slm_fence";
1132 descs << "SLM fence";
1133 extraAttrs |= MessageInfo::Attr::SLM;
1134 } else if (surfId == 0) {
1135 sym << "global_fence";
1136 descs << "global fence";
1137 if (getDescBits(9, 4) && getDescBit(8)) {
1138 error(8, 1, "L3 implies L1 flush");
1139 }
1140 descs << " flushing";
1141 if (decodeDescBitField("L1Flush", 8, "Flush L3", "FLush L1") != 0) {
1142 sym << ".l1";
1143 descs << " L1";
1144 }
1145 if (decodeDescField("L3 Flush Targets", 9, 4)) {
1146 if (getDescBits(9, 4) == 0xF) {
1147 descs << " all L3 data";
1148 sym << ".dcti"; // data, const?, text, inst
1149 } else {
1150 int n = 0;
1151 descs << " L3";
1152 sym << ".";
1153 if (getDescBit(12)) {
1154 sym << "d";
1155 descs << " r/w data";
1156 }
1157 if (getDescBit(11)) {
1158 if (n++ > 0)
1159 descs << ",";
1160 sym << "c";
1161 descs << " constant data";
1162 }
1163 if (getDescBit(10)) {
1164 if (n++ > 0)
1165 descs << ",";
1166 sym << "t";
1167 descs << " texture data";
1168 }
1169 if (getDescBit(9)) {
1170 if (n++ > 0)
1171 descs << ",";
1172 sym << "i";
1173 descs << " instruction data";
1174 }
1175 }
1176 }
1177 } else {
1178 error(0, 8, "invalid BTI for fence (must be 0x0 or 0xFE)");
1179 }
1180 setSpecialOpX(sym.str(), descs.str(), SendOp::FENCE, AddrType::FLAT,
1181 SendDesc(surfId), 1, 1, extraAttrs);
1182 setDoc("7049", "44768", nullptr);
1183 decodeMDC_HR();
1184 }
1185
1186 void MessageDecoderHDC::tryDecodeDC0ScratchBlock() {
1187 const int msgType = getDescBits(14, 5);
1188 // scratch read
1189 // scratch write
1190 //
1191 // scratch block is a muddy situation
1192 // they used to have ChannelMode at 16, so we want to ignore that
1193 // and only use bits
1194 bool isRead = getDescBit(17) == 0;
1195 const char *msgName =
1196 isRead ? "hword scratch block read" : "hword scratch block write";
1197 addField("MessageType", 14, 5, msgType, msgName);
1198 //
1199 setHdcHwBlock(isRead ? "load_block" : "store_block", msgName,
1200 isRead ? SendOp::LOAD : SendOp::STORE,
1201 32, // r0.5
1202 12, 2, // [13:12] num HWs
1203 MessageInfo::Attr::SCRATCH);
1204 // scratch offset [11:0] (reg aligned)
1205 uint32_t hwOff =
1206 32 * decodeDescField("HWordOffset", 0, 12,
1207 [&](std::stringstream &ss, uint32_t val) {
1208 ss << val << " HWords from scratch base";
1209 });
1210 result.info.immediateOffset = hwOff;
1211 if (platform() < Platform::GEN10) {
1212 decodeDescBitField("ChannelMode", 16, "OWord", "DWord");
1213 }
1214 setDoc(isRead ? "7027" : "7031", isRead ? "44724" : "44732", nullptr);
1215
1216 decodeMDC_HR();
1217 }
1218
1219 void MessageDecoderHDC::tryDecodeDC1() {
1220 const int msgType = getDescBits(14, 5);
1221 switch (msgType) {
1222 case MSD1R_US: // untyped surface read
1223 case MSD1W_US: // untyped surface write
1224 {
1225 const char *msgName =
1226 msgType == MSD1R_US ? "untyped surface read" : "untyped surface write";
1227 addField("MessageType", 14, 5, msgType, msgName);
1228 //
1229 setHdcUntypedSurfaceMessage(msgName, msgType == MSD1R_US, 32,
1230 MessageInfo::Attr::NONE);
1231 setDoc(msgType == MSD1R_US ? "7088" : "7091",
1232 msgType == MSD1R_US ? "44747" : "44757", nullptr);
1233 decodeMDC_H();
1234 break;
1235 }
1236 case MSD1R_A64_US: // a64 untype surface read
1237 case MSD1W_A64_US: // a64 untype surface write
1238 {
1239 const char *msgName = msgType == MSD1R_A64_US ? "a64 untyped surface read"
1240 : "a64 untyped surface write";
1241 addField("MessageType", 14, 5, msgType, msgName);
1242 //
1243 setHdcUntypedSurfaceMessage(msgName, msgType == MSD1R_A64_US,
1244 64, // 8B addrs
1245 MessageInfo::Attr::NONE);
1246 setDoc(msgType == MSD1R_A64_US ? "7086" : "7089",
1247 msgType == MSD1R_A64_US ? "44743" : "44754", nullptr);
1248 decodeMDC_HF();
1249 break;
1250 }
1251 case MSD1R_A64_BS: // a64 gathering read (byte/dw/qw)
1252 case MSD1W_A64_BS: // a64 scattered write (byte/dw/qw)
1253 {
1254 // 0 is byte-scattered, the others (DW/QW) are true SIMT
1255 int subType = getDescBits(8, 2);
1256 bool isRead = msgType == MSD1R_A64_BS;
1257 const auto BYTE_SUBTYPE = 0x0, BSRWSR_SUBTYPE = 0x3;
1258 if (subType == BYTE_SUBTYPE || subType == BSRWSR_SUBTYPE) {
1259 // c.f. handling above with non-A64 version of BSR
1260 const char *msgName = msgType == MSD1R_A64_BS
1261 ? "a64 byte gathering read"
1262 : "a64 byte scattering write";
1263 addField("MessageType", 14, 5, msgType, msgName);
1264 //
1265 if (subType == BYTE_SUBTYPE) {
1266 addField("SubType", 8, 2, subType, "Byte");
1267 setDoc(msgType == MSD1R_A64_BS ? "7070" : "7073",
1268 msgType == MSD1R_A64_BS ? "44737" : "44748", nullptr);
1269 } else { // subType == 0x3
1270 addField("SubType", 8, 2, subType, "Byte with Status Return");
1271 setDoc(msgType == MSD1R_A64_BS ? "19316" : nullptr);
1272 if (msgType == MSD1W_A64_BS)
1273 error(14, 5, "a64 byte scattering with status return message");
1274 }
1275 //
1276 std::stringstream descs;
1277 descs << msgName;
1278 int bExt = MDC_A64_DS(10);
1279 if (bExt == 1)
1280 descs << " 8b";
1281 else if (bExt == 2)
1282 descs << " 16b";
1283 else if (bExt == 4)
1284 descs << " 32b";
1285 //
1286 setHdcMessageX(isRead ? "load" : "store", descs.str(),
1287 isRead ? SendOp::LOAD : SendOp::STORE,
1288 64, // A64
1289 32, // widens to DW (similar to non-A64 version)
1290 8 * bExt, // bits from memory
1291 1, //
1292 decodeMDC_SM2(12), MessageInfo::Attr::NONE);
1293 } else {
1294 const auto DW_SUBTYPE = 0x1;
1295 // const auto QW_SUBTYPE = 0x2;
1296 bool isDword = subType == DW_SUBTYPE; // else QW
1297 // unlike non-A64 version, this variant supports DW and QW
1298 // in the same message type, the MDC_A64_DS is treated as a
1299 // vector length
1300 const char *msgTypeName = msgType == MSD1R_A64_BS
1301 ? "a64 gathering read"
1302 : "a64 scattering write";
1303 addField("MessageType", 14, 5, msgType, msgTypeName);
1304 //
1305 const char *msgName = isDword ? (isRead ? "a64 dword gathering read"
1306 : "a64 dword scattering write")
1307 : (isRead ? "a64 qword gathering read"
1308 : "a64 qword scattering write");
1309 //
1310 int elemsPerAddr = decodeMDC_DWS_DS(10);
1311 std::stringstream ss;
1312 if (elemsPerAddr != 1)
1313 ss << msgName << " x" << elemsPerAddr;
1314 //
1315 addField("SubType", 8, 2, subType, subType == 1 ? "DWord" : "QWord");
1316 //
1317 setHdcMessage(isRead ? "load" : "store", msgName,
1318 isRead ? SendOp::LOAD : SendOp::STORE, 64,
1319 isDword ? 32 : 64,
1320 elemsPerAddr, // true vector
1321 decodeMDC_SM2(12), MessageInfo::Attr::NONE);
1322 if (isDword) {
1323 setDoc(isRead ? "7071" : "7074", isRead ? "44738" : "44749", nullptr);
1324 } else {
1325 setDoc(isRead ? "7072" : "7075");
1326 }
1327 }
1328 result.info.cachingL3 = decodeMDC_IAR();
1329 decodeMDC_HF();
1330 break;
1331 }
1332 case MSD1R_A64_HWB: // a64 [un]aligned (hword|oword) block read
1333 case MSD1W_A64_HWB: // a64 [un]aligned (hword|oword) block write
1334 {
1335 bool isRead = msgType == MSD1R_A64_HWB;
1336
1337 addField("MessageType", 14, 5, msgType,
1338 isRead ? "a64 block read" : "a64 block write");
1339 bool isHword = false;
1340 bool isUnaligned = false;
1341 auto subType = decodeDescField(
1342 "SubType", 11, 2, [&](std::stringstream &ss, uint32_t val) {
1343 switch (val) {
1344 case 0x0:
1345 isUnaligned = true;
1346 ss << "oword unaligned";
1347 break;
1348 case 0x1:
1349 ss << "oword aligned";
1350 break;
1351 case 0x3:
1352 isHword = true;
1353 isUnaligned = true;
1354 ss << "hword unaligned";
1355 break;
1356 //
1357 default:
1358 ss << "dual block";
1359 isUnaligned = true;
1360 error(11, 2, "a64 dual block read/write unsupported");
1361 break;
1362 }
1363 });
1364
1365 if (subType == 2) {
1366 setDoc(isRead ? "7036" : "7040");
1367 result.info.description = "a64 dual block ";
1368 result.info.description += (isRead ? " read" : " write");
1369 result.info.symbol = isRead ? "MSD1R_A64_OWDB" : "MSD1W_A64_OWDB";
1370 result.info.addrSizeBits = 64;
1371 decodeMDC_HR();
1372 break; // dual block (error)
1373 } else if (isHword && isUnaligned) {
1374 setDoc(isRead ? "7034" : "7038", isRead ? "44739" : "44750", nullptr);
1375 } else if (isHword && !isUnaligned) {
1376 bool supported = platform() >= Platform::XE_HPG;
1377 setDoc(isRead ? "20861" : "20862");
1378 if (!supported)
1379 error(11, 2, "HWord aligned unsupported on this platform");
1380 } else if (!isHword && isUnaligned) {
1381 setDoc(isRead ? "7037" : "33440", isRead ? "44740" : "44751",
1382 nullptr); // MSD1R_A64_OWAB|MSD1W_A64_OWAB
1383 } else if (!isHword && !isUnaligned) {
1384 setDoc("7039", isRead ? "44741" : "44752",
1385 nullptr); // MSD1R_A64_OWB|MSD1W_A64_OWB
1386 }
1387 //
1388 std::string msgSym = isRead ? "load_block" : "store_block";
1389 std::string msgDesc = "a64";
1390 if (isUnaligned) {
1391 msgDesc += " unaligned";
1392 } else {
1393 msgDesc += " aligned";
1394 msgSym += "_aligned";
1395 }
1396 if (isHword) {
1397 msgDesc += " hword";
1398 } else {
1399 msgDesc += " oword";
1400 }
1401 msgDesc += " block";
1402 if (msgType == 0x14) {
1403 msgDesc += " read";
1404 } else {
1405 msgDesc += " write";
1406 }
1407 if (isHword) {
1408 setHdcHwBlock(msgSym, msgDesc, isRead ? SendOp::LOAD : SendOp::STORE,
1409 64, // 64b addr
1410 8, 3, // offset of HWs
1411 MessageInfo::Attr::NONE);
1412 } else {
1413 setHdcOwBlock(msgSym, msgDesc, isRead ? SendOp::LOAD : SendOp::STORE,
1414 64, // 64b addr
1415 MessageInfo::Attr::NONE);
1416 }
1417 result.info.cachingL3 = decodeMDC_IAR();
1418 decodeMDC_HR(); // all block require a header
1419 break;
1420 }
1421 case MSD1W_A64_DWAF: // a64 untyped fp32 atomic
1422 setHdcFloatAtomicMessage("a64 float atomic", 64, 32, "7126", "7118",
1423 "44682", "44649");
1424 decodeMDC_HF();
1425 break;
1426
1427 case MSD1W_DWAF: // a32 untyped fp32 atomic
1428 setHdcFloatAtomicMessage("float atomic", 32, 32, "7130", "7122", "44697",
1429 "44664");
1430 decodeMDC_H();
1431 break;
1432 case MSD1W_A64_AI: // a64 untyped atomic int{32,64}
1433 {
1434 // the encoding repurposes the SIMD size as the data size and the
1435 // message and thus the SIMD size is always fixed
1436 int simd = platform() >= Platform::XE_HPC ? 16 : 8;
1437 auto is64b = decodeDescBitField("DataWidth", 12, "32b", "64b");
1438 const char *msgName = is64b ? "a64 atomic int64" : "a64 atomic int32";
1439 const char *docNoRet = is64b ? "7161" : "7155";
1440 const char *docNoRetXe = is64b ? "44688" : "44685";
1441 const char *docWiRet = is64b ? "7143" : "7137";
1442 const char *docWiRetXe = is64b ? "44655" : "44652";
1443 //
1444 setHdcIntAtomicMessage("untyped", msgName, 64, is64b ? 64 : 32, simd,
1445 docNoRet, docWiRet, docNoRetXe, docWiRetXe);
1446 decodeMDC_HF();
1447 break;
1448 }
1449 case MSD1W_DWAI: // atomic int32
1450 {
1451 const char *msgName = "untyped atomic int32";
1452 addField("MessageType", 14, 5, msgType, msgName);
1453 //
1454 setHdcIntAtomicMessage("untyped", "atomic int32", 32, 32,
1455 decodeMDC_SM2R(12), "7167", "7149", "44700",
1456 "44667");
1457 decodeMDC_H();
1458 break;
1459 }
1460 case MSD1R_MB: // media block read
1461 case MSD1W_MB: // media block write
1462 {
1463 std::stringstream sym, descs;
1464 sym << "mb";
1465 descs << "media block ";
1466 int bytesTransmitted = 0;
1467 if (msgType == MSD1R_MB) {
1468 descs << "read";
1469 sym << "rd";
1470 bytesTransmitted = 2 * DEFAULT_EXEC_SIZE * getDescBits(20, 5);
1471 } else {
1472 descs << "write";
1473 sym << "wr";
1474 int mlen = getDescBits(25, 4);
1475 if (mlen == 0) {
1476 error(25, 4, "mlen == 0 on write");
1477 } else {
1478 bytesTransmitted = 2 * DEFAULT_EXEC_SIZE * (mlen - 1);
1479 }
1480 }
1481 int vlso = getDescBits(8, 3); // [10:8] is vert. line stride overr.
1482 if (vlso) {
1483 descs << " with vertical line stride ";
1484 int n = 0;
1485 if (vlso & 0x2) {
1486 descs << "override";
1487 n++;
1488 }
1489 if (vlso & 0x1) {
1490 if ((vlso & 0x2) == 0)
1491 descs << " and ";
1492 else if (n > 0)
1493 descs << ",";
1494 descs << "skip";
1495 n++;
1496 }
1497 if (vlso & 0x2) {
1498 if (n >= 2)
1499 descs << ", and ";
1500 else if (n > 0)
1501 descs << " and ";
1502 descs << "offset";
1503 n++;
1504 if ((vlso & 0) == 0) {
1505 warning(8, 3, "stride offset meaningless when override not set");
1506 }
1507 }
1508 }
1509 setHdcMessage(sym.str(), descs.str(),
1510 msgType == 0x4 ? SendOp::LOAD : SendOp::STORE, 32, 8,
1511 bytesTransmitted, 1, MessageInfo::Attr::TRANSPOSED);
1512 setDoc(msgType == MSD1R_MB ? "7046" : "7048",
1513 msgType == MSD1R_MB ? "44744" : "44755", nullptr);
1514 decodeMDC_HR();
1515 break;
1516 }
1517 case MSD1R_TS: // typed surface read
1518 setHdcTypedSurfaceMessage(true, "7087", "44745");
1519 decodeMDC_H();
1520 break;
1521 case MSD1W_TS: // typed surface write
1522 setHdcTypedSurfaceMessage(false, "7090", "44756");
1523 decodeMDC_H();
1524 break;
1525 case MSD1RS_TS: // typed surface read with status
1526 setHdcTypedSurfaceMessage(true, "19315", "44735", true);
1527 decodeMDC_H();
1528 break;
1529 case MSD1A_DWAC:
1530 setHdcIntAtomicMessage("typed", "atomic 32-bit counter",
1531 32, // addrSize
1532 32, // dataSize
1533 decodeMDC_SM2R(12), "7109", "7099", "44696",
1534 "44663");
1535 decodeMDC_HR();
1536 result.info.attributeSet |= MessageInfo::Attr::HAS_UVRLOD;
1537 break;
1538 case MSD1A_DWTAI: {
1539 bool sgh = decodeMDC_SG2();
1540 setHdcIntAtomicMessage(sgh ? "typed_sgh" : "typed",
1541 sgh ? "atomic 32-bit integer (slot group high)"
1542 : "atomic 32-bit integer",
1543 32, // addrSize
1544 32, // dataSize
1545 DEFAULT_EXEC_SIZE / 2, "7113", "7103", "44703",
1546 "44670");
1547 decodeMDC_H();
1548 break;
1549 }
1550 case MSD1A_WAC:
1551 setHdcIntAtomicMessage("typed", "atomic 16-bit counter",
1552 32, // addrSize
1553 16, // dataSize
1554 decodeMDC_SM2R(12), "21412", "21411", "44706",
1555 "44673");
1556 decodeMDC_HR();
1557 result.info.attributeSet |= MessageInfo::Attr::HAS_UVRLOD;
1558 break;
1559 case MSD1A_WTAI: {
1560 bool sgh = decodeMDC_SG2();
1561 setHdcIntAtomicMessage(sgh ? "typed_sgh" : "typed",
1562 sgh ? "atomic 16-bit integer (slot group high)"
1563 : "atomic 16-bit integer",
1564 32, // addrSize
1565 16, // dataSize
1566 DEFAULT_EXEC_SIZE / 2, "21416", "21415", "44703",
1567 "44670");
1568 decodeMDC_H();
1569 result.info.attributeSet |= MessageInfo::Attr::HAS_UVRLOD;
1570 break;
1571 }
1572 case MSD1A_A64_WAF: // a64 fp16 atomic
1573 case MSD1A_WAF: // fp16 atomic
1574 {
1575 if (platform() <= Platform::GEN11) {
1576 // these used to be SIMD4x2
1577 error(14, 5, "SIMD4x2 atomic float decode unsupported");
1578 return;
1579 }
1580 bool isA64 = msgType == MSD1A_A64_WAF;
1581 setHdcFloatAtomicMessage(
1582 isA64 ? "a64 untyped half-float atomic" : "untyped half-float atomic",
1583 isA64 ? 64 : 32, 16, isA64 ? "21405" : "21407",
1584 isA64 ? "21404" : "21406", isA64 ? "44690" : "54102",
1585 isA64 ? "44657" : "54101");
1586 if (isA64)
1587 decodeMDC_HF();
1588 else
1589 decodeMDC_H();
1590 break;
1591 }
1592 case MSD1A_A64_WAI: // a64 int16 atomic
1593 case MSD1A_WAI: // int16 atomic
1594 {
1595 if (platform() <= Platform::GEN11) {
1596 // these used to be SIMD4x2
1597 error(14, 5, "SIMD4x2 atomic int decode unsupported");
1598 return;
1599 }
1600 bool isA64 = msgType == MSD1A_A64_WAI;
1601 setHdcIntAtomicMessage(
1602 "untyped", isA64 ? "a64 atomic int16" : "atomic int16",
1603 msgType == MSD1A_A64_WAI ? 64 : 32, 16, decodeMDC_SM2R(12),
1604 isA64 ? "21390" : "21396", isA64 ? "21389" : "21397",
1605 isA64 ? "44693" : "44710", isA64 ? "44660" : "44677");
1606 if (isA64)
1607 decodeMDC_HF();
1608 else
1609 decodeMDC_H();
1610 break;
1611 }
1612 default:
1613 error(14, 5, "unsupported DC1 op");
1614 return;
1615 } // DC1 switch
1616 }
1617
1618 void iga::decodeDescriptorsHDC(Platform platform, SFID sfid, ExecSize execSize,
1619 uint32_t exImmOffDesc, SendDesc exDesc,
1620 SendDesc desc, DecodeResult &result) {
1621 MessageDecoderHDC mdo(platform, sfid, execSize, exImmOffDesc, exDesc, desc,
1622 result);
1623 mdo.tryDecode();
1624 }