| ... | @@ -1035,6 +1035,22 @@ static LLVMValueRef get_coro_end_fn_val(CodeGen *g) { | ... | @@ -1035,6 +1035,22 @@ static LLVMValueRef get_coro_end_fn_val(CodeGen *g) { |
| 1035 | return g->coro_end_fn_val; | 1035 | return g->coro_end_fn_val; |
| 1036 | } | 1036 | } |
| 1037 | | 1037 | |
| | 1038 | static LLVMValueRef get_coro_free_fn_val(CodeGen *g) { |
| | 1039 | if (g->coro_free_fn_val) |
| | 1040 | return g->coro_free_fn_val; |
| | 1041 | |
| | 1042 | LLVMTypeRef param_types[] = { |
| | 1043 | ZigLLVMTokenTypeInContext(LLVMGetGlobalContext()), |
| | 1044 | LLVMPointerType(LLVMInt8Type(), 0), |
| | 1045 | }; |
| | 1046 | LLVMTypeRef fn_type = LLVMFunctionType(LLVMPointerType(LLVMInt8Type(), 0), param_types, 2, false); |
| | 1047 | Buf *name = buf_sprintf("llvm.coro.free"); |
| | 1048 | g->coro_free_fn_val = LLVMAddFunction(g->module, buf_ptr(name), fn_type); |
| | 1049 | assert(LLVMGetIntrinsicID(g->coro_free_fn_val)); |
| | 1050 | |
| | 1051 | return g->coro_free_fn_val; |
| | 1052 | } |
| | 1053 | |
| 1038 | static LLVMValueRef get_return_address_fn_val(CodeGen *g) { | 1054 | static LLVMValueRef get_return_address_fn_val(CodeGen *g) { |
| 1039 | if (g->return_address_fn_val) | 1055 | if (g->return_address_fn_val) |
| 1040 | return g->return_address_fn_val; | 1056 | return g->return_address_fn_val; |
| ... | @@ -3909,7 +3925,13 @@ static LLVMValueRef ir_render_coro_end(CodeGen *g, IrExecutable *executable, IrI | ... | @@ -3909,7 +3925,13 @@ static LLVMValueRef ir_render_coro_end(CodeGen *g, IrExecutable *executable, IrI |
| 3909 | } | 3925 | } |
| 3910 | | 3926 | |
| 3911 | static LLVMValueRef ir_render_coro_free(CodeGen *g, IrExecutable *executable, IrInstructionCoroFree *instruction) { | 3927 | static LLVMValueRef ir_render_coro_free(CodeGen *g, IrExecutable *executable, IrInstructionCoroFree *instruction) { |
| 3912 | zig_panic("TODO ir_render_coro_free"); | 3928 | LLVMValueRef coro_id = ir_llvm_value(g, instruction->coro_id); |
| | 3929 | LLVMValueRef coro_handle = ir_llvm_value(g, instruction->coro_handle); |
| | 3930 | LLVMValueRef params[] = { |
| | 3931 | coro_id, |
| | 3932 | coro_handle, |
| | 3933 | }; |
| | 3934 | return LLVMBuildCall(g->builder, get_coro_free_fn_val(g), params, 2, ""); |
| 3913 | } | 3935 | } |
| 3914 | | 3936 | |
| 3915 | static LLVMValueRef ir_render_coro_resume(CodeGen *g, IrExecutable *executable, IrInstructionCoroResume *instruction) { | 3937 | static LLVMValueRef ir_render_coro_resume(CodeGen *g, IrExecutable *executable, IrInstructionCoroResume *instruction) { |