mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-13 06:41:26 -07:00
Specific sized booleans: b8, b16, b32, b64
This commit is contained in:
+15
-9
@@ -3019,8 +3019,18 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
// bool <-> llvm bool
|
||||
if (is_type_boolean(src) && dst == t_llvm_bool) {
|
||||
return ir_emit(proc, ir_instr_conv(proc, irConv_trunc, value, src_type, t));
|
||||
}
|
||||
if (src == t_llvm_bool && is_type_boolean(dst)) {
|
||||
return ir_emit(proc, ir_instr_conv(proc, irConv_zext, value, src_type, t));
|
||||
}
|
||||
|
||||
// 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 &&
|
||||
dst->kind == Type_Basic);
|
||||
i64 sz = type_size_of(proc->module->allocator, default_type(src));
|
||||
@@ -3044,13 +3054,6 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
||||
return ir_emit(proc, ir_instr_conv(proc, kind, value, src_type, t));
|
||||
}
|
||||
|
||||
// bool <-> llvm bool
|
||||
if (is_type_boolean(src) && dst == t_llvm_bool) {
|
||||
return ir_emit(proc, ir_instr_conv(proc, irConv_trunc, value, src_type, t));
|
||||
}
|
||||
if (src == t_llvm_bool && is_type_boolean(dst)) {
|
||||
return ir_emit(proc, ir_instr_conv(proc, irConv_zext, value, src_type, t));
|
||||
}
|
||||
|
||||
// boolean -> integer
|
||||
if (is_type_boolean(src) && is_type_integer(dst)) {
|
||||
@@ -3062,7 +3065,6 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
|
||||
return ir_emit_comp(proc, Token_NotEq, value, v_zero);
|
||||
}
|
||||
|
||||
|
||||
// float -> float
|
||||
if (is_type_float(src) && is_type_float(dst)) {
|
||||
gbAllocator a = proc->module->allocator;
|
||||
@@ -7870,6 +7872,10 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
|
||||
ir_emit_comment(proc, str_lit("Type_Info_Basic"));
|
||||
switch (t->Basic.kind) {
|
||||
case Basic_bool:
|
||||
case Basic_b8:
|
||||
case Basic_b16:
|
||||
case Basic_b32:
|
||||
case Basic_b64:
|
||||
tag = ir_emit_conv(proc, variant_ptr, t_type_info_boolean_ptr);
|
||||
break;
|
||||
|
||||
|
||||
+6
-2
@@ -269,8 +269,12 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t, bool in_struct) {
|
||||
switch (t->kind) {
|
||||
case Type_Basic:
|
||||
switch (t->Basic.kind) {
|
||||
case Basic_bool: ir_write_string(f, "i8"); return;
|
||||
case Basic_llvm_bool: ir_write_string(f, "i1"); return;
|
||||
case Basic_llvm_bool: ir_write_string(f, "i1"); return;
|
||||
case Basic_bool: ir_write_string(f, "i8"); return;
|
||||
case Basic_b8: ir_write_string(f, "i8"); return;
|
||||
case Basic_b16: ir_write_string(f, "i16"); return;
|
||||
case Basic_b32: ir_write_string(f, "i32"); return;
|
||||
case Basic_b64: ir_write_string(f, "i64"); return;
|
||||
|
||||
case Basic_i8: ir_write_string(f, "i8"); return;
|
||||
case Basic_u8: ir_write_string(f, "i8"); return;
|
||||
|
||||
@@ -6,6 +6,11 @@ enum BasicKind {
|
||||
|
||||
Basic_llvm_bool,
|
||||
Basic_bool,
|
||||
Basic_b8,
|
||||
Basic_b16,
|
||||
Basic_b32,
|
||||
Basic_b64,
|
||||
|
||||
Basic_i8,
|
||||
Basic_u8,
|
||||
Basic_i16,
|
||||
@@ -238,6 +243,10 @@ gb_global Type basic_types[] = {
|
||||
{Type_Basic, {Basic_llvm_bool, BasicFlag_Boolean, 1, STR_LIT("llvm bool")}},
|
||||
|
||||
{Type_Basic, {Basic_bool, BasicFlag_Boolean, 1, STR_LIT("bool")}},
|
||||
{Type_Basic, {Basic_b8, BasicFlag_Boolean, 1, STR_LIT("b8")}},
|
||||
{Type_Basic, {Basic_b16, BasicFlag_Boolean, 2, STR_LIT("b16")}},
|
||||
{Type_Basic, {Basic_b32, BasicFlag_Boolean, 4, STR_LIT("b32")}},
|
||||
{Type_Basic, {Basic_b64, BasicFlag_Boolean, 8, STR_LIT("b64")}},
|
||||
|
||||
{Type_Basic, {Basic_i8, BasicFlag_Integer, 1, STR_LIT("i8")}},
|
||||
{Type_Basic, {Basic_u8, BasicFlag_Integer | BasicFlag_Unsigned, 1, STR_LIT("u8")}},
|
||||
|
||||
Reference in New Issue
Block a user