Skip to content

Commit cb3ed54

Browse files
jgu222sys_zuul
authored andcommitted
Support emulation of general call and return for i64 type.
This issue was reported when using -O0, but the bug exists for normal compile flow as well. Change-Id: I984528d258069046e94588d4544b5ed99455f7d0
1 parent d9e4775 commit cb3ed54

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

IGC/Compiler/CISACodeGen/Emu64OpsPass.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,23 @@ bool InstExpander::visitInstruction(Instruction& I) {
665665
}
666666

667667
bool InstExpander::visitRet(ReturnInst& RI) {
668-
if (Value * V = RI.getReturnValue())
668+
if (Value* V = RI.getReturnValue())
669669
{
670-
// TODO: Add 64-bit return value support when function/subroutine call is supported.
671670
IGC_ASSERT(nullptr != Emu);
672-
IGC_ASSERT_MESSAGE(false == Emu->isInt64(V), "TODO: NOT IMPLEMENTED YET!");
671+
if (Emu->isInt64(V))
672+
{
673+
Value* Lo = nullptr, *Hi = nullptr;
674+
std::tie(Lo, Hi) = Emu->getExpandedValues(V);
675+
Type* V2I32Ty = Emu->getV2Int32Ty();
676+
Value* NewVal = UndefValue::get(V2I32Ty);
677+
NewVal = IRB->CreateInsertElement(NewVal, Lo, IRB->getInt32(0));
678+
NewVal = IRB->CreateInsertElement(NewVal, Hi, IRB->getInt32(1));
679+
NewVal = IRB->CreateBitCast(NewVal, IRB->getInt64Ty());
680+
681+
IRB->SetInsertPoint(&RI);
682+
(void) IRB->CreateRet(NewVal);
683+
return true;
684+
}
673685
}
674686
return false;
675687
}
@@ -1969,7 +1981,9 @@ bool InstExpander::visitCall(CallInst& Call) {
19691981
}
19701982
}
19711983
// Support for stack/indirect/subroutine calls
1972-
else if (!F || F->hasFnAttribute("visaStackCall") || F->hasFnAttribute("UserSubroutine"))
1984+
// Note: should use enableFunctionCall() without using attr checking.
1985+
else if ( !F || F->hasFnAttribute("visaStackCall") || F->hasFnAttribute("UserSubroutine")
1986+
|| Emu->CGC->enableFunctionCall())
19731987
{
19741988
auto* CallCopy = Call.clone();
19751989
IGC_ASSERT(nullptr != CallCopy);

0 commit comments

Comments
 (0)