authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-27 17:57:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-28 12:58:40-07:00
loge072ace436e3bfda18cde71492380f863e51cc61
tree7586138774ce3df6b9a63ce4338eb694e7c20ecb
parenteb37722d79a2cde636c80d35c9478139d8513931

stage1: rename IrExecutableSrc to Stage1Zir

and make IrBuilderSrc private to astgen.cpp

8 files changed, 89 insertions(+), 89 deletions(-)

src/stage1/all_types.hpp+3-3
...@@ -110,7 +110,7 @@ enum X64CABIClass {...@@ -110,7 +110,7 @@ enum X64CABIClass {
110 X64CABIClass_SSE,110 X64CABIClass_SSE,
111};111};
112112
113struct IrExecutableSrc {113struct Stage1Zir {
114 ZigList<IrBasicBlockSrc *> basic_block_list;114 ZigList<IrBasicBlockSrc *> basic_block_list;
115 Buf *name;115 Buf *name;
116 ZigFn *name_fn;116 ZigFn *name_fn;
...@@ -148,7 +148,7 @@ struct IrExecutableGen {...@@ -148,7 +148,7 @@ struct IrExecutableGen {
148 Buf *c_import_buf;148 Buf *c_import_buf;
149 AstNode *source_node;149 AstNode *source_node;
150 IrExecutableGen *parent_exec;150 IrExecutableGen *parent_exec;
151 IrExecutableSrc *source_exec;151 Stage1Zir *source_exec;
152 Scope *begin_scope;152 Scope *begin_scope;
153 ErrorMsg *first_err_trace_msg;153 ErrorMsg *first_err_trace_msg;
154 ZigList<Tld *> tld_list;154 ZigList<Tld *> tld_list;
...@@ -1651,7 +1651,7 @@ struct ZigFn {...@@ -1651,7 +1651,7 @@ struct ZigFn {
1651 // in the case of async functions this is the implicit return type according to the1651 // in the case of async functions this is the implicit return type according to the
1652 // zig source code, not according to zig ir1652 // zig source code, not according to zig ir
1653 ZigType *src_implicit_return_type;1653 ZigType *src_implicit_return_type;
1654 IrExecutableSrc *ir_executable;1654 Stage1Zir *ir_executable;
1655 IrExecutableGen analyzed_executable;1655 IrExecutableGen analyzed_executable;
1656 size_t prealloc_bbc;1656 size_t prealloc_bbc;
1657 size_t prealloc_backward_branch_quota;1657 size_t prealloc_backward_branch_quota;
src/stage1/analyze.cpp+2-2
...@@ -3653,7 +3653,7 @@ static void get_fully_qualified_decl_name(CodeGen *g, Buf *buf, Tld *tld, bool i...@@ -3653,7 +3653,7 @@ static void get_fully_qualified_decl_name(CodeGen *g, Buf *buf, Tld *tld, bool i
36533653
3654static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) {3654static 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<IrExecutableSrc>();3656 fn_entry->ir_executable = heap::c_allocator.create<Stage1Zir>();
36573657
3658 fn_entry->prealloc_backward_branch_quota = default_backward_branch_quota;3658 fn_entry->prealloc_backward_branch_quota = default_backward_branch_quota;
36593659
...@@ -9862,7 +9862,7 @@ void AstNode::src() {...@@ -9862,7 +9862,7 @@ void AstNode::src() {
9862 line, column);9862 line, column);
9863}9863}
98649864
9865void IrExecutableSrc::src() {9865void Stage1Zir::src() {
9866 if (this->source_node != nullptr) {9866 if (this->source_node != nullptr) {
9867 this->source_node->src();9867 this->source_node->src();
9868 }9868 }
src/stage1/astgen.cpp+18-11
...@@ -11,6 +11,13 @@...@@ -11,6 +11,13 @@
11#include "os.hpp"11#include "os.hpp"
12#include "parser.hpp"12#include "parser.hpp"
1313
14struct IrBuilderSrc {
15 CodeGen *codegen;
16 Stage1Zir *exec;
17 IrBasicBlockSrc *current_basic_block;
18 AstNode *main_block_node;
19};
20
14static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope);21static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope);
15static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval,22static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval,
16 ResultLoc *result_loc);23 ResultLoc *result_loc);
...@@ -34,14 +41,14 @@ static void ir_assert_impl(bool ok, IrInst *source_instruction, char const *file...@@ -34,14 +41,14 @@ static void ir_assert_impl(bool ok, IrInst *source_instruction, char const *file
34 src_assert_impl(ok, source_instruction->source_node, file, line);41 src_assert_impl(ok, source_instruction->source_node, file, line);
35}42}
3643
37static void ir_add_call_stack_errors(CodeGen *codegen, IrExecutableSrc *exec, ErrorMsg *err_msg, int limit) {44static void ir_add_call_stack_errors(CodeGen *codegen, Stage1Zir *exec, ErrorMsg *err_msg, int limit) {
38 if (!exec || !exec->source_node || limit < 0) return;45 if (!exec || !exec->source_node || limit < 0) return;
39 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));46 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));
4047
41 ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1);48 ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1);
42}49}
4350
44static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg) {51static ErrorMsg *exec_add_error_node(CodeGen *codegen, Stage1Zir *exec, AstNode *source_node, Buf *msg) {
45 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);52 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);
46 invalidate_exec(exec, err_msg);53 invalidate_exec(exec, err_msg);
47 if (exec->parent_exec) {54 if (exec->parent_exec) {
...@@ -342,7 +349,7 @@ void destroy_instruction_src(IrInstSrc *inst) {...@@ -342,7 +349,7 @@ void destroy_instruction_src(IrInstSrc *inst) {
342}349}
343350
344351
345bool ir_should_inline(IrExecutableSrc *exec, Scope *scope) {352bool ir_should_inline(Stage1Zir *exec, Scope *scope) {
346 if (exec->is_inline)353 if (exec->is_inline)
347 return true;354 return true;
348355
...@@ -364,17 +371,17 @@ static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instr...@@ -364,17 +371,17 @@ static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instr
364 basic_block->instruction_list.append(instruction);371 basic_block->instruction_list.append(instruction);
365}372}
366373
367static size_t exec_next_debug_id(IrExecutableSrc *exec) {374static size_t exec_next_debug_id(Stage1Zir *exec) {
368 size_t result = exec->next_debug_id;375 size_t result = exec->next_debug_id;
369 exec->next_debug_id += 1;376 exec->next_debug_id += 1;
370 return result;377 return result;
371}378}
372379
373static ZigFn *exec_fn_entry(IrExecutableSrc *exec) {380static ZigFn *exec_fn_entry(Stage1Zir *exec) {
374 return exec->fn_entry;381 return exec->fn_entry;
375}382}
376383
377static Buf *exec_c_import_buf(IrExecutableSrc *exec) {384static Buf *exec_c_import_buf(Stage1Zir *exec) {
378 return exec->c_import_buf;385 return exec->c_import_buf;
379}386}
380387
...@@ -5891,7 +5898,7 @@ static IrInstSrc *ir_gen_var_decl(IrBuilderSrc *irb, Scope *scope, AstNode *node...@@ -5891,7 +5898,7 @@ static IrInstSrc *ir_gen_var_decl(IrBuilderSrc *irb, Scope *scope, AstNode *node
5891 Scope *init_scope = is_comptime_scalar ?5898 Scope *init_scope = is_comptime_scalar ?
5892 create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope;5899 create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope;
58935900
5894 // Temporarily set the name of the IrExecutableSrc to the VariableDeclaration5901 // Temporarily set the name of the Stage1Zir to the VariableDeclaration
5895 // so that the struct or enum from the init expression inherits the name.5902 // so that the struct or enum from the init expression inherits the name.
5896 Buf *old_exec_name = irb->exec->name;5903 Buf *old_exec_name = irb->exec->name;
5897 irb->exec->name = variable_declaration->symbol;5904 irb->exec->name = variable_declaration->symbol;
...@@ -7511,7 +7518,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o...@@ -7511,7 +7518,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o
7511 return true;7518 return true;
7512}7519}
75137520
7514Buf *get_anon_type_name(CodeGen *codegen, IrExecutableSrc *exec, const char *kind_name,7521Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name,
7515 Scope *scope, AstNode *source_node, Buf *out_bare_name)7522 Scope *scope, AstNode *source_node, Buf *out_bare_name)
7516{7523{
7517 if (exec != nullptr && exec->name) {7524 if (exec != nullptr && exec->name) {
...@@ -8040,7 +8047,7 @@ static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope) {...@@ -8040,7 +8047,7 @@ static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope) {
8040 return ir_gen_node_extra(irb, node, scope, LValNone, nullptr);8047 return ir_gen_node_extra(irb, node, scope, LValNone, nullptr);
8041}8048}
80428049
8043bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_executable) {8050bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *ir_executable) {
8044 assert(node->owner);8051 assert(node->owner);
80458052
8046 IrBuilderSrc ir_builder = {0};8053 IrBuilderSrc ir_builder = {0};
...@@ -8081,7 +8088,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_e...@@ -8081,7 +8088,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_e
8081bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {8088bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {
8082 assert(fn_entry);8089 assert(fn_entry);
80838090
8084 IrExecutableSrc *ir_executable = fn_entry->ir_executable;8091 Stage1Zir *ir_executable = fn_entry->ir_executable;
8085 AstNode *body_node = fn_entry->body_node;8092 AstNode *body_node = fn_entry->body_node;
80868093
8087 assert(fn_entry->child_scope);8094 assert(fn_entry->child_scope);
...@@ -8089,7 +8096,7 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {...@@ -8089,7 +8096,7 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {
8089 return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable);8096 return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable);
8090}8097}
80918098
8092void invalidate_exec(IrExecutableSrc *exec, ErrorMsg *msg) {8099void invalidate_exec(Stage1Zir *exec, ErrorMsg *msg) {
8093 if (exec->first_err_trace_msg != nullptr)8100 if (exec->first_err_trace_msg != nullptr)
8094 return;8101 return;
80958102
src/stage1/astgen.hpp+4-11
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
1010
11#include "all_types.hpp"11#include "all_types.hpp"
1212
13bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, IrExecutableSrc *ir_executable);13bool ir_gen(CodeGen *g, AstNode *node, Scope *scope, Stage1Zir *ir_executable);
14bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);14bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);
1515
16bool ir_inst_src_has_side_effects(IrInstSrc *inst);16bool ir_inst_src_has_side_effects(IrInstSrc *inst);
...@@ -21,7 +21,7 @@ ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope,...@@ -21,7 +21,7 @@ ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope,
2121
22ResultLoc *no_result_loc(void);22ResultLoc *no_result_loc(void);
2323
24void invalidate_exec(IrExecutableSrc *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, IrExecutableGen *exec, ErrorMsg *err_msg,
...@@ -29,15 +29,8 @@ void ir_add_call_stack_errors_gen(CodeGen *codegen, IrExecutableGen *exec, Error...@@ -29,15 +29,8 @@ void ir_add_call_stack_errors_gen(CodeGen *codegen, IrExecutableGen *exec, Error
2929
30void destroy_instruction_src(IrInstSrc *inst);30void destroy_instruction_src(IrInstSrc *inst);
3131
32struct IrBuilderSrc {32bool ir_should_inline(Stage1Zir *exec, Scope *scope);
33 CodeGen *codegen;33Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name,
34 IrExecutableSrc *exec;
35 IrBasicBlockSrc *current_basic_block;
36 AstNode *main_block_node;
37};
38
39bool ir_should_inline(IrExecutableSrc *exec, Scope *scope);
40Buf *get_anon_type_name(CodeGen *codegen, IrExecutableSrc *exec, const char *kind_name,
41 Scope *scope, AstNode *source_node, Buf *out_bare_name);34 Scope *scope, AstNode *source_node, Buf *out_bare_name);
4235
43#endif36#endif
src/stage1/ir.cpp+59-59
...@@ -33,7 +33,8 @@ struct IrBuilderGen {...@@ -33,7 +33,8 @@ struct IrBuilderGen {
3333
34struct IrAnalyze {34struct IrAnalyze {
35 CodeGen *codegen;35 CodeGen *codegen;
36 IrBuilderSrc old_irb;36 Stage1Zir *zir;
37 IrBasicBlockSrc *zir_current_basic_block;
37 IrBuilderGen new_irb;38 IrBuilderGen new_irb;
38 size_t old_bb_index;39 size_t old_bb_index;
39 size_t instruction_index;40 size_t instruction_index;
...@@ -476,17 +477,17 @@ static void ira_deref(IrAnalyze *ira) {...@@ -476,17 +477,17 @@ static void ira_deref(IrAnalyze *ira) {
476 }477 }
477 assert(ira->ref_count != 0);478 assert(ira->ref_count != 0);
478479
479 for (size_t bb_i = 0; bb_i < ira->old_irb.exec->basic_block_list.length; bb_i += 1) {480 for (size_t bb_i = 0; bb_i < ira->zir->basic_block_list.length; bb_i += 1) {
480 IrBasicBlockSrc *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i];481 IrBasicBlockSrc *pass1_bb = ira->zir->basic_block_list.items[bb_i];
481 for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) {482 for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) {
482 IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i];483 IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i];
483 destroy_instruction_src(pass1_inst);484 destroy_instruction_src(pass1_inst);
484 }485 }
485 heap::c_allocator.destroy(pass1_bb);486 heap::c_allocator.destroy(pass1_bb);
486 }487 }
487 ira->old_irb.exec->basic_block_list.deinit();488 ira->zir->basic_block_list.deinit();
488 ira->old_irb.exec->tld_list.deinit();489 ira->zir->tld_list.deinit();
489 heap::c_allocator.destroy(ira->old_irb.exec);490 heap::c_allocator.destroy(ira->zir);
490 ira->src_implicit_return_type_list.deinit();491 ira->src_implicit_return_type_list.deinit();
491 ira->resume_stack.deinit();492 ira->resume_stack.deinit();
492493
...@@ -2630,7 +2631,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex...@@ -2630,7 +2631,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex
2630}2631}
26312632
2632static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInst* source_instruction) {2633static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInst* source_instruction) {
2633 if (ir_should_inline(ira->old_irb.exec, source_instruction->scope)) {2634 if (ir_should_inline(ira->zir, source_instruction->scope)) {
2634 ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression"));2635 ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression"));
2635 return false;2636 return false;
2636 }2637 }
...@@ -5287,7 +5288,7 @@ static IrBasicBlockGen *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlockSrc *o...@@ -5287,7 +5288,7 @@ static IrBasicBlockGen *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlockSrc *o
5287static void ir_start_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrBasicBlockSrc *const_predecessor_bb) {5288static void ir_start_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrBasicBlockSrc *const_predecessor_bb) {
5288 ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? &old_bb->instruction_list.at(0)->base : nullptr);5289 ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? &old_bb->instruction_list.at(0)->base : nullptr);
5289 ira->instruction_index = 0;5290 ira->instruction_index = 0;
5290 ira->old_irb.current_basic_block = old_bb;5291 ira->zir_current_basic_block = old_bb;
5291 ira->const_predecessor_bb = const_predecessor_bb;5292 ira->const_predecessor_bb = const_predecessor_bb;
5292 ira->old_bb_index = old_bb->index;5293 ira->old_bb_index = old_bb->index;
5293}5294}
...@@ -5297,23 +5298,23 @@ static IrInstGen *ira_suspend(IrAnalyze *ira, IrInst *old_instruction, IrBasicBl...@@ -5297,23 +5298,23 @@ static IrInstGen *ira_suspend(IrAnalyze *ira, IrInst *old_instruction, IrBasicBl
5297{5298{
5298 if (ira->codegen->verbose_ir) {5299 if (ira->codegen->verbose_ir) {
5299 fprintf(stderr, "suspend %s_%" PRIu32 " %s_%" PRIu32 " #%" PRIu32 " (%zu,%zu)\n",5300 fprintf(stderr, "suspend %s_%" PRIu32 " %s_%" PRIu32 " #%" PRIu32 " (%zu,%zu)\n",
5300 ira->old_irb.current_basic_block->name_hint,5301 ira->zir_current_basic_block->name_hint,
5301 ira->old_irb.current_basic_block->debug_id,5302 ira->zir_current_basic_block->debug_id,
5302 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint,5303 ira->zir->basic_block_list.at(ira->old_bb_index)->name_hint,
5303 ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id,5304 ira->zir->basic_block_list.at(ira->old_bb_index)->debug_id,
5304 ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index)->base.debug_id,5305 ira->zir_current_basic_block->instruction_list.at(ira->instruction_index)->base.debug_id,
5305 ira->old_bb_index, ira->instruction_index);5306 ira->old_bb_index, ira->instruction_index);
5306 }5307 }
5307 suspend_pos->basic_block_index = ira->old_bb_index;5308 suspend_pos->basic_block_index = ira->old_bb_index;
5308 suspend_pos->instruction_index = ira->instruction_index;5309 suspend_pos->instruction_index = ira->instruction_index;
53095310
5310 ira->old_irb.current_basic_block->suspended = true;5311 ira->zir_current_basic_block->suspended = true;
53115312
5312 // null next_bb means that the caller plans to call ira_resume before returning5313 // null next_bb means that the caller plans to call ira_resume before returning
5313 if (next_bb != nullptr) {5314 if (next_bb != nullptr) {
5314 ira->old_bb_index = next_bb->index;5315 ira->old_bb_index = next_bb->index;
5315 ira->old_irb.current_basic_block = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index);5316 ira->zir_current_basic_block = ira->zir->basic_block_list.at(ira->old_bb_index);
5316 assert(ira->old_irb.current_basic_block == next_bb);5317 assert(ira->zir_current_basic_block == next_bb);
5317 ira->instruction_index = 0;5318 ira->instruction_index = 0;
5318 ira->const_predecessor_bb = nullptr;5319 ira->const_predecessor_bb = nullptr;
5319 next_bb->child = ir_get_new_bb_runtime(ira, next_bb, old_instruction);5320 next_bb->child = ir_get_new_bb_runtime(ira, next_bb, old_instruction);
...@@ -5328,19 +5329,19 @@ static IrInstGen *ira_resume(IrAnalyze *ira) {...@@ -5328,19 +5329,19 @@ static IrInstGen *ira_resume(IrAnalyze *ira) {
5328 fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index);5329 fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index);
5329 }5330 }
5330 ira->old_bb_index = pos.basic_block_index;5331 ira->old_bb_index = pos.basic_block_index;
5331 ira->old_irb.current_basic_block = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index);5332 ira->zir_current_basic_block = ira->zir->basic_block_list.at(ira->old_bb_index);
5332 assert(ira->old_irb.current_basic_block->in_resume_stack);5333 assert(ira->zir_current_basic_block->in_resume_stack);
5333 ira->old_irb.current_basic_block->in_resume_stack = false;5334 ira->zir_current_basic_block->in_resume_stack = false;
5334 ira->old_irb.current_basic_block->suspended = false;5335 ira->zir_current_basic_block->suspended = false;
5335 ira->instruction_index = pos.instruction_index;5336 ira->instruction_index = pos.instruction_index;
5336 assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length);5337 assert(pos.instruction_index < ira->zir_current_basic_block->instruction_list.length);
5337 if (ira->codegen->verbose_ir) {5338 if (ira->codegen->verbose_ir) {
5338 fprintf(stderr, "%s_%" PRIu32 " #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint,5339 fprintf(stderr, "%s_%" PRIu32 " #%" PRIu32 "\n", ira->zir_current_basic_block->name_hint,
5339 ira->old_irb.current_basic_block->debug_id,5340 ira->zir_current_basic_block->debug_id,
5340 ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->base.debug_id);5341 ira->zir_current_basic_block->instruction_list.at(pos.instruction_index)->base.debug_id);
5341 }5342 }
5342 ira->const_predecessor_bb = nullptr;5343 ira->const_predecessor_bb = nullptr;
5343 ira->new_irb.current_basic_block = ira->old_irb.current_basic_block->child;5344 ira->new_irb.current_basic_block = ira->zir_current_basic_block->child;
5344 assert(ira->new_irb.current_basic_block != nullptr);5345 assert(ira->new_irb.current_basic_block != nullptr);
5345 return ira->codegen->unreach_instruction;5346 return ira->codegen->unreach_instruction;
5346}5347}
...@@ -5350,8 +5351,8 @@ static void ir_start_next_bb(IrAnalyze *ira) {...@@ -5350,8 +5351,8 @@ static void ir_start_next_bb(IrAnalyze *ira) {
53505351
5351 bool need_repeat = true;5352 bool need_repeat = true;
5352 for (;;) {5353 for (;;) {
5353 while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) {5354 while (ira->old_bb_index < ira->zir->basic_block_list.length) {
5354 IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index);5355 IrBasicBlockSrc *old_bb = ira->zir->basic_block_list.at(ira->old_bb_index);
5355 if (old_bb->child == nullptr && old_bb->suspend_instruction_ref == nullptr) {5356 if (old_bb->child == nullptr && old_bb->suspend_instruction_ref == nullptr) {
5356 ira->old_bb_index += 1;5357 ira->old_bb_index += 1;
5357 continue;5358 continue;
...@@ -5403,8 +5404,8 @@ static void ir_finish_bb(IrAnalyze *ira) {...@@ -5403,8 +5404,8 @@ static void ir_finish_bb(IrAnalyze *ira) {
5403 }5404 }
5404 }5405 }
5405 ira->instruction_index += 1;5406 ira->instruction_index += 1;
5406 while (ira->instruction_index < ira->old_irb.current_basic_block->instruction_list.length) {5407 while (ira->instruction_index < ira->zir_current_basic_block->instruction_list.length) {
5407 IrInstSrc *next_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index);5408 IrInstSrc *next_instruction = ira->zir_current_basic_block->instruction_list.at(ira->instruction_index);
5408 if (!next_instruction->is_gen) {5409 if (!next_instruction->is_gen) {
5409 ir_add_error(ira, &next_instruction->base, buf_sprintf("unreachable code"));5410 ir_add_error(ira, &next_instruction->base, buf_sprintf("unreachable code"));
5410 break;5411 break;
...@@ -5443,13 +5444,13 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction)...@@ -5443,13 +5444,13 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction)
5443}5444}
54445445
5445static IrInstGen *ir_inline_bb(IrAnalyze *ira, IrInst* source_instruction, IrBasicBlockSrc *old_bb) {5446static IrInstGen *ir_inline_bb(IrAnalyze *ira, IrInst* source_instruction, IrBasicBlockSrc *old_bb) {
5446 if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) {5447 if (old_bb->debug_id <= ira->zir_current_basic_block->debug_id) {
5447 if (!ir_emit_backward_branch(ira, source_instruction))5448 if (!ir_emit_backward_branch(ira, source_instruction))
5448 return ir_unreach_error(ira);5449 return ir_unreach_error(ira);
5449 }5450 }
54505451
5451 old_bb->child = ira->old_irb.current_basic_block->child;5452 old_bb->child = ira->zir_current_basic_block->child;
5452 ir_start_bb(ira, old_bb, ira->old_irb.current_basic_block);5453 ir_start_bb(ira, old_bb, ira->zir_current_basic_block);
5453 return ira->codegen->unreach_instruction;5454 return ira->codegen->unreach_instruction;
5454}5455}
54555456
...@@ -5587,7 +5588,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,...@@ -5587,7 +5588,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
5587 if (type_is_invalid(return_ptr->type))5588 if (type_is_invalid(return_ptr->type))
5588 return ErrorSemanticAnalyzeFail;5589 return ErrorSemanticAnalyzeFail;
55895590
5590 IrExecutableSrc *ir_executable = heap::c_allocator.create<IrExecutableSrc>();5591 Stage1Zir *ir_executable = heap::c_allocator.create<Stage1Zir>();
5591 ir_executable->source_node = source_node;5592 ir_executable->source_node = source_node;
5592 ir_executable->parent_exec = parent_exec;5593 ir_executable->parent_exec = parent_exec;
5593 ir_executable->name = exec_name;5594 ir_executable->name = exec_name;
...@@ -6914,7 +6915,7 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInst* sou...@@ -6914,7 +6915,7 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInst* sou
6914 size_t instr_field_count = actual_type->data.structure.src_field_count;6915 size_t instr_field_count = actual_type->data.structure.src_field_count;
6915 assert(array_len == instr_field_count);6916 assert(array_len == instr_field_count);
69166917
6917 bool need_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope)6918 bool need_comptime = ir_should_inline(ira->zir, source_instr->scope)
6918 || type_requires_comptime(ira->codegen, wanted_type) == ReqCompTimeYes;6919 || type_requires_comptime(ira->codegen, wanted_type) == ReqCompTimeYes;
6919 bool is_comptime = true;6920 bool is_comptime = true;
69206921
...@@ -7004,7 +7005,7 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInst* so...@@ -7004,7 +7005,7 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInst* so
7004 size_t actual_field_count = wanted_type->data.structure.src_field_count;7005 size_t actual_field_count = wanted_type->data.structure.src_field_count;
7005 size_t instr_field_count = actual_type->data.structure.src_field_count;7006 size_t instr_field_count = actual_type->data.structure.src_field_count;
70067007
7007 bool need_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope)7008 bool need_comptime = ir_should_inline(ira->zir, source_instr->scope)
7008 || type_requires_comptime(ira->codegen, wanted_type) == ReqCompTimeYes;7009 || type_requires_comptime(ira->codegen, wanted_type) == ReqCompTimeYes;
7009 bool is_comptime = true;7010 bool is_comptime = true;
70107011
...@@ -11419,7 +11420,7 @@ static IrInstGen *ir_analyze_instruction_extern(IrAnalyze *ira, IrInstSrcExtern...@@ -11419,7 +11420,7 @@ static IrInstGen *ir_analyze_instruction_extern(IrAnalyze *ira, IrInstSrcExtern
11419 is_thread_local, expr_type);11420 is_thread_local, expr_type);
11420}11421}
1142111422
11422static bool exec_has_err_ret_trace(CodeGen *g, IrExecutableSrc *exec) {11423static bool exec_has_err_ret_trace(CodeGen *g, Stage1Zir *exec) {
11423 ZigFn *fn_entry = exec->fn_entry;11424 ZigFn *fn_entry = exec->fn_entry;
11424 return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;11425 return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;
11425}11426}
...@@ -11430,7 +11431,7 @@ static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,...@@ -11430,7 +11431,7 @@ static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
11430 ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false);11431 ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false);
11431 if (instruction->optional == IrInstErrorReturnTraceNull) {11432 if (instruction->optional == IrInstErrorReturnTraceNull) {
11432 ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);11433 ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type);
11433 if (!exec_has_err_ret_trace(ira->codegen, ira->old_irb.exec)) {11434 if (!exec_has_err_ret_trace(ira->codegen, ira->zir)) {
11434 IrInstGen *result = ir_const(ira, &instruction->base.base, optional_type);11435 IrInstGen *result = ir_const(ira, &instruction->base.base, optional_type);
11435 ZigValue *out_val = result->value;11436 ZigValue *out_val = result->value;
11436 assert(get_src_ptr_type(optional_type) != nullptr);11437 assert(get_src_ptr_type(optional_type) != nullptr);
...@@ -13213,7 +13214,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr,...@@ -13213,7 +13214,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr,
13213 return ira->codegen->invalid_inst_gen;13214 return ira->codegen->invalid_inst_gen;
13214 CallModifier modifier = (CallModifier)bigint_as_u32(&modifier_val->data.x_enum_tag);13215 CallModifier modifier = (CallModifier)bigint_as_u32(&modifier_val->data.x_enum_tag);
1321513216
13216 if (ir_should_inline(ira->old_irb.exec, source_instr->scope)) {13217 if (ir_should_inline(ira->zir, source_instr->scope)) {
13217 switch (modifier) {13218 switch (modifier) {
13218 case CallModifierBuiltin:13219 case CallModifierBuiltin:
13219 zig_unreachable();13220 zig_unreachable();
...@@ -13302,7 +13303,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, IrInst* source_ins...@@ -13302,7 +13303,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, IrInst* source_ins
13302 if (type_is_invalid(fn_ref->value->type))13303 if (type_is_invalid(fn_ref->value->type))
13303 return ira->codegen->invalid_inst_gen;13304 return ira->codegen->invalid_inst_gen;
1330413305
13305 if (ir_should_inline(ira->old_irb.exec, source_instr->scope)) {13306 if (ir_should_inline(ira->zir, source_instr->scope)) {
13306 ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @asyncCall"));13307 ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @asyncCall"));
13307 return ira->codegen->invalid_inst_gen;13308 return ira->codegen->invalid_inst_gen;
13308 }13309 }
...@@ -13415,7 +13416,7 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal...@@ -13415,7 +13416,7 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal
13415 return ira->codegen->invalid_inst_gen;13416 return ira->codegen->invalid_inst_gen;
1341613417
13417 bool is_comptime = (call_instruction->modifier == CallModifierCompileTime) ||13418 bool is_comptime = (call_instruction->modifier == CallModifierCompileTime) ||
13418 ir_should_inline(ira->old_irb.exec, call_instruction->base.base.scope);13419 ir_should_inline(ira->zir, call_instruction->base.base.scope);
13419 CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier;13420 CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier;
1342013421
13421 if (is_comptime || instr_is_comptime(fn_ref)) {13422 if (is_comptime || instr_is_comptime(fn_ref)) {
...@@ -13777,7 +13778,7 @@ static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *in...@@ -13777,7 +13778,7 @@ static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *in
13777}13778}
1377813779
13779static void ir_push_resume(IrAnalyze *ira, IrSuspendPosition pos) {13780static void ir_push_resume(IrAnalyze *ira, IrSuspendPosition pos) {
13780 IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(pos.basic_block_index);13781 IrBasicBlockSrc *old_bb = ira->zir->basic_block_list.at(pos.basic_block_index);
13781 if (old_bb->in_resume_stack) return;13782 if (old_bb->in_resume_stack) return;
13782 ira->resume_stack.append(pos);13783 ira->resume_stack.append(pos);
13783 old_bb->in_resume_stack = true;13784 old_bb->in_resume_stack = true;
...@@ -13864,7 +13865,7 @@ static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr...@@ -13864,7 +13865,7 @@ static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr
13864static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira,13865static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira,
13865 IrInstSrcUnreachable *unreachable_instruction)13866 IrInstSrcUnreachable *unreachable_instruction)
13866{13867{
13867 if (ir_should_inline(ira->old_irb.exec, unreachable_instruction->base.base.scope)) {13868 if (ir_should_inline(ira->zir, unreachable_instruction->base.base.scope)) {
13868 ir_add_error(ira, &unreachable_instruction->base.base, buf_sprintf("reached unreachable code"));13869 ir_add_error(ira, &unreachable_instruction->base.base, buf_sprintf("reached unreachable code"));
13869 return ir_unreach_error(ira);13870 return ir_unreach_error(ira);
13870 }13871 }
...@@ -16479,7 +16480,7 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instructi...@@ -16479,7 +16480,7 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instructi
16479 }16480 }
16480 }16481 }
1648116482
16482 bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instruction->scope)16483 bool is_comptime = ir_should_inline(ira->zir, source_instruction->scope)
16483 || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes;16484 || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes;
1648416485
16485 IrInstGen *result = ir_get_deref(ira, source_instruction, result_loc, nullptr);16486 IrInstGen *result = ir_get_deref(ira, source_instruction, result_loc, nullptr);
...@@ -16532,7 +16533,7 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc...@@ -16532,7 +16533,7 @@ static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *sourc
16532 AstNode **field_assign_nodes = heap::c_allocator.allocate<AstNode *>(actual_field_count);16533 AstNode **field_assign_nodes = heap::c_allocator.allocate<AstNode *>(actual_field_count);
16533 ZigList<IrInstGen *> const_ptrs = {};16534 ZigList<IrInstGen *> const_ptrs = {};
1653416535
16535 bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope)16536 bool is_comptime = ir_should_inline(ira->zir, source_instr->scope)
16536 || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes;16537 || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes;
1653716538
1653816539
...@@ -16719,7 +16720,7 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -16719,7 +16720,7 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
16719 case ReqCompTimeInvalid:16720 case ReqCompTimeInvalid:
16720 return ira->codegen->invalid_inst_gen;16721 return ira->codegen->invalid_inst_gen;
16721 case ReqCompTimeNo:16722 case ReqCompTimeNo:
16722 is_comptime = ir_should_inline(ira->old_irb.exec, instruction->base.base.scope);16723 is_comptime = ir_should_inline(ira->zir, instruction->base.base.scope);
16723 break;16724 break;
16724 case ReqCompTimeYes:16725 case ReqCompTimeYes:
16725 is_comptime = true;16726 is_comptime = true;
...@@ -18491,7 +18492,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -18491,7 +18492,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1849118492
18492 Buf *bare_name = buf_alloc();18493 Buf *bare_name = buf_alloc();
18493 Buf *full_name = get_anon_type_name(ira->codegen,18494 Buf *full_name = get_anon_type_name(ira->codegen,
18494 ira->old_irb.exec, "opaque", source_instr->scope, source_instr->source_node, bare_name);18495 ira->zir, "opaque", source_instr->scope, source_instr->source_node, bare_name);
18495 return get_opaque_type(ira->codegen,18496 return get_opaque_type(ira->codegen,
18496 source_instr->scope, source_instr->source_node, buf_ptr(full_name), bare_name);18497 source_instr->scope, source_instr->source_node, buf_ptr(full_name), bare_name);
18497 }18498 }
...@@ -18538,7 +18539,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -18538,7 +18539,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
18538 assert(is_slice(slice->type));18539 assert(is_slice(slice->type));
18539 ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet);18540 ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet);
18540 Buf bare_name = BUF_INIT;18541 Buf bare_name = BUF_INIT;
18541 buf_init_from_buf(&err_set_type->name, get_anon_type_name(ira->codegen, ira->old_irb.exec, "error", source_instr->scope, source_instr->source_node, &bare_name));18542 buf_init_from_buf(&err_set_type->name, get_anon_type_name(ira->codegen, ira->zir, "error", source_instr->scope, source_instr->source_node, &bare_name));
18542 err_set_type->size_in_bits = ira->codegen->builtin_types.entry_global_error_set->size_in_bits;18543 err_set_type->size_in_bits = ira->codegen->builtin_types.entry_global_error_set->size_in_bits;
18543 err_set_type->abi_align = ira->codegen->builtin_types.entry_global_error_set->abi_align;18544 err_set_type->abi_align = ira->codegen->builtin_types.entry_global_error_set->abi_align;
18544 err_set_type->abi_size = ira->codegen->builtin_types.entry_global_error_set->abi_size;18545 err_set_type->abi_size = ira->codegen->builtin_types.entry_global_error_set->abi_size;
...@@ -18617,7 +18618,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -18617,7 +18618,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1861718618
18618 ZigType *entry = new_type_table_entry(ZigTypeIdStruct);18619 ZigType *entry = new_type_table_entry(ZigTypeIdStruct);
18619 buf_init_from_buf(&entry->name,18620 buf_init_from_buf(&entry->name,
18620 get_anon_type_name(ira->codegen, ira->old_irb.exec, "struct", source_instr->scope, source_instr->source_node, &entry->name));18621 get_anon_type_name(ira->codegen, ira->zir, "struct", source_instr->scope, source_instr->source_node, &entry->name));
18621 entry->data.structure.decl_node = source_instr->source_node;18622 entry->data.structure.decl_node = source_instr->source_node;
18622 entry->data.structure.fields = alloc_type_struct_fields(fields_len);18623 entry->data.structure.fields = alloc_type_struct_fields(fields_len);
18623 entry->data.structure.fields_by_name.init(fields_len);18624 entry->data.structure.fields_by_name.init(fields_len);
...@@ -18727,7 +18728,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -18727,7 +18728,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1872718728
18728 ZigType *entry = new_type_table_entry(ZigTypeIdEnum);18729 ZigType *entry = new_type_table_entry(ZigTypeIdEnum);
18729 buf_init_from_buf(&entry->name,18730 buf_init_from_buf(&entry->name,
18730 get_anon_type_name(ira->codegen, ira->old_irb.exec, "enum", source_instr->scope, source_instr->source_node, &entry->name));18731 get_anon_type_name(ira->codegen, ira->zir, "enum", source_instr->scope, source_instr->source_node, &entry->name));
18731 entry->data.enumeration.decl_node = source_instr->source_node;18732 entry->data.enumeration.decl_node = source_instr->source_node;
18732 entry->data.enumeration.tag_int_type = tag_type;18733 entry->data.enumeration.tag_int_type = tag_type;
18733 entry->data.enumeration.decls_scope = create_decls_scope(18734 entry->data.enumeration.decls_scope = create_decls_scope(
...@@ -18809,7 +18810,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI...@@ -18809,7 +18810,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1880918810
18810 ZigType *entry = new_type_table_entry(ZigTypeIdUnion);18811 ZigType *entry = new_type_table_entry(ZigTypeIdUnion);
18811 buf_init_from_buf(&entry->name,18812 buf_init_from_buf(&entry->name,
18812 get_anon_type_name(ira->codegen, ira->old_irb.exec, "union", source_instr->scope, source_instr->source_node, &entry->name));18813 get_anon_type_name(ira->codegen, ira->zir, "union", source_instr->scope, source_instr->source_node, &entry->name));
18813 entry->data.unionation.decl_node = source_instr->source_node;18814 entry->data.unionation.decl_node = source_instr->source_node;
18814 entry->data.unionation.fields = heap::c_allocator.allocate<TypeUnionField>(fields_len);18815 entry->data.unionation.fields = heap::c_allocator.allocate<TypeUnionField>(fields_len);
18815 entry->data.unionation.fields_by_name.init(fields_len);18816 entry->data.unionation.fields_by_name.init(fields_len);
...@@ -22004,7 +22005,7 @@ static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *i...@@ -22004,7 +22005,7 @@ static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *i
22004 if (type_is_invalid(msg->value->type))22005 if (type_is_invalid(msg->value->type))
22005 return ir_unreach_error(ira);22006 return ir_unreach_error(ira);
2200622007
22007 if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope)) {22008 if (ir_should_inline(ira->zir, instruction->base.base.scope)) {
22008 ir_add_error(ira, &instruction->base.base, buf_sprintf("encountered @panic at compile-time"));22009 ir_add_error(ira, &instruction->base.base, buf_sprintf("encountered @panic at compile-time"));
22009 return ir_unreach_error(ira);22010 return ir_unreach_error(ira);
22010 }22011 }
...@@ -24077,7 +24078,7 @@ static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume...@@ -24077,7 +24078,7 @@ static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume
24077}24078}
2407824079
24079static IrInstGen *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstSrcSpillBegin *instruction) {24080static IrInstGen *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstSrcSpillBegin *instruction) {
24080 if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope))24081 if (ir_should_inline(ira->zir, instruction->base.base.scope))
24081 return ir_const_void(ira, &instruction->base.base);24082 return ir_const_void(ira, &instruction->base.base);
2408224083
24083 IrInstGen *operand = instruction->operand->child;24084 IrInstGen *operand = instruction->operand->child;
...@@ -24103,7 +24104,7 @@ static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpil...@@ -24103,7 +24104,7 @@ static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpil
24103 if (type_is_invalid(operand->value->type))24104 if (type_is_invalid(operand->value->type))
24104 return ira->codegen->invalid_inst_gen;24105 return ira->codegen->invalid_inst_gen;
2410524106
24106 if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope) ||24107 if (ir_should_inline(ira->zir, instruction->base.base.scope) ||
24107 !type_has_bits(ira->codegen, operand->value->type) ||24108 !type_has_bits(ira->codegen, operand->value->type) ||
24108 instr_is_comptime(operand))24109 instr_is_comptime(operand))
24109 {24110 {
...@@ -24467,7 +24468,7 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc...@@ -24467,7 +24468,7 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
2446724468
24468// This function attempts to evaluate IR code while doing type checking and other analysis.24469// This function attempts to evaluate IR code while doing type checking and other analysis.
24469// It emits to a new IrExecutableGen which is partially evaluated IR code.24470// It emits to a new IrExecutableGen which is partially evaluated IR code.
24470ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen *new_exec,24471ZigType *ir_analyze(CodeGen *codegen, Stage1Zir *old_exec, IrExecutableGen *new_exec,
24471 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr)24472 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr)
24472{24473{
24473 assert(old_exec->first_err_trace_msg == nullptr);24474 assert(old_exec->first_err_trace_msg == nullptr);
...@@ -24481,13 +24482,12 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen...@@ -24481,13 +24482,12 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen
24481 ira->explicit_return_type = expected_type;24482 ira->explicit_return_type = expected_type;
24482 ira->explicit_return_type_source_node = expected_type_source_node;24483 ira->explicit_return_type_source_node = expected_type_source_node;
2448324484
24484 ira->old_irb.codegen = codegen;24485 ira->zir = old_exec;
24485 ira->old_irb.exec = old_exec;
2448624486
24487 ira->new_irb.codegen = codegen;24487 ira->new_irb.codegen = codegen;
24488 ira->new_irb.exec = new_exec;24488 ira->new_irb.exec = new_exec;
2448924489
24490 IrBasicBlockSrc *old_entry_bb = ira->old_irb.exec->basic_block_list.at(0);24490 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);24491 IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr);
24492 ira->new_irb.current_basic_block = new_entry_bb;24492 ira->new_irb.current_basic_block = new_entry_bb;
24493 ira->old_bb_index = 0;24493 ira->old_bb_index = 0;
...@@ -24507,8 +24507,8 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen...@@ -24507,8 +24507,8 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen
24507 get_pointer_to_type(codegen, expected_type, false));24507 get_pointer_to_type(codegen, expected_type, false));
24508 }24508 }
2450924509
24510 while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) {24510 while (ira->old_bb_index < ira->zir->basic_block_list.length) {
24511 IrInstSrc *old_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index);24511 IrInstSrc *old_instruction = ira->zir_current_basic_block->instruction_list.at(ira->instruction_index);
2451224512
24513 if (old_instruction->base.ref_count == 0 && !ir_inst_src_has_side_effects(old_instruction)) {24513 if (old_instruction->base.ref_count == 0 && !ir_inst_src_has_side_effects(old_instruction)) {
24514 ira->instruction_index += 1;24514 ira->instruction_index += 1;
src/stage1/ir.hpp+1-1
...@@ -20,7 +20,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,...@@ -20,7 +20,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
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, IrExecutableSrc *old_executable, IrExecutableGen *new_executable,23ZigType *ir_analyze(CodeGen *g, Stage1Zir *old_executable, IrExecutableGen *new_executable,
24 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *return_ptr);24 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *return_ptr);
2525
26bool ir_inst_gen_has_side_effects(IrInstGen *inst);26bool ir_inst_gen_has_side_effects(IrInstGen *inst);
src/stage1/ir_print.cpp+1-1
...@@ -3395,7 +3395,7 @@ void ir_print_basic_block_gen(CodeGen *codegen, FILE *f, IrBasicBlockGen *bb, in...@@ -3395,7 +3395,7 @@ void ir_print_basic_block_gen(CodeGen *codegen, FILE *f, IrBasicBlockGen *bb, in
3395 ir_print.printed.deinit();3395 ir_print.printed.deinit();
3396}3396}
33973397
3398void ir_print_src(CodeGen *codegen, FILE *f, IrExecutableSrc *executable, int indent_size) {3398void ir_print_src(CodeGen *codegen, FILE *f, Stage1Zir *executable, int indent_size) {
3399 IrPrintSrc ir_print = {};3399 IrPrintSrc ir_print = {};
3400 IrPrintSrc *irp = &ir_print;3400 IrPrintSrc *irp = &ir_print;
3401 irp->codegen = codegen;3401 irp->codegen = codegen;
src/stage1/ir_print.hpp+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
1212
13#include <stdio.h>13#include <stdio.h>
1414
15void ir_print_src(CodeGen *codegen, FILE *f, IrExecutableSrc *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, IrExecutableGen *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);