authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-25 20:29:14-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-25 20:29:14-05:00
log6fef7406c80d6db26513a6ae53f9c44444bef1f2
treee0cc3e8583dfe4a4a648c217cb4371323cad9299
parent6b436146a8065b3e19c11359df85a44dac269730

move coroutine init code to after coro.begin


1 files changed, 13 insertions(+), 12 deletions(-)

src/ir.cpp+13-12
...@@ -5995,19 +5995,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec...@@ -5995,19 +5995,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
5995 return_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;5995 return_type = fn_entry->type_entry->data.fn.fn_type_id.return_type;
5996 IrInstruction *promise_init = ir_build_const_promise_init(irb, scope, node, return_type);5996 IrInstruction *promise_init = ir_build_const_promise_init(irb, scope, node, return_type);
5997 ir_build_var_decl(irb, scope, node, promise_var, nullptr, nullptr, promise_init);5997 ir_build_var_decl(irb, scope, node, promise_var, nullptr, nullptr, promise_init);
5998
5999 coro_promise_ptr = ir_build_var_ptr(irb, scope, node, promise_var, false, false);5998 coro_promise_ptr = ir_build_var_ptr(irb, scope, node, promise_var, false, false);
6000 Buf *awaiter_handle_field_name = buf_create_from_str(AWAITER_HANDLE_FIELD_NAME);
6001 irb->exec->coro_awaiter_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr,
6002 awaiter_handle_field_name);
6003 if (type_has_bits(return_type)) {
6004 Buf *result_field_name = buf_create_from_str(RESULT_FIELD_NAME);
6005 coro_result_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, result_field_name);
6006 result_ptr_field_name = buf_create_from_str(RESULT_PTR_FIELD_NAME);
6007 irb->exec->coro_result_ptr_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr,
6008 result_ptr_field_name);
6009 ir_build_store_ptr(irb, scope, node, irb->exec->coro_result_ptr_field_ptr, coro_result_field_ptr);
6010 }
60115999
6012 u8_ptr_type = ir_build_const_type(irb, scope, node,6000 u8_ptr_type = ir_build_const_type(irb, scope, node,
6013 get_pointer_to_type(irb->codegen, irb->codegen->builtin_types.entry_u8, false));6001 get_pointer_to_type(irb->codegen, irb->codegen->builtin_types.entry_u8, false));
...@@ -6076,6 +6064,19 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec...@@ -6076,6 +6064,19 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec
60766064
6077 irb->exec->coro_handle = ir_build_coro_begin(irb, scope, node, coro_id, coro_mem);6065 irb->exec->coro_handle = ir_build_coro_begin(irb, scope, node, coro_id, coro_mem);
60786066
6067 Buf *awaiter_handle_field_name = buf_create_from_str(AWAITER_HANDLE_FIELD_NAME);
6068 irb->exec->coro_awaiter_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr,
6069 awaiter_handle_field_name);
6070 if (type_has_bits(return_type)) {
6071 Buf *result_field_name = buf_create_from_str(RESULT_FIELD_NAME);
6072 coro_result_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, result_field_name);
6073 result_ptr_field_name = buf_create_from_str(RESULT_PTR_FIELD_NAME);
6074 irb->exec->coro_result_ptr_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr,
6075 result_ptr_field_name);
6076 ir_build_store_ptr(irb, scope, node, irb->exec->coro_result_ptr_field_ptr, coro_result_field_ptr);
6077 }
6078
6079
6079 irb->exec->coro_early_final = ir_create_basic_block(irb, scope, "CoroEarlyFinal");6080 irb->exec->coro_early_final = ir_create_basic_block(irb, scope, "CoroEarlyFinal");
6080 irb->exec->coro_normal_final = ir_create_basic_block(irb, scope, "CoroNormalFinal");6081 irb->exec->coro_normal_final = ir_create_basic_block(irb, scope, "CoroNormalFinal");
6081 }6082 }