mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Comptime math and bug fixes
This commit is contained in:
parent
621fe99882
commit
61f54a4f88
14 changed files with 684 additions and 122 deletions
|
@ -2673,6 +2673,15 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
SetResult(curId, mBeModule->GetInsertBlock());
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_Comptime_Error:
|
||||
{
|
||||
CMD_PARAM(int32, error);
|
||||
|
||||
auto inst = mBeModule->AllocInst<BeComptimeError>();
|
||||
inst->mError = error;
|
||||
SetResult(curId, inst);
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_Comptime_GetBfType:
|
||||
{
|
||||
CMD_PARAM(int32, typeId);
|
||||
|
|
|
@ -16364,11 +16364,33 @@ void BeMCContext::Generate(BeFunction* function)
|
|||
auto mcLHS = GetOperand(castedInst->mLHS);
|
||||
auto mcRHS = GetOperand(castedInst->mRHS);
|
||||
|
||||
auto valType = castedInst->mLHS->GetType();
|
||||
|
||||
auto mcInst = AllocInst(BeMCInstKind_Cmp, mcLHS, mcRHS);
|
||||
|
||||
auto cmpResultIdx = (int)mCmpResults.size();
|
||||
BeCmpResult cmpResult;
|
||||
cmpResult.mCmpKind = castedInst->mCmpKind;
|
||||
cmpResult.mCmpKind = castedInst->mCmpKind;
|
||||
|
||||
if (valType->IsFloat())
|
||||
{
|
||||
switch (cmpResult.mCmpKind)
|
||||
{
|
||||
case BeCmpKind_SLT:
|
||||
cmpResult.mCmpKind = BeCmpKind_ULT;
|
||||
break;
|
||||
case BeCmpKind_SLE:
|
||||
cmpResult.mCmpKind = BeCmpKind_ULE;
|
||||
break;
|
||||
case BeCmpKind_SGT:
|
||||
cmpResult.mCmpKind = BeCmpKind_UGT;
|
||||
break;
|
||||
case BeCmpKind_SGE:
|
||||
cmpResult.mCmpKind = BeCmpKind_UGE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mCmpResults.push_back(cmpResult);
|
||||
|
||||
result.mKind = BeMCOperandKind_CmpResult;
|
||||
|
|
|
@ -2451,6 +2451,7 @@ String BeModule::ToString(BeFunction* wantFunc)
|
|||
}
|
||||
}
|
||||
break;
|
||||
DISPLAY_INST1(BeComptimeError, "ComptimeError", mError);
|
||||
DISPLAY_INST1(BeComptimeGetType, "ComptimeGetType", mTypeId);
|
||||
DISPLAY_INST1(BeComptimeGetReflectType, "ComptimeGetReflectType", mTypeId);
|
||||
DISPLAY_INST2(BeComptimeDynamicCastCheck, "ComptimeDynamicCastCheck", mValue, mTypeId);
|
||||
|
|
|
@ -1348,6 +1348,22 @@ public:
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class BeComptimeError : public BeInst
|
||||
{
|
||||
public:
|
||||
BE_VALUE_TYPE(BeComptimeError, BeInst);
|
||||
|
||||
public:
|
||||
int mError;
|
||||
|
||||
public:
|
||||
virtual void HashInst(BeHashContext& hashCtx) override
|
||||
{
|
||||
hashCtx.Mixin(TypeId);
|
||||
hashCtx.Mixin(mError);
|
||||
}
|
||||
};
|
||||
|
||||
class BeComptimeGetType : public BeInst
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue