aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-02-14 11:11:05 +0000
committergingerBill <bill@gingerbill.org>2019-02-14 11:11:05 +0000
commitdbd06388538b3ba38ab4e5d03c4bc695854f5ff0 (patch)
tree87161ae27a60f789ee1f9308d9dcb32b74c05976
parent53d8216311b07237b3a5a6b821c7c5c9c6fdee5c (diff)
Fix untyped ternary string IR conversion
-rw-r--r--core/mem/allocators.odin2
-rw-r--r--src/ir.cpp9
2 files changed, 10 insertions, 1 deletions
diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin
index af6ed329a..6dafe18c0 100644
--- a/core/mem/allocators.odin
+++ b/core/mem/allocators.odin
@@ -381,6 +381,8 @@ small_stack_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
return nil;
}
+ alignment = clamp(alignment, 1, 8*size_of(Stack_Allocation_Header{}.padding)/2);
+
raw_alloc :: proc(s: ^Small_Stack, size, alignment: int) -> rawptr {
curr_addr := uintptr(&s.data[0]) + uintptr(s.offset);
padding := calc_padding_with_header(curr_addr, uintptr(alignment), size_of(Small_Stack_Allocation_Header));
diff --git a/src/ir.cpp b/src/ir.cpp
index aca3c3ce9..bdccaa5a6 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -4644,6 +4644,7 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, 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));
@@ -4906,7 +4907,13 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
return ir_emit_load(proc, result);
}
-
+ if (is_type_untyped(src)) {
+ if (is_type_string(src) && is_type_string(dst)) {
+ irValue *result = ir_add_local_generated(proc, t, false);
+ ir_emit_store(proc, result, value);
+ return ir_emit_load(proc, result);
+ }
+ }
gb_printf_err("ir_emit_conv: src -> dst\n");
gb_printf_err("Not Identical %s != %s\n", type_to_string(src_type), type_to_string(t));