| 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 "SendDescriptorDecoding.hpp" |
| 10 |
#include "../IR/Messages.hpp" |
| 11 |
#include "../bits.hpp" |
| 12 |
#include "../strings.hpp" |
| 13 |
|
| 14 |
#include <algorithm> |
| 15 |
|
| 16 |
using namespace iga; |
| 17 |
|
| 18 |
static const char *getSFIDString(Platform p, uint32_t sfid) { |
| 19 |
static const char *HSWBDW_SFIDS[]{ |
| 20 |
"null", // 0000b the null function |
| 21 |
nullptr, // 0001b |
| 22 |
"sampler", // 0010b new sampler |
| 23 |
"gateway", // 0011b gateway |
| 24 |
|
| 25 |
"sampler", // 0100b (old sampler encoding) |
| 26 |
"hdc.rc", // 0101b render cache |
| 27 |
"hdc.urb", // 0110b unified return buffer |
| 28 |
"spawner", // 0111b thread spawner |
| 29 |
|
| 30 |
"vme", // 1000b video motion estimation |
| 31 |
"hdc.ccdp", // 1001b constant cache |
| 32 |
"hdc.dc0", // 1010b |
| 33 |
"pi", // 1011b pixel interpolator |
| 34 |
|
| 35 |
"hdc.dc1", // 1100b data-cache 1 |
| 36 |
"cre", // 1101b check and refinement |
| 37 |
nullptr, nullptr, |
| 38 |
}; |
| 39 |
static const char *SKL_SFIDS[]{ |
| 40 |
"null", // 0000b the null function |
| 41 |
nullptr, // 0001b |
| 42 |
"sampler", // 0010b new sampler |
| 43 |
"gateway", // 0011b gateway |
| 44 |
|
| 45 |
"hdc.dc2", // 0100b data cache 2 (old sampler) |
| 46 |
"hdc.rc", // 0101b render cache |
| 47 |
"hdc.urb", // 0110b unified return buffer |
| 48 |
"spawner", // 0111b thread spawner |
| 49 |
|
| 50 |
"vme", // 1000b video motion estimation |
| 51 |
"hdc.dcro", // 1001b data cache read only (renaming) |
| 52 |
"hdc.dc0", // 1010b |
| 53 |
"pi", // 1011b pixel interpolator |
| 54 |
|
| 55 |
"hdc.dc1", // 1100b data-cache 1 |
| 56 |
"cre", // 1101b check and refinement |
| 57 |
nullptr, nullptr, |
| 58 |
}; |
| 59 |
const char **sfidTable = p < Platform::GEN9 ? HSWBDW_SFIDS : SKL_SFIDS; |
| 60 |
|
| 61 |
if (sfidTable[sfid] == nullptr) { |
| 62 |
return "?"; |
| 63 |
} |
| 64 |
|
| 65 |
return sfidTable[sfid]; |
| 66 |
} |
| 67 |
|
| 68 |
static uint32_t getHeaderBit(uint32_t desc) { return getBits(desc, 19, 1); } |
| 69 |
|
| 70 |
static void appendUVR(Platform p, SFID sfid, int src0Len, |
| 71 |
const DecodeResult &dr, std::stringstream &ss) { |
| 72 |
bool appendUvrLod = |
| 73 |
dr.info.hasAttr(MessageInfo::Attr::HAS_UVRLOD) && src0Len > 0; |
| 74 |
if (appendUvrLod) { |
| 75 |
// Deduce the number of typed coordinates included |
| 76 |
// (e.g. U, V, R, LOD) |
| 77 |
const int BITS_PER_REG = p >= Platform::XE_HPC ? 512 : 256; |
| 78 |
// We do this by assuming address coordinates are in GRF padded |
| 79 |
// SOA order: |
| 80 |
// - U's registers, then V's, then R's, the LOD's |
| 81 |
// - if a cooridate takes less than a full GRF, then we pad it up |
| 82 |
// to that |
| 83 |
// - not all decoded combinations are supported in hardware, but |
| 84 |
// that's between the user and their deity; we're an assembler |
| 85 |
// and can't track the endlessly changing spec |
| 86 |
// Typical usage is the default message and a GRF's worth of A32 |
| 87 |
// elements as the SIMD size (e.g. 8 for TGL) |
| 88 |
// |
| 89 |
// bits for a full vector's worth of U's, V's, etc.... |
| 90 |
const int regsPerCoord = std::max<int>( |
| 91 |
1, dr.info.execWidth * dr.info.addrSizeBits / BITS_PER_REG); |
| 92 |
static const char *coordTableUVRL[5] { |
| 93 |
"?", "u", "u,v", "u,v,r", "u,v,r,lod" |
| 94 |
}; |
| 95 |
const char **coordTable = coordTableUVRL; |
| 96 |
static const char *coordTableUVRSi[5] { |
| 97 |
"?", "u", "u,v", "u,v,r", "u,v,r,si" |
| 98 |
}; |
| 99 |
if (dr.info.op == SendOp::LOAD_QUAD_MSRT || |
| 100 |
dr.info.op == SendOp::STORE_QUAD_MSRT) |
| 101 |
{ |
| 102 |
coordTable = coordTableUVRSi; |
| 103 |
} |
| 104 |
int nCoords = src0Len / regsPerCoord; |
| 105 |
ss << "; "; |
| 106 |
if (nCoords <= 4) { |
| 107 |
ss << coordTable[nCoords]; |
| 108 |
} else { |
| 109 |
ss << "???"; |
| 110 |
} |
| 111 |
} // U,V,R,LOD |
| 112 |
} |
| 113 |
|
| 114 |
void iga::EmitSendDescriptorInfo(Platform p, SFID sfid, ExecSize execSize, |
| 115 |
bool dstNonNull, int dstLen, int src0Len, |
| 116 |
int src1Len, uint32_t exImmOffDesc, |
| 117 |
const SendDesc &exDesc, const SendDesc &desc, |
| 118 |
std::stringstream &ss) { |
| 119 |
////////////////////////////////////// |
| 120 |
// emit the: "wr:1h+2, rd:4" part |
| 121 |
ss << "wr:"; |
| 122 |
if (src0Len >= 0) { |
| 123 |
ss << src0Len; |
| 124 |
} else if (desc.isReg()) { |
| 125 |
ss << "a0." << (int)desc.reg.subRegNum << "[28:25]"; |
| 126 |
} else { |
| 127 |
ss << "?"; |
| 128 |
} |
| 129 |
bool hasHeaderBit = sfid != SFID::UGM && sfid != SFID::UGML && |
| 130 |
sfid != SFID::SLM && sfid != SFID::TGM; |
| 131 |
hasHeaderBit &= (p <= Platform::XE2 || sfid != SFID::URB); |
| 132 |
|
| 133 |
if (hasHeaderBit && desc.isImm() && getHeaderBit(desc.imm)) { |
| 134 |
ss << "h"; |
| 135 |
} |
| 136 |
// |
| 137 |
ss << "+"; |
| 138 |
if (src1Len >= 0) { |
| 139 |
ss << src1Len; |
| 140 |
} else if (exDesc.isReg()) { |
| 141 |
ss << "a0." << (int)exDesc.reg.subRegNum << "[10:6]"; |
| 142 |
} else { |
| 143 |
ss << "?"; |
| 144 |
} |
| 145 |
ss << ", rd:"; |
| 146 |
if (desc.isReg()) { |
| 147 |
ss << "a0." << (int)desc.reg.subRegNum << "[24:20]"; |
| 148 |
} else { |
| 149 |
ss << dstLen; |
| 150 |
} |
| 151 |
// |
| 152 |
//////////////////////////////// |
| 153 |
// now the message description |
| 154 |
if (p < Platform::XE) { |
| 155 |
// pre-XE, emit the SFID first since it's not part of the op yet |
| 156 |
if (exDesc.isReg()) { |
| 157 |
ss << "; sfid a0." << (int)exDesc.reg.subRegNum << "[3:0]"; |
| 158 |
} else { // no a0.0 |
| 159 |
ss << "; " << getSFIDString(p, exDesc.imm & 0xF); |
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
if (desc.isImm()) { |
| 164 |
const DecodeResult dr = tryDecode(p, sfid, execSize, |
| 165 |
exImmOffDesc, |
| 166 |
exDesc, desc, nullptr); |
| 167 |
if (dr.syntax.isValid()) { |
| 168 |
ss << "; " << dr.syntax.sym(); |
| 169 |
} else if (!dr.info.description.empty()) { |
| 170 |
ss << "; " << dr.info.description; |
| 171 |
} else { |
| 172 |
ss << "; ?"; |
| 173 |
} |
| 174 |
|
| 175 |
appendUVR(p, sfid, src0Len, dr, ss); |
| 176 |
} // is imm desc |
| 177 |
} // iga::EmitSendDescriptorInfo |
| 178 |
|
| 179 |
void iga::EmitSendgDescriptorInfoXe3p(Platform p, SFID sfid, ExecSize execSize, |
| 180 |
bool dstNonNull, int src0Len, int src1Len, |
| 181 |
RegRef id0, RegRef id1, uint64_t desc, |
| 182 |
std::stringstream &ss) { |
| 183 |
DiagnosticList ws, es; |
| 184 |
DecodeResult dr = |
| 185 |
tryDecode(p, sfid, execSize, src0Len, src1Len, id0, id1, desc, nullptr); |
| 186 |
if (!dstNonNull) |
| 187 |
dr.info.dstLenBytes = 0; |
| 188 |
if (dr.info.dstLenBytes >= 0) |
| 189 |
ss << "rd:" << dr.info.dstLenBytes << " B; "; |
| 190 |
if (dr.syntax.isValid()) { |
| 191 |
ss << dr.syntax.sym(); |
| 192 |
} else if (!dr.info.description.empty()) { |
| 193 |
ss << dr.info.description; |
| 194 |
} else { |
| 195 |
ss << "???"; |
| 196 |
} |
| 197 |
|
| 198 |
appendUVR(p, sfid, src0Len, dr, ss); |
| 199 |
} |