| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | //! Semantic analysis of ZIR instructions. |
| 2 | 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 | 4 | //! Transforms untyped ZIR instructions into semantically-analyzed AIR instructions. |
| 5 | 5 | //! Does type checking, comptime control flow, and safety-check generation. |
| 6 | 6 | //! This is the the heart of the Zig compiler. |
| ... | ... | @@ -11,6 +11,10 @@ gpa: *Allocator, |
| 11 | 11 | /// Points to the arena allocator of the Decl. |
| 12 | 12 | arena: *Allocator, |
| 13 | 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 | 18 | /// Maps ZIR to AIR. |
| 15 | 19 | inst_map: InstMap = .{}, |
| 16 | 20 | /// When analyzing an inline function call, owner_decl is the Decl of the caller |
| ... | ... | @@ -32,7 +36,7 @@ func: ?*Module.Fn, |
| 32 | 36 | /// > Denormalized data to make `resolveInst` faster. This is 0 if not inside a function, |
| 33 | 37 | /// > otherwise it is the number of parameters of the function. |
| 34 | 38 | /// > param_count: u32 |
| 35 | | param_inst_list: []const *ir.Inst, |
| 39 | param_inst_list: []const Air.Inst.Index, |
| 36 | 40 | branch_quota: u32 = 1000, |
| 37 | 41 | branch_count: u32 = 0, |
| 38 | 42 | /// This field is updated when a new source location becomes active, so that |
| ... | ... | @@ -65,10 +69,15 @@ const LazySrcLoc = Module.LazySrcLoc; |
| 65 | 69 | const RangeSet = @import("RangeSet.zig"); |
| 66 | 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 | 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 | 81 | sema.* = undefined; |
| 73 | 82 | } |
| 74 | 83 | |
| ... | ... | @@ -108,7 +117,7 @@ pub fn analyzeFnBody( |
| 108 | 117 | /// Returns only the result from the body that is specified. |
| 109 | 118 | /// Only appropriate to call when it is determined at comptime that this body |
| 110 | 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 | 121 | const break_inst = try sema.analyzeBody(block, body); |
| 113 | 122 | const operand_ref = sema.code.instructions.items(.data)[break_inst].@"break".operand; |
| 114 | 123 | return sema.resolveInst(operand_ref); |
| ... | ... | @@ -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 | 546 | const extended = sema.code.instructions.items(.data)[inst].extended; |
| 538 | 547 | switch (extended.opcode) { |
| 539 | 548 | // zig fmt: off |
| ... | ... | @@ -569,7 +578,7 @@ fn zirExtended(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 569 | 578 | } |
| 570 | 579 | |
| 571 | 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 | 582 | var i: usize = @enumToInt(zir_ref); |
| 574 | 583 | |
| 575 | 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 | 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 | 631 | const wanted_type = Type.initTag(.@"type"); |
| 623 | 632 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 624 | 633 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| 625 | 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 | 638 | return (try sema.resolveDefinedValue(block, src, base)) orelse |
| 630 | 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 | 643 | if (try sema.resolvePossiblyUndefinedValue(block, src, base)) |val| { |
| 635 | 644 | if (val.isUndef()) { |
| 636 | 645 | return sema.failWithUseOfUndef(block, src); |
| ... | ... | @@ -644,7 +653,7 @@ fn resolvePossiblyUndefinedValue( |
| 644 | 653 | sema: *Sema, |
| 645 | 654 | block: *Scope.Block, |
| 646 | 655 | src: LazySrcLoc, |
| 647 | | base: *ir.Inst, |
| 656 | base: Air.Inst.Index, |
| 648 | 657 | ) !?Value { |
| 649 | 658 | if (try sema.typeHasOnePossibleValue(block, src, base.ty)) |opv| { |
| 650 | 659 | return opv; |
| ... | ... | @@ -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 | 721 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 713 | 722 | const src = inst_data.src(); |
| 714 | 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 | 727 | _ = inst; |
| 719 | 728 | const tracy = trace(@src()); |
| 720 | 729 | defer tracy.end(); |
| ... | ... | @@ -749,7 +758,7 @@ fn zirStructDecl( |
| 749 | 758 | block: *Scope.Block, |
| 750 | 759 | extended: Zir.Inst.Extended.InstData, |
| 751 | 760 | inst: Zir.Inst.Index, |
| 752 | | ) InnerError!*Inst { |
| 761 | ) InnerError!Air.Inst.Index { |
| 753 | 762 | const small = @bitCast(Zir.Inst.StructDecl.Small, extended.small); |
| 754 | 763 | const src: LazySrcLoc = if (small.has_src_node) blk: { |
| 755 | 764 | const node_offset = @bitCast(i32, sema.code.extra[extended.operand]); |
| ... | ... | @@ -820,7 +829,7 @@ fn zirEnumDecl( |
| 820 | 829 | sema: *Sema, |
| 821 | 830 | block: *Scope.Block, |
| 822 | 831 | extended: Zir.Inst.Extended.InstData, |
| 823 | | ) InnerError!*Inst { |
| 832 | ) InnerError!Air.Inst.Index { |
| 824 | 833 | const tracy = trace(@src()); |
| 825 | 834 | defer tracy.end(); |
| 826 | 835 | |
| ... | ... | @@ -1017,7 +1026,7 @@ fn zirUnionDecl( |
| 1017 | 1026 | block: *Scope.Block, |
| 1018 | 1027 | extended: Zir.Inst.Extended.InstData, |
| 1019 | 1028 | inst: Zir.Inst.Index, |
| 1020 | | ) InnerError!*Inst { |
| 1029 | ) InnerError!Air.Inst.Index { |
| 1021 | 1030 | const tracy = trace(@src()); |
| 1022 | 1031 | defer tracy.end(); |
| 1023 | 1032 | |
| ... | ... | @@ -1081,7 +1090,7 @@ fn zirOpaqueDecl( |
| 1081 | 1090 | block: *Scope.Block, |
| 1082 | 1091 | inst: Zir.Inst.Index, |
| 1083 | 1092 | name_strategy: Zir.Inst.NameStrategy, |
| 1084 | | ) InnerError!*Inst { |
| 1093 | ) InnerError!Air.Inst.Index { |
| 1085 | 1094 | const tracy = trace(@src()); |
| 1086 | 1095 | defer tracy.end(); |
| 1087 | 1096 | |
| ... | ... | @@ -1101,7 +1110,7 @@ fn zirErrorSetDecl( |
| 1101 | 1110 | block: *Scope.Block, |
| 1102 | 1111 | inst: Zir.Inst.Index, |
| 1103 | 1112 | name_strategy: Zir.Inst.NameStrategy, |
| 1104 | | ) InnerError!*Inst { |
| 1113 | ) InnerError!Air.Inst.Index { |
| 1105 | 1114 | const tracy = trace(@src()); |
| 1106 | 1115 | defer tracy.end(); |
| 1107 | 1116 | |
| ... | ... | @@ -1141,7 +1150,7 @@ fn zirRetPtr( |
| 1141 | 1150 | sema: *Sema, |
| 1142 | 1151 | block: *Scope.Block, |
| 1143 | 1152 | extended: Zir.Inst.Extended.InstData, |
| 1144 | | ) InnerError!*Inst { |
| 1153 | ) InnerError!Air.Inst.Index { |
| 1145 | 1154 | const tracy = trace(@src()); |
| 1146 | 1155 | defer tracy.end(); |
| 1147 | 1156 | |
| ... | ... | @@ -1153,7 +1162,7 @@ fn zirRetPtr( |
| 1153 | 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 | 1166 | const tracy = trace(@src()); |
| 1158 | 1167 | defer tracy.end(); |
| 1159 | 1168 | |
| ... | ... | @@ -1166,7 +1175,7 @@ fn zirRetType( |
| 1166 | 1175 | sema: *Sema, |
| 1167 | 1176 | block: *Scope.Block, |
| 1168 | 1177 | extended: Zir.Inst.Extended.InstData, |
| 1169 | | ) InnerError!*Inst { |
| 1178 | ) InnerError!Air.Inst.Index { |
| 1170 | 1179 | const tracy = trace(@src()); |
| 1171 | 1180 | defer tracy.end(); |
| 1172 | 1181 | |
| ... | ... | @@ -1191,7 +1200,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) I |
| 1191 | 1200 | fn ensureResultUsed( |
| 1192 | 1201 | sema: *Sema, |
| 1193 | 1202 | block: *Scope.Block, |
| 1194 | | operand: *Inst, |
| 1203 | operand: Air.Inst.Index, |
| 1195 | 1204 | src: LazySrcLoc, |
| 1196 | 1205 | ) InnerError!void { |
| 1197 | 1206 | switch (operand.ty.zigTypeTag()) { |
| ... | ... | @@ -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 | 1226 | const tracy = trace(@src()); |
| 1218 | 1227 | defer tracy.end(); |
| 1219 | 1228 | |
| ... | ... | @@ -1247,7 +1256,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) In |
| 1247 | 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 | 1260 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 1252 | 1261 | const arg_name = inst_data.get(sema.code); |
| 1253 | 1262 | const arg_index = sema.next_arg_index; |
| ... | ... | @@ -1269,13 +1278,13 @@ fn zirAllocExtended( |
| 1269 | 1278 | sema: *Sema, |
| 1270 | 1279 | block: *Scope.Block, |
| 1271 | 1280 | extended: Zir.Inst.Extended.InstData, |
| 1272 | | ) InnerError!*Inst { |
| 1281 | ) InnerError!Air.Inst.Index { |
| 1273 | 1282 | const extra = sema.code.extraData(Zir.Inst.AllocExtended, extended.operand); |
| 1274 | 1283 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; |
| 1275 | 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 | 1288 | const tracy = trace(@src()); |
| 1280 | 1289 | defer tracy.end(); |
| 1281 | 1290 | |
| ... | ... | @@ -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 | 1311 | const src_node = sema.code.instructions.items(.data)[inst].node; |
| 1303 | 1312 | const src: LazySrcLoc = .{ .node_offset = src_node }; |
| 1304 | 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 | 1317 | const tracy = trace(@src()); |
| 1309 | 1318 | defer tracy.end(); |
| 1310 | 1319 | |
| ... | ... | @@ -1317,7 +1326,7 @@ fn zirAlloc(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!* |
| 1317 | 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 | 1330 | const tracy = trace(@src()); |
| 1322 | 1331 | defer tracy.end(); |
| 1323 | 1332 | |
| ... | ... | @@ -1336,7 +1345,7 @@ fn zirAllocInferred( |
| 1336 | 1345 | block: *Scope.Block, |
| 1337 | 1346 | inst: Zir.Inst.Index, |
| 1338 | 1347 | inferred_alloc_ty: Type, |
| 1339 | | ) InnerError!*Inst { |
| 1348 | ) InnerError!Air.Inst.Index { |
| 1340 | 1349 | const tracy = trace(@src()); |
| 1341 | 1350 | defer tracy.end(); |
| 1342 | 1351 | |
| ... | ... | @@ -1589,7 +1598,7 @@ fn zirStoreNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 1589 | 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 | 1602 | const tracy = trace(@src()); |
| 1594 | 1603 | defer tracy.end(); |
| 1595 | 1604 | |
| ... | ... | @@ -1625,7 +1634,7 @@ fn zirParamType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 1625 | 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 | 1638 | const tracy = trace(@src()); |
| 1630 | 1639 | defer tracy.end(); |
| 1631 | 1640 | |
| ... | ... | @@ -1653,7 +1662,7 @@ fn zirStr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 1653 | 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 | 1666 | _ = block; |
| 1658 | 1667 | const tracy = trace(@src()); |
| 1659 | 1668 | defer tracy.end(); |
| ... | ... | @@ -1662,7 +1671,7 @@ fn zirInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 1662 | 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 | 1675 | _ = block; |
| 1667 | 1676 | const tracy = trace(@src()); |
| 1668 | 1677 | defer tracy.end(); |
| ... | ... | @@ -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 | 1693 | _ = block; |
| 1685 | 1694 | const arena = sema.arena; |
| 1686 | 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 | 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 | 1706 | _ = block; |
| 1698 | 1707 | const arena = sema.arena; |
| 1699 | 1708 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| ... | ... | @@ -1722,7 +1731,7 @@ fn zirCompileLog( |
| 1722 | 1731 | sema: *Sema, |
| 1723 | 1732 | block: *Scope.Block, |
| 1724 | 1733 | extended: Zir.Inst.Extended.InstData, |
| 1725 | | ) InnerError!*Inst { |
| 1734 | ) InnerError!Air.Inst.Index { |
| 1726 | 1735 | var managed = sema.mod.compile_log_text.toManaged(sema.gpa); |
| 1727 | 1736 | defer sema.mod.compile_log_text = managed.moveToUnmanaged(); |
| 1728 | 1737 | const writer = managed.writer(); |
| ... | ... | @@ -1772,7 +1781,7 @@ fn zirPanic(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!Z |
| 1772 | 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 | 1785 | const tracy = trace(@src()); |
| 1777 | 1786 | defer tracy.end(); |
| 1778 | 1787 | |
| ... | ... | @@ -1832,12 +1841,12 @@ fn zirLoop(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 1832 | 1841 | // Loop repetition is implied so the last instruction may or may not be a noreturn instruction. |
| 1833 | 1842 | |
| 1834 | 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 | 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 | 1850 | const tracy = trace(@src()); |
| 1842 | 1851 | defer tracy.end(); |
| 1843 | 1852 | |
| ... | ... | @@ -1847,13 +1856,13 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 1847 | 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 | 1860 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 1852 | 1861 | const src = inst_data.src(); |
| 1853 | 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 | 1866 | const tracy = trace(@src()); |
| 1858 | 1867 | defer tracy.end(); |
| 1859 | 1868 | |
| ... | ... | @@ -1911,7 +1920,7 @@ fn resolveBlockBody( |
| 1911 | 1920 | child_block: *Scope.Block, |
| 1912 | 1921 | body: []const Zir.Inst.Index, |
| 1913 | 1922 | merges: *Scope.Block.Merges, |
| 1914 | | ) InnerError!*Inst { |
| 1923 | ) InnerError!Air.Inst.Index { |
| 1915 | 1924 | _ = try sema.analyzeBody(child_block, body); |
| 1916 | 1925 | return sema.analyzeBlockBody(parent_block, src, child_block, merges); |
| 1917 | 1926 | } |
| ... | ... | @@ -1922,7 +1931,7 @@ fn analyzeBlockBody( |
| 1922 | 1931 | src: LazySrcLoc, |
| 1923 | 1932 | child_block: *Scope.Block, |
| 1924 | 1933 | merges: *Scope.Block.Merges, |
| 1925 | | ) InnerError!*Inst { |
| 1934 | ) InnerError!Air.Inst.Index { |
| 1926 | 1935 | const tracy = trace(@src()); |
| 1927 | 1936 | defer tracy.end(); |
| 1928 | 1937 | |
| ... | ... | @@ -1933,7 +1942,7 @@ fn analyzeBlockBody( |
| 1933 | 1942 | if (merges.results.items.len == 0) { |
| 1934 | 1943 | // No need for a block instruction. We can put the new instructions |
| 1935 | 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 | 1946 | try parent_block.instructions.appendSlice(sema.gpa, copied_instructions); |
| 1938 | 1947 | return copied_instructions[copied_instructions.len - 1]; |
| 1939 | 1948 | } |
| ... | ... | @@ -1944,7 +1953,7 @@ fn analyzeBlockBody( |
| 1944 | 1953 | if (br_block == merges.block_inst) { |
| 1945 | 1954 | // No need for a block instruction. We can put the new instructions directly |
| 1946 | 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 | 1957 | try parent_block.instructions.appendSlice(sema.gpa, copied_instructions); |
| 1949 | 1958 | return merges.results.items[0]; |
| 1950 | 1959 | } |
| ... | ... | @@ -1959,7 +1968,7 @@ fn analyzeBlockBody( |
| 1959 | 1968 | const resolved_ty = try sema.resolvePeerTypes(parent_block, src, merges.results.items); |
| 1960 | 1969 | merges.block_inst.base.ty = resolved_ty; |
| 1961 | 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 | 1973 | // Now that the block has its type resolved, we need to go back into all the break |
| 1965 | 1974 | // instructions, and insert type coercion on the operands. |
| ... | ... | @@ -1991,7 +2000,7 @@ fn analyzeBlockBody( |
| 1991 | 2000 | }, |
| 1992 | 2001 | .block = merges.block_inst, |
| 1993 | 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 | 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 | 2143 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2135 | 2144 | const src = inst_data.src(); |
| 2136 | 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 | 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 | 2151 | const inst_data = sema.code.instructions.items(.data)[inst].str_tok; |
| 2143 | 2152 | const src = inst_data.src(); |
| 2144 | 2153 | const decl_name = inst_data.get(sema.code); |
| ... | ... | @@ -2192,7 +2201,7 @@ fn zirCall( |
| 2192 | 2201 | inst: Zir.Inst.Index, |
| 2193 | 2202 | modifier: std.builtin.CallOptions.Modifier, |
| 2194 | 2203 | ensure_result_used: bool, |
| 2195 | | ) InnerError!*Inst { |
| 2204 | ) InnerError!Air.Inst.Index { |
| 2196 | 2205 | const tracy = trace(@src()); |
| 2197 | 2206 | defer tracy.end(); |
| 2198 | 2207 | |
| ... | ... | @@ -2204,7 +2213,7 @@ fn zirCall( |
| 2204 | 2213 | |
| 2205 | 2214 | const func = try sema.resolveInst(extra.data.callee); |
| 2206 | 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 | 2217 | for (args) |zir_arg, i| { |
| 2209 | 2218 | // the args are already casted to the result of a param type instruction. |
| 2210 | 2219 | resolved_args[i] = try sema.resolveInst(zir_arg); |
| ... | ... | @@ -2216,13 +2225,13 @@ fn zirCall( |
| 2216 | 2225 | fn analyzeCall( |
| 2217 | 2226 | sema: *Sema, |
| 2218 | 2227 | block: *Scope.Block, |
| 2219 | | func: *ir.Inst, |
| 2228 | func: Air.Inst.Index, |
| 2220 | 2229 | func_src: LazySrcLoc, |
| 2221 | 2230 | call_src: LazySrcLoc, |
| 2222 | 2231 | modifier: std.builtin.CallOptions.Modifier, |
| 2223 | 2232 | ensure_result_used: bool, |
| 2224 | | args: []const *ir.Inst, |
| 2225 | | ) InnerError!*ir.Inst { |
| 2233 | args: []const Air.Inst.Index, |
| 2234 | ) InnerError!Air.Inst.Index { |
| 2226 | 2235 | if (func.ty.zigTypeTag() != .Fn) |
| 2227 | 2236 | return sema.mod.fail(&block.base, func_src, "type '{}' not a function", .{func.ty}); |
| 2228 | 2237 | |
| ... | ... | @@ -2279,7 +2288,7 @@ fn analyzeCall( |
| 2279 | 2288 | const is_comptime_call = block.is_comptime or modifier == .compile_time; |
| 2280 | 2289 | const is_inline_call = is_comptime_call or modifier == .always_inline or |
| 2281 | 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 | 2292 | const func_val = try sema.resolveConstValue(block, func_src, func); |
| 2284 | 2293 | const module_fn = switch (func_val.tag()) { |
| 2285 | 2294 | .function => func_val.castTag(.function).?.data, |
| ... | ... | @@ -2377,7 +2386,7 @@ fn analyzeCall( |
| 2377 | 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 | 2390 | _ = block; |
| 2382 | 2391 | const tracy = trace(@src()); |
| 2383 | 2392 | defer tracy.end(); |
| ... | ... | @@ -2389,7 +2398,7 @@ fn zirIntType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 2389 | 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 | 2402 | const tracy = trace(@src()); |
| 2394 | 2403 | defer tracy.end(); |
| 2395 | 2404 | |
| ... | ... | @@ -2401,7 +2410,7 @@ fn zirOptionalType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2401 | 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 | 2414 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2406 | 2415 | const src = inst_data.src(); |
| 2407 | 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 | 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 | 2422 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 2414 | 2423 | const src = inst_data.src(); |
| 2415 | 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 | 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 | 2437 | const tracy = trace(@src()); |
| 2429 | 2438 | defer tracy.end(); |
| 2430 | 2439 | |
| ... | ... | @@ -2437,7 +2446,7 @@ fn zirArrayType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2437 | 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 | 2450 | const tracy = trace(@src()); |
| 2442 | 2451 | defer tracy.end(); |
| 2443 | 2452 | |
| ... | ... | @@ -2452,7 +2461,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) |
| 2452 | 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 | 2465 | const tracy = trace(@src()); |
| 2457 | 2466 | defer tracy.end(); |
| 2458 | 2467 | |
| ... | ... | @@ -2465,7 +2474,7 @@ fn zirAnyframeType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2465 | 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 | 2478 | const tracy = trace(@src()); |
| 2470 | 2479 | defer tracy.end(); |
| 2471 | 2480 | |
| ... | ... | @@ -2486,7 +2495,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inn |
| 2486 | 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 | 2499 | _ = block; |
| 2491 | 2500 | const tracy = trace(@src()); |
| 2492 | 2501 | defer tracy.end(); |
| ... | ... | @@ -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 | 2518 | const tracy = trace(@src()); |
| 2510 | 2519 | defer tracy.end(); |
| 2511 | 2520 | |
| ... | ... | @@ -2535,7 +2544,7 @@ fn zirErrorToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2535 | 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 | 2548 | const tracy = trace(@src()); |
| 2540 | 2549 | defer tracy.end(); |
| 2541 | 2550 | |
| ... | ... | @@ -2568,7 +2577,7 @@ fn zirIntToError(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 2568 | 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 | 2581 | const tracy = trace(@src()); |
| 2573 | 2582 | defer tracy.end(); |
| 2574 | 2583 | |
| ... | ... | @@ -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 | 2671 | _ = block; |
| 2663 | 2672 | const tracy = trace(@src()); |
| 2664 | 2673 | defer tracy.end(); |
| ... | ... | @@ -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 | 2685 | const mod = sema.mod; |
| 2677 | 2686 | const arena = sema.arena; |
| 2678 | 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 | 2689 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 2681 | 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 | 2693 | .Enum => operand, |
| 2685 | 2694 | .Union => { |
| 2686 | 2695 | //if (!operand.ty.unionHasTag()) { |
| ... | ... | @@ -2754,7 +2763,7 @@ fn zirEnumToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 2754 | 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 | 2767 | const mod = sema.mod; |
| 2759 | 2768 | const target = mod.getTarget(); |
| 2760 | 2769 | const arena = sema.arena; |
| ... | ... | @@ -2815,7 +2824,7 @@ fn zirOptionalPayloadPtr( |
| 2815 | 2824 | block: *Scope.Block, |
| 2816 | 2825 | inst: Zir.Inst.Index, |
| 2817 | 2826 | safety_check: bool, |
| 2818 | | ) InnerError!*Inst { |
| 2827 | ) InnerError!Air.Inst.Index { |
| 2819 | 2828 | const tracy = trace(@src()); |
| 2820 | 2829 | defer tracy.end(); |
| 2821 | 2830 | |
| ... | ... | @@ -2858,7 +2867,7 @@ fn zirOptionalPayload( |
| 2858 | 2867 | block: *Scope.Block, |
| 2859 | 2868 | inst: Zir.Inst.Index, |
| 2860 | 2869 | safety_check: bool, |
| 2861 | | ) InnerError!*Inst { |
| 2870 | ) InnerError!Air.Inst.Index { |
| 2862 | 2871 | const tracy = trace(@src()); |
| 2863 | 2872 | defer tracy.end(); |
| 2864 | 2873 | |
| ... | ... | @@ -2896,7 +2905,7 @@ fn zirErrUnionPayload( |
| 2896 | 2905 | block: *Scope.Block, |
| 2897 | 2906 | inst: Zir.Inst.Index, |
| 2898 | 2907 | safety_check: bool, |
| 2899 | | ) InnerError!*Inst { |
| 2908 | ) InnerError!Air.Inst.Index { |
| 2900 | 2909 | const tracy = trace(@src()); |
| 2901 | 2910 | defer tracy.end(); |
| 2902 | 2911 | |
| ... | ... | @@ -2930,7 +2939,7 @@ fn zirErrUnionPayloadPtr( |
| 2930 | 2939 | block: *Scope.Block, |
| 2931 | 2940 | inst: Zir.Inst.Index, |
| 2932 | 2941 | safety_check: bool, |
| 2933 | | ) InnerError!*Inst { |
| 2942 | ) InnerError!Air.Inst.Index { |
| 2934 | 2943 | const tracy = trace(@src()); |
| 2935 | 2944 | defer tracy.end(); |
| 2936 | 2945 | |
| ... | ... | @@ -2969,7 +2978,7 @@ fn zirErrUnionPayloadPtr( |
| 2969 | 2978 | } |
| 2970 | 2979 | |
| 2971 | 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 | 2982 | const tracy = trace(@src()); |
| 2974 | 2983 | defer tracy.end(); |
| 2975 | 2984 | |
| ... | ... | @@ -2995,7 +3004,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inner |
| 2995 | 3004 | } |
| 2996 | 3005 | |
| 2997 | 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 | 3008 | const tracy = trace(@src()); |
| 3000 | 3009 | defer tracy.end(); |
| 3001 | 3010 | |
| ... | ... | @@ -3042,7 +3051,7 @@ fn zirFunc( |
| 3042 | 3051 | block: *Scope.Block, |
| 3043 | 3052 | inst: Zir.Inst.Index, |
| 3044 | 3053 | inferred_error_set: bool, |
| 3045 | | ) InnerError!*Inst { |
| 3054 | ) InnerError!Air.Inst.Index { |
| 3046 | 3055 | const tracy = trace(@src()); |
| 3047 | 3056 | defer tracy.end(); |
| 3048 | 3057 | |
| ... | ... | @@ -3093,7 +3102,7 @@ fn funcCommon( |
| 3093 | 3102 | is_extern: bool, |
| 3094 | 3103 | src_locs: Zir.Inst.Func.SrcLocs, |
| 3095 | 3104 | opt_lib_name: ?[]const u8, |
| 3096 | | ) InnerError!*Inst { |
| 3105 | ) InnerError!Air.Inst.Index { |
| 3097 | 3106 | const src: LazySrcLoc = .{ .node_offset = src_node_offset }; |
| 3098 | 3107 | const ret_ty_src: LazySrcLoc = .{ .node_offset_fn_type_ret_ty = src_node_offset }; |
| 3099 | 3108 | const bare_return_type = try sema.resolveType(block, ret_ty_src, zir_return_type); |
| ... | ... | @@ -3234,7 +3243,7 @@ fn funcCommon( |
| 3234 | 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 | 3247 | const tracy = trace(@src()); |
| 3239 | 3248 | defer tracy.end(); |
| 3240 | 3249 | |
| ... | ... | @@ -3242,7 +3251,7 @@ fn zirAs(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*Ins |
| 3242 | 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 | 3255 | const tracy = trace(@src()); |
| 3247 | 3256 | defer tracy.end(); |
| 3248 | 3257 | |
| ... | ... | @@ -3258,13 +3267,13 @@ fn analyzeAs( |
| 3258 | 3267 | src: LazySrcLoc, |
| 3259 | 3268 | zir_dest_type: Zir.Inst.Ref, |
| 3260 | 3269 | zir_operand: Zir.Inst.Ref, |
| 3261 | | ) InnerError!*Inst { |
| 3270 | ) InnerError!Air.Inst.Index { |
| 3262 | 3271 | const dest_type = try sema.resolveType(block, src, zir_dest_type); |
| 3263 | 3272 | const operand = try sema.resolveInst(zir_operand); |
| 3264 | 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 | 3277 | const tracy = trace(@src()); |
| 3269 | 3278 | defer tracy.end(); |
| 3270 | 3279 | |
| ... | ... | @@ -3281,7 +3290,7 @@ fn zirPtrToInt(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3281 | 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 | 3294 | const tracy = trace(@src()); |
| 3286 | 3295 | defer tracy.end(); |
| 3287 | 3296 | |
| ... | ... | @@ -3299,7 +3308,7 @@ fn zirFieldVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3299 | 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 | 3312 | const tracy = trace(@src()); |
| 3304 | 3313 | defer tracy.end(); |
| 3305 | 3314 | |
| ... | ... | @@ -3312,7 +3321,7 @@ fn zirFieldPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3312 | 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 | 3325 | const tracy = trace(@src()); |
| 3317 | 3326 | defer tracy.end(); |
| 3318 | 3327 | |
| ... | ... | @@ -3327,7 +3336,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3327 | 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 | 3340 | const tracy = trace(@src()); |
| 3332 | 3341 | defer tracy.end(); |
| 3333 | 3342 | |
| ... | ... | @@ -3340,7 +3349,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 3340 | 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 | 3353 | const tracy = trace(@src()); |
| 3345 | 3354 | defer tracy.end(); |
| 3346 | 3355 | |
| ... | ... | @@ -3383,7 +3392,7 @@ fn zirIntCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3383 | 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 | 3396 | const tracy = trace(@src()); |
| 3388 | 3397 | defer tracy.end(); |
| 3389 | 3398 | |
| ... | ... | @@ -3396,7 +3405,7 @@ fn zirBitcast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3396 | 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 | 3409 | const tracy = trace(@src()); |
| 3401 | 3410 | defer tracy.end(); |
| 3402 | 3411 | |
| ... | ... | @@ -3439,7 +3448,7 @@ fn zirFloatCast(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErr |
| 3439 | 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 | 3452 | const tracy = trace(@src()); |
| 3444 | 3453 | defer tracy.end(); |
| 3445 | 3454 | |
| ... | ... | @@ -3454,7 +3463,7 @@ fn zirElemVal(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3454 | 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 | 3467 | const tracy = trace(@src()); |
| 3459 | 3468 | defer tracy.end(); |
| 3460 | 3469 | |
| ... | ... | @@ -3472,7 +3481,7 @@ fn zirElemValNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 3472 | 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 | 3485 | const tracy = trace(@src()); |
| 3477 | 3486 | defer tracy.end(); |
| 3478 | 3487 | |
| ... | ... | @@ -3482,7 +3491,7 @@ fn zirElemPtr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 3482 | 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 | 3495 | const tracy = trace(@src()); |
| 3487 | 3496 | defer tracy.end(); |
| 3488 | 3497 | |
| ... | ... | @@ -3495,7 +3504,7 @@ fn zirElemPtrNode(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerE |
| 3495 | 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 | 3508 | const tracy = trace(@src()); |
| 3500 | 3509 | defer tracy.end(); |
| 3501 | 3510 | |
| ... | ... | @@ -3508,7 +3517,7 @@ fn zirSliceStart(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 3508 | 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 | 3521 | const tracy = trace(@src()); |
| 3513 | 3522 | defer tracy.end(); |
| 3514 | 3523 | |
| ... | ... | @@ -3522,7 +3531,7 @@ fn zirSliceEnd(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 3522 | 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 | 3535 | const tracy = trace(@src()); |
| 3527 | 3536 | defer tracy.end(); |
| 3528 | 3537 | |
| ... | ... | @@ -3544,7 +3553,7 @@ fn zirSwitchCapture( |
| 3544 | 3553 | inst: Zir.Inst.Index, |
| 3545 | 3554 | is_multi: bool, |
| 3546 | 3555 | is_ref: bool, |
| 3547 | | ) InnerError!*Inst { |
| 3556 | ) InnerError!Air.Inst.Index { |
| 3548 | 3557 | const tracy = trace(@src()); |
| 3549 | 3558 | defer tracy.end(); |
| 3550 | 3559 | |
| ... | ... | @@ -3563,7 +3572,7 @@ fn zirSwitchCaptureElse( |
| 3563 | 3572 | block: *Scope.Block, |
| 3564 | 3573 | inst: Zir.Inst.Index, |
| 3565 | 3574 | is_ref: bool, |
| 3566 | | ) InnerError!*Inst { |
| 3575 | ) InnerError!Air.Inst.Index { |
| 3567 | 3576 | const tracy = trace(@src()); |
| 3568 | 3577 | defer tracy.end(); |
| 3569 | 3578 | |
| ... | ... | @@ -3582,7 +3591,7 @@ fn zirSwitchBlock( |
| 3582 | 3591 | inst: Zir.Inst.Index, |
| 3583 | 3592 | is_ref: bool, |
| 3584 | 3593 | special_prong: Zir.SpecialProng, |
| 3585 | | ) InnerError!*Inst { |
| 3594 | ) InnerError!Air.Inst.Index { |
| 3586 | 3595 | const tracy = trace(@src()); |
| 3587 | 3596 | defer tracy.end(); |
| 3588 | 3597 | |
| ... | ... | @@ -3615,7 +3624,7 @@ fn zirSwitchBlockMulti( |
| 3615 | 3624 | inst: Zir.Inst.Index, |
| 3616 | 3625 | is_ref: bool, |
| 3617 | 3626 | special_prong: Zir.SpecialProng, |
| 3618 | | ) InnerError!*Inst { |
| 3627 | ) InnerError!Air.Inst.Index { |
| 3619 | 3628 | const tracy = trace(@src()); |
| 3620 | 3629 | defer tracy.end(); |
| 3621 | 3630 | |
| ... | ... | @@ -3645,14 +3654,14 @@ fn zirSwitchBlockMulti( |
| 3645 | 3654 | fn analyzeSwitch( |
| 3646 | 3655 | sema: *Sema, |
| 3647 | 3656 | block: *Scope.Block, |
| 3648 | | operand: *Inst, |
| 3657 | operand: Air.Inst.Index, |
| 3649 | 3658 | extra_end: usize, |
| 3650 | 3659 | special_prong: Zir.SpecialProng, |
| 3651 | 3660 | scalar_cases_len: usize, |
| 3652 | 3661 | multi_cases_len: usize, |
| 3653 | 3662 | switch_inst: Zir.Inst.Index, |
| 3654 | 3663 | src_node_offset: i32, |
| 3655 | | ) InnerError!*Inst { |
| 3664 | ) InnerError!Air.Inst.Index { |
| 3656 | 3665 | const gpa = sema.gpa; |
| 3657 | 3666 | const mod = sema.mod; |
| 3658 | 3667 | |
| ... | ... | @@ -4187,7 +4196,7 @@ fn analyzeSwitch( |
| 4187 | 4196 | |
| 4188 | 4197 | cases[scalar_i] = .{ |
| 4189 | 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 | 4216 | |
| 4208 | 4217 | case_block.instructions.shrinkRetainingCapacity(0); |
| 4209 | 4218 | |
| 4210 | | var any_ok: ?*Inst = null; |
| 4219 | var any_ok: ?Air.Inst.Index = null; |
| 4211 | 4220 | const bool_ty = comptime Type.initTag(.bool); |
| 4212 | 4221 | |
| 4213 | 4222 | for (items) |item_ref| { |
| ... | ... | @@ -4280,7 +4289,7 @@ fn analyzeSwitch( |
| 4280 | 4289 | try case_block.instructions.append(gpa, &new_condbr.base); |
| 4281 | 4290 | |
| 4282 | 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 | 4295 | case_block.instructions.shrinkRetainingCapacity(0); |
| ... | ... | @@ -4288,7 +4297,7 @@ fn analyzeSwitch( |
| 4288 | 4297 | extra_index += body_len; |
| 4289 | 4298 | _ = try sema.analyzeBody(&case_block, body); |
| 4290 | 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 | 4302 | if (prev_condbr) |condbr| { |
| 4294 | 4303 | condbr.else_body = cond_body; |
| ... | ... | @@ -4303,7 +4312,7 @@ fn analyzeSwitch( |
| 4303 | 4312 | case_block.instructions.shrinkRetainingCapacity(0); |
| 4304 | 4313 | _ = try sema.analyzeBody(&case_block, special.body); |
| 4305 | 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 | 4317 | if (prev_condbr) |condbr| { |
| 4309 | 4318 | condbr.else_body = else_body; |
| ... | ... | @@ -4507,7 +4516,7 @@ fn validateSwitchNoRange( |
| 4507 | 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 | 4520 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4512 | 4521 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4513 | 4522 | _ = extra; |
| ... | ... | @@ -4516,7 +4525,7 @@ fn zirHasField(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 4516 | 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 | 4529 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 4521 | 4530 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 4522 | 4531 | const src = inst_data.src(); |
| ... | ... | @@ -4541,7 +4550,7 @@ fn zirHasDecl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 4541 | 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 | 4554 | const tracy = trace(@src()); |
| 4546 | 4555 | defer tracy.end(); |
| 4547 | 4556 | |
| ... | ... | @@ -4566,13 +4575,13 @@ fn zirImport(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4566 | 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 | 4579 | _ = block; |
| 4571 | 4580 | _ = inst; |
| 4572 | 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 | 4585 | const tracy = trace(@src()); |
| 4577 | 4586 | defer tracy.end(); |
| 4578 | 4587 | |
| ... | ... | @@ -4581,7 +4590,7 @@ fn zirShl(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError!*In |
| 4581 | 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 | 4594 | const tracy = trace(@src()); |
| 4586 | 4595 | defer tracy.end(); |
| 4587 | 4596 | |
| ... | ... | @@ -4594,7 +4603,7 @@ fn zirBitwise( |
| 4594 | 4603 | block: *Scope.Block, |
| 4595 | 4604 | inst: Zir.Inst.Index, |
| 4596 | 4605 | ir_tag: ir.Inst.Tag, |
| 4597 | | ) InnerError!*Inst { |
| 4606 | ) InnerError!Air.Inst.Index { |
| 4598 | 4607 | const tracy = trace(@src()); |
| 4599 | 4608 | defer tracy.end(); |
| 4600 | 4609 | |
| ... | ... | @@ -4606,7 +4615,7 @@ fn zirBitwise( |
| 4606 | 4615 | const lhs = try sema.resolveInst(extra.lhs); |
| 4607 | 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 | 4619 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 4611 | 4620 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| 4612 | 4621 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| ... | ... | @@ -4652,7 +4661,7 @@ fn zirBitwise( |
| 4652 | 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 | 4665 | const tracy = trace(@src()); |
| 4657 | 4666 | defer tracy.end(); |
| 4658 | 4667 | |
| ... | ... | @@ -4660,7 +4669,7 @@ fn zirBitNot(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError! |
| 4660 | 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 | 4673 | const tracy = trace(@src()); |
| 4665 | 4674 | defer tracy.end(); |
| 4666 | 4675 | |
| ... | ... | @@ -4668,7 +4677,7 @@ fn zirArrayCat(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 4668 | 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 | 4681 | const tracy = trace(@src()); |
| 4673 | 4682 | defer tracy.end(); |
| 4674 | 4683 | |
| ... | ... | @@ -4681,7 +4690,7 @@ fn zirNegate( |
| 4681 | 4690 | block: *Scope.Block, |
| 4682 | 4691 | inst: Zir.Inst.Index, |
| 4683 | 4692 | tag_override: Zir.Inst.Tag, |
| 4684 | | ) InnerError!*Inst { |
| 4693 | ) InnerError!Air.Inst.Index { |
| 4685 | 4694 | const tracy = trace(@src()); |
| 4686 | 4695 | defer tracy.end(); |
| 4687 | 4696 | |
| ... | ... | @@ -4695,7 +4704,7 @@ fn zirNegate( |
| 4695 | 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 | 4708 | const tracy = trace(@src()); |
| 4700 | 4709 | defer tracy.end(); |
| 4701 | 4710 | |
| ... | ... | @@ -4715,7 +4724,7 @@ fn zirOverflowArithmetic( |
| 4715 | 4724 | sema: *Sema, |
| 4716 | 4725 | block: *Scope.Block, |
| 4717 | 4726 | extended: Zir.Inst.Extended.InstData, |
| 4718 | | ) InnerError!*Inst { |
| 4727 | ) InnerError!Air.Inst.Index { |
| 4719 | 4728 | const tracy = trace(@src()); |
| 4720 | 4729 | defer tracy.end(); |
| 4721 | 4730 | |
| ... | ... | @@ -4729,13 +4738,13 @@ fn analyzeArithmetic( |
| 4729 | 4738 | sema: *Sema, |
| 4730 | 4739 | block: *Scope.Block, |
| 4731 | 4740 | zir_tag: Zir.Inst.Tag, |
| 4732 | | lhs: *Inst, |
| 4733 | | rhs: *Inst, |
| 4741 | lhs: Air.Inst.Index, |
| 4742 | rhs: Air.Inst.Index, |
| 4734 | 4743 | src: LazySrcLoc, |
| 4735 | 4744 | lhs_src: LazySrcLoc, |
| 4736 | 4745 | rhs_src: LazySrcLoc, |
| 4737 | | ) InnerError!*Inst { |
| 4738 | | const instructions = &[_]*Inst{ lhs, rhs }; |
| 4746 | ) InnerError!Air.Inst.Index { |
| 4747 | const instructions = &[_]Air.Inst.Index{ lhs, rhs }; |
| 4739 | 4748 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 4740 | 4749 | const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src); |
| 4741 | 4750 | const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src); |
| ... | ... | @@ -4844,7 +4853,7 @@ fn analyzeArithmetic( |
| 4844 | 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 | 4857 | const tracy = trace(@src()); |
| 4849 | 4858 | defer tracy.end(); |
| 4850 | 4859 | |
| ... | ... | @@ -4859,7 +4868,7 @@ fn zirAsm( |
| 4859 | 4868 | sema: *Sema, |
| 4860 | 4869 | block: *Scope.Block, |
| 4861 | 4870 | extended: Zir.Inst.Extended.InstData, |
| 4862 | | ) InnerError!*Inst { |
| 4871 | ) InnerError!Air.Inst.Index { |
| 4863 | 4872 | const tracy = trace(@src()); |
| 4864 | 4873 | defer tracy.end(); |
| 4865 | 4874 | |
| ... | ... | @@ -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 | 4912 | const inputs = try sema.arena.alloc([]const u8, inputs_len); |
| 4904 | 4913 | |
| 4905 | 4914 | for (args) |*arg, arg_i| { |
| ... | ... | @@ -4943,7 +4952,7 @@ fn zirCmp( |
| 4943 | 4952 | block: *Scope.Block, |
| 4944 | 4953 | inst: Zir.Inst.Index, |
| 4945 | 4954 | op: std.math.CompareOperator, |
| 4946 | | ) InnerError!*Inst { |
| 4955 | ) InnerError!Air.Inst.Index { |
| 4947 | 4956 | const tracy = trace(@src()); |
| 4948 | 4957 | defer tracy.end(); |
| 4949 | 4958 | |
| ... | ... | @@ -5009,7 +5018,7 @@ fn zirCmp( |
| 5009 | 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 | 5022 | const resolved_type = try sema.resolvePeerTypes(block, src, instructions); |
| 5014 | 5023 | if (!resolved_type.isSelfComparable(is_equality_cmp)) { |
| 5015 | 5024 | return mod.fail(&block.base, src, "operator not allowed for type '{}'", .{resolved_type}); |
| ... | ... | @@ -5041,7 +5050,7 @@ fn zirCmp( |
| 5041 | 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 | 5054 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5046 | 5055 | const src = inst_data.src(); |
| 5047 | 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 | 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 | 5064 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5056 | 5065 | const src = inst_data.src(); |
| 5057 | 5066 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | ... | @@ -5065,7 +5074,7 @@ fn zirThis( |
| 5065 | 5074 | sema: *Sema, |
| 5066 | 5075 | block: *Scope.Block, |
| 5067 | 5076 | extended: Zir.Inst.Extended.InstData, |
| 5068 | | ) InnerError!*Inst { |
| 5077 | ) InnerError!Air.Inst.Index { |
| 5069 | 5078 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5070 | 5079 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirThis", .{}); |
| 5071 | 5080 | } |
| ... | ... | @@ -5074,7 +5083,7 @@ fn zirRetAddr( |
| 5074 | 5083 | sema: *Sema, |
| 5075 | 5084 | block: *Scope.Block, |
| 5076 | 5085 | extended: Zir.Inst.Extended.InstData, |
| 5077 | | ) InnerError!*Inst { |
| 5086 | ) InnerError!Air.Inst.Index { |
| 5078 | 5087 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5079 | 5088 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirRetAddr", .{}); |
| 5080 | 5089 | } |
| ... | ... | @@ -5083,12 +5092,12 @@ fn zirBuiltinSrc( |
| 5083 | 5092 | sema: *Sema, |
| 5084 | 5093 | block: *Scope.Block, |
| 5085 | 5094 | extended: Zir.Inst.Extended.InstData, |
| 5086 | | ) InnerError!*Inst { |
| 5095 | ) InnerError!Air.Inst.Index { |
| 5087 | 5096 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5088 | 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 | 5101 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5093 | 5102 | const src = inst_data.src(); |
| 5094 | 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 | 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 | 5144 | _ = block; |
| 5136 | 5145 | const zir_datas = sema.code.instructions.items(.data); |
| 5137 | 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 | 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 | 5153 | _ = block; |
| 5145 | 5154 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5146 | 5155 | const src = inst_data.src(); |
| ... | ... | @@ -5149,13 +5158,13 @@ fn zirTypeofElem(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerEr |
| 5149 | 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 | 5162 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5154 | 5163 | const src = inst_data.src(); |
| 5155 | 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 | 5168 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5160 | 5169 | const src = inst_data.src(); |
| 5161 | 5170 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirLog2IntType", .{}); |
| ... | ... | @@ -5165,7 +5174,7 @@ fn zirTypeofPeer( |
| 5165 | 5174 | sema: *Sema, |
| 5166 | 5175 | block: *Scope.Block, |
| 5167 | 5176 | extended: Zir.Inst.Extended.InstData, |
| 5168 | | ) InnerError!*Inst { |
| 5177 | ) InnerError!Air.Inst.Index { |
| 5169 | 5178 | const tracy = trace(@src()); |
| 5170 | 5179 | defer tracy.end(); |
| 5171 | 5180 | |
| ... | ... | @@ -5173,7 +5182,7 @@ fn zirTypeofPeer( |
| 5173 | 5182 | const src: LazySrcLoc = .{ .node_offset = extra.data.src_node }; |
| 5174 | 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 | 5186 | defer sema.gpa.free(inst_list); |
| 5178 | 5187 | |
| 5179 | 5188 | for (args) |arg_ref, i| { |
| ... | ... | @@ -5184,7 +5193,7 @@ fn zirTypeofPeer( |
| 5184 | 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 | 5197 | const tracy = trace(@src()); |
| 5189 | 5198 | defer tracy.end(); |
| 5190 | 5199 | |
| ... | ... | @@ -5206,7 +5215,7 @@ fn zirBoolOp( |
| 5206 | 5215 | block: *Scope.Block, |
| 5207 | 5216 | inst: Zir.Inst.Index, |
| 5208 | 5217 | comptime is_bool_or: bool, |
| 5209 | | ) InnerError!*Inst { |
| 5218 | ) InnerError!Air.Inst.Index { |
| 5210 | 5219 | const tracy = trace(@src()); |
| 5211 | 5220 | defer tracy.end(); |
| 5212 | 5221 | |
| ... | ... | @@ -5237,7 +5246,7 @@ fn zirBoolBr( |
| 5237 | 5246 | parent_block: *Scope.Block, |
| 5238 | 5247 | inst: Zir.Inst.Index, |
| 5239 | 5248 | is_bool_or: bool, |
| 5240 | | ) InnerError!*Inst { |
| 5249 | ) InnerError!Air.Inst.Index { |
| 5241 | 5250 | const tracy = trace(@src()); |
| 5242 | 5251 | defer tracy.end(); |
| 5243 | 5252 | |
| ... | ... | @@ -5292,12 +5301,12 @@ fn zirBoolBr( |
| 5292 | 5301 | const rhs_result = try sema.resolveBody(rhs_block, body); |
| 5293 | 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) }; |
| 5296 | | const air_else_body: ir.Body = .{ .instructions = try sema.arena.dupe(*Inst, else_block.instructions.items) }; |
| 5304 | const air_then_body: ir.Body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, then_block.instructions.items) }; |
| 5305 | const air_else_body: ir.Body = .{ .instructions = try sema.arena.dupe(Air.Inst.Index, else_block.instructions.items) }; |
| 5297 | 5306 | _ = try child_block.addCondBr(src, lhs, air_then_body, air_else_body); |
| 5298 | 5307 | |
| 5299 | 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 | 5311 | try parent_block.instructions.append(sema.gpa, &block_inst.base); |
| 5303 | 5312 | return &block_inst.base; |
| ... | ... | @@ -5307,7 +5316,7 @@ fn zirIsNonNull( |
| 5307 | 5316 | sema: *Sema, |
| 5308 | 5317 | block: *Scope.Block, |
| 5309 | 5318 | inst: Zir.Inst.Index, |
| 5310 | | ) InnerError!*Inst { |
| 5319 | ) InnerError!Air.Inst.Index { |
| 5311 | 5320 | const tracy = trace(@src()); |
| 5312 | 5321 | defer tracy.end(); |
| 5313 | 5322 | |
| ... | ... | @@ -5321,7 +5330,7 @@ fn zirIsNonNullPtr( |
| 5321 | 5330 | sema: *Sema, |
| 5322 | 5331 | block: *Scope.Block, |
| 5323 | 5332 | inst: Zir.Inst.Index, |
| 5324 | | ) InnerError!*Inst { |
| 5333 | ) InnerError!Air.Inst.Index { |
| 5325 | 5334 | const tracy = trace(@src()); |
| 5326 | 5335 | defer tracy.end(); |
| 5327 | 5336 | |
| ... | ... | @@ -5332,7 +5341,7 @@ fn zirIsNonNullPtr( |
| 5332 | 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 | 5345 | const tracy = trace(@src()); |
| 5337 | 5346 | defer tracy.end(); |
| 5338 | 5347 | |
| ... | ... | @@ -5341,7 +5350,7 @@ fn zirIsNonErr(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerErro |
| 5341 | 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 | 5354 | const tracy = trace(@src()); |
| 5346 | 5355 | defer tracy.end(); |
| 5347 | 5356 | |
| ... | ... | @@ -5385,14 +5394,14 @@ fn zirCondbr( |
| 5385 | 5394 | |
| 5386 | 5395 | _ = try sema.analyzeBody(&sub_block, then_body); |
| 5387 | 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 | 5400 | sub_block.instructions.shrinkRetainingCapacity(0); |
| 5392 | 5401 | |
| 5393 | 5402 | _ = try sema.analyzeBody(&sub_block, else_body); |
| 5394 | 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 | 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 | 5479 | fn analyzeRet( |
| 5471 | 5480 | sema: *Sema, |
| 5472 | 5481 | block: *Scope.Block, |
| 5473 | | operand: *Inst, |
| 5482 | operand: Air.Inst.Index, |
| 5474 | 5483 | src: LazySrcLoc, |
| 5475 | 5484 | need_coercion: bool, |
| 5476 | 5485 | ) InnerError!Zir.Inst.Index { |
| ... | ... | @@ -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 | 5518 | const tracy = trace(@src()); |
| 5510 | 5519 | defer tracy.end(); |
| 5511 | 5520 | |
| ... | ... | @@ -5526,7 +5535,7 @@ fn zirPtrTypeSimple(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) Inne |
| 5526 | 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 | 5539 | const tracy = trace(@src()); |
| 5531 | 5540 | defer tracy.end(); |
| 5532 | 5541 | |
| ... | ... | @@ -5580,7 +5589,7 @@ fn zirPtrType(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index) InnerError |
| 5580 | 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 | 5593 | const tracy = trace(@src()); |
| 5585 | 5594 | defer tracy.end(); |
| 5586 | 5595 | |
| ... | ... | @@ -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 | 5607 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5599 | 5608 | const src = inst_data.src(); |
| 5600 | 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 | 5613 | const mod = sema.mod; |
| 5605 | 5614 | const gpa = sema.gpa; |
| 5606 | 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 | 5631 | mem.set(Zir.Inst.Index, found_fields, 0); |
| 5623 | 5632 | |
| 5624 | 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 | 5635 | defer gpa.free(field_inits); |
| 5627 | 5636 | |
| 5628 | 5637 | var field_i: u32 = 0; |
| ... | ... | @@ -5713,7 +5722,7 @@ fn zirStructInit(sema: *Sema, block: *Scope.Block, inst: Zir.Inst.Index, is_ref: |
| 5713 | 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 | 5726 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5718 | 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 | 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 | 5734 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5726 | 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 | 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 | 5742 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5734 | 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 | 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 | 5750 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5742 | 5751 | const src = inst_data.src(); |
| 5743 | 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 | 5756 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5748 | 5757 | const extra = sema.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; |
| 5749 | 5758 | const src = inst_data.src(); |
| ... | ... | @@ -5765,7 +5774,7 @@ fn zirErrorReturnTrace( |
| 5765 | 5774 | sema: *Sema, |
| 5766 | 5775 | block: *Scope.Block, |
| 5767 | 5776 | extended: Zir.Inst.Extended.InstData, |
| 5768 | | ) InnerError!*Inst { |
| 5777 | ) InnerError!Air.Inst.Index { |
| 5769 | 5778 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5770 | 5779 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirErrorReturnTrace", .{}); |
| 5771 | 5780 | } |
| ... | ... | @@ -5774,7 +5783,7 @@ fn zirFrame( |
| 5774 | 5783 | sema: *Sema, |
| 5775 | 5784 | block: *Scope.Block, |
| 5776 | 5785 | extended: Zir.Inst.Extended.InstData, |
| 5777 | | ) InnerError!*Inst { |
| 5786 | ) InnerError!Air.Inst.Index { |
| 5778 | 5787 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5779 | 5788 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirFrame", .{}); |
| 5780 | 5789 | } |
| ... | ... | @@ -5783,84 +5792,84 @@ fn zirFrameAddress( |
| 5783 | 5792 | sema: *Sema, |
| 5784 | 5793 | block: *Scope.Block, |
| 5785 | 5794 | extended: Zir.Inst.Extended.InstData, |
| 5786 | | ) InnerError!*Inst { |
| 5795 | ) InnerError!Air.Inst.Index { |
| 5787 | 5796 | const src: LazySrcLoc = .{ .node_offset = @bitCast(i32, extended.operand) }; |
| 5788 | 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 | 5801 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5793 | 5802 | const src = inst_data.src(); |
| 5794 | 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 | 5807 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5799 | 5808 | const src = inst_data.src(); |
| 5800 | 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 | 5813 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5805 | 5814 | const src = inst_data.src(); |
| 5806 | 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 | 5819 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5811 | 5820 | const src = inst_data.src(); |
| 5812 | 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 | 5825 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5817 | 5826 | const src = inst_data.src(); |
| 5818 | 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 | 5831 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5823 | 5832 | const src = inst_data.src(); |
| 5824 | 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 | 5837 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5829 | 5838 | const src = inst_data.src(); |
| 5830 | 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 | 5843 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5835 | 5844 | const src = inst_data.src(); |
| 5836 | 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 | 5849 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5841 | 5850 | const src = inst_data.src(); |
| 5842 | 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 | 5855 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5847 | 5856 | const src = inst_data.src(); |
| 5848 | 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 | 5861 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5853 | 5862 | const src = inst_data.src(); |
| 5854 | 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 | 5867 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5859 | 5868 | const src = inst_data.src(); |
| 5860 | 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 | 5873 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5865 | 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 | 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 | 5936 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5928 | 5937 | const src = inst_data.src(); |
| 5929 | 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 | 5942 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5934 | 5943 | const src = inst_data.src(); |
| 5935 | 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 | 5948 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5940 | 5949 | const src = inst_data.src(); |
| 5941 | 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 | 5954 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5946 | 5955 | const src = inst_data.src(); |
| 5947 | 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 | 5960 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5952 | 5961 | const src = inst_data.src(); |
| 5953 | 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 | 5966 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5958 | 5967 | const src = inst_data.src(); |
| 5959 | 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 | 5972 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5964 | 5973 | const src = inst_data.src(); |
| 5965 | 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 | 5978 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5970 | 5979 | const src = inst_data.src(); |
| 5971 | 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 | 5984 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5976 | 5985 | const src = inst_data.src(); |
| 5977 | 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 | 5990 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5982 | 5991 | const src = inst_data.src(); |
| 5983 | 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 | 5996 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5988 | 5997 | const src = inst_data.src(); |
| 5989 | 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 | 6002 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 5994 | 6003 | const src = inst_data.src(); |
| 5995 | 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 | 6008 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6000 | 6009 | const src = inst_data.src(); |
| 6001 | 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 | 6014 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6006 | 6015 | const src = inst_data.src(); |
| 6007 | 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 | 6020 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6012 | 6021 | const src = inst_data.src(); |
| 6013 | 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 | 6026 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6018 | 6027 | const src = inst_data.src(); |
| 6019 | 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 | 6032 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6024 | 6033 | const src = inst_data.src(); |
| 6025 | 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 | 6038 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6030 | 6039 | const src = inst_data.src(); |
| 6031 | 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 | 6044 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6036 | 6045 | const src = inst_data.src(); |
| 6037 | 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 | 6050 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6042 | 6051 | const src = inst_data.src(); |
| 6043 | 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 | 6056 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6048 | 6057 | const src = inst_data.src(); |
| 6049 | 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 | 6062 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6054 | 6063 | const src = inst_data.src(); |
| 6055 | 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 | 6068 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6060 | 6069 | const src = inst_data.src(); |
| 6061 | 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 | 6074 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6066 | 6075 | const src = inst_data.src(); |
| 6067 | 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 | 6080 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6072 | 6081 | const src = inst_data.src(); |
| 6073 | 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 | 6086 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6078 | 6087 | const src = inst_data.src(); |
| 6079 | 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 | 6092 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6084 | 6093 | const src = inst_data.src(); |
| 6085 | 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 | 6098 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6090 | 6099 | const src = inst_data.src(); |
| 6091 | 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 | 6104 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6096 | 6105 | const src = inst_data.src(); |
| 6097 | 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 | 6110 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6102 | 6111 | const src = inst_data.src(); |
| 6103 | 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 | 6116 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6108 | 6117 | const src = inst_data.src(); |
| 6109 | 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 | 6122 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 6114 | 6123 | const src = inst_data.src(); |
| 6115 | 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 | 6128 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6120 | 6129 | const src = inst_data.src(); |
| 6121 | 6130 | return sema.mod.fail(&block.base, src, "TODO: Sema.zirResume", .{}); |
| ... | ... | @@ -6126,7 +6135,7 @@ fn zirAwait( |
| 6126 | 6135 | block: *Scope.Block, |
| 6127 | 6136 | inst: Zir.Inst.Index, |
| 6128 | 6137 | is_nosuspend: bool, |
| 6129 | | ) InnerError!*Inst { |
| 6138 | ) InnerError!Air.Inst.Index { |
| 6130 | 6139 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6131 | 6140 | const src = inst_data.src(); |
| 6132 | 6141 | |
| ... | ... | @@ -6138,7 +6147,7 @@ fn zirVarExtended( |
| 6138 | 6147 | sema: *Sema, |
| 6139 | 6148 | block: *Scope.Block, |
| 6140 | 6149 | extended: Zir.Inst.Extended.InstData, |
| 6141 | | ) InnerError!*Inst { |
| 6150 | ) InnerError!Air.Inst.Index { |
| 6142 | 6151 | const extra = sema.code.extraData(Zir.Inst.ExtendedVar, extended.operand); |
| 6143 | 6152 | const src = sema.src; |
| 6144 | 6153 | const ty_src: LazySrcLoc = src; // TODO add a LazySrcLoc that points at type |
| ... | ... | @@ -6204,7 +6213,7 @@ fn zirFuncExtended( |
| 6204 | 6213 | block: *Scope.Block, |
| 6205 | 6214 | extended: Zir.Inst.Extended.InstData, |
| 6206 | 6215 | inst: Zir.Inst.Index, |
| 6207 | | ) InnerError!*Inst { |
| 6216 | ) InnerError!Air.Inst.Index { |
| 6208 | 6217 | const tracy = trace(@src()); |
| 6209 | 6218 | defer tracy.end(); |
| 6210 | 6219 | |
| ... | ... | @@ -6271,7 +6280,7 @@ fn zirCUndef( |
| 6271 | 6280 | sema: *Sema, |
| 6272 | 6281 | block: *Scope.Block, |
| 6273 | 6282 | extended: Zir.Inst.Extended.InstData, |
| 6274 | | ) InnerError!*Inst { |
| 6283 | ) InnerError!Air.Inst.Index { |
| 6275 | 6284 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6276 | 6285 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6277 | 6286 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCUndef", .{}); |
| ... | ... | @@ -6281,7 +6290,7 @@ fn zirCInclude( |
| 6281 | 6290 | sema: *Sema, |
| 6282 | 6291 | block: *Scope.Block, |
| 6283 | 6292 | extended: Zir.Inst.Extended.InstData, |
| 6284 | | ) InnerError!*Inst { |
| 6293 | ) InnerError!Air.Inst.Index { |
| 6285 | 6294 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6286 | 6295 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6287 | 6296 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCInclude", .{}); |
| ... | ... | @@ -6291,7 +6300,7 @@ fn zirCDefine( |
| 6291 | 6300 | sema: *Sema, |
| 6292 | 6301 | block: *Scope.Block, |
| 6293 | 6302 | extended: Zir.Inst.Extended.InstData, |
| 6294 | | ) InnerError!*Inst { |
| 6303 | ) InnerError!Air.Inst.Index { |
| 6295 | 6304 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6296 | 6305 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6297 | 6306 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirCDefine", .{}); |
| ... | ... | @@ -6301,7 +6310,7 @@ fn zirWasmMemorySize( |
| 6301 | 6310 | sema: *Sema, |
| 6302 | 6311 | block: *Scope.Block, |
| 6303 | 6312 | extended: Zir.Inst.Extended.InstData, |
| 6304 | | ) InnerError!*Inst { |
| 6313 | ) InnerError!Air.Inst.Index { |
| 6305 | 6314 | const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| 6306 | 6315 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6307 | 6316 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemorySize", .{}); |
| ... | ... | @@ -6311,7 +6320,7 @@ fn zirWasmMemoryGrow( |
| 6311 | 6320 | sema: *Sema, |
| 6312 | 6321 | block: *Scope.Block, |
| 6313 | 6322 | extended: Zir.Inst.Extended.InstData, |
| 6314 | | ) InnerError!*Inst { |
| 6323 | ) InnerError!Air.Inst.Index { |
| 6315 | 6324 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6316 | 6325 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6317 | 6326 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirWasmMemoryGrow", .{}); |
| ... | ... | @@ -6321,7 +6330,7 @@ fn zirBuiltinExtern( |
| 6321 | 6330 | sema: *Sema, |
| 6322 | 6331 | block: *Scope.Block, |
| 6323 | 6332 | extended: Zir.Inst.Extended.InstData, |
| 6324 | | ) InnerError!*Inst { |
| 6333 | ) InnerError!Air.Inst.Index { |
| 6325 | 6334 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 6326 | 6335 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 6327 | 6336 | return sema.mod.fail(&block.base, src, "TODO: implement Sema.zirBuiltinExtern", .{}); |
| ... | ... | @@ -6355,7 +6364,7 @@ pub const PanicId = enum { |
| 6355 | 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 | 6368 | const block_inst = try sema.arena.create(Inst.Block); |
| 6360 | 6369 | block_inst.* = .{ |
| 6361 | 6370 | .base = .{ |
| ... | ... | @@ -6364,12 +6373,12 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 6364 | 6373 | .src = ok.src, |
| 6365 | 6374 | }, |
| 6366 | 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 | 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 | 6383 | const br_void = try sema.arena.create(Inst.BrVoid); |
| 6375 | 6384 | br_void.* = .{ |
| ... | ... | @@ -6395,7 +6404,7 @@ fn addSafetyCheck(sema: *Sema, parent_block: *Scope.Block, ok: *Inst, panic_id: |
| 6395 | 6404 | |
| 6396 | 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 | 6409 | const condbr = try sema.arena.create(Inst.CondBr); |
| 6401 | 6410 | condbr.* = .{ |
| ... | ... | @@ -6417,7 +6426,7 @@ fn panicWithMsg( |
| 6417 | 6426 | sema: *Sema, |
| 6418 | 6427 | block: *Scope.Block, |
| 6419 | 6428 | src: LazySrcLoc, |
| 6420 | | msg_inst: *ir.Inst, |
| 6429 | msg_inst: Air.Inst.Index, |
| 6421 | 6430 | ) !Zir.Inst.Index { |
| 6422 | 6431 | const mod = sema.mod; |
| 6423 | 6432 | const arena = sema.arena; |
| ... | ... | @@ -6438,7 +6447,7 @@ fn panicWithMsg( |
| 6438 | 6447 | .ty = try mod.optionalType(arena, ptr_stack_trace_ty), |
| 6439 | 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 | 6451 | args.* = .{ msg_inst, null_stack_trace }; |
| 6443 | 6452 | _ = try sema.analyzeCall(block, panic_fn, src, src, .auto, false, args); |
| 6444 | 6453 | return always_noreturn; |
| ... | ... | @@ -6494,10 +6503,10 @@ fn namedFieldPtr( |
| 6494 | 6503 | sema: *Sema, |
| 6495 | 6504 | block: *Scope.Block, |
| 6496 | 6505 | src: LazySrcLoc, |
| 6497 | | object_ptr: *Inst, |
| 6506 | object_ptr: Air.Inst.Index, |
| 6498 | 6507 | field_name: []const u8, |
| 6499 | 6508 | field_name_src: LazySrcLoc, |
| 6500 | | ) InnerError!*Inst { |
| 6509 | ) InnerError!Air.Inst.Index { |
| 6501 | 6510 | const mod = sema.mod; |
| 6502 | 6511 | const arena = sema.arena; |
| 6503 | 6512 | |
| ... | ... | @@ -6647,7 +6656,7 @@ fn analyzeNamespaceLookup( |
| 6647 | 6656 | src: LazySrcLoc, |
| 6648 | 6657 | namespace: *Scope.Namespace, |
| 6649 | 6658 | decl_name: []const u8, |
| 6650 | | ) InnerError!?*Inst { |
| 6659 | ) InnerError!?Air.Inst.Index { |
| 6651 | 6660 | const mod = sema.mod; |
| 6652 | 6661 | const gpa = sema.gpa; |
| 6653 | 6662 | if (try sema.lookupInNamespace(namespace, decl_name)) |decl| { |
| ... | ... | @@ -6671,11 +6680,11 @@ fn analyzeStructFieldPtr( |
| 6671 | 6680 | sema: *Sema, |
| 6672 | 6681 | block: *Scope.Block, |
| 6673 | 6682 | src: LazySrcLoc, |
| 6674 | | struct_ptr: *Inst, |
| 6683 | struct_ptr: Air.Inst.Index, |
| 6675 | 6684 | field_name: []const u8, |
| 6676 | 6685 | field_name_src: LazySrcLoc, |
| 6677 | 6686 | unresolved_struct_ty: Type, |
| 6678 | | ) InnerError!*Inst { |
| 6687 | ) InnerError!Air.Inst.Index { |
| 6679 | 6688 | const mod = sema.mod; |
| 6680 | 6689 | const arena = sema.arena; |
| 6681 | 6690 | assert(unresolved_struct_ty.zigTypeTag() == .Struct); |
| ... | ... | @@ -6706,11 +6715,11 @@ fn analyzeUnionFieldPtr( |
| 6706 | 6715 | sema: *Sema, |
| 6707 | 6716 | block: *Scope.Block, |
| 6708 | 6717 | src: LazySrcLoc, |
| 6709 | | union_ptr: *Inst, |
| 6718 | union_ptr: Air.Inst.Index, |
| 6710 | 6719 | field_name: []const u8, |
| 6711 | 6720 | field_name_src: LazySrcLoc, |
| 6712 | 6721 | unresolved_union_ty: Type, |
| 6713 | | ) InnerError!*Inst { |
| 6722 | ) InnerError!Air.Inst.Index { |
| 6714 | 6723 | const mod = sema.mod; |
| 6715 | 6724 | const arena = sema.arena; |
| 6716 | 6725 | assert(unresolved_union_ty.zigTypeTag() == .Union); |
| ... | ... | @@ -6743,10 +6752,10 @@ fn elemPtr( |
| 6743 | 6752 | sema: *Sema, |
| 6744 | 6753 | block: *Scope.Block, |
| 6745 | 6754 | src: LazySrcLoc, |
| 6746 | | array_ptr: *Inst, |
| 6747 | | elem_index: *Inst, |
| 6755 | array_ptr: Air.Inst.Index, |
| 6756 | elem_index: Air.Inst.Index, |
| 6748 | 6757 | elem_index_src: LazySrcLoc, |
| 6749 | | ) InnerError!*Inst { |
| 6758 | ) InnerError!Air.Inst.Index { |
| 6750 | 6759 | const array_ty = switch (array_ptr.ty.zigTypeTag()) { |
| 6751 | 6760 | .Pointer => array_ptr.ty.elemType(), |
| 6752 | 6761 | else => return sema.mod.fail(&block.base, array_ptr.src, "expected pointer, found '{}'", .{array_ptr.ty}), |
| ... | ... | @@ -6770,10 +6779,10 @@ fn elemPtrArray( |
| 6770 | 6779 | sema: *Sema, |
| 6771 | 6780 | block: *Scope.Block, |
| 6772 | 6781 | src: LazySrcLoc, |
| 6773 | | array_ptr: *Inst, |
| 6774 | | elem_index: *Inst, |
| 6782 | array_ptr: Air.Inst.Index, |
| 6783 | elem_index: Air.Inst.Index, |
| 6775 | 6784 | elem_index_src: LazySrcLoc, |
| 6776 | | ) InnerError!*Inst { |
| 6785 | ) InnerError!Air.Inst.Index { |
| 6777 | 6786 | if (array_ptr.value()) |array_ptr_val| { |
| 6778 | 6787 | if (elem_index.value()) |index_val| { |
| 6779 | 6788 | // Both array pointer and index are compile-time known. |
| ... | ... | @@ -6798,9 +6807,9 @@ fn coerce( |
| 6798 | 6807 | sema: *Sema, |
| 6799 | 6808 | block: *Scope.Block, |
| 6800 | 6809 | dest_type: Type, |
| 6801 | | inst: *Inst, |
| 6810 | inst: Air.Inst.Index, |
| 6802 | 6811 | inst_src: LazySrcLoc, |
| 6803 | | ) InnerError!*Inst { |
| 6812 | ) InnerError!Air.Inst.Index { |
| 6804 | 6813 | if (dest_type.tag() == .var_args_param) { |
| 6805 | 6814 | return sema.coerceVarArgParam(block, inst); |
| 6806 | 6815 | } |
| ... | ... | @@ -6976,7 +6985,7 @@ fn coerceInMemoryAllowed(dest_type: Type, src_type: Type) InMemoryCoercionResult |
| 6976 | 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 | 6989 | const val = inst.value() orelse return null; |
| 6981 | 6990 | const src_zig_tag = inst.ty.zigTypeTag(); |
| 6982 | 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 | 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 | 7027 | switch (inst.ty.zigTypeTag()) { |
| 7019 | 7028 | .ComptimeInt, .ComptimeFloat => return sema.mod.fail(&block.base, inst.src, "integer and float literals in var args function must be casted", .{}), |
| 7020 | 7029 | else => {}, |
| ... | ... | @@ -7027,8 +7036,8 @@ fn storePtr( |
| 7027 | 7036 | sema: *Sema, |
| 7028 | 7037 | block: *Scope.Block, |
| 7029 | 7038 | src: LazySrcLoc, |
| 7030 | | ptr: *Inst, |
| 7031 | | uncasted_value: *Inst, |
| 7039 | ptr: Air.Inst.Index, |
| 7040 | uncasted_value: Air.Inst.Index, |
| 7032 | 7041 | ) !void { |
| 7033 | 7042 | if (ptr.ty.isConstPtr()) |
| 7034 | 7043 | return sema.mod.fail(&block.base, src, "cannot assign to constant", .{}); |
| ... | ... | @@ -7076,7 +7085,7 @@ fn storePtr( |
| 7076 | 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 | 7089 | if (inst.value()) |val| { |
| 7081 | 7090 | // Keep the comptime Value representation; take the new type. |
| 7082 | 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 | 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 | 7099 | if (inst.value()) |val| { |
| 7091 | 7100 | // The comptime Value representation is compatible with both types. |
| 7092 | 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 | 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 | 7107 | if (inst.value()) |val| { |
| 7099 | 7108 | // The comptime Value representation is compatible with both types. |
| 7100 | 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 | 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 | 7115 | const decl_ref = try sema.analyzeDeclRef(block, src, decl); |
| 7107 | 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 | 7120 | try sema.mod.declareDeclDependency(sema.owner_decl, decl); |
| 7112 | 7121 | sema.mod.ensureDeclAnalyzed(decl) catch |err| { |
| 7113 | 7122 | if (sema.func) |func| { |
| ... | ... | @@ -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 | 7141 | const variable = tv.val.castTag(.variable).?.data; |
| 7133 | 7142 | |
| 7134 | 7143 | const ty = try sema.mod.simplePtrType(sema.arena, tv.ty, variable.is_mutable, .One); |
| ... | ... | @@ -7157,8 +7166,8 @@ fn analyzeRef( |
| 7157 | 7166 | sema: *Sema, |
| 7158 | 7167 | block: *Scope.Block, |
| 7159 | 7168 | src: LazySrcLoc, |
| 7160 | | operand: *Inst, |
| 7161 | | ) InnerError!*Inst { |
| 7169 | operand: Air.Inst.Index, |
| 7170 | ) InnerError!Air.Inst.Index { |
| 7162 | 7171 | const ptr_type = try sema.mod.simplePtrType(sema.arena, operand.ty, false, .One); |
| 7163 | 7172 | |
| 7164 | 7173 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |val| { |
| ... | ... | @@ -7176,9 +7185,9 @@ fn analyzeLoad( |
| 7176 | 7185 | sema: *Sema, |
| 7177 | 7186 | block: *Scope.Block, |
| 7178 | 7187 | src: LazySrcLoc, |
| 7179 | | ptr: *Inst, |
| 7188 | ptr: Air.Inst.Index, |
| 7180 | 7189 | ptr_src: LazySrcLoc, |
| 7181 | | ) InnerError!*Inst { |
| 7190 | ) InnerError!Air.Inst.Index { |
| 7182 | 7191 | const elem_ty = switch (ptr.ty.zigTypeTag()) { |
| 7183 | 7192 | .Pointer => ptr.ty.elemType(), |
| 7184 | 7193 | else => return sema.mod.fail(&block.base, ptr_src, "expected pointer, found '{}'", .{ptr.ty}), |
| ... | ... | @@ -7201,9 +7210,9 @@ fn analyzeIsNull( |
| 7201 | 7210 | sema: *Sema, |
| 7202 | 7211 | block: *Scope.Block, |
| 7203 | 7212 | src: LazySrcLoc, |
| 7204 | | operand: *Inst, |
| 7213 | operand: Air.Inst.Index, |
| 7205 | 7214 | invert_logic: bool, |
| 7206 | | ) InnerError!*Inst { |
| 7215 | ) InnerError!Air.Inst.Index { |
| 7207 | 7216 | const result_ty = Type.initTag(.bool); |
| 7208 | 7217 | if (try sema.resolvePossiblyUndefinedValue(block, src, operand)) |opt_val| { |
| 7209 | 7218 | if (opt_val.isUndef()) { |
| ... | ... | @@ -7222,8 +7231,8 @@ fn analyzeIsNonErr( |
| 7222 | 7231 | sema: *Sema, |
| 7223 | 7232 | block: *Scope.Block, |
| 7224 | 7233 | src: LazySrcLoc, |
| 7225 | | operand: *Inst, |
| 7226 | | ) InnerError!*Inst { |
| 7234 | operand: Air.Inst.Index, |
| 7235 | ) InnerError!Air.Inst.Index { |
| 7227 | 7236 | const ot = operand.ty.zigTypeTag(); |
| 7228 | 7237 | if (ot != .ErrorSet and ot != .ErrorUnion) return sema.mod.constBool(sema.arena, src, true); |
| 7229 | 7238 | if (ot == .ErrorSet) return sema.mod.constBool(sema.arena, src, false); |
| ... | ... | @@ -7243,12 +7252,12 @@ fn analyzeSlice( |
| 7243 | 7252 | sema: *Sema, |
| 7244 | 7253 | block: *Scope.Block, |
| 7245 | 7254 | src: LazySrcLoc, |
| 7246 | | array_ptr: *Inst, |
| 7247 | | start: *Inst, |
| 7248 | | end_opt: ?*Inst, |
| 7249 | | sentinel_opt: ?*Inst, |
| 7255 | array_ptr: Air.Inst.Index, |
| 7256 | start: Air.Inst.Index, |
| 7257 | end_opt: ?Air.Inst.Index, |
| 7258 | sentinel_opt: ?Air.Inst.Index, |
| 7250 | 7259 | sentinel_src: LazySrcLoc, |
| 7251 | | ) InnerError!*Inst { |
| 7260 | ) InnerError!Air.Inst.Index { |
| 7252 | 7261 | const ptr_child = switch (array_ptr.ty.zigTypeTag()) { |
| 7253 | 7262 | .Pointer => array_ptr.ty.elemType(), |
| 7254 | 7263 | else => return sema.mod.fail(&block.base, src, "expected pointer, found '{}'", .{array_ptr.ty}), |
| ... | ... | @@ -7319,10 +7328,10 @@ fn cmpNumeric( |
| 7319 | 7328 | sema: *Sema, |
| 7320 | 7329 | block: *Scope.Block, |
| 7321 | 7330 | src: LazySrcLoc, |
| 7322 | | lhs: *Inst, |
| 7323 | | rhs: *Inst, |
| 7331 | lhs: Air.Inst.Index, |
| 7332 | rhs: Air.Inst.Index, |
| 7324 | 7333 | op: std.math.CompareOperator, |
| 7325 | | ) InnerError!*Inst { |
| 7334 | ) InnerError!Air.Inst.Index { |
| 7326 | 7335 | assert(lhs.ty.isNumeric()); |
| 7327 | 7336 | assert(rhs.ty.isNumeric()); |
| 7328 | 7337 | |
| ... | ... | @@ -7488,7 +7497,7 @@ fn cmpNumeric( |
| 7488 | 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 | 7501 | if (inst.value()) |val| { |
| 7493 | 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 | 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 | 7510 | const err_union = dest_type.castTag(.error_union).?; |
| 7502 | 7511 | if (inst.value()) |val| { |
| 7503 | 7512 | if (inst.ty.zigTypeTag() != .ErrorSet) { |
| ... | ... | @@ -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 | 7581 | if (instructions.len == 0) |
| 7573 | 7582 | return Type.initTag(.noreturn); |
| 7574 | 7583 | |
| ... | ... | @@ -7704,7 +7713,7 @@ fn getBuiltin( |
| 7704 | 7713 | block: *Scope.Block, |
| 7705 | 7714 | src: LazySrcLoc, |
| 7706 | 7715 | name: []const u8, |
| 7707 | | ) InnerError!*ir.Inst { |
| 7716 | ) InnerError!Air.Inst.Index { |
| 7708 | 7717 | const mod = sema.mod; |
| 7709 | 7718 | const std_pkg = mod.root_pkg.table.get("std").?; |
| 7710 | 7719 | const std_file = (mod.importPkg(std_pkg) catch unreachable).file; |