From 7d9a9a2283c6c0cbd1e1034b2496d4898335beb0 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 12 Jan 2020 13:53:51 +0000 Subject: Add extra check for opaque types --- src/ir.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index 2de2b2669..8af0b85bd 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4713,6 +4713,10 @@ irValue *ir_emit_struct_ep(irProcedure *proc, irValue *s, i32 index) { Type *t = base_type(type_deref(ir_type(s))); Type *result_type = nullptr; + if (t->kind == Type_Opaque) { + t = t->Opaque.elem; + } + if (is_type_struct(t)) { result_type = alloc_type_pointer(t->Struct.fields[index]->type); } else if (is_type_union(t)) { @@ -4896,6 +4900,9 @@ irValue *ir_emit_deep_field_gep(irProcedure *proc, irValue *e, Selection sel) { // e = ir_emit_ptr_offset(proc, e, v_zero); // TODO(bill): Do I need these copies? } type = core_type(type); + if (type->kind == Type_Opaque) { + type = type->Opaque.elem; + } if (is_type_quaternion(type)) { e = ir_emit_struct_ep(proc, e, index); -- cgit v1.2.3 From ae7cbd5171ef1ae1d27c354bab04c2e6d241176a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 14 Jan 2020 17:37:45 +0000 Subject: Add debug info for enumerated arrays --- src/ir.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index de7bfef82..4630153a0 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -2664,6 +2664,20 @@ irDebugInfo *ir_add_debug_info_type(irModule *module, Type *type, Entity *e, irD return di; } + if (is_type_enumerated_array(type)) { + irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_CompositeType); + di->CompositeType.size = ir_debug_size_bits(type); + di->CompositeType.align = ir_debug_align_bits(type); + di->CompositeType.tag = irDebugBasicEncoding_array_type; + di->CompositeType.array_count = (i32)type->EnumeratedArray.count; + + map_set(&module->debug_info, hash_type(type), di); + di->CompositeType.base_type = ir_add_debug_info_type(module, type->EnumeratedArray.elem, e, scope, file); + GB_ASSERT(base->kind != Type_Named); + + return di; + } + if (is_type_slice(type)) { // NOTE(lachsinc): Every slice type has its own composite type / field debug infos created. This is sorta wasteful. irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_CompositeType); -- cgit v1.2.3 From 5db4bd99440c47506a6e22be193efdc235229772 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 15 Jan 2020 12:01:29 +0000 Subject: Fix #536 --- src/ir.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index 4630153a0..04c57c37b 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3931,7 +3931,7 @@ irValue *ir_addr_get_ptr(irProcedure *proc, irAddr const &addr) { } irValue *ir_build_addr_ptr(irProcedure *proc, Ast *expr) { - irAddr const &addr = ir_build_addr(proc, expr); + irAddr addr = ir_build_addr(proc, expr); return ir_addr_get_ptr(proc, addr); } @@ -6609,7 +6609,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, Ast *expr, TypeAndValue tv, Bu case BuiltinProc_swizzle: { ir_emit_comment(proc, str_lit("swizzle.begin")); - irAddr const &addr = ir_build_addr(proc, ce->args[0]); + irAddr addr = ir_build_addr(proc, ce->args[0]); isize index_count = ce->args.count-1; if (index_count == 0) { return ir_addr_load(proc, addr); @@ -7730,7 +7730,13 @@ bool ir_is_elem_const(irModule *m, Ast *elem, Type *elem_type) { irAddr ir_build_addr_from_entity(irProcedure *proc, Entity *e, Ast *expr) { GB_ASSERT(e != nullptr); - GB_ASSERT(e->kind != Entity_Constant); + if (e->kind == Entity_Constant) { + Type *t = default_type(type_of_expr(expr)); + irValue *v = ir_add_module_constant(proc->module, t, e->Constant.value); + irValue *g = ir_add_global_generated(proc->module, ir_type(v), v); + return ir_addr(g); + } + irValue *v = nullptr; irValue **found = map_get(&proc->module->values, hash_entity(e)); @@ -7837,7 +7843,7 @@ irAddr ir_build_addr(irProcedure *proc, Ast *expr) { if (sel.entity->type->kind == Type_BitFieldValue) { - irAddr const &addr = ir_build_addr(proc, se->expr); + irAddr addr = ir_build_addr(proc, se->expr); Type *bft = type_deref(ir_addr_type(addr)); if (sel.index.count == 1) { GB_ASSERT(is_type_bit_field(bft)); @@ -9921,7 +9927,7 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) { case Type_Map: { is_map = true; gbAllocator a = ir_allocator(); - irAddr const &addr = ir_build_addr(proc, expr); + irAddr addr = ir_build_addr(proc, expr); irValue *map = ir_addr_get_ptr(proc, addr); if (is_type_pointer(type_deref(ir_addr_type(addr)))) { map = ir_addr_load(proc, addr); -- cgit v1.2.3