authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-28 15:22:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-28 15:22:03-07:00
logf5d4fe3e17533f83404c16fbceff0dc7bb12cb18
tree2748965ae28b10f937bf0e45b2947861346503a2
parent52b3daa90ee41ba7e059331cf7541eb8570ec236

stage1: memoize strings in the AST

Currently, stage1 runs astgen for every comptime function call, resulting in identifier strings being allocated multiple times, wasting memory. As a workaround until the code is adjusted to make astgen run only once per source node, we memoize the result into the AST. * Rename `ir_gen_*` to `astgen_*` - Oops, meant to do this in a separate commit. My bad. * tokenizer: avoid using designated initializer syntax. MSVC does not support it.

5 files changed, 489 insertions(+), 467 deletions(-)

src/stage1/all_types.hpp+14
......@@ -1123,6 +1123,14 @@ struct AstNodeContainerInitExpr {
11231123 ContainerInitKind kind;
11241124};
11251125
1126struct AstNodeIdentifier {
1127 Buf *name;
1128};
1129
1130struct AstNodeEnumLiteral {
1131 Buf *name;
1132};
1133
11261134struct AstNodeBoolLiteral {
11271135 bool value;
11281136};
......@@ -1204,6 +1212,12 @@ struct AstNode {
12041212 AstNodeAwaitExpr await_expr;
12051213 AstNodeSuspend suspend;
12061214 AstNodeAnyFrameType anyframe_type;
1215
1216 // These are part of an astgen workaround to use less memory by
1217 // memoizing into the AST. Once astgen is modified to only run once
1218 // per corresponding source, this workaround can be removed.
1219 AstNodeIdentifier identifier;
1220 AstNodeEnumLiteral enum_literal;
12071221 } data;
12081222
12091223 // This is a function for use in the debugger to print
src/stage1/astgen.cpp+448-439
......@@ -21,15 +21,15 @@ struct Stage1AstGen {
2121 bool in_c_import_scope;
2222};
2323
24static IrInstSrc *ir_gen_node(Stage1AstGen *ag, AstNode *node, Scope *scope);
25static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval,
24static IrInstSrc *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope);
25static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval,
2626 ResultLoc *result_loc);
2727
2828static IrInstSrc *ir_lval_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *value, LVal lval,
2929 ResultLoc *result_loc);
3030static IrInstSrc *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *inst,
3131 ResultLoc *result_loc);
32static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
32static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
3333 IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node,
3434 LVal lval, ResultLoc *parent_result_loc);
3535static ResultLocCast *ir_build_cast_result_loc(Stage1AstGen *ag, IrInstSrc *dest_type,
......@@ -2890,7 +2890,7 @@ static IrInstSrc *ir_mark_gen(IrInstSrc *instruction) {
28902890 return instruction;
28912891}
28922892
2893static bool ir_gen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, IrInstSrc *err_value) {
2893static bool astgen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, IrInstSrc *err_value) {
28942894 Scope *scope = inner_scope;
28952895 if (is_noreturn != nullptr) *is_noreturn = false;
28962896 while (scope != outer_scope) {
......@@ -2941,7 +2941,7 @@ static bool ir_gen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope
29412941 defer_expr_scope = err_var->child_scope;
29422942 }
29432943
2944 IrInstSrc *defer_expr_value = ir_gen_node(ag, defer_expr_node, defer_expr_scope);
2944 IrInstSrc *defer_expr_value = astgen_node(ag, defer_expr_node, defer_expr_scope);
29452945 if (defer_expr_value == ag->codegen->invalid_inst_src)
29462946 return ag->codegen->invalid_inst_src;
29472947
......@@ -3011,7 +3011,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) {
30113011 return nullptr;
30123012}
30133013
3014static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
3014static IrInstSrc *astgen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
30153015 assert(node->type == NodeTypeReturnExpr);
30163016
30173017 ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope);
......@@ -3038,7 +3038,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L
30383038 // Temporarily set this so that if we return a type it gets the name of the function
30393039 ZigFn *prev_name_fn = ag->exec->name_fn;
30403040 ag->exec->name_fn = ag->fn;
3041 return_value = ir_gen_node_extra(ag, expr_node, scope, LValNone, &result_loc_ret->base);
3041 return_value = astgen_node_extra(ag, expr_node, scope, LValNone, &result_loc_ret->base);
30423042 ag->exec->name_fn = prev_name_fn;
30433043 if (return_value == ag->codegen->invalid_inst_src)
30443044 return ag->codegen->invalid_inst_src;
......@@ -3054,7 +3054,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L
30543054 bool have_err_defers = defer_counts[ReturnKindError] > 0;
30553055 if (!have_err_defers && !ag->codegen->have_err_ret_tracing) {
30563056 // only generate unconditional defers
3057 if (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr))
3057 if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr))
30583058 return ag->codegen->invalid_inst_src;
30593059 IrInstSrc *result = ir_build_return_src(ag, scope, node, nullptr);
30603060 result_loc_ret->base.source_instruction = result;
......@@ -3078,7 +3078,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L
30783078 Stage1ZirBasicBlock *ret_stmt_block = ir_create_basic_block(ag, scope, "RetStmt");
30793079
30803080 ir_set_cursor_at_end_and_append_block(ag, err_block);
3081 if (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, return_value))
3081 if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, return_value))
30823082 return ag->codegen->invalid_inst_src;
30833083 if (ag->codegen->have_err_ret_tracing && !should_inline) {
30843084 ir_build_save_err_ret_addr_src(ag, scope, node);
......@@ -3086,7 +3086,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L
30863086 ir_build_br(ag, scope, node, ret_stmt_block, is_comptime);
30873087
30883088 ir_set_cursor_at_end_and_append_block(ag, ok_block);
3089 if (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr))
3089 if (!astgen_defers_for_block(ag, scope, outer_scope, nullptr, nullptr))
30903090 return ag->codegen->invalid_inst_src;
30913091 ir_build_br(ag, scope, node, ret_stmt_block, is_comptime);
30923092
......@@ -3098,7 +3098,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L
30983098 case ReturnKindError:
30993099 {
31003100 assert(expr_node);
3101 IrInstSrc *err_union_ptr = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
3101 IrInstSrc *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
31023102 if (err_union_ptr == ag->codegen->invalid_inst_src)
31033103 return ag->codegen->invalid_inst_src;
31043104 IrInstSrc *is_err_val = ir_build_test_err_src(ag, scope, node, err_union_ptr, true, false);
......@@ -3126,7 +3126,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L
31263126 ir_build_end_expr(ag, scope, node, err_val, &result_loc_ret->base);
31273127
31283128 bool is_noreturn = false;
3129 if (!ir_gen_defers_for_block(ag, scope, outer_scope, &is_noreturn, err_val)) {
3129 if (!astgen_defers_for_block(ag, scope, outer_scope, &is_noreturn, err_val)) {
31303130 return ag->codegen->invalid_inst_src;
31313131 }
31323132 if (!is_noreturn) {
......@@ -3260,7 +3260,7 @@ static bool is_duplicate_label(CodeGen *g, Scope *scope, AstNode *node, Buf *nam
32603260 return false;
32613261}
32623262
3263static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *block_node, LVal lval,
3263static IrInstSrc *astgen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *block_node, LVal lval,
32643264 ResultLoc *result_loc)
32653265{
32663266 assert(block_node->type == NodeTypeBlock);
......@@ -3313,7 +3313,7 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b
33133313 for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) {
33143314 AstNode *statement_node = block_node->data.block.statements.at(i);
33153315
3316 IrInstSrc *statement_value = ir_gen_node(ag, statement_node, child_scope);
3316 IrInstSrc *statement_value = astgen_node(ag, statement_node, child_scope);
33173317 if (statement_value == ag->codegen->invalid_inst_src) {
33183318 // keep generating all the elements of the block in case of error,
33193319 // we want to collect other compile errors
......@@ -3381,7 +3381,7 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b
33813381
33823382 bool is_return_from_fn = block_node == ag->main_block_node;
33833383 if (!is_return_from_fn) {
3384 if (!ir_gen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr))
3384 if (!astgen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr))
33853385 return ag->codegen->invalid_inst_src;
33863386 }
33873387
......@@ -3407,19 +3407,19 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b
34073407 result_loc_ret->base.id = ResultLocIdReturn;
34083408 ir_build_reset_result(ag, parent_scope, block_node, &result_loc_ret->base);
34093409 ir_mark_gen(ir_build_end_expr(ag, parent_scope, block_node, result, &result_loc_ret->base));
3410 if (!ir_gen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr))
3410 if (!astgen_defers_for_block(ag, child_scope, outer_block_scope, nullptr, nullptr))
34113411 return ag->codegen->invalid_inst_src;
34123412 return ir_mark_gen(ir_build_return_src(ag, child_scope, result->base.source_node, result));
34133413}
34143414
3415static IrInstSrc *ir_gen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) {
3415static IrInstSrc *astgen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) {
34163416 Scope *inner_scope = scope;
34173417 if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) {
34183418 inner_scope = create_comptime_scope(ag->codegen, node, scope);
34193419 }
34203420
3421 IrInstSrc *op1 = ir_gen_node(ag, node->data.bin_op_expr.op1, inner_scope);
3422 IrInstSrc *op2 = ir_gen_node(ag, node->data.bin_op_expr.op2, inner_scope);
3421 IrInstSrc *op1 = astgen_node(ag, node->data.bin_op_expr.op1, inner_scope);
3422 IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, inner_scope);
34233423
34243424 if (op1 == ag->codegen->invalid_inst_src || op2 == ag->codegen->invalid_inst_src)
34253425 return ag->codegen->invalid_inst_src;
......@@ -3427,9 +3427,9 @@ static IrInstSrc *ir_gen_bin_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node
34273427 return ir_build_bin_op(ag, scope, node, op_id, op1, op2, true);
34283428}
34293429
3430static IrInstSrc *ir_gen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3431 IrInstSrc *op1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope);
3432 IrInstSrc *op2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope);
3430static IrInstSrc *astgen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3431 IrInstSrc *op1 = astgen_node(ag, node->data.bin_op_expr.op1, scope);
3432 IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope);
34333433
34343434 if (op1 == ag->codegen->invalid_inst_src || op2 == ag->codegen->invalid_inst_src)
34353435 return ag->codegen->invalid_inst_src;
......@@ -3441,8 +3441,8 @@ static IrInstSrc *ir_gen_merge_err_sets(Stage1AstGen *ag, Scope *scope, AstNode
34413441 return ir_build_merge_err_sets(ag, scope, node, op1, op2, type_name);
34423442}
34433443
3444static IrInstSrc *ir_gen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3445 IrInstSrc *lvalue = ir_gen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr);
3444static IrInstSrc *astgen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3445 IrInstSrc *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr);
34463446 if (lvalue == ag->codegen->invalid_inst_src)
34473447 return ag->codegen->invalid_inst_src;
34483448
......@@ -3452,7 +3452,7 @@ static IrInstSrc *ir_gen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) {
34523452 ir_ref_instruction(lvalue, ag->current_basic_block);
34533453 ir_build_reset_result(ag, scope, node, &result_loc_inst->base);
34543454
3455 IrInstSrc *rvalue = ir_gen_node_extra(ag, node->data.bin_op_expr.op2, scope, LValNone,
3455 IrInstSrc *rvalue = astgen_node_extra(ag, node->data.bin_op_expr.op2, scope, LValNone,
34563456 &result_loc_inst->base);
34573457 if (rvalue == ag->codegen->invalid_inst_src)
34583458 return ag->codegen->invalid_inst_src;
......@@ -3460,12 +3460,12 @@ static IrInstSrc *ir_gen_assign(Stage1AstGen *ag, Scope *scope, AstNode *node) {
34603460 return ir_build_const_void(ag, scope, node);
34613461}
34623462
3463static IrInstSrc *ir_gen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) {
3464 IrInstSrc *lvalue = ir_gen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr);
3463static IrInstSrc *astgen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrBinOp op_id) {
3464 IrInstSrc *lvalue = astgen_node_extra(ag, node->data.bin_op_expr.op1, scope, LValAssign, nullptr);
34653465 if (lvalue == ag->codegen->invalid_inst_src)
34663466 return lvalue;
34673467 IrInstSrc *op1 = ir_build_load_ptr(ag, scope, node->data.bin_op_expr.op1, lvalue);
3468 IrInstSrc *op2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope);
3468 IrInstSrc *op2 = astgen_node(ag, node->data.bin_op_expr.op2, scope);
34693469 if (op2 == ag->codegen->invalid_inst_src)
34703470 return op2;
34713471 IrInstSrc *result = ir_build_bin_op(ag, scope, node, op_id, op1, op2, true);
......@@ -3473,10 +3473,10 @@ static IrInstSrc *ir_gen_assign_op(Stage1AstGen *ag, Scope *scope, AstNode *node
34733473 return ir_build_const_void(ag, scope, node);
34743474}
34753475
3476static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3476static IrInstSrc *astgen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) {
34773477 assert(node->type == NodeTypeBinOpExpr);
34783478
3479 IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope);
3479 IrInstSrc *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope);
34803480 if (val1 == ag->codegen->invalid_inst_src)
34813481 return ag->codegen->invalid_inst_src;
34823482 Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block;
......@@ -3496,7 +3496,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node)
34963496 ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime);
34973497
34983498 ir_set_cursor_at_end_and_append_block(ag, false_block);
3499 IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope);
3499 IrInstSrc *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope);
35003500 if (val2 == ag->codegen->invalid_inst_src)
35013501 return ag->codegen->invalid_inst_src;
35023502 Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block;
......@@ -3515,10 +3515,10 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node)
35153515 return ir_build_phi(ag, scope, node, 2, incoming_blocks, incoming_values, nullptr);
35163516}
35173517
3518static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3518static IrInstSrc *astgen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) {
35193519 assert(node->type == NodeTypeBinOpExpr);
35203520
3521 IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope);
3521 IrInstSrc *val1 = astgen_node(ag, node->data.bin_op_expr.op1, scope);
35223522 if (val1 == ag->codegen->invalid_inst_src)
35233523 return ag->codegen->invalid_inst_src;
35243524 Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block;
......@@ -3538,7 +3538,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node)
35383538 ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime);
35393539
35403540 ir_set_cursor_at_end_and_append_block(ag, true_block);
3541 IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope);
3541 IrInstSrc *val2 = astgen_node(ag, node->data.bin_op_expr.op2, scope);
35423542 if (val2 == ag->codegen->invalid_inst_src)
35433543 return ag->codegen->invalid_inst_src;
35443544 Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block;
......@@ -3591,7 +3591,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, IrIns
35913591 return peer_parent;
35923592}
35933593
3594static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval,
3594static IrInstSrc *astgen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval,
35953595 ResultLoc *result_loc)
35963596{
35973597 assert(node->type == NodeTypeBinOpExpr);
......@@ -3599,7 +3599,7 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *
35993599 AstNode *op1_node = node->data.bin_op_expr.op1;
36003600 AstNode *op2_node = node->data.bin_op_expr.op2;
36013601
3602 IrInstSrc *maybe_ptr = ir_gen_node_extra(ag, op1_node, parent_scope, LValPtr, nullptr);
3602 IrInstSrc *maybe_ptr = astgen_node_extra(ag, op1_node, parent_scope, LValPtr, nullptr);
36033603 if (maybe_ptr == ag->codegen->invalid_inst_src)
36043604 return ag->codegen->invalid_inst_src;
36053605
......@@ -3622,7 +3622,7 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *
36223622 result_loc, is_comptime);
36233623
36243624 ir_set_cursor_at_end_and_append_block(ag, null_block);
3625 IrInstSrc *null_result = ir_gen_node_extra(ag, op2_node, parent_scope, LValNone,
3625 IrInstSrc *null_result = astgen_node_extra(ag, op2_node, parent_scope, LValNone,
36263626 &peer_parent->peers.at(0)->base);
36273627 if (null_result == ag->codegen->invalid_inst_src)
36283628 return ag->codegen->invalid_inst_src;
......@@ -3648,24 +3648,24 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode *
36483648 return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc);
36493649}
36503650
3651static IrInstSrc *ir_gen_error_union(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
3651static IrInstSrc *astgen_error_union(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
36523652 assert(node->type == NodeTypeBinOpExpr);
36533653
36543654 AstNode *op1_node = node->data.bin_op_expr.op1;
36553655 AstNode *op2_node = node->data.bin_op_expr.op2;
36563656
3657 IrInstSrc *err_set = ir_gen_node(ag, op1_node, parent_scope);
3657 IrInstSrc *err_set = astgen_node(ag, op1_node, parent_scope);
36583658 if (err_set == ag->codegen->invalid_inst_src)
36593659 return ag->codegen->invalid_inst_src;
36603660
3661 IrInstSrc *payload = ir_gen_node(ag, op2_node, parent_scope);
3661 IrInstSrc *payload = astgen_node(ag, op2_node, parent_scope);
36623662 if (payload == ag->codegen->invalid_inst_src)
36633663 return ag->codegen->invalid_inst_src;
36643664
36653665 return ir_build_error_union(ag, parent_scope, node, err_set, payload);
36663666}
36673667
3668static IrInstSrc *ir_gen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
3668static IrInstSrc *astgen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
36693669 assert(node->type == NodeTypeBinOpExpr);
36703670
36713671 BinOpType bin_op_type = node->data.bin_op_expr.bin_op;
......@@ -3673,90 +3673,90 @@ static IrInstSrc *ir_gen_bin_op(Stage1AstGen *ag, Scope *scope, AstNode *node, L
36733673 case BinOpTypeInvalid:
36743674 zig_unreachable();
36753675 case BinOpTypeAssign:
3676 return ir_lval_wrap(ag, scope, ir_gen_assign(ag, scope, node), lval, result_loc);
3676 return ir_lval_wrap(ag, scope, astgen_assign(ag, scope, node), lval, result_loc);
36773677 case BinOpTypeAssignTimes:
3678 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpMult), lval, result_loc);
3678 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpMult), lval, result_loc);
36793679 case BinOpTypeAssignTimesWrap:
3680 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpMultWrap), lval, result_loc);
3680 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpMultWrap), lval, result_loc);
36813681 case BinOpTypeAssignDiv:
3682 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc);
3682 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc);
36833683 case BinOpTypeAssignMod:
3684 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc);
3684 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc);
36853685 case BinOpTypeAssignPlus:
3686 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpAdd), lval, result_loc);
3686 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpAdd), lval, result_loc);
36873687 case BinOpTypeAssignPlusWrap:
3688 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpAddWrap), lval, result_loc);
3688 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpAddWrap), lval, result_loc);
36893689 case BinOpTypeAssignMinus:
3690 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpSub), lval, result_loc);
3690 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpSub), lval, result_loc);
36913691 case BinOpTypeAssignMinusWrap:
3692 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpSubWrap), lval, result_loc);
3692 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpSubWrap), lval, result_loc);
36933693 case BinOpTypeAssignBitShiftLeft:
3694 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc);
3694 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc);
36953695 case BinOpTypeAssignBitShiftRight:
3696 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc);
3696 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc);
36973697 case BinOpTypeAssignBitAnd:
3698 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBinAnd), lval, result_loc);
3698 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBinAnd), lval, result_loc);
36993699 case BinOpTypeAssignBitXor:
3700 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBinXor), lval, result_loc);
3700 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBinXor), lval, result_loc);
37013701 case BinOpTypeAssignBitOr:
3702 return ir_lval_wrap(ag, scope, ir_gen_assign_op(ag, scope, node, IrBinOpBinOr), lval, result_loc);
3702 return ir_lval_wrap(ag, scope, astgen_assign_op(ag, scope, node, IrBinOpBinOr), lval, result_loc);
37033703 case BinOpTypeBoolOr:
3704 return ir_lval_wrap(ag, scope, ir_gen_bool_or(ag, scope, node), lval, result_loc);
3704 return ir_lval_wrap(ag, scope, astgen_bool_or(ag, scope, node), lval, result_loc);
37053705 case BinOpTypeBoolAnd:
3706 return ir_lval_wrap(ag, scope, ir_gen_bool_and(ag, scope, node), lval, result_loc);
3706 return ir_lval_wrap(ag, scope, astgen_bool_and(ag, scope, node), lval, result_loc);
37073707 case BinOpTypeCmpEq:
3708 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpEq), lval, result_loc);
3708 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpEq), lval, result_loc);
37093709 case BinOpTypeCmpNotEq:
3710 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpNotEq), lval, result_loc);
3710 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpNotEq), lval, result_loc);
37113711 case BinOpTypeCmpLessThan:
3712 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpLessThan), lval, result_loc);
3712 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpLessThan), lval, result_loc);
37133713 case BinOpTypeCmpGreaterThan:
3714 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterThan), lval, result_loc);
3714 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterThan), lval, result_loc);
37153715 case BinOpTypeCmpLessOrEq:
3716 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpLessOrEq), lval, result_loc);
3716 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpLessOrEq), lval, result_loc);
37173717 case BinOpTypeCmpGreaterOrEq:
3718 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterOrEq), lval, result_loc);
3718 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpCmpGreaterOrEq), lval, result_loc);
37193719 case BinOpTypeBinOr:
3720 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBinOr), lval, result_loc);
3720 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBinOr), lval, result_loc);
37213721 case BinOpTypeBinXor:
3722 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBinXor), lval, result_loc);
3722 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBinXor), lval, result_loc);
37233723 case BinOpTypeBinAnd:
3724 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBinAnd), lval, result_loc);
3724 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBinAnd), lval, result_loc);
37253725 case BinOpTypeBitShiftLeft:
3726 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc);
3726 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBitShiftLeftLossy), lval, result_loc);
37273727 case BinOpTypeBitShiftRight:
3728 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc);
3728 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpBitShiftRightLossy), lval, result_loc);
37293729 case BinOpTypeAdd:
3730 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpAdd), lval, result_loc);
3730 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpAdd), lval, result_loc);
37313731 case BinOpTypeAddWrap:
3732 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpAddWrap), lval, result_loc);
3732 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpAddWrap), lval, result_loc);
37333733 case BinOpTypeSub:
3734 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpSub), lval, result_loc);
3734 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpSub), lval, result_loc);
37353735 case BinOpTypeSubWrap:
3736 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpSubWrap), lval, result_loc);
3736 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpSubWrap), lval, result_loc);
37373737 case BinOpTypeMult:
3738 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpMult), lval, result_loc);
3738 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpMult), lval, result_loc);
37393739 case BinOpTypeMultWrap:
3740 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpMultWrap), lval, result_loc);
3740 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpMultWrap), lval, result_loc);
37413741 case BinOpTypeDiv:
3742 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc);
3742 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpDivUnspecified), lval, result_loc);
37433743 case BinOpTypeMod:
3744 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc);
3744 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpRemUnspecified), lval, result_loc);
37453745 case BinOpTypeArrayCat:
3746 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpArrayCat), lval, result_loc);
3746 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpArrayCat), lval, result_loc);
37473747 case BinOpTypeArrayMult:
3748 return ir_lval_wrap(ag, scope, ir_gen_bin_op_id(ag, scope, node, IrBinOpArrayMult), lval, result_loc);
3748 return ir_lval_wrap(ag, scope, astgen_bin_op_id(ag, scope, node, IrBinOpArrayMult), lval, result_loc);
37493749 case BinOpTypeMergeErrorSets:
3750 return ir_lval_wrap(ag, scope, ir_gen_merge_err_sets(ag, scope, node), lval, result_loc);
3750 return ir_lval_wrap(ag, scope, astgen_merge_err_sets(ag, scope, node), lval, result_loc);
37513751 case BinOpTypeUnwrapOptional:
3752 return ir_gen_orelse(ag, scope, node, lval, result_loc);
3752 return astgen_orelse(ag, scope, node, lval, result_loc);
37533753 case BinOpTypeErrorUnion:
3754 return ir_lval_wrap(ag, scope, ir_gen_error_union(ag, scope, node), lval, result_loc);
3754 return ir_lval_wrap(ag, scope, astgen_error_union(ag, scope, node), lval, result_loc);
37553755 }
37563756 zig_unreachable();
37573757}
37583758
3759static IrInstSrc *ir_gen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3759static IrInstSrc *astgen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) {
37603760 assert(node->type == NodeTypeIntLiteral);
37613761
37623762 RootStruct *root_struct = node->owner->data.structure.root_struct;
......@@ -3765,7 +3765,7 @@ static IrInstSrc *ir_gen_int_lit(Stage1AstGen *ag, Scope *scope, AstNode *node)
37653765 return ir_build_const_bigint(ag, scope, node, bigint);
37663766}
37673767
3768static IrInstSrc *ir_gen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3768static IrInstSrc *astgen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) {
37693769 Error err;
37703770 assert(node->type == NodeTypeFloatLiteral);
37713771
......@@ -3782,7 +3782,7 @@ static IrInstSrc *ir_gen_float_lit(Stage1AstGen *ag, Scope *scope, AstNode *node
37823782 return ir_build_const_bigfloat(ag, scope, node, bigfloat);
37833783}
37843784
3785static IrInstSrc *ir_gen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3785static IrInstSrc *astgen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node) {
37863786 Error err;
37873787 assert(node->type == NodeTypeCharLiteral);
37883788
......@@ -3802,13 +3802,15 @@ static IrInstSrc *ir_gen_char_lit(Stage1AstGen *ag, Scope *scope, AstNode *node)
38023802 return ir_build_const_uint(ag, scope, node, codepoint);
38033803}
38043804
3805static IrInstSrc *ir_gen_null_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3805static IrInstSrc *astgen_null_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
38063806 assert(node->type == NodeTypeNullLiteral);
38073807
38083808 return ir_build_const_null(ag, scope, node);
38093809}
38103810
3811static IrInstSrc *ir_gen_symbol(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
3811static IrInstSrc *astgen_identifier(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
3812 ResultLoc *result_loc)
3813{
38123814 Error err;
38133815 assert(node->type == NodeTypeIdentifier);
38143816
......@@ -3877,13 +3879,13 @@ static IrInstSrc *ir_gen_symbol(Stage1AstGen *ag, Scope *scope, AstNode *node, L
38773879 return ir_build_undeclared_identifier(ag, scope, node, variable_name);
38783880}
38793881
3880static IrInstSrc *ir_gen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
3882static IrInstSrc *astgen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
38813883 ResultLoc *result_loc)
38823884{
38833885 assert(node->type == NodeTypeArrayAccessExpr);
38843886
38853887 AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr;
3886 IrInstSrc *array_ref_instruction = ir_gen_node_extra(ag, array_ref_node, scope, LValPtr, nullptr);
3888 IrInstSrc *array_ref_instruction = astgen_node_extra(ag, array_ref_node, scope, LValPtr, nullptr);
38873889 if (array_ref_instruction == ag->codegen->invalid_inst_src)
38883890 return array_ref_instruction;
38893891
......@@ -3894,7 +3896,7 @@ static IrInstSrc *ir_gen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *n
38943896 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, usize_type_inst, no_result_loc());
38953897
38963898 AstNode *subscript_node = node->data.array_access_expr.subscript;
3897 IrInstSrc *subscript_value = ir_gen_node_extra(ag, subscript_node, scope, LValNone, &result_loc_cast->base);
3899 IrInstSrc *subscript_value = astgen_node_extra(ag, subscript_node, scope, LValNone, &result_loc_cast->base);
38983900 if (subscript_value == ag->codegen->invalid_inst_src)
38993901 return ag->codegen->invalid_inst_src;
39003902
......@@ -3909,20 +3911,20 @@ static IrInstSrc *ir_gen_array_access(Stage1AstGen *ag, Scope *scope, AstNode *n
39093911 return ir_expr_wrap(ag, scope, load_ptr, result_loc);
39103912}
39113913
3912static IrInstSrc *ir_gen_field_access(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3914static IrInstSrc *astgen_field_access(Stage1AstGen *ag, Scope *scope, AstNode *node) {
39133915 assert(node->type == NodeTypeFieldAccessExpr);
39143916
39153917 AstNode *container_ref_node = node->data.field_access_expr.struct_expr;
39163918 Buf *field_name = node->data.field_access_expr.field_name;
39173919
3918 IrInstSrc *container_ref_instruction = ir_gen_node_extra(ag, container_ref_node, scope, LValPtr, nullptr);
3920 IrInstSrc *container_ref_instruction = astgen_node_extra(ag, container_ref_node, scope, LValPtr, nullptr);
39193921 if (container_ref_instruction == ag->codegen->invalid_inst_src)
39203922 return container_ref_instruction;
39213923
39223924 return ir_build_field_ptr(ag, scope, node, container_ref_instruction, field_name, false);
39233925}
39243926
3925static IrInstSrc *ir_gen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrOverflowOp op) {
3927static IrInstSrc *astgen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *node, IrOverflowOp op) {
39263928 assert(node->type == NodeTypeFnCallExpr);
39273929
39283930 AstNode *type_node = node->data.fn_call_expr.params.at(0);
......@@ -3931,26 +3933,26 @@ static IrInstSrc *ir_gen_overflow_op(Stage1AstGen *ag, Scope *scope, AstNode *no
39313933 AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3);
39323934
39333935
3934 IrInstSrc *type_value = ir_gen_node(ag, type_node, scope);
3936 IrInstSrc *type_value = astgen_node(ag, type_node, scope);
39353937 if (type_value == ag->codegen->invalid_inst_src)
39363938 return ag->codegen->invalid_inst_src;
39373939
3938 IrInstSrc *op1 = ir_gen_node(ag, op1_node, scope);
3940 IrInstSrc *op1 = astgen_node(ag, op1_node, scope);
39393941 if (op1 == ag->codegen->invalid_inst_src)
39403942 return ag->codegen->invalid_inst_src;
39413943
3942 IrInstSrc *op2 = ir_gen_node(ag, op2_node, scope);
3944 IrInstSrc *op2 = astgen_node(ag, op2_node, scope);
39433945 if (op2 == ag->codegen->invalid_inst_src)
39443946 return ag->codegen->invalid_inst_src;
39453947
3946 IrInstSrc *result_ptr = ir_gen_node(ag, result_ptr_node, scope);
3948 IrInstSrc *result_ptr = astgen_node(ag, result_ptr_node, scope);
39473949 if (result_ptr == ag->codegen->invalid_inst_src)
39483950 return ag->codegen->invalid_inst_src;
39493951
39503952 return ir_build_overflow_op_src(ag, scope, node, op, type_value, op1, op2, result_ptr);
39513953}
39523954
3953static IrInstSrc *ir_gen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) {
3955static IrInstSrc *astgen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node) {
39543956 assert(node->type == NodeTypeFnCallExpr);
39553957
39563958 AstNode *type_node = node->data.fn_call_expr.params.at(0);
......@@ -3958,26 +3960,26 @@ static IrInstSrc *ir_gen_mul_add(Stage1AstGen *ag, Scope *scope, AstNode *node)
39583960 AstNode *op2_node = node->data.fn_call_expr.params.at(2);
39593961 AstNode *op3_node = node->data.fn_call_expr.params.at(3);
39603962
3961 IrInstSrc *type_value = ir_gen_node(ag, type_node, scope);
3963 IrInstSrc *type_value = astgen_node(ag, type_node, scope);
39623964 if (type_value == ag->codegen->invalid_inst_src)
39633965 return ag->codegen->invalid_inst_src;
39643966
3965 IrInstSrc *op1 = ir_gen_node(ag, op1_node, scope);
3967 IrInstSrc *op1 = astgen_node(ag, op1_node, scope);
39663968 if (op1 == ag->codegen->invalid_inst_src)
39673969 return ag->codegen->invalid_inst_src;
39683970
3969 IrInstSrc *op2 = ir_gen_node(ag, op2_node, scope);
3971 IrInstSrc *op2 = astgen_node(ag, op2_node, scope);
39703972 if (op2 == ag->codegen->invalid_inst_src)
39713973 return ag->codegen->invalid_inst_src;
39723974
3973 IrInstSrc *op3 = ir_gen_node(ag, op3_node, scope);
3975 IrInstSrc *op3 = astgen_node(ag, op3_node, scope);
39743976 if (op3 == ag->codegen->invalid_inst_src)
39753977 return ag->codegen->invalid_inst_src;
39763978
39773979 return ir_build_mul_add_src(ag, scope, node, type_value, op1, op2, op3);
39783980}
39793981
3980static IrInstSrc *ir_gen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node) {
3982static IrInstSrc *astgen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node) {
39813983 for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) {
39823984 if (it_scope->id == ScopeIdDecls) {
39833985 ScopeDecls *decls_scope = (ScopeDecls *)it_scope;
......@@ -3992,7 +3994,7 @@ static IrInstSrc *ir_gen_this(Stage1AstGen *ag, Scope *orig_scope, AstNode *node
39923994 zig_unreachable();
39933995}
39943996
3995static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *await_node, AstNode *call_node,
3997static IrInstSrc *astgen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *await_node, AstNode *call_node,
39963998 LVal lval, ResultLoc *result_loc)
39973999{
39984000 if (call_node->data.fn_call_expr.params.length != 4) {
......@@ -4003,17 +4005,17 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa
40034005 }
40044006
40054007 AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0);
4006 IrInstSrc *bytes = ir_gen_node(ag, bytes_node, scope);
4008 IrInstSrc *bytes = astgen_node(ag, bytes_node, scope);
40074009 if (bytes == ag->codegen->invalid_inst_src)
40084010 return bytes;
40094011
40104012 AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1);
4011 IrInstSrc *ret_ptr = ir_gen_node(ag, ret_ptr_node, scope);
4013 IrInstSrc *ret_ptr = astgen_node(ag, ret_ptr_node, scope);
40124014 if (ret_ptr == ag->codegen->invalid_inst_src)
40134015 return ret_ptr;
40144016
40154017 AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2);
4016 IrInstSrc *fn_ref = ir_gen_node(ag, fn_ref_node, scope);
4018 IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope);
40174019 if (fn_ref == ag->codegen->invalid_inst_src)
40184020 return fn_ref;
40194021
......@@ -4028,7 +4030,7 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa
40284030 IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count);
40294031 for (size_t i = 0; i < arg_count; i += 1) {
40304032 AstNode *arg_node = args_node->data.container_init_expr.entries.at(i);
4031 IrInstSrc *arg = ir_gen_node(ag, arg_node, scope);
4033 IrInstSrc *arg = astgen_node(ag, arg_node, scope);
40324034 if (arg == ag->codegen->invalid_inst_src)
40334035 return arg;
40344036 args[i] = arg;
......@@ -4043,7 +4045,7 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa
40434045 return ag->codegen->invalid_inst_src;
40444046 }
40454047 }
4046 IrInstSrc *args = ir_gen_node(ag, args_node, scope);
4048 IrInstSrc *args = astgen_node(ag, args_node, scope);
40474049 if (args == ag->codegen->invalid_inst_src)
40484050 return args;
40494051
......@@ -4051,11 +4053,11 @@ static IrInstSrc *ir_gen_async_call(Stage1AstGen *ag, Scope *scope, AstNode *awa
40514053 return ir_lval_wrap(ag, scope, call, lval, result_loc);
40524054}
40534055
4054static IrInstSrc *ir_gen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
4056static IrInstSrc *astgen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
40554057 AstNode *fn_ref_node, CallModifier modifier, IrInstSrc *options,
40564058 AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc)
40574059{
4058 IrInstSrc *fn_ref = ir_gen_node(ag, fn_ref_node, scope);
4060 IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope);
40594061 if (fn_ref == ag->codegen->invalid_inst_src)
40604062 return fn_ref;
40614063
......@@ -4071,7 +4073,7 @@ static IrInstSrc *ir_gen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNo
40714073 ir_build_reset_result(ag, scope, source_node, no_result);
40724074 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, arg_type, no_result);
40734075
4074 IrInstSrc *arg = ir_gen_node_extra(ag, arg_node, scope, LValNone, &result_loc_cast->base);
4076 IrInstSrc *arg = astgen_node_extra(ag, arg_node, scope, LValNone, &result_loc_cast->base);
40754077 if (arg == ag->codegen->invalid_inst_src)
40764078 return arg;
40774079
......@@ -4088,7 +4090,7 @@ static IrInstSrc *ir_gen_fn_call_with_args(Stage1AstGen *ag, Scope *scope, AstNo
40884090 return ir_lval_wrap(ag, scope, fn_call, lval, result_loc);
40894091}
40904092
4091static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
4093static IrInstSrc *astgen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
40924094 ResultLoc *result_loc)
40934095{
40944096 assert(node->type == NodeTypeFnCallExpr);
......@@ -4130,7 +4132,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41304132 return ag->codegen->invalid_inst_src;
41314133 } else if (arg_count == 1) {
41324134 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4133 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, sub_scope);
4135 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, sub_scope);
41344136 if (arg0_value == ag->codegen->invalid_inst_src)
41354137 return arg0_value;
41364138
......@@ -4139,7 +4141,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41394141 IrInstSrc **args = heap::c_allocator.allocate<IrInstSrc*>(arg_count);
41404142 for (size_t i = 0; i < arg_count; i += 1) {
41414143 AstNode *arg_node = node->data.fn_call_expr.params.at(i);
4142 IrInstSrc *arg = ir_gen_node(ag, arg_node, sub_scope);
4144 IrInstSrc *arg = astgen_node(ag, arg_node, sub_scope);
41434145 if (arg == ag->codegen->invalid_inst_src)
41444146 return ag->codegen->invalid_inst_src;
41454147 args[i] = arg;
......@@ -4152,7 +4154,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41524154 case BuiltinFnIdSetCold:
41534155 {
41544156 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4155 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4157 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
41564158 if (arg0_value == ag->codegen->invalid_inst_src)
41574159 return arg0_value;
41584160
......@@ -4162,7 +4164,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41624164 case BuiltinFnIdSetRuntimeSafety:
41634165 {
41644166 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4165 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4167 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
41664168 if (arg0_value == ag->codegen->invalid_inst_src)
41674169 return arg0_value;
41684170
......@@ -4172,7 +4174,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41724174 case BuiltinFnIdSetFloatMode:
41734175 {
41744176 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4175 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4177 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
41764178 if (arg0_value == ag->codegen->invalid_inst_src)
41774179 return arg0_value;
41784180
......@@ -4183,7 +4185,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41834185 case BuiltinFnIdBitSizeof:
41844186 {
41854187 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4186 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4188 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
41874189 if (arg0_value == ag->codegen->invalid_inst_src)
41884190 return arg0_value;
41894191
......@@ -4193,7 +4195,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
41934195 case BuiltinFnIdImport:
41944196 {
41954197 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4196 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4198 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
41974199 if (arg0_value == ag->codegen->invalid_inst_src)
41984200 return arg0_value;
41994201
......@@ -4208,7 +4210,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42084210 case BuiltinFnIdCInclude:
42094211 {
42104212 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4211 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4213 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
42124214 if (arg0_value == ag->codegen->invalid_inst_src)
42134215 return arg0_value;
42144216
......@@ -4223,12 +4225,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42234225 case BuiltinFnIdCDefine:
42244226 {
42254227 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4226 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4228 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
42274229 if (arg0_value == ag->codegen->invalid_inst_src)
42284230 return arg0_value;
42294231
42304232 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4231 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4233 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
42324234 if (arg1_value == ag->codegen->invalid_inst_src)
42334235 return arg1_value;
42344236
......@@ -4243,7 +4245,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42434245 case BuiltinFnIdCUndef:
42444246 {
42454247 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4246 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4248 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
42474249 if (arg0_value == ag->codegen->invalid_inst_src)
42484250 return arg0_value;
42494251
......@@ -4258,7 +4260,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42584260 case BuiltinFnIdCompileErr:
42594261 {
42604262 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4261 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4263 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
42624264 if (arg0_value == ag->codegen->invalid_inst_src)
42634265 return arg0_value;
42644266
......@@ -4271,7 +4273,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42714273
42724274 for (size_t i = 0; i < actual_param_count; i += 1) {
42734275 AstNode *arg_node = node->data.fn_call_expr.params.at(i);
4274 args[i] = ir_gen_node(ag, arg_node, scope);
4276 args[i] = astgen_node(ag, arg_node, scope);
42754277 if (args[i] == ag->codegen->invalid_inst_src)
42764278 return ag->codegen->invalid_inst_src;
42774279 }
......@@ -4282,7 +4284,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42824284 case BuiltinFnIdErrName:
42834285 {
42844286 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4285 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4287 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
42864288 if (arg0_value == ag->codegen->invalid_inst_src)
42874289 return arg0_value;
42884290
......@@ -4292,7 +4294,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
42924294 case BuiltinFnIdEmbedFile:
42934295 {
42944296 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4295 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4297 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
42964298 if (arg0_value == ag->codegen->invalid_inst_src)
42974299 return arg0_value;
42984300
......@@ -4303,32 +4305,32 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
43034305 case BuiltinFnIdCmpxchgStrong:
43044306 {
43054307 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4306 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4308 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
43074309 if (arg0_value == ag->codegen->invalid_inst_src)
43084310 return arg0_value;
43094311
43104312 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4311 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4313 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
43124314 if (arg1_value == ag->codegen->invalid_inst_src)
43134315 return arg1_value;
43144316
43154317 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
4316 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
4318 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
43174319 if (arg2_value == ag->codegen->invalid_inst_src)
43184320 return arg2_value;
43194321
43204322 AstNode *arg3_node = node->data.fn_call_expr.params.at(3);
4321 IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope);
4323 IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope);
43224324 if (arg3_value == ag->codegen->invalid_inst_src)
43234325 return arg3_value;
43244326
43254327 AstNode *arg4_node = node->data.fn_call_expr.params.at(4);
4326 IrInstSrc *arg4_value = ir_gen_node(ag, arg4_node, scope);
4328 IrInstSrc *arg4_value = astgen_node(ag, arg4_node, scope);
43274329 if (arg4_value == ag->codegen->invalid_inst_src)
43284330 return arg4_value;
43294331
43304332 AstNode *arg5_node = node->data.fn_call_expr.params.at(5);
4331 IrInstSrc *arg5_value = ir_gen_node(ag, arg5_node, scope);
4333 IrInstSrc *arg5_value = astgen_node(ag, arg5_node, scope);
43324334 if (arg5_value == ag->codegen->invalid_inst_src)
43334335 return arg5_value;
43344336
......@@ -4340,7 +4342,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
43404342 case BuiltinFnIdFence:
43414343 {
43424344 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4343 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4345 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
43444346 if (arg0_value == ag->codegen->invalid_inst_src)
43454347 return arg0_value;
43464348
......@@ -4350,12 +4352,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
43504352 case BuiltinFnIdReduce:
43514353 {
43524354 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4353 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4355 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
43544356 if (arg0_value == ag->codegen->invalid_inst_src)
43554357 return arg0_value;
43564358
43574359 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4358 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4360 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
43594361 if (arg1_value == ag->codegen->invalid_inst_src)
43604362 return arg1_value;
43614363
......@@ -4365,12 +4367,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
43654367 case BuiltinFnIdDivExact:
43664368 {
43674369 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4368 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4370 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
43694371 if (arg0_value == ag->codegen->invalid_inst_src)
43704372 return arg0_value;
43714373
43724374 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4373 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4375 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
43744376 if (arg1_value == ag->codegen->invalid_inst_src)
43754377 return arg1_value;
43764378
......@@ -4380,12 +4382,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
43804382 case BuiltinFnIdDivTrunc:
43814383 {
43824384 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4383 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4385 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
43844386 if (arg0_value == ag->codegen->invalid_inst_src)
43854387 return arg0_value;
43864388
43874389 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4388 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4390 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
43894391 if (arg1_value == ag->codegen->invalid_inst_src)
43904392 return arg1_value;
43914393
......@@ -4395,12 +4397,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
43954397 case BuiltinFnIdDivFloor:
43964398 {
43974399 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4398 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4400 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
43994401 if (arg0_value == ag->codegen->invalid_inst_src)
44004402 return arg0_value;
44014403
44024404 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4403 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4405 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
44044406 if (arg1_value == ag->codegen->invalid_inst_src)
44054407 return arg1_value;
44064408
......@@ -4410,12 +4412,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
44104412 case BuiltinFnIdRem:
44114413 {
44124414 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4413 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4415 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
44144416 if (arg0_value == ag->codegen->invalid_inst_src)
44154417 return arg0_value;
44164418
44174419 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4418 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4420 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
44194421 if (arg1_value == ag->codegen->invalid_inst_src)
44204422 return arg1_value;
44214423
......@@ -4425,12 +4427,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
44254427 case BuiltinFnIdMod:
44264428 {
44274429 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4428 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4430 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
44294431 if (arg0_value == ag->codegen->invalid_inst_src)
44304432 return arg0_value;
44314433
44324434 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4433 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4435 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
44344436 if (arg1_value == ag->codegen->invalid_inst_src)
44354437 return arg1_value;
44364438
......@@ -4453,7 +4455,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
44534455 case BuiltinFnIdRound:
44544456 {
44554457 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4456 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4458 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
44574459 if (arg0_value == ag->codegen->invalid_inst_src)
44584460 return arg0_value;
44594461
......@@ -4463,12 +4465,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
44634465 case BuiltinFnIdTruncate:
44644466 {
44654467 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4466 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4468 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
44674469 if (arg0_value == ag->codegen->invalid_inst_src)
44684470 return arg0_value;
44694471
44704472 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4471 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4473 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
44724474 if (arg1_value == ag->codegen->invalid_inst_src)
44734475 return arg1_value;
44744476
......@@ -4478,12 +4480,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
44784480 case BuiltinFnIdIntCast:
44794481 {
44804482 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4481 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4483 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
44824484 if (arg0_value == ag->codegen->invalid_inst_src)
44834485 return arg0_value;
44844486
44854487 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4486 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4488 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
44874489 if (arg1_value == ag->codegen->invalid_inst_src)
44884490 return arg1_value;
44894491
......@@ -4493,12 +4495,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
44934495 case BuiltinFnIdFloatCast:
44944496 {
44954497 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4496 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4498 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
44974499 if (arg0_value == ag->codegen->invalid_inst_src)
44984500 return arg0_value;
44994501
45004502 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4501 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4503 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
45024504 if (arg1_value == ag->codegen->invalid_inst_src)
45034505 return arg1_value;
45044506
......@@ -4508,12 +4510,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45084510 case BuiltinFnIdErrSetCast:
45094511 {
45104512 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4511 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4513 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45124514 if (arg0_value == ag->codegen->invalid_inst_src)
45134515 return arg0_value;
45144516
45154517 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4516 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4518 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
45174519 if (arg1_value == ag->codegen->invalid_inst_src)
45184520 return arg1_value;
45194521
......@@ -4523,12 +4525,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45234525 case BuiltinFnIdIntToFloat:
45244526 {
45254527 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4526 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4528 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45274529 if (arg0_value == ag->codegen->invalid_inst_src)
45284530 return arg0_value;
45294531
45304532 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4531 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4533 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
45324534 if (arg1_value == ag->codegen->invalid_inst_src)
45334535 return arg1_value;
45344536
......@@ -4538,12 +4540,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45384540 case BuiltinFnIdFloatToInt:
45394541 {
45404542 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4541 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4543 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45424544 if (arg0_value == ag->codegen->invalid_inst_src)
45434545 return arg0_value;
45444546
45454547 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4546 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4548 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
45474549 if (arg1_value == ag->codegen->invalid_inst_src)
45484550 return arg1_value;
45494551
......@@ -4553,7 +4555,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45534555 case BuiltinFnIdErrToInt:
45544556 {
45554557 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4556 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4558 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45574559 if (arg0_value == ag->codegen->invalid_inst_src)
45584560 return arg0_value;
45594561
......@@ -4563,7 +4565,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45634565 case BuiltinFnIdIntToErr:
45644566 {
45654567 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4566 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4568 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45674569 if (arg0_value == ag->codegen->invalid_inst_src)
45684570 return arg0_value;
45694571
......@@ -4573,7 +4575,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45734575 case BuiltinFnIdBoolToInt:
45744576 {
45754577 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4576 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4578 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45774579 if (arg0_value == ag->codegen->invalid_inst_src)
45784580 return arg0_value;
45794581
......@@ -4583,12 +4585,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45834585 case BuiltinFnIdVectorType:
45844586 {
45854587 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4586 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4588 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
45874589 if (arg0_value == ag->codegen->invalid_inst_src)
45884590 return arg0_value;
45894591
45904592 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4591 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4593 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
45924594 if (arg1_value == ag->codegen->invalid_inst_src)
45934595 return arg1_value;
45944596
......@@ -4598,22 +4600,22 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
45984600 case BuiltinFnIdShuffle:
45994601 {
46004602 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4601 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4603 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
46024604 if (arg0_value == ag->codegen->invalid_inst_src)
46034605 return arg0_value;
46044606
46054607 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4606 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4608 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
46074609 if (arg1_value == ag->codegen->invalid_inst_src)
46084610 return arg1_value;
46094611
46104612 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
4611 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
4613 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
46124614 if (arg2_value == ag->codegen->invalid_inst_src)
46134615 return arg2_value;
46144616
46154617 AstNode *arg3_node = node->data.fn_call_expr.params.at(3);
4616 IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope);
4618 IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope);
46174619 if (arg3_value == ag->codegen->invalid_inst_src)
46184620 return arg3_value;
46194621
......@@ -4624,12 +4626,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
46244626 case BuiltinFnIdSplat:
46254627 {
46264628 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4627 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4629 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
46284630 if (arg0_value == ag->codegen->invalid_inst_src)
46294631 return arg0_value;
46304632
46314633 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4632 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4634 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
46334635 if (arg1_value == ag->codegen->invalid_inst_src)
46344636 return arg1_value;
46354637
......@@ -4640,17 +4642,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
46404642 case BuiltinFnIdMemcpy:
46414643 {
46424644 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4643 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4645 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
46444646 if (arg0_value == ag->codegen->invalid_inst_src)
46454647 return arg0_value;
46464648
46474649 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4648 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4650 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
46494651 if (arg1_value == ag->codegen->invalid_inst_src)
46504652 return arg1_value;
46514653
46524654 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
4653 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
4655 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
46544656 if (arg2_value == ag->codegen->invalid_inst_src)
46554657 return arg2_value;
46564658
......@@ -4660,17 +4662,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
46604662 case BuiltinFnIdMemset:
46614663 {
46624664 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4663 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4665 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
46644666 if (arg0_value == ag->codegen->invalid_inst_src)
46654667 return arg0_value;
46664668
46674669 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4668 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4670 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
46694671 if (arg1_value == ag->codegen->invalid_inst_src)
46704672 return arg1_value;
46714673
46724674 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
4673 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
4675 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
46744676 if (arg2_value == ag->codegen->invalid_inst_src)
46754677 return arg2_value;
46764678
......@@ -4680,7 +4682,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
46804682 case BuiltinFnIdWasmMemorySize:
46814683 {
46824684 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4683 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4685 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
46844686 if (arg0_value == ag->codegen->invalid_inst_src)
46854687 return arg0_value;
46864688
......@@ -4690,12 +4692,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
46904692 case BuiltinFnIdWasmMemoryGrow:
46914693 {
46924694 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4693 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4695 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
46944696 if (arg0_value == ag->codegen->invalid_inst_src)
46954697 return arg0_value;
46964698
46974699 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4698 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4700 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
46994701 if (arg1_value == ag->codegen->invalid_inst_src)
47004702 return arg1_value;
47014703
......@@ -4705,12 +4707,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47054707 case BuiltinFnIdField:
47064708 {
47074709 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4708 IrInstSrc *arg0_value = ir_gen_node_extra(ag, arg0_node, scope, LValPtr, nullptr);
4710 IrInstSrc *arg0_value = astgen_node_extra(ag, arg0_node, scope, LValPtr, nullptr);
47094711 if (arg0_value == ag->codegen->invalid_inst_src)
47104712 return arg0_value;
47114713
47124714 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4713 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4715 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
47144716 if (arg1_value == ag->codegen->invalid_inst_src)
47154717 return arg1_value;
47164718
......@@ -4726,12 +4728,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47264728 case BuiltinFnIdHasField:
47274729 {
47284730 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4729 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4731 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
47304732 if (arg0_value == ag->codegen->invalid_inst_src)
47314733 return arg0_value;
47324734
47334735 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4734 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4736 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
47354737 if (arg1_value == ag->codegen->invalid_inst_src)
47364738 return arg1_value;
47374739
......@@ -4741,7 +4743,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47414743 case BuiltinFnIdTypeInfo:
47424744 {
47434745 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4744 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4746 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
47454747 if (arg0_value == ag->codegen->invalid_inst_src)
47464748 return arg0_value;
47474749
......@@ -4751,7 +4753,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47514753 case BuiltinFnIdType:
47524754 {
47534755 AstNode *arg_node = node->data.fn_call_expr.params.at(0);
4754 IrInstSrc *arg = ir_gen_node(ag, arg_node, scope);
4756 IrInstSrc *arg = astgen_node(ag, arg_node, scope);
47554757 if (arg == ag->codegen->invalid_inst_src)
47564758 return arg;
47574759
......@@ -4773,7 +4775,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47734775 return ir_lval_wrap(ag, scope, ir_build_handle_src(ag, scope, node), lval, result_loc);
47744776 case BuiltinFnIdFrameType: {
47754777 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4776 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4778 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
47774779 if (arg0_value == ag->codegen->invalid_inst_src)
47784780 return arg0_value;
47794781
......@@ -4782,7 +4784,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47824784 }
47834785 case BuiltinFnIdFrameSize: {
47844786 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4785 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4787 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
47864788 if (arg0_value == ag->codegen->invalid_inst_src)
47874789 return arg0_value;
47884790
......@@ -4792,7 +4794,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
47924794 case BuiltinFnIdAlignOf:
47934795 {
47944796 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4795 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4797 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
47964798 if (arg0_value == ag->codegen->invalid_inst_src)
47974799 return arg0_value;
47984800
......@@ -4800,19 +4802,19 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48004802 return ir_lval_wrap(ag, scope, align_of, lval, result_loc);
48014803 }
48024804 case BuiltinFnIdAddWithOverflow:
4803 return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpAdd), lval, result_loc);
4805 return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpAdd), lval, result_loc);
48044806 case BuiltinFnIdSubWithOverflow:
4805 return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpSub), lval, result_loc);
4807 return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpSub), lval, result_loc);
48064808 case BuiltinFnIdMulWithOverflow:
4807 return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpMul), lval, result_loc);
4809 return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpMul), lval, result_loc);
48084810 case BuiltinFnIdShlWithOverflow:
4809 return ir_lval_wrap(ag, scope, ir_gen_overflow_op(ag, scope, node, IrOverflowOpShl), lval, result_loc);
4811 return ir_lval_wrap(ag, scope, astgen_overflow_op(ag, scope, node, IrOverflowOpShl), lval, result_loc);
48104812 case BuiltinFnIdMulAdd:
4811 return ir_lval_wrap(ag, scope, ir_gen_mul_add(ag, scope, node), lval, result_loc);
4813 return ir_lval_wrap(ag, scope, astgen_mul_add(ag, scope, node), lval, result_loc);
48124814 case BuiltinFnIdTypeName:
48134815 {
48144816 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4815 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4817 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
48164818 if (arg0_value == ag->codegen->invalid_inst_src)
48174819 return arg0_value;
48184820
......@@ -4822,7 +4824,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48224824 case BuiltinFnIdPanic:
48234825 {
48244826 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4825 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4827 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
48264828 if (arg0_value == ag->codegen->invalid_inst_src)
48274829 return arg0_value;
48284830
......@@ -4832,12 +4834,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48324834 case BuiltinFnIdPtrCast:
48334835 {
48344836 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4835 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4837 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
48364838 if (arg0_value == ag->codegen->invalid_inst_src)
48374839 return arg0_value;
48384840
48394841 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4840 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4842 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
48414843 if (arg1_value == ag->codegen->invalid_inst_src)
48424844 return arg1_value;
48434845
......@@ -4847,7 +4849,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48474849 case BuiltinFnIdBitCast:
48484850 {
48494851 AstNode *dest_type_node = node->data.fn_call_expr.params.at(0);
4850 IrInstSrc *dest_type = ir_gen_node(ag, dest_type_node, scope);
4852 IrInstSrc *dest_type = astgen_node(ag, dest_type_node, scope);
48514853 if (dest_type == ag->codegen->invalid_inst_src)
48524854 return dest_type;
48534855
......@@ -4861,7 +4863,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48614863 ir_build_reset_result(ag, scope, node, &result_loc_bit_cast->base);
48624864
48634865 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4864 IrInstSrc *arg1_value = ir_gen_node_extra(ag, arg1_node, scope, LValNone,
4866 IrInstSrc *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone,
48654867 &result_loc_bit_cast->base);
48664868 if (arg1_value == ag->codegen->invalid_inst_src)
48674869 return arg1_value;
......@@ -4872,14 +4874,14 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48724874 case BuiltinFnIdAs:
48734875 {
48744876 AstNode *dest_type_node = node->data.fn_call_expr.params.at(0);
4875 IrInstSrc *dest_type = ir_gen_node(ag, dest_type_node, scope);
4877 IrInstSrc *dest_type = astgen_node(ag, dest_type_node, scope);
48764878 if (dest_type == ag->codegen->invalid_inst_src)
48774879 return dest_type;
48784880
48794881 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, dest_type, result_loc);
48804882
48814883 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4882 IrInstSrc *arg1_value = ir_gen_node_extra(ag, arg1_node, scope, LValNone,
4884 IrInstSrc *arg1_value = astgen_node_extra(ag, arg1_node, scope, LValNone,
48834885 &result_loc_cast->base);
48844886 if (arg1_value == ag->codegen->invalid_inst_src)
48854887 return arg1_value;
......@@ -4890,12 +4892,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
48904892 case BuiltinFnIdIntToPtr:
48914893 {
48924894 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4893 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4895 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
48944896 if (arg0_value == ag->codegen->invalid_inst_src)
48954897 return arg0_value;
48964898
48974899 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4898 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4900 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
48994901 if (arg1_value == ag->codegen->invalid_inst_src)
49004902 return arg1_value;
49014903
......@@ -4905,7 +4907,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49054907 case BuiltinFnIdPtrToInt:
49064908 {
49074909 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4908 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4910 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
49094911 if (arg0_value == ag->codegen->invalid_inst_src)
49104912 return arg0_value;
49114913
......@@ -4915,7 +4917,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49154917 case BuiltinFnIdTagName:
49164918 {
49174919 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4918 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4920 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
49194921 if (arg0_value == ag->codegen->invalid_inst_src)
49204922 return arg0_value;
49214923
......@@ -4925,17 +4927,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49254927 case BuiltinFnIdFieldParentPtr:
49264928 {
49274929 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4928 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4930 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
49294931 if (arg0_value == ag->codegen->invalid_inst_src)
49304932 return arg0_value;
49314933
49324934 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4933 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4935 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
49344936 if (arg1_value == ag->codegen->invalid_inst_src)
49354937 return arg1_value;
49364938
49374939 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
4938 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
4940 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
49394941 if (arg2_value == ag->codegen->invalid_inst_src)
49404942 return arg2_value;
49414943
......@@ -4946,12 +4948,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49464948 case BuiltinFnIdByteOffsetOf:
49474949 {
49484950 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4949 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4951 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
49504952 if (arg0_value == ag->codegen->invalid_inst_src)
49514953 return arg0_value;
49524954
49534955 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4954 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4956 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
49554957 if (arg1_value == ag->codegen->invalid_inst_src)
49564958 return arg1_value;
49574959
......@@ -4961,12 +4963,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49614963 case BuiltinFnIdBitOffsetOf:
49624964 {
49634965 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
4964 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
4966 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
49654967 if (arg0_value == ag->codegen->invalid_inst_src)
49664968 return arg0_value;
49674969
49684970 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
4969 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
4971 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
49704972 if (arg1_value == ag->codegen->invalid_inst_src)
49714973 return arg1_value;
49724974
......@@ -4980,7 +4982,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49804982 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc());
49814983
49824984 AstNode *options_node = node->data.fn_call_expr.params.at(0);
4983 IrInstSrc *options_inner = ir_gen_node_extra(ag, options_node, scope,
4985 IrInstSrc *options_inner = astgen_node_extra(ag, options_node, scope,
49844986 LValNone, &result_loc_cast->base);
49854987 if (options_inner == ag->codegen->invalid_inst_src)
49864988 return options_inner;
......@@ -4992,7 +4994,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
49924994 if (args_node->data.container_init_expr.kind == ContainerInitKindArray ||
49934995 args_node->data.container_init_expr.entries.length == 0)
49944996 {
4995 return ir_gen_fn_call_with_args(ag, scope, node,
4997 return astgen_fn_call_with_args(ag, scope, node,
49964998 fn_ref_node, CallModifierNone, options,
49974999 args_node->data.container_init_expr.entries.items,
49985000 args_node->data.container_init_expr.entries.length,
......@@ -5003,11 +5005,11 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50035005 return ag->codegen->invalid_inst_src;
50045006 }
50055007 } else {
5006 IrInstSrc *fn_ref = ir_gen_node(ag, fn_ref_node, scope);
5008 IrInstSrc *fn_ref = astgen_node(ag, fn_ref_node, scope);
50075009 if (fn_ref == ag->codegen->invalid_inst_src)
50085010 return fn_ref;
50095011
5010 IrInstSrc *args = ir_gen_node(ag, args_node, scope);
5012 IrInstSrc *args = astgen_node(ag, args_node, scope);
50115013 if (args == ag->codegen->invalid_inst_src)
50125014 return args;
50135015
......@@ -5016,16 +5018,16 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50165018 }
50175019 }
50185020 case BuiltinFnIdAsyncCall:
5019 return ir_gen_async_call(ag, scope, nullptr, node, lval, result_loc);
5021 return astgen_async_call(ag, scope, nullptr, node, lval, result_loc);
50205022 case BuiltinFnIdShlExact:
50215023 {
50225024 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5023 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5025 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
50245026 if (arg0_value == ag->codegen->invalid_inst_src)
50255027 return arg0_value;
50265028
50275029 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5028 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5030 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
50295031 if (arg1_value == ag->codegen->invalid_inst_src)
50305032 return arg1_value;
50315033
......@@ -5035,12 +5037,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50355037 case BuiltinFnIdShrExact:
50365038 {
50375039 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5038 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5040 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
50395041 if (arg0_value == ag->codegen->invalid_inst_src)
50405042 return arg0_value;
50415043
50425044 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5043 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5045 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
50445046 if (arg1_value == ag->codegen->invalid_inst_src)
50455047 return arg1_value;
50465048
......@@ -5050,7 +5052,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50505052 case BuiltinFnIdSetEvalBranchQuota:
50515053 {
50525054 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5053 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5055 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
50545056 if (arg0_value == ag->codegen->invalid_inst_src)
50555057 return arg0_value;
50565058
......@@ -5060,12 +5062,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50605062 case BuiltinFnIdAlignCast:
50615063 {
50625064 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5063 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5065 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
50645066 if (arg0_value == ag->codegen->invalid_inst_src)
50655067 return arg0_value;
50665068
50675069 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5068 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5070 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
50695071 if (arg1_value == ag->codegen->invalid_inst_src)
50705072 return arg1_value;
50715073
......@@ -5074,13 +5076,13 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50745076 }
50755077 case BuiltinFnIdThis:
50765078 {
5077 IrInstSrc *this_inst = ir_gen_this(ag, scope, node);
5079 IrInstSrc *this_inst = astgen_this(ag, scope, node);
50785080 return ir_lval_wrap(ag, scope, this_inst, lval, result_loc);
50795081 }
50805082 case BuiltinFnIdSetAlignStack:
50815083 {
50825084 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5083 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5085 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
50845086 if (arg0_value == ag->codegen->invalid_inst_src)
50855087 return arg0_value;
50865088
......@@ -5095,12 +5097,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
50955097 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc());
50965098
50975099 AstNode *target_node = node->data.fn_call_expr.params.at(0);
5098 IrInstSrc *target_value = ir_gen_node(ag, target_node, scope);
5100 IrInstSrc *target_value = astgen_node(ag, target_node, scope);
50995101 if (target_value == ag->codegen->invalid_inst_src)
51005102 return target_value;
51015103
51025104 AstNode *options_node = node->data.fn_call_expr.params.at(1);
5103 IrInstSrc *options_value = ir_gen_node_extra(ag, options_node,
5105 IrInstSrc *options_value = astgen_node_extra(ag, options_node,
51045106 scope, LValNone, &result_loc_cast->base);
51055107 if (options_value == ag->codegen->invalid_inst_src)
51065108 return options_value;
......@@ -5119,12 +5121,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
51195121 ResultLocCast *result_loc_cast = ir_build_cast_result_loc(ag, options_type_inst, no_result_loc());
51205122
51215123 AstNode *type_node = node->data.fn_call_expr.params.at(0);
5122 IrInstSrc *type_value = ir_gen_node(ag, type_node, scope);
5124 IrInstSrc *type_value = astgen_node(ag, type_node, scope);
51235125 if (type_value == ag->codegen->invalid_inst_src)
51245126 return type_value;
51255127
51265128 AstNode *options_node = node->data.fn_call_expr.params.at(1);
5127 IrInstSrc *options_value = ir_gen_node_extra(ag, options_node,
5129 IrInstSrc *options_value = astgen_node_extra(ag, options_node,
51285130 scope, LValNone, &result_loc_cast->base);
51295131 if (options_value == ag->codegen->invalid_inst_src)
51305132 return options_value;
......@@ -5144,27 +5146,27 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
51445146 case BuiltinFnIdAtomicRmw:
51455147 {
51465148 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5147 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5149 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
51485150 if (arg0_value == ag->codegen->invalid_inst_src)
51495151 return arg0_value;
51505152
51515153 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5152 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5154 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
51535155 if (arg1_value == ag->codegen->invalid_inst_src)
51545156 return arg1_value;
51555157
51565158 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
5157 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
5159 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
51585160 if (arg2_value == ag->codegen->invalid_inst_src)
51595161 return arg2_value;
51605162
51615163 AstNode *arg3_node = node->data.fn_call_expr.params.at(3);
5162 IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope);
5164 IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope);
51635165 if (arg3_value == ag->codegen->invalid_inst_src)
51645166 return arg3_value;
51655167
51665168 AstNode *arg4_node = node->data.fn_call_expr.params.at(4);
5167 IrInstSrc *arg4_value = ir_gen_node(ag, arg4_node, scope);
5169 IrInstSrc *arg4_value = astgen_node(ag, arg4_node, scope);
51685170 if (arg4_value == ag->codegen->invalid_inst_src)
51695171 return arg4_value;
51705172
......@@ -5175,17 +5177,17 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
51755177 case BuiltinFnIdAtomicLoad:
51765178 {
51775179 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5178 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5180 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
51795181 if (arg0_value == ag->codegen->invalid_inst_src)
51805182 return arg0_value;
51815183
51825184 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5183 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5185 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
51845186 if (arg1_value == ag->codegen->invalid_inst_src)
51855187 return arg1_value;
51865188
51875189 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
5188 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
5190 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
51895191 if (arg2_value == ag->codegen->invalid_inst_src)
51905192 return arg2_value;
51915193
......@@ -5195,22 +5197,22 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
51955197 case BuiltinFnIdAtomicStore:
51965198 {
51975199 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5198 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5200 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
51995201 if (arg0_value == ag->codegen->invalid_inst_src)
52005202 return arg0_value;
52015203
52025204 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5203 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5205 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
52045206 if (arg1_value == ag->codegen->invalid_inst_src)
52055207 return arg1_value;
52065208
52075209 AstNode *arg2_node = node->data.fn_call_expr.params.at(2);
5208 IrInstSrc *arg2_value = ir_gen_node(ag, arg2_node, scope);
5210 IrInstSrc *arg2_value = astgen_node(ag, arg2_node, scope);
52095211 if (arg2_value == ag->codegen->invalid_inst_src)
52105212 return arg2_value;
52115213
52125214 AstNode *arg3_node = node->data.fn_call_expr.params.at(3);
5213 IrInstSrc *arg3_value = ir_gen_node(ag, arg3_node, scope);
5215 IrInstSrc *arg3_value = astgen_node(ag, arg3_node, scope);
52145216 if (arg3_value == ag->codegen->invalid_inst_src)
52155217 return arg3_value;
52165218
......@@ -5221,12 +5223,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
52215223 case BuiltinFnIdIntToEnum:
52225224 {
52235225 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5224 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5226 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
52255227 if (arg0_value == ag->codegen->invalid_inst_src)
52265228 return arg0_value;
52275229
52285230 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5229 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5231 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
52305232 if (arg1_value == ag->codegen->invalid_inst_src)
52315233 return arg1_value;
52325234
......@@ -5236,7 +5238,7 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
52365238 case BuiltinFnIdEnumToInt:
52375239 {
52385240 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5239 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5241 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
52405242 if (arg0_value == ag->codegen->invalid_inst_src)
52415243 return arg0_value;
52425244
......@@ -5250,12 +5252,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
52505252 case BuiltinFnIdBitReverse:
52515253 {
52525254 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5253 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5255 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
52545256 if (arg0_value == ag->codegen->invalid_inst_src)
52555257 return arg0_value;
52565258
52575259 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5258 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5260 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
52595261 if (arg1_value == ag->codegen->invalid_inst_src)
52605262 return arg1_value;
52615263
......@@ -5284,12 +5286,12 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
52845286 case BuiltinFnIdHasDecl:
52855287 {
52865288 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
5287 IrInstSrc *arg0_value = ir_gen_node(ag, arg0_node, scope);
5289 IrInstSrc *arg0_value = astgen_node(ag, arg0_node, scope);
52885290 if (arg0_value == ag->codegen->invalid_inst_src)
52895291 return arg0_value;
52905292
52915293 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
5292 IrInstSrc *arg1_value = ir_gen_node(ag, arg1_node, scope);
5294 IrInstSrc *arg1_value = astgen_node(ag, arg1_node, scope);
52935295 if (arg1_value == ag->codegen->invalid_inst_src)
52945296 return arg1_value;
52955297
......@@ -5299,18 +5301,18 @@ static IrInstSrc *ir_gen_builtin_fn_call(Stage1AstGen *ag, Scope *scope, AstNode
52995301 case BuiltinFnIdUnionInit:
53005302 {
53015303 AstNode *union_type_node = node->data.fn_call_expr.params.at(0);
5302 IrInstSrc *union_type_inst = ir_gen_node(ag, union_type_node, scope);
5304 IrInstSrc *union_type_inst = astgen_node(ag, union_type_node, scope);
53035305 if (union_type_inst == ag->codegen->invalid_inst_src)
53045306 return union_type_inst;
53055307
53065308 AstNode *name_node = node->data.fn_call_expr.params.at(1);
5307 IrInstSrc *name_inst = ir_gen_node(ag, name_node, scope);
5309 IrInstSrc *name_inst = astgen_node(ag, name_node, scope);
53085310 if (name_inst == ag->codegen->invalid_inst_src)
53095311 return name_inst;
53105312
53115313 AstNode *init_node = node->data.fn_call_expr.params.at(2);
53125314
5313 return ir_gen_union_init_expr(ag, scope, node, union_type_inst, name_inst, init_node,
5315 return astgen_union_init_expr(ag, scope, node, union_type_inst, name_inst, init_node,
53145316 lval, result_loc);
53155317 }
53165318 case BuiltinFnIdSrc:
......@@ -5334,13 +5336,13 @@ static ScopeNoSuspend *get_scope_nosuspend(Scope *scope) {
53345336 return nullptr;
53355337}
53365338
5337static IrInstSrc *ir_gen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
5339static IrInstSrc *astgen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
53385340 ResultLoc *result_loc)
53395341{
53405342 assert(node->type == NodeTypeFnCallExpr);
53415343
53425344 if (node->data.fn_call_expr.modifier == CallModifierBuiltin)
5343 return ir_gen_builtin_fn_call(ag, scope, node, lval, result_loc);
5345 return astgen_builtin_fn_call(ag, scope, node, lval, result_loc);
53445346
53455347 bool is_nosuspend = get_scope_nosuspend(scope) != nullptr;
53465348 CallModifier modifier = node->data.fn_call_expr.modifier;
......@@ -5349,16 +5351,16 @@ static IrInstSrc *ir_gen_fn_call(Stage1AstGen *ag, Scope *scope, AstNode *node,
53495351 }
53505352
53515353 AstNode *fn_ref_node = node->data.fn_call_expr.fn_ref_expr;
5352 return ir_gen_fn_call_with_args(ag, scope, node, fn_ref_node, modifier,
5354 return astgen_fn_call_with_args(ag, scope, node, fn_ref_node, modifier,
53535355 nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc);
53545356}
53555357
5356static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
5358static IrInstSrc *astgen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
53575359 ResultLoc *result_loc)
53585360{
53595361 assert(node->type == NodeTypeIfBoolExpr);
53605362
5361 IrInstSrc *condition = ir_gen_node(ag, node->data.if_bool_expr.condition, scope);
5363 IrInstSrc *condition = astgen_node(ag, node->data.if_bool_expr.condition, scope);
53625364 if (condition == ag->codegen->invalid_inst_src)
53635365 return ag->codegen->invalid_inst_src;
53645366
......@@ -5384,7 +5386,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n
53845386 ir_set_cursor_at_end_and_append_block(ag, then_block);
53855387
53865388 Scope *subexpr_scope = create_runtime_scope(ag->codegen, node, scope, is_comptime);
5387 IrInstSrc *then_expr_result = ir_gen_node_extra(ag, then_node, subexpr_scope, lval,
5389 IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, subexpr_scope, lval,
53885390 &peer_parent->peers.at(0)->base);
53895391 if (then_expr_result == ag->codegen->invalid_inst_src)
53905392 return ag->codegen->invalid_inst_src;
......@@ -5395,7 +5397,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n
53955397 ir_set_cursor_at_end_and_append_block(ag, else_block);
53965398 IrInstSrc *else_expr_result;
53975399 if (else_node) {
5398 else_expr_result = ir_gen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base);
5400 else_expr_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base);
53995401 if (else_expr_result == ag->codegen->invalid_inst_src)
54005402 return ag->codegen->invalid_inst_src;
54015403 } else {
......@@ -5418,19 +5420,19 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n
54185420 return ir_expr_wrap(ag, scope, phi, result_loc);
54195421}
54205422
5421static IrInstSrc *ir_gen_prefix_op_id_lval(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) {
5423static IrInstSrc *astgen_prefix_op_id_lval(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) {
54225424 assert(node->type == NodeTypePrefixOpExpr);
54235425 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
54245426
5425 IrInstSrc *value = ir_gen_node_extra(ag, expr_node, scope, lval, nullptr);
5427 IrInstSrc *value = astgen_node_extra(ag, expr_node, scope, lval, nullptr);
54265428 if (value == ag->codegen->invalid_inst_src)
54275429 return value;
54285430
54295431 return ir_build_un_op(ag, scope, node, op_id, value);
54305432}
54315433
5432static IrInstSrc *ir_gen_prefix_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id) {
5433 return ir_gen_prefix_op_id_lval(ag, scope, node, op_id, LValNone);
5434static IrInstSrc *astgen_prefix_op_id(Stage1AstGen *ag, Scope *scope, AstNode *node, IrUnOp op_id) {
5435 return astgen_prefix_op_id_lval(ag, scope, node, op_id, LValNone);
54345436}
54355437
54365438static IrInstSrc *ir_expr_wrap(Stage1AstGen *ag, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc) {
......@@ -5499,7 +5501,7 @@ static Error token_number_literal_u32(Stage1AstGen *ag, AstNode *source_node,
54995501
55005502}
55015503
5502static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
5504static IrInstSrc *astgen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
55035505 Error err;
55045506 assert(node->type == NodeTypePointerType);
55055507
......@@ -5516,7 +5518,7 @@ static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n
55165518
55175519 IrInstSrc *sentinel;
55185520 if (sentinel_expr != nullptr) {
5519 sentinel = ir_gen_node(ag, sentinel_expr, scope);
5521 sentinel = astgen_node(ag, sentinel_expr, scope);
55205522 if (sentinel == ag->codegen->invalid_inst_src)
55215523 return sentinel;
55225524 } else {
......@@ -5525,14 +5527,14 @@ static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n
55255527
55265528 IrInstSrc *align_value;
55275529 if (align_expr != nullptr) {
5528 align_value = ir_gen_node(ag, align_expr, scope);
5530 align_value = astgen_node(ag, align_expr, scope);
55295531 if (align_value == ag->codegen->invalid_inst_src)
55305532 return align_value;
55315533 } else {
55325534 align_value = nullptr;
55335535 }
55345536
5535 IrInstSrc *child_type = ir_gen_node(ag, expr_node, scope);
5537 IrInstSrc *child_type = astgen_node(ag, expr_node, scope);
55365538 if (child_type == ag->codegen->invalid_inst_src)
55375539 return child_type;
55385540
......@@ -5564,10 +5566,10 @@ static IrInstSrc *ir_gen_pointer_type(Stage1AstGen *ag, Scope *scope, AstNode *n
55645566 ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero);
55655567}
55665568
5567static IrInstSrc *ir_gen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
5569static IrInstSrc *astgen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
55685570 AstNode *expr_node, LVal lval, ResultLoc *result_loc)
55695571{
5570 IrInstSrc *err_union_ptr = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
5572 IrInstSrc *err_union_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
55715573 if (err_union_ptr == ag->codegen->invalid_inst_src)
55725574 return ag->codegen->invalid_inst_src;
55735575
......@@ -5582,18 +5584,18 @@ static IrInstSrc *ir_gen_catch_unreachable(Stage1AstGen *ag, Scope *scope, AstNo
55825584 return ir_expr_wrap(ag, scope, load_ptr, result_loc);
55835585}
55845586
5585static IrInstSrc *ir_gen_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *node) {
5587static IrInstSrc *astgen_bool_not(Stage1AstGen *ag, Scope *scope, AstNode *node) {
55865588 assert(node->type == NodeTypePrefixOpExpr);
55875589 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
55885590
5589 IrInstSrc *value = ir_gen_node(ag, expr_node, scope);
5591 IrInstSrc *value = astgen_node(ag, expr_node, scope);
55905592 if (value == ag->codegen->invalid_inst_src)
55915593 return ag->codegen->invalid_inst_src;
55925594
55935595 return ir_build_bool_not(ag, scope, node, value);
55945596}
55955597
5596static IrInstSrc *ir_gen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
5598static IrInstSrc *astgen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
55975599 ResultLoc *result_loc)
55985600{
55995601 assert(node->type == NodeTypePrefixOpExpr);
......@@ -5604,24 +5606,24 @@ static IrInstSrc *ir_gen_prefix_op_expr(Stage1AstGen *ag, Scope *scope, AstNode
56045606 case PrefixOpInvalid:
56055607 zig_unreachable();
56065608 case PrefixOpBoolNot:
5607 return ir_lval_wrap(ag, scope, ir_gen_bool_not(ag, scope, node), lval, result_loc);
5609 return ir_lval_wrap(ag, scope, astgen_bool_not(ag, scope, node), lval, result_loc);
56085610 case PrefixOpBinNot:
5609 return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpBinNot), lval, result_loc);
5611 return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpBinNot), lval, result_loc);
56105612 case PrefixOpNegation:
5611 return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpNegation), lval, result_loc);
5613 return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpNegation), lval, result_loc);
56125614 case PrefixOpNegationWrap:
5613 return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpNegationWrap), lval, result_loc);
5615 return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpNegationWrap), lval, result_loc);
56145616 case PrefixOpOptional:
5615 return ir_lval_wrap(ag, scope, ir_gen_prefix_op_id(ag, scope, node, IrUnOpOptional), lval, result_loc);
5617 return ir_lval_wrap(ag, scope, astgen_prefix_op_id(ag, scope, node, IrUnOpOptional), lval, result_loc);
56165618 case PrefixOpAddrOf: {
56175619 AstNode *expr_node = node->data.prefix_op_expr.primary_expr;
5618 return ir_lval_wrap(ag, scope, ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr), lval, result_loc);
5620 return ir_lval_wrap(ag, scope, astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr), lval, result_loc);
56195621 }
56205622 }
56215623 zig_unreachable();
56225624}
56235625
5624static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
5626static IrInstSrc *astgen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *source_node,
56255627 IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node,
56265628 LVal lval, ResultLoc *parent_result_loc)
56275629{
......@@ -5635,7 +5637,7 @@ static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode
56355637 ir_ref_instruction(field_ptr, ag->current_basic_block);
56365638 ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base);
56375639
5638 IrInstSrc *expr_value = ir_gen_node_extra(ag, expr_node, scope, LValNone,
5640 IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone,
56395641 &result_loc_inst->base);
56405642 if (expr_value == ag->codegen->invalid_inst_src)
56415643 return expr_value;
......@@ -5646,7 +5648,7 @@ static IrInstSrc *ir_gen_union_init_expr(Stage1AstGen *ag, Scope *scope, AstNode
56465648 return ir_lval_wrap(ag, scope, init_union, lval, parent_result_loc);
56475649}
56485650
5649static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
5651static IrInstSrc *astgen_container_init_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
56505652 ResultLoc *parent_result_loc)
56515653{
56525654 assert(node->type == NodeTypeContainerInitExpr);
......@@ -5667,14 +5669,14 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast
56675669 }
56685670 IrInstSrc *sentinel;
56695671 if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) {
5670 sentinel = ir_gen_node(ag, container_init_expr->type->data.inferred_array_type.sentinel, scope);
5672 sentinel = astgen_node(ag, container_init_expr->type->data.inferred_array_type.sentinel, scope);
56715673 if (sentinel == ag->codegen->invalid_inst_src)
56725674 return sentinel;
56735675 } else {
56745676 sentinel = nullptr;
56755677 }
56765678
5677 IrInstSrc *elem_type = ir_gen_node(ag,
5679 IrInstSrc *elem_type = astgen_node(ag,
56785680 container_init_expr->type->data.inferred_array_type.child_type, scope);
56795681 if (elem_type == ag->codegen->invalid_inst_src)
56805682 return elem_type;
......@@ -5682,7 +5684,7 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast
56825684 IrInstSrc *item_count_inst = ir_build_const_usize(ag, scope, node, item_count);
56835685 container_type = ir_build_array_type(ag, scope, node, item_count_inst, sentinel, elem_type);
56845686 } else {
5685 container_type = ir_gen_node(ag, container_init_expr->type, scope);
5687 container_type = astgen_node(ag, container_init_expr->type, scope);
56865688 if (container_type == ag->codegen->invalid_inst_src)
56875689 return container_type;
56885690 }
......@@ -5721,7 +5723,7 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast
57215723 ir_ref_instruction(field_ptr, ag->current_basic_block);
57225724 ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base);
57235725
5724 IrInstSrc *expr_value = ir_gen_node_extra(ag, expr_node, scope, LValNone,
5726 IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone,
57255727 &result_loc_inst->base);
57265728 if (expr_value == ag->codegen->invalid_inst_src)
57275729 return expr_value;
......@@ -5758,7 +5760,7 @@ static IrInstSrc *ir_gen_container_init_expr(Stage1AstGen *ag, Scope *scope, Ast
57585760 ir_ref_instruction(elem_ptr, ag->current_basic_block);
57595761 ir_build_reset_result(ag, scope, expr_node, &result_loc_inst->base);
57605762
5761 IrInstSrc *expr_value = ir_gen_node_extra(ag, expr_node, scope, LValNone,
5763 IrInstSrc *expr_value = astgen_node_extra(ag, expr_node, scope, LValNone,
57625764 &result_loc_inst->base);
57635765 if (expr_value == ag->codegen->invalid_inst_src)
57645766 return expr_value;
......@@ -5812,7 +5814,7 @@ static void build_decl_var_and_init(Stage1AstGen *ag, Scope *scope, AstNode *sou
58125814 ir_build_var_decl_src(ag, scope, source_node, var, nullptr, alloca);
58135815}
58145816
5815static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) {
5817static IrInstSrc *astgen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node) {
58165818 assert(node->type == NodeTypeVariableDeclaration);
58175819
58185820 AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration;
......@@ -5827,7 +5829,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node)
58275829
58285830 IrInstSrc *type_instruction;
58295831 if (variable_declaration->type != nullptr) {
5830 type_instruction = ir_gen_node(ag, variable_declaration->type, comptime_scope);
5832 type_instruction = astgen_node(ag, variable_declaration->type, comptime_scope);
58315833 if (type_instruction == ag->codegen->invalid_inst_src)
58325834 return type_instruction;
58335835 } else {
......@@ -5853,7 +5855,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node)
58535855
58545856 IrInstSrc *align_value = nullptr;
58555857 if (variable_declaration->align_expr != nullptr) {
5856 align_value = ir_gen_node(ag, variable_declaration->align_expr, comptime_scope);
5858 align_value = astgen_node(ag, variable_declaration->align_expr, comptime_scope);
58575859 if (align_value == ag->codegen->invalid_inst_src)
58585860 return align_value;
58595861 }
......@@ -5888,7 +5890,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node)
58885890 // so that the struct or enum from the init expression inherits the name.
58895891 Buf *old_exec_name = ag->exec->name;
58905892 ag->exec->name = variable_declaration->symbol;
5891 IrInstSrc *init_value = ir_gen_node_extra(ag, variable_declaration->expr, init_scope,
5893 IrInstSrc *init_value = astgen_node_extra(ag, variable_declaration->expr, init_scope,
58925894 LValNone, init_result_loc);
58935895 ag->exec->name = old_exec_name;
58945896
......@@ -5904,7 +5906,7 @@ static IrInstSrc *ir_gen_var_decl(Stage1AstGen *ag, Scope *scope, AstNode *node)
59045906 return ir_build_var_decl_src(ag, scope, node, var, align_value, alloca);
59055907}
59065908
5907static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
5909static IrInstSrc *astgen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
59085910 ResultLoc *result_loc)
59095911{
59105912 assert(node->type == NodeTypeWhileExpr);
......@@ -5942,7 +5944,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
59425944 payload_scope = subexpr_scope;
59435945 }
59445946 ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, payload_scope);
5945 IrInstSrc *err_val_ptr = ir_gen_node_extra(ag, node->data.while_expr.condition, subexpr_scope,
5947 IrInstSrc *err_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope,
59465948 LValPtr, nullptr);
59475949 if (err_val_ptr == ag->codegen->invalid_inst_src)
59485950 return err_val_ptr;
......@@ -5990,8 +5992,8 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
59905992
59915993 // Note the body block of the loop is not the place that lval and result_loc are used -
59925994 // it's actually in break statements, handled similarly to return statements.
5993 // That is why we set those values in loop_scope above and not in this ir_gen_node call.
5994 IrInstSrc *body_result = ir_gen_node(ag, node->data.while_expr.body, &loop_scope->base);
5995 // That is why we set those values in loop_scope above and not in this astgen_node call.
5996 IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base);
59955997 if (body_result == ag->codegen->invalid_inst_src)
59965998 return body_result;
59975999
......@@ -6006,7 +6008,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
60066008
60076009 if (continue_expr_node) {
60086010 ir_set_cursor_at_end_and_append_block(ag, continue_block);
6009 IrInstSrc *expr_result = ir_gen_node(ag, continue_expr_node, payload_scope);
6011 IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, payload_scope);
60106012 if (expr_result == ag->codegen->invalid_inst_src)
60116013 return expr_result;
60126014 if (!instr_is_unreachable(expr_result)) {
......@@ -6032,7 +6034,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
60326034 }
60336035 ResultLocPeer *peer_result = create_peer_result(peer_parent);
60346036 peer_parent->peers.append(peer_result);
6035 IrInstSrc *else_result = ir_gen_node_extra(ag, else_node, err_scope, lval, &peer_result->base);
6037 IrInstSrc *else_result = astgen_node_extra(ag, else_node, err_scope, lval, &peer_result->base);
60366038 if (else_result == ag->codegen->invalid_inst_src)
60376039 return else_result;
60386040 if (!instr_is_unreachable(else_result))
......@@ -6063,7 +6065,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
60636065 true, false, false, is_comptime);
60646066 Scope *child_scope = payload_var->child_scope;
60656067 ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, child_scope);
6066 IrInstSrc *maybe_val_ptr = ir_gen_node_extra(ag, node->data.while_expr.condition, subexpr_scope,
6068 IrInstSrc *maybe_val_ptr = astgen_node_extra(ag, node->data.while_expr.condition, subexpr_scope,
60676069 LValPtr, nullptr);
60686070 if (maybe_val_ptr == ag->codegen->invalid_inst_src)
60696071 return maybe_val_ptr;
......@@ -6108,8 +6110,8 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
61086110
61096111 // Note the body block of the loop is not the place that lval and result_loc are used -
61106112 // it's actually in break statements, handled similarly to return statements.
6111 // That is why we set those values in loop_scope above and not in this ir_gen_node call.
6112 IrInstSrc *body_result = ir_gen_node(ag, node->data.while_expr.body, &loop_scope->base);
6113 // That is why we set those values in loop_scope above and not in this astgen_node call.
6114 IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base);
61136115 if (body_result == ag->codegen->invalid_inst_src)
61146116 return body_result;
61156117
......@@ -6124,7 +6126,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
61246126
61256127 if (continue_expr_node) {
61266128 ir_set_cursor_at_end_and_append_block(ag, continue_block);
6127 IrInstSrc *expr_result = ir_gen_node(ag, continue_expr_node, child_scope);
6129 IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, child_scope);
61286130 if (expr_result == ag->codegen->invalid_inst_src)
61296131 return expr_result;
61306132 if (!instr_is_unreachable(expr_result)) {
......@@ -6142,7 +6144,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
61426144 }
61436145 ResultLocPeer *peer_result = create_peer_result(peer_parent);
61446146 peer_parent->peers.append(peer_result);
6145 else_result = ir_gen_node_extra(ag, else_node, scope, lval, &peer_result->base);
6147 else_result = astgen_node_extra(ag, else_node, scope, lval, &peer_result->base);
61466148 if (else_result == ag->codegen->invalid_inst_src)
61476149 return else_result;
61486150 if (!instr_is_unreachable(else_result))
......@@ -6166,7 +6168,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
61666168 return ir_expr_wrap(ag, scope, phi, result_loc);
61676169 } else {
61686170 ir_set_cursor_at_end_and_append_block(ag, cond_block);
6169 IrInstSrc *cond_val = ir_gen_node(ag, node->data.while_expr.condition, scope);
6171 IrInstSrc *cond_val = astgen_node(ag, node->data.while_expr.condition, scope);
61706172 if (cond_val == ag->codegen->invalid_inst_src)
61716173 return cond_val;
61726174 Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block;
......@@ -6204,8 +6206,8 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
62046206
62056207 // Note the body block of the loop is not the place that lval and result_loc are used -
62066208 // it's actually in break statements, handled similarly to return statements.
6207 // That is why we set those values in loop_scope above and not in this ir_gen_node call.
6208 IrInstSrc *body_result = ir_gen_node(ag, node->data.while_expr.body, &loop_scope->base);
6209 // That is why we set those values in loop_scope above and not in this astgen_node call.
6210 IrInstSrc *body_result = astgen_node(ag, node->data.while_expr.body, &loop_scope->base);
62096211 if (body_result == ag->codegen->invalid_inst_src)
62106212 return body_result;
62116213
......@@ -6220,7 +6222,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
62206222
62216223 if (continue_expr_node) {
62226224 ir_set_cursor_at_end_and_append_block(ag, continue_block);
6223 IrInstSrc *expr_result = ir_gen_node(ag, continue_expr_node, subexpr_scope);
6225 IrInstSrc *expr_result = astgen_node(ag, continue_expr_node, subexpr_scope);
62246226 if (expr_result == ag->codegen->invalid_inst_src)
62256227 return expr_result;
62266228 if (!instr_is_unreachable(expr_result)) {
......@@ -6239,7 +6241,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
62396241 ResultLocPeer *peer_result = create_peer_result(peer_parent);
62406242 peer_parent->peers.append(peer_result);
62416243
6242 else_result = ir_gen_node_extra(ag, else_node, subexpr_scope, lval, &peer_result->base);
6244 else_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_result->base);
62436245 if (else_result == ag->codegen->invalid_inst_src)
62446246 return else_result;
62456247 if (!instr_is_unreachable(else_result))
......@@ -6264,7 +6266,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
62646266 }
62656267}
62666268
6267static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval,
6269static IrInstSrc *astgen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval,
62686270 ResultLoc *result_loc)
62696271{
62706272 assert(node->type == NodeTypeForExpr);
......@@ -6283,7 +6285,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode
62836285
62846286 ScopeExpr *spill_scope = create_expr_scope(ag->codegen, node, parent_scope);
62856287
6286 IrInstSrc *array_val_ptr = ir_gen_node_extra(ag, array_node, &spill_scope->base, LValPtr, nullptr);
6288 IrInstSrc *array_val_ptr = astgen_node_extra(ag, array_node, &spill_scope->base, LValPtr, nullptr);
62876289 if (array_val_ptr == ag->codegen->invalid_inst_src)
62886290 return array_val_ptr;
62896291
......@@ -6362,8 +6364,8 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode
63626364
63636365 // Note the body block of the loop is not the place that lval and result_loc are used -
63646366 // it's actually in break statements, handled similarly to return statements.
6365 // That is why we set those values in loop_scope above and not in this ir_gen_node call.
6366 IrInstSrc *body_result = ir_gen_node(ag, body_node, &loop_scope->base);
6367 // That is why we set those values in loop_scope above and not in this astgen_node call.
6368 IrInstSrc *body_result = astgen_node(ag, body_node, &loop_scope->base);
63676369 if (body_result == ag->codegen->invalid_inst_src)
63686370 return ag->codegen->invalid_inst_src;
63696371
......@@ -6390,7 +6392,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode
63906392 }
63916393 ResultLocPeer *peer_result = create_peer_result(peer_parent);
63926394 peer_parent->peers.append(peer_result);
6393 else_result = ir_gen_node_extra(ag, else_node, parent_scope, LValNone, &peer_result->base);
6395 else_result = astgen_node_extra(ag, else_node, parent_scope, LValNone, &peer_result->base);
63946396 if (else_result == ag->codegen->invalid_inst_src)
63956397 return else_result;
63966398 if (!instr_is_unreachable(else_result))
......@@ -6415,19 +6417,25 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode
64156417 return ir_lval_wrap(ag, parent_scope, phi, lval, result_loc);
64166418}
64176419
6418static IrInstSrc *ir_gen_bool_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6420static IrInstSrc *astgen_bool_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
64196421 assert(node->type == NodeTypeBoolLiteral);
64206422 return ir_build_const_bool(ag, scope, node, node->data.bool_literal.value);
64216423}
64226424
6423static IrInstSrc *ir_gen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6425static IrInstSrc *astgen_enum_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
64246426 assert(node->type == NodeTypeEnumLiteral);
6425 RootStruct *root_struct = node->owner->data.structure.root_struct;
6426 Buf *name = token_identifier_buf(root_struct, node->main_token + 1);
6427 return ir_build_const_enum_literal(ag, scope, node, name);
6427 // Currently, stage1 runs astgen for every comptime function call,
6428 // resulting the allocation here wasting memory. As a workaround until
6429 // the code is adjusted to make astgen run only once per source node,
6430 // we memoize the result into the AST here.
6431 if (node->data.enum_literal.name == nullptr) {
6432 RootStruct *root_struct = node->owner->data.structure.root_struct;
6433 node->data.enum_literal.name = token_identifier_buf(root_struct, node->main_token + 1);
6434 }
6435 return ir_build_const_enum_literal(ag, scope, node, node->data.enum_literal.name);
64286436}
64296437
6430static IrInstSrc *ir_gen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6438static IrInstSrc *astgen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
64316439 Error err;
64326440 assert(node->type == NodeTypeStringLiteral);
64336441
......@@ -6465,10 +6473,11 @@ static IrInstSrc *ir_gen_string_literal(Stage1AstGen *ag, Scope *scope, AstNode
64656473 } else {
64666474 zig_unreachable();
64676475 }
6476
64686477 return ir_build_const_str_lit(ag, scope, node, str);
64696478}
64706479
6471static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6480static IrInstSrc *astgen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
64726481 assert(node->type == NodeTypeArrayType);
64736482
64746483 AstNode *size_node = node->data.array_type.size;
......@@ -6483,7 +6492,7 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod
64836492
64846493 IrInstSrc *sentinel;
64856494 if (sentinel_expr != nullptr) {
6486 sentinel = ir_gen_node(ag, sentinel_expr, comptime_scope);
6495 sentinel = astgen_node(ag, sentinel_expr, comptime_scope);
64876496 if (sentinel == ag->codegen->invalid_inst_src)
64886497 return sentinel;
64896498 } else {
......@@ -6508,11 +6517,11 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod
65086517 return ag->codegen->invalid_inst_src;
65096518 }
65106519
6511 IrInstSrc *size_value = ir_gen_node(ag, size_node, comptime_scope);
6520 IrInstSrc *size_value = astgen_node(ag, size_node, comptime_scope);
65126521 if (size_value == ag->codegen->invalid_inst_src)
65136522 return size_value;
65146523
6515 IrInstSrc *child_type = ir_gen_node(ag, child_type_node, comptime_scope);
6524 IrInstSrc *child_type = astgen_node(ag, child_type_node, comptime_scope);
65166525 if (child_type == ag->codegen->invalid_inst_src)
65176526 return child_type;
65186527
......@@ -6520,14 +6529,14 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod
65206529 } else {
65216530 IrInstSrc *align_value;
65226531 if (align_expr != nullptr) {
6523 align_value = ir_gen_node(ag, align_expr, comptime_scope);
6532 align_value = astgen_node(ag, align_expr, comptime_scope);
65246533 if (align_value == ag->codegen->invalid_inst_src)
65256534 return align_value;
65266535 } else {
65276536 align_value = nullptr;
65286537 }
65296538
6530 IrInstSrc *child_type = ir_gen_node(ag, child_type_node, comptime_scope);
6539 IrInstSrc *child_type = astgen_node(ag, child_type_node, comptime_scope);
65316540 if (child_type == ag->codegen->invalid_inst_src)
65326541 return child_type;
65336542
......@@ -6536,14 +6545,14 @@ static IrInstSrc *ir_gen_array_type(Stage1AstGen *ag, Scope *scope, AstNode *nod
65366545 }
65376546}
65386547
6539static IrInstSrc *ir_gen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6548static IrInstSrc *astgen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
65406549 assert(node->type == NodeTypeAnyFrameType);
65416550
65426551 AstNode *payload_type_node = node->data.anyframe_type.payload_type;
65436552 IrInstSrc *payload_type_value = nullptr;
65446553
65456554 if (payload_type_node != nullptr) {
6546 payload_type_value = ir_gen_node(ag, payload_type_node, scope);
6555 payload_type_value = astgen_node(ag, payload_type_node, scope);
65476556 if (payload_type_value == ag->codegen->invalid_inst_src)
65486557 return payload_type_value;
65496558
......@@ -6552,16 +6561,16 @@ static IrInstSrc *ir_gen_anyframe_type(Stage1AstGen *ag, Scope *scope, AstNode *
65526561 return ir_build_anyframe_type(ag, scope, node, payload_type_value);
65536562}
65546563
6555static IrInstSrc *ir_gen_undefined_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6564static IrInstSrc *astgen_undefined_literal(Stage1AstGen *ag, Scope *scope, AstNode *node) {
65566565 assert(node->type == NodeTypeUndefinedLiteral);
65576566 return ir_build_const_undefined(ag, scope, node);
65586567}
65596568
6560static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) {
6569static IrInstSrc *astgen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node) {
65616570 assert(node->type == NodeTypeAsmExpr);
65626571 AstNodeAsmExpr *asm_expr = &node->data.asm_expr;
65636572
6564 IrInstSrc *asm_template = ir_gen_node(ag, asm_expr->asm_template, scope);
6573 IrInstSrc *asm_template = astgen_node(ag, asm_expr->asm_template, scope);
65656574 if (asm_template == ag->codegen->invalid_inst_src)
65666575 return ag->codegen->invalid_inst_src;
65676576
......@@ -6601,7 +6610,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node)
66016610 if (asm_output->return_type) {
66026611 return_count += 1;
66036612
6604 IrInstSrc *return_type = ir_gen_node(ag, asm_output->return_type, scope);
6613 IrInstSrc *return_type = astgen_node(ag, asm_output->return_type, scope);
66056614 if (return_type == ag->codegen->invalid_inst_src)
66066615 return ag->codegen->invalid_inst_src;
66076616 if (return_count > 1) {
......@@ -6612,7 +6621,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node)
66126621 output_types[i] = return_type;
66136622 } else {
66146623 Buf *variable_name = asm_output->variable_name;
6615 // TODO there is some duplication here with ir_gen_symbol. I need to do a full audit of how
6624 // TODO there is some duplication here with astgen_identifier. I need to do a full audit of how
66166625 // inline assembly works. https://github.com/ziglang/zig/issues/215
66176626 ZigVar *var = find_variable(ag->codegen, scope, variable_name, nullptr);
66186627 if (var) {
......@@ -6635,7 +6644,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node)
66356644 }
66366645 for (size_t i = 0; i < asm_expr->input_list.length; i += 1) {
66376646 AsmInput *asm_input = asm_expr->input_list.at(i);
6638 IrInstSrc *input_value = ir_gen_node(ag, asm_input->expr, scope);
6647 IrInstSrc *input_value = astgen_node(ag, asm_input->expr, scope);
66396648 if (input_value == ag->codegen->invalid_inst_src)
66406649 return ag->codegen->invalid_inst_src;
66416650
......@@ -6646,7 +6655,7 @@ static IrInstSrc *ir_gen_asm_expr(Stage1AstGen *ag, Scope *scope, AstNode *node)
66466655 output_vars, return_count, is_volatile, false);
66476656}
66486657
6649static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
6658static IrInstSrc *astgen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
66506659 ResultLoc *result_loc)
66516660{
66526661 assert(node->type == NodeTypeIfOptional);
......@@ -6660,7 +6669,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod
66606669 ScopeExpr *spill_scope = create_expr_scope(ag->codegen, expr_node, scope);
66616670 spill_scope->spill_harder = true;
66626671
6663 IrInstSrc *maybe_val_ptr = ir_gen_node_extra(ag, expr_node, &spill_scope->base, LValPtr, nullptr);
6672 IrInstSrc *maybe_val_ptr = astgen_node_extra(ag, expr_node, &spill_scope->base, LValPtr, nullptr);
66646673 if (maybe_val_ptr == ag->codegen->invalid_inst_src)
66656674 return maybe_val_ptr;
66666675
......@@ -6701,7 +6710,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod
67016710 } else {
67026711 var_scope = subexpr_scope;
67036712 }
6704 IrInstSrc *then_expr_result = ir_gen_node_extra(ag, then_node, var_scope, lval,
6713 IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval,
67056714 &peer_parent->peers.at(0)->base);
67066715 if (then_expr_result == ag->codegen->invalid_inst_src)
67076716 return then_expr_result;
......@@ -6712,7 +6721,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod
67126721 ir_set_cursor_at_end_and_append_block(ag, else_block);
67136722 IrInstSrc *else_expr_result;
67146723 if (else_node) {
6715 else_expr_result = ir_gen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base);
6724 else_expr_result = astgen_node_extra(ag, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base);
67166725 if (else_expr_result == ag->codegen->invalid_inst_src)
67176726 return else_expr_result;
67186727 } else {
......@@ -6735,7 +6744,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod
67356744 return ir_expr_wrap(ag, scope, phi, result_loc);
67366745}
67376746
6738static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
6747static IrInstSrc *astgen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
67396748 ResultLoc *result_loc)
67406749{
67416750 assert(node->type == NodeTypeIfErrorExpr);
......@@ -6748,7 +6757,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
67486757 Buf *var_symbol = node->data.if_err_expr.var_symbol;
67496758 Buf *err_symbol = node->data.if_err_expr.err_symbol;
67506759
6751 IrInstSrc *err_val_ptr = ir_gen_node_extra(ag, target_node, scope, LValPtr, nullptr);
6760 IrInstSrc *err_val_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr);
67526761 if (err_val_ptr == ag->codegen->invalid_inst_src)
67536762 return err_val_ptr;
67546763
......@@ -6784,7 +6793,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
67846793 } else {
67856794 var_scope = subexpr_scope;
67866795 }
6787 IrInstSrc *then_expr_result = ir_gen_node_extra(ag, then_node, var_scope, lval,
6796 IrInstSrc *then_expr_result = astgen_node_extra(ag, then_node, var_scope, lval,
67886797 &peer_parent->peers.at(0)->base);
67896798 if (then_expr_result == ag->codegen->invalid_inst_src)
67906799 return then_expr_result;
......@@ -6810,7 +6819,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
68106819 } else {
68116820 err_var_scope = subexpr_scope;
68126821 }
6813 else_expr_result = ir_gen_node_extra(ag, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base);
6822 else_expr_result = astgen_node_extra(ag, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base);
68146823 if (else_expr_result == ag->codegen->invalid_inst_src)
68156824 return else_expr_result;
68166825 } else {
......@@ -6833,7 +6842,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
68336842 return ir_expr_wrap(ag, scope, phi, result_loc);
68346843}
68356844
6836static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node,
6845static bool astgen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node,
68376846 Stage1ZirBasicBlock *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime,
68386847 IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len,
68396848 ZigList<Stage1ZirBasicBlock *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values,
......@@ -6877,7 +6886,7 @@ static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw
68776886 child_scope = scope;
68786887 }
68796888
6880 IrInstSrc *expr_result = ir_gen_node_extra(ag, expr_node, child_scope, lval, result_loc);
6889 IrInstSrc *expr_result = astgen_node_extra(ag, expr_node, child_scope, lval, result_loc);
68816890 if (expr_result == ag->codegen->invalid_inst_src)
68826891 return false;
68836892 if (!instr_is_unreachable(expr_result))
......@@ -6887,13 +6896,13 @@ static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *sw
68876896 return true;
68886897}
68896898
6890static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
6899static IrInstSrc *astgen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
68916900 ResultLoc *result_loc)
68926901{
68936902 assert(node->type == NodeTypeSwitchExpr);
68946903
68956904 AstNode *target_node = node->data.switch_expr.expr;
6896 IrInstSrc *target_value_ptr = ir_gen_node_extra(ag, target_node, scope, LValPtr, nullptr);
6905 IrInstSrc *target_value_ptr = astgen_node_extra(ag, target_node, scope, LValPtr, nullptr);
68976906 if (target_value_ptr == ag->codegen->invalid_inst_src)
68986907 return target_value_ptr;
68996908 IrInstSrc *target_value = ir_build_switch_target(ag, scope, node, target_value_ptr);
......@@ -6949,11 +6958,11 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
69496958 AstNode *start_node = item_node->data.switch_range.start;
69506959 AstNode *end_node = item_node->data.switch_range.end;
69516960
6952 IrInstSrc *start_value = ir_gen_node(ag, start_node, comptime_scope);
6961 IrInstSrc *start_value = astgen_node(ag, start_node, comptime_scope);
69536962 if (start_value == ag->codegen->invalid_inst_src)
69546963 return ag->codegen->invalid_inst_src;
69556964
6956 IrInstSrc *end_value = ir_gen_node(ag, end_node, comptime_scope);
6965 IrInstSrc *end_value = astgen_node(ag, end_node, comptime_scope);
69576966 if (end_value == ag->codegen->invalid_inst_src)
69586967 return ag->codegen->invalid_inst_src;
69596968
......@@ -6973,7 +6982,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
69736982 ok_bit = both_ok;
69746983 }
69756984 } else {
6976 IrInstSrc *item_value = ir_gen_node(ag, item_node, comptime_scope);
6985 IrInstSrc *item_value = astgen_node(ag, item_node, comptime_scope);
69776986 if (item_value == ag->codegen->invalid_inst_src)
69786987 return ag->codegen->invalid_inst_src;
69796988
......@@ -7007,7 +7016,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
70077016 }
70087017 peer_parent->peers.append(this_peer_result_loc);
70097018 ir_set_cursor_at_end_and_append_block(ag, range_block_yes);
7010 if (!ir_gen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block,
7019 if (!astgen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block,
70117020 is_comptime, var_is_comptime, target_value_ptr, nullptr, 0,
70127021 &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base))
70137022 {
......@@ -7058,7 +7067,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
70587067 }
70597068 peer_parent->peers.append(this_peer_result_loc);
70607069 ir_set_cursor_at_end_and_append_block(ag, else_block);
7061 if (!ir_gen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block,
7070 if (!astgen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block,
70627071 is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, &incoming_blocks, &incoming_values,
70637072 &switch_else_var, LValNone, &this_peer_result_loc->base))
70647073 {
......@@ -7088,7 +7097,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
70887097 AstNode *item_node = prong_node->data.switch_prong.items.at(item_i);
70897098 assert(item_node->type != NodeTypeSwitchRange);
70907099
7091 IrInstSrc *item_value = ir_gen_node(ag, item_node, comptime_scope);
7100 IrInstSrc *item_value = astgen_node(ag, item_node, comptime_scope);
70927101 if (item_value == ag->codegen->invalid_inst_src)
70937102 return ag->codegen->invalid_inst_src;
70947103
......@@ -7109,7 +7118,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
71097118 }
71107119 peer_parent->peers.append(this_peer_result_loc);
71117120 ir_set_cursor_at_end_and_append_block(ag, prong_block);
7112 if (!ir_gen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block,
7121 if (!astgen_switch_prong_expr(ag, subexpr_scope, node, prong_node, end_block,
71137122 is_comptime, var_is_comptime, target_value_ptr, items, prong_item_count,
71147123 &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base))
71157124 {
......@@ -7165,23 +7174,23 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no
71657174 return ir_lval_wrap(ag, scope, result_instruction, lval, result_loc);
71667175}
71677176
7168static IrInstSrc *ir_gen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) {
7177static IrInstSrc *astgen_comptime(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) {
71697178 assert(node->type == NodeTypeCompTime);
71707179
71717180 Scope *child_scope = create_comptime_scope(ag->codegen, node, parent_scope);
71727181 // purposefully pass null for result_loc and let EndExpr handle it
7173 return ir_gen_node_extra(ag, node->data.comptime_expr.expr, child_scope, lval, nullptr);
7182 return astgen_node_extra(ag, node->data.comptime_expr.expr, child_scope, lval, nullptr);
71747183}
71757184
7176static IrInstSrc *ir_gen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) {
7185static IrInstSrc *astgen_nosuspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval) {
71777186 assert(node->type == NodeTypeNoSuspend);
71787187
71797188 Scope *child_scope = create_nosuspend_scope(ag->codegen, node, parent_scope);
71807189 // purposefully pass null for result_loc and let EndExpr handle it
7181 return ir_gen_node_extra(ag, node->data.nosuspend_expr.expr, child_scope, lval, nullptr);
7190 return astgen_node_extra(ag, node->data.nosuspend_expr.expr, child_scope, lval, nullptr);
71827191}
71837192
7184static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) {
7193static IrInstSrc *astgen_return_from_block(Stage1AstGen *ag, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) {
71857194 IrInstSrc *is_comptime;
71867195 if (ir_should_inline(ag->exec, break_scope)) {
71877196 is_comptime = ir_build_const_bool(ag, break_scope, node, true);
......@@ -7194,7 +7203,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope,
71947203 ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent);
71957204 block_scope->peer_parent->peers.append(peer_result);
71967205
7197 result_value = ir_gen_node_extra(ag, node->data.break_expr.expr, break_scope, block_scope->lval,
7206 result_value = astgen_node_extra(ag, node->data.break_expr.expr, break_scope, block_scope->lval,
71987207 &peer_result->base);
71997208 if (result_value == ag->codegen->invalid_inst_src)
72007209 return ag->codegen->invalid_inst_src;
......@@ -7203,7 +7212,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope,
72037212 }
72047213
72057214 Stage1ZirBasicBlock *dest_block = block_scope->end_block;
7206 if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr))
7215 if (!astgen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr))
72077216 return ag->codegen->invalid_inst_src;
72087217
72097218 block_scope->incoming_blocks->append(ag->current_basic_block);
......@@ -7211,7 +7220,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope,
72117220 return ir_build_br(ag, break_scope, node, dest_block, is_comptime);
72127221}
72137222
7214static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *node) {
7223static IrInstSrc *astgen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *node) {
72157224 assert(node->type == NodeTypeBreak);
72167225
72177226 // Search up the scope. We'll find one of these things first:
......@@ -7250,7 +7259,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no
72507259 {
72517260 assert(this_block_scope->end_block != nullptr);
72527261 this_block_scope->name_used = true;
7253 return ir_gen_return_from_block(ag, break_scope, node, this_block_scope);
7262 return astgen_return_from_block(ag, break_scope, node, this_block_scope);
72547263 }
72557264 } else if (search_scope->id == ScopeIdSuspend) {
72567265 add_node_error(ag->codegen, node, buf_sprintf("cannot break out of suspend block"));
......@@ -7271,7 +7280,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no
72717280 ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent);
72727281 loop_scope->peer_parent->peers.append(peer_result);
72737282
7274 result_value = ir_gen_node_extra(ag, node->data.break_expr.expr, break_scope,
7283 result_value = astgen_node_extra(ag, node->data.break_expr.expr, break_scope,
72757284 loop_scope->lval, &peer_result->base);
72767285 if (result_value == ag->codegen->invalid_inst_src)
72777286 return ag->codegen->invalid_inst_src;
......@@ -7280,7 +7289,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no
72807289 }
72817290
72827291 Stage1ZirBasicBlock *dest_block = loop_scope->break_block;
7283 if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr))
7292 if (!astgen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr))
72847293 return ag->codegen->invalid_inst_src;
72857294
72867295 loop_scope->incoming_blocks->append(ag->current_basic_block);
......@@ -7288,7 +7297,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no
72887297 return ir_build_br(ag, break_scope, node, dest_block, is_comptime);
72897298}
72907299
7291static IrInstSrc *ir_gen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNode *node) {
7300static IrInstSrc *astgen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNode *node) {
72927301 assert(node->type == NodeTypeContinue);
72937302
72947303 // Search up the scope. We'll find one of these things first:
......@@ -7342,17 +7351,17 @@ static IrInstSrc *ir_gen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNo
73427351 runtime_scopes.deinit();
73437352
73447353 Stage1ZirBasicBlock *dest_block = loop_scope->continue_block;
7345 if (!ir_gen_defers_for_block(ag, continue_scope, dest_block->scope, nullptr, nullptr))
7354 if (!astgen_defers_for_block(ag, continue_scope, dest_block->scope, nullptr, nullptr))
73467355 return ag->codegen->invalid_inst_src;
73477356 return ir_mark_gen(ir_build_br(ag, continue_scope, node, dest_block, is_comptime));
73487357}
73497358
7350static IrInstSrc *ir_gen_error_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
7359static IrInstSrc *astgen_error_type(Stage1AstGen *ag, Scope *scope, AstNode *node) {
73517360 assert(node->type == NodeTypeErrorType);
73527361 return ir_build_const_type(ag, scope, node, ag->codegen->builtin_types.entry_global_error_set);
73537362}
73547363
7355static IrInstSrc *ir_gen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
7364static IrInstSrc *astgen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
73567365 assert(node->type == NodeTypeDefer);
73577366
73587367 ScopeDefer *defer_child_scope = create_defer_scope(ag->codegen, node, parent_scope);
......@@ -7364,7 +7373,7 @@ static IrInstSrc *ir_gen_defer(Stage1AstGen *ag, Scope *parent_scope, AstNode *n
73647373 return ir_build_const_void(ag, parent_scope, node);
73657374}
73667375
7367static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
7376static IrInstSrc *astgen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) {
73687377 assert(node->type == NodeTypeSliceExpr);
73697378
73707379 AstNodeSliceExpr *slice_expr = &node->data.slice_expr;
......@@ -7373,17 +7382,17 @@ static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV
73737382 AstNode *end_node = slice_expr->end;
73747383 AstNode *sentinel_node = slice_expr->sentinel;
73757384
7376 IrInstSrc *ptr_value = ir_gen_node_extra(ag, array_node, scope, LValPtr, nullptr);
7385 IrInstSrc *ptr_value = astgen_node_extra(ag, array_node, scope, LValPtr, nullptr);
73777386 if (ptr_value == ag->codegen->invalid_inst_src)
73787387 return ag->codegen->invalid_inst_src;
73797388
7380 IrInstSrc *start_value = ir_gen_node(ag, start_node, scope);
7389 IrInstSrc *start_value = astgen_node(ag, start_node, scope);
73817390 if (start_value == ag->codegen->invalid_inst_src)
73827391 return ag->codegen->invalid_inst_src;
73837392
73847393 IrInstSrc *end_value;
73857394 if (end_node) {
7386 end_value = ir_gen_node(ag, end_node, scope);
7395 end_value = astgen_node(ag, end_node, scope);
73877396 if (end_value == ag->codegen->invalid_inst_src)
73887397 return ag->codegen->invalid_inst_src;
73897398 } else {
......@@ -7392,7 +7401,7 @@ static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV
73927401
73937402 IrInstSrc *sentinel_value;
73947403 if (sentinel_node) {
7395 sentinel_value = ir_gen_node(ag, sentinel_node, scope);
7404 sentinel_value = astgen_node(ag, sentinel_node, scope);
73967405 if (sentinel_value == ag->codegen->invalid_inst_src)
73977406 return ag->codegen->invalid_inst_src;
73987407 } else {
......@@ -7404,7 +7413,7 @@ static IrInstSrc *ir_gen_slice(Stage1AstGen *ag, Scope *scope, AstNode *node, LV
74047413 return ir_lval_wrap(ag, scope, slice, lval, result_loc);
74057414}
74067415
7407static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval,
7416static IrInstSrc *astgen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *node, LVal lval,
74087417 ResultLoc *result_loc)
74097418{
74107419 assert(node->type == NodeTypeCatchExpr);
......@@ -7420,14 +7429,14 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n
74207429 add_node_error(ag->codegen, var_node, buf_sprintf("unused variable: '%s'", buf_ptr(var_name)));
74217430 return ag->codegen->invalid_inst_src;
74227431 }
7423 return ir_gen_catch_unreachable(ag, parent_scope, node, op1_node, lval, result_loc);
7432 return astgen_catch_unreachable(ag, parent_scope, node, op1_node, lval, result_loc);
74247433 }
74257434
74267435
74277436 ScopeExpr *spill_scope = create_expr_scope(ag->codegen, op1_node, parent_scope);
74287437 spill_scope->spill_harder = true;
74297438
7430 IrInstSrc *err_union_ptr = ir_gen_node_extra(ag, op1_node, &spill_scope->base, LValPtr, nullptr);
7439 IrInstSrc *err_union_ptr = astgen_node_extra(ag, op1_node, &spill_scope->base, LValPtr, nullptr);
74317440 if (err_union_ptr == ag->codegen->invalid_inst_src)
74327441 return ag->codegen->invalid_inst_src;
74337442
......@@ -7465,7 +7474,7 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n
74657474 } else {
74667475 err_scope = subexpr_scope;
74677476 }
7468 IrInstSrc *err_result = ir_gen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base);
7477 IrInstSrc *err_result = astgen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base);
74697478 if (err_result == ag->codegen->invalid_inst_src)
74707479 return ag->codegen->invalid_inst_src;
74717480 Stage1ZirBasicBlock *after_err_block = ag->current_basic_block;
......@@ -7535,7 +7544,7 @@ Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name
75357544 }
75367545}
75377546
7538static IrInstSrc *ir_gen_container_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
7547static IrInstSrc *astgen_container_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
75397548 assert(node->type == NodeTypeContainerDecl);
75407549
75417550 ContainerKind kind = node->data.container_decl.kind;
......@@ -7564,7 +7573,7 @@ static IrInstSrc *ir_gen_container_decl(Stage1AstGen *ag, Scope *parent_scope, A
75647573 return ir_build_const_type(ag, parent_scope, node, container_type);
75657574}
75667575
7567static IrInstSrc *ir_gen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
7576static IrInstSrc *astgen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
75687577 assert(node->type == NodeTypeErrorSetDecl);
75697578
75707579 uint32_t err_count = node->data.err_set_decl.decls.length;
......@@ -7615,7 +7624,7 @@ static IrInstSrc *ir_gen_err_set_decl(Stage1AstGen *ag, Scope *parent_scope, Ast
76157624 return ir_build_const_type(ag, parent_scope, node, err_set_type);
76167625}
76177626
7618static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
7627static IrInstSrc *astgen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
76197628 assert(node->type == NodeTypeFnProto);
76207629
76217630 size_t param_count = node->data.fn_proto.params.length;
......@@ -7630,7 +7639,7 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode
76307639 }
76317640 if (param_node->data.param_decl.anytype_token == 0) {
76327641 AstNode *type_node = param_node->data.param_decl.type;
7633 IrInstSrc *type_value = ir_gen_node(ag, type_node, parent_scope);
7642 IrInstSrc *type_value = astgen_node(ag, type_node, parent_scope);
76347643 if (type_value == ag->codegen->invalid_inst_src)
76357644 return ag->codegen->invalid_inst_src;
76367645 param_types[i] = type_value;
......@@ -7641,14 +7650,14 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode
76417650
76427651 IrInstSrc *align_value = nullptr;
76437652 if (node->data.fn_proto.align_expr != nullptr) {
7644 align_value = ir_gen_node(ag, node->data.fn_proto.align_expr, parent_scope);
7653 align_value = astgen_node(ag, node->data.fn_proto.align_expr, parent_scope);
76457654 if (align_value == ag->codegen->invalid_inst_src)
76467655 return ag->codegen->invalid_inst_src;
76477656 }
76487657
76497658 IrInstSrc *callconv_value = nullptr;
76507659 if (node->data.fn_proto.callconv_expr != nullptr) {
7651 callconv_value = ir_gen_node(ag, node->data.fn_proto.callconv_expr, parent_scope);
7660 callconv_value = astgen_node(ag, node->data.fn_proto.callconv_expr, parent_scope);
76527661 if (callconv_value == ag->codegen->invalid_inst_src)
76537662 return ag->codegen->invalid_inst_src;
76547663 }
......@@ -7657,7 +7666,7 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode
76577666 if (node->data.fn_proto.return_type == nullptr) {
76587667 return_type = ir_build_const_type(ag, parent_scope, node, ag->codegen->builtin_types.entry_void);
76597668 } else {
7660 return_type = ir_gen_node(ag, node->data.fn_proto.return_type, parent_scope);
7669 return_type = astgen_node(ag, node->data.fn_proto.return_type, parent_scope);
76617670 if (return_type == ag->codegen->invalid_inst_src)
76627671 return ag->codegen->invalid_inst_src;
76637672 }
......@@ -7665,17 +7674,17 @@ static IrInstSrc *ir_gen_fn_proto(Stage1AstGen *ag, Scope *parent_scope, AstNode
76657674 return ir_build_fn_proto(ag, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args);
76667675}
76677676
7668static IrInstSrc *ir_gen_resume(Stage1AstGen *ag, Scope *scope, AstNode *node) {
7677static IrInstSrc *astgen_resume(Stage1AstGen *ag, Scope *scope, AstNode *node) {
76697678 assert(node->type == NodeTypeResume);
76707679
7671 IrInstSrc *target_inst = ir_gen_node_extra(ag, node->data.resume_expr.expr, scope, LValPtr, nullptr);
7680 IrInstSrc *target_inst = astgen_node_extra(ag, node->data.resume_expr.expr, scope, LValPtr, nullptr);
76727681 if (target_inst == ag->codegen->invalid_inst_src)
76737682 return ag->codegen->invalid_inst_src;
76747683
76757684 return ir_build_resume_src(ag, scope, node, target_inst);
76767685}
76777686
7678static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
7687static IrInstSrc *astgen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *node, LVal lval,
76797688 ResultLoc *result_loc)
76807689{
76817690 assert(node->type == NodeTypeAwaitExpr);
......@@ -7690,7 +7699,7 @@ static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
76907699 if (entry != nullptr) {
76917700 BuiltinFnEntry *builtin_fn = entry->value;
76927701 if (builtin_fn->id == BuiltinFnIdAsyncCall) {
7693 return ir_gen_async_call(ag, scope, node, expr_node, lval, result_loc);
7702 return astgen_async_call(ag, scope, node, expr_node, lval, result_loc);
76947703 }
76957704 }
76967705 }
......@@ -7709,7 +7718,7 @@ static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
77097718 return ag->codegen->invalid_inst_src;
77107719 }
77117720
7712 IrInstSrc *target_inst = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
7721 IrInstSrc *target_inst = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
77137722 if (target_inst == ag->codegen->invalid_inst_src)
77147723 return ag->codegen->invalid_inst_src;
77157724
......@@ -7717,7 +7726,7 @@ static IrInstSrc *ir_gen_await_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod
77177726 return ir_lval_wrap(ag, scope, await_inst, lval, result_loc);
77187727}
77197728
7720static IrInstSrc *ir_gen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
7729static IrInstSrc *astgen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode *node) {
77217730 assert(node->type == NodeTypeSuspend);
77227731
77237732 if (!ag->fn) {
......@@ -7742,7 +7751,7 @@ static IrInstSrc *ir_gen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode
77427751 IrInstSrcSuspendBegin *begin = ir_build_suspend_begin_src(ag, parent_scope, node);
77437752 ScopeSuspend *suspend_scope = create_suspend_scope(ag->codegen, node, parent_scope);
77447753 Scope *child_scope = &suspend_scope->base;
7745 IrInstSrc *susp_res = ir_gen_node(ag, node->data.suspend.block, child_scope);
7754 IrInstSrc *susp_res = astgen_node(ag, node->data.suspend.block, child_scope);
77467755 if (susp_res == ag->codegen->invalid_inst_src)
77477756 return ag->codegen->invalid_inst_src;
77487757 ir_mark_gen(ir_build_check_statement_is_void(ag, child_scope, node->data.suspend.block, susp_res));
......@@ -7750,7 +7759,7 @@ static IrInstSrc *ir_gen_suspend(Stage1AstGen *ag, Scope *parent_scope, AstNode
77507759 return ir_mark_gen(ir_build_suspend_finish_src(ag, parent_scope, node, begin));
77517760}
77527761
7753static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope,
7762static IrInstSrc *astgen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope,
77547763 LVal lval, ResultLoc *result_loc)
77557764{
77567765 assert(scope);
......@@ -7766,40 +7775,40 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope,
77667775 case NodeTypeTestDecl:
77677776 zig_unreachable();
77687777 case NodeTypeBlock:
7769 return ir_gen_block(ag, scope, node, lval, result_loc);
7778 return astgen_block(ag, scope, node, lval, result_loc);
77707779 case NodeTypeGroupedExpr:
7771 return ir_gen_node_raw(ag, node->data.grouped_expr, scope, lval, result_loc);
7780 return astgen_node_raw(ag, node->data.grouped_expr, scope, lval, result_loc);
77727781 case NodeTypeBinOpExpr:
7773 return ir_gen_bin_op(ag, scope, node, lval, result_loc);
7782 return astgen_bin_op(ag, scope, node, lval, result_loc);
77747783 case NodeTypeIntLiteral:
7775 return ir_lval_wrap(ag, scope, ir_gen_int_lit(ag, scope, node), lval, result_loc);
7784 return ir_lval_wrap(ag, scope, astgen_int_lit(ag, scope, node), lval, result_loc);
77767785 case NodeTypeFloatLiteral:
7777 return ir_lval_wrap(ag, scope, ir_gen_float_lit(ag, scope, node), lval, result_loc);
7786 return ir_lval_wrap(ag, scope, astgen_float_lit(ag, scope, node), lval, result_loc);
77787787 case NodeTypeCharLiteral:
7779 return ir_lval_wrap(ag, scope, ir_gen_char_lit(ag, scope, node), lval, result_loc);
7788 return ir_lval_wrap(ag, scope, astgen_char_lit(ag, scope, node), lval, result_loc);
77807789 case NodeTypeIdentifier:
7781 return ir_gen_symbol(ag, scope, node, lval, result_loc);
7790 return astgen_identifier(ag, scope, node, lval, result_loc);
77827791 case NodeTypeFnCallExpr:
7783 return ir_gen_fn_call(ag, scope, node, lval, result_loc);
7792 return astgen_fn_call(ag, scope, node, lval, result_loc);
77847793 case NodeTypeIfBoolExpr:
7785 return ir_gen_if_bool_expr(ag, scope, node, lval, result_loc);
7794 return astgen_if_bool_expr(ag, scope, node, lval, result_loc);
77867795 case NodeTypePrefixOpExpr:
7787 return ir_gen_prefix_op_expr(ag, scope, node, lval, result_loc);
7796 return astgen_prefix_op_expr(ag, scope, node, lval, result_loc);
77887797 case NodeTypeContainerInitExpr:
7789 return ir_gen_container_init_expr(ag, scope, node, lval, result_loc);
7798 return astgen_container_init_expr(ag, scope, node, lval, result_loc);
77907799 case NodeTypeVariableDeclaration:
7791 return ir_gen_var_decl(ag, scope, node);
7800 return astgen_var_decl(ag, scope, node);
77927801 case NodeTypeWhileExpr:
7793 return ir_gen_while_expr(ag, scope, node, lval, result_loc);
7802 return astgen_while_expr(ag, scope, node, lval, result_loc);
77947803 case NodeTypeForExpr:
7795 return ir_gen_for_expr(ag, scope, node, lval, result_loc);
7804 return astgen_for_expr(ag, scope, node, lval, result_loc);
77967805 case NodeTypeArrayAccessExpr:
7797 return ir_gen_array_access(ag, scope, node, lval, result_loc);
7806 return astgen_array_access(ag, scope, node, lval, result_loc);
77987807 case NodeTypeReturnExpr:
7799 return ir_gen_return(ag, scope, node, lval, result_loc);
7808 return astgen_return(ag, scope, node, lval, result_loc);
78007809 case NodeTypeFieldAccessExpr:
78017810 {
7802 IrInstSrc *ptr_instruction = ir_gen_field_access(ag, scope, node);
7811 IrInstSrc *ptr_instruction = astgen_field_access(ag, scope, node);
78037812 if (ptr_instruction == ag->codegen->invalid_inst_src)
78047813 return ptr_instruction;
78057814 if (lval == LValPtr || lval == LValAssign)
......@@ -7815,7 +7824,7 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope,
78157824 if (child_lval == LValAssign)
78167825 child_lval = LValPtr;
78177826
7818 IrInstSrc *value = ir_gen_node_extra(ag, expr_node, scope, child_lval, nullptr);
7827 IrInstSrc *value = astgen_node_extra(ag, expr_node, scope, child_lval, nullptr);
78197828 if (value == ag->codegen->invalid_inst_src)
78207829 return value;
78217830
......@@ -7828,7 +7837,7 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope,
78287837 case NodeTypeUnwrapOptional: {
78297838 AstNode *expr_node = node->data.unwrap_optional.expr;
78307839
7831 IrInstSrc *maybe_ptr = ir_gen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
7840 IrInstSrc *maybe_ptr = astgen_node_extra(ag, expr_node, scope, LValPtr, nullptr);
78327841 if (maybe_ptr == ag->codegen->invalid_inst_src)
78337842 return ag->codegen->invalid_inst_src;
78347843
......@@ -7840,59 +7849,59 @@ static IrInstSrc *ir_gen_node_raw(Stage1AstGen *ag, AstNode *node, Scope *scope,
78407849 return ir_expr_wrap(ag, scope, load_ptr, result_loc);
78417850 }
78427851 case NodeTypeBoolLiteral:
7843 return ir_lval_wrap(ag, scope, ir_gen_bool_literal(ag, scope, node), lval, result_loc);
7852 return ir_lval_wrap(ag, scope, astgen_bool_literal(ag, scope, node), lval, result_loc);
78447853 case NodeTypeArrayType:
7845 return ir_lval_wrap(ag, scope, ir_gen_array_type(ag, scope, node), lval, result_loc);
7854 return ir_lval_wrap(ag, scope, astgen_array_type(ag, scope, node), lval, result_loc);
78467855 case NodeTypePointerType:
7847 return ir_lval_wrap(ag, scope, ir_gen_pointer_type(ag, scope, node), lval, result_loc);
7856 return ir_lval_wrap(ag, scope, astgen_pointer_type(ag, scope, node), lval, result_loc);
78487857 case NodeTypeAnyFrameType:
7849 return ir_lval_wrap(ag, scope, ir_gen_anyframe_type(ag, scope, node), lval, result_loc);
7858 return ir_lval_wrap(ag, scope, astgen_anyframe_type(ag, scope, node), lval, result_loc);
78507859 case NodeTypeStringLiteral:
7851 return ir_lval_wrap(ag, scope, ir_gen_string_literal(ag, scope, node), lval, result_loc);
7860 return ir_lval_wrap(ag, scope, astgen_string_literal(ag, scope, node), lval, result_loc);
78527861 case NodeTypeUndefinedLiteral:
7853 return ir_lval_wrap(ag, scope, ir_gen_undefined_literal(ag, scope, node), lval, result_loc);
7862 return ir_lval_wrap(ag, scope, astgen_undefined_literal(ag, scope, node), lval, result_loc);
78547863 case NodeTypeAsmExpr:
7855 return ir_lval_wrap(ag, scope, ir_gen_asm_expr(ag, scope, node), lval, result_loc);
7864 return ir_lval_wrap(ag, scope, astgen_asm_expr(ag, scope, node), lval, result_loc);
78567865 case NodeTypeNullLiteral:
7857 return ir_lval_wrap(ag, scope, ir_gen_null_literal(ag, scope, node), lval, result_loc);
7866 return ir_lval_wrap(ag, scope, astgen_null_literal(ag, scope, node), lval, result_loc);
78587867 case NodeTypeIfErrorExpr:
7859 return ir_gen_if_err_expr(ag, scope, node, lval, result_loc);
7868 return astgen_if_err_expr(ag, scope, node, lval, result_loc);
78607869 case NodeTypeIfOptional:
7861 return ir_gen_if_optional_expr(ag, scope, node, lval, result_loc);
7870 return astgen_if_optional_expr(ag, scope, node, lval, result_loc);
78627871 case NodeTypeSwitchExpr:
7863 return ir_gen_switch_expr(ag, scope, node, lval, result_loc);
7872 return astgen_switch_expr(ag, scope, node, lval, result_loc);
78647873 case NodeTypeCompTime:
7865 return ir_expr_wrap(ag, scope, ir_gen_comptime(ag, scope, node, lval), result_loc);
7874 return ir_expr_wrap(ag, scope, astgen_comptime(ag, scope, node, lval), result_loc);
78667875 case NodeTypeNoSuspend:
7867 return ir_expr_wrap(ag, scope, ir_gen_nosuspend(ag, scope, node, lval), result_loc);
7876 return ir_expr_wrap(ag, scope, astgen_nosuspend(ag, scope, node, lval), result_loc);
78687877 case NodeTypeErrorType:
7869 return ir_lval_wrap(ag, scope, ir_gen_error_type(ag, scope, node), lval, result_loc);
7878 return ir_lval_wrap(ag, scope, astgen_error_type(ag, scope, node), lval, result_loc);
78707879 case NodeTypeBreak:
7871 return ir_lval_wrap(ag, scope, ir_gen_break(ag, scope, node), lval, result_loc);
7880 return ir_lval_wrap(ag, scope, astgen_break(ag, scope, node), lval, result_loc);
78727881 case NodeTypeContinue:
7873 return ir_lval_wrap(ag, scope, ir_gen_continue(ag, scope, node), lval, result_loc);
7882 return ir_lval_wrap(ag, scope, astgen_continue(ag, scope, node), lval, result_loc);
78747883 case NodeTypeUnreachable:
78757884 return ir_build_unreachable(ag, scope, node);
78767885 case NodeTypeDefer:
7877 return ir_lval_wrap(ag, scope, ir_gen_defer(ag, scope, node), lval, result_loc);
7886 return ir_lval_wrap(ag, scope, astgen_defer(ag, scope, node), lval, result_loc);
78787887 case NodeTypeSliceExpr:
7879 return ir_gen_slice(ag, scope, node, lval, result_loc);
7888 return astgen_slice(ag, scope, node, lval, result_loc);
78807889 case NodeTypeCatchExpr:
7881 return ir_gen_catch(ag, scope, node, lval, result_loc);
7890 return astgen_catch(ag, scope, node, lval, result_loc);
78827891 case NodeTypeContainerDecl:
7883 return ir_lval_wrap(ag, scope, ir_gen_container_decl(ag, scope, node), lval, result_loc);
7892 return ir_lval_wrap(ag, scope, astgen_container_decl(ag, scope, node), lval, result_loc);
78847893 case NodeTypeFnProto:
7885 return ir_lval_wrap(ag, scope, ir_gen_fn_proto(ag, scope, node), lval, result_loc);
7894 return ir_lval_wrap(ag, scope, astgen_fn_proto(ag, scope, node), lval, result_loc);
78867895 case NodeTypeErrorSetDecl:
7887 return ir_lval_wrap(ag, scope, ir_gen_err_set_decl(ag, scope, node), lval, result_loc);
7896 return ir_lval_wrap(ag, scope, astgen_err_set_decl(ag, scope, node), lval, result_loc);
78887897 case NodeTypeResume:
7889 return ir_lval_wrap(ag, scope, ir_gen_resume(ag, scope, node), lval, result_loc);
7898 return ir_lval_wrap(ag, scope, astgen_resume(ag, scope, node), lval, result_loc);
78907899 case NodeTypeAwaitExpr:
7891 return ir_gen_await_expr(ag, scope, node, lval, result_loc);
7900 return astgen_await_expr(ag, scope, node, lval, result_loc);
78927901 case NodeTypeSuspend:
7893 return ir_lval_wrap(ag, scope, ir_gen_suspend(ag, scope, node), lval, result_loc);
7902 return ir_lval_wrap(ag, scope, astgen_suspend(ag, scope, node), lval, result_loc);
78947903 case NodeTypeEnumLiteral:
7895 return ir_lval_wrap(ag, scope, ir_gen_enum_literal(ag, scope, node), lval, result_loc);
7904 return ir_lval_wrap(ag, scope, astgen_enum_literal(ag, scope, node), lval, result_loc);
78967905 case NodeTypeInferredArrayType:
78977906 add_node_error(ag->codegen, node,
78987907 buf_sprintf("inferred array size invalid here"));
......@@ -7910,7 +7919,7 @@ ResultLoc *no_result_loc(void) {
79107919 return &result_loc_none->base;
79117920}
79127921
7913static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval,
7922static IrInstSrc *astgen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scope, LVal lval,
79147923 ResultLoc *result_loc)
79157924{
79167925 if (lval == LValAssign) {
......@@ -8018,7 +8027,7 @@ static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scop
80188027 } else {
80198028 child_scope = &create_expr_scope(ag->codegen, node, scope)->base;
80208029 }
8021 IrInstSrc *result = ir_gen_node_raw(ag, node, child_scope, lval, result_loc);
8030 IrInstSrc *result = astgen_node_raw(ag, node, child_scope, lval, result_loc);
80228031 if (result == ag->codegen->invalid_inst_src) {
80238032 if (ag->exec->first_err_trace_msg == nullptr) {
80248033 ag->exec->first_err_trace_msg = ag->codegen->trace_err;
......@@ -8027,8 +8036,8 @@ static IrInstSrc *ir_gen_node_extra(Stage1AstGen *ag, AstNode *node, Scope *scop
80278036 return result;
80288037}
80298038
8030static IrInstSrc *ir_gen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) {
8031 return ir_gen_node_extra(ag, node, scope, LValNone, nullptr);
8039static IrInstSrc *astgen_node(Stage1AstGen *ag, AstNode *node, Scope *scope) {
8040 return astgen_node_extra(ag, node, scope, LValNone, nullptr);
80328041}
80338042
80348043bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *stage1_zir,
......@@ -8050,7 +8059,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *sta
80508059 // Entry block gets a reference because we enter it to begin.
80518060 ir_ref_bb(ag->current_basic_block);
80528061
8053 IrInstSrc *result = ir_gen_node_extra(ag, node, scope, LValNone, nullptr);
8062 IrInstSrc *result = astgen_node_extra(ag, node, scope, LValNone, nullptr);
80548063
80558064 if (result == ag->codegen->invalid_inst_src)
80568065 return false;
src/stage1/parser.cpp+22-21
......@@ -202,6 +202,19 @@ static void put_back_token(ParseContext *pc) {
202202 pc->current_token -= 1;
203203}
204204
205static Buf *token_string_literal_buf(RootStruct *root_struct, TokenIndex token) {
206 Error err;
207 assert(root_struct->token_ids[token] == TokenIdStringLiteral);
208 const char *source = buf_ptr(root_struct->source_code);
209 size_t byte_offset = root_struct->token_locs[token].offset;
210 size_t bad_index;
211 Buf *str = buf_alloc();
212 if ((err = source_string_literal_buf(source + byte_offset, str, &bad_index))) {
213 zig_panic("TODO handle string literal parse error");
214 }
215 return str;
216}
217
205218static Buf *token_buf(ParseContext *pc, TokenIndex token) {
206219 if (token == 0)
207220 return nullptr;
......@@ -3465,19 +3478,6 @@ Error source_char_literal(const char *source, uint32_t *result, size_t *bad_inde
34653478}
34663479
34673480
3468Buf *token_string_literal_buf(RootStruct *root_struct, TokenIndex token) {
3469 Error err;
3470 assert(root_struct->token_ids[token] == TokenIdStringLiteral);
3471 const char *source = buf_ptr(root_struct->source_code);
3472 size_t byte_offset = root_struct->token_locs[token].offset;
3473 size_t bad_index;
3474 Buf *str = buf_alloc();
3475 if ((err = source_string_literal_buf(source + byte_offset, str, &bad_index))) {
3476 zig_panic("TODO handle string literal parse error");
3477 }
3478 return str;
3479}
3480
34813481Buf *token_identifier_buf(RootStruct *root_struct, TokenIndex token) {
34823482 Error err;
34833483 const char *source = buf_ptr(root_struct->source_code);
......@@ -3515,14 +3515,15 @@ Buf *token_identifier_buf(RootStruct *root_struct, TokenIndex token) {
35153515
35163516Buf *node_identifier_buf(AstNode *node) {
35173517 assert(node->type == NodeTypeIdentifier);
3518 RootStruct *root_struct = node->owner->data.structure.root_struct;
3519 return token_identifier_buf(root_struct, node->main_token);
3520}
3521
3522Buf *node_string_literal_buf(AstNode *node) {
3523 assert(node->type == NodeTypeStringLiteral);
3524 RootStruct *root_struct = node->owner->data.structure.root_struct;
3525 return token_string_literal_buf(root_struct, node->main_token);
3518 // Currently, stage1 runs astgen for every comptime function call,
3519 // resulting the allocation here wasting memory. As a workaround until
3520 // the code is adjusted to make astgen run only once per source node,
3521 // we memoize the result into the AST here.
3522 if (node->data.identifier.name == nullptr) {
3523 RootStruct *root_struct = node->owner->data.structure.root_struct;
3524 node->data.identifier.name = token_identifier_buf(root_struct, node->main_token);
3525 }
3526 return node->data.identifier.name;
35263527}
35273528
35283529void token_number_literal_bigint(RootStruct *root_struct, BigInt *result, TokenIndex token) {
src/stage1/parser.hpp-2
......@@ -19,10 +19,8 @@ void ast_print(AstNode *node, int indent);
1919void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *context), void *context);
2020
2121Buf *node_identifier_buf(AstNode *node);
22Buf *node_string_literal_buf(AstNode *node);
2322
2423Buf *token_identifier_buf(RootStruct *root_struct, TokenIndex token);
25Buf *token_string_literal_buf(RootStruct *root_struct, TokenIndex token);
2624
2725void token_number_literal_bigint(RootStruct *root_struct, BigInt *result, TokenIndex token);
2826
src/stage1/tokenizer.cpp+5-5
......@@ -291,11 +291,11 @@ static void tokenize_error(Tokenize *t, const char *format, ...) {
291291
292292static void begin_token(Tokenize *t, TokenId id) {
293293 t->out->ids.append(id);
294 t->out->locs.append({
295 .offset = (uint32_t) t->pos,
296 .line = t->line,
297 .column = t->column,
298 });
294 TokenLoc tok_loc;
295 tok_loc.offset = (uint32_t) t->pos;
296 tok_loc.line = t->line;
297 tok_loc.column = t->column;
298 t->out->locs.append(tok_loc);
299299}
300300
301301static void cancel_token(Tokenize *t) {