| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | //! Semantic analysis of ZIR instructions. | 1 | //! Semantic analysis of ZIR instructions. |
| 2 | //! Shared to every Block. Stored on the stack. | 2 | //! Shared to every Block. Stored on the stack. |
| 3 | //! State used for compiling a `Zir` into AIR. | 3 | //! State used for compiling a ZIR into AIR. |
| 4 | //! Transforms untyped ZIR instructions into semantically-analyzed AIR instructions. | 4 | //! Transforms untyped ZIR instructions into semantically-analyzed AIR instructions. |
| 5 | //! Does type checking, comptime control flow, and safety-check generation. | 5 | //! Does type checking, comptime control flow, and safety-check generation. |
| 6 | //! This is the the heart of the Zig compiler. | 6 | //! This is the the heart of the Zig compiler. |
| ... | @@ -11,6 +11,10 @@ gpa: *Allocator, | ... | @@ -11,6 +11,10 @@ gpa: *Allocator, |
| 11 | /// Points to the arena allocator of the Decl. | 11 | /// Points to the arena allocator of the Decl. |
| 12 | arena: *Allocator, | 12 | arena: *Allocator, |
| 13 | code: Zir, | 13 | code: Zir, |
| | 14 | air_instructions: std.MultiArrayList(Air.Inst) = .{}, |
| | 15 | air_extra: ArrayListUnmanaged(u32) = .{}, |
| | 16 | air_values: ArrayListUnmanaged(Value) = .{}, |
| | 17 | air_variables: ArrayListUnmanaged(Module.Var) = .{}, |
| 14 | /// Maps ZIR to AIR. | 18 | /// Maps ZIR to AIR. |
| 15 | inst_map: InstMap = .{}, | 19 | inst_map: InstMap = .{}, |
| 16 | /// When analyzing an inline function call, owner_decl is the Decl of the caller | 20 | /// When analyzing an inline function call, owner_decl is the Decl of the caller |
| ... | @@ -32,7 +36,7 @@ func: ?*Module.Fn, | ... | @@ -32,7 +36,7 @@ func: ?*Module.Fn, |
| 32 | /// > 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, |
| 33 | /// > otherwise it is the number of parameters of the function. | 37 | /// > otherwise it is the number of parameters of the function. |
| 34 | /// > param_count: u32 | 38 | /// > param_count: u32 |
| 35 | param_inst_list: []const *ir.Inst, | 39 | param_inst_list: []const Air.Inst.Index, |
| 36 | branch_quota: u32 = 1000, | 40 | branch_quota: u32 = 1000, |
| 37 | branch_count: u32 = 0, | 41 | branch_count: u32 = 0, |
| 38 | /// 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 |
| ... | @@ -65,10 +69,15 @@ const LazySrcLoc = Module.LazySrcLoc; | ... | @@ -65,10 +69,15 @@ const LazySrcLoc = Module.LazySrcLoc; |
| 65 | const RangeSet = @import("RangeSet.zig"); | 69 | const RangeSet = @import("RangeSet.zig"); |
| 66 | const target_util = @import("target.zig"); | 70 | const target_util = @import("target.zig"); |
| 67 | | 71 | |
| 68 | pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, *ir.Inst); | 72 | pub const InstMap = std.AutoHashMapUnmanaged(Zir.Inst.Index, Air.Inst.Index); |
| 69 | | 73 | |
| 70 | pub fn deinit(sema: *Sema) void { | 74 | pub fn deinit(sema: *Sema) void { |
| 71 | sema.inst_map.deinit(sema.gpa); | 75 | const gpa = sema.gpa; |
| | 76 | sema.air_instructions.deinit(gpa); |
| | 77 | sema.air_extra.deinit(gpa); |
| | 78 | sema.air_values.deinit(gpa); |
| | 79 | sema.air_variables.deinit(gpa); |
| | 80 | sema.inst_map.deinit(gpa); |
| 72 | sema.* = undefined; | 81 | sema.* = undefined; |
| 73 | } | 82 | } |
| 74 | | 83 | |
| ... | @@ -108,7 +117,7 @@ pub fn analyzeFnBody( | ... | @@ -108,7 +117,7 @@ pub fn analyzeFnBody( |
| 108 | /// Returns only the result from the body that is specified. | 117 | /// Returns only the result from the body that is specified. |
| 109 | /// Only appropriate to call when it is determined at comptime that this body | 118 | /// Only appropriate to call when it is determined at comptime that this body |
| 110 | /// has no peers. | 119 | /// has no peers. |
| 111 | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!*Inst { | 120 | fn resolveBody(sema: *Sema, block: *Scope.Block, body: []const Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 112 | const break_inst = try sema.analyzeBody(block, body); | 121 | const break_inst = try sema.analyzeBody(block, body); |
| 113 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; | 122 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 114 | return sema.resolveInst(operand_ref); | 123 | return sema.resolveInst(operand_ref); |
| ... | @@ -533,7 +542,7 @@ pub fn analyzeBody( | ... | @@ -533,7 +542,7 @@ pub fn analyzeBody( |
| 533 | } | 542 | } |
| 534 | } | 543 | } |
| 535 | | 544 | |
| 536 | fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 545 | fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 537 | const extended = sema.code.instructions.items(.data)[inst].extended; | 546 | const extended = sema.code.instructions.items(.data)[inst].extended; |
| 538 | switch (extended.opcode) { | 547 | switch (extended.opcode) { |
| 539 | // zig fmt: off | 548 | // zig fmt: off |
| ... | @@ -569,7 +578,7 @@ fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -569,7 +578,7 @@ fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 569 | } | 578 | } |
| 570 | | 579 | |
| 571 | /// TODO when we rework AIR memory layout, this function will no longer have a possible error. | 580 | /// TODO when we rework AIR memory layout, this function will no longer have a possible error. |
| 572 | pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) error{OutOfMemory}!*ir.Inst { | 581 | pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) error{OutOfMemory}!Air.Inst.Index { |
| 573 | var i: usize = @enumToInt(zir_ref); | 582 | var i: usize = @enumToInt(zir_ref); |
| 574 | | 583 | |
| 575 | // First section of indexes correspond to a set number of constant values. | 584 | // First section of indexes correspond to a set number of constant values. |
| ... | @@ -618,19 +627,19 @@ pub fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Z | ... | @@ -618,19 +627,19 @@ pub fn resolveType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, zir_ref: Z |
| 618 | return sema.resolveAirAsType(block, src, air_inst); | 627 | return sema.resolveAirAsType(block, src, air_inst); |
| 619 | } | 628 | } |
| 620 | | 629 | |
| 621 | fn resolveAirAsType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, air_inst: *ir.Inst) !Type { | 630 | fn resolveAirAsType(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, air_inst: Air.Inst.Index) !Type { |
| 622 | const wanted_type = Type.initTag(.@"type"); | 631 | const wanted_type = Type.initTag(.@"type"); |
| 623 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 632 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 624 | const val = try sema.resolveConstValue(block, src, coerced_inst); | 633 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| 625 | return val.toType(sema.arena); | 634 | return val.toType(sema.arena); |
| 626 | } | 635 | } |
| 627 | | 636 | |
| 628 | fn resolveConstValue(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, base: *ir.Inst) !Value { | 637 | fn resolveConstValue(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, base: Air.Inst.Index) !Value { |
| 629 | return (try sema.resolveDefinedValue(block, src, base)) orelse | 638 | return (try sema.resolveDefinedValue(block, src, base)) orelse |
| 630 | return sema.failWithNeededComptime(block, src); | 639 | return sema.failWithNeededComptime(block, src); |
| 631 | } | 640 | } |
| 632 | | 641 | |
| 633 | fn resolveDefinedValue(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, base: *ir.Inst) !?Value { | 642 | fn resolveDefinedValue(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, base: Air.Inst.Index) !?Value { |
| 634 | if (try sema.resolvePossiblyUndefinedValue(block, src, base)) |val| { | 643 | if (try sema.resolvePossiblyUndefinedValue(block, src, base)) |val| { |
| 635 | if (val.isUndef()) { | 644 | if (val.isUndef()) { |
| 636 | return sema.failWithUseOfUndef(block, src); | 645 | return sema.failWithUseOfUndef(block, src); |
| ... | @@ -644,7 +653,7 @@ fn resolvePossiblyUndefinedValue( | ... | @@ -644,7 +653,7 @@ fn resolvePossiblyUndefinedValue( |
| 644 | sema: *Sema, | 653 | sema: *Sema, |
| 645 | block: *Scope.Block, | 654 | block: *Scope.Block, |
| 646 | src: LazySrcLoc, | 655 | src: LazySrcLoc, |
| 647 | base: *ir.Inst, | 656 | base: Air.Inst.Index, |
| 648 | ) !?Value { | 657 | ) !?Value { |
| 649 | if (try sema.typeHasOnePossibleValue(block, src, base.ty)) |opv| { | 658 | if (try sema.typeHasOnePossibleValue(block, src, base.ty)) |opv| { |
| 650 | return opv; | 659 | return opv; |
| ... | @@ -708,13 +717,13 @@ pub fn resolveInstConst( | ... | @@ -708,13 +717,13 @@ pub fn resolveInstConst( |
| 708 | }; | 717 | }; |
| 709 | } | 718 | } |
| 710 | | 719 | |
| 711 | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 720 | fn zirBitcastResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 712 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 721 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 713 | const src = inst_data.src(); | 722 | const src = inst_data.src(); |
| 714 | return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); | 723 | return sema.mod.fail(&block.base, src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); |
| 715 | } | 724 | } |
| 716 | | 725 | |
| 717 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 726 | fn zirCoerceResultPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 718 | _ = inst; | 727 | _ = inst; |
| 719 | const tracy = trace(@src()); | 728 | const tracy = trace(@src()); |
| 720 | defer tracy.end(); | 729 | defer tracy.end(); |
| ... | @@ -749,7 +758,7 @@ fn zirStructDecl( | ... | @@ -749,7 +758,7 @@ fn zirStructDecl( |
| 749 | block: *Scope.Block, | 758 | block: *Scope.Block, |
| 750 | extended: Zir.Inst.Extended.InstData, | 759 | extended: Zir.Inst.Extended.InstData, |
| 751 | inst: Zir.Inst.Index, | 760 | inst: Zir.Inst.Index, |
| 752 | ) InnerError!*Inst { | 761 | ) InnerError!Air.Inst.Index { |
| 753 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); | 762 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); |
| 754 | const src: LazySrcLoc = if (small.has_src_node) blk: { | 763 | const src: LazySrcLoc = if (small.has_src_node) blk: { |
| 755 | const node_offset = @bitCast(i32, sema.code.extra[extended.operand]); | 764 | const node_offset = @bitCast(i32, sema.code.extra[extended.operand]); |
| ... | @@ -820,7 +829,7 @@ fn zirEnumDecl( | ... | @@ -820,7 +829,7 @@ fn zirEnumDecl( |
| 820 | sema: *Sema, | 829 | sema: *Sema, |
| 821 | block: *Scope.Block, | 830 | block: *Scope.Block, |
| 822 | extended: Zir.Inst.Extended.InstData, | 831 | extended: Zir.Inst.Extended.InstData, |
| 823 | ) InnerError!*Inst { | 832 | ) InnerError!Air.Inst.Index { |
| 824 | const tracy = trace(@src()); | 833 | const tracy = trace(@src()); |
| 825 | defer tracy.end(); | 834 | defer tracy.end(); |
| 826 | | 835 | |
| ... | @@ -1017,7 +1026,7 @@ fn zirUnionDecl( | ... | @@ -1017,7 +1026,7 @@ fn zirUnionDecl( |
| 1017 | block: *Scope.Block, | 1026 | block: *Scope.Block, |
| 1018 | extended: Zir.Inst.Extended.InstData, | 1027 | extended: Zir.Inst.Extended.InstData, |
| 1019 | inst: Zir.Inst.Index, | 1028 | inst: Zir.Inst.Index, |
| 1020 | ) InnerError!*Inst { | 1029 | ) InnerError!Air.Inst.Index { |
| 1021 | const tracy = trace(@src()); | 1030 | const tracy = trace(@src()); |
| 1022 | defer tracy.end(); | 1031 | defer tracy.end(); |
| 1023 | | 1032 | |
| ... | @@ -1081,7 +1090,7 @@ fn zirOpaqueDecl( | ... | @@ -1081,7 +1090,7 @@ fn zirOpaqueDecl( |
| 1081 | block: *Scope.Block, | 1090 | block: *Scope.Block, |
| 1082 | inst: Zir.Inst.Index, | 1091 | inst: Zir.Inst.Index, |
| 1083 | name_strategy: Zir.Inst.NameStrategy, | 1092 | name_strategy: Zir.Inst.NameStrategy, |
| 1084 | ) InnerError!*Inst { | 1093 | ) InnerError!Air.Inst.Index { |
| 1085 | const tracy = trace(@src()); | 1094 | const tracy = trace(@src()); |
| 1086 | defer tracy.end(); | 1095 | defer tracy.end(); |
| 1087 | | 1096 | |
| ... | @@ -1101,7 +1110,7 @@ fn zirErrorSetDecl( | ... | @@ -1101,7 +1110,7 @@ fn zirErrorSetDecl( |
| 1101 | block: *Scope.Block, | 1110 | block: *Scope.Block, |
| 1102 | inst: Zir.Inst.Index, | 1111 | inst: Zir.Inst.Index, |
| 1103 | name_strategy: Zir.Inst.NameStrategy, | 1112 | name_strategy: Zir.Inst.NameStrategy, |
| 1104 | ) InnerError!*Inst { | 1113 | ) InnerError!Air.Inst.Index { |
| 1105 | const tracy = trace(@src()); | 1114 | const tracy = trace(@src()); |
| 1106 | defer tracy.end(); | 1115 | defer tracy.end(); |
| 1107 | | 1116 | |
| ... | @@ -1141,7 +1150,7 @@ fn zirRetPtr( | ... | @@ -1141,7 +1150,7 @@ fn zirRetPtr( |
| 1141 | sema: *Sema, | 1150 | sema: *Sema, |
| 1142 | block: *Scope.Block, | 1151 | block: *Scope.Block, |
| 1143 | extended: Zir.Inst.Extended.InstData, | 1152 | extended: Zir.Inst.Extended.InstData, |
| 1144 | ) InnerError!*Inst { | 1153 | ) InnerError!Air.Inst.Index { |
| 1145 | const tracy = trace(@src()); | 1154 | const tracy = trace(@src()); |
| 1146 | defer tracy.end(); | 1155 | defer tracy.end(); |
| 1147 | | 1156 | |
| ... | @@ -1153,7 +1162,7 @@ fn zirRetPtr( | ... | @@ -1153,7 +1162,7 @@ fn zirRetPtr( |
| 1153 | return block.addNoOp(src, ptr_type, .alloc); | 1162 | return block.addNoOp(src, ptr_type, .alloc); |
| 1154 | } | 1163 | } |
| 1155 | | 1164 | |
| 1156 | fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1165 | fn zirRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1157 | const tracy = trace(@src()); | 1166 | const tracy = trace(@src()); |
| 1158 | defer tracy.end(); | 1167 | defer tracy.end(); |
| 1159 | | 1168 | |
| ... | @@ -1166,7 +1175,7 @@ fn zirRetType( | ... | @@ -1166,7 +1175,7 @@ fn zirRetType( |
| 1166 | sema: *Sema, | 1175 | sema: *Sema, |
| 1167 | block: *Scope.Block, | 1176 | block: *Scope.Block, |
| 1168 | extended: Zir.Inst.Extended.InstData, | 1177 | extended: Zir.Inst.Extended.InstData, |
| 1169 | ) InnerError!*Inst { | 1178 | ) InnerError!Air.Inst.Index { |
| 1170 | const tracy = trace(@src()); | 1179 | const tracy = trace(@src()); |
| 1171 | defer tracy.end(); | 1180 | defer tracy.end(); |
| 1172 | | 1181 | |
| ... | @@ -1191,7 +1200,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I | ... | @@ -1191,7 +1200,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I |
| 1191 | fn ensureResultUsed( | 1200 | fn ensureResultUsed( |
| 1192 | sema: *Sema, | 1201 | sema: *Sema, |
| 1193 | block: *Scope.Block, | 1202 | block: *Scope.Block, |
| 1194 | operand: *Inst, | 1203 | operand: Air.Inst.Index, |
| 1195 | src: LazySrcLoc, | 1204 | src: LazySrcLoc, |
| 1196 | ) InnerError!void { | 1205 | ) InnerError!void { |
| 1197 | switch (operand.ty.zigTypeTag()) { | 1206 | switch (operand.ty.zigTypeTag()) { |
| ... | @@ -1213,7 +1222,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde | ... | @@ -1213,7 +1222,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Inde |
| 1213 | } | 1222 | } |
| 1214 | } | 1223 | } |
| 1215 | | 1224 | |
| 1216 | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1225 | fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1217 | const tracy = trace(@src()); | 1226 | const tracy = trace(@src()); |
| 1218 | defer tracy.end(); | 1227 | defer tracy.end(); |
| 1219 | | 1228 | |
| ... | @@ -1247,7 +1256,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In | ... | @@ -1247,7 +1256,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 1247 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); | 1256 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); |
| 1248 | } | 1257 | } |
| 1249 | | 1258 | |
| 1250 | fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1259 | fn zirArg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1251 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 1260 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1252 | const arg_name = inst_data.get(sema.code); | 1261 | const arg_name = inst_data.get(sema.code); |
| 1253 | const arg_index = sema.next_arg_index; | 1262 | const arg_index = sema.next_arg_index; |
| ... | @@ -1269,13 +1278,13 @@ fn zirAllocExtended( | ... | @@ -1269,13 +1278,13 @@ fn zirAllocExtended( |
| 1269 | sema: *Sema, | 1278 | sema: *Sema, |
| 1270 | block: *Scope.Block, | 1279 | block: *Scope.Block, |
| 1271 | extended: Zir.Inst.Extended.InstData, | 1280 | extended: Zir.Inst.Extended.InstData, |
| 1272 | ) InnerError!*Inst { | 1281 | ) InnerError!Air.Inst.Index { |
| 1273 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); | 1282 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); |
| 1274 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; | 1283 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; |
| 1275 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{}); | 1284 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocExtended", .{}); |
| 1276 | } | 1285 | } |
| 1277 | | 1286 | |
| 1278 | fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1287 | fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1279 | const tracy = trace(@src()); | 1288 | const tracy = trace(@src()); |
| 1280 | defer tracy.end(); | 1289 | defer tracy.end(); |
| 1281 | | 1290 | |
| ... | @@ -1298,13 +1307,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -1298,13 +1307,13 @@ fn zirAllocComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 1298 | }); | 1307 | }); |
| 1299 | } | 1308 | } |
| 1300 | | 1309 | |
| 1301 | fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1310 | fn zirAllocInferredComptime(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1302 | const src_node = sema.code.instructions.items(.data)[inst].node; | 1311 | const src_node = sema.code.instructions.items(.data)[inst].node; |
| 1303 | const src: LazySrcLoc = .{ .node_offset = src_node }; | 1312 | const src: LazySrcLoc = .{ .node_offset = src_node }; |
| 1304 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{}); | 1313 | return sema.mod.fail(&block.base, src, "TODO implement Sema.zirAllocInferredComptime", .{}); |
| 1305 | } | 1314 | } |
| 1306 | | 1315 | |
| 1307 | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1316 | fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1308 | const tracy = trace(@src()); | 1317 | const tracy = trace(@src()); |
| 1309 | defer tracy.end(); | 1318 | defer tracy.end(); |
| 1310 | | 1319 | |
| ... | @@ -1317,7 +1326,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* | ... | @@ -1317,7 +1326,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* |
| 1317 | return block.addNoOp(var_decl_src, ptr_type, .alloc); | 1326 | return block.addNoOp(var_decl_src, ptr_type, .alloc); |
| 1318 | } | 1327 | } |
| 1319 | | 1328 | |
| 1320 | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1329 | fn zirAllocMut(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1321 | const tracy = trace(@src()); | 1330 | const tracy = trace(@src()); |
| 1322 | defer tracy.end(); | 1331 | defer tracy.end(); |
| 1323 | | 1332 | |
| ... | @@ -1336,7 +1345,7 @@ fn zirAllocInferred( | ... | @@ -1336,7 +1345,7 @@ fn zirAllocInferred( |
| 1336 | block: *Scope.Block, | 1345 | block: *Scope.Block, |
| 1337 | inst: Zir.Inst.Index, | 1346 | inst: Zir.Inst.Index, |
| 1338 | inferred_alloc_ty: Type, | 1347 | inferred_alloc_ty: Type, |
| 1339 | ) InnerError!*Inst { | 1348 | ) InnerError!Air.Inst.Index { |
| 1340 | const tracy = trace(@src()); | 1349 | const tracy = trace(@src()); |
| 1341 | defer tracy.end(); | 1350 | defer tracy.end(); |
| 1342 | | 1351 | |
| ... | @@ -1589,7 +1598,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -1589,7 +1598,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 1589 | return sema.storePtr(block, src, ptr, value); | 1598 | return sema.storePtr(block, src, ptr, value); |
| 1590 | } | 1599 | } |
| 1591 | | 1600 | |
| 1592 | fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1601 | fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1593 | const tracy = trace(@src()); | 1602 | const tracy = trace(@src()); |
| 1594 | defer tracy.end(); | 1603 | defer tracy.end(); |
| 1595 | | 1604 | |
| ... | @@ -1625,7 +1634,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -1625,7 +1634,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 1625 | return sema.mod.constType(sema.arena, src, param_type); | 1634 | return sema.mod.constType(sema.arena, src, param_type); |
| 1626 | } | 1635 | } |
| 1627 | | 1636 | |
| 1628 | fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1637 | fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1629 | const tracy = trace(@src()); | 1638 | const tracy = trace(@src()); |
| 1630 | defer tracy.end(); | 1639 | defer tracy.end(); |
| 1631 | | 1640 | |
| ... | @@ -1653,7 +1662,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In | ... | @@ -1653,7 +1662,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 1653 | return sema.analyzeDeclRef(block, .unneeded, new_decl); | 1662 | return sema.analyzeDeclRef(block, .unneeded, new_decl); |
| 1654 | } | 1663 | } |
| 1655 | | 1664 | |
| 1656 | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1665 | fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1657 | _ = block; | 1666 | _ = block; |
| 1658 | const tracy = trace(@src()); | 1667 | const tracy = trace(@src()); |
| 1659 | defer tracy.end(); | 1668 | defer tracy.end(); |
| ... | @@ -1662,7 +1671,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In | ... | @@ -1662,7 +1671,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 1662 | return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int); | 1671 | return sema.mod.constIntUnsigned(sema.arena, .unneeded, Type.initTag(.comptime_int), int); |
| 1663 | } | 1672 | } |
| 1664 | | 1673 | |
| 1665 | fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1674 | fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1666 | _ = block; | 1675 | _ = block; |
| 1667 | const tracy = trace(@src()); | 1676 | const tracy = trace(@src()); |
| 1668 | defer tracy.end(); | 1677 | defer tracy.end(); |
| ... | @@ -1680,7 +1689,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -1680,7 +1689,7 @@ fn zirIntBig(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 1680 | }); | 1689 | }); |
| 1681 | } | 1690 | } |
| 1682 | | 1691 | |
| 1683 | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1692 | fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1684 | _ = block; | 1693 | _ = block; |
| 1685 | const arena = sema.arena; | 1694 | const arena = sema.arena; |
| 1686 | const inst_data = sema.code.instructions.items(.data)[inst].float; | 1695 | const inst_data = sema.code.instructions.items(.data)[inst].float; |
| ... | @@ -1693,7 +1702,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* | ... | @@ -1693,7 +1702,7 @@ fn zirFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* |
| 1693 | }); | 1702 | }); |
| 1694 | } | 1703 | } |
| 1695 | | 1704 | |
| 1696 | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1705 | fn zirFloat128(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1697 | _ = block; | 1706 | _ = block; |
| 1698 | const arena = sema.arena; | 1707 | const arena = sema.arena; |
| 1699 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1708 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| ... | @@ -1722,7 +1731,7 @@ fn zirCompileLog( | ... | @@ -1722,7 +1731,7 @@ fn zirCompileLog( |
| 1722 | sema: *Sema, | 1731 | sema: *Sema, |
| 1723 | block: *Scope.Block, | 1732 | block: *Scope.Block, |
| 1724 | extended: Zir.Inst.Extended.InstData, | 1733 | extended: Zir.Inst.Extended.InstData, |
| 1725 | ) InnerError!*Inst { | 1734 | ) InnerError!Air.Inst.Index { |
| 1726 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); | 1735 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); |
| 1727 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); | 1736 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); |
| 1728 | const writer = managed.writer(); | 1737 | const writer = managed.writer(); |
| ... | @@ -1772,7 +1781,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Z | ... | @@ -1772,7 +1781,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Z |
| 1772 | return sema.panicWithMsg(block, src, msg_inst); | 1781 | return sema.panicWithMsg(block, src, msg_inst); |
| 1773 | } | 1782 | } |
| 1774 | | 1783 | |
| 1775 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1784 | fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1776 | const tracy = trace(@src()); | 1785 | const tracy = trace(@src()); |
| 1777 | defer tracy.end(); | 1786 | defer tracy.end(); |
| 1778 | | 1787 | |
| ... | @@ -1832,12 +1841,12 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -1832,12 +1841,12 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 1832 | // Loop repetition is implied so the last instruction may or may not be a noreturn instruction. | 1841 | // Loop repetition is implied so the last instruction may or may not be a noreturn instruction. |
| 1833 | | 1842 | |
| 1834 | try child_block.instructions.append(sema.gpa, &loop_inst.base); | 1843 | try child_block.instructions.append(sema.gpa, &loop_inst.base); |
| 1835 | loop_inst.body = .{ .instructions = try sema.arena.dupe(*Inst, loop_block.instructions.items) }; | 1844 | loop_inst.body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, loop_block.instructions.items) }; |
| 1836 | | 1845 | |
| 1837 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); | 1846 | return sema.analyzeBlockBody(parent_block, src, &child_block, merges); |
| 1838 | } | 1847 | } |
| 1839 | | 1848 | |
| 1840 | fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1849 | fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1841 | const tracy = trace(@src()); | 1850 | const tracy = trace(@src()); |
| 1842 | defer tracy.end(); | 1851 | defer tracy.end(); |
| 1843 | | 1852 | |
| ... | @@ -1847,13 +1856,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -1847,13 +1856,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 1847 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{}); | 1856 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirCImport", .{}); |
| 1848 | } | 1857 | } |
| 1849 | | 1858 | |
| 1850 | fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1859 | fn zirSuspendBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1851 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 1860 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1852 | const src = inst_data.src(); | 1861 | const src = inst_data.src(); |
| 1853 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{}); | 1862 | return sema.mod.fail(&parent_block.base, src, "TODO: implement Sema.zirSuspendBlock", .{}); |
| 1854 | } | 1863 | } |
| 1855 | | 1864 | |
| 1856 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 1865 | fn zirBlock(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 1857 | const tracy = trace(@src()); | 1866 | const tracy = trace(@src()); |
| 1858 | defer tracy.end(); | 1867 | defer tracy.end(); |
| 1859 | | 1868 | |
| ... | @@ -1911,7 +1920,7 @@ fn resolveBlockBody( | ... | @@ -1911,7 +1920,7 @@ fn resolveBlockBody( |
| 1911 | child_block: *Scope.Block, | 1920 | child_block: *Scope.Block, |
| 1912 | body: []const Zir.Inst.Index, | 1921 | body: []const Zir.Inst.Index, |
| 1913 | merges: *Scope.Block.Merges, | 1922 | merges: *Scope.Block.Merges, |
| 1914 | ) InnerError!*Inst { | 1923 | ) InnerError!Air.Inst.Index { |
| 1915 | _ = try sema.analyzeBody(child_block, body); | 1924 | _ = try sema.analyzeBody(child_block, body); |
| 1916 | return sema.analyzeBlockBody(parent_block, src, child_block, merges); | 1925 | return sema.analyzeBlockBody(parent_block, src, child_block, merges); |
| 1917 | } | 1926 | } |
| ... | @@ -1922,7 +1931,7 @@ fn analyzeBlockBody( | ... | @@ -1922,7 +1931,7 @@ fn analyzeBlockBody( |
| 1922 | src: LazySrcLoc, | 1931 | src: LazySrcLoc, |
| 1923 | child_block: *Scope.Block, | 1932 | child_block: *Scope.Block, |
| 1924 | merges: *Scope.Block.Merges, | 1933 | merges: *Scope.Block.Merges, |
| 1925 | ) InnerError!*Inst { | 1934 | ) InnerError!Air.Inst.Index { |
| 1926 | const tracy = trace(@src()); | 1935 | const tracy = trace(@src()); |
| 1927 | defer tracy.end(); | 1936 | defer tracy.end(); |
| 1928 | | 1937 | |
| ... | @@ -1933,7 +1942,7 @@ fn analyzeBlockBody( | ... | @@ -1933,7 +1942,7 @@ fn analyzeBlockBody( |
| 1933 | if (merges.results.items.len == 0) { | 1942 | if (merges.results.items.len == 0) { |
| 1934 | // No need for a block instruction. We can put the new instructions | 1943 | // No need for a block instruction. We can put the new instructions |
| 1935 | // directly into the parent block. | 1944 | // directly into the parent block. |
| 1936 | const copied_instructions = try sema.arena.dupe(*Inst, child_block.instructions.items); | 1945 | const copied_instructions = try sema.arena.dupe(Air.Inst.Index, child_block.instructions.items); |
| 1937 | try parent_block.instructions.appendSlice(sema.gpa, copied_instructions); | 1946 | try parent_block.instructions.appendSlice(sema.gpa, copied_instructions); |
| 1938 | return copied_instructions[copied_instructions.len - 1]; | 1947 | return copied_instructions[copied_instructions.len - 1]; |
| 1939 | } | 1948 | } |
| ... | @@ -1944,7 +1953,7 @@ fn analyzeBlockBody( | ... | @@ -1944,7 +1953,7 @@ fn analyzeBlockBody( |
| 1944 | if (br_block == merges.block_inst) { | 1953 | if (br_block == merges.block_inst) { |
| 1945 | // No need for a block instruction. We can put the new instructions directly | 1954 | // No need for a block instruction. We can put the new instructions directly |
| 1946 | // into the parent block. Here we omit the break instruction. | 1955 | // into the parent block. Here we omit the break instruction. |
| 1947 | const copied_instructions = try sema.arena.dupe(*Inst, child_block.instructions.items[0..last_inst_index]); | 1956 | const copied_instructions = try sema.arena.dupe(Air.Inst.Index, child_block.instructions.items[0..last_inst_index]); |
| 1948 | try parent_block.instructions.appendSlice(sema.gpa, copied_instructions); | 1957 | try parent_block.instructions.appendSlice(sema.gpa, copied_instructions); |
| 1949 | return merges.results.items[0]; | 1958 | return merges.results.items[0]; |
| 1950 | } | 1959 | } |
| ... | @@ -1959,7 +1968,7 @@ fn analyzeBlockBody( | ... | @@ -1959,7 +1968,7 @@ fn analyzeBlockBody( |
| 1959 | const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items); | 1968 | const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items); |
| 1960 | merges.block_inst.base.ty = resolved_ty; | 1969 | merges.block_inst.base.ty = resolved_ty; |
| 1961 | merges.block_inst.body = .{ | 1970 | merges.block_inst.body = .{ |
| 1962 | .instructions = try sema.arena.dupe(*Inst, child_block.instructions.items), | 1971 | .instructions = try sema.arena.dupe(Air.Inst.Index, child_block.instructions.items), |
| 1963 | }; | 1972 | }; |
| 1964 | // Now that the block has its type resolved, we need to go back into all the break | 1973 | // Now that the block has its type resolved, we need to go back into all the break |
| 1965 | // instructions, and insert type coercion on the operands. | 1974 | // instructions, and insert type coercion on the operands. |
| ... | @@ -1991,7 +2000,7 @@ fn analyzeBlockBody( | ... | @@ -1991,7 +2000,7 @@ fn analyzeBlockBody( |
| 1991 | }, | 2000 | }, |
| 1992 | .block = merges.block_inst, | 2001 | .block = merges.block_inst, |
| 1993 | .body = .{ | 2002 | .body = .{ |
| 1994 | .instructions = try sema.arena.dupe(*Inst, coerce_block.instructions.items), | 2003 | .instructions = try sema.arena.dupe(Air.Inst.Index, coerce_block.instructions.items), |
| 1995 | }, | 2004 | }, |
| 1996 | }; | 2005 | }; |
| 1997 | } | 2006 | } |
| ... | @@ -2130,7 +2139,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -2130,7 +2139,7 @@ fn zirDbgStmt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2130 | _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column); | 2139 | _ = try block.addDbgStmt(.unneeded, inst_data.line, inst_data.column); |
| 2131 | } | 2140 | } |
| 2132 | | 2141 | |
| 2133 | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2142 | fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2134 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 2143 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2135 | const src = inst_data.src(); | 2144 | const src = inst_data.src(); |
| 2136 | const decl_name = inst_data.get(sema.code); | 2145 | const decl_name = inst_data.get(sema.code); |
| ... | @@ -2138,7 +2147,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -2138,7 +2147,7 @@ fn zirDeclRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2138 | return sema.analyzeDeclRef(block, src, decl); | 2147 | return sema.analyzeDeclRef(block, src, decl); |
| 2139 | } | 2148 | } |
| 2140 | | 2149 | |
| 2141 | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2150 | fn zirDeclVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2142 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; | 2151 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2143 | const src = inst_data.src(); | 2152 | const src = inst_data.src(); |
| 2144 | const decl_name = inst_data.get(sema.code); | 2153 | const decl_name = inst_data.get(sema.code); |
| ... | @@ -2192,7 +2201,7 @@ fn zirCall( | ... | @@ -2192,7 +2201,7 @@ fn zirCall( |
| 2192 | inst: Zir.Inst.Index, | 2201 | inst: Zir.Inst.Index, |
| 2193 | modifier: std.builtin.CallOptions.Modifier, | 2202 | modifier: std.builtin.CallOptions.Modifier, |
| 2194 | ensure_result_used: bool, | 2203 | ensure_result_used: bool, |
| 2195 | ) InnerError!*Inst { | 2204 | ) InnerError!Air.Inst.Index { |
| 2196 | const tracy = trace(@src()); | 2205 | const tracy = trace(@src()); |
| 2197 | defer tracy.end(); | 2206 | defer tracy.end(); |
| 2198 | | 2207 | |
| ... | @@ -2204,7 +2213,7 @@ fn zirCall( | ... | @@ -2204,7 +2213,7 @@ fn zirCall( |
| 2204 | | 2213 | |
| 2205 | const func = try sema.resolveInst(extra.data.callee); | 2214 | const func = try sema.resolveInst(extra.data.callee); |
| 2206 | // TODO handle function calls of generic functions | 2215 | // TODO handle function calls of generic functions |
| 2207 | const resolved_args = try sema.arena.alloc(*Inst, args.len); | 2216 | const resolved_args = try sema.arena.alloc(Air.Inst.Index, args.len); |
| 2208 | for (args) |zir_arg, i| { | 2217 | for (args) |zir_arg, i| { |
| 2209 | // the args are already casted to the result of a param type instruction. | 2218 | // the args are already casted to the result of a param type instruction. |
| 2210 | resolved_args[i] = try sema.resolveInst(zir_arg); | 2219 | resolved_args[i] = try sema.resolveInst(zir_arg); |
| ... | @@ -2216,13 +2225,13 @@ fn zirCall( | ... | @@ -2216,13 +2225,13 @@ fn zirCall( |
| 2216 | fn analyzeCall( | 2225 | fn analyzeCall( |
| 2217 | sema: *Sema, | 2226 | sema: *Sema, |
| 2218 | block: *Scope.Block, | 2227 | block: *Scope.Block, |
| 2219 | func: *ir.Inst, | 2228 | func: Air.Inst.Index, |
| 2220 | func_src: LazySrcLoc, | 2229 | func_src: LazySrcLoc, |
| 2221 | call_src: LazySrcLoc, | 2230 | call_src: LazySrcLoc, |
| 2222 | modifier: std.builtin.CallOptions.Modifier, | 2231 | modifier: std.builtin.CallOptions.Modifier, |
| 2223 | ensure_result_used: bool, | 2232 | ensure_result_used: bool, |
| 2224 | args: []const *ir.Inst, | 2233 | args: []const Air.Inst.Index, |
| 2225 | ) InnerError!*ir.Inst { | 2234 | ) InnerError!Air.Inst.Index { |
| 2226 | if (func.ty.zigTypeTag() != .Fn) | 2235 | if (func.ty.zigTypeTag() != .Fn) |
| 2227 | return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty}); | 2236 | return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty}); |
| 2228 | | 2237 | |
| ... | @@ -2279,7 +2288,7 @@ fn analyzeCall( | ... | @@ -2279,7 +2288,7 @@ fn analyzeCall( |
| 2279 | const is_comptime_call = block.is_comptime or modifier == .compile_time; | 2288 | const is_comptime_call = block.is_comptime or modifier == .compile_time; |
| 2280 | const is_inline_call = is_comptime_call or modifier == .always_inline or | 2289 | const is_inline_call = is_comptime_call or modifier == .always_inline or |
| 2281 | func.ty.fnCallingConvention() == .Inline; | 2290 | func.ty.fnCallingConvention() == .Inline; |
| 2282 | const result: *Inst = if (is_inline_call) res: { | 2291 | const result: Air.Inst.Index = if (is_inline_call) res: { |
| 2283 | const func_val = try sema.resolveConstValue(block, func_src, func); | 2292 | const func_val = try sema.resolveConstValue(block, func_src, func); |
| 2284 | const module_fn = switch (func_val.tag()) { | 2293 | const module_fn = switch (func_val.tag()) { |
| 2285 | .function => func_val.castTag(.function).?.data, | 2294 | .function => func_val.castTag(.function).?.data, |
| ... | @@ -2377,7 +2386,7 @@ fn analyzeCall( | ... | @@ -2377,7 +2386,7 @@ fn analyzeCall( |
| 2377 | return result; | 2386 | return result; |
| 2378 | } | 2387 | } |
| 2379 | | 2388 | |
| 2380 | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2389 | fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2381 | _ = block; | 2390 | _ = block; |
| 2382 | const tracy = trace(@src()); | 2391 | const tracy = trace(@src()); |
| 2383 | defer tracy.end(); | 2392 | defer tracy.end(); |
| ... | @@ -2389,7 +2398,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -2389,7 +2398,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2389 | return sema.mod.constType(sema.arena, src, ty); | 2398 | return sema.mod.constType(sema.arena, src, ty); |
| 2390 | } | 2399 | } |
| 2391 | | 2400 | |
| 2392 | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2401 | fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2393 | const tracy = trace(@src()); | 2402 | const tracy = trace(@src()); |
| 2394 | defer tracy.end(); | 2403 | defer tracy.end(); |
| 2395 | | 2404 | |
| ... | @@ -2401,7 +2410,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner | ... | @@ -2401,7 +2410,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2401 | return sema.mod.constType(sema.arena, src, opt_type); | 2410 | return sema.mod.constType(sema.arena, src, opt_type); |
| 2402 | } | 2411 | } |
| 2403 | | 2412 | |
| 2404 | fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2413 | fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2405 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2414 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2406 | const src = inst_data.src(); | 2415 | const src = inst_data.src(); |
| 2407 | const array_type = try sema.resolveType(block, src, inst_data.operand); | 2416 | const array_type = try sema.resolveType(block, src, inst_data.operand); |
| ... | @@ -2409,7 +2418,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -2409,7 +2418,7 @@ fn zirElemType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 2409 | return sema.mod.constType(sema.arena, src, elem_type); | 2418 | return sema.mod.constType(sema.arena, src, elem_type); |
| 2410 | } | 2419 | } |
| 2411 | | 2420 | |
| 2412 | fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2421 | fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2413 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 2422 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2414 | const src = inst_data.src(); | 2423 | const src = inst_data.src(); |
| 2415 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2424 | const elem_type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -2424,7 +2433,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2424,7 +2433,7 @@ fn zirVectorType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2424 | return sema.mod.constType(sema.arena, src, vector_type); | 2433 | return sema.mod.constType(sema.arena, src, vector_type); |
| 2425 | } | 2434 | } |
| 2426 | | 2435 | |
| 2427 | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2436 | fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2428 | const tracy = trace(@src()); | 2437 | const tracy = trace(@src()); |
| 2429 | defer tracy.end(); | 2438 | defer tracy.end(); |
| 2430 | | 2439 | |
| ... | @@ -2437,7 +2446,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -2437,7 +2446,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2437 | return sema.mod.constType(sema.arena, .unneeded, array_ty); | 2446 | return sema.mod.constType(sema.arena, .unneeded, array_ty); |
| 2438 | } | 2447 | } |
| 2439 | | 2448 | |
| 2440 | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2449 | fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2441 | const tracy = trace(@src()); | 2450 | const tracy = trace(@src()); |
| 2442 | defer tracy.end(); | 2451 | defer tracy.end(); |
| 2443 | | 2452 | |
| ... | @@ -2452,7 +2461,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) | ... | @@ -2452,7 +2461,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 2452 | return sema.mod.constType(sema.arena, .unneeded, array_ty); | 2461 | return sema.mod.constType(sema.arena, .unneeded, array_ty); |
| 2453 | } | 2462 | } |
| 2454 | | 2463 | |
| 2455 | fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2464 | fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2456 | const tracy = trace(@src()); | 2465 | const tracy = trace(@src()); |
| 2457 | defer tracy.end(); | 2466 | defer tracy.end(); |
| 2458 | | 2467 | |
| ... | @@ -2465,7 +2474,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner | ... | @@ -2465,7 +2474,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2465 | return sema.mod.constType(sema.arena, src, anyframe_type); | 2474 | return sema.mod.constType(sema.arena, src, anyframe_type); |
| 2466 | } | 2475 | } |
| 2467 | | 2476 | |
| 2468 | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2477 | fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2469 | const tracy = trace(@src()); | 2478 | const tracy = trace(@src()); |
| 2470 | defer tracy.end(); | 2479 | defer tracy.end(); |
| 2471 | | 2480 | |
| ... | @@ -2486,7 +2495,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -2486,7 +2495,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2486 | return sema.mod.constType(sema.arena, src, err_union_ty); | 2495 | return sema.mod.constType(sema.arena, src, err_union_ty); |
| 2487 | } | 2496 | } |
| 2488 | | 2497 | |
| 2489 | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2498 | fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2490 | _ = block; | 2499 | _ = block; |
| 2491 | const tracy = trace(@src()); | 2500 | const tracy = trace(@src()); |
| 2492 | defer tracy.end(); | 2501 | defer tracy.end(); |
| ... | @@ -2505,7 +2514,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2505,7 +2514,7 @@ fn zirErrorValue(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2505 | }); | 2514 | }); |
| 2506 | } | 2515 | } |
| 2507 | | 2516 | |
| 2508 | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2517 | fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2509 | const tracy = trace(@src()); | 2518 | const tracy = trace(@src()); |
| 2510 | defer tracy.end(); | 2519 | defer tracy.end(); |
| 2511 | | 2520 | |
| ... | @@ -2535,7 +2544,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2535,7 +2544,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2535 | return block.addUnOp(src, result_ty, .bitcast, op_coerced); | 2544 | return block.addUnOp(src, result_ty, .bitcast, op_coerced); |
| 2536 | } | 2545 | } |
| 2537 | | 2546 | |
| 2538 | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2547 | fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2539 | const tracy = trace(@src()); | 2548 | const tracy = trace(@src()); |
| 2540 | defer tracy.end(); | 2549 | defer tracy.end(); |
| 2541 | | 2550 | |
| ... | @@ -2568,7 +2577,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -2568,7 +2577,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2568 | return block.addUnOp(src, Type.initTag(.anyerror), .bitcast, op); | 2577 | return block.addUnOp(src, Type.initTag(.anyerror), .bitcast, op); |
| 2569 | } | 2578 | } |
| 2570 | | 2579 | |
| 2571 | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2580 | fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2572 | const tracy = trace(@src()); | 2581 | const tracy = trace(@src()); |
| 2573 | defer tracy.end(); | 2582 | defer tracy.end(); |
| 2574 | | 2583 | |
| ... | @@ -2658,7 +2667,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn | ... | @@ -2658,7 +2667,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2658 | }); | 2667 | }); |
| 2659 | } | 2668 | } |
| 2660 | | 2669 | |
| 2661 | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2670 | fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2662 | _ = block; | 2671 | _ = block; |
| 2663 | const tracy = trace(@src()); | 2672 | const tracy = trace(@src()); |
| 2664 | defer tracy.end(); | 2673 | defer tracy.end(); |
| ... | @@ -2672,7 +2681,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -2672,7 +2681,7 @@ fn zirEnumLiteral(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 2672 | }); | 2681 | }); |
| 2673 | } | 2682 | } |
| 2674 | | 2683 | |
| 2675 | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2684 | fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2676 | const mod = sema.mod; | 2685 | const mod = sema.mod; |
| 2677 | const arena = sema.arena; | 2686 | const arena = sema.arena; |
| 2678 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2687 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| ... | @@ -2680,7 +2689,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -2680,7 +2689,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2680 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 2689 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2681 | const operand = try sema.resolveInst(inst_data.operand); | 2690 | const operand = try sema.resolveInst(inst_data.operand); |
| 2682 | | 2691 | |
| 2683 | const enum_tag: *Inst = switch (operand.ty.zigTypeTag()) { | 2692 | const enum_tag: Air.Inst.Index = switch (operand.ty.zigTypeTag()) { |
| 2684 | .Enum => operand, | 2693 | .Enum => operand, |
| 2685 | .Union => { | 2694 | .Union => { |
| 2686 | //if (!operand.ty.unionHasTag()) { | 2695 | //if (!operand.ty.unionHasTag()) { |
| ... | @@ -2754,7 +2763,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -2754,7 +2763,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2754 | return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag); | 2763 | return block.addUnOp(src, int_tag_ty, .bitcast, enum_tag); |
| 2755 | } | 2764 | } |
| 2756 | | 2765 | |
| 2757 | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2766 | fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2758 | const mod = sema.mod; | 2767 | const mod = sema.mod; |
| 2759 | const target = mod.getTarget(); | 2768 | const target = mod.getTarget(); |
| 2760 | const arena = sema.arena; | 2769 | const arena = sema.arena; |
| ... | @@ -2815,7 +2824,7 @@ fn zirOptionalPayloadPtr( | ... | @@ -2815,7 +2824,7 @@ fn zirOptionalPayloadPtr( |
| 2815 | block: *Scope.Block, | 2824 | block: *Scope.Block, |
| 2816 | inst: Zir.Inst.Index, | 2825 | inst: Zir.Inst.Index, |
| 2817 | safety_check: bool, | 2826 | safety_check: bool, |
| 2818 | ) InnerError!*Inst { | 2827 | ) InnerError!Air.Inst.Index { |
| 2819 | const tracy = trace(@src()); | 2828 | const tracy = trace(@src()); |
| 2820 | defer tracy.end(); | 2829 | defer tracy.end(); |
| 2821 | | 2830 | |
| ... | @@ -2858,7 +2867,7 @@ fn zirOptionalPayload( | ... | @@ -2858,7 +2867,7 @@ fn zirOptionalPayload( |
| 2858 | block: *Scope.Block, | 2867 | block: *Scope.Block, |
| 2859 | inst: Zir.Inst.Index, | 2868 | inst: Zir.Inst.Index, |
| 2860 | safety_check: bool, | 2869 | safety_check: bool, |
| 2861 | ) InnerError!*Inst { | 2870 | ) InnerError!Air.Inst.Index { |
| 2862 | const tracy = trace(@src()); | 2871 | const tracy = trace(@src()); |
| 2863 | defer tracy.end(); | 2872 | defer tracy.end(); |
| 2864 | | 2873 | |
| ... | @@ -2896,7 +2905,7 @@ fn zirErrUnionPayload( | ... | @@ -2896,7 +2905,7 @@ fn zirErrUnionPayload( |
| 2896 | block: *Scope.Block, | 2905 | block: *Scope.Block, |
| 2897 | inst: Zir.Inst.Index, | 2906 | inst: Zir.Inst.Index, |
| 2898 | safety_check: bool, | 2907 | safety_check: bool, |
| 2899 | ) InnerError!*Inst { | 2908 | ) InnerError!Air.Inst.Index { |
| 2900 | const tracy = trace(@src()); | 2909 | const tracy = trace(@src()); |
| 2901 | defer tracy.end(); | 2910 | defer tracy.end(); |
| 2902 | | 2911 | |
| ... | @@ -2930,7 +2939,7 @@ fn zirErrUnionPayloadPtr( | ... | @@ -2930,7 +2939,7 @@ fn zirErrUnionPayloadPtr( |
| 2930 | block: *Scope.Block, | 2939 | block: *Scope.Block, |
| 2931 | inst: Zir.Inst.Index, | 2940 | inst: Zir.Inst.Index, |
| 2932 | safety_check: bool, | 2941 | safety_check: bool, |
| 2933 | ) InnerError!*Inst { | 2942 | ) InnerError!Air.Inst.Index { |
| 2934 | const tracy = trace(@src()); | 2943 | const tracy = trace(@src()); |
| 2935 | defer tracy.end(); | 2944 | defer tracy.end(); |
| 2936 | | 2945 | |
| ... | @@ -2969,7 +2978,7 @@ fn zirErrUnionPayloadPtr( | ... | @@ -2969,7 +2978,7 @@ fn zirErrUnionPayloadPtr( |
| 2969 | } | 2978 | } |
| 2970 | | 2979 | |
| 2971 | /// Value in, value out | 2980 | /// Value in, value out |
| 2972 | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 2981 | fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2973 | const tracy = trace(@src()); | 2982 | const tracy = trace(@src()); |
| 2974 | defer tracy.end(); | 2983 | defer tracy.end(); |
| 2975 | | 2984 | |
| ... | @@ -2995,7 +3004,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner | ... | @@ -2995,7 +3004,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2995 | } | 3004 | } |
| 2996 | | 3005 | |
| 2997 | /// Pointer in, value out | 3006 | /// Pointer in, value out |
| 2998 | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3007 | fn zirErrUnionCodePtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 2999 | const tracy = trace(@src()); | 3008 | const tracy = trace(@src()); |
| 3000 | defer tracy.end(); | 3009 | defer tracy.end(); |
| 3001 | | 3010 | |
| ... | @@ -3042,7 +3051,7 @@ fn zirFunc( | ... | @@ -3042,7 +3051,7 @@ fn zirFunc( |
| 3042 | block: *Scope.Block, | 3051 | block: *Scope.Block, |
| 3043 | inst: Zir.Inst.Index, | 3052 | inst: Zir.Inst.Index, |
| 3044 | inferred_error_set: bool, | 3053 | inferred_error_set: bool, |
| 3045 | ) InnerError!*Inst { | 3054 | ) InnerError!Air.Inst.Index { |
| 3046 | const tracy = trace(@src()); | 3055 | const tracy = trace(@src()); |
| 3047 | defer tracy.end(); | 3056 | defer tracy.end(); |
| 3048 | | 3057 | |
| ... | @@ -3093,7 +3102,7 @@ fn funcCommon( | ... | @@ -3093,7 +3102,7 @@ fn funcCommon( |
| 3093 | is_extern: bool, | 3102 | is_extern: bool, |
| 3094 | src_locs: Zir.Inst.Func.SrcLocs, | 3103 | src_locs: Zir.Inst.Func.SrcLocs, |
| 3095 | opt_lib_name: ?[]const u8, | 3104 | opt_lib_name: ?[]const u8, |
| 3096 | ) InnerError!*Inst { | 3105 | ) InnerError!Air.Inst.Index { |
| 3097 | const src: LazySrcLoc = .{ .node_offset = src_node_offset }; | 3106 | const src: LazySrcLoc = .{ .node_offset = src_node_offset }; |
| 3098 | const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; | 3107 | const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; |
| 3099 | const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type); | 3108 | const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type); |
| ... | @@ -3234,7 +3243,7 @@ fn funcCommon( | ... | @@ -3234,7 +3243,7 @@ fn funcCommon( |
| 3234 | return result; | 3243 | return result; |
| 3235 | } | 3244 | } |
| 3236 | | 3245 | |
| 3237 | fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3246 | fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3238 | const tracy = trace(@src()); | 3247 | const tracy = trace(@src()); |
| 3239 | defer tracy.end(); | 3248 | defer tracy.end(); |
| 3240 | | 3249 | |
| ... | @@ -3242,7 +3251,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Ins | ... | @@ -3242,7 +3251,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Ins |
| 3242 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); | 3251 | return sema.analyzeAs(block, .unneeded, bin_inst.lhs, bin_inst.rhs); |
| 3243 | } | 3252 | } |
| 3244 | | 3253 | |
| 3245 | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3254 | fn zirAsNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3246 | const tracy = trace(@src()); | 3255 | const tracy = trace(@src()); |
| 3247 | defer tracy.end(); | 3256 | defer tracy.end(); |
| 3248 | | 3257 | |
| ... | @@ -3258,13 +3267,13 @@ fn analyzeAs( | ... | @@ -3258,13 +3267,13 @@ fn analyzeAs( |
| 3258 | src: LazySrcLoc, | 3267 | src: LazySrcLoc, |
| 3259 | zir_dest_type: Zir.Inst.Ref, | 3268 | zir_dest_type: Zir.Inst.Ref, |
| 3260 | zir_operand: Zir.Inst.Ref, | 3269 | zir_operand: Zir.Inst.Ref, |
| 3261 | ) InnerError!*Inst { | 3270 | ) InnerError!Air.Inst.Index { |
| 3262 | const dest_type = try sema.resolveType(block, src, zir_dest_type); | 3271 | const dest_type = try sema.resolveType(block, src, zir_dest_type); |
| 3263 | const operand = try sema.resolveInst(zir_operand); | 3272 | const operand = try sema.resolveInst(zir_operand); |
| 3264 | return sema.coerce(block, dest_type, operand, src); | 3273 | return sema.coerce(block, dest_type, operand, src); |
| 3265 | } | 3274 | } |
| 3266 | | 3275 | |
| 3267 | fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3276 | fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3268 | const tracy = trace(@src()); | 3277 | const tracy = trace(@src()); |
| 3269 | defer tracy.end(); | 3278 | defer tracy.end(); |
| 3270 | | 3279 | |
| ... | @@ -3281,7 +3290,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3281,7 +3290,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3281 | return block.addUnOp(src, ty, .ptrtoint, ptr); | 3290 | return block.addUnOp(src, ty, .ptrtoint, ptr); |
| 3282 | } | 3291 | } |
| 3283 | | 3292 | |
| 3284 | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3293 | fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3285 | const tracy = trace(@src()); | 3294 | const tracy = trace(@src()); |
| 3286 | defer tracy.end(); | 3295 | defer tracy.end(); |
| 3287 | | 3296 | |
| ... | @@ -3299,7 +3308,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3299,7 +3308,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3299 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); | 3308 | return sema.analyzeLoad(block, src, result_ptr, result_ptr.src); |
| 3300 | } | 3309 | } |
| 3301 | | 3310 | |
| 3302 | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3311 | fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3303 | const tracy = trace(@src()); | 3312 | const tracy = trace(@src()); |
| 3304 | defer tracy.end(); | 3313 | defer tracy.end(); |
| 3305 | | 3314 | |
| ... | @@ -3312,7 +3321,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3312,7 +3321,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3312 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 3321 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 3313 | } | 3322 | } |
| 3314 | | 3323 | |
| 3315 | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3324 | fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3316 | const tracy = trace(@src()); | 3325 | const tracy = trace(@src()); |
| 3317 | defer tracy.end(); | 3326 | defer tracy.end(); |
| 3318 | | 3327 | |
| ... | @@ -3327,7 +3336,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -3327,7 +3336,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3327 | return sema.analyzeLoad(block, src, result_ptr, src); | 3336 | return sema.analyzeLoad(block, src, result_ptr, src); |
| 3328 | } | 3337 | } |
| 3329 | | 3338 | |
| 3330 | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3339 | fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3331 | const tracy = trace(@src()); | 3340 | const tracy = trace(@src()); |
| 3332 | defer tracy.end(); | 3341 | defer tracy.end(); |
| 3333 | | 3342 | |
| ... | @@ -3340,7 +3349,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -3340,7 +3349,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3340 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); | 3349 | return sema.namedFieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 3341 | } | 3350 | } |
| 3342 | | 3351 | |
| 3343 | fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3352 | fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3344 | const tracy = trace(@src()); | 3353 | const tracy = trace(@src()); |
| 3345 | defer tracy.end(); | 3354 | defer tracy.end(); |
| 3346 | | 3355 | |
| ... | @@ -3383,7 +3392,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -3383,7 +3392,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3383 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{}); | 3392 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten int", .{}); |
| 3384 | } | 3393 | } |
| 3385 | | 3394 | |
| 3386 | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3395 | fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3387 | const tracy = trace(@src()); | 3396 | const tracy = trace(@src()); |
| 3388 | defer tracy.end(); | 3397 | defer tracy.end(); |
| 3389 | | 3398 | |
| ... | @@ -3396,7 +3405,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -3396,7 +3405,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3396 | return sema.bitcast(block, dest_type, operand); | 3405 | return sema.bitcast(block, dest_type, operand); |
| 3397 | } | 3406 | } |
| 3398 | | 3407 | |
| 3399 | fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3408 | fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3400 | const tracy = trace(@src()); | 3409 | const tracy = trace(@src()); |
| 3401 | defer tracy.end(); | 3410 | defer tracy.end(); |
| 3402 | | 3411 | |
| ... | @@ -3439,7 +3448,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr | ... | @@ -3439,7 +3448,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 3439 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{}); | 3448 | return sema.mod.fail(&block.base, src, "TODO implement analyze widen or shorten float", .{}); |
| 3440 | } | 3449 | } |
| 3441 | | 3450 | |
| 3442 | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3451 | fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3443 | const tracy = trace(@src()); | 3452 | const tracy = trace(@src()); |
| 3444 | defer tracy.end(); | 3453 | defer tracy.end(); |
| 3445 | | 3454 | |
| ... | @@ -3454,7 +3463,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -3454,7 +3463,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3454 | return sema.analyzeLoad(block, sema.src, result_ptr, sema.src); | 3463 | return sema.analyzeLoad(block, sema.src, result_ptr, sema.src); |
| 3455 | } | 3464 | } |
| 3456 | | 3465 | |
| 3457 | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3466 | fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3458 | const tracy = trace(@src()); | 3467 | const tracy = trace(@src()); |
| 3459 | defer tracy.end(); | 3468 | defer tracy.end(); |
| 3460 | | 3469 | |
| ... | @@ -3472,7 +3481,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -3472,7 +3481,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 3472 | return sema.analyzeLoad(block, src, result_ptr, src); | 3481 | return sema.analyzeLoad(block, src, result_ptr, src); |
| 3473 | } | 3482 | } |
| 3474 | | 3483 | |
| 3475 | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3484 | fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3476 | const tracy = trace(@src()); | 3485 | const tracy = trace(@src()); |
| 3477 | defer tracy.end(); | 3486 | defer tracy.end(); |
| 3478 | | 3487 | |
| ... | @@ -3482,7 +3491,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -3482,7 +3491,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3482 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); | 3491 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); |
| 3483 | } | 3492 | } |
| 3484 | | 3493 | |
| 3485 | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3494 | fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3486 | const tracy = trace(@src()); | 3495 | const tracy = trace(@src()); |
| 3487 | defer tracy.end(); | 3496 | defer tracy.end(); |
| 3488 | | 3497 | |
| ... | @@ -3495,7 +3504,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE | ... | @@ -3495,7 +3504,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 3495 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); | 3504 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); |
| 3496 | } | 3505 | } |
| 3497 | | 3506 | |
| 3498 | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3507 | fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3499 | const tracy = trace(@src()); | 3508 | const tracy = trace(@src()); |
| 3500 | defer tracy.end(); | 3509 | defer tracy.end(); |
| 3501 | | 3510 | |
| ... | @@ -3508,7 +3517,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -3508,7 +3517,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 3508 | return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded); | 3517 | return sema.analyzeSlice(block, src, array_ptr, start, null, null, .unneeded); |
| 3509 | } | 3518 | } |
| 3510 | | 3519 | |
| 3511 | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3520 | fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3512 | const tracy = trace(@src()); | 3521 | const tracy = trace(@src()); |
| 3513 | defer tracy.end(); | 3522 | defer tracy.end(); |
| 3514 | | 3523 | |
| ... | @@ -3522,7 +3531,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -3522,7 +3531,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3522 | return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded); | 3531 | return sema.analyzeSlice(block, src, array_ptr, start, end, null, .unneeded); |
| 3523 | } | 3532 | } |
| 3524 | | 3533 | |
| 3525 | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 3534 | fn zirSliceSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 3526 | const tracy = trace(@src()); | 3535 | const tracy = trace(@src()); |
| 3527 | defer tracy.end(); | 3536 | defer tracy.end(); |
| 3528 | | 3537 | |
| ... | @@ -3544,7 +3553,7 @@ fn zirSwitchCapture( | ... | @@ -3544,7 +3553,7 @@ fn zirSwitchCapture( |
| 3544 | inst: Zir.Inst.Index, | 3553 | inst: Zir.Inst.Index, |
| 3545 | is_multi: bool, | 3554 | is_multi: bool, |
| 3546 | is_ref: bool, | 3555 | is_ref: bool, |
| 3547 | ) InnerError!*Inst { | 3556 | ) InnerError!Air.Inst.Index { |
| 3548 | const tracy = trace(@src()); | 3557 | const tracy = trace(@src()); |
| 3549 | defer tracy.end(); | 3558 | defer tracy.end(); |
| 3550 | | 3559 | |
| ... | @@ -3563,7 +3572,7 @@ fn zirSwitchCaptureElse( | ... | @@ -3563,7 +3572,7 @@ fn zirSwitchCaptureElse( |
| 3563 | block: *Scope.Block, | 3572 | block: *Scope.Block, |
| 3564 | inst: Zir.Inst.Index, | 3573 | inst: Zir.Inst.Index, |
| 3565 | is_ref: bool, | 3574 | is_ref: bool, |
| 3566 | ) InnerError!*Inst { | 3575 | ) InnerError!Air.Inst.Index { |
| 3567 | const tracy = trace(@src()); | 3576 | const tracy = trace(@src()); |
| 3568 | defer tracy.end(); | 3577 | defer tracy.end(); |
| 3569 | | 3578 | |
| ... | @@ -3582,7 +3591,7 @@ fn zirSwitchBlock( | ... | @@ -3582,7 +3591,7 @@ fn zirSwitchBlock( |
| 3582 | inst: Zir.Inst.Index, | 3591 | inst: Zir.Inst.Index, |
| 3583 | is_ref: bool, | 3592 | is_ref: bool, |
| 3584 | special_prong: Zir.SpecialProng, | 3593 | special_prong: Zir.SpecialProng, |
| 3585 | ) InnerError!*Inst { | 3594 | ) InnerError!Air.Inst.Index { |
| 3586 | const tracy = trace(@src()); | 3595 | const tracy = trace(@src()); |
| 3587 | defer tracy.end(); | 3596 | defer tracy.end(); |
| 3588 | | 3597 | |
| ... | @@ -3615,7 +3624,7 @@ fn zirSwitchBlockMulti( | ... | @@ -3615,7 +3624,7 @@ fn zirSwitchBlockMulti( |
| 3615 | inst: Zir.Inst.Index, | 3624 | inst: Zir.Inst.Index, |
| 3616 | is_ref: bool, | 3625 | is_ref: bool, |
| 3617 | special_prong: Zir.SpecialProng, | 3626 | special_prong: Zir.SpecialProng, |
| 3618 | ) InnerError!*Inst { | 3627 | ) InnerError!Air.Inst.Index { |
| 3619 | const tracy = trace(@src()); | 3628 | const tracy = trace(@src()); |
| 3620 | defer tracy.end(); | 3629 | defer tracy.end(); |
| 3621 | | 3630 | |
| ... | @@ -3645,14 +3654,14 @@ fn zirSwitchBlockMulti( | ... | @@ -3645,14 +3654,14 @@ fn zirSwitchBlockMulti( |
| 3645 | fn analyzeSwitch( | 3654 | fn analyzeSwitch( |
| 3646 | sema: *Sema, | 3655 | sema: *Sema, |
| 3647 | block: *Scope.Block, | 3656 | block: *Scope.Block, |
| 3648 | operand: *Inst, | 3657 | operand: Air.Inst.Index, |
| 3649 | extra_end: usize, | 3658 | extra_end: usize, |
| 3650 | special_prong: Zir.SpecialProng, | 3659 | special_prong: Zir.SpecialProng, |
| 3651 | scalar_cases_len: usize, | 3660 | scalar_cases_len: usize, |
| 3652 | multi_cases_len: usize, | 3661 | multi_cases_len: usize, |
| 3653 | switch_inst: Zir.Inst.Index, | 3662 | switch_inst: Zir.Inst.Index, |
| 3654 | src_node_offset: i32, | 3663 | src_node_offset: i32, |
| 3655 | ) InnerError!*Inst { | 3664 | ) InnerError!Air.Inst.Index { |
| 3656 | const gpa = sema.gpa; | 3665 | const gpa = sema.gpa; |
| 3657 | const mod = sema.mod; | 3666 | const mod = sema.mod; |
| 3658 | | 3667 | |
| ... | @@ -4187,7 +4196,7 @@ fn analyzeSwitch( | ... | @@ -4187,7 +4196,7 @@ fn analyzeSwitch( |
| 4187 | | 4196 | |
| 4188 | cases[scalar_i] = .{ | 4197 | cases[scalar_i] = .{ |
| 4189 | .item = item_val, | 4198 | .item = item_val, |
| 4190 | .body = .{ .instructions = try sema.arena.dupe(*Inst, case_block.instructions.items) }, | 4199 | .body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, case_block.instructions.items) }, |
| 4191 | }; | 4200 | }; |
| 4192 | } | 4201 | } |
| 4193 | | 4202 | |
| ... | @@ -4207,7 +4216,7 @@ fn analyzeSwitch( | ... | @@ -4207,7 +4216,7 @@ fn analyzeSwitch( |
| 4207 | | 4216 | |
| 4208 | case_block.instructions.shrinkRetainingCapacity(0); | 4217 | case_block.instructions.shrinkRetainingCapacity(0); |
| 4209 | | 4218 | |
| 4210 | var any_ok: ?*Inst = null; | 4219 | var any_ok: ?Air.Inst.Index = null; |
| 4211 | const bool_ty = comptime Type.initTag(.bool); | 4220 | const bool_ty = comptime Type.initTag(.bool); |
| 4212 | | 4221 | |
| 4213 | for (items) |item_ref| { | 4222 | for (items) |item_ref| { |
| ... | @@ -4280,7 +4289,7 @@ fn analyzeSwitch( | ... | @@ -4280,7 +4289,7 @@ fn analyzeSwitch( |
| 4280 | try case_block.instructions.append(gpa, &new_condbr.base); | 4289 | try case_block.instructions.append(gpa, &new_condbr.base); |
| 4281 | | 4290 | |
| 4282 | const cond_body: Body = .{ | 4291 | const cond_body: Body = .{ |
| 4283 | .instructions = try sema.arena.dupe(*Inst, case_block.instructions.items), | 4292 | .instructions = try sema.arena.dupe(Air.Inst.Index, case_block.instructions.items), |
| 4284 | }; | 4293 | }; |
| 4285 | | 4294 | |
| 4286 | case_block.instructions.shrinkRetainingCapacity(0); | 4295 | case_block.instructions.shrinkRetainingCapacity(0); |
| ... | @@ -4288,7 +4297,7 @@ fn analyzeSwitch( | ... | @@ -4288,7 +4297,7 @@ fn analyzeSwitch( |
| 4288 | extra_index += body_len; | 4297 | extra_index += body_len; |
| 4289 | _ = try sema.analyzeBody(&case_block, body); | 4298 | _ = try sema.analyzeBody(&case_block, body); |
| 4290 | new_condbr.then_body = .{ | 4299 | new_condbr.then_body = .{ |
| 4291 | .instructions = try sema.arena.dupe(*Inst, case_block.instructions.items), | 4300 | .instructions = try sema.arena.dupe(Air.Inst.Index, case_block.instructions.items), |
| 4292 | }; | 4301 | }; |
| 4293 | if (prev_condbr) |condbr| { | 4302 | if (prev_condbr) |condbr| { |
| 4294 | condbr.else_body = cond_body; | 4303 | condbr.else_body = cond_body; |
| ... | @@ -4303,7 +4312,7 @@ fn analyzeSwitch( | ... | @@ -4303,7 +4312,7 @@ fn analyzeSwitch( |
| 4303 | case_block.instructions.shrinkRetainingCapacity(0); | 4312 | case_block.instructions.shrinkRetainingCapacity(0); |
| 4304 | _ = try sema.analyzeBody(&case_block, special.body); | 4313 | _ = try sema.analyzeBody(&case_block, special.body); |
| 4305 | const else_body: Body = .{ | 4314 | const else_body: Body = .{ |
| 4306 | .instructions = try sema.arena.dupe(*Inst, case_block.instructions.items), | 4315 | .instructions = try sema.arena.dupe(Air.Inst.Index, case_block.instructions.items), |
| 4307 | }; | 4316 | }; |
| 4308 | if (prev_condbr) |condbr| { | 4317 | if (prev_condbr) |condbr| { |
| 4309 | condbr.else_body = else_body; | 4318 | condbr.else_body = else_body; |
| ... | @@ -4507,7 +4516,7 @@ fn validateSwitchNoRange( | ... | @@ -4507,7 +4516,7 @@ fn validateSwitchNoRange( |
| 4507 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); | 4516 | return sema.mod.failWithOwnedErrorMsg(&block.base, msg); |
| 4508 | } | 4517 | } |
| 4509 | | 4518 | |
| 4510 | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4519 | fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4511 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4520 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4512 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4521 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4513 | _ = extra; | 4522 | _ = extra; |
| ... | @@ -4516,7 +4525,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -4516,7 +4525,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 4516 | return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); | 4525 | return sema.mod.fail(&block.base, src, "TODO implement zirHasField", .{}); |
| 4517 | } | 4526 | } |
| 4518 | | 4527 | |
| 4519 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4528 | fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4520 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 4529 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4521 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 4530 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4522 | const src = inst_data.src(); | 4531 | const src = inst_data.src(); |
| ... | @@ -4541,7 +4550,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -4541,7 +4550,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 4541 | return mod.constBool(arena, src, false); | 4550 | return mod.constBool(arena, src, false); |
| 4542 | } | 4551 | } |
| 4543 | | 4552 | |
| 4544 | fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4553 | fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4545 | const tracy = trace(@src()); | 4554 | const tracy = trace(@src()); |
| 4546 | defer tracy.end(); | 4555 | defer tracy.end(); |
| 4547 | | 4556 | |
| ... | @@ -4566,13 +4575,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -4566,13 +4575,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4566 | return mod.constType(sema.arena, src, file_root_decl.ty); | 4575 | return mod.constType(sema.arena, src, file_root_decl.ty); |
| 4567 | } | 4576 | } |
| 4568 | | 4577 | |
| 4569 | fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4578 | fn zirRetErrValueCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4570 | _ = block; | 4579 | _ = block; |
| 4571 | _ = inst; | 4580 | _ = inst; |
| 4572 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{}); | 4581 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirRetErrValueCode", .{}); |
| 4573 | } | 4582 | } |
| 4574 | | 4583 | |
| 4575 | fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4584 | fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4576 | const tracy = trace(@src()); | 4585 | const tracy = trace(@src()); |
| 4577 | defer tracy.end(); | 4586 | defer tracy.end(); |
| 4578 | | 4587 | |
| ... | @@ -4581,7 +4590,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In | ... | @@ -4581,7 +4590,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 4581 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); | 4590 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirShl", .{}); |
| 4582 | } | 4591 | } |
| 4583 | | 4592 | |
| 4584 | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4593 | fn zirShr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4585 | const tracy = trace(@src()); | 4594 | const tracy = trace(@src()); |
| 4586 | defer tracy.end(); | 4595 | defer tracy.end(); |
| 4587 | | 4596 | |
| ... | @@ -4594,7 +4603,7 @@ fn zirBitwise( | ... | @@ -4594,7 +4603,7 @@ fn zirBitwise( |
| 4594 | block: *Scope.Block, | 4603 | block: *Scope.Block, |
| 4595 | inst: Zir.Inst.Index, | 4604 | inst: Zir.Inst.Index, |
| 4596 | ir_tag: ir.Inst.Tag, | 4605 | ir_tag: ir.Inst.Tag, |
| 4597 | ) InnerError!*Inst { | 4606 | ) InnerError!Air.Inst.Index { |
| 4598 | const tracy = trace(@src()); | 4607 | const tracy = trace(@src()); |
| 4599 | defer tracy.end(); | 4608 | defer tracy.end(); |
| 4600 | | 4609 | |
| ... | @@ -4606,7 +4615,7 @@ fn zirBitwise( | ... | @@ -4606,7 +4615,7 @@ fn zirBitwise( |
| 4606 | const lhs = try sema.resolveInst(extra.lhs); | 4615 | const lhs = try sema.resolveInst(extra.lhs); |
| 4607 | const rhs = try sema.resolveInst(extra.rhs); | 4616 | const rhs = try sema.resolveInst(extra.rhs); |
| 4608 | | 4617 | |
| 4609 | const instructions = &[_]*Inst{ lhs, rhs }; | 4618 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; |
| 4610 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); | 4619 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 4611 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); | 4620 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| 4612 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); | 4621 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| ... | @@ -4652,7 +4661,7 @@ fn zirBitwise( | ... | @@ -4652,7 +4661,7 @@ fn zirBitwise( |
| 4652 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 4661 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); |
| 4653 | } | 4662 | } |
| 4654 | | 4663 | |
| 4655 | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4664 | fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4656 | const tracy = trace(@src()); | 4665 | const tracy = trace(@src()); |
| 4657 | defer tracy.end(); | 4666 | defer tracy.end(); |
| 4658 | | 4667 | |
| ... | @@ -4660,7 +4669,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -4660,7 +4669,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4660 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); | 4669 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirBitNot", .{}); |
| 4661 | } | 4670 | } |
| 4662 | | 4671 | |
| 4663 | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4672 | fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4664 | const tracy = trace(@src()); | 4673 | const tracy = trace(@src()); |
| 4665 | defer tracy.end(); | 4674 | defer tracy.end(); |
| 4666 | | 4675 | |
| ... | @@ -4668,7 +4677,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -4668,7 +4677,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 4668 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); | 4677 | return sema.mod.fail(&block.base, sema.src, "TODO implement zirArrayCat", .{}); |
| 4669 | } | 4678 | } |
| 4670 | | 4679 | |
| 4671 | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4680 | fn zirArrayMul(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4672 | const tracy = trace(@src()); | 4681 | const tracy = trace(@src()); |
| 4673 | defer tracy.end(); | 4682 | defer tracy.end(); |
| 4674 | | 4683 | |
| ... | @@ -4681,7 +4690,7 @@ fn zirNegate( | ... | @@ -4681,7 +4690,7 @@ fn zirNegate( |
| 4681 | block: *Scope.Block, | 4690 | block: *Scope.Block, |
| 4682 | inst: Zir.Inst.Index, | 4691 | inst: Zir.Inst.Index, |
| 4683 | tag_override: Zir.Inst.Tag, | 4692 | tag_override: Zir.Inst.Tag, |
| 4684 | ) InnerError!*Inst { | 4693 | ) InnerError!Air.Inst.Index { |
| 4685 | const tracy = trace(@src()); | 4694 | const tracy = trace(@src()); |
| 4686 | defer tracy.end(); | 4695 | defer tracy.end(); |
| 4687 | | 4696 | |
| ... | @@ -4695,7 +4704,7 @@ fn zirNegate( | ... | @@ -4695,7 +4704,7 @@ fn zirNegate( |
| 4695 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src); | 4704 | return sema.analyzeArithmetic(block, tag_override, lhs, rhs, src, lhs_src, rhs_src); |
| 4696 | } | 4705 | } |
| 4697 | | 4706 | |
| 4698 | fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4707 | fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4699 | const tracy = trace(@src()); | 4708 | const tracy = trace(@src()); |
| 4700 | defer tracy.end(); | 4709 | defer tracy.end(); |
| 4701 | | 4710 | |
| ... | @@ -4715,7 +4724,7 @@ fn zirOverflowArithmetic( | ... | @@ -4715,7 +4724,7 @@ fn zirOverflowArithmetic( |
| 4715 | sema: *Sema, | 4724 | sema: *Sema, |
| 4716 | block: *Scope.Block, | 4725 | block: *Scope.Block, |
| 4717 | extended: Zir.Inst.Extended.InstData, | 4726 | extended: Zir.Inst.Extended.InstData, |
| 4718 | ) InnerError!*Inst { | 4727 | ) InnerError!Air.Inst.Index { |
| 4719 | const tracy = trace(@src()); | 4728 | const tracy = trace(@src()); |
| 4720 | defer tracy.end(); | 4729 | defer tracy.end(); |
| 4721 | | 4730 | |
| ... | @@ -4729,13 +4738,13 @@ fn analyzeArithmetic( | ... | @@ -4729,13 +4738,13 @@ fn analyzeArithmetic( |
| 4729 | sema: *Sema, | 4738 | sema: *Sema, |
| 4730 | block: *Scope.Block, | 4739 | block: *Scope.Block, |
| 4731 | zir_tag: Zir.Inst.Tag, | 4740 | zir_tag: Zir.Inst.Tag, |
| 4732 | lhs: *Inst, | 4741 | lhs: Air.Inst.Index, |
| 4733 | rhs: *Inst, | 4742 | rhs: Air.Inst.Index, |
| 4734 | src: LazySrcLoc, | 4743 | src: LazySrcLoc, |
| 4735 | lhs_src: LazySrcLoc, | 4744 | lhs_src: LazySrcLoc, |
| 4736 | rhs_src: LazySrcLoc, | 4745 | rhs_src: LazySrcLoc, |
| 4737 | ) InnerError!*Inst { | 4746 | ) InnerError!Air.Inst.Index { |
| 4738 | const instructions = &[_]*Inst{ lhs, rhs }; | 4747 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; |
| 4739 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); | 4748 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 4740 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); | 4749 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| 4741 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); | 4750 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| ... | @@ -4844,7 +4853,7 @@ fn analyzeArithmetic( | ... | @@ -4844,7 +4853,7 @@ fn analyzeArithmetic( |
| 4844 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 4853 | return block.addBinOp(src, scalar_type, ir_tag, casted_lhs, casted_rhs); |
| 4845 | } | 4854 | } |
| 4846 | | 4855 | |
| 4847 | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 4856 | fn zirLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 4848 | const tracy = trace(@src()); | 4857 | const tracy = trace(@src()); |
| 4849 | defer tracy.end(); | 4858 | defer tracy.end(); |
| 4850 | | 4859 | |
| ... | @@ -4859,7 +4868,7 @@ fn zirAsm( | ... | @@ -4859,7 +4868,7 @@ fn zirAsm( |
| 4859 | sema: *Sema, | 4868 | sema: *Sema, |
| 4860 | block: *Scope.Block, | 4869 | block: *Scope.Block, |
| 4861 | extended: Zir.Inst.Extended.InstData, | 4870 | extended: Zir.Inst.Extended.InstData, |
| 4862 | ) InnerError!*Inst { | 4871 | ) InnerError!Air.Inst.Index { |
| 4863 | const tracy = trace(@src()); | 4872 | const tracy = trace(@src()); |
| 4864 | defer tracy.end(); | 4873 | defer tracy.end(); |
| 4865 | | 4874 | |
| ... | @@ -4899,7 +4908,7 @@ fn zirAsm( | ... | @@ -4899,7 +4908,7 @@ fn zirAsm( |
| 4899 | }; | 4908 | }; |
| 4900 | }; | 4909 | }; |
| 4901 | | 4910 | |
| 4902 | const args = try sema.arena.alloc(*Inst, inputs_len); | 4911 | const args = try sema.arena.alloc(Air.Inst.Index, inputs_len); |
| 4903 | const inputs = try sema.arena.alloc([]const u8, inputs_len); | 4912 | const inputs = try sema.arena.alloc([]const u8, inputs_len); |
| 4904 | | 4913 | |
| 4905 | for (args) |*arg, arg_i| { | 4914 | for (args) |*arg, arg_i| { |
| ... | @@ -4943,7 +4952,7 @@ fn zirCmp( | ... | @@ -4943,7 +4952,7 @@ fn zirCmp( |
| 4943 | block: *Scope.Block, | 4952 | block: *Scope.Block, |
| 4944 | inst: Zir.Inst.Index, | 4953 | inst: Zir.Inst.Index, |
| 4945 | op: std.math.CompareOperator, | 4954 | op: std.math.CompareOperator, |
| 4946 | ) InnerError!*Inst { | 4955 | ) InnerError!Air.Inst.Index { |
| 4947 | const tracy = trace(@src()); | 4956 | const tracy = trace(@src()); |
| 4948 | defer tracy.end(); | 4957 | defer tracy.end(); |
| 4949 | | 4958 | |
| ... | @@ -5009,7 +5018,7 @@ fn zirCmp( | ... | @@ -5009,7 +5018,7 @@ fn zirCmp( |
| 5009 | return mod.constBool(sema.arena, src, lhs.value().?.eql(rhs.value().?) == (op == .eq)); | 5018 | return mod.constBool(sema.arena, src, lhs.value().?.eql(rhs.value().?) == (op == .eq)); |
| 5010 | } | 5019 | } |
| 5011 | | 5020 | |
| 5012 | const instructions = &[_]*Inst{ lhs, rhs }; | 5021 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; |
| 5013 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); | 5022 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 5014 | if (!resolved_type.isSelfComparable(is_equality_cmp)) { | 5023 | if (!resolved_type.isSelfComparable(is_equality_cmp)) { |
| 5015 | return mod.fail(&block.base, src, "operator not allowed for type '{}'", .{resolved_type}); | 5024 | return mod.fail(&block.base, src, "operator not allowed for type '{}'", .{resolved_type}); |
| ... | @@ -5041,7 +5050,7 @@ fn zirCmp( | ... | @@ -5041,7 +5050,7 @@ fn zirCmp( |
| 5041 | return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs); | 5050 | return block.addBinOp(src, bool_type, tag, casted_lhs, casted_rhs); |
| 5042 | } | 5051 | } |
| 5043 | | 5052 | |
| 5044 | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5053 | fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5045 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5054 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5046 | const src = inst_data.src(); | 5055 | const src = inst_data.src(); |
| 5047 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5056 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -5051,7 +5060,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -5051,7 +5060,7 @@ fn zirSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 5051 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size); | 5060 | return sema.mod.constIntUnsigned(sema.arena, src, Type.initTag(.comptime_int), abi_size); |
| 5052 | } | 5061 | } |
| 5053 | | 5062 | |
| 5054 | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5063 | fn zirBitSizeOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5055 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5064 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5056 | const src = inst_data.src(); | 5065 | const src = inst_data.src(); |
| 5057 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5066 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -5065,7 +5074,7 @@ fn zirThis( | ... | @@ -5065,7 +5074,7 @@ fn zirThis( |
| 5065 | sema: *Sema, | 5074 | sema: *Sema, |
| 5066 | block: *Scope.Block, | 5075 | block: *Scope.Block, |
| 5067 | extended: Zir.Inst.Extended.InstData, | 5076 | extended: Zir.Inst.Extended.InstData, |
| 5068 | ) InnerError!*Inst { | 5077 | ) InnerError!Air.Inst.Index { |
| 5069 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5078 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5070 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); | 5079 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); |
| 5071 | } | 5080 | } |
| ... | @@ -5074,7 +5083,7 @@ fn zirRetAddr( | ... | @@ -5074,7 +5083,7 @@ fn zirRetAddr( |
| 5074 | sema: *Sema, | 5083 | sema: *Sema, |
| 5075 | block: *Scope.Block, | 5084 | block: *Scope.Block, |
| 5076 | extended: Zir.Inst.Extended.InstData, | 5085 | extended: Zir.Inst.Extended.InstData, |
| 5077 | ) InnerError!*Inst { | 5086 | ) InnerError!Air.Inst.Index { |
| 5078 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5087 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5079 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); | 5088 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); |
| 5080 | } | 5089 | } |
| ... | @@ -5083,12 +5092,12 @@ fn zirBuiltinSrc( | ... | @@ -5083,12 +5092,12 @@ fn zirBuiltinSrc( |
| 5083 | sema: *Sema, | 5092 | sema: *Sema, |
| 5084 | block: *Scope.Block, | 5093 | block: *Scope.Block, |
| 5085 | extended: Zir.Inst.Extended.InstData, | 5094 | extended: Zir.Inst.Extended.InstData, |
| 5086 | ) InnerError!*Inst { | 5095 | ) InnerError!Air.Inst.Index { |
| 5087 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5096 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5088 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{}); | 5097 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinSrc", .{}); |
| 5089 | } | 5098 | } |
| 5090 | | 5099 | |
| 5091 | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5100 | fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5092 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5101 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5093 | const src = inst_data.src(); | 5102 | const src = inst_data.src(); |
| 5094 | const ty = try sema.resolveType(block, src, inst_data.operand); | 5103 | const ty = try sema.resolveType(block, src, inst_data.operand); |
| ... | @@ -5131,7 +5140,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -5131,7 +5140,7 @@ fn zirTypeInfo(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5131 | } | 5140 | } |
| 5132 | } | 5141 | } |
| 5133 | | 5142 | |
| 5134 | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5143 | fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5135 | _ = block; | 5144 | _ = block; |
| 5136 | const zir_datas = sema.code.instructions.items(.data); | 5145 | const zir_datas = sema.code.instructions.items(.data); |
| 5137 | const inst_data = zir_datas[inst].un_node; | 5146 | const inst_data = zir_datas[inst].un_node; |
| ... | @@ -5140,7 +5149,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! | ... | @@ -5140,7 +5149,7 @@ fn zirTypeof(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 5140 | return sema.mod.constType(sema.arena, src, operand.ty); | 5149 | return sema.mod.constType(sema.arena, src, operand.ty); |
| 5141 | } | 5150 | } |
| 5142 | | 5151 | |
| 5143 | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5152 | fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5144 | _ = block; | 5153 | _ = block; |
| 5145 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5154 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5146 | const src = inst_data.src(); | 5155 | const src = inst_data.src(); |
| ... | @@ -5149,13 +5158,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr | ... | @@ -5149,13 +5158,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 5149 | return sema.mod.constType(sema.arena, src, elem_ty); | 5158 | return sema.mod.constType(sema.arena, src, elem_ty); |
| 5150 | } | 5159 | } |
| 5151 | | 5160 | |
| 5152 | fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5161 | fn zirTypeofLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5153 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5162 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5154 | const src = inst_data.src(); | 5163 | const src = inst_data.src(); |
| 5155 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{}); | 5164 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirTypeofLog2IntType", .{}); |
| 5156 | } | 5165 | } |
| 5157 | | 5166 | |
| 5158 | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5167 | fn zirLog2IntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5159 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5168 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5160 | const src = inst_data.src(); | 5169 | const src = inst_data.src(); |
| 5161 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{}); | 5170 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{}); |
| ... | @@ -5165,7 +5174,7 @@ fn zirTypeofPeer( | ... | @@ -5165,7 +5174,7 @@ fn zirTypeofPeer( |
| 5165 | sema: *Sema, | 5174 | sema: *Sema, |
| 5166 | block: *Scope.Block, | 5175 | block: *Scope.Block, |
| 5167 | extended: Zir.Inst.Extended.InstData, | 5176 | extended: Zir.Inst.Extended.InstData, |
| 5168 | ) InnerError!*Inst { | 5177 | ) InnerError!Air.Inst.Index { |
| 5169 | const tracy = trace(@src()); | 5178 | const tracy = trace(@src()); |
| 5170 | defer tracy.end(); | 5179 | defer tracy.end(); |
| 5171 | | 5180 | |
| ... | @@ -5173,7 +5182,7 @@ fn zirTypeofPeer( | ... | @@ -5173,7 +5182,7 @@ fn zirTypeofPeer( |
| 5173 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; | 5182 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; |
| 5174 | const args = sema.code.refSlice(extra.end, extended.small); | 5183 | const args = sema.code.refSlice(extra.end, extended.small); |
| 5175 | | 5184 | |
| 5176 | const inst_list = try sema.gpa.alloc(*ir.Inst, args.len); | 5185 | const inst_list = try sema.gpa.alloc(Air.Inst.Index, args.len); |
| 5177 | defer sema.gpa.free(inst_list); | 5186 | defer sema.gpa.free(inst_list); |
| 5178 | | 5187 | |
| 5179 | for (args) |arg_ref, i| { | 5188 | for (args) |arg_ref, i| { |
| ... | @@ -5184,7 +5193,7 @@ fn zirTypeofPeer( | ... | @@ -5184,7 +5193,7 @@ fn zirTypeofPeer( |
| 5184 | return sema.mod.constType(sema.arena, src, result_type); | 5193 | return sema.mod.constType(sema.arena, src, result_type); |
| 5185 | } | 5194 | } |
| 5186 | | 5195 | |
| 5187 | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5196 | fn zirBoolNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5188 | const tracy = trace(@src()); | 5197 | const tracy = trace(@src()); |
| 5189 | defer tracy.end(); | 5198 | defer tracy.end(); |
| 5190 | | 5199 | |
| ... | @@ -5206,7 +5215,7 @@ fn zirBoolOp( | ... | @@ -5206,7 +5215,7 @@ fn zirBoolOp( |
| 5206 | block: *Scope.Block, | 5215 | block: *Scope.Block, |
| 5207 | inst: Zir.Inst.Index, | 5216 | inst: Zir.Inst.Index, |
| 5208 | comptime is_bool_or: bool, | 5217 | comptime is_bool_or: bool, |
| 5209 | ) InnerError!*Inst { | 5218 | ) InnerError!Air.Inst.Index { |
| 5210 | const tracy = trace(@src()); | 5219 | const tracy = trace(@src()); |
| 5211 | defer tracy.end(); | 5220 | defer tracy.end(); |
| 5212 | | 5221 | |
| ... | @@ -5237,7 +5246,7 @@ fn zirBoolBr( | ... | @@ -5237,7 +5246,7 @@ fn zirBoolBr( |
| 5237 | parent_block: *Scope.Block, | 5246 | parent_block: *Scope.Block, |
| 5238 | inst: Zir.Inst.Index, | 5247 | inst: Zir.Inst.Index, |
| 5239 | is_bool_or: bool, | 5248 | is_bool_or: bool, |
| 5240 | ) InnerError!*Inst { | 5249 | ) InnerError!Air.Inst.Index { |
| 5241 | const tracy = trace(@src()); | 5250 | const tracy = trace(@src()); |
| 5242 | defer tracy.end(); | 5251 | defer tracy.end(); |
| 5243 | | 5252 | |
| ... | @@ -5292,12 +5301,12 @@ fn zirBoolBr( | ... | @@ -5292,12 +5301,12 @@ fn zirBoolBr( |
| 5292 | const rhs_result = try sema.resolveBody(rhs_block, body); | 5301 | const rhs_result = try sema.resolveBody(rhs_block, body); |
| 5293 | _ = try rhs_block.addBr(src, block_inst, rhs_result); | 5302 | _ = try rhs_block.addBr(src, block_inst, rhs_result); |
| 5294 | | 5303 | |
| 5295 | const air_then_body: ir.Body = .{ .instructions = try sema.arena.dupe(*Inst, then_block.instructions.items) }; | 5304 | const air_then_body: ir.Body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, then_block.instructions.items) }; |
| 5296 | const air_else_body: ir.Body = .{ .instructions = try sema.arena.dupe(*Inst, else_block.instructions.items) }; | 5305 | const air_else_body: ir.Body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, else_block.instructions.items) }; |
| 5297 | _ = try child_block.addCondBr(src, lhs, air_then_body, air_else_body); | 5306 | _ = try child_block.addCondBr(src, lhs, air_then_body, air_else_body); |
| 5298 | | 5307 | |
| 5299 | block_inst.body = .{ | 5308 | block_inst.body = .{ |
| 5300 | .instructions = try sema.arena.dupe(*Inst, child_block.instructions.items), | 5309 | .instructions = try sema.arena.dupe(Air.Inst.Index, child_block.instructions.items), |
| 5301 | }; | 5310 | }; |
| 5302 | try parent_block.instructions.append(sema.gpa, &block_inst.base); | 5311 | try parent_block.instructions.append(sema.gpa, &block_inst.base); |
| 5303 | return &block_inst.base; | 5312 | return &block_inst.base; |
| ... | @@ -5307,7 +5316,7 @@ fn zirIsNonNull( | ... | @@ -5307,7 +5316,7 @@ fn zirIsNonNull( |
| 5307 | sema: *Sema, | 5316 | sema: *Sema, |
| 5308 | block: *Scope.Block, | 5317 | block: *Scope.Block, |
| 5309 | inst: Zir.Inst.Index, | 5318 | inst: Zir.Inst.Index, |
| 5310 | ) InnerError!*Inst { | 5319 | ) InnerError!Air.Inst.Index { |
| 5311 | const tracy = trace(@src()); | 5320 | const tracy = trace(@src()); |
| 5312 | defer tracy.end(); | 5321 | defer tracy.end(); |
| 5313 | | 5322 | |
| ... | @@ -5321,7 +5330,7 @@ fn zirIsNonNullPtr( | ... | @@ -5321,7 +5330,7 @@ fn zirIsNonNullPtr( |
| 5321 | sema: *Sema, | 5330 | sema: *Sema, |
| 5322 | block: *Scope.Block, | 5331 | block: *Scope.Block, |
| 5323 | inst: Zir.Inst.Index, | 5332 | inst: Zir.Inst.Index, |
| 5324 | ) InnerError!*Inst { | 5333 | ) InnerError!Air.Inst.Index { |
| 5325 | const tracy = trace(@src()); | 5334 | const tracy = trace(@src()); |
| 5326 | defer tracy.end(); | 5335 | defer tracy.end(); |
| 5327 | | 5336 | |
| ... | @@ -5332,7 +5341,7 @@ fn zirIsNonNullPtr( | ... | @@ -5332,7 +5341,7 @@ fn zirIsNonNullPtr( |
| 5332 | return sema.analyzeIsNull(block, src, loaded, true); | 5341 | return sema.analyzeIsNull(block, src, loaded, true); |
| 5333 | } | 5342 | } |
| 5334 | | 5343 | |
| 5335 | fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5344 | fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5336 | const tracy = trace(@src()); | 5345 | const tracy = trace(@src()); |
| 5337 | defer tracy.end(); | 5346 | defer tracy.end(); |
| 5338 | | 5347 | |
| ... | @@ -5341,7 +5350,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -5341,7 +5350,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5341 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); | 5350 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); |
| 5342 | } | 5351 | } |
| 5343 | | 5352 | |
| 5344 | fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5353 | fn zirIsNonErrPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5345 | const tracy = trace(@src()); | 5354 | const tracy = trace(@src()); |
| 5346 | defer tracy.end(); | 5355 | defer tracy.end(); |
| 5347 | | 5356 | |
| ... | @@ -5385,14 +5394,14 @@ fn zirCondbr( | ... | @@ -5385,14 +5394,14 @@ fn zirCondbr( |
| 5385 | | 5394 | |
| 5386 | _ = try sema.analyzeBody(&sub_block, then_body); | 5395 | _ = try sema.analyzeBody(&sub_block, then_body); |
| 5387 | const air_then_body: ir.Body = .{ | 5396 | const air_then_body: ir.Body = .{ |
| 5388 | .instructions = try sema.arena.dupe(*Inst, sub_block.instructions.items), | 5397 | .instructions = try sema.arena.dupe(Air.Inst.Index, sub_block.instructions.items), |
| 5389 | }; | 5398 | }; |
| 5390 | | 5399 | |
| 5391 | sub_block.instructions.shrinkRetainingCapacity(0); | 5400 | sub_block.instructions.shrinkRetainingCapacity(0); |
| 5392 | | 5401 | |
| 5393 | _ = try sema.analyzeBody(&sub_block, else_body); | 5402 | _ = try sema.analyzeBody(&sub_block, else_body); |
| 5394 | const air_else_body: ir.Body = .{ | 5403 | const air_else_body: ir.Body = .{ |
| 5395 | .instructions = try sema.arena.dupe(*Inst, sub_block.instructions.items), | 5404 | .instructions = try sema.arena.dupe(Air.Inst.Index, sub_block.instructions.items), |
| 5396 | }; | 5405 | }; |
| 5397 | | 5406 | |
| 5398 | _ = try parent_block.addCondBr(src, cond, air_then_body, air_else_body); | 5407 | _ = try parent_block.addCondBr(src, cond, air_then_body, air_else_body); |
| ... | @@ -5470,7 +5479,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -5470,7 +5479,7 @@ fn zirRetNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 5470 | fn analyzeRet( | 5479 | fn analyzeRet( |
| 5471 | sema: *Sema, | 5480 | sema: *Sema, |
| 5472 | block: *Scope.Block, | 5481 | block: *Scope.Block, |
| 5473 | operand: *Inst, | 5482 | operand: Air.Inst.Index, |
| 5474 | src: LazySrcLoc, | 5483 | src: LazySrcLoc, |
| 5475 | need_coercion: bool, | 5484 | need_coercion: bool, |
| 5476 | ) InnerError!Zir.Inst.Index { | 5485 | ) InnerError!Zir.Inst.Index { |
| ... | @@ -5505,7 +5514,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { | ... | @@ -5505,7 +5514,7 @@ fn floatOpAllowed(tag: Zir.Inst.Tag) bool { |
| 5505 | }; | 5514 | }; |
| 5506 | } | 5515 | } |
| 5507 | | 5516 | |
| 5508 | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5517 | fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5509 | const tracy = trace(@src()); | 5518 | const tracy = trace(@src()); |
| 5510 | defer tracy.end(); | 5519 | defer tracy.end(); |
| 5511 | | 5520 | |
| ... | @@ -5526,7 +5535,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne | ... | @@ -5526,7 +5535,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 5526 | return sema.mod.constType(sema.arena, .unneeded, ty); | 5535 | return sema.mod.constType(sema.arena, .unneeded, ty); |
| 5527 | } | 5536 | } |
| 5528 | | 5537 | |
| 5529 | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5538 | fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5530 | const tracy = trace(@src()); | 5539 | const tracy = trace(@src()); |
| 5531 | defer tracy.end(); | 5540 | defer tracy.end(); |
| 5532 | | 5541 | |
| ... | @@ -5580,7 +5589,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError | ... | @@ -5580,7 +5589,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 5580 | return sema.mod.constType(sema.arena, src, ty); | 5589 | return sema.mod.constType(sema.arena, src, ty); |
| 5581 | } | 5590 | } |
| 5582 | | 5591 | |
| 5583 | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5592 | fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5584 | const tracy = trace(@src()); | 5593 | const tracy = trace(@src()); |
| 5585 | defer tracy.end(); | 5594 | defer tracy.end(); |
| 5586 | | 5595 | |
| ... | @@ -5594,13 +5603,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In | ... | @@ -5594,13 +5603,13 @@ fn zirStructInitEmpty(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 5594 | }); | 5603 | }); |
| 5595 | } | 5604 | } |
| 5596 | | 5605 | |
| 5597 | fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5606 | fn zirUnionInitPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5598 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5607 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5599 | const src = inst_data.src(); | 5608 | const src = inst_data.src(); |
| 5600 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{}); | 5609 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnionInitPtr", .{}); |
| 5601 | } | 5610 | } |
| 5602 | | 5611 | |
| 5603 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { | 5612 | fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { |
| 5604 | const mod = sema.mod; | 5613 | const mod = sema.mod; |
| 5605 | const gpa = sema.gpa; | 5614 | const gpa = sema.gpa; |
| 5606 | const zir_datas = sema.code.instructions.items(.data); | 5615 | const zir_datas = sema.code.instructions.items(.data); |
| ... | @@ -5622,7 +5631,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: | ... | @@ -5622,7 +5631,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5622 | mem.set(Zir.Inst.Index, found_fields, 0); | 5631 | mem.set(Zir.Inst.Index, found_fields, 0); |
| 5623 | | 5632 | |
| 5624 | // The init values to use for the struct instance. | 5633 | // The init values to use for the struct instance. |
| 5625 | const field_inits = try gpa.alloc(*ir.Inst, struct_obj.fields.count()); | 5634 | const field_inits = try gpa.alloc(Air.Inst.Index, struct_obj.fields.count()); |
| 5626 | defer gpa.free(field_inits); | 5635 | defer gpa.free(field_inits); |
| 5627 | | 5636 | |
| 5628 | var field_i: u32 = 0; | 5637 | var field_i: u32 = 0; |
| ... | @@ -5713,7 +5722,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: | ... | @@ -5713,7 +5722,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5713 | return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{}); | 5722 | return mod.fail(&block.base, src, "TODO: Sema.zirStructInit for runtime-known struct values", .{}); |
| 5714 | } | 5723 | } |
| 5715 | | 5724 | |
| 5716 | fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { | 5725 | fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { |
| 5717 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5726 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5718 | const src = inst_data.src(); | 5727 | const src = inst_data.src(); |
| 5719 | | 5728 | |
| ... | @@ -5721,7 +5730,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ | ... | @@ -5721,7 +5730,7 @@ fn zirStructInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ |
| 5721 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); | 5730 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirStructInitAnon", .{}); |
| 5722 | } | 5731 | } |
| 5723 | | 5732 | |
| 5724 | fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { | 5733 | fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { |
| 5725 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5734 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5726 | const src = inst_data.src(); | 5735 | const src = inst_data.src(); |
| 5727 | | 5736 | |
| ... | @@ -5729,7 +5738,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: | ... | @@ -5729,7 +5738,7 @@ fn zirArrayInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5729 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); | 5738 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInit", .{}); |
| 5730 | } | 5739 | } |
| 5731 | | 5740 | |
| 5732 | fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!*Inst { | 5741 | fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: bool) InnerError!Air.Inst.Index { |
| 5733 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5742 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5734 | const src = inst_data.src(); | 5743 | const src = inst_data.src(); |
| 5735 | | 5744 | |
| ... | @@ -5737,13 +5746,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r | ... | @@ -5737,13 +5746,13 @@ fn zirArrayInitAnon(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_r |
| 5737 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); | 5746 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirArrayInitAnon", .{}); |
| 5738 | } | 5747 | } |
| 5739 | | 5748 | |
| 5740 | fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5749 | fn zirFieldTypeRef(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5741 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5750 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5742 | const src = inst_data.src(); | 5751 | const src = inst_data.src(); |
| 5743 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{}); | 5752 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldTypeRef", .{}); |
| 5744 | } | 5753 | } |
| 5745 | | 5754 | |
| 5746 | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5755 | fn zirFieldType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5747 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5756 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5748 | const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; | 5757 | const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; |
| 5749 | const src = inst_data.src(); | 5758 | const src = inst_data.src(); |
| ... | @@ -5765,7 +5774,7 @@ fn zirErrorReturnTrace( | ... | @@ -5765,7 +5774,7 @@ fn zirErrorReturnTrace( |
| 5765 | sema: *Sema, | 5774 | sema: *Sema, |
| 5766 | block: *Scope.Block, | 5775 | block: *Scope.Block, |
| 5767 | extended: Zir.Inst.Extended.InstData, | 5776 | extended: Zir.Inst.Extended.InstData, |
| 5768 | ) InnerError!*Inst { | 5777 | ) InnerError!Air.Inst.Index { |
| 5769 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5778 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5770 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{}); | 5779 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{}); |
| 5771 | } | 5780 | } |
| ... | @@ -5774,7 +5783,7 @@ fn zirFrame( | ... | @@ -5774,7 +5783,7 @@ fn zirFrame( |
| 5774 | sema: *Sema, | 5783 | sema: *Sema, |
| 5775 | block: *Scope.Block, | 5784 | block: *Scope.Block, |
| 5776 | extended: Zir.Inst.Extended.InstData, | 5785 | extended: Zir.Inst.Extended.InstData, |
| 5777 | ) InnerError!*Inst { | 5786 | ) InnerError!Air.Inst.Index { |
| 5778 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5787 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5779 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{}); | 5788 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{}); |
| 5780 | } | 5789 | } |
| ... | @@ -5783,84 +5792,84 @@ fn zirFrameAddress( | ... | @@ -5783,84 +5792,84 @@ fn zirFrameAddress( |
| 5783 | sema: *Sema, | 5792 | sema: *Sema, |
| 5784 | block: *Scope.Block, | 5793 | block: *Scope.Block, |
| 5785 | extended: Zir.Inst.Extended.InstData, | 5794 | extended: Zir.Inst.Extended.InstData, |
| 5786 | ) InnerError!*Inst { | 5795 | ) InnerError!Air.Inst.Index { |
| 5787 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; | 5796 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5788 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{}); | 5797 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameAddress", .{}); |
| 5789 | } | 5798 | } |
| 5790 | | 5799 | |
| 5791 | fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5800 | fn zirAlignOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5792 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5801 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5793 | const src = inst_data.src(); | 5802 | const src = inst_data.src(); |
| 5794 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{}); | 5803 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignOf", .{}); |
| 5795 | } | 5804 | } |
| 5796 | | 5805 | |
| 5797 | fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5806 | fn zirBoolToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5798 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5807 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5799 | const src = inst_data.src(); | 5808 | const src = inst_data.src(); |
| 5800 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{}); | 5809 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBoolToInt", .{}); |
| 5801 | } | 5810 | } |
| 5802 | | 5811 | |
| 5803 | fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5812 | fn zirEmbedFile(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5804 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5813 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5805 | const src = inst_data.src(); | 5814 | const src = inst_data.src(); |
| 5806 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{}); | 5815 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirEmbedFile", .{}); |
| 5807 | } | 5816 | } |
| 5808 | | 5817 | |
| 5809 | fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5818 | fn zirErrorName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5810 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5819 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5811 | const src = inst_data.src(); | 5820 | const src = inst_data.src(); |
| 5812 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{}); | 5821 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorName", .{}); |
| 5813 | } | 5822 | } |
| 5814 | | 5823 | |
| 5815 | fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5824 | fn zirUnaryMath(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5816 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5825 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5817 | const src = inst_data.src(); | 5826 | const src = inst_data.src(); |
| 5818 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{}); | 5827 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirUnaryMath", .{}); |
| 5819 | } | 5828 | } |
| 5820 | | 5829 | |
| 5821 | fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5830 | fn zirTagName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5822 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5831 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5823 | const src = inst_data.src(); | 5832 | const src = inst_data.src(); |
| 5824 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{}); | 5833 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTagName", .{}); |
| 5825 | } | 5834 | } |
| 5826 | | 5835 | |
| 5827 | fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5836 | fn zirReify(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5828 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5837 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5829 | const src = inst_data.src(); | 5838 | const src = inst_data.src(); |
| 5830 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{}); | 5839 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReify", .{}); |
| 5831 | } | 5840 | } |
| 5832 | | 5841 | |
| 5833 | fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5842 | fn zirTypeName(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5834 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5843 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5835 | const src = inst_data.src(); | 5844 | const src = inst_data.src(); |
| 5836 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{}); | 5845 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTypeName", .{}); |
| 5837 | } | 5846 | } |
| 5838 | | 5847 | |
| 5839 | fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5848 | fn zirFrameType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5840 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5849 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5841 | const src = inst_data.src(); | 5850 | const src = inst_data.src(); |
| 5842 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{}); | 5851 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameType", .{}); |
| 5843 | } | 5852 | } |
| 5844 | | 5853 | |
| 5845 | fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5854 | fn zirFrameSize(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5846 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5855 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5847 | const src = inst_data.src(); | 5856 | const src = inst_data.src(); |
| 5848 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{}); | 5857 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrameSize", .{}); |
| 5849 | } | 5858 | } |
| 5850 | | 5859 | |
| 5851 | fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5860 | fn zirFloatToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5852 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5861 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5853 | const src = inst_data.src(); | 5862 | const src = inst_data.src(); |
| 5854 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{}); | 5863 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFloatToInt", .{}); |
| 5855 | } | 5864 | } |
| 5856 | | 5865 | |
| 5857 | fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5866 | fn zirIntToFloat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5858 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5867 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5859 | const src = inst_data.src(); | 5868 | const src = inst_data.src(); |
| 5860 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{}); | 5869 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirIntToFloat", .{}); |
| 5861 | } | 5870 | } |
| 5862 | | 5871 | |
| 5863 | fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5872 | fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5864 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5873 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5865 | const src = inst_data.src(); | 5874 | const src = inst_data.src(); |
| 5866 | | 5875 | |
| ... | @@ -5923,199 +5932,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro | ... | @@ -5923,199 +5932,199 @@ fn zirIntToPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5923 | return block.addUnOp(src, type_res, .bitcast, operand_coerced); | 5932 | return block.addUnOp(src, type_res, .bitcast, operand_coerced); |
| 5924 | } | 5933 | } |
| 5925 | | 5934 | |
| 5926 | fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5935 | fn zirErrSetCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5927 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5936 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5928 | const src = inst_data.src(); | 5937 | const src = inst_data.src(); |
| 5929 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{}); | 5938 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrSetCast", .{}); |
| 5930 | } | 5939 | } |
| 5931 | | 5940 | |
| 5932 | fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5941 | fn zirPtrCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5933 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5942 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5934 | const src = inst_data.src(); | 5943 | const src = inst_data.src(); |
| 5935 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{}); | 5944 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPtrCast", .{}); |
| 5936 | } | 5945 | } |
| 5937 | | 5946 | |
| 5938 | fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5947 | fn zirTruncate(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5939 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5948 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5940 | const src = inst_data.src(); | 5949 | const src = inst_data.src(); |
| 5941 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{}); | 5950 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirTruncate", .{}); |
| 5942 | } | 5951 | } |
| 5943 | | 5952 | |
| 5944 | fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5953 | fn zirAlignCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5945 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5954 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5946 | const src = inst_data.src(); | 5955 | const src = inst_data.src(); |
| 5947 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{}); | 5956 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAlignCast", .{}); |
| 5948 | } | 5957 | } |
| 5949 | | 5958 | |
| 5950 | fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5959 | fn zirClz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5951 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5960 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5952 | const src = inst_data.src(); | 5961 | const src = inst_data.src(); |
| 5953 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{}); | 5962 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirClz", .{}); |
| 5954 | } | 5963 | } |
| 5955 | | 5964 | |
| 5956 | fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5965 | fn zirCtz(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5957 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5966 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5958 | const src = inst_data.src(); | 5967 | const src = inst_data.src(); |
| 5959 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{}); | 5968 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCtz", .{}); |
| 5960 | } | 5969 | } |
| 5961 | | 5970 | |
| 5962 | fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5971 | fn zirPopCount(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5963 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5972 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5964 | const src = inst_data.src(); | 5973 | const src = inst_data.src(); |
| 5965 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{}); | 5974 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirPopCount", .{}); |
| 5966 | } | 5975 | } |
| 5967 | | 5976 | |
| 5968 | fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5977 | fn zirByteSwap(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5969 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5978 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5970 | const src = inst_data.src(); | 5979 | const src = inst_data.src(); |
| 5971 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{}); | 5980 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirByteSwap", .{}); |
| 5972 | } | 5981 | } |
| 5973 | | 5982 | |
| 5974 | fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5983 | fn zirBitReverse(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5975 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5984 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5976 | const src = inst_data.src(); | 5985 | const src = inst_data.src(); |
| 5977 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{}); | 5986 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitReverse", .{}); |
| 5978 | } | 5987 | } |
| 5979 | | 5988 | |
| 5980 | fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5989 | fn zirDivExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5981 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5990 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5982 | const src = inst_data.src(); | 5991 | const src = inst_data.src(); |
| 5983 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{}); | 5992 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivExact", .{}); |
| 5984 | } | 5993 | } |
| 5985 | | 5994 | |
| 5986 | fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 5995 | fn zirDivFloor(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5987 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 5996 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5988 | const src = inst_data.src(); | 5997 | const src = inst_data.src(); |
| 5989 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{}); | 5998 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivFloor", .{}); |
| 5990 | } | 5999 | } |
| 5991 | | 6000 | |
| 5992 | fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6001 | fn zirDivTrunc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5993 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6002 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5994 | const src = inst_data.src(); | 6003 | const src = inst_data.src(); |
| 5995 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{}); | 6004 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirDivTrunc", .{}); |
| 5996 | } | 6005 | } |
| 5997 | | 6006 | |
| 5998 | fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6007 | fn zirMod(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 5999 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6008 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6000 | const src = inst_data.src(); | 6009 | const src = inst_data.src(); |
| 6001 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{}); | 6010 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMod", .{}); |
| 6002 | } | 6011 | } |
| 6003 | | 6012 | |
| 6004 | fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6013 | fn zirRem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6005 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6014 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6006 | const src = inst_data.src(); | 6015 | const src = inst_data.src(); |
| 6007 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{}); | 6016 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirRem", .{}); |
| 6008 | } | 6017 | } |
| 6009 | | 6018 | |
| 6010 | fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6019 | fn zirShlExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6011 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6020 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6012 | const src = inst_data.src(); | 6021 | const src = inst_data.src(); |
| 6013 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{}); | 6022 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShlExact", .{}); |
| 6014 | } | 6023 | } |
| 6015 | | 6024 | |
| 6016 | fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6025 | fn zirShrExact(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6017 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6026 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6018 | const src = inst_data.src(); | 6027 | const src = inst_data.src(); |
| 6019 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{}); | 6028 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShrExact", .{}); |
| 6020 | } | 6029 | } |
| 6021 | | 6030 | |
| 6022 | fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6031 | fn zirBitOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6023 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6032 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6024 | const src = inst_data.src(); | 6033 | const src = inst_data.src(); |
| 6025 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{}); | 6034 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBitOffsetOf", .{}); |
| 6026 | } | 6035 | } |
| 6027 | | 6036 | |
| 6028 | fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6037 | fn zirOffsetOf(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6029 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6038 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6030 | const src = inst_data.src(); | 6039 | const src = inst_data.src(); |
| 6031 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{}); | 6040 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirOffsetOf", .{}); |
| 6032 | } | 6041 | } |
| 6033 | | 6042 | |
| 6034 | fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6043 | fn zirCmpxchg(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6035 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6044 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6036 | const src = inst_data.src(); | 6045 | const src = inst_data.src(); |
| 6037 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{}); | 6046 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirCmpxchg", .{}); |
| 6038 | } | 6047 | } |
| 6039 | | 6048 | |
| 6040 | fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6049 | fn zirSplat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6041 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6050 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6042 | const src = inst_data.src(); | 6051 | const src = inst_data.src(); |
| 6043 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{}); | 6052 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirSplat", .{}); |
| 6044 | } | 6053 | } |
| 6045 | | 6054 | |
| 6046 | fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6055 | fn zirReduce(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6047 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6056 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6048 | const src = inst_data.src(); | 6057 | const src = inst_data.src(); |
| 6049 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{}); | 6058 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirReduce", .{}); |
| 6050 | } | 6059 | } |
| 6051 | | 6060 | |
| 6052 | fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6061 | fn zirShuffle(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6053 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6062 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6054 | const src = inst_data.src(); | 6063 | const src = inst_data.src(); |
| 6055 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{}); | 6064 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirShuffle", .{}); |
| 6056 | } | 6065 | } |
| 6057 | | 6066 | |
| 6058 | fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6067 | fn zirAtomicLoad(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6059 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6068 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6060 | const src = inst_data.src(); | 6069 | const src = inst_data.src(); |
| 6061 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{}); | 6070 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicLoad", .{}); |
| 6062 | } | 6071 | } |
| 6063 | | 6072 | |
| 6064 | fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6073 | fn zirAtomicRmw(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6065 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6074 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6066 | const src = inst_data.src(); | 6075 | const src = inst_data.src(); |
| 6067 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{}); | 6076 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicRmw", .{}); |
| 6068 | } | 6077 | } |
| 6069 | | 6078 | |
| 6070 | fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6079 | fn zirAtomicStore(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6071 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6080 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6072 | const src = inst_data.src(); | 6081 | const src = inst_data.src(); |
| 6073 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{}); | 6082 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirAtomicStore", .{}); |
| 6074 | } | 6083 | } |
| 6075 | | 6084 | |
| 6076 | fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6085 | fn zirMulAdd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6077 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6086 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6078 | const src = inst_data.src(); | 6087 | const src = inst_data.src(); |
| 6079 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{}); | 6088 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMulAdd", .{}); |
| 6080 | } | 6089 | } |
| 6081 | | 6090 | |
| 6082 | fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6091 | fn zirBuiltinCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6083 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6092 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6084 | const src = inst_data.src(); | 6093 | const src = inst_data.src(); |
| 6085 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{}); | 6094 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinCall", .{}); |
| 6086 | } | 6095 | } |
| 6087 | | 6096 | |
| 6088 | fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6097 | fn zirFieldPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6089 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6098 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6090 | const src = inst_data.src(); | 6099 | const src = inst_data.src(); |
| 6091 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{}); | 6100 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldPtrType", .{}); |
| 6092 | } | 6101 | } |
| 6093 | | 6102 | |
| 6094 | fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6103 | fn zirFieldParentPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6095 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6104 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6096 | const src = inst_data.src(); | 6105 | const src = inst_data.src(); |
| 6097 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{}); | 6106 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFieldParentPtr", .{}); |
| 6098 | } | 6107 | } |
| 6099 | | 6108 | |
| 6100 | fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6109 | fn zirMemcpy(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6101 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6110 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6102 | const src = inst_data.src(); | 6111 | const src = inst_data.src(); |
| 6103 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{}); | 6112 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemcpy", .{}); |
| 6104 | } | 6113 | } |
| 6105 | | 6114 | |
| 6106 | fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6115 | fn zirMemset(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6107 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6116 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6108 | const src = inst_data.src(); | 6117 | const src = inst_data.src(); |
| 6109 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{}); | 6118 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirMemset", .{}); |
| 6110 | } | 6119 | } |
| 6111 | | 6120 | |
| 6112 | fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6121 | fn zirBuiltinAsyncCall(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6113 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 6122 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6114 | const src = inst_data.src(); | 6123 | const src = inst_data.src(); |
| 6115 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{}); | 6124 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirBuiltinAsyncCall", .{}); |
| 6116 | } | 6125 | } |
| 6117 | | 6126 | |
| 6118 | fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Inst { | 6127 | fn zirResume(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Air.Inst.Index { |
| 6119 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6128 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6120 | const src = inst_data.src(); | 6129 | const src = inst_data.src(); |
| 6121 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{}); | 6130 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{}); |
| ... | @@ -6126,7 +6135,7 @@ fn zirAwait( | ... | @@ -6126,7 +6135,7 @@ fn zirAwait( |
| 6126 | block: *Scope.Block, | 6135 | block: *Scope.Block, |
| 6127 | inst: Zir.Inst.Index, | 6136 | inst: Zir.Inst.Index, |
| 6128 | is_nosuspend: bool, | 6137 | is_nosuspend: bool, |
| 6129 | ) InnerError!*Inst { | 6138 | ) InnerError!Air.Inst.Index { |
| 6130 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6139 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6131 | const src = inst_data.src(); | 6140 | const src = inst_data.src(); |
| 6132 | | 6141 | |
| ... | @@ -6138,7 +6147,7 @@ fn zirVarExtended( | ... | @@ -6138,7 +6147,7 @@ fn zirVarExtended( |
| 6138 | sema: *Sema, | 6147 | sema: *Sema, |
| 6139 | block: *Scope.Block, | 6148 | block: *Scope.Block, |
| 6140 | extended: Zir.Inst.Extended.InstData, | 6149 | extended: Zir.Inst.Extended.InstData, |
| 6141 | ) InnerError!*Inst { | 6150 | ) InnerError!Air.Inst.Index { |
| 6142 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); | 6151 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); |
| 6143 | const src = sema.src; | 6152 | const src = sema.src; |
| 6144 | const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type | 6153 | const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type |
| ... | @@ -6204,7 +6213,7 @@ fn zirFuncExtended( | ... | @@ -6204,7 +6213,7 @@ fn zirFuncExtended( |
| 6204 | block: *Scope.Block, | 6213 | block: *Scope.Block, |
| 6205 | extended: Zir.Inst.Extended.InstData, | 6214 | extended: Zir.Inst.Extended.InstData, |
| 6206 | inst: Zir.Inst.Index, | 6215 | inst: Zir.Inst.Index, |
| 6207 | ) InnerError!*Inst { | 6216 | ) InnerError!Air.Inst.Index { |
| 6208 | const tracy = trace(@src()); | 6217 | const tracy = trace(@src()); |
| 6209 | defer tracy.end(); | 6218 | defer tracy.end(); |
| 6210 | | 6219 | |
| ... | @@ -6271,7 +6280,7 @@ fn zirCUndef( | ... | @@ -6271,7 +6280,7 @@ fn zirCUndef( |
| 6271 | sema: *Sema, | 6280 | sema: *Sema, |
| 6272 | block: *Scope.Block, | 6281 | block: *Scope.Block, |
| 6273 | extended: Zir.Inst.Extended.InstData, | 6282 | extended: Zir.Inst.Extended.InstData, |
| 6274 | ) InnerError!*Inst { | 6283 | ) InnerError!Air.Inst.Index { |
| 6275 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 6284 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6276 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6285 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6277 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{}); | 6286 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{}); |
| ... | @@ -6281,7 +6290,7 @@ fn zirCInclude( | ... | @@ -6281,7 +6290,7 @@ fn zirCInclude( |
| 6281 | sema: *Sema, | 6290 | sema: *Sema, |
| 6282 | block: *Scope.Block, | 6291 | block: *Scope.Block, |
| 6283 | extended: Zir.Inst.Extended.InstData, | 6292 | extended: Zir.Inst.Extended.InstData, |
| 6284 | ) InnerError!*Inst { | 6293 | ) InnerError!Air.Inst.Index { |
| 6285 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 6294 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6286 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6295 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6287 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{}); | 6296 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{}); |
| ... | @@ -6291,7 +6300,7 @@ fn zirCDefine( | ... | @@ -6291,7 +6300,7 @@ fn zirCDefine( |
| 6291 | sema: *Sema, | 6300 | sema: *Sema, |
| 6292 | block: *Scope.Block, | 6301 | block: *Scope.Block, |
| 6293 | extended: Zir.Inst.Extended.InstData, | 6302 | extended: Zir.Inst.Extended.InstData, |
| 6294 | ) InnerError!*Inst { | 6303 | ) InnerError!Air.Inst.Index { |
| 6295 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 6304 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6296 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6305 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6297 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{}); | 6306 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{}); |
| ... | @@ -6301,7 +6310,7 @@ fn zirWasmMemorySize( | ... | @@ -6301,7 +6310,7 @@ fn zirWasmMemorySize( |
| 6301 | sema: *Sema, | 6310 | sema: *Sema, |
| 6302 | block: *Scope.Block, | 6311 | block: *Scope.Block, |
| 6303 | extended: Zir.Inst.Extended.InstData, | 6312 | extended: Zir.Inst.Extended.InstData, |
| 6304 | ) InnerError!*Inst { | 6313 | ) InnerError!Air.Inst.Index { |
| 6305 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 6314 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6306 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6315 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6307 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{}); | 6316 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{}); |
| ... | @@ -6311,7 +6320,7 @@ fn zirWasmMemoryGrow( | ... | @@ -6311,7 +6320,7 @@ fn zirWasmMemoryGrow( |
| 6311 | sema: *Sema, | 6320 | sema: *Sema, |
| 6312 | block: *Scope.Block, | 6321 | block: *Scope.Block, |
| 6313 | extended: Zir.Inst.Extended.InstData, | 6322 | extended: Zir.Inst.Extended.InstData, |
| 6314 | ) InnerError!*Inst { | 6323 | ) InnerError!Air.Inst.Index { |
| 6315 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 6324 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6316 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6325 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6317 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{}); | 6326 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{}); |
| ... | @@ -6321,7 +6330,7 @@ fn zirBuiltinExtern( | ... | @@ -6321,7 +6330,7 @@ fn zirBuiltinExtern( |
| 6321 | sema: *Sema, | 6330 | sema: *Sema, |
| 6322 | block: *Scope.Block, | 6331 | block: *Scope.Block, |
| 6323 | extended: Zir.Inst.Extended.InstData, | 6332 | extended: Zir.Inst.Extended.InstData, |
| 6324 | ) InnerError!*Inst { | 6333 | ) InnerError!Air.Inst.Index { |
| 6325 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 6334 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6326 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 6335 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6327 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{}); | 6336 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{}); |
| ... | @@ -6355,7 +6364,7 @@ pub const PanicId = enum { | ... | @@ -6355,7 +6364,7 @@ pub const PanicId = enum { |
| 6355 | invalid_error_code, | 6364 | invalid_error_code, |
| 6356 | }; | 6365 | }; |
| 6357 | | 6366 | |
| 6358 | fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: PanicId) !void { | 6367 | fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: Air.Inst.Index, panic_id: PanicId) !void { |
| 6359 | const block_inst = try sema.arena.create(Inst.Block); | 6368 | const block_inst = try sema.arena.create(Inst.Block); |
| 6360 | block_inst.* = .{ | 6369 | block_inst.* = .{ |
| 6361 | .base = .{ | 6370 | .base = .{ |
| ... | @@ -6364,12 +6373,12 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: | ... | @@ -6364,12 +6373,12 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 6364 | .src = ok.src, | 6373 | .src = ok.src, |
| 6365 | }, | 6374 | }, |
| 6366 | .body = .{ | 6375 | .body = .{ |
| 6367 | .instructions = try sema.arena.alloc(*Inst, 1), // Only need space for the condbr. | 6376 | .instructions = try sema.arena.alloc(Air.Inst.Index, 1), // Only need space for the condbr. |
| 6368 | }, | 6377 | }, |
| 6369 | }; | 6378 | }; |
| 6370 | | 6379 | |
| 6371 | const ok_body: ir.Body = .{ | 6380 | const ok_body: ir.Body = .{ |
| 6372 | .instructions = try sema.arena.alloc(*Inst, 1), // Only need space for the br_void. | 6381 | .instructions = try sema.arena.alloc(Air.Inst.Index, 1), // Only need space for the br_void. |
| 6373 | }; | 6382 | }; |
| 6374 | const br_void = try sema.arena.create(Inst.BrVoid); | 6383 | const br_void = try sema.arena.create(Inst.BrVoid); |
| 6375 | br_void.* = .{ | 6384 | br_void.* = .{ |
| ... | @@ -6395,7 +6404,7 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: | ... | @@ -6395,7 +6404,7 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 6395 | | 6404 | |
| 6396 | _ = try sema.safetyPanic(&fail_block, ok.src, panic_id); | 6405 | _ = try sema.safetyPanic(&fail_block, ok.src, panic_id); |
| 6397 | | 6406 | |
| 6398 | const fail_body: ir.Body = .{ .instructions = try sema.arena.dupe(*Inst, fail_block.instructions.items) }; | 6407 | const fail_body: ir.Body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, fail_block.instructions.items) }; |
| 6399 | | 6408 | |
| 6400 | const condbr = try sema.arena.create(Inst.CondBr); | 6409 | const condbr = try sema.arena.create(Inst.CondBr); |
| 6401 | condbr.* = .{ | 6410 | condbr.* = .{ |
| ... | @@ -6417,7 +6426,7 @@ fn panicWithMsg( | ... | @@ -6417,7 +6426,7 @@ fn panicWithMsg( |
| 6417 | sema: *Sema, | 6426 | sema: *Sema, |
| 6418 | block: *Scope.Block, | 6427 | block: *Scope.Block, |
| 6419 | src: LazySrcLoc, | 6428 | src: LazySrcLoc, |
| 6420 | msg_inst: *ir.Inst, | 6429 | msg_inst: Air.Inst.Index, |
| 6421 | ) !Zir.Inst.Index { | 6430 | ) !Zir.Inst.Index { |
| 6422 | const mod = sema.mod; | 6431 | const mod = sema.mod; |
| 6423 | const arena = sema.arena; | 6432 | const arena = sema.arena; |
| ... | @@ -6438,7 +6447,7 @@ fn panicWithMsg( | ... | @@ -6438,7 +6447,7 @@ fn panicWithMsg( |
| 6438 | .ty = try mod.optionalType(arena, ptr_stack_trace_ty), | 6447 | .ty = try mod.optionalType(arena, ptr_stack_trace_ty), |
| 6439 | .val = Value.initTag(.null_value), | 6448 | .val = Value.initTag(.null_value), |
| 6440 | }); | 6449 | }); |
| 6441 | const args = try arena.create([2]*ir.Inst); | 6450 | const args = try arena.create([2]Air.Inst.Index); |
| 6442 | args.* = .{ msg_inst, null_stack_trace }; | 6451 | args.* = .{ msg_inst, null_stack_trace }; |
| 6443 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, args); | 6452 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, args); |
| 6444 | return always_noreturn; | 6453 | return always_noreturn; |
| ... | @@ -6494,10 +6503,10 @@ fn namedFieldPtr( | ... | @@ -6494,10 +6503,10 @@ fn namedFieldPtr( |
| 6494 | sema: *Sema, | 6503 | sema: *Sema, |
| 6495 | block: *Scope.Block, | 6504 | block: *Scope.Block, |
| 6496 | src: LazySrcLoc, | 6505 | src: LazySrcLoc, |
| 6497 | object_ptr: *Inst, | 6506 | object_ptr: Air.Inst.Index, |
| 6498 | field_name: []const u8, | 6507 | field_name: []const u8, |
| 6499 | field_name_src: LazySrcLoc, | 6508 | field_name_src: LazySrcLoc, |
| 6500 | ) InnerError!*Inst { | 6509 | ) InnerError!Air.Inst.Index { |
| 6501 | const mod = sema.mod; | 6510 | const mod = sema.mod; |
| 6502 | const arena = sema.arena; | 6511 | const arena = sema.arena; |
| 6503 | | 6512 | |
| ... | @@ -6647,7 +6656,7 @@ fn analyzeNamespaceLookup( | ... | @@ -6647,7 +6656,7 @@ fn analyzeNamespaceLookup( |
| 6647 | src: LazySrcLoc, | 6656 | src: LazySrcLoc, |
| 6648 | namespace: *Scope.Namespace, | 6657 | namespace: *Scope.Namespace, |
| 6649 | decl_name: []const u8, | 6658 | decl_name: []const u8, |
| 6650 | ) InnerError!?*Inst { | 6659 | ) InnerError!?Air.Inst.Index { |
| 6651 | const mod = sema.mod; | 6660 | const mod = sema.mod; |
| 6652 | const gpa = sema.gpa; | 6661 | const gpa = sema.gpa; |
| 6653 | if (try sema.lookupInNamespace(namespace, decl_name)) |decl| { | 6662 | if (try sema.lookupInNamespace(namespace, decl_name)) |decl| { |
| ... | @@ -6671,11 +6680,11 @@ fn analyzeStructFieldPtr( | ... | @@ -6671,11 +6680,11 @@ fn analyzeStructFieldPtr( |
| 6671 | sema: *Sema, | 6680 | sema: *Sema, |
| 6672 | block: *Scope.Block, | 6681 | block: *Scope.Block, |
| 6673 | src: LazySrcLoc, | 6682 | src: LazySrcLoc, |
| 6674 | struct_ptr: *Inst, | 6683 | struct_ptr: Air.Inst.Index, |
| 6675 | field_name: []const u8, | 6684 | field_name: []const u8, |
| 6676 | field_name_src: LazySrcLoc, | 6685 | field_name_src: LazySrcLoc, |
| 6677 | unresolved_struct_ty: Type, | 6686 | unresolved_struct_ty: Type, |
| 6678 | ) InnerError!*Inst { | 6687 | ) InnerError!Air.Inst.Index { |
| 6679 | const mod = sema.mod; | 6688 | const mod = sema.mod; |
| 6680 | const arena = sema.arena; | 6689 | const arena = sema.arena; |
| 6681 | assert(unresolved_struct_ty.zigTypeTag() == .Struct); | 6690 | assert(unresolved_struct_ty.zigTypeTag() == .Struct); |
| ... | @@ -6706,11 +6715,11 @@ fn analyzeUnionFieldPtr( | ... | @@ -6706,11 +6715,11 @@ fn analyzeUnionFieldPtr( |
| 6706 | sema: *Sema, | 6715 | sema: *Sema, |
| 6707 | block: *Scope.Block, | 6716 | block: *Scope.Block, |
| 6708 | src: LazySrcLoc, | 6717 | src: LazySrcLoc, |
| 6709 | union_ptr: *Inst, | 6718 | union_ptr: Air.Inst.Index, |
| 6710 | field_name: []const u8, | 6719 | field_name: []const u8, |
| 6711 | field_name_src: LazySrcLoc, | 6720 | field_name_src: LazySrcLoc, |
| 6712 | unresolved_union_ty: Type, | 6721 | unresolved_union_ty: Type, |
| 6713 | ) InnerError!*Inst { | 6722 | ) InnerError!Air.Inst.Index { |
| 6714 | const mod = sema.mod; | 6723 | const mod = sema.mod; |
| 6715 | const arena = sema.arena; | 6724 | const arena = sema.arena; |
| 6716 | assert(unresolved_union_ty.zigTypeTag() == .Union); | 6725 | assert(unresolved_union_ty.zigTypeTag() == .Union); |
| ... | @@ -6743,10 +6752,10 @@ fn elemPtr( | ... | @@ -6743,10 +6752,10 @@ fn elemPtr( |
| 6743 | sema: *Sema, | 6752 | sema: *Sema, |
| 6744 | block: *Scope.Block, | 6753 | block: *Scope.Block, |
| 6745 | src: LazySrcLoc, | 6754 | src: LazySrcLoc, |
| 6746 | array_ptr: *Inst, | 6755 | array_ptr: Air.Inst.Index, |
| 6747 | elem_index: *Inst, | 6756 | elem_index: Air.Inst.Index, |
| 6748 | elem_index_src: LazySrcLoc, | 6757 | elem_index_src: LazySrcLoc, |
| 6749 | ) InnerError!*Inst { | 6758 | ) InnerError!Air.Inst.Index { |
| 6750 | const array_ty = switch (array_ptr.ty.zigTypeTag()) { | 6759 | const array_ty = switch (array_ptr.ty.zigTypeTag()) { |
| 6751 | .Pointer => array_ptr.ty.elemType(), | 6760 | .Pointer => array_ptr.ty.elemType(), |
| 6752 | else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}), | 6761 | else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}), |
| ... | @@ -6770,10 +6779,10 @@ fn elemPtrArray( | ... | @@ -6770,10 +6779,10 @@ fn elemPtrArray( |
| 6770 | sema: *Sema, | 6779 | sema: *Sema, |
| 6771 | block: *Scope.Block, | 6780 | block: *Scope.Block, |
| 6772 | src: LazySrcLoc, | 6781 | src: LazySrcLoc, |
| 6773 | array_ptr: *Inst, | 6782 | array_ptr: Air.Inst.Index, |
| 6774 | elem_index: *Inst, | 6783 | elem_index: Air.Inst.Index, |
| 6775 | elem_index_src: LazySrcLoc, | 6784 | elem_index_src: LazySrcLoc, |
| 6776 | ) InnerError!*Inst { | 6785 | ) InnerError!Air.Inst.Index { |
| 6777 | if (array_ptr.value()) |array_ptr_val| { | 6786 | if (array_ptr.value()) |array_ptr_val| { |
| 6778 | if (elem_index.value()) |index_val| { | 6787 | if (elem_index.value()) |index_val| { |
| 6779 | // Both array pointer and index are compile-time known. | 6788 | // Both array pointer and index are compile-time known. |
| ... | @@ -6798,9 +6807,9 @@ fn coerce( | ... | @@ -6798,9 +6807,9 @@ fn coerce( |
| 6798 | sema: *Sema, | 6807 | sema: *Sema, |
| 6799 | block: *Scope.Block, | 6808 | block: *Scope.Block, |
| 6800 | dest_type: Type, | 6809 | dest_type: Type, |
| 6801 | inst: *Inst, | 6810 | inst: Air.Inst.Index, |
| 6802 | inst_src: LazySrcLoc, | 6811 | inst_src: LazySrcLoc, |
| 6803 | ) InnerError!*Inst { | 6812 | ) InnerError!Air.Inst.Index { |
| 6804 | if (dest_type.tag() == .var_args_param) { | 6813 | if (dest_type.tag() == .var_args_param) { |
| 6805 | return sema.coerceVarArgParam(block, inst); | 6814 | return sema.coerceVarArgParam(block, inst); |
| 6806 | } | 6815 | } |
| ... | @@ -6976,7 +6985,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult | ... | @@ -6976,7 +6985,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult |
| 6976 | return .no_match; | 6985 | return .no_match; |
| 6977 | } | 6986 | } |
| 6978 | | 6987 | |
| 6979 | fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) InnerError!?*Inst { | 6988 | fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) InnerError!?Air.Inst.Index { |
| 6980 | const val = inst.value() orelse return null; | 6989 | const val = inst.value() orelse return null; |
| 6981 | const src_zig_tag = inst.ty.zigTypeTag(); | 6990 | const src_zig_tag = inst.ty.zigTypeTag(); |
| 6982 | const dst_zig_tag = dest_type.zigTypeTag(); | 6991 | const dst_zig_tag = dest_type.zigTypeTag(); |
| ... | @@ -7014,7 +7023,7 @@ fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) Inn | ... | @@ -7014,7 +7023,7 @@ fn coerceNum(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) Inn |
| 7014 | return null; | 7023 | return null; |
| 7015 | } | 7024 | } |
| 7016 | | 7025 | |
| 7017 | fn coerceVarArgParam(sema: *Sema, block: *Scope.Block, inst: *Inst) !*Inst { | 7026 | fn coerceVarArgParam(sema: *Sema, block: *Scope.Block, inst: Air.Inst.Index) !Air.Inst.Index { |
| 7018 | switch (inst.ty.zigTypeTag()) { | 7027 | switch (inst.ty.zigTypeTag()) { |
| 7019 | .ComptimeInt, .ComptimeFloat => return sema.mod.fail(&block.base, inst.src, "integer and float literals in var args function must be casted", .{}), | 7028 | .ComptimeInt, .ComptimeFloat => return sema.mod.fail(&block.base, inst.src, "integer and float literals in var args function must be casted", .{}), |
| 7020 | else => {}, | 7029 | else => {}, |
| ... | @@ -7027,8 +7036,8 @@ fn storePtr( | ... | @@ -7027,8 +7036,8 @@ fn storePtr( |
| 7027 | sema: *Sema, | 7036 | sema: *Sema, |
| 7028 | block: *Scope.Block, | 7037 | block: *Scope.Block, |
| 7029 | src: LazySrcLoc, | 7038 | src: LazySrcLoc, |
| 7030 | ptr: *Inst, | 7039 | ptr: Air.Inst.Index, |
| 7031 | uncasted_value: *Inst, | 7040 | uncasted_value: Air.Inst.Index, |
| 7032 | ) !void { | 7041 | ) !void { |
| 7033 | if (ptr.ty.isConstPtr()) | 7042 | if (ptr.ty.isConstPtr()) |
| 7034 | return sema.mod.fail(&block.base, src, "cannot assign to constant", .{}); | 7043 | return sema.mod.fail(&block.base, src, "cannot assign to constant", .{}); |
| ... | @@ -7076,7 +7085,7 @@ fn storePtr( | ... | @@ -7076,7 +7085,7 @@ fn storePtr( |
| 7076 | _ = try block.addBinOp(src, Type.initTag(.void), .store, ptr, value); | 7085 | _ = try block.addBinOp(src, Type.initTag(.void), .store, ptr, value); |
| 7077 | } | 7086 | } |
| 7078 | | 7087 | |
| 7079 | fn bitcast(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Inst { | 7088 | fn bitcast(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { |
| 7080 | if (inst.value()) |val| { | 7089 | if (inst.value()) |val| { |
| 7081 | // Keep the comptime Value representation; take the new type. | 7090 | // Keep the comptime Value representation; take the new type. |
| 7082 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7091 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| ... | @@ -7086,7 +7095,7 @@ fn bitcast(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Ins | ... | @@ -7086,7 +7095,7 @@ fn bitcast(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Ins |
| 7086 | return block.addUnOp(inst.src, dest_type, .bitcast, inst); | 7095 | return block.addUnOp(inst.src, dest_type, .bitcast, inst); |
| 7087 | } | 7096 | } |
| 7088 | | 7097 | |
| 7089 | fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Inst { | 7098 | fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { |
| 7090 | if (inst.value()) |val| { | 7099 | if (inst.value()) |val| { |
| 7091 | // The comptime Value representation is compatible with both types. | 7100 | // The comptime Value representation is compatible with both types. |
| 7092 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7101 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| ... | @@ -7094,7 +7103,7 @@ fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst | ... | @@ -7094,7 +7103,7 @@ fn coerceArrayPtrToSlice(sema: *Sema, block: *Scope.Block, dest_type: Type, inst |
| 7094 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{}); | 7103 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{}); |
| 7095 | } | 7104 | } |
| 7096 | | 7105 | |
| 7097 | fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Inst { | 7106 | fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { |
| 7098 | if (inst.value()) |val| { | 7107 | if (inst.value()) |val| { |
| 7099 | // The comptime Value representation is compatible with both types. | 7108 | // The comptime Value representation is compatible with both types. |
| 7100 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7109 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| ... | @@ -7102,12 +7111,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: | ... | @@ -7102,12 +7111,12 @@ fn coerceArrayPtrToMany(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: |
| 7102 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{}); | 7111 | return sema.mod.fail(&block.base, inst.src, "TODO implement coerceArrayPtrToMany runtime instruction", .{}); |
| 7103 | } | 7112 | } |
| 7104 | | 7113 | |
| 7105 | fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!*Inst { | 7114 | fn analyzeDeclVal(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Index { |
| 7106 | const decl_ref = try sema.analyzeDeclRef(block, src, decl); | 7115 | const decl_ref = try sema.analyzeDeclRef(block, src, decl); |
| 7107 | return sema.analyzeLoad(block, src, decl_ref, src); | 7116 | return sema.analyzeLoad(block, src, decl_ref, src); |
| 7108 | } | 7117 | } |
| 7109 | | 7118 | |
| 7110 | fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!*Inst { | 7119 | fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl) InnerError!Air.Inst.Index { |
| 7111 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); | 7120 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); |
| 7112 | sema.mod.ensureDeclAnalyzed(decl) catch |err| { | 7121 | sema.mod.ensureDeclAnalyzed(decl) catch |err| { |
| 7113 | if (sema.func) |func| { | 7122 | if (sema.func) |func| { |
| ... | @@ -7128,7 +7137,7 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl | ... | @@ -7128,7 +7137,7 @@ fn analyzeDeclRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, decl: *Decl |
| 7128 | }); | 7137 | }); |
| 7129 | } | 7138 | } |
| 7130 | | 7139 | |
| 7131 | fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) InnerError!*Inst { | 7140 | fn analyzeVarRef(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, tv: TypedValue) InnerError!Air.Inst.Index { |
| 7132 | const variable = tv.val.castTag(.variable).?.data; | 7141 | const variable = tv.val.castTag(.variable).?.data; |
| 7133 | | 7142 | |
| 7134 | const ty = try sema.mod.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One); | 7143 | const ty = try sema.mod.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One); |
| ... | @@ -7157,8 +7166,8 @@ fn analyzeRef( | ... | @@ -7157,8 +7166,8 @@ fn analyzeRef( |
| 7157 | sema: *Sema, | 7166 | sema: *Sema, |
| 7158 | block: *Scope.Block, | 7167 | block: *Scope.Block, |
| 7159 | src: LazySrcLoc, | 7168 | src: LazySrcLoc, |
| 7160 | operand: *Inst, | 7169 | operand: Air.Inst.Index, |
| 7161 | ) InnerError!*Inst { | 7170 | ) InnerError!Air.Inst.Index { |
| 7162 | const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One); | 7171 | const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One); |
| 7163 | | 7172 | |
| 7164 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| { | 7173 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| { |
| ... | @@ -7176,9 +7185,9 @@ fn analyzeLoad( | ... | @@ -7176,9 +7185,9 @@ fn analyzeLoad( |
| 7176 | sema: *Sema, | 7185 | sema: *Sema, |
| 7177 | block: *Scope.Block, | 7186 | block: *Scope.Block, |
| 7178 | src: LazySrcLoc, | 7187 | src: LazySrcLoc, |
| 7179 | ptr: *Inst, | 7188 | ptr: Air.Inst.Index, |
| 7180 | ptr_src: LazySrcLoc, | 7189 | ptr_src: LazySrcLoc, |
| 7181 | ) InnerError!*Inst { | 7190 | ) InnerError!Air.Inst.Index { |
| 7182 | const elem_ty = switch (ptr.ty.zigTypeTag()) { | 7191 | const elem_ty = switch (ptr.ty.zigTypeTag()) { |
| 7183 | .Pointer => ptr.ty.elemType(), | 7192 | .Pointer => ptr.ty.elemType(), |
| 7184 | else => return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}), | 7193 | else => return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}), |
| ... | @@ -7201,9 +7210,9 @@ fn analyzeIsNull( | ... | @@ -7201,9 +7210,9 @@ fn analyzeIsNull( |
| 7201 | sema: *Sema, | 7210 | sema: *Sema, |
| 7202 | block: *Scope.Block, | 7211 | block: *Scope.Block, |
| 7203 | src: LazySrcLoc, | 7212 | src: LazySrcLoc, |
| 7204 | operand: *Inst, | 7213 | operand: Air.Inst.Index, |
| 7205 | invert_logic: bool, | 7214 | invert_logic: bool, |
| 7206 | ) InnerError!*Inst { | 7215 | ) InnerError!Air.Inst.Index { |
| 7207 | const result_ty = Type.initTag(.bool); | 7216 | const result_ty = Type.initTag(.bool); |
| 7208 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| { | 7217 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| { |
| 7209 | if (opt_val.isUndef()) { | 7218 | if (opt_val.isUndef()) { |
| ... | @@ -7222,8 +7231,8 @@ fn analyzeIsNonErr( | ... | @@ -7222,8 +7231,8 @@ fn analyzeIsNonErr( |
| 7222 | sema: *Sema, | 7231 | sema: *Sema, |
| 7223 | block: *Scope.Block, | 7232 | block: *Scope.Block, |
| 7224 | src: LazySrcLoc, | 7233 | src: LazySrcLoc, |
| 7225 | operand: *Inst, | 7234 | operand: Air.Inst.Index, |
| 7226 | ) InnerError!*Inst { | 7235 | ) InnerError!Air.Inst.Index { |
| 7227 | const ot = operand.ty.zigTypeTag(); | 7236 | const ot = operand.ty.zigTypeTag(); |
| 7228 | if (ot != .ErrorSet and ot != .ErrorUnion) return sema.mod.constBool(sema.arena, src, true); | 7237 | if (ot != .ErrorSet and ot != .ErrorUnion) return sema.mod.constBool(sema.arena, src, true); |
| 7229 | if (ot == .ErrorSet) return sema.mod.constBool(sema.arena, src, false); | 7238 | if (ot == .ErrorSet) return sema.mod.constBool(sema.arena, src, false); |
| ... | @@ -7243,12 +7252,12 @@ fn analyzeSlice( | ... | @@ -7243,12 +7252,12 @@ fn analyzeSlice( |
| 7243 | sema: *Sema, | 7252 | sema: *Sema, |
| 7244 | block: *Scope.Block, | 7253 | block: *Scope.Block, |
| 7245 | src: LazySrcLoc, | 7254 | src: LazySrcLoc, |
| 7246 | array_ptr: *Inst, | 7255 | array_ptr: Air.Inst.Index, |
| 7247 | start: *Inst, | 7256 | start: Air.Inst.Index, |
| 7248 | end_opt: ?*Inst, | 7257 | end_opt: ?Air.Inst.Index, |
| 7249 | sentinel_opt: ?*Inst, | 7258 | sentinel_opt: ?Air.Inst.Index, |
| 7250 | sentinel_src: LazySrcLoc, | 7259 | sentinel_src: LazySrcLoc, |
| 7251 | ) InnerError!*Inst { | 7260 | ) InnerError!Air.Inst.Index { |
| 7252 | const ptr_child = switch (array_ptr.ty.zigTypeTag()) { | 7261 | const ptr_child = switch (array_ptr.ty.zigTypeTag()) { |
| 7253 | .Pointer => array_ptr.ty.elemType(), | 7262 | .Pointer => array_ptr.ty.elemType(), |
| 7254 | else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}), | 7263 | else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}), |
| ... | @@ -7319,10 +7328,10 @@ fn cmpNumeric( | ... | @@ -7319,10 +7328,10 @@ fn cmpNumeric( |
| 7319 | sema: *Sema, | 7328 | sema: *Sema, |
| 7320 | block: *Scope.Block, | 7329 | block: *Scope.Block, |
| 7321 | src: LazySrcLoc, | 7330 | src: LazySrcLoc, |
| 7322 | lhs: *Inst, | 7331 | lhs: Air.Inst.Index, |
| 7323 | rhs: *Inst, | 7332 | rhs: Air.Inst.Index, |
| 7324 | op: std.math.CompareOperator, | 7333 | op: std.math.CompareOperator, |
| 7325 | ) InnerError!*Inst { | 7334 | ) InnerError!Air.Inst.Index { |
| 7326 | assert(lhs.ty.isNumeric()); | 7335 | assert(lhs.ty.isNumeric()); |
| 7327 | assert(rhs.ty.isNumeric()); | 7336 | assert(rhs.ty.isNumeric()); |
| 7328 | | 7337 | |
| ... | @@ -7488,7 +7497,7 @@ fn cmpNumeric( | ... | @@ -7488,7 +7497,7 @@ fn cmpNumeric( |
| 7488 | return block.addBinOp(src, Type.initTag(.bool), Inst.Tag.fromCmpOp(op), casted_lhs, casted_rhs); | 7497 | return block.addBinOp(src, Type.initTag(.bool), Inst.Tag.fromCmpOp(op), casted_lhs, casted_rhs); |
| 7489 | } | 7498 | } |
| 7490 | | 7499 | |
| 7491 | fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Inst { | 7500 | fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { |
| 7492 | if (inst.value()) |val| { | 7501 | if (inst.value()) |val| { |
| 7493 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); | 7502 | return sema.mod.constInst(sema.arena, inst.src, .{ .ty = dest_type, .val = val }); |
| 7494 | } | 7503 | } |
| ... | @@ -7497,7 +7506,7 @@ fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) | ... | @@ -7497,7 +7506,7 @@ fn wrapOptional(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) |
| 7497 | return block.addUnOp(inst.src, dest_type, .wrap_optional, inst); | 7506 | return block.addUnOp(inst.src, dest_type, .wrap_optional, inst); |
| 7498 | } | 7507 | } |
| 7499 | | 7508 | |
| 7500 | fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst) !*Inst { | 7509 | fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: Air.Inst.Index) !Air.Inst.Index { |
| 7501 | const err_union = dest_type.castTag(.error_union).?; | 7510 | const err_union = dest_type.castTag(.error_union).?; |
| 7502 | if (inst.value()) |val| { | 7511 | if (inst.value()) |val| { |
| 7503 | if (inst.ty.zigTypeTag() != .ErrorSet) { | 7512 | if (inst.ty.zigTypeTag() != .ErrorSet) { |
| ... | @@ -7568,7 +7577,7 @@ fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst | ... | @@ -7568,7 +7577,7 @@ fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst |
| 7568 | } | 7577 | } |
| 7569 | } | 7578 | } |
| 7570 | | 7579 | |
| 7571 | fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, instructions: []*Inst) !Type { | 7580 | fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, instructions: []Air.Inst.Index) !Type { |
| 7572 | if (instructions.len == 0) | 7581 | if (instructions.len == 0) |
| 7573 | return Type.initTag(.noreturn); | 7582 | return Type.initTag(.noreturn); |
| 7574 | | 7583 | |
| ... | @@ -7704,7 +7713,7 @@ fn getBuiltin( | ... | @@ -7704,7 +7713,7 @@ fn getBuiltin( |
| 7704 | block: *Scope.Block, | 7713 | block: *Scope.Block, |
| 7705 | src: LazySrcLoc, | 7714 | src: LazySrcLoc, |
| 7706 | name: []const u8, | 7715 | name: []const u8, |
| 7707 | ) InnerError!*ir.Inst { | 7716 | ) InnerError!Air.Inst.Index { |
| 7708 | const mod = sema.mod; | 7717 | const mod = sema.mod; |
| 7709 | const std_pkg = mod.root_pkg.table.get("std").?; | 7718 | const std_pkg = mod.root_pkg.table.get("std").?; |
| 7710 | const std_file = (mod.importPkg(std_pkg) catch unreachable).file; | 7719 | const std_file = (mod.importPkg(std_pkg) catch unreachable).file; |