authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-27 18:40:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-28 12:58:40-07:00
logb11ac9c5bfb4048eb4aa561f8b3b058a76787f7e
tree53ac787d868ca852bbbf854b829dfd3e4296cd8c
parente072ace436e3bfda18cde71492380f863e51cc61

stage1: move some mutable state from Stage1Zir to IrAnalyze

This is progress towards making Stage1Zir immutable, so that we can avoid generating it for every comptime function call. Also rename IrExecutableGen to Stage1Air.

9 files changed, 157 insertions(+), 178 deletions(-)

src/stage1/all_types.hpp+5-14
...@@ -51,7 +51,7 @@ struct ResultLocPeerParent;...@@ -51,7 +51,7 @@ struct ResultLocPeerParent;
51struct ResultLocBitCast;51struct ResultLocBitCast;
52struct ResultLocCast;52struct ResultLocCast;
53struct ResultLocReturn;53struct ResultLocReturn;
54struct IrExecutableGen;54struct Stage1Air;
5555
56enum FileExt {56enum FileExt {
57 FileExtUnknown,57 FileExtUnknown,
...@@ -116,19 +116,14 @@ struct Stage1Zir {...@@ -116,19 +116,14 @@ struct Stage1Zir {
116 ZigFn *name_fn;116 ZigFn *name_fn;
117 size_t mem_slot_count;117 size_t mem_slot_count;
118 size_t next_debug_id;118 size_t next_debug_id;
119 size_t *backward_branch_count;
120 size_t *backward_branch_quota;
121 ZigFn *fn_entry;119 ZigFn *fn_entry;
122 Buf *c_import_buf;120 Buf *c_import_buf;
123 AstNode *source_node;121 AstNode *source_node;
124 IrExecutableGen *parent_exec;
125 IrAnalyze *analysis;
126 Scope *begin_scope;122 Scope *begin_scope;
127 ErrorMsg *first_err_trace_msg;123 ErrorMsg *first_err_trace_msg;
128 ZigList<Tld *> tld_list;124 ZigList<Tld *> tld_list;
129125
130 bool is_inline;126 bool is_inline;
131 bool is_generic_instantiation;
132 bool need_err_code_spill;127 bool need_err_code_spill;
133128
134 // This is a function for use in the debugger to print129 // This is a function for use in the debugger to print
...@@ -136,25 +131,22 @@ struct Stage1Zir {...@@ -136,25 +131,22 @@ struct Stage1Zir {
136 void src();131 void src();
137};132};
138133
139struct IrExecutableGen {134struct Stage1Air {
140 ZigList<IrBasicBlockGen *> basic_block_list;135 ZigList<IrBasicBlockGen *> basic_block_list;
141 Buf *name;136 Buf *name;
142 ZigFn *name_fn;137 ZigFn *name_fn;
143 size_t mem_slot_count;138 size_t mem_slot_count;
144 size_t next_debug_id;139 size_t next_debug_id;
145 size_t *backward_branch_count;
146 size_t *backward_branch_quota;
147 ZigFn *fn_entry;140 ZigFn *fn_entry;
148 Buf *c_import_buf;141 Buf *c_import_buf;
149 AstNode *source_node;142 AstNode *source_node;
150 IrExecutableGen *parent_exec;143 Stage1Air *parent_exec;
151 Stage1Zir *source_exec;144 Stage1Zir *source_exec;
152 Scope *begin_scope;145 Scope *begin_scope;
153 ErrorMsg *first_err_trace_msg;146 ErrorMsg *first_err_trace_msg;
154 ZigList<Tld *> tld_list;147 ZigList<Tld *> tld_list;
155148
156 bool is_inline;149 bool is_inline;
157 bool is_generic_instantiation;
158 bool need_err_code_spill;150 bool need_err_code_spill;
159151
160 // This is a function for use in the debugger to print152 // This is a function for use in the debugger to print
...@@ -1652,9 +1644,8 @@ struct ZigFn {...@@ -1652,9 +1644,8 @@ struct ZigFn {
1652 // zig source code, not according to zig ir1644 // zig source code, not according to zig ir
1653 ZigType *src_implicit_return_type;1645 ZigType *src_implicit_return_type;
1654 Stage1Zir *ir_executable;1646 Stage1Zir *ir_executable;
1655 IrExecutableGen analyzed_executable;1647 Stage1Air analyzed_executable;
1656 size_t prealloc_bbc;1648 size_t branch_quota;
1657 size_t prealloc_backward_branch_quota;
1658 AstNode **param_source_nodes;1649 AstNode **param_source_nodes;
1659 Buf **param_names;1650 Buf **param_names;
1660 IrInstGen *err_code_spill;1651 IrInstGen *err_code_spill;
src/stage1/analyze.cpp+7-11
...@@ -3655,10 +3655,6 @@ static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) {...@@ -3655,10 +3655,6 @@ static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) {
3655 ZigFn *fn_entry = heap::c_allocator.create<ZigFn>();3655 ZigFn *fn_entry = heap::c_allocator.create<ZigFn>();
3656 fn_entry->ir_executable = heap::c_allocator.create<Stage1Zir>();3656 fn_entry->ir_executable = heap::c_allocator.create<Stage1Zir>();
36573657
3658 fn_entry->prealloc_backward_branch_quota = default_backward_branch_quota;
3659
3660 fn_entry->analyzed_executable.backward_branch_count = &fn_entry->prealloc_bbc;
3661 fn_entry->analyzed_executable.backward_branch_quota = &fn_entry->prealloc_backward_branch_quota;
3662 fn_entry->analyzed_executable.fn_entry = fn_entry;3658 fn_entry->analyzed_executable.fn_entry = fn_entry;
3663 fn_entry->ir_executable->fn_entry = fn_entry;3659 fn_entry->ir_executable->fn_entry = fn_entry;
3664 fn_entry->is_noinline = is_noinline;3660 fn_entry->is_noinline = is_noinline;
...@@ -5134,8 +5130,11 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn, AstNode *return_type_node) {...@@ -5134,8 +5130,11 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn, AstNode *return_type_node) {
5134 if (fn->analyzed_executable.source_node == nullptr) {5130 if (fn->analyzed_executable.source_node == nullptr) {
5135 fn->analyzed_executable.source_node = fn->body_node;5131 fn->analyzed_executable.source_node = fn->body_node;
5136 }5132 }
5137 ZigType *block_return_type = ir_analyze(g, fn->ir_executable,5133 size_t backward_branch_count = 0;
5138 &fn->analyzed_executable, fn_type_id->return_type, return_type_node, nullptr);5134 size_t backward_branch_quota = max(fn->branch_quota, default_backward_branch_quota);
5135 ZigType *block_return_type = ir_analyze(g, fn->ir_executable, &fn->analyzed_executable,
5136 &backward_branch_count, &backward_branch_quota,
5137 fn_type_id->return_type, return_type_node, nullptr);
5139 fn->src_implicit_return_type = block_return_type;5138 fn->src_implicit_return_type = block_return_type;
51405139
5141 if (type_is_invalid(block_return_type) || fn->analyzed_executable.first_err_trace_msg != nullptr) {5140 if (type_is_invalid(block_return_type) || fn->analyzed_executable.first_err_trace_msg != nullptr) {
...@@ -9866,13 +9865,10 @@ void Stage1Zir::src() {...@@ -9866,13 +9865,10 @@ void Stage1Zir::src() {
9866 if (this->source_node != nullptr) {9865 if (this->source_node != nullptr) {
9867 this->source_node->src();9866 this->source_node->src();
9868 }9867 }
9869 if (this->parent_exec != nullptr) {
9870 this->parent_exec->src();
9871 }
9872}9868}
98739869
9874void IrExecutableGen::src() {9870void Stage1Air::src() {
9875 IrExecutableGen *it;9871 Stage1Air *it;
9876 for (it = this; it != nullptr && it->source_node != nullptr; it = it->parent_exec) {9872 for (it = this; it != nullptr && it->source_node != nullptr; it = it->parent_exec) {
9877 it->source_node->src();9873 it->source_node->src();
9878 }9874 }
src/stage1/astgen.cpp+1-11
...@@ -41,19 +41,9 @@ static void ir_assert_impl(bool ok, IrInst *source_instruction, char const *file...@@ -41,19 +41,9 @@ static void ir_assert_impl(bool ok, IrInst *source_instruction, char const *file
41 src_assert_impl(ok, source_instruction->source_node, file, line);41 src_assert_impl(ok, source_instruction->source_node, file, line);
42}42}
4343
44static void ir_add_call_stack_errors(CodeGen *codegen, Stage1Zir *exec, ErrorMsg *err_msg, int limit) {
45 if (!exec || !exec->source_node || limit < 0) return;
46 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));
47
48 ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1);
49}
50
51static ErrorMsg *exec_add_error_node(CodeGen *codegen, Stage1Zir *exec, AstNode *source_node, Buf *msg) {44static ErrorMsg *exec_add_error_node(CodeGen *codegen, Stage1Zir *exec, AstNode *source_node, Buf *msg) {
52 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);45 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);
53 invalidate_exec(exec, err_msg);46 invalidate_exec(exec, err_msg);
54 if (exec->parent_exec) {
55 ir_add_call_stack_errors(codegen, exec, err_msg, 10);
56 }
57 return err_msg;47 return err_msg;
58}48}
5949
...@@ -8118,7 +8108,7 @@ AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) {...@@ -8118,7 +8108,7 @@ AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) {
8118 }8108 }
8119}8109}
81208110
8121void ir_add_call_stack_errors_gen(CodeGen *codegen, IrExecutableGen *exec, ErrorMsg *err_msg, int limit) {8111void ir_add_call_stack_errors_gen(CodeGen *codegen, Stage1Air *exec, ErrorMsg *err_msg, int limit) {
8122 if (!exec || !exec->source_node || limit < 0) return;8112 if (!exec || !exec->source_node || limit < 0) return;
8123 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));8113 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));
81248114
src/stage1/astgen.hpp+1-1
...@@ -24,7 +24,7 @@ ResultLoc *no_result_loc(void);...@@ -24,7 +24,7 @@ ResultLoc *no_result_loc(void);
24void invalidate_exec(Stage1Zir *exec, ErrorMsg *msg);24void invalidate_exec(Stage1Zir *exec, ErrorMsg *msg);
2525
26AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node);26AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node);
27void ir_add_call_stack_errors_gen(CodeGen *codegen, IrExecutableGen *exec, ErrorMsg *err_msg,27void ir_add_call_stack_errors_gen(CodeGen *codegen, Stage1Air *exec, ErrorMsg *err_msg,
28 int limit);28 int limit);
2929
30void destroy_instruction_src(IrInstSrc *inst);30void destroy_instruction_src(IrInstSrc *inst);
src/stage1/codegen.cpp+91-91
...@@ -2443,7 +2443,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {...@@ -2443,7 +2443,7 @@ static LLVMValueRef get_merge_err_ret_traces_fn_val(CodeGen *g) {
2443 return fn_val;2443 return fn_val;
24442444
2445}2445}
2446static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, IrExecutableGen *executable,2446static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, Stage1Air *executable,
2447 IrInstGenSaveErrRetAddr *save_err_ret_addr_instruction)2447 IrInstGenSaveErrRetAddr *save_err_ret_addr_instruction)
2448{2448{
2449 assert(g->have_err_ret_tracing);2449 assert(g->have_err_ret_tracing);
...@@ -2636,7 +2636,7 @@ static void gen_async_return(CodeGen *g, IrInstGenReturn *instruction) {...@@ -2636,7 +2636,7 @@ static void gen_async_return(CodeGen *g, IrInstGenReturn *instruction) {
2636 LLVMBuildRetVoid(g->builder);2636 LLVMBuildRetVoid(g->builder);
2637}2637}
26382638
2639static LLVMValueRef ir_render_return(CodeGen *g, IrExecutableGen *executable, IrInstGenReturn *instruction) {2639static LLVMValueRef ir_render_return(CodeGen *g, Stage1Air *executable, IrInstGenReturn *instruction) {
2640 if (fn_is_async(g->cur_fn)) {2640 if (fn_is_async(g->cur_fn)) {
2641 gen_async_return(g, instruction);2641 gen_async_return(g, instruction);
2642 return nullptr;2642 return nullptr;
...@@ -3061,7 +3061,7 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type...@@ -3061,7 +3061,7 @@ static void gen_shift_rhs_check(CodeGen *g, ZigType *lhs_type, ZigType *rhs_type
3061 }3061 }
3062}3062}
30633063
3064static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutableGen *executable,3064static LLVMValueRef ir_render_bin_op(CodeGen *g, Stage1Air *executable,
3065 IrInstGenBinOp *bin_op_instruction)3065 IrInstGenBinOp *bin_op_instruction)
3066{3066{
3067 IrBinOp op_id = bin_op_instruction->op_id;3067 IrBinOp op_id = bin_op_instruction->op_id;
...@@ -3283,7 +3283,7 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in...@@ -3283,7 +3283,7 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in
3283 }3283 }
3284}3284}
32853285
3286static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable,3286static LLVMValueRef ir_render_cast(CodeGen *g, Stage1Air *executable,
3287 IrInstGenCast *cast_instruction)3287 IrInstGenCast *cast_instruction)
3288{3288{
3289 Error err;3289 Error err;
...@@ -3367,7 +3367,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable,...@@ -3367,7 +3367,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable,
3367 zig_unreachable();3367 zig_unreachable();
3368}3368}
33693369
3370static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen *executable,3370static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, Stage1Air *executable,
3371 IrInstGenPtrOfArrayToSlice *instruction)3371 IrInstGenPtrOfArrayToSlice *instruction)
3372{3372{
3373 ZigType *actual_type = instruction->operand->value->type;3373 ZigType *actual_type = instruction->operand->value->type;
...@@ -3404,7 +3404,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen...@@ -3404,7 +3404,7 @@ static LLVMValueRef ir_render_ptr_of_array_to_slice(CodeGen *g, IrExecutableGen
3404 return result_loc;3404 return result_loc;
3405}3405}
34063406
3407static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutableGen *executable,3407static LLVMValueRef ir_render_ptr_cast(CodeGen *g, Stage1Air *executable,
3408 IrInstGenPtrCast *instruction)3408 IrInstGenPtrCast *instruction)
3409{3409{
3410 ZigType *wanted_type = instruction->base.value->type;3410 ZigType *wanted_type = instruction->base.value->type;
...@@ -3430,7 +3430,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutableGen *executable,...@@ -3430,7 +3430,7 @@ static LLVMValueRef ir_render_ptr_cast(CodeGen *g, IrExecutableGen *executable,
3430 return result_ptr;3430 return result_ptr;
3431}3431}
34323432
3433static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutableGen *executable,3433static LLVMValueRef ir_render_bit_cast(CodeGen *g, Stage1Air *executable,
3434 IrInstGenBitCast *instruction)3434 IrInstGenBitCast *instruction)
3435{3435{
3436 ZigType *wanted_type = instruction->base.value->type;3436 ZigType *wanted_type = instruction->base.value->type;
...@@ -3458,7 +3458,7 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutableGen *executable,...@@ -3458,7 +3458,7 @@ static LLVMValueRef ir_render_bit_cast(CodeGen *g, IrExecutableGen *executable,
3458 }3458 }
3459}3459}
34603460
3461static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *executable,3461static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, Stage1Air *executable,
3462 IrInstGenWidenOrShorten *instruction)3462 IrInstGenWidenOrShorten *instruction)
3463{3463{
3464 ZigType *actual_type = instruction->target->value->type;3464 ZigType *actual_type = instruction->target->value->type;
...@@ -3475,7 +3475,7 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *exec...@@ -3475,7 +3475,7 @@ static LLVMValueRef ir_render_widen_or_shorten(CodeGen *g, IrExecutableGen *exec
3475 instruction->base.value->type, target_val);3475 instruction->base.value->type, target_val);
3476}3476}
34773477
3478static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToPtr *instruction) {3478static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, Stage1Air *executable, IrInstGenIntToPtr *instruction) {
3479 ZigType *wanted_type = instruction->base.value->type;3479 ZigType *wanted_type = instruction->base.value->type;
3480 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);3480 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
3481 const uint32_t align_bytes = get_ptr_align(g, wanted_type);3481 const uint32_t align_bytes = get_ptr_align(g, wanted_type);
...@@ -3513,13 +3513,13 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable...@@ -3513,13 +3513,13 @@ static LLVMValueRef ir_render_int_to_ptr(CodeGen *g, IrExecutableGen *executable
3513 return LLVMBuildIntToPtr(g->builder, target_val, get_llvm_type(g, wanted_type), "");3513 return LLVMBuildIntToPtr(g->builder, target_val, get_llvm_type(g, wanted_type), "");
3514}3514}
35153515
3516static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, IrExecutableGen *executable, IrInstGenPtrToInt *instruction) {3516static LLVMValueRef ir_render_ptr_to_int(CodeGen *g, Stage1Air *executable, IrInstGenPtrToInt *instruction) {
3517 ZigType *wanted_type = instruction->base.value->type;3517 ZigType *wanted_type = instruction->base.value->type;
3518 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);3518 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
3519 return LLVMBuildPtrToInt(g->builder, target_val, get_llvm_type(g, wanted_type), "");3519 return LLVMBuildPtrToInt(g->builder, target_val, get_llvm_type(g, wanted_type), "");
3520}3520}
35213521
3522static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToEnum *instruction) {3522static LLVMValueRef ir_render_int_to_enum(CodeGen *g, Stage1Air *executable, IrInstGenIntToEnum *instruction) {
3523 ZigType *wanted_type = instruction->base.value->type;3523 ZigType *wanted_type = instruction->base.value->type;
3524 assert(wanted_type->id == ZigTypeIdEnum);3524 assert(wanted_type->id == ZigTypeIdEnum);
3525 ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type;3525 ZigType *tag_int_type = wanted_type->data.enumeration.tag_int_type;
...@@ -3559,7 +3559,7 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executabl...@@ -3559,7 +3559,7 @@ static LLVMValueRef ir_render_int_to_enum(CodeGen *g, IrExecutableGen *executabl
3559 return tag_int_value;3559 return tag_int_value;
3560}3560}
35613561
3562static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutableGen *executable, IrInstGenIntToErr *instruction) {3562static LLVMValueRef ir_render_int_to_err(CodeGen *g, Stage1Air *executable, IrInstGenIntToErr *instruction) {
3563 ZigType *wanted_type = instruction->base.value->type;3563 ZigType *wanted_type = instruction->base.value->type;
3564 assert(wanted_type->id == ZigTypeIdErrorSet);3564 assert(wanted_type->id == ZigTypeIdErrorSet);
35653565
...@@ -3576,7 +3576,7 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutableGen *executable...@@ -3576,7 +3576,7 @@ static LLVMValueRef ir_render_int_to_err(CodeGen *g, IrExecutableGen *executable
3576 return gen_widen_or_shorten(g, false, actual_type, g->err_tag_type, target_val);3576 return gen_widen_or_shorten(g, false, actual_type, g->err_tag_type, target_val);
3577}3577}
35783578
3579static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutableGen *executable, IrInstGenErrToInt *instruction) {3579static LLVMValueRef ir_render_err_to_int(CodeGen *g, Stage1Air *executable, IrInstGenErrToInt *instruction) {
3580 ZigType *wanted_type = instruction->base.value->type;3580 ZigType *wanted_type = instruction->base.value->type;
3581 assert(wanted_type->id == ZigTypeIdInt);3581 assert(wanted_type->id == ZigTypeIdInt);
3582 assert(!wanted_type->data.integral.is_signed);3582 assert(!wanted_type->data.integral.is_signed);
...@@ -3602,7 +3602,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutableGen *executable...@@ -3602,7 +3602,7 @@ static LLVMValueRef ir_render_err_to_int(CodeGen *g, IrExecutableGen *executable
3602 }3602 }
3603}3603}
36043604
3605static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutableGen *executable,3605static LLVMValueRef ir_render_unreachable(CodeGen *g, Stage1Air *executable,
3606 IrInstGenUnreachable *unreachable_instruction)3606 IrInstGenUnreachable *unreachable_instruction)
3607{3607{
3608 if (ir_want_runtime_safety(g, &unreachable_instruction->base)) {3608 if (ir_want_runtime_safety(g, &unreachable_instruction->base)) {
...@@ -3613,7 +3613,7 @@ static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutableGen *executabl...@@ -3613,7 +3613,7 @@ static LLVMValueRef ir_render_unreachable(CodeGen *g, IrExecutableGen *executabl
3613 return nullptr;3613 return nullptr;
3614}3614}
36153615
3616static LLVMValueRef ir_render_cond_br(CodeGen *g, IrExecutableGen *executable,3616static LLVMValueRef ir_render_cond_br(CodeGen *g, Stage1Air *executable,
3617 IrInstGenCondBr *cond_br_instruction)3617 IrInstGenCondBr *cond_br_instruction)
3618{3618{
3619 LLVMBuildCondBr(g->builder,3619 LLVMBuildCondBr(g->builder,
...@@ -3623,12 +3623,12 @@ static LLVMValueRef ir_render_cond_br(CodeGen *g, IrExecutableGen *executable,...@@ -3623,12 +3623,12 @@ static LLVMValueRef ir_render_cond_br(CodeGen *g, IrExecutableGen *executable,
3623 return nullptr;3623 return nullptr;
3624}3624}
36253625
3626static LLVMValueRef ir_render_br(CodeGen *g, IrExecutableGen *executable, IrInstGenBr *br_instruction) {3626static LLVMValueRef ir_render_br(CodeGen *g, Stage1Air *executable, IrInstGenBr *br_instruction) {
3627 LLVMBuildBr(g->builder, br_instruction->dest_block->llvm_block);3627 LLVMBuildBr(g->builder, br_instruction->dest_block->llvm_block);
3628 return nullptr;3628 return nullptr;
3629}3629}
36303630
3631static LLVMValueRef ir_render_binary_not(CodeGen *g, IrExecutableGen *executable,3631static LLVMValueRef ir_render_binary_not(CodeGen *g, Stage1Air *executable,
3632 IrInstGenBinaryNot *inst)3632 IrInstGenBinaryNot *inst)
3633{3633{
3634 LLVMValueRef operand = ir_llvm_value(g, inst->operand);3634 LLVMValueRef operand = ir_llvm_value(g, inst->operand);
...@@ -3660,13 +3660,13 @@ static LLVMValueRef ir_gen_negation(CodeGen *g, IrInstGen *inst, IrInstGen *oper...@@ -3660,13 +3660,13 @@ static LLVMValueRef ir_gen_negation(CodeGen *g, IrInstGen *inst, IrInstGen *oper
3660 }3660 }
3661}3661}
36623662
3663static LLVMValueRef ir_render_negation(CodeGen *g, IrExecutableGen *executable,3663static LLVMValueRef ir_render_negation(CodeGen *g, Stage1Air *executable,
3664 IrInstGenNegation *inst)3664 IrInstGenNegation *inst)
3665{3665{
3666 return ir_gen_negation(g, &inst->base, inst->operand, inst->wrapping);3666 return ir_gen_negation(g, &inst->base, inst->operand, inst->wrapping);
3667}3667}
36683668
3669static LLVMValueRef ir_render_bool_not(CodeGen *g, IrExecutableGen *executable, IrInstGenBoolNot *instruction) {3669static LLVMValueRef ir_render_bool_not(CodeGen *g, Stage1Air *executable, IrInstGenBoolNot *instruction) {
3670 LLVMValueRef value = ir_llvm_value(g, instruction->value);3670 LLVMValueRef value = ir_llvm_value(g, instruction->value);
3671 LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(value));3671 LLVMValueRef zero = LLVMConstNull(LLVMTypeOf(value));
3672 return LLVMBuildICmp(g->builder, LLVMIntEQ, value, zero, "");3672 return LLVMBuildICmp(g->builder, LLVMIntEQ, value, zero, "");
...@@ -3680,14 +3680,14 @@ static void render_decl_var(CodeGen *g, ZigVar *var) {...@@ -3680,14 +3680,14 @@ static void render_decl_var(CodeGen *g, ZigVar *var) {
3680 gen_var_debug_decl(g, var);3680 gen_var_debug_decl(g, var);
3681}3681}
36823682
3683static LLVMValueRef ir_render_decl_var(CodeGen *g, IrExecutableGen *executable, IrInstGenDeclVar *instruction) {3683static LLVMValueRef ir_render_decl_var(CodeGen *g, Stage1Air *executable, IrInstGenDeclVar *instruction) {
3684 instruction->var->ptr_instruction = instruction->var_ptr;3684 instruction->var->ptr_instruction = instruction->var_ptr;
3685 instruction->var->did_the_decl_codegen = true;3685 instruction->var->did_the_decl_codegen = true;
3686 render_decl_var(g, instruction->var);3686 render_decl_var(g, instruction->var);
3687 return nullptr;3687 return nullptr;
3688}3688}
36893689
3690static LLVMValueRef ir_render_load_ptr(CodeGen *g, IrExecutableGen *executable,3690static LLVMValueRef ir_render_load_ptr(CodeGen *g, Stage1Air *executable,
3691 IrInstGenLoadPtr *instruction)3691 IrInstGenLoadPtr *instruction)
3692{3692{
3693 ZigType *child_type = instruction->base.value->type;3693 ZigType *child_type = instruction->base.value->type;
...@@ -3889,7 +3889,7 @@ static void gen_undef_init(CodeGen *g, ZigType *ptr_type, ZigType *value_type, L...@@ -3889,7 +3889,7 @@ static void gen_undef_init(CodeGen *g, ZigType *ptr_type, ZigType *value_type, L
3889 gen_assign_raw(g, ptr, ptr_type, zero);3889 gen_assign_raw(g, ptr, ptr_type, zero);
3890}3890}
38913891
3892static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenStorePtr *instruction) {3892static LLVMValueRef ir_render_store_ptr(CodeGen *g, Stage1Air *executable, IrInstGenStorePtr *instruction) {
3893 Error err;3893 Error err;
38943894
3895 ZigType *ptr_type = instruction->ptr->value->type;3895 ZigType *ptr_type = instruction->ptr->value->type;
...@@ -3921,7 +3921,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutableGen *executable,...@@ -3921,7 +3921,7 @@ static LLVMValueRef ir_render_store_ptr(CodeGen *g, IrExecutableGen *executable,
3921 return nullptr;3921 return nullptr;
3922}3922}
39233923
3924static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *executable,3924static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, Stage1Air *executable,
3925 IrInstGenVectorStoreElem *instruction)3925 IrInstGenVectorStoreElem *instruction)
3926{3926{
3927 LLVMValueRef vector_ptr = ir_llvm_value(g, instruction->vector_ptr);3927 LLVMValueRef vector_ptr = ir_llvm_value(g, instruction->vector_ptr);
...@@ -3934,7 +3934,7 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *exe...@@ -3934,7 +3934,7 @@ static LLVMValueRef ir_render_vector_store_elem(CodeGen *g, IrExecutableGen *exe
3934 return nullptr;3934 return nullptr;
3935}3935}
39363936
3937static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenVarPtr *instruction) {3937static LLVMValueRef ir_render_var_ptr(CodeGen *g, Stage1Air *executable, IrInstGenVarPtr *instruction) {
3938 Error err;3938 Error err;
39393939
3940 ZigType *ptr_type = instruction->base.value->type;3940 ZigType *ptr_type = instruction->base.value->type;
...@@ -3961,7 +3961,7 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, I...@@ -3961,7 +3961,7 @@ static LLVMValueRef ir_render_var_ptr(CodeGen *g, IrExecutableGen *executable, I
3961 get_llvm_type(g, ptr_type), "");3961 get_llvm_type(g, ptr_type), "");
3962}3962}
39633963
3964static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable,3964static LLVMValueRef ir_render_return_ptr(CodeGen *g, Stage1Air *executable,
3965 IrInstGenReturnPtr *instruction)3965 IrInstGenReturnPtr *instruction)
3966{3966{
3967 if (!type_has_bits(g, instruction->base.value->type))3967 if (!type_has_bits(g, instruction->base.value->type))
...@@ -3970,7 +3970,7 @@ static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable...@@ -3970,7 +3970,7 @@ static LLVMValueRef ir_render_return_ptr(CodeGen *g, IrExecutableGen *executable
3970 return g->cur_ret_ptr;3970 return g->cur_ret_ptr;
3971}3971}
39723972
3973static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutableGen *executable, IrInstGenElemPtr *instruction) {3973static LLVMValueRef ir_render_elem_ptr(CodeGen *g, Stage1Air *executable, IrInstGenElemPtr *instruction) {
3974 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr);3974 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->array_ptr);
3975 ZigType *array_ptr_type = instruction->array_ptr->value->type;3975 ZigType *array_ptr_type = instruction->array_ptr->value->type;
3976 assert(array_ptr_type->id == ZigTypeIdPointer);3976 assert(array_ptr_type->id == ZigTypeIdPointer);
...@@ -4222,7 +4222,7 @@ static void gen_init_stack_trace(CodeGen *g, LLVMValueRef trace_field_ptr, LLVMV...@@ -4222,7 +4222,7 @@ static void gen_init_stack_trace(CodeGen *g, LLVMValueRef trace_field_ptr, LLVMV
4222 LLVMBuildStore(g->builder, LLVMConstInt(usize_type_ref, stack_trace_ptr_count, false), addrs_len_ptr);4222 LLVMBuildStore(g->builder, LLVMConstInt(usize_type_ref, stack_trace_ptr_count, false), addrs_len_ptr);
4223}4223}
42244224
4225static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrInstGenCall *instruction) {4225static LLVMValueRef ir_render_call(CodeGen *g, Stage1Air *executable, IrInstGenCall *instruction) {
4226 Error err;4226 Error err;
42274227
4228 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;4228 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;
...@@ -4642,7 +4642,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn...@@ -4642,7 +4642,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutableGen *executable, IrIn
4642 }4642 }
4643}4643}
46444644
4645static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutableGen *executable,4645static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, Stage1Air *executable,
4646 IrInstGenStructFieldPtr *instruction)4646 IrInstGenStructFieldPtr *instruction)
4647{4647{
4648 Error err;4648 Error err;
...@@ -4693,7 +4693,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutableGen *exec...@@ -4693,7 +4693,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutableGen *exec
4693 return field_ptr_val;4693 return field_ptr_val;
4694}4694}
46954695
4696static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, IrExecutableGen *executable,4696static LLVMValueRef ir_render_union_field_ptr(CodeGen *g, Stage1Air *executable,
4697 IrInstGenUnionFieldPtr *instruction)4697 IrInstGenUnionFieldPtr *instruction)
4698{4698{
4699 if (instruction->base.value->special != ConstValSpecialRuntime)4699 if (instruction->base.value->special != ConstValSpecialRuntime)
...@@ -4793,7 +4793,7 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_...@@ -4793,7 +4793,7 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_
4793 return SIZE_MAX;4793 return SIZE_MAX;
4794}4794}
47954795
4796static LLVMValueRef ir_render_asm_gen(CodeGen *g, IrExecutableGen *executable, IrInstGenAsm *instruction) {4796static LLVMValueRef ir_render_asm_gen(CodeGen *g, Stage1Air *executable, IrInstGenAsm *instruction) {
4797 AstNode *asm_node = instruction->base.base.source_node;4797 AstNode *asm_node = instruction->base.base.source_node;
4798 assert(asm_node->type == NodeTypeAsmExpr);4798 assert(asm_node->type == NodeTypeAsmExpr);
4799 AstNodeAsmExpr *asm_expr = &asm_node->data.asm_expr;4799 AstNodeAsmExpr *asm_expr = &asm_node->data.asm_expr;
...@@ -4970,13 +4970,13 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueR...@@ -4970,13 +4970,13 @@ static LLVMValueRef gen_non_null_bit(CodeGen *g, ZigType *maybe_type, LLVMValueR
4970 return gen_load_untyped(g, maybe_field_ptr, 0, false, "");4970 return gen_load_untyped(g, maybe_field_ptr, 0, false, "");
4971}4971}
49724972
4973static LLVMValueRef ir_render_test_non_null(CodeGen *g, IrExecutableGen *executable,4973static LLVMValueRef ir_render_test_non_null(CodeGen *g, Stage1Air *executable,
4974 IrInstGenTestNonNull *instruction)4974 IrInstGenTestNonNull *instruction)
4975{4975{
4976 return gen_non_null_bit(g, instruction->value->value->type, ir_llvm_value(g, instruction->value));4976 return gen_non_null_bit(g, instruction->value->value->type, ir_llvm_value(g, instruction->value));
4977}4977}
49784978
4979static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *executable,4979static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, Stage1Air *executable,
4980 IrInstGenOptionalUnwrapPtr *instruction)4980 IrInstGenOptionalUnwrapPtr *instruction)
4981{4981{
4982 if (instruction->base.value->special != ConstValSpecialRuntime)4982 if (instruction->base.value->special != ConstValSpecialRuntime)
...@@ -5083,7 +5083,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn...@@ -5083,7 +5083,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn
5083 return fn_val;5083 return fn_val;
5084}5084}
50855085
5086static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutableGen *executable, IrInstGenClz *instruction) {5086static LLVMValueRef ir_render_clz(CodeGen *g, Stage1Air *executable, IrInstGenClz *instruction) {
5087 ZigType *int_type = instruction->op->value->type;5087 ZigType *int_type = instruction->op->value->type;
5088 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz);5088 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdClz);
5089 LLVMValueRef operand = ir_llvm_value(g, instruction->op);5089 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
...@@ -5095,7 +5095,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutableGen *executable, IrIns...@@ -5095,7 +5095,7 @@ static LLVMValueRef ir_render_clz(CodeGen *g, IrExecutableGen *executable, IrIns
5095 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);5095 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
5096}5096}
50975097
5098static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutableGen *executable, IrInstGenCtz *instruction) {5098static LLVMValueRef ir_render_ctz(CodeGen *g, Stage1Air *executable, IrInstGenCtz *instruction) {
5099 ZigType *int_type = instruction->op->value->type;5099 ZigType *int_type = instruction->op->value->type;
5100 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz);5100 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdCtz);
5101 LLVMValueRef operand = ir_llvm_value(g, instruction->op);5101 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
...@@ -5107,7 +5107,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutableGen *executable, IrIns...@@ -5107,7 +5107,7 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutableGen *executable, IrIns
5107 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);5107 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
5108}5108}
51095109
5110static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutableGen *executable, IrInstGenShuffleVector *instruction) {5110static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, Stage1Air *executable, IrInstGenShuffleVector *instruction) {
5111 uint64_t len_a = instruction->a->value->type->data.vector.len;5111 uint64_t len_a = instruction->a->value->type->data.vector.len;
5112 uint64_t len_mask = instruction->mask->value->type->data.vector.len;5112 uint64_t len_mask = instruction->mask->value->type->data.vector.len;
51135113
...@@ -5137,7 +5137,7 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutableGen *execut...@@ -5137,7 +5137,7 @@ static LLVMValueRef ir_render_shuffle_vector(CodeGen *g, IrExecutableGen *execut
5137 llvm_mask_value, "");5137 llvm_mask_value, "");
5138}5138}
51395139
5140static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutableGen *executable, IrInstGenSplat *instruction) {5140static LLVMValueRef ir_render_splat(CodeGen *g, Stage1Air *executable, IrInstGenSplat *instruction) {
5141 ZigType *result_type = instruction->base.value->type;5141 ZigType *result_type = instruction->base.value->type;
5142 ir_assert(result_type->id == ZigTypeIdVector, &instruction->base);5142 ir_assert(result_type->id == ZigTypeIdVector, &instruction->base);
5143 uint32_t len = result_type->data.vector.len;5143 uint32_t len = result_type->data.vector.len;
...@@ -5149,7 +5149,7 @@ static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutableGen *executable, IrI...@@ -5149,7 +5149,7 @@ static LLVMValueRef ir_render_splat(CodeGen *g, IrExecutableGen *executable, IrI
5149 return LLVMBuildShuffleVector(g->builder, op_vector, undef_vector, LLVMConstNull(mask_llvm_type), "");5149 return LLVMBuildShuffleVector(g->builder, op_vector, undef_vector, LLVMConstNull(mask_llvm_type), "");
5150}5150}
51515151
5152static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutableGen *executable, IrInstGenPopCount *instruction) {5152static LLVMValueRef ir_render_pop_count(CodeGen *g, Stage1Air *executable, IrInstGenPopCount *instruction) {
5153 ZigType *int_type = instruction->op->value->type;5153 ZigType *int_type = instruction->op->value->type;
5154 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);5154 LLVMValueRef fn_val = get_int_builtin_fn(g, int_type, BuiltinFnIdPopCount);
5155 LLVMValueRef operand = ir_llvm_value(g, instruction->op);5155 LLVMValueRef operand = ir_llvm_value(g, instruction->op);
...@@ -5157,7 +5157,7 @@ static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutableGen *executable,...@@ -5157,7 +5157,7 @@ static LLVMValueRef ir_render_pop_count(CodeGen *g, IrExecutableGen *executable,
5157 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);5157 return gen_widen_or_shorten(g, false, int_type, instruction->base.value->type, wrong_size_int);
5158}5158}
51595159
5160static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutableGen *executable, IrInstGenSwitchBr *instruction) {5160static LLVMValueRef ir_render_switch_br(CodeGen *g, Stage1Air *executable, IrInstGenSwitchBr *instruction) {
5161 ZigType *target_type = instruction->target_value->value->type;5161 ZigType *target_type = instruction->target_value->value->type;
5162 LLVMBasicBlockRef else_block = instruction->else_block->llvm_block;5162 LLVMBasicBlockRef else_block = instruction->else_block->llvm_block;
51635163
...@@ -5185,7 +5185,7 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutableGen *executable,...@@ -5185,7 +5185,7 @@ static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutableGen *executable,
5185 return nullptr;5185 return nullptr;
5186}5186}
51875187
5188static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrInstGenPhi *instruction) {5188static LLVMValueRef ir_render_phi(CodeGen *g, Stage1Air *executable, IrInstGenPhi *instruction) {
5189 if (!type_has_bits(g, instruction->base.value->type))5189 if (!type_has_bits(g, instruction->base.value->type))
5190 return nullptr;5190 return nullptr;
51915191
...@@ -5209,7 +5209,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrIns...@@ -5209,7 +5209,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutableGen *executable, IrIns
5209 return phi;5209 return phi;
5210}5210}
52115211
5212static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutableGen *executable, IrInstGenRef *instruction) {5212static LLVMValueRef ir_render_ref(CodeGen *g, Stage1Air *executable, IrInstGenRef *instruction) {
5213 if (!type_has_bits(g, instruction->base.value->type)) {5213 if (!type_has_bits(g, instruction->base.value->type)) {
5214 return nullptr;5214 return nullptr;
5215 }5215 }
...@@ -5229,7 +5229,7 @@ static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutableGen *executable, IrIns...@@ -5229,7 +5229,7 @@ static LLVMValueRef ir_render_ref(CodeGen *g, IrExecutableGen *executable, IrIns
5229 }5229 }
5230}5230}
52315231
5232static LLVMValueRef ir_render_err_name(CodeGen *g, IrExecutableGen *executable, IrInstGenErrName *instruction) {5232static LLVMValueRef ir_render_err_name(CodeGen *g, Stage1Air *executable, IrInstGenErrName *instruction) {
5233 assert(g->generate_error_name_table);5233 assert(g->generate_error_name_table);
5234 assert(g->errors_by_index.length > 0);5234 assert(g->errors_by_index.length > 0);
52355235
...@@ -5356,7 +5356,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {...@@ -5356,7 +5356,7 @@ static LLVMValueRef get_enum_tag_name_function(CodeGen *g, ZigType *enum_type) {
5356 return fn_val;5356 return fn_val;
5357}5357}
53585358
5359static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutableGen *executable,5359static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, Stage1Air *executable,
5360 IrInstGenTagName *instruction)5360 IrInstGenTagName *instruction)
5361{5361{
5362 ZigType *enum_type = instruction->target->value->type;5362 ZigType *enum_type = instruction->target->value->type;
...@@ -5369,7 +5369,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutableGen *executa...@@ -5369,7 +5369,7 @@ static LLVMValueRef ir_render_enum_tag_name(CodeGen *g, IrExecutableGen *executa
5369 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");5369 get_llvm_cc(g, CallingConventionUnspecified), ZigLLVM_CallAttrAuto, "");
5370}5370}
53715371
5372static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutableGen *executable,5372static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, Stage1Air *executable,
5373 IrInstGenFieldParentPtr *instruction)5373 IrInstGenFieldParentPtr *instruction)
5374{5374{
5375 ZigType *container_ptr_type = instruction->base.value->type;5375 ZigType *container_ptr_type = instruction->base.value->type;
...@@ -5396,7 +5396,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutableGen *exec...@@ -5396,7 +5396,7 @@ static LLVMValueRef ir_render_field_parent_ptr(CodeGen *g, IrExecutableGen *exec
5396 }5396 }
5397}5397}
53985398
5399static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutableGen *executable, IrInstGenAlignCast *instruction) {5399static LLVMValueRef ir_render_align_cast(CodeGen *g, Stage1Air *executable, IrInstGenAlignCast *instruction) {
5400 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);5400 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
5401 assert(target_val);5401 assert(target_val);
54025402
...@@ -5459,7 +5459,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutableGen *executable...@@ -5459,7 +5459,7 @@ static LLVMValueRef ir_render_align_cast(CodeGen *g, IrExecutableGen *executable
5459 return target_val;5459 return target_val;
5460}5460}
54615461
5462static LLVMValueRef ir_render_error_return_trace(CodeGen *g, IrExecutableGen *executable,5462static LLVMValueRef ir_render_error_return_trace(CodeGen *g, Stage1Air *executable,
5463 IrInstGenErrorReturnTrace *instruction)5463 IrInstGenErrorReturnTrace *instruction)
5464{5464{
5465 bool is_llvm_alloca;5465 bool is_llvm_alloca;
...@@ -5530,7 +5530,7 @@ static LLVMTypeRef get_atomic_abi_type(CodeGen *g, IrInstGen *instruction) {...@@ -5530,7 +5530,7 @@ static LLVMTypeRef get_atomic_abi_type(CodeGen *g, IrInstGen *instruction) {
5530 }5530 }
5531}5531}
55325532
5533static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutableGen *executable, IrInstGenCmpxchg *instruction) {5533static LLVMValueRef ir_render_cmpxchg(CodeGen *g, Stage1Air *executable, IrInstGenCmpxchg *instruction) {
5534 LLVMValueRef ptr_val = ir_llvm_value(g, instruction->ptr);5534 LLVMValueRef ptr_val = ir_llvm_value(g, instruction->ptr);
5535 LLVMValueRef cmp_val = ir_llvm_value(g, instruction->cmp_value);5535 LLVMValueRef cmp_val = ir_llvm_value(g, instruction->cmp_value);
5536 LLVMValueRef new_val = ir_llvm_value(g, instruction->new_value);5536 LLVMValueRef new_val = ir_llvm_value(g, instruction->new_value);
...@@ -5592,7 +5592,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutableGen *executable, I...@@ -5592,7 +5592,7 @@ static LLVMValueRef ir_render_cmpxchg(CodeGen *g, IrExecutableGen *executable, I
5592 return result_loc;5592 return result_loc;
5593}5593}
55945594
5595static LLVMValueRef ir_render_reduce(CodeGen *g, IrExecutableGen *executable, IrInstGenReduce *instruction) {5595static LLVMValueRef ir_render_reduce(CodeGen *g, Stage1Air *executable, IrInstGenReduce *instruction) {
5596 LLVMValueRef value = ir_llvm_value(g, instruction->value);5596 LLVMValueRef value = ir_llvm_value(g, instruction->value);
55975597
5598 ZigType *value_type = instruction->value->value->type;5598 ZigType *value_type = instruction->value->value->type;
...@@ -5656,13 +5656,13 @@ static LLVMValueRef ir_render_reduce(CodeGen *g, IrExecutableGen *executable, Ir...@@ -5656,13 +5656,13 @@ static LLVMValueRef ir_render_reduce(CodeGen *g, IrExecutableGen *executable, Ir
5656 return result_val;5656 return result_val;
5657}5657}
56585658
5659static LLVMValueRef ir_render_fence(CodeGen *g, IrExecutableGen *executable, IrInstGenFence *instruction) {5659static LLVMValueRef ir_render_fence(CodeGen *g, Stage1Air *executable, IrInstGenFence *instruction) {
5660 LLVMAtomicOrdering atomic_order = to_LLVMAtomicOrdering(instruction->order);5660 LLVMAtomicOrdering atomic_order = to_LLVMAtomicOrdering(instruction->order);
5661 LLVMBuildFence(g->builder, atomic_order, false, "");5661 LLVMBuildFence(g->builder, atomic_order, false, "");
5662 return nullptr;5662 return nullptr;
5663}5663}
56645664
5665static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutableGen *executable, IrInstGenTruncate *instruction) {5665static LLVMValueRef ir_render_truncate(CodeGen *g, Stage1Air *executable, IrInstGenTruncate *instruction) {
5666 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);5666 LLVMValueRef target_val = ir_llvm_value(g, instruction->target);
5667 ZigType *dest_type = instruction->base.value->type;5667 ZigType *dest_type = instruction->base.value->type;
5668 ZigType *src_type = instruction->target->value->type;5668 ZigType *src_type = instruction->target->value->type;
...@@ -5677,7 +5677,7 @@ static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutableGen *executable,...@@ -5677,7 +5677,7 @@ static LLVMValueRef ir_render_truncate(CodeGen *g, IrExecutableGen *executable,
5677 }5677 }
5678}5678}
56795679
5680static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutableGen *executable, IrInstGenMemset *instruction) {5680static LLVMValueRef ir_render_memset(CodeGen *g, Stage1Air *executable, IrInstGenMemset *instruction) {
5681 LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr);5681 LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr);
5682 LLVMValueRef len_val = ir_llvm_value(g, instruction->count);5682 LLVMValueRef len_val = ir_llvm_value(g, instruction->count);
56835683
...@@ -5707,7 +5707,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutableGen *executable, Ir...@@ -5707,7 +5707,7 @@ static LLVMValueRef ir_render_memset(CodeGen *g, IrExecutableGen *executable, Ir
5707 return nullptr;5707 return nullptr;
5708}5708}
57095709
5710static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, IrInstGenMemcpy *instruction) {5710static LLVMValueRef ir_render_memcpy(CodeGen *g, Stage1Air *executable, IrInstGenMemcpy *instruction) {
5711 LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr);5711 LLVMValueRef dest_ptr = ir_llvm_value(g, instruction->dest_ptr);
5712 LLVMValueRef src_ptr = ir_llvm_value(g, instruction->src_ptr);5712 LLVMValueRef src_ptr = ir_llvm_value(g, instruction->src_ptr);
5713 LLVMValueRef len_val = ir_llvm_value(g, instruction->count);5713 LLVMValueRef len_val = ir_llvm_value(g, instruction->count);
...@@ -5729,14 +5729,14 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir...@@ -5729,14 +5729,14 @@ static LLVMValueRef ir_render_memcpy(CodeGen *g, IrExecutableGen *executable, Ir
5729 return nullptr;5729 return nullptr;
5730}5730}
57315731
5732static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, IrExecutableGen *executable, IrInstGenWasmMemorySize *instruction) {5732static LLVMValueRef ir_render_wasm_memory_size(CodeGen *g, Stage1Air *executable, IrInstGenWasmMemorySize *instruction) {
5733 // TODO adjust for wasm645733 // TODO adjust for wasm64
5734 LLVMValueRef param = ir_llvm_value(g, instruction->index);5734 LLVMValueRef param = ir_llvm_value(g, instruction->index);
5735 LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &param, 1, "");5735 LLVMValueRef val = LLVMBuildCall(g->builder, gen_wasm_memory_size(g), &param, 1, "");
5736 return val;5736 return val;
5737}5737}
57385738
5739static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *executable, IrInstGenWasmMemoryGrow *instruction) {5739static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, Stage1Air *executable, IrInstGenWasmMemoryGrow *instruction) {
5740 // TODO adjust for wasm645740 // TODO adjust for wasm64
5741 LLVMValueRef params[] = {5741 LLVMValueRef params[] = {
5742 ir_llvm_value(g, instruction->index),5742 ir_llvm_value(g, instruction->index),
...@@ -5746,7 +5746,7 @@ static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *exec...@@ -5746,7 +5746,7 @@ static LLVMValueRef ir_render_wasm_memory_grow(CodeGen *g, IrExecutableGen *exec
5746 return val;5746 return val;
5747}5747}
57485748
5749static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutableGen *executable, IrInstGenSlice *instruction) {5749static LLVMValueRef ir_render_slice(CodeGen *g, Stage1Air *executable, IrInstGenSlice *instruction) {
5750 Error err;5750 Error err;
57515751
5752 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);5752 LLVMValueRef array_ptr_ptr = ir_llvm_value(g, instruction->ptr);
...@@ -5983,12 +5983,12 @@ static LLVMValueRef get_trap_fn_val(CodeGen *g) {...@@ -5983,12 +5983,12 @@ static LLVMValueRef get_trap_fn_val(CodeGen *g) {
5983}5983}
59845984
59855985
5986static LLVMValueRef ir_render_breakpoint(CodeGen *g, IrExecutableGen *executable, IrInstGenBreakpoint *instruction) {5986static LLVMValueRef ir_render_breakpoint(CodeGen *g, Stage1Air *executable, IrInstGenBreakpoint *instruction) {
5987 LLVMBuildCall(g->builder, get_trap_fn_val(g), nullptr, 0, "");5987 LLVMBuildCall(g->builder, get_trap_fn_val(g), nullptr, 0, "");
5988 return nullptr;5988 return nullptr;
5989}5989}
59905990
5991static LLVMValueRef ir_render_return_address(CodeGen *g, IrExecutableGen *executable,5991static LLVMValueRef ir_render_return_address(CodeGen *g, Stage1Air *executable,
5992 IrInstGenReturnAddress *instruction)5992 IrInstGenReturnAddress *instruction)
5993{5993{
5994 if (target_is_wasm(g->zig_target) && g->zig_target->os != OsEmscripten) {5994 if (target_is_wasm(g->zig_target) && g->zig_target->os != OsEmscripten) {
...@@ -6016,7 +6016,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) {...@@ -6016,7 +6016,7 @@ static LLVMValueRef get_frame_address_fn_val(CodeGen *g) {
6016 return g->frame_address_fn_val;6016 return g->frame_address_fn_val;
6017}6017}
60186018
6019static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutableGen *executable,6019static LLVMValueRef ir_render_frame_address(CodeGen *g, Stage1Air *executable,
6020 IrInstGenFrameAddress *instruction)6020 IrInstGenFrameAddress *instruction)
6021{6021{
6022 LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type);6022 LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_i32->llvm_type);
...@@ -6024,7 +6024,7 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutableGen *executa...@@ -6024,7 +6024,7 @@ static LLVMValueRef ir_render_frame_address(CodeGen *g, IrExecutableGen *executa
6024 return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, "");6024 return LLVMBuildPtrToInt(g->builder, ptr_val, g->builtin_types.entry_usize->llvm_type, "");
6025}6025}
60266026
6027static LLVMValueRef ir_render_handle(CodeGen *g, IrExecutableGen *executable, IrInstGenFrameHandle *instruction) {6027static LLVMValueRef ir_render_handle(CodeGen *g, Stage1Air *executable, IrInstGenFrameHandle *instruction) {
6028 return g->cur_frame_ptr;6028 return g->cur_frame_ptr;
6029}6029}
60306030
...@@ -6053,7 +6053,7 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstGenOverflowOp *in...@@ -6053,7 +6053,7 @@ static LLVMValueRef render_shl_with_overflow(CodeGen *g, IrInstGenOverflowOp *in
6053 return overflow_bit;6053 return overflow_bit;
6054}6054}
60556055
6056static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutableGen *executable, IrInstGenOverflowOp *instruction) {6056static LLVMValueRef ir_render_overflow_op(CodeGen *g, Stage1Air *executable, IrInstGenOverflowOp *instruction) {
6057 AddSubMul add_sub_mul;6057 AddSubMul add_sub_mul;
6058 switch (instruction->op) {6058 switch (instruction->op) {
6059 case IrOverflowOpAdd:6059 case IrOverflowOpAdd:
...@@ -6091,7 +6091,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutableGen *executabl...@@ -6091,7 +6091,7 @@ static LLVMValueRef ir_render_overflow_op(CodeGen *g, IrExecutableGen *executabl
6091 return overflow_bit;6091 return overflow_bit;
6092}6092}
60936093
6094static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutableGen *executable, IrInstGenTestErr *instruction) {6094static LLVMValueRef ir_render_test_err(CodeGen *g, Stage1Air *executable, IrInstGenTestErr *instruction) {
6095 ZigType *err_union_type = instruction->err_union->value->type;6095 ZigType *err_union_type = instruction->err_union->value->type;
6096 ZigType *payload_type = err_union_type->data.error_union.payload_type;6096 ZigType *payload_type = err_union_type->data.error_union.payload_type;
6097 LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->err_union);6097 LLVMValueRef err_union_handle = ir_llvm_value(g, instruction->err_union);
...@@ -6108,7 +6108,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutableGen *executable,...@@ -6108,7 +6108,7 @@ static LLVMValueRef ir_render_test_err(CodeGen *g, IrExecutableGen *executable,
6108 return LLVMBuildICmp(g->builder, LLVMIntNE, err_val, zero, "");6108 return LLVMBuildICmp(g->builder, LLVMIntNE, err_val, zero, "");
6109}6109}
61106110
6111static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutableGen *executable,6111static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, Stage1Air *executable,
6112 IrInstGenUnwrapErrCode *instruction)6112 IrInstGenUnwrapErrCode *instruction)
6113{6113{
6114 if (instruction->base.value->special != ConstValSpecialRuntime)6114 if (instruction->base.value->special != ConstValSpecialRuntime)
...@@ -6128,7 +6128,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutableGen *execu...@@ -6128,7 +6128,7 @@ static LLVMValueRef ir_render_unwrap_err_code(CodeGen *g, IrExecutableGen *execu
6128 }6128 }
6129}6129}
61306130
6131static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutableGen *executable,6131static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, Stage1Air *executable,
6132 IrInstGenUnwrapErrPayload *instruction)6132 IrInstGenUnwrapErrPayload *instruction)
6133{6133{
6134 Error err;6134 Error err;
...@@ -6197,7 +6197,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutableGen *ex...@@ -6197,7 +6197,7 @@ static LLVMValueRef ir_render_unwrap_err_payload(CodeGen *g, IrExecutableGen *ex
6197 }6197 }
6198}6198}
61996199
6200static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutableGen *executable, IrInstGenOptionalWrap *instruction) {6200static LLVMValueRef ir_render_optional_wrap(CodeGen *g, Stage1Air *executable, IrInstGenOptionalWrap *instruction) {
6201 ZigType *wanted_type = instruction->base.value->type;6201 ZigType *wanted_type = instruction->base.value->type;
62026202
6203 assert(wanted_type->id == ZigTypeIdOptional);6203 assert(wanted_type->id == ZigTypeIdOptional);
...@@ -6233,7 +6233,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutableGen *executa...@@ -6233,7 +6233,7 @@ static LLVMValueRef ir_render_optional_wrap(CodeGen *g, IrExecutableGen *executa
6233 return result_loc;6233 return result_loc;
6234}6234}
62356235
6236static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutableGen *executable, IrInstGenErrWrapCode *instruction) {6236static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, Stage1Air *executable, IrInstGenErrWrapCode *instruction) {
6237 ZigType *wanted_type = instruction->base.value->type;6237 ZigType *wanted_type = instruction->base.value->type;
62386238
6239 assert(wanted_type->id == ZigTypeIdErrorUnion);6239 assert(wanted_type->id == ZigTypeIdErrorUnion);
...@@ -6253,7 +6253,7 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutableGen *executa...@@ -6253,7 +6253,7 @@ static LLVMValueRef ir_render_err_wrap_code(CodeGen *g, IrExecutableGen *executa
6253 return result_loc;6253 return result_loc;
6254}6254}
62556255
6256static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutableGen *executable, IrInstGenErrWrapPayload *instruction) {6256static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, Stage1Air *executable, IrInstGenErrWrapPayload *instruction) {
6257 ZigType *wanted_type = instruction->base.value->type;6257 ZigType *wanted_type = instruction->base.value->type;
62586258
6259 assert(wanted_type->id == ZigTypeIdErrorUnion);6259 assert(wanted_type->id == ZigTypeIdErrorUnion);
...@@ -6284,7 +6284,7 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutableGen *exec...@@ -6284,7 +6284,7 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutableGen *exec
6284 return result_loc;6284 return result_loc;
6285}6285}
62866286
6287static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutableGen *executable, IrInstGenUnionTag *instruction) {6287static LLVMValueRef ir_render_union_tag(CodeGen *g, Stage1Air *executable, IrInstGenUnionTag *instruction) {
6288 ZigType *union_type = instruction->value->value->type;6288 ZigType *union_type = instruction->value->value->type;
62896289
6290 ZigType *tag_type = union_type->data.unionation.tag_type;6290 ZigType *tag_type = union_type->data.unionation.tag_type;
...@@ -6302,14 +6302,14 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutableGen *executable,...@@ -6302,14 +6302,14 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutableGen *executable,
6302 return get_handle_value(g, tag_field_ptr, tag_type, ptr_type);6302 return get_handle_value(g, tag_field_ptr, tag_type, ptr_type);
6303}6303}
63046304
6305static LLVMValueRef ir_render_panic(CodeGen *g, IrExecutableGen *executable, IrInstGenPanic *instruction) {6305static LLVMValueRef ir_render_panic(CodeGen *g, Stage1Air *executable, IrInstGenPanic *instruction) {
6306 bool is_llvm_alloca;6306 bool is_llvm_alloca;
6307 LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.base.scope, &is_llvm_alloca);6307 LLVMValueRef err_ret_trace_val = get_cur_err_ret_trace_val(g, instruction->base.base.scope, &is_llvm_alloca);
6308 gen_panic(g, ir_llvm_value(g, instruction->msg), err_ret_trace_val, is_llvm_alloca);6308 gen_panic(g, ir_llvm_value(g, instruction->msg), err_ret_trace_val, is_llvm_alloca);
6309 return nullptr;6309 return nullptr;
6310}6310}
63116311
6312static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutableGen *executable,6312static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, Stage1Air *executable,
6313 IrInstGenAtomicRmw *instruction)6313 IrInstGenAtomicRmw *instruction)
6314{6314{
6315 bool is_signed;6315 bool is_signed;
...@@ -6354,7 +6354,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutableGen *executable...@@ -6354,7 +6354,7 @@ static LLVMValueRef ir_render_atomic_rmw(CodeGen *g, IrExecutableGen *executable
6354 return LLVMBuildIntToPtr(g->builder, uncasted_result, get_llvm_type(g, operand_type), "");6354 return LLVMBuildIntToPtr(g->builder, uncasted_result, get_llvm_type(g, operand_type), "");
6355}6355}
63566356
6357static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutableGen *executable,6357static LLVMValueRef ir_render_atomic_load(CodeGen *g, Stage1Air *executable,
6358 IrInstGenAtomicLoad *instruction)6358 IrInstGenAtomicLoad *instruction)
6359{6359{
6360 LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering);6360 LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering);
...@@ -6375,7 +6375,7 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutableGen *executabl...@@ -6375,7 +6375,7 @@ static LLVMValueRef ir_render_atomic_load(CodeGen *g, IrExecutableGen *executabl
6375 return load_inst;6375 return load_inst;
6376}6376}
63776377
6378static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutableGen *executable,6378static LLVMValueRef ir_render_atomic_store(CodeGen *g, Stage1Air *executable,
6379 IrInstGenAtomicStore *instruction)6379 IrInstGenAtomicStore *instruction)
6380{6380{
6381 LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering);6381 LLVMAtomicOrdering ordering = to_LLVMAtomicOrdering(instruction->ordering);
...@@ -6398,13 +6398,13 @@ static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutableGen *executab...@@ -6398,13 +6398,13 @@ static LLVMValueRef ir_render_atomic_store(CodeGen *g, IrExecutableGen *executab
6398 return nullptr;6398 return nullptr;
6399}6399}
64006400
6401static LLVMValueRef ir_render_float_op(CodeGen *g, IrExecutableGen *executable, IrInstGenFloatOp *instruction) {6401static LLVMValueRef ir_render_float_op(CodeGen *g, Stage1Air *executable, IrInstGenFloatOp *instruction) {
6402 LLVMValueRef operand = ir_llvm_value(g, instruction->operand);6402 LLVMValueRef operand = ir_llvm_value(g, instruction->operand);
6403 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFloatOp, instruction->fn_id);6403 LLVMValueRef fn_val = get_float_fn(g, instruction->base.value->type, ZigLLVMFnIdFloatOp, instruction->fn_id);
6404 return LLVMBuildCall(g->builder, fn_val, &operand, 1, "");6404 return LLVMBuildCall(g->builder, fn_val, &operand, 1, "");
6405}6405}
64066406
6407static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutableGen *executable, IrInstGenMulAdd *instruction) {6407static LLVMValueRef ir_render_mul_add(CodeGen *g, Stage1Air *executable, IrInstGenMulAdd *instruction) {
6408 LLVMValueRef op1 = ir_llvm_value(g, instruction->op1);6408 LLVMValueRef op1 = ir_llvm_value(g, instruction->op1);
6409 LLVMValueRef op2 = ir_llvm_value(g, instruction->op2);6409 LLVMValueRef op2 = ir_llvm_value(g, instruction->op2);
6410 LLVMValueRef op3 = ir_llvm_value(g, instruction->op3);6410 LLVMValueRef op3 = ir_llvm_value(g, instruction->op3);
...@@ -6419,7 +6419,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutableGen *executable, I...@@ -6419,7 +6419,7 @@ static LLVMValueRef ir_render_mul_add(CodeGen *g, IrExecutableGen *executable, I
6419 return LLVMBuildCall(g->builder, fn_val, args, 3, "");6419 return LLVMBuildCall(g->builder, fn_val, args, 3, "");
6420}6420}
64216421
6422static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutableGen *executable, IrInstGenBswap *instruction) {6422static LLVMValueRef ir_render_bswap(CodeGen *g, Stage1Air *executable, IrInstGenBswap *instruction) {
6423 LLVMValueRef op = ir_llvm_value(g, instruction->op);6423 LLVMValueRef op = ir_llvm_value(g, instruction->op);
6424 ZigType *expr_type = instruction->base.value->type;6424 ZigType *expr_type = instruction->base.value->type;
6425 bool is_vector = expr_type->id == ZigTypeIdVector;6425 bool is_vector = expr_type->id == ZigTypeIdVector;
...@@ -6453,7 +6453,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutableGen *executable, IrI...@@ -6453,7 +6453,7 @@ static LLVMValueRef ir_render_bswap(CodeGen *g, IrExecutableGen *executable, IrI
6453 return LLVMBuildTrunc(g->builder, shifted, get_llvm_type(g, expr_type), "");6453 return LLVMBuildTrunc(g->builder, shifted, get_llvm_type(g, expr_type), "");
6454}6454}
64556455
6456static LLVMValueRef ir_render_extern(CodeGen *g, IrExecutableGen *executable,6456static LLVMValueRef ir_render_extern(CodeGen *g, Stage1Air *executable,
6457 IrInstGenExtern *instruction)6457 IrInstGenExtern *instruction)
6458{6458{
6459 ZigType *expr_type = instruction->base.value->type;6459 ZigType *expr_type = instruction->base.value->type;
...@@ -6477,7 +6477,7 @@ static LLVMValueRef ir_render_extern(CodeGen *g, IrExecutableGen *executable,...@@ -6477,7 +6477,7 @@ static LLVMValueRef ir_render_extern(CodeGen *g, IrExecutableGen *executable,
6477 return LLVMBuildBitCast(g->builder, global_value, get_llvm_type(g, expr_type), "");6477 return LLVMBuildBitCast(g->builder, global_value, get_llvm_type(g, expr_type), "");
6478}6478}
64796479
6480static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutableGen *executable, IrInstGenBitReverse *instruction) {6480static LLVMValueRef ir_render_bit_reverse(CodeGen *g, Stage1Air *executable, IrInstGenBitReverse *instruction) {
6481 LLVMValueRef op = ir_llvm_value(g, instruction->op);6481 LLVMValueRef op = ir_llvm_value(g, instruction->op);
6482 ZigType *int_type = instruction->base.value->type;6482 ZigType *int_type = instruction->base.value->type;
6483 assert(int_type->id == ZigTypeIdInt);6483 assert(int_type->id == ZigTypeIdInt);
...@@ -6485,7 +6485,7 @@ static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutableGen *executabl...@@ -6485,7 +6485,7 @@ static LLVMValueRef ir_render_bit_reverse(CodeGen *g, IrExecutableGen *executabl
6485 return LLVMBuildCall(g->builder, fn_val, &op, 1, "");6485 return LLVMBuildCall(g->builder, fn_val, &op, 1, "");
6486}6486}
64876487
6488static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutableGen *executable,6488static LLVMValueRef ir_render_vector_to_array(CodeGen *g, Stage1Air *executable,
6489 IrInstGenVectorToArray *instruction)6489 IrInstGenVectorToArray *instruction)
6490{6490{
6491 ZigType *array_type = instruction->base.value->type;6491 ZigType *array_type = instruction->base.value->type;
...@@ -6519,7 +6519,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutableGen *execu...@@ -6519,7 +6519,7 @@ static LLVMValueRef ir_render_vector_to_array(CodeGen *g, IrExecutableGen *execu
6519 return result_loc;6519 return result_loc;
6520}6520}
65216521
6522static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutableGen *executable,6522static LLVMValueRef ir_render_array_to_vector(CodeGen *g, Stage1Air *executable,
6523 IrInstGenArrayToVector *instruction)6523 IrInstGenArrayToVector *instruction)
6524{6524{
6525 ZigType *vector_type = instruction->base.value->type;6525 ZigType *vector_type = instruction->base.value->type;
...@@ -6556,7 +6556,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutableGen *execu...@@ -6556,7 +6556,7 @@ static LLVMValueRef ir_render_array_to_vector(CodeGen *g, IrExecutableGen *execu
6556 }6556 }
6557}6557}
65586558
6559static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutableGen *executable,6559static LLVMValueRef ir_render_assert_zero(CodeGen *g, Stage1Air *executable,
6560 IrInstGenAssertZero *instruction)6560 IrInstGenAssertZero *instruction)
6561{6561{
6562 LLVMValueRef target = ir_llvm_value(g, instruction->target);6562 LLVMValueRef target = ir_llvm_value(g, instruction->target);
...@@ -6567,7 +6567,7 @@ static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutableGen *executabl...@@ -6567,7 +6567,7 @@ static LLVMValueRef ir_render_assert_zero(CodeGen *g, IrExecutableGen *executabl
6567 return nullptr;6567 return nullptr;
6568}6568}
65696569
6570static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutableGen *executable,6570static LLVMValueRef ir_render_assert_non_null(CodeGen *g, Stage1Air *executable,
6571 IrInstGenAssertNonNull *instruction)6571 IrInstGenAssertNonNull *instruction)
6572{6572{
6573 LLVMValueRef target = ir_llvm_value(g, instruction->target);6573 LLVMValueRef target = ir_llvm_value(g, instruction->target);
...@@ -6592,7 +6592,7 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutableGen *execu...@@ -6592,7 +6592,7 @@ static LLVMValueRef ir_render_assert_non_null(CodeGen *g, IrExecutableGen *execu
6592 return nullptr;6592 return nullptr;
6593}6593}
65946594
6595static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutableGen *executable,6595static LLVMValueRef ir_render_suspend_begin(CodeGen *g, Stage1Air *executable,
6596 IrInstGenSuspendBegin *instruction)6596 IrInstGenSuspendBegin *instruction)
6597{6597{
6598 if (fn_is_async(g->cur_fn)) {6598 if (fn_is_async(g->cur_fn)) {
...@@ -6601,7 +6601,7 @@ static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutableGen *executa...@@ -6601,7 +6601,7 @@ static LLVMValueRef ir_render_suspend_begin(CodeGen *g, IrExecutableGen *executa
6601 return nullptr;6601 return nullptr;
6602}6602}
66036603
6604static LLVMValueRef ir_render_suspend_finish(CodeGen *g, IrExecutableGen *executable,6604static LLVMValueRef ir_render_suspend_finish(CodeGen *g, Stage1Air *executable,
6605 IrInstGenSuspendFinish *instruction)6605 IrInstGenSuspendFinish *instruction)
6606{6606{
6607 LLVMBuildRetVoid(g->builder);6607 LLVMBuildRetVoid(g->builder);
...@@ -6653,7 +6653,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr,...@@ -6653,7 +6653,7 @@ static LLVMValueRef gen_await_early_return(CodeGen *g, IrInstGen *source_instr,
6653 }6653 }
6654}6654}
66556655
6656static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrInstGenAwait *instruction) {6656static LLVMValueRef ir_render_await(CodeGen *g, Stage1Air *executable, IrInstGenAwait *instruction) {
6657 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;6657 LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type;
6658 LLVMValueRef zero = LLVMConstNull(usize_type_ref);6658 LLVMValueRef zero = LLVMConstNull(usize_type_ref);
6659 LLVMValueRef target_frame_ptr = ir_llvm_value(g, instruction->frame);6659 LLVMValueRef target_frame_ptr = ir_llvm_value(g, instruction->frame);
...@@ -6740,7 +6740,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrI...@@ -6740,7 +6740,7 @@ static LLVMValueRef ir_render_await(CodeGen *g, IrExecutableGen *executable, IrI
6740 return nullptr;6740 return nullptr;
6741}6741}
67426742
6743static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutableGen *executable, IrInstGenResume *instruction) {6743static LLVMValueRef ir_render_resume(CodeGen *g, Stage1Air *executable, IrInstGenResume *instruction) {
6744 LLVMValueRef frame = ir_llvm_value(g, instruction->frame);6744 LLVMValueRef frame = ir_llvm_value(g, instruction->frame);
6745 ZigType *frame_type = instruction->frame->value->type;6745 ZigType *frame_type = instruction->frame->value->type;
6746 assert(frame_type->id == ZigTypeIdAnyFrame);6746 assert(frame_type->id == ZigTypeIdAnyFrame);
...@@ -6749,14 +6749,14 @@ static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutableGen *executable, Ir...@@ -6749,14 +6749,14 @@ static LLVMValueRef ir_render_resume(CodeGen *g, IrExecutableGen *executable, Ir
6749 return nullptr;6749 return nullptr;
6750}6750}
67516751
6752static LLVMValueRef ir_render_frame_size(CodeGen *g, IrExecutableGen *executable,6752static LLVMValueRef ir_render_frame_size(CodeGen *g, Stage1Air *executable,
6753 IrInstGenFrameSize *instruction)6753 IrInstGenFrameSize *instruction)
6754{6754{
6755 LLVMValueRef fn_val = ir_llvm_value(g, instruction->fn);6755 LLVMValueRef fn_val = ir_llvm_value(g, instruction->fn);
6756 return gen_frame_size(g, fn_val);6756 return gen_frame_size(g, fn_val);
6757}6757}
67586758
6759static LLVMValueRef ir_render_spill_begin(CodeGen *g, IrExecutableGen *executable,6759static LLVMValueRef ir_render_spill_begin(CodeGen *g, Stage1Air *executable,
6760 IrInstGenSpillBegin *instruction)6760 IrInstGenSpillBegin *instruction)
6761{6761{
6762 if (!fn_is_async(g->cur_fn))6762 if (!fn_is_async(g->cur_fn))
...@@ -6776,7 +6776,7 @@ static LLVMValueRef ir_render_spill_begin(CodeGen *g, IrExecutableGen *executabl...@@ -6776,7 +6776,7 @@ static LLVMValueRef ir_render_spill_begin(CodeGen *g, IrExecutableGen *executabl
6776 zig_unreachable();6776 zig_unreachable();
6777}6777}
67786778
6779static LLVMValueRef ir_render_spill_end(CodeGen *g, IrExecutableGen *executable, IrInstGenSpillEnd *instruction) {6779static LLVMValueRef ir_render_spill_end(CodeGen *g, Stage1Air *executable, IrInstGenSpillEnd *instruction) {
6780 if (!fn_is_async(g->cur_fn))6780 if (!fn_is_async(g->cur_fn))
6781 return ir_llvm_value(g, instruction->begin->operand);6781 return ir_llvm_value(g, instruction->begin->operand);
67826782
...@@ -6792,7 +6792,7 @@ static LLVMValueRef ir_render_spill_end(CodeGen *g, IrExecutableGen *executable,...@@ -6792,7 +6792,7 @@ static LLVMValueRef ir_render_spill_end(CodeGen *g, IrExecutableGen *executable,
6792 zig_unreachable();6792 zig_unreachable();
6793}6793}
67946794
6795static LLVMValueRef ir_render_vector_extract_elem(CodeGen *g, IrExecutableGen *executable,6795static LLVMValueRef ir_render_vector_extract_elem(CodeGen *g, Stage1Air *executable,
6796 IrInstGenVectorExtractElem *instruction)6796 IrInstGenVectorExtractElem *instruction)
6797{6797{
6798 LLVMValueRef vector = ir_llvm_value(g, instruction->vector);6798 LLVMValueRef vector = ir_llvm_value(g, instruction->vector);
...@@ -6811,7 +6811,7 @@ static void set_debug_location(CodeGen *g, IrInstGen *instruction) {...@@ -6811,7 +6811,7 @@ static void set_debug_location(CodeGen *g, IrInstGen *instruction) {
6811 node_column_onebased(source_node), get_di_scope(g, scope));6811 node_column_onebased(source_node), get_di_scope(g, scope));
6812}6812}
68136813
6814static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executable, IrInstGen *instruction) {6814static LLVMValueRef ir_render_instruction(CodeGen *g, Stage1Air *executable, IrInstGen *instruction) {
6815 switch (instruction->id) {6815 switch (instruction->id) {
6816 case IrInstGenIdInvalid:6816 case IrInstGenIdInvalid:
6817 case IrInstGenIdConst:6817 case IrInstGenIdConst:
...@@ -6999,7 +6999,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executabl...@@ -6999,7 +6999,7 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executabl
6999static void ir_render(CodeGen *g, ZigFn *fn_entry) {6999static void ir_render(CodeGen *g, ZigFn *fn_entry) {
7000 assert(fn_entry);7000 assert(fn_entry);
70017001
7002 IrExecutableGen *executable = &fn_entry->analyzed_executable;7002 Stage1Air *executable = &fn_entry->analyzed_executable;
7003 assert(executable->basic_block_list.length > 0);7003 assert(executable->basic_block_list.length > 0);
70047004
7005 for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) {7005 for (size_t block_i = 0; block_i < executable->basic_block_list.length; block_i += 1) {
...@@ -7997,7 +7997,7 @@ static void generate_error_name_table(CodeGen *g) {...@@ -7997,7 +7997,7 @@ static void generate_error_name_table(CodeGen *g) {
7997}7997}
79987998
7999static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) {7999static void build_all_basic_blocks(CodeGen *g, ZigFn *fn) {
8000 IrExecutableGen *executable = &fn->analyzed_executable;8000 Stage1Air *executable = &fn->analyzed_executable;
8001 assert(executable->basic_block_list.length > 0);8001 assert(executable->basic_block_list.length > 0);
8002 LLVMValueRef fn_val = fn_llvm_value(g, fn);8002 LLVMValueRef fn_val = fn_llvm_value(g, fn);
8003 LLVMBasicBlockRef first_bb = nullptr;8003 LLVMBasicBlockRef first_bb = nullptr;
...@@ -8380,7 +8380,7 @@ static void do_code_gen(CodeGen *g) {...@@ -8380,7 +8380,7 @@ static void do_code_gen(CodeGen *g) {
8380 node_line_onebased(source_node), node_column_onebased(source_node),8380 node_line_onebased(source_node), node_column_onebased(source_node),
8381 get_di_scope(g, fn_table_entry->child_scope));8381 get_di_scope(g, fn_table_entry->child_scope));
8382 }8382 }
8383 IrExecutableGen *executable = &fn_table_entry->analyzed_executable;8383 Stage1Air *executable = &fn_table_entry->analyzed_executable;
8384 LLVMBasicBlockRef bad_resume_block = LLVMAppendBasicBlock(g->cur_fn_val, "BadResume");8384 LLVMBasicBlockRef bad_resume_block = LLVMAppendBasicBlock(g->cur_fn_val, "BadResume");
8385 LLVMPositionBuilderAtEnd(g->builder, bad_resume_block);8385 LLVMPositionBuilderAtEnd(g->builder, bad_resume_block);
8386 gen_assertion_scope(g, PanicMsgIdBadResume, fn_table_entry->child_scope);8386 gen_assertion_scope(g, PanicMsgIdBadResume, fn_table_entry->child_scope);
src/stage1/ir.cpp+46-45
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
2424
25struct IrBuilderGen {25struct IrBuilderGen {
26 CodeGen *codegen;26 CodeGen *codegen;
27 IrExecutableGen *exec;27 Stage1Air *exec;
28 IrBasicBlockGen *current_basic_block;28 IrBasicBlockGen *current_basic_block;
2929
30 // track for immediate post-analysis destruction30 // track for immediate post-analysis destruction
...@@ -46,6 +46,9 @@ struct IrAnalyze {...@@ -46,6 +46,9 @@ struct IrAnalyze {
46 size_t ref_count;46 size_t ref_count;
47 size_t break_debug_id; // for debugging purposes47 size_t break_debug_id; // for debugging purposes
48 IrInstGen *return_ptr;48 IrInstGen *return_ptr;
49 Stage1Air *parent_exec;
50 size_t *backward_branch_count;
51 size_t *backward_branch_quota;
4952
50 // For the purpose of using in a debugger53 // For the purpose of using in a debugger
51 void dump();54 void dump();
...@@ -672,7 +675,7 @@ static void ir_inst_gen_append(IrBasicBlockGen *basic_block, IrInstGen *instruct...@@ -672,7 +675,7 @@ static void ir_inst_gen_append(IrBasicBlockGen *basic_block, IrInstGen *instruct
672 basic_block->instruction_list.append(instruction);675 basic_block->instruction_list.append(instruction);
673}676}
674677
675static size_t exec_next_debug_id_gen(IrExecutableGen *exec) {678static size_t exec_next_debug_id_gen(Stage1Air *exec) {
676 size_t result = exec->next_debug_id;679 size_t result = exec->next_debug_id;
677 exec->next_debug_id += 1;680 exec->next_debug_id += 1;
678 return result;681 return result;
...@@ -716,7 +719,7 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) {...@@ -716,7 +719,7 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) {
716 create_result_ptr(ira->codegen, ira->codegen->builtin_types.entry_type, &result, &result_ptr);719 create_result_ptr(ira->codegen, ira->codegen->builtin_types.entry_type, &result, &result_ptr);
717720
718 if ((err = ir_eval_const_value(ira->codegen, scope, node, result_ptr,721 if ((err = ir_eval_const_value(ira->codegen, scope, node, result_ptr,
719 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota,722 ira->backward_branch_count, ira->backward_branch_quota,
720 nullptr, nullptr, node, nullptr, ira->new_irb.exec, nullptr, UndefBad)))723 nullptr, nullptr, node, nullptr, ira->new_irb.exec, nullptr, UndefBad)))
721 {724 {
722 return ira->codegen->builtin_types.entry_invalid;725 return ira->codegen->builtin_types.entry_invalid;
...@@ -2512,7 +2515,7 @@ static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstN...@@ -2512,7 +2515,7 @@ static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstN
2512 return err_set_type;2515 return err_set_type;
2513}2516}
25142517
2515static void invalidate_exec_gen(IrExecutableGen *exec, ErrorMsg *msg) {2518static void invalidate_exec_gen(Stage1Air *exec, ErrorMsg *msg) {
2516 if (exec->first_err_trace_msg != nullptr)2519 if (exec->first_err_trace_msg != nullptr)
2517 return;2520 return;
25182521
...@@ -2527,7 +2530,7 @@ static void invalidate_exec_gen(IrExecutableGen *exec, ErrorMsg *msg) {...@@ -2527,7 +2530,7 @@ static void invalidate_exec_gen(IrExecutableGen *exec, ErrorMsg *msg) {
2527}2530}
25282531
25292532
2530static ErrorMsg *exec_add_error_node_gen(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, Buf *msg) {2533static ErrorMsg *exec_add_error_node_gen(CodeGen *codegen, Stage1Air *exec, AstNode *source_node, Buf *msg) {
2531 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);2534 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);
2532 invalidate_exec_gen(exec, err_msg);2535 invalidate_exec_gen(exec, err_msg);
2533 if (exec->parent_exec) {2536 if (exec->parent_exec) {
...@@ -2601,7 +2604,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va...@@ -2601,7 +2604,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va
2601 return val;2604 return val;
2602}2605}
26032606
2604static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *exec) {2607static Error ir_exec_scan_for_side_effects(CodeGen *codegen, Stage1Air *exec) {
2605 IrBasicBlockGen *bb = exec->basic_block_list.at(0);2608 IrBasicBlockGen *bb = exec->basic_block_list.at(0);
2606 for (size_t i = 0; i < bb->instruction_list.length; i += 1) {2609 for (size_t i = 0; i < bb->instruction_list.length; i += 1) {
2607 IrInstGen *instruction = bb->instruction_list.at(i);2610 IrInstGen *instruction = bb->instruction_list.at(i);
...@@ -5425,8 +5428,8 @@ static IrInstGen *ir_unreach_error(IrAnalyze *ira) {...@@ -5425,8 +5428,8 @@ static IrInstGen *ir_unreach_error(IrAnalyze *ira) {
5425}5428}
54265429
5427static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction) {5430static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction) {
5428 size_t *bbc = ira->new_irb.exec->backward_branch_count;5431 size_t *bbc = ira->backward_branch_count;
5429 size_t *quota = ira->new_irb.exec->backward_branch_quota;5432 size_t *quota = ira->backward_branch_quota;
54305433
5431 // If we're already over quota, we've already given an error message for this.5434 // If we're already over quota, we've already given an error message for this.
5432 if (*bbc > *quota) {5435 if (*bbc > *quota) {
...@@ -5532,7 +5535,7 @@ static IrInstGen *ir_get_const_ptr(IrAnalyze *ira, IrInst *instruction,...@@ -5532,7 +5535,7 @@ static IrInstGen *ir_get_const_ptr(IrAnalyze *ira, IrInst *instruction,
5532 return const_instr;5535 return const_instr;
5533}5536}
55345537
5535static Error ir_resolve_const_val(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node,5538static Error ir_resolve_const_val(CodeGen *codegen, Stage1Air *exec, AstNode *source_node,
5536 ZigValue *val, UndefAllowed undef_allowed)5539 ZigValue *val, UndefAllowed undef_allowed)
5537{5540{
5538 Error err;5541 Error err;
...@@ -5579,7 +5582,7 @@ static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed...@@ -5579,7 +5582,7 @@ static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed
5579Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,5582Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
5580 ZigValue *return_ptr, size_t *backward_branch_count, size_t *backward_branch_quota,5583 ZigValue *return_ptr, size_t *backward_branch_count, size_t *backward_branch_quota,
5581 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,5584 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
5582 IrExecutableGen *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed)5585 Stage1Air *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed)
5583{5586{
5584 Error err;5587 Error err;
55855588
...@@ -5590,7 +5593,6 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,...@@ -5590,7 +5593,6 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
55905593
5591 Stage1Zir *ir_executable = heap::c_allocator.create<Stage1Zir>();5594 Stage1Zir *ir_executable = heap::c_allocator.create<Stage1Zir>();
5592 ir_executable->source_node = source_node;5595 ir_executable->source_node = source_node;
5593 ir_executable->parent_exec = parent_exec;
5594 ir_executable->name = exec_name;5596 ir_executable->name = exec_name;
5595 ir_executable->is_inline = true;5597 ir_executable->is_inline = true;
5596 ir_executable->fn_entry = fn_entry;5598 ir_executable->fn_entry = fn_entry;
...@@ -5610,7 +5612,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,...@@ -5610,7 +5612,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
5610 ir_print_src(codegen, stderr, ir_executable, 2);5612 ir_print_src(codegen, stderr, ir_executable, 2);
5611 fprintf(stderr, "}\n");5613 fprintf(stderr, "}\n");
5612 }5614 }
5613 IrExecutableGen *analyzed_executable = heap::c_allocator.create<IrExecutableGen>();5615 Stage1Air *analyzed_executable = heap::c_allocator.create<Stage1Air>();
5614 analyzed_executable->source_node = source_node;5616 analyzed_executable->source_node = source_node;
5615 analyzed_executable->parent_exec = parent_exec;5617 analyzed_executable->parent_exec = parent_exec;
5616 analyzed_executable->source_exec = ir_executable;5618 analyzed_executable->source_exec = ir_executable;
...@@ -5618,10 +5620,9 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,...@@ -5618,10 +5620,9 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
5618 analyzed_executable->is_inline = true;5620 analyzed_executable->is_inline = true;
5619 analyzed_executable->fn_entry = fn_entry;5621 analyzed_executable->fn_entry = fn_entry;
5620 analyzed_executable->c_import_buf = c_import_buf;5622 analyzed_executable->c_import_buf = c_import_buf;
5621 analyzed_executable->backward_branch_count = backward_branch_count;
5622 analyzed_executable->backward_branch_quota = backward_branch_quota;
5623 analyzed_executable->begin_scope = scope;5623 analyzed_executable->begin_scope = scope;
5624 ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable,5624 ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable,
5625 backward_branch_count, backward_branch_quota,
5625 return_ptr->type->data.pointer.child_type, expected_type_source_node, return_ptr);5626 return_ptr->type->data.pointer.child_type, expected_type_source_node, return_ptr);
5626 if (type_is_invalid(result_type)) {5627 if (type_is_invalid(result_type)) {
5627 return ErrorSemanticAnalyzeFail;5628 return ErrorSemanticAnalyzeFail;
...@@ -5663,7 +5664,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstGen *err_value) {...@@ -5663,7 +5664,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstGen *err_value) {
5663 return const_val->data.x_err_set;5664 return const_val->data.x_err_set;
5664}5665}
56655666
5666static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node,5667static ZigType *ir_resolve_const_type(CodeGen *codegen, Stage1Air *exec, AstNode *source_node,
5667 ZigValue *val)5668 ZigValue *val)
5668{5669{
5669 Error err;5670 Error err;
...@@ -8071,7 +8072,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns...@@ -8071,7 +8072,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns
8071 return ir_build_load_ptr_gen(ira, source_instruction, ptr, child_type, result_loc_inst);8072 return ir_build_load_ptr_gen(ira, source_instruction, ptr, child_type, result_loc_inst);
8072}8073}
80738074
8074static bool ir_resolve_const_align(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node,8075static bool ir_resolve_const_align(CodeGen *codegen, Stage1Air *exec, AstNode *source_node,
8075 ZigValue *const_val, uint32_t *out)8076 ZigValue *const_val, uint32_t *out)
8076{8077{
8077 Error err;8078 Error err;
...@@ -12752,7 +12753,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -12752,7 +12753,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
12752 create_result_ptr(ira->codegen, return_type, &result, &result_ptr);12753 create_result_ptr(ira->codegen, return_type, &result, &result_ptr);
1275312754
12754 if ((err = ir_eval_const_value(ira->codegen, exec_scope, body_node, result_ptr,12755 if ((err = ir_eval_const_value(ira->codegen, exec_scope, body_node, result_ptr,
12755 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota,12756 ira->backward_branch_count, ira->backward_branch_quota,
12756 fn_entry, nullptr, source_instr->source_node, nullptr, ira->new_irb.exec, return_type_node,12757 fn_entry, nullptr, source_instr->source_node, nullptr, ira->new_irb.exec, return_type_node,
12757 UndefOk)))12758 UndefOk)))
12758 {12759 {
...@@ -12869,7 +12870,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -12869,7 +12870,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
12869 create_result_ptr(ira->codegen, get_align_amt_type(ira->codegen), &align_result, &result_ptr);12870 create_result_ptr(ira->codegen, get_align_amt_type(ira->codegen), &align_result, &result_ptr);
12870 if ((err = ir_eval_const_value(ira->codegen, impl_fn->child_scope,12871 if ((err = ir_eval_const_value(ira->codegen, impl_fn->child_scope,
12871 fn_proto_node->data.fn_proto.align_expr, result_ptr,12872 fn_proto_node->data.fn_proto.align_expr, result_ptr,
12872 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota,12873 ira->backward_branch_count, ira->backward_branch_quota,
12873 nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec,12874 nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec,
12874 nullptr, UndefBad)))12875 nullptr, UndefBad)))
12875 {12876 {
...@@ -12934,11 +12935,9 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -12934,11 +12935,9 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
12934 return ira->codegen->invalid_inst_gen;12935 return ira->codegen->invalid_inst_gen;
1293512936
12936 impl_fn->ir_executable->source_node = source_instr->source_node;12937 impl_fn->ir_executable->source_node = source_instr->source_node;
12937 impl_fn->ir_executable->parent_exec = ira->new_irb.exec;
12938 impl_fn->analyzed_executable.source_node = source_instr->source_node;12938 impl_fn->analyzed_executable.source_node = source_instr->source_node;
12939 impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec;12939 impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec;
12940 impl_fn->analyzed_executable.backward_branch_quota = ira->new_irb.exec->backward_branch_quota;12940 impl_fn->branch_quota = *ira->backward_branch_quota;
12941 impl_fn->analyzed_executable.is_generic_instantiation = true;
1294212941
12943 ira->codegen->fn_defs.append(impl_fn);12942 ira->codegen->fn_defs.append(impl_fn);
12944 }12943 }
...@@ -18980,8 +18979,8 @@ static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,...@@ -18980,8 +18979,8 @@ static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
18980 if (!ir_resolve_unsigned(ira, instruction->new_quota->child, ira->codegen->builtin_types.entry_u32, &new_quota))18979 if (!ir_resolve_unsigned(ira, instruction->new_quota->child, ira->codegen->builtin_types.entry_u32, &new_quota))
18981 return ira->codegen->invalid_inst_gen;18980 return ira->codegen->invalid_inst_gen;
1898218981
18983 if (new_quota > *ira->new_irb.exec->backward_branch_quota) {18982 if (new_quota > *ira->backward_branch_quota) {
18984 *ira->new_irb.exec->backward_branch_quota = new_quota;18983 *ira->backward_branch_quota = new_quota;
18985 }18984 }
1898618985
18987 return ir_const_void(ira, &instruction->base.base);18986 return ir_const_void(ira, &instruction->base.base);
...@@ -19015,7 +19014,7 @@ static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImpo...@@ -19015,7 +19014,7 @@ static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImpo
19015 ZigValue *result_ptr;19014 ZigValue *result_ptr;
19016 create_result_ptr(ira->codegen, void_type, &cimport_result, &result_ptr);19015 create_result_ptr(ira->codegen, void_type, &cimport_result, &result_ptr);
19017 if ((err = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, result_ptr,19016 if ((err = ir_eval_const_value(ira->codegen, &cimport_scope->base, block_node, result_ptr,
19018 ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr,19017 ira->backward_branch_count, ira->backward_branch_quota, nullptr,
19019 &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad)))19018 &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad)))
19020 {19019 {
19021 return ira->codegen->invalid_inst_gen;19020 return ira->codegen->invalid_inst_gen;
...@@ -24467,25 +24466,27 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc...@@ -24467,25 +24466,27 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
24467}24466}
2446824467
24469// This function attempts to evaluate IR code while doing type checking and other analysis.24468// This function attempts to evaluate IR code while doing type checking and other analysis.
24470// It emits to a new IrExecutableGen which is partially evaluated IR code.24469// It emits to a new Stage1Air which is partially evaluated IR code.
24471ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_exec,24470ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_air,
24471 size_t *backward_branch_count, size_t *backward_branch_quota,
24472 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr)24472 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr)
24473{24473{
24474 assert(old_exec->first_err_trace_msg == nullptr);24474 assert(stage1_zir->first_err_trace_msg == nullptr);
24475 assert(expected_type == nullptr || !type_is_invalid(expected_type));24475 assert(expected_type == nullptr || !type_is_invalid(expected_type));
2447624476
24477 IrAnalyze *ira = heap::c_allocator.create<IrAnalyze>();24477 IrAnalyze *ira = heap::c_allocator.create<IrAnalyze>();
24478 ira->backward_branch_count = backward_branch_count;
24479 ira->backward_branch_quota = backward_branch_quota;
24478 ira->ref_count = 1;24480 ira->ref_count = 1;
24479 old_exec->analysis = ira;
24480 ira->codegen = codegen;24481 ira->codegen = codegen;
2448124482
24482 ira->explicit_return_type = expected_type;24483 ira->explicit_return_type = expected_type;
24483 ira->explicit_return_type_source_node = expected_type_source_node;24484 ira->explicit_return_type_source_node = expected_type_source_node;
2448424485
24485 ira->zir = old_exec;24486 ira->zir = stage1_zir;
2448624487
24487 ira->new_irb.codegen = codegen;24488 ira->new_irb.codegen = codegen;
24488 ira->new_irb.exec = new_exec;24489 ira->new_irb.exec = stage1_air;
2448924490
24490 IrBasicBlockSrc *old_entry_bb = ira->zir->basic_block_list.at(0);24491 IrBasicBlockSrc *old_entry_bb = ira->zir->basic_block_list.at(0);
24491 IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr);24492 IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr);
...@@ -24497,13 +24498,13 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_...@@ -24497,13 +24498,13 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_
24497 if (result_ptr != nullptr) {24498 if (result_ptr != nullptr) {
24498 assert(result_ptr->type->id == ZigTypeIdPointer);24499 assert(result_ptr->type->id == ZigTypeIdPointer);
24499 IrInstGenConst *const_inst = ir_create_inst_noval<IrInstGenConst>(24500 IrInstGenConst *const_inst = ir_create_inst_noval<IrInstGenConst>(
24500 &ira->new_irb, new_exec->begin_scope, new_exec->source_node);24501 &ira->new_irb, stage1_air->begin_scope, stage1_air->source_node);
24501 const_inst->base.value = result_ptr;24502 const_inst->base.value = result_ptr;
24502 ira->return_ptr = &const_inst->base;24503 ira->return_ptr = &const_inst->base;
24503 } else {24504 } else {
24504 assert(new_exec->begin_scope != nullptr);24505 assert(stage1_air->begin_scope != nullptr);
24505 assert(new_exec->source_node != nullptr);24506 assert(stage1_air->source_node != nullptr);
24506 ira->return_ptr = ir_build_return_ptr(ira, new_exec->begin_scope, new_exec->source_node,24507 ira->return_ptr = ir_build_return_ptr(ira, stage1_air->begin_scope, stage1_air->source_node,
24507 get_pointer_to_type(codegen, expected_type, false));24508 get_pointer_to_type(codegen, expected_type, false));
24508 }24509 }
2450924510
...@@ -24531,16 +24532,16 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_...@@ -24531,16 +24532,16 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_
24531 fprintf(stderr, "-> (invalid)");24532 fprintf(stderr, "-> (invalid)");
24532 }24533 }
2453324534
24534 if (new_exec->first_err_trace_msg != nullptr) {24535 if (stage1_air->first_err_trace_msg != nullptr) {
24535 ira->codegen->trace_err = new_exec->first_err_trace_msg;24536 ira->codegen->trace_err = stage1_air->first_err_trace_msg;
24536 } else {24537 } else {
24537 new_exec->first_err_trace_msg = ira->codegen->trace_err;24538 stage1_air->first_err_trace_msg = ira->codegen->trace_err;
24538 }24539 }
24539 if (new_exec->first_err_trace_msg != nullptr &&24540 if (stage1_air->first_err_trace_msg != nullptr &&
24540 !old_instruction->base.source_node->already_traced_this_node)24541 !old_instruction->base.source_node->already_traced_this_node)
24541 {24542 {
24542 old_instruction->base.source_node->already_traced_this_node = true;24543 old_instruction->base.source_node->already_traced_this_node = true;
24543 new_exec->first_err_trace_msg = add_error_note(ira->codegen, new_exec->first_err_trace_msg,24544 stage1_air->first_err_trace_msg = add_error_note(ira->codegen, stage1_air->first_err_trace_msg,
24544 old_instruction->base.source_node, buf_create_from_str("referenced here"));24545 old_instruction->base.source_node, buf_create_from_str("referenced here"));
24545 }24546 }
24546 return ira->codegen->builtin_types.entry_invalid;24547 return ira->codegen->builtin_types.entry_invalid;
...@@ -24566,14 +24567,14 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_...@@ -24566,14 +24567,14 @@ ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_
24566 }24567 }
2456724568
24568 ZigType *res_type;24569 ZigType *res_type;
24569 if (new_exec->first_err_trace_msg != nullptr) {24570 if (stage1_air->first_err_trace_msg != nullptr) {
24570 codegen->trace_err = new_exec->first_err_trace_msg;24571 codegen->trace_err = stage1_air->first_err_trace_msg;
24571 if (codegen->trace_err != nullptr && new_exec->source_node != nullptr &&24572 if (codegen->trace_err != nullptr && stage1_air->source_node != nullptr &&
24572 !new_exec->source_node->already_traced_this_node)24573 !stage1_air->source_node->already_traced_this_node)
24573 {24574 {
24574 new_exec->source_node->already_traced_this_node = true;24575 stage1_air->source_node->already_traced_this_node = true;
24575 codegen->trace_err = add_error_note(codegen, codegen->trace_err,24576 codegen->trace_err = add_error_note(codegen, codegen->trace_err,
24576 new_exec->source_node, buf_create_from_str("referenced here"));24577 stage1_air->source_node, buf_create_from_str("referenced here"));
24577 }24578 }
24578 res_type = ira->codegen->builtin_types.entry_invalid;24579 res_type = ira->codegen->builtin_types.entry_invalid;
24579 } else if (ira->src_implicit_return_type_list.length == 0) {24580 } else if (ira->src_implicit_return_type_list.length == 0) {
src/stage1/ir.hpp+4-3
...@@ -16,12 +16,13 @@ IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigF...@@ -16,12 +16,13 @@ IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigF
16Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,16Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
17 ZigValue *return_ptr, size_t *backward_branch_count, size_t *backward_branch_quota,17 ZigValue *return_ptr, size_t *backward_branch_count, size_t *backward_branch_quota,
18 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,18 ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name,
19 IrExecutableGen *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef);19 Stage1Air *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef);
2020
21Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val);21Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val);
2222
23ZigType *ir_analyze(CodeGen *g, Stage1Zir *old_executable, IrExecutableGen *new_executable,23ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *stage1_zir, Stage1Air *stage1_air,
24 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *return_ptr);24 size_t *backward_branch_count, size_t *backward_branch_quota,
25 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr);
2526
26bool ir_inst_gen_has_side_effects(IrInstGen *inst);27bool ir_inst_gen_has_side_effects(IrInstGen *inst);
27bool ir_inst_src_has_side_effects(IrInstSrc *inst);28bool ir_inst_src_has_side_effects(IrInstSrc *inst);
src/stage1/ir_print.cpp+1-1
...@@ -3408,7 +3408,7 @@ void ir_print_src(CodeGen *codegen, FILE *f, Stage1Zir *executable, int indent_s...@@ -3408,7 +3408,7 @@ void ir_print_src(CodeGen *codegen, FILE *f, Stage1Zir *executable, int indent_s
3408 }3408 }
3409}3409}
34103410
3411void ir_print_gen(CodeGen *codegen, FILE *f, IrExecutableGen *executable, int indent_size) {3411void ir_print_gen(CodeGen *codegen, FILE *f, Stage1Air *executable, int indent_size) {
3412 IrPrintGen ir_print = {};3412 IrPrintGen ir_print = {};
3413 IrPrintGen *irp = &ir_print;3413 IrPrintGen *irp = &ir_print;
3414 irp->codegen = codegen;3414 irp->codegen = codegen;
src/stage1/ir_print.hpp+1-1
...@@ -13,7 +13,7 @@...@@ -13,7 +13,7 @@
13#include <stdio.h>13#include <stdio.h>
1414
15void ir_print_src(CodeGen *codegen, FILE *f, Stage1Zir *executable, int indent_size);15void ir_print_src(CodeGen *codegen, FILE *f, Stage1Zir *executable, int indent_size);
16void ir_print_gen(CodeGen *codegen, FILE *f, IrExecutableGen *executable, int indent_size);16void ir_print_gen(CodeGen *codegen, FILE *f, Stage1Air *executable, int indent_size);
17void ir_print_inst_src(CodeGen *codegen, FILE *f, IrInstSrc *inst, int indent_size);17void ir_print_inst_src(CodeGen *codegen, FILE *f, IrInstSrc *inst, int indent_size);
18void ir_print_inst_gen(CodeGen *codegen, FILE *f, IrInstGen *inst, int indent_size);18void ir_print_inst_gen(CodeGen *codegen, FILE *f, IrInstGen *inst, int indent_size);
19void ir_print_basic_block_src(CodeGen *codegen, FILE *f, IrBasicBlockSrc *bb, int indent_size);19void ir_print_basic_block_src(CodeGen *codegen, FILE *f, IrBasicBlockSrc *bb, int indent_size);