Fix error when boolean combined with ??. First checkin of C3 tester (unfinished)

This commit is contained in:
Christoffer Lerno
2025-02-19 01:02:58 +01:00
parent cbacd64987
commit d9e5926d57
8 changed files with 498 additions and 93 deletions

View File

@@ -1247,7 +1247,21 @@ void llvm_set_phi(LLVMValueRef phi, LLVMValueRef val1, LLVMBasicBlockRef block1,
void llvm_new_phi(GenContext *c, BEValue *value, const char *name, Type *type, LLVMValueRef val1, LLVMBasicBlockRef block1, LLVMValueRef val2, LLVMBasicBlockRef block2)
{
LLVMValueRef phi = LLVMBuildPhi(c->builder, LLVMTypeOf(val1), name);
LLVMTypeRef ret_type = LLVMTypeOf(val1);
LLVMTypeRef other_type = LLVMTypeOf(val2);
if (ret_type != other_type)
{
if (ret_type == c->bool_type)
{
val2 = LLVMBuildTrunc(c->builder, val2, ret_type, "");
}
else
{
assert(other_type == c->bool_type);
val2 = LLVMBuildZExt(c->builder, val2, ret_type, "");
}
}
LLVMValueRef phi = LLVMBuildPhi(c->builder, ret_type, name);
llvm_set_phi(phi, val1, block1, val2, block2);
llvm_value_set(value, phi, type);
}