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

Wasm calling convention fixes. IDEHelper/Tests runs on wasm now.

This commit is contained in:
Brian Fiete 2024-10-25 11:20:01 -04:00
parent c0ebcc8fda
commit 31746c1f19
12 changed files with 99 additions and 13 deletions

View file

@ -14018,7 +14018,14 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr)
else if ((closureTypeInst != NULL) && (captureThisByValue))
{
// When we need to aggregrate a splat for a target, we just point out delegate's mTarget to inside ourselves where we aggregated the value
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, 1);
int dataIdx = 1;
if (!closureTypeInst->mFieldInstances.IsEmpty())
{
auto& fieldInst = closureTypeInst->mFieldInstances[0];
BF_ASSERT(fieldInst.GetFieldDef()->mName == "__this");
dataIdx = fieldInst.mDataIdx;
}
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, dataIdx);
target = mModule->LoadValue(target);
mModule->mBfIRBuilder->CreateStore(target.mValue, fieldPtr);
target = BfTypedValue(fieldPtr, target.mType, true);

View file

@ -1259,7 +1259,7 @@ void BfModule::SetupIRBuilder(bool dbgVerifyCodeGen)
//mBfIRBuilder->mDbgVerifyCodeGen = true;
if (
(mModuleName == "-")
|| (mModuleName == "")
//|| (mModuleName == "")
//|| (mModuleName == "Tests_FuncRefs")
)
mBfIRBuilder->mDbgVerifyCodeGen = true;

View file

@ -1801,11 +1801,11 @@ void BfTypeInstance::Dispose()
mTypeDef = NULL;
}
int BfTypeInstance::GetSplatCount()
int BfTypeInstance::GetSplatCount(bool force)
{
if (IsValuelessType())
return 0;
if (!mIsSplattable)
if ((!mIsSplattable) && (!force))
return 1;
int splatCount = 0;
BfTypeUtils::SplatIterate([&](BfType* checkType) { splatCount++; }, this);
@ -2048,6 +2048,30 @@ bool BfTypeInstance::GetLoweredType(BfTypeUsage typeUsage, BfTypeCode* outTypeCo
bool deepCheck = false;
if (mModule->mCompiler->mOptions.mMachineType == BfMachineType_Wasm32)
{
if (IsComposite())
{
if (GetSplatCount(true) == 1)
{
BfType* componentType = NULL;
BfTypeUtils::SplatIterate([&](BfType* checkType) { componentType = checkType; }, this);
if (componentType != NULL)
{
if (componentType->IsPrimitiveType())
{
auto primType = (BfPrimitiveType*)componentType;
if (outTypeCode != NULL)
*outTypeCode = primType->mTypeDef->mTypeCode;
return true;
}
}
}
else
return false;
}
}
if (mModule->mCompiler->mOptions.mPlatformType == BfPlatformType_Windows)
{
// Odd Windows rule: composite returns for non-static methods are always sret

View file

@ -553,7 +553,7 @@ public:
virtual bool IsSpecializedByAutoCompleteMethod() { return false; }
virtual bool IsUnspecializedTypeVariation() { return false; }
virtual bool IsSplattable() { return false; }
virtual int GetSplatCount() { return 1; }
virtual int GetSplatCount(bool force = false) { return 1; }
virtual bool IsVoid() { return false; }
virtual bool IsVoidPtr() { return false; }
virtual bool CanBeValuelessType() { return false; }
@ -2134,7 +2134,7 @@ public:
virtual bool IsFinishingType() override { return mIsFinishingType; }
virtual bool IsIncomplete() override { return (mTypeIncomplete) || (mBaseTypeMayBeIncomplete); }
virtual bool IsSplattable() override { BF_ASSERT((mInstSize >= 0) || (!IsComposite())); return mIsSplattable; }
virtual int GetSplatCount() override;
virtual int GetSplatCount(bool force = false) override;
virtual bool IsTypeInstance() override { return true; }
virtual BfTypeCode GetTypeCode() override { return mTypeDef->mTypeCode; }
virtual bool IsInterface() override { return mTypeDef->mTypeCode == BfTypeCode_Interface; }
@ -2465,7 +2465,7 @@ public:
virtual bool IsComposite() override { return true; }
virtual bool IsMethodRef() override { return true; }
virtual bool IsSplattable() override { return true; }
virtual int GetSplatCount() override { return (int)mDataToParamIdx.mSize; }
virtual int GetSplatCount(bool force) override { return (int)mDataToParamIdx.mSize; }
virtual bool IsOnDemand() override { return true; }
virtual bool IsTemporary() override { return true; }