| author | |
| committer | |
| log | 548ef780707eb2b438015c28d594a59a3f37ba3e |
| tree | 4d08a2a50ababf29bbbc38dbb8c3712b3dcf28b7 |
| parent | 554dd52c36711e9b07f35e20c3427027ad2fa60f |
This field is unneeded because we always have the source node available
in the context that we have a Stage1Zir object.5 files changed, 19 insertions(+), 32 deletions(-)
src/stage1/all_types.hpp+1-6| ... | ... | @@ -114,17 +114,12 @@ struct Stage1Zir { |
| 114 | 114 | ZigList<IrBasicBlockSrc *> basic_block_list; |
| 115 | 115 | Buf *name; |
| 116 | 116 | ZigFn *name_fn; |
| 117 | AstNode *source_node; | |
| 118 | 117 | Scope *begin_scope; |
| 119 | 118 | ErrorMsg *first_err_trace_msg; |
| 120 | 119 | ZigList<Tld *> tld_list; |
| 121 | 120 | |
| 122 | 121 | bool is_inline; |
| 123 | 122 | bool need_err_code_spill; |
| 124 | ||
| 125 | // This is a function for use in the debugger to print | |
| 126 | // the source location. | |
| 127 | void src(); | |
| 128 | 123 | }; |
| 129 | 124 | |
| 130 | 125 | struct Stage1Air { |
| ... | ... | @@ -1638,7 +1633,7 @@ struct ZigFn { |
| 1638 | 1633 | // in the case of async functions this is the implicit return type according to the |
| 1639 | 1634 | // zig source code, not according to zig ir |
| 1640 | 1635 | ZigType *src_implicit_return_type; |
| 1641 | Stage1Zir *ir_executable; | |
| 1636 | Stage1Zir *stage1_zir; | |
| 1642 | 1637 | Stage1Air analyzed_executable; |
| 1643 | 1638 | size_t branch_quota; |
| 1644 | 1639 | AstNode **param_source_nodes; |
src/stage1/analyze.cpp+4-10| ... | ... | @@ -3653,7 +3653,7 @@ static void get_fully_qualified_decl_name(CodeGen *g, Buf *buf, Tld *tld, bool i |
| 3653 | 3653 | |
| 3654 | 3654 | static ZigFn *create_fn_raw(CodeGen *g, bool is_noinline) { |
| 3655 | 3655 | ZigFn *fn_entry = heap::c_allocator.create<ZigFn>(); |
| 3656 | fn_entry->ir_executable = heap::c_allocator.create<Stage1Zir>(); | |
| 3656 | fn_entry->stage1_zir = heap::c_allocator.create<Stage1Zir>(); | |
| 3657 | 3657 | fn_entry->is_noinline = is_noinline; |
| 3658 | 3658 | |
| 3659 | 3659 | return fn_entry; |
| ... | ... | @@ -5129,7 +5129,7 @@ static void analyze_fn_ir(CodeGen *g, ZigFn *fn, AstNode *return_type_node) { |
| 5129 | 5129 | } |
| 5130 | 5130 | size_t backward_branch_count = 0; |
| 5131 | 5131 | size_t backward_branch_quota = max(fn->branch_quota, default_backward_branch_quota); |
| 5132 | ZigType *block_return_type = ir_analyze(g, fn->ir_executable, &fn->analyzed_executable, | |
| 5132 | ZigType *block_return_type = ir_analyze(g, fn->stage1_zir, &fn->analyzed_executable, | |
| 5133 | 5133 | &backward_branch_count, &backward_branch_quota, |
| 5134 | 5134 | fn_type_id->return_type, return_type_node, nullptr, fn); |
| 5135 | 5135 | fn->src_implicit_return_type = block_return_type; |
| ... | ... | @@ -5233,14 +5233,14 @@ static void analyze_fn_body(CodeGen *g, ZigFn *fn_table_entry) { |
| 5233 | 5233 | return; |
| 5234 | 5234 | } |
| 5235 | 5235 | |
| 5236 | if (fn_table_entry->ir_executable->first_err_trace_msg != nullptr) { | |
| 5236 | if (fn_table_entry->stage1_zir->first_err_trace_msg != nullptr) { | |
| 5237 | 5237 | fn_table_entry->anal_state = FnAnalStateInvalid; |
| 5238 | 5238 | return; |
| 5239 | 5239 | } |
| 5240 | 5240 | |
| 5241 | 5241 | if (g->verbose_ir) { |
| 5242 | 5242 | fprintf(stderr, "\nfn %s() { // (IR)\n", buf_ptr(&fn_table_entry->symbol_name)); |
| 5243 | ir_print_src(g, stderr, fn_table_entry->ir_executable, 4); | |
| 5243 | ir_print_src(g, stderr, fn_table_entry->stage1_zir, 4); | |
| 5244 | 5244 | fprintf(stderr, "}\n"); |
| 5245 | 5245 | } |
| 5246 | 5246 | |
| ... | ... | @@ -9858,12 +9858,6 @@ void AstNode::src() { |
| 9858 | 9858 | line, column); |
| 9859 | 9859 | } |
| 9860 | 9860 | |
| 9861 | void Stage1Zir::src() { | |
| 9862 | if (this->source_node != nullptr) { | |
| 9863 | this->source_node->src(); | |
| 9864 | } | |
| 9865 | } | |
| 9866 | ||
| 9867 | 9861 | void Stage1Air::src() { |
| 9868 | 9862 | Stage1Air *it; |
| 9869 | 9863 | for (it = this; it != nullptr && it->source_node != nullptr; it = it->parent_exec) { |
src/stage1/astgen.cpp+3-3| ... | ... | @@ -8031,7 +8031,7 @@ static IrInstSrc *ir_gen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) { |
| 8031 | 8031 | return ir_gen_node_extra(ag, node, scope, LValNone, nullptr); |
| 8032 | 8032 | } |
| 8033 | 8033 | |
| 8034 | bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *ir_executable, | |
| 8034 | bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *stage1_zir, | |
| 8035 | 8035 | ZigFn *fn, bool in_c_import_scope) |
| 8036 | 8036 | { |
| 8037 | 8037 | assert(node->owner); |
| ... | ... | @@ -8042,7 +8042,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *ir_ |
| 8042 | 8042 | ag->codegen = codegen; |
| 8043 | 8043 | ag->fn = fn; |
| 8044 | 8044 | ag->in_c_import_scope = in_c_import_scope; |
| 8045 | ag->exec = ir_executable; | |
| 8045 | ag->exec = stage1_zir; | |
| 8046 | 8046 | ag->main_block_node = node; |
| 8047 | 8047 | |
| 8048 | 8048 | IrBasicBlockSrc *entry_block = ir_create_basic_block(ag, scope, "Entry"); |
| ... | ... | @@ -8076,7 +8076,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *ir_ |
| 8076 | 8076 | bool stage1_astgen_fn(CodeGen *codegen, ZigFn *fn) { |
| 8077 | 8077 | assert(fn != nullptr); |
| 8078 | 8078 | assert(fn->child_scope != nullptr); |
| 8079 | return stage1_astgen(codegen, fn->body_node, fn->child_scope, fn->ir_executable, fn, false); | |
| 8079 | return stage1_astgen(codegen, fn->body_node, fn->child_scope, fn->stage1_zir, fn, false); | |
| 8080 | 8080 | } |
| 8081 | 8081 | |
| 8082 | 8082 | void invalidate_exec(Stage1Zir *exec, ErrorMsg *msg) { |
src/stage1/astgen.hpp+1-1| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | |
| 11 | 11 | #include "all_types.hpp" |
| 12 | 12 | |
| 13 | bool stage1_astgen(CodeGen *g, AstNode *node, Scope *scope, Stage1Zir *ir_executable, | |
| 13 | bool stage1_astgen(CodeGen *g, AstNode *node, Scope *scope, Stage1Zir *stage1_zir, | |
| 14 | 14 | ZigFn *fn, bool in_c_import_scope); |
| 15 | 15 | bool stage1_astgen_fn(CodeGen *g, ZigFn *fn_entry); |
| 16 | 16 |
src/stage1/ir.cpp+10-12| ... | ... | @@ -5592,36 +5592,35 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 5592 | 5592 | if (type_is_invalid(return_ptr->type)) |
| 5593 | 5593 | return ErrorSemanticAnalyzeFail; |
| 5594 | 5594 | |
| 5595 | Stage1Zir *ir_executable = heap::c_allocator.create<Stage1Zir>(); | |
| 5596 | ir_executable->source_node = source_node; | |
| 5597 | ir_executable->name = exec_name; | |
| 5598 | ir_executable->is_inline = true; | |
| 5599 | ir_executable->begin_scope = scope; | |
| 5595 | Stage1Zir *stage1_zir = heap::c_allocator.create<Stage1Zir>(); | |
| 5596 | stage1_zir->name = exec_name; | |
| 5597 | stage1_zir->is_inline = true; | |
| 5598 | stage1_zir->begin_scope = scope; | |
| 5600 | 5599 | |
| 5601 | 5600 | bool in_c_import_scope = c_import_buf != nullptr; |
| 5602 | 5601 | |
| 5603 | if (!stage1_astgen(codegen, node, scope, ir_executable, fn_entry, in_c_import_scope)) | |
| 5602 | if (!stage1_astgen(codegen, node, scope, stage1_zir, fn_entry, in_c_import_scope)) | |
| 5604 | 5603 | return ErrorSemanticAnalyzeFail; |
| 5605 | 5604 | |
| 5606 | if (ir_executable->first_err_trace_msg != nullptr) { | |
| 5607 | codegen->trace_err = ir_executable->first_err_trace_msg; | |
| 5605 | if (stage1_zir->first_err_trace_msg != nullptr) { | |
| 5606 | codegen->trace_err = stage1_zir->first_err_trace_msg; | |
| 5608 | 5607 | return ErrorSemanticAnalyzeFail; |
| 5609 | 5608 | } |
| 5610 | 5609 | |
| 5611 | 5610 | if (codegen->verbose_ir) { |
| 5612 | 5611 | fprintf(stderr, "\n{ // (IR)\n"); |
| 5613 | ir_print_src(codegen, stderr, ir_executable, 2); | |
| 5612 | ir_print_src(codegen, stderr, stage1_zir, 2); | |
| 5614 | 5613 | fprintf(stderr, "}\n"); |
| 5615 | 5614 | } |
| 5616 | 5615 | Stage1Air *analyzed_executable = heap::c_allocator.create<Stage1Air>(); |
| 5617 | 5616 | analyzed_executable->source_node = source_node; |
| 5618 | 5617 | analyzed_executable->parent_exec = parent_exec; |
| 5619 | analyzed_executable->source_exec = ir_executable; | |
| 5618 | analyzed_executable->source_exec = stage1_zir; | |
| 5620 | 5619 | analyzed_executable->name = exec_name; |
| 5621 | 5620 | analyzed_executable->is_inline = true; |
| 5622 | 5621 | analyzed_executable->c_import_buf = c_import_buf; |
| 5623 | 5622 | analyzed_executable->begin_scope = scope; |
| 5624 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, | |
| 5623 | ZigType *result_type = ir_analyze(codegen, stage1_zir, analyzed_executable, | |
| 5625 | 5624 | backward_branch_count, backward_branch_quota, |
| 5626 | 5625 | return_ptr->type->data.pointer.child_type, expected_type_source_node, return_ptr, |
| 5627 | 5626 | fn_entry); |
| ... | ... | @@ -12935,7 +12934,6 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 12935 | 12934 | if (type_is_invalid(impl_fn->type_entry)) |
| 12936 | 12935 | return ira->codegen->invalid_inst_gen; |
| 12937 | 12936 | |
| 12938 | impl_fn->ir_executable->source_node = source_instr->source_node; | |
| 12939 | 12937 | impl_fn->analyzed_executable.source_node = source_instr->source_node; |
| 12940 | 12938 | impl_fn->analyzed_executable.parent_exec = ira->new_irb.exec; |
| 12941 | 12939 | impl_fn->branch_quota = *ira->backward_branch_quota; |