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 {
110110 X64CABIClass_SSE,
111111};
112112
113struct IrExecutableSrc {
113struct Stage1Zir {
114114 ZigList<IrBasicBlockSrc *> basic_block_list;
115115 Buf *name;
116116 ZigFn *name_fn;
......@@ -148,7 +148,7 @@ struct IrExecutableGen {
148148 Buf *c_import_buf;
149149 AstNode *source_node;
150150 IrExecutableGen *parent_exec;
151 IrExecutableSrc *source_exec;
151 Stage1Zir *source_exec;
152152 Scope *begin_scope;
153153 ErrorMsg *first_err_trace_msg;
154154 ZigList<Tld *> tld_list;
......@@ -1651,7 +1651,7 @@ struct ZigFn {
16511651 // in the case of async functions this is the implicit return type according to the
16521652 // zig source code, not according to zig ir
16531653 ZigType *src_implicit_return_type;
1654 IrExecutableSrc *ir_executable;
1654 Stage1Zir *ir_executable;
16551655 IrExecutableGen analyzed_executable;
16561656 size_t prealloc_bbc;
16571657 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
36533653
36543654static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) {
36553655 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
36583658 fn_entry->prealloc_backward_branch_quota = default_backward_branch_quota;
36593659
......@@ -9862,7 +9862,7 @@ void AstNode::src() {
98629862 line, column);
98639863}
98649864
9865void IrExecutableSrc::src() {
9865void Stage1Zir::src() {
98669866 if (this->source_node != nullptr) {
98679867 this->source_node->src();
98689868 }
src/stage1/astgen.cpp+18-11
......@@ -11,6 +11,13 @@
1111#include "os.hpp"
1212#include "parser.hpp"
1313
14struct IrBuilderSrc {
15 CodeGen *codegen;
16 Stage1Zir *exec;
17 IrBasicBlockSrc *current_basic_block;
18 AstNode *main_block_node;
19};
20
1421static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope);
1522static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval,
1623 ResultLoc *result_loc);
......@@ -34,14 +41,14 @@ static void ir_assert_impl(bool ok, IrInst *source_instruction, char const *file
3441 src_assert_impl(ok, source_instruction->source_node, file, line);
3542}
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) {
3845 if (!exec || !exec->source_node || limit < 0) return;
3946 add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here"));
4047
4148 ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1);
4249}
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) {
4552 ErrorMsg *err_msg = add_node_error(codegen, source_node, msg);
4653 invalidate_exec(exec, err_msg);
4754 if (exec->parent_exec) {
......@@ -342,7 +349,7 @@ void destroy_instruction_src(IrInstSrc *inst) {
342349}
343350
344351
345bool ir_should_inline(IrExecutableSrc *exec, Scope *scope) {
352bool ir_should_inline(Stage1Zir *exec, Scope *scope) {
346353 if (exec->is_inline)
347354 return true;
348355
......@@ -364,17 +371,17 @@ static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instr
364371 basic_block->instruction_list.append(instruction);
365372}
366373
367static size_t exec_next_debug_id(IrExecutableSrc *exec) {
374static size_t exec_next_debug_id(Stage1Zir *exec) {
368375 size_t result = exec->next_debug_id;
369376 exec->next_debug_id += 1;
370377 return result;
371378}
372379
373static ZigFn *exec_fn_entry(IrExecutableSrc *exec) {
380static ZigFn *exec_fn_entry(Stage1Zir *exec) {
374381 return exec->fn_entry;
375382}
376383
377static Buf *exec_c_import_buf(IrExecutableSrc *exec) {
384static Buf *exec_c_import_buf(Stage1Zir *exec) {
378385 return exec->c_import_buf;
379386}
380387
......@@ -5891,7 +5898,7 @@ static IrInstSrc *ir_gen_var_decl(IrBuilderSrc *irb, Scope *scope, AstNode *node
58915898 Scope *init_scope = is_comptime_scalar ?
58925899 create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope;
58935900
5894 // Temporarily set the name of the IrExecutableSrc to the VariableDeclaration
5901 // Temporarily set the name of the Stage1Zir to the VariableDeclaration
58955902 // so that the struct or enum from the init expression inherits the name.
58965903 Buf *old_exec_name = irb->exec->name;
58975904 irb->exec->name = variable_declaration->symbol;
......@@ -7511,7 +7518,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o
75117518 return true;
75127519}
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,
75157522 Scope *scope, AstNode *source_node, Buf *out_bare_name)
75167523{
75177524 if (exec != nullptr && exec->name) {
......@@ -8040,7 +8047,7 @@ static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope) {
80408047 return ir_gen_node_extra(irb, node, scope, LValNone, nullptr);
80418048}
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) {
80448051 assert(node->owner);
80458052
80468053 IrBuilderSrc ir_builder = {0};
......@@ -8081,7 +8088,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_e
80818088bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {
80828089 assert(fn_entry);
80838090
8084 IrExecutableSrc *ir_executable = fn_entry->ir_executable;
8091 Stage1Zir *ir_executable = fn_entry->ir_executable;
80858092 AstNode *body_node = fn_entry->body_node;
80868093
80878094 assert(fn_entry->child_scope);
......@@ -8089,7 +8096,7 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) {
80898096 return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable);
80908097}
80918098
8092void invalidate_exec(IrExecutableSrc *exec, ErrorMsg *msg) {
8099void invalidate_exec(Stage1Zir *exec, ErrorMsg *msg) {
80938100 if (exec->first_err_trace_msg != nullptr)
80948101 return;
80958102
src/stage1/astgen.hpp+4-11
......@@ -10,7 +10,7 @@
1010
1111#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);
1414bool ir_gen_fn(CodeGen *g, ZigFn *fn_entry);
1515
1616bool ir_inst_src_has_side_effects(IrInstSrc *inst);
......@@ -21,7 +21,7 @@ ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope,
2121
2222ResultLoc *no_result_loc(void);
2323
24void invalidate_exec(IrExecutableSrc *exec, ErrorMsg *msg);
24void invalidate_exec(Stage1Zir *exec, ErrorMsg *msg);
2525
2626AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node);
2727void 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
2929
3030void destroy_instruction_src(IrInstSrc *inst);
3131
32struct IrBuilderSrc {
33 CodeGen *codegen;
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,
32bool ir_should_inline(Stage1Zir *exec, Scope *scope);
33Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name,
4134 Scope *scope, AstNode *source_node, Buf *out_bare_name);
4235
4336#endif
src/stage1/ir.cpp+59-59
......@@ -33,7 +33,8 @@ struct IrBuilderGen {
3333
3434struct IrAnalyze {
3535 CodeGen *codegen;
36 IrBuilderSrc old_irb;
36 Stage1Zir *zir;
37 IrBasicBlockSrc *zir_current_basic_block;
3738 IrBuilderGen new_irb;
3839 size_t old_bb_index;
3940 size_t instruction_index;
......@@ -476,17 +477,17 @@ static void ira_deref(IrAnalyze *ira) {
476477 }
477478 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 IrBasicBlockSrc *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i];
480 for (size_t bb_i = 0; bb_i < ira->zir->basic_block_list.length; bb_i += 1) {
481 IrBasicBlockSrc *pass1_bb = ira->zir->basic_block_list.items[bb_i];
481482 for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) {
482483 IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i];
483484 destroy_instruction_src(pass1_inst);
484485 }
485486 heap::c_allocator.destroy(pass1_bb);
486487 }
487 ira->old_irb.exec->basic_block_list.deinit();
488 ira->old_irb.exec->tld_list.deinit();
489 heap::c_allocator.destroy(ira->old_irb.exec);
488 ira->zir->basic_block_list.deinit();
489 ira->zir->tld_list.deinit();
490 heap::c_allocator.destroy(ira->zir);
490491 ira->src_implicit_return_type_list.deinit();
491492 ira->resume_stack.deinit();
492493
......@@ -2630,7 +2631,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex
26302631}
26312632
26322633static 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)) {
26342635 ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression"));
26352636 return false;
26362637 }
......@@ -5287,7 +5288,7 @@ static IrBasicBlockGen *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlockSrc *o
52875288static void ir_start_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrBasicBlockSrc *const_predecessor_bb) {
52885289 ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? &old_bb->instruction_list.at(0)->base : nullptr);
52895290 ira->instruction_index = 0;
5290 ira->old_irb.current_basic_block = old_bb;
5291 ira->zir_current_basic_block = old_bb;
52915292 ira->const_predecessor_bb = const_predecessor_bb;
52925293 ira->old_bb_index = old_bb->index;
52935294}
......@@ -5297,23 +5298,23 @@ static IrInstGen *ira_suspend(IrAnalyze *ira, IrInst *old_instruction, IrBasicBl
52975298{
52985299 if (ira->codegen->verbose_ir) {
52995300 fprintf(stderr, "suspend %s_%" PRIu32 " %s_%" PRIu32 " #%" PRIu32 " (%zu,%zu)\n",
5300 ira->old_irb.current_basic_block->name_hint,
5301 ira->old_irb.current_basic_block->debug_id,
5302 ira->old_irb.exec->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->old_irb.current_basic_block->instruction_list.at(ira->instruction_index)->base.debug_id,
5301 ira->zir_current_basic_block->name_hint,
5302 ira->zir_current_basic_block->debug_id,
5303 ira->zir->basic_block_list.at(ira->old_bb_index)->name_hint,
5304 ira->zir->basic_block_list.at(ira->old_bb_index)->debug_id,
5305 ira->zir_current_basic_block->instruction_list.at(ira->instruction_index)->base.debug_id,
53055306 ira->old_bb_index, ira->instruction_index);
53065307 }
53075308 suspend_pos->basic_block_index = ira->old_bb_index;
53085309 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
53125313 // null next_bb means that the caller plans to call ira_resume before returning
53135314 if (next_bb != nullptr) {
53145315 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 assert(ira->old_irb.current_basic_block == next_bb);
5316 ira->zir_current_basic_block = ira->zir->basic_block_list.at(ira->old_bb_index);
5317 assert(ira->zir_current_basic_block == next_bb);
53175318 ira->instruction_index = 0;
53185319 ira->const_predecessor_bb = nullptr;
53195320 next_bb->child = ir_get_new_bb_runtime(ira, next_bb, old_instruction);
......@@ -5328,19 +5329,19 @@ static IrInstGen *ira_resume(IrAnalyze *ira) {
53285329 fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index);
53295330 }
53305331 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 assert(ira->old_irb.current_basic_block->in_resume_stack);
5333 ira->old_irb.current_basic_block->in_resume_stack = false;
5334 ira->old_irb.current_basic_block->suspended = false;
5332 ira->zir_current_basic_block = ira->zir->basic_block_list.at(ira->old_bb_index);
5333 assert(ira->zir_current_basic_block->in_resume_stack);
5334 ira->zir_current_basic_block->in_resume_stack = false;
5335 ira->zir_current_basic_block->suspended = false;
53355336 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);
53375338 if (ira->codegen->verbose_ir) {
5338 fprintf(stderr, "%s_%" PRIu32 " #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint,
5339 ira->old_irb.current_basic_block->debug_id,
5340 ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->base.debug_id);
5339 fprintf(stderr, "%s_%" PRIu32 " #%" PRIu32 "\n", ira->zir_current_basic_block->name_hint,
5340 ira->zir_current_basic_block->debug_id,
5341 ira->zir_current_basic_block->instruction_list.at(pos.instruction_index)->base.debug_id);
53415342 }
53425343 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;
53445345 assert(ira->new_irb.current_basic_block != nullptr);
53455346 return ira->codegen->unreach_instruction;
53465347}
......@@ -5350,8 +5351,8 @@ static void ir_start_next_bb(IrAnalyze *ira) {
53505351
53515352 bool need_repeat = true;
53525353 for (;;) {
5353 while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) {
5354 IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index);
5354 while (ira->old_bb_index < ira->zir->basic_block_list.length) {
5355 IrBasicBlockSrc *old_bb = ira->zir->basic_block_list.at(ira->old_bb_index);
53555356 if (old_bb->child == nullptr && old_bb->suspend_instruction_ref == nullptr) {
53565357 ira->old_bb_index += 1;
53575358 continue;
......@@ -5403,8 +5404,8 @@ static void ir_finish_bb(IrAnalyze *ira) {
54035404 }
54045405 }
54055406 ira->instruction_index += 1;
5406 while (ira->instruction_index < ira->old_irb.current_basic_block->instruction_list.length) {
5407 IrInstSrc *next_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index);
5407 while (ira->instruction_index < ira->zir_current_basic_block->instruction_list.length) {
5408 IrInstSrc *next_instruction = ira->zir_current_basic_block->instruction_list.at(ira->instruction_index);
54085409 if (!next_instruction->is_gen) {
54095410 ir_add_error(ira, &next_instruction->base, buf_sprintf("unreachable code"));
54105411 break;
......@@ -5443,13 +5444,13 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction)
54435444}
54445445
54455446static 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) {
54475448 if (!ir_emit_backward_branch(ira, source_instruction))
54485449 return ir_unreach_error(ira);
54495450 }
54505451
5451 old_bb->child = ira->old_irb.current_basic_block->child;
5452 ir_start_bb(ira, old_bb, ira->old_irb.current_basic_block);
5452 old_bb->child = ira->zir_current_basic_block->child;
5453 ir_start_bb(ira, old_bb, ira->zir_current_basic_block);
54535454 return ira->codegen->unreach_instruction;
54545455}
54555456
......@@ -5587,7 +5588,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node,
55875588 if (type_is_invalid(return_ptr->type))
55885589 return ErrorSemanticAnalyzeFail;
55895590
5590 IrExecutableSrc *ir_executable = heap::c_allocator.create<IrExecutableSrc>();
5591 Stage1Zir *ir_executable = heap::c_allocator.create<Stage1Zir>();
55915592 ir_executable->source_node = source_node;
55925593 ir_executable->parent_exec = parent_exec;
55935594 ir_executable->name = exec_name;
......@@ -6914,7 +6915,7 @@ static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInst* sou
69146915 size_t instr_field_count = actual_type->data.structure.src_field_count;
69156916 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)
69186919 || type_requires_comptime(ira->codegen, wanted_type) == ReqCompTimeYes;
69196920 bool is_comptime = true;
69206921
......@@ -7004,7 +7005,7 @@ static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInst* so
70047005 size_t actual_field_count = wanted_type->data.structure.src_field_count;
70057006 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)
70087009 || type_requires_comptime(ira->codegen, wanted_type) == ReqCompTimeYes;
70097010 bool is_comptime = true;
70107011
......@@ -11419,7 +11420,7 @@ static IrInstGen *ir_analyze_instruction_extern(IrAnalyze *ira, IrInstSrcExtern
1141911420 is_thread_local, expr_type);
1142011421}
1142111422
11422static bool exec_has_err_ret_trace(CodeGen *g, IrExecutableSrc *exec) {
11423static bool exec_has_err_ret_trace(CodeGen *g, Stage1Zir *exec) {
1142311424 ZigFn *fn_entry = exec->fn_entry;
1142411425 return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing;
1142511426}
......@@ -11430,7 +11431,7 @@ static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira,
1143011431 ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false);
1143111432 if (instruction->optional == IrInstErrorReturnTraceNull) {
1143211433 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)) {
1143411435 IrInstGen *result = ir_const(ira, &instruction->base.base, optional_type);
1143511436 ZigValue *out_val = result->value;
1143611437 assert(get_src_ptr_type(optional_type) != nullptr);
......@@ -13213,7 +13214,7 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr,
1321313214 return ira->codegen->invalid_inst_gen;
1321413215 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)) {
1321713218 switch (modifier) {
1321813219 case CallModifierBuiltin:
1321913220 zig_unreachable();
......@@ -13302,7 +13303,7 @@ static IrInstGen *ir_analyze_async_call_extra(IrAnalyze *ira, IrInst* source_ins
1330213303 if (type_is_invalid(fn_ref->value->type))
1330313304 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)) {
1330613307 ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @asyncCall"));
1330713308 return ira->codegen->invalid_inst_gen;
1330813309 }
......@@ -13415,7 +13416,7 @@ static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *cal
1341513416 return ira->codegen->invalid_inst_gen;
1341613417
1341713418 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);
1341913420 CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier;
1342013421
1342113422 if (is_comptime || instr_is_comptime(fn_ref)) {
......@@ -13777,7 +13778,7 @@ static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *in
1377713778}
1377813779
1377913780static 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);
1378113782 if (old_bb->in_resume_stack) return;
1378213783 ira->resume_stack.append(pos);
1378313784 old_bb->in_resume_stack = true;
......@@ -13864,7 +13865,7 @@ static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr
1386413865static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira,
1386513866 IrInstSrcUnreachable *unreachable_instruction)
1386613867{
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)) {
1386813869 ir_add_error(ira, &unreachable_instruction->base.base, buf_sprintf("reached unreachable code"));
1386913870 return ir_unreach_error(ira);
1387013871 }
......@@ -16479,7 +16480,7 @@ static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instructi
1647916480 }
1648016481 }
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)
1648316484 || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes;
1648416485
1648516486 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
1653216533 AstNode **field_assign_nodes = heap::c_allocator.allocate<AstNode *>(actual_field_count);
1653316534 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)
1653616537 || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes;
1653716538
1653816539
......@@ -16719,7 +16720,7 @@ static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
1671916720 case ReqCompTimeInvalid:
1672016721 return ira->codegen->invalid_inst_gen;
1672116722 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);
1672316724 break;
1672416725 case ReqCompTimeYes:
1672516726 is_comptime = true;
......@@ -18491,7 +18492,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1849118492
1849218493 Buf *bare_name = buf_alloc();
1849318494 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);
1849518496 return get_opaque_type(ira->codegen,
1849618497 source_instr->scope, source_instr->source_node, buf_ptr(full_name), bare_name);
1849718498 }
......@@ -18538,7 +18539,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1853818539 assert(is_slice(slice->type));
1853918540 ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet);
1854018541 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));
1854218543 err_set_type->size_in_bits = ira->codegen->builtin_types.entry_global_error_set->size_in_bits;
1854318544 err_set_type->abi_align = ira->codegen->builtin_types.entry_global_error_set->abi_align;
1854418545 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
1861718618
1861818619 ZigType *entry = new_type_table_entry(ZigTypeIdStruct);
1861918620 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));
1862118622 entry->data.structure.decl_node = source_instr->source_node;
1862218623 entry->data.structure.fields = alloc_type_struct_fields(fields_len);
1862318624 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
1872718728
1872818729 ZigType *entry = new_type_table_entry(ZigTypeIdEnum);
1872918730 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));
1873118732 entry->data.enumeration.decl_node = source_instr->source_node;
1873218733 entry->data.enumeration.tag_int_type = tag_type;
1873318734 entry->data.enumeration.decls_scope = create_decls_scope(
......@@ -18809,7 +18810,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeI
1880918810
1881018811 ZigType *entry = new_type_table_entry(ZigTypeIdUnion);
1881118812 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));
1881318814 entry->data.unionation.decl_node = source_instr->source_node;
1881418815 entry->data.unionation.fields = heap::c_allocator.allocate<TypeUnionField>(fields_len);
1881518816 entry->data.unionation.fields_by_name.init(fields_len);
......@@ -22004,7 +22005,7 @@ static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *i
2200422005 if (type_is_invalid(msg->value->type))
2200522006 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)) {
2200822009 ir_add_error(ira, &instruction->base.base, buf_sprintf("encountered @panic at compile-time"));
2200922010 return ir_unreach_error(ira);
2201022011 }
......@@ -24077,7 +24078,7 @@ static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume
2407724078}
2407824079
2407924080static 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))
2408124082 return ir_const_void(ira, &instruction->base.base);
2408224083
2408324084 IrInstGen *operand = instruction->operand->child;
......@@ -24103,7 +24104,7 @@ static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpil
2410324104 if (type_is_invalid(operand->value->type))
2410424105 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) ||
2410724108 !type_has_bits(ira->codegen, operand->value->type) ||
2410824109 instr_is_comptime(operand))
2410924110 {
......@@ -24467,7 +24468,7 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
2446724468
2446824469// This function attempts to evaluate IR code while doing type checking and other analysis.
2446924470// 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,
2447124472 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr)
2447224473{
2447324474 assert(old_exec->first_err_trace_msg == nullptr);
......@@ -24481,13 +24482,12 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen
2448124482 ira->explicit_return_type = expected_type;
2448224483 ira->explicit_return_type_source_node = expected_type_source_node;
2448324484
24484 ira->old_irb.codegen = codegen;
24485 ira->old_irb.exec = old_exec;
24485 ira->zir = old_exec;
2448624486
2448724487 ira->new_irb.codegen = codegen;
2448824488 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);
2449124491 IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr);
2449224492 ira->new_irb.current_basic_block = new_entry_bb;
2449324493 ira->old_bb_index = 0;
......@@ -24507,8 +24507,8 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen
2450724507 get_pointer_to_type(codegen, expected_type, false));
2450824508 }
2450924509
24510 while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) {
24511 IrInstSrc *old_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index);
24510 while (ira->old_bb_index < ira->zir->basic_block_list.length) {
24511 IrInstSrc *old_instruction = ira->zir_current_basic_block->instruction_list.at(ira->instruction_index);
2451224512
2451324513 if (old_instruction->base.ref_count == 0 && !ir_inst_src_has_side_effects(old_instruction)) {
2451424514 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,
2020
2121Error 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,
2424 ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *return_ptr);
2525
2626bool 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
33953395 ir_print.printed.deinit();
33963396}
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) {
33993399 IrPrintSrc ir_print = {};
34003400 IrPrintSrc *irp = &ir_print;
34013401 irp->codegen = codegen;
src/stage1/ir_print.hpp+1-1
......@@ -12,7 +12,7 @@
1212
1313#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);
1616void ir_print_gen(CodeGen *codegen, FILE *f, IrExecutableGen *executable, int indent_size);
1717void ir_print_inst_src(CodeGen *codegen, FILE *f, IrInstSrc *inst, int indent_size);
1818void ir_print_inst_gen(CodeGen *codegen, FILE *f, IrInstGen *inst, int indent_size);