diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-02-25 17:34:05 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-02-25 17:34:05 -0500 |
| commit | 83f89064490350991806aea02ea6ba4b948c0376 (patch) | |
| tree | 974070d5e0d3cd4251a699de9476b60e57502ce7 /src/codegen.cpp | |
| parent | 4eac75914bcdf9648518d1837f48e07e35744dc1 (diff) | |
| download | zig-83f89064490350991806aea02ea6ba4b948c0376.tar.gz zig-83f89064490350991806aea02ea6ba4b948c0376.zip | |
codegen for coro_resume instruction
See #727
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 163e9d804b..0c4f66daa4 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1051,6 +1051,21 @@ static LLVMValueRef get_coro_free_fn_val(CodeGen *g) { return g->coro_free_fn_val; } +static LLVMValueRef get_coro_resume_fn_val(CodeGen *g) { + if (g->coro_resume_fn_val) + return g->coro_resume_fn_val; + + LLVMTypeRef param_types[] = { + LLVMPointerType(LLVMInt8Type(), 0), + }; + LLVMTypeRef fn_type = LLVMFunctionType(LLVMVoidType(), param_types, 1, false); + Buf *name = buf_sprintf("llvm.coro.resume"); + g->coro_resume_fn_val = LLVMAddFunction(g->module, buf_ptr(name), fn_type); + assert(LLVMGetIntrinsicID(g->coro_resume_fn_val)); + + return g->coro_resume_fn_val; +} + static LLVMValueRef get_return_address_fn_val(CodeGen *g) { if (g->return_address_fn_val) return g->return_address_fn_val; @@ -3935,7 +3950,8 @@ static LLVMValueRef ir_render_coro_free(CodeGen *g, IrExecutable *executable, Ir } static LLVMValueRef ir_render_coro_resume(CodeGen *g, IrExecutable *executable, IrInstructionCoroResume *instruction) { - zig_panic("TODO ir_render_coro_resume"); + LLVMValueRef awaiter_handle = ir_llvm_value(g, instruction->awaiter_handle); + return LLVMBuildCall(g->builder, get_coro_resume_fn_val(g), &awaiter_handle, 1, ""); } static void set_debug_location(CodeGen *g, IrInstruction *instruction) { |
