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...@@ -2568,6 +2568,11 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
2568 }2568 }
2569}2569}
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
2571static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstructionCall *instruction) {2576static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstructionCall *instruction) {
2572 LLVMValueRef fn_val;2577 LLVMValueRef fn_val;
2573 TypeTableEntry *fn_type;2578 TypeTableEntry *fn_type;
...@@ -2587,7 +2592,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -2587,7 +2592,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
25872592
2588 bool first_arg_ret = ret_has_bits && handle_is_ptr(src_return_type) &&2593 bool first_arg_ret = ret_has_bits && handle_is_ptr(src_return_type) &&
2589 calling_convention_does_first_arg_return(fn_type->data.fn.fn_type_id.cc);2594 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);
2591 size_t actual_param_count = instruction->arg_count + (first_arg_ret ? 1 : 0) + (prefix_arg_err_ret_stack ? 1 : 0);2596 size_t actual_param_count = instruction->arg_count + (first_arg_ret ? 1 : 0) + (prefix_arg_err_ret_stack ? 1 : 0);
2592 bool is_var_args = fn_type_id->is_var_args;2597 bool is_var_args = fn_type_id->is_var_args;
2593 LLVMValueRef *gen_param_values = allocate<LLVMValueRef>(actual_param_count);2598 LLVMValueRef *gen_param_values = allocate<LLVMValueRef>(actual_param_count);
...@@ -3178,8 +3183,13 @@ static LLVMValueRef ir_render_cancel(CodeGen *g, IrExecutable *executable, IrIns...@@ -3178,8 +3183,13 @@ static LLVMValueRef ir_render_cancel(CodeGen *g, IrExecutable *executable, IrIns
3178 return nullptr;3183 return nullptr;
3179}3184}
31803185
3181static LLVMValueRef ir_render_get_implicit_allocator(CodeGen *g, IrExecutable *executable, IrInstructionGetImplicitAllocator *instruction) {3186static LLVMValueRef ir_render_get_implicit_allocator(CodeGen *g, IrExecutable *executable,
3182 zig_panic("TODO ir_render_get_implicit_allocator");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);
3183}3193}
31843194
3185static LLVMAtomicOrdering to_LLVMAtomicOrdering(AtomicOrder atomic_order) {3195static LLVMAtomicOrdering to_LLVMAtomicOrdering(AtomicOrder atomic_order) {