| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | struct Stage1AstGen { | 14 | struct Stage1AstGen { |
| 15 | CodeGen *codegen; | 15 | CodeGen *codegen; |
| 16 | Stage1Zir *exec; | 16 | Stage1Zir *exec; |
| 17 | IrBasicBlockSrc *current_basic_block; | 17 | Stage1ZirBasicBlock *current_basic_block; |
| 18 | AstNode *main_block_node; | 18 | AstNode *main_block_node; |
| 19 | size_t next_debug_id; | 19 | size_t next_debug_id; |
| 20 | ZigFn *fn; | 20 | ZigFn *fn; |
| ... | @@ -358,7 +358,7 @@ bool ir_should_inline(Stage1Zir *exec, Scope *scope) { | ... | @@ -358,7 +358,7 @@ bool ir_should_inline(Stage1Zir *exec, Scope *scope) { |
| 358 | return false; | 358 | return false; |
| 359 | } | 359 | } |
| 360 | | 360 | |
| 361 | static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instruction) { | 361 | static void ir_instruction_append(Stage1ZirBasicBlock *basic_block, IrInstSrc *instruction) { |
| 362 | assert(basic_block); | 362 | assert(basic_block); |
| 363 | assert(instruction); | 363 | assert(instruction); |
| 364 | basic_block->instruction_list.append(instruction); | 364 | basic_block->instruction_list.append(instruction); |
| ... | @@ -370,11 +370,11 @@ static size_t irb_next_debug_id(Stage1AstGen *ag) { | ... | @@ -370,11 +370,11 @@ static size_t irb_next_debug_id(Stage1AstGen *ag) { |
| 370 | return result; | 370 | return result; |
| 371 | } | 371 | } |
| 372 | | 372 | |
| 373 | static void ir_ref_bb(IrBasicBlockSrc *bb) { | 373 | static void ir_ref_bb(Stage1ZirBasicBlock *bb) { |
| 374 | bb->ref_count += 1; | 374 | bb->ref_count += 1; |
| 375 | } | 375 | } |
| 376 | | 376 | |
| 377 | static void ir_ref_instruction(IrInstSrc *instruction, IrBasicBlockSrc *cur_bb) { | 377 | static void ir_ref_instruction(IrInstSrc *instruction, Stage1ZirBasicBlock *cur_bb) { |
| 378 | assert(instruction->id != IrInstSrcIdInvalid); | 378 | assert(instruction->id != IrInstSrcIdInvalid); |
| 379 | instruction->base.ref_count += 1; | 379 | instruction->base.ref_count += 1; |
| 380 | if (instruction->owner_bb != cur_bb && !instr_is_unreachable(instruction) | 380 | if (instruction->owner_bb != cur_bb && !instr_is_unreachable(instruction) |
| ... | @@ -384,8 +384,8 @@ static void ir_ref_instruction(IrInstSrc *instruction, IrBasicBlockSrc *cur_bb) | ... | @@ -384,8 +384,8 @@ static void ir_ref_instruction(IrInstSrc *instruction, IrBasicBlockSrc *cur_bb) |
| 384 | } | 384 | } |
| 385 | } | 385 | } |
| 386 | | 386 | |
| 387 | static IrBasicBlockSrc *ir_create_basic_block(Stage1AstGen *ag, Scope *scope, const char *name_hint) { | 387 | static Stage1ZirBasicBlock *ir_create_basic_block(Stage1AstGen *ag, Scope *scope, const char *name_hint) { |
| 388 | IrBasicBlockSrc *result = heap::c_allocator.create<IrBasicBlockSrc>(); | 388 | Stage1ZirBasicBlock *result = heap::c_allocator.create<Stage1ZirBasicBlock>(); |
| 389 | result->scope = scope; | 389 | result->scope = scope; |
| 390 | result->name_hint = name_hint; | 390 | result->name_hint = name_hint; |
| 391 | result->debug_id = irb_next_debug_id(ag); | 391 | result->debug_id = irb_next_debug_id(ag); |
| ... | @@ -944,7 +944,7 @@ static T *ir_build_instruction(Stage1AstGen *ag, Scope *scope, AstNode *source_n | ... | @@ -944,7 +944,7 @@ static T *ir_build_instruction(Stage1AstGen *ag, Scope *scope, AstNode *source_n |
| 944 | } | 944 | } |
| 945 | | 945 | |
| 946 | static IrInstSrc *ir_build_cond_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *condition, | 946 | static IrInstSrc *ir_build_cond_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, IrInstSrc *condition, |
| 947 | IrBasicBlockSrc *then_block, IrBasicBlockSrc *else_block, IrInstSrc *is_comptime) | 947 | Stage1ZirBasicBlock *then_block, Stage1ZirBasicBlock *else_block, IrInstSrc *is_comptime) |
| 948 | { | 948 | { |
| 949 | IrInstSrcCondBr *inst = ir_build_instruction<IrInstSrcCondBr>(ag, scope, source_node); | 949 | IrInstSrcCondBr *inst = ir_build_instruction<IrInstSrcCondBr>(ag, scope, source_node); |
| 950 | inst->base.is_noreturn = true; | 950 | inst->base.is_noreturn = true; |
| ... | @@ -1279,7 +1279,7 @@ static IrInstSrc *ir_build_call_src(Stage1AstGen *ag, Scope *scope, AstNode *sou | ... | @@ -1279,7 +1279,7 @@ static IrInstSrc *ir_build_call_src(Stage1AstGen *ag, Scope *scope, AstNode *sou |
| 1279 | } | 1279 | } |
| 1280 | | 1280 | |
| 1281 | static IrInstSrc *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | 1281 | static IrInstSrc *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 1282 | size_t incoming_count, IrBasicBlockSrc **incoming_blocks, IrInstSrc **incoming_values, | 1282 | size_t incoming_count, Stage1ZirBasicBlock **incoming_blocks, IrInstSrc **incoming_values, |
| 1283 | ResultLocPeerParent *peer_parent) | 1283 | ResultLocPeerParent *peer_parent) |
| 1284 | { | 1284 | { |
| 1285 | assert(incoming_count != 0); | 1285 | assert(incoming_count != 0); |
| ... | @@ -1300,7 +1300,7 @@ static IrInstSrc *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_n | ... | @@ -1300,7 +1300,7 @@ static IrInstSrc *ir_build_phi(Stage1AstGen *ag, Scope *scope, AstNode *source_n |
| 1300 | } | 1300 | } |
| 1301 | | 1301 | |
| 1302 | static IrInstSrc *ir_build_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | 1302 | static IrInstSrc *ir_build_br(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 1303 | IrBasicBlockSrc *dest_block, IrInstSrc *is_comptime) | 1303 | Stage1ZirBasicBlock *dest_block, IrInstSrc *is_comptime) |
| 1304 | { | 1304 | { |
| 1305 | IrInstSrcBr *inst = ir_build_instruction<IrInstSrcBr>(ag, scope, source_node); | 1305 | IrInstSrcBr *inst = ir_build_instruction<IrInstSrcBr>(ag, scope, source_node); |
| 1306 | inst->base.is_noreturn = true; | 1306 | inst->base.is_noreturn = true; |
| ... | @@ -1714,7 +1714,7 @@ static IrInstSrc *ir_build_bit_reverse(Stage1AstGen *ag, Scope *scope, AstNode * | ... | @@ -1714,7 +1714,7 @@ static IrInstSrc *ir_build_bit_reverse(Stage1AstGen *ag, Scope *scope, AstNode * |
| 1714 | } | 1714 | } |
| 1715 | | 1715 | |
| 1716 | static IrInstSrcSwitchBr *ir_build_switch_br_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, | 1716 | static IrInstSrcSwitchBr *ir_build_switch_br_src(Stage1AstGen *ag, Scope *scope, AstNode *source_node, |
| 1717 | IrInstSrc *target_value, IrBasicBlockSrc *else_block, size_t case_count, IrInstSrcSwitchBrCase *cases, | 1717 | IrInstSrc *target_value, Stage1ZirBasicBlock *else_block, size_t case_count, IrInstSrcSwitchBrCase *cases, |
| 1718 | IrInstSrc *is_comptime, IrInstSrc *switch_prongs_void) | 1718 | IrInstSrc *is_comptime, IrInstSrc *switch_prongs_void) |
| 1719 | { | 1719 | { |
| 1720 | IrInstSrcSwitchBr *instruction = ir_build_instruction<IrInstSrcSwitchBr>(ag, scope, source_node); | 1720 | IrInstSrcSwitchBr *instruction = ir_build_instruction<IrInstSrcSwitchBr>(ag, scope, source_node); |
| ... | @@ -2976,12 +2976,12 @@ static bool ir_gen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope | ... | @@ -2976,12 +2976,12 @@ static bool ir_gen_defers_for_block(Stage1AstGen *ag, Scope *inner_scope, Scope |
| 2976 | return true; | 2976 | return true; |
| 2977 | } | 2977 | } |
| 2978 | | 2978 | |
| 2979 | static void ir_set_cursor_at_end(Stage1AstGen *ag, IrBasicBlockSrc *basic_block) { | 2979 | static void ir_set_cursor_at_end(Stage1AstGen *ag, Stage1ZirBasicBlock *basic_block) { |
| 2980 | assert(basic_block); | 2980 | assert(basic_block); |
| 2981 | ag->current_basic_block = basic_block; | 2981 | ag->current_basic_block = basic_block; |
| 2982 | } | 2982 | } |
| 2983 | | 2983 | |
| 2984 | static void ir_set_cursor_at_end_and_append_block(Stage1AstGen *ag, IrBasicBlockSrc *basic_block) { | 2984 | static void ir_set_cursor_at_end_and_append_block(Stage1AstGen *ag, Stage1ZirBasicBlock *basic_block) { |
| 2985 | basic_block->index = ag->exec->basic_block_list.length; | 2985 | basic_block->index = ag->exec->basic_block_list.length; |
| 2986 | ag->exec->basic_block_list.append(basic_block); | 2986 | ag->exec->basic_block_list.append(basic_block); |
| 2987 | ir_set_cursor_at_end(ag, basic_block); | 2987 | ir_set_cursor_at_end(ag, basic_block); |
| ... | @@ -3062,8 +3062,8 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L | ... | @@ -3062,8 +3062,8 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3062 | } | 3062 | } |
| 3063 | bool should_inline = ir_should_inline(ag->exec, scope); | 3063 | bool should_inline = ir_should_inline(ag->exec, scope); |
| 3064 | | 3064 | |
| 3065 | IrBasicBlockSrc *err_block = ir_create_basic_block(ag, scope, "ErrRetErr"); | 3065 | Stage1ZirBasicBlock *err_block = ir_create_basic_block(ag, scope, "ErrRetErr"); |
| 3066 | IrBasicBlockSrc *ok_block = ir_create_basic_block(ag, scope, "ErrRetOk"); | 3066 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, scope, "ErrRetOk"); |
| 3067 | | 3067 | |
| 3068 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node, return_value, false, true); | 3068 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node, return_value, false, true); |
| 3069 | | 3069 | |
| ... | @@ -3075,7 +3075,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L | ... | @@ -3075,7 +3075,7 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3075 | } | 3075 | } |
| 3076 | | 3076 | |
| 3077 | ir_mark_gen(ir_build_cond_br(ag, scope, node, is_err, err_block, ok_block, is_comptime)); | 3077 | ir_mark_gen(ir_build_cond_br(ag, scope, node, is_err, err_block, ok_block, is_comptime)); |
| 3078 | IrBasicBlockSrc *ret_stmt_block = ir_create_basic_block(ag, scope, "RetStmt"); | 3078 | Stage1ZirBasicBlock *ret_stmt_block = ir_create_basic_block(ag, scope, "RetStmt"); |
| 3079 | | 3079 | |
| 3080 | ir_set_cursor_at_end_and_append_block(ag, err_block); | 3080 | 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 (!ir_gen_defers_for_block(ag, scope, outer_scope, nullptr, return_value)) |
| ... | @@ -3103,8 +3103,8 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L | ... | @@ -3103,8 +3103,8 @@ static IrInstSrc *ir_gen_return(Stage1AstGen *ag, Scope *scope, AstNode *node, L |
| 3103 | return ag->codegen->invalid_inst_src; | 3103 | return ag->codegen->invalid_inst_src; |
| 3104 | IrInstSrc *is_err_val = ir_build_test_err_src(ag, scope, node, err_union_ptr, true, false); | 3104 | IrInstSrc *is_err_val = ir_build_test_err_src(ag, scope, node, err_union_ptr, true, false); |
| 3105 | | 3105 | |
| 3106 | IrBasicBlockSrc *return_block = ir_create_basic_block(ag, scope, "ErrRetReturn"); | 3106 | Stage1ZirBasicBlock *return_block = ir_create_basic_block(ag, scope, "ErrRetReturn"); |
| 3107 | IrBasicBlockSrc *continue_block = ir_create_basic_block(ag, scope, "ErrRetContinue"); | 3107 | Stage1ZirBasicBlock *continue_block = ir_create_basic_block(ag, scope, "ErrRetContinue"); |
| 3108 | IrInstSrc *is_comptime; | 3108 | IrInstSrc *is_comptime; |
| 3109 | bool should_inline = ir_should_inline(ag->exec, scope); | 3109 | bool should_inline = ir_should_inline(ag->exec, scope); |
| 3110 | if (should_inline) { | 3110 | if (should_inline) { |
| ... | @@ -3266,7 +3266,7 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b | ... | @@ -3266,7 +3266,7 @@ static IrInstSrc *ir_gen_block(Stage1AstGen *ag, Scope *parent_scope, AstNode *b |
| 3266 | assert(block_node->type == NodeTypeBlock); | 3266 | assert(block_node->type == NodeTypeBlock); |
| 3267 | | 3267 | |
| 3268 | ZigList<IrInstSrc *> incoming_values = {0}; | 3268 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 3269 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | 3269 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 3270 | | 3270 | |
| 3271 | if (is_duplicate_label(ag->codegen, parent_scope, block_node, block_node->data.block.name)) | 3271 | if (is_duplicate_label(ag->codegen, parent_scope, block_node, block_node->data.block.name)) |
| 3272 | return ag->codegen->invalid_inst_src; | 3272 | return ag->codegen->invalid_inst_src; |
| ... | @@ -3479,7 +3479,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3479,7 +3479,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3479 | IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); | 3479 | IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3480 | if (val1 == ag->codegen->invalid_inst_src) | 3480 | if (val1 == ag->codegen->invalid_inst_src) |
| 3481 | return ag->codegen->invalid_inst_src; | 3481 | return ag->codegen->invalid_inst_src; |
| 3482 | IrBasicBlockSrc *post_val1_block = ag->current_basic_block; | 3482 | Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block; |
| 3483 | | 3483 | |
| 3484 | IrInstSrc *is_comptime; | 3484 | IrInstSrc *is_comptime; |
| 3485 | if (ir_should_inline(ag->exec, scope)) { | 3485 | if (ir_should_inline(ag->exec, scope)) { |
| ... | @@ -3489,9 +3489,9 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3489,9 +3489,9 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3489 | } | 3489 | } |
| 3490 | | 3490 | |
| 3491 | // block for when val1 == false | 3491 | // block for when val1 == false |
| 3492 | IrBasicBlockSrc *false_block = ir_create_basic_block(ag, scope, "BoolOrFalse"); | 3492 | Stage1ZirBasicBlock *false_block = ir_create_basic_block(ag, scope, "BoolOrFalse"); |
| 3493 | // block for when val1 == true (don't even evaluate the second part) | 3493 | // block for when val1 == true (don't even evaluate the second part) |
| 3494 | IrBasicBlockSrc *true_block = ir_create_basic_block(ag, scope, "BoolOrTrue"); | 3494 | Stage1ZirBasicBlock *true_block = ir_create_basic_block(ag, scope, "BoolOrTrue"); |
| 3495 | | 3495 | |
| 3496 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); | 3496 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); |
| 3497 | | 3497 | |
| ... | @@ -3499,7 +3499,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3499,7 +3499,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3499 | IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); | 3499 | IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3500 | if (val2 == ag->codegen->invalid_inst_src) | 3500 | if (val2 == ag->codegen->invalid_inst_src) |
| 3501 | return ag->codegen->invalid_inst_src; | 3501 | return ag->codegen->invalid_inst_src; |
| 3502 | IrBasicBlockSrc *post_val2_block = ag->current_basic_block; | 3502 | Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block; |
| 3503 | | 3503 | |
| 3504 | ir_build_br(ag, scope, node, true_block, is_comptime); | 3504 | ir_build_br(ag, scope, node, true_block, is_comptime); |
| 3505 | | 3505 | |
| ... | @@ -3508,7 +3508,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3508,7 +3508,7 @@ static IrInstSrc *ir_gen_bool_or(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3508 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 3508 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 3509 | incoming_values[0] = val1; | 3509 | incoming_values[0] = val1; |
| 3510 | incoming_values[1] = val2; | 3510 | incoming_values[1] = val2; |
| 3511 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 3511 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 3512 | incoming_blocks[0] = post_val1_block; | 3512 | incoming_blocks[0] = post_val1_block; |
| 3513 | incoming_blocks[1] = post_val2_block; | 3513 | incoming_blocks[1] = post_val2_block; |
| 3514 | | 3514 | |
| ... | @@ -3521,7 +3521,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3521,7 +3521,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3521 | IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); | 3521 | IrInstSrc *val1 = ir_gen_node(ag, node->data.bin_op_expr.op1, scope); |
| 3522 | if (val1 == ag->codegen->invalid_inst_src) | 3522 | if (val1 == ag->codegen->invalid_inst_src) |
| 3523 | return ag->codegen->invalid_inst_src; | 3523 | return ag->codegen->invalid_inst_src; |
| 3524 | IrBasicBlockSrc *post_val1_block = ag->current_basic_block; | 3524 | Stage1ZirBasicBlock *post_val1_block = ag->current_basic_block; |
| 3525 | | 3525 | |
| 3526 | IrInstSrc *is_comptime; | 3526 | IrInstSrc *is_comptime; |
| 3527 | if (ir_should_inline(ag->exec, scope)) { | 3527 | if (ir_should_inline(ag->exec, scope)) { |
| ... | @@ -3531,9 +3531,9 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3531,9 +3531,9 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3531 | } | 3531 | } |
| 3532 | | 3532 | |
| 3533 | // block for when val1 == true | 3533 | // block for when val1 == true |
| 3534 | IrBasicBlockSrc *true_block = ir_create_basic_block(ag, scope, "BoolAndTrue"); | 3534 | Stage1ZirBasicBlock *true_block = ir_create_basic_block(ag, scope, "BoolAndTrue"); |
| 3535 | // block for when val1 == false (don't even evaluate the second part) | 3535 | // block for when val1 == false (don't even evaluate the second part) |
| 3536 | IrBasicBlockSrc *false_block = ir_create_basic_block(ag, scope, "BoolAndFalse"); | 3536 | Stage1ZirBasicBlock *false_block = ir_create_basic_block(ag, scope, "BoolAndFalse"); |
| 3537 | | 3537 | |
| 3538 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); | 3538 | ir_build_cond_br(ag, scope, node, val1, true_block, false_block, is_comptime); |
| 3539 | | 3539 | |
| ... | @@ -3541,7 +3541,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3541,7 +3541,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3541 | IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); | 3541 | IrInstSrc *val2 = ir_gen_node(ag, node->data.bin_op_expr.op2, scope); |
| 3542 | if (val2 == ag->codegen->invalid_inst_src) | 3542 | if (val2 == ag->codegen->invalid_inst_src) |
| 3543 | return ag->codegen->invalid_inst_src; | 3543 | return ag->codegen->invalid_inst_src; |
| 3544 | IrBasicBlockSrc *post_val2_block = ag->current_basic_block; | 3544 | Stage1ZirBasicBlock *post_val2_block = ag->current_basic_block; |
| 3545 | | 3545 | |
| 3546 | ir_build_br(ag, scope, node, false_block, is_comptime); | 3546 | ir_build_br(ag, scope, node, false_block, is_comptime); |
| 3547 | | 3547 | |
| ... | @@ -3550,7 +3550,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3550,7 +3550,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3550 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 3550 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 3551 | incoming_values[0] = val1; | 3551 | incoming_values[0] = val1; |
| 3552 | incoming_values[1] = val2; | 3552 | incoming_values[1] = val2; |
| 3553 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 3553 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 3554 | incoming_blocks[0] = post_val1_block; | 3554 | incoming_blocks[0] = post_val1_block; |
| 3555 | incoming_blocks[1] = post_val2_block; | 3555 | incoming_blocks[1] = post_val2_block; |
| 3556 | | 3556 | |
| ... | @@ -3558,7 +3558,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) | ... | @@ -3558,7 +3558,7 @@ static IrInstSrc *ir_gen_bool_and(Stage1AstGen *ag, Scope *scope, AstNode *node) |
| 3558 | } | 3558 | } |
| 3559 | | 3559 | |
| 3560 | static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *cond_br_inst, | 3560 | static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *cond_br_inst, |
| 3561 | IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) | 3561 | Stage1ZirBasicBlock *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 3562 | { | 3562 | { |
| 3563 | ResultLocPeerParent *peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); | 3563 | ResultLocPeerParent *peer_parent = heap::c_allocator.create<ResultLocPeerParent>(); |
| 3564 | peer_parent->base.id = ResultLocIdPeerParent; | 3564 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | @@ -3578,7 +3578,7 @@ static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *c | ... | @@ -3578,7 +3578,7 @@ static ResultLocPeerParent *ir_build_result_peers(Stage1AstGen *ag, IrInstSrc *c |
| 3578 | } | 3578 | } |
| 3579 | | 3579 | |
| 3580 | static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, IrInstSrc *cond_br_inst, | 3580 | static ResultLocPeerParent *ir_build_binary_result_peers(Stage1AstGen *ag, IrInstSrc *cond_br_inst, |
| 3581 | IrBasicBlockSrc *else_block, IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) | 3581 | Stage1ZirBasicBlock *else_block, Stage1ZirBasicBlock *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 3582 | { | 3582 | { |
| 3583 | ResultLocPeerParent *peer_parent = ir_build_result_peers(ag, cond_br_inst, end_block, parent, is_comptime); | 3583 | ResultLocPeerParent *peer_parent = ir_build_result_peers(ag, cond_br_inst, end_block, parent, is_comptime); |
| 3584 | | 3584 | |
| ... | @@ -3613,9 +3613,9 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * | ... | @@ -3613,9 +3613,9 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3613 | is_comptime = ir_build_test_comptime(ag, parent_scope, node, is_non_null); | 3613 | is_comptime = ir_build_test_comptime(ag, parent_scope, node, is_non_null); |
| 3614 | } | 3614 | } |
| 3615 | | 3615 | |
| 3616 | IrBasicBlockSrc *ok_block = ir_create_basic_block(ag, parent_scope, "OptionalNonNull"); | 3616 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, parent_scope, "OptionalNonNull"); |
| 3617 | IrBasicBlockSrc *null_block = ir_create_basic_block(ag, parent_scope, "OptionalNull"); | 3617 | Stage1ZirBasicBlock *null_block = ir_create_basic_block(ag, parent_scope, "OptionalNull"); |
| 3618 | IrBasicBlockSrc *end_block = ir_create_basic_block(ag, parent_scope, "OptionalEnd"); | 3618 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, parent_scope, "OptionalEnd"); |
| 3619 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); | 3619 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); |
| 3620 | | 3620 | |
| 3621 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, ok_block, end_block, | 3621 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, ok_block, end_block, |
| ... | @@ -3626,7 +3626,7 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * | ... | @@ -3626,7 +3626,7 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3626 | &peer_parent->peers.at(0)->base); | 3626 | &peer_parent->peers.at(0)->base); |
| 3627 | if (null_result == ag->codegen->invalid_inst_src) | 3627 | if (null_result == ag->codegen->invalid_inst_src) |
| 3628 | return ag->codegen->invalid_inst_src; | 3628 | return ag->codegen->invalid_inst_src; |
| 3629 | IrBasicBlockSrc *after_null_block = ag->current_basic_block; | 3629 | Stage1ZirBasicBlock *after_null_block = ag->current_basic_block; |
| 3630 | if (!instr_is_unreachable(null_result)) | 3630 | if (!instr_is_unreachable(null_result)) |
| 3631 | ir_mark_gen(ir_build_br(ag, parent_scope, node, end_block, is_comptime)); | 3631 | ir_mark_gen(ir_build_br(ag, parent_scope, node, end_block, is_comptime)); |
| 3632 | | 3632 | |
| ... | @@ -3634,14 +3634,14 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * | ... | @@ -3634,14 +3634,14 @@ static IrInstSrc *ir_gen_orelse(Stage1AstGen *ag, Scope *parent_scope, AstNode * |
| 3634 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(ag, parent_scope, node, maybe_ptr, false); | 3634 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(ag, parent_scope, node, maybe_ptr, false); |
| 3635 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); | 3635 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); |
| 3636 | ir_build_end_expr(ag, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); | 3636 | ir_build_end_expr(ag, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 3637 | IrBasicBlockSrc *after_ok_block = ag->current_basic_block; | 3637 | Stage1ZirBasicBlock *after_ok_block = ag->current_basic_block; |
| 3638 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); | 3638 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); |
| 3639 | | 3639 | |
| 3640 | ir_set_cursor_at_end_and_append_block(ag, end_block); | 3640 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 3641 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 3641 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 3642 | incoming_values[0] = null_result; | 3642 | incoming_values[0] = null_result; |
| 3643 | incoming_values[1] = unwrapped_payload; | 3643 | incoming_values[1] = unwrapped_payload; |
| 3644 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 3644 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 3645 | incoming_blocks[0] = after_null_block; | 3645 | incoming_blocks[0] = after_null_block; |
| 3646 | incoming_blocks[1] = after_ok_block; | 3646 | incoming_blocks[1] = after_ok_block; |
| 3647 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 3647 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| ... | @@ -5372,9 +5372,9 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n | ... | @@ -5372,9 +5372,9 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5372 | AstNode *then_node = node->data.if_bool_expr.then_block; | 5372 | AstNode *then_node = node->data.if_bool_expr.then_block; |
| 5373 | AstNode *else_node = node->data.if_bool_expr.else_node; | 5373 | AstNode *else_node = node->data.if_bool_expr.else_node; |
| 5374 | | 5374 | |
| 5375 | IrBasicBlockSrc *then_block = ir_create_basic_block(ag, scope, "Then"); | 5375 | Stage1ZirBasicBlock *then_block = ir_create_basic_block(ag, scope, "Then"); |
| 5376 | IrBasicBlockSrc *else_block = ir_create_basic_block(ag, scope, "Else"); | 5376 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "Else"); |
| 5377 | IrBasicBlockSrc *endif_block = ir_create_basic_block(ag, scope, "EndIf"); | 5377 | Stage1ZirBasicBlock *endif_block = ir_create_basic_block(ag, scope, "EndIf"); |
| 5378 | | 5378 | |
| 5379 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, scope, node, condition, | 5379 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, scope, node, condition, |
| 5380 | then_block, else_block, is_comptime); | 5380 | then_block, else_block, is_comptime); |
| ... | @@ -5388,7 +5388,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n | ... | @@ -5388,7 +5388,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5388 | &peer_parent->peers.at(0)->base); | 5388 | &peer_parent->peers.at(0)->base); |
| 5389 | if (then_expr_result == ag->codegen->invalid_inst_src) | 5389 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 5390 | return ag->codegen->invalid_inst_src; | 5390 | return ag->codegen->invalid_inst_src; |
| 5391 | IrBasicBlockSrc *after_then_block = ag->current_basic_block; | 5391 | Stage1ZirBasicBlock *after_then_block = ag->current_basic_block; |
| 5392 | if (!instr_is_unreachable(then_expr_result)) | 5392 | if (!instr_is_unreachable(then_expr_result)) |
| 5393 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); | 5393 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); |
| 5394 | | 5394 | |
| ... | @@ -5402,7 +5402,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n | ... | @@ -5402,7 +5402,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5402 | else_expr_result = ir_build_const_void(ag, scope, node); | 5402 | else_expr_result = ir_build_const_void(ag, scope, node); |
| 5403 | ir_build_end_expr(ag, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 5403 | ir_build_end_expr(ag, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 5404 | } | 5404 | } |
| 5405 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 5405 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 5406 | if (!instr_is_unreachable(else_expr_result)) | 5406 | if (!instr_is_unreachable(else_expr_result)) |
| 5407 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); | 5407 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); |
| 5408 | | 5408 | |
| ... | @@ -5410,7 +5410,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n | ... | @@ -5410,7 +5410,7 @@ static IrInstSrc *ir_gen_if_bool_expr(Stage1AstGen *ag, Scope *scope, AstNode *n |
| 5410 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 5410 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 5411 | incoming_values[0] = then_expr_result; | 5411 | incoming_values[0] = then_expr_result; |
| 5412 | incoming_values[1] = else_expr_result; | 5412 | incoming_values[1] = else_expr_result; |
| 5413 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 5413 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 5414 | incoming_blocks[0] = after_then_block; | 5414 | incoming_blocks[0] = after_then_block; |
| 5415 | incoming_blocks[1] = after_else_block; | 5415 | incoming_blocks[1] = after_else_block; |
| 5416 | | 5416 | |
| ... | @@ -5912,12 +5912,12 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -5912,12 +5912,12 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5912 | AstNode *continue_expr_node = node->data.while_expr.continue_expr; | 5912 | AstNode *continue_expr_node = node->data.while_expr.continue_expr; |
| 5913 | AstNode *else_node = node->data.while_expr.else_node; | 5913 | AstNode *else_node = node->data.while_expr.else_node; |
| 5914 | | 5914 | |
| 5915 | IrBasicBlockSrc *cond_block = ir_create_basic_block(ag, scope, "WhileCond"); | 5915 | Stage1ZirBasicBlock *cond_block = ir_create_basic_block(ag, scope, "WhileCond"); |
| 5916 | IrBasicBlockSrc *body_block = ir_create_basic_block(ag, scope, "WhileBody"); | 5916 | Stage1ZirBasicBlock *body_block = ir_create_basic_block(ag, scope, "WhileBody"); |
| 5917 | IrBasicBlockSrc *continue_block = continue_expr_node ? | 5917 | Stage1ZirBasicBlock *continue_block = continue_expr_node ? |
| 5918 | ir_create_basic_block(ag, scope, "WhileContinue") : cond_block; | 5918 | ir_create_basic_block(ag, scope, "WhileContinue") : cond_block; |
| 5919 | IrBasicBlockSrc *end_block = ir_create_basic_block(ag, scope, "WhileEnd"); | 5919 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, scope, "WhileEnd"); |
| 5920 | IrBasicBlockSrc *else_block = else_node ? | 5920 | Stage1ZirBasicBlock *else_block = else_node ? |
| 5921 | ir_create_basic_block(ag, scope, "WhileElse") : end_block; | 5921 | ir_create_basic_block(ag, scope, "WhileElse") : end_block; |
| 5922 | | 5922 | |
| 5923 | IrInstSrc *is_comptime = ir_build_const_bool(ag, scope, node, | 5923 | IrInstSrc *is_comptime = ir_build_const_bool(ag, scope, node, |
| ... | @@ -5948,7 +5948,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -5948,7 +5948,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5948 | return err_val_ptr; | 5948 | return err_val_ptr; |
| 5949 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node->data.while_expr.condition, err_val_ptr, | 5949 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node->data.while_expr.condition, err_val_ptr, |
| 5950 | true, false); | 5950 | true, false); |
| 5951 | IrBasicBlockSrc *after_cond_block = ag->current_basic_block; | 5951 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 5952 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, scope, node)); | 5952 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, scope, node)); |
| 5953 | IrInstSrc *cond_br_inst; | 5953 | IrInstSrc *cond_br_inst; |
| 5954 | if (!instr_is_unreachable(is_err)) { | 5954 | if (!instr_is_unreachable(is_err)) { |
| ... | @@ -5973,7 +5973,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -5973,7 +5973,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 5973 | } | 5973 | } |
| 5974 | | 5974 | |
| 5975 | ZigList<IrInstSrc *> incoming_values = {0}; | 5975 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 5976 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | 5976 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 5977 | | 5977 | |
| 5978 | if (is_duplicate_label(ag->codegen, payload_scope, node, node->data.while_expr.name)) | 5978 | if (is_duplicate_label(ag->codegen, payload_scope, node, node->data.while_expr.name)) |
| 5979 | return ag->codegen->invalid_inst_src; | 5979 | return ag->codegen->invalid_inst_src; |
| ... | @@ -6037,7 +6037,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6037,7 +6037,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6037 | return else_result; | 6037 | return else_result; |
| 6038 | if (!instr_is_unreachable(else_result)) | 6038 | if (!instr_is_unreachable(else_result)) |
| 6039 | ir_mark_gen(ir_build_br(ag, scope, node, end_block, is_comptime)); | 6039 | ir_mark_gen(ir_build_br(ag, scope, node, end_block, is_comptime)); |
| 6040 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 6040 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 6041 | ir_set_cursor_at_end_and_append_block(ag, end_block); | 6041 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 6042 | if (else_result) { | 6042 | if (else_result) { |
| 6043 | incoming_blocks.append(after_else_block); | 6043 | incoming_blocks.append(after_else_block); |
| ... | @@ -6069,7 +6069,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6069,7 +6069,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6069 | return maybe_val_ptr; | 6069 | return maybe_val_ptr; |
| 6070 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, scope, node->data.while_expr.condition, maybe_val_ptr); | 6070 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, scope, node->data.while_expr.condition, maybe_val_ptr); |
| 6071 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, scope, node->data.while_expr.condition, maybe_val); | 6071 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, scope, node->data.while_expr.condition, maybe_val); |
| 6072 | IrBasicBlockSrc *after_cond_block = ag->current_basic_block; | 6072 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 6073 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, scope, node)); | 6073 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, scope, node)); |
| 6074 | IrInstSrc *cond_br_inst; | 6074 | IrInstSrc *cond_br_inst; |
| 6075 | if (!instr_is_unreachable(is_non_null)) { | 6075 | if (!instr_is_unreachable(is_non_null)) { |
| ... | @@ -6091,7 +6091,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6091,7 +6091,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6091 | build_decl_var_and_init(ag, child_scope, symbol_node, payload_var, var_value, buf_ptr(var_symbol), is_comptime); | 6091 | build_decl_var_and_init(ag, child_scope, symbol_node, payload_var, var_value, buf_ptr(var_symbol), is_comptime); |
| 6092 | | 6092 | |
| 6093 | ZigList<IrInstSrc *> incoming_values = {0}; | 6093 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 6094 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | 6094 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6095 | | 6095 | |
| 6096 | if (is_duplicate_label(ag->codegen, child_scope, node, node->data.while_expr.name)) | 6096 | if (is_duplicate_label(ag->codegen, child_scope, node, node->data.while_expr.name)) |
| 6097 | return ag->codegen->invalid_inst_src; | 6097 | return ag->codegen->invalid_inst_src; |
| ... | @@ -6148,7 +6148,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6148,7 +6148,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6148 | if (!instr_is_unreachable(else_result)) | 6148 | if (!instr_is_unreachable(else_result)) |
| 6149 | ir_mark_gen(ir_build_br(ag, scope, node, end_block, is_comptime)); | 6149 | ir_mark_gen(ir_build_br(ag, scope, node, end_block, is_comptime)); |
| 6150 | } | 6150 | } |
| 6151 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 6151 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 6152 | ir_set_cursor_at_end_and_append_block(ag, end_block); | 6152 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 6153 | if (else_result) { | 6153 | if (else_result) { |
| 6154 | incoming_blocks.append(after_else_block); | 6154 | incoming_blocks.append(after_else_block); |
| ... | @@ -6169,7 +6169,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6169,7 +6169,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6169 | IrInstSrc *cond_val = ir_gen_node(ag, node->data.while_expr.condition, scope); | 6169 | IrInstSrc *cond_val = ir_gen_node(ag, node->data.while_expr.condition, scope); |
| 6170 | if (cond_val == ag->codegen->invalid_inst_src) | 6170 | if (cond_val == ag->codegen->invalid_inst_src) |
| 6171 | return cond_val; | 6171 | return cond_val; |
| 6172 | IrBasicBlockSrc *after_cond_block = ag->current_basic_block; | 6172 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 6173 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, scope, node)); | 6173 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, scope, node)); |
| 6174 | IrInstSrc *cond_br_inst; | 6174 | IrInstSrc *cond_br_inst; |
| 6175 | if (!instr_is_unreachable(cond_val)) { | 6175 | if (!instr_is_unreachable(cond_val)) { |
| ... | @@ -6186,7 +6186,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6186,7 +6186,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6186 | ir_set_cursor_at_end_and_append_block(ag, body_block); | 6186 | ir_set_cursor_at_end_and_append_block(ag, body_block); |
| 6187 | | 6187 | |
| 6188 | ZigList<IrInstSrc *> incoming_values = {0}; | 6188 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 6189 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | 6189 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6190 | | 6190 | |
| 6191 | Scope *subexpr_scope = create_runtime_scope(ag->codegen, node, scope, is_comptime); | 6191 | Scope *subexpr_scope = create_runtime_scope(ag->codegen, node, scope, is_comptime); |
| 6192 | | 6192 | |
| ... | @@ -6245,7 +6245,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod | ... | @@ -6245,7 +6245,7 @@ static IrInstSrc *ir_gen_while_expr(Stage1AstGen *ag, Scope *scope, AstNode *nod |
| 6245 | if (!instr_is_unreachable(else_result)) | 6245 | if (!instr_is_unreachable(else_result)) |
| 6246 | ir_mark_gen(ir_build_br(ag, scope, node, end_block, is_comptime)); | 6246 | ir_mark_gen(ir_build_br(ag, scope, node, end_block, is_comptime)); |
| 6247 | } | 6247 | } |
| 6248 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 6248 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 6249 | ir_set_cursor_at_end_and_append_block(ag, end_block); | 6249 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 6250 | if (else_result) { | 6250 | if (else_result) { |
| 6251 | incoming_blocks.append(after_else_block); | 6251 | incoming_blocks.append(after_else_block); |
| ... | @@ -6312,11 +6312,11 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode | ... | @@ -6312,11 +6312,11 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6312 | IrInstSrc *index_ptr = ir_build_var_ptr(ag, parent_scope, node, index_var); | 6312 | IrInstSrc *index_ptr = ir_build_var_ptr(ag, parent_scope, node, index_var); |
| 6313 | | 6313 | |
| 6314 | | 6314 | |
| 6315 | IrBasicBlockSrc *cond_block = ir_create_basic_block(ag, parent_scope, "ForCond"); | 6315 | Stage1ZirBasicBlock *cond_block = ir_create_basic_block(ag, parent_scope, "ForCond"); |
| 6316 | IrBasicBlockSrc *body_block = ir_create_basic_block(ag, parent_scope, "ForBody"); | 6316 | Stage1ZirBasicBlock *body_block = ir_create_basic_block(ag, parent_scope, "ForBody"); |
| 6317 | IrBasicBlockSrc *end_block = ir_create_basic_block(ag, parent_scope, "ForEnd"); | 6317 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, parent_scope, "ForEnd"); |
| 6318 | IrBasicBlockSrc *else_block = else_node ? ir_create_basic_block(ag, parent_scope, "ForElse") : end_block; | 6318 | Stage1ZirBasicBlock *else_block = else_node ? ir_create_basic_block(ag, parent_scope, "ForElse") : end_block; |
| 6319 | IrBasicBlockSrc *continue_block = ir_create_basic_block(ag, parent_scope, "ForContinue"); | 6319 | Stage1ZirBasicBlock *continue_block = ir_create_basic_block(ag, parent_scope, "ForContinue"); |
| 6320 | | 6320 | |
| 6321 | Buf *len_field_name = buf_create_from_str("len"); | 6321 | Buf *len_field_name = buf_create_from_str("len"); |
| 6322 | IrInstSrc *len_ref = ir_build_field_ptr(ag, parent_scope, node, array_val_ptr, len_field_name, false); | 6322 | IrInstSrc *len_ref = ir_build_field_ptr(ag, parent_scope, node, array_val_ptr, len_field_name, false); |
| ... | @@ -6326,7 +6326,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode | ... | @@ -6326,7 +6326,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6326 | ir_set_cursor_at_end_and_append_block(ag, cond_block); | 6326 | ir_set_cursor_at_end_and_append_block(ag, cond_block); |
| 6327 | IrInstSrc *index_val = ir_build_load_ptr(ag, &spill_scope->base, node, index_ptr); | 6327 | IrInstSrc *index_val = ir_build_load_ptr(ag, &spill_scope->base, node, index_ptr); |
| 6328 | IrInstSrc *cond = ir_build_bin_op(ag, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); | 6328 | IrInstSrc *cond = ir_build_bin_op(ag, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); |
| 6329 | IrBasicBlockSrc *after_cond_block = ag->current_basic_block; | 6329 | Stage1ZirBasicBlock *after_cond_block = ag->current_basic_block; |
| 6330 | IrInstSrc *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, parent_scope, node)); | 6330 | IrInstSrc *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(ag, parent_scope, node)); |
| 6331 | IrInstSrc *cond_br_inst = ir_mark_gen(ir_build_cond_br(ag, parent_scope, node, cond, | 6331 | IrInstSrc *cond_br_inst = ir_mark_gen(ir_build_cond_br(ag, parent_scope, node, cond, |
| 6332 | body_block, else_block, is_comptime)); | 6332 | body_block, else_block, is_comptime)); |
| ... | @@ -6349,7 +6349,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode | ... | @@ -6349,7 +6349,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6349 | return ag->codegen->invalid_inst_src; | 6349 | return ag->codegen->invalid_inst_src; |
| 6350 | | 6350 | |
| 6351 | ZigList<IrInstSrc *> incoming_values = {0}; | 6351 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 6352 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | 6352 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6353 | ScopeLoop *loop_scope = create_loop_scope(ag->codegen, node, child_scope); | 6353 | ScopeLoop *loop_scope = create_loop_scope(ag->codegen, node, child_scope); |
| 6354 | loop_scope->break_block = end_block; | 6354 | loop_scope->break_block = end_block; |
| 6355 | loop_scope->continue_block = continue_block; | 6355 | loop_scope->continue_block = continue_block; |
| ... | @@ -6396,7 +6396,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode | ... | @@ -6396,7 +6396,7 @@ static IrInstSrc *ir_gen_for_expr(Stage1AstGen *ag, Scope *parent_scope, AstNode |
| 6396 | if (!instr_is_unreachable(else_result)) | 6396 | if (!instr_is_unreachable(else_result)) |
| 6397 | ir_mark_gen(ir_build_br(ag, parent_scope, node, end_block, is_comptime)); | 6397 | ir_mark_gen(ir_build_br(ag, parent_scope, node, end_block, is_comptime)); |
| 6398 | } | 6398 | } |
| 6399 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 6399 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 6400 | ir_set_cursor_at_end_and_append_block(ag, end_block); | 6400 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 6401 | | 6401 | |
| 6402 | if (else_result) { | 6402 | if (else_result) { |
| ... | @@ -6667,9 +6667,9 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod | ... | @@ -6667,9 +6667,9 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6667 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, scope, node, maybe_val_ptr); | 6667 | IrInstSrc *maybe_val = ir_build_load_ptr(ag, scope, node, maybe_val_ptr); |
| 6668 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, scope, node, maybe_val); | 6668 | IrInstSrc *is_non_null = ir_build_test_non_null_src(ag, scope, node, maybe_val); |
| 6669 | | 6669 | |
| 6670 | IrBasicBlockSrc *then_block = ir_create_basic_block(ag, scope, "OptionalThen"); | 6670 | Stage1ZirBasicBlock *then_block = ir_create_basic_block(ag, scope, "OptionalThen"); |
| 6671 | IrBasicBlockSrc *else_block = ir_create_basic_block(ag, scope, "OptionalElse"); | 6671 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "OptionalElse"); |
| 6672 | IrBasicBlockSrc *endif_block = ir_create_basic_block(ag, scope, "OptionalEndIf"); | 6672 | Stage1ZirBasicBlock *endif_block = ir_create_basic_block(ag, scope, "OptionalEndIf"); |
| 6673 | | 6673 | |
| 6674 | IrInstSrc *is_comptime; | 6674 | IrInstSrc *is_comptime; |
| 6675 | if (ir_should_inline(ag->exec, scope)) { | 6675 | if (ir_should_inline(ag->exec, scope)) { |
| ... | @@ -6705,7 +6705,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod | ... | @@ -6705,7 +6705,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6705 | &peer_parent->peers.at(0)->base); | 6705 | &peer_parent->peers.at(0)->base); |
| 6706 | if (then_expr_result == ag->codegen->invalid_inst_src) | 6706 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 6707 | return then_expr_result; | 6707 | return then_expr_result; |
| 6708 | IrBasicBlockSrc *after_then_block = ag->current_basic_block; | 6708 | Stage1ZirBasicBlock *after_then_block = ag->current_basic_block; |
| 6709 | if (!instr_is_unreachable(then_expr_result)) | 6709 | if (!instr_is_unreachable(then_expr_result)) |
| 6710 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); | 6710 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); |
| 6711 | | 6711 | |
| ... | @@ -6719,7 +6719,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod | ... | @@ -6719,7 +6719,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6719 | else_expr_result = ir_build_const_void(ag, scope, node); | 6719 | else_expr_result = ir_build_const_void(ag, scope, node); |
| 6720 | ir_build_end_expr(ag, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 6720 | ir_build_end_expr(ag, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 6721 | } | 6721 | } |
| 6722 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 6722 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 6723 | if (!instr_is_unreachable(else_expr_result)) | 6723 | if (!instr_is_unreachable(else_expr_result)) |
| 6724 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); | 6724 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); |
| 6725 | | 6725 | |
| ... | @@ -6727,7 +6727,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod | ... | @@ -6727,7 +6727,7 @@ static IrInstSrc *ir_gen_if_optional_expr(Stage1AstGen *ag, Scope *scope, AstNod |
| 6727 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 6727 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 6728 | incoming_values[0] = then_expr_result; | 6728 | incoming_values[0] = then_expr_result; |
| 6729 | incoming_values[1] = else_expr_result; | 6729 | incoming_values[1] = else_expr_result; |
| 6730 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 6730 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 6731 | incoming_blocks[0] = after_then_block; | 6731 | incoming_blocks[0] = after_then_block; |
| 6732 | incoming_blocks[1] = after_else_block; | 6732 | incoming_blocks[1] = after_else_block; |
| 6733 | | 6733 | |
| ... | @@ -6755,9 +6755,9 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6755,9 +6755,9 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6755 | IrInstSrc *err_val = ir_build_load_ptr(ag, scope, node, err_val_ptr); | 6755 | IrInstSrc *err_val = ir_build_load_ptr(ag, scope, node, err_val_ptr); |
| 6756 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node, err_val_ptr, true, false); | 6756 | IrInstSrc *is_err = ir_build_test_err_src(ag, scope, node, err_val_ptr, true, false); |
| 6757 | | 6757 | |
| 6758 | IrBasicBlockSrc *ok_block = ir_create_basic_block(ag, scope, "TryOk"); | 6758 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, scope, "TryOk"); |
| 6759 | IrBasicBlockSrc *else_block = ir_create_basic_block(ag, scope, "TryElse"); | 6759 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "TryElse"); |
| 6760 | IrBasicBlockSrc *endif_block = ir_create_basic_block(ag, scope, "TryEnd"); | 6760 | Stage1ZirBasicBlock *endif_block = ir_create_basic_block(ag, scope, "TryEnd"); |
| 6761 | | 6761 | |
| 6762 | bool force_comptime = ir_should_inline(ag->exec, scope); | 6762 | bool force_comptime = ir_should_inline(ag->exec, scope); |
| 6763 | IrInstSrc *is_comptime = force_comptime ? ir_build_const_bool(ag, scope, node, true) : ir_build_test_comptime(ag, scope, node, is_err); | 6763 | IrInstSrc *is_comptime = force_comptime ? ir_build_const_bool(ag, scope, node, true) : ir_build_test_comptime(ag, scope, node, is_err); |
| ... | @@ -6788,7 +6788,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6788,7 +6788,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6788 | &peer_parent->peers.at(0)->base); | 6788 | &peer_parent->peers.at(0)->base); |
| 6789 | if (then_expr_result == ag->codegen->invalid_inst_src) | 6789 | if (then_expr_result == ag->codegen->invalid_inst_src) |
| 6790 | return then_expr_result; | 6790 | return then_expr_result; |
| 6791 | IrBasicBlockSrc *after_then_block = ag->current_basic_block; | 6791 | Stage1ZirBasicBlock *after_then_block = ag->current_basic_block; |
| 6792 | if (!instr_is_unreachable(then_expr_result)) | 6792 | if (!instr_is_unreachable(then_expr_result)) |
| 6793 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); | 6793 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); |
| 6794 | | 6794 | |
| ... | @@ -6817,7 +6817,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6817,7 +6817,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6817 | else_expr_result = ir_build_const_void(ag, scope, node); | 6817 | else_expr_result = ir_build_const_void(ag, scope, node); |
| 6818 | ir_build_end_expr(ag, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 6818 | ir_build_end_expr(ag, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 6819 | } | 6819 | } |
| 6820 | IrBasicBlockSrc *after_else_block = ag->current_basic_block; | 6820 | Stage1ZirBasicBlock *after_else_block = ag->current_basic_block; |
| 6821 | if (!instr_is_unreachable(else_expr_result)) | 6821 | if (!instr_is_unreachable(else_expr_result)) |
| 6822 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); | 6822 | ir_mark_gen(ir_build_br(ag, scope, node, endif_block, is_comptime)); |
| 6823 | | 6823 | |
| ... | @@ -6825,7 +6825,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6825,7 +6825,7 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6825 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 6825 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 6826 | incoming_values[0] = then_expr_result; | 6826 | incoming_values[0] = then_expr_result; |
| 6827 | incoming_values[1] = else_expr_result; | 6827 | incoming_values[1] = else_expr_result; |
| 6828 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 6828 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 6829 | incoming_blocks[0] = after_then_block; | 6829 | incoming_blocks[0] = after_then_block; |
| 6830 | incoming_blocks[1] = after_else_block; | 6830 | incoming_blocks[1] = after_else_block; |
| 6831 | | 6831 | |
| ... | @@ -6834,9 +6834,9 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6834,9 +6834,9 @@ static IrInstSrc *ir_gen_if_err_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6834 | } | 6834 | } |
| 6835 | | 6835 | |
| 6836 | static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node, | 6836 | static bool ir_gen_switch_prong_expr(Stage1AstGen *ag, Scope *scope, AstNode *switch_node, AstNode *prong_node, |
| 6837 | IrBasicBlockSrc *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime, | 6837 | Stage1ZirBasicBlock *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime, |
| 6838 | IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len, | 6838 | IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len, |
| 6839 | ZigList<IrBasicBlockSrc *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values, | 6839 | ZigList<Stage1ZirBasicBlock *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values, |
| 6840 | IrInstSrcSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) | 6840 | IrInstSrcSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) |
| 6841 | { | 6841 | { |
| 6842 | assert(switch_node->type == NodeTypeSwitchExpr); | 6842 | assert(switch_node->type == NodeTypeSwitchExpr); |
| ... | @@ -6898,8 +6898,8 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6898,8 +6898,8 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6898 | return target_value_ptr; | 6898 | return target_value_ptr; |
| 6899 | IrInstSrc *target_value = ir_build_switch_target(ag, scope, node, target_value_ptr); | 6899 | IrInstSrc *target_value = ir_build_switch_target(ag, scope, node, target_value_ptr); |
| 6900 | | 6900 | |
| 6901 | IrBasicBlockSrc *else_block = ir_create_basic_block(ag, scope, "SwitchElse"); | 6901 | Stage1ZirBasicBlock *else_block = ir_create_basic_block(ag, scope, "SwitchElse"); |
| 6902 | IrBasicBlockSrc *end_block = ir_create_basic_block(ag, scope, "SwitchEnd"); | 6902 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, scope, "SwitchEnd"); |
| 6903 | | 6903 | |
| 6904 | size_t prong_count = node->data.switch_expr.prongs.length; | 6904 | size_t prong_count = node->data.switch_expr.prongs.length; |
| 6905 | ZigList<IrInstSrcSwitchBrCase> cases = {0}; | 6905 | ZigList<IrInstSrcSwitchBrCase> cases = {0}; |
| ... | @@ -6915,7 +6915,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6915,7 +6915,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6915 | } | 6915 | } |
| 6916 | | 6916 | |
| 6917 | ZigList<IrInstSrc *> incoming_values = {0}; | 6917 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 6918 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; | 6918 | ZigList<Stage1ZirBasicBlock *> incoming_blocks = {0}; |
| 6919 | ZigList<IrInstSrcCheckSwitchProngsRange> check_ranges = {0}; | 6919 | ZigList<IrInstSrcCheckSwitchProngsRange> check_ranges = {0}; |
| 6920 | | 6920 | |
| 6921 | IrInstSrcSwitchElseVar *switch_else_var = nullptr; | 6921 | IrInstSrcSwitchElseVar *switch_else_var = nullptr; |
| ... | @@ -6991,8 +6991,8 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -6991,8 +6991,8 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 6991 | } | 6991 | } |
| 6992 | } | 6992 | } |
| 6993 | | 6993 | |
| 6994 | IrBasicBlockSrc *range_block_yes = ir_create_basic_block(ag, scope, "SwitchRangeYes"); | 6994 | Stage1ZirBasicBlock *range_block_yes = ir_create_basic_block(ag, scope, "SwitchRangeYes"); |
| 6995 | IrBasicBlockSrc *range_block_no = ir_create_basic_block(ag, scope, "SwitchRangeNo"); | 6995 | Stage1ZirBasicBlock *range_block_no = ir_create_basic_block(ag, scope, "SwitchRangeNo"); |
| 6996 | | 6996 | |
| 6997 | assert(ok_bit); | 6997 | assert(ok_bit); |
| 6998 | assert(last_item_node); | 6998 | assert(last_item_node); |
| ... | @@ -7052,7 +7052,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -7052,7 +7052,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7052 | } | 7052 | } |
| 7053 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 7053 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 7054 | | 7054 | |
| 7055 | IrBasicBlockSrc *prev_block = ag->current_basic_block; | 7055 | Stage1ZirBasicBlock *prev_block = ag->current_basic_block; |
| 7056 | if (peer_parent->peers.length > 0) { | 7056 | if (peer_parent->peers.length > 0) { |
| 7057 | peer_parent->peers.last()->next_bb = else_block; | 7057 | peer_parent->peers.last()->next_bb = else_block; |
| 7058 | } | 7058 | } |
| ... | @@ -7081,7 +7081,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -7081,7 +7081,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7081 | | 7081 | |
| 7082 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 7082 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 7083 | | 7083 | |
| 7084 | IrBasicBlockSrc *prong_block = ir_create_basic_block(ag, scope, "SwitchProng"); | 7084 | Stage1ZirBasicBlock *prong_block = ir_create_basic_block(ag, scope, "SwitchProng"); |
| 7085 | IrInstSrc **items = heap::c_allocator.allocate<IrInstSrc *>(prong_item_count); | 7085 | IrInstSrc **items = heap::c_allocator.allocate<IrInstSrc *>(prong_item_count); |
| 7086 | | 7086 | |
| 7087 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { | 7087 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| ... | @@ -7103,7 +7103,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no | ... | @@ -7103,7 +7103,7 @@ static IrInstSrc *ir_gen_switch_expr(Stage1AstGen *ag, Scope *scope, AstNode *no |
| 7103 | items[item_i] = item_value; | 7103 | items[item_i] = item_value; |
| 7104 | } | 7104 | } |
| 7105 | | 7105 | |
| 7106 | IrBasicBlockSrc *prev_block = ag->current_basic_block; | 7106 | Stage1ZirBasicBlock *prev_block = ag->current_basic_block; |
| 7107 | if (peer_parent->peers.length > 0) { | 7107 | if (peer_parent->peers.length > 0) { |
| 7108 | peer_parent->peers.last()->next_bb = prong_block; | 7108 | peer_parent->peers.last()->next_bb = prong_block; |
| 7109 | } | 7109 | } |
| ... | @@ -7202,7 +7202,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, | ... | @@ -7202,7 +7202,7 @@ static IrInstSrc *ir_gen_return_from_block(Stage1AstGen *ag, Scope *break_scope, |
| 7202 | result_value = ir_build_const_void(ag, break_scope, node); | 7202 | result_value = ir_build_const_void(ag, break_scope, node); |
| 7203 | } | 7203 | } |
| 7204 | | 7204 | |
| 7205 | IrBasicBlockSrc *dest_block = block_scope->end_block; | 7205 | Stage1ZirBasicBlock *dest_block = block_scope->end_block; |
| 7206 | if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) | 7206 | if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) |
| 7207 | return ag->codegen->invalid_inst_src; | 7207 | return ag->codegen->invalid_inst_src; |
| 7208 | | 7208 | |
| ... | @@ -7279,7 +7279,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no | ... | @@ -7279,7 +7279,7 @@ static IrInstSrc *ir_gen_break(Stage1AstGen *ag, Scope *break_scope, AstNode *no |
| 7279 | result_value = ir_build_const_void(ag, break_scope, node); | 7279 | result_value = ir_build_const_void(ag, break_scope, node); |
| 7280 | } | 7280 | } |
| 7281 | | 7281 | |
| 7282 | IrBasicBlockSrc *dest_block = loop_scope->break_block; | 7282 | Stage1ZirBasicBlock *dest_block = loop_scope->break_block; |
| 7283 | if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) | 7283 | if (!ir_gen_defers_for_block(ag, break_scope, dest_block->scope, nullptr, nullptr)) |
| 7284 | return ag->codegen->invalid_inst_src; | 7284 | return ag->codegen->invalid_inst_src; |
| 7285 | | 7285 | |
| ... | @@ -7341,7 +7341,7 @@ static IrInstSrc *ir_gen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNo | ... | @@ -7341,7 +7341,7 @@ static IrInstSrc *ir_gen_continue(Stage1AstGen *ag, Scope *continue_scope, AstNo |
| 7341 | } | 7341 | } |
| 7342 | runtime_scopes.deinit(); | 7342 | runtime_scopes.deinit(); |
| 7343 | | 7343 | |
| 7344 | IrBasicBlockSrc *dest_block = loop_scope->continue_block; | 7344 | Stage1ZirBasicBlock *dest_block = loop_scope->continue_block; |
| 7345 | if (!ir_gen_defers_for_block(ag, continue_scope, dest_block->scope, nullptr, nullptr)) | 7345 | if (!ir_gen_defers_for_block(ag, continue_scope, dest_block->scope, nullptr, nullptr)) |
| 7346 | return ag->codegen->invalid_inst_src; | 7346 | return ag->codegen->invalid_inst_src; |
| 7347 | return ir_mark_gen(ir_build_br(ag, continue_scope, node, dest_block, is_comptime)); | 7347 | return ir_mark_gen(ir_build_br(ag, continue_scope, node, dest_block, is_comptime)); |
| ... | @@ -7440,9 +7440,9 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n | ... | @@ -7440,9 +7440,9 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7440 | is_comptime = ir_build_test_comptime(ag, parent_scope, node, is_err); | 7440 | is_comptime = ir_build_test_comptime(ag, parent_scope, node, is_err); |
| 7441 | } | 7441 | } |
| 7442 | | 7442 | |
| 7443 | IrBasicBlockSrc *ok_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrOk"); | 7443 | Stage1ZirBasicBlock *ok_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrOk"); |
| 7444 | IrBasicBlockSrc *err_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrError"); | 7444 | Stage1ZirBasicBlock *err_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrError"); |
| 7445 | IrBasicBlockSrc *end_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrEnd"); | 7445 | Stage1ZirBasicBlock *end_block = ir_create_basic_block(ag, parent_scope, "UnwrapErrEnd"); |
| 7446 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_err, err_block, ok_block, is_comptime); | 7446 | IrInstSrc *cond_br_inst = ir_build_cond_br(ag, parent_scope, node, is_err, err_block, ok_block, is_comptime); |
| 7447 | | 7447 | |
| 7448 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, ok_block, end_block, result_loc, | 7448 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(ag, cond_br_inst, ok_block, end_block, result_loc, |
| ... | @@ -7468,7 +7468,7 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n | ... | @@ -7468,7 +7468,7 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7468 | IrInstSrc *err_result = ir_gen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); | 7468 | IrInstSrc *err_result = ir_gen_node_extra(ag, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); |
| 7469 | if (err_result == ag->codegen->invalid_inst_src) | 7469 | if (err_result == ag->codegen->invalid_inst_src) |
| 7470 | return ag->codegen->invalid_inst_src; | 7470 | return ag->codegen->invalid_inst_src; |
| 7471 | IrBasicBlockSrc *after_err_block = ag->current_basic_block; | 7471 | Stage1ZirBasicBlock *after_err_block = ag->current_basic_block; |
| 7472 | if (!instr_is_unreachable(err_result)) | 7472 | if (!instr_is_unreachable(err_result)) |
| 7473 | ir_mark_gen(ir_build_br(ag, parent_scope, node, end_block, is_comptime)); | 7473 | ir_mark_gen(ir_build_br(ag, parent_scope, node, end_block, is_comptime)); |
| 7474 | | 7474 | |
| ... | @@ -7476,14 +7476,14 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n | ... | @@ -7476,14 +7476,14 @@ static IrInstSrc *ir_gen_catch(Stage1AstGen *ag, Scope *parent_scope, AstNode *n |
| 7476 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(ag, parent_scope, node, err_union_ptr, false, false); | 7476 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(ag, parent_scope, node, err_union_ptr, false, false); |
| 7477 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); | 7477 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(ag, parent_scope, node, unwrapped_ptr); |
| 7478 | ir_build_end_expr(ag, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); | 7478 | ir_build_end_expr(ag, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 7479 | IrBasicBlockSrc *after_ok_block = ag->current_basic_block; | 7479 | Stage1ZirBasicBlock *after_ok_block = ag->current_basic_block; |
| 7480 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); | 7480 | ir_build_br(ag, parent_scope, node, end_block, is_comptime); |
| 7481 | | 7481 | |
| 7482 | ir_set_cursor_at_end_and_append_block(ag, end_block); | 7482 | ir_set_cursor_at_end_and_append_block(ag, end_block); |
| 7483 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); | 7483 | IrInstSrc **incoming_values = heap::c_allocator.allocate<IrInstSrc *>(2); |
| 7484 | incoming_values[0] = err_result; | 7484 | incoming_values[0] = err_result; |
| 7485 | incoming_values[1] = unwrapped_payload; | 7485 | incoming_values[1] = unwrapped_payload; |
| 7486 | IrBasicBlockSrc **incoming_blocks = heap::c_allocator.allocate<IrBasicBlockSrc *>(2); | 7486 | Stage1ZirBasicBlock **incoming_blocks = heap::c_allocator.allocate<Stage1ZirBasicBlock *>(2); |
| 7487 | incoming_blocks[0] = after_err_block; | 7487 | incoming_blocks[0] = after_err_block; |
| 7488 | incoming_blocks[1] = after_ok_block; | 7488 | incoming_blocks[1] = after_ok_block; |
| 7489 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 7489 | IrInstSrc *phi = ir_build_phi(ag, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| ... | @@ -8045,7 +8045,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *sta | ... | @@ -8045,7 +8045,7 @@ bool stage1_astgen(CodeGen *codegen, AstNode *node, Scope *scope, Stage1Zir *sta |
| 8045 | ag->exec = stage1_zir; | 8045 | ag->exec = stage1_zir; |
| 8046 | ag->main_block_node = node; | 8046 | ag->main_block_node = node; |
| 8047 | | 8047 | |
| 8048 | IrBasicBlockSrc *entry_block = ir_create_basic_block(ag, scope, "Entry"); | 8048 | Stage1ZirBasicBlock *entry_block = ir_create_basic_block(ag, scope, "Entry"); |
| 8049 | ir_set_cursor_at_end_and_append_block(ag, entry_block); | 8049 | ir_set_cursor_at_end_and_append_block(ag, entry_block); |
| 8050 | // Entry block gets a reference because we enter it to begin. | 8050 | // Entry block gets a reference because we enter it to begin. |
| 8051 | ir_ref_bb(ag->current_basic_block); | 8051 | ir_ref_bb(ag->current_basic_block); |