@@ -1007,74 +1007,121 @@ SendDesc BinaryEncodingIGA::getIGASendDesc(G4_INST* sendInst) const
10071007 return desc;
10081008}
10091009
1010+ // /////////////////////////////////////////////////////////////////////////////
1011+ // ExDesc encoding
1012+ static SendDesc encodeExDescSendUnary (
1013+ G4_INST* sendInst, int & xlen, InstOptSet& extraOpts)
1014+ {
1015+ SendDesc exDescIga;
1016+
1017+ // old unary packed send
1018+ // exDesc is stored in SendMsgDesc and must be IMM
1019+ G4_SendMsgDescriptor* descG4 = sendInst->getMsgDesc ();
1020+ assert (descG4 != nullptr && " null msg desc" );
1021+
1022+ exDescIga.type = SendDesc::Kind::IMM;
1023+ uint32_t tVal = descG4->getExtendedDesc ();
1024+
1025+ // We must clear the funcID in the extended message.
1026+ // In Gen12+ this is part of the EU encoding, not the descriptor.
1027+ // vISA/G4IR still treat it as part of the descriptor.
1028+ if (getPlatformGeneration (sendInst->getPlatform ()) >= PlatformGen::GEN12)
1029+ {
1030+ tVal = tVal & 0xFFFFFFF0 ;
1031+ }
1032+ exDescIga.imm = tVal;
1033+
1034+ // non-split send implies Src1.Length == 0
1035+ xlen = 0 ;
1036+
1037+ return exDescIga;
1038+ }
1039+
1040+ // //////////////////////////////////////////////////////////////////
1041+ // these handle binary sends (old "sends" and GEN12+ "send"
1042+ //
1043+ SendDesc BinaryEncodingIGA::encodeExDescImm (
1044+ G4_INST* sendInst,
1045+ int & xlen,
1046+ InstOptSet& extraOpts) const
1047+ {
1048+ SendDesc exDescIga;
1049+
1050+ G4_Operand* exDescG4 = sendInst->getSrc (3 );
1051+ G4_SendMsgDescriptor* descG4 = sendInst->getMsgDesc ();
1052+ assert (descG4 != nullptr && " null msg desc" );
1053+
1054+ xlen = (int )descG4->extMessageLength ();
1055+ //
1056+ exDescIga.type = SendDesc::Kind::IMM;
1057+ exDescIga.imm = (uint32_t )exDescG4->asImm ()->getImm ();
1058+ // We must clear the funcID in the extended message for Gen12+
1059+ // because it is part of the EU instruction, not the descriptor,
1060+ // and, vISA/G4-IR still thinks of it as part of the descriptor.
1061+ //
1062+ // Ditto for the EOT bit which is moved out of extDesc
1063+ //
1064+ // The extended message format
1065+ // struct ExtendedMsgDescLayout {
1066+ // uint32_t funcID : 4; // bit 0:3 << not part of ExDesc
1067+ // uint32_t unnamed1 : 1; // bit 4
1068+ // uint32_t eot : 1; // bit 5 << not part of ExDesc
1069+ // uint32_t extMsgLength : 5; // bit 6:10
1070+ // uint32_t unnamed2 : 5; // bit 11:15
1071+ // uint32_t extFuncCtrl : 16; // bit 16:31
1072+ // };
1073+ if (getPlatformGeneration (sendInst->getPlatform ()) >= PlatformGen::GEN12)
1074+ {
1075+ exDescIga.imm &= 0xFFFFFFC0 ;
1076+ }
1077+
1078+ return exDescIga;
1079+ }
1080+
1081+ iga::SendDesc BinaryEncodingIGA::encodeExDescRegA0 (
1082+ G4_INST* sendInst, int & xlen, iga::InstOptSet& extraOpts) const
1083+ {
1084+ SendDesc exDescIga;
1085+
1086+ G4_Operand* exDescG4 = sendInst->getSrc (3 );
1087+ const G4_SendMsgDescriptor* descG4 = sendInst->getMsgDesc ();
1088+ assert (descG4 != nullptr && " null msg desc" );
1089+
1090+ exDescIga.type = SendDesc::Kind::REG32A;
1091+ exDescIga.reg .regNum = 0 ; // must be a0
1092+ bool valid = false ;
1093+ exDescIga.reg .subRegNum =
1094+ (uint16_t )exDescG4->asSrcRegRegion ()->ExSubRegNum (valid);
1095+ assert (valid && " invalid subreg" );
1096+
1097+
1098+ // G4 IR keeps Src1.Length (xlen) separate. So it's known,
1099+ xlen = (int )descG4->extMessageLength ();
1100+
1101+ return exDescIga;
1102+ }
1103+
10101104SendDesc BinaryEncodingIGA::getIGASendExDesc (
10111105 G4_INST* sendInst, int & xlen, iga::InstOptSet& extraOpts) const
10121106{
1013- SendDesc exDescArg ;
1107+ assert (sendInst-> isSend () && " expect send inst " ) ;
10141108
10151109 if (sendInst->isEOT ())
10161110 extraOpts.add (InstOpt::EOT);
10171111
10181112 xlen = -1 ;
10191113
1020- assert (sendInst->isSend () && " expect send inst" );
10211114 if (sendInst->isSplitSend ())
10221115 {
1023- G4_Operand* exDesc = sendInst->getSrc (3 );
1024- if (exDesc->isImm ())
1025- {
1026- G4_SendMsgDescriptor* g4SendMsg = sendInst->getMsgDesc ();
1027- xlen = (int )g4SendMsg->extMessageLength ();
1028- //
1029- exDescArg.type = SendDesc::Kind::IMM;
1030- uint32_t tVal = (uint32_t )exDesc->asImm ()->getImm ();
1031- // We must clear the funcID in the extended message for Gen12+
1032- // It's because the explicit encoding is applied, no mapping anymore.
1033- // ditto for the EOT bit which is moved out of extDesc
1034- // The extended message format
1035- // struct ExtendedMsgDescLayout {
1036- // uint32_t funcID : 4; // bit 0:3 << not part of ExDesc
1037- // uint32_t unnamed1 : 1; // bit 4
1038- // uint32_t eot : 1; // bit 5 << not part of ExDesc
1039- // uint32_t extMsgLength : 5; // bit 6:10
1040- // uint32_t unnamed2 : 5; // bit 11:15
1041- // uint32_t extFuncCtrl : 16; // bit 16:31
1042- // };
1043- if (getPlatformGeneration (sendInst->getPlatform ()) >= PlatformGen::GEN12)
1044- {
1045- tVal &= 0xFFFFFFC0 ;
1046- }
1047- exDescArg.imm = tVal;
1048- }
1049- else
1050- {
1051- exDescArg.type = SendDesc::Kind::REG32A;
1052- exDescArg.reg .regNum = 0 ; // must be a0
1053- bool valid = false ;
1054- exDescArg.reg .subRegNum =
1055- (uint8_t )exDesc->asSrcRegRegion ()->ExSubRegNum (valid);
1056- assert (valid && " invalid subreg" );
1057- }
1116+ const G4_Operand* exDesc = sendInst->getSrc (3 );
1117+ return exDesc->isImm () ?
1118+ encodeExDescImm (sendInst, xlen, extraOpts) :
1119+ encodeExDescRegA0 (sendInst, xlen, extraOpts);
10581120 }
1059- else // old unary packed send
1121+ else
10601122 {
1061- // exDesc is stored in SendMsgDesc and must be IMM
1062- G4_SendMsgDescriptor* sendDesc = sendInst->getMsgDesc ();
1063- assert (sendDesc != nullptr && " null msg desc" );
1064- exDescArg.type = SendDesc::Kind::IMM;
1065- uint32_t tVal = sendDesc->getExtendedDesc ();
1066-
1067- // We must clear the funcID in the extended message
1068- if (getPlatformGeneration (sendInst->getPlatform ()) >= PlatformGen::GEN12)
1069- {
1070- tVal = tVal & 0xFFFFFFF0 ;
1071- }
1072- exDescArg.imm = tVal;
1073- // non-split send implies Src1.Length == 0
1074- xlen = 0 ;
1123+ return encodeExDescSendUnary (sendInst, xlen, extraOpts);
10751124 }
1076-
1077- return exDescArg;
10781125}
10791126
10801127void *BinaryEncodingIGA::EmitBinary (uint32_t & binarySize)
0 commit comments