mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Modify boolean conversion in IR
This commit is contained in:
+11
-2
@@ -3023,8 +3023,7 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// integer -> integer
|
// integer -> integer
|
||||||
if ((is_type_integer(src) && is_type_integer(dst)) ||
|
if (is_type_integer(src) && is_type_integer(dst)) {
|
||||||
(is_type_boolean(src) && is_type_boolean(dst))) {
|
|
||||||
GB_ASSERT(src->kind == Type_Basic &&
|
GB_ASSERT(src->kind == Type_Basic &&
|
||||||
dst->kind == Type_Basic);
|
dst->kind == Type_Basic);
|
||||||
i64 sz = type_size_of(proc->module->allocator, default_type(src));
|
i64 sz = type_size_of(proc->module->allocator, default_type(src));
|
||||||
@@ -3048,6 +3047,16 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
|||||||
return ir_emit(proc, ir_instr_conv(proc, kind, value, src_type, t));
|
return ir_emit(proc, ir_instr_conv(proc, kind, value, src_type, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// boolean -> boolean
|
||||||
|
if (is_type_boolean(src) && is_type_boolean(dst)) {
|
||||||
|
GB_ASSERT(src->kind == Type_Basic &&
|
||||||
|
dst->kind == Type_Basic);
|
||||||
|
GB_ASSERT(src != t_llvm_bool);
|
||||||
|
|
||||||
|
irValue *b = ir_emit(proc, ir_instr_binary_op(proc, Token_NotEq, value, v_zero, t_llvm_bool));
|
||||||
|
return ir_emit(proc, ir_instr_conv(proc, irConv_zext, b, t_llvm_bool, t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// boolean -> integer
|
// boolean -> integer
|
||||||
if (is_type_boolean(src) && is_type_integer(dst)) {
|
if (is_type_boolean(src) && is_type_integer(dst)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user