Skip to content

Commit dde453b

Browse files
Dimus77igcbot
authored andcommitted
Changes in code.
1 parent a0f9f3d commit dde453b

File tree

9 files changed

+68
-35
lines changed

9 files changed

+68
-35
lines changed

visa/BinaryEncoding.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,9 +1557,8 @@ BinaryEncoding::Status BinaryEncoding::EncodeOperandDst(G4_INST* inst)
15571557
inline BinaryEncoding::Status BinaryEncoding::EncodeOperandSrc0(G4_INST* inst)
15581558
{
15591559
Status myStatus = SUCCESS;
1560-
if (inst->isLabel() ||
1561-
inst->isCall() ||
1562-
inst->isFCall())
1560+
if (inst->isLabel() ||
1561+
inst->isCall())
15631562
return myStatus;
15641563

15651564
if (inst->isSplitSend())
@@ -3169,7 +3168,7 @@ bool BinaryEncoding::EncodeConditionalBranches(G4_INST *inst,
31693168
}
31703169
}
31713170

3172-
if ((op == G4_call || op == G4_pseudo_fcall) && inst->getSrc(0))
3171+
if (op == G4_call && inst->getSrc(0))
31733172
{
31743173

31753174
if (inst->getSrc(0)->isLabel())

visa/BinaryEncoding.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,13 +819,13 @@ namespace vISA
819819
}
820820

821821
// ToDo: disable compacting nop/return until it is clear that we can compact them
822-
if (op == G4_nop || op == G4_return || op == G4_pseudo_fret)
822+
if (op == G4_nop || op == G4_return)
823823
{
824824
return false;
825825
}
826826

827827
// temporary WA, to be removed later
828-
if (op == G4_call || op == G4_pseudo_fcall)
828+
if (op == G4_call)
829829
{
830830
return false;
831831
}

visa/BinaryEncodingCNL.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ uint32_t BinaryEncodingBase::getEUOpcode(G4_opcode g4opc)
105105
case G4_brd: euopcode = G9HDL::EU_OPCODE_BRD; break;
106106
case G4_break: euopcode = G9HDL::EU_OPCODE_BREAK; break;
107107
case G4_call: euopcode = G9HDL::EU_OPCODE_CALL; break;
108-
case G4_pseudo_fcall: euopcode = G9HDL::EU_OPCODE_CALL; break;
109108
//case G4_calla: euopcode = G9HDL::EU_OPCODE_CALLA; break;
110109
case G4_cont: euopcode = G9HDL::EU_OPCODE_CONT; break;
111110
case G4_else: euopcode = G9HDL::EU_OPCODE_ELSE; break;
@@ -115,10 +114,7 @@ uint32_t BinaryEncodingBase::getEUOpcode(G4_opcode g4opc)
115114
case G4_if: euopcode = G9HDL::EU_OPCODE_IF; break;
116115
case G4_jmpi: euopcode = G9HDL::EU_OPCODE_JMPI; break;
117116
case G4_join: euopcode = G9HDL::EU_OPCODE_JOIN; break;
118-
case G4_return:
119-
case G4_pseudo_fret:
120-
euopcode = G9HDL::EU_OPCODE_RET;
121-
break;
117+
case G4_return: euopcode = G9HDL::EU_OPCODE_RET; break;
122118
case G4_wait: euopcode = G9HDL::EU_OPCODE_WAIT; break;
123119
case G4_while: euopcode = G9HDL::EU_OPCODE_WHILE; break;
124120

@@ -1748,8 +1744,8 @@ bool BinaryEncodingCNL::EncodeConditionalBranches(G4_INST *inst,
17481744
}
17491745
}
17501746

1751-
if ((op == G4_call || op == G4_pseudo_fcall) &&
1752-
inst->getSrc(0) &&
1747+
if (op == G4_call &&
1748+
inst->getSrc(0) &&
17531749
inst->getSrc(0)->isLabel())
17541750
{
17551751
G4_Operand *opnd = inst->getSrc(0);
@@ -2393,7 +2389,7 @@ BinaryEncodingCNL::Status BinaryEncodingCNL::DoAllEncoding(G4_INST* inst)
23932389
{
23942390
DoAllEncodingCF(inst);
23952391
}
2396-
else if (inst->opcode() == G4_call || inst->opcode() == G4_pseudo_fcall)
2392+
else if (inst->opcode() == G4_call)
23972393
{
23982394
DoAllEncodingCALL(inst);
23992395
}

visa/BinaryEncodingIGA.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,8 @@ std::pair<iga::Op,iga::Subfunction> BinaryEncodingIGA::getIgaOpInfo(
263263
case G4_break: igaOp = iga::Op::BREAK; break;
264264
case G4_cont: igaOp = iga::Op::CONT; break;
265265
case G4_halt: igaOp = iga::Op::HALT; break;
266-
case G4_call:
267-
case G4_pseudo_fcall:
268-
//TODO: select calla for indirect call
269-
igaOp = iga::Op::CALL;
270-
break;
271-
case G4_return:
272-
case G4_pseudo_fret:
273-
igaOp = iga::Op::RET;
274-
break;
266+
case G4_call: igaOp = iga::Op::CALL; break;
267+
case G4_return: igaOp = iga::Op::RET; break;
275268
case G4_goto: igaOp = iga::Op::GOTO; break;
276269
case G4_join: igaOp = iga::Op::JOIN; break;
277270
case G4_wait:
@@ -359,6 +352,8 @@ std::pair<iga::Op,iga::Subfunction> BinaryEncodingIGA::getIgaOpInfo(
359352
case G4_pseudo_or: igaOp = iga::Op::OR; break;
360353
case G4_pseudo_xor: igaOp = iga::Op::XOR; break;
361354
case G4_pseudo_not: igaOp = iga::Op::NOT; break;
355+
case G4_pseudo_fcall: igaOp = iga::Op::CALL; break;
356+
case G4_pseudo_fret: igaOp = iga::Op::RET; break;
362357
case G4_pseudo_sada2: igaOp = iga::Op::SADA2; break;
363358
case G4_pseudo_exit:
364359
ASSERT_USER(!allowUnknownOp, "G4_pseudo_exit not GEN ISA OPCODE.");

visa/BuildCISAIRImpl.cpp

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,20 @@ int CISA_IR_Builder::AddFunction(VISAFunction *& function, const char* functionN
404404
void restoreFCallState(
405405
G4_Kernel* kernel, const std::map<G4_BB*, G4_INST*>& savedFCallState)
406406
{
407-
// Iterate over all BBs in kernel and clean up the edges.
408-
// FIXME: do we need to do this still?
407+
// Iterate over all BBs in kernel and fix all fcalls converted
408+
// to calls by reconverting them to fcall. This is required
409+
// because we want to reuse IR of function for next kernel.
410+
409411
for (auto&& iter : savedFCallState)
410412
{
411413
auto curBB = iter.first;
414+
auto genOffset = curBB->back()->getGenOffset();
415+
curBB->pop_back();
412416
auto origInst = iter.second;
413417
assert(origInst->isFCall() || origInst->isFReturn());
418+
curBB->push_back(origInst);
419+
// set the genOffset in case of GenOffset being used when creating symbol table
420+
origInst->setGenOffset(genOffset);
414421

415422
if (origInst->isFCall() && !origInst->asCFInst()->isIndirectCall())
416423
{
@@ -440,6 +447,7 @@ void restoreFCallState(
440447

441448
// Stitch the FG of subFunctions to mainFunc
442449
// mainFunc could be a kernel or a non-kernel function.
450+
// It also modifies pseudo_fcall/fret in to call/ret opcodes.
443451
// ToDo: may consider stitching only functions that may be called by this kernel/function
444452
static void Stitch_Compiled_Units(
445453
G4_Kernel* mainFunc, std::map<std::string, G4_Kernel*>& subFuncs,
@@ -463,7 +471,8 @@ static void Stitch_Compiled_Units(
463471
mainFunc->fg.reassignBlockIDs();
464472
mainFunc->fg.setPhysicalPredSucc(); // this is to locate the next BB after an fcall
465473

466-
// setup caller/callee edges
474+
auto builder = mainFunc->fg.builder;
475+
// Change fcall/fret to call/ret and setup caller/callee edges
467476
for (G4_BB* cur : mainFunc->fg)
468477
{
469478
if (cur->isEndWithFCall())
@@ -491,11 +500,47 @@ static void Stitch_Compiled_Units(
491500
// Connect new fg
492501
mainFunc->fg.addPredSuccEdges(cur, callee->fg.getEntryBB());
493502
mainFunc->fg.addPredSuccEdges(callee->fg.getUniqueReturnBlock(), retBlock);
503+
504+
G4_INST* calleeLabel = callee->fg.getEntryBB()->front();
505+
ASSERT_USER(calleeLabel->isLabel() == true, "Entry inst is not label");
506+
507+
auto callInst = builder->createInternalInst(
508+
fcall->getPredicate(), G4_call, nullptr, g4::NOSAT, fcall->getExecSize(),
509+
fcall->getDst(), calleeLabel->getSrc(0), fcall->getSrc(0), fcall->getOption());
510+
callInst->inheritDIFrom(fcall);
511+
cur->pop_back();
512+
cur->push_back(callInst);
513+
}
514+
else
515+
{
516+
// src0 is dont care for indirect call as long it's not a label
517+
auto callInst = builder->createInternalInst(
518+
fcall->getPredicate(), G4_call, nullptr, g4::NOSAT, fcall->getExecSize(),
519+
fcall->getDst(), fcall->getSrc(0), fcall->getSrc(0), fcall->getOption());
520+
callInst->inheritDIFrom(fcall);
521+
cur->pop_back();
522+
cur->push_back(callInst);
494523
}
495524
FCallRetMap[cur] = fcall;
496525
}
497526
}
498527

528+
// Change fret to ret
529+
for (G4_BB* cur : mainFunc->fg)
530+
{
531+
if (cur->isEndWithFRet())
532+
{
533+
G4_INST* fret = cur->back();
534+
auto retInst = builder->createInternalInst(
535+
fret->getPredicate(), G4_return, nullptr, g4::NOSAT, fret->getExecSize(),
536+
builder->createNullDst(Type_UD), fret->getSrc(0), fret->getSrc(1), fret->getOption());
537+
retInst->inheritDIFrom(fret);
538+
cur->pop_back();
539+
cur->push_back(retInst);
540+
FCallRetMap[cur] = fret;
541+
}
542+
}
543+
499544
// Append declarations and color attributes from all callees to mainFunc
500545
for (auto iter : subFuncs)
501546
{

visa/Common_BinaryEncoding.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ namespace vISA
15961596
op == G4_halt ||
15971597
op == G4_endif)
15981598
return true;
1599-
else if ((op == G4_call || op == G4_pseudo_fcall) &&
1599+
else if (op == G4_call &&
16001600
inst->getSrc(0) &&
16011601
inst->getSrc(0)->isLabel())
16021602
{
@@ -2289,7 +2289,7 @@ namespace vISA
22892289
// temporary WA, to be removed later
22902290
// we disable compacting nop/return
22912291
// until it is clear that we can compact them
2292-
if (op == G4_call || op == G4_pseudo_fcall || op == G4_return || op == G4_pseudo_fret)
2292+
if (op == G4_call || op == G4_return)
22932293
{
22942294
return false;
22952295
}

visa/LocalScheduler/SWSB_G4IR.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ void SWSB::SWSBBuildSIMDCFG()
531531
}
532532
}
533533
}
534-
else if (lastInst->isReturn() || lastInst->isCall() || lastInst->isFCall() || lastInst->isFReturn())
534+
else if (lastInst->isReturn() || lastInst->isCall())
535535
{
536536
BB_LIST_ITER iter = currBB->getBB()->Succs.begin();
537537
while (iter != currBB->getBB()->Succs.end())
@@ -671,8 +671,7 @@ void SWSB::handleIndirectCall()
671671
SBNode* node = SBNodes[BBVector[i]->last_node];
672672

673673
if ((node->GetInstruction()->isCall() && !node->GetInstruction()->getSrc(0)->isLabel()) ||
674-
node->GetInstruction()->isReturn() ||
675-
node->GetInstruction()->isFReturn())
674+
node->GetInstruction()->isReturn())
676675
{
677676
LiveGRFBuckets send_use_out(mem, kernel.getNumRegTotal(), *fg.getKernel());
678677
for (size_t j = 0; j < globalSendOpndList.size(); j++)
@@ -693,7 +692,7 @@ void SWSB::handleIndirectCall()
693692
}
694693
}
695694
}
696-
if (node->GetInstruction()->isReturn() || node->GetInstruction()->isFReturn())
695+
if (node->GetInstruction()->isReturn())
697696
{
698697
node->GetInstruction()->setDistance(1);
699698
}
@@ -1000,7 +999,6 @@ static bool isBranch(SBNode* N) {
1000999
return false;
10011000
// Skip function call/ret.
10021001
if (Inst->isCall() || Inst->isReturn() ||
1003-
Inst->isFCall() || Inst->isFReturn() ||
10041002
Inst->opcode() == G4_pseudo_fc_call ||
10051003
Inst->opcode() == G4_pseudo_fc_ret)
10061004
return false;

visa/Optimizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7578,7 +7578,7 @@ bool Optimizer::foldPseudoAndOr(G4_BB* bb, INST_LIST_ITER& ii)
75787578
// check every fcall
75797579
for (auto bb : kernel.fg)
75807580
{
7581-
if (bb->isEndWithFCall())
7581+
if (bb->back()->isFCall())
75827582
{
75837583
G4_INST* fcall = bb->back();
75847584
if (fcall->getSrc(0)->isGreg() || fcall->getSrc(0)->isA0()) {

visa/VISAKernelImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void VISAKernelImpl::adjustIndirectCallOffset()
273273
continue;
274274

275275
// At this point G4_pseudo_fcall may be converted to G4_call
276-
if (bb->isEndWithCall() || bb->isEndWithFCall())
276+
if (bb->back()->isCall() || bb->back()->isFCall())
277277
{
278278
G4_INST* fcall = bb->back();
279279
if (fcall->getSrc(0)->isGreg() || fcall->getSrc(0)->isA0())

0 commit comments

Comments
 (0)