diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-28 14:11:00 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-28 14:11:00 +0100 |
| commit | b41f09b73000f45963c445f7b2b56e2adb96a00b (patch) | |
| tree | e5e8bae0c5fc3e0def4d9442ebbcdc4a97550e5d /src/check_expr.c | |
| parent | 06185e176988085ed7e77793f128b9e431eedd5e (diff) | |
Experimental try for ABI for return values on windows
It's all done by reverse engineering it. I may be wrong...
Diffstat (limited to 'src/check_expr.c')
| -rw-r--r-- | src/check_expr.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/check_expr.c b/src/check_expr.c index 0ee819913..ec13d26b0 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -1217,6 +1217,29 @@ Type *type_to_abi_compat_result_type(gbAllocator a, Type *original_type) { return new_type; } +bool abi_compat_return_by_value(gbAllocator a, ProcCallingConvention cc, Type *abi_return_type) { + if (abi_return_type == NULL) { + return false; + } + if (cc == ProcCC_Odin) { + return false; + } + + if (str_eq(build_context.ODIN_OS, str_lit("windows"))) { + i64 size = 8*type_size_of(a, abi_return_type); + switch (size) { + case 0: + case 8: + case 16: + case 32: + case 64: + return false; + default: + return true; + } + } + return false; +} void check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node) { ast_node(pt, ProcType, proc_type_node); @@ -1248,6 +1271,7 @@ void check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node) { // NOTE(bill): The types are the same type->Proc.abi_compat_result_type = type_to_abi_compat_result_type(c->allocator, type->Proc.results); + type->Proc.return_by_pointer = abi_compat_return_by_value(c->allocator, pt->calling_convention, type->Proc.abi_compat_result_type); } |