diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-22 08:48:13 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-22 08:48:13 +0100 |
| commit | b09ea17f0ecbfc30d9f41bd450fd2010820db28c (patch) | |
| tree | d17452d66064610ec8f6f44697d9bb19f5d99ca2 /src/tilde_stmt.cpp | |
| parent | 99ebfc337e7dc3b103dcc77ce6609e4a1c44073f (diff) | |
Support multiple return values for non-odin calling conventions
Diffstat (limited to 'src/tilde_stmt.cpp')
| -rw-r--r-- | src/tilde_stmt.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/tilde_stmt.cpp b/src/tilde_stmt.cpp index 2cdedbacf..f0203e724 100644 --- a/src/tilde_stmt.cpp +++ b/src/tilde_stmt.cpp @@ -736,6 +736,20 @@ gb_internal cgAddr cg_add_local(cgProcedure *p, Type *type, Entity *e, bool zero return addr; } +gb_internal cgValue cg_copy_value_to_ptr(cgProcedure *p, cgValue value, Type *original_type, isize min_alignment) { + TB_CharUnits size = cast(TB_CharUnits)type_size_of(original_type); + TB_CharUnits align = cast(TB_CharUnits)gb_max(type_align_of(original_type), min_alignment); + TB_Node *copy = tb_inst_local(p->func, size, align); + if (value.kind == cgValue_Value) { + tb_inst_store(p->func, cg_data_type(original_type), copy, value.node, align, false); + } else { + GB_ASSERT(value.kind == cgValue_Addr); + tb_inst_memcpy(p->func, copy, value.node, tb_inst_uint(p->func, TB_TYPE_INT, size), align, false); + } + + return cg_value(copy, alloc_type_pointer(original_type)); +} + gb_internal cgValue cg_address_from_load_or_generate_local(cgProcedure *p, cgValue value) { switch (value.kind) { case cgValue_Value: |