Skip to content

Commit 1236f59

Browse files
trbauerigcbot
authored andcommitted
High-Level Load/Store G4IR support.
The goal is to move us away from twiddling bits in descriptors every time we need to examine or modify send messages. * All send descriptors (formerly G4_SendMsgDescriptor) are subclasses of G4_SendDesc * The old raw descriptor is G4_SendDescRaw and there is a new G4_SendDescLdSt which is unused at the moment. * Anywhere possible, we now use the generic methods of the superclass G4_SendDesc. * In cases where the old code fiddles with bits directly and requires the raw descriptor, we add a type check and convert to G4_SendDescRaw (assert on fail / return false on pattern match if safe to do so (e.g. SendFusion::canFuse(..))). * Do not let the old raw descriptor gunk pollute the generic interface of the parent. * Push #5
1 parent c5c21e1 commit 1236f59

38 files changed

+2152
-1088
lines changed

visa/BinaryEncoding.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ inline void BinaryEncoding::EncodeSendMsgDesc29_30(G4_INST* inst)
285285
MUST_BE_TRUE(inst->isSend(), "must be a send inst");
286286

287287
BinInst *mybin = inst->getBinInst();
288-
G4_SendMsgDescriptor* msgDesc = inst->getMsgDesc();
288+
G4_SendDescRaw* msgDesc = inst->getMsgDescRaw();
289+
MUST_BE_TRUE(msgDesc, "expected raw descriptor");
289290
G4_Operand* descOpnd = inst->isSplitSend() ? inst->getSrc(2) : inst->getSrc(1);
290291
if (!descOpnd->isImm())
291292
{
@@ -2612,10 +2613,9 @@ inline
26122613
BinaryEncoding::Status BinaryEncoding::EncodeExtMsgDescr(G4_INST* inst)
26132614
{
26142615
BinInst *mybin = inst->getBinInst();
2615-
{
2616-
uint32_t msgDesc = inst->getMsgDesc()->getExtendedDesc();
2617-
SetExtMsgDescr(inst, mybin, msgDesc);
2618-
}
2616+
MUST_BE_TRUE(inst->getMsgDescRaw(), "expected raw descriptor");
2617+
uint32_t msgDesc = inst->getMsgDescRaw()->getExtendedDesc();
2618+
SetExtMsgDescr(inst, mybin, msgDesc);
26192619
return SUCCESS;
26202620
}
26212621

visa/BinaryEncodingCNL.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ inline void BinaryEncodingCNL::EncodeTwoSrcInst(G4_INST* inst, G9HDL::EU_INSTRUC
915915
///
916916
void PatchSend(G4_INST* inst, G9HDL::EU_INSTRUCTION_BASIC_TWO_SRC* twoSrc)
917917
{
918-
uint32_t msgDesc = inst->getMsgDesc()->getExtendedDesc();
918+
MUST_BE_TRUE(inst->getMsgDescRaw(), "expected raw descriptor");
919+
uint32_t msgDesc = inst->getMsgDescRaw()->getExtendedDesc();
919920
EncExtMsgDescriptor emd;
920921
emd.ulData = msgDesc;
921922

@@ -1921,7 +1922,8 @@ BinaryEncodingCNL::Status BinaryEncodingCNL::EncodeSplitSend(G4_INST* inst, G9HD
19211922

19221923
//Patch SFID and EOT
19231924
{
1924-
uint32_t msgDesc = inst->getMsgDesc()->getExtendedDesc();
1925+
MUST_BE_TRUE(inst->getMsgDescRaw(), "expected raw descriptor");
1926+
uint32_t msgDesc = inst->getMsgDescRaw()->getExtendedDesc();
19251927
EncExtMsgDescriptor emd;
19261928
emd.ulData = msgDesc;
19271929

visa/BinaryEncodingIGA.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ iga::SFID BinaryEncodingIGA::getSFID(const G4_INST *inst)
391391
{
392392
ASSERT_USER(inst->isSend(), "Only send has SFID");
393393

394-
G4_SendMsgDescriptor *msgDesc = inst->getMsgDesc();
395-
auto funcID = msgDesc->getFuncId();
394+
G4_SendDesc *msgDesc = inst->getMsgDesc();
395+
auto funcID = msgDesc->getSFID();
396396

397397
iga::SFID sfid = iga::SFID::INVALID;
398398
switch (funcID)
@@ -406,7 +406,7 @@ iga::SFID BinaryEncodingIGA::getSFID(const G4_INST *inst)
406406
case vISA::SFID::SPAWNER: sfid = iga::SFID::TS; break;
407407
case vISA::SFID::VME: sfid = iga::SFID::VME; break;
408408
case vISA::SFID::DP_CC: sfid = iga::SFID::DCRO; break;
409-
case vISA::SFID::DP_DC: sfid = iga::SFID::DC0; break;
409+
case vISA::SFID::DP_DC0: sfid = iga::SFID::DC0; break;
410410
case vISA::SFID::DP_PI: sfid = iga::SFID::PIXI; break;
411411
case vISA::SFID::DP_DC1: sfid = iga::SFID::DC1; break;
412412
case vISA::SFID::CRE: sfid = iga::SFID::CRE; break;
@@ -1004,7 +1004,8 @@ void BinaryEncodingIGA::translateInstructionDst(
10041004
// not all bits are copied from immediate descriptor
10051005
if (g4inst->isSend() && platform >= GENX_SKL && platform < GENX_ICLLP)
10061006
{
1007-
G4_SendMsgDescriptor* msgDesc = g4inst->getMsgDesc();
1007+
const G4_SendDescRaw* msgDesc = g4inst->getMsgDescRaw();
1008+
assert(msgDesc && "expected raw descriptor");
10081009
G4_Operand* descOpnd = g4inst->isSplitSend() ?
10091010
g4inst->getSrc(2) : g4inst->getSrc(1);
10101011
if (!descOpnd->isImm() && msgDesc->is16BitReturn())
@@ -1148,7 +1149,8 @@ void BinaryEncodingIGA::translateInstructionSrcs(
11481149
{
11491150
// work around for SKL bug
11501151
// not all bits are copied from immediate descriptor
1151-
G4_SendMsgDescriptor* msgDesc = inst->getMsgDesc();
1152+
G4_SendDescRaw* msgDesc = inst->getMsgDescRaw();
1153+
assert(msgDesc && "expected raw descriptor");
11521154
G4_Operand* descOpnd = inst->isSplitSend() ?
11531155
inst->getSrc(2) : inst->getSrc(1);
11541156
if (!descOpnd->isImm() && msgDesc->is16BitInput())
@@ -1248,8 +1250,8 @@ static SendDesc encodeExDescSendUnary(
12481250

12491251
// old unary packed send
12501252
// exDesc is stored in SendMsgDesc and must be IMM
1251-
G4_SendMsgDescriptor* descG4 = sendInst->getMsgDesc();
1252-
assert(descG4 != nullptr && "null msg desc");
1253+
G4_SendDescRaw* descG4 = sendInst->getMsgDescRaw();
1254+
assert(descG4 != nullptr && "expected raw send");
12531255

12541256
exDescIga.type = SendDesc::Kind::IMM;
12551257
uint32_t tVal = descG4->getExtendedDesc();
@@ -1280,8 +1282,8 @@ SendDesc BinaryEncodingIGA::encodeExDescImm(
12801282
SendDesc exDescIga;
12811283

12821284
G4_Operand* exDescG4 = sendInst->getSrc(3);
1283-
G4_SendMsgDescriptor* descG4 = sendInst->getMsgDesc();
1284-
assert(descG4 != nullptr && "null msg desc");
1285+
G4_SendDescRaw* descG4 = sendInst->getMsgDescRaw();
1286+
assert(descG4 != nullptr && "expected raw descriptor");
12851287

12861288
xlen = (int)descG4->extMessageLength();
12871289
//
@@ -1316,8 +1318,8 @@ iga::SendDesc BinaryEncodingIGA::encodeExDescRegA0(
13161318
SendDesc exDescIga;
13171319

13181320
G4_Operand* exDescG4 = sendInst->getSrc(3);
1319-
const G4_SendMsgDescriptor* descG4 = sendInst->getMsgDesc();
1320-
assert(descG4 != nullptr && "null msg desc");
1321+
const G4_SendDescRaw* descG4 = sendInst->getMsgDescRaw();
1322+
assert(descG4 != nullptr && "expected raw descriptor");
13211323

13221324
exDescIga.type = SendDesc::Kind::REG32A;
13231325
exDescIga.reg.regNum = 0; // must be a0

visa/BuildIR.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -850,29 +850,29 @@ class IR_Builder
850850

851851
// ToDo: get rid of this version and use the message type specific ones below instead,
852852
// so we can avoid having to explicitly create extDesc bits
853-
G4_SendMsgDescriptor* createGeneralMsgDesc(
853+
G4_SendDescRaw * createGeneralMsgDesc(
854854
uint32_t desc,
855855
uint32_t extDesc,
856856
SendAccess access,
857857
G4_Operand* bti = nullptr,
858858
G4_Operand* sti = nullptr);
859859

860-
G4_SendMsgDescriptor* createReadMsgDesc(
860+
G4_SendDescRaw * createReadMsgDesc(
861861
SFID sfid,
862862
uint32_t desc,
863863
G4_Operand* bti = nullptr);
864864

865-
G4_SendMsgDescriptor* createWriteMsgDesc(
865+
G4_SendDescRaw * createWriteMsgDesc(
866866
SFID sfid,
867867
uint32_t desc,
868868
int src1Len,
869869
G4_Operand* bti = nullptr);
870870

871-
G4_SendMsgDescriptor* createSyncMsgDesc(
871+
G4_SendDescRaw * createSyncMsgDesc(
872872
SFID sfid,
873873
uint32_t desc);
874874

875-
G4_SendMsgDescriptor* createSampleMsgDesc(
875+
G4_SendDescRaw * createSampleMsgDesc(
876876
uint32_t desc,
877877
bool cps,
878878
int src1Len,
@@ -887,7 +887,7 @@ class IR_Builder
887887
return isRead ? SendAccess::READ_ONLY : SendAccess::WRITE_ONLY;
888888
}
889889

890-
G4_SendMsgDescriptor* createSendMsgDesc(
890+
G4_SendDescRaw * createSendMsgDesc(
891891
SFID sfid,
892892
uint32_t desc,
893893
uint32_t extDesc,
@@ -896,7 +896,7 @@ class IR_Builder
896896
G4_Operand *bti,
897897
bool isValidFuncCtrl = true);
898898

899-
G4_SendMsgDescriptor* createSendMsgDesc(
899+
G4_SendDescRaw * createSendMsgDesc(
900900
unsigned funcCtrl,
901901
unsigned regs2rcv,
902902
unsigned regs2snd,
@@ -1204,22 +1204,22 @@ class IR_Builder
12041204
G4_DstRegRegion* postDst, G4_SrcRegRegion* payload,
12051205
G4_Operand* msg,
12061206
G4_InstOpts options, // FIXME: re-order options to follow all operands
1207-
G4_SendMsgDescriptor *msgDesc,
1207+
G4_SendDesc *msgDesc,
12081208
bool addToInstList);
12091209
G4_InstSend* createInternalSendInst(
12101210
G4_Predicate* prd, G4_opcode op,
12111211
G4_ExecSize execSize,
12121212
G4_DstRegRegion* postDst, G4_SrcRegRegion* payload,
12131213
G4_Operand* msg,
12141214
G4_InstOpts options, // FIXME: re-order options to follow all operands
1215-
G4_SendMsgDescriptor *msgDescs);
1215+
G4_SendDesc *msgDescs);
12161216

12171217
G4_InstSend* createSplitSendInst(
12181218
G4_Predicate* prd, G4_opcode op,
12191219
G4_ExecSize execSize,
12201220
G4_DstRegRegion* dst, G4_SrcRegRegion* src1, G4_SrcRegRegion* src2,
12211221
G4_Operand* msg, G4_InstOpts options,
1222-
G4_SendMsgDescriptor *msgDesc,
1222+
G4_SendDesc* msgDesc,
12231223
G4_Operand* src3,
12241224
bool addToInstList);
12251225

@@ -1228,7 +1228,7 @@ class IR_Builder
12281228
G4_DstRegRegion* dst, G4_SrcRegRegion* src1, G4_SrcRegRegion* src2,
12291229
// TODO: reorder parameters to put options last
12301230
G4_Operand* msg, G4_InstOpts options,
1231-
G4_SendMsgDescriptor *msgDesc,
1231+
G4_SendDesc*msgDesc,
12321232
G4_Operand* src3);
12331233

12341234
G4_INST* createMathInst(
@@ -1321,15 +1321,15 @@ class IR_Builder
13211321
G4_Predicate *pred,
13221322
G4_DstRegRegion *postDst, G4_SrcRegRegion *payload,
13231323
G4_ExecSize execSize,
1324-
G4_SendMsgDescriptor *msgDesc,
1324+
G4_SendDescRaw *msgDesc,
13251325
G4_InstOpts options,
13261326
bool is_sendc);
13271327

13281328
G4_InstSend *Create_SplitSend_Inst(
13291329
G4_Predicate *pred,
13301330
G4_DstRegRegion *dst, G4_SrcRegRegion *src1, G4_SrcRegRegion *src2,
13311331
G4_ExecSize execSize,
1332-
G4_SendMsgDescriptor *msgDesc,
1332+
G4_SendDescRaw *msgDesc,
13331333
G4_InstOpts options,
13341334
bool is_sendc);
13351335

@@ -1341,7 +1341,7 @@ class IR_Builder
13411341
G4_SrcRegRegion *src2,
13421342
G4_SrcRegRegion *extDesc,
13431343
G4_ExecSize execSize,
1344-
G4_SendMsgDescriptor *msgDesc,
1344+
G4_SendDescRaw *msgDesc,
13451345
G4_InstOpts option);
13461346

13471347
G4_InstSend* Create_Send_Inst_For_CISA(
@@ -1978,7 +1978,7 @@ class IR_Builder
19781978
G4_SrcRegRegion *src1,
19791979
G4_DstRegRegion *dst);
19801980

1981-
void applySideBandOffset(G4_Operand* sideBand, G4_SendMsgDescriptor* sendMsgDesc);
1981+
void applySideBandOffset(G4_Operand* sideBand, const G4_SendDescRaw * sendMsgDesc);
19821982

19831983
int translateVISAGather4ScaledInst(
19841984
G4_Predicate *pred,

0 commit comments

Comments
 (0)