Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LoongArch64] Synchronize with PR#102469. #102638

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/jit/lsra.h
Original file line number Diff line number Diff line change
Expand Up @@ -2014,11 +2014,11 @@ class LinearScan : public LinearScanInterface
void BuildDefs(GenTree* tree, int dstCount, regMaskTP dstCandidates = RBM_NONE);
void BuildCallDefs(GenTree* tree, int dstCount, regMaskTP dstCandidates);
void BuildKills(GenTree* tree, regMaskTP killMask);
#if defined(TARGET_ARMARCH) || defined(TARGET_RISCV64)
#if defined(TARGET_ARMARCH) || defined(TARGET_RISCV64) || defined(TARGET_LOONGARCH64)
void BuildDefWithKills(GenTree* tree, regMaskTP dstCandidates, regMaskTP killMask);
#else
void BuildDefWithKills(GenTree* tree, int dstCount, regMaskTP dstCandidates, regMaskTP killMask);
#endif // TARGET_ARMARCH || TARGET_RISCV64
#endif // TARGET_ARMARCH || TARGET_RISCV64 || TARGET_LOONGARCH64
void BuildCallDefsWithKills(GenTree* tree, int dstCount, regMaskTP dstCandidates, regMaskTP killMask);

int BuildReturn(GenTree* tree);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,7 @@ void LinearScan::BuildKills(GenTree* tree, regMaskTP killMask)
}
}

#if defined(TARGET_ARMARCH) || defined(TARGET_RISCV64)
#if defined(TARGET_ARMARCH) || defined(TARGET_RISCV64) || defined(TARGET_LOONGARCH64)

//------------------------------------------------------------------------
// BuildDefWithKills: Build one RefTypeDef RefPositions for the given node,
Expand Down
64 changes: 40 additions & 24 deletions src/coreclr/jit/lsraloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ int LinearScan::BuildNode(GenTree* tree)
srcCount = 0;
assert(dstCount == 0);
killMask = getKillSetForProfilerHook();
BuildDefsWithKills(tree, 0, RBM_NONE, killMask);
BuildKills(tree, killMask);
break;

case GT_START_PREEMPTGC:
// This kills GC refs in callee save regs
srcCount = 0;
assert(dstCount == 0);
BuildDefsWithKills(tree, 0, RBM_NONE, RBM_NONE);
BuildKills(tree, RBM_NONE);
break;

case GT_CNS_DBL:
Expand Down Expand Up @@ -170,7 +170,7 @@ int LinearScan::BuildNode(GenTree* tree)
case GT_RETURN:
srcCount = BuildReturn(tree);
killMask = getKillSetForReturn();
BuildDefsWithKills(tree, 0, RBM_NONE, killMask);
BuildKills(tree, killMask);
break;

case GT_RETFILT:
Expand Down Expand Up @@ -267,7 +267,7 @@ int LinearScan::BuildNode(GenTree* tree)
srcCount = 1;
assert(dstCount == 0);
killMask = compiler->compHelperCallKillSet(CORINFO_HELP_STOP_FOR_GC);
BuildDefsWithKills(tree, 0, RBM_NONE, killMask);
BuildKills(tree, killMask);
break;

case GT_MUL:
Expand Down Expand Up @@ -679,9 +679,9 @@ int LinearScan::BuildIndir(GenTreeIndir* indirTree)
//
int LinearScan::BuildCall(GenTreeCall* call)
{
bool hasMultiRegRetVal = false;
const ReturnTypeDesc* retTypeDesc = nullptr;
regMaskTP dstCandidates = RBM_NONE;
bool hasMultiRegRetVal = false;
const ReturnTypeDesc* retTypeDesc = nullptr;
regMaskTP singleDstCandidates = RBM_NONE;

int srcCount = 0;
int dstCount = 0;
Expand Down Expand Up @@ -745,22 +745,20 @@ int LinearScan::BuildCall(GenTreeCall* call)

// Set destination candidates for return value of the call.

if (hasMultiRegRetVal)
if (!hasMultiRegRetVal)
{
assert(retTypeDesc != nullptr);
dstCandidates = retTypeDesc->GetABIReturnRegs(call->GetUnmanagedCallConv());
}
else if (varTypeUsesFloatArgReg(registerType))
{
dstCandidates = RBM_FLOATRET;
}
else if (registerType == TYP_LONG)
{
dstCandidates = RBM_LNGRET;
}
else
{
dstCandidates = RBM_INTRET;
if (varTypeUsesFloatArgReg(registerType))
{
singleDstCandidates = RBM_FLOATRET;
}
else if (registerType == TYP_LONG)
{
singleDstCandidates = RBM_LNGRET;
}
else
{
singleDstCandidates = RBM_INTRET;
}
}

// First, count reg args
Expand Down Expand Up @@ -872,7 +870,25 @@ int LinearScan::BuildCall(GenTreeCall* call)

// Now generate defs and kills.
regMaskTP killMask = getKillSetForCall(call);
BuildDefsWithKills(call, dstCount, dstCandidates, killMask);
if (dstCount > 0)
{
if (hasMultiRegRetVal)
{
assert(retTypeDesc != nullptr);
regMaskTP multiDstCandidates = retTypeDesc->GetABIReturnRegs(call->GetUnmanagedCallConv());
assert(genCountBits(multiDstCandidates) > 0);
BuildCallDefsWithKills(call, dstCount, multiDstCandidates, killMask);
}
else
{
assert(dstCount == 1);
BuildDefWithKills(call, singleDstCandidates, killMask);
}
}
else
{
BuildKills(call, killMask);
}

// No args are placed in registers anymore.
placedArgRegs = RBM_NONE;
Expand Down Expand Up @@ -1189,7 +1205,7 @@ int LinearScan::BuildBlockStore(GenTreeBlk* blkNode)

buildInternalRegisterUses();
regMaskTP killMask = getKillSetForBlockStore(blkNode);
BuildDefsWithKills(blkNode, 0, RBM_NONE, killMask);
BuildKills(blkNode, killMask);
return useCount;
}

Expand Down