1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 12:02:21 +02:00

Reworking some lowering logic

This commit is contained in:
Brian Fiete 2020-05-04 09:11:36 -07:00
parent ae3ea7f209
commit 63e51ec4d8
2 changed files with 32 additions and 16 deletions

View file

@ -4955,7 +4955,7 @@ void BfExprEvaluator::PushThis(BfAstNode* targetSrc, BfTypedValue argVal, BfMeth
if (argVal.mType->IsValuelessType()) if (argVal.mType->IsValuelessType())
return; return;
if ((argVal.mType->IsTypedPrimitive()) && (!methodInstance->AllowsThisSplatting())) if (!methodInstance->AllowsThisSplatting())
{ {
argVal = mModule->MakeAddressable(argVal); argVal = mModule->MakeAddressable(argVal);
irArgs.push_back(argVal.mValue); irArgs.push_back(argVal.mValue);
@ -5010,7 +5010,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
if (!mModule->mCompiler->mIsResolveOnly) if (!mModule->mCompiler->mIsResolveOnly)
sCallIdx++; sCallIdx++;
int callIdx = sCallIdx; int callIdx = sCallIdx;
if (callIdx == 7462) if (callIdx == 44)
{ {
NOP; NOP;
} }

View file

@ -940,7 +940,33 @@ void BfMethodInstance::GetIRFunctionInfo(BfModule* module, BfIRType& returnType,
checkType = GetParamType(paramIdx); checkType = GetParamType(paramIdx);
} }
if ((paramIdx != -1) || (!mMethodDef->mNoSplat && !mMethodDef->mIsMutating))
bool checkLowered = false;
bool doSplat = false;
if (paramIdx == -1)
{
if ((checkType->IsSplattable()) && (AllowsThisSplatting()))
{
doSplat = true;
}
else if (!mMethodDef->mIsMutating)
checkLowered = true;
}
else
{
if (checkType->IsMethodRef())
{
doSplat = true;
}
else if ((checkType->IsSplattable()) && (AllowsSplatting()))
{
doSplat = true;
}
else
checkLowered = true;
}
if (checkLowered)
{ {
auto loweredTypeCode = checkType->GetLoweredType(); auto loweredTypeCode = checkType->GetLoweredType();
if (loweredTypeCode != BfTypeCode_None) if (loweredTypeCode != BfTypeCode_None)
@ -960,20 +986,10 @@ void BfMethodInstance::GetIRFunctionInfo(BfModule* module, BfIRType& returnType,
module->PopulateType(checkType, BfPopulateType_Data); module->PopulateType(checkType, BfPopulateType_Data);
if ((checkType->IsValuelessType()) && (!checkType->IsMethodRef())) if ((checkType->IsValuelessType()) && (!checkType->IsMethodRef()))
continue; continue;
bool doSplat = false; if (doSplat)
if (checkType->IsMethodRef())
{ {
doSplat = true; int splatCount = checkType->GetSplatCount();
}
else if (mMethodDef->mNoSplat)
{
doSplat = false;
}
else if ((paramIdx == -1) ? AllowsThisSplatting() : AllowsSplatting())
{
int splatCount = checkType->GetSplatCount();
doSplat = ((checkType->IsSplattable()) && ((paramIdx != -1) || (!mMethodDef->mIsMutating)));
if ((int)paramTypes.size() + splatCount > module->mCompiler->mOptions.mMaxSplatRegs) if ((int)paramTypes.size() + splatCount > module->mCompiler->mOptions.mMaxSplatRegs)
{ {
auto checkTypeInst = checkType->ToTypeInstance(); auto checkTypeInst = checkType->ToTypeInstance();