mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Added VarArgs
This commit is contained in:
parent
fd1d9644f7
commit
9ccdf7282e
8 changed files with 228 additions and 26 deletions
|
@ -770,8 +770,11 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
|
|||
anyIsExtension = true;
|
||||
}
|
||||
|
||||
bool hadEnoughArgs = newMethodInstance->GetParamCount() - newImplicitParamCount < (int)mArguments.size();
|
||||
bool prevHadEnoughArgs = prevMethodInstance->GetParamCount() - prevImplicitParamCount < (int)mArguments.size();
|
||||
int newMethodParamCount = newMethodInstance->GetParamCount();
|
||||
int prevMethodParamCount = prevMethodInstance->GetParamCount();
|
||||
|
||||
bool hadEnoughArgs = newMethodParamCount - newImplicitParamCount < (int)mArguments.size();
|
||||
bool prevHadEnoughArgs = prevMethodParamCount - prevImplicitParamCount < (int)mArguments.size();
|
||||
RETURN_BETTER_OR_WORSE(hadEnoughArgs, prevHadEnoughArgs);
|
||||
|
||||
bool chainSkip = (newMethodInstance->mChainType == BfMethodChainType_ChainMember) || (newMethodInstance->mChainType == BfMethodChainType_ChainSkip);
|
||||
|
@ -808,6 +811,11 @@ void BfMethodMatcher::CompareMethods(BfMethodInstance* prevMethodInstance, BfTyp
|
|||
int newArgIdx = argIdx + newImplicitParamCount;
|
||||
int prevArgIdx = argIdx + prevImplicitParamCount;
|
||||
|
||||
if (newArgIdx >= newMethodParamCount)
|
||||
break;
|
||||
if (prevArgIdx >= prevMethodParamCount)
|
||||
break;
|
||||
|
||||
bool wasGenericParam = (newArgIdx >= 0) && newMethodInstance->WasGenericParam(newArgIdx);
|
||||
bool prevWasGenericParam = (prevArgIdx >= 0) && prevMethodInstance->WasGenericParam(prevArgIdx);
|
||||
|
||||
|
|
|
@ -456,7 +456,10 @@ enum BfIRIntrinsic : uint8
|
|||
BfIRIntrinsic_Shuffle,
|
||||
BfIRIntrinsic_Sin,
|
||||
BfIRIntrinsic_Sqrt,
|
||||
BfIRIntrinsic_Sub,
|
||||
BfIRIntrinsic_Sub,
|
||||
BfIRIntrinsic_VAArg,
|
||||
BfIRIntrinsic_VAEnd,
|
||||
BfIRIntrinsic_VAStart,
|
||||
BfIRIntrinsic_Xor,
|
||||
|
||||
BfIRIntrinsic_COUNT,
|
||||
|
|
|
@ -189,6 +189,9 @@ static const BuiltinEntry gIntrinEntries[] =
|
|||
{"sin"},
|
||||
{"sqrt"},
|
||||
{"sub"},
|
||||
{"va_arg"},
|
||||
{"va_end"},
|
||||
{"va_start"},
|
||||
{"xor"},
|
||||
};
|
||||
|
||||
|
@ -2631,6 +2634,9 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
{ llvm::Intrinsic::sin, 0, -1},
|
||||
{ llvm::Intrinsic::sqrt, 0, -1},
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // sub,
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // va_arg,
|
||||
{ llvm::Intrinsic::vaend, -1}, // va_end,
|
||||
{ llvm::Intrinsic::vastart, -1}, // va_start,
|
||||
{ (llvm::Intrinsic::ID)-2, -1}, // xor
|
||||
};
|
||||
BF_STATIC_ASSERT(BF_ARRAY_COUNT(intrinsics) == BfIRIntrinsic_COUNT);
|
||||
|
@ -3451,6 +3457,16 @@ void BfIRCodeGen::HandleNextCmd()
|
|||
}
|
||||
}
|
||||
break;
|
||||
case BfIRIntrinsic_VAArg:
|
||||
{
|
||||
auto constInt = llvm::dyn_cast<llvm::ConstantInt>(args[2]);
|
||||
auto argType = GetLLVMTypeById((int)constInt->getSExtValue());
|
||||
auto vaArgVal = mIRBuilder->CreateVAArg(args[0], argType);
|
||||
|
||||
auto resultPtr = mIRBuilder->CreateBitCast(args[1], argType->getPointerTo());
|
||||
mIRBuilder->CreateStore(vaArgVal, resultPtr);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FatalError("Unhandled intrinsic");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue