diff options
| author | gingerBill <bill@gingerbill.org> | 2020-01-15 12:01:29 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-01-15 12:01:29 +0000 |
| commit | 5db4bd99440c47506a6e22be193efdc235229772 (patch) | |
| tree | e02236cc07e1a9dc4b453525fc01cefa295a0319 | |
| parent | 20b410f149645e02d53fc05bc794fad44f2db5ee (diff) | |
Fix #536
| -rw-r--r-- | src/ir.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
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); |