authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-25 16:15:14-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-25 16:15:14-05:00
log79f1ff574b3badf7cf0a0cd7632c529801b4c611
treec891a66cc0440e3fff7e90c6b8cf6e9cfb6c6c1f
parentbced3fb64cbb9006886bc237d959ce0f2ca3c3f7

codegen for coro_alloc_fail instruction

See #727

1 files changed, 18 insertions(+), 2 deletions(-)

src/codegen.cpp+18-2
...@@ -3811,8 +3811,24 @@ static LLVMValueRef ir_render_coro_begin(CodeGen *g, IrExecutable *executable, I...@@ -3811,8 +3811,24 @@ static LLVMValueRef ir_render_coro_begin(CodeGen *g, IrExecutable *executable, I
3811 zig_panic("TODO ir_render_coro_begin");3811 zig_panic("TODO ir_render_coro_begin");
3812}3812}
38133813
3814static LLVMValueRef ir_render_coro_alloc_fail(CodeGen *g, IrExecutable *executable, IrInstructionCoroAllocFail *instruction) {3814static LLVMValueRef ir_render_coro_alloc_fail(CodeGen *g, IrExecutable *executable,
3815 zig_panic("TODO ir_render_coro_alloc_fail");3815 IrInstructionCoroAllocFail *instruction)
3816{
3817 TypeTableEntry *src_return_type = g->cur_fn->type_entry->data.fn.fn_type_id.return_type;
3818 bool prefix_arg_err_ret_stack = get_prefix_arg_err_ret_stack(g, src_return_type);
3819 size_t err_code_ptr_arg_index = prefix_arg_err_ret_stack ? 2 : 1;
3820 LLVMValueRef err_code_ptr_val = LLVMGetParam(g->cur_fn_val, err_code_ptr_arg_index);
3821 LLVMValueRef err_code = ir_llvm_value(g, instruction->err_val);
3822 LLVMBuildStore(g->builder, err_code, err_code_ptr_val);
3823
3824 LLVMValueRef return_value;
3825 if (ir_want_runtime_safety(g, &instruction->base)) {
3826 return_value = LLVMConstNull(LLVMPointerType(LLVMInt8Type(), 0));
3827 } else {
3828 return_value = LLVMGetUndef(LLVMPointerType(LLVMInt8Type(), 0));
3829 }
3830 LLVMBuildRet(g->builder, return_value);
3831 return nullptr;
3816}3832}
38173833
3818static LLVMValueRef ir_render_coro_suspend(CodeGen *g, IrExecutable *executable, IrInstructionCoroSuspend *instruction) {3834static LLVMValueRef ir_render_coro_suspend(CodeGen *g, IrExecutable *executable, IrInstructionCoroSuspend *instruction) {