| ... | ... | @@ -987,6 +987,22 @@ static LLVMValueRef get_coro_size_fn_val(CodeGen *g) { |
| 987 | 987 | return g->coro_size_fn_val; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | static LLVMValueRef get_coro_begin_fn_val(CodeGen *g) { |
| 991 | if (g->coro_begin_fn_val) |
| 992 | return g->coro_begin_fn_val; |
| 993 | |
| 994 | LLVMTypeRef param_types[] = { |
| 995 | ZigLLVMTokenTypeInContext(LLVMGetGlobalContext()), |
| 996 | LLVMPointerType(LLVMInt8Type(), 0), |
| 997 | }; |
| 998 | LLVMTypeRef fn_type = LLVMFunctionType(LLVMPointerType(LLVMInt8Type(), 0), param_types, 2, false); |
| 999 | Buf *name = buf_sprintf("llvm.coro.begin"); |
| 1000 | g->coro_begin_fn_val = LLVMAddFunction(g->module, buf_ptr(name), fn_type); |
| 1001 | assert(LLVMGetIntrinsicID(g->coro_begin_fn_val)); |
| 1002 | |
| 1003 | return g->coro_begin_fn_val; |
| 1004 | } |
| 1005 | |
| 990 | 1006 | static LLVMValueRef get_return_address_fn_val(CodeGen *g) { |
| 991 | 1007 | if (g->return_address_fn_val) |
| 992 | 1008 | return g->return_address_fn_val; |
| ... | ... | @@ -3808,7 +3824,13 @@ static LLVMValueRef ir_render_coro_size(CodeGen *g, IrExecutable *executable, Ir |
| 3808 | 3824 | } |
| 3809 | 3825 | |
| 3810 | 3826 | static LLVMValueRef ir_render_coro_begin(CodeGen *g, IrExecutable *executable, IrInstructionCoroBegin *instruction) { |
| 3811 | | zig_panic("TODO ir_render_coro_begin"); |
| 3827 | LLVMValueRef coro_id = ir_llvm_value(g, instruction->coro_id); |
| 3828 | LLVMValueRef coro_mem_ptr = ir_llvm_value(g, instruction->coro_mem_ptr); |
| 3829 | LLVMValueRef params[] = { |
| 3830 | coro_id, |
| 3831 | coro_mem_ptr, |
| 3832 | }; |
| 3833 | return LLVMBuildCall(g->builder, get_coro_begin_fn_val(g), params, 2, ""); |
| 3812 | 3834 | } |
| 3813 | 3835 | |
| 3814 | 3836 | static LLVMValueRef ir_render_coro_alloc_fail(CodeGen *g, IrExecutable *executable, |