@@ -1019,6 +1019,22 @@ static LLVMValueRef get_coro_suspend_fn_val(CodeGen *g) {
1019
1019
return g->coro_suspend_fn_val ;
1020
1020
}
1021
1021
1022
+ static LLVMValueRef get_coro_end_fn_val (CodeGen *g) {
1023
+ if (g->coro_end_fn_val )
1024
+ return g->coro_end_fn_val ;
1025
+
1026
+ LLVMTypeRef param_types[] = {
1027
+ LLVMPointerType (LLVMInt8Type (), 0 ),
1028
+ LLVMInt1Type (),
1029
+ };
1030
+ LLVMTypeRef fn_type = LLVMFunctionType (LLVMInt1Type (), param_types, 2 , false );
1031
+ Buf *name = buf_sprintf (" llvm.coro.end" );
1032
+ g->coro_end_fn_val = LLVMAddFunction (g->module , buf_ptr (name), fn_type);
1033
+ assert (LLVMGetIntrinsicID (g->coro_end_fn_val ));
1034
+
1035
+ return g->coro_end_fn_val ;
1036
+ }
1037
+
1022
1038
static LLVMValueRef get_return_address_fn_val (CodeGen *g) {
1023
1039
if (g->return_address_fn_val )
1024
1040
return g->return_address_fn_val ;
@@ -3885,7 +3901,11 @@ static LLVMValueRef ir_render_coro_suspend(CodeGen *g, IrExecutable *executable,
3885
3901
}
3886
3902
3887
3903
static LLVMValueRef ir_render_coro_end (CodeGen *g, IrExecutable *executable, IrInstructionCoroEnd *instruction) {
3888
- zig_panic (" TODO ir_render_coro_end" );
3904
+ LLVMValueRef params[] = {
3905
+ LLVMConstNull (LLVMPointerType (LLVMInt8Type (), 0 )),
3906
+ LLVMConstNull (LLVMInt1Type ()),
3907
+ };
3908
+ return LLVMBuildCall (g->builder , get_coro_end_fn_val (g), params, 2 , " " );
3889
3909
}
3890
3910
3891
3911
static LLVMValueRef ir_render_coro_free (CodeGen *g, IrExecutable *executable, IrInstructionCoroFree *instruction) {
0 commit comments