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

Added a 'cast' intrinsic

This commit is contained in:
Brian Fiete 2020-02-19 13:16:33 -08:00
parent 660e7d8125
commit 1f20d76f94
14 changed files with 75 additions and 22 deletions

View file

@ -1902,7 +1902,9 @@ void BeIRCodeGen::HandleNextCmd()
case BfIRCmd_GetIntrinsic:
{
CMD_PARAM(int, intrinId);
CMD_PARAM(BeType*, returnType);
CMD_PARAM(CmdParamVec<BeType*>, paramTypes);
auto intrin = mBeModule->mAlloc.Alloc<BeIntrinsic>();
intrin->mKind = (BfIRIntrinsic)intrinId;
@ -1933,6 +1935,9 @@ void BeIRCodeGen::HandleNextCmd()
case BfIRIntrinsic_AtomicCmpStore:
case BfIRIntrinsic_AtomicCmpStore_Weak:
intrin->mReturnType = mBeContext->GetPrimitiveType(BeTypeCode_Boolean);
break;
case BfIRIntrinsic_Cast:
intrin->mReturnType = returnType;
break;
}

View file

@ -16209,6 +16209,15 @@ void BeMCContext::Generate(BeFunction* function)
result = scratchReg;
}
break;
case BfIRIntrinsic_Cast:
{
result = AllocVirtualReg(intrin->mReturnType);
CreateDefineVReg(result);
auto vregInfo = GetVRegInfo(result);
vregInfo->mRelTo = GetOperand(castedInst->mArgs[0].mValue);
vregInfo->mIsExpr = true;
}
break;
case BfIRIntrinsic_MemSet:
{
if (auto constVal = BeValueDynCast<BeConstant>(castedInst->mArgs[1].mValue))