| ... | ... | @@ -481,61 +481,61 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 481 | 481 | |
| 482 | 482 | .assign => { |
| 483 | 483 | try assign(gz, scope, node); |
| 484 | | return rvalue(gz, scope, rl, .void_value, node); |
| 484 | return rvalue(gz, rl, .void_value, node); |
| 485 | 485 | }, |
| 486 | 486 | |
| 487 | 487 | .assign_bit_shift_left => { |
| 488 | 488 | try assignShift(gz, scope, node, .shl); |
| 489 | | return rvalue(gz, scope, rl, .void_value, node); |
| 489 | return rvalue(gz, rl, .void_value, node); |
| 490 | 490 | }, |
| 491 | 491 | .assign_bit_shift_right => { |
| 492 | 492 | try assignShift(gz, scope, node, .shr); |
| 493 | | return rvalue(gz, scope, rl, .void_value, node); |
| 493 | return rvalue(gz, rl, .void_value, node); |
| 494 | 494 | }, |
| 495 | 495 | |
| 496 | 496 | .assign_bit_and => { |
| 497 | 497 | try assignOp(gz, scope, node, .bit_and); |
| 498 | | return rvalue(gz, scope, rl, .void_value, node); |
| 498 | return rvalue(gz, rl, .void_value, node); |
| 499 | 499 | }, |
| 500 | 500 | .assign_bit_or => { |
| 501 | 501 | try assignOp(gz, scope, node, .bit_or); |
| 502 | | return rvalue(gz, scope, rl, .void_value, node); |
| 502 | return rvalue(gz, rl, .void_value, node); |
| 503 | 503 | }, |
| 504 | 504 | .assign_bit_xor => { |
| 505 | 505 | try assignOp(gz, scope, node, .xor); |
| 506 | | return rvalue(gz, scope, rl, .void_value, node); |
| 506 | return rvalue(gz, rl, .void_value, node); |
| 507 | 507 | }, |
| 508 | 508 | .assign_div => { |
| 509 | 509 | try assignOp(gz, scope, node, .div); |
| 510 | | return rvalue(gz, scope, rl, .void_value, node); |
| 510 | return rvalue(gz, rl, .void_value, node); |
| 511 | 511 | }, |
| 512 | 512 | .assign_sub => { |
| 513 | 513 | try assignOp(gz, scope, node, .sub); |
| 514 | | return rvalue(gz, scope, rl, .void_value, node); |
| 514 | return rvalue(gz, rl, .void_value, node); |
| 515 | 515 | }, |
| 516 | 516 | .assign_sub_wrap => { |
| 517 | 517 | try assignOp(gz, scope, node, .subwrap); |
| 518 | | return rvalue(gz, scope, rl, .void_value, node); |
| 518 | return rvalue(gz, rl, .void_value, node); |
| 519 | 519 | }, |
| 520 | 520 | .assign_mod => { |
| 521 | 521 | try assignOp(gz, scope, node, .mod_rem); |
| 522 | | return rvalue(gz, scope, rl, .void_value, node); |
| 522 | return rvalue(gz, rl, .void_value, node); |
| 523 | 523 | }, |
| 524 | 524 | .assign_add => { |
| 525 | 525 | try assignOp(gz, scope, node, .add); |
| 526 | | return rvalue(gz, scope, rl, .void_value, node); |
| 526 | return rvalue(gz, rl, .void_value, node); |
| 527 | 527 | }, |
| 528 | 528 | .assign_add_wrap => { |
| 529 | 529 | try assignOp(gz, scope, node, .addwrap); |
| 530 | | return rvalue(gz, scope, rl, .void_value, node); |
| 530 | return rvalue(gz, rl, .void_value, node); |
| 531 | 531 | }, |
| 532 | 532 | .assign_mul => { |
| 533 | 533 | try assignOp(gz, scope, node, .mul); |
| 534 | | return rvalue(gz, scope, rl, .void_value, node); |
| 534 | return rvalue(gz, rl, .void_value, node); |
| 535 | 535 | }, |
| 536 | 536 | .assign_mul_wrap => { |
| 537 | 537 | try assignOp(gz, scope, node, .mulwrap); |
| 538 | | return rvalue(gz, scope, rl, .void_value, node); |
| 538 | return rvalue(gz, rl, .void_value, node); |
| 539 | 539 | }, |
| 540 | 540 | |
| 541 | 541 | // zig fmt: off |
| ... | ... | @@ -659,7 +659,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 659 | 659 | .lhs = lhs, |
| 660 | 660 | .start = start, |
| 661 | 661 | }); |
| 662 | | return rvalue(gz, scope, rl, result, node); |
| 662 | return rvalue(gz, rl, result, node); |
| 663 | 663 | }, |
| 664 | 664 | .slice => { |
| 665 | 665 | const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); |
| ... | ... | @@ -671,7 +671,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 671 | 671 | .start = start, |
| 672 | 672 | .end = end, |
| 673 | 673 | }); |
| 674 | | return rvalue(gz, scope, rl, result, node); |
| 674 | return rvalue(gz, rl, result, node); |
| 675 | 675 | }, |
| 676 | 676 | .slice_sentinel => { |
| 677 | 677 | const lhs = try expr(gz, scope, .ref, node_datas[node].lhs); |
| ... | ... | @@ -685,7 +685,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 685 | 685 | .end = end, |
| 686 | 686 | .sentinel = sentinel, |
| 687 | 687 | }); |
| 688 | | return rvalue(gz, scope, rl, result, node); |
| 688 | return rvalue(gz, rl, result, node); |
| 689 | 689 | }, |
| 690 | 690 | |
| 691 | 691 | .deref => { |
| ... | ... | @@ -694,22 +694,22 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 694 | 694 | .ref, .none_or_ref => return lhs, |
| 695 | 695 | else => { |
| 696 | 696 | const result = try gz.addUnNode(.load, lhs, node); |
| 697 | | return rvalue(gz, scope, rl, result, node); |
| 697 | return rvalue(gz, rl, result, node); |
| 698 | 698 | }, |
| 699 | 699 | } |
| 700 | 700 | }, |
| 701 | 701 | .address_of => { |
| 702 | 702 | const result = try expr(gz, scope, .ref, node_datas[node].lhs); |
| 703 | | return rvalue(gz, scope, rl, result, node); |
| 703 | return rvalue(gz, rl, result, node); |
| 704 | 704 | }, |
| 705 | | .undefined_literal => return rvalue(gz, scope, rl, .undef, node), |
| 706 | | .true_literal => return rvalue(gz, scope, rl, .bool_true, node), |
| 707 | | .false_literal => return rvalue(gz, scope, rl, .bool_false, node), |
| 708 | | .null_literal => return rvalue(gz, scope, rl, .null_value, node), |
| 705 | .undefined_literal => return rvalue(gz, rl, .undef, node), |
| 706 | .true_literal => return rvalue(gz, rl, .bool_true, node), |
| 707 | .false_literal => return rvalue(gz, rl, .bool_false, node), |
| 708 | .null_literal => return rvalue(gz, rl, .null_value, node), |
| 709 | 709 | .optional_type => { |
| 710 | 710 | const operand = try typeExpr(gz, scope, node_datas[node].lhs); |
| 711 | 711 | const result = try gz.addUnNode(.optional_type, operand, node); |
| 712 | | return rvalue(gz, scope, rl, result, node); |
| 712 | return rvalue(gz, rl, result, node); |
| 713 | 713 | }, |
| 714 | 714 | .unwrap_optional => switch (rl) { |
| 715 | 715 | .ref => return gz.addUnNode( |
| ... | ... | @@ -717,7 +717,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 717 | 717 | try expr(gz, scope, .ref, node_datas[node].lhs), |
| 718 | 718 | node, |
| 719 | 719 | ), |
| 720 | | else => return rvalue(gz, scope, rl, try gz.addUnNode( |
| 720 | else => return rvalue(gz, rl, try gz.addUnNode( |
| 721 | 721 | .optional_payload_safe, |
| 722 | 722 | try expr(gz, scope, .none, node_datas[node].lhs), |
| 723 | 723 | node, |
| ... | ... | @@ -739,11 +739,11 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr |
| 739 | 739 | }, |
| 740 | 740 | .enum_literal => return simpleStrTok(gz, scope, rl, main_tokens[node], node, .enum_literal), |
| 741 | 741 | .error_value => return simpleStrTok(gz, scope, rl, node_datas[node].rhs, node, .error_value), |
| 742 | | .anyframe_literal => return rvalue(gz, scope, rl, .anyframe_type, node), |
| 742 | .anyframe_literal => return rvalue(gz, rl, .anyframe_type, node), |
| 743 | 743 | .anyframe_type => { |
| 744 | 744 | const return_type = try typeExpr(gz, scope, node_datas[node].rhs); |
| 745 | 745 | const result = try gz.addUnNode(.anyframe_type, return_type, node); |
| 746 | | return rvalue(gz, scope, rl, result, node); |
| 746 | return rvalue(gz, rl, result, node); |
| 747 | 747 | }, |
| 748 | 748 | .@"catch" => { |
| 749 | 749 | const catch_token = main_tokens[node]; |
| ... | ... | @@ -916,7 +916,7 @@ fn nosuspendExpr( |
| 916 | 916 | gz.nosuspend_node = node; |
| 917 | 917 | const result = try expr(gz, scope, rl, body_node); |
| 918 | 918 | gz.nosuspend_node = 0; |
| 919 | | return rvalue(gz, scope, rl, result, node); |
| 919 | return rvalue(gz, rl, result, node); |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | fn suspendExpr( |
| ... | ... | @@ -977,7 +977,7 @@ fn awaitExpr( |
| 977 | 977 | const operand = try expr(gz, scope, .none, rhs_node); |
| 978 | 978 | const tag: Zir.Inst.Tag = if (gz.nosuspend_node != 0) .await_nosuspend else .@"await"; |
| 979 | 979 | const result = try gz.addUnNode(tag, operand, node); |
| 980 | | return rvalue(gz, scope, rl, result, node); |
| 980 | return rvalue(gz, rl, result, node); |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | 983 | fn resumeExpr( |
| ... | ... | @@ -992,7 +992,7 @@ fn resumeExpr( |
| 992 | 992 | const rhs_node = node_datas[node].lhs; |
| 993 | 993 | const operand = try expr(gz, scope, .none, rhs_node); |
| 994 | 994 | const result = try gz.addUnNode(.@"resume", operand, node); |
| 995 | | return rvalue(gz, scope, rl, result, node); |
| 995 | return rvalue(gz, rl, result, node); |
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | fn fnProtoExpr( |
| ... | ... | @@ -1098,7 +1098,7 @@ fn fnProtoExpr( |
| 1098 | 1098 | .is_test = false, |
| 1099 | 1099 | .is_extern = false, |
| 1100 | 1100 | }); |
| 1101 | | return rvalue(gz, scope, rl, result, fn_proto.ast.proto_node); |
| 1101 | return rvalue(gz, rl, result, fn_proto.ast.proto_node); |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | fn arrayInitExpr( |
| ... | ... | @@ -1184,7 +1184,7 @@ fn arrayInitExpr( |
| 1184 | 1184 | .ty => |ty_inst| { |
| 1185 | 1185 | if (types.array != .none) { |
| 1186 | 1186 | const result = try arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init); |
| 1187 | | return rvalue(gz, scope, rl, result, node); |
| 1187 | return rvalue(gz, rl, result, node); |
| 1188 | 1188 | } else { |
| 1189 | 1189 | const elem_type = try gz.addUnNode(.elem_type, ty_inst, node); |
| 1190 | 1190 | return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, elem_type, .array_init); |
| ... | ... | @@ -1288,7 +1288,7 @@ fn structInitExpr( |
| 1288 | 1288 | |
| 1289 | 1289 | if (struct_init.ast.fields.len == 0) { |
| 1290 | 1290 | if (struct_init.ast.type_expr == 0) { |
| 1291 | | return rvalue(gz, scope, rl, .empty_struct, node); |
| 1291 | return rvalue(gz, rl, .empty_struct, node); |
| 1292 | 1292 | } |
| 1293 | 1293 | array: { |
| 1294 | 1294 | const node_tags = tree.nodes.items(.tag); |
| ... | ... | @@ -1310,12 +1310,12 @@ fn structInitExpr( |
| 1310 | 1310 | break :blk try gz.addArrayTypeSentinel(.zero_usize, elem_type, sentinel); |
| 1311 | 1311 | }; |
| 1312 | 1312 | const result = try gz.addUnNode(.struct_init_empty, array_type_inst, node); |
| 1313 | | return rvalue(gz, scope, rl, result, node); |
| 1313 | return rvalue(gz, rl, result, node); |
| 1314 | 1314 | } |
| 1315 | 1315 | } |
| 1316 | 1316 | const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1317 | 1317 | const result = try gz.addUnNode(.struct_init_empty, ty_inst, node); |
| 1318 | | return rvalue(gz, scope, rl, result, node); |
| 1318 | return rvalue(gz, rl, result, node); |
| 1319 | 1319 | } |
| 1320 | 1320 | switch (rl) { |
| 1321 | 1321 | .discard => { |
| ... | ... | @@ -1348,7 +1348,7 @@ fn structInitExpr( |
| 1348 | 1348 | } |
| 1349 | 1349 | const inner_ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr); |
| 1350 | 1350 | const result = try structInitExprRlTy(gz, scope, node, struct_init, inner_ty_inst, .struct_init); |
| 1351 | | return rvalue(gz, scope, rl, result, node); |
| 1351 | return rvalue(gz, rl, result, node); |
| 1352 | 1352 | }, |
| 1353 | 1353 | .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, node, struct_init, ptr_inst), |
| 1354 | 1354 | .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, node, struct_init, block_gz.rl_ptr), |
| ... | ... | @@ -1651,7 +1651,7 @@ fn blockExpr( |
| 1651 | 1651 | } |
| 1652 | 1652 | |
| 1653 | 1653 | try blockExprStmts(gz, scope, statements); |
| 1654 | | return rvalue(gz, scope, rl, .void_value, block_node); |
| 1654 | return rvalue(gz, rl, .void_value, block_node); |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | 1657 | fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.TokenIndex) !void { |
| ... | ... | @@ -1761,7 +1761,7 @@ fn labeledBlockExpr( |
| 1761 | 1761 | const block_ref = gz.indexToRef(block_inst); |
| 1762 | 1762 | switch (rl) { |
| 1763 | 1763 | .ref => return block_ref, |
| 1764 | | else => return rvalue(gz, parent_scope, rl, block_ref, block_node), |
| 1764 | else => return rvalue(gz, rl, block_ref, block_node), |
| 1765 | 1765 | } |
| 1766 | 1766 | }, |
| 1767 | 1767 | } |
| ... | ... | @@ -2560,7 +2560,7 @@ fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inne |
| 2560 | 2560 | |
| 2561 | 2561 | const operand = try expr(gz, scope, bool_rl, node_datas[node].lhs); |
| 2562 | 2562 | const result = try gz.addUnNode(.bool_not, operand, node); |
| 2563 | | return rvalue(gz, scope, rl, result, node); |
| 2563 | return rvalue(gz, rl, result, node); |
| 2564 | 2564 | } |
| 2565 | 2565 | |
| 2566 | 2566 | fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref { |
| ... | ... | @@ -2570,7 +2570,7 @@ fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inner |
| 2570 | 2570 | |
| 2571 | 2571 | const operand = try expr(gz, scope, .none, node_datas[node].lhs); |
| 2572 | 2572 | const result = try gz.addUnNode(.bit_not, operand, node); |
| 2573 | | return rvalue(gz, scope, rl, result, node); |
| 2573 | return rvalue(gz, rl, result, node); |
| 2574 | 2574 | } |
| 2575 | 2575 | |
| 2576 | 2576 | fn negation( |
| ... | ... | @@ -2586,7 +2586,7 @@ fn negation( |
| 2586 | 2586 | |
| 2587 | 2587 | const operand = try expr(gz, scope, .none, node_datas[node].lhs); |
| 2588 | 2588 | const result = try gz.addUnNode(tag, operand, node); |
| 2589 | | return rvalue(gz, scope, rl, result, node); |
| 2589 | return rvalue(gz, rl, result, node); |
| 2590 | 2590 | } |
| 2591 | 2591 | |
| 2592 | 2592 | fn ptrType( |
| ... | ... | @@ -2612,7 +2612,7 @@ fn ptrType( |
| 2612 | 2612 | .elem_type = elem_type, |
| 2613 | 2613 | }, |
| 2614 | 2614 | } }); |
| 2615 | | return rvalue(gz, scope, rl, result, node); |
| 2615 | return rvalue(gz, rl, result, node); |
| 2616 | 2616 | } |
| 2617 | 2617 | |
| 2618 | 2618 | var sentinel_ref: Zir.Inst.Ref = .none; |
| ... | ... | @@ -2672,7 +2672,7 @@ fn ptrType( |
| 2672 | 2672 | } }); |
| 2673 | 2673 | gz.instructions.appendAssumeCapacity(new_index); |
| 2674 | 2674 | |
| 2675 | | return rvalue(gz, scope, rl, result, node); |
| 2675 | return rvalue(gz, rl, result, node); |
| 2676 | 2676 | } |
| 2677 | 2677 | |
| 2678 | 2678 | fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { |
| ... | ... | @@ -2692,7 +2692,7 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Z |
| 2692 | 2692 | const elem_type = try typeExpr(gz, scope, node_datas[node].rhs); |
| 2693 | 2693 | |
| 2694 | 2694 | const result = try gz.addBin(.array_type, len, elem_type); |
| 2695 | | return rvalue(gz, scope, rl, result, node); |
| 2695 | return rvalue(gz, rl, result, node); |
| 2696 | 2696 | } |
| 2697 | 2697 | |
| 2698 | 2698 | fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { |
| ... | ... | @@ -2714,7 +2714,7 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.I |
| 2714 | 2714 | const sentinel = try expr(gz, scope, .{ .ty = elem_type }, extra.sentinel); |
| 2715 | 2715 | |
| 2716 | 2716 | const result = try gz.addArrayTypeSentinel(len, elem_type, sentinel); |
| 2717 | | return rvalue(gz, scope, rl, result, node); |
| 2717 | return rvalue(gz, rl, result, node); |
| 2718 | 2718 | } |
| 2719 | 2719 | |
| 2720 | 2720 | const WipDecls = struct { |
| ... | ... | @@ -3950,7 +3950,7 @@ fn containerDecl( |
| 3950 | 3950 | assert(arg_inst == .none); |
| 3951 | 3951 | |
| 3952 | 3952 | const result = try structDeclInner(gz, scope, node, container_decl, layout); |
| 3953 | | return rvalue(gz, scope, rl, result, node); |
| 3953 | return rvalue(gz, rl, result, node); |
| 3954 | 3954 | }, |
| 3955 | 3955 | .keyword_union => { |
| 3956 | 3956 | const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { |
| ... | ... | @@ -3962,7 +3962,7 @@ fn containerDecl( |
| 3962 | 3962 | const have_auto_enum = container_decl.ast.enum_token != null; |
| 3963 | 3963 | |
| 3964 | 3964 | const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, arg_inst, have_auto_enum); |
| 3965 | | return rvalue(gz, scope, rl, result, node); |
| 3965 | return rvalue(gz, rl, result, node); |
| 3966 | 3966 | }, |
| 3967 | 3967 | .keyword_enum => { |
| 3968 | 3968 | if (container_decl.layout_token) |t| { |
| ... | ... | @@ -4291,7 +4291,7 @@ fn containerDecl( |
| 4291 | 4291 | astgen.extra.appendAssumeCapacity(cur_bit_bag); |
| 4292 | 4292 | astgen.extra.appendSliceAssumeCapacity(fields_data.items); |
| 4293 | 4293 | |
| 4294 | | return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node); |
| 4294 | return rvalue(gz, rl, gz.indexToRef(decl_inst), node); |
| 4295 | 4295 | }, |
| 4296 | 4296 | .keyword_opaque => { |
| 4297 | 4297 | var namespace: Scope.Namespace = .{ .parent = scope }; |
| ... | ... | @@ -4452,7 +4452,7 @@ fn containerDecl( |
| 4452 | 4452 | } |
| 4453 | 4453 | astgen.extra.appendSliceAssumeCapacity(wip_decls.payload.items); |
| 4454 | 4454 | |
| 4455 | | return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node); |
| 4455 | return rvalue(gz, rl, gz.indexToRef(decl_inst), node); |
| 4456 | 4456 | }, |
| 4457 | 4457 | else => unreachable, |
| 4458 | 4458 | } |
| ... | ... | @@ -4495,7 +4495,7 @@ fn errorSetDecl( |
| 4495 | 4495 | .fields_len = @intCast(u32, field_names.items.len), |
| 4496 | 4496 | }); |
| 4497 | 4497 | try astgen.extra.appendSlice(gpa, field_names.items); |
| 4498 | | return rvalue(gz, scope, rl, result, node); |
| 4498 | return rvalue(gz, rl, result, node); |
| 4499 | 4499 | } |
| 4500 | 4500 | |
| 4501 | 4501 | fn tryExpr( |
| ... | ... | @@ -4554,7 +4554,7 @@ fn tryExpr( |
| 4554 | 4554 | const unwrapped_payload = try else_scope.addUnNode(err_ops[2], operand, node); |
| 4555 | 4555 | const else_result = switch (rl) { |
| 4556 | 4556 | .ref => unwrapped_payload, |
| 4557 | | else => try rvalue(&else_scope, &else_scope.base, block_scope.break_result_loc, unwrapped_payload, node), |
| 4557 | else => try rvalue(&else_scope, block_scope.break_result_loc, unwrapped_payload, node), |
| 4558 | 4558 | }; |
| 4559 | 4559 | |
| 4560 | 4560 | return finishThenElseBlock( |
| ... | ... | @@ -4647,7 +4647,7 @@ fn orelseCatchExpr( |
| 4647 | 4647 | const unwrapped_payload = try else_scope.addUnNode(unwrap_op, operand, node); |
| 4648 | 4648 | const else_result = switch (rl) { |
| 4649 | 4649 | .ref => unwrapped_payload, |
| 4650 | | else => try rvalue(&else_scope, &else_scope.base, block_scope.break_result_loc, unwrapped_payload, node), |
| 4650 | else => try rvalue(&else_scope, block_scope.break_result_loc, unwrapped_payload, node), |
| 4651 | 4651 | }; |
| 4652 | 4652 | |
| 4653 | 4653 | return finishThenElseBlock( |
| ... | ... | @@ -4719,7 +4719,7 @@ fn finishThenElseBlock( |
| 4719 | 4719 | const block_ref = parent_gz.indexToRef(main_block); |
| 4720 | 4720 | switch (rl) { |
| 4721 | 4721 | .ref => return block_ref, |
| 4722 | | else => return rvalue(parent_gz, parent_scope, rl, block_ref, node), |
| 4722 | else => return rvalue(parent_gz, rl, block_ref, node), |
| 4723 | 4723 | } |
| 4724 | 4724 | }, |
| 4725 | 4725 | } |
| ... | ... | @@ -4755,7 +4755,7 @@ fn fieldAccess( |
| 4755 | 4755 | .lhs = try expr(gz, scope, .ref, object_node), |
| 4756 | 4756 | .field_name_start = str_index, |
| 4757 | 4757 | }), |
| 4758 | | else => return rvalue(gz, scope, rl, try gz.addPlNode(.field_val, node, Zir.Inst.Field{ |
| 4758 | else => return rvalue(gz, rl, try gz.addPlNode(.field_val, node, Zir.Inst.Field{ |
| 4759 | 4759 | .lhs = try expr(gz, scope, .none_or_ref, object_node), |
| 4760 | 4760 | .field_name_start = str_index, |
| 4761 | 4761 | }), node), |
| ... | ... | @@ -4777,7 +4777,7 @@ fn arrayAccess( |
| 4777 | 4777 | try expr(gz, scope, .ref, node_datas[node].lhs), |
| 4778 | 4778 | try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), |
| 4779 | 4779 | ), |
| 4780 | | else => return rvalue(gz, scope, rl, try gz.addBin( |
| 4780 | else => return rvalue(gz, rl, try gz.addBin( |
| 4781 | 4781 | .elem_val, |
| 4782 | 4782 | try expr(gz, scope, .none_or_ref, node_datas[node].lhs), |
| 4783 | 4783 | try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs), |
| ... | ... | @@ -4800,7 +4800,7 @@ fn simpleBinOp( |
| 4800 | 4800 | .lhs = try expr(gz, scope, .none, node_datas[node].lhs), |
| 4801 | 4801 | .rhs = try expr(gz, scope, .none, node_datas[node].rhs), |
| 4802 | 4802 | }); |
| 4803 | | return rvalue(gz, scope, rl, result, node); |
| 4803 | return rvalue(gz, rl, result, node); |
| 4804 | 4804 | } |
| 4805 | 4805 | |
| 4806 | 4806 | fn simpleStrTok( |
| ... | ... | @@ -4814,7 +4814,7 @@ fn simpleStrTok( |
| 4814 | 4814 | const astgen = gz.astgen; |
| 4815 | 4815 | const str_index = try astgen.identAsString(ident_token); |
| 4816 | 4816 | const result = try gz.addStrTok(op_inst_tag, str_index, ident_token); |
| 4817 | | return rvalue(gz, scope, rl, result, node); |
| 4817 | return rvalue(gz, rl, result, node); |
| 4818 | 4818 | } |
| 4819 | 4819 | |
| 4820 | 4820 | fn boolBinOp( |
| ... | ... | @@ -4840,7 +4840,7 @@ fn boolBinOp( |
| 4840 | 4840 | try rhs_scope.setBoolBrBody(bool_br); |
| 4841 | 4841 | |
| 4842 | 4842 | const block_ref = gz.indexToRef(bool_br); |
| 4843 | | return rvalue(gz, scope, rl, block_ref, node); |
| 4843 | return rvalue(gz, rl, block_ref, node); |
| 4844 | 4844 | } |
| 4845 | 4845 | |
| 4846 | 4846 | fn ifExpr( |
| ... | ... | @@ -6010,7 +6010,7 @@ fn switchExpr( |
| 6010 | 6010 | const block_ref = parent_gz.indexToRef(switch_block); |
| 6011 | 6011 | switch (rl) { |
| 6012 | 6012 | .ref => return block_ref, |
| 6013 | | else => return rvalue(parent_gz, scope, rl, block_ref, switch_node), |
| 6013 | else => return rvalue(parent_gz, rl, block_ref, switch_node), |
| 6014 | 6014 | } |
| 6015 | 6015 | }, |
| 6016 | 6016 | .break_void => { |
| ... | ... | @@ -6151,7 +6151,7 @@ fn identifier( |
| 6151 | 6151 | } |
| 6152 | 6152 | |
| 6153 | 6153 | if (simple_types.get(ident_name)) |zir_const_ref| { |
| 6154 | | return rvalue(gz, scope, rl, zir_const_ref, ident); |
| 6154 | return rvalue(gz, rl, zir_const_ref, ident); |
| 6155 | 6155 | } |
| 6156 | 6156 | |
| 6157 | 6157 | if (ident_name.len >= 2) integer: { |
| ... | ... | @@ -6177,7 +6177,7 @@ fn identifier( |
| 6177 | 6177 | .bit_count = bit_count, |
| 6178 | 6178 | } }, |
| 6179 | 6179 | }); |
| 6180 | | return rvalue(gz, scope, rl, result, ident); |
| 6180 | return rvalue(gz, rl, result, ident); |
| 6181 | 6181 | } |
| 6182 | 6182 | } |
| 6183 | 6183 | |
| ... | ... | @@ -6196,7 +6196,7 @@ fn identifier( |
| 6196 | 6196 | // Captures of non-locals need to be emitted as decl_val or decl_ref. |
| 6197 | 6197 | // This *might* be capturable depending on if it is comptime known. |
| 6198 | 6198 | if (!hit_namespace) { |
| 6199 | | return rvalue(gz, scope, rl, local_val.inst, ident); |
| 6199 | return rvalue(gz, rl, local_val.inst, ident); |
| 6200 | 6200 | } |
| 6201 | 6201 | } |
| 6202 | 6202 | s = local_val.parent; |
| ... | ... | @@ -6220,7 +6220,7 @@ fn identifier( |
| 6220 | 6220 | .ref, .none_or_ref => return local_ptr.ptr, |
| 6221 | 6221 | else => { |
| 6222 | 6222 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, ident); |
| 6223 | | return rvalue(gz, scope, rl, loaded, ident); |
| 6223 | return rvalue(gz, rl, loaded, ident); |
| 6224 | 6224 | }, |
| 6225 | 6225 | } |
| 6226 | 6226 | } |
| ... | ... | @@ -6254,7 +6254,7 @@ fn identifier( |
| 6254 | 6254 | .ref, .none_or_ref => return gz.addStrTok(.decl_ref, name_str_index, ident_token), |
| 6255 | 6255 | else => { |
| 6256 | 6256 | const result = try gz.addStrTok(.decl_val, name_str_index, ident_token); |
| 6257 | | return rvalue(gz, scope, rl, result, ident); |
| 6257 | return rvalue(gz, rl, result, ident); |
| 6258 | 6258 | }, |
| 6259 | 6259 | } |
| 6260 | 6260 | } |
| ... | ... | @@ -6277,7 +6277,7 @@ fn stringLiteral( |
| 6277 | 6277 | .len = str.len, |
| 6278 | 6278 | } }, |
| 6279 | 6279 | }); |
| 6280 | | return rvalue(gz, scope, rl, result, node); |
| 6280 | return rvalue(gz, rl, result, node); |
| 6281 | 6281 | } |
| 6282 | 6282 | |
| 6283 | 6283 | fn multilineStringLiteral( |
| ... | ... | @@ -6320,7 +6320,7 @@ fn multilineStringLiteral( |
| 6320 | 6320 | .len = @intCast(u32, string_bytes.items.len - str_index), |
| 6321 | 6321 | } }, |
| 6322 | 6322 | }); |
| 6323 | | return rvalue(gz, scope, rl, result, node); |
| 6323 | return rvalue(gz, rl, result, node); |
| 6324 | 6324 | } |
| 6325 | 6325 | |
| 6326 | 6326 | fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref { |
| ... | ... | @@ -6343,7 +6343,7 @@ fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) |
| 6343 | 6343 | }, |
| 6344 | 6344 | }; |
| 6345 | 6345 | const result = try gz.addInt(value); |
| 6346 | | return rvalue(gz, scope, rl, result, node); |
| 6346 | return rvalue(gz, rl, result, node); |
| 6347 | 6347 | } |
| 6348 | 6348 | |
| 6349 | 6349 | fn integerLiteral( |
| ... | ... | @@ -6363,7 +6363,7 @@ fn integerLiteral( |
| 6363 | 6363 | 1 => .one, |
| 6364 | 6364 | else => try gz.addInt(small_int), |
| 6365 | 6365 | }; |
| 6366 | | return rvalue(gz, scope, rl, result, node); |
| 6366 | return rvalue(gz, rl, result, node); |
| 6367 | 6367 | } else |err| switch (err) { |
| 6368 | 6368 | error.InvalidCharacter => unreachable, // Caught by the parser. |
| 6369 | 6369 | error.Overflow => {}, |
| ... | ... | @@ -6394,7 +6394,7 @@ fn integerLiteral( |
| 6394 | 6394 | const limbs = big_int.limbs[0..big_int.len()]; |
| 6395 | 6395 | assert(big_int.isPositive()); |
| 6396 | 6396 | const result = try gz.addIntBig(limbs); |
| 6397 | | return rvalue(gz, scope, rl, result, node); |
| 6397 | return rvalue(gz, rl, result, node); |
| 6398 | 6398 | } |
| 6399 | 6399 | |
| 6400 | 6400 | fn floatLiteral( |
| ... | ... | @@ -6424,7 +6424,7 @@ fn floatLiteral( |
| 6424 | 6424 | const bigger_again: f128 = smaller_float; |
| 6425 | 6425 | if (bigger_again == float_number) { |
| 6426 | 6426 | const result = try gz.addFloat(smaller_float, node); |
| 6427 | | return rvalue(gz, scope, rl, result, node); |
| 6427 | return rvalue(gz, rl, result, node); |
| 6428 | 6428 | } |
| 6429 | 6429 | // We need to use 128 bits. Break the float into 4 u32 values so we can |
| 6430 | 6430 | // put it into the `extra` array. |
| ... | ... | @@ -6435,7 +6435,7 @@ fn floatLiteral( |
| 6435 | 6435 | .piece2 = @truncate(u32, int_bits >> 64), |
| 6436 | 6436 | .piece3 = @truncate(u32, int_bits >> 96), |
| 6437 | 6437 | }); |
| 6438 | | return rvalue(gz, scope, rl, result, node); |
| 6438 | return rvalue(gz, rl, result, node); |
| 6439 | 6439 | } |
| 6440 | 6440 | |
| 6441 | 6441 | fn asmExpr( |
| ... | ... | @@ -6578,7 +6578,7 @@ fn asmExpr( |
| 6578 | 6578 | .inputs = inputs, |
| 6579 | 6579 | .clobbers = clobbers_buffer[0..clobber_i], |
| 6580 | 6580 | }); |
| 6581 | | return rvalue(gz, scope, rl, result, node); |
| 6581 | return rvalue(gz, rl, result, node); |
| 6582 | 6582 | } |
| 6583 | 6583 | |
| 6584 | 6584 | fn as( |
| ... | ... | @@ -6593,7 +6593,7 @@ fn as( |
| 6593 | 6593 | switch (rl) { |
| 6594 | 6594 | .none, .none_or_ref, .discard, .ref, .ty => { |
| 6595 | 6595 | const result = try expr(gz, scope, .{ .ty = dest_type }, rhs); |
| 6596 | | return rvalue(gz, scope, rl, result, node); |
| 6596 | return rvalue(gz, rl, result, node); |
| 6597 | 6597 | }, |
| 6598 | 6598 | .ptr, .inferred_ptr => |result_ptr| { |
| 6599 | 6599 | return asRlPtr(gz, scope, rl, result_ptr, rhs, dest_type); |
| ... | ... | @@ -6620,13 +6620,13 @@ fn unionInit( |
| 6620 | 6620 | .field_name = field_name, |
| 6621 | 6621 | }); |
| 6622 | 6622 | const result = try expr(gz, scope, .{ .ty = union_type }, params[2]); |
| 6623 | | return rvalue(gz, scope, rl, result, node); |
| 6623 | return rvalue(gz, rl, result, node); |
| 6624 | 6624 | }, |
| 6625 | 6625 | .ptr => |result_ptr| { |
| 6626 | | return unionInitRlPtr(gz, scope, rl, node, result_ptr, params[2], union_type, field_name); |
| 6626 | return unionInitRlPtr(gz, scope, node, result_ptr, params[2], union_type, field_name); |
| 6627 | 6627 | }, |
| 6628 | 6628 | .block_ptr => |block_scope| { |
| 6629 | | return unionInitRlPtr(gz, scope, rl, node, block_scope.rl_ptr, params[2], union_type, field_name); |
| 6629 | return unionInitRlPtr(gz, scope, node, block_scope.rl_ptr, params[2], union_type, field_name); |
| 6630 | 6630 | }, |
| 6631 | 6631 | } |
| 6632 | 6632 | } |
| ... | ... | @@ -6634,14 +6634,12 @@ fn unionInit( |
| 6634 | 6634 | fn unionInitRlPtr( |
| 6635 | 6635 | parent_gz: *GenZir, |
| 6636 | 6636 | scope: *Scope, |
| 6637 | | rl: ResultLoc, |
| 6638 | 6637 | node: ast.Node.Index, |
| 6639 | 6638 | result_ptr: Zir.Inst.Ref, |
| 6640 | 6639 | expr_node: ast.Node.Index, |
| 6641 | 6640 | union_type: Zir.Inst.Ref, |
| 6642 | 6641 | field_name: Zir.Inst.Ref, |
| 6643 | 6642 | ) InnerError!Zir.Inst.Ref { |
| 6644 | | _ = rl; |
| 6645 | 6643 | const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{ |
| 6646 | 6644 | .result_ptr = result_ptr, |
| 6647 | 6645 | .union_type = union_type, |
| ... | ... | @@ -6683,7 +6681,7 @@ fn asRlPtr( |
| 6683 | 6681 | parent_zir.appendAssumeCapacity(src_inst); |
| 6684 | 6682 | } |
| 6685 | 6683 | const casted_result = try parent_gz.addBin(.as, dest_type, result); |
| 6686 | | return rvalue(parent_gz, scope, rl, casted_result, operand_node); |
| 6684 | return rvalue(parent_gz, rl, casted_result, operand_node); |
| 6687 | 6685 | } else { |
| 6688 | 6686 | try parent_zir.appendSlice(astgen.gpa, as_scope.instructions.items); |
| 6689 | 6687 | return result; |
| ... | ... | @@ -6707,16 +6705,16 @@ fn bitCast( |
| 6707 | 6705 | .lhs = dest_type, |
| 6708 | 6706 | .rhs = operand, |
| 6709 | 6707 | }); |
| 6710 | | return rvalue(gz, scope, rl, result, node); |
| 6708 | return rvalue(gz, rl, result, node); |
| 6711 | 6709 | }, |
| 6712 | 6710 | .ref => { |
| 6713 | 6711 | return astgen.failNode(node, "cannot take address of `@bitCast` result", .{}); |
| 6714 | 6712 | }, |
| 6715 | 6713 | .ptr, .inferred_ptr => |result_ptr| { |
| 6716 | | return bitCastRlPtr(gz, scope, rl, node, dest_type, result_ptr, rhs); |
| 6714 | return bitCastRlPtr(gz, scope, node, dest_type, result_ptr, rhs); |
| 6717 | 6715 | }, |
| 6718 | 6716 | .block_ptr => |block| { |
| 6719 | | return bitCastRlPtr(gz, scope, rl, node, dest_type, block.rl_ptr, rhs); |
| 6717 | return bitCastRlPtr(gz, scope, node, dest_type, block.rl_ptr, rhs); |
| 6720 | 6718 | }, |
| 6721 | 6719 | } |
| 6722 | 6720 | } |
| ... | ... | @@ -6724,14 +6722,11 @@ fn bitCast( |
| 6724 | 6722 | fn bitCastRlPtr( |
| 6725 | 6723 | gz: *GenZir, |
| 6726 | 6724 | scope: *Scope, |
| 6727 | | rl: ResultLoc, |
| 6728 | 6725 | node: ast.Node.Index, |
| 6729 | 6726 | dest_type: Zir.Inst.Ref, |
| 6730 | 6727 | result_ptr: Zir.Inst.Ref, |
| 6731 | 6728 | rhs: ast.Node.Index, |
| 6732 | 6729 | ) InnerError!Zir.Inst.Ref { |
| 6733 | | _ = rl; |
| 6734 | | _ = scope; |
| 6735 | 6730 | const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{ |
| 6736 | 6731 | .lhs = dest_type, |
| 6737 | 6732 | .rhs = result_ptr, |
| ... | ... | @@ -6751,7 +6746,7 @@ fn typeOf( |
| 6751 | 6746 | } |
| 6752 | 6747 | if (params.len == 1) { |
| 6753 | 6748 | const result = try gz.addUnNode(.typeof, try expr(gz, scope, .none, params[0]), node); |
| 6754 | | return rvalue(gz, scope, rl, result, node); |
| 6749 | return rvalue(gz, rl, result, node); |
| 6755 | 6750 | } |
| 6756 | 6751 | const arena = gz.astgen.arena; |
| 6757 | 6752 | var items = try arena.alloc(Zir.Inst.Ref, params.len); |
| ... | ... | @@ -6760,7 +6755,7 @@ fn typeOf( |
| 6760 | 6755 | } |
| 6761 | 6756 | |
| 6762 | 6757 | const result = try gz.addExtendedMultiOp(.typeof_peer, node, items); |
| 6763 | | return rvalue(gz, scope, rl, result, node); |
| 6758 | return rvalue(gz, rl, result, node); |
| 6764 | 6759 | } |
| 6765 | 6760 | |
| 6766 | 6761 | fn builtinCall( |
| ... | ... | @@ -6810,7 +6805,7 @@ fn builtinCall( |
| 6810 | 6805 | const str = try astgen.strLitAsString(str_lit_token); |
| 6811 | 6806 | try astgen.imports.put(astgen.gpa, str.index, {}); |
| 6812 | 6807 | const result = try gz.addStrTok(.import, str.index, str_lit_token); |
| 6813 | | return rvalue(gz, scope, rl, result, node); |
| 6808 | return rvalue(gz, rl, result, node); |
| 6814 | 6809 | }, |
| 6815 | 6810 | .compile_log => { |
| 6816 | 6811 | const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len); |
| ... | ... | @@ -6819,7 +6814,7 @@ fn builtinCall( |
| 6819 | 6814 | for (params) |param, i| arg_refs[i] = try expr(gz, scope, .none, param); |
| 6820 | 6815 | |
| 6821 | 6816 | const result = try gz.addExtendedMultiOp(.compile_log, node, arg_refs); |
| 6822 | | return rvalue(gz, scope, rl, result, node); |
| 6817 | return rvalue(gz, rl, result, node); |
| 6823 | 6818 | }, |
| 6824 | 6819 | .field => { |
| 6825 | 6820 | const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]); |
| ... | ... | @@ -6833,7 +6828,7 @@ fn builtinCall( |
| 6833 | 6828 | .lhs = try expr(gz, scope, .none, params[0]), |
| 6834 | 6829 | .field_name = field_name, |
| 6835 | 6830 | }); |
| 6836 | | return rvalue(gz, scope, rl, result, node); |
| 6831 | return rvalue(gz, rl, result, node); |
| 6837 | 6832 | }, |
| 6838 | 6833 | .as => return as( gz, scope, rl, node, params[0], params[1]), |
| 6839 | 6834 | .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]), |
| ... | ... | @@ -6896,7 +6891,7 @@ fn builtinCall( |
| 6896 | 6891 | .decl_name = decl_name, |
| 6897 | 6892 | .options = options, |
| 6898 | 6893 | }); |
| 6899 | | return rvalue(gz, scope, rl, .void_value, node); |
| 6894 | return rvalue(gz, rl, .void_value, node); |
| 6900 | 6895 | }, |
| 6901 | 6896 | .@"extern" => { |
| 6902 | 6897 | const type_inst = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -6906,18 +6901,18 @@ fn builtinCall( |
| 6906 | 6901 | .lhs = type_inst, |
| 6907 | 6902 | .rhs = options, |
| 6908 | 6903 | }); |
| 6909 | | return rvalue(gz, scope, rl, result, node); |
| 6904 | return rvalue(gz, rl, result, node); |
| 6910 | 6905 | }, |
| 6911 | 6906 | |
| 6912 | 6907 | .breakpoint => return simpleNoOpVoid(gz, scope, rl, node, .breakpoint), |
| 6913 | 6908 | .fence => return simpleNoOpVoid(gz, scope, rl, node, .fence), |
| 6914 | 6909 | |
| 6915 | | .This => return rvalue(gz, scope, rl, try gz.addNodeExtended(.this, node), node), |
| 6916 | | .return_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.ret_addr, node), node), |
| 6917 | | .src => return rvalue(gz, scope, rl, try gz.addNodeExtended(.builtin_src, node), node), |
| 6918 | | .error_return_trace => return rvalue(gz, scope, rl, try gz.addNodeExtended(.error_return_trace, node), node), |
| 6919 | | .frame => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame, node), node), |
| 6920 | | .frame_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame_address, node), node), |
| 6910 | .This => return rvalue(gz, rl, try gz.addNodeExtended(.this, node), node), |
| 6911 | .return_address => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr, node), node), |
| 6912 | .src => return rvalue(gz, rl, try gz.addNodeExtended(.builtin_src, node), node), |
| 6913 | .error_return_trace => return rvalue(gz, rl, try gz.addNodeExtended(.error_return_trace, node), node), |
| 6914 | .frame => return rvalue(gz, rl, try gz.addNodeExtended(.frame, node), node), |
| 6915 | .frame_address => return rvalue(gz, rl, try gz.addNodeExtended(.frame_address, node), node), |
| 6921 | 6916 | |
| 6922 | 6917 | .type_info => return simpleUnOpType(gz, scope, rl, node, params[0], .type_info), |
| 6923 | 6918 | .size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .size_of), |
| ... | ... | @@ -6973,7 +6968,7 @@ fn builtinCall( |
| 6973 | 6968 | .lhs = dest_align, |
| 6974 | 6969 | .rhs = rhs, |
| 6975 | 6970 | }); |
| 6976 | | return rvalue(gz, scope, rl, result, node); |
| 6971 | return rvalue(gz, rl, result, node); |
| 6977 | 6972 | }, |
| 6978 | 6973 | |
| 6979 | 6974 | .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl), |
| ... | ... | @@ -7009,7 +7004,7 @@ fn builtinCall( |
| 7009 | 7004 | .node = gz.nodeIndexToRelative(node), |
| 7010 | 7005 | .operand = operand, |
| 7011 | 7006 | }); |
| 7012 | | return rvalue(gz, scope, rl, result, node); |
| 7007 | return rvalue(gz, rl, result, node); |
| 7013 | 7008 | }, |
| 7014 | 7009 | .wasm_memory_grow => { |
| 7015 | 7010 | const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]); |
| ... | ... | @@ -7019,7 +7014,7 @@ fn builtinCall( |
| 7019 | 7014 | .lhs = index_arg, |
| 7020 | 7015 | .rhs = delta_arg, |
| 7021 | 7016 | }); |
| 7022 | | return rvalue(gz, scope, rl, result, node); |
| 7017 | return rvalue(gz, rl, result, node); |
| 7023 | 7018 | }, |
| 7024 | 7019 | .c_define => { |
| 7025 | 7020 | const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[0]); |
| ... | ... | @@ -7029,7 +7024,7 @@ fn builtinCall( |
| 7029 | 7024 | .lhs = name, |
| 7030 | 7025 | .rhs = value, |
| 7031 | 7026 | }); |
| 7032 | | return rvalue(gz, scope, rl, result, node); |
| 7027 | return rvalue(gz, rl, result, node); |
| 7033 | 7028 | }, |
| 7034 | 7029 | |
| 7035 | 7030 | .splat => { |
| ... | ... | @@ -7039,7 +7034,7 @@ fn builtinCall( |
| 7039 | 7034 | .lhs = len, |
| 7040 | 7035 | .rhs = scalar, |
| 7041 | 7036 | }); |
| 7042 | | return rvalue(gz, scope, rl, result, node); |
| 7037 | return rvalue(gz, rl, result, node); |
| 7043 | 7038 | }, |
| 7044 | 7039 | .reduce => { |
| 7045 | 7040 | const op = try expr(gz, scope, .{ .ty = .reduce_op_type }, params[0]); |
| ... | ... | @@ -7048,7 +7043,7 @@ fn builtinCall( |
| 7048 | 7043 | .lhs = op, |
| 7049 | 7044 | .rhs = scalar, |
| 7050 | 7045 | }); |
| 7051 | | return rvalue(gz, scope, rl, result, node); |
| 7046 | return rvalue(gz, rl, result, node); |
| 7052 | 7047 | }, |
| 7053 | 7048 | |
| 7054 | 7049 | .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow), |
| ... | ... | @@ -7075,7 +7070,7 @@ fn builtinCall( |
| 7075 | 7070 | .rhs = rhs, |
| 7076 | 7071 | .ptr = ptr, |
| 7077 | 7072 | }); |
| 7078 | | return rvalue(gz, scope, rl, result, node); |
| 7073 | return rvalue(gz, rl, result, node); |
| 7079 | 7074 | }, |
| 7080 | 7075 | |
| 7081 | 7076 | .atomic_load => { |
| ... | ... | @@ -7095,7 +7090,7 @@ fn builtinCall( |
| 7095 | 7090 | .lhs = ptr, |
| 7096 | 7091 | .rhs = ordering, |
| 7097 | 7092 | }); |
| 7098 | | return rvalue(gz, scope, rl, result, node); |
| 7093 | return rvalue(gz, rl, result, node); |
| 7099 | 7094 | }, |
| 7100 | 7095 | .atomic_rmw => { |
| 7101 | 7096 | const int_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7118,7 +7113,7 @@ fn builtinCall( |
| 7118 | 7113 | .operand = operand, |
| 7119 | 7114 | .ordering = ordering, |
| 7120 | 7115 | }); |
| 7121 | | return rvalue(gz, scope, rl, result, node); |
| 7116 | return rvalue(gz, rl, result, node); |
| 7122 | 7117 | }, |
| 7123 | 7118 | .atomic_store => { |
| 7124 | 7119 | const int_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7139,7 +7134,7 @@ fn builtinCall( |
| 7139 | 7134 | .operand = operand, |
| 7140 | 7135 | .ordering = ordering, |
| 7141 | 7136 | }); |
| 7142 | | return rvalue(gz, scope, rl, result, node); |
| 7137 | return rvalue(gz, rl, result, node); |
| 7143 | 7138 | }, |
| 7144 | 7139 | .mul_add => { |
| 7145 | 7140 | const float_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7151,7 +7146,7 @@ fn builtinCall( |
| 7151 | 7146 | .mulend2 = mulend2, |
| 7152 | 7147 | .addend = addend, |
| 7153 | 7148 | }); |
| 7154 | | return rvalue(gz, scope, rl, result, node); |
| 7149 | return rvalue(gz, rl, result, node); |
| 7155 | 7150 | }, |
| 7156 | 7151 | .call => { |
| 7157 | 7152 | const options = try comptimeExpr(gz, scope, .{ .ty = .call_options_type }, params[0]); |
| ... | ... | @@ -7162,7 +7157,7 @@ fn builtinCall( |
| 7162 | 7157 | .callee = callee, |
| 7163 | 7158 | .args = args, |
| 7164 | 7159 | }); |
| 7165 | | return rvalue(gz, scope, rl, result, node); |
| 7160 | return rvalue(gz, rl, result, node); |
| 7166 | 7161 | }, |
| 7167 | 7162 | .field_parent_ptr => { |
| 7168 | 7163 | const parent_type = try typeExpr(gz, scope, params[0]); |
| ... | ... | @@ -7173,7 +7168,7 @@ fn builtinCall( |
| 7173 | 7168 | .field_name = field_name, |
| 7174 | 7169 | .field_ptr = try expr(gz, scope, .{ .ty = field_ptr_type }, params[2]), |
| 7175 | 7170 | }); |
| 7176 | | return rvalue(gz, scope, rl, result, node); |
| 7171 | return rvalue(gz, rl, result, node); |
| 7177 | 7172 | }, |
| 7178 | 7173 | .memcpy => { |
| 7179 | 7174 | const result = try gz.addPlNode(.memcpy, node, Zir.Inst.Memcpy{ |
| ... | ... | @@ -7181,7 +7176,7 @@ fn builtinCall( |
| 7181 | 7176 | .source = try expr(gz, scope, .{ .ty = .manyptr_const_u8_type }, params[1]), |
| 7182 | 7177 | .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), |
| 7183 | 7178 | }); |
| 7184 | | return rvalue(gz, scope, rl, result, node); |
| 7179 | return rvalue(gz, rl, result, node); |
| 7185 | 7180 | }, |
| 7186 | 7181 | .memset => { |
| 7187 | 7182 | const result = try gz.addPlNode(.memset, node, Zir.Inst.Memset{ |
| ... | ... | @@ -7189,7 +7184,7 @@ fn builtinCall( |
| 7189 | 7184 | .byte = try expr(gz, scope, .{ .ty = .u8_type }, params[1]), |
| 7190 | 7185 | .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]), |
| 7191 | 7186 | }); |
| 7192 | | return rvalue(gz, scope, rl, result, node); |
| 7187 | return rvalue(gz, rl, result, node); |
| 7193 | 7188 | }, |
| 7194 | 7189 | .shuffle => { |
| 7195 | 7190 | const result = try gz.addPlNode(.shuffle, node, Zir.Inst.Shuffle{ |
| ... | ... | @@ -7198,7 +7193,7 @@ fn builtinCall( |
| 7198 | 7193 | .b = try expr(gz, scope, .none, params[2]), |
| 7199 | 7194 | .mask = try comptimeExpr(gz, scope, .none, params[3]), |
| 7200 | 7195 | }); |
| 7201 | | return rvalue(gz, scope, rl, result, node); |
| 7196 | return rvalue(gz, rl, result, node); |
| 7202 | 7197 | }, |
| 7203 | 7198 | .async_call => { |
| 7204 | 7199 | const result = try gz.addPlNode(.builtin_async_call, node, Zir.Inst.AsyncCall{ |
| ... | ... | @@ -7207,14 +7202,14 @@ fn builtinCall( |
| 7207 | 7202 | .fn_ptr = try expr(gz, scope, .none, params[2]), |
| 7208 | 7203 | .args = try expr(gz, scope, .none, params[3]), |
| 7209 | 7204 | }); |
| 7210 | | return rvalue(gz, scope, rl, result, node); |
| 7205 | return rvalue(gz, rl, result, node); |
| 7211 | 7206 | }, |
| 7212 | 7207 | .Vector => { |
| 7213 | 7208 | const result = try gz.addPlNode(.vector_type, node, Zir.Inst.Bin{ |
| 7214 | 7209 | .lhs = try comptimeExpr(gz, scope, .{.ty = .u32_type}, params[0]), |
| 7215 | 7210 | .rhs = try typeExpr(gz, scope, params[1]), |
| 7216 | 7211 | }); |
| 7217 | | return rvalue(gz, scope, rl, result, node); |
| 7212 | return rvalue(gz, rl, result, node); |
| 7218 | 7213 | }, |
| 7219 | 7214 | |
| 7220 | 7215 | } |
| ... | ... | @@ -7229,7 +7224,7 @@ fn simpleNoOpVoid( |
| 7229 | 7224 | tag: Zir.Inst.Tag, |
| 7230 | 7225 | ) InnerError!Zir.Inst.Ref { |
| 7231 | 7226 | _ = try gz.addNode(tag, node); |
| 7232 | | return rvalue(gz, scope, rl, .void_value, node); |
| 7227 | return rvalue(gz, rl, .void_value, node); |
| 7233 | 7228 | } |
| 7234 | 7229 | |
| 7235 | 7230 | fn hasDeclOrField( |
| ... | ... | @@ -7247,7 +7242,7 @@ fn hasDeclOrField( |
| 7247 | 7242 | .lhs = container_type, |
| 7248 | 7243 | .rhs = name, |
| 7249 | 7244 | }); |
| 7250 | | return rvalue(gz, scope, rl, result, node); |
| 7245 | return rvalue(gz, rl, result, node); |
| 7251 | 7246 | } |
| 7252 | 7247 | |
| 7253 | 7248 | fn typeCast( |
| ... | ... | @@ -7263,7 +7258,7 @@ fn typeCast( |
| 7263 | 7258 | .lhs = try typeExpr(gz, scope, lhs_node), |
| 7264 | 7259 | .rhs = try expr(gz, scope, .none, rhs_node), |
| 7265 | 7260 | }); |
| 7266 | | return rvalue(gz, scope, rl, result, node); |
| 7261 | return rvalue(gz, rl, result, node); |
| 7267 | 7262 | } |
| 7268 | 7263 | |
| 7269 | 7264 | fn simpleUnOpType( |
| ... | ... | @@ -7276,7 +7271,7 @@ fn simpleUnOpType( |
| 7276 | 7271 | ) InnerError!Zir.Inst.Ref { |
| 7277 | 7272 | const operand = try typeExpr(gz, scope, operand_node); |
| 7278 | 7273 | const result = try gz.addUnNode(tag, operand, node); |
| 7279 | | return rvalue(gz, scope, rl, result, node); |
| 7274 | return rvalue(gz, rl, result, node); |
| 7280 | 7275 | } |
| 7281 | 7276 | |
| 7282 | 7277 | fn simpleUnOp( |
| ... | ... | @@ -7290,7 +7285,7 @@ fn simpleUnOp( |
| 7290 | 7285 | ) InnerError!Zir.Inst.Ref { |
| 7291 | 7286 | const operand = try expr(gz, scope, operand_rl, operand_node); |
| 7292 | 7287 | const result = try gz.addUnNode(tag, operand, node); |
| 7293 | | return rvalue(gz, scope, rl, result, node); |
| 7288 | return rvalue(gz, rl, result, node); |
| 7294 | 7289 | } |
| 7295 | 7290 | |
| 7296 | 7291 | fn cmpxchg( |
| ... | ... | @@ -7320,7 +7315,7 @@ fn cmpxchg( |
| 7320 | 7315 | .fail_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[5]), |
| 7321 | 7316 | // zig fmt: on |
| 7322 | 7317 | }); |
| 7323 | | return rvalue(gz, scope, rl, result, node); |
| 7318 | return rvalue(gz, rl, result, node); |
| 7324 | 7319 | } |
| 7325 | 7320 | |
| 7326 | 7321 | fn bitBuiltin( |
| ... | ... | @@ -7335,7 +7330,7 @@ fn bitBuiltin( |
| 7335 | 7330 | const int_type = try typeExpr(gz, scope, int_type_node); |
| 7336 | 7331 | const operand = try expr(gz, scope, .{ .ty = int_type }, operand_node); |
| 7337 | 7332 | const result = try gz.addUnNode(tag, operand, node); |
| 7338 | | return rvalue(gz, scope, rl, result, node); |
| 7333 | return rvalue(gz, rl, result, node); |
| 7339 | 7334 | } |
| 7340 | 7335 | |
| 7341 | 7336 | fn divBuiltin( |
| ... | ... | @@ -7351,7 +7346,7 @@ fn divBuiltin( |
| 7351 | 7346 | .lhs = try expr(gz, scope, .none, lhs_node), |
| 7352 | 7347 | .rhs = try expr(gz, scope, .none, rhs_node), |
| 7353 | 7348 | }); |
| 7354 | | return rvalue(gz, scope, rl, result, node); |
| 7349 | return rvalue(gz, rl, result, node); |
| 7355 | 7350 | } |
| 7356 | 7351 | |
| 7357 | 7352 | fn simpleCBuiltin( |
| ... | ... | @@ -7367,7 +7362,7 @@ fn simpleCBuiltin( |
| 7367 | 7362 | .node = gz.nodeIndexToRelative(node), |
| 7368 | 7363 | .operand = operand, |
| 7369 | 7364 | }); |
| 7370 | | return rvalue(gz, scope, rl, .void_value, node); |
| 7365 | return rvalue(gz, rl, .void_value, node); |
| 7371 | 7366 | } |
| 7372 | 7367 | |
| 7373 | 7368 | fn offsetOf( |
| ... | ... | @@ -7385,7 +7380,7 @@ fn offsetOf( |
| 7385 | 7380 | .lhs = type_inst, |
| 7386 | 7381 | .rhs = field_name, |
| 7387 | 7382 | }); |
| 7388 | | return rvalue(gz, scope, rl, result, node); |
| 7383 | return rvalue(gz, rl, result, node); |
| 7389 | 7384 | } |
| 7390 | 7385 | |
| 7391 | 7386 | fn shiftOp( |
| ... | ... | @@ -7404,7 +7399,7 @@ fn shiftOp( |
| 7404 | 7399 | .lhs = lhs, |
| 7405 | 7400 | .rhs = rhs, |
| 7406 | 7401 | }); |
| 7407 | | return rvalue(gz, scope, rl, result, node); |
| 7402 | return rvalue(gz, rl, result, node); |
| 7408 | 7403 | } |
| 7409 | 7404 | |
| 7410 | 7405 | fn cImport( |
| ... | ... | @@ -7429,7 +7424,7 @@ fn cImport( |
| 7429 | 7424 | try block_scope.setBlockBody(block_inst); |
| 7430 | 7425 | try gz.instructions.append(gpa, block_inst); |
| 7431 | 7426 | |
| 7432 | | return rvalue(gz, scope, rl, .void_value, node); |
| 7427 | return rvalue(gz, rl, .void_value, node); |
| 7433 | 7428 | } |
| 7434 | 7429 | |
| 7435 | 7430 | fn overflowArithmetic( |
| ... | ... | @@ -7459,7 +7454,7 @@ fn overflowArithmetic( |
| 7459 | 7454 | .rhs = rhs, |
| 7460 | 7455 | .ptr = ptr, |
| 7461 | 7456 | }); |
| 7462 | | return rvalue(gz, scope, rl, result, node); |
| 7457 | return rvalue(gz, rl, result, node); |
| 7463 | 7458 | } |
| 7464 | 7459 | |
| 7465 | 7460 | fn callExpr( |
| ... | ... | @@ -7511,7 +7506,7 @@ fn callExpr( |
| 7511 | 7506 | }; |
| 7512 | 7507 | break :res try gz.addCall(tag, lhs, args, node); |
| 7513 | 7508 | }; |
| 7514 | | return rvalue(gz, scope, rl, result, node); // TODO function call with result location |
| 7509 | return rvalue(gz, rl, result, node); // TODO function call with result location |
| 7515 | 7510 | } |
| 7516 | 7511 | |
| 7517 | 7512 | pub const simple_types = std.ComptimeStringMap(Zir.Inst.Ref, .{ |
| ... | ... | @@ -7987,12 +7982,10 @@ fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum { |
| 7987 | 7982 | /// If the `ResultLoc` is `ty`, it will coerce the result to the type. |
| 7988 | 7983 | fn rvalue( |
| 7989 | 7984 | gz: *GenZir, |
| 7990 | | scope: *Scope, |
| 7991 | 7985 | rl: ResultLoc, |
| 7992 | 7986 | result: Zir.Inst.Ref, |
| 7993 | 7987 | src_node: ast.Node.Index, |
| 7994 | 7988 | ) InnerError!Zir.Inst.Ref { |
| 7995 | | _ = scope; |
| 7996 | 7989 | switch (rl) { |
| 7997 | 7990 | .none, .none_or_ref => return result, |
| 7998 | 7991 | .discard => { |