authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 13:16:03-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-21 17:03:03-07:00
loga51ff3a9033d6befabdd3d80374f6bf2a6bbb62e
treec2f6a359483adc190667ea123b0b5360e26096bf
parentb9b0e53197a977be6cecca29366bd1e758e66be8

AstGen: remove unused scope parameter from rvalue


1 files changed, 125 insertions(+), 132 deletions(-)

src/AstGen.zig+125-132
...@@ -481,61 +481,61 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr...@@ -481,61 +481,61 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
481481
482 .assign => {482 .assign => {
483 try assign(gz, scope, node);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 },
486486
487 .assign_bit_shift_left => {487 .assign_bit_shift_left => {
488 try assignShift(gz, scope, node, .shl);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 .assign_bit_shift_right => {491 .assign_bit_shift_right => {
492 try assignShift(gz, scope, node, .shr);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 },
495495
496 .assign_bit_and => {496 .assign_bit_and => {
497 try assignOp(gz, scope, node, .bit_and);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 .assign_bit_or => {500 .assign_bit_or => {
501 try assignOp(gz, scope, node, .bit_or);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 .assign_bit_xor => {504 .assign_bit_xor => {
505 try assignOp(gz, scope, node, .xor);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 .assign_div => {508 .assign_div => {
509 try assignOp(gz, scope, node, .div);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 .assign_sub => {512 .assign_sub => {
513 try assignOp(gz, scope, node, .sub);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 .assign_sub_wrap => {516 .assign_sub_wrap => {
517 try assignOp(gz, scope, node, .subwrap);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 .assign_mod => {520 .assign_mod => {
521 try assignOp(gz, scope, node, .mod_rem);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 .assign_add => {524 .assign_add => {
525 try assignOp(gz, scope, node, .add);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 .assign_add_wrap => {528 .assign_add_wrap => {
529 try assignOp(gz, scope, node, .addwrap);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 .assign_mul => {532 .assign_mul => {
533 try assignOp(gz, scope, node, .mul);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 .assign_mul_wrap => {536 .assign_mul_wrap => {
537 try assignOp(gz, scope, node, .mulwrap);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 },
540540
541 // zig fmt: off541 // zig fmt: off
...@@ -659,7 +659,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr...@@ -659,7 +659,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
659 .lhs = lhs,659 .lhs = lhs,
660 .start = start,660 .start = start,
661 });661 });
662 return rvalue(gz, scope, rl, result, node);662 return rvalue(gz, rl, result, node);
663 },663 },
664 .slice => {664 .slice => {
665 const lhs = try expr(gz, scope, .ref, node_datas[node].lhs);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,7 +671,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
671 .start = start,671 .start = start,
672 .end = end,672 .end = end,
673 });673 });
674 return rvalue(gz, scope, rl, result, node);674 return rvalue(gz, rl, result, node);
675 },675 },
676 .slice_sentinel => {676 .slice_sentinel => {
677 const lhs = try expr(gz, scope, .ref, node_datas[node].lhs);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,7 +685,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
685 .end = end,685 .end = end,
686 .sentinel = sentinel,686 .sentinel = sentinel,
687 });687 });
688 return rvalue(gz, scope, rl, result, node);688 return rvalue(gz, rl, result, node);
689 },689 },
690690
691 .deref => {691 .deref => {
...@@ -694,22 +694,22 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr...@@ -694,22 +694,22 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
694 .ref, .none_or_ref => return lhs,694 .ref, .none_or_ref => return lhs,
695 else => {695 else => {
696 const result = try gz.addUnNode(.load, lhs, node);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 .address_of => {701 .address_of => {
702 const result = try expr(gz, scope, .ref, node_datas[node].lhs);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),705 .undefined_literal => return rvalue(gz, rl, .undef, node),
706 .true_literal => return rvalue(gz, scope, rl, .bool_true, node),706 .true_literal => return rvalue(gz, rl, .bool_true, node),
707 .false_literal => return rvalue(gz, scope, rl, .bool_false, node),707 .false_literal => return rvalue(gz, rl, .bool_false, node),
708 .null_literal => return rvalue(gz, scope, rl, .null_value, node),708 .null_literal => return rvalue(gz, rl, .null_value, node),
709 .optional_type => {709 .optional_type => {
710 const operand = try typeExpr(gz, scope, node_datas[node].lhs);710 const operand = try typeExpr(gz, scope, node_datas[node].lhs);
711 const result = try gz.addUnNode(.optional_type, operand, node);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 .unwrap_optional => switch (rl) {714 .unwrap_optional => switch (rl) {
715 .ref => return gz.addUnNode(715 .ref => return gz.addUnNode(
...@@ -717,7 +717,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr...@@ -717,7 +717,7 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
717 try expr(gz, scope, .ref, node_datas[node].lhs),717 try expr(gz, scope, .ref, node_datas[node].lhs),
718 node,718 node,
719 ),719 ),
720 else => return rvalue(gz, scope, rl, try gz.addUnNode(720 else => return rvalue(gz, rl, try gz.addUnNode(
721 .optional_payload_safe,721 .optional_payload_safe,
722 try expr(gz, scope, .none, node_datas[node].lhs),722 try expr(gz, scope, .none, node_datas[node].lhs),
723 node,723 node,
...@@ -739,11 +739,11 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr...@@ -739,11 +739,11 @@ fn expr(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerEr
739 },739 },
740 .enum_literal => return simpleStrTok(gz, scope, rl, main_tokens[node], node, .enum_literal),740 .enum_literal => return simpleStrTok(gz, scope, rl, main_tokens[node], node, .enum_literal),
741 .error_value => return simpleStrTok(gz, scope, rl, node_datas[node].rhs, node, .error_value),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 .anyframe_type => {743 .anyframe_type => {
744 const return_type = try typeExpr(gz, scope, node_datas[node].rhs);744 const return_type = try typeExpr(gz, scope, node_datas[node].rhs);
745 const result = try gz.addUnNode(.anyframe_type, return_type, node);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 .@"catch" => {748 .@"catch" => {
749 const catch_token = main_tokens[node];749 const catch_token = main_tokens[node];
...@@ -916,7 +916,7 @@ fn nosuspendExpr(...@@ -916,7 +916,7 @@ fn nosuspendExpr(
916 gz.nosuspend_node = node;916 gz.nosuspend_node = node;
917 const result = try expr(gz, scope, rl, body_node);917 const result = try expr(gz, scope, rl, body_node);
918 gz.nosuspend_node = 0;918 gz.nosuspend_node = 0;
919 return rvalue(gz, scope, rl, result, node);919 return rvalue(gz, rl, result, node);
920}920}
921921
922fn suspendExpr(922fn suspendExpr(
...@@ -977,7 +977,7 @@ fn awaitExpr(...@@ -977,7 +977,7 @@ fn awaitExpr(
977 const operand = try expr(gz, scope, .none, rhs_node);977 const operand = try expr(gz, scope, .none, rhs_node);
978 const tag: Zir.Inst.Tag = if (gz.nosuspend_node != 0) .await_nosuspend else .@"await";978 const tag: Zir.Inst.Tag = if (gz.nosuspend_node != 0) .await_nosuspend else .@"await";
979 const result = try gz.addUnNode(tag, operand, node);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}
982982
983fn resumeExpr(983fn resumeExpr(
...@@ -992,7 +992,7 @@ fn resumeExpr(...@@ -992,7 +992,7 @@ fn resumeExpr(
992 const rhs_node = node_datas[node].lhs;992 const rhs_node = node_datas[node].lhs;
993 const operand = try expr(gz, scope, .none, rhs_node);993 const operand = try expr(gz, scope, .none, rhs_node);
994 const result = try gz.addUnNode(.@"resume", operand, node);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}
997997
998fn fnProtoExpr(998fn fnProtoExpr(
...@@ -1098,7 +1098,7 @@ fn fnProtoExpr(...@@ -1098,7 +1098,7 @@ fn fnProtoExpr(
1098 .is_test = false,1098 .is_test = false,
1099 .is_extern = false,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}
11031103
1104fn arrayInitExpr(1104fn arrayInitExpr(
...@@ -1184,7 +1184,7 @@ fn arrayInitExpr(...@@ -1184,7 +1184,7 @@ fn arrayInitExpr(
1184 .ty => |ty_inst| {1184 .ty => |ty_inst| {
1185 if (types.array != .none) {1185 if (types.array != .none) {
1186 const result = try arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, types.elem, .array_init);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 } else {1188 } else {
1189 const elem_type = try gz.addUnNode(.elem_type, ty_inst, node);1189 const elem_type = try gz.addUnNode(.elem_type, ty_inst, node);
1190 return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, elem_type, .array_init);1190 return arrayInitExprRlTy(gz, scope, node, array_init.ast.elements, elem_type, .array_init);
...@@ -1288,7 +1288,7 @@ fn structInitExpr(...@@ -1288,7 +1288,7 @@ fn structInitExpr(
12881288
1289 if (struct_init.ast.fields.len == 0) {1289 if (struct_init.ast.fields.len == 0) {
1290 if (struct_init.ast.type_expr == 0) {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 array: {1293 array: {
1294 const node_tags = tree.nodes.items(.tag);1294 const node_tags = tree.nodes.items(.tag);
...@@ -1310,12 +1310,12 @@ fn structInitExpr(...@@ -1310,12 +1310,12 @@ fn structInitExpr(
1310 break :blk try gz.addArrayTypeSentinel(.zero_usize, elem_type, sentinel);1310 break :blk try gz.addArrayTypeSentinel(.zero_usize, elem_type, sentinel);
1311 };1311 };
1312 const result = try gz.addUnNode(.struct_init_empty, array_type_inst, node);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 const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr);1316 const ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr);
1317 const result = try gz.addUnNode(.struct_init_empty, ty_inst, node);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 switch (rl) {1320 switch (rl) {
1321 .discard => {1321 .discard => {
...@@ -1348,7 +1348,7 @@ fn structInitExpr(...@@ -1348,7 +1348,7 @@ fn structInitExpr(
1348 }1348 }
1349 const inner_ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr);1349 const inner_ty_inst = try typeExpr(gz, scope, struct_init.ast.type_expr);
1350 const result = try structInitExprRlTy(gz, scope, node, struct_init, inner_ty_inst, .struct_init);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 .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, node, struct_init, ptr_inst),1353 .ptr, .inferred_ptr => |ptr_inst| return structInitExprRlPtr(gz, scope, node, struct_init, ptr_inst),
1354 .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, node, struct_init, block_gz.rl_ptr),1354 .block_ptr => |block_gz| return structInitExprRlPtr(gz, scope, node, struct_init, block_gz.rl_ptr),
...@@ -1651,7 +1651,7 @@ fn blockExpr(...@@ -1651,7 +1651,7 @@ fn blockExpr(
1651 }1651 }
16521652
1653 try blockExprStmts(gz, scope, statements);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}
16561656
1657fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.TokenIndex) !void {1657fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: ast.TokenIndex) !void {
...@@ -1761,7 +1761,7 @@ fn labeledBlockExpr(...@@ -1761,7 +1761,7 @@ fn labeledBlockExpr(
1761 const block_ref = gz.indexToRef(block_inst);1761 const block_ref = gz.indexToRef(block_inst);
1762 switch (rl) {1762 switch (rl) {
1763 .ref => return block_ref,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,7 +2560,7 @@ fn boolNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inne
25602560
2561 const operand = try expr(gz, scope, bool_rl, node_datas[node].lhs);2561 const operand = try expr(gz, scope, bool_rl, node_datas[node].lhs);
2562 const result = try gz.addUnNode(.bool_not, operand, node);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}
25652565
2566fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) InnerError!Zir.Inst.Ref {2566fn 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,7 +2570,7 @@ fn bitNot(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) Inner
25702570
2571 const operand = try expr(gz, scope, .none, node_datas[node].lhs);2571 const operand = try expr(gz, scope, .none, node_datas[node].lhs);
2572 const result = try gz.addUnNode(.bit_not, operand, node);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}
25752575
2576fn negation(2576fn negation(
...@@ -2586,7 +2586,7 @@ fn negation(...@@ -2586,7 +2586,7 @@ fn negation(
25862586
2587 const operand = try expr(gz, scope, .none, node_datas[node].lhs);2587 const operand = try expr(gz, scope, .none, node_datas[node].lhs);
2588 const result = try gz.addUnNode(tag, operand, node);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}
25912591
2592fn ptrType(2592fn ptrType(
...@@ -2612,7 +2612,7 @@ fn ptrType(...@@ -2612,7 +2612,7 @@ fn ptrType(
2612 .elem_type = elem_type,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 }
26172617
2618 var sentinel_ref: Zir.Inst.Ref = .none;2618 var sentinel_ref: Zir.Inst.Ref = .none;
...@@ -2672,7 +2672,7 @@ fn ptrType(...@@ -2672,7 +2672,7 @@ fn ptrType(
2672 } });2672 } });
2673 gz.instructions.appendAssumeCapacity(new_index);2673 gz.instructions.appendAssumeCapacity(new_index);
26742674
2675 return rvalue(gz, scope, rl, result, node);2675 return rvalue(gz, rl, result, node);
2676}2676}
26772677
2678fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {2678fn 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,7 +2692,7 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Z
2692 const elem_type = try typeExpr(gz, scope, node_datas[node].rhs);2692 const elem_type = try typeExpr(gz, scope, node_datas[node].rhs);
26932693
2694 const result = try gz.addBin(.array_type, len, elem_type);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}
26972697
2698fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {2698fn 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,7 +2714,7 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.I
2714 const sentinel = try expr(gz, scope, .{ .ty = elem_type }, extra.sentinel);2714 const sentinel = try expr(gz, scope, .{ .ty = elem_type }, extra.sentinel);
27152715
2716 const result = try gz.addArrayTypeSentinel(len, elem_type, sentinel);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}
27192719
2720const WipDecls = struct {2720const WipDecls = struct {
...@@ -3950,7 +3950,7 @@ fn containerDecl(...@@ -3950,7 +3950,7 @@ fn containerDecl(
3950 assert(arg_inst == .none);3950 assert(arg_inst == .none);
39513951
3952 const result = try structDeclInner(gz, scope, node, container_decl, layout);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 .keyword_union => {3955 .keyword_union => {
3956 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {3956 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
...@@ -3962,7 +3962,7 @@ fn containerDecl(...@@ -3962,7 +3962,7 @@ fn containerDecl(
3962 const have_auto_enum = container_decl.ast.enum_token != null;3962 const have_auto_enum = container_decl.ast.enum_token != null;
39633963
3964 const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, arg_inst, have_auto_enum);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 .keyword_enum => {3967 .keyword_enum => {
3968 if (container_decl.layout_token) |t| {3968 if (container_decl.layout_token) |t| {
...@@ -4291,7 +4291,7 @@ fn containerDecl(...@@ -4291,7 +4291,7 @@ fn containerDecl(
4291 astgen.extra.appendAssumeCapacity(cur_bit_bag);4291 astgen.extra.appendAssumeCapacity(cur_bit_bag);
4292 astgen.extra.appendSliceAssumeCapacity(fields_data.items);4292 astgen.extra.appendSliceAssumeCapacity(fields_data.items);
42934293
4294 return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node);4294 return rvalue(gz, rl, gz.indexToRef(decl_inst), node);
4295 },4295 },
4296 .keyword_opaque => {4296 .keyword_opaque => {
4297 var namespace: Scope.Namespace = .{ .parent = scope };4297 var namespace: Scope.Namespace = .{ .parent = scope };
...@@ -4452,7 +4452,7 @@ fn containerDecl(...@@ -4452,7 +4452,7 @@ fn containerDecl(
4452 }4452 }
4453 astgen.extra.appendSliceAssumeCapacity(wip_decls.payload.items);4453 astgen.extra.appendSliceAssumeCapacity(wip_decls.payload.items);
44544454
4455 return rvalue(gz, scope, rl, gz.indexToRef(decl_inst), node);4455 return rvalue(gz, rl, gz.indexToRef(decl_inst), node);
4456 },4456 },
4457 else => unreachable,4457 else => unreachable,
4458 }4458 }
...@@ -4495,7 +4495,7 @@ fn errorSetDecl(...@@ -4495,7 +4495,7 @@ fn errorSetDecl(
4495 .fields_len = @intCast(u32, field_names.items.len),4495 .fields_len = @intCast(u32, field_names.items.len),
4496 });4496 });
4497 try astgen.extra.appendSlice(gpa, field_names.items);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}
45004500
4501fn tryExpr(4501fn tryExpr(
...@@ -4554,7 +4554,7 @@ fn tryExpr(...@@ -4554,7 +4554,7 @@ fn tryExpr(
4554 const unwrapped_payload = try else_scope.addUnNode(err_ops[2], operand, node);4554 const unwrapped_payload = try else_scope.addUnNode(err_ops[2], operand, node);
4555 const else_result = switch (rl) {4555 const else_result = switch (rl) {
4556 .ref => unwrapped_payload,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 };
45594559
4560 return finishThenElseBlock(4560 return finishThenElseBlock(
...@@ -4647,7 +4647,7 @@ fn orelseCatchExpr(...@@ -4647,7 +4647,7 @@ fn orelseCatchExpr(
4647 const unwrapped_payload = try else_scope.addUnNode(unwrap_op, operand, node);4647 const unwrapped_payload = try else_scope.addUnNode(unwrap_op, operand, node);
4648 const else_result = switch (rl) {4648 const else_result = switch (rl) {
4649 .ref => unwrapped_payload,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 };
46524652
4653 return finishThenElseBlock(4653 return finishThenElseBlock(
...@@ -4719,7 +4719,7 @@ fn finishThenElseBlock(...@@ -4719,7 +4719,7 @@ fn finishThenElseBlock(
4719 const block_ref = parent_gz.indexToRef(main_block);4719 const block_ref = parent_gz.indexToRef(main_block);
4720 switch (rl) {4720 switch (rl) {
4721 .ref => return block_ref,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,7 +4755,7 @@ fn fieldAccess(
4755 .lhs = try expr(gz, scope, .ref, object_node),4755 .lhs = try expr(gz, scope, .ref, object_node),
4756 .field_name_start = str_index,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 .lhs = try expr(gz, scope, .none_or_ref, object_node),4759 .lhs = try expr(gz, scope, .none_or_ref, object_node),
4760 .field_name_start = str_index,4760 .field_name_start = str_index,
4761 }), node),4761 }), node),
...@@ -4777,7 +4777,7 @@ fn arrayAccess(...@@ -4777,7 +4777,7 @@ fn arrayAccess(
4777 try expr(gz, scope, .ref, node_datas[node].lhs),4777 try expr(gz, scope, .ref, node_datas[node].lhs),
4778 try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs),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 .elem_val,4781 .elem_val,
4782 try expr(gz, scope, .none_or_ref, node_datas[node].lhs),4782 try expr(gz, scope, .none_or_ref, node_datas[node].lhs),
4783 try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs),4783 try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].rhs),
...@@ -4800,7 +4800,7 @@ fn simpleBinOp(...@@ -4800,7 +4800,7 @@ fn simpleBinOp(
4800 .lhs = try expr(gz, scope, .none, node_datas[node].lhs),4800 .lhs = try expr(gz, scope, .none, node_datas[node].lhs),
4801 .rhs = try expr(gz, scope, .none, node_datas[node].rhs),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}
48054805
4806fn simpleStrTok(4806fn simpleStrTok(
...@@ -4814,7 +4814,7 @@ fn simpleStrTok(...@@ -4814,7 +4814,7 @@ fn simpleStrTok(
4814 const astgen = gz.astgen;4814 const astgen = gz.astgen;
4815 const str_index = try astgen.identAsString(ident_token);4815 const str_index = try astgen.identAsString(ident_token);
4816 const result = try gz.addStrTok(op_inst_tag, str_index, ident_token);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}
48194819
4820fn boolBinOp(4820fn boolBinOp(
...@@ -4840,7 +4840,7 @@ fn boolBinOp(...@@ -4840,7 +4840,7 @@ fn boolBinOp(
4840 try rhs_scope.setBoolBrBody(bool_br);4840 try rhs_scope.setBoolBrBody(bool_br);
48414841
4842 const block_ref = gz.indexToRef(bool_br);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}
48454845
4846fn ifExpr(4846fn ifExpr(
...@@ -6010,7 +6010,7 @@ fn switchExpr(...@@ -6010,7 +6010,7 @@ fn switchExpr(
6010 const block_ref = parent_gz.indexToRef(switch_block);6010 const block_ref = parent_gz.indexToRef(switch_block);
6011 switch (rl) {6011 switch (rl) {
6012 .ref => return block_ref,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 .break_void => {6016 .break_void => {
...@@ -6151,7 +6151,7 @@ fn identifier(...@@ -6151,7 +6151,7 @@ fn identifier(
6151 }6151 }
61526152
6153 if (simple_types.get(ident_name)) |zir_const_ref| {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 }
61566156
6157 if (ident_name.len >= 2) integer: {6157 if (ident_name.len >= 2) integer: {
...@@ -6177,7 +6177,7 @@ fn identifier(...@@ -6177,7 +6177,7 @@ fn identifier(
6177 .bit_count = bit_count,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 }
61836183
...@@ -6196,7 +6196,7 @@ fn identifier(...@@ -6196,7 +6196,7 @@ fn identifier(
6196 // Captures of non-locals need to be emitted as decl_val or decl_ref.6196 // Captures of non-locals need to be emitted as decl_val or decl_ref.
6197 // This *might* be capturable depending on if it is comptime known.6197 // This *might* be capturable depending on if it is comptime known.
6198 if (!hit_namespace) {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 s = local_val.parent;6202 s = local_val.parent;
...@@ -6220,7 +6220,7 @@ fn identifier(...@@ -6220,7 +6220,7 @@ fn identifier(
6220 .ref, .none_or_ref => return local_ptr.ptr,6220 .ref, .none_or_ref => return local_ptr.ptr,
6221 else => {6221 else => {
6222 const loaded = try gz.addUnNode(.load, local_ptr.ptr, ident);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,7 +6254,7 @@ fn identifier(
6254 .ref, .none_or_ref => return gz.addStrTok(.decl_ref, name_str_index, ident_token),6254 .ref, .none_or_ref => return gz.addStrTok(.decl_ref, name_str_index, ident_token),
6255 else => {6255 else => {
6256 const result = try gz.addStrTok(.decl_val, name_str_index, ident_token);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,7 +6277,7 @@ fn stringLiteral(
6277 .len = str.len,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}
62826282
6283fn multilineStringLiteral(6283fn multilineStringLiteral(
...@@ -6320,7 +6320,7 @@ fn multilineStringLiteral(...@@ -6320,7 +6320,7 @@ fn multilineStringLiteral(
6320 .len = @intCast(u32, string_bytes.items.len - str_index),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}
63256325
6326fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Zir.Inst.Ref {6326fn 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,7 +6343,7 @@ fn charLiteral(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index)
6343 },6343 },
6344 };6344 };
6345 const result = try gz.addInt(value);6345 const result = try gz.addInt(value);
6346 return rvalue(gz, scope, rl, result, node);6346 return rvalue(gz, rl, result, node);
6347}6347}
63486348
6349fn integerLiteral(6349fn integerLiteral(
...@@ -6363,7 +6363,7 @@ fn integerLiteral(...@@ -6363,7 +6363,7 @@ fn integerLiteral(
6363 1 => .one,6363 1 => .one,
6364 else => try gz.addInt(small_int),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 } else |err| switch (err) {6367 } else |err| switch (err) {
6368 error.InvalidCharacter => unreachable, // Caught by the parser.6368 error.InvalidCharacter => unreachable, // Caught by the parser.
6369 error.Overflow => {},6369 error.Overflow => {},
...@@ -6394,7 +6394,7 @@ fn integerLiteral(...@@ -6394,7 +6394,7 @@ fn integerLiteral(
6394 const limbs = big_int.limbs[0..big_int.len()];6394 const limbs = big_int.limbs[0..big_int.len()];
6395 assert(big_int.isPositive());6395 assert(big_int.isPositive());
6396 const result = try gz.addIntBig(limbs);6396 const result = try gz.addIntBig(limbs);
6397 return rvalue(gz, scope, rl, result, node);6397 return rvalue(gz, rl, result, node);
6398}6398}
63996399
6400fn floatLiteral(6400fn floatLiteral(
...@@ -6424,7 +6424,7 @@ fn floatLiteral(...@@ -6424,7 +6424,7 @@ fn floatLiteral(
6424 const bigger_again: f128 = smaller_float;6424 const bigger_again: f128 = smaller_float;
6425 if (bigger_again == float_number) {6425 if (bigger_again == float_number) {
6426 const result = try gz.addFloat(smaller_float, node);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 // We need to use 128 bits. Break the float into 4 u32 values so we can6429 // We need to use 128 bits. Break the float into 4 u32 values so we can
6430 // put it into the `extra` array.6430 // put it into the `extra` array.
...@@ -6435,7 +6435,7 @@ fn floatLiteral(...@@ -6435,7 +6435,7 @@ fn floatLiteral(
6435 .piece2 = @truncate(u32, int_bits >> 64),6435 .piece2 = @truncate(u32, int_bits >> 64),
6436 .piece3 = @truncate(u32, int_bits >> 96),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}
64406440
6441fn asmExpr(6441fn asmExpr(
...@@ -6578,7 +6578,7 @@ fn asmExpr(...@@ -6578,7 +6578,7 @@ fn asmExpr(
6578 .inputs = inputs,6578 .inputs = inputs,
6579 .clobbers = clobbers_buffer[0..clobber_i],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}
65836583
6584fn as(6584fn as(
...@@ -6593,7 +6593,7 @@ fn as(...@@ -6593,7 +6593,7 @@ fn as(
6593 switch (rl) {6593 switch (rl) {
6594 .none, .none_or_ref, .discard, .ref, .ty => {6594 .none, .none_or_ref, .discard, .ref, .ty => {
6595 const result = try expr(gz, scope, .{ .ty = dest_type }, rhs);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 .ptr, .inferred_ptr => |result_ptr| {6598 .ptr, .inferred_ptr => |result_ptr| {
6599 return asRlPtr(gz, scope, rl, result_ptr, rhs, dest_type);6599 return asRlPtr(gz, scope, rl, result_ptr, rhs, dest_type);
...@@ -6620,13 +6620,13 @@ fn unionInit(...@@ -6620,13 +6620,13 @@ fn unionInit(
6620 .field_name = field_name,6620 .field_name = field_name,
6621 });6621 });
6622 const result = try expr(gz, scope, .{ .ty = union_type }, params[2]);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 .ptr => |result_ptr| {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 .block_ptr => |block_scope| {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,14 +6634,12 @@ fn unionInit(
6634fn unionInitRlPtr(6634fn unionInitRlPtr(
6635 parent_gz: *GenZir,6635 parent_gz: *GenZir,
6636 scope: *Scope,6636 scope: *Scope,
6637 rl: ResultLoc,
6638 node: ast.Node.Index,6637 node: ast.Node.Index,
6639 result_ptr: Zir.Inst.Ref,6638 result_ptr: Zir.Inst.Ref,
6640 expr_node: ast.Node.Index,6639 expr_node: ast.Node.Index,
6641 union_type: Zir.Inst.Ref,6640 union_type: Zir.Inst.Ref,
6642 field_name: Zir.Inst.Ref,6641 field_name: Zir.Inst.Ref,
6643) InnerError!Zir.Inst.Ref {6642) InnerError!Zir.Inst.Ref {
6644 _ = rl;
6645 const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{6643 const union_init_ptr = try parent_gz.addPlNode(.union_init_ptr, node, Zir.Inst.UnionInitPtr{
6646 .result_ptr = result_ptr,6644 .result_ptr = result_ptr,
6647 .union_type = union_type,6645 .union_type = union_type,
...@@ -6683,7 +6681,7 @@ fn asRlPtr(...@@ -6683,7 +6681,7 @@ fn asRlPtr(
6683 parent_zir.appendAssumeCapacity(src_inst);6681 parent_zir.appendAssumeCapacity(src_inst);
6684 }6682 }
6685 const casted_result = try parent_gz.addBin(.as, dest_type, result);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 } else {6685 } else {
6688 try parent_zir.appendSlice(astgen.gpa, as_scope.instructions.items);6686 try parent_zir.appendSlice(astgen.gpa, as_scope.instructions.items);
6689 return result;6687 return result;
...@@ -6707,16 +6705,16 @@ fn bitCast(...@@ -6707,16 +6705,16 @@ fn bitCast(
6707 .lhs = dest_type,6705 .lhs = dest_type,
6708 .rhs = operand,6706 .rhs = operand,
6709 });6707 });
6710 return rvalue(gz, scope, rl, result, node);6708 return rvalue(gz, rl, result, node);
6711 },6709 },
6712 .ref => {6710 .ref => {
6713 return astgen.failNode(node, "cannot take address of `@bitCast` result", .{});6711 return astgen.failNode(node, "cannot take address of `@bitCast` result", .{});
6714 },6712 },
6715 .ptr, .inferred_ptr => |result_ptr| {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 .block_ptr => |block| {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,14 +6722,11 @@ fn bitCast(
6724fn bitCastRlPtr(6722fn bitCastRlPtr(
6725 gz: *GenZir,6723 gz: *GenZir,
6726 scope: *Scope,6724 scope: *Scope,
6727 rl: ResultLoc,
6728 node: ast.Node.Index,6725 node: ast.Node.Index,
6729 dest_type: Zir.Inst.Ref,6726 dest_type: Zir.Inst.Ref,
6730 result_ptr: Zir.Inst.Ref,6727 result_ptr: Zir.Inst.Ref,
6731 rhs: ast.Node.Index,6728 rhs: ast.Node.Index,
6732) InnerError!Zir.Inst.Ref {6729) InnerError!Zir.Inst.Ref {
6733 _ = rl;
6734 _ = scope;
6735 const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{6730 const casted_result_ptr = try gz.addPlNode(.bitcast_result_ptr, node, Zir.Inst.Bin{
6736 .lhs = dest_type,6731 .lhs = dest_type,
6737 .rhs = result_ptr,6732 .rhs = result_ptr,
...@@ -6751,7 +6746,7 @@ fn typeOf(...@@ -6751,7 +6746,7 @@ fn typeOf(
6751 }6746 }
6752 if (params.len == 1) {6747 if (params.len == 1) {
6753 const result = try gz.addUnNode(.typeof, try expr(gz, scope, .none, params[0]), node);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 const arena = gz.astgen.arena;6751 const arena = gz.astgen.arena;
6757 var items = try arena.alloc(Zir.Inst.Ref, params.len);6752 var items = try arena.alloc(Zir.Inst.Ref, params.len);
...@@ -6760,7 +6755,7 @@ fn typeOf(...@@ -6760,7 +6755,7 @@ fn typeOf(
6760 }6755 }
67616756
6762 const result = try gz.addExtendedMultiOp(.typeof_peer, node, items);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}
67656760
6766fn builtinCall(6761fn builtinCall(
...@@ -6810,7 +6805,7 @@ fn builtinCall(...@@ -6810,7 +6805,7 @@ fn builtinCall(
6810 const str = try astgen.strLitAsString(str_lit_token);6805 const str = try astgen.strLitAsString(str_lit_token);
6811 try astgen.imports.put(astgen.gpa, str.index, {});6806 try astgen.imports.put(astgen.gpa, str.index, {});
6812 const result = try gz.addStrTok(.import, str.index, str_lit_token);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 .compile_log => {6810 .compile_log => {
6816 const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len);6811 const arg_refs = try astgen.gpa.alloc(Zir.Inst.Ref, params.len);
...@@ -6819,7 +6814,7 @@ fn builtinCall(...@@ -6819,7 +6814,7 @@ fn builtinCall(
6819 for (params) |param, i| arg_refs[i] = try expr(gz, scope, .none, param);6814 for (params) |param, i| arg_refs[i] = try expr(gz, scope, .none, param);
68206815
6821 const result = try gz.addExtendedMultiOp(.compile_log, node, arg_refs);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 .field => {6819 .field => {
6825 const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);6820 const field_name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[1]);
...@@ -6833,7 +6828,7 @@ fn builtinCall(...@@ -6833,7 +6828,7 @@ fn builtinCall(
6833 .lhs = try expr(gz, scope, .none, params[0]),6828 .lhs = try expr(gz, scope, .none, params[0]),
6834 .field_name = field_name,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 .as => return as( gz, scope, rl, node, params[0], params[1]),6833 .as => return as( gz, scope, rl, node, params[0], params[1]),
6839 .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]),6834 .bit_cast => return bitCast( gz, scope, rl, node, params[0], params[1]),
...@@ -6896,7 +6891,7 @@ fn builtinCall(...@@ -6896,7 +6891,7 @@ fn builtinCall(
6896 .decl_name = decl_name,6891 .decl_name = decl_name,
6897 .options = options,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 .@"extern" => {6896 .@"extern" => {
6902 const type_inst = try typeExpr(gz, scope, params[0]);6897 const type_inst = try typeExpr(gz, scope, params[0]);
...@@ -6906,18 +6901,18 @@ fn builtinCall(...@@ -6906,18 +6901,18 @@ fn builtinCall(
6906 .lhs = type_inst,6901 .lhs = type_inst,
6907 .rhs = options,6902 .rhs = options,
6908 });6903 });
6909 return rvalue(gz, scope, rl, result, node);6904 return rvalue(gz, rl, result, node);
6910 },6905 },
69116906
6912 .breakpoint => return simpleNoOpVoid(gz, scope, rl, node, .breakpoint),6907 .breakpoint => return simpleNoOpVoid(gz, scope, rl, node, .breakpoint),
6913 .fence => return simpleNoOpVoid(gz, scope, rl, node, .fence),6908 .fence => return simpleNoOpVoid(gz, scope, rl, node, .fence),
69146909
6915 .This => return rvalue(gz, scope, rl, try gz.addNodeExtended(.this, node), node),6910 .This => return rvalue(gz, rl, try gz.addNodeExtended(.this, node), node),
6916 .return_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.ret_addr, node), node),6911 .return_address => return rvalue(gz, rl, try gz.addNodeExtended(.ret_addr, node), node),
6917 .src => return rvalue(gz, scope, rl, try gz.addNodeExtended(.builtin_src, node), node),6912 .src => return rvalue(gz, 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),6913 .error_return_trace => return rvalue(gz, rl, try gz.addNodeExtended(.error_return_trace, node), node),
6919 .frame => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame, node), node),6914 .frame => return rvalue(gz, rl, try gz.addNodeExtended(.frame, node), node),
6920 .frame_address => return rvalue(gz, scope, rl, try gz.addNodeExtended(.frame_address, node), node),6915 .frame_address => return rvalue(gz, rl, try gz.addNodeExtended(.frame_address, node), node),
69216916
6922 .type_info => return simpleUnOpType(gz, scope, rl, node, params[0], .type_info),6917 .type_info => return simpleUnOpType(gz, scope, rl, node, params[0], .type_info),
6923 .size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .size_of),6918 .size_of => return simpleUnOpType(gz, scope, rl, node, params[0], .size_of),
...@@ -6973,7 +6968,7 @@ fn builtinCall(...@@ -6973,7 +6968,7 @@ fn builtinCall(
6973 .lhs = dest_align,6968 .lhs = dest_align,
6974 .rhs = rhs,6969 .rhs = rhs,
6975 });6970 });
6976 return rvalue(gz, scope, rl, result, node);6971 return rvalue(gz, rl, result, node);
6977 },6972 },
69786973
6979 .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl),6974 .has_decl => return hasDeclOrField(gz, scope, rl, node, params[0], params[1], .has_decl),
...@@ -7009,7 +7004,7 @@ fn builtinCall(...@@ -7009,7 +7004,7 @@ fn builtinCall(
7009 .node = gz.nodeIndexToRelative(node),7004 .node = gz.nodeIndexToRelative(node),
7010 .operand = operand,7005 .operand = operand,
7011 });7006 });
7012 return rvalue(gz, scope, rl, result, node);7007 return rvalue(gz, rl, result, node);
7013 },7008 },
7014 .wasm_memory_grow => {7009 .wasm_memory_grow => {
7015 const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]);7010 const index_arg = try expr(gz, scope, .{ .ty = .u32_type }, params[0]);
...@@ -7019,7 +7014,7 @@ fn builtinCall(...@@ -7019,7 +7014,7 @@ fn builtinCall(
7019 .lhs = index_arg,7014 .lhs = index_arg,
7020 .rhs = delta_arg,7015 .rhs = delta_arg,
7021 });7016 });
7022 return rvalue(gz, scope, rl, result, node);7017 return rvalue(gz, rl, result, node);
7023 },7018 },
7024 .c_define => {7019 .c_define => {
7025 const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[0]);7020 const name = try comptimeExpr(gz, scope, .{ .ty = .const_slice_u8_type }, params[0]);
...@@ -7029,7 +7024,7 @@ fn builtinCall(...@@ -7029,7 +7024,7 @@ fn builtinCall(
7029 .lhs = name,7024 .lhs = name,
7030 .rhs = value,7025 .rhs = value,
7031 });7026 });
7032 return rvalue(gz, scope, rl, result, node);7027 return rvalue(gz, rl, result, node);
7033 },7028 },
70347029
7035 .splat => {7030 .splat => {
...@@ -7039,7 +7034,7 @@ fn builtinCall(...@@ -7039,7 +7034,7 @@ fn builtinCall(
7039 .lhs = len,7034 .lhs = len,
7040 .rhs = scalar,7035 .rhs = scalar,
7041 });7036 });
7042 return rvalue(gz, scope, rl, result, node);7037 return rvalue(gz, rl, result, node);
7043 },7038 },
7044 .reduce => {7039 .reduce => {
7045 const op = try expr(gz, scope, .{ .ty = .reduce_op_type }, params[0]);7040 const op = try expr(gz, scope, .{ .ty = .reduce_op_type }, params[0]);
...@@ -7048,7 +7043,7 @@ fn builtinCall(...@@ -7048,7 +7043,7 @@ fn builtinCall(
7048 .lhs = op,7043 .lhs = op,
7049 .rhs = scalar,7044 .rhs = scalar,
7050 });7045 });
7051 return rvalue(gz, scope, rl, result, node);7046 return rvalue(gz, rl, result, node);
7052 },7047 },
70537048
7054 .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow),7049 .add_with_overflow => return overflowArithmetic(gz, scope, rl, node, params, .add_with_overflow),
...@@ -7075,7 +7070,7 @@ fn builtinCall(...@@ -7075,7 +7070,7 @@ fn builtinCall(
7075 .rhs = rhs,7070 .rhs = rhs,
7076 .ptr = ptr,7071 .ptr = ptr,
7077 });7072 });
7078 return rvalue(gz, scope, rl, result, node);7073 return rvalue(gz, rl, result, node);
7079 },7074 },
70807075
7081 .atomic_load => {7076 .atomic_load => {
...@@ -7095,7 +7090,7 @@ fn builtinCall(...@@ -7095,7 +7090,7 @@ fn builtinCall(
7095 .lhs = ptr,7090 .lhs = ptr,
7096 .rhs = ordering,7091 .rhs = ordering,
7097 });7092 });
7098 return rvalue(gz, scope, rl, result, node);7093 return rvalue(gz, rl, result, node);
7099 },7094 },
7100 .atomic_rmw => {7095 .atomic_rmw => {
7101 const int_type = try typeExpr(gz, scope, params[0]);7096 const int_type = try typeExpr(gz, scope, params[0]);
...@@ -7118,7 +7113,7 @@ fn builtinCall(...@@ -7118,7 +7113,7 @@ fn builtinCall(
7118 .operand = operand,7113 .operand = operand,
7119 .ordering = ordering,7114 .ordering = ordering,
7120 });7115 });
7121 return rvalue(gz, scope, rl, result, node);7116 return rvalue(gz, rl, result, node);
7122 },7117 },
7123 .atomic_store => {7118 .atomic_store => {
7124 const int_type = try typeExpr(gz, scope, params[0]);7119 const int_type = try typeExpr(gz, scope, params[0]);
...@@ -7139,7 +7134,7 @@ fn builtinCall(...@@ -7139,7 +7134,7 @@ fn builtinCall(
7139 .operand = operand,7134 .operand = operand,
7140 .ordering = ordering,7135 .ordering = ordering,
7141 });7136 });
7142 return rvalue(gz, scope, rl, result, node);7137 return rvalue(gz, rl, result, node);
7143 },7138 },
7144 .mul_add => {7139 .mul_add => {
7145 const float_type = try typeExpr(gz, scope, params[0]);7140 const float_type = try typeExpr(gz, scope, params[0]);
...@@ -7151,7 +7146,7 @@ fn builtinCall(...@@ -7151,7 +7146,7 @@ fn builtinCall(
7151 .mulend2 = mulend2,7146 .mulend2 = mulend2,
7152 .addend = addend,7147 .addend = addend,
7153 });7148 });
7154 return rvalue(gz, scope, rl, result, node);7149 return rvalue(gz, rl, result, node);
7155 },7150 },
7156 .call => {7151 .call => {
7157 const options = try comptimeExpr(gz, scope, .{ .ty = .call_options_type }, params[0]);7152 const options = try comptimeExpr(gz, scope, .{ .ty = .call_options_type }, params[0]);
...@@ -7162,7 +7157,7 @@ fn builtinCall(...@@ -7162,7 +7157,7 @@ fn builtinCall(
7162 .callee = callee,7157 .callee = callee,
7163 .args = args,7158 .args = args,
7164 });7159 });
7165 return rvalue(gz, scope, rl, result, node);7160 return rvalue(gz, rl, result, node);
7166 },7161 },
7167 .field_parent_ptr => {7162 .field_parent_ptr => {
7168 const parent_type = try typeExpr(gz, scope, params[0]);7163 const parent_type = try typeExpr(gz, scope, params[0]);
...@@ -7173,7 +7168,7 @@ fn builtinCall(...@@ -7173,7 +7168,7 @@ fn builtinCall(
7173 .field_name = field_name,7168 .field_name = field_name,
7174 .field_ptr = try expr(gz, scope, .{ .ty = field_ptr_type }, params[2]),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 .memcpy => {7173 .memcpy => {
7179 const result = try gz.addPlNode(.memcpy, node, Zir.Inst.Memcpy{7174 const result = try gz.addPlNode(.memcpy, node, Zir.Inst.Memcpy{
...@@ -7181,7 +7176,7 @@ fn builtinCall(...@@ -7181,7 +7176,7 @@ fn builtinCall(
7181 .source = try expr(gz, scope, .{ .ty = .manyptr_const_u8_type }, params[1]),7176 .source = try expr(gz, scope, .{ .ty = .manyptr_const_u8_type }, params[1]),
7182 .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]),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 .memset => {7181 .memset => {
7187 const result = try gz.addPlNode(.memset, node, Zir.Inst.Memset{7182 const result = try gz.addPlNode(.memset, node, Zir.Inst.Memset{
...@@ -7189,7 +7184,7 @@ fn builtinCall(...@@ -7189,7 +7184,7 @@ fn builtinCall(
7189 .byte = try expr(gz, scope, .{ .ty = .u8_type }, params[1]),7184 .byte = try expr(gz, scope, .{ .ty = .u8_type }, params[1]),
7190 .byte_count = try expr(gz, scope, .{ .ty = .usize_type }, params[2]),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 .shuffle => {7189 .shuffle => {
7195 const result = try gz.addPlNode(.shuffle, node, Zir.Inst.Shuffle{7190 const result = try gz.addPlNode(.shuffle, node, Zir.Inst.Shuffle{
...@@ -7198,7 +7193,7 @@ fn builtinCall(...@@ -7198,7 +7193,7 @@ fn builtinCall(
7198 .b = try expr(gz, scope, .none, params[2]),7193 .b = try expr(gz, scope, .none, params[2]),
7199 .mask = try comptimeExpr(gz, scope, .none, params[3]),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 .async_call => {7198 .async_call => {
7204 const result = try gz.addPlNode(.builtin_async_call, node, Zir.Inst.AsyncCall{7199 const result = try gz.addPlNode(.builtin_async_call, node, Zir.Inst.AsyncCall{
...@@ -7207,14 +7202,14 @@ fn builtinCall(...@@ -7207,14 +7202,14 @@ fn builtinCall(
7207 .fn_ptr = try expr(gz, scope, .none, params[2]),7202 .fn_ptr = try expr(gz, scope, .none, params[2]),
7208 .args = try expr(gz, scope, .none, params[3]),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 .Vector => {7207 .Vector => {
7213 const result = try gz.addPlNode(.vector_type, node, Zir.Inst.Bin{7208 const result = try gz.addPlNode(.vector_type, node, Zir.Inst.Bin{
7214 .lhs = try comptimeExpr(gz, scope, .{.ty = .u32_type}, params[0]),7209 .lhs = try comptimeExpr(gz, scope, .{.ty = .u32_type}, params[0]),
7215 .rhs = try typeExpr(gz, scope, params[1]),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 },
72197214
7220 }7215 }
...@@ -7229,7 +7224,7 @@ fn simpleNoOpVoid(...@@ -7229,7 +7224,7 @@ fn simpleNoOpVoid(
7229 tag: Zir.Inst.Tag,7224 tag: Zir.Inst.Tag,
7230) InnerError!Zir.Inst.Ref {7225) InnerError!Zir.Inst.Ref {
7231 _ = try gz.addNode(tag, node);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}
72347229
7235fn hasDeclOrField(7230fn hasDeclOrField(
...@@ -7247,7 +7242,7 @@ fn hasDeclOrField(...@@ -7247,7 +7242,7 @@ fn hasDeclOrField(
7247 .lhs = container_type,7242 .lhs = container_type,
7248 .rhs = name,7243 .rhs = name,
7249 });7244 });
7250 return rvalue(gz, scope, rl, result, node);7245 return rvalue(gz, rl, result, node);
7251}7246}
72527247
7253fn typeCast(7248fn typeCast(
...@@ -7263,7 +7258,7 @@ fn typeCast(...@@ -7263,7 +7258,7 @@ fn typeCast(
7263 .lhs = try typeExpr(gz, scope, lhs_node),7258 .lhs = try typeExpr(gz, scope, lhs_node),
7264 .rhs = try expr(gz, scope, .none, rhs_node),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}
72687263
7269fn simpleUnOpType(7264fn simpleUnOpType(
...@@ -7276,7 +7271,7 @@ fn simpleUnOpType(...@@ -7276,7 +7271,7 @@ fn simpleUnOpType(
7276) InnerError!Zir.Inst.Ref {7271) InnerError!Zir.Inst.Ref {
7277 const operand = try typeExpr(gz, scope, operand_node);7272 const operand = try typeExpr(gz, scope, operand_node);
7278 const result = try gz.addUnNode(tag, operand, node);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}
72817276
7282fn simpleUnOp(7277fn simpleUnOp(
...@@ -7290,7 +7285,7 @@ fn simpleUnOp(...@@ -7290,7 +7285,7 @@ fn simpleUnOp(
7290) InnerError!Zir.Inst.Ref {7285) InnerError!Zir.Inst.Ref {
7291 const operand = try expr(gz, scope, operand_rl, operand_node);7286 const operand = try expr(gz, scope, operand_rl, operand_node);
7292 const result = try gz.addUnNode(tag, operand, node);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}
72957290
7296fn cmpxchg(7291fn cmpxchg(
...@@ -7320,7 +7315,7 @@ fn cmpxchg(...@@ -7320,7 +7315,7 @@ fn cmpxchg(
7320 .fail_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[5]),7315 .fail_order = try expr(gz, scope, .{ .ty = .atomic_ordering_type }, params[5]),
7321 // zig fmt: on7316 // zig fmt: on
7322 });7317 });
7323 return rvalue(gz, scope, rl, result, node);7318 return rvalue(gz, rl, result, node);
7324}7319}
73257320
7326fn bitBuiltin(7321fn bitBuiltin(
...@@ -7335,7 +7330,7 @@ fn bitBuiltin(...@@ -7335,7 +7330,7 @@ fn bitBuiltin(
7335 const int_type = try typeExpr(gz, scope, int_type_node);7330 const int_type = try typeExpr(gz, scope, int_type_node);
7336 const operand = try expr(gz, scope, .{ .ty = int_type }, operand_node);7331 const operand = try expr(gz, scope, .{ .ty = int_type }, operand_node);
7337 const result = try gz.addUnNode(tag, operand, node);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}
73407335
7341fn divBuiltin(7336fn divBuiltin(
...@@ -7351,7 +7346,7 @@ fn divBuiltin(...@@ -7351,7 +7346,7 @@ fn divBuiltin(
7351 .lhs = try expr(gz, scope, .none, lhs_node),7346 .lhs = try expr(gz, scope, .none, lhs_node),
7352 .rhs = try expr(gz, scope, .none, rhs_node),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}
73567351
7357fn simpleCBuiltin(7352fn simpleCBuiltin(
...@@ -7367,7 +7362,7 @@ fn simpleCBuiltin(...@@ -7367,7 +7362,7 @@ fn simpleCBuiltin(
7367 .node = gz.nodeIndexToRelative(node),7362 .node = gz.nodeIndexToRelative(node),
7368 .operand = operand,7363 .operand = operand,
7369 });7364 });
7370 return rvalue(gz, scope, rl, .void_value, node);7365 return rvalue(gz, rl, .void_value, node);
7371}7366}
73727367
7373fn offsetOf(7368fn offsetOf(
...@@ -7385,7 +7380,7 @@ fn offsetOf(...@@ -7385,7 +7380,7 @@ fn offsetOf(
7385 .lhs = type_inst,7380 .lhs = type_inst,
7386 .rhs = field_name,7381 .rhs = field_name,
7387 });7382 });
7388 return rvalue(gz, scope, rl, result, node);7383 return rvalue(gz, rl, result, node);
7389}7384}
73907385
7391fn shiftOp(7386fn shiftOp(
...@@ -7404,7 +7399,7 @@ fn shiftOp(...@@ -7404,7 +7399,7 @@ fn shiftOp(
7404 .lhs = lhs,7399 .lhs = lhs,
7405 .rhs = rhs,7400 .rhs = rhs,
7406 });7401 });
7407 return rvalue(gz, scope, rl, result, node);7402 return rvalue(gz, rl, result, node);
7408}7403}
74097404
7410fn cImport(7405fn cImport(
...@@ -7429,7 +7424,7 @@ fn cImport(...@@ -7429,7 +7424,7 @@ fn cImport(
7429 try block_scope.setBlockBody(block_inst);7424 try block_scope.setBlockBody(block_inst);
7430 try gz.instructions.append(gpa, block_inst);7425 try gz.instructions.append(gpa, block_inst);
74317426
7432 return rvalue(gz, scope, rl, .void_value, node);7427 return rvalue(gz, rl, .void_value, node);
7433}7428}
74347429
7435fn overflowArithmetic(7430fn overflowArithmetic(
...@@ -7459,7 +7454,7 @@ fn overflowArithmetic(...@@ -7459,7 +7454,7 @@ fn overflowArithmetic(
7459 .rhs = rhs,7454 .rhs = rhs,
7460 .ptr = ptr,7455 .ptr = ptr,
7461 });7456 });
7462 return rvalue(gz, scope, rl, result, node);7457 return rvalue(gz, rl, result, node);
7463}7458}
74647459
7465fn callExpr(7460fn callExpr(
...@@ -7511,7 +7506,7 @@ fn callExpr(...@@ -7511,7 +7506,7 @@ fn callExpr(
7511 };7506 };
7512 break :res try gz.addCall(tag, lhs, args, node);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 location7509 return rvalue(gz, rl, result, node); // TODO function call with result location
7515}7510}
75167511
7517pub const simple_types = std.ComptimeStringMap(Zir.Inst.Ref, .{7512pub 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,12 +7982,10 @@ fn nodeMayEvalToError(tree: *const ast.Tree, start_node: ast.Node.Index) enum {
7987/// If the `ResultLoc` is `ty`, it will coerce the result to the type.7982/// If the `ResultLoc` is `ty`, it will coerce the result to the type.
7988fn rvalue(7983fn rvalue(
7989 gz: *GenZir,7984 gz: *GenZir,
7990 scope: *Scope,
7991 rl: ResultLoc,7985 rl: ResultLoc,
7992 result: Zir.Inst.Ref,7986 result: Zir.Inst.Ref,
7993 src_node: ast.Node.Index,7987 src_node: ast.Node.Index,
7994) InnerError!Zir.Inst.Ref {7988) InnerError!Zir.Inst.Ref {
7995 _ = scope;
7996 switch (rl) {7989 switch (rl) {
7997 .none, .none_or_ref => return result,7990 .none, .none_or_ref => return result,
7998 .discard => {7991 .discard => {