mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Added const evals for IsNull
This commit is contained in:
parent
df2c110de2
commit
f04da6d826
1 changed files with 22 additions and 0 deletions
|
@ -4237,6 +4237,17 @@ BfIRValue BfIRBuilder::CreateInBoundsGEP(BfIRValue val, BfIRValue idx0, BfIRValu
|
|||
|
||||
BfIRValue BfIRBuilder::CreateIsNull(BfIRValue val)
|
||||
{
|
||||
auto constant = GetConstant(val);
|
||||
if (constant != NULL)
|
||||
{
|
||||
if (constant->mTypeCode == BfTypeCode_NullPtr)
|
||||
return CreateConst(BfTypeCode_Boolean, 1);
|
||||
if (constant->mConstType == BfConstType_BitCastNull)
|
||||
return CreateConst(BfTypeCode_Boolean, 1);
|
||||
if (constant->mConstType == BfConstType_GlobalVar)
|
||||
return CreateConst(BfTypeCode_Boolean, 0);
|
||||
}
|
||||
|
||||
BfIRValue retVal = WriteCmd(BfIRCmd_IsNull, val);
|
||||
NEW_CMD_INSERTED_IRVALUE;
|
||||
return retVal;
|
||||
|
@ -4244,6 +4255,17 @@ BfIRValue BfIRBuilder::CreateIsNull(BfIRValue val)
|
|||
|
||||
BfIRValue BfIRBuilder::CreateIsNotNull(BfIRValue val)
|
||||
{
|
||||
auto constant = GetConstant(val);
|
||||
if (constant != NULL)
|
||||
{
|
||||
if (constant->mTypeCode == BfTypeCode_NullPtr)
|
||||
return CreateConst(BfTypeCode_Boolean, 0);
|
||||
if (constant->mConstType == BfConstType_BitCastNull)
|
||||
return CreateConst(BfTypeCode_Boolean, 0);
|
||||
if (constant->mConstType == BfConstType_GlobalVar)
|
||||
return CreateConst(BfTypeCode_Boolean, 1);
|
||||
}
|
||||
|
||||
BfIRValue retVal = WriteCmd(BfIRCmd_IsNotNull, val);
|
||||
NEW_CMD_INSERTED_IRVALUE;
|
||||
return retVal;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue