| ... | @@ -584,7 +584,7 @@ fn resolveBody( | ... | @@ -584,7 +584,7 @@ fn resolveBody( |
| 584 | sema.comptime_break_inst = break_data.inst; | 584 | sema.comptime_break_inst = break_data.inst; |
| 585 | return error.ComptimeBreak; | 585 | return error.ComptimeBreak; |
| 586 | } | 586 | } |
| 587 | return sema.resolveInst(break_data.operand); | 587 | return try sema.resolveInst(break_data.operand); |
| 588 | } | 588 | } |
| 589 | | 589 | |
| 590 | pub fn analyzeBody( | 590 | pub fn analyzeBody( |
| ... | @@ -1191,7 +1191,7 @@ fn analyzeBodyInner( | ... | @@ -1191,7 +1191,7 @@ fn analyzeBodyInner( |
| 1191 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse | 1191 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1192 | break always_noreturn; | 1192 | break always_noreturn; |
| 1193 | if (inst == break_data.block_inst) { | 1193 | if (inst == break_data.block_inst) { |
| 1194 | break :blk sema.resolveInst(break_data.operand); | 1194 | break :blk try sema.resolveInst(break_data.operand); |
| 1195 | } else { | 1195 | } else { |
| 1196 | break break_data.inst; | 1196 | break break_data.inst; |
| 1197 | } | 1197 | } |
| ... | @@ -1214,7 +1214,7 @@ fn analyzeBodyInner( | ... | @@ -1214,7 +1214,7 @@ fn analyzeBodyInner( |
| 1214 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse | 1214 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1215 | break always_noreturn; | 1215 | break always_noreturn; |
| 1216 | if (inst == break_data.block_inst) { | 1216 | if (inst == break_data.block_inst) { |
| 1217 | break :blk sema.resolveInst(break_data.operand); | 1217 | break :blk try sema.resolveInst(break_data.operand); |
| 1218 | } else { | 1218 | } else { |
| 1219 | break break_data.inst; | 1219 | break break_data.inst; |
| 1220 | } | 1220 | } |
| ... | @@ -1283,7 +1283,7 @@ fn analyzeBodyInner( | ... | @@ -1283,7 +1283,7 @@ fn analyzeBodyInner( |
| 1283 | | 1283 | |
| 1284 | const break_data = opt_break_data orelse break always_noreturn; | 1284 | const break_data = opt_break_data orelse break always_noreturn; |
| 1285 | if (inst == break_data.block_inst) { | 1285 | if (inst == break_data.block_inst) { |
| 1286 | break :blk sema.resolveInst(break_data.operand); | 1286 | break :blk try sema.resolveInst(break_data.operand); |
| 1287 | } else { | 1287 | } else { |
| 1288 | break break_data.inst; | 1288 | break break_data.inst; |
| 1289 | } | 1289 | } |
| ... | @@ -1301,7 +1301,7 @@ fn analyzeBodyInner( | ... | @@ -1301,7 +1301,7 @@ fn analyzeBodyInner( |
| 1301 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse | 1301 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1302 | break always_noreturn; | 1302 | break always_noreturn; |
| 1303 | if (inst == break_data.block_inst) { | 1303 | if (inst == break_data.block_inst) { |
| 1304 | break :blk sema.resolveInst(break_data.operand); | 1304 | break :blk try sema.resolveInst(break_data.operand); |
| 1305 | } else { | 1305 | } else { |
| 1306 | break break_data.inst; | 1306 | break break_data.inst; |
| 1307 | } | 1307 | } |
| ... | @@ -1317,7 +1317,7 @@ fn analyzeBodyInner( | ... | @@ -1317,7 +1317,7 @@ fn analyzeBodyInner( |
| 1317 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse | 1317 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1318 | break always_noreturn; | 1318 | break always_noreturn; |
| 1319 | if (inst == break_data.block_inst) { | 1319 | if (inst == break_data.block_inst) { |
| 1320 | break :blk sema.resolveInst(break_data.operand); | 1320 | break :blk try sema.resolveInst(break_data.operand); |
| 1321 | } else { | 1321 | } else { |
| 1322 | break break_data.inst; | 1322 | break break_data.inst; |
| 1323 | } | 1323 | } |
| ... | @@ -1350,7 +1350,7 @@ fn analyzeBodyInner( | ... | @@ -1350,7 +1350,7 @@ fn analyzeBodyInner( |
| 1350 | return result; | 1350 | return result; |
| 1351 | } | 1351 | } |
| 1352 | | 1352 | |
| 1353 | pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref { | 1353 | pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref { |
| 1354 | var i: usize = @enumToInt(zir_ref); | 1354 | var i: usize = @enumToInt(zir_ref); |
| 1355 | | 1355 | |
| 1356 | // First section of indexes correspond to a set number of constant values. | 1356 | // First section of indexes correspond to a set number of constant values. |
| ... | @@ -1361,7 +1361,9 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref { | ... | @@ -1361,7 +1361,9 @@ pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref { |
| 1361 | i -= Zir.Inst.Ref.typed_value_map.len; | 1361 | i -= Zir.Inst.Ref.typed_value_map.len; |
| 1362 | | 1362 | |
| 1363 | // Finally, the last section of indexes refers to the map of ZIR=>AIR. | 1363 | // Finally, the last section of indexes refers to the map of ZIR=>AIR. |
| 1364 | return sema.inst_map.get(@intCast(u32, i)).?; | 1364 | const inst = sema.inst_map.get(@intCast(u32, i)).?; |
| | 1365 | if (sema.typeOf(inst).tag() == .generic_poison) return error.GenericPoison; |
| | 1366 | return inst; |
| 1365 | } | 1367 | } |
| 1366 | | 1368 | |
| 1367 | fn resolveConstBool( | 1369 | fn resolveConstBool( |
| ... | @@ -1370,7 +1372,7 @@ fn resolveConstBool( | ... | @@ -1370,7 +1372,7 @@ fn resolveConstBool( |
| 1370 | src: LazySrcLoc, | 1372 | src: LazySrcLoc, |
| 1371 | zir_ref: Zir.Inst.Ref, | 1373 | zir_ref: Zir.Inst.Ref, |
| 1372 | ) !bool { | 1374 | ) !bool { |
| 1373 | const air_inst = sema.resolveInst(zir_ref); | 1375 | const air_inst = try sema.resolveInst(zir_ref); |
| 1374 | const wanted_type = Type.bool; | 1376 | const wanted_type = Type.bool; |
| 1375 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 1377 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1376 | const val = try sema.resolveConstValue(block, src, coerced_inst); | 1378 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| ... | @@ -1383,7 +1385,7 @@ pub fn resolveConstString( | ... | @@ -1383,7 +1385,7 @@ pub fn resolveConstString( |
| 1383 | src: LazySrcLoc, | 1385 | src: LazySrcLoc, |
| 1384 | zir_ref: Zir.Inst.Ref, | 1386 | zir_ref: Zir.Inst.Ref, |
| 1385 | ) ![]u8 { | 1387 | ) ![]u8 { |
| 1386 | const air_inst = sema.resolveInst(zir_ref); | 1388 | const air_inst = try sema.resolveInst(zir_ref); |
| 1387 | const wanted_type = Type.initTag(.const_slice_u8); | 1389 | const wanted_type = Type.initTag(.const_slice_u8); |
| 1388 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); | 1390 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1389 | const val = try sema.resolveConstValue(block, src, coerced_inst); | 1391 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| ... | @@ -1391,7 +1393,7 @@ pub fn resolveConstString( | ... | @@ -1391,7 +1393,7 @@ pub fn resolveConstString( |
| 1391 | } | 1393 | } |
| 1392 | | 1394 | |
| 1393 | pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { | 1395 | pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !Type { |
| 1394 | const air_inst = sema.resolveInst(zir_ref); | 1396 | const air_inst = try sema.resolveInst(zir_ref); |
| 1395 | const ty = try sema.analyzeAsType(block, src, air_inst); | 1397 | const ty = try sema.analyzeAsType(block, src, air_inst); |
| 1396 | if (ty.tag() == .generic_poison) return error.GenericPoison; | 1398 | if (ty.tag() == .generic_poison) return error.GenericPoison; |
| 1397 | return ty; | 1399 | return ty; |
| ... | @@ -1513,6 +1515,7 @@ fn resolveDefinedValue( | ... | @@ -1513,6 +1515,7 @@ fn resolveDefinedValue( |
| 1513 | ) CompileError!?Value { | 1515 | ) CompileError!?Value { |
| 1514 | if (try sema.resolveMaybeUndefVal(block, src, air_ref)) |val| { | 1516 | if (try sema.resolveMaybeUndefVal(block, src, air_ref)) |val| { |
| 1515 | if (val.isUndef()) { | 1517 | if (val.isUndef()) { |
| | 1518 | if (block.is_typeof) return null; |
| 1516 | return sema.failWithUseOfUndef(block, src); | 1519 | return sema.failWithUseOfUndef(block, src); |
| 1517 | } | 1520 | } |
| 1518 | return val; | 1521 | return val; |
| ... | @@ -1737,7 +1740,7 @@ fn resolveInt( | ... | @@ -1737,7 +1740,7 @@ fn resolveInt( |
| 1737 | zir_ref: Zir.Inst.Ref, | 1740 | zir_ref: Zir.Inst.Ref, |
| 1738 | dest_ty: Type, | 1741 | dest_ty: Type, |
| 1739 | ) !u64 { | 1742 | ) !u64 { |
| 1740 | const air_inst = sema.resolveInst(zir_ref); | 1743 | const air_inst = try sema.resolveInst(zir_ref); |
| 1741 | const coerced = try sema.coerce(block, dest_ty, air_inst, src); | 1744 | const coerced = try sema.coerce(block, dest_ty, air_inst, src); |
| 1742 | const val = try sema.resolveConstValue(block, src, coerced); | 1745 | const val = try sema.resolveConstValue(block, src, coerced); |
| 1743 | const target = sema.mod.getTarget(); | 1746 | const target = sema.mod.getTarget(); |
| ... | @@ -1752,7 +1755,7 @@ pub fn resolveInstConst( | ... | @@ -1752,7 +1755,7 @@ pub fn resolveInstConst( |
| 1752 | src: LazySrcLoc, | 1755 | src: LazySrcLoc, |
| 1753 | zir_ref: Zir.Inst.Ref, | 1756 | zir_ref: Zir.Inst.Ref, |
| 1754 | ) CompileError!TypedValue { | 1757 | ) CompileError!TypedValue { |
| 1755 | const air_ref = sema.resolveInst(zir_ref); | 1758 | const air_ref = try sema.resolveInst(zir_ref); |
| 1756 | const val = try sema.resolveConstValue(block, src, air_ref); | 1759 | const val = try sema.resolveConstValue(block, src, air_ref); |
| 1757 | return TypedValue{ | 1760 | return TypedValue{ |
| 1758 | .ty = sema.typeOf(air_ref), | 1761 | .ty = sema.typeOf(air_ref), |
| ... | @@ -1768,7 +1771,7 @@ pub fn resolveInstValue( | ... | @@ -1768,7 +1771,7 @@ pub fn resolveInstValue( |
| 1768 | src: LazySrcLoc, | 1771 | src: LazySrcLoc, |
| 1769 | zir_ref: Zir.Inst.Ref, | 1772 | zir_ref: Zir.Inst.Ref, |
| 1770 | ) CompileError!TypedValue { | 1773 | ) CompileError!TypedValue { |
| 1771 | const air_ref = sema.resolveInst(zir_ref); | 1774 | const air_ref = try sema.resolveInst(zir_ref); |
| 1772 | const val = try sema.resolveValue(block, src, air_ref); | 1775 | const val = try sema.resolveValue(block, src, air_ref); |
| 1773 | return TypedValue{ | 1776 | return TypedValue{ |
| 1774 | .ty = sema.typeOf(air_ref), | 1777 | .ty = sema.typeOf(air_ref), |
| ... | @@ -1783,7 +1786,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -1783,7 +1786,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 1783 | const src: LazySrcLoc = sema.src; | 1786 | const src: LazySrcLoc = sema.src; |
| 1784 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 1787 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 1785 | const pointee_ty = try sema.resolveType(block, src, bin_inst.lhs); | 1788 | const pointee_ty = try sema.resolveType(block, src, bin_inst.lhs); |
| 1786 | const ptr = sema.resolveInst(bin_inst.rhs); | 1789 | const ptr = try sema.resolveInst(bin_inst.rhs); |
| 1787 | const target = sema.mod.getTarget(); | 1790 | const target = sema.mod.getTarget(); |
| 1788 | const addr_space = target_util.defaultAddressSpace(target, .local); | 1791 | const addr_space = target_util.defaultAddressSpace(target, .local); |
| 1789 | | 1792 | |
| ... | @@ -2531,7 +2534,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -2531,7 +2534,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 2531 | defer tracy.end(); | 2534 | defer tracy.end(); |
| 2532 | | 2535 | |
| 2533 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; | 2536 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 2534 | const operand = sema.resolveInst(inst_data.operand); | 2537 | const operand = try sema.resolveInst(inst_data.operand); |
| 2535 | return sema.analyzeRef(block, inst_data.src(), operand); | 2538 | return sema.analyzeRef(block, inst_data.src(), operand); |
| 2536 | } | 2539 | } |
| 2537 | | 2540 | |
| ... | @@ -2550,7 +2553,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile | ... | @@ -2550,7 +2553,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile |
| 2550 | defer tracy.end(); | 2553 | defer tracy.end(); |
| 2551 | | 2554 | |
| 2552 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2555 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2553 | const operand = sema.resolveInst(inst_data.operand); | 2556 | const operand = try sema.resolveInst(inst_data.operand); |
| 2554 | const src = inst_data.src(); | 2557 | const src = inst_data.src(); |
| 2555 | | 2558 | |
| 2556 | return sema.ensureResultUsed(block, operand, src); | 2559 | return sema.ensureResultUsed(block, operand, src); |
| ... | @@ -2574,7 +2577,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -2574,7 +2577,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 2574 | defer tracy.end(); | 2577 | defer tracy.end(); |
| 2575 | | 2578 | |
| 2576 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2579 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2577 | const operand = sema.resolveInst(inst_data.operand); | 2580 | const operand = try sema.resolveInst(inst_data.operand); |
| 2578 | const src = inst_data.src(); | 2581 | const src = inst_data.src(); |
| 2579 | const operand_ty = sema.typeOf(operand); | 2582 | const operand_ty = sema.typeOf(operand); |
| 2580 | switch (operand_ty.zigTypeTag()) { | 2583 | switch (operand_ty.zigTypeTag()) { |
| ... | @@ -2589,7 +2592,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -2589,7 +2592,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 2589 | | 2592 | |
| 2590 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2593 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2591 | const src = inst_data.src(); | 2594 | const src = inst_data.src(); |
| 2592 | const object = sema.resolveInst(inst_data.operand); | 2595 | const object = try sema.resolveInst(inst_data.operand); |
| 2593 | const object_ty = sema.typeOf(object); | 2596 | const object_ty = sema.typeOf(object); |
| 2594 | | 2597 | |
| 2595 | const is_pointer_to = object_ty.isSinglePointer(); | 2598 | const is_pointer_to = object_ty.isSinglePointer(); |
| ... | @@ -2708,7 +2711,7 @@ fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -2708,7 +2711,7 @@ fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 2708 | | 2711 | |
| 2709 | fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 2712 | fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2710 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2713 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2711 | const ptr = sema.resolveInst(inst_data.operand); | 2714 | const ptr = try sema.resolveInst(inst_data.operand); |
| 2712 | const ptr_ty = sema.typeOf(ptr); | 2715 | const ptr_ty = sema.typeOf(ptr); |
| 2713 | var ptr_info = ptr_ty.ptrInfo().data; | 2716 | var ptr_info = ptr_ty.ptrInfo().data; |
| 2714 | ptr_info.mutable = false; | 2717 | ptr_info.mutable = false; |
| ... | @@ -2824,7 +2827,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -2824,7 +2827,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 2824 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2827 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2825 | const src = inst_data.src(); | 2828 | const src = inst_data.src(); |
| 2826 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; | 2829 | const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = inst_data.src_node }; |
| 2827 | const ptr = sema.resolveInst(inst_data.operand); | 2830 | const ptr = try sema.resolveInst(inst_data.operand); |
| 2828 | const ptr_inst = Air.refToIndex(ptr).?; | 2831 | const ptr_inst = Air.refToIndex(ptr).?; |
| 2829 | assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant); | 2832 | assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant); |
| 2830 | const value_index = sema.air_instructions.items(.data)[ptr_inst].ty_pl.payload; | 2833 | const value_index = sema.air_instructions.items(.data)[ptr_inst].ty_pl.payload; |
| ... | @@ -2986,7 +2989,7 @@ fn zirArrayBasePtr( | ... | @@ -2986,7 +2989,7 @@ fn zirArrayBasePtr( |
| 2986 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 2989 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2987 | const src = inst_data.src(); | 2990 | const src = inst_data.src(); |
| 2988 | | 2991 | |
| 2989 | const start_ptr = sema.resolveInst(inst_data.operand); | 2992 | const start_ptr = try sema.resolveInst(inst_data.operand); |
| 2990 | var base_ptr = start_ptr; | 2993 | var base_ptr = start_ptr; |
| 2991 | while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) { | 2994 | while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) { |
| 2992 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), | 2995 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), |
| ... | @@ -3011,7 +3014,7 @@ fn zirFieldBasePtr( | ... | @@ -3011,7 +3014,7 @@ fn zirFieldBasePtr( |
| 3011 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 3014 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3012 | const src = inst_data.src(); | 3015 | const src = inst_data.src(); |
| 3013 | | 3016 | |
| 3014 | const start_ptr = sema.resolveInst(inst_data.operand); | 3017 | const start_ptr = try sema.resolveInst(inst_data.operand); |
| 3015 | var base_ptr = start_ptr; | 3018 | var base_ptr = start_ptr; |
| 3016 | while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) { | 3019 | while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) { |
| 3017 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), | 3020 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), |
| ... | @@ -3075,7 +3078,7 @@ fn zirValidateStructInit( | ... | @@ -3075,7 +3078,7 @@ fn zirValidateStructInit( |
| 3075 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; | 3078 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; |
| 3076 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; | 3079 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; |
| 3077 | const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data; | 3080 | const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data; |
| 3078 | const object_ptr = sema.resolveInst(field_ptr_extra.lhs); | 3081 | const object_ptr = try sema.resolveInst(field_ptr_extra.lhs); |
| 3079 | const agg_ty = sema.typeOf(object_ptr).childType(); | 3082 | const agg_ty = sema.typeOf(object_ptr).childType(); |
| 3080 | switch (agg_ty.zigTypeTag()) { | 3083 | switch (agg_ty.zigTypeTag()) { |
| 3081 | .Struct => return sema.validateStructInit( | 3084 | .Struct => return sema.validateStructInit( |
| ... | @@ -3251,7 +3254,7 @@ fn validateStructInit( | ... | @@ -3251,7 +3254,7 @@ fn validateStructInit( |
| 3251 | var root_msg: ?*Module.ErrorMsg = null; | 3254 | var root_msg: ?*Module.ErrorMsg = null; |
| 3252 | | 3255 | |
| 3253 | const fields = struct_obj.fields.values(); | 3256 | const fields = struct_obj.fields.values(); |
| 3254 | const struct_ptr = sema.resolveInst(struct_ptr_zir_ref); | 3257 | const struct_ptr = try sema.resolveInst(struct_ptr_zir_ref); |
| 3255 | const struct_ty = sema.typeOf(struct_ptr).childType(); | 3258 | const struct_ty = sema.typeOf(struct_ptr).childType(); |
| 3256 | | 3259 | |
| 3257 | if (is_comptime or block.is_comptime) { | 3260 | if (is_comptime or block.is_comptime) { |
| ... | @@ -3448,7 +3451,7 @@ fn zirValidateArrayInit( | ... | @@ -3448,7 +3451,7 @@ fn zirValidateArrayInit( |
| 3448 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; | 3451 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; |
| 3449 | const first_elem_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; | 3452 | const first_elem_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; |
| 3450 | const elem_ptr_extra = sema.code.extraData(Zir.Inst.ElemPtrImm, first_elem_ptr_data.payload_index).data; | 3453 | const elem_ptr_extra = sema.code.extraData(Zir.Inst.ElemPtrImm, first_elem_ptr_data.payload_index).data; |
| 3451 | const array_ptr = sema.resolveInst(elem_ptr_extra.ptr); | 3454 | const array_ptr = try sema.resolveInst(elem_ptr_extra.ptr); |
| 3452 | const array_ty = sema.typeOf(array_ptr).childType(); | 3455 | const array_ty = sema.typeOf(array_ptr).childType(); |
| 3453 | const array_len = array_ty.arrayLen(); | 3456 | const array_len = array_ty.arrayLen(); |
| 3454 | | 3457 | |
| ... | @@ -3646,7 +3649,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -3646,7 +3649,7 @@ fn zirStoreToBlockPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 3646 | // This is an elided instruction, but AstGen was unable to omit it. | 3649 | // This is an elided instruction, but AstGen was unable to omit it. |
| 3647 | return; | 3650 | return; |
| 3648 | }; | 3651 | }; |
| 3649 | const operand = sema.resolveInst(bin_inst.rhs); | 3652 | const operand = try sema.resolveInst(bin_inst.rhs); |
| 3650 | const src: LazySrcLoc = sema.src; | 3653 | const src: LazySrcLoc = sema.src; |
| 3651 | blk: { | 3654 | blk: { |
| 3652 | const ptr_inst = Air.refToIndex(ptr) orelse break :blk; | 3655 | const ptr_inst = Air.refToIndex(ptr) orelse break :blk; |
| ... | @@ -3675,8 +3678,8 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi | ... | @@ -3675,8 +3678,8 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi |
| 3675 | | 3678 | |
| 3676 | const src: LazySrcLoc = sema.src; | 3679 | const src: LazySrcLoc = sema.src; |
| 3677 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 3680 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 3678 | const ptr = sema.resolveInst(bin_inst.lhs); | 3681 | const ptr = try sema.resolveInst(bin_inst.lhs); |
| 3679 | const operand = sema.resolveInst(bin_inst.rhs); | 3682 | const operand = try sema.resolveInst(bin_inst.rhs); |
| 3680 | const ptr_inst = Air.refToIndex(ptr).?; | 3683 | const ptr_inst = Air.refToIndex(ptr).?; |
| 3681 | assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant); | 3684 | assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant); |
| 3682 | const air_datas = sema.air_instructions.items(.data); | 3685 | const air_datas = sema.air_instructions.items(.data); |
| ... | @@ -3758,8 +3761,8 @@ fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -3758,8 +3761,8 @@ fn zirStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 3758 | defer tracy.end(); | 3761 | defer tracy.end(); |
| 3759 | | 3762 | |
| 3760 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 3763 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 3761 | const ptr = sema.resolveInst(bin_inst.lhs); | 3764 | const ptr = try sema.resolveInst(bin_inst.lhs); |
| 3762 | const value = sema.resolveInst(bin_inst.rhs); | 3765 | const value = try sema.resolveInst(bin_inst.rhs); |
| 3763 | return sema.storePtr(block, sema.src, ptr, value); | 3766 | return sema.storePtr(block, sema.src, ptr, value); |
| 3764 | } | 3767 | } |
| 3765 | | 3768 | |
| ... | @@ -3772,8 +3775,8 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v | ... | @@ -3772,8 +3775,8 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v |
| 3772 | const inst_data = zir_datas[inst].pl_node; | 3775 | const inst_data = zir_datas[inst].pl_node; |
| 3773 | const src = inst_data.src(); | 3776 | const src = inst_data.src(); |
| 3774 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 3777 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3775 | const ptr = sema.resolveInst(extra.lhs); | 3778 | const ptr = try sema.resolveInst(extra.lhs); |
| 3776 | const operand = sema.resolveInst(extra.rhs); | 3779 | const operand = try sema.resolveInst(extra.rhs); |
| 3777 | | 3780 | |
| 3778 | // Check for the possibility of this pattern: | 3781 | // Check for the possibility of this pattern: |
| 3779 | // %a = ret_ptr | 3782 | // %a = ret_ptr |
| ... | @@ -3798,7 +3801,7 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -3798,7 +3801,7 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 3798 | const callee_src = sema.src; | 3801 | const callee_src = sema.src; |
| 3799 | | 3802 | |
| 3800 | const inst_data = sema.code.instructions.items(.data)[inst].param_type; | 3803 | const inst_data = sema.code.instructions.items(.data)[inst].param_type; |
| 3801 | const callee = sema.resolveInst(inst_data.callee); | 3804 | const callee = try sema.resolveInst(inst_data.callee); |
| 3802 | const callee_ty = sema.typeOf(callee); | 3805 | const callee_ty = sema.typeOf(callee); |
| 3803 | var param_index = inst_data.param_index; | 3806 | var param_index = inst_data.param_index; |
| 3804 | | 3807 | |
| ... | @@ -3959,7 +3962,7 @@ fn zirCompileLog( | ... | @@ -3959,7 +3962,7 @@ fn zirCompileLog( |
| 3959 | for (args) |arg_ref, i| { | 3962 | for (args) |arg_ref, i| { |
| 3960 | if (i != 0) try writer.print(", ", .{}); | 3963 | if (i != 0) try writer.print(", ", .{}); |
| 3961 | | 3964 | |
| 3962 | const arg = sema.resolveInst(arg_ref); | 3965 | const arg = try sema.resolveInst(arg_ref); |
| 3963 | const arg_ty = sema.typeOf(arg); | 3966 | const arg_ty = sema.typeOf(arg); |
| 3964 | if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| { | 3967 | if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| { |
| 3965 | try writer.print("@as({}, {})", .{ | 3968 | try writer.print("@as({}, {})", .{ |
| ... | @@ -3981,7 +3984,7 @@ fn zirCompileLog( | ... | @@ -3981,7 +3984,7 @@ fn zirCompileLog( |
| 3981 | fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { | 3984 | fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 3982 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 3985 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3983 | const src: LazySrcLoc = inst_data.src(); | 3986 | const src: LazySrcLoc = inst_data.src(); |
| 3984 | const msg_inst = sema.resolveInst(inst_data.operand); | 3987 | const msg_inst = try sema.resolveInst(inst_data.operand); |
| 3985 | | 3988 | |
| 3986 | return sema.panicWithMsg(block, src, msg_inst); | 3989 | return sema.panicWithMsg(block, src, msg_inst); |
| 3987 | } | 3990 | } |
| ... | @@ -4205,7 +4208,7 @@ fn resolveBlockBody( | ... | @@ -4205,7 +4208,7 @@ fn resolveBlockBody( |
| 4205 | const break_inst = sema.comptime_break_inst; | 4208 | const break_inst = sema.comptime_break_inst; |
| 4206 | const break_data = sema.code.instructions.items(.data)[break_inst].@"break"; | 4209 | const break_data = sema.code.instructions.items(.data)[break_inst].@"break"; |
| 4207 | if (break_data.block_inst == body_inst) { | 4210 | if (break_data.block_inst == body_inst) { |
| 4208 | return sema.resolveInst(break_data.operand); | 4211 | return try sema.resolveInst(break_data.operand); |
| 4209 | } else { | 4212 | } else { |
| 4210 | return error.ComptimeBreak; | 4213 | return error.ComptimeBreak; |
| 4211 | } | 4214 | } |
| ... | @@ -4535,7 +4538,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -4535,7 +4538,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError |
| 4535 | defer tracy.end(); | 4538 | defer tracy.end(); |
| 4536 | | 4539 | |
| 4537 | const inst_data = sema.code.instructions.items(.data)[inst].@"break"; | 4540 | const inst_data = sema.code.instructions.items(.data)[inst].@"break"; |
| 4538 | const operand = sema.resolveInst(inst_data.operand); | 4541 | const operand = try sema.resolveInst(inst_data.operand); |
| 4539 | const zir_block = inst_data.block_inst; | 4542 | const zir_block = inst_data.block_inst; |
| 4540 | | 4543 | |
| 4541 | var block = start_block; | 4544 | var block = start_block; |
| ... | @@ -4601,7 +4604,7 @@ fn zirDbgVar( | ... | @@ -4601,7 +4604,7 @@ fn zirDbgVar( |
| 4601 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; | 4604 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; |
| 4602 | | 4605 | |
| 4603 | const str_op = sema.code.instructions.items(.data)[inst].str_op; | 4606 | const str_op = sema.code.instructions.items(.data)[inst].str_op; |
| 4604 | const operand = sema.resolveInst(str_op.operand); | 4607 | const operand = try sema.resolveInst(str_op.operand); |
| 4605 | const name = str_op.getStr(sema.code); | 4608 | const name = str_op.getStr(sema.code); |
| 4606 | try sema.addDbgVar(block, operand, air_tag, name); | 4609 | try sema.addDbgVar(block, operand, air_tag, name); |
| 4607 | } | 4610 | } |
| ... | @@ -4784,7 +4787,7 @@ fn zirCall( | ... | @@ -4784,7 +4787,7 @@ fn zirCall( |
| 4784 | const modifier = @intToEnum(std.builtin.CallOptions.Modifier, extra.data.flags.packed_modifier); | 4787 | const modifier = @intToEnum(std.builtin.CallOptions.Modifier, extra.data.flags.packed_modifier); |
| 4785 | const ensure_result_used = extra.data.flags.ensure_result_used; | 4788 | const ensure_result_used = extra.data.flags.ensure_result_used; |
| 4786 | | 4789 | |
| 4787 | var func = sema.resolveInst(extra.data.callee); | 4790 | var func = try sema.resolveInst(extra.data.callee); |
| 4788 | var resolved_args: []Air.Inst.Ref = undefined; | 4791 | var resolved_args: []Air.Inst.Ref = undefined; |
| 4789 | | 4792 | |
| 4790 | const func_type = sema.typeOf(func); | 4793 | const func_type = sema.typeOf(func); |
| ... | @@ -4797,12 +4800,12 @@ fn zirCall( | ... | @@ -4797,12 +4800,12 @@ fn zirCall( |
| 4797 | resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len + 1); | 4800 | resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len + 1); |
| 4798 | resolved_args[0] = bound_data.arg0_inst; | 4801 | resolved_args[0] = bound_data.arg0_inst; |
| 4799 | for (args) |zir_arg, i| { | 4802 | for (args) |zir_arg, i| { |
| 4800 | resolved_args[i + 1] = sema.resolveInst(zir_arg); | 4803 | resolved_args[i + 1] = try sema.resolveInst(zir_arg); |
| 4801 | } | 4804 | } |
| 4802 | } else { | 4805 | } else { |
| 4803 | resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len); | 4806 | resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len); |
| 4804 | for (args) |zir_arg, i| { | 4807 | for (args) |zir_arg, i| { |
| 4805 | resolved_args[i] = sema.resolveInst(zir_arg); | 4808 | resolved_args[i] = try sema.resolveInst(zir_arg); |
| 4806 | } | 4809 | } |
| 4807 | } | 4810 | } |
| 4808 | | 4811 | |
| ... | @@ -5826,7 +5829,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil | ... | @@ -5826,7 +5829,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil |
| 5826 | const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node }; | 5829 | const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node }; |
| 5827 | const len = try sema.resolveInt(block, len_src, extra.len, Type.usize); | 5830 | const len = try sema.resolveInt(block, len_src, extra.len, Type.usize); |
| 5828 | const elem_type = try sema.resolveType(block, elem_src, extra.elem_type); | 5831 | const elem_type = try sema.resolveType(block, elem_src, extra.elem_type); |
| 5829 | const uncasted_sentinel = sema.resolveInst(extra.sentinel); | 5832 | const uncasted_sentinel = try sema.resolveInst(extra.sentinel); |
| 5830 | const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src); | 5833 | const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src); |
| 5831 | const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel); | 5834 | const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel); |
| 5832 | const array_ty = try Type.array(sema.arena, len, sentinel_val, elem_type, sema.mod); | 5835 | const array_ty = try Type.array(sema.arena, len, sentinel_val, elem_type, sema.mod); |
| ... | @@ -5891,7 +5894,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -5891,7 +5894,7 @@ fn zirErrorToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 5891 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5894 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5892 | const src = inst_data.src(); | 5895 | const src = inst_data.src(); |
| 5893 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5896 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 5894 | const op = sema.resolveInst(inst_data.operand); | 5897 | const op = try sema.resolveInst(inst_data.operand); |
| 5895 | const op_coerced = try sema.coerce(block, Type.anyerror, op, operand_src); | 5898 | const op_coerced = try sema.coerce(block, Type.anyerror, op, operand_src); |
| 5896 | const result_ty = Type.u16; | 5899 | const result_ty = Type.u16; |
| 5897 | | 5900 | |
| ... | @@ -5928,7 +5931,7 @@ fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -5928,7 +5931,7 @@ fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 5928 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 5931 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5929 | const src = inst_data.src(); | 5932 | const src = inst_data.src(); |
| 5930 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 5933 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 5931 | const uncasted_operand = sema.resolveInst(inst_data.operand); | 5934 | const uncasted_operand = try sema.resolveInst(inst_data.operand); |
| 5932 | const operand = try sema.coerce(block, Type.u16, uncasted_operand, operand_src); | 5935 | const operand = try sema.coerce(block, Type.u16, uncasted_operand, operand_src); |
| 5933 | const target = sema.mod.getTarget(); | 5936 | const target = sema.mod.getTarget(); |
| 5934 | | 5937 | |
| ... | @@ -5966,8 +5969,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -5966,8 +5969,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 5966 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; | 5969 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 5967 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 5970 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 5968 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 5971 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 5969 | const lhs = sema.resolveInst(extra.lhs); | 5972 | const lhs = try sema.resolveInst(extra.lhs); |
| 5970 | const rhs = sema.resolveInst(extra.rhs); | 5973 | const rhs = try sema.resolveInst(extra.rhs); |
| 5971 | if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) { | 5974 | if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) { |
| 5972 | const msg = msg: { | 5975 | const msg = msg: { |
| 5973 | const msg = try sema.errMsg(block, lhs_src, "expected error set type, found 'bool'", .{}); | 5976 | const msg = try sema.errMsg(block, lhs_src, "expected error set type, found 'bool'", .{}); |
| ... | @@ -6026,7 +6029,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -6026,7 +6029,7 @@ fn zirEnumToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 6026 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6029 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6027 | const src = inst_data.src(); | 6030 | const src = inst_data.src(); |
| 6028 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 6031 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 6029 | const operand = sema.resolveInst(inst_data.operand); | 6032 | const operand = try sema.resolveInst(inst_data.operand); |
| 6030 | const operand_ty = sema.typeOf(operand); | 6033 | const operand_ty = sema.typeOf(operand); |
| 6031 | | 6034 | |
| 6032 | const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag()) { | 6035 | const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag()) { |
| ... | @@ -6074,7 +6077,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -6074,7 +6077,7 @@ fn zirIntToEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 6074 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 6077 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 6075 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 6078 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 6076 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 6079 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 6077 | const operand = sema.resolveInst(extra.rhs); | 6080 | const operand = try sema.resolveInst(extra.rhs); |
| 6078 | | 6081 | |
| 6079 | if (dest_ty.zigTypeTag() != .Enum) { | 6082 | if (dest_ty.zigTypeTag() != .Enum) { |
| 6080 | return sema.fail(block, dest_ty_src, "expected enum, found {}", .{dest_ty.fmt(sema.mod)}); | 6083 | return sema.fail(block, dest_ty_src, "expected enum, found {}", .{dest_ty.fmt(sema.mod)}); |
| ... | @@ -6125,7 +6128,7 @@ fn zirOptionalPayloadPtr( | ... | @@ -6125,7 +6128,7 @@ fn zirOptionalPayloadPtr( |
| 6125 | defer tracy.end(); | 6128 | defer tracy.end(); |
| 6126 | | 6129 | |
| 6127 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6130 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6128 | const optional_ptr = sema.resolveInst(inst_data.operand); | 6131 | const optional_ptr = try sema.resolveInst(inst_data.operand); |
| 6129 | const src = inst_data.src(); | 6132 | const src = inst_data.src(); |
| 6130 | | 6133 | |
| 6131 | return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false); | 6134 | return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false); |
| ... | @@ -6210,7 +6213,7 @@ fn zirOptionalPayload( | ... | @@ -6210,7 +6213,7 @@ fn zirOptionalPayload( |
| 6210 | | 6213 | |
| 6211 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6214 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6212 | const src = inst_data.src(); | 6215 | const src = inst_data.src(); |
| 6213 | const operand = sema.resolveInst(inst_data.operand); | 6216 | const operand = try sema.resolveInst(inst_data.operand); |
| 6214 | const operand_ty = sema.typeOf(operand); | 6217 | const operand_ty = sema.typeOf(operand); |
| 6215 | const result_ty = switch (operand_ty.zigTypeTag()) { | 6218 | const result_ty = switch (operand_ty.zigTypeTag()) { |
| 6216 | .Optional => try operand_ty.optionalChildAlloc(sema.arena), | 6219 | .Optional => try operand_ty.optionalChildAlloc(sema.arena), |
| ... | @@ -6262,7 +6265,7 @@ fn zirErrUnionPayload( | ... | @@ -6262,7 +6265,7 @@ fn zirErrUnionPayload( |
| 6262 | | 6265 | |
| 6263 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6266 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6264 | const src = inst_data.src(); | 6267 | const src = inst_data.src(); |
| 6265 | const operand = sema.resolveInst(inst_data.operand); | 6268 | const operand = try sema.resolveInst(inst_data.operand); |
| 6266 | const operand_src = src; | 6269 | const operand_src = src; |
| 6267 | const operand_ty = sema.typeOf(operand); | 6270 | const operand_ty = sema.typeOf(operand); |
| 6268 | if (operand_ty.zigTypeTag() != .ErrorUnion) { | 6271 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| ... | @@ -6303,7 +6306,7 @@ fn zirErrUnionPayloadPtr( | ... | @@ -6303,7 +6306,7 @@ fn zirErrUnionPayloadPtr( |
| 6303 | defer tracy.end(); | 6306 | defer tracy.end(); |
| 6304 | | 6307 | |
| 6305 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6308 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6306 | const operand = sema.resolveInst(inst_data.operand); | 6309 | const operand = try sema.resolveInst(inst_data.operand); |
| 6307 | const src = inst_data.src(); | 6310 | const src = inst_data.src(); |
| 6308 | | 6311 | |
| 6309 | return sema.analyzeErrUnionPayloadPtr(block, src, operand, safety_check, false); | 6312 | return sema.analyzeErrUnionPayloadPtr(block, src, operand, safety_check, false); |
| ... | @@ -6389,7 +6392,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -6389,7 +6392,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 6389 | | 6392 | |
| 6390 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6393 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6391 | const src = inst_data.src(); | 6394 | const src = inst_data.src(); |
| 6392 | const operand = sema.resolveInst(inst_data.operand); | 6395 | const operand = try sema.resolveInst(inst_data.operand); |
| 6393 | const operand_ty = sema.typeOf(operand); | 6396 | const operand_ty = sema.typeOf(operand); |
| 6394 | if (operand_ty.zigTypeTag() != .ErrorUnion) { | 6397 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| 6395 | return sema.fail(block, src, "expected error union type, found '{}'", .{ | 6398 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| ... | @@ -6415,7 +6418,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -6415,7 +6418,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 6415 | | 6418 | |
| 6416 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6419 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6417 | const src = inst_data.src(); | 6420 | const src = inst_data.src(); |
| 6418 | const operand = sema.resolveInst(inst_data.operand); | 6421 | const operand = try sema.resolveInst(inst_data.operand); |
| 6419 | const operand_ty = sema.typeOf(operand); | 6422 | const operand_ty = sema.typeOf(operand); |
| 6420 | assert(operand_ty.zigTypeTag() == .Pointer); | 6423 | assert(operand_ty.zigTypeTag() == .Pointer); |
| 6421 | | 6424 | |
| ... | @@ -6444,7 +6447,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -6444,7 +6447,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 6444 | | 6447 | |
| 6445 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; | 6448 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 6446 | const src = inst_data.src(); | 6449 | const src = inst_data.src(); |
| 6447 | const operand = sema.resolveInst(inst_data.operand); | 6450 | const operand = try sema.resolveInst(inst_data.operand); |
| 6448 | const operand_ty = sema.typeOf(operand); | 6451 | const operand_ty = sema.typeOf(operand); |
| 6449 | if (operand_ty.zigTypeTag() != .ErrorUnion) { | 6452 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| 6450 | return sema.fail(block, src, "expected error union type, found '{}'", .{ | 6453 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| ... | @@ -6940,7 +6943,7 @@ fn analyzeAs( | ... | @@ -6940,7 +6943,7 @@ fn analyzeAs( |
| 6940 | zir_operand: Zir.Inst.Ref, | 6943 | zir_operand: Zir.Inst.Ref, |
| 6941 | ) CompileError!Air.Inst.Ref { | 6944 | ) CompileError!Air.Inst.Ref { |
| 6942 | const dest_ty = try sema.resolveType(block, src, zir_dest_type); | 6945 | const dest_ty = try sema.resolveType(block, src, zir_dest_type); |
| 6943 | const operand = sema.resolveInst(zir_operand); | 6946 | const operand = try sema.resolveInst(zir_operand); |
| 6944 | if (dest_ty.tag() == .var_args_param) return operand; | 6947 | if (dest_ty.tag() == .var_args_param) return operand; |
| 6945 | return sema.coerce(block, dest_ty, operand, src); | 6948 | return sema.coerce(block, dest_ty, operand, src); |
| 6946 | } | 6949 | } |
| ... | @@ -6951,7 +6954,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -6951,7 +6954,7 @@ fn zirPtrToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 6951 | | 6954 | |
| 6952 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 6955 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6953 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 6956 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 6954 | const ptr = sema.resolveInst(inst_data.operand); | 6957 | const ptr = try sema.resolveInst(inst_data.operand); |
| 6955 | const ptr_ty = sema.typeOf(ptr); | 6958 | const ptr_ty = sema.typeOf(ptr); |
| 6956 | if (!ptr_ty.isPtrAtRuntime()) { | 6959 | if (!ptr_ty.isPtrAtRuntime()) { |
| 6957 | return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(sema.mod)}); | 6960 | return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(sema.mod)}); |
| ... | @@ -6972,7 +6975,7 @@ fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -6972,7 +6975,7 @@ fn zirFieldVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 6972 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 6975 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 6973 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; | 6976 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 6974 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 6977 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 6975 | const object = sema.resolveInst(extra.lhs); | 6978 | const object = try sema.resolveInst(extra.lhs); |
| 6976 | return sema.fieldVal(block, src, object, field_name, field_name_src); | 6979 | return sema.fieldVal(block, src, object, field_name, field_name_src); |
| 6977 | } | 6980 | } |
| 6978 | | 6981 | |
| ... | @@ -6985,7 +6988,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -6985,7 +6988,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 6985 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 6988 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 6986 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; | 6989 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 6987 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 6990 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 6988 | const object_ptr = sema.resolveInst(extra.lhs); | 6991 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 6989 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src); | 6992 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 6990 | } | 6993 | } |
| 6991 | | 6994 | |
| ... | @@ -6998,7 +7001,7 @@ fn zirFieldCallBind(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -6998,7 +7001,7 @@ fn zirFieldCallBind(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 6998 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; | 7001 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 6999 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; | 7002 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 7000 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); | 7003 | const field_name = sema.code.nullTerminatedString(extra.field_name_start); |
| 7001 | const object_ptr = sema.resolveInst(extra.lhs); | 7004 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 7002 | return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src); | 7005 | return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src); |
| 7003 | } | 7006 | } |
| 7004 | | 7007 | |
| ... | @@ -7010,7 +7013,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -7010,7 +7013,7 @@ fn zirFieldValNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 7010 | const src = inst_data.src(); | 7013 | const src = inst_data.src(); |
| 7011 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 7014 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 7012 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; | 7015 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 7013 | const object = sema.resolveInst(extra.lhs); | 7016 | const object = try sema.resolveInst(extra.lhs); |
| 7014 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 7017 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 7015 | return sema.fieldVal(block, src, object, field_name, field_name_src); | 7018 | return sema.fieldVal(block, src, object, field_name, field_name_src); |
| 7016 | } | 7019 | } |
| ... | @@ -7023,7 +7026,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -7023,7 +7026,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 7023 | const src = inst_data.src(); | 7026 | const src = inst_data.src(); |
| 7024 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 7027 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 7025 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; | 7028 | const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 7026 | const object_ptr = sema.resolveInst(extra.lhs); | 7029 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 7027 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 7030 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 7028 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src); | 7031 | return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src); |
| 7029 | } | 7032 | } |
| ... | @@ -7035,7 +7038,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Block, extended: Zir.Inst.Extended | ... | @@ -7035,7 +7038,7 @@ fn zirFieldCallBindNamed(sema: *Sema, block: *Block, extended: Zir.Inst.Extended |
| 7035 | const extra = sema.code.extraData(Zir.Inst.FieldNamedNode, extended.operand).data; | 7038 | const extra = sema.code.extraData(Zir.Inst.FieldNamedNode, extended.operand).data; |
| 7036 | const src: LazySrcLoc = .{ .node_offset = extra.node }; | 7039 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 7037 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 7040 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 7038 | const object_ptr = sema.resolveInst(extra.lhs); | 7041 | const object_ptr = try sema.resolveInst(extra.lhs); |
| 7039 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); | 7042 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 7040 | return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src); | 7043 | return sema.fieldCallBind(block, src, object_ptr, field_name, field_name_src); |
| 7041 | } | 7044 | } |
| ... | @@ -7050,7 +7053,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7050,7 +7053,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7050 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 7053 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7051 | | 7054 | |
| 7052 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 7055 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 7053 | const operand = sema.resolveInst(extra.rhs); | 7056 | const operand = try sema.resolveInst(extra.rhs); |
| 7054 | | 7057 | |
| 7055 | return sema.intCast(block, dest_ty, dest_ty_src, operand, operand_src, true); | 7058 | return sema.intCast(block, dest_ty, dest_ty_src, operand, operand_src, true); |
| 7056 | } | 7059 | } |
| ... | @@ -7240,7 +7243,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7240,7 +7243,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7240 | => {}, | 7243 | => {}, |
| 7241 | } | 7244 | } |
| 7242 | | 7245 | |
| 7243 | const operand = sema.resolveInst(extra.rhs); | 7246 | const operand = try sema.resolveInst(extra.rhs); |
| 7244 | return sema.bitCast(block, dest_ty, operand, operand_src); | 7247 | return sema.bitCast(block, dest_ty, operand, operand_src); |
| 7245 | } | 7248 | } |
| 7246 | | 7249 | |
| ... | @@ -7255,7 +7258,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -7255,7 +7258,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 7255 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 7258 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7256 | | 7259 | |
| 7257 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 7260 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 7258 | const operand = sema.resolveInst(extra.rhs); | 7261 | const operand = try sema.resolveInst(extra.rhs); |
| 7259 | | 7262 | |
| 7260 | const target = sema.mod.getTarget(); | 7263 | const target = sema.mod.getTarget(); |
| 7261 | const dest_is_comptime_float = switch (dest_ty.zigTypeTag()) { | 7264 | const dest_is_comptime_float = switch (dest_ty.zigTypeTag()) { |
| ... | @@ -7300,8 +7303,8 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7300,8 +7303,8 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7300 | defer tracy.end(); | 7303 | defer tracy.end(); |
| 7301 | | 7304 | |
| 7302 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 7305 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 7303 | const array = sema.resolveInst(bin_inst.lhs); | 7306 | const array = try sema.resolveInst(bin_inst.lhs); |
| 7304 | const elem_index = sema.resolveInst(bin_inst.rhs); | 7307 | const elem_index = try sema.resolveInst(bin_inst.rhs); |
| 7305 | return sema.elemVal(block, sema.src, array, elem_index, sema.src); | 7308 | return sema.elemVal(block, sema.src, array, elem_index, sema.src); |
| 7306 | } | 7309 | } |
| 7307 | | 7310 | |
| ... | @@ -7313,8 +7316,8 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7313,8 +7316,8 @@ fn zirElemValNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7313 | const src = inst_data.src(); | 7316 | const src = inst_data.src(); |
| 7314 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; | 7317 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 7315 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 7318 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7316 | const array = sema.resolveInst(extra.lhs); | 7319 | const array = try sema.resolveInst(extra.lhs); |
| 7317 | const elem_index = sema.resolveInst(extra.rhs); | 7320 | const elem_index = try sema.resolveInst(extra.rhs); |
| 7318 | return sema.elemVal(block, src, array, elem_index, elem_index_src); | 7321 | return sema.elemVal(block, src, array, elem_index, elem_index_src); |
| 7319 | } | 7322 | } |
| 7320 | | 7323 | |
| ... | @@ -7323,8 +7326,8 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -7323,8 +7326,8 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 7323 | defer tracy.end(); | 7326 | defer tracy.end(); |
| 7324 | | 7327 | |
| 7325 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; | 7328 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 7326 | const array_ptr = sema.resolveInst(bin_inst.lhs); | 7329 | const array_ptr = try sema.resolveInst(bin_inst.lhs); |
| 7327 | const elem_index = sema.resolveInst(bin_inst.rhs); | 7330 | const elem_index = try sema.resolveInst(bin_inst.rhs); |
| 7328 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); | 7331 | return sema.elemPtr(block, sema.src, array_ptr, elem_index, sema.src); |
| 7329 | } | 7332 | } |
| 7330 | | 7333 | |
| ... | @@ -7336,8 +7339,8 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7336,8 +7339,8 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7336 | const src = inst_data.src(); | 7339 | const src = inst_data.src(); |
| 7337 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; | 7340 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 7338 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 7341 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7339 | const array_ptr = sema.resolveInst(extra.lhs); | 7342 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7340 | const elem_index = sema.resolveInst(extra.rhs); | 7343 | const elem_index = try sema.resolveInst(extra.rhs); |
| 7341 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); | 7344 | return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src); |
| 7342 | } | 7345 | } |
| 7343 | | 7346 | |
| ... | @@ -7348,7 +7351,7 @@ fn zirElemPtrImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -7348,7 +7351,7 @@ fn zirElemPtrImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 7348 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 7351 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7349 | const src = inst_data.src(); | 7352 | const src = inst_data.src(); |
| 7350 | const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data; | 7353 | const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data; |
| 7351 | const array_ptr = sema.resolveInst(extra.ptr); | 7354 | const array_ptr = try sema.resolveInst(extra.ptr); |
| 7352 | const elem_index = try sema.addIntUnsigned(Type.usize, extra.index); | 7355 | const elem_index = try sema.addIntUnsigned(Type.usize, extra.index); |
| 7353 | return sema.elemPtr(block, src, array_ptr, elem_index, src); | 7356 | return sema.elemPtr(block, src, array_ptr, elem_index, src); |
| 7354 | } | 7357 | } |
| ... | @@ -7360,8 +7363,8 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -7360,8 +7363,8 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 7360 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 7363 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7361 | const src = inst_data.src(); | 7364 | const src = inst_data.src(); |
| 7362 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; | 7365 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| 7363 | const array_ptr = sema.resolveInst(extra.lhs); | 7366 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7364 | const start = sema.resolveInst(extra.start); | 7367 | const start = try sema.resolveInst(extra.start); |
| 7365 | | 7368 | |
| 7366 | return sema.analyzeSlice(block, src, array_ptr, start, .none, .none, .unneeded); | 7369 | return sema.analyzeSlice(block, src, array_ptr, start, .none, .none, .unneeded); |
| 7367 | } | 7370 | } |
| ... | @@ -7373,9 +7376,9 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -7373,9 +7376,9 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 7373 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 7376 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7374 | const src = inst_data.src(); | 7377 | const src = inst_data.src(); |
| 7375 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; | 7378 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| 7376 | const array_ptr = sema.resolveInst(extra.lhs); | 7379 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7377 | const start = sema.resolveInst(extra.start); | 7380 | const start = try sema.resolveInst(extra.start); |
| 7378 | const end = sema.resolveInst(extra.end); | 7381 | const end = try sema.resolveInst(extra.end); |
| 7379 | | 7382 | |
| 7380 | return sema.analyzeSlice(block, src, array_ptr, start, end, .none, .unneeded); | 7383 | return sema.analyzeSlice(block, src, array_ptr, start, end, .none, .unneeded); |
| 7381 | } | 7384 | } |
| ... | @@ -7388,10 +7391,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -7388,10 +7391,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 7388 | const src = inst_data.src(); | 7391 | const src = inst_data.src(); |
| 7389 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; | 7392 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; |
| 7390 | const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; | 7393 | const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; |
| 7391 | const array_ptr = sema.resolveInst(extra.lhs); | 7394 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7392 | const start = sema.resolveInst(extra.start); | 7395 | const start = try sema.resolveInst(extra.start); |
| 7393 | const end = sema.resolveInst(extra.end); | 7396 | const end = try sema.resolveInst(extra.end); |
| 7394 | const sentinel = sema.resolveInst(extra.sentinel); | 7397 | const sentinel = try sema.resolveInst(extra.sentinel); |
| 7395 | | 7398 | |
| 7396 | return sema.analyzeSlice(block, src, array_ptr, start, end, sentinel, sentinel_src); | 7399 | return sema.analyzeSlice(block, src, array_ptr, start, end, sentinel, sentinel_src); |
| 7397 | } | 7400 | } |
| ... | @@ -7415,7 +7418,7 @@ fn zirSwitchCapture( | ... | @@ -7415,7 +7418,7 @@ fn zirSwitchCapture( |
| 7415 | const operand_is_ref = switch_extra.data.bits.is_ref; | 7418 | const operand_is_ref = switch_extra.data.bits.is_ref; |
| 7416 | const cond_inst = Zir.refToIndex(switch_extra.data.operand).?; | 7419 | const cond_inst = Zir.refToIndex(switch_extra.data.operand).?; |
| 7417 | const cond_info = sema.code.instructions.items(.data)[cond_inst].un_node; | 7420 | const cond_info = sema.code.instructions.items(.data)[cond_inst].un_node; |
| 7418 | const operand_ptr = sema.resolveInst(cond_info.operand); | 7421 | const operand_ptr = try sema.resolveInst(cond_info.operand); |
| 7419 | const operand_ptr_ty = sema.typeOf(operand_ptr); | 7422 | const operand_ptr_ty = sema.typeOf(operand_ptr); |
| 7420 | const operand_ty = if (operand_is_ref) operand_ptr_ty.childType() else operand_ptr_ty; | 7423 | const operand_ty = if (operand_is_ref) operand_ptr_ty.childType() else operand_ptr_ty; |
| 7421 | | 7424 | |
| ... | @@ -7449,7 +7452,7 @@ fn zirSwitchCapture( | ... | @@ -7449,7 +7452,7 @@ fn zirSwitchCapture( |
| 7449 | const union_obj = operand_ty.cast(Type.Payload.Union).?.data; | 7452 | const union_obj = operand_ty.cast(Type.Payload.Union).?.data; |
| 7450 | const enum_ty = union_obj.tag_ty; | 7453 | const enum_ty = union_obj.tag_ty; |
| 7451 | | 7454 | |
| 7452 | const first_item = sema.resolveInst(items[0]); | 7455 | const first_item = try sema.resolveInst(items[0]); |
| 7453 | // Previous switch validation ensured this will succeed | 7456 | // Previous switch validation ensured this will succeed |
| 7454 | const first_item_val = sema.resolveConstValue(block, .unneeded, first_item) catch unreachable; | 7457 | const first_item_val = sema.resolveConstValue(block, .unneeded, first_item) catch unreachable; |
| 7455 | | 7458 | |
| ... | @@ -7457,7 +7460,7 @@ fn zirSwitchCapture( | ... | @@ -7457,7 +7460,7 @@ fn zirSwitchCapture( |
| 7457 | const first_field = union_obj.fields.values()[first_field_index]; | 7460 | const first_field = union_obj.fields.values()[first_field_index]; |
| 7458 | | 7461 | |
| 7459 | for (items[1..]) |item| { | 7462 | for (items[1..]) |item| { |
| 7460 | const item_ref = sema.resolveInst(item); | 7463 | const item_ref = try sema.resolveInst(item); |
| 7461 | // Previous switch validation ensured this will succeed | 7464 | // Previous switch validation ensured this will succeed |
| 7462 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; | 7465 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; |
| 7463 | | 7466 | |
| ... | @@ -7514,7 +7517,7 @@ fn zirSwitchCapture( | ... | @@ -7514,7 +7517,7 @@ fn zirSwitchCapture( |
| 7514 | var names: Module.ErrorSet.NameMap = .{}; | 7517 | var names: Module.ErrorSet.NameMap = .{}; |
| 7515 | try names.ensureUnusedCapacity(sema.arena, items.len); | 7518 | try names.ensureUnusedCapacity(sema.arena, items.len); |
| 7516 | for (items) |item| { | 7519 | for (items) |item| { |
| 7517 | const item_ref = sema.resolveInst(item); | 7520 | const item_ref = try sema.resolveInst(item); |
| 7518 | // Previous switch validation ensured this will succeed | 7521 | // Previous switch validation ensured this will succeed |
| 7519 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; | 7522 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; |
| 7520 | names.putAssumeCapacityNoClobber( | 7523 | names.putAssumeCapacityNoClobber( |
| ... | @@ -7528,7 +7531,7 @@ fn zirSwitchCapture( | ... | @@ -7528,7 +7531,7 @@ fn zirSwitchCapture( |
| 7528 | | 7531 | |
| 7529 | return sema.bitCast(block, else_error_ty, operand, operand_src); | 7532 | return sema.bitCast(block, else_error_ty, operand, operand_src); |
| 7530 | } else { | 7533 | } else { |
| 7531 | const item_ref = sema.resolveInst(items[0]); | 7534 | const item_ref = try sema.resolveInst(items[0]); |
| 7532 | // Previous switch validation ensured this will succeed | 7535 | // Previous switch validation ensured this will succeed |
| 7533 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; | 7536 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; |
| 7534 | | 7537 | |
| ... | @@ -7558,7 +7561,7 @@ fn zirSwitchCond( | ... | @@ -7558,7 +7561,7 @@ fn zirSwitchCond( |
| 7558 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 7561 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7559 | const src = inst_data.src(); | 7562 | const src = inst_data.src(); |
| 7560 | const operand_src = src; // TODO make this point at the switch operand | 7563 | const operand_src = src; // TODO make this point at the switch operand |
| 7561 | const operand_ptr = sema.resolveInst(inst_data.operand); | 7564 | const operand_ptr = try sema.resolveInst(inst_data.operand); |
| 7562 | const operand = if (is_ref) | 7565 | const operand = if (is_ref) |
| 7563 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) | 7566 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) |
| 7564 | else | 7567 | else |
| ... | @@ -7629,7 +7632,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -7629,7 +7632,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7629 | const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset }; | 7632 | const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset }; |
| 7630 | const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); | 7633 | const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); |
| 7631 | | 7634 | |
| 7632 | const operand = sema.resolveInst(extra.data.operand); | 7635 | const operand = try sema.resolveInst(extra.data.operand); |
| 7633 | | 7636 | |
| 7634 | var header_extra_index: usize = extra.end; | 7637 | var header_extra_index: usize = extra.end; |
| 7635 | | 7638 | |
| ... | @@ -8207,7 +8210,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8207,7 +8210,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8207 | const body = sema.code.extra[extra_index..][0..body_len]; | 8210 | const body = sema.code.extra[extra_index..][0..body_len]; |
| 8208 | extra_index += body_len; | 8211 | extra_index += body_len; |
| 8209 | | 8212 | |
| 8210 | const item = sema.resolveInst(item_ref); | 8213 | const item = try sema.resolveInst(item_ref); |
| 8211 | // Validation above ensured these will succeed. | 8214 | // Validation above ensured these will succeed. |
| 8212 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable; | 8215 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable; |
| 8213 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { | 8216 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { |
| ... | @@ -8229,7 +8232,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8229,7 +8232,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8229 | const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..body_len]; | 8232 | const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..body_len]; |
| 8230 | | 8233 | |
| 8231 | for (items) |item_ref| { | 8234 | for (items) |item_ref| { |
| 8232 | const item = sema.resolveInst(item_ref); | 8235 | const item = try sema.resolveInst(item_ref); |
| 8233 | // Validation above ensured these will succeed. | 8236 | // Validation above ensured these will succeed. |
| 8234 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable; | 8237 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable; |
| 8235 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { | 8238 | if (operand_val.eql(item_val, operand_ty, sema.mod)) { |
| ... | @@ -8297,7 +8300,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8297,7 +8300,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8297 | case_block.instructions.shrinkRetainingCapacity(0); | 8300 | case_block.instructions.shrinkRetainingCapacity(0); |
| 8298 | case_block.wip_capture_scope = wip_captures.scope; | 8301 | case_block.wip_capture_scope = wip_captures.scope; |
| 8299 | | 8302 | |
| 8300 | const item = sema.resolveInst(item_ref); | 8303 | const item = try sema.resolveInst(item_ref); |
| 8301 | // `item` is already guaranteed to be constant known. | 8304 | // `item` is already guaranteed to be constant known. |
| 8302 | | 8305 | |
| 8303 | _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) { | 8306 | _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) { |
| ... | @@ -8374,14 +8377,14 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8374,14 +8377,14 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8374 | cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); | 8377 | cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); |
| 8375 | | 8378 | |
| 8376 | for (items) |item_ref| { | 8379 | for (items) |item_ref| { |
| 8377 | const item = sema.resolveInst(item_ref); | 8380 | const item = try sema.resolveInst(item_ref); |
| 8378 | cases_extra.appendAssumeCapacity(@enumToInt(item)); | 8381 | cases_extra.appendAssumeCapacity(@enumToInt(item)); |
| 8379 | } | 8382 | } |
| 8380 | | 8383 | |
| 8381 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); | 8384 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 8382 | } else { | 8385 | } else { |
| 8383 | for (items) |item_ref| { | 8386 | for (items) |item_ref| { |
| 8384 | const item = sema.resolveInst(item_ref); | 8387 | const item = try sema.resolveInst(item_ref); |
| 8385 | const cmp_ok = try case_block.addBinOp(.cmp_eq, operand, item); | 8388 | const cmp_ok = try case_block.addBinOp(.cmp_eq, operand, item); |
| 8386 | if (any_ok != .none) { | 8389 | if (any_ok != .none) { |
| 8387 | any_ok = try case_block.addBinOp(.bool_or, any_ok, cmp_ok); | 8390 | any_ok = try case_block.addBinOp(.bool_or, any_ok, cmp_ok); |
| ... | @@ -8397,8 +8400,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8397,8 +8400,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8397 | const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); | 8400 | const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 8398 | extra_index += 1; | 8401 | extra_index += 1; |
| 8399 | | 8402 | |
| 8400 | const item_first = sema.resolveInst(first_ref); | 8403 | const item_first = try sema.resolveInst(first_ref); |
| 8401 | const item_last = sema.resolveInst(last_ref); | 8404 | const item_last = try sema.resolveInst(last_ref); |
| 8402 | | 8405 | |
| 8403 | // operand >= first and operand <= last | 8406 | // operand >= first and operand <= last |
| 8404 | const range_first_ok = try case_block.addBinOp( | 8407 | const range_first_ok = try case_block.addBinOp( |
| ... | @@ -8551,7 +8554,7 @@ fn resolveSwitchItemVal( | ... | @@ -8551,7 +8554,7 @@ fn resolveSwitchItemVal( |
| 8551 | switch_prong_src: Module.SwitchProngSrc, | 8554 | switch_prong_src: Module.SwitchProngSrc, |
| 8552 | range_expand: Module.SwitchProngSrc.RangeExpand, | 8555 | range_expand: Module.SwitchProngSrc.RangeExpand, |
| 8553 | ) CompileError!TypedValue { | 8556 | ) CompileError!TypedValue { |
| 8554 | const item = sema.resolveInst(item_ref); | 8557 | const item = try sema.resolveInst(item_ref); |
| 8555 | const item_ty = sema.typeOf(item); | 8558 | const item_ty = sema.typeOf(item); |
| 8556 | // Constructing a LazySrcLoc is costly because we only have the switch AST node. | 8559 | // Constructing a LazySrcLoc is costly because we only have the switch AST node. |
| 8557 | // Only if we know for sure we need to report a compile error do we resolve the | 8560 | // Only if we know for sure we need to report a compile error do we resolve the |
| ... | @@ -8902,8 +8905,8 @@ fn zirShl( | ... | @@ -8902,8 +8905,8 @@ fn zirShl( |
| 8902 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 8905 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 8903 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 8906 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 8904 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 8907 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8905 | const lhs = sema.resolveInst(extra.lhs); | 8908 | const lhs = try sema.resolveInst(extra.lhs); |
| 8906 | const rhs = sema.resolveInst(extra.rhs); | 8909 | const rhs = try sema.resolveInst(extra.rhs); |
| 8907 | const lhs_ty = sema.typeOf(lhs); | 8910 | const lhs_ty = sema.typeOf(lhs); |
| 8908 | const rhs_ty = sema.typeOf(rhs); | 8911 | const rhs_ty = sema.typeOf(rhs); |
| 8909 | const target = sema.mod.getTarget(); | 8912 | const target = sema.mod.getTarget(); |
| ... | @@ -9030,8 +9033,8 @@ fn zirShr( | ... | @@ -9030,8 +9033,8 @@ fn zirShr( |
| 9030 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 9033 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 9031 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 9034 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 9032 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9035 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9033 | const lhs = sema.resolveInst(extra.lhs); | 9036 | const lhs = try sema.resolveInst(extra.lhs); |
| 9034 | const rhs = sema.resolveInst(extra.rhs); | 9037 | const rhs = try sema.resolveInst(extra.rhs); |
| 9035 | const lhs_ty = sema.typeOf(lhs); | 9038 | const lhs_ty = sema.typeOf(lhs); |
| 9036 | const rhs_ty = sema.typeOf(rhs); | 9039 | const rhs_ty = sema.typeOf(rhs); |
| 9037 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); | 9040 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| ... | @@ -9084,8 +9087,8 @@ fn zirBitwise( | ... | @@ -9084,8 +9087,8 @@ fn zirBitwise( |
| 9084 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 9087 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 9085 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 9088 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 9086 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9089 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9087 | const lhs = sema.resolveInst(extra.lhs); | 9090 | const lhs = try sema.resolveInst(extra.lhs); |
| 9088 | const rhs = sema.resolveInst(extra.rhs); | 9091 | const rhs = try sema.resolveInst(extra.rhs); |
| 9089 | const lhs_ty = sema.typeOf(lhs); | 9092 | const lhs_ty = sema.typeOf(lhs); |
| 9090 | const rhs_ty = sema.typeOf(rhs); | 9093 | const rhs_ty = sema.typeOf(rhs); |
| 9091 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); | 9094 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| ... | @@ -9129,7 +9132,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -9129,7 +9132,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 9129 | const src = inst_data.src(); | 9132 | const src = inst_data.src(); |
| 9130 | const operand_src = src; // TODO put this on the operand, not the '~' | 9133 | const operand_src = src; // TODO put this on the operand, not the '~' |
| 9131 | | 9134 | |
| 9132 | const operand = sema.resolveInst(inst_data.operand); | 9135 | const operand = try sema.resolveInst(inst_data.operand); |
| 9133 | const operand_type = sema.typeOf(operand); | 9136 | const operand_type = sema.typeOf(operand); |
| 9134 | const scalar_type = operand_type.scalarType(); | 9137 | const scalar_type = operand_type.scalarType(); |
| 9135 | const target = sema.mod.getTarget(); | 9138 | const target = sema.mod.getTarget(); |
| ... | @@ -9244,8 +9247,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -9244,8 +9247,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9244 | | 9247 | |
| 9245 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 9248 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9246 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9249 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9247 | const lhs = sema.resolveInst(extra.lhs); | 9250 | const lhs = try sema.resolveInst(extra.lhs); |
| 9248 | const rhs = sema.resolveInst(extra.rhs); | 9251 | const rhs = try sema.resolveInst(extra.rhs); |
| 9249 | const lhs_ty = sema.typeOf(lhs); | 9252 | const lhs_ty = sema.typeOf(lhs); |
| 9250 | const rhs_ty = sema.typeOf(rhs); | 9253 | const rhs_ty = sema.typeOf(rhs); |
| 9251 | | 9254 | |
| ... | @@ -9428,7 +9431,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -9428,7 +9431,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9428 | | 9431 | |
| 9429 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 9432 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9430 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9433 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9431 | const lhs = sema.resolveInst(extra.lhs); | 9434 | const lhs = try sema.resolveInst(extra.lhs); |
| 9432 | const lhs_ty = sema.typeOf(lhs); | 9435 | const lhs_ty = sema.typeOf(lhs); |
| 9433 | const src: LazySrcLoc = inst_data.src(); | 9436 | const src: LazySrcLoc = inst_data.src(); |
| 9434 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 9437 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| ... | @@ -9508,7 +9511,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -9508,7 +9511,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 9508 | const lhs_src = src; | 9511 | const lhs_src = src; |
| 9509 | const rhs_src = src; // TODO better source location | 9512 | const rhs_src = src; // TODO better source location |
| 9510 | | 9513 | |
| 9511 | const rhs = sema.resolveInst(inst_data.operand); | 9514 | const rhs = try sema.resolveInst(inst_data.operand); |
| 9512 | const rhs_ty = sema.typeOf(rhs); | 9515 | const rhs_ty = sema.typeOf(rhs); |
| 9513 | const rhs_scalar_ty = rhs_ty.scalarType(); | 9516 | const rhs_scalar_ty = rhs_ty.scalarType(); |
| 9514 | | 9517 | |
| ... | @@ -9528,7 +9531,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -9528,7 +9531,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 9528 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) | 9531 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) |
| 9529 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) | 9532 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) |
| 9530 | else | 9533 | else |
| 9531 | sema.resolveInst(.zero); | 9534 | try sema.resolveInst(.zero); |
| 9532 | | 9535 | |
| 9533 | return sema.analyzeArithmetic(block, .sub, lhs, rhs, src, lhs_src, rhs_src); | 9536 | return sema.analyzeArithmetic(block, .sub, lhs, rhs, src, lhs_src, rhs_src); |
| 9534 | } | 9537 | } |
| ... | @@ -9539,13 +9542,13 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -9539,13 +9542,13 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 9539 | const lhs_src = src; | 9542 | const lhs_src = src; |
| 9540 | const rhs_src = src; // TODO better source location | 9543 | const rhs_src = src; // TODO better source location |
| 9541 | | 9544 | |
| 9542 | const rhs = sema.resolveInst(inst_data.operand); | 9545 | const rhs = try sema.resolveInst(inst_data.operand); |
| 9543 | const rhs_ty = sema.typeOf(rhs); | 9546 | const rhs_ty = sema.typeOf(rhs); |
| 9544 | | 9547 | |
| 9545 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) | 9548 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) |
| 9546 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) | 9549 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) |
| 9547 | else | 9550 | else |
| 9548 | sema.resolveInst(.zero); | 9551 | try sema.resolveInst(.zero); |
| 9549 | | 9552 | |
| 9550 | return sema.analyzeArithmetic(block, .subwrap, lhs, rhs, src, lhs_src, rhs_src); | 9553 | return sema.analyzeArithmetic(block, .subwrap, lhs, rhs, src, lhs_src, rhs_src); |
| 9551 | } | 9554 | } |
| ... | @@ -9564,8 +9567,8 @@ fn zirArithmetic( | ... | @@ -9564,8 +9567,8 @@ fn zirArithmetic( |
| 9564 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 9567 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 9565 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 9568 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 9566 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9569 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9567 | const lhs = sema.resolveInst(extra.lhs); | 9570 | const lhs = try sema.resolveInst(extra.lhs); |
| 9568 | const rhs = sema.resolveInst(extra.rhs); | 9571 | const rhs = try sema.resolveInst(extra.rhs); |
| 9569 | | 9572 | |
| 9570 | return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, sema.src, lhs_src, rhs_src); | 9573 | return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, sema.src, lhs_src, rhs_src); |
| 9571 | } | 9574 | } |
| ... | @@ -9586,9 +9589,9 @@ fn zirOverflowArithmetic( | ... | @@ -9586,9 +9589,9 @@ fn zirOverflowArithmetic( |
| 9586 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 9589 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 9587 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = extra.node }; | 9590 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = extra.node }; |
| 9588 | | 9591 | |
| 9589 | const lhs = sema.resolveInst(extra.lhs); | 9592 | const lhs = try sema.resolveInst(extra.lhs); |
| 9590 | const rhs = sema.resolveInst(extra.rhs); | 9593 | const rhs = try sema.resolveInst(extra.rhs); |
| 9591 | const ptr = sema.resolveInst(extra.ptr); | 9594 | const ptr = try sema.resolveInst(extra.ptr); |
| 9592 | | 9595 | |
| 9593 | const lhs_ty = sema.typeOf(lhs); | 9596 | const lhs_ty = sema.typeOf(lhs); |
| 9594 | const rhs_ty = sema.typeOf(rhs); | 9597 | const rhs_ty = sema.typeOf(rhs); |
| ... | @@ -10787,7 +10790,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In | ... | @@ -10787,7 +10790,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In |
| 10787 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 10790 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 10788 | const src = inst_data.src(); | 10791 | const src = inst_data.src(); |
| 10789 | const ptr_src: LazySrcLoc = .{ .node_offset_deref_ptr = inst_data.src_node }; | 10792 | const ptr_src: LazySrcLoc = .{ .node_offset_deref_ptr = inst_data.src_node }; |
| 10790 | const ptr = sema.resolveInst(inst_data.operand); | 10793 | const ptr = try sema.resolveInst(inst_data.operand); |
| 10791 | return sema.analyzeLoad(block, src, ptr, ptr_src); | 10794 | return sema.analyzeLoad(block, src, ptr, ptr_src); |
| 10792 | } | 10795 | } |
| 10793 | | 10796 | |
| ... | @@ -10879,7 +10882,7 @@ fn zirAsm( | ... | @@ -10879,7 +10882,7 @@ fn zirAsm( |
| 10879 | const input = sema.code.extraData(Zir.Inst.Asm.Input, extra_i); | 10882 | const input = sema.code.extraData(Zir.Inst.Asm.Input, extra_i); |
| 10880 | extra_i = input.end; | 10883 | extra_i = input.end; |
| 10881 | | 10884 | |
| 10882 | const uncasted_arg = sema.resolveInst(input.data.operand); | 10885 | const uncasted_arg = try sema.resolveInst(input.data.operand); |
| 10883 | const uncasted_arg_ty = sema.typeOf(uncasted_arg); | 10886 | const uncasted_arg_ty = sema.typeOf(uncasted_arg); |
| 10884 | switch (uncasted_arg_ty.zigTypeTag()) { | 10887 | switch (uncasted_arg_ty.zigTypeTag()) { |
| 10885 | .ComptimeInt => arg.* = try sema.coerce(block, Type.initTag(.usize), uncasted_arg, src), | 10888 | .ComptimeInt => arg.* = try sema.coerce(block, Type.initTag(.usize), uncasted_arg, src), |
| ... | @@ -10968,8 +10971,8 @@ fn zirCmpEq( | ... | @@ -10968,8 +10971,8 @@ fn zirCmpEq( |
| 10968 | const src: LazySrcLoc = inst_data.src(); | 10971 | const src: LazySrcLoc = inst_data.src(); |
| 10969 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 10972 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 10970 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 10973 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 10971 | const lhs = sema.resolveInst(extra.lhs); | 10974 | const lhs = try sema.resolveInst(extra.lhs); |
| 10972 | const rhs = sema.resolveInst(extra.rhs); | 10975 | const rhs = try sema.resolveInst(extra.rhs); |
| 10973 | | 10976 | |
| 10974 | const lhs_ty = sema.typeOf(lhs); | 10977 | const lhs_ty = sema.typeOf(lhs); |
| 10975 | const rhs_ty = sema.typeOf(rhs); | 10978 | const rhs_ty = sema.typeOf(rhs); |
| ... | @@ -11080,8 +11083,8 @@ fn zirCmp( | ... | @@ -11080,8 +11083,8 @@ fn zirCmp( |
| 11080 | const src: LazySrcLoc = inst_data.src(); | 11083 | const src: LazySrcLoc = inst_data.src(); |
| 11081 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 11084 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 11082 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 11085 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 11083 | const lhs = sema.resolveInst(extra.lhs); | 11086 | const lhs = try sema.resolveInst(extra.lhs); |
| 11084 | const rhs = sema.resolveInst(extra.rhs); | 11087 | const rhs = try sema.resolveInst(extra.rhs); |
| 11085 | return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false); | 11088 | return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false); |
| 11086 | } | 11089 | } |
| 11087 | | 11090 | |
| ... | @@ -11275,7 +11278,7 @@ fn zirClosureCapture( | ... | @@ -11275,7 +11278,7 @@ fn zirClosureCapture( |
| 11275 | // fn foo(x: anytype) void { const S = struct {field: @TypeOf(x)}; } | 11278 | // fn foo(x: anytype) void { const S = struct {field: @TypeOf(x)}; } |
| 11276 | // ...in which case the closure_capture instruction has access to a runtime | 11279 | // ...in which case the closure_capture instruction has access to a runtime |
| 11277 | // value only. In such case we preserve the type and use a dummy runtime value. | 11280 | // value only. In such case we preserve the type and use a dummy runtime value. |
| 11278 | const operand = sema.resolveInst(inst_data.operand); | 11281 | const operand = try sema.resolveInst(inst_data.operand); |
| 11279 | const val = (try sema.resolveMaybeUndefValAllowVariables(block, src, operand)) orelse | 11282 | const val = (try sema.resolveMaybeUndefValAllowVariables(block, src, operand)) orelse |
| 11280 | Value.initTag(.generic_poison); | 11283 | Value.initTag(.generic_poison); |
| 11281 | | 11284 | |
| ... | @@ -12248,7 +12251,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -12248,7 +12251,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12248 | _ = block; | 12251 | _ = block; |
| 12249 | const zir_datas = sema.code.instructions.items(.data); | 12252 | const zir_datas = sema.code.instructions.items(.data); |
| 12250 | const inst_data = zir_datas[inst].un_node; | 12253 | const inst_data = zir_datas[inst].un_node; |
| 12251 | const operand = sema.resolveInst(inst_data.operand); | 12254 | const operand = try sema.resolveInst(inst_data.operand); |
| 12252 | const operand_ty = sema.typeOf(operand); | 12255 | const operand_ty = sema.typeOf(operand); |
| 12253 | return sema.addType(operand_ty); | 12256 | return sema.addType(operand_ty); |
| 12254 | } | 12257 | } |
| ... | @@ -12268,6 +12271,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -12268,6 +12271,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 12268 | .inlining = block.inlining, | 12271 | .inlining = block.inlining, |
| 12269 | .is_comptime = false, | 12272 | .is_comptime = false, |
| 12270 | .is_typeof = true, | 12273 | .is_typeof = true, |
| | 12274 | .want_safety = false, |
| 12271 | }; | 12275 | }; |
| 12272 | defer child_block.instructions.deinit(sema.gpa); | 12276 | defer child_block.instructions.deinit(sema.gpa); |
| 12273 | | 12277 | |
| ... | @@ -12280,7 +12284,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -12280,7 +12284,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 12280 | fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 12284 | fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 12281 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12285 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12282 | const src = inst_data.src(); | 12286 | const src = inst_data.src(); |
| 12283 | const operand = sema.resolveInst(inst_data.operand); | 12287 | const operand = try sema.resolveInst(inst_data.operand); |
| 12284 | const operand_ty = sema.typeOf(operand); | 12288 | const operand_ty = sema.typeOf(operand); |
| 12285 | const res_ty = try sema.log2IntType(block, operand_ty, src); | 12289 | const res_ty = try sema.log2IntType(block, operand_ty, src); |
| 12286 | return sema.addType(res_ty); | 12290 | return sema.addType(res_ty); |
| ... | @@ -12362,8 +12366,7 @@ fn zirTypeofPeer( | ... | @@ -12362,8 +12366,7 @@ fn zirTypeofPeer( |
| 12362 | defer sema.gpa.free(inst_list); | 12366 | defer sema.gpa.free(inst_list); |
| 12363 | | 12367 | |
| 12364 | for (args) |arg_ref, i| { | 12368 | for (args) |arg_ref, i| { |
| 12365 | inst_list[i] = sema.resolveInst(arg_ref); | 12369 | inst_list[i] = try sema.resolveInst(arg_ref); |
| 12366 | if (sema.typeOf(inst_list[i]).tag() == .generic_poison) return error.GenericPoison; | | |
| 12367 | } | 12370 | } |
| 12368 | | 12371 | |
| 12369 | const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node }); | 12372 | const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node }); |
| ... | @@ -12377,7 +12380,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -12377,7 +12380,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 12377 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12380 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12378 | const src = inst_data.src(); | 12381 | const src = inst_data.src(); |
| 12379 | const operand_src = src; // TODO put this on the operand, not the `!` | 12382 | const operand_src = src; // TODO put this on the operand, not the `!` |
| 12380 | const uncasted_operand = sema.resolveInst(inst_data.operand); | 12383 | const uncasted_operand = try sema.resolveInst(inst_data.operand); |
| 12381 | | 12384 | |
| 12382 | const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src); | 12385 | const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src); |
| 12383 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { | 12386 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| ... | @@ -12403,7 +12406,7 @@ fn zirBoolBr( | ... | @@ -12403,7 +12406,7 @@ fn zirBoolBr( |
| 12403 | | 12406 | |
| 12404 | const datas = sema.code.instructions.items(.data); | 12407 | const datas = sema.code.instructions.items(.data); |
| 12405 | const inst_data = datas[inst].bool_br; | 12408 | const inst_data = datas[inst].bool_br; |
| 12406 | const lhs = sema.resolveInst(inst_data.lhs); | 12409 | const lhs = try sema.resolveInst(inst_data.lhs); |
| 12407 | const lhs_src = sema.src; | 12410 | const lhs_src = sema.src; |
| 12408 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); | 12411 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 12409 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; | 12412 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| ... | @@ -12488,7 +12491,7 @@ fn zirIsNonNull( | ... | @@ -12488,7 +12491,7 @@ fn zirIsNonNull( |
| 12488 | | 12491 | |
| 12489 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12492 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12490 | const src = inst_data.src(); | 12493 | const src = inst_data.src(); |
| 12491 | const operand = sema.resolveInst(inst_data.operand); | 12494 | const operand = try sema.resolveInst(inst_data.operand); |
| 12492 | return sema.analyzeIsNull(block, src, operand, true); | 12495 | return sema.analyzeIsNull(block, src, operand, true); |
| 12493 | } | 12496 | } |
| 12494 | | 12497 | |
| ... | @@ -12502,7 +12505,7 @@ fn zirIsNonNullPtr( | ... | @@ -12502,7 +12505,7 @@ fn zirIsNonNullPtr( |
| 12502 | | 12505 | |
| 12503 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12506 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12504 | const src = inst_data.src(); | 12507 | const src = inst_data.src(); |
| 12505 | const ptr = sema.resolveInst(inst_data.operand); | 12508 | const ptr = try sema.resolveInst(inst_data.operand); |
| 12506 | if ((try sema.resolveMaybeUndefVal(block, src, ptr)) == null) { | 12509 | if ((try sema.resolveMaybeUndefVal(block, src, ptr)) == null) { |
| 12507 | return block.addUnOp(.is_non_null_ptr, ptr); | 12510 | return block.addUnOp(.is_non_null_ptr, ptr); |
| 12508 | } | 12511 | } |
| ... | @@ -12515,7 +12518,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12515,7 +12518,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12515 | defer tracy.end(); | 12518 | defer tracy.end(); |
| 12516 | | 12519 | |
| 12517 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12520 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12518 | const operand = sema.resolveInst(inst_data.operand); | 12521 | const operand = try sema.resolveInst(inst_data.operand); |
| 12519 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); | 12522 | return sema.analyzeIsNonErr(block, inst_data.src(), operand); |
| 12520 | } | 12523 | } |
| 12521 | | 12524 | |
| ... | @@ -12525,7 +12528,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -12525,7 +12528,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 12525 | | 12528 | |
| 12526 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12529 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12527 | const src = inst_data.src(); | 12530 | const src = inst_data.src(); |
| 12528 | const ptr = sema.resolveInst(inst_data.operand); | 12531 | const ptr = try sema.resolveInst(inst_data.operand); |
| 12529 | const loaded = try sema.analyzeLoad(block, src, ptr, src); | 12532 | const loaded = try sema.analyzeLoad(block, src, ptr, src); |
| 12530 | return sema.analyzeIsNonErr(block, src, loaded); | 12533 | return sema.analyzeIsNonErr(block, src, loaded); |
| 12531 | } | 12534 | } |
| ... | @@ -12546,7 +12549,7 @@ fn zirCondbr( | ... | @@ -12546,7 +12549,7 @@ fn zirCondbr( |
| 12546 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; | 12549 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 12547 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; | 12550 | const else_body = sema.code.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; |
| 12548 | | 12551 | |
| 12549 | const uncasted_cond = sema.resolveInst(extra.data.condition); | 12552 | const uncasted_cond = try sema.resolveInst(extra.data.condition); |
| 12550 | const cond = try sema.coerce(parent_block, Type.bool, uncasted_cond, cond_src); | 12553 | const cond = try sema.coerce(parent_block, Type.bool, uncasted_cond, cond_src); |
| 12551 | | 12554 | |
| 12552 | if (try sema.resolveDefinedValue(parent_block, src, cond)) |cond_val| { | 12555 | if (try sema.resolveDefinedValue(parent_block, src, cond)) |cond_val| { |
| ... | @@ -12654,7 +12657,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, break_data: BreakData) !voi | ... | @@ -12654,7 +12657,7 @@ fn addRuntimeBreak(sema: *Sema, child_block: *Block, break_data: BreakData) !voi |
| 12654 | break :blk labeled_block; | 12657 | break :blk labeled_block; |
| 12655 | }; | 12658 | }; |
| 12656 | | 12659 | |
| 12657 | const operand = sema.resolveInst(break_data.operand); | 12660 | const operand = try sema.resolveInst(break_data.operand); |
| 12658 | const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand); | 12661 | const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand); |
| 12659 | try labeled_block.label.merges.results.append(sema.gpa, operand); | 12662 | try labeled_block.label.merges.results.append(sema.gpa, operand); |
| 12660 | try labeled_block.label.merges.br_list.append(sema.gpa, Air.refToIndex(br_ref).?); | 12663 | try labeled_block.label.merges.br_list.append(sema.gpa, Air.refToIndex(br_ref).?); |
| ... | @@ -12705,7 +12708,7 @@ fn zirRetTok( | ... | @@ -12705,7 +12708,7 @@ fn zirRetTok( |
| 12705 | defer tracy.end(); | 12708 | defer tracy.end(); |
| 12706 | | 12709 | |
| 12707 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; | 12710 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 12708 | const operand = sema.resolveInst(inst_data.operand); | 12711 | const operand = try sema.resolveInst(inst_data.operand); |
| 12709 | const src = inst_data.src(); | 12712 | const src = inst_data.src(); |
| 12710 | | 12713 | |
| 12711 | return sema.analyzeRet(block, operand, src); | 12714 | return sema.analyzeRet(block, operand, src); |
| ... | @@ -12716,7 +12719,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir | ... | @@ -12716,7 +12719,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir |
| 12716 | defer tracy.end(); | 12719 | defer tracy.end(); |
| 12717 | | 12720 | |
| 12718 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12721 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12719 | const operand = sema.resolveInst(inst_data.operand); | 12722 | const operand = try sema.resolveInst(inst_data.operand); |
| 12720 | const src = inst_data.src(); | 12723 | const src = inst_data.src(); |
| 12721 | | 12724 | |
| 12722 | return sema.analyzeRet(block, operand, src); | 12725 | return sema.analyzeRet(block, operand, src); |
| ... | @@ -12728,7 +12731,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir | ... | @@ -12728,7 +12731,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir |
| 12728 | | 12731 | |
| 12729 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 12732 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12730 | const src = inst_data.src(); | 12733 | const src = inst_data.src(); |
| 12731 | const ret_ptr = sema.resolveInst(inst_data.operand); | 12734 | const ret_ptr = try sema.resolveInst(inst_data.operand); |
| 12732 | | 12735 | |
| 12733 | if (block.is_comptime or block.inlining != null) { | 12736 | if (block.is_comptime or block.inlining != null) { |
| 12734 | const operand = try sema.analyzeLoad(block, src, ret_ptr, src); | 12737 | const operand = try sema.analyzeLoad(block, src, ret_ptr, src); |
| ... | @@ -12851,7 +12854,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -12851,7 +12854,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 12851 | const abi_align: u32 = if (inst_data.flags.has_align) blk: { | 12854 | const abi_align: u32 = if (inst_data.flags.has_align) blk: { |
| 12852 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); | 12855 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 12853 | extra_i += 1; | 12856 | extra_i += 1; |
| 12854 | const coerced = try sema.coerce(block, Type.u32, sema.resolveInst(ref), src); | 12857 | const coerced = try sema.coerce(block, Type.u32, try sema.resolveInst(ref), src); |
| 12855 | const val = try sema.resolveConstValue(block, src, coerced); | 12858 | const val = try sema.resolveConstValue(block, src, coerced); |
| 12856 | // Check if this happens to be the lazy alignment of our element type, in | 12859 | // Check if this happens to be the lazy alignment of our element type, in |
| 12857 | // which case we can make this 0 without resolving it. | 12860 | // which case we can make this 0 without resolving it. |
| ... | @@ -12978,7 +12981,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -12978,7 +12981,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 12978 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; | 12981 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; |
| 12979 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); | 12982 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); |
| 12980 | const field_name = try sema.resolveConstString(block, field_src, extra.field_name); | 12983 | const field_name = try sema.resolveConstString(block, field_src, extra.field_name); |
| 12981 | const init = sema.resolveInst(extra.init); | 12984 | const init = try sema.resolveInst(extra.init); |
| 12982 | return sema.unionInit(block, init, init_src, union_ty, ty_src, field_name, field_src); | 12985 | return sema.unionInit(block, init, init_src, union_ty, ty_src, field_name, field_src); |
| 12983 | } | 12986 | } |
| 12984 | | 12987 | |
| ... | @@ -13068,7 +13071,7 @@ fn zirStructInit( | ... | @@ -13068,7 +13071,7 @@ fn zirStructInit( |
| 13068 | return sema.failWithOwnedErrorMsg(block, msg); | 13071 | return sema.failWithOwnedErrorMsg(block, msg); |
| 13069 | } | 13072 | } |
| 13070 | found_fields[field_index] = item.data.field_type; | 13073 | found_fields[field_index] = item.data.field_type; |
| 13071 | field_inits[field_index] = sema.resolveInst(item.data.init); | 13074 | field_inits[field_index] = try sema.resolveInst(item.data.init); |
| 13072 | } | 13075 | } |
| 13073 | | 13076 | |
| 13074 | var root_msg: ?*Module.ErrorMsg = null; | 13077 | var root_msg: ?*Module.ErrorMsg = null; |
| ... | @@ -13105,7 +13108,7 @@ fn zirStructInit( | ... | @@ -13105,7 +13108,7 @@ fn zirStructInit( |
| 13105 | const field_name = sema.code.nullTerminatedString(field_type_extra.name_start); | 13108 | const field_name = sema.code.nullTerminatedString(field_type_extra.name_start); |
| 13106 | const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src); | 13109 | const field_index = try sema.unionFieldIndex(block, resolved_ty, field_name, field_src); |
| 13107 | | 13110 | |
| 13108 | const init_inst = sema.resolveInst(item.data.init); | 13111 | const init_inst = try sema.resolveInst(item.data.init); |
| 13109 | if (try sema.resolveMaybeUndefVal(block, field_src, init_inst)) |val| { | 13112 | if (try sema.resolveMaybeUndefVal(block, field_src, init_inst)) |val| { |
| 13110 | const tag_val = try Value.Tag.enum_field_index.create(sema.arena, field_index); | 13113 | const tag_val = try Value.Tag.enum_field_index.create(sema.arena, field_index); |
| 13111 | return sema.addConstantMaybeRef( | 13114 | return sema.addConstantMaybeRef( |
| ... | @@ -13213,7 +13216,7 @@ fn zirStructInitAnon( | ... | @@ -13213,7 +13216,7 @@ fn zirStructInitAnon( |
| 13213 | extra_index = item.end; | 13216 | extra_index = item.end; |
| 13214 | | 13217 | |
| 13215 | names[i] = sema.code.nullTerminatedString(item.data.field_name); | 13218 | names[i] = sema.code.nullTerminatedString(item.data.field_name); |
| 13216 | const init = sema.resolveInst(item.data.init); | 13219 | const init = try sema.resolveInst(item.data.init); |
| 13217 | field_ty.* = sema.typeOf(init); | 13220 | field_ty.* = sema.typeOf(init); |
| 13218 | const init_src = src; // TODO better source location | 13221 | const init_src = src; // TODO better source location |
| 13219 | if (try sema.resolveMaybeUndefVal(block, init_src, init)) |init_val| { | 13222 | if (try sema.resolveMaybeUndefVal(block, init_src, init)) |init_val| { |
| ... | @@ -13258,7 +13261,7 @@ fn zirStructInitAnon( | ... | @@ -13258,7 +13261,7 @@ fn zirStructInitAnon( |
| 13258 | .pointee_type = field_ty, | 13261 | .pointee_type = field_ty, |
| 13259 | }); | 13262 | }); |
| 13260 | if (values[i].tag() == .unreachable_value) { | 13263 | if (values[i].tag() == .unreachable_value) { |
| 13261 | const init = sema.resolveInst(item.data.init); | 13264 | const init = try sema.resolveInst(item.data.init); |
| 13262 | const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty); | 13265 | const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty); |
| 13263 | _ = try block.addBinOp(.store, field_ptr, init); | 13266 | _ = try block.addBinOp(.store, field_ptr, init); |
| 13264 | } | 13267 | } |
| ... | @@ -13272,7 +13275,7 @@ fn zirStructInitAnon( | ... | @@ -13272,7 +13275,7 @@ fn zirStructInitAnon( |
| 13272 | for (types) |_, i| { | 13275 | for (types) |_, i| { |
| 13273 | const item = sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index); | 13276 | const item = sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index); |
| 13274 | extra_index = item.end; | 13277 | extra_index = item.end; |
| 13275 | element_refs[i] = sema.resolveInst(item.data.init); | 13278 | element_refs[i] = try sema.resolveInst(item.data.init); |
| 13276 | } | 13279 | } |
| 13277 | | 13280 | |
| 13278 | return block.addAggregateInit(tuple_ty, element_refs); | 13281 | return block.addAggregateInit(tuple_ty, element_refs); |
| ... | @@ -13296,7 +13299,7 @@ fn zirArrayInit( | ... | @@ -13296,7 +13299,7 @@ fn zirArrayInit( |
| 13296 | const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len); | 13299 | const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len); |
| 13297 | defer gpa.free(resolved_args); | 13300 | defer gpa.free(resolved_args); |
| 13298 | | 13301 | |
| 13299 | for (args) |arg, i| resolved_args[i] = sema.resolveInst(arg); | 13302 | for (args) |arg, i| resolved_args[i] = try sema.resolveInst(arg); |
| 13300 | | 13303 | |
| 13301 | const elem_ty = sema.typeOf(resolved_args[0]); | 13304 | const elem_ty = sema.typeOf(resolved_args[0]); |
| 13302 | const array_ty = blk: { | 13305 | const array_ty = blk: { |
| ... | @@ -13380,7 +13383,7 @@ fn zirArrayInitAnon( | ... | @@ -13380,7 +13383,7 @@ fn zirArrayInitAnon( |
| 13380 | const opt_runtime_src = rs: { | 13383 | const opt_runtime_src = rs: { |
| 13381 | var runtime_src: ?LazySrcLoc = null; | 13384 | var runtime_src: ?LazySrcLoc = null; |
| 13382 | for (operands) |operand, i| { | 13385 | for (operands) |operand, i| { |
| 13383 | const elem = sema.resolveInst(operand); | 13386 | const elem = try sema.resolveInst(operand); |
| 13384 | types[i] = sema.typeOf(elem); | 13387 | types[i] = sema.typeOf(elem); |
| 13385 | const operand_src = src; // TODO better source location | 13388 | const operand_src = src; // TODO better source location |
| 13386 | if (try sema.resolveMaybeUndefVal(block, operand_src, elem)) |val| { | 13389 | if (try sema.resolveMaybeUndefVal(block, operand_src, elem)) |val| { |
| ... | @@ -13421,7 +13424,7 @@ fn zirArrayInitAnon( | ... | @@ -13421,7 +13424,7 @@ fn zirArrayInitAnon( |
| 13421 | }); | 13424 | }); |
| 13422 | if (values[i].tag() == .unreachable_value) { | 13425 | if (values[i].tag() == .unreachable_value) { |
| 13423 | const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty); | 13426 | const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty); |
| 13424 | _ = try block.addBinOp(.store, field_ptr, sema.resolveInst(operand)); | 13427 | _ = try block.addBinOp(.store, field_ptr, try sema.resolveInst(operand)); |
| 13425 | } | 13428 | } |
| 13426 | } | 13429 | } |
| 13427 | | 13430 | |
| ... | @@ -13430,7 +13433,7 @@ fn zirArrayInitAnon( | ... | @@ -13430,7 +13433,7 @@ fn zirArrayInitAnon( |
| 13430 | | 13433 | |
| 13431 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len); | 13434 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len); |
| 13432 | for (operands) |operand, i| { | 13435 | for (operands) |operand, i| { |
| 13433 | element_refs[i] = sema.resolveInst(operand); | 13436 | element_refs[i] = try sema.resolveInst(operand); |
| 13434 | } | 13437 | } |
| 13435 | | 13438 | |
| 13436 | return block.addAggregateInit(tuple_ty, element_refs); | 13439 | return block.addAggregateInit(tuple_ty, element_refs); |
| ... | @@ -13573,7 +13576,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -13573,7 +13576,7 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 13573 | fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 13576 | fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 13574 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 13577 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13575 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 13578 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13576 | const operand = sema.resolveInst(inst_data.operand); | 13579 | const operand = try sema.resolveInst(inst_data.operand); |
| 13577 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { | 13580 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| 13578 | if (val.isUndef()) return sema.addConstUndef(Type.initTag(.u1)); | 13581 | if (val.isUndef()) return sema.addConstUndef(Type.initTag(.u1)); |
| 13579 | const bool_ints = [2]Air.Inst.Ref{ .zero, .one }; | 13582 | const bool_ints = [2]Air.Inst.Ref{ .zero, .one }; |
| ... | @@ -13586,7 +13589,7 @@ fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -13586,7 +13589,7 @@ fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 13586 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 13589 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13587 | const src = inst_data.src(); | 13590 | const src = inst_data.src(); |
| 13588 | _ = src; | 13591 | _ = src; |
| 13589 | const operand = sema.resolveInst(inst_data.operand); | 13592 | const operand = try sema.resolveInst(inst_data.operand); |
| 13590 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 13593 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13591 | | 13594 | |
| 13592 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| { | 13595 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| { |
| ... | @@ -13610,7 +13613,7 @@ fn zirUnaryMath( | ... | @@ -13610,7 +13613,7 @@ fn zirUnaryMath( |
| 13610 | defer tracy.end(); | 13613 | defer tracy.end(); |
| 13611 | | 13614 | |
| 13612 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 13615 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13613 | const operand = sema.resolveInst(inst_data.operand); | 13616 | const operand = try sema.resolveInst(inst_data.operand); |
| 13614 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 13617 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13615 | const operand_ty = sema.typeOf(operand); | 13618 | const operand_ty = sema.typeOf(operand); |
| 13616 | const target = sema.mod.getTarget(); | 13619 | const target = sema.mod.getTarget(); |
| ... | @@ -13670,7 +13673,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -13670,7 +13673,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 13670 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 13673 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13671 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 13674 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13672 | const src = inst_data.src(); | 13675 | const src = inst_data.src(); |
| 13673 | const operand = sema.resolveInst(inst_data.operand); | 13676 | const operand = try sema.resolveInst(inst_data.operand); |
| 13674 | const operand_ty = sema.typeOf(operand); | 13677 | const operand_ty = sema.typeOf(operand); |
| 13675 | const mod = sema.mod; | 13678 | const mod = sema.mod; |
| 13676 | | 13679 | |
| ... | @@ -13728,7 +13731,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -13728,7 +13731,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 13728 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 13731 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13729 | const src = inst_data.src(); | 13732 | const src = inst_data.src(); |
| 13730 | const type_info_ty = try sema.resolveBuiltinTypeFields(block, src, "Type"); | 13733 | const type_info_ty = try sema.resolveBuiltinTypeFields(block, src, "Type"); |
| 13731 | const uncasted_operand = sema.resolveInst(inst_data.operand); | 13734 | const uncasted_operand = try sema.resolveInst(inst_data.operand); |
| 13732 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 13735 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13733 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); | 13736 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); |
| 13734 | const val = try sema.resolveConstValue(block, operand_src, type_info); | 13737 | const val = try sema.resolveConstValue(block, operand_src, type_info); |
| ... | @@ -14403,7 +14406,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -14403,7 +14406,7 @@ fn zirFloatToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 14403 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 14406 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14404 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14407 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14405 | const dest_ty = try sema.resolveType(block, ty_src, extra.lhs); | 14408 | const dest_ty = try sema.resolveType(block, ty_src, extra.lhs); |
| 14406 | const operand = sema.resolveInst(extra.rhs); | 14409 | const operand = try sema.resolveInst(extra.rhs); |
| 14407 | const operand_ty = sema.typeOf(operand); | 14410 | const operand_ty = sema.typeOf(operand); |
| 14408 | | 14411 | |
| 14409 | _ = try sema.checkIntType(block, ty_src, dest_ty); | 14412 | _ = try sema.checkIntType(block, ty_src, dest_ty); |
| ... | @@ -14424,7 +14427,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -14424,7 +14427,7 @@ fn zirIntToFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 14424 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 14427 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14425 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14428 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14426 | const dest_ty = try sema.resolveType(block, ty_src, extra.lhs); | 14429 | const dest_ty = try sema.resolveType(block, ty_src, extra.lhs); |
| 14427 | const operand = sema.resolveInst(extra.rhs); | 14430 | const operand = try sema.resolveInst(extra.rhs); |
| 14428 | const operand_ty = sema.typeOf(operand); | 14431 | const operand_ty = sema.typeOf(operand); |
| 14429 | | 14432 | |
| 14430 | try sema.checkFloatType(block, ty_src, dest_ty); | 14433 | try sema.checkFloatType(block, ty_src, dest_ty); |
| ... | @@ -14447,7 +14450,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14447,7 +14450,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14447 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 14450 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 14448 | | 14451 | |
| 14449 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14452 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14450 | const operand_res = sema.resolveInst(extra.rhs); | 14453 | const operand_res = try sema.resolveInst(extra.rhs); |
| 14451 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); | 14454 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); |
| 14452 | | 14455 | |
| 14453 | const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 14456 | const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| ... | @@ -14503,7 +14506,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat | ... | @@ -14503,7 +14506,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 14503 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; | 14506 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 14504 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 14507 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 14505 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 14508 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 14506 | const operand = sema.resolveInst(extra.rhs); | 14509 | const operand = try sema.resolveInst(extra.rhs); |
| 14507 | const operand_ty = sema.typeOf(operand); | 14510 | const operand_ty = sema.typeOf(operand); |
| 14508 | try sema.checkErrorSetType(block, dest_ty_src, dest_ty); | 14511 | try sema.checkErrorSetType(block, dest_ty_src, dest_ty); |
| 14509 | try sema.checkErrorSetType(block, operand_src, operand_ty); | 14512 | try sema.checkErrorSetType(block, operand_src, operand_ty); |
| ... | @@ -14591,7 +14594,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -14591,7 +14594,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 14591 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14594 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14592 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 14595 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 14593 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 14596 | const dest_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 14594 | const operand = sema.resolveInst(extra.rhs); | 14597 | const operand = try sema.resolveInst(extra.rhs); |
| 14595 | const operand_ty = sema.typeOf(operand); | 14598 | const operand_ty = sema.typeOf(operand); |
| 14596 | const target = sema.mod.getTarget(); | 14599 | const target = sema.mod.getTarget(); |
| 14597 | | 14600 | |
| ... | @@ -14651,7 +14654,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14651,7 +14654,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14651 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14654 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14652 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 14655 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 14653 | const dest_scalar_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); | 14656 | const dest_scalar_ty = try sema.resolveType(block, dest_ty_src, extra.lhs); |
| 14654 | const operand = sema.resolveInst(extra.rhs); | 14657 | const operand = try sema.resolveInst(extra.rhs); |
| 14655 | const dest_is_comptime_int = try sema.checkIntType(block, dest_ty_src, dest_scalar_ty); | 14658 | const dest_is_comptime_int = try sema.checkIntType(block, dest_ty_src, dest_scalar_ty); |
| 14656 | const operand_ty = sema.typeOf(operand); | 14659 | const operand_ty = sema.typeOf(operand); |
| 14657 | const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); | 14660 | const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); |
| ... | @@ -14734,7 +14737,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -14734,7 +14737,7 @@ fn zirAlignCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 14734 | const align_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 14737 | const align_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14735 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14738 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14736 | const dest_align = try sema.resolveAlign(block, align_src, extra.lhs); | 14739 | const dest_align = try sema.resolveAlign(block, align_src, extra.lhs); |
| 14737 | const ptr = sema.resolveInst(extra.rhs); | 14740 | const ptr = try sema.resolveInst(extra.rhs); |
| 14738 | const ptr_ty = sema.typeOf(ptr); | 14741 | const ptr_ty = sema.typeOf(ptr); |
| 14739 | | 14742 | |
| 14740 | // TODO in addition to pointers, this instruction is supposed to work for | 14743 | // TODO in addition to pointers, this instruction is supposed to work for |
| ... | @@ -14768,7 +14771,7 @@ fn zirBitCount( | ... | @@ -14768,7 +14771,7 @@ fn zirBitCount( |
| 14768 | ) CompileError!Air.Inst.Ref { | 14771 | ) CompileError!Air.Inst.Ref { |
| 14769 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 14772 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 14770 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14773 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14771 | const operand = sema.resolveInst(inst_data.operand); | 14774 | const operand = try sema.resolveInst(inst_data.operand); |
| 14772 | const operand_ty = sema.typeOf(operand); | 14775 | const operand_ty = sema.typeOf(operand); |
| 14773 | _ = try checkIntOrVector(sema, block, operand, operand_src); | 14776 | _ = try checkIntOrVector(sema, block, operand, operand_src); |
| 14774 | const target = sema.mod.getTarget(); | 14777 | const target = sema.mod.getTarget(); |
| ... | @@ -14820,7 +14823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14820,7 +14823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14820 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 14823 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 14821 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 14824 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14822 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14825 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14823 | const operand = sema.resolveInst(inst_data.operand); | 14826 | const operand = try sema.resolveInst(inst_data.operand); |
| 14824 | const operand_ty = sema.typeOf(operand); | 14827 | const operand_ty = sema.typeOf(operand); |
| 14825 | const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); | 14828 | const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); |
| 14826 | const target = sema.mod.getTarget(); | 14829 | const target = sema.mod.getTarget(); |
| ... | @@ -14877,7 +14880,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14877,7 +14880,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14877 | fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 14880 | fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 14878 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; | 14881 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 14879 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 14882 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14880 | const operand = sema.resolveInst(inst_data.operand); | 14883 | const operand = try sema.resolveInst(inst_data.operand); |
| 14881 | const operand_ty = sema.typeOf(operand); | 14884 | const operand_ty = sema.typeOf(operand); |
| 14882 | _ = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); | 14885 | _ = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); |
| 14883 | | 14886 | |
| ... | @@ -15363,7 +15366,7 @@ fn resolveExportOptions( | ... | @@ -15363,7 +15366,7 @@ fn resolveExportOptions( |
| 15363 | zir_ref: Zir.Inst.Ref, | 15366 | zir_ref: Zir.Inst.Ref, |
| 15364 | ) CompileError!std.builtin.ExportOptions { | 15367 | ) CompileError!std.builtin.ExportOptions { |
| 15365 | const export_options_ty = try sema.getBuiltinType(block, src, "ExportOptions"); | 15368 | const export_options_ty = try sema.getBuiltinType(block, src, "ExportOptions"); |
| 15366 | const air_ref = sema.resolveInst(zir_ref); | 15369 | const air_ref = try sema.resolveInst(zir_ref); |
| 15367 | const options = try sema.coerce(block, export_options_ty, air_ref, src); | 15370 | const options = try sema.coerce(block, export_options_ty, air_ref, src); |
| 15368 | | 15371 | |
| 15369 | const name_operand = try sema.fieldVal(block, src, options, "name", src); | 15372 | const name_operand = try sema.fieldVal(block, src, options, "name", src); |
| ... | @@ -15408,7 +15411,7 @@ fn resolveBuiltinEnum( | ... | @@ -15408,7 +15411,7 @@ fn resolveBuiltinEnum( |
| 15408 | comptime name: []const u8, | 15411 | comptime name: []const u8, |
| 15409 | ) CompileError!@field(std.builtin, name) { | 15412 | ) CompileError!@field(std.builtin, name) { |
| 15410 | const ty = try sema.getBuiltinType(block, src, name); | 15413 | const ty = try sema.getBuiltinType(block, src, name); |
| 15411 | const air_ref = sema.resolveInst(zir_ref); | 15414 | const air_ref = try sema.resolveInst(zir_ref); |
| 15412 | const coerced = try sema.coerce(block, ty, air_ref, src); | 15415 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 15413 | const val = try sema.resolveConstValue(block, src, coerced); | 15416 | const val = try sema.resolveConstValue(block, src, coerced); |
| 15414 | return val.toEnum(@field(std.builtin, name)); | 15417 | return val.toEnum(@field(std.builtin, name)); |
| ... | @@ -15449,7 +15452,7 @@ fn zirCmpxchg( | ... | @@ -15449,7 +15452,7 @@ fn zirCmpxchg( |
| 15449 | const success_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; | 15452 | const success_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; |
| 15450 | const failure_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg5 = inst_data.src_node }; | 15453 | const failure_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg5 = inst_data.src_node }; |
| 15451 | // zig fmt: on | 15454 | // zig fmt: on |
| 15452 | const expected_value = sema.resolveInst(extra.expected_value); | 15455 | const expected_value = try sema.resolveInst(extra.expected_value); |
| 15453 | const elem_ty = sema.typeOf(expected_value); | 15456 | const elem_ty = sema.typeOf(expected_value); |
| 15454 | if (elem_ty.zigTypeTag() == .Float) { | 15457 | if (elem_ty.zigTypeTag() == .Float) { |
| 15455 | return sema.fail( | 15458 | return sema.fail( |
| ... | @@ -15459,9 +15462,9 @@ fn zirCmpxchg( | ... | @@ -15459,9 +15462,9 @@ fn zirCmpxchg( |
| 15459 | .{elem_ty.fmt(sema.mod)}, | 15462 | .{elem_ty.fmt(sema.mod)}, |
| 15460 | ); | 15463 | ); |
| 15461 | } | 15464 | } |
| 15462 | const uncasted_ptr = sema.resolveInst(extra.ptr); | 15465 | const uncasted_ptr = try sema.resolveInst(extra.ptr); |
| 15463 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); | 15466 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); |
| 15464 | const new_value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.new_value), new_value_src); | 15467 | const new_value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.new_value), new_value_src); |
| 15465 | const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order); | 15468 | const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order); |
| 15466 | const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order); | 15469 | const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order); |
| 15467 | | 15470 | |
| ... | @@ -15529,7 +15532,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -15529,7 +15532,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 15529 | const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 15532 | const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 15530 | const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 15533 | const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 15531 | const len = @intCast(u32, try sema.resolveInt(block, len_src, extra.lhs, Type.u32)); | 15534 | const len = @intCast(u32, try sema.resolveInt(block, len_src, extra.lhs, Type.u32)); |
| 15532 | const scalar = sema.resolveInst(extra.rhs); | 15535 | const scalar = try sema.resolveInst(extra.rhs); |
| 15533 | const scalar_ty = sema.typeOf(scalar); | 15536 | const scalar_ty = sema.typeOf(scalar); |
| 15534 | try sema.checkVectorElemType(block, scalar_src, scalar_ty); | 15537 | try sema.checkVectorElemType(block, scalar_src, scalar_ty); |
| 15535 | const vector_ty = try Type.Tag.vector.create(sema.arena, .{ | 15538 | const vector_ty = try Type.Tag.vector.create(sema.arena, .{ |
| ... | @@ -15555,7 +15558,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15555,7 +15558,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15555 | const op_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 15558 | const op_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 15556 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 15559 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 15557 | const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, "ReduceOp"); | 15560 | const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, "ReduceOp"); |
| 15558 | const operand = sema.resolveInst(extra.rhs); | 15561 | const operand = try sema.resolveInst(extra.rhs); |
| 15559 | const operand_ty = sema.typeOf(operand); | 15562 | const operand_ty = sema.typeOf(operand); |
| 15560 | const target = sema.mod.getTarget(); | 15563 | const target = sema.mod.getTarget(); |
| 15561 | | 15564 | |
| ... | @@ -15627,9 +15630,9 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -15627,9 +15630,9 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 15627 | | 15630 | |
| 15628 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); | 15631 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); |
| 15629 | try sema.checkVectorElemType(block, elem_ty_src, elem_ty); | 15632 | try sema.checkVectorElemType(block, elem_ty_src, elem_ty); |
| 15630 | var a = sema.resolveInst(extra.a); | 15633 | var a = try sema.resolveInst(extra.a); |
| 15631 | var b = sema.resolveInst(extra.b); | 15634 | var b = try sema.resolveInst(extra.b); |
| 15632 | var mask = sema.resolveInst(extra.mask); | 15635 | var mask = try sema.resolveInst(extra.mask); |
| 15633 | var mask_ty = sema.typeOf(mask); | 15636 | var mask_ty = sema.typeOf(mask); |
| 15634 | | 15637 | |
| 15635 | const mask_len = switch (sema.typeOf(mask).zigTypeTag()) { | 15638 | const mask_len = switch (sema.typeOf(mask).zigTypeTag()) { |
| ... | @@ -15821,7 +15824,7 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15821,7 +15824,7 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15821 | | 15824 | |
| 15822 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); | 15825 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); |
| 15823 | try sema.checkVectorElemType(block, elem_ty_src, elem_ty); | 15826 | try sema.checkVectorElemType(block, elem_ty_src, elem_ty); |
| 15824 | const pred_uncoerced = sema.resolveInst(extra.pred); | 15827 | const pred_uncoerced = try sema.resolveInst(extra.pred); |
| 15825 | const pred_ty = sema.typeOf(pred_uncoerced); | 15828 | const pred_ty = sema.typeOf(pred_uncoerced); |
| 15826 | | 15829 | |
| 15827 | const vec_len_u64 = switch (try pred_ty.zigTypeTagOrPoison()) { | 15830 | const vec_len_u64 = switch (try pred_ty.zigTypeTagOrPoison()) { |
| ... | @@ -15834,8 +15837,8 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -15834,8 +15837,8 @@ fn zirSelect(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 15834 | const pred = try sema.coerce(block, bool_vec_ty, pred_uncoerced, pred_src); | 15837 | const pred = try sema.coerce(block, bool_vec_ty, pred_uncoerced, pred_src); |
| 15835 | | 15838 | |
| 15836 | const vec_ty = try Type.vector(sema.arena, vec_len, elem_ty); | 15839 | const vec_ty = try Type.vector(sema.arena, vec_len, elem_ty); |
| 15837 | const a = try sema.coerce(block, vec_ty, sema.resolveInst(extra.a), a_src); | 15840 | const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src); |
| 15838 | const b = try sema.coerce(block, vec_ty, sema.resolveInst(extra.b), b_src); | 15841 | const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src); |
| 15839 | | 15842 | |
| 15840 | const maybe_pred = try sema.resolveMaybeUndefVal(block, pred_src, pred); | 15843 | const maybe_pred = try sema.resolveMaybeUndefVal(block, pred_src, pred); |
| 15841 | const maybe_a = try sema.resolveMaybeUndefVal(block, a_src, a); | 15844 | const maybe_a = try sema.resolveMaybeUndefVal(block, a_src, a); |
| ... | @@ -15907,7 +15910,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -15907,7 +15910,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 15907 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; | 15910 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 15908 | // zig fmt: on | 15911 | // zig fmt: on |
| 15909 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); | 15912 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); |
| 15910 | const uncasted_ptr = sema.resolveInst(extra.ptr); | 15913 | const uncasted_ptr = try sema.resolveInst(extra.ptr); |
| 15911 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true); | 15914 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true); |
| 15912 | const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering); | 15915 | const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering); |
| 15913 | | 15916 | |
| ... | @@ -15954,9 +15957,9 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -15954,9 +15957,9 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 15954 | const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; | 15957 | const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; |
| 15955 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; | 15958 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; |
| 15956 | // zig fmt: on | 15959 | // zig fmt: on |
| 15957 | const operand = sema.resolveInst(extra.operand); | 15960 | const operand = try sema.resolveInst(extra.operand); |
| 15958 | const elem_ty = sema.typeOf(operand); | 15961 | const elem_ty = sema.typeOf(operand); |
| 15959 | const uncasted_ptr = sema.resolveInst(extra.ptr); | 15962 | const uncasted_ptr = try sema.resolveInst(extra.ptr); |
| 15960 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); | 15963 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); |
| 15961 | const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation); | 15964 | const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation); |
| 15962 | | 15965 | |
| ... | @@ -16037,9 +16040,9 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -16037,9 +16040,9 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16037 | const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; | 16040 | const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 16038 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; | 16041 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; |
| 16039 | // zig fmt: on | 16042 | // zig fmt: on |
| 16040 | const operand = sema.resolveInst(extra.operand); | 16043 | const operand = try sema.resolveInst(extra.operand); |
| 16041 | const elem_ty = sema.typeOf(operand); | 16044 | const elem_ty = sema.typeOf(operand); |
| 16042 | const uncasted_ptr = sema.resolveInst(extra.ptr); | 16045 | const uncasted_ptr = try sema.resolveInst(extra.ptr); |
| 16043 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); | 16046 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); |
| 16044 | const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering); | 16047 | const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering); |
| 16045 | | 16048 | |
| ... | @@ -16070,10 +16073,10 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. | ... | @@ -16070,10 +16073,10 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 16070 | const mulend2_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; | 16073 | const mulend2_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 16071 | const addend_src: LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; | 16074 | const addend_src: LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; |
| 16072 | | 16075 | |
| 16073 | const addend = sema.resolveInst(extra.addend); | 16076 | const addend = try sema.resolveInst(extra.addend); |
| 16074 | const ty = sema.typeOf(addend); | 16077 | const ty = sema.typeOf(addend); |
| 16075 | const mulend1 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend1), mulend1_src); | 16078 | const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src); |
| 16076 | const mulend2 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend2), mulend2_src); | 16079 | const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src); |
| 16077 | | 16080 | |
| 16078 | const target = sema.mod.getTarget(); | 16081 | const target = sema.mod.getTarget(); |
| 16079 | | 16082 | |
| ... | @@ -16137,9 +16140,9 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -16137,9 +16140,9 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16137 | const call_src = inst_data.src(); | 16140 | const call_src = inst_data.src(); |
| 16138 | | 16141 | |
| 16139 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; | 16142 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; |
| 16140 | var func = sema.resolveInst(extra.callee); | 16143 | var func = try sema.resolveInst(extra.callee); |
| 16141 | const options = sema.resolveInst(extra.options); | 16144 | const options = try sema.resolveInst(extra.options); |
| 16142 | const args = sema.resolveInst(extra.args); | 16145 | const args = try sema.resolveInst(extra.args); |
| 16143 | | 16146 | |
| 16144 | const wanted_modifier: std.builtin.CallOptions.Modifier = modifier: { | 16147 | const wanted_modifier: std.builtin.CallOptions.Modifier = modifier: { |
| 16145 | const call_options_ty = try sema.getBuiltinType(block, options_src, "CallOptions"); | 16148 | const call_options_ty = try sema.getBuiltinType(block, options_src, "CallOptions"); |
| ... | @@ -16229,7 +16232,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -16229,7 +16232,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 16229 | | 16232 | |
| 16230 | const struct_ty = try sema.resolveType(block, ty_src, extra.parent_type); | 16233 | const struct_ty = try sema.resolveType(block, ty_src, extra.parent_type); |
| 16231 | const field_name = try sema.resolveConstString(block, name_src, extra.field_name); | 16234 | const field_name = try sema.resolveConstString(block, name_src, extra.field_name); |
| 16232 | const field_ptr = sema.resolveInst(extra.field_ptr); | 16235 | const field_ptr = try sema.resolveInst(extra.field_ptr); |
| 16233 | const field_ptr_ty = sema.typeOf(field_ptr); | 16236 | const field_ptr_ty = sema.typeOf(field_ptr); |
| 16234 | | 16237 | |
| 16235 | if (struct_ty.zigTypeTag() != .Struct) { | 16238 | if (struct_ty.zigTypeTag() != .Struct) { |
| ... | @@ -16294,8 +16297,8 @@ fn zirMinMax( | ... | @@ -16294,8 +16297,8 @@ fn zirMinMax( |
| 16294 | const src = inst_data.src(); | 16297 | const src = inst_data.src(); |
| 16295 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 16298 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 16296 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 16299 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 16297 | const lhs = sema.resolveInst(extra.lhs); | 16300 | const lhs = try sema.resolveInst(extra.lhs); |
| 16298 | const rhs = sema.resolveInst(extra.rhs); | 16301 | const rhs = try sema.resolveInst(extra.rhs); |
| 16299 | try sema.checkNumericType(block, lhs_src, sema.typeOf(lhs)); | 16302 | try sema.checkNumericType(block, lhs_src, sema.typeOf(lhs)); |
| 16300 | try sema.checkNumericType(block, rhs_src, sema.typeOf(rhs)); | 16303 | try sema.checkNumericType(block, rhs_src, sema.typeOf(rhs)); |
| 16301 | return sema.analyzeMinMax(block, src, lhs, rhs, air_tag, lhs_src, rhs_src); | 16304 | return sema.analyzeMinMax(block, src, lhs, rhs, air_tag, lhs_src, rhs_src); |
| ... | @@ -16362,7 +16365,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -16362,7 +16365,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 16362 | const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 16365 | const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 16363 | const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 16366 | const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 16364 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; | 16367 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 16365 | const dest_ptr = sema.resolveInst(extra.dest); | 16368 | const dest_ptr = try sema.resolveInst(extra.dest); |
| 16366 | const dest_ptr_ty = sema.typeOf(dest_ptr); | 16369 | const dest_ptr_ty = sema.typeOf(dest_ptr); |
| 16367 | | 16370 | |
| 16368 | try sema.checkPtrOperand(block, dest_src, dest_ptr_ty); | 16371 | try sema.checkPtrOperand(block, dest_src, dest_ptr_ty); |
| ... | @@ -16370,7 +16373,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -16370,7 +16373,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 16370 | return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)}); | 16373 | return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)}); |
| 16371 | } | 16374 | } |
| 16372 | | 16375 | |
| 16373 | const uncasted_src_ptr = sema.resolveInst(extra.source); | 16376 | const uncasted_src_ptr = try sema.resolveInst(extra.source); |
| 16374 | const uncasted_src_ptr_ty = sema.typeOf(uncasted_src_ptr); | 16377 | const uncasted_src_ptr_ty = sema.typeOf(uncasted_src_ptr); |
| 16375 | try sema.checkPtrOperand(block, src_src, uncasted_src_ptr_ty); | 16378 | try sema.checkPtrOperand(block, src_src, uncasted_src_ptr_ty); |
| 16376 | const src_ptr_info = uncasted_src_ptr_ty.ptrInfo().data; | 16379 | const src_ptr_info = uncasted_src_ptr_ty.ptrInfo().data; |
| ... | @@ -16384,7 +16387,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -16384,7 +16387,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 16384 | .size = .Many, | 16387 | .size = .Many, |
| 16385 | }); | 16388 | }); |
| 16386 | const src_ptr = try sema.coerce(block, wanted_src_ptr_ty, uncasted_src_ptr, src_src); | 16389 | const src_ptr = try sema.coerce(block, wanted_src_ptr_ty, uncasted_src_ptr, src_src); |
| 16387 | const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src); | 16390 | const len = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.byte_count), len_src); |
| 16388 | | 16391 | |
| 16389 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: { | 16392 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: { |
| 16390 | if (!dest_ptr_val.isComptimeMutablePtr()) break :rs dest_src; | 16393 | if (!dest_ptr_val.isComptimeMutablePtr()) break :rs dest_src; |
| ... | @@ -16419,15 +16422,15 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -16419,15 +16422,15 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 16419 | const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 16422 | const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 16420 | const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 16423 | const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 16421 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; | 16424 | const len_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 16422 | const dest_ptr = sema.resolveInst(extra.dest); | 16425 | const dest_ptr = try sema.resolveInst(extra.dest); |
| 16423 | const dest_ptr_ty = sema.typeOf(dest_ptr); | 16426 | const dest_ptr_ty = sema.typeOf(dest_ptr); |
| 16424 | try sema.checkPtrOperand(block, dest_src, dest_ptr_ty); | 16427 | try sema.checkPtrOperand(block, dest_src, dest_ptr_ty); |
| 16425 | if (dest_ptr_ty.isConstPtr()) { | 16428 | if (dest_ptr_ty.isConstPtr()) { |
| 16426 | return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)}); | 16429 | return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)}); |
| 16427 | } | 16430 | } |
| 16428 | const elem_ty = dest_ptr_ty.elemType2(); | 16431 | const elem_ty = dest_ptr_ty.elemType2(); |
| 16429 | const value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.byte), value_src); | 16432 | const value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.byte), value_src); |
| 16430 | const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src); | 16433 | const len = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.byte_count), len_src); |
| 16431 | | 16434 | |
| 16432 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |ptr_val| rs: { | 16435 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |ptr_val| rs: { |
| 16433 | if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src; | 16436 | if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src; |
| ... | @@ -16521,7 +16524,7 @@ fn zirVarExtended( | ... | @@ -16521,7 +16524,7 @@ fn zirVarExtended( |
| 16521 | const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { | 16524 | const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { |
| 16522 | const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); | 16525 | const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 16523 | extra_index += 1; | 16526 | extra_index += 1; |
| 16524 | break :blk sema.resolveInst(init_ref); | 16527 | break :blk try sema.resolveInst(init_ref); |
| 16525 | } else .none; | 16528 | } else .none; |
| 16526 | | 16529 | |
| 16527 | const have_ty = extra.data.var_type != .none; | 16530 | const have_ty = extra.data.var_type != .none; |
| ... | @@ -16669,7 +16672,7 @@ fn zirCDefine( | ... | @@ -16669,7 +16672,7 @@ fn zirCDefine( |
| 16669 | const val_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 16672 | const val_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 16670 | | 16673 | |
| 16671 | const name = try sema.resolveConstString(block, name_src, extra.lhs); | 16674 | const name = try sema.resolveConstString(block, name_src, extra.lhs); |
| 16672 | const rhs = sema.resolveInst(extra.rhs); | 16675 | const rhs = try sema.resolveInst(extra.rhs); |
| 16673 | if (sema.typeOf(rhs).zigTypeTag() != .Void) { | 16676 | if (sema.typeOf(rhs).zigTypeTag() != .Void) { |
| 16674 | const value = try sema.resolveConstString(block, val_src, extra.rhs); | 16677 | const value = try sema.resolveConstString(block, val_src, extra.rhs); |
| 16675 | try block.c_import_buf.?.writer().print("#define {s} {s}\n", .{ name, value }); | 16678 | try block.c_import_buf.?.writer().print("#define {s} {s}\n", .{ name, value }); |
| ... | @@ -16718,7 +16721,7 @@ fn zirWasmMemoryGrow( | ... | @@ -16718,7 +16721,7 @@ fn zirWasmMemoryGrow( |
| 16718 | } | 16721 | } |
| 16719 | | 16722 | |
| 16720 | const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.lhs, Type.u32)); | 16723 | const index = @intCast(u32, try sema.resolveInt(block, index_src, extra.lhs, Type.u32)); |
| 16721 | const delta = try sema.coerce(block, Type.u32, sema.resolveInst(extra.rhs), delta_src); | 16724 | const delta = try sema.coerce(block, Type.u32, try sema.resolveInst(extra.rhs), delta_src); |
| 16722 | | 16725 | |
| 16723 | try sema.requireRuntimeBlock(block, builtin_src); | 16726 | try sema.requireRuntimeBlock(block, builtin_src); |
| 16724 | return block.addInst(.{ | 16727 | return block.addInst(.{ |
| ... | @@ -16739,9 +16742,9 @@ fn zirPrefetch( | ... | @@ -16739,9 +16742,9 @@ fn zirPrefetch( |
| 16739 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; | 16742 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 16740 | const opts_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 16743 | const opts_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 16741 | const options_ty = try sema.getBuiltinType(block, opts_src, "PrefetchOptions"); | 16744 | const options_ty = try sema.getBuiltinType(block, opts_src, "PrefetchOptions"); |
| 16742 | const ptr = sema.resolveInst(extra.lhs); | 16745 | const ptr = try sema.resolveInst(extra.lhs); |
| 16743 | try sema.checkPtrOperand(block, ptr_src, sema.typeOf(ptr)); | 16746 | try sema.checkPtrOperand(block, ptr_src, sema.typeOf(ptr)); |
| 16744 | const options = try sema.coerce(block, options_ty, sema.resolveInst(extra.rhs), opts_src); | 16747 | const options = try sema.coerce(block, options_ty, try sema.resolveInst(extra.rhs), opts_src); |
| 16745 | const target = sema.mod.getTarget(); | 16748 | const target = sema.mod.getTarget(); |
| 16746 | | 16749 | |
| 16747 | const rw = try sema.fieldVal(block, opts_src, options, "rw", opts_src); | 16750 | const rw = try sema.fieldVal(block, opts_src, options, "rw", opts_src); |
| ... | @@ -16782,7 +16785,7 @@ fn zirBuiltinExtern( | ... | @@ -16782,7 +16785,7 @@ fn zirBuiltinExtern( |
| 16782 | const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; | 16785 | const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 16783 | | 16786 | |
| 16784 | var ty = try sema.resolveType(block, ty_src, extra.lhs); | 16787 | var ty = try sema.resolveType(block, ty_src, extra.lhs); |
| 16785 | const options_inst = sema.resolveInst(extra.rhs); | 16788 | const options_inst = try sema.resolveInst(extra.rhs); |
| 16786 | const mod = sema.mod; | 16789 | const mod = sema.mod; |
| 16787 | | 16790 | |
| 16788 | const options = options: { | 16791 | const options = options: { |
| ... | @@ -20197,7 +20200,11 @@ fn beginComptimePtrLoad( | ... | @@ -20197,7 +20200,11 @@ fn beginComptimePtrLoad( |
| 20197 | var deref = try beginComptimePtrLoad(sema, block, src, field_ptr.container_ptr, field_ptr.container_ty); | 20200 | var deref = try beginComptimePtrLoad(sema, block, src, field_ptr.container_ptr, field_ptr.container_ty); |
| 20198 | | 20201 | |
| 20199 | if (field_ptr.container_ty.hasWellDefinedLayout()) { | 20202 | if (field_ptr.container_ty.hasWellDefinedLayout()) { |
| 20200 | if (deref.parent) |*parent| { | 20203 | const struct_ty = field_ptr.container_ty.castTag(.@"struct"); |
| | 20204 | if (struct_ty != null and struct_ty.?.data.layout == .Packed) { |
| | 20205 | // packed structs are not byte addressable |
| | 20206 | deref.parent = null; |
| | 20207 | } else if (deref.parent) |*parent| { |
| 20201 | // Update the byte offset (in-place) | 20208 | // Update the byte offset (in-place) |
| 20202 | try sema.resolveTypeLayout(block, src, field_ptr.container_ty); | 20209 | try sema.resolveTypeLayout(block, src, field_ptr.container_ty); |
| 20203 | const field_offset = field_ptr.container_ty.structFieldOffset(field_index, target); | 20210 | const field_offset = field_ptr.container_ty.structFieldOffset(field_index, target); |
| ... | @@ -20828,7 +20835,7 @@ fn analyzeDeclVal( | ... | @@ -20828,7 +20835,7 @@ fn analyzeDeclVal( |
| 20828 | const decl_ref = try sema.analyzeDeclRef(decl_index); | 20835 | const decl_ref = try sema.analyzeDeclRef(decl_index); |
| 20829 | const result = try sema.analyzeLoad(block, src, decl_ref, src); | 20836 | const result = try sema.analyzeLoad(block, src, decl_ref, src); |
| 20830 | if (Air.refToIndex(result)) |index| { | 20837 | if (Air.refToIndex(result)) |index| { |
| 20831 | if (sema.air_instructions.items(.tag)[index] == .constant) { | 20838 | if (sema.air_instructions.items(.tag)[index] == .constant and !block.is_typeof) { |
| 20832 | try sema.decl_val_table.put(sema.gpa, decl_index, result); | 20839 | try sema.decl_val_table.put(sema.gpa, decl_index, result); |
| 20833 | } | 20840 | } |
| 20834 | } | 20841 | } |
| ... | @@ -20959,8 +20966,14 @@ fn analyzeLoad( | ... | @@ -20959,8 +20966,14 @@ fn analyzeLoad( |
| 20959 | if (try sema.pointerDeref(block, ptr_src, ptr_val, ptr_ty)) |elem_val| { | 20966 | if (try sema.pointerDeref(block, ptr_src, ptr_val, ptr_ty)) |elem_val| { |
| 20960 | return sema.addConstant(elem_ty, elem_val); | 20967 | return sema.addConstant(elem_ty, elem_val); |
| 20961 | } | 20968 | } |
| | 20969 | if (block.is_typeof) { |
| | 20970 | return sema.addConstUndef(elem_ty); |
| | 20971 | } |
| 20962 | } | 20972 | } |
| 20963 | | 20973 | |
| | 20974 | const valid_rt = try sema.validateRunTimeType(block, src, elem_ty, false); |
| | 20975 | if (!valid_rt) return sema.failWithNeededComptime(block, src); |
| | 20976 | |
| 20964 | try sema.requireRuntimeBlock(block, src); | 20977 | try sema.requireRuntimeBlock(block, src); |
| 20965 | return block.addTyOp(.load, elem_ty, ptr); | 20978 | return block.addTyOp(.load, elem_ty, ptr); |
| 20966 | } | 20979 | } |
| ... | @@ -22845,7 +22858,7 @@ fn semaStructFields( | ... | @@ -22845,7 +22858,7 @@ fn semaStructFields( |
| 22845 | if (has_default) { | 22858 | if (has_default) { |
| 22846 | const default_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); | 22859 | const default_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); |
| 22847 | extra_index += 1; | 22860 | extra_index += 1; |
| 22848 | const default_inst = sema.resolveInst(default_ref); | 22861 | const default_inst = try sema.resolveInst(default_ref); |
| 22849 | // TODO: if we need to report an error here, use a source location | 22862 | // TODO: if we need to report an error here, use a source location |
| 22850 | // that points to this default value expression rather than the struct. | 22863 | // that points to this default value expression rather than the struct. |
| 22851 | // But only resolve the source location if we need to emit a compile error. | 22864 | // But only resolve the source location if we need to emit a compile error. |
| ... | @@ -23029,7 +23042,7 @@ fn semaUnionFields(block: *Block, mod: *Module, union_obj: *Module.Union) Compil | ... | @@ -23029,7 +23042,7 @@ fn semaUnionFields(block: *Block, mod: *Module, union_obj: *Module.Union) Compil |
| 23029 | const tag_ref: Zir.Inst.Ref = if (has_tag) blk: { | 23042 | const tag_ref: Zir.Inst.Ref = if (has_tag) blk: { |
| 23030 | const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); | 23043 | const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); |
| 23031 | extra_index += 1; | 23044 | extra_index += 1; |
| 23032 | break :blk sema.resolveInst(tag_ref); | 23045 | break :blk try sema.resolveInst(tag_ref); |
| 23033 | } else .none; | 23046 | } else .none; |
| 23034 | | 23047 | |
| 23035 | if (enum_value_map) |map| { | 23048 | if (enum_value_map) |map| { |
| ... | @@ -23654,7 +23667,7 @@ fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) CompileError!Air.Inst.Ref { | ... | @@ -23654,7 +23667,7 @@ fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) CompileError!Air.Inst.Ref { |
| 23654 | fn addBool(sema: *Sema, ty: Type, boolean: bool) CompileError!Air.Inst.Ref { | 23667 | fn addBool(sema: *Sema, ty: Type, boolean: bool) CompileError!Air.Inst.Ref { |
| 23655 | return switch (ty.zigTypeTag()) { | 23668 | return switch (ty.zigTypeTag()) { |
| 23656 | .Vector => sema.addConstant(ty, try Value.Tag.repeated.create(sema.arena, Value.makeBool(boolean))), | 23669 | .Vector => sema.addConstant(ty, try Value.Tag.repeated.create(sema.arena, Value.makeBool(boolean))), |
| 23657 | .Bool => sema.resolveInst(if (boolean) .bool_true else .bool_false), | 23670 | .Bool => try sema.resolveInst(if (boolean) .bool_true else .bool_false), |
| 23658 | else => unreachable, | 23671 | else => unreachable, |
| 23659 | }; | 23672 | }; |
| 23660 | } | 23673 | } |