mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Arithmetic overflow checks
This commit is contained in:
parent
1f0d2dcc82
commit
eb375362a1
29 changed files with 503 additions and 87 deletions
|
@ -590,6 +590,11 @@ void BeIRCodeGen::Read(bool& val)
|
|||
BE_MEM_END("bool");
|
||||
}
|
||||
|
||||
void BeIRCodeGen::Read(int8& val)
|
||||
{
|
||||
val = mStream->Read();
|
||||
}
|
||||
|
||||
void BeIRCodeGen::Read(BeIRTypeEntry*& type)
|
||||
{
|
||||
BE_MEM_START;
|
||||
|
@ -1432,21 +1437,24 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
{
|
||||
CMD_PARAM(BeValue*, lhs);
|
||||
CMD_PARAM(BeValue*, rhs);
|
||||
SetResult(curId, mBeModule->CreateBinaryOp(BeBinaryOpKind_Add, lhs, rhs));
|
||||
CMD_PARAM(int8, overflowCheckKind);
|
||||
SetResult(curId, mBeModule->CreateBinaryOp(BeBinaryOpKind_Add, lhs, rhs, (BfOverflowCheckKind)overflowCheckKind));
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_Sub:
|
||||
{
|
||||
CMD_PARAM(BeValue*, lhs);
|
||||
CMD_PARAM(BeValue*, rhs);
|
||||
SetResult(curId, mBeModule->CreateBinaryOp(BeBinaryOpKind_Subtract, lhs, rhs));
|
||||
CMD_PARAM(int8, overflowCheckKind);
|
||||
SetResult(curId, mBeModule->CreateBinaryOp(BeBinaryOpKind_Subtract, lhs, rhs, (BfOverflowCheckKind)overflowCheckKind));
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_Mul:
|
||||
{
|
||||
CMD_PARAM(BeValue*, lhs);
|
||||
CMD_PARAM(BeValue*, rhs);
|
||||
SetResult(curId, mBeModule->CreateBinaryOp(BeBinaryOpKind_Multiply, lhs, rhs));
|
||||
CMD_PARAM(int8, overflowCheckKind);
|
||||
SetResult(curId, mBeModule->CreateBinaryOp(BeBinaryOpKind_Multiply, lhs, rhs, (BfOverflowCheckKind)overflowCheckKind));
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_SDiv:
|
||||
|
@ -2100,6 +2108,11 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
mBeModule->RemoveBlock(mActiveFunction, fromBlock);
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_GetInsertBlock:
|
||||
{
|
||||
SetResult(curId, mBeModule->mActiveBlock);
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_SetInsertPoint:
|
||||
{
|
||||
CMD_PARAM(BeBlock*, block);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue