From 11bd50f2b2a74ce25d841a15ba67d042d41b71c2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 21 Jul 2019 20:54:08 -0400 Subject: implement coroutine resume --- src/codegen.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 4a9e5fd629..fa5f3ef8ee 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -4969,6 +4969,18 @@ static LLVMValueRef ir_render_suspend_br(CodeGen *g, IrExecutable *executable, return nullptr; } +static LLVMValueRef ir_render_coro_resume(CodeGen *g, IrExecutable *executable, + IrInstructionCoroResume *instruction) +{ + LLVMValueRef frame = ir_llvm_value(g, instruction->frame); + ZigType *frame_type = instruction->frame->value.type; + assert(frame_type->id == ZigTypeIdCoroFrame); + ZigFn *fn = frame_type->data.frame.fn; + LLVMValueRef fn_val = fn_llvm_value(g, fn); + LLVMBuildCall(g->builder, fn_val, &frame, 1, ""); + return nullptr; +} + static void set_debug_location(CodeGen *g, IrInstruction *instruction) { AstNode *source_node = instruction->source_node; Scope *scope = instruction->scope; @@ -5213,6 +5225,8 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, return ir_render_suspend_begin(g, executable, (IrInstructionSuspendBegin *)instruction); case IrInstructionIdSuspendBr: return ir_render_suspend_br(g, executable, (IrInstructionSuspendBr *)instruction); + case IrInstructionIdCoroResume: + return ir_render_coro_resume(g, executable, (IrInstructionCoroResume *)instruction); } zig_unreachable(); } -- cgit v1.2.3