| ... | @@ -36,7 +36,7 @@ func: ?*Module.Fn, | ... | @@ -36,7 +36,7 @@ func: ?*Module.Fn, |
| 36 | /// > Denormalized data to make `resolveInst` faster. This is 0 if not inside a function, | 36 | /// > Denormalized data to make `resolveInst` faster. This is 0 if not inside a function, |
| 37 | /// > otherwise it is the number of parameters of the function. | 37 | /// > otherwise it is the number of parameters of the function. |
| 38 | /// > param_count: u32 | 38 | /// > param_count: u32 |
| 39 | param_inst_list: []const Air.Inst.Index, | 39 | param_inst_list: []const Air.Inst.Ref, |
| 40 | branch_quota: u32 = 1000, | 40 | branch_quota: u32 = 1000, |
| 41 | branch_count: u32 = 0, | 41 | branch_count: u32 = 0, |
| 42 | /// This field is updated when a new source location becomes active, so that | 42 | /// This field is updated when a new source location becomes active, so that |
| ... | @@ -59,8 +59,6 @@ const TypedValue = @import("TypedValue.zig"); | ... | @@ -59,8 +59,6 @@ const TypedValue = @import("TypedValue.zig"); |
| 59 | const Air = @import("Air.zig"); | 59 | const Air = @import("Air.zig"); |
| 60 | const Zir = @import("Zir.zig"); | 60 | const Zir = @import("Zir.zig"); |
| 61 | const Module = @import("Module.zig"); | 61 | const Module = @import("Module.zig"); |
| 62 | const Inst = ir.Inst; | | |
| 63 | const Body = ir.Body; | | |
| 64 | const trace = @import("tracy.zig").trace; | 62 | const trace = @import("tracy.zig").trace; |
| 65 | const Scope = Module.Scope; | 63 | const Scope = Module.Scope; |
| 66 | const InnerError = Module.InnerError; | 64 | const InnerError = Module.InnerError; |
| ... | @@ -117,7 +115,7 @@ pub fn analyzeFnBody( | ... | @@ -117,7 +115,7 @@ pub fn analyzeFnBody( |
| 117 | /// Returns only the result from the body that is specified. | 115 | /// Returns only the result from the body that is specified. |
| 118 | /// Only appropriate to call when it is determined at comptime that this body | 116 | /// Only appropriate to call when it is determined at comptime that this body |
| 119 | /// has no peers. | 117 | /// has no peers. |
| 120 | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!Air.Inst.Index { | 118 | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 121 | const break_inst = try sema.analyzeBody(block, body); | 119 | const break_inst = try sema.analyzeBody(block, body); |
| 122 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; | 120 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 123 | return sema.resolveInst(operand_ref); | 121 | return sema.resolveInst(operand_ref); |
| ... | @@ -513,7 +511,7 @@ pub fn analyzeBody( | ... | @@ -513,7 +511,7 @@ pub fn analyzeBody( |
| 513 | // const break_inst = try sema.analyzeBody(block, inline_body); | 511 | // const break_inst = try sema.analyzeBody(block, inline_body); |
| 514 | // const break_data = datas[break_inst].@"break"; | 512 | // const break_data = datas[break_inst].@"break"; |
| 515 | // if (inst == break_data.block_inst) { | 513 | // if (inst == break_data.block_inst) { |
| 516 | // break :blk try sema.resolveInst(break_data.operand); | 514 | // break :blk sema.resolveInst(break_data.operand); |
| 517 | // } else { | 515 | // } else { |
| 518 | // return break_inst; | 516 | // return break_inst; |
| 519 | // } | 517 | // } |
| ... | @@ -529,12 +527,12 @@ pub fn analyzeBody( | ... | @@ -529,12 +527,12 @@ pub fn analyzeBody( |
| 529 | // const break_inst = try sema.analyzeBody(block, inline_body); | 527 | // const break_inst = try sema.analyzeBody(block, inline_body); |
| 530 | // const break_data = datas[break_inst].@"break"; | 528 | // const break_data = datas[break_inst].@"break"; |
| 531 | // if (inst == break_data.block_inst) { | 529 | // if (inst == break_data.block_inst) { |
| 532 | // break :blk try sema.resolveInst(break_data.operand); | 530 | // break :blk sema.resolveInst(break_data.operand); |
| 533 | // } else { | 531 | // } else { |
| 534 | // return break_inst; | 532 | // return break_inst; |
| 535 | // } | 533 | // } |
| 536 | //}, | 534 | //}, |
| 537 | else => @panic("TODO remove else prong"), | 535 | else => @panic("TODO finish updating Sema for AIR memory layout changes and then remove this else prong"), |
| 538 | }; | 536 | }; |
| 539 | if (sema.getAirType(air_inst).isNoReturn()) | 537 | if (sema.getAirType(air_inst).isNoReturn()) |
| 540 | return always_noreturn; | 538 | return always_noreturn; |
| ... | @@ -543,7 +541,7 @@ pub fn analyzeBody( | ... | @@ -543,7 +541,7 @@ pub fn analyzeBody( |
| 543 | } | 541 | } |
| 544 | } | 542 | } |
| 545 | | 543 | |
| 546 | fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 544 | fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 547 | const extended = sema.code.instructions.items(.data)[inst].extended; | 545 | const extended = sema.code.instructions.items(.data)[inst].extended; |
| 548 | switch (extended.opcode) { | 546 | switch (extended.opcode) { |
| 549 | // zig fmt: off | 547 | // zig fmt: off |
| ... | @@ -598,7 +596,7 @@ fn resolveConstBool( | ... | @@ -598,7 +596,7 @@ fn resolveConstBool( |
| 598 | src: LazySrcLoc, | 596 | src: LazySrcLoc, |
| 599 | zir_ref: Zir.Inst.Ref, | 597 | zir_ref: Zir.Inst.Ref, |
| 600 | ) !bool { | 598 | ) !bool { |
| 601 | const air_inst = try sema.resolveInst(zir_ref); | 599 | const air_inst = sema.resolveInst(zir_ref); |
| 602 | const wanted_type = Type.initTag(.bool); | 600 | const wanted_type = Type.initTag(.bool); |
| 603 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 601 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 604 | const val = try sema.resolveConstValue(block, src, coerced_inst); | 602 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| ... | @@ -611,7 +609,7 @@ fn resolveConstString( | ... | @@ -611,7 +609,7 @@ fn resolveConstString( |
| 611 | src: LazySrcLoc, | 609 | src: LazySrcLoc, |
| 612 | zir_ref: Zir.Inst.Ref, | 610 | zir_ref: Zir.Inst.Ref, |
| 613 | ) ![]u8 { | 611 | ) ![]u8 { |
| 614 | const air_inst = try sema.resolveInst(zir_ref); | 612 | const air_inst = sema.resolveInst(zir_ref); |
| 615 | const wanted_type = Type.initTag(.const_slice_u8); | 613 | const wanted_type = Type.initTag(.const_slice_u8); |
| 616 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 614 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 617 | const val = try sema.resolveConstValue(block, src, coerced_inst); | 615 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| ... | @@ -619,24 +617,39 @@ fn resolveConstString( | ... | @@ -619,24 +617,39 @@ fn resolveConstString( |
| 619 | } | 617 | } |
| 620 | | 618 | |
| 621 | pub fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { | 619 | pub fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { |
| 622 | const air_inst = try sema.resolveInst(zir_ref); | 620 | const air_inst = sema.resolveInst(zir_ref); |
| 623 | return sema.resolveAirAsType(block, src, air_inst); | 621 | return sema.resolveAirAsType(block, src, air_inst); |
| 624 | } | 622 | } |
| 625 | | 623 | |
| 626 | fn resolveAirAsType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, air_inst: Air.Inst.Index) !Type { | 624 | fn resolveAirAsType( |
| | 625 | sema: *Sema, |
| | 626 | block: *Scope.Block, |
| | 627 | src: LazySrcLoc, |
| | 628 | air_inst: Air.Inst.Ref, |
| | 629 | ) !Type { |
| 627 | const wanted_type = Type.initTag(.@"type"); | 630 | const wanted_type = Type.initTag(.@"type"); |
| 628 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 631 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 629 | const val = try sema.resolveConstValue(block, src, coerced_inst); | 632 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| 630 | return val.toType(sema.arena); | 633 | return val.toType(sema.arena); |
| 631 | } | 634 | } |
| 632 | | 635 | |
| 633 | fn resolveConstValue(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, base: Air.Inst.Index) !Value { | 636 | fn resolveConstValue( |
| 634 | return (try sema.resolveDefinedValue(block, src, base)) orelse | 637 | sema: *Sema, |
| | 638 | block: *Scope.Block, |
| | 639 | src: LazySrcLoc, |
| | 640 | air_ref: Air.Inst.Ref, |
| | 641 | ) !Value { |
| | 642 | return (try sema.resolveDefinedValue(block, src, air_ref)) orelse |
| 635 | return sema.failWithNeededComptime(block, src); | 643 | return sema.failWithNeededComptime(block, src); |
| 636 | } | 644 | } |
| 637 | | 645 | |
| 638 | fn resolveDefinedValue(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, base: Air.Inst.Index) !?Value { | 646 | fn resolveDefinedValue( |
| 639 | if (try sema.resolvePossiblyUndefinedValue(block, src, base)) |val| { | 647 | sema: *Sema, |
| | 648 | block: *Scope.Block, |
| | 649 | src: LazySrcLoc, |
| | 650 | air_ref: Air.Inst.Ref, |
| | 651 | ) !?Value { |
| | 652 | if (try sema.resolvePossiblyUndefinedValue(block, src, air_ref)) |val| { |
| 640 | if (val.isUndef()) { | 653 | if (val.isUndef()) { |
| 641 | return sema.failWithUseOfUndef(block, src); | 654 | return sema.failWithUseOfUndef(block, src); |
| 642 | } | 655 | } |
| ... | @@ -649,13 +662,29 @@ fn resolvePossiblyUndefinedValue( | ... | @@ -649,13 +662,29 @@ fn resolvePossiblyUndefinedValue( |
| 649 | sema: *Sema, | 662 | sema: *Sema, |
| 650 | block: *Scope.Block, | 663 | block: *Scope.Block, |
| 651 | src: LazySrcLoc, | 664 | src: LazySrcLoc, |
| 652 | base: Air.Inst.Index, | 665 | air_ref: Air.Inst.Ref, |
| 653 | ) !?Value { | 666 | ) !?Value { |
| 654 | if (try sema.typeHasOnePossibleValue(block, src, base.ty)) |opv| { | 667 | const ty = sema.getTypeOfAirRef(air_ref); |
| | 668 | if (try sema.typeHasOnePossibleValue(block, src, ty)) |opv| { |
| 655 | return opv; | 669 | return opv; |
| 656 | } | 670 | } |
| 657 | const inst = base.castTag(.constant) orelse return null; | 671 | // First section of indexes correspond to a set number of constant values. |
| 658 | return inst.val; | 672 | var i: usize = @enumToInt(air_ref); |
| | 673 | if (i < Air.Inst.Ref.typed_value_map.len) { |
| | 674 | return Air.Inst.Ref.typed_value_map[i].val; |
| | 675 | } |
| | 676 | i -= Air.Inst.Ref.typed_value_map.len; |
| | 677 | |
| | 678 | switch (sema.air_instructions.items(.tag)[i]) { |
| | 679 | .constant => { |
| | 680 | const ty_pl = sema.air_instructions.items(.data)[i].ty_pl; |
| | 681 | return sema.air_values.items[ty_pl.payload]; |
| | 682 | }, |
| | 683 | .const_ty => { |
| | 684 | return sema.air_instructions.items(.data)[i].ty.toValue(undefined) catch unreachable; |
| | 685 | }, |
| | 686 | else => return null, |
| | 687 | } |
| 659 | } | 688 | } |
| 660 | | 689 | |
| 661 | fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) InnerError { | 690 | fn failWithNeededComptime(sema: *Sema, block: *Scope.Block, src: LazySrcLoc) InnerError { |
| ... | @@ -677,7 +706,7 @@ fn resolveAlreadyCoercedInt( | ... | @@ -677,7 +706,7 @@ fn resolveAlreadyCoercedInt( |
| 677 | comptime Int: type, | 706 | comptime Int: type, |
| 678 | ) !Int { | 707 | ) !Int { |
| 679 | comptime assert(@typeInfo(Int).Int.bits <= 64); | 708 | comptime assert(@typeInfo(Int).Int.bits <= 64); |
| 680 | const air_inst = try sema.resolveInst(zir_ref); | 709 | const air_inst = sema.resolveInst(zir_ref); |
| 681 | const val = try sema.resolveConstValue(block, src, air_inst); | 710 | const val = try sema.resolveConstValue(block, src, air_inst); |
| 682 | switch (@typeInfo(Int).Int.signedness) { | 711 | switch (@typeInfo(Int).Int.signedness) { |
| 683 | .signed => return @intCast(Int, val.toSignedInt()), | 712 | .signed => return @intCast(Int, val.toSignedInt()), |
| ... | @@ -692,7 +721,7 @@ fn resolveInt( | ... | @@ -692,7 +721,7 @@ fn resolveInt( |
| 692 | zir_ref: Zir.Inst.Ref, | 721 | zir_ref: Zir.Inst.Ref, |
| 693 | dest_type: Type, | 722 | dest_type: Type, |
| 694 | ) !u64 { | 723 | ) !u64 { |
| 695 | const air_inst = try sema.resolveInst(zir_ref); | 724 | const air_inst = sema.resolveInst(zir_ref); |
| 696 | const coerced = try sema.coerce(block, dest_type, air_inst, src); | 725 | const coerced = try sema.coerce(block, dest_type, air_inst, src); |
| 697 | const val = try sema.resolveConstValue(block, src, coerced); | 726 | const val = try sema.resolveConstValue(block, src, coerced); |
| 698 | | 727 | |
| ... | @@ -705,21 +734,21 @@ pub fn resolveInstConst( | ... | @@ -705,21 +734,21 @@ pub fn resolveInstConst( |
| 705 | src: LazySrcLoc, | 734 | src: LazySrcLoc, |
| 706 | zir_ref: Zir.Inst.Ref, | 735 | zir_ref: Zir.Inst.Ref, |
| 707 | ) InnerError!TypedValue { | 736 | ) InnerError!TypedValue { |
| 708 | const air_inst = try sema.resolveInst(zir_ref); | 737 | const air_ref = sema.resolveInst(zir_ref); |
| 709 | const val = try sema.resolveConstValue(block, src, air_inst); | 738 | const val = try sema.resolveConstValue(block, src, air_ref); |
| 710 | return TypedValue{ | 739 | return TypedValue{ |
| 711 | .ty = air_inst.ty, | 740 | .ty = sema.getTypeOfAirRef(air_ref), |
| 712 | .val = val, | 741 | .val = val, |
| 713 | }; | 742 | }; |
| 714 | } | 743 | } |
| 715 | | 744 | |
| 716 | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 745 | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 717 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 746 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 718 | const src = inst_data.src(); | 747 | const src = inst_data.src(); |
| 719 | return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); | 748 | return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); |
| 720 | } | 749 | } |
| 721 | | 750 | |
| 722 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 751 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 723 | _ = inst; | 752 | _ = inst; |
| 724 | const tracy = trace(@src()); | 753 | const tracy = trace(@src()); |
| 725 | defer tracy.end(); | 754 | defer tracy.end(); |
| ... | @@ -754,7 +783,7 @@ fn zirStructDecl( | ... | @@ -754,7 +783,7 @@ fn zirStructDecl( |
| 754 | block: *Scope.Block, | 783 | block: *Scope.Block, |
| 755 | extended: Zir.Inst.Extended.InstData, | 784 | extended: Zir.Inst.Extended.InstData, |
| 756 | inst: Zir.Inst.Index, | 785 | inst: Zir.Inst.Index, |
| 757 | ) InnerError!Air.Inst.Index { | 786 | ) InnerError!Air.Inst.Ref { |
| 758 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); | 787 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); |
| 759 | const src: LazySrcLoc = if (small.has_src_node) blk: { | 788 | const src: LazySrcLoc = if (small.has_src_node) blk: { |
| 760 | const node_offset = @bitCast(i32, sema.code.extra[extended.operand]); | 789 | const node_offset = @bitCast(i32, sema.code.extra[extended.operand]); |
| ... | @@ -825,7 +854,7 @@ fn zirEnumDecl( | ... | @@ -825,7 +854,7 @@ fn zirEnumDecl( |
| 825 | sema: *Sema, | 854 | sema: *Sema, |
| 826 | block: *Scope.Block, | 855 | block: *Scope.Block, |
| 827 | extended: Zir.Inst.Extended.InstData, | 856 | extended: Zir.Inst.Extended.InstData, |
| 828 | ) InnerError!Air.Inst.Index { | 857 | ) InnerError!Air.Inst.Ref { |
| 829 | const tracy = trace(@src()); | 858 | const tracy = trace(@src()); |
| 830 | defer tracy.end(); | 859 | defer tracy.end(); |
| 831 | | 860 | |
| ... | @@ -1022,7 +1051,7 @@ fn zirUnionDecl( | ... | @@ -1022,7 +1051,7 @@ fn zirUnionDecl( |
| 1022 | block: *Scope.Block, | 1051 | block: *Scope.Block, |
| 1023 | extended: Zir.Inst.Extended.InstData, | 1052 | extended: Zir.Inst.Extended.InstData, |
| 1024 | inst: Zir.Inst.Index, | 1053 | inst: Zir.Inst.Index, |
| 1025 | ) InnerError!Air.Inst.Index { | 1054 | ) InnerError!Air.Inst.Ref { |
| 1026 | const tracy = trace(@src()); | 1055 | const tracy = trace(@src()); |
| 1027 | defer tracy.end(); | 1056 | defer tracy.end(); |
| 1028 | | 1057 | |
| ... | @@ -1086,7 +1115,7 @@ fn zirOpaqueDecl( | ... | @@ -1086,7 +1115,7 @@ fn zirOpaqueDecl( |
| 1086 | block: *Scope.Block, | 1115 | block: *Scope.Block, |
| 1087 | inst: Zir.Inst.Index, | 1116 | inst: Zir.Inst.Index, |
| 1088 | name_strategy: Zir.Inst.NameStrategy, | 1117 | name_strategy: Zir.Inst.NameStrategy, |
| 1089 | ) InnerError!Air.Inst.Index { | 1118 | ) InnerError!Air.Inst.Ref { |
| 1090 | const tracy = trace(@src()); | 1119 | const tracy = trace(@src()); |
| 1091 | defer tracy.end(); | 1120 | defer tracy.end(); |
| 1092 | | 1121 | |
| ... | @@ -1106,7 +1135,7 @@ fn zirErrorSetDecl( | ... | @@ -1106,7 +1135,7 @@ fn zirErrorSetDecl( |
| 1106 | block: *Scope.Block, | 1135 | block: *Scope.Block, |
| 1107 | inst: Zir.Inst.Index, | 1136 | inst: Zir.Inst.Index, |
| 1108 | name_strategy: Zir.Inst.NameStrategy, | 1137 | name_strategy: Zir.Inst.NameStrategy, |
| 1109 | ) InnerError!Air.Inst.Index { | 1138 | ) InnerError!Air.Inst.Ref { |
| 1110 | const tracy = trace(@src()); | 1139 | const tracy = trace(@src()); |
| 1111 | defer tracy.end(); | 1140 | defer tracy.end(); |
| 1112 | | 1141 | |
| ... | @@ -1146,7 +1175,7 @@ fn zirRetPtr( | ... | @@ -1146,7 +1175,7 @@ fn zirRetPtr( |
| 1146 | sema: *Sema, | 1175 | sema: *Sema, |
| 1147 | block: *Scope.Block, | 1176 | block: *Scope.Block, |
| 1148 | extended: Zir.Inst.Extended.InstData, | 1177 | extended: Zir.Inst.Extended.InstData, |
| 1149 | ) InnerError!Air.Inst.Index { | 1178 | ) InnerError!Air.Inst.Ref { |
| 1150 | const tracy = trace(@src()); | 1179 | const tracy = trace(@src()); |
| 1151 | defer tracy.end(); | 1180 | defer tracy.end(); |
| 1152 | | 1181 | |
| ... | @@ -1154,16 +1183,16 @@ fn zirRetPtr( | ... | @@ -1154,16 +1183,16 @@ fn zirRetPtr( |
| 1154 | try sema.requireFunctionBlock(block, src); | 1183 | try sema.requireFunctionBlock(block, src); |
| 1155 | const fn_ty = sema.func.?.owner_decl.ty; | 1184 | const fn_ty = sema.func.?.owner_decl.ty; |
| 1156 | const ret_type = fn_ty.fnReturnType(); | 1185 | const ret_type = fn_ty.fnReturnType(); |
| 1157 | const ptr_type = try sema.mod.simplePtrType(sema.arena, ret_type, true, .One); | 1186 | const ptr_type = try Module.simplePtrType(sema.arena, ret_type, true, .One); |
| 1158 | return block.addNoOp(src, ptr_type, .alloc); | 1187 | return block.addNoOp(src, ptr_type, .alloc); |
| 1159 | } | 1188 | } |
| 1160 | | 1189 | |
| 1161 | fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1190 | fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1162 | const tracy = trace(@src()); | 1191 | const tracy = trace(@src()); |
| 1163 | defer tracy.end(); | 1192 | defer tracy.end(); |
| 1164 | | 1193 | |
| 1165 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; | 1194 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 1166 | const operand = try sema.resolveInst(inst_data.operand); | 1195 | const operand = sema.resolveInst(inst_data.operand); |
| 1167 | return sema.analyzeRef(block, inst_data.src(), operand); | 1196 | return sema.analyzeRef(block, inst_data.src(), operand); |
| 1168 | } | 1197 | } |
| 1169 | | 1198 | |
| ... | @@ -1171,7 +1200,7 @@ fn zirRetType( | ... | @@ -1171,7 +1200,7 @@ fn zirRetType( |
| 1171 | sema: *Sema, | 1200 | sema: *Sema, |
| 1172 | block: *Scope.Block, | 1201 | block: *Scope.Block, |
| 1173 | extended: Zir.Inst.Extended.InstData, | 1202 | extended: Zir.Inst.Extended.InstData, |
| 1174 | ) InnerError!Air.Inst.Index { | 1203 | ) InnerError!Air.Inst.Ref { |
| 1175 | const tracy = trace(@src()); | 1204 | const tracy = trace(@src()); |
| 1176 | defer tracy.end(); | 1205 | defer tracy.end(); |
| 1177 | | 1206 | |
| ... | @@ -1187,7 +1216,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I | ... | @@ -1187,7 +1216,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I |
| 1187 | defer tracy.end(); | 1216 | defer tracy.end(); |
| 1188 | | 1217 | |
| 1189 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 1218 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1190 | const operand = try sema.resolveInst(inst_data.operand); | 1219 | const operand = sema.resolveInst(inst_data.operand); |
| 1191 | const src = inst_data.src(); | 1220 | const src = inst_data.src(); |
| 1192 | | 1221 | |
| 1193 | return sema.ensureResultUsed(block, operand, src); | 1222 | return sema.ensureResultUsed(block, operand, src); |
| ... | @@ -1196,7 +1225,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I | ... | @@ -1196,7 +1225,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I |
| 1196 | fn ensureResultUsed( | 1225 | fn ensureResultUsed( |
| 1197 | sema: *Sema, | 1226 | sema: *Sema, |
| 1198 | block: *Scope.Block, | 1227 | block: *Scope.Block, |
| 1199 | operand: Air.Inst.Index, | 1228 | operand: Air.Inst.Ref, |
| 1200 | src: LazySrcLoc, | 1229 | src: LazySrcLoc, |
| 1201 | ) InnerError!void { | 1230 | ) InnerError!void { |
| 1202 | switch (operand.ty.zigTypeTag()) { | 1231 | switch (operand.ty.zigTypeTag()) { |
| ... | @@ -1210,7 +1239,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1210,7 +1239,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1210 | defer tracy.end(); | 1239 | defer tracy.end(); |
| 1211 | | 1240 | |
| 1212 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 1241 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1213 | const operand = try sema.resolveInst(inst_data.operand); | 1242 | const operand = sema.resolveInst(inst_data.operand); |
| 1214 | const src = inst_data.src(); | 1243 | const src = inst_data.src(); |
| 1215 | switch (operand.ty.zigTypeTag()) { | 1244 | switch (operand.ty.zigTypeTag()) { |
| 1216 | .ErrorSet, .ErrorUnion => return sema.mod.fail(&block.base, src, "error is discarded", .{}), | 1245 | .ErrorSet, .ErrorUnion => return sema.mod.fail(&block.base, src, "error is discarded", .{}), |
| ... | @@ -1218,13 +1247,13 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1218,13 +1247,13 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1218 | } | 1247 | } |
| 1219 | } | 1248 | } |
| 1220 | | 1249 | |
| 1221 | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1250 | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1222 | const tracy = trace(@src()); | 1251 | const tracy = trace(@src()); |
| 1223 | defer tracy.end(); | 1252 | defer tracy.end(); |
| 1224 | | 1253 | |
| 1225 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 1254 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1226 | const src = inst_data.src(); | 1255 | const src = inst_data.src(); |
| 1227 | const array_ptr = try sema.resolveInst(inst_data.operand); | 1256 | const array_ptr = sema.resolveInst(inst_data.operand); |
| 1228 | | 1257 | |
| 1229 | const elem_ty = array_ptr.ty.elemType(); | 1258 | const elem_ty = array_ptr.ty.elemType(); |
| 1230 | if (!elem_ty.isIndexable()) { | 1259 | if (!elem_ty.isIndexable()) { |
| ... | @@ -1267,7 +1296,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air | ... | @@ -1267,7 +1296,7 @@ fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air |
| 1267 | | 1296 | |
| 1268 | // Set the name of the Air.Arg instruction for use by codegen debug info. | 1297 | // Set the name of the Air.Arg instruction for use by codegen debug info. |
| 1269 | const air_arg = sema.param_inst_list[arg_index]; | 1298 | const air_arg = sema.param_inst_list[arg_index]; |
| 1270 | sema.air_instructions.items(.data)[air_arg].ty_str.str = inst_data.start; | 1299 | sema.air_instructions.items(.data)[refToIndex(air_arg).?].ty_str.str = inst_data.start; |
| 1271 | return air_arg; | 1300 | return air_arg; |
| 1272 | } | 1301 | } |
| 1273 | | 1302 | |
| ... | @@ -1275,13 +1304,13 @@ fn zirAllocExtended( | ... | @@ -1275,13 +1304,13 @@ fn zirAllocExtended( |
| 1275 | sema: *Sema, | 1304 | sema: *Sema, |
| 1276 | block: *Scope.Block, | 1305 | block: *Scope.Block, |
| 1277 | extended: Zir.Inst.Extended.InstData, | 1306 | extended: Zir.Inst.Extended.InstData, |
| 1278 | ) InnerError!Air.Inst.Index { | 1307 | ) InnerError!Air.Inst.Ref { |
| 1279 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); | 1308 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); |
| 1280 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; | 1309 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; |
| 1281 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{}); | 1310 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{}); |
| 1282 | } | 1311 | } |
| 1283 | | 1312 | |
| 1284 | fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1313 | fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1285 | const tracy = trace(@src()); | 1314 | const tracy = trace(@src()); |
| 1286 | defer tracy.end(); | 1315 | defer tracy.end(); |
| 1287 | | 1316 | |
| ... | @@ -1289,7 +1318,7 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -1289,7 +1318,7 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 1289 | const src = inst_data.src(); | 1318 | const src = inst_data.src(); |
| 1290 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; | 1319 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 1291 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); | 1320 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); |
| 1292 | const ptr_type = try sema.mod.simplePtrType(sema.arena, var_type, true, .One); | 1321 | const ptr_type = try Module.simplePtrType(sema.arena, var_type, true, .One); |
| 1293 | | 1322 | |
| 1294 | const val_payload = try sema.arena.create(Value.Payload.ComptimeAlloc); | 1323 | const val_payload = try sema.arena.create(Value.Payload.ComptimeAlloc); |
| 1295 | val_payload.* = .{ | 1324 | val_payload.* = .{ |
| ... | @@ -1304,13 +1333,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -1304,13 +1333,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 1304 | }); | 1333 | }); |
| 1305 | } | 1334 | } |
| 1306 | | 1335 | |
| 1307 | fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1336 | fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1308 | const src_node = sema.code.instructions.items(.data)[inst].node; | 1337 | const src_node = sema.code.instructions.items(.data)[inst].node; |
| 1309 | const src: LazySrcLoc = .{ .node_offset = src_node }; | 1338 | const src: LazySrcLoc = .{ .node_offset = src_node }; |
| 1310 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{}); | 1339 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{}); |
| 1311 | } | 1340 | } |
| 1312 | | 1341 | |
| 1313 | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1342 | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1314 | const tracy = trace(@src()); | 1343 | const tracy = trace(@src()); |
| 1315 | defer tracy.end(); | 1344 | defer tracy.end(); |
| 1316 | | 1345 | |
| ... | @@ -1318,12 +1347,12 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A | ... | @@ -1318,12 +1347,12 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A |
| 1318 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; | 1347 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 1319 | const var_decl_src = inst_data.src(); | 1348 | const var_decl_src = inst_data.src(); |
| 1320 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); | 1349 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); |
| 1321 | const ptr_type = try sema.mod.simplePtrType(sema.arena, var_type, true, .One); | 1350 | const ptr_type = try Module.simplePtrType(sema.arena, var_type, true, .One); |
| 1322 | try sema.requireRuntimeBlock(block, var_decl_src); | 1351 | try sema.requireRuntimeBlock(block, var_decl_src); |
| 1323 | return block.addNoOp(var_decl_src, ptr_type, .alloc); | 1352 | return block.addNoOp(var_decl_src, ptr_type, .alloc); |
| 1324 | } | 1353 | } |
| 1325 | | 1354 | |
| 1326 | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1355 | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1327 | const tracy = trace(@src()); | 1356 | const tracy = trace(@src()); |
| 1328 | defer tracy.end(); | 1357 | defer tracy.end(); |
| 1329 | | 1358 | |
| ... | @@ -1332,7 +1361,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -1332,7 +1361,7 @@ fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 1332 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; | 1361 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 1333 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); | 1362 | const var_type = try sema.resolveType(block, ty_src, inst_data.operand); |
| 1334 | try sema.validateVarType(block, ty_src, var_type); | 1363 | try sema.validateVarType(block, ty_src, var_type); |
| 1335 | const ptr_type = try sema.mod.simplePtrType(sema.arena, var_type, true, .One); | 1364 | const ptr_type = try Module.simplePtrType(sema.arena, var_type, true, .One); |
| 1336 | try sema.requireRuntimeBlock(block, var_decl_src); | 1365 | try sema.requireRuntimeBlock(block, var_decl_src); |
| 1337 | return block.addNoOp(var_decl_src, ptr_type, .alloc); | 1366 | return block.addNoOp(var_decl_src, ptr_type, .alloc); |
| 1338 | } | 1367 | } |
| ... | @@ -1342,7 +1371,7 @@ fn zirAllocInferred( | ... | @@ -1342,7 +1371,7 @@ fn zirAllocInferred( |
| 1342 | block: *Scope.Block, | 1371 | block: *Scope.Block, |
| 1343 | inst: Zir.Inst.Index, | 1372 | inst: Zir.Inst.Index, |
| 1344 | inferred_alloc_ty: Type, | 1373 | inferred_alloc_ty: Type, |
| 1345 | ) InnerError!Air.Inst.Index { | 1374 | ) InnerError!Air.Inst.Ref { |
| 1346 | const tracy = trace(@src()); | 1375 | const tracy = trace(@src()); |
| 1347 | defer tracy.end(); | 1376 | defer tracy.end(); |
| 1348 | | 1377 | |
| ... | @@ -1372,7 +1401,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1372,7 +1401,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1372 | | 1401 | |
| 1373 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 1402 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1374 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; | 1403 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 1375 | const ptr = try sema.resolveInst(inst_data.operand); | 1404 | const ptr = sema.resolveInst(inst_data.operand); |
| 1376 | const ptr_val = ptr.castTag(.constant).?.val; | 1405 | const ptr_val = ptr.castTag(.constant).?.val; |
| 1377 | const inferred_alloc = ptr_val.castTag(.inferred_alloc).?; | 1406 | const inferred_alloc = ptr_val.castTag(.inferred_alloc).?; |
| 1378 | const peer_inst_list = inferred_alloc.data.stored_inst_list.items; | 1407 | const peer_inst_list = inferred_alloc.data.stored_inst_list.items; |
| ... | @@ -1385,7 +1414,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1385,7 +1414,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1385 | if (var_is_mut) { | 1414 | if (var_is_mut) { |
| 1386 | try sema.validateVarType(block, ty_src, final_elem_ty); | 1415 | try sema.validateVarType(block, ty_src, final_elem_ty); |
| 1387 | } | 1416 | } |
| 1388 | const final_ptr_ty = try sema.mod.simplePtrType(sema.arena, final_elem_ty, true, .One); | 1417 | const final_ptr_ty = try Module.simplePtrType(sema.arena, final_elem_ty, true, .One); |
| 1389 | | 1418 | |
| 1390 | // Change it to a normal alloc. | 1419 | // Change it to a normal alloc. |
| 1391 | ptr.ty = final_ptr_ty; | 1420 | ptr.ty = final_ptr_ty; |
| ... | @@ -1406,7 +1435,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind | ... | @@ -1406,7 +1435,7 @@ fn zirValidateStructInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Ind |
| 1406 | const struct_obj: *Module.Struct = s: { | 1435 | const struct_obj: *Module.Struct = s: { |
| 1407 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; | 1436 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; |
| 1408 | const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data; | 1437 | const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data; |
| 1409 | const object_ptr = try sema.resolveInst(field_ptr_extra.lhs); | 1438 | const object_ptr = sema.resolveInst(field_ptr_extra.lhs); |
| 1410 | break :s object_ptr.ty.elemType().castTag(.@"struct").?.data; | 1439 | break :s object_ptr.ty.elemType().castTag(.@"struct").?.data; |
| 1411 | }; | 1440 | }; |
| 1412 | | 1441 | |
| ... | @@ -1535,9 +1564,9 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In | ... | @@ -1535,9 +1564,9 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 1535 | // to omit it. | 1564 | // to omit it. |
| 1536 | return; | 1565 | return; |
| 1537 | } | 1566 | } |
| 1538 | const ptr = try sema.resolveInst(bin_inst.lhs); | 1567 | const ptr = sema.resolveInst(bin_inst.lhs); |
| 1539 | const value = try sema.resolveInst(bin_inst.rhs); | 1568 | const value = sema.resolveInst(bin_inst.rhs); |
| 1540 | const ptr_ty = try sema.mod.simplePtrType(sema.arena, value.ty, true, .One); | 1569 | const ptr_ty = try Module.simplePtrType(sema.arena, value.ty, true, .One); |
| 1541 | // TODO detect when this store should be done at compile-time. For example, | 1570 | // TODO detect when this store should be done at compile-time. For example, |
| 1542 | // if expressions should force it when the condition is compile-time known. | 1571 | // if expressions should force it when the condition is compile-time known. |
| 1543 | const src: LazySrcLoc = .unneeded; | 1572 | const src: LazySrcLoc = .unneeded; |
| ... | @@ -1552,14 +1581,14 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) | ... | @@ -1552,14 +1581,14 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 1552 | | 1581 | |
| 1553 | const src: LazySrcLoc = .unneeded; | 1582 | const src: LazySrcLoc = .unneeded; |
| 1554 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 1583 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 1555 | const ptr = try sema.resolveInst(bin_inst.lhs); | 1584 | const ptr = sema.resolveInst(bin_inst.lhs); |
| 1556 | const value = try sema.resolveInst(bin_inst.rhs); | 1585 | const value = sema.resolveInst(bin_inst.rhs); |
| 1557 | const inferred_alloc = ptr.castTag(.constant).?.val.castTag(.inferred_alloc).?; | 1586 | const inferred_alloc = ptr.castTag(.constant).?.val.castTag(.inferred_alloc).?; |
| 1558 | // Add the stored instruction to the set we will use to resolve peer types | 1587 | // Add the stored instruction to the set we will use to resolve peer types |
| 1559 | // for the inferred allocation. | 1588 | // for the inferred allocation. |
| 1560 | try inferred_alloc.data.stored_inst_list.append(sema.arena, value); | 1589 | try inferred_alloc.data.stored_inst_list.append(sema.arena, value); |
| 1561 | // Create a runtime bitcast instruction with exactly the type the pointer wants. | 1590 | // Create a runtime bitcast instruction with exactly the type the pointer wants. |
| 1562 | const ptr_ty = try sema.mod.simplePtrType(sema.arena, value.ty, true, .One); | 1591 | const ptr_ty = try Module.simplePtrType(sema.arena, value.ty, true, .One); |
| 1563 | try sema.requireRuntimeBlock(block, src); | 1592 | try sema.requireRuntimeBlock(block, src); |
| 1564 | const bitcasted_ptr = try block.addUnOp(src, ptr_ty, .bitcast, ptr); | 1593 | const bitcasted_ptr = try block.addUnOp(src, ptr_ty, .bitcast, ptr); |
| 1565 | return sema.storePtr(block, src, bitcasted_ptr, value); | 1594 | return sema.storePtr(block, src, bitcasted_ptr, value); |
| ... | @@ -1578,8 +1607,8 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!v | ... | @@ -1578,8 +1607,8 @@ fn zirStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!v |
| 1578 | defer tracy.end(); | 1607 | defer tracy.end(); |
| 1579 | | 1608 | |
| 1580 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 1609 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 1581 | const ptr = try sema.resolveInst(bin_inst.lhs); | 1610 | const ptr = sema.resolveInst(bin_inst.lhs); |
| 1582 | const value = try sema.resolveInst(bin_inst.rhs); | 1611 | const value = sema.resolveInst(bin_inst.rhs); |
| 1583 | return sema.storePtr(block, sema.src, ptr, value); | 1612 | return sema.storePtr(block, sema.src, ptr, value); |
| 1584 | } | 1613 | } |
| 1585 | | 1614 | |
| ... | @@ -1590,18 +1619,18 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -1590,18 +1619,18 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 1590 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1619 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1591 | const src = inst_data.src(); | 1620 | const src = inst_data.src(); |
| 1592 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 1621 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 1593 | const ptr = try sema.resolveInst(extra.lhs); | 1622 | const ptr = sema.resolveInst(extra.lhs); |
| 1594 | const value = try sema.resolveInst(extra.rhs); | 1623 | const value = sema.resolveInst(extra.rhs); |
| 1595 | return sema.storePtr(block, src, ptr, value); | 1624 | return sema.storePtr(block, src, ptr, value); |
| 1596 | } | 1625 | } |
| 1597 | | 1626 | |
| 1598 | fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1627 | fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1599 | const tracy = trace(@src()); | 1628 | const tracy = trace(@src()); |
| 1600 | defer tracy.end(); | 1629 | defer tracy.end(); |
| 1601 | | 1630 | |
| 1602 | const src: LazySrcLoc = .unneeded; | 1631 | const src: LazySrcLoc = .unneeded; |
| 1603 | const inst_data = sema.code.instructions.items(.data)[inst].param_type; | 1632 | const inst_data = sema.code.instructions.items(.data)[inst].param_type; |
| 1604 | const fn_inst = try sema.resolveInst(inst_data.callee); | 1633 | const fn_inst = sema.resolveInst(inst_data.callee); |
| 1605 | const param_index = inst_data.param_index; | 1634 | const param_index = inst_data.param_index; |
| 1606 | | 1635 | |
| 1607 | const fn_ty: Type = switch (fn_inst.ty.zigTypeTag()) { | 1636 | const fn_ty: Type = switch (fn_inst.ty.zigTypeTag()) { |
| ... | @@ -1631,7 +1660,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -1631,7 +1660,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 1631 | return sema.mod.constType(sema.arena, src, param_type); | 1660 | return sema.mod.constType(sema.arena, src, param_type); |
| 1632 | } | 1661 | } |
| 1633 | | 1662 | |
| 1634 | fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1663 | fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1635 | const tracy = trace(@src()); | 1664 | const tracy = trace(@src()); |
| 1636 | defer tracy.end(); | 1665 | defer tracy.end(); |
| 1637 | | 1666 | |
| ... | @@ -1659,7 +1688,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air | ... | @@ -1659,7 +1688,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air |
| 1659 | return sema.analyzeDeclRef(block, .unneeded, new_decl); | 1688 | return sema.analyzeDeclRef(block, .unneeded, new_decl); |
| 1660 | } | 1689 | } |
| 1661 | | 1690 | |
| 1662 | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1691 | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1663 | _ = block; | 1692 | _ = block; |
| 1664 | const tracy = trace(@src()); | 1693 | const tracy = trace(@src()); |
| 1665 | defer tracy.end(); | 1694 | defer tracy.end(); |
| ... | @@ -1668,7 +1697,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air | ... | @@ -1668,7 +1697,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air |
| 1668 | return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int); | 1697 | return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int); |
| 1669 | } | 1698 | } |
| 1670 | | 1699 | |
| 1671 | fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1700 | fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1672 | _ = block; | 1701 | _ = block; |
| 1673 | const tracy = trace(@src()); | 1702 | const tracy = trace(@src()); |
| 1674 | defer tracy.end(); | 1703 | defer tracy.end(); |
| ... | @@ -1686,7 +1715,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -1686,7 +1715,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 1686 | }); | 1715 | }); |
| 1687 | } | 1716 | } |
| 1688 | | 1717 | |
| 1689 | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1718 | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1690 | _ = block; | 1719 | _ = block; |
| 1691 | const arena = sema.arena; | 1720 | const arena = sema.arena; |
| 1692 | const inst_data = sema.code.instructions.items(.data)[inst].float; | 1721 | const inst_data = sema.code.instructions.items(.data)[inst].float; |
| ... | @@ -1699,7 +1728,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A | ... | @@ -1699,7 +1728,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!A |
| 1699 | }); | 1728 | }); |
| 1700 | } | 1729 | } |
| 1701 | | 1730 | |
| 1702 | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1731 | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1703 | _ = block; | 1732 | _ = block; |
| 1704 | const arena = sema.arena; | 1733 | const arena = sema.arena; |
| 1705 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1734 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| ... | @@ -1728,7 +1757,7 @@ fn zirCompileLog( | ... | @@ -1728,7 +1757,7 @@ fn zirCompileLog( |
| 1728 | sema: *Sema, | 1757 | sema: *Sema, |
| 1729 | block: *Scope.Block, | 1758 | block: *Scope.Block, |
| 1730 | extended: Zir.Inst.Extended.InstData, | 1759 | extended: Zir.Inst.Extended.InstData, |
| 1731 | ) InnerError!Air.Inst.Index { | 1760 | ) InnerError!Air.Inst.Ref { |
| 1732 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); | 1761 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); |
| 1733 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); | 1762 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); |
| 1734 | const writer = managed.writer(); | 1763 | const writer = managed.writer(); |
| ... | @@ -1741,7 +1770,7 @@ fn zirCompileLog( | ... | @@ -1741,7 +1770,7 @@ fn zirCompileLog( |
| 1741 | for (args) |arg_ref, i| { | 1770 | for (args) |arg_ref, i| { |
| 1742 | if (i != 0) try writer.print(", ", .{}); | 1771 | if (i != 0) try writer.print(", ", .{}); |
| 1743 | | 1772 | |
| 1744 | const arg = try sema.resolveInst(arg_ref); | 1773 | const arg = sema.resolveInst(arg_ref); |
| 1745 | if (try sema.resolvePossiblyUndefinedValue(block, src, arg)) |val| { | 1774 | if (try sema.resolvePossiblyUndefinedValue(block, src, arg)) |val| { |
| 1746 | try writer.print("@as({}, {})", .{ arg.ty, val }); | 1775 | try writer.print("@as({}, {})", .{ arg.ty, val }); |
| 1747 | } else { | 1776 | } else { |
| ... | @@ -1773,12 +1802,12 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -1773,12 +1802,12 @@ fn zirRepeat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 1773 | fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { | 1802 | fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Zir.Inst.Index { |
| 1774 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 1803 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 1775 | const src: LazySrcLoc = inst_data.src(); | 1804 | const src: LazySrcLoc = inst_data.src(); |
| 1776 | const msg_inst = try sema.resolveInst(inst_data.operand); | 1805 | const msg_inst = sema.resolveInst(inst_data.operand); |
| 1777 | | 1806 | |
| 1778 | return sema.panicWithMsg(block, src, msg_inst); | 1807 | return sema.panicWithMsg(block, src, msg_inst); |
| 1779 | } | 1808 | } |
| 1780 | | 1809 | |
| 1781 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1810 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1782 | const tracy = trace(@src()); | 1811 | const tracy = trace(@src()); |
| 1783 | defer tracy.end(); | 1812 | defer tracy.end(); |
| 1784 | | 1813 | |
| ... | @@ -1843,7 +1872,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -1843,7 +1872,7 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 1843 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); | 1872 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); |
| 1844 | } | 1873 | } |
| 1845 | | 1874 | |
| 1846 | fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1875 | fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1847 | const tracy = trace(@src()); | 1876 | const tracy = trace(@src()); |
| 1848 | defer tracy.end(); | 1877 | defer tracy.end(); |
| 1849 | | 1878 | |
| ... | @@ -1853,13 +1882,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -1853,13 +1882,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 1853 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{}); | 1882 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{}); |
| 1854 | } | 1883 | } |
| 1855 | | 1884 | |
| 1856 | fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1885 | fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1857 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1886 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1858 | const src = inst_data.src(); | 1887 | const src = inst_data.src(); |
| 1859 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{}); | 1888 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{}); |
| 1860 | } | 1889 | } |
| 1861 | | 1890 | |
| 1862 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 1891 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 1863 | const tracy = trace(@src()); | 1892 | const tracy = trace(@src()); |
| 1864 | defer tracy.end(); | 1893 | defer tracy.end(); |
| 1865 | | 1894 | |
| ... | @@ -1917,7 +1946,7 @@ fn resolveBlockBody( | ... | @@ -1917,7 +1946,7 @@ fn resolveBlockBody( |
| 1917 | child_block: *Scope.Block, | 1946 | child_block: *Scope.Block, |
| 1918 | body: []const Zir.Inst.Index, | 1947 | body: []const Zir.Inst.Index, |
| 1919 | merges: *Scope.Block.Merges, | 1948 | merges: *Scope.Block.Merges, |
| 1920 | ) InnerError!Air.Inst.Index { | 1949 | ) InnerError!Air.Inst.Ref { |
| 1921 | _ = try sema.analyzeBody(child_block, body); | 1950 | _ = try sema.analyzeBody(child_block, body); |
| 1922 | return sema.analyzeBlockBody(parent_block, src, child_block, merges); | 1951 | return sema.analyzeBlockBody(parent_block, src, child_block, merges); |
| 1923 | } | 1952 | } |
| ... | @@ -1928,7 +1957,7 @@ fn analyzeBlockBody( | ... | @@ -1928,7 +1957,7 @@ fn analyzeBlockBody( |
| 1928 | src: LazySrcLoc, | 1957 | src: LazySrcLoc, |
| 1929 | child_block: *Scope.Block, | 1958 | child_block: *Scope.Block, |
| 1930 | merges: *Scope.Block.Merges, | 1959 | merges: *Scope.Block.Merges, |
| 1931 | ) InnerError!Air.Inst.Index { | 1960 | ) InnerError!Air.Inst.Ref { |
| 1932 | const tracy = trace(@src()); | 1961 | const tracy = trace(@src()); |
| 1933 | defer tracy.end(); | 1962 | defer tracy.end(); |
| 1934 | | 1963 | |
| ... | @@ -2088,7 +2117,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -2088,7 +2117,7 @@ fn zirBreak(sema: *Sema, start_block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 2088 | | 2117 | |
| 2089 | const inst_data = sema.code.instructions.items(.data)[inst].@"break"; | 2118 | const inst_data = sema.code.instructions.items(.data)[inst].@"break"; |
| 2090 | const src = sema.src; | 2119 | const src = sema.src; |
| 2091 | const operand = try sema.resolveInst(inst_data.operand); | 2120 | const operand = sema.resolveInst(inst_data.operand); |
| 2092 | const zir_block = inst_data.block_inst; | 2121 | const zir_block = inst_data.block_inst; |
| 2093 | | 2122 | |
| 2094 | var block = start_block; | 2123 | var block = start_block; |
| ... | @@ -2136,7 +2165,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -2136,7 +2165,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2136 | _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column); | 2165 | _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column); |
| 2137 | } | 2166 | } |
| 2138 | | 2167 | |
| 2139 | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2168 | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2140 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 2169 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2141 | const src = inst_data.src(); | 2170 | const src = inst_data.src(); |
| 2142 | const decl_name = inst_data.get(sema.code); | 2171 | const decl_name = inst_data.get(sema.code); |
| ... | @@ -2144,7 +2173,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -2144,7 +2173,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2144 | return sema.analyzeDeclRef(block, src, decl); | 2173 | return sema.analyzeDeclRef(block, src, decl); |
| 2145 | } | 2174 | } |
| 2146 | | 2175 | |
| 2147 | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2176 | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2148 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 2177 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2149 | const src = inst_data.src(); | 2178 | const src = inst_data.src(); |
| 2150 | const decl_name = inst_data.get(sema.code); | 2179 | const decl_name = inst_data.get(sema.code); |
| ... | @@ -2198,7 +2227,7 @@ fn zirCall( | ... | @@ -2198,7 +2227,7 @@ fn zirCall( |
| 2198 | inst: Zir.Inst.Index, | 2227 | inst: Zir.Inst.Index, |
| 2199 | modifier: std.builtin.CallOptions.Modifier, | 2228 | modifier: std.builtin.CallOptions.Modifier, |
| 2200 | ensure_result_used: bool, | 2229 | ensure_result_used: bool, |
| 2201 | ) InnerError!Air.Inst.Index { | 2230 | ) InnerError!Air.Inst.Ref { |
| 2202 | const tracy = trace(@src()); | 2231 | const tracy = trace(@src()); |
| 2203 | defer tracy.end(); | 2232 | defer tracy.end(); |
| 2204 | | 2233 | |
| ... | @@ -2208,12 +2237,12 @@ fn zirCall( | ... | @@ -2208,12 +2237,12 @@ fn zirCall( |
| 2208 | const extra = sema.code.extraData(Zir.Inst.Call, inst_data.payload_index); | 2237 | const extra = sema.code.extraData(Zir.Inst.Call, inst_data.payload_index); |
| 2209 | const args = sema.code.refSlice(extra.end, extra.data.args_len); | 2238 | const args = sema.code.refSlice(extra.end, extra.data.args_len); |
| 2210 | | 2239 | |
| 2211 | const func = try sema.resolveInst(extra.data.callee); | 2240 | const func = sema.resolveInst(extra.data.callee); |
| 2212 | // TODO handle function calls of generic functions | 2241 | // TODO handle function calls of generic functions |
| 2213 | const resolved_args = try sema.arena.alloc(Air.Inst.Index, args.len); | 2242 | const resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len); |
| 2214 | for (args) |zir_arg, i| { | 2243 | for (args) |zir_arg, i| { |
| 2215 | // the args are already casted to the result of a param type instruction. | 2244 | // the args are already casted to the result of a param type instruction. |
| 2216 | resolved_args[i] = try sema.resolveInst(zir_arg); | 2245 | resolved_args[i] = sema.resolveInst(zir_arg); |
| 2217 | } | 2246 | } |
| 2218 | | 2247 | |
| 2219 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args); | 2248 | return sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args); |
| ... | @@ -2222,13 +2251,13 @@ fn zirCall( | ... | @@ -2222,13 +2251,13 @@ fn zirCall( |
| 2222 | fn analyzeCall( | 2251 | fn analyzeCall( |
| 2223 | sema: *Sema, | 2252 | sema: *Sema, |
| 2224 | block: *Scope.Block, | 2253 | block: *Scope.Block, |
| 2225 | func: Air.Inst.Index, | 2254 | func: Air.Inst.Ref, |
| 2226 | func_src: LazySrcLoc, | 2255 | func_src: LazySrcLoc, |
| 2227 | call_src: LazySrcLoc, | 2256 | call_src: LazySrcLoc, |
| 2228 | modifier: std.builtin.CallOptions.Modifier, | 2257 | modifier: std.builtin.CallOptions.Modifier, |
| 2229 | ensure_result_used: bool, | 2258 | ensure_result_used: bool, |
| 2230 | args: []const Air.Inst.Index, | 2259 | args: []const Air.Inst.Ref, |
| 2231 | ) InnerError!Air.Inst.Index { | 2260 | ) InnerError!Air.Inst.Ref { |
| 2232 | if (func.ty.zigTypeTag() != .Fn) | 2261 | if (func.ty.zigTypeTag() != .Fn) |
| 2233 | return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty}); | 2262 | return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty}); |
| 2234 | | 2263 | |
| ... | @@ -2285,7 +2314,7 @@ fn analyzeCall( | ... | @@ -2285,7 +2314,7 @@ fn analyzeCall( |
| 2285 | const is_comptime_call = block.is_comptime or modifier == .compile_time; | 2314 | const is_comptime_call = block.is_comptime or modifier == .compile_time; |
| 2286 | const is_inline_call = is_comptime_call or modifier == .always_inline or | 2315 | const is_inline_call = is_comptime_call or modifier == .always_inline or |
| 2287 | func.ty.fnCallingConvention() == .Inline; | 2316 | func.ty.fnCallingConvention() == .Inline; |
| 2288 | const result: Air.Inst.Index = if (is_inline_call) res: { | 2317 | const result: Air.Inst.Ref = if (is_inline_call) res: { |
| 2289 | const func_val = try sema.resolveConstValue(block, func_src, func); | 2318 | const func_val = try sema.resolveConstValue(block, func_src, func); |
| 2290 | const module_fn = switch (func_val.tag()) { | 2319 | const module_fn = switch (func_val.tag()) { |
| 2291 | .function => func_val.castTag(.function).?.data, | 2320 | .function => func_val.castTag(.function).?.data, |
| ... | @@ -2383,7 +2412,7 @@ fn analyzeCall( | ... | @@ -2383,7 +2412,7 @@ fn analyzeCall( |
| 2383 | return result; | 2412 | return result; |
| 2384 | } | 2413 | } |
| 2385 | | 2414 | |
| 2386 | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2415 | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2387 | _ = block; | 2416 | _ = block; |
| 2388 | const tracy = trace(@src()); | 2417 | const tracy = trace(@src()); |
| 2389 | defer tracy.end(); | 2418 | defer tracy.end(); |
| ... | @@ -2395,7 +2424,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -2395,7 +2424,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2395 | return sema.mod.constType(sema.arena, src, ty); | 2424 | return sema.mod.constType(sema.arena, src, ty); |
| 2396 | } | 2425 | } |
| 2397 | | 2426 | |
| 2398 | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2427 | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2399 | const tracy = trace(@src()); | 2428 | const tracy = trace(@src()); |
| 2400 | defer tracy.end(); | 2429 | defer tracy.end(); |
| 2401 | | 2430 | |
| ... | @@ -2407,7 +2436,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner | ... | @@ -2407,7 +2436,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2407 | return sema.mod.constType(sema.arena, src, opt_type); | 2436 | return sema.mod.constType(sema.arena, src, opt_type); |
| 2408 | } | 2437 | } |
| 2409 | | 2438 | |
| 2410 | fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2439 | fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2411 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2440 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2412 | const src = inst_data.src(); | 2441 | const src = inst_data.src(); |
| 2413 | const array_type = try sema.resolveType(block, src, inst_data.operand); | 2442 | const array_type = try sema.resolveType(block, src, inst_data.operand); |
| ... | @@ -2415,7 +2444,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -2415,7 +2444,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 2415 | return sema.mod.constType(sema.arena, src, elem_type); | 2444 | return sema.mod.constType(sema.arena, src, elem_type); |
| 2416 | } | 2445 | } |
| 2417 | | 2446 | |
| 2418 | fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2447 | fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2419 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2448 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2420 | const src = inst_data.src(); | 2449 | const src = inst_data.src(); |
| 2421 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2450 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -2430,7 +2459,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2430,7 +2459,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2430 | return sema.mod.constType(sema.arena, src, vector_type); | 2459 | return sema.mod.constType(sema.arena, src, vector_type); |
| 2431 | } | 2460 | } |
| 2432 | | 2461 | |
| 2433 | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2462 | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2434 | const tracy = trace(@src()); | 2463 | const tracy = trace(@src()); |
| 2435 | defer tracy.end(); | 2464 | defer tracy.end(); |
| 2436 | | 2465 | |
| ... | @@ -2443,7 +2472,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -2443,7 +2472,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2443 | return sema.mod.constType(sema.arena, .unneeded, array_ty); | 2472 | return sema.mod.constType(sema.arena, .unneeded, array_ty); |
| 2444 | } | 2473 | } |
| 2445 | | 2474 | |
| 2446 | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2475 | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2447 | const tracy = trace(@src()); | 2476 | const tracy = trace(@src()); |
| 2448 | defer tracy.end(); | 2477 | defer tracy.end(); |
| 2449 | | 2478 | |
| ... | @@ -2458,7 +2487,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) | ... | @@ -2458,7 +2487,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 2458 | return sema.mod.constType(sema.arena, .unneeded, array_ty); | 2487 | return sema.mod.constType(sema.arena, .unneeded, array_ty); |
| 2459 | } | 2488 | } |
| 2460 | | 2489 | |
| 2461 | fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2490 | fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2462 | const tracy = trace(@src()); | 2491 | const tracy = trace(@src()); |
| 2463 | defer tracy.end(); | 2492 | defer tracy.end(); |
| 2464 | | 2493 | |
| ... | @@ -2471,7 +2500,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner | ... | @@ -2471,7 +2500,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2471 | return sema.mod.constType(sema.arena, src, anyframe_type); | 2500 | return sema.mod.constType(sema.arena, src, anyframe_type); |
| 2472 | } | 2501 | } |
| 2473 | | 2502 | |
| 2474 | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2503 | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2475 | const tracy = trace(@src()); | 2504 | const tracy = trace(@src()); |
| 2476 | defer tracy.end(); | 2505 | defer tracy.end(); |
| 2477 | | 2506 | |
| ... | @@ -2492,7 +2521,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -2492,7 +2521,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2492 | return sema.mod.constType(sema.arena, src, err_union_ty); | 2521 | return sema.mod.constType(sema.arena, src, err_union_ty); |
| 2493 | } | 2522 | } |
| 2494 | | 2523 | |
| 2495 | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2524 | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2496 | _ = block; | 2525 | _ = block; |
| 2497 | const tracy = trace(@src()); | 2526 | const tracy = trace(@src()); |
| 2498 | defer tracy.end(); | 2527 | defer tracy.end(); |
| ... | @@ -2511,14 +2540,14 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2511,14 +2540,14 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2511 | }); | 2540 | }); |
| 2512 | } | 2541 | } |
| 2513 | | 2542 | |
| 2514 | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2543 | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2515 | const tracy = trace(@src()); | 2544 | const tracy = trace(@src()); |
| 2516 | defer tracy.end(); | 2545 | defer tracy.end(); |
| 2517 | | 2546 | |
| 2518 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2547 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2519 | const src = inst_data.src(); | 2548 | const src = inst_data.src(); |
| 2520 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2549 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2521 | const op = try sema.resolveInst(inst_data.operand); | 2550 | const op = sema.resolveInst(inst_data.operand); |
| 2522 | const op_coerced = try sema.coerce(block, Type.initTag(.anyerror), op, operand_src); | 2551 | const op_coerced = try sema.coerce(block, Type.initTag(.anyerror), op, operand_src); |
| 2523 | const result_ty = Type.initTag(.u16); | 2552 | const result_ty = Type.initTag(.u16); |
| 2524 | | 2553 | |
| ... | @@ -2541,7 +2570,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2541,7 +2570,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2541 | return block.addUnOp(src, result_ty, .bitcast, op_coerced); | 2570 | return block.addUnOp(src, result_ty, .bitcast, op_coerced); |
| 2542 | } | 2571 | } |
| 2543 | | 2572 | |
| 2544 | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2573 | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2545 | const tracy = trace(@src()); | 2574 | const tracy = trace(@src()); |
| 2546 | defer tracy.end(); | 2575 | defer tracy.end(); |
| 2547 | | 2576 | |
| ... | @@ -2549,7 +2578,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2549,7 +2578,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2549 | const src = inst_data.src(); | 2578 | const src = inst_data.src(); |
| 2550 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2579 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2551 | | 2580 | |
| 2552 | const op = try sema.resolveInst(inst_data.operand); | 2581 | const op = sema.resolveInst(inst_data.operand); |
| 2553 | | 2582 | |
| 2554 | if (try sema.resolveDefinedValue(block, operand_src, op)) |value| { | 2583 | if (try sema.resolveDefinedValue(block, operand_src, op)) |value| { |
| 2555 | const int = value.toUnsignedInt(); | 2584 | const int = value.toUnsignedInt(); |
| ... | @@ -2574,7 +2603,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2574,7 +2603,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2574 | return block.addUnOp(src, Type.initTag(.anyerror), .bitcast, op); | 2603 | return block.addUnOp(src, Type.initTag(.anyerror), .bitcast, op); |
| 2575 | } | 2604 | } |
| 2576 | | 2605 | |
| 2577 | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2606 | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2578 | const tracy = trace(@src()); | 2607 | const tracy = trace(@src()); |
| 2579 | defer tracy.end(); | 2608 | defer tracy.end(); |
| 2580 | | 2609 | |
| ... | @@ -2583,8 +2612,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -2583,8 +2612,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2583 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 2612 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 2584 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 2613 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 2585 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 2614 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 2586 | const lhs = try sema.resolveInst(extra.lhs); | 2615 | const lhs = sema.resolveInst(extra.lhs); |
| 2587 | const rhs = try sema.resolveInst(extra.rhs); | 2616 | const rhs = sema.resolveInst(extra.rhs); |
| 2588 | if (rhs.ty.zigTypeTag() == .Bool and lhs.ty.zigTypeTag() == .Bool) { | 2617 | if (rhs.ty.zigTypeTag() == .Bool and lhs.ty.zigTypeTag() == .Bool) { |
| 2589 | const msg = msg: { | 2618 | const msg = msg: { |
| 2590 | const msg = try sema.mod.errMsg(&block.base, lhs_src, "expected error set type, found 'bool'", .{}); | 2619 | const msg = try sema.mod.errMsg(&block.base, lhs_src, "expected error set type, found 'bool'", .{}); |
| ... | @@ -2664,7 +2693,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -2664,7 +2693,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2664 | }); | 2693 | }); |
| 2665 | } | 2694 | } |
| 2666 | | 2695 | |
| 2667 | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2696 | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2668 | _ = block; | 2697 | _ = block; |
| 2669 | const tracy = trace(@src()); | 2698 | const tracy = trace(@src()); |
| 2670 | defer tracy.end(); | 2699 | defer tracy.end(); |
| ... | @@ -2678,15 +2707,15 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -2678,15 +2707,15 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 2678 | }); | 2707 | }); |
| 2679 | } | 2708 | } |
| 2680 | | 2709 | |
| 2681 | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2710 | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2682 | const mod = sema.mod; | 2711 | const mod = sema.mod; |
| 2683 | const arena = sema.arena; | 2712 | const arena = sema.arena; |
| 2684 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2713 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2685 | const src = inst_data.src(); | 2714 | const src = inst_data.src(); |
| 2686 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2715 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2687 | const operand = try sema.resolveInst(inst_data.operand); | 2716 | const operand = sema.resolveInst(inst_data.operand); |
| 2688 | | 2717 | |
| 2689 | const enum_tag: Air.Inst.Index = switch (operand.ty.zigTypeTag()) { | 2718 | const enum_tag: Air.Inst.Ref = switch (operand.ty.zigTypeTag()) { |
| 2690 | .Enum => operand, | 2719 | .Enum => operand, |
| 2691 | .Union => { | 2720 | .Union => { |
| 2692 | //if (!operand.ty.unionHasTag()) { | 2721 | //if (!operand.ty.unionHasTag()) { |
| ... | @@ -2760,7 +2789,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -2760,7 +2789,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2760 | return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag); | 2789 | return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag); |
| 2761 | } | 2790 | } |
| 2762 | | 2791 | |
| 2763 | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 2792 | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2764 | const mod = sema.mod; | 2793 | const mod = sema.mod; |
| 2765 | const target = mod.getTarget(); | 2794 | const target = mod.getTarget(); |
| 2766 | const arena = sema.arena; | 2795 | const arena = sema.arena; |
| ... | @@ -2770,7 +2799,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -2770,7 +2799,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2770 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2799 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2771 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 2800 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 2772 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 2801 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 2773 | const operand = try sema.resolveInst(extra.rhs); | 2802 | const operand = sema.resolveInst(extra.rhs); |
| 2774 | | 2803 | |
| 2775 | if (dest_ty.zigTypeTag() != .Enum) { | 2804 | if (dest_ty.zigTypeTag() != .Enum) { |
| 2776 | return mod.fail(&block.base, dest_ty_src, "expected enum, found {}", .{dest_ty}); | 2805 | return mod.fail(&block.base, dest_ty_src, "expected enum, found {}", .{dest_ty}); |
| ... | @@ -2821,12 +2850,12 @@ fn zirOptionalPayloadPtr( | ... | @@ -2821,12 +2850,12 @@ fn zirOptionalPayloadPtr( |
| 2821 | block: *Scope.Block, | 2850 | block: *Scope.Block, |
| 2822 | inst: Zir.Inst.Index, | 2851 | inst: Zir.Inst.Index, |
| 2823 | safety_check: bool, | 2852 | safety_check: bool, |
| 2824 | ) InnerError!Air.Inst.Index { | 2853 | ) InnerError!Air.Inst.Ref { |
| 2825 | const tracy = trace(@src()); | 2854 | const tracy = trace(@src()); |
| 2826 | defer tracy.end(); | 2855 | defer tracy.end(); |
| 2827 | | 2856 | |
| 2828 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2857 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2829 | const optional_ptr = try sema.resolveInst(inst_data.operand); | 2858 | const optional_ptr = sema.resolveInst(inst_data.operand); |
| 2830 | assert(optional_ptr.ty.zigTypeTag() == .Pointer); | 2859 | assert(optional_ptr.ty.zigTypeTag() == .Pointer); |
| 2831 | const src = inst_data.src(); | 2860 | const src = inst_data.src(); |
| 2832 | | 2861 | |
| ... | @@ -2836,7 +2865,7 @@ fn zirOptionalPayloadPtr( | ... | @@ -2836,7 +2865,7 @@ fn zirOptionalPayloadPtr( |
| 2836 | } | 2865 | } |
| 2837 | | 2866 | |
| 2838 | const child_type = try opt_type.optionalChildAlloc(sema.arena); | 2867 | const child_type = try opt_type.optionalChildAlloc(sema.arena); |
| 2839 | const child_pointer = try sema.mod.simplePtrType(sema.arena, child_type, !optional_ptr.ty.isConstPtr(), .One); | 2868 | const child_pointer = try Module.simplePtrType(sema.arena, child_type, !optional_ptr.ty.isConstPtr(), .One); |
| 2840 | | 2869 | |
| 2841 | if (optional_ptr.value()) |pointer_val| { | 2870 | if (optional_ptr.value()) |pointer_val| { |
| 2842 | const val = try pointer_val.pointerDeref(sema.arena); | 2871 | const val = try pointer_val.pointerDeref(sema.arena); |
| ... | @@ -2864,13 +2893,13 @@ fn zirOptionalPayload( | ... | @@ -2864,13 +2893,13 @@ fn zirOptionalPayload( |
| 2864 | block: *Scope.Block, | 2893 | block: *Scope.Block, |
| 2865 | inst: Zir.Inst.Index, | 2894 | inst: Zir.Inst.Index, |
| 2866 | safety_check: bool, | 2895 | safety_check: bool, |
| 2867 | ) InnerError!Air.Inst.Index { | 2896 | ) InnerError!Air.Inst.Ref { |
| 2868 | const tracy = trace(@src()); | 2897 | const tracy = trace(@src()); |
| 2869 | defer tracy.end(); | 2898 | defer tracy.end(); |
| 2870 | | 2899 | |
| 2871 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2900 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2872 | const src = inst_data.src(); | 2901 | const src = inst_data.src(); |
| 2873 | const operand = try sema.resolveInst(inst_data.operand); | 2902 | const operand = sema.resolveInst(inst_data.operand); |
| 2874 | const opt_type = operand.ty; | 2903 | const opt_type = operand.ty; |
| 2875 | if (opt_type.zigTypeTag() != .Optional) { | 2904 | if (opt_type.zigTypeTag() != .Optional) { |
| 2876 | return sema.mod.fail(&block.base, src, "expected optional type, found {}", .{opt_type}); | 2905 | return sema.mod.fail(&block.base, src, "expected optional type, found {}", .{opt_type}); |
| ... | @@ -2902,13 +2931,13 @@ fn zirErrUnionPayload( | ... | @@ -2902,13 +2931,13 @@ fn zirErrUnionPayload( |
| 2902 | block: *Scope.Block, | 2931 | block: *Scope.Block, |
| 2903 | inst: Zir.Inst.Index, | 2932 | inst: Zir.Inst.Index, |
| 2904 | safety_check: bool, | 2933 | safety_check: bool, |
| 2905 | ) InnerError!Air.Inst.Index { | 2934 | ) InnerError!Air.Inst.Ref { |
| 2906 | const tracy = trace(@src()); | 2935 | const tracy = trace(@src()); |
| 2907 | defer tracy.end(); | 2936 | defer tracy.end(); |
| 2908 | | 2937 | |
| 2909 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2938 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2910 | const src = inst_data.src(); | 2939 | const src = inst_data.src(); |
| 2911 | const operand = try sema.resolveInst(inst_data.operand); | 2940 | const operand = sema.resolveInst(inst_data.operand); |
| 2912 | if (operand.ty.zigTypeTag() != .ErrorUnion) | 2941 | if (operand.ty.zigTypeTag() != .ErrorUnion) |
| 2913 | return sema.mod.fail(&block.base, operand.src, "expected error union type, found '{}'", .{operand.ty}); | 2942 | return sema.mod.fail(&block.base, operand.src, "expected error union type, found '{}'", .{operand.ty}); |
| 2914 | | 2943 | |
| ... | @@ -2936,19 +2965,19 @@ fn zirErrUnionPayloadPtr( | ... | @@ -2936,19 +2965,19 @@ fn zirErrUnionPayloadPtr( |
| 2936 | block: *Scope.Block, | 2965 | block: *Scope.Block, |
| 2937 | inst: Zir.Inst.Index, | 2966 | inst: Zir.Inst.Index, |
| 2938 | safety_check: bool, | 2967 | safety_check: bool, |
| 2939 | ) InnerError!Air.Inst.Index { | 2968 | ) InnerError!Air.Inst.Ref { |
| 2940 | const tracy = trace(@src()); | 2969 | const tracy = trace(@src()); |
| 2941 | defer tracy.end(); | 2970 | defer tracy.end(); |
| 2942 | | 2971 | |
| 2943 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2972 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2944 | const src = inst_data.src(); | 2973 | const src = inst_data.src(); |
| 2945 | const operand = try sema.resolveInst(inst_data.operand); | 2974 | const operand = sema.resolveInst(inst_data.operand); |
| 2946 | assert(operand.ty.zigTypeTag() == .Pointer); | 2975 | assert(operand.ty.zigTypeTag() == .Pointer); |
| 2947 | | 2976 | |
| 2948 | if (operand.ty.elemType().zigTypeTag() != .ErrorUnion) | 2977 | if (operand.ty.elemType().zigTypeTag() != .ErrorUnion) |
| 2949 | return sema.mod.fail(&block.base, src, "expected error union type, found {}", .{operand.ty.elemType()}); | 2978 | return sema.mod.fail(&block.base, src, "expected error union type, found {}", .{operand.ty.elemType()}); |
| 2950 | | 2979 | |
| 2951 | const operand_pointer_ty = try sema.mod.simplePtrType(sema.arena, operand.ty.elemType().castTag(.error_union).?.data.payload, !operand.ty.isConstPtr(), .One); | 2980 | const operand_pointer_ty = try Module.simplePtrType(sema.arena, operand.ty.elemType().castTag(.error_union).?.data.payload, !operand.ty.isConstPtr(), .One); |
| 2952 | | 2981 | |
| 2953 | if (operand.value()) |pointer_val| { | 2982 | if (operand.value()) |pointer_val| { |
| 2954 | const val = try pointer_val.pointerDeref(sema.arena); | 2983 | const val = try pointer_val.pointerDeref(sema.arena); |
| ... | @@ -2975,13 +3004,13 @@ fn zirErrUnionPayloadPtr( | ... | @@ -2975,13 +3004,13 @@ fn zirErrUnionPayloadPtr( |
| 2975 | } | 3004 | } |
| 2976 | | 3005 | |
| 2977 | /// Value in, value out | 3006 | /// Value in, value out |
| 2978 | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3007 | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 2979 | const tracy = trace(@src()); | 3008 | const tracy = trace(@src()); |
| 2980 | defer tracy.end(); | 3009 | defer tracy.end(); |
| 2981 | | 3010 | |
| 2982 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 3011 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2983 | const src = inst_data.src(); | 3012 | const src = inst_data.src(); |
| 2984 | const operand = try sema.resolveInst(inst_data.operand); | 3013 | const operand = sema.resolveInst(inst_data.operand); |
| 2985 | if (operand.ty.zigTypeTag() != .ErrorUnion) | 3014 | if (operand.ty.zigTypeTag() != .ErrorUnion) |
| 2986 | return sema.mod.fail(&block.base, src, "expected error union type, found '{}'", .{operand.ty}); | 3015 | return sema.mod.fail(&block.base, src, "expected error union type, found '{}'", .{operand.ty}); |
| 2987 | | 3016 | |
| ... | @@ -3001,13 +3030,13 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner | ... | @@ -3001,13 +3030,13 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 3001 | } | 3030 | } |
| 3002 | | 3031 | |
| 3003 | /// Pointer in, value out | 3032 | /// Pointer in, value out |
| 3004 | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3033 | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3005 | const tracy = trace(@src()); | 3034 | const tracy = trace(@src()); |
| 3006 | defer tracy.end(); | 3035 | defer tracy.end(); |
| 3007 | | 3036 | |
| 3008 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 3037 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3009 | const src = inst_data.src(); | 3038 | const src = inst_data.src(); |
| 3010 | const operand = try sema.resolveInst(inst_data.operand); | 3039 | const operand = sema.resolveInst(inst_data.operand); |
| 3011 | assert(operand.ty.zigTypeTag() == .Pointer); | 3040 | assert(operand.ty.zigTypeTag() == .Pointer); |
| 3012 | | 3041 | |
| 3013 | if (operand.ty.elemType().zigTypeTag() != .ErrorUnion) | 3042 | if (operand.ty.elemType().zigTypeTag() != .ErrorUnion) |
| ... | @@ -3035,7 +3064,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -3035,7 +3064,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 3035 | | 3064 | |
| 3036 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; | 3065 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 3037 | const src = inst_data.src(); | 3066 | const src = inst_data.src(); |
| 3038 | const operand = try sema.resolveInst(inst_data.operand); | 3067 | const operand = sema.resolveInst(inst_data.operand); |
| 3039 | if (operand.ty.zigTypeTag() != .ErrorUnion) | 3068 | if (operand.ty.zigTypeTag() != .ErrorUnion) |
| 3040 | return sema.mod.fail(&block.base, src, "expected error union type, found '{}'", .{operand.ty}); | 3069 | return sema.mod.fail(&block.base, src, "expected error union type, found '{}'", .{operand.ty}); |
| 3041 | if (operand.ty.castTag(.error_union).?.data.payload.zigTypeTag() != .Void) { | 3070 | if (operand.ty.castTag(.error_union).?.data.payload.zigTypeTag() != .Void) { |
| ... | @@ -3048,7 +3077,7 @@ fn zirFunc( | ... | @@ -3048,7 +3077,7 @@ fn zirFunc( |
| 3048 | block: *Scope.Block, | 3077 | block: *Scope.Block, |
| 3049 | inst: Zir.Inst.Index, | 3078 | inst: Zir.Inst.Index, |
| 3050 | inferred_error_set: bool, | 3079 | inferred_error_set: bool, |
| 3051 | ) InnerError!Air.Inst.Index { | 3080 | ) InnerError!Air.Inst.Ref { |
| 3052 | const tracy = trace(@src()); | 3081 | const tracy = trace(@src()); |
| 3053 | defer tracy.end(); | 3082 | defer tracy.end(); |
| 3054 | | 3083 | |
| ... | @@ -3099,7 +3128,7 @@ fn funcCommon( | ... | @@ -3099,7 +3128,7 @@ fn funcCommon( |
| 3099 | is_extern: bool, | 3128 | is_extern: bool, |
| 3100 | src_locs: Zir.Inst.Func.SrcLocs, | 3129 | src_locs: Zir.Inst.Func.SrcLocs, |
| 3101 | opt_lib_name: ?[]const u8, | 3130 | opt_lib_name: ?[]const u8, |
| 3102 | ) InnerError!Air.Inst.Index { | 3131 | ) InnerError!Air.Inst.Ref { |
| 3103 | const src: LazySrcLoc = .{ .node_offset = src_node_offset }; | 3132 | const src: LazySrcLoc = .{ .node_offset = src_node_offset }; |
| 3104 | const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; | 3133 | const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; |
| 3105 | const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type); | 3134 | const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type); |
| ... | @@ -3240,7 +3269,7 @@ fn funcCommon( | ... | @@ -3240,7 +3269,7 @@ fn funcCommon( |
| 3240 | return result; | 3269 | return result; |
| 3241 | } | 3270 | } |
| 3242 | | 3271 | |
| 3243 | fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3272 | fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3244 | const tracy = trace(@src()); | 3273 | const tracy = trace(@src()); |
| 3245 | defer tracy.end(); | 3274 | defer tracy.end(); |
| 3246 | | 3275 | |
| ... | @@ -3248,7 +3277,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air. | ... | @@ -3248,7 +3277,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air. |
| 3248 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); | 3277 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); |
| 3249 | } | 3278 | } |
| 3250 | | 3279 | |
| 3251 | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3280 | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3252 | const tracy = trace(@src()); | 3281 | const tracy = trace(@src()); |
| 3253 | defer tracy.end(); | 3282 | defer tracy.end(); |
| 3254 | | 3283 | |
| ... | @@ -3264,18 +3293,18 @@ fn analyzeAs( | ... | @@ -3264,18 +3293,18 @@ fn analyzeAs( |
| 3264 | src: LazySrcLoc, | 3293 | src: LazySrcLoc, |
| 3265 | zir_dest_type: Zir.Inst.Ref, | 3294 | zir_dest_type: Zir.Inst.Ref, |
| 3266 | zir_operand: Zir.Inst.Ref, | 3295 | zir_operand: Zir.Inst.Ref, |
| 3267 | ) InnerError!Air.Inst.Index { | 3296 | ) InnerError!Air.Inst.Ref { |
| 3268 | const dest_type = try sema.resolveType(block, src, zir_dest_type); | 3297 | const dest_type = try sema.resolveType(block, src, zir_dest_type); |
| 3269 | const operand = try sema.resolveInst(zir_operand); | 3298 | const operand = sema.resolveInst(zir_operand); |
| 3270 | return sema.coerce(block, dest_type, operand, src); | 3299 | return sema.coerce(block, dest_type, operand, src); |
| 3271 | } | 3300 | } |
| 3272 | | 3301 | |
| 3273 | fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3302 | fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3274 | const tracy = trace(@src()); | 3303 | const tracy = trace(@src()); |
| 3275 | defer tracy.end(); | 3304 | defer tracy.end(); |
| 3276 | | 3305 | |
| 3277 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 3306 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3278 | const ptr = try sema.resolveInst(inst_data.operand); | 3307 | const ptr = sema.resolveInst(inst_data.operand); |
| 3279 | if (ptr.ty.zigTypeTag() != .Pointer) { | 3308 | if (ptr.ty.zigTypeTag() != .Pointer) { |
| 3280 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 3309 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 3281 | return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}); | 3310 | return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}); |
| ... | @@ -3287,7 +3316,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3287,7 +3316,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3287 | return block.addUnOp(src, ty, .ptrtoint, ptr); | 3316 | return block.addUnOp(src, ty, .ptrtoint, ptr); |
| 3288 | } | 3317 | } |
| 3289 | | 3318 | |
| 3290 | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3319 | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3291 | const tracy = trace(@src()); | 3320 | const tracy = trace(@src()); |
| 3292 | defer tracy.end(); | 3321 | defer tracy.end(); |
| 3293 | | 3322 | |
| ... | @@ -3296,7 +3325,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3296,7 +3325,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3296 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 3325 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 3297 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; | 3326 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 3298 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 3327 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 3299 | const object = try sema.resolveInst(extra.lhs); | 3328 | const object = sema.resolveInst(extra.lhs); |
| 3300 | const object_ptr = if (object.ty.zigTypeTag() == .Pointer) | 3329 | const object_ptr = if (object.ty.zigTypeTag() == .Pointer) |
| 3301 | object | 3330 | object |
| 3302 | else | 3331 | else |
| ... | @@ -3305,7 +3334,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3305,7 +3334,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3305 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); | 3334 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); |
| 3306 | } | 3335 | } |
| 3307 | | 3336 | |
| 3308 | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3337 | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3309 | const tracy = trace(@src()); | 3338 | const tracy = trace(@src()); |
| 3310 | defer tracy.end(); | 3339 | defer tracy.end(); |
| 3311 | | 3340 | |
| ... | @@ -3314,11 +3343,11 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3314,11 +3343,11 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3314 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 3343 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 3315 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; | 3344 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 3316 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 3345 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 3317 | const object_ptr = try sema.resolveInst(extra.lhs); | 3346 | const object_ptr = sema.resolveInst(extra.lhs); |
| 3318 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 3347 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 3319 | } | 3348 | } |
| 3320 | | 3349 | |
| 3321 | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3350 | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3322 | const tracy = trace(@src()); | 3351 | const tracy = trace(@src()); |
| 3323 | defer tracy.end(); | 3352 | defer tracy.end(); |
| 3324 | | 3353 | |
| ... | @@ -3326,14 +3355,14 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -3326,14 +3355,14 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3326 | const src = inst_data.src(); | 3355 | const src = inst_data.src(); |
| 3327 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 3356 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 3328 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; | 3357 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 3329 | const object = try sema.resolveInst(extra.lhs); | 3358 | const object = sema.resolveInst(extra.lhs); |
| 3330 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 3359 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 3331 | const object_ptr = try sema.analyzeRef(block, src, object); | 3360 | const object_ptr = try sema.analyzeRef(block, src, object); |
| 3332 | const result_ptr = try sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 3361 | const result_ptr = try sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 3333 | return sema.analyzeLoad(block, src, result_ptr, src); | 3362 | return sema.analyzeLoad(block, src, result_ptr, src); |
| 3334 | } | 3363 | } |
| 3335 | | 3364 | |
| 3336 | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3365 | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3337 | const tracy = trace(@src()); | 3366 | const tracy = trace(@src()); |
| 3338 | defer tracy.end(); | 3367 | defer tracy.end(); |
| 3339 | | 3368 | |
| ... | @@ -3341,12 +3370,12 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -3341,12 +3370,12 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3341 | const src = inst_data.src(); | 3370 | const src = inst_data.src(); |
| 3342 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 3371 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 3343 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; | 3372 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 3344 | const object_ptr = try sema.resolveInst(extra.lhs); | 3373 | const object_ptr = sema.resolveInst(extra.lhs); |
| 3345 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 3374 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 3346 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 3375 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 3347 | } | 3376 | } |
| 3348 | | 3377 | |
| 3349 | fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3378 | fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3350 | const tracy = trace(@src()); | 3379 | const tracy = trace(@src()); |
| 3351 | defer tracy.end(); | 3380 | defer tracy.end(); |
| 3352 | | 3381 | |
| ... | @@ -3357,7 +3386,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -3357,7 +3386,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3357 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 3386 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3358 | | 3387 | |
| 3359 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); | 3388 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 3360 | const operand = try sema.resolveInst(extra.rhs); | 3389 | const operand = sema.resolveInst(extra.rhs); |
| 3361 | | 3390 | |
| 3362 | const dest_is_comptime_int = switch (dest_type.zigTypeTag()) { | 3391 | const dest_is_comptime_int = switch (dest_type.zigTypeTag()) { |
| 3363 | .ComptimeInt => true, | 3392 | .ComptimeInt => true, |
| ... | @@ -3389,20 +3418,21 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -3389,20 +3418,21 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3389 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{}); | 3418 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{}); |
| 3390 | } | 3419 | } |
| 3391 | | 3420 | |
| 3392 | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3421 | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3393 | const tracy = trace(@src()); | 3422 | const tracy = trace(@src()); |
| 3394 | defer tracy.end(); | 3423 | defer tracy.end(); |
| 3395 | | 3424 | |
| 3396 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 3425 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3397 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 3426 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| | 3427 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 3398 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 3428 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3399 | | 3429 | |
| 3400 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); | 3430 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 3401 | const operand = try sema.resolveInst(extra.rhs); | 3431 | const operand = sema.resolveInst(extra.rhs); |
| 3402 | return sema.bitcast(block, dest_type, operand); | 3432 | return sema.bitcast(block, dest_type, operand, operand_src); |
| 3403 | } | 3433 | } |
| 3404 | | 3434 | |
| 3405 | fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3435 | fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3406 | const tracy = trace(@src()); | 3436 | const tracy = trace(@src()); |
| 3407 | defer tracy.end(); | 3437 | defer tracy.end(); |
| 3408 | | 3438 | |
| ... | @@ -3413,7 +3443,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -3413,7 +3443,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 3413 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 3443 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3414 | | 3444 | |
| 3415 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); | 3445 | const dest_type = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 3416 | const operand = try sema.resolveInst(extra.rhs); | 3446 | const operand = sema.resolveInst(extra.rhs); |
| 3417 | | 3447 | |
| 3418 | const dest_is_comptime_float = switch (dest_type.zigTypeTag()) { | 3448 | const dest_is_comptime_float = switch (dest_type.zigTypeTag()) { |
| 3419 | .ComptimeFloat => true, | 3449 | .ComptimeFloat => true, |
| ... | @@ -3445,22 +3475,22 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -3445,22 +3475,22 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 3445 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{}); | 3475 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{}); |
| 3446 | } | 3476 | } |
| 3447 | | 3477 | |
| 3448 | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3478 | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3449 | const tracy = trace(@src()); | 3479 | const tracy = trace(@src()); |
| 3450 | defer tracy.end(); | 3480 | defer tracy.end(); |
| 3451 | | 3481 | |
| 3452 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 3482 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 3453 | const array = try sema.resolveInst(bin_inst.lhs); | 3483 | const array = sema.resolveInst(bin_inst.lhs); |
| 3454 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) | 3484 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) |
| 3455 | array | 3485 | array |
| 3456 | else | 3486 | else |
| 3457 | try sema.analyzeRef(block, sema.src, array); | 3487 | try sema.analyzeRef(block, sema.src, array); |
| 3458 | const elem_index = try sema.resolveInst(bin_inst.rhs); | 3488 | const elem_index = sema.resolveInst(bin_inst.rhs); |
| 3459 | const result_ptr = try sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); | 3489 | const result_ptr = try sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); |
| 3460 | return sema.analyzeLoad(block, sema.src, result_ptr, sema.src); | 3490 | return sema.analyzeLoad(block, sema.src, result_ptr, sema.src); |
| 3461 | } | 3491 | } |
| 3462 | | 3492 | |
| 3463 | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3493 | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3464 | const tracy = trace(@src()); | 3494 | const tracy = trace(@src()); |
| 3465 | defer tracy.end(); | 3495 | defer tracy.end(); |
| 3466 | | 3496 | |
| ... | @@ -3468,27 +3498,27 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -3468,27 +3498,27 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 3468 | const src = inst_data.src(); | 3498 | const src = inst_data.src(); |
| 3469 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; | 3499 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 3470 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 3500 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3471 | const array = try sema.resolveInst(extra.lhs); | 3501 | const array = sema.resolveInst(extra.lhs); |
| 3472 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) | 3502 | const array_ptr = if (array.ty.zigTypeTag() == .Pointer) |
| 3473 | array | 3503 | array |
| 3474 | else | 3504 | else |
| 3475 | try sema.analyzeRef(block, src, array); | 3505 | try sema.analyzeRef(block, src, array); |
| 3476 | const elem_index = try sema.resolveInst(extra.rhs); | 3506 | const elem_index = sema.resolveInst(extra.rhs); |
| 3477 | const result_ptr = try sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); | 3507 | const result_ptr = try sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); |
| 3478 | return sema.analyzeLoad(block, src, result_ptr, src); | 3508 | return sema.analyzeLoad(block, src, result_ptr, src); |
| 3479 | } | 3509 | } |
| 3480 | | 3510 | |
| 3481 | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3511 | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3482 | const tracy = trace(@src()); | 3512 | const tracy = trace(@src()); |
| 3483 | defer tracy.end(); | 3513 | defer tracy.end(); |
| 3484 | | 3514 | |
| 3485 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 3515 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 3486 | const array_ptr = try sema.resolveInst(bin_inst.lhs); | 3516 | const array_ptr = sema.resolveInst(bin_inst.lhs); |
| 3487 | const elem_index = try sema.resolveInst(bin_inst.rhs); | 3517 | const elem_index = sema.resolveInst(bin_inst.rhs); |
| 3488 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); | 3518 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); |
| 3489 | } | 3519 | } |
| 3490 | | 3520 | |
| 3491 | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3521 | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3492 | const tracy = trace(@src()); | 3522 | const tracy = trace(@src()); |
| 3493 | defer tracy.end(); | 3523 | defer tracy.end(); |
| 3494 | | 3524 | |
| ... | @@ -3496,39 +3526,39 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -3496,39 +3526,39 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 3496 | const src = inst_data.src(); | 3526 | const src = inst_data.src(); |
| 3497 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; | 3527 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 3498 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 3528 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3499 | const array_ptr = try sema.resolveInst(extra.lhs); | 3529 | const array_ptr = sema.resolveInst(extra.lhs); |
| 3500 | const elem_index = try sema.resolveInst(extra.rhs); | 3530 | const elem_index = sema.resolveInst(extra.rhs); |
| 3501 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); | 3531 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); |
| 3502 | } | 3532 | } |
| 3503 | | 3533 | |
| 3504 | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3534 | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3505 | const tracy = trace(@src()); | 3535 | const tracy = trace(@src()); |
| 3506 | defer tracy.end(); | 3536 | defer tracy.end(); |
| 3507 | | 3537 | |
| 3508 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 3538 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3509 | const src = inst_data.src(); | 3539 | const src = inst_data.src(); |
| 3510 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; | 3540 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| 3511 | const array_ptr = try sema.resolveInst(extra.lhs); | 3541 | const array_ptr = sema.resolveInst(extra.lhs); |
| 3512 | const start = try sema.resolveInst(extra.start); | 3542 | const start = sema.resolveInst(extra.start); |
| 3513 | | 3543 | |
| 3514 | return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded); | 3544 | return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded); |
| 3515 | } | 3545 | } |
| 3516 | | 3546 | |
| 3517 | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3547 | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3518 | const tracy = trace(@src()); | 3548 | const tracy = trace(@src()); |
| 3519 | defer tracy.end(); | 3549 | defer tracy.end(); |
| 3520 | | 3550 | |
| 3521 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 3551 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 3522 | const src = inst_data.src(); | 3552 | const src = inst_data.src(); |
| 3523 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; | 3553 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| 3524 | const array_ptr = try sema.resolveInst(extra.lhs); | 3554 | const array_ptr = sema.resolveInst(extra.lhs); |
| 3525 | const start = try sema.resolveInst(extra.start); | 3555 | const start = sema.resolveInst(extra.start); |
| 3526 | const end = try sema.resolveInst(extra.end); | 3556 | const end = sema.resolveInst(extra.end); |
| 3527 | | 3557 | |
| 3528 | return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded); | 3558 | return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded); |
| 3529 | } | 3559 | } |
| 3530 | | 3560 | |
| 3531 | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 3561 | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 3532 | const tracy = trace(@src()); | 3562 | const tracy = trace(@src()); |
| 3533 | defer tracy.end(); | 3563 | defer tracy.end(); |
| 3534 | | 3564 | |
| ... | @@ -3536,10 +3566,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -3536,10 +3566,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3536 | const src = inst_data.src(); | 3566 | const src = inst_data.src(); |
| 3537 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; | 3567 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; |
| 3538 | const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; | 3568 | const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; |
| 3539 | const array_ptr = try sema.resolveInst(extra.lhs); | 3569 | const array_ptr = sema.resolveInst(extra.lhs); |
| 3540 | const start = try sema.resolveInst(extra.start); | 3570 | const start = sema.resolveInst(extra.start); |
| 3541 | const end = try sema.resolveInst(extra.end); | 3571 | const end = sema.resolveInst(extra.end); |
| 3542 | const sentinel = try sema.resolveInst(extra.sentinel); | 3572 | const sentinel = sema.resolveInst(extra.sentinel); |
| 3543 | | 3573 | |
| 3544 | return sema.analyzeSlice(block, src, array_ptr, start, end, sentinel, sentinel_src); | 3574 | return sema.analyzeSlice(block, src, array_ptr, start, end, sentinel, sentinel_src); |
| 3545 | } | 3575 | } |
| ... | @@ -3550,7 +3580,7 @@ fn zirSwitchCapture( | ... | @@ -3550,7 +3580,7 @@ fn zirSwitchCapture( |
| 3550 | inst: Zir.Inst.Index, | 3580 | inst: Zir.Inst.Index, |
| 3551 | is_multi: bool, | 3581 | is_multi: bool, |
| 3552 | is_ref: bool, | 3582 | is_ref: bool, |
| 3553 | ) InnerError!Air.Inst.Index { | 3583 | ) InnerError!Air.Inst.Ref { |
| 3554 | const tracy = trace(@src()); | 3584 | const tracy = trace(@src()); |
| 3555 | defer tracy.end(); | 3585 | defer tracy.end(); |
| 3556 | | 3586 | |
| ... | @@ -3569,7 +3599,7 @@ fn zirSwitchCaptureElse( | ... | @@ -3569,7 +3599,7 @@ fn zirSwitchCaptureElse( |
| 3569 | block: *Scope.Block, | 3599 | block: *Scope.Block, |
| 3570 | inst: Zir.Inst.Index, | 3600 | inst: Zir.Inst.Index, |
| 3571 | is_ref: bool, | 3601 | is_ref: bool, |
| 3572 | ) InnerError!Air.Inst.Index { | 3602 | ) InnerError!Air.Inst.Ref { |
| 3573 | const tracy = trace(@src()); | 3603 | const tracy = trace(@src()); |
| 3574 | defer tracy.end(); | 3604 | defer tracy.end(); |
| 3575 | | 3605 | |
| ... | @@ -3588,7 +3618,7 @@ fn zirSwitchBlock( | ... | @@ -3588,7 +3618,7 @@ fn zirSwitchBlock( |
| 3588 | inst: Zir.Inst.Index, | 3618 | inst: Zir.Inst.Index, |
| 3589 | is_ref: bool, | 3619 | is_ref: bool, |
| 3590 | special_prong: Zir.SpecialProng, | 3620 | special_prong: Zir.SpecialProng, |
| 3591 | ) InnerError!Air.Inst.Index { | 3621 | ) InnerError!Air.Inst.Ref { |
| 3592 | const tracy = trace(@src()); | 3622 | const tracy = trace(@src()); |
| 3593 | defer tracy.end(); | 3623 | defer tracy.end(); |
| 3594 | | 3624 | |
| ... | @@ -3597,7 +3627,7 @@ fn zirSwitchBlock( | ... | @@ -3597,7 +3627,7 @@ fn zirSwitchBlock( |
| 3597 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; | 3627 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; |
| 3598 | const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); | 3628 | const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); |
| 3599 | | 3629 | |
| 3600 | const operand_ptr = try sema.resolveInst(extra.data.operand); | 3630 | const operand_ptr = sema.resolveInst(extra.data.operand); |
| 3601 | const operand = if (is_ref) | 3631 | const operand = if (is_ref) |
| 3602 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) | 3632 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) |
| 3603 | else | 3633 | else |
| ... | @@ -3621,7 +3651,7 @@ fn zirSwitchBlockMulti( | ... | @@ -3621,7 +3651,7 @@ fn zirSwitchBlockMulti( |
| 3621 | inst: Zir.Inst.Index, | 3651 | inst: Zir.Inst.Index, |
| 3622 | is_ref: bool, | 3652 | is_ref: bool, |
| 3623 | special_prong: Zir.SpecialProng, | 3653 | special_prong: Zir.SpecialProng, |
| 3624 | ) InnerError!Air.Inst.Index { | 3654 | ) InnerError!Air.Inst.Ref { |
| 3625 | const tracy = trace(@src()); | 3655 | const tracy = trace(@src()); |
| 3626 | defer tracy.end(); | 3656 | defer tracy.end(); |
| 3627 | | 3657 | |
| ... | @@ -3630,7 +3660,7 @@ fn zirSwitchBlockMulti( | ... | @@ -3630,7 +3660,7 @@ fn zirSwitchBlockMulti( |
| 3630 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; | 3660 | const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = inst_data.src_node }; |
| 3631 | const extra = sema.code.extraData(Zir.Inst.SwitchBlockMulti, inst_data.payload_index); | 3661 | const extra = sema.code.extraData(Zir.Inst.SwitchBlockMulti, inst_data.payload_index); |
| 3632 | | 3662 | |
| 3633 | const operand_ptr = try sema.resolveInst(extra.data.operand); | 3663 | const operand_ptr = sema.resolveInst(extra.data.operand); |
| 3634 | const operand = if (is_ref) | 3664 | const operand = if (is_ref) |
| 3635 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) | 3665 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) |
| 3636 | else | 3666 | else |
| ... | @@ -3651,14 +3681,14 @@ fn zirSwitchBlockMulti( | ... | @@ -3651,14 +3681,14 @@ fn zirSwitchBlockMulti( |
| 3651 | fn analyzeSwitch( | 3681 | fn analyzeSwitch( |
| 3652 | sema: *Sema, | 3682 | sema: *Sema, |
| 3653 | block: *Scope.Block, | 3683 | block: *Scope.Block, |
| 3654 | operand: Air.Inst.Index, | 3684 | operand: Air.Inst.Ref, |
| 3655 | extra_end: usize, | 3685 | extra_end: usize, |
| 3656 | special_prong: Zir.SpecialProng, | 3686 | special_prong: Zir.SpecialProng, |
| 3657 | scalar_cases_len: usize, | 3687 | scalar_cases_len: usize, |
| 3658 | multi_cases_len: usize, | 3688 | multi_cases_len: usize, |
| 3659 | switch_inst: Zir.Inst.Index, | 3689 | switch_inst: Zir.Inst.Index, |
| 3660 | src_node_offset: i32, | 3690 | src_node_offset: i32, |
| 3661 | ) InnerError!Air.Inst.Index { | 3691 | ) InnerError!Air.Inst.Ref { |
| 3662 | const gpa = sema.gpa; | 3692 | const gpa = sema.gpa; |
| 3663 | const mod = sema.mod; | 3693 | const mod = sema.mod; |
| 3664 | | 3694 | |
| ... | @@ -4217,7 +4247,7 @@ fn analyzeSwitch( | ... | @@ -4217,7 +4247,7 @@ fn analyzeSwitch( |
| 4217 | const bool_ty = comptime Type.initTag(.bool); | 4247 | const bool_ty = comptime Type.initTag(.bool); |
| 4218 | | 4248 | |
| 4219 | for (items) |item_ref| { | 4249 | for (items) |item_ref| { |
| 4220 | const item = try sema.resolveInst(item_ref); | 4250 | const item = sema.resolveInst(item_ref); |
| 4221 | _ = try sema.resolveConstValue(&child_block, item.src, item); | 4251 | _ = try sema.resolveConstValue(&child_block, item.src, item); |
| 4222 | | 4252 | |
| 4223 | const cmp_ok = try case_block.addBinOp(item.src, bool_ty, .cmp_eq, operand, item); | 4253 | const cmp_ok = try case_block.addBinOp(item.src, bool_ty, .cmp_eq, operand, item); |
| ... | @@ -4235,8 +4265,8 @@ fn analyzeSwitch( | ... | @@ -4235,8 +4265,8 @@ fn analyzeSwitch( |
| 4235 | const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); | 4265 | const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 4236 | extra_index += 1; | 4266 | extra_index += 1; |
| 4237 | | 4267 | |
| 4238 | const item_first = try sema.resolveInst(first_ref); | 4268 | const item_first = sema.resolveInst(first_ref); |
| 4239 | const item_last = try sema.resolveInst(last_ref); | 4269 | const item_last = sema.resolveInst(last_ref); |
| 4240 | | 4270 | |
| 4241 | _ = try sema.resolveConstValue(&child_block, item_first.src, item_first); | 4271 | _ = try sema.resolveConstValue(&child_block, item_first.src, item_first); |
| 4242 | _ = try sema.resolveConstValue(&child_block, item_last.src, item_last); | 4272 | _ = try sema.resolveConstValue(&child_block, item_last.src, item_last); |
| ... | @@ -4334,7 +4364,7 @@ fn resolveSwitchItemVal( | ... | @@ -4334,7 +4364,7 @@ fn resolveSwitchItemVal( |
| 4334 | switch_prong_src: Module.SwitchProngSrc, | 4364 | switch_prong_src: Module.SwitchProngSrc, |
| 4335 | range_expand: Module.SwitchProngSrc.RangeExpand, | 4365 | range_expand: Module.SwitchProngSrc.RangeExpand, |
| 4336 | ) InnerError!TypedValue { | 4366 | ) InnerError!TypedValue { |
| 4337 | const item = try sema.resolveInst(item_ref); | 4367 | const item = sema.resolveInst(item_ref); |
| 4338 | // We have to avoid the other helper functions here because we cannot construct a LazySrcLoc | 4368 | // We have to avoid the other helper functions here because we cannot construct a LazySrcLoc |
| 4339 | // because we only have the switch AST node. Only if we know for sure we need to report | 4369 | // because we only have the switch AST node. Only if we know for sure we need to report |
| 4340 | // a compile error do we resolve the full source locations. | 4370 | // a compile error do we resolve the full source locations. |
| ... | @@ -4513,7 +4543,7 @@ fn validateSwitchNoRange( | ... | @@ -4513,7 +4543,7 @@ fn validateSwitchNoRange( |
| 4513 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); | 4543 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); |
| 4514 | } | 4544 | } |
| 4515 | | 4545 | |
| 4516 | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4546 | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4517 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4547 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4518 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4548 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4519 | _ = extra; | 4549 | _ = extra; |
| ... | @@ -4522,7 +4552,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -4522,7 +4552,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 4522 | return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); | 4552 | return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); |
| 4523 | } | 4553 | } |
| 4524 | | 4554 | |
| 4525 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4555 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4526 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4556 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4527 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4557 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4528 | const src = inst_data.src(); | 4558 | const src = inst_data.src(); |
| ... | @@ -4547,7 +4577,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -4547,7 +4577,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 4547 | return mod.constBool(arena, src, false); | 4577 | return mod.constBool(arena, src, false); |
| 4548 | } | 4578 | } |
| 4549 | | 4579 | |
| 4550 | fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4580 | fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4551 | const tracy = trace(@src()); | 4581 | const tracy = trace(@src()); |
| 4552 | defer tracy.end(); | 4582 | defer tracy.end(); |
| 4553 | | 4583 | |
| ... | @@ -4572,13 +4602,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -4572,13 +4602,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4572 | return mod.constType(sema.arena, src, file_root_decl.ty); | 4602 | return mod.constType(sema.arena, src, file_root_decl.ty); |
| 4573 | } | 4603 | } |
| 4574 | | 4604 | |
| 4575 | fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4605 | fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4576 | _ = block; | 4606 | _ = block; |
| 4577 | _ = inst; | 4607 | _ = inst; |
| 4578 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{}); | 4608 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{}); |
| 4579 | } | 4609 | } |
| 4580 | | 4610 | |
| 4581 | fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4611 | fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4582 | const tracy = trace(@src()); | 4612 | const tracy = trace(@src()); |
| 4583 | defer tracy.end(); | 4613 | defer tracy.end(); |
| 4584 | | 4614 | |
| ... | @@ -4587,7 +4617,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air | ... | @@ -4587,7 +4617,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air |
| 4587 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); | 4617 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); |
| 4588 | } | 4618 | } |
| 4589 | | 4619 | |
| 4590 | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4620 | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4591 | const tracy = trace(@src()); | 4621 | const tracy = trace(@src()); |
| 4592 | defer tracy.end(); | 4622 | defer tracy.end(); |
| 4593 | | 4623 | |
| ... | @@ -4599,8 +4629,8 @@ fn zirBitwise( | ... | @@ -4599,8 +4629,8 @@ fn zirBitwise( |
| 4599 | sema: *Sema, | 4629 | sema: *Sema, |
| 4600 | block: *Scope.Block, | 4630 | block: *Scope.Block, |
| 4601 | inst: Zir.Inst.Index, | 4631 | inst: Zir.Inst.Index, |
| 4602 | ir_tag: ir.Inst.Tag, | 4632 | air_tag: Air.Inst.Tag, |
| 4603 | ) InnerError!Air.Inst.Index { | 4633 | ) InnerError!Air.Inst.Ref { |
| 4604 | const tracy = trace(@src()); | 4634 | const tracy = trace(@src()); |
| 4605 | defer tracy.end(); | 4635 | defer tracy.end(); |
| 4606 | | 4636 | |
| ... | @@ -4609,8 +4639,8 @@ fn zirBitwise( | ... | @@ -4609,8 +4639,8 @@ fn zirBitwise( |
| 4609 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 4639 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4610 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 4640 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 4611 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4641 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4612 | const lhs = try sema.resolveInst(extra.lhs); | 4642 | const lhs = sema.resolveInst(extra.lhs); |
| 4613 | const rhs = try sema.resolveInst(extra.rhs); | 4643 | const rhs = sema.resolveInst(extra.rhs); |
| 4614 | | 4644 | |
| 4615 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; | 4645 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; |
| 4616 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); | 4646 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| ... | @@ -4655,10 +4685,10 @@ fn zirBitwise( | ... | @@ -4655,10 +4685,10 @@ fn zirBitwise( |
| 4655 | } | 4685 | } |
| 4656 | | 4686 | |
| 4657 | try sema.requireRuntimeBlock(block, src); | 4687 | try sema.requireRuntimeBlock(block, src); |
| 4658 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 4688 | return block.addBinOp(src, scalar_type, air_tag, casted_lhs, casted_rhs); |
| 4659 | } | 4689 | } |
| 4660 | | 4690 | |
| 4661 | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4691 | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4662 | const tracy = trace(@src()); | 4692 | const tracy = trace(@src()); |
| 4663 | defer tracy.end(); | 4693 | defer tracy.end(); |
| 4664 | | 4694 | |
| ... | @@ -4666,7 +4696,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -4666,7 +4696,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4666 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); | 4696 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); |
| 4667 | } | 4697 | } |
| 4668 | | 4698 | |
| 4669 | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4699 | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4670 | const tracy = trace(@src()); | 4700 | const tracy = trace(@src()); |
| 4671 | defer tracy.end(); | 4701 | defer tracy.end(); |
| 4672 | | 4702 | |
| ... | @@ -4674,7 +4704,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -4674,7 +4704,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 4674 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); | 4704 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); |
| 4675 | } | 4705 | } |
| 4676 | | 4706 | |
| 4677 | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4707 | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4678 | const tracy = trace(@src()); | 4708 | const tracy = trace(@src()); |
| 4679 | defer tracy.end(); | 4709 | defer tracy.end(); |
| 4680 | | 4710 | |
| ... | @@ -4687,7 +4717,7 @@ fn zirNegate( | ... | @@ -4687,7 +4717,7 @@ fn zirNegate( |
| 4687 | block: *Scope.Block, | 4717 | block: *Scope.Block, |
| 4688 | inst: Zir.Inst.Index, | 4718 | inst: Zir.Inst.Index, |
| 4689 | tag_override: Zir.Inst.Tag, | 4719 | tag_override: Zir.Inst.Tag, |
| 4690 | ) InnerError!Air.Inst.Index { | 4720 | ) InnerError!Air.Inst.Ref { |
| 4691 | const tracy = trace(@src()); | 4721 | const tracy = trace(@src()); |
| 4692 | defer tracy.end(); | 4722 | defer tracy.end(); |
| 4693 | | 4723 | |
| ... | @@ -4695,13 +4725,13 @@ fn zirNegate( | ... | @@ -4695,13 +4725,13 @@ fn zirNegate( |
| 4695 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 4725 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 4696 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 4726 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4697 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 4727 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 4698 | const lhs = try sema.resolveInst(.zero); | 4728 | const lhs = sema.resolveInst(.zero); |
| 4699 | const rhs = try sema.resolveInst(inst_data.operand); | 4729 | const rhs = sema.resolveInst(inst_data.operand); |
| 4700 | | 4730 | |
| 4701 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src); | 4731 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src); |
| 4702 | } | 4732 | } |
| 4703 | | 4733 | |
| 4704 | fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4734 | fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4705 | const tracy = trace(@src()); | 4735 | const tracy = trace(@src()); |
| 4706 | defer tracy.end(); | 4736 | defer tracy.end(); |
| 4707 | | 4737 | |
| ... | @@ -4711,8 +4741,8 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -4711,8 +4741,8 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 4711 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 4741 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4712 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 4742 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 4713 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4743 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4714 | const lhs = try sema.resolveInst(extra.lhs); | 4744 | const lhs = sema.resolveInst(extra.lhs); |
| 4715 | const rhs = try sema.resolveInst(extra.rhs); | 4745 | const rhs = sema.resolveInst(extra.rhs); |
| 4716 | | 4746 | |
| 4717 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, sema.src, lhs_src, rhs_src); | 4747 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, sema.src, lhs_src, rhs_src); |
| 4718 | } | 4748 | } |
| ... | @@ -4721,7 +4751,7 @@ fn zirOverflowArithmetic( | ... | @@ -4721,7 +4751,7 @@ fn zirOverflowArithmetic( |
| 4721 | sema: *Sema, | 4751 | sema: *Sema, |
| 4722 | block: *Scope.Block, | 4752 | block: *Scope.Block, |
| 4723 | extended: Zir.Inst.Extended.InstData, | 4753 | extended: Zir.Inst.Extended.InstData, |
| 4724 | ) InnerError!Air.Inst.Index { | 4754 | ) InnerError!Air.Inst.Ref { |
| 4725 | const tracy = trace(@src()); | 4755 | const tracy = trace(@src()); |
| 4726 | defer tracy.end(); | 4756 | defer tracy.end(); |
| 4727 | | 4757 | |
| ... | @@ -4735,12 +4765,12 @@ fn analyzeArithmetic( | ... | @@ -4735,12 +4765,12 @@ fn analyzeArithmetic( |
| 4735 | sema: *Sema, | 4765 | sema: *Sema, |
| 4736 | block: *Scope.Block, | 4766 | block: *Scope.Block, |
| 4737 | zir_tag: Zir.Inst.Tag, | 4767 | zir_tag: Zir.Inst.Tag, |
| 4738 | lhs: Air.Inst.Index, | 4768 | lhs: Air.Inst.Ref, |
| 4739 | rhs: Air.Inst.Index, | 4769 | rhs: Air.Inst.Ref, |
| 4740 | src: LazySrcLoc, | 4770 | src: LazySrcLoc, |
| 4741 | lhs_src: LazySrcLoc, | 4771 | lhs_src: LazySrcLoc, |
| 4742 | rhs_src: LazySrcLoc, | 4772 | rhs_src: LazySrcLoc, |
| 4743 | ) InnerError!Air.Inst.Index { | 4773 | ) InnerError!Air.Inst.Ref { |
| 4744 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; | 4774 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; |
| 4745 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); | 4775 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 4746 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); | 4776 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| ... | @@ -4850,14 +4880,14 @@ fn analyzeArithmetic( | ... | @@ -4850,14 +4880,14 @@ fn analyzeArithmetic( |
| 4850 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 4880 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); |
| 4851 | } | 4881 | } |
| 4852 | | 4882 | |
| 4853 | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 4883 | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 4854 | const tracy = trace(@src()); | 4884 | const tracy = trace(@src()); |
| 4855 | defer tracy.end(); | 4885 | defer tracy.end(); |
| 4856 | | 4886 | |
| 4857 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 4887 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 4858 | const src = inst_data.src(); | 4888 | const src = inst_data.src(); |
| 4859 | const ptr_src: LazySrcLoc = .{ .node_offset_deref_ptr = inst_data.src_node }; | 4889 | const ptr_src: LazySrcLoc = .{ .node_offset_deref_ptr = inst_data.src_node }; |
| 4860 | const ptr = try sema.resolveInst(inst_data.operand); | 4890 | const ptr = sema.resolveInst(inst_data.operand); |
| 4861 | return sema.analyzeLoad(block, src, ptr, ptr_src); | 4891 | return sema.analyzeLoad(block, src, ptr, ptr_src); |
| 4862 | } | 4892 | } |
| 4863 | | 4893 | |
| ... | @@ -4865,7 +4895,7 @@ fn zirAsm( | ... | @@ -4865,7 +4895,7 @@ fn zirAsm( |
| 4865 | sema: *Sema, | 4895 | sema: *Sema, |
| 4866 | block: *Scope.Block, | 4896 | block: *Scope.Block, |
| 4867 | extended: Zir.Inst.Extended.InstData, | 4897 | extended: Zir.Inst.Extended.InstData, |
| 4868 | ) InnerError!Air.Inst.Index { | 4898 | ) InnerError!Air.Inst.Ref { |
| 4869 | const tracy = trace(@src()); | 4899 | const tracy = trace(@src()); |
| 4870 | defer tracy.end(); | 4900 | defer tracy.end(); |
| 4871 | | 4901 | |
| ... | @@ -4915,7 +4945,7 @@ fn zirAsm( | ... | @@ -4915,7 +4945,7 @@ fn zirAsm( |
| 4915 | const name = sema.code.nullTerminatedString(input.data.name); | 4945 | const name = sema.code.nullTerminatedString(input.data.name); |
| 4916 | _ = name; // TODO: use the name | 4946 | _ = name; // TODO: use the name |
| 4917 | | 4947 | |
| 4918 | arg.* = try sema.resolveInst(input.data.operand); | 4948 | arg.* = sema.resolveInst(input.data.operand); |
| 4919 | inputs[arg_i] = sema.code.nullTerminatedString(input.data.constraint); | 4949 | inputs[arg_i] = sema.code.nullTerminatedString(input.data.constraint); |
| 4920 | } | 4950 | } |
| 4921 | | 4951 | |
| ... | @@ -4949,7 +4979,7 @@ fn zirCmp( | ... | @@ -4949,7 +4979,7 @@ fn zirCmp( |
| 4949 | block: *Scope.Block, | 4979 | block: *Scope.Block, |
| 4950 | inst: Zir.Inst.Index, | 4980 | inst: Zir.Inst.Index, |
| 4951 | op: std.math.CompareOperator, | 4981 | op: std.math.CompareOperator, |
| 4952 | ) InnerError!Air.Inst.Index { | 4982 | ) InnerError!Air.Inst.Ref { |
| 4953 | const tracy = trace(@src()); | 4983 | const tracy = trace(@src()); |
| 4954 | defer tracy.end(); | 4984 | defer tracy.end(); |
| 4955 | | 4985 | |
| ... | @@ -4960,8 +4990,8 @@ fn zirCmp( | ... | @@ -4960,8 +4990,8 @@ fn zirCmp( |
| 4960 | const src: LazySrcLoc = inst_data.src(); | 4990 | const src: LazySrcLoc = inst_data.src(); |
| 4961 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 4991 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 4962 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 4992 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 4963 | const lhs = try sema.resolveInst(extra.lhs); | 4993 | const lhs = sema.resolveInst(extra.lhs); |
| 4964 | const rhs = try sema.resolveInst(extra.rhs); | 4994 | const rhs = sema.resolveInst(extra.rhs); |
| 4965 | | 4995 | |
| 4966 | const is_equality_cmp = switch (op) { | 4996 | const is_equality_cmp = switch (op) { |
| 4967 | .eq, .neq => true, | 4997 | .eq, .neq => true, |
| ... | @@ -5047,7 +5077,7 @@ fn zirCmp( | ... | @@ -5047,7 +5077,7 @@ fn zirCmp( |
| 5047 | return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs); | 5077 | return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs); |
| 5048 | } | 5078 | } |
| 5049 | | 5079 | |
| 5050 | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5080 | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5051 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5081 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5052 | const src = inst_data.src(); | 5082 | const src = inst_data.src(); |
| 5053 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5083 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -5057,7 +5087,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -5057,7 +5087,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 5057 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size); | 5087 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size); |
| 5058 | } | 5088 | } |
| 5059 | | 5089 | |
| 5060 | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5090 | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5061 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5091 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5062 | const src = inst_data.src(); | 5092 | const src = inst_data.src(); |
| 5063 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5093 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -5071,7 +5101,7 @@ fn zirThis( | ... | @@ -5071,7 +5101,7 @@ fn zirThis( |
| 5071 | sema: *Sema, | 5101 | sema: *Sema, |
| 5072 | block: *Scope.Block, | 5102 | block: *Scope.Block, |
| 5073 | extended: Zir.Inst.Extended.InstData, | 5103 | extended: Zir.Inst.Extended.InstData, |
| 5074 | ) InnerError!Air.Inst.Index { | 5104 | ) InnerError!Air.Inst.Ref { |
| 5075 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5105 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5076 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); | 5106 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); |
| 5077 | } | 5107 | } |
| ... | @@ -5080,7 +5110,7 @@ fn zirRetAddr( | ... | @@ -5080,7 +5110,7 @@ fn zirRetAddr( |
| 5080 | sema: *Sema, | 5110 | sema: *Sema, |
| 5081 | block: *Scope.Block, | 5111 | block: *Scope.Block, |
| 5082 | extended: Zir.Inst.Extended.InstData, | 5112 | extended: Zir.Inst.Extended.InstData, |
| 5083 | ) InnerError!Air.Inst.Index { | 5113 | ) InnerError!Air.Inst.Ref { |
| 5084 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5114 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5085 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); | 5115 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); |
| 5086 | } | 5116 | } |
| ... | @@ -5089,12 +5119,12 @@ fn zirBuiltinSrc( | ... | @@ -5089,12 +5119,12 @@ fn zirBuiltinSrc( |
| 5089 | sema: *Sema, | 5119 | sema: *Sema, |
| 5090 | block: *Scope.Block, | 5120 | block: *Scope.Block, |
| 5091 | extended: Zir.Inst.Extended.InstData, | 5121 | extended: Zir.Inst.Extended.InstData, |
| 5092 | ) InnerError!Air.Inst.Index { | 5122 | ) InnerError!Air.Inst.Ref { |
| 5093 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5123 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5094 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{}); | 5124 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{}); |
| 5095 | } | 5125 | } |
| 5096 | | 5126 | |
| 5097 | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5127 | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5098 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5128 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5099 | const src = inst_data.src(); | 5129 | const src = inst_data.src(); |
| 5100 | const ty = try sema.resolveType(block, src, inst_data.operand); | 5130 | const ty = try sema.resolveType(block, src, inst_data.operand); |
| ... | @@ -5137,31 +5167,31 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -5137,31 +5167,31 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5137 | } | 5167 | } |
| 5138 | } | 5168 | } |
| 5139 | | 5169 | |
| 5140 | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5170 | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5141 | _ = block; | 5171 | _ = block; |
| 5142 | const zir_datas = sema.code.instructions.items(.data); | 5172 | const zir_datas = sema.code.instructions.items(.data); |
| 5143 | const inst_data = zir_datas[inst].un_node; | 5173 | const inst_data = zir_datas[inst].un_node; |
| 5144 | const src = inst_data.src(); | 5174 | const src = inst_data.src(); |
| 5145 | const operand = try sema.resolveInst(inst_data.operand); | 5175 | const operand = sema.resolveInst(inst_data.operand); |
| 5146 | return sema.mod.constType(sema.arena, src, operand.ty); | 5176 | return sema.mod.constType(sema.arena, src, operand.ty); |
| 5147 | } | 5177 | } |
| 5148 | | 5178 | |
| 5149 | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5179 | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5150 | _ = block; | 5180 | _ = block; |
| 5151 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5181 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5152 | const src = inst_data.src(); | 5182 | const src = inst_data.src(); |
| 5153 | const operand_ptr = try sema.resolveInst(inst_data.operand); | 5183 | const operand_ptr = sema.resolveInst(inst_data.operand); |
| 5154 | const elem_ty = operand_ptr.ty.elemType(); | 5184 | const elem_ty = operand_ptr.ty.elemType(); |
| 5155 | return sema.mod.constType(sema.arena, src, elem_ty); | 5185 | return sema.mod.constType(sema.arena, src, elem_ty); |
| 5156 | } | 5186 | } |
| 5157 | | 5187 | |
| 5158 | fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5188 | fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5159 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5189 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5160 | const src = inst_data.src(); | 5190 | const src = inst_data.src(); |
| 5161 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{}); | 5191 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{}); |
| 5162 | } | 5192 | } |
| 5163 | | 5193 | |
| 5164 | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5194 | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5165 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5195 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5166 | const src = inst_data.src(); | 5196 | const src = inst_data.src(); |
| 5167 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{}); | 5197 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{}); |
| ... | @@ -5171,7 +5201,7 @@ fn zirTypeofPeer( | ... | @@ -5171,7 +5201,7 @@ fn zirTypeofPeer( |
| 5171 | sema: *Sema, | 5201 | sema: *Sema, |
| 5172 | block: *Scope.Block, | 5202 | block: *Scope.Block, |
| 5173 | extended: Zir.Inst.Extended.InstData, | 5203 | extended: Zir.Inst.Extended.InstData, |
| 5174 | ) InnerError!Air.Inst.Index { | 5204 | ) InnerError!Air.Inst.Ref { |
| 5175 | const tracy = trace(@src()); | 5205 | const tracy = trace(@src()); |
| 5176 | defer tracy.end(); | 5206 | defer tracy.end(); |
| 5177 | | 5207 | |
| ... | @@ -5183,20 +5213,20 @@ fn zirTypeofPeer( | ... | @@ -5183,20 +5213,20 @@ fn zirTypeofPeer( |
| 5183 | defer sema.gpa.free(inst_list); | 5213 | defer sema.gpa.free(inst_list); |
| 5184 | | 5214 | |
| 5185 | for (args) |arg_ref, i| { | 5215 | for (args) |arg_ref, i| { |
| 5186 | inst_list[i] = try sema.resolveInst(arg_ref); | 5216 | inst_list[i] = sema.resolveInst(arg_ref); |
| 5187 | } | 5217 | } |
| 5188 | | 5218 | |
| 5189 | const result_type = try sema.resolvePeerTypes(block, src, inst_list); | 5219 | const result_type = try sema.resolvePeerTypes(block, src, inst_list); |
| 5190 | return sema.mod.constType(sema.arena, src, result_type); | 5220 | return sema.mod.constType(sema.arena, src, result_type); |
| 5191 | } | 5221 | } |
| 5192 | | 5222 | |
| 5193 | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5223 | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5194 | const tracy = trace(@src()); | 5224 | const tracy = trace(@src()); |
| 5195 | defer tracy.end(); | 5225 | defer tracy.end(); |
| 5196 | | 5226 | |
| 5197 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5227 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5198 | const src = inst_data.src(); | 5228 | const src = inst_data.src(); |
| 5199 | const uncasted_operand = try sema.resolveInst(inst_data.operand); | 5229 | const uncasted_operand = sema.resolveInst(inst_data.operand); |
| 5200 | | 5230 | |
| 5201 | const bool_type = Type.initTag(.bool); | 5231 | const bool_type = Type.initTag(.bool); |
| 5202 | const operand = try sema.coerce(block, bool_type, uncasted_operand, uncasted_operand.src); | 5232 | const operand = try sema.coerce(block, bool_type, uncasted_operand, uncasted_operand.src); |
| ... | @@ -5212,16 +5242,16 @@ fn zirBoolOp( | ... | @@ -5212,16 +5242,16 @@ fn zirBoolOp( |
| 5212 | block: *Scope.Block, | 5242 | block: *Scope.Block, |
| 5213 | inst: Zir.Inst.Index, | 5243 | inst: Zir.Inst.Index, |
| 5214 | comptime is_bool_or: bool, | 5244 | comptime is_bool_or: bool, |
| 5215 | ) InnerError!Air.Inst.Index { | 5245 | ) InnerError!Air.Inst.Ref { |
| 5216 | const tracy = trace(@src()); | 5246 | const tracy = trace(@src()); |
| 5217 | defer tracy.end(); | 5247 | defer tracy.end(); |
| 5218 | | 5248 | |
| 5219 | const src: LazySrcLoc = .unneeded; | 5249 | const src: LazySrcLoc = .unneeded; |
| 5220 | const bool_type = Type.initTag(.bool); | 5250 | const bool_type = Type.initTag(.bool); |
| 5221 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 5251 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 5222 | const uncasted_lhs = try sema.resolveInst(bin_inst.lhs); | 5252 | const uncasted_lhs = sema.resolveInst(bin_inst.lhs); |
| 5223 | const lhs = try sema.coerce(block, bool_type, uncasted_lhs, uncasted_lhs.src); | 5253 | const lhs = try sema.coerce(block, bool_type, uncasted_lhs, uncasted_lhs.src); |
| 5224 | const uncasted_rhs = try sema.resolveInst(bin_inst.rhs); | 5254 | const uncasted_rhs = sema.resolveInst(bin_inst.rhs); |
| 5225 | const rhs = try sema.coerce(block, bool_type, uncasted_rhs, uncasted_rhs.src); | 5255 | const rhs = try sema.coerce(block, bool_type, uncasted_rhs, uncasted_rhs.src); |
| 5226 | | 5256 | |
| 5227 | if (lhs.value()) |lhs_val| { | 5257 | if (lhs.value()) |lhs_val| { |
| ... | @@ -5234,7 +5264,7 @@ fn zirBoolOp( | ... | @@ -5234,7 +5264,7 @@ fn zirBoolOp( |
| 5234 | } | 5264 | } |
| 5235 | } | 5265 | } |
| 5236 | try sema.requireRuntimeBlock(block, src); | 5266 | try sema.requireRuntimeBlock(block, src); |
| 5237 | const tag: ir.Inst.Tag = if (is_bool_or) .bool_or else .bool_and; | 5267 | const tag: Air.Inst.Tag = if (is_bool_or) .bool_or else .bool_and; |
| 5238 | return block.addBinOp(src, bool_type, tag, lhs, rhs); | 5268 | return block.addBinOp(src, bool_type, tag, lhs, rhs); |
| 5239 | } | 5269 | } |
| 5240 | | 5270 | |
| ... | @@ -5243,14 +5273,14 @@ fn zirBoolBr( | ... | @@ -5243,14 +5273,14 @@ fn zirBoolBr( |
| 5243 | parent_block: *Scope.Block, | 5273 | parent_block: *Scope.Block, |
| 5244 | inst: Zir.Inst.Index, | 5274 | inst: Zir.Inst.Index, |
| 5245 | is_bool_or: bool, | 5275 | is_bool_or: bool, |
| 5246 | ) InnerError!Air.Inst.Index { | 5276 | ) InnerError!Air.Inst.Ref { |
| 5247 | const tracy = trace(@src()); | 5277 | const tracy = trace(@src()); |
| 5248 | defer tracy.end(); | 5278 | defer tracy.end(); |
| 5249 | | 5279 | |
| 5250 | const datas = sema.code.instructions.items(.data); | 5280 | const datas = sema.code.instructions.items(.data); |
| 5251 | const inst_data = datas[inst].bool_br; | 5281 | const inst_data = datas[inst].bool_br; |
| 5252 | const src: LazySrcLoc = .unneeded; | 5282 | const src: LazySrcLoc = .unneeded; |
| 5253 | const lhs = try sema.resolveInst(inst_data.lhs); | 5283 | const lhs = sema.resolveInst(inst_data.lhs); |
| 5254 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); | 5284 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 5255 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 5285 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| 5256 | | 5286 | |
| ... | @@ -5313,13 +5343,13 @@ fn zirIsNonNull( | ... | @@ -5313,13 +5343,13 @@ fn zirIsNonNull( |
| 5313 | sema: *Sema, | 5343 | sema: *Sema, |
| 5314 | block: *Scope.Block, | 5344 | block: *Scope.Block, |
| 5315 | inst: Zir.Inst.Index, | 5345 | inst: Zir.Inst.Index, |
| 5316 | ) InnerError!Air.Inst.Index { | 5346 | ) InnerError!Air.Inst.Ref { |
| 5317 | const tracy = trace(@src()); | 5347 | const tracy = trace(@src()); |
| 5318 | defer tracy.end(); | 5348 | defer tracy.end(); |
| 5319 | | 5349 | |
| 5320 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5350 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5321 | const src = inst_data.src(); | 5351 | const src = inst_data.src(); |
| 5322 | const operand = try sema.resolveInst(inst_data.operand); | 5352 | const operand = sema.resolveInst(inst_data.operand); |
| 5323 | return sema.analyzeIsNull(block, src, operand, true); | 5353 | return sema.analyzeIsNull(block, src, operand, true); |
| 5324 | } | 5354 | } |
| 5325 | | 5355 | |
| ... | @@ -5327,33 +5357,33 @@ fn zirIsNonNullPtr( | ... | @@ -5327,33 +5357,33 @@ fn zirIsNonNullPtr( |
| 5327 | sema: *Sema, | 5357 | sema: *Sema, |
| 5328 | block: *Scope.Block, | 5358 | block: *Scope.Block, |
| 5329 | inst: Zir.Inst.Index, | 5359 | inst: Zir.Inst.Index, |
| 5330 | ) InnerError!Air.Inst.Index { | 5360 | ) InnerError!Air.Inst.Ref { |
| 5331 | const tracy = trace(@src()); | 5361 | const tracy = trace(@src()); |
| 5332 | defer tracy.end(); | 5362 | defer tracy.end(); |
| 5333 | | 5363 | |
| 5334 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5364 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5335 | const src = inst_data.src(); | 5365 | const src = inst_data.src(); |
| 5336 | const ptr = try sema.resolveInst(inst_data.operand); | 5366 | const ptr = sema.resolveInst(inst_data.operand); |
| 5337 | const loaded = try sema.analyzeLoad(block, src, ptr, src); | 5367 | const loaded = try sema.analyzeLoad(block, src, ptr, src); |
| 5338 | return sema.analyzeIsNull(block, src, loaded, true); | 5368 | return sema.analyzeIsNull(block, src, loaded, true); |
| 5339 | } | 5369 | } |
| 5340 | | 5370 | |
| 5341 | fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5371 | fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5342 | const tracy = trace(@src()); | 5372 | const tracy = trace(@src()); |
| 5343 | defer tracy.end(); | 5373 | defer tracy.end(); |
| 5344 | | 5374 | |
| 5345 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5375 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5346 | const operand = try sema.resolveInst(inst_data.operand); | 5376 | const operand = sema.resolveInst(inst_data.operand); |
| 5347 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); | 5377 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); |
| 5348 | } | 5378 | } |
| 5349 | | 5379 | |
| 5350 | fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5380 | fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5351 | const tracy = trace(@src()); | 5381 | const tracy = trace(@src()); |
| 5352 | defer tracy.end(); | 5382 | defer tracy.end(); |
| 5353 | | 5383 | |
| 5354 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5384 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5355 | const src = inst_data.src(); | 5385 | const src = inst_data.src(); |
| 5356 | const ptr = try sema.resolveInst(inst_data.operand); | 5386 | const ptr = sema.resolveInst(inst_data.operand); |
| 5357 | const loaded = try sema.analyzeLoad(block, src, ptr, src); | 5387 | const loaded = try sema.analyzeLoad(block, src, ptr, src); |
| 5358 | return sema.analyzeIsNonErr(block, src, loaded); | 5388 | return sema.analyzeIsNonErr(block, src, loaded); |
| 5359 | } | 5389 | } |
| ... | @@ -5374,7 +5404,7 @@ fn zirCondbr( | ... | @@ -5374,7 +5404,7 @@ fn zirCondbr( |
| 5374 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; | 5404 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 5375 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; | 5405 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; |
| 5376 | | 5406 | |
| 5377 | const uncasted_cond = try sema.resolveInst(extra.data.condition); | 5407 | const uncasted_cond = sema.resolveInst(extra.data.condition); |
| 5378 | const cond = try sema.coerce(parent_block, Type.initTag(.bool), uncasted_cond, cond_src); | 5408 | const cond = try sema.coerce(parent_block, Type.initTag(.bool), uncasted_cond, cond_src); |
| 5379 | | 5409 | |
| 5380 | if (try sema.resolveDefinedValue(parent_block, src, cond)) |cond_val| { | 5410 | if (try sema.resolveDefinedValue(parent_block, src, cond)) |cond_val| { |
| ... | @@ -5456,7 +5486,7 @@ fn zirRetCoerce( | ... | @@ -5456,7 +5486,7 @@ fn zirRetCoerce( |
| 5456 | defer tracy.end(); | 5486 | defer tracy.end(); |
| 5457 | | 5487 | |
| 5458 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; | 5488 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 5459 | const operand = try sema.resolveInst(inst_data.operand); | 5489 | const operand = sema.resolveInst(inst_data.operand); |
| 5460 | const src = inst_data.src(); | 5490 | const src = inst_data.src(); |
| 5461 | | 5491 | |
| 5462 | return sema.analyzeRet(block, operand, src, need_coercion); | 5492 | return sema.analyzeRet(block, operand, src, need_coercion); |
| ... | @@ -5467,7 +5497,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -5467,7 +5497,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 5467 | defer tracy.end(); | 5497 | defer tracy.end(); |
| 5468 | | 5498 | |
| 5469 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5499 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5470 | const operand = try sema.resolveInst(inst_data.operand); | 5500 | const operand = sema.resolveInst(inst_data.operand); |
| 5471 | const src = inst_data.src(); | 5501 | const src = inst_data.src(); |
| 5472 | | 5502 | |
| 5473 | return sema.analyzeRet(block, operand, src, false); | 5503 | return sema.analyzeRet(block, operand, src, false); |
| ... | @@ -5476,7 +5506,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -5476,7 +5506,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 5476 | fn analyzeRet( | 5506 | fn analyzeRet( |
| 5477 | sema: *Sema, | 5507 | sema: *Sema, |
| 5478 | block: *Scope.Block, | 5508 | block: *Scope.Block, |
| 5479 | operand: Air.Inst.Index, | 5509 | operand: Air.Inst.Ref, |
| 5480 | src: LazySrcLoc, | 5510 | src: LazySrcLoc, |
| 5481 | need_coercion: bool, | 5511 | need_coercion: bool, |
| 5482 | ) InnerError!Zir.Inst.Index { | 5512 | ) InnerError!Zir.Inst.Index { |
| ... | @@ -5511,7 +5541,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { | ... | @@ -5511,7 +5541,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { |
| 5511 | }; | 5541 | }; |
| 5512 | } | 5542 | } |
| 5513 | | 5543 | |
| 5514 | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5544 | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5515 | const tracy = trace(@src()); | 5545 | const tracy = trace(@src()); |
| 5516 | defer tracy.end(); | 5546 | defer tracy.end(); |
| 5517 | | 5547 | |
| ... | @@ -5532,7 +5562,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -5532,7 +5562,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 5532 | return sema.mod.constType(sema.arena, .unneeded, ty); | 5562 | return sema.mod.constType(sema.arena, .unneeded, ty); |
| 5533 | } | 5563 | } |
| 5534 | | 5564 | |
| 5535 | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5565 | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5536 | const tracy = trace(@src()); | 5566 | const tracy = trace(@src()); |
| 5537 | defer tracy.end(); | 5567 | defer tracy.end(); |
| 5538 | | 5568 | |
| ... | @@ -5586,7 +5616,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -5586,7 +5616,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 5586 | return sema.mod.constType(sema.arena, src, ty); | 5616 | return sema.mod.constType(sema.arena, src, ty); |
| 5587 | } | 5617 | } |
| 5588 | | 5618 | |
| 5589 | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5619 | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5590 | const tracy = trace(@src()); | 5620 | const tracy = trace(@src()); |
| 5591 | defer tracy.end(); | 5621 | defer tracy.end(); |
| 5592 | | 5622 | |
| ... | @@ -5600,13 +5630,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In | ... | @@ -5600,13 +5630,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 5600 | }); | 5630 | }); |
| 5601 | } | 5631 | } |
| 5602 | | 5632 | |
| 5603 | fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5633 | fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5604 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5634 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5605 | const src = inst_data.src(); | 5635 | const src = inst_data.src(); |
| 5606 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{}); | 5636 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{}); |
| 5607 | } | 5637 | } |
| 5608 | | 5638 | |
| 5609 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { | 5639 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref { |
| 5610 | const mod = sema.mod; | 5640 | const mod = sema.mod; |
| 5611 | const gpa = sema.gpa; | 5641 | const gpa = sema.gpa; |
| 5612 | const zir_datas = sema.code.instructions.items(.data); | 5642 | const zir_datas = sema.code.instructions.items(.data); |
| ... | @@ -5657,7 +5687,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: | ... | @@ -5657,7 +5687,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5657 | return mod.failWithOwnedErrorMsg(&block.base, msg); | 5687 | return mod.failWithOwnedErrorMsg(&block.base, msg); |
| 5658 | } | 5688 | } |
| 5659 | found_fields[field_index] = item.data.field_type; | 5689 | found_fields[field_index] = item.data.field_type; |
| 5660 | field_inits[field_index] = try sema.resolveInst(item.data.init); | 5690 | field_inits[field_index] = sema.resolveInst(item.data.init); |
| 5661 | } | 5691 | } |
| 5662 | | 5692 | |
| 5663 | var root_msg: ?*Module.ErrorMsg = null; | 5693 | var root_msg: ?*Module.ErrorMsg = null; |
| ... | @@ -5719,7 +5749,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: | ... | @@ -5719,7 +5749,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5719 | return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{}); | 5749 | return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{}); |
| 5720 | } | 5750 | } |
| 5721 | | 5751 | |
| 5722 | fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { | 5752 | fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref { |
| 5723 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5753 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5724 | const src = inst_data.src(); | 5754 | const src = inst_data.src(); |
| 5725 | | 5755 | |
| ... | @@ -5727,7 +5757,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ | ... | @@ -5727,7 +5757,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ |
| 5727 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); | 5757 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); |
| 5728 | } | 5758 | } |
| 5729 | | 5759 | |
| 5730 | fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { | 5760 | fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref { |
| 5731 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5761 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5732 | const src = inst_data.src(); | 5762 | const src = inst_data.src(); |
| 5733 | | 5763 | |
| ... | @@ -5735,7 +5765,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: | ... | @@ -5735,7 +5765,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5735 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); | 5765 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); |
| 5736 | } | 5766 | } |
| 5737 | | 5767 | |
| 5738 | fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { | 5768 | fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Ref { |
| 5739 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5769 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5740 | const src = inst_data.src(); | 5770 | const src = inst_data.src(); |
| 5741 | | 5771 | |
| ... | @@ -5743,13 +5773,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r | ... | @@ -5743,13 +5773,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r |
| 5743 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); | 5773 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); |
| 5744 | } | 5774 | } |
| 5745 | | 5775 | |
| 5746 | fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5776 | fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5747 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5777 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5748 | const src = inst_data.src(); | 5778 | const src = inst_data.src(); |
| 5749 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{}); | 5779 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{}); |
| 5750 | } | 5780 | } |
| 5751 | | 5781 | |
| 5752 | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5782 | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5753 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5783 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5754 | const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; | 5784 | const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; |
| 5755 | const src = inst_data.src(); | 5785 | const src = inst_data.src(); |
| ... | @@ -5771,7 +5801,7 @@ fn zirErrorReturnTrace( | ... | @@ -5771,7 +5801,7 @@ fn zirErrorReturnTrace( |
| 5771 | sema: *Sema, | 5801 | sema: *Sema, |
| 5772 | block: *Scope.Block, | 5802 | block: *Scope.Block, |
| 5773 | extended: Zir.Inst.Extended.InstData, | 5803 | extended: Zir.Inst.Extended.InstData, |
| 5774 | ) InnerError!Air.Inst.Index { | 5804 | ) InnerError!Air.Inst.Ref { |
| 5775 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5805 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5776 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{}); | 5806 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{}); |
| 5777 | } | 5807 | } |
| ... | @@ -5780,7 +5810,7 @@ fn zirFrame( | ... | @@ -5780,7 +5810,7 @@ fn zirFrame( |
| 5780 | sema: *Sema, | 5810 | sema: *Sema, |
| 5781 | block: *Scope.Block, | 5811 | block: *Scope.Block, |
| 5782 | extended: Zir.Inst.Extended.InstData, | 5812 | extended: Zir.Inst.Extended.InstData, |
| 5783 | ) InnerError!Air.Inst.Index { | 5813 | ) InnerError!Air.Inst.Ref { |
| 5784 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5814 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5785 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{}); | 5815 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{}); |
| 5786 | } | 5816 | } |
| ... | @@ -5789,91 +5819,91 @@ fn zirFrameAddress( | ... | @@ -5789,91 +5819,91 @@ fn zirFrameAddress( |
| 5789 | sema: *Sema, | 5819 | sema: *Sema, |
| 5790 | block: *Scope.Block, | 5820 | block: *Scope.Block, |
| 5791 | extended: Zir.Inst.Extended.InstData, | 5821 | extended: Zir.Inst.Extended.InstData, |
| 5792 | ) InnerError!Air.Inst.Index { | 5822 | ) InnerError!Air.Inst.Ref { |
| 5793 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5823 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5794 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{}); | 5824 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{}); |
| 5795 | } | 5825 | } |
| 5796 | | 5826 | |
| 5797 | fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5827 | fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5798 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5828 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5799 | const src = inst_data.src(); | 5829 | const src = inst_data.src(); |
| 5800 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{}); | 5830 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{}); |
| 5801 | } | 5831 | } |
| 5802 | | 5832 | |
| 5803 | fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5833 | fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5804 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5834 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5805 | const src = inst_data.src(); | 5835 | const src = inst_data.src(); |
| 5806 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{}); | 5836 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{}); |
| 5807 | } | 5837 | } |
| 5808 | | 5838 | |
| 5809 | fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5839 | fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5810 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5840 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5811 | const src = inst_data.src(); | 5841 | const src = inst_data.src(); |
| 5812 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{}); | 5842 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{}); |
| 5813 | } | 5843 | } |
| 5814 | | 5844 | |
| 5815 | fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5845 | fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5816 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5846 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5817 | const src = inst_data.src(); | 5847 | const src = inst_data.src(); |
| 5818 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{}); | 5848 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{}); |
| 5819 | } | 5849 | } |
| 5820 | | 5850 | |
| 5821 | fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5851 | fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5822 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5852 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5823 | const src = inst_data.src(); | 5853 | const src = inst_data.src(); |
| 5824 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{}); | 5854 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{}); |
| 5825 | } | 5855 | } |
| 5826 | | 5856 | |
| 5827 | fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5857 | fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5828 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5858 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5829 | const src = inst_data.src(); | 5859 | const src = inst_data.src(); |
| 5830 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{}); | 5860 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{}); |
| 5831 | } | 5861 | } |
| 5832 | | 5862 | |
| 5833 | fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5863 | fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5834 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5864 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5835 | const src = inst_data.src(); | 5865 | const src = inst_data.src(); |
| 5836 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{}); | 5866 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{}); |
| 5837 | } | 5867 | } |
| 5838 | | 5868 | |
| 5839 | fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5869 | fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5840 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5870 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5841 | const src = inst_data.src(); | 5871 | const src = inst_data.src(); |
| 5842 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{}); | 5872 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{}); |
| 5843 | } | 5873 | } |
| 5844 | | 5874 | |
| 5845 | fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5875 | fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5846 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5876 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5847 | const src = inst_data.src(); | 5877 | const src = inst_data.src(); |
| 5848 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{}); | 5878 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{}); |
| 5849 | } | 5879 | } |
| 5850 | | 5880 | |
| 5851 | fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5881 | fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5852 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5882 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5853 | const src = inst_data.src(); | 5883 | const src = inst_data.src(); |
| 5854 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{}); | 5884 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{}); |
| 5855 | } | 5885 | } |
| 5856 | | 5886 | |
| 5857 | fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5887 | fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5858 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5888 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5859 | const src = inst_data.src(); | 5889 | const src = inst_data.src(); |
| 5860 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{}); | 5890 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{}); |
| 5861 | } | 5891 | } |
| 5862 | | 5892 | |
| 5863 | fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5893 | fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5864 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5894 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5865 | const src = inst_data.src(); | 5895 | const src = inst_data.src(); |
| 5866 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{}); | 5896 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{}); |
| 5867 | } | 5897 | } |
| 5868 | | 5898 | |
| 5869 | fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5899 | fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5870 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5900 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5871 | const src = inst_data.src(); | 5901 | const src = inst_data.src(); |
| 5872 | | 5902 | |
| 5873 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 5903 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 5874 | | 5904 | |
| 5875 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 5905 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 5876 | const operand_res = try sema.resolveInst(extra.rhs); | 5906 | const operand_res = sema.resolveInst(extra.rhs); |
| 5877 | const operand_coerced = try sema.coerce(block, Type.initTag(.usize), operand_res, operand_src); | 5907 | const operand_coerced = try sema.coerce(block, Type.initTag(.usize), operand_res, operand_src); |
| 5878 | | 5908 | |
| 5879 | const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5909 | const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -5929,199 +5959,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -5929,199 +5959,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5929 | return block.addUnOp(src, type_res, .bitcast, operand_coerced); | 5959 | return block.addUnOp(src, type_res, .bitcast, operand_coerced); |
| 5930 | } | 5960 | } |
| 5931 | | 5961 | |
| 5932 | fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5962 | fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5933 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5963 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5934 | const src = inst_data.src(); | 5964 | const src = inst_data.src(); |
| 5935 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{}); | 5965 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{}); |
| 5936 | } | 5966 | } |
| 5937 | | 5967 | |
| 5938 | fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5968 | fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5939 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5969 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5940 | const src = inst_data.src(); | 5970 | const src = inst_data.src(); |
| 5941 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{}); | 5971 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{}); |
| 5942 | } | 5972 | } |
| 5943 | | 5973 | |
| 5944 | fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5974 | fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5945 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5975 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5946 | const src = inst_data.src(); | 5976 | const src = inst_data.src(); |
| 5947 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{}); | 5977 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{}); |
| 5948 | } | 5978 | } |
| 5949 | | 5979 | |
| 5950 | fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5980 | fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5951 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5981 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5952 | const src = inst_data.src(); | 5982 | const src = inst_data.src(); |
| 5953 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{}); | 5983 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{}); |
| 5954 | } | 5984 | } |
| 5955 | | 5985 | |
| 5956 | fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5986 | fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5957 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5987 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5958 | const src = inst_data.src(); | 5988 | const src = inst_data.src(); |
| 5959 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{}); | 5989 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{}); |
| 5960 | } | 5990 | } |
| 5961 | | 5991 | |
| 5962 | fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5992 | fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5963 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5993 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5964 | const src = inst_data.src(); | 5994 | const src = inst_data.src(); |
| 5965 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{}); | 5995 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{}); |
| 5966 | } | 5996 | } |
| 5967 | | 5997 | |
| 5968 | fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 5998 | fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5969 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5999 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5970 | const src = inst_data.src(); | 6000 | const src = inst_data.src(); |
| 5971 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{}); | 6001 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{}); |
| 5972 | } | 6002 | } |
| 5973 | | 6003 | |
| 5974 | fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6004 | fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5975 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6005 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5976 | const src = inst_data.src(); | 6006 | const src = inst_data.src(); |
| 5977 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{}); | 6007 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{}); |
| 5978 | } | 6008 | } |
| 5979 | | 6009 | |
| 5980 | fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6010 | fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5981 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6011 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5982 | const src = inst_data.src(); | 6012 | const src = inst_data.src(); |
| 5983 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{}); | 6013 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{}); |
| 5984 | } | 6014 | } |
| 5985 | | 6015 | |
| 5986 | fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6016 | fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5987 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6017 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5988 | const src = inst_data.src(); | 6018 | const src = inst_data.src(); |
| 5989 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{}); | 6019 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{}); |
| 5990 | } | 6020 | } |
| 5991 | | 6021 | |
| 5992 | fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6022 | fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5993 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6023 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5994 | const src = inst_data.src(); | 6024 | const src = inst_data.src(); |
| 5995 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{}); | 6025 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{}); |
| 5996 | } | 6026 | } |
| 5997 | | 6027 | |
| 5998 | fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6028 | fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 5999 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6029 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6000 | const src = inst_data.src(); | 6030 | const src = inst_data.src(); |
| 6001 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{}); | 6031 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{}); |
| 6002 | } | 6032 | } |
| 6003 | | 6033 | |
| 6004 | fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6034 | fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6005 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6035 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6006 | const src = inst_data.src(); | 6036 | const src = inst_data.src(); |
| 6007 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{}); | 6037 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{}); |
| 6008 | } | 6038 | } |
| 6009 | | 6039 | |
| 6010 | fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6040 | fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6011 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6041 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6012 | const src = inst_data.src(); | 6042 | const src = inst_data.src(); |
| 6013 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{}); | 6043 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{}); |
| 6014 | } | 6044 | } |
| 6015 | | 6045 | |
| 6016 | fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6046 | fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6017 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6047 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6018 | const src = inst_data.src(); | 6048 | const src = inst_data.src(); |
| 6019 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{}); | 6049 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{}); |
| 6020 | } | 6050 | } |
| 6021 | | 6051 | |
| 6022 | fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6052 | fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6023 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6053 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6024 | const src = inst_data.src(); | 6054 | const src = inst_data.src(); |
| 6025 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{}); | 6055 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{}); |
| 6026 | } | 6056 | } |
| 6027 | | 6057 | |
| 6028 | fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6058 | fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6029 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6059 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6030 | const src = inst_data.src(); | 6060 | const src = inst_data.src(); |
| 6031 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{}); | 6061 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{}); |
| 6032 | } | 6062 | } |
| 6033 | | 6063 | |
| 6034 | fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6064 | fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6035 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6065 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6036 | const src = inst_data.src(); | 6066 | const src = inst_data.src(); |
| 6037 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{}); | 6067 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{}); |
| 6038 | } | 6068 | } |
| 6039 | | 6069 | |
| 6040 | fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6070 | fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6041 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6071 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6042 | const src = inst_data.src(); | 6072 | const src = inst_data.src(); |
| 6043 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{}); | 6073 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{}); |
| 6044 | } | 6074 | } |
| 6045 | | 6075 | |
| 6046 | fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6076 | fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6047 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6077 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6048 | const src = inst_data.src(); | 6078 | const src = inst_data.src(); |
| 6049 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{}); | 6079 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{}); |
| 6050 | } | 6080 | } |
| 6051 | | 6081 | |
| 6052 | fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6082 | fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6053 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6083 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6054 | const src = inst_data.src(); | 6084 | const src = inst_data.src(); |
| 6055 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{}); | 6085 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{}); |
| 6056 | } | 6086 | } |
| 6057 | | 6087 | |
| 6058 | fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6088 | fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6059 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6089 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6060 | const src = inst_data.src(); | 6090 | const src = inst_data.src(); |
| 6061 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{}); | 6091 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{}); |
| 6062 | } | 6092 | } |
| 6063 | | 6093 | |
| 6064 | fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6094 | fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6065 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6095 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6066 | const src = inst_data.src(); | 6096 | const src = inst_data.src(); |
| 6067 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{}); | 6097 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{}); |
| 6068 | } | 6098 | } |
| 6069 | | 6099 | |
| 6070 | fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6100 | fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6071 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6101 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6072 | const src = inst_data.src(); | 6102 | const src = inst_data.src(); |
| 6073 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{}); | 6103 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{}); |
| 6074 | } | 6104 | } |
| 6075 | | 6105 | |
| 6076 | fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6106 | fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6077 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6107 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6078 | const src = inst_data.src(); | 6108 | const src = inst_data.src(); |
| 6079 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{}); | 6109 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{}); |
| 6080 | } | 6110 | } |
| 6081 | | 6111 | |
| 6082 | fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6112 | fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6083 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6113 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6084 | const src = inst_data.src(); | 6114 | const src = inst_data.src(); |
| 6085 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{}); | 6115 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{}); |
| 6086 | } | 6116 | } |
| 6087 | | 6117 | |
| 6088 | fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6118 | fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6089 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6119 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6090 | const src = inst_data.src(); | 6120 | const src = inst_data.src(); |
| 6091 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{}); | 6121 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{}); |
| 6092 | } | 6122 | } |
| 6093 | | 6123 | |
| 6094 | fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6124 | fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6095 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6125 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6096 | const src = inst_data.src(); | 6126 | const src = inst_data.src(); |
| 6097 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{}); | 6127 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{}); |
| 6098 | } | 6128 | } |
| 6099 | | 6129 | |
| 6100 | fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6130 | fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6101 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6131 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6102 | const src = inst_data.src(); | 6132 | const src = inst_data.src(); |
| 6103 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{}); | 6133 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{}); |
| 6104 | } | 6134 | } |
| 6105 | | 6135 | |
| 6106 | fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6136 | fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6107 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6137 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6108 | const src = inst_data.src(); | 6138 | const src = inst_data.src(); |
| 6109 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{}); | 6139 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{}); |
| 6110 | } | 6140 | } |
| 6111 | | 6141 | |
| 6112 | fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6142 | fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6113 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6143 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6114 | const src = inst_data.src(); | 6144 | const src = inst_data.src(); |
| 6115 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{}); | 6145 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{}); |
| 6116 | } | 6146 | } |
| 6117 | | 6147 | |
| 6118 | fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6148 | fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6119 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6149 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6120 | const src = inst_data.src(); | 6150 | const src = inst_data.src(); |
| 6121 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{}); | 6151 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{}); |
| 6122 | } | 6152 | } |
| 6123 | | 6153 | |
| 6124 | fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { | 6154 | fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Ref { |
| 6125 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6155 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6126 | const src = inst_data.src(); | 6156 | const src = inst_data.src(); |
| 6127 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{}); | 6157 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{}); |
| ... | @@ -6132,7 +6162,7 @@ fn zirAwait( | ... | @@ -6132,7 +6162,7 @@ fn zirAwait( |
| 6132 | block: *Scope.Block, | 6162 | block: *Scope.Block, |
| 6133 | inst: Zir.Inst.Index, | 6163 | inst: Zir.Inst.Index, |
| 6134 | is_nosuspend: bool, | 6164 | is_nosuspend: bool, |
| 6135 | ) InnerError!Air.Inst.Index { | 6165 | ) InnerError!Air.Inst.Ref { |
| 6136 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6166 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6137 | const src = inst_data.src(); | 6167 | const src = inst_data.src(); |
| 6138 | | 6168 | |
| ... | @@ -6144,7 +6174,7 @@ fn zirVarExtended( | ... | @@ -6144,7 +6174,7 @@ fn zirVarExtended( |
| 6144 | sema: *Sema, | 6174 | sema: *Sema, |
| 6145 | block: *Scope.Block, | 6175 | block: *Scope.Block, |
| 6146 | extended: Zir.Inst.Extended.InstData, | 6176 | extended: Zir.Inst.Extended.InstData, |
| 6147 | ) InnerError!Air.Inst.Index { | 6177 | ) InnerError!Air.Inst.Ref { |
| 6148 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); | 6178 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); |
| 6149 | const src = sema.src; | 6179 | const src = sema.src; |
| 6150 | const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type | 6180 | const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type |
| ... | @@ -6210,7 +6240,7 @@ fn zirFuncExtended( | ... | @@ -6210,7 +6240,7 @@ fn zirFuncExtended( |
| 6210 | block: *Scope.Block, | 6240 | block: *Scope.Block, |
| 6211 | extended: Zir.Inst.Extended.InstData, | 6241 | extended: Zir.Inst.Extended.InstData, |
| 6212 | inst: Zir.Inst.Index, | 6242 | inst: Zir.Inst.Index, |
| 6213 | ) InnerError!Air.Inst.Index { | 6243 | ) InnerError!Air.Inst.Ref { |
| 6214 | const tracy = trace(@src()); | 6244 | const tracy = trace(@src()); |
| 6215 | defer tracy.end(); | 6245 | defer tracy.end(); |
| 6216 | | 6246 | |
| ... | @@ -6277,7 +6307,7 @@ fn zirCUndef( | ... | @@ -6277,7 +6307,7 @@ fn zirCUndef( |
| 6277 | sema: *Sema, | 6307 | sema: *Sema, |
| 6278 | block: *Scope.Block, | 6308 | block: *Scope.Block, |
| 6279 | extended: Zir.Inst.Extended.InstData, | 6309 | extended: Zir.Inst.Extended.InstData, |
| 6280 | ) InnerError!Air.Inst.Index { | 6310 | ) InnerError!Air.Inst.Ref { |
| 6281 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 6311 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6282 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6312 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6283 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{}); | 6313 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{}); |
| ... | @@ -6287,7 +6317,7 @@ fn zirCInclude( | ... | @@ -6287,7 +6317,7 @@ fn zirCInclude( |
| 6287 | sema: *Sema, | 6317 | sema: *Sema, |
| 6288 | block: *Scope.Block, | 6318 | block: *Scope.Block, |
| 6289 | extended: Zir.Inst.Extended.InstData, | 6319 | extended: Zir.Inst.Extended.InstData, |
| 6290 | ) InnerError!Air.Inst.Index { | 6320 | ) InnerError!Air.Inst.Ref { |
| 6291 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 6321 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6292 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6322 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6293 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{}); | 6323 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{}); |
| ... | @@ -6297,7 +6327,7 @@ fn zirCDefine( | ... | @@ -6297,7 +6327,7 @@ fn zirCDefine( |
| 6297 | sema: *Sema, | 6327 | sema: *Sema, |
| 6298 | block: *Scope.Block, | 6328 | block: *Scope.Block, |
| 6299 | extended: Zir.Inst.Extended.InstData, | 6329 | extended: Zir.Inst.Extended.InstData, |
| 6300 | ) InnerError!Air.Inst.Index { | 6330 | ) InnerError!Air.Inst.Ref { |
| 6301 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 6331 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6302 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6332 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6303 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{}); | 6333 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{}); |
| ... | @@ -6307,7 +6337,7 @@ fn zirWasmMemorySize( | ... | @@ -6307,7 +6337,7 @@ fn zirWasmMemorySize( |
| 6307 | sema: *Sema, | 6337 | sema: *Sema, |
| 6308 | block: *Scope.Block, | 6338 | block: *Scope.Block, |
| 6309 | extended: Zir.Inst.Extended.InstData, | 6339 | extended: Zir.Inst.Extended.InstData, |
| 6310 | ) InnerError!Air.Inst.Index { | 6340 | ) InnerError!Air.Inst.Ref { |
| 6311 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 6341 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6312 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6342 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6313 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{}); | 6343 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{}); |
| ... | @@ -6317,7 +6347,7 @@ fn zirWasmMemoryGrow( | ... | @@ -6317,7 +6347,7 @@ fn zirWasmMemoryGrow( |
| 6317 | sema: *Sema, | 6347 | sema: *Sema, |
| 6318 | block: *Scope.Block, | 6348 | block: *Scope.Block, |
| 6319 | extended: Zir.Inst.Extended.InstData, | 6349 | extended: Zir.Inst.Extended.InstData, |
| 6320 | ) InnerError!Air.Inst.Index { | 6350 | ) InnerError!Air.Inst.Ref { |
| 6321 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 6351 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6322 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6352 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6323 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{}); | 6353 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{}); |
| ... | @@ -6327,7 +6357,7 @@ fn zirBuiltinExtern( | ... | @@ -6327,7 +6357,7 @@ fn zirBuiltinExtern( |
| 6327 | sema: *Sema, | 6357 | sema: *Sema, |
| 6328 | block: *Scope.Block, | 6358 | block: *Scope.Block, |
| 6329 | extended: Zir.Inst.Extended.InstData, | 6359 | extended: Zir.Inst.Extended.InstData, |
| 6330 | ) InnerError!Air.Inst.Index { | 6360 | ) InnerError!Air.Inst.Ref { |
| 6331 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 6361 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6332 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6362 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6333 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{}); | 6363 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{}); |
| ... | @@ -6361,7 +6391,7 @@ pub const PanicId = enum { | ... | @@ -6361,7 +6391,7 @@ pub const PanicId = enum { |
| 6361 | invalid_error_code, | 6391 | invalid_error_code, |
| 6362 | }; | 6392 | }; |
| 6363 | | 6393 | |
| 6364 | fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: Air.Inst.Index, panic_id: PanicId) !void { | 6394 | fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: Air.Inst.Ref, panic_id: PanicId) !void { |
| 6365 | const block_inst = try sema.arena.create(Inst.Block); | 6395 | const block_inst = try sema.arena.create(Inst.Block); |
| 6366 | block_inst.* = .{ | 6396 | block_inst.* = .{ |
| 6367 | .base = .{ | 6397 | .base = .{ |
| ... | @@ -6423,7 +6453,7 @@ fn panicWithMsg( | ... | @@ -6423,7 +6453,7 @@ fn panicWithMsg( |
| 6423 | sema: *Sema, | 6453 | sema: *Sema, |
| 6424 | block: *Scope.Block, | 6454 | block: *Scope.Block, |
| 6425 | src: LazySrcLoc, | 6455 | src: LazySrcLoc, |
| 6426 | msg_inst: Air.Inst.Index, | 6456 | msg_inst: Air.Inst.Ref, |
| 6427 | ) !Zir.Inst.Index { | 6457 | ) !Zir.Inst.Index { |
| 6428 | const mod = sema.mod; | 6458 | const mod = sema.mod; |
| 6429 | const arena = sema.arena; | 6459 | const arena = sema.arena; |
| ... | @@ -6439,7 +6469,7 @@ fn panicWithMsg( | ... | @@ -6439,7 +6469,7 @@ fn panicWithMsg( |
| 6439 | const panic_fn = try sema.getBuiltin(block, src, "panic"); | 6469 | const panic_fn = try sema.getBuiltin(block, src, "panic"); |
| 6440 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); | 6470 | const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); |
| 6441 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); | 6471 | const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); |
| 6442 | const ptr_stack_trace_ty = try mod.simplePtrType(arena, stack_trace_ty, true, .One); | 6472 | const ptr_stack_trace_ty = try Module.simplePtrType(arena, stack_trace_ty, true, .One); |
| 6443 | const null_stack_trace = try mod.constInst(arena, src, .{ | 6473 | const null_stack_trace = try mod.constInst(arena, src, .{ |
| 6444 | .ty = try mod.optionalType(arena, ptr_stack_trace_ty), | 6474 | .ty = try mod.optionalType(arena, ptr_stack_trace_ty), |
| 6445 | .val = Value.initTag(.null_value), | 6475 | .val = Value.initTag(.null_value), |
| ... | @@ -6500,10 +6530,10 @@ fn namedFieldPtr( | ... | @@ -6500,10 +6530,10 @@ fn namedFieldPtr( |
| 6500 | sema: *Sema, | 6530 | sema: *Sema, |
| 6501 | block: *Scope.Block, | 6531 | block: *Scope.Block, |
| 6502 | src: LazySrcLoc, | 6532 | src: LazySrcLoc, |
| 6503 | object_ptr: Air.Inst.Index, | 6533 | object_ptr: Air.Inst.Ref, |
| 6504 | field_name: []const u8, | 6534 | field_name: []const u8, |
| 6505 | field_name_src: LazySrcLoc, | 6535 | field_name_src: LazySrcLoc, |
| 6506 | ) InnerError!Air.Inst.Index { | 6536 | ) InnerError!Air.Inst.Ref { |
| 6507 | const mod = sema.mod; | 6537 | const mod = sema.mod; |
| 6508 | const arena = sema.arena; | 6538 | const arena = sema.arena; |
| 6509 | | 6539 | |
| ... | @@ -6579,7 +6609,7 @@ fn namedFieldPtr( | ... | @@ -6579,7 +6609,7 @@ fn namedFieldPtr( |
| 6579 | } else (try mod.getErrorValue(field_name)).key; | 6609 | } else (try mod.getErrorValue(field_name)).key; |
| 6580 | | 6610 | |
| 6581 | return mod.constInst(arena, src, .{ | 6611 | return mod.constInst(arena, src, .{ |
| 6582 | .ty = try mod.simplePtrType(arena, child_type, false, .One), | 6612 | .ty = try Module.simplePtrType(arena, child_type, false, .One), |
| 6583 | .val = try Value.Tag.ref_val.create( | 6613 | .val = try Value.Tag.ref_val.create( |
| 6584 | arena, | 6614 | arena, |
| 6585 | try Value.Tag.@"error".create(arena, .{ | 6615 | try Value.Tag.@"error".create(arena, .{ |
| ... | @@ -6633,7 +6663,7 @@ fn namedFieldPtr( | ... | @@ -6633,7 +6663,7 @@ fn namedFieldPtr( |
| 6633 | const field_index_u32 = @intCast(u32, field_index); | 6663 | const field_index_u32 = @intCast(u32, field_index); |
| 6634 | const enum_val = try Value.Tag.enum_field_index.create(arena, field_index_u32); | 6664 | const enum_val = try Value.Tag.enum_field_index.create(arena, field_index_u32); |
| 6635 | return mod.constInst(arena, src, .{ | 6665 | return mod.constInst(arena, src, .{ |
| 6636 | .ty = try mod.simplePtrType(arena, child_type, false, .One), | 6666 | .ty = try Module.simplePtrType(arena, child_type, false, .One), |
| 6637 | .val = try Value.Tag.ref_val.create(arena, enum_val), | 6667 | .val = try Value.Tag.ref_val.create(arena, enum_val), |
| 6638 | }); | 6668 | }); |
| 6639 | }, | 6669 | }, |
| ... | @@ -6653,7 +6683,7 @@ fn analyzeNamespaceLookup( | ... | @@ -6653,7 +6683,7 @@ fn analyzeNamespaceLookup( |
| 6653 | src: LazySrcLoc, | 6683 | src: LazySrcLoc, |
| 6654 | namespace: *Scope.Namespace, | 6684 | namespace: *Scope.Namespace, |
| 6655 | decl_name: []const u8, | 6685 | decl_name: []const u8, |
| 6656 | ) InnerError!?Air.Inst.Index { | 6686 | ) InnerError!?Air.Inst.Ref { |
| 6657 | const mod = sema.mod; | 6687 | const mod = sema.mod; |
| 6658 | const gpa = sema.gpa; | 6688 | const gpa = sema.gpa; |
| 6659 | if (try sema.lookupInNamespace(namespace, decl_name)) |decl| { | 6689 | if (try sema.lookupInNamespace(namespace, decl_name)) |decl| { |
| ... | @@ -6677,11 +6707,11 @@ fn analyzeStructFieldPtr( | ... | @@ -6677,11 +6707,11 @@ fn analyzeStructFieldPtr( |
| 6677 | sema: *Sema, | 6707 | sema: *Sema, |
| 6678 | block: *Scope.Block, | 6708 | block: *Scope.Block, |
| 6679 | src: LazySrcLoc, | 6709 | src: LazySrcLoc, |
| 6680 | struct_ptr: Air.Inst.Index, | 6710 | struct_ptr: Air.Inst.Ref, |
| 6681 | field_name: []const u8, | 6711 | field_name: []const u8, |
| 6682 | field_name_src: LazySrcLoc, | 6712 | field_name_src: LazySrcLoc, |
| 6683 | unresolved_struct_ty: Type, | 6713 | unresolved_struct_ty: Type, |
| 6684 | ) InnerError!Air.Inst.Index { | 6714 | ) InnerError!Air.Inst.Ref { |
| 6685 | const mod = sema.mod; | 6715 | const mod = sema.mod; |
| 6686 | const arena = sema.arena; | 6716 | const arena = sema.arena; |
| 6687 | assert(unresolved_struct_ty.zigTypeTag() == .Struct); | 6717 | assert(unresolved_struct_ty.zigTypeTag() == .Struct); |
| ... | @@ -6692,7 +6722,7 @@ fn analyzeStructFieldPtr( | ... | @@ -6692,7 +6722,7 @@ fn analyzeStructFieldPtr( |
| 6692 | const field_index = struct_obj.fields.getIndex(field_name) orelse | 6722 | const field_index = struct_obj.fields.getIndex(field_name) orelse |
| 6693 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); | 6723 | return sema.failWithBadFieldAccess(block, struct_obj, field_name_src, field_name); |
| 6694 | const field = struct_obj.fields.values()[field_index]; | 6724 | const field = struct_obj.fields.values()[field_index]; |
| 6695 | const ptr_field_ty = try mod.simplePtrType(arena, field.ty, true, .One); | 6725 | const ptr_field_ty = try Module.simplePtrType(arena, field.ty, true, .One); |
| 6696 | | 6726 | |
| 6697 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { | 6727 | if (try sema.resolveDefinedValue(block, src, struct_ptr)) |struct_ptr_val| { |
| 6698 | return mod.constInst(arena, src, .{ | 6728 | return mod.constInst(arena, src, .{ |
| ... | @@ -6712,11 +6742,11 @@ fn analyzeUnionFieldPtr( | ... | @@ -6712,11 +6742,11 @@ fn analyzeUnionFieldPtr( |
| 6712 | sema: *Sema, | 6742 | sema: *Sema, |
| 6713 | block: *Scope.Block, | 6743 | block: *Scope.Block, |
| 6714 | src: LazySrcLoc, | 6744 | src: LazySrcLoc, |
| 6715 | union_ptr: Air.Inst.Index, | 6745 | union_ptr: Air.Inst.Ref, |
| 6716 | field_name: []const u8, | 6746 | field_name: []const u8, |
| 6717 | field_name_src: LazySrcLoc, | 6747 | field_name_src: LazySrcLoc, |
| 6718 | unresolved_union_ty: Type, | 6748 | unresolved_union_ty: Type, |
| 6719 | ) InnerError!Air.Inst.Index { | 6749 | ) InnerError!Air.Inst.Ref { |
| 6720 | const mod = sema.mod; | 6750 | const mod = sema.mod; |
| 6721 | const arena = sema.arena; | 6751 | const arena = sema.arena; |
| 6722 | assert(unresolved_union_ty.zigTypeTag() == .Union); | 6752 | assert(unresolved_union_ty.zigTypeTag() == .Union); |
| ... | @@ -6728,7 +6758,7 @@ fn analyzeUnionFieldPtr( | ... | @@ -6728,7 +6758,7 @@ fn analyzeUnionFieldPtr( |
| 6728 | return sema.failWithBadUnionFieldAccess(block, union_obj, field_name_src, field_name); | 6758 | return sema.failWithBadUnionFieldAccess(block, union_obj, field_name_src, field_name); |
| 6729 | | 6759 | |
| 6730 | const field = union_obj.fields.values()[field_index]; | 6760 | const field = union_obj.fields.values()[field_index]; |
| 6731 | const ptr_field_ty = try mod.simplePtrType(arena, field.ty, true, .One); | 6761 | const ptr_field_ty = try Module.simplePtrType(arena, field.ty, true, .One); |
| 6732 | | 6762 | |
| 6733 | if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| { | 6763 | if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| { |
| 6734 | // TODO detect inactive union field and emit compile error | 6764 | // TODO detect inactive union field and emit compile error |
| ... | @@ -6749,10 +6779,10 @@ fn elemPtr( | ... | @@ -6749,10 +6779,10 @@ fn elemPtr( |
| 6749 | sema: *Sema, | 6779 | sema: *Sema, |
| 6750 | block: *Scope.Block, | 6780 | block: *Scope.Block, |
| 6751 | src: LazySrcLoc, | 6781 | src: LazySrcLoc, |
| 6752 | array_ptr: Air.Inst.Index, | 6782 | array_ptr: Air.Inst.Ref, |
| 6753 | elem_index: Air.Inst.Index, | 6783 | elem_index: Air.Inst.Ref, |
| 6754 | elem_index_src: LazySrcLoc, | 6784 | elem_index_src: LazySrcLoc, |
| 6755 | ) InnerError!Air.Inst.Index { | 6785 | ) InnerError!Air.Inst.Ref { |
| 6756 | const array_ty = switch (array_ptr.ty.zigTypeTag()) { | 6786 | const array_ty = switch (array_ptr.ty.zigTypeTag()) { |
| 6757 | .Pointer => array_ptr.ty.elemType(), | 6787 | .Pointer => array_ptr.ty.elemType(), |
| 6758 | else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}), | 6788 | else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}), |
| ... | @@ -6776,10 +6806,10 @@ fn elemPtrArray( | ... | @@ -6776,10 +6806,10 @@ fn elemPtrArray( |
| 6776 | sema: *Sema, | 6806 | sema: *Sema, |
| 6777 | block: *Scope.Block, | 6807 | block: *Scope.Block, |
| 6778 | src: LazySrcLoc, | 6808 | src: LazySrcLoc, |
| 6779 | array_ptr: Air.Inst.Index, | 6809 | array_ptr: Air.Inst.Ref, |
| 6780 | elem_index: Air.Inst.Index, | 6810 | elem_index: Air.Inst.Ref, |
| 6781 | elem_index_src: LazySrcLoc, | 6811 | elem_index_src: LazySrcLoc, |
| 6782 | ) InnerError!Air.Inst.Index { | 6812 | ) InnerError!Air.Inst.Ref { |
| 6783 | if (array_ptr.value()) |array_ptr_val| { | 6813 | if (array_ptr.value()) |array_ptr_val| { |
| 6784 | if (elem_index.value()) |index_val| { | 6814 | if (elem_index.value()) |index_val| { |
| 6785 | // Both array pointer and index are compile-time known. | 6815 | // Both array pointer and index are compile-time known. |
| ... | @@ -6804,35 +6834,41 @@ fn coerce( | ... | @@ -6804,35 +6834,41 @@ fn coerce( |
| 6804 | sema: *Sema, | 6834 | sema: *Sema, |
| 6805 | block: *Scope.Block, | 6835 | block: *Scope.Block, |
| 6806 | dest_type: Type, | 6836 | dest_type: Type, |
| 6807 | inst: Air.Inst.Index, | 6837 | inst: Air.Inst.Ref, |
| 6808 | inst_src: LazySrcLoc, | 6838 | inst_src: LazySrcLoc, |
| 6809 | ) InnerError!Air.Inst.Index { | 6839 | ) InnerError!Air.Inst.Ref { |
| 6810 | if (dest_type.tag() == .var_args_param) { | 6840 | if (dest_type.tag() == .var_args_param) { |
| 6811 | return sema.coerceVarArgParam(block, inst); | 6841 | return sema.coerceVarArgParam(block, inst, inst_src); |
| 6812 | } | 6842 | } |
| | 6843 | |
| | 6844 | const inst_ty = sema.getTypeOfAirRef(inst); |
| 6813 | // If the types are the same, we can return the operand. | 6845 | // If the types are the same, we can return the operand. |
| 6814 | if (dest_type.eql(inst.ty)) | 6846 | if (dest_type.eql(inst_ty)) |
| 6815 | return inst; | 6847 | return inst; |
| 6816 | | 6848 | |
| 6817 | const in_memory_result = coerceInMemoryAllowed(dest_type, inst.ty); | 6849 | const in_memory_result = coerceInMemoryAllowed(dest_type, inst_ty); |
| 6818 | if (in_memory_result == .ok) { | 6850 | if (in_memory_result == .ok) { |
| 6819 | return sema.bitcast(block, dest_type, inst); | 6851 | return sema.bitcast(block, dest_type, inst, inst_src); |
| 6820 | } | 6852 | } |
| 6821 | | 6853 | |
| 6822 | const mod = sema.mod; | 6854 | const mod = sema.mod; |
| 6823 | const arena = sema.arena; | 6855 | const arena = sema.arena; |
| 6824 | | 6856 | |
| 6825 | // undefined to anything | 6857 | // undefined to anything |
| 6826 | if (inst.value()) |val| { | 6858 | if (try sema.resolvePossiblyUndefinedValue(block, inst_src, inst)) |val| { |
| 6827 | if (val.isUndef() or inst.ty.zigTypeTag() == .Undefined) { | 6859 | if (val.isUndef() or inst_ty.zigTypeTag() == .Undefined) { |
| 6828 | return mod.constInst(arena, inst_src, .{ .ty = dest_type, .val = val }); | 6860 | return sema.addConstant(dest_type, val); |
| 6829 | } | 6861 | } |
| 6830 | } | 6862 | } |
| 6831 | assert(inst.ty.zigTypeTag() != .Undefined); | 6863 | assert(inst_ty.zigTypeTag() != .Undefined); |
| | 6864 | |
| | 6865 | if (true) { |
| | 6866 | @panic("TODO finish AIR memory layout rework"); |
| | 6867 | } |
| 6832 | | 6868 | |
| 6833 | // T to E!T or E to E!T | 6869 | // T to E!T or E to E!T |
| 6834 | if (dest_type.tag() == .error_union) { | 6870 | if (dest_type.tag() == .error_union) { |
| 6835 | return try sema.wrapErrorUnion(block, dest_type, inst); | 6871 | return try sema.wrapErrorUnion(block, dest_type, inst, inst_src); |
| 6836 | } | 6872 | } |
| 6837 | | 6873 | |
| 6838 | // comptime known number to other number | 6874 | // comptime known number to other number |
| ... | @@ -6844,14 +6880,14 @@ fn coerce( | ... | @@ -6844,14 +6880,14 @@ fn coerce( |
| 6844 | switch (dest_type.zigTypeTag()) { | 6880 | switch (dest_type.zigTypeTag()) { |
| 6845 | .Optional => { | 6881 | .Optional => { |
| 6846 | // null to ?T | 6882 | // null to ?T |
| 6847 | if (inst.ty.zigTypeTag() == .Null) { | 6883 | if (inst_ty.zigTypeTag() == .Null) { |
| 6848 | return mod.constInst(arena, inst_src, .{ .ty = dest_type, .val = Value.initTag(.null_value) }); | 6884 | return mod.constInst(arena, inst_src, .{ .ty = dest_type, .val = Value.initTag(.null_value) }); |
| 6849 | } | 6885 | } |
| 6850 | | 6886 | |
| 6851 | // T to ?T | 6887 | // T to ?T |
| 6852 | var buf: Type.Payload.ElemType = undefined; | 6888 | var buf: Type.Payload.ElemType = undefined; |
| 6853 | const child_type = dest_type.optionalChild(&buf); | 6889 | const child_type = dest_type.optionalChild(&buf); |
| 6854 | if (child_type.eql(inst.ty)) { | 6890 | if (child_type.eql(inst_ty)) { |
| 6855 | return sema.wrapOptional(block, dest_type, inst); | 6891 | return sema.wrapOptional(block, dest_type, inst); |
| 6856 | } else if (try sema.coerceNum(block, child_type, inst)) |some| { | 6892 | } else if (try sema.coerceNum(block, child_type, inst)) |some| { |
| 6857 | return sema.wrapOptional(block, dest_type, some); | 6893 | return sema.wrapOptional(block, dest_type, some); |
| ... | @@ -6860,12 +6896,12 @@ fn coerce( | ... | @@ -6860,12 +6896,12 @@ fn coerce( |
| 6860 | .Pointer => { | 6896 | .Pointer => { |
| 6861 | // Coercions where the source is a single pointer to an array. | 6897 | // Coercions where the source is a single pointer to an array. |
| 6862 | src_array_ptr: { | 6898 | src_array_ptr: { |
| 6863 | if (!inst.ty.isSinglePointer()) break :src_array_ptr; | 6899 | if (!inst_ty.isSinglePointer()) break :src_array_ptr; |
| 6864 | const array_type = inst.ty.elemType(); | 6900 | const array_type = inst_ty.elemType(); |
| 6865 | if (array_type.zigTypeTag() != .Array) break :src_array_ptr; | 6901 | if (array_type.zigTypeTag() != .Array) break :src_array_ptr; |
| 6866 | const array_elem_type = array_type.elemType(); | 6902 | const array_elem_type = array_type.elemType(); |
| 6867 | if (inst.ty.isConstPtr() and !dest_type.isConstPtr()) break :src_array_ptr; | 6903 | if (inst_ty.isConstPtr() and !dest_type.isConstPtr()) break :src_array_ptr; |
| 6868 | if (inst.ty.isVolatilePtr() and !dest_type.isVolatilePtr()) break :src_array_ptr; | 6904 | if (inst_ty.isVolatilePtr() and !dest_type.isVolatilePtr()) break :src_array_ptr; |
| 6869 | | 6905 | |
| 6870 | const dst_elem_type = dest_type.elemType(); | 6906 | const dst_elem_type = dest_type.elemType(); |
| 6871 | switch (coerceInMemoryAllowed(dst_elem_type, array_elem_type)) { | 6907 | switch (coerceInMemoryAllowed(dst_elem_type, array_elem_type)) { |
| ... | @@ -6904,11 +6940,11 @@ fn coerce( | ... | @@ -6904,11 +6940,11 @@ fn coerce( |
| 6904 | }, | 6940 | }, |
| 6905 | .Int => { | 6941 | .Int => { |
| 6906 | // integer widening | 6942 | // integer widening |
| 6907 | if (inst.ty.zigTypeTag() == .Int) { | 6943 | if (inst_ty.zigTypeTag() == .Int) { |
| 6908 | assert(inst.value() == null); // handled above | 6944 | assert(inst.value() == null); // handled above |
| 6909 | | 6945 | |
| 6910 | const dst_info = dest_type.intInfo(target); | 6946 | const dst_info = dest_type.intInfo(target); |
| 6911 | const src_info = inst.ty.intInfo(target); | 6947 | const src_info = inst_ty.intInfo(target); |
| 6912 | if ((src_info.signedness == dst_info.signedness and dst_info.bits >= src_info.bits) or | 6948 | if ((src_info.signedness == dst_info.signedness and dst_info.bits >= src_info.bits) or |
| 6913 | // small enough unsigned ints can get casted to large enough signed ints | 6949 | // small enough unsigned ints can get casted to large enough signed ints |
| 6914 | (src_info.signedness == .signed and dst_info.signedness == .unsigned and dst_info.bits > src_info.bits)) | 6950 | (src_info.signedness == .signed and dst_info.signedness == .unsigned and dst_info.bits > src_info.bits)) |
| ... | @@ -6920,10 +6956,10 @@ fn coerce( | ... | @@ -6920,10 +6956,10 @@ fn coerce( |
| 6920 | }, | 6956 | }, |
| 6921 | .Float => { | 6957 | .Float => { |
| 6922 | // float widening | 6958 | // float widening |
| 6923 | if (inst.ty.zigTypeTag() == .Float) { | 6959 | if (inst_ty.zigTypeTag() == .Float) { |
| 6924 | assert(inst.value() == null); // handled above | 6960 | assert(inst.value() == null); // handled above |
| 6925 | | 6961 | |
| 6926 | const src_bits = inst.ty.floatBits(target); | 6962 | const src_bits = inst_ty.floatBits(target); |
| 6927 | const dst_bits = dest_type.floatBits(target); | 6963 | const dst_bits = dest_type.floatBits(target); |
| 6928 | if (dst_bits >= src_bits) { | 6964 | if (dst_bits >= src_bits) { |
| 6929 | try sema.requireRuntimeBlock(block, inst_src); | 6965 | try sema.requireRuntimeBlock(block, inst_src); |
| ... | @@ -6933,7 +6969,7 @@ fn coerce( | ... | @@ -6933,7 +6969,7 @@ fn coerce( |
| 6933 | }, | 6969 | }, |
| 6934 | .Enum => { | 6970 | .Enum => { |
| 6935 | // enum literal to enum | 6971 | // enum literal to enum |
| 6936 | if (inst.ty.zigTypeTag() == .EnumLiteral) { | 6972 | if (inst_ty.zigTypeTag() == .EnumLiteral) { |
| 6937 | const val = try sema.resolveConstValue(block, inst_src, inst); | 6973 | const val = try sema.resolveConstValue(block, inst_src, inst); |
| 6938 | const bytes = val.castTag(.enum_literal).?.data; | 6974 | const bytes = val.castTag(.enum_literal).?.data; |
| 6939 | const resolved_dest_type = try sema.resolveTypeFields(block, inst_src, dest_type); | 6975 | const resolved_dest_type = try sema.resolveTypeFields(block, inst_src, dest_type); |
| ... | @@ -6965,7 +7001,7 @@ fn coerce( | ... | @@ -6965,7 +7001,7 @@ fn coerce( |
| 6965 | else => {}, | 7001 | else => {}, |
| 6966 | } | 7002 | } |
| 6967 | | 7003 | |
| 6968 | return mod.fail(&block.base, inst_src, "expected {}, found {}", .{ dest_type, inst.ty }); | 7004 | return mod.fail(&block.base, inst_src, "expected {}, found {}", .{ dest_type, inst_ty }); |
| 6969 | } | 7005 | } |
| 6970 | | 7006 | |
| 6971 | const InMemoryCoercionResult = enum { | 7007 | const InMemoryCoercionResult = enum { |
| ... | @@ -6982,7 +7018,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult | ... | @@ -6982,7 +7018,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult |
| 6982 | return .no_match; | 7018 | return .no_match; |
| 6983 | } | 7019 | } |
| 6984 | | 7020 | |
| 6985 | fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) InnerError!?Air.Inst.Index { | 7021 | fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) InnerError!?Air.Inst.Index { |
| 6986 | const val = inst.value() orelse return null; | 7022 | const val = inst.value() orelse return null; |
| 6987 | const src_zig_tag = inst.ty.zigTypeTag(); | 7023 | const src_zig_tag = inst.ty.zigTypeTag(); |
| 6988 | const dst_zig_tag = dest_type.zigTypeTag(); | 7024 | const dst_zig_tag = dest_type.zigTypeTag(); |
| ... | @@ -7020,9 +7056,15 @@ fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.I | ... | @@ -7020,9 +7056,15 @@ fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.I |
| 7020 | return null; | 7056 | return null; |
| 7021 | } | 7057 | } |
| 7022 | | 7058 | |
| 7023 | fn coerceVarArgParam(sema: *Sema, block: *Scope.Block, inst: Air.Inst.Index) !Air.Inst.Index { | 7059 | fn coerceVarArgParam( |
| 7024 | switch (inst.ty.zigTypeTag()) { | 7060 | sema: *Sema, |
| 7025 | .ComptimeInt, .ComptimeFloat => return sema.mod.fail(&block.base, inst.src, "integer and float literals in var args function must be casted", .{}), | 7061 | block: *Scope.Block, |
| | 7062 | inst: Air.Inst.Ref, |
| | 7063 | inst_src: LazySrcLoc, |
| | 7064 | ) !Air.Inst.Ref { |
| | 7065 | const inst_ty = sema.getTypeOfAirRef(inst); |
| | 7066 | switch (inst_ty.zigTypeTag()) { |
| | 7067 | .ComptimeInt, .ComptimeFloat => return sema.mod.fail(&block.base, inst_src, "integer and float literals in var args function must be casted", .{}), |
| 7026 | else => {}, | 7068 | else => {}, |
| 7027 | } | 7069 | } |
| 7028 | // TODO implement more of this function. | 7070 | // TODO implement more of this function. |
| ... | @@ -7033,8 +7075,8 @@ fn storePtr( | ... | @@ -7033,8 +7075,8 @@ fn storePtr( |
| 7033 | sema: *Sema, | 7075 | sema: *Sema, |
| 7034 | block: *Scope.Block, | 7076 | block: *Scope.Block, |
| 7035 | src: LazySrcLoc, | 7077 | src: LazySrcLoc, |
| 7036 | ptr: Air.Inst.Index, | 7078 | ptr: Air.Inst.Ref, |
| 7037 | uncasted_value: Air.Inst.Index, | 7079 | uncasted_value: Air.Inst.Ref, |
| 7038 | ) !void { | 7080 | ) !void { |
| 7039 | if (ptr.ty.isConstPtr()) | 7081 | if (ptr.ty.isConstPtr()) |
| 7040 | return sema.mod.fail(&block.base, src, "cannot assign to constant", .{}); | 7082 | return sema.mod.fail(&block.base, src, "cannot assign to constant", .{}); |
| ... | @@ -7082,17 +7124,23 @@ fn storePtr( | ... | @@ -7082,17 +7124,23 @@ fn storePtr( |
| 7082 | _ = try block.addBinOp(src, Type.initTag(.void), .store, ptr, value); | 7124 | _ = try block.addBinOp(src, Type.initTag(.void), .store, ptr, value); |
| 7083 | } | 7125 | } |
| 7084 | | 7126 | |
| 7085 | fn bitcast(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { | 7127 | fn bitcast( |
| 7086 | if (inst.value()) |val| { | 7128 | sema: *Sema, |
| | 7129 | block: *Scope.Block, |
| | 7130 | dest_type: Type, |
| | 7131 | inst: Air.Inst.Ref, |
| | 7132 | inst_src: LazySrcLoc, |
| | 7133 | ) InnerError!Air.Inst.Ref { |
| | 7134 | if (try sema.resolvePossiblyUndefinedValue(block, inst_src, inst)) |val| { |
| 7087 | // Keep the comptime Value representation; take the new type. | 7135 | // Keep the comptime Value representation; take the new type. |
| 7088 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7136 | return sema.addConstant(dest_type, val); |
| 7089 | } | 7137 | } |
| 7090 | // TODO validate the type size and other compile errors | 7138 | // TODO validate the type size and other compile errors |
| 7091 | try sema.requireRuntimeBlock(block, inst.src); | 7139 | try sema.requireRuntimeBlock(block, inst_src); |
| 7092 | return block.addUnOp(inst.src, dest_type, .bitcast, inst); | 7140 | return block.addTyOp(.bitcast, dest_type, inst); |
| 7093 | } | 7141 | } |
| 7094 | | 7142 | |
| 7095 | fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { | 7143 | fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) InnerError!Air.Inst.Ref { |
| 7096 | if (inst.value()) |val| { | 7144 | if (inst.value()) |val| { |
| 7097 | // The comptime Value representation is compatible with both types. | 7145 | // The comptime Value representation is compatible with both types. |
| 7098 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7146 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| ... | @@ -7100,7 +7148,7 @@ fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst | ... | @@ -7100,7 +7148,7 @@ fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst |
| 7100 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{}); | 7148 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{}); |
| 7101 | } | 7149 | } |
| 7102 | | 7150 | |
| 7103 | fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { | 7151 | fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) !Air.Inst.Ref { |
| 7104 | if (inst.value()) |val| { | 7152 | if (inst.value()) |val| { |
| 7105 | // The comptime Value representation is compatible with both types. | 7153 | // The comptime Value representation is compatible with both types. |
| 7106 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7154 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| ... | @@ -7108,12 +7156,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: | ... | @@ -7108,12 +7156,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: |
| 7108 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{}); | 7156 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{}); |
| 7109 | } | 7157 | } |
| 7110 | | 7158 | |
| 7111 | fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Index { | 7159 | fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Ref { |
| 7112 | const decl_ref = try sema.analyzeDeclRef(block, src, decl); | 7160 | const decl_ref = try sema.analyzeDeclRef(block, src, decl); |
| 7113 | return sema.analyzeLoad(block, src, decl_ref, src); | 7161 | return sema.analyzeLoad(block, src, decl_ref, src); |
| 7114 | } | 7162 | } |
| 7115 | | 7163 | |
| 7116 | fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Index { | 7164 | fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Ref { |
| 7117 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); | 7165 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); |
| 7118 | sema.mod.ensureDeclAnalyzed(decl) catch |err| { | 7166 | sema.mod.ensureDeclAnalyzed(decl) catch |err| { |
| 7119 | if (sema.func) |func| { | 7167 | if (sema.func) |func| { |
| ... | @@ -7128,43 +7176,41 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl | ... | @@ -7128,43 +7176,41 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl |
| 7128 | if (decl_tv.val.tag() == .variable) { | 7176 | if (decl_tv.val.tag() == .variable) { |
| 7129 | return sema.analyzeVarRef(block, src, decl_tv); | 7177 | return sema.analyzeVarRef(block, src, decl_tv); |
| 7130 | } | 7178 | } |
| 7131 | return sema.mod.constInst(sema.arena, src, .{ | 7179 | return sema.addConstant( |
| 7132 | .ty = try sema.mod.simplePtrType(sema.arena, decl_tv.ty, false, .One), | 7180 | try Module.simplePtrType(sema.arena, decl_tv.ty, false, .One), |
| 7133 | .val = try Value.Tag.decl_ref.create(sema.arena, decl), | 7181 | try Value.Tag.decl_ref.create(sema.arena, decl), |
| 7134 | }); | 7182 | ); |
| 7135 | } | 7183 | } |
| 7136 | | 7184 | |
| 7137 | fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) InnerError!Air.Inst.Index { | 7185 | fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) InnerError!Air.Inst.Ref { |
| 7138 | const variable = tv.val.castTag(.variable).?.data; | 7186 | const variable = tv.val.castTag(.variable).?.data; |
| 7139 | | 7187 | |
| 7140 | const ty = try sema.mod.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One); | 7188 | const ty = try Module.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One); |
| 7141 | if (!variable.is_mutable and !variable.is_extern) { | 7189 | if (!variable.is_mutable and !variable.is_extern) { |
| 7142 | return sema.mod.constInst(sema.arena, src, .{ | 7190 | return sema.addConstant(ty, try Value.Tag.ref_val.create(sema.arena, variable.init)); |
| 7143 | .ty = ty, | | |
| 7144 | .val = try Value.Tag.ref_val.create(sema.arena, variable.init), | | |
| 7145 | }); | | |
| 7146 | } | 7191 | } |
| 7147 | | 7192 | |
| | 7193 | const gpa = sema.gpa; |
| 7148 | try sema.requireRuntimeBlock(block, src); | 7194 | try sema.requireRuntimeBlock(block, src); |
| 7149 | const inst = try sema.arena.create(Inst.VarPtr); | 7195 | try sema.air_variables.append(gpa, variable); |
| 7150 | inst.* = .{ | 7196 | const result_inst = @intCast(Air.Inst.Index, sema.air_instructions.len); |
| 7151 | .base = .{ | 7197 | try sema.air_instructions.append(gpa, .{ |
| 7152 | .tag = .varptr, | 7198 | .tag = .varptr, |
| 7153 | .ty = ty, | 7199 | .data = .{ .ty_pl = .{ |
| 7154 | .src = src, | 7200 | .ty = try sema.addType(ty), |
| 7155 | }, | 7201 | .payload = @intCast(u32, sema.air_variables.items.len - 1), |
| 7156 | .variable = variable, | 7202 | } }, |
| 7157 | }; | 7203 | }); |
| 7158 | try block.instructions.append(sema.gpa, &inst.base); | 7204 | try block.instructions.append(gpa, result_inst); |
| 7159 | return &inst.base; | 7205 | return indexToRef(result_inst); |
| 7160 | } | 7206 | } |
| 7161 | | 7207 | |
| 7162 | fn analyzeRef( | 7208 | fn analyzeRef( |
| 7163 | sema: *Sema, | 7209 | sema: *Sema, |
| 7164 | block: *Scope.Block, | 7210 | block: *Scope.Block, |
| 7165 | src: LazySrcLoc, | 7211 | src: LazySrcLoc, |
| 7166 | operand: Air.Inst.Index, | 7212 | operand: Air.Inst.Ref, |
| 7167 | ) InnerError!Air.Inst.Index { | 7213 | ) InnerError!Air.Inst.Ref { |
| 7168 | const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One); | 7214 | const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One); |
| 7169 | | 7215 | |
| 7170 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| { | 7216 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| { |
| ... | @@ -7182,34 +7228,32 @@ fn analyzeLoad( | ... | @@ -7182,34 +7228,32 @@ fn analyzeLoad( |
| 7182 | sema: *Sema, | 7228 | sema: *Sema, |
| 7183 | block: *Scope.Block, | 7229 | block: *Scope.Block, |
| 7184 | src: LazySrcLoc, | 7230 | src: LazySrcLoc, |
| 7185 | ptr: Air.Inst.Index, | 7231 | ptr: Air.Inst.Ref, |
| 7186 | ptr_src: LazySrcLoc, | 7232 | ptr_src: LazySrcLoc, |
| 7187 | ) InnerError!Air.Inst.Index { | 7233 | ) InnerError!Air.Inst.Ref { |
| 7188 | const elem_ty = switch (ptr.ty.zigTypeTag()) { | 7234 | const ptr_ty = sema.getTypeOfAirRef(ptr); |
| 7189 | .Pointer => ptr.ty.elemType(), | 7235 | const elem_ty = switch (ptr_ty.zigTypeTag()) { |
| 7190 | else => return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}), | 7236 | .Pointer => ptr_ty.elemType(), |
| | 7237 | else => return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr_ty}), |
| 7191 | }; | 7238 | }; |
| 7192 | if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| blk: { | 7239 | if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| blk: { |
| 7193 | if (ptr_val.tag() == .int_u64) | 7240 | if (ptr_val.tag() == .int_u64) |
| 7194 | break :blk; // do it at runtime | 7241 | break :blk; // do it at runtime |
| 7195 | | 7242 | |
| 7196 | return sema.mod.constInst(sema.arena, src, .{ | 7243 | return sema.addConstant(elem_ty, try ptr_val.pointerDeref(sema.arena)); |
| 7197 | .ty = elem_ty, | | |
| 7198 | .val = try ptr_val.pointerDeref(sema.arena), | | |
| 7199 | }); | | |
| 7200 | } | 7244 | } |
| 7201 | | 7245 | |
| 7202 | try sema.requireRuntimeBlock(block, src); | 7246 | try sema.requireRuntimeBlock(block, src); |
| 7203 | return block.addUnOp(src, elem_ty, .load, ptr); | 7247 | return block.addTyOp(.load, elem_ty, ptr); |
| 7204 | } | 7248 | } |
| 7205 | | 7249 | |
| 7206 | fn analyzeIsNull( | 7250 | fn analyzeIsNull( |
| 7207 | sema: *Sema, | 7251 | sema: *Sema, |
| 7208 | block: *Scope.Block, | 7252 | block: *Scope.Block, |
| 7209 | src: LazySrcLoc, | 7253 | src: LazySrcLoc, |
| 7210 | operand: Air.Inst.Index, | 7254 | operand: Air.Inst.Ref, |
| 7211 | invert_logic: bool, | 7255 | invert_logic: bool, |
| 7212 | ) InnerError!Air.Inst.Index { | 7256 | ) InnerError!Air.Inst.Ref { |
| 7213 | const result_ty = Type.initTag(.bool); | 7257 | const result_ty = Type.initTag(.bool); |
| 7214 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| { | 7258 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| { |
| 7215 | if (opt_val.isUndef()) { | 7259 | if (opt_val.isUndef()) { |
| ... | @@ -7228,8 +7272,8 @@ fn analyzeIsNonErr( | ... | @@ -7228,8 +7272,8 @@ fn analyzeIsNonErr( |
| 7228 | sema: *Sema, | 7272 | sema: *Sema, |
| 7229 | block: *Scope.Block, | 7273 | block: *Scope.Block, |
| 7230 | src: LazySrcLoc, | 7274 | src: LazySrcLoc, |
| 7231 | operand: Air.Inst.Index, | 7275 | operand: Air.Inst.Ref, |
| 7232 | ) InnerError!Air.Inst.Index { | 7276 | ) InnerError!Air.Inst.Ref { |
| 7233 | const ot = operand.ty.zigTypeTag(); | 7277 | const ot = operand.ty.zigTypeTag(); |
| 7234 | if (ot != .ErrorSet and ot != .ErrorUnion) return sema.mod.constBool(sema.arena, src, true); | 7278 | if (ot != .ErrorSet and ot != .ErrorUnion) return sema.mod.constBool(sema.arena, src, true); |
| 7235 | if (ot == .ErrorSet) return sema.mod.constBool(sema.arena, src, false); | 7279 | if (ot == .ErrorSet) return sema.mod.constBool(sema.arena, src, false); |
| ... | @@ -7249,12 +7293,12 @@ fn analyzeSlice( | ... | @@ -7249,12 +7293,12 @@ fn analyzeSlice( |
| 7249 | sema: *Sema, | 7293 | sema: *Sema, |
| 7250 | block: *Scope.Block, | 7294 | block: *Scope.Block, |
| 7251 | src: LazySrcLoc, | 7295 | src: LazySrcLoc, |
| 7252 | array_ptr: Air.Inst.Index, | 7296 | array_ptr: Air.Inst.Ref, |
| 7253 | start: Air.Inst.Index, | 7297 | start: Air.Inst.Ref, |
| 7254 | end_opt: ?Air.Inst.Index, | 7298 | end_opt: ?Air.Inst.Index, |
| 7255 | sentinel_opt: ?Air.Inst.Index, | 7299 | sentinel_opt: ?Air.Inst.Index, |
| 7256 | sentinel_src: LazySrcLoc, | 7300 | sentinel_src: LazySrcLoc, |
| 7257 | ) InnerError!Air.Inst.Index { | 7301 | ) InnerError!Air.Inst.Ref { |
| 7258 | const ptr_child = switch (array_ptr.ty.zigTypeTag()) { | 7302 | const ptr_child = switch (array_ptr.ty.zigTypeTag()) { |
| 7259 | .Pointer => array_ptr.ty.elemType(), | 7303 | .Pointer => array_ptr.ty.elemType(), |
| 7260 | else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}), | 7304 | else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}), |
| ... | @@ -7325,10 +7369,10 @@ fn cmpNumeric( | ... | @@ -7325,10 +7369,10 @@ fn cmpNumeric( |
| 7325 | sema: *Sema, | 7369 | sema: *Sema, |
| 7326 | block: *Scope.Block, | 7370 | block: *Scope.Block, |
| 7327 | src: LazySrcLoc, | 7371 | src: LazySrcLoc, |
| 7328 | lhs: Air.Inst.Index, | 7372 | lhs: Air.Inst.Ref, |
| 7329 | rhs: Air.Inst.Index, | 7373 | rhs: Air.Inst.Ref, |
| 7330 | op: std.math.CompareOperator, | 7374 | op: std.math.CompareOperator, |
| 7331 | ) InnerError!Air.Inst.Index { | 7375 | ) InnerError!Air.Inst.Ref { |
| 7332 | assert(lhs.ty.isNumeric()); | 7376 | assert(lhs.ty.isNumeric()); |
| 7333 | assert(rhs.ty.isNumeric()); | 7377 | assert(rhs.ty.isNumeric()); |
| 7334 | | 7378 | |
| ... | @@ -7494,7 +7538,7 @@ fn cmpNumeric( | ... | @@ -7494,7 +7538,7 @@ fn cmpNumeric( |
| 7494 | return block.addBinOp(src, Type.initTag(.bool), Inst.Tag.fromCmpOp(op), casted_lhs, casted_rhs); | 7538 | return block.addBinOp(src, Type.initTag(.bool), Inst.Tag.fromCmpOp(op), casted_lhs, casted_rhs); |
| 7495 | } | 7539 | } |
| 7496 | | 7540 | |
| 7497 | fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { | 7541 | fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Ref) !Air.Inst.Index { |
| 7498 | if (inst.value()) |val| { | 7542 | if (inst.value()) |val| { |
| 7499 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7543 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| 7500 | } | 7544 | } |
| ... | @@ -7503,9 +7547,15 @@ fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Ins | ... | @@ -7503,9 +7547,15 @@ fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Ins |
| 7503 | return block.addUnOp(inst.src, dest_type, .wrap_optional, inst); | 7547 | return block.addUnOp(inst.src, dest_type, .wrap_optional, inst); |
| 7504 | } | 7548 | } |
| 7505 | | 7549 | |
| 7506 | fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { | 7550 | fn wrapErrorUnion( |
| | 7551 | sema: *Sema, |
| | 7552 | block: *Scope.Block, |
| | 7553 | dest_type: Type, |
| | 7554 | inst: Air.Inst.Ref, |
| | 7555 | inst_src: LazySrcLoc, |
| | 7556 | ) !Air.Inst.Index { |
| 7507 | const err_union = dest_type.castTag(.error_union).?; | 7557 | const err_union = dest_type.castTag(.error_union).?; |
| 7508 | if (inst.value()) |val| { | 7558 | if (try sema.resolvePossiblyUndefinedValue(block, inst_src, inst)) |val| { |
| 7509 | if (inst.ty.zigTypeTag() != .ErrorSet) { | 7559 | if (inst.ty.zigTypeTag() != .ErrorSet) { |
| 7510 | _ = try sema.coerce(block, err_union.data.payload, inst, inst.src); | 7560 | _ = try sema.coerce(block, err_union.data.payload, inst, inst.src); |
| 7511 | } else switch (err_union.data.error_set.tag()) { | 7561 | } else switch (err_union.data.error_set.tag()) { |
| ... | @@ -7710,7 +7760,7 @@ fn getBuiltin( | ... | @@ -7710,7 +7760,7 @@ fn getBuiltin( |
| 7710 | block: *Scope.Block, | 7760 | block: *Scope.Block, |
| 7711 | src: LazySrcLoc, | 7761 | src: LazySrcLoc, |
| 7712 | name: []const u8, | 7762 | name: []const u8, |
| 7713 | ) InnerError!Air.Inst.Index { | 7763 | ) InnerError!Air.Inst.Ref { |
| 7714 | const mod = sema.mod; | 7764 | const mod = sema.mod; |
| 7715 | const std_pkg = mod.root_pkg.table.get("std").?; | 7765 | const std_pkg = mod.root_pkg.table.get("std").?; |
| 7716 | const std_file = (mod.importPkg(std_pkg) catch unreachable).file; | 7766 | const std_file = (mod.importPkg(std_pkg) catch unreachable).file; |
| ... | @@ -7938,6 +7988,68 @@ fn enumFieldSrcLoc( | ... | @@ -7938,6 +7988,68 @@ fn enumFieldSrcLoc( |
| 7938 | } else unreachable; | 7988 | } else unreachable; |
| 7939 | } | 7989 | } |
| 7940 | | 7990 | |
| | 7991 | /// Returns the type of the AIR instruction. |
| | 7992 | fn getTypeOfAirRef(sema: *Sema, air_ref: Air.Inst.Ref) Type { |
| | 7993 | switch (air_ref) { |
| | 7994 | .none => unreachable, |
| | 7995 | .u8_type => return Type.initTag(.u8), |
| | 7996 | .i8_type => return Type.initTag(.i8), |
| | 7997 | .u16_type => return Type.initTag(.u16), |
| | 7998 | .i16_type => return Type.initTag(.i16), |
| | 7999 | .u32_type => return Type.initTag(.u32), |
| | 8000 | .i32_type => return Type.initTag(.i32), |
| | 8001 | .u64_type => return Type.initTag(.u64), |
| | 8002 | .i64_type => return Type.initTag(.i64), |
| | 8003 | .u128_type => return Type.initTag(.u128), |
| | 8004 | .i128_type => return Type.initTag(.i128), |
| | 8005 | .usize_type => return Type.initTag(.usize), |
| | 8006 | .isize_type => return Type.initTag(.isize), |
| | 8007 | .c_short_type => return Type.initTag(.c_short), |
| | 8008 | .c_ushort_type => return Type.initTag(.c_ushort), |
| | 8009 | .c_int_type => return Type.initTag(.c_int), |
| | 8010 | .c_uint_type => return Type.initTag(.c_uint), |
| | 8011 | .c_long_type => return Type.initTag(.c_long), |
| | 8012 | .c_ulong_type => return Type.initTag(.c_ulong), |
| | 8013 | .c_longlong_type => return Type.initTag(.c_longlong), |
| | 8014 | .c_ulonglong_type => return Type.initTag(.c_ulonglong), |
| | 8015 | .c_longdouble_type => return Type.initTag(.c_longdouble), |
| | 8016 | .f16_type => return Type.initTag(.f16), |
| | 8017 | .f32_type => return Type.initTag(.f32), |
| | 8018 | .f64_type => return Type.initTag(.f64), |
| | 8019 | .f128_type => return Type.initTag(.f128), |
| | 8020 | .c_void_type => return Type.initTag(.c_void), |
| | 8021 | .bool_type => return Type.initTag(.bool), |
| | 8022 | .void_type => return Type.initTag(.void), |
| | 8023 | .type_type => return Type.initTag(.type), |
| | 8024 | .anyerror_type => return Type.initTag(.anyerror), |
| | 8025 | .comptime_int_type => return Type.initTag(.comptime_int), |
| | 8026 | .comptime_float_type => return Type.initTag(.comptime_float), |
| | 8027 | .noreturn_type => return Type.initTag(.noreturn), |
| | 8028 | .anyframe_type => return Type.initTag(.@"anyframe"), |
| | 8029 | .null_type => return Type.initTag(.@"null"), |
| | 8030 | .undefined_type => return Type.initTag(.@"undefined"), |
| | 8031 | .enum_literal_type => return Type.initTag(.enum_literal), |
| | 8032 | .atomic_ordering_type => return Type.initTag(.atomic_ordering), |
| | 8033 | .atomic_rmw_op_type => return Type.initTag(.atomic_rmw_op), |
| | 8034 | .calling_convention_type => return Type.initTag(.calling_convention), |
| | 8035 | .float_mode_type => return Type.initTag(.float_mode), |
| | 8036 | .reduce_op_type => return Type.initTag(.reduce_op), |
| | 8037 | .call_options_type => return Type.initTag(.call_options), |
| | 8038 | .export_options_type => return Type.initTag(.export_options), |
| | 8039 | .extern_options_type => return Type.initTag(.extern_options), |
| | 8040 | .manyptr_u8_type => return Type.initTag(.manyptr_u8), |
| | 8041 | .manyptr_const_u8_type => return Type.initTag(.manyptr_const_u8), |
| | 8042 | .fn_noreturn_no_args_type => return Type.initTag(.fn_noreturn_no_args), |
| | 8043 | .fn_void_no_args_type => return Type.initTag(.fn_void_no_args), |
| | 8044 | .fn_naked_noreturn_no_args_type => return Type.initTag(.fn_naked_noreturn_no_args), |
| | 8045 | .fn_ccc_void_no_args_type => return Type.initTag(.fn_ccc_void_no_args), |
| | 8046 | .single_const_pointer_to_comptime_int_type => return Type.initTag(.single_const_pointer_to_comptime_int), |
| | 8047 | .const_slice_u8_type => return Type.initTag(.const_slice_u8), |
| | 8048 | else => return sema.getAirType(air_ref), |
| | 8049 | } |
| | 8050 | } |
| | 8051 | |
| | 8052 | /// Asserts the AIR instruction is a `const_ty` and returns the type. |
| 7941 | fn getAirType(sema: *Sema, air_ref: Air.Inst.Ref) Type { | 8053 | fn getAirType(sema: *Sema, air_ref: Air.Inst.Ref) Type { |
| 7942 | var i: usize = @enumToInt(air_ref); | 8054 | var i: usize = @enumToInt(air_ref); |
| 7943 | if (i < Air.Inst.Ref.typed_value_map.len) { | 8055 | if (i < Air.Inst.Ref.typed_value_map.len) { |
| ... | @@ -8014,13 +8126,27 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref { | ... | @@ -8014,13 +8126,27 @@ pub fn addType(sema: *Sema, ty: Type) !Air.Inst.Ref { |
| 8014 | return indexToRef(@intCast(u32, sema.air_instructions.len - 1)); | 8126 | return indexToRef(@intCast(u32, sema.air_instructions.len - 1)); |
| 8015 | } | 8127 | } |
| 8016 | | 8128 | |
| | 8129 | pub fn addConstant(sema: *Sema, ty: Type, val: Value) InnerError!Air.Inst.Ref { |
| | 8130 | const gpa = sema.gpa; |
| | 8131 | const ty_inst = try sema.addType(ty); |
| | 8132 | try sema.air_values.append(gpa, val); |
| | 8133 | try sema.air_instructions.append(gpa, .{ |
| | 8134 | .tag = .constant, |
| | 8135 | .data = .{ .ty_pl = .{ |
| | 8136 | .ty = ty_inst, |
| | 8137 | .payload = @intCast(u32, sema.air_values.items.len - 1), |
| | 8138 | } }, |
| | 8139 | }); |
| | 8140 | return indexToRef(@intCast(u32, sema.air_instructions.len - 1)); |
| | 8141 | } |
| | 8142 | |
| 8017 | const ref_start_index: u32 = Air.Inst.Ref.typed_value_map.len; | 8143 | const ref_start_index: u32 = Air.Inst.Ref.typed_value_map.len; |
| 8018 | | 8144 | |
| 8019 | fn indexToRef(inst: Air.Inst.Index) Air.Inst.Ref { | 8145 | pub fn indexToRef(inst: Air.Inst.Index) Air.Inst.Ref { |
| 8020 | return @intToEnum(Air.Inst.Ref, ref_start_index + inst); | 8146 | return @intToEnum(Air.Inst.Ref, ref_start_index + inst); |
| 8021 | } | 8147 | } |
| 8022 | | 8148 | |
| 8023 | fn refToIndex(inst: Air.Inst.Ref) ?Air.Inst.Index { | 8149 | pub fn refToIndex(inst: Air.Inst.Ref) ?Air.Inst.Index { |
| 8024 | const ref_int = @enumToInt(inst); | 8150 | const ref_int = @enumToInt(inst); |
| 8025 | if (ref_int >= ref_start_index) { | 8151 | if (ref_int >= ref_start_index) { |
| 8026 | return ref_int - ref_start_index; | 8152 | return ref_int - ref_start_index; |