Skip to content

Commit c0a1b28

Browse files
DianaChensys_zuul
authored andcommitted
[Autobackout][Manual]Revert of change: 7abb500
Add iga::OpSpec::hasImplicitFlagModifier to check if instructions have implicit flag modifier. In the case the instructions have, we should set the flag registers. Also refactor BinaryEncodingIGA. Change-Id: I9d9dba8b556131cf5c09cce1bcf11430cf0d238a
1 parent f45f364 commit c0a1b28

File tree

4 files changed

+33
-46
lines changed

4 files changed

+33
-46
lines changed

visa/BinaryEncodingIGA.cpp

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -592,35 +592,6 @@ void BinaryEncodingIGA::SetSWSB(G4_INST *inst, iga::SWSB &sw)
592592
return;
593593
}
594594

595-
void BinaryEncodingIGA::getIGAFlagInfo(
596-
G4_INST* inst, const OpSpec* opSpec, Predication& pred, FlagModifier& condMod, RegRef& flagReg)
597-
{
598-
G4_Predicate* predG4 = inst->getPredicate();
599-
G4_CondMod* condModG4 = inst->getCondMod();
600-
iga::RegRef predFlag;
601-
bool hasPredFlag = false;
602-
603-
if (opSpec->supportsPredication() && predG4 != nullptr)
604-
{
605-
pred = getIGAPredication(predG4);
606-
predFlag = getIGAFlagReg(predG4->getBase());
607-
flagReg = predFlag;
608-
hasPredFlag = true;
609-
}
610-
611-
if ((opSpec->supportsFlagModifier() || opSpec->hasImplicitFlagModifier()) &&
612-
condModG4 != nullptr)
613-
{
614-
condMod = getIGAFlagModifier(condModG4);
615-
// in case for min/max sel instruction, it could have CondMod but has no flag registers
616-
if (condModG4->getBase() != nullptr) {
617-
flagReg = getIGAFlagReg(condModG4->getBase());
618-
// pred and condMod Flags must be the same
619-
assert(!hasPredFlag || predFlag == flagReg);
620-
}
621-
}
622-
}
623-
624595
void BinaryEncodingIGA::DoAll()
625596
{
626597
FixInst();
@@ -704,7 +675,17 @@ void BinaryEncodingIGA::DoAll()
704675
MaskCtrl maskCtrl = getIGAMaskCtrl(inst->opcode() == G4_jmpi ? true : inst->isWriteEnableInst());
705676
FlagModifier condModifier = FlagModifier::NONE;
706677

707-
getIGAFlagInfo(inst, opSpec, pred, condModifier, flagReg);
678+
if (opSpec->supportsPredication())
679+
{
680+
flagReg = getIGAFlagReg(inst);
681+
pred = getIGAPredication(inst->getPredicate());
682+
}
683+
if (opSpec->supportsFlagModifier() ||
684+
(inst->getCondMod() != nullptr && inst->getCondMod()->getMod() != G4_CondModifier::Mod_cond_undef))
685+
{
686+
flagReg = getIGAFlagReg(inst);
687+
condModifier = getIGAFlagModifier(inst);
688+
}
708689

709690
if (opSpec->isBranching())
710691
{

visa/BinaryEncodingIGA.h

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,22 +392,35 @@ class BinaryEncodingIGA
392392
return b;
393393
}
394394

395-
void getIGAFlagInfo(
396-
G4_INST* inst, const iga::OpSpec* opSpec, iga::Predication& pred,
397-
iga::FlagModifier& condMod, iga::RegRef& flagReg);
398-
399-
iga::RegRef getIGAFlagReg(G4_VarBase* g4Base)
395+
iga::RegRef getIGAFlagReg(G4_INST *inst)
400396
{
401397
iga::RegRef reg = iga::REGREF_INVALID;
398+
G4_Predicate* predG4 = inst->getPredicate();
402399
bool flagRegNumValid = true;
403-
reg.regNum = (uint8_t)g4Base->ExRegNum(flagRegNumValid);
400+
if (predG4)
401+
{
402+
reg.regNum =
403+
(uint8_t)predG4->getBase()->ExRegNum(flagRegNumValid);
404+
reg.subRegNum = (uint8_t)predG4->getBase()->asRegVar()->getPhyRegOff();
405+
}
406+
407+
G4_CondMod* condModG4 = inst->getCondMod();
408+
if (condModG4)
409+
{
410+
G4_VarBase* flagReg = condModG4->getBase();
411+
if (flagReg != NULL)
412+
{
413+
reg.regNum = (uint8_t)flagReg->ExRegNum(flagRegNumValid);
414+
reg.subRegNum = (uint8_t)flagReg->asRegVar()->getPhyRegOff();
415+
}
416+
}
404417
ASSERT_USER(flagRegNumValid, "Unable to retrieve flag Reg Num for predicate or conditional modifier.");
405-
reg.subRegNum = (uint8_t)g4Base->asRegVar()->getPhyRegOff();
406418
return reg;
407419
}
408420

409-
iga::FlagModifier getIGAFlagModifier(G4_CondMod* cMod) const
421+
iga::FlagModifier getIGAFlagModifier(G4_INST *inst) const
410422
{
423+
auto cMod = inst->getCondMod();
411424
if (cMod == nullptr)
412425
{
413426
return iga::FlagModifier::NONE;

visa/iga/IGALibrary/Backend/GED/Decoder.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,10 +1453,8 @@ FlagRegInfo DecoderBase::decodeFlagRegInfo(bool imm64Src0Overlaps) {
14531453
// GEN12 SWSB overlaps CondModifier and Imm64 values
14541454
GED_DECODE_RAW(GED_COND_MODIFIER, condMod, CondModifier);
14551455
fri.modifier = GEDToIGATranslation::translate(condMod);
1456-
} else if (m_opSpec->hasImplicitFlagModifier()) {
1456+
} else if (m_opSpec->isMathSubFunc() && m_opSpec->isMacro()) {
14571457
// math.inv and math.rsqrtm both implicitly support EO
1458-
// currently math is the only case, and its flagModifier must be EO
1459-
assert(m_opSpec->isMathSubFunc());
14601458
fri.modifier = FlagModifier::EO;
14611459
}
14621460

visa/iga/IGALibrary/Models/OpSpec.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,6 @@ namespace iga
597597
bool supportsFlagModifier() const {
598598
return hasAttrs(Attr::SUPPORTS_FLAGMODIFIER);
599599
}
600-
bool hasImplicitFlagModifier() const {
601-
// math.invm and math.sqtrm has implicit flag modifier, which
602-
// that flag register must be exisited
603-
return isMathSubFunc() && isMacro();
604-
}
605600
bool supportsSaturation() const {
606601
return hasAttrs(Attr::SUPPORTS_SATURATION);
607602
}

0 commit comments

Comments
 (0)