authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-25 16:05:10-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-25 16:05:10-05:00
logbced3fb64cbb9006886bc237d959ce0f2ca3c3f7
tree62146aeffc2ad5cbc15e7fceff80946f73060caf
parent93cbd4eeb97f30062311d6e083dd056b8fb8b021

codegen for get_implicit_allocator instruction

See #727

1 files changed, 13 insertions(+), 3 deletions(-)

src/codegen.cpp+13-3
......@@ -2568,6 +2568,11 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
25682568 }
25692569}
25702570
2571static bool get_prefix_arg_err_ret_stack(CodeGen *g, TypeTableEntry *src_return_type) {
2572 return g->have_err_ret_tracing &&
2573 (src_return_type->id == TypeTableEntryIdErrorUnion || src_return_type->id == TypeTableEntryIdErrorSet);
2574}
2575
25712576static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstructionCall *instruction) {
25722577 LLVMValueRef fn_val;
25732578 TypeTableEntry *fn_type;
......@@ -2587,7 +2592,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
25872592
25882593 bool first_arg_ret = ret_has_bits && handle_is_ptr(src_return_type) &&
25892594 calling_convention_does_first_arg_return(fn_type->data.fn.fn_type_id.cc);
2590 bool prefix_arg_err_ret_stack = g->have_err_ret_tracing && (src_return_type->id == TypeTableEntryIdErrorUnion || src_return_type->id == TypeTableEntryIdErrorSet);
2595 bool prefix_arg_err_ret_stack = get_prefix_arg_err_ret_stack(g, src_return_type);
25912596 size_t actual_param_count = instruction->arg_count + (first_arg_ret ? 1 : 0) + (prefix_arg_err_ret_stack ? 1 : 0);
25922597 bool is_var_args = fn_type_id->is_var_args;
25932598 LLVMValueRef *gen_param_values = allocate<LLVMValueRef>(actual_param_count);
......@@ -3178,8 +3183,13 @@ static LLVMValueRef ir_render_cancel(CodeGen *g, IrExecutable *executable, IrIns
31783183 return nullptr;
31793184}
31803185
3181static LLVMValueRef ir_render_get_implicit_allocator(CodeGen *g, IrExecutable *executable, IrInstructionGetImplicitAllocator *instruction) {
3182 zig_panic("TODO ir_render_get_implicit_allocator");
3186static LLVMValueRef ir_render_get_implicit_allocator(CodeGen *g, IrExecutable *executable,
3187 IrInstructionGetImplicitAllocator *instruction)
3188{
3189 TypeTableEntry *src_return_type = g->cur_fn->type_entry->data.fn.fn_type_id.return_type;
3190 bool prefix_arg_err_ret_stack = get_prefix_arg_err_ret_stack(g, src_return_type);
3191 size_t allocator_arg_index = prefix_arg_err_ret_stack ? 1 : 0;
3192 return LLVMGetParam(g->cur_fn_val, allocator_arg_index);
31833193}
31843194
31853195static LLVMAtomicOrdering to_LLVMAtomicOrdering(AtomicOrder atomic_order) {