| ... | ... | @@ -584,7 +584,7 @@ fn resolveBody( |
| 584 | 584 | sema.comptime_break_inst = break_data.inst; |
| 585 | 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 | 590 | pub fn analyzeBody( |
| ... | ... | @@ -1191,7 +1191,7 @@ fn analyzeBodyInner( |
| 1191 | 1191 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1192 | 1192 | break always_noreturn; |
| 1193 | 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 | 1195 | } else { |
| 1196 | 1196 | break break_data.inst; |
| 1197 | 1197 | } |
| ... | ... | @@ -1214,7 +1214,7 @@ fn analyzeBodyInner( |
| 1214 | 1214 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1215 | 1215 | break always_noreturn; |
| 1216 | 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 | 1218 | } else { |
| 1219 | 1219 | break break_data.inst; |
| 1220 | 1220 | } |
| ... | ... | @@ -1283,7 +1283,7 @@ fn analyzeBodyInner( |
| 1283 | 1283 | |
| 1284 | 1284 | const break_data = opt_break_data orelse break always_noreturn; |
| 1285 | 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 | 1287 | } else { |
| 1288 | 1288 | break break_data.inst; |
| 1289 | 1289 | } |
| ... | ... | @@ -1301,7 +1301,7 @@ fn analyzeBodyInner( |
| 1301 | 1301 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1302 | 1302 | break always_noreturn; |
| 1303 | 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 | 1305 | } else { |
| 1306 | 1306 | break break_data.inst; |
| 1307 | 1307 | } |
| ... | ... | @@ -1317,7 +1317,7 @@ fn analyzeBodyInner( |
| 1317 | 1317 | const break_data = (try sema.analyzeBodyBreak(block, inline_body)) orelse |
| 1318 | 1318 | break always_noreturn; |
| 1319 | 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 | 1321 | } else { |
| 1322 | 1322 | break break_data.inst; |
| 1323 | 1323 | } |
| ... | ... | @@ -1350,7 +1350,7 @@ fn analyzeBodyInner( |
| 1350 | 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 | 1354 | var i: usize = @enumToInt(zir_ref); |
| 1355 | 1355 | |
| 1356 | 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 | 1361 | i -= Zir.Inst.Ref.typed_value_map.len; |
| 1362 | 1362 | |
| 1363 | 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 | 1369 | fn resolveConstBool( |
| ... | ... | @@ -1370,7 +1372,7 @@ fn resolveConstBool( |
| 1370 | 1372 | src: LazySrcLoc, |
| 1371 | 1373 | zir_ref: Zir.Inst.Ref, |
| 1372 | 1374 | ) !bool { |
| 1373 | | const air_inst = sema.resolveInst(zir_ref); |
| 1375 | const air_inst = try sema.resolveInst(zir_ref); |
| 1374 | 1376 | const wanted_type = Type.bool; |
| 1375 | 1377 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1376 | 1378 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| ... | ... | @@ -1383,7 +1385,7 @@ pub fn resolveConstString( |
| 1383 | 1385 | src: LazySrcLoc, |
| 1384 | 1386 | zir_ref: Zir.Inst.Ref, |
| 1385 | 1387 | ) ![]u8 { |
| 1386 | | const air_inst = sema.resolveInst(zir_ref); |
| 1388 | const air_inst = try sema.resolveInst(zir_ref); |
| 1387 | 1389 | const wanted_type = Type.initTag(.const_slice_u8); |
| 1388 | 1390 | const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src); |
| 1389 | 1391 | const val = try sema.resolveConstValue(block, src, coerced_inst); |
| ... | ... | @@ -1391,7 +1393,7 @@ pub fn resolveConstString( |
| 1391 | 1393 | } |
| 1392 | 1394 | |
| 1393 | 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 | 1397 | const ty = try sema.analyzeAsType(block, src, air_inst); |
| 1396 | 1398 | if (ty.tag() == .generic_poison) return error.GenericPoison; |
| 1397 | 1399 | return ty; |
| ... | ... | @@ -1513,6 +1515,7 @@ fn resolveDefinedValue( |
| 1513 | 1515 | ) CompileError!?Value { |
| 1514 | 1516 | if (try sema.resolveMaybeUndefVal(block, src, air_ref)) |val| { |
| 1515 | 1517 | if (val.isUndef()) { |
| 1518 | if (block.is_typeof) return null; |
| 1516 | 1519 | return sema.failWithUseOfUndef(block, src); |
| 1517 | 1520 | } |
| 1518 | 1521 | return val; |
| ... | ... | @@ -1737,7 +1740,7 @@ fn resolveInt( |
| 1737 | 1740 | zir_ref: Zir.Inst.Ref, |
| 1738 | 1741 | dest_ty: Type, |
| 1739 | 1742 | ) !u64 { |
| 1740 | | const air_inst = sema.resolveInst(zir_ref); |
| 1743 | const air_inst = try sema.resolveInst(zir_ref); |
| 1741 | 1744 | const coerced = try sema.coerce(block, dest_ty, air_inst, src); |
| 1742 | 1745 | const val = try sema.resolveConstValue(block, src, coerced); |
| 1743 | 1746 | const target = sema.mod.getTarget(); |
| ... | ... | @@ -1752,7 +1755,7 @@ pub fn resolveInstConst( |
| 1752 | 1755 | src: LazySrcLoc, |
| 1753 | 1756 | zir_ref: Zir.Inst.Ref, |
| 1754 | 1757 | ) CompileError!TypedValue { |
| 1755 | | const air_ref = sema.resolveInst(zir_ref); |
| 1758 | const air_ref = try sema.resolveInst(zir_ref); |
| 1756 | 1759 | const val = try sema.resolveConstValue(block, src, air_ref); |
| 1757 | 1760 | return TypedValue{ |
| 1758 | 1761 | .ty = sema.typeOf(air_ref), |
| ... | ... | @@ -1768,7 +1771,7 @@ pub fn resolveInstValue( |
| 1768 | 1771 | src: LazySrcLoc, |
| 1769 | 1772 | zir_ref: Zir.Inst.Ref, |
| 1770 | 1773 | ) CompileError!TypedValue { |
| 1771 | | const air_ref = sema.resolveInst(zir_ref); |
| 1774 | const air_ref = try sema.resolveInst(zir_ref); |
| 1772 | 1775 | const val = try sema.resolveValue(block, src, air_ref); |
| 1773 | 1776 | return TypedValue{ |
| 1774 | 1777 | .ty = sema.typeOf(air_ref), |
| ... | ... | @@ -1783,7 +1786,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 1783 | 1786 | const src: LazySrcLoc = sema.src; |
| 1784 | 1787 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 1785 | 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 | 1790 | const target = sema.mod.getTarget(); |
| 1788 | 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 | 2534 | defer tracy.end(); |
| 2532 | 2535 | |
| 2533 | 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 | 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 | 2553 | defer tracy.end(); |
| 2551 | 2554 | |
| 2552 | 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 | 2557 | const src = inst_data.src(); |
| 2555 | 2558 | |
| 2556 | 2559 | return sema.ensureResultUsed(block, operand, src); |
| ... | ... | @@ -2574,7 +2577,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 2574 | 2577 | defer tracy.end(); |
| 2575 | 2578 | |
| 2576 | 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 | 2581 | const src = inst_data.src(); |
| 2579 | 2582 | const operand_ty = sema.typeOf(operand); |
| 2580 | 2583 | switch (operand_ty.zigTypeTag()) { |
| ... | ... | @@ -2589,7 +2592,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 2589 | 2592 | |
| 2590 | 2593 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2591 | 2594 | const src = inst_data.src(); |
| 2592 | | const object = sema.resolveInst(inst_data.operand); |
| 2595 | const object = try sema.resolveInst(inst_data.operand); |
| 2593 | 2596 | const object_ty = sema.typeOf(object); |
| 2594 | 2597 | |
| 2595 | 2598 | const is_pointer_to = object_ty.isSinglePointer(); |
| ... | ... | @@ -2708,7 +2711,7 @@ fn zirAllocComptime(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 2708 | 2711 | |
| 2709 | 2712 | fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 2710 | 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 | 2715 | const ptr_ty = sema.typeOf(ptr); |
| 2713 | 2716 | var ptr_info = ptr_ty.ptrInfo().data; |
| 2714 | 2717 | ptr_info.mutable = false; |
| ... | ... | @@ -2824,7 +2827,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 2824 | 2827 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2825 | 2828 | const src = inst_data.src(); |
| 2826 | 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 | 2831 | const ptr_inst = Air.refToIndex(ptr).?; |
| 2829 | 2832 | assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant); |
| 2830 | 2833 | const value_index = sema.air_instructions.items(.data)[ptr_inst].ty_pl.payload; |
| ... | ... | @@ -2986,7 +2989,7 @@ fn zirArrayBasePtr( |
| 2986 | 2989 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 2987 | 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 | 2993 | var base_ptr = start_ptr; |
| 2991 | 2994 | while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) { |
| 2992 | 2995 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), |
| ... | ... | @@ -3011,7 +3014,7 @@ fn zirFieldBasePtr( |
| 3011 | 3014 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3012 | 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 | 3018 | var base_ptr = start_ptr; |
| 3016 | 3019 | while (true) switch (sema.typeOf(base_ptr).childType().zigTypeTag()) { |
| 3017 | 3020 | .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true), |
| ... | ... | @@ -3075,7 +3078,7 @@ fn zirValidateStructInit( |
| 3075 | 3078 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; |
| 3076 | 3079 | const field_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; |
| 3077 | 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 | 3082 | const agg_ty = sema.typeOf(object_ptr).childType(); |
| 3080 | 3083 | switch (agg_ty.zigTypeTag()) { |
| 3081 | 3084 | .Struct => return sema.validateStructInit( |
| ... | ... | @@ -3251,7 +3254,7 @@ fn validateStructInit( |
| 3251 | 3254 | var root_msg: ?*Module.ErrorMsg = null; |
| 3252 | 3255 | |
| 3253 | 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 | 3258 | const struct_ty = sema.typeOf(struct_ptr).childType(); |
| 3256 | 3259 | |
| 3257 | 3260 | if (is_comptime or block.is_comptime) { |
| ... | ... | @@ -3448,7 +3451,7 @@ fn zirValidateArrayInit( |
| 3448 | 3451 | const instrs = sema.code.extra[validate_extra.end..][0..validate_extra.data.body_len]; |
| 3449 | 3452 | const first_elem_ptr_data = sema.code.instructions.items(.data)[instrs[0]].pl_node; |
| 3450 | 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 | 3455 | const array_ty = sema.typeOf(array_ptr).childType(); |
| 3453 | 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 | 3649 | // This is an elided instruction, but AstGen was unable to omit it. |
| 3647 | 3650 | return; |
| 3648 | 3651 | }; |
| 3649 | | const operand = sema.resolveInst(bin_inst.rhs); |
| 3652 | const operand = try sema.resolveInst(bin_inst.rhs); |
| 3650 | 3653 | const src: LazySrcLoc = sema.src; |
| 3651 | 3654 | blk: { |
| 3652 | 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 | 3678 | |
| 3676 | 3679 | const src: LazySrcLoc = sema.src; |
| 3677 | 3680 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 3678 | | const ptr = sema.resolveInst(bin_inst.lhs); |
| 3679 | | const operand = sema.resolveInst(bin_inst.rhs); |
| 3681 | const ptr = try sema.resolveInst(bin_inst.lhs); |
| 3682 | const operand = try sema.resolveInst(bin_inst.rhs); |
| 3680 | 3683 | const ptr_inst = Air.refToIndex(ptr).?; |
| 3681 | 3684 | assert(sema.air_instructions.items(.tag)[ptr_inst] == .constant); |
| 3682 | 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 | 3761 | defer tracy.end(); |
| 3759 | 3762 | |
| 3760 | 3763 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 3761 | | const ptr = sema.resolveInst(bin_inst.lhs); |
| 3762 | | const value = sema.resolveInst(bin_inst.rhs); |
| 3764 | const ptr = try sema.resolveInst(bin_inst.lhs); |
| 3765 | const value = try sema.resolveInst(bin_inst.rhs); |
| 3763 | 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 | 3775 | const inst_data = zir_datas[inst].pl_node; |
| 3773 | 3776 | const src = inst_data.src(); |
| 3774 | 3777 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 3775 | | const ptr = sema.resolveInst(extra.lhs); |
| 3776 | | const operand = sema.resolveInst(extra.rhs); |
| 3778 | const ptr = try sema.resolveInst(extra.lhs); |
| 3779 | const operand = try sema.resolveInst(extra.rhs); |
| 3777 | 3780 | |
| 3778 | 3781 | // Check for the possibility of this pattern: |
| 3779 | 3782 | // %a = ret_ptr |
| ... | ... | @@ -3798,7 +3801,7 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 3798 | 3801 | const callee_src = sema.src; |
| 3799 | 3802 | |
| 3800 | 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 | 3805 | const callee_ty = sema.typeOf(callee); |
| 3803 | 3806 | var param_index = inst_data.param_index; |
| 3804 | 3807 | |
| ... | ... | @@ -3959,7 +3962,7 @@ fn zirCompileLog( |
| 3959 | 3962 | for (args) |arg_ref, i| { |
| 3960 | 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 | 3966 | const arg_ty = sema.typeOf(arg); |
| 3964 | 3967 | if (try sema.resolveMaybeUndefVal(block, src, arg)) |val| { |
| 3965 | 3968 | try writer.print("@as({}, {})", .{ |
| ... | ... | @@ -3981,7 +3984,7 @@ fn zirCompileLog( |
| 3981 | 3984 | fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir.Inst.Index { |
| 3982 | 3985 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 3983 | 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 | 3989 | return sema.panicWithMsg(block, src, msg_inst); |
| 3987 | 3990 | } |
| ... | ... | @@ -4205,7 +4208,7 @@ fn resolveBlockBody( |
| 4205 | 4208 | const break_inst = sema.comptime_break_inst; |
| 4206 | 4209 | const break_data = sema.code.instructions.items(.data)[break_inst].@"break"; |
| 4207 | 4210 | if (break_data.block_inst == body_inst) { |
| 4208 | | return sema.resolveInst(break_data.operand); |
| 4211 | return try sema.resolveInst(break_data.operand); |
| 4209 | 4212 | } else { |
| 4210 | 4213 | return error.ComptimeBreak; |
| 4211 | 4214 | } |
| ... | ... | @@ -4535,7 +4538,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError |
| 4535 | 4538 | defer tracy.end(); |
| 4536 | 4539 | |
| 4537 | 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 | 4542 | const zir_block = inst_data.block_inst; |
| 4540 | 4543 | |
| 4541 | 4544 | var block = start_block; |
| ... | ... | @@ -4601,7 +4604,7 @@ fn zirDbgVar( |
| 4601 | 4604 | if (block.is_comptime or sema.mod.comp.bin_file.options.strip) return; |
| 4602 | 4605 | |
| 4603 | 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 | 4608 | const name = str_op.getStr(sema.code); |
| 4606 | 4609 | try sema.addDbgVar(block, operand, air_tag, name); |
| 4607 | 4610 | } |
| ... | ... | @@ -4784,7 +4787,7 @@ fn zirCall( |
| 4784 | 4787 | const modifier = @intToEnum(std.builtin.CallOptions.Modifier, extra.data.flags.packed_modifier); |
| 4785 | 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 | 4791 | var resolved_args: []Air.Inst.Ref = undefined; |
| 4789 | 4792 | |
| 4790 | 4793 | const func_type = sema.typeOf(func); |
| ... | ... | @@ -4797,12 +4800,12 @@ fn zirCall( |
| 4797 | 4800 | resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len + 1); |
| 4798 | 4801 | resolved_args[0] = bound_data.arg0_inst; |
| 4799 | 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 | 4805 | } else { |
| 4803 | 4806 | resolved_args = try sema.arena.alloc(Air.Inst.Ref, args.len); |
| 4804 | 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 | 5829 | const elem_src: LazySrcLoc = .{ .node_offset_array_type_elem = inst_data.src_node }; |
| 5827 | 5830 | const len = try sema.resolveInt(block, len_src, extra.len, Type.usize); |
| 5828 | 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 | 5833 | const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src); |
| 5831 | 5834 | const sentinel_val = try sema.resolveConstValue(block, sentinel_src, sentinel); |
| 5832 | 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 | 5894 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5892 | 5895 | const src = inst_data.src(); |
| 5893 | 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 | 5898 | const op_coerced = try sema.coerce(block, Type.anyerror, op, operand_src); |
| 5896 | 5899 | const result_ty = Type.u16; |
| 5897 | 5900 | |
| ... | ... | @@ -5928,7 +5931,7 @@ fn zirIntToError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 5928 | 5931 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 5929 | 5932 | const src = inst_data.src(); |
| 5930 | 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 | 5935 | const operand = try sema.coerce(block, Type.u16, uncasted_operand, operand_src); |
| 5933 | 5936 | const target = sema.mod.getTarget(); |
| 5934 | 5937 | |
| ... | ... | @@ -5966,8 +5969,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 5966 | 5969 | const src: LazySrcLoc = .{ .node_offset_bin_op = inst_data.src_node }; |
| 5967 | 5970 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 5968 | 5971 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 5969 | | const lhs = sema.resolveInst(extra.lhs); |
| 5970 | | const rhs = sema.resolveInst(extra.rhs); |
| 5972 | const lhs = try sema.resolveInst(extra.lhs); |
| 5973 | const rhs = try sema.resolveInst(extra.rhs); |
| 5971 | 5974 | if (sema.typeOf(lhs).zigTypeTag() == .Bool and sema.typeOf(rhs).zigTypeTag() == .Bool) { |
| 5972 | 5975 | const msg = msg: { |
| 5973 | 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 | 6029 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6027 | 6030 | const src = inst_data.src(); |
| 6028 | 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 | 6033 | const operand_ty = sema.typeOf(operand); |
| 6031 | 6034 | |
| 6032 | 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 | 6077 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 6075 | 6078 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 6076 | 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 | 6082 | if (dest_ty.zigTypeTag() != .Enum) { |
| 6080 | 6083 | return sema.fail(block, dest_ty_src, "expected enum, found {}", .{dest_ty.fmt(sema.mod)}); |
| ... | ... | @@ -6125,7 +6128,7 @@ fn zirOptionalPayloadPtr( |
| 6125 | 6128 | defer tracy.end(); |
| 6126 | 6129 | |
| 6127 | 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 | 6132 | const src = inst_data.src(); |
| 6130 | 6133 | |
| 6131 | 6134 | return sema.analyzeOptionalPayloadPtr(block, src, optional_ptr, safety_check, false); |
| ... | ... | @@ -6210,7 +6213,7 @@ fn zirOptionalPayload( |
| 6210 | 6213 | |
| 6211 | 6214 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6212 | 6215 | const src = inst_data.src(); |
| 6213 | | const operand = sema.resolveInst(inst_data.operand); |
| 6216 | const operand = try sema.resolveInst(inst_data.operand); |
| 6214 | 6217 | const operand_ty = sema.typeOf(operand); |
| 6215 | 6218 | const result_ty = switch (operand_ty.zigTypeTag()) { |
| 6216 | 6219 | .Optional => try operand_ty.optionalChildAlloc(sema.arena), |
| ... | ... | @@ -6262,7 +6265,7 @@ fn zirErrUnionPayload( |
| 6262 | 6265 | |
| 6263 | 6266 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6264 | 6267 | const src = inst_data.src(); |
| 6265 | | const operand = sema.resolveInst(inst_data.operand); |
| 6268 | const operand = try sema.resolveInst(inst_data.operand); |
| 6266 | 6269 | const operand_src = src; |
| 6267 | 6270 | const operand_ty = sema.typeOf(operand); |
| 6268 | 6271 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| ... | ... | @@ -6303,7 +6306,7 @@ fn zirErrUnionPayloadPtr( |
| 6303 | 6306 | defer tracy.end(); |
| 6304 | 6307 | |
| 6305 | 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 | 6310 | const src = inst_data.src(); |
| 6308 | 6311 | |
| 6309 | 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 | 6392 | |
| 6390 | 6393 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6391 | 6394 | const src = inst_data.src(); |
| 6392 | | const operand = sema.resolveInst(inst_data.operand); |
| 6395 | const operand = try sema.resolveInst(inst_data.operand); |
| 6393 | 6396 | const operand_ty = sema.typeOf(operand); |
| 6394 | 6397 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| 6395 | 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 | 6418 | |
| 6416 | 6419 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6417 | 6420 | const src = inst_data.src(); |
| 6418 | | const operand = sema.resolveInst(inst_data.operand); |
| 6421 | const operand = try sema.resolveInst(inst_data.operand); |
| 6419 | 6422 | const operand_ty = sema.typeOf(operand); |
| 6420 | 6423 | assert(operand_ty.zigTypeTag() == .Pointer); |
| 6421 | 6424 | |
| ... | ... | @@ -6444,7 +6447,7 @@ fn zirEnsureErrPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 6444 | 6447 | |
| 6445 | 6448 | const inst_data = sema.code.instructions.items(.data)[inst].un_tok; |
| 6446 | 6449 | const src = inst_data.src(); |
| 6447 | | const operand = sema.resolveInst(inst_data.operand); |
| 6450 | const operand = try sema.resolveInst(inst_data.operand); |
| 6448 | 6451 | const operand_ty = sema.typeOf(operand); |
| 6449 | 6452 | if (operand_ty.zigTypeTag() != .ErrorUnion) { |
| 6450 | 6453 | return sema.fail(block, src, "expected error union type, found '{}'", .{ |
| ... | ... | @@ -6940,7 +6943,7 @@ fn analyzeAs( |
| 6940 | 6943 | zir_operand: Zir.Inst.Ref, |
| 6941 | 6944 | ) CompileError!Air.Inst.Ref { |
| 6942 | 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 | 6947 | if (dest_ty.tag() == .var_args_param) return operand; |
| 6945 | 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 | 6954 | |
| 6952 | 6955 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 6953 | 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 | 6958 | const ptr_ty = sema.typeOf(ptr); |
| 6956 | 6959 | if (!ptr_ty.isPtrAtRuntime()) { |
| 6957 | 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 | 6975 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 6973 | 6976 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 6974 | 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 | 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 | 6988 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 6986 | 6989 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 6987 | 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 | 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 | 7001 | const field_name_src: LazySrcLoc = .{ .node_offset_field_name = inst_data.src_node }; |
| 6999 | 7002 | const extra = sema.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 7000 | 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 | 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 | 7013 | const src = inst_data.src(); |
| 7011 | 7014 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 7012 | 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 | 7017 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 7015 | 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 | 7026 | const src = inst_data.src(); |
| 7024 | 7027 | const field_name_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 7025 | 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 | 7030 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 7028 | 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 | 7038 | const extra = sema.code.extraData(Zir.Inst.FieldNamedNode, extended.operand).data; |
| 7036 | 7039 | const src: LazySrcLoc = .{ .node_offset = extra.node }; |
| 7037 | 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 | 7042 | const field_name = try sema.resolveConstString(block, field_name_src, extra.field_name); |
| 7040 | 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 | 7053 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7051 | 7054 | |
| 7052 | 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 | 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 | 7243 | => {}, |
| 7241 | 7244 | } |
| 7242 | 7245 | |
| 7243 | | const operand = sema.resolveInst(extra.rhs); |
| 7246 | const operand = try sema.resolveInst(extra.rhs); |
| 7244 | 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 | 7258 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7256 | 7259 | |
| 7257 | 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 | 7263 | const target = sema.mod.getTarget(); |
| 7261 | 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 | 7303 | defer tracy.end(); |
| 7301 | 7304 | |
| 7302 | 7305 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 7303 | | const array = sema.resolveInst(bin_inst.lhs); |
| 7304 | | const elem_index = sema.resolveInst(bin_inst.rhs); |
| 7306 | const array = try sema.resolveInst(bin_inst.lhs); |
| 7307 | const elem_index = try sema.resolveInst(bin_inst.rhs); |
| 7305 | 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 | 7316 | const src = inst_data.src(); |
| 7314 | 7317 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 7315 | 7318 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7316 | | const array = sema.resolveInst(extra.lhs); |
| 7317 | | const elem_index = sema.resolveInst(extra.rhs); |
| 7319 | const array = try sema.resolveInst(extra.lhs); |
| 7320 | const elem_index = try sema.resolveInst(extra.rhs); |
| 7318 | 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 | 7326 | defer tracy.end(); |
| 7324 | 7327 | |
| 7325 | 7328 | const bin_inst = sema.code.instructions.items(.data)[inst].bin; |
| 7326 | | const array_ptr = sema.resolveInst(bin_inst.lhs); |
| 7327 | | const elem_index = sema.resolveInst(bin_inst.rhs); |
| 7329 | const array_ptr = try sema.resolveInst(bin_inst.lhs); |
| 7330 | const elem_index = try sema.resolveInst(bin_inst.rhs); |
| 7328 | 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 | 7339 | const src = inst_data.src(); |
| 7337 | 7340 | const elem_index_src: LazySrcLoc = .{ .node_offset_array_access_index = inst_data.src_node }; |
| 7338 | 7341 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 7339 | | const array_ptr = sema.resolveInst(extra.lhs); |
| 7340 | | const elem_index = sema.resolveInst(extra.rhs); |
| 7342 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7343 | const elem_index = try sema.resolveInst(extra.rhs); |
| 7341 | 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 | 7351 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7349 | 7352 | const src = inst_data.src(); |
| 7350 | 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 | 7355 | const elem_index = try sema.addIntUnsigned(Type.usize, extra.index); |
| 7353 | 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 | 7363 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7361 | 7364 | const src = inst_data.src(); |
| 7362 | 7365 | const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| 7363 | | const array_ptr = sema.resolveInst(extra.lhs); |
| 7364 | | const start = sema.resolveInst(extra.start); |
| 7366 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7367 | const start = try sema.resolveInst(extra.start); |
| 7365 | 7368 | |
| 7366 | 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 | 7376 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 7374 | 7377 | const src = inst_data.src(); |
| 7375 | 7378 | const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| 7376 | | const array_ptr = sema.resolveInst(extra.lhs); |
| 7377 | | const start = sema.resolveInst(extra.start); |
| 7378 | | const end = sema.resolveInst(extra.end); |
| 7379 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7380 | const start = try sema.resolveInst(extra.start); |
| 7381 | const end = try sema.resolveInst(extra.end); |
| 7379 | 7382 | |
| 7380 | 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 | 7391 | const src = inst_data.src(); |
| 7389 | 7392 | const sentinel_src: LazySrcLoc = .{ .node_offset_slice_sentinel = inst_data.src_node }; |
| 7390 | 7393 | const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; |
| 7391 | | const array_ptr = sema.resolveInst(extra.lhs); |
| 7392 | | const start = sema.resolveInst(extra.start); |
| 7393 | | const end = sema.resolveInst(extra.end); |
| 7394 | | const sentinel = sema.resolveInst(extra.sentinel); |
| 7394 | const array_ptr = try sema.resolveInst(extra.lhs); |
| 7395 | const start = try sema.resolveInst(extra.start); |
| 7396 | const end = try sema.resolveInst(extra.end); |
| 7397 | const sentinel = try sema.resolveInst(extra.sentinel); |
| 7395 | 7398 | |
| 7396 | 7399 | return sema.analyzeSlice(block, src, array_ptr, start, end, sentinel, sentinel_src); |
| 7397 | 7400 | } |
| ... | ... | @@ -7415,7 +7418,7 @@ fn zirSwitchCapture( |
| 7415 | 7418 | const operand_is_ref = switch_extra.data.bits.is_ref; |
| 7416 | 7419 | const cond_inst = Zir.refToIndex(switch_extra.data.operand).?; |
| 7417 | 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 | 7422 | const operand_ptr_ty = sema.typeOf(operand_ptr); |
| 7420 | 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 | 7452 | const union_obj = operand_ty.cast(Type.Payload.Union).?.data; |
| 7450 | 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 | 7456 | // Previous switch validation ensured this will succeed |
| 7454 | 7457 | const first_item_val = sema.resolveConstValue(block, .unneeded, first_item) catch unreachable; |
| 7455 | 7458 | |
| ... | ... | @@ -7457,7 +7460,7 @@ fn zirSwitchCapture( |
| 7457 | 7460 | const first_field = union_obj.fields.values()[first_field_index]; |
| 7458 | 7461 | |
| 7459 | 7462 | for (items[1..]) |item| { |
| 7460 | | const item_ref = sema.resolveInst(item); |
| 7463 | const item_ref = try sema.resolveInst(item); |
| 7461 | 7464 | // Previous switch validation ensured this will succeed |
| 7462 | 7465 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; |
| 7463 | 7466 | |
| ... | ... | @@ -7514,7 +7517,7 @@ fn zirSwitchCapture( |
| 7514 | 7517 | var names: Module.ErrorSet.NameMap = .{}; |
| 7515 | 7518 | try names.ensureUnusedCapacity(sema.arena, items.len); |
| 7516 | 7519 | for (items) |item| { |
| 7517 | | const item_ref = sema.resolveInst(item); |
| 7520 | const item_ref = try sema.resolveInst(item); |
| 7518 | 7521 | // Previous switch validation ensured this will succeed |
| 7519 | 7522 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; |
| 7520 | 7523 | names.putAssumeCapacityNoClobber( |
| ... | ... | @@ -7528,7 +7531,7 @@ fn zirSwitchCapture( |
| 7528 | 7531 | |
| 7529 | 7532 | return sema.bitCast(block, else_error_ty, operand, operand_src); |
| 7530 | 7533 | } else { |
| 7531 | | const item_ref = sema.resolveInst(items[0]); |
| 7534 | const item_ref = try sema.resolveInst(items[0]); |
| 7532 | 7535 | // Previous switch validation ensured this will succeed |
| 7533 | 7536 | const item_val = sema.resolveConstValue(block, .unneeded, item_ref) catch unreachable; |
| 7534 | 7537 | |
| ... | ... | @@ -7558,7 +7561,7 @@ fn zirSwitchCond( |
| 7558 | 7561 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 7559 | 7562 | const src = inst_data.src(); |
| 7560 | 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 | 7565 | const operand = if (is_ref) |
| 7563 | 7566 | try sema.analyzeLoad(block, src, operand_ptr, operand_src) |
| 7564 | 7567 | else |
| ... | ... | @@ -7629,7 +7632,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 7629 | 7632 | const special_prong_src: LazySrcLoc = .{ .node_offset_switch_special_prong = src_node_offset }; |
| 7630 | 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 | 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 | 8210 | const body = sema.code.extra[extra_index..][0..body_len]; |
| 8208 | 8211 | extra_index += body_len; |
| 8209 | 8212 | |
| 8210 | | const item = sema.resolveInst(item_ref); |
| 8213 | const item = try sema.resolveInst(item_ref); |
| 8211 | 8214 | // Validation above ensured these will succeed. |
| 8212 | 8215 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable; |
| 8213 | 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 | 8232 | const body = sema.code.extra[extra_index + 2 * ranges_len ..][0..body_len]; |
| 8230 | 8233 | |
| 8231 | 8234 | for (items) |item_ref| { |
| 8232 | | const item = sema.resolveInst(item_ref); |
| 8235 | const item = try sema.resolveInst(item_ref); |
| 8233 | 8236 | // Validation above ensured these will succeed. |
| 8234 | 8237 | const item_val = sema.resolveConstValue(&child_block, .unneeded, item) catch unreachable; |
| 8235 | 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 | 8300 | case_block.instructions.shrinkRetainingCapacity(0); |
| 8298 | 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 | 8304 | // `item` is already guaranteed to be constant known. |
| 8302 | 8305 | |
| 8303 | 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 | 8377 | cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len)); |
| 8375 | 8378 | |
| 8376 | 8379 | for (items) |item_ref| { |
| 8377 | | const item = sema.resolveInst(item_ref); |
| 8380 | const item = try sema.resolveInst(item_ref); |
| 8378 | 8381 | cases_extra.appendAssumeCapacity(@enumToInt(item)); |
| 8379 | 8382 | } |
| 8380 | 8383 | |
| 8381 | 8384 | cases_extra.appendSliceAssumeCapacity(case_block.instructions.items); |
| 8382 | 8385 | } else { |
| 8383 | 8386 | for (items) |item_ref| { |
| 8384 | | const item = sema.resolveInst(item_ref); |
| 8387 | const item = try sema.resolveInst(item_ref); |
| 8385 | 8388 | const cmp_ok = try case_block.addBinOp(.cmp_eq, operand, item); |
| 8386 | 8389 | if (any_ok != .none) { |
| 8387 | 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 | 8400 | const last_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 8398 | 8401 | extra_index += 1; |
| 8399 | 8402 | |
| 8400 | | const item_first = sema.resolveInst(first_ref); |
| 8401 | | const item_last = sema.resolveInst(last_ref); |
| 8403 | const item_first = try sema.resolveInst(first_ref); |
| 8404 | const item_last = try sema.resolveInst(last_ref); |
| 8402 | 8405 | |
| 8403 | 8406 | // operand >= first and operand <= last |
| 8404 | 8407 | const range_first_ok = try case_block.addBinOp( |
| ... | ... | @@ -8551,7 +8554,7 @@ fn resolveSwitchItemVal( |
| 8551 | 8554 | switch_prong_src: Module.SwitchProngSrc, |
| 8552 | 8555 | range_expand: Module.SwitchProngSrc.RangeExpand, |
| 8553 | 8556 | ) CompileError!TypedValue { |
| 8554 | | const item = sema.resolveInst(item_ref); |
| 8557 | const item = try sema.resolveInst(item_ref); |
| 8555 | 8558 | const item_ty = sema.typeOf(item); |
| 8556 | 8559 | // Constructing a LazySrcLoc is costly because we only have the switch AST node. |
| 8557 | 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 | 8905 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 8903 | 8906 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 8904 | 8907 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8905 | | const lhs = sema.resolveInst(extra.lhs); |
| 8906 | | const rhs = sema.resolveInst(extra.rhs); |
| 8908 | const lhs = try sema.resolveInst(extra.lhs); |
| 8909 | const rhs = try sema.resolveInst(extra.rhs); |
| 8907 | 8910 | const lhs_ty = sema.typeOf(lhs); |
| 8908 | 8911 | const rhs_ty = sema.typeOf(rhs); |
| 8909 | 8912 | const target = sema.mod.getTarget(); |
| ... | ... | @@ -9030,8 +9033,8 @@ fn zirShr( |
| 9030 | 9033 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 9031 | 9034 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 9032 | 9035 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9033 | | const lhs = sema.resolveInst(extra.lhs); |
| 9034 | | const rhs = sema.resolveInst(extra.rhs); |
| 9036 | const lhs = try sema.resolveInst(extra.lhs); |
| 9037 | const rhs = try sema.resolveInst(extra.rhs); |
| 9035 | 9038 | const lhs_ty = sema.typeOf(lhs); |
| 9036 | 9039 | const rhs_ty = sema.typeOf(rhs); |
| 9037 | 9040 | try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src); |
| ... | ... | @@ -9084,8 +9087,8 @@ fn zirBitwise( |
| 9084 | 9087 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 9085 | 9088 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 9086 | 9089 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9087 | | const lhs = sema.resolveInst(extra.lhs); |
| 9088 | | const rhs = sema.resolveInst(extra.rhs); |
| 9090 | const lhs = try sema.resolveInst(extra.lhs); |
| 9091 | const rhs = try sema.resolveInst(extra.rhs); |
| 9089 | 9092 | const lhs_ty = sema.typeOf(lhs); |
| 9090 | 9093 | const rhs_ty = sema.typeOf(rhs); |
| 9091 | 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 | 9132 | const src = inst_data.src(); |
| 9130 | 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 | 9136 | const operand_type = sema.typeOf(operand); |
| 9134 | 9137 | const scalar_type = operand_type.scalarType(); |
| 9135 | 9138 | const target = sema.mod.getTarget(); |
| ... | ... | @@ -9244,8 +9247,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 9244 | 9247 | |
| 9245 | 9248 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9246 | 9249 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9247 | | const lhs = sema.resolveInst(extra.lhs); |
| 9248 | | const rhs = sema.resolveInst(extra.rhs); |
| 9250 | const lhs = try sema.resolveInst(extra.lhs); |
| 9251 | const rhs = try sema.resolveInst(extra.rhs); |
| 9249 | 9252 | const lhs_ty = sema.typeOf(lhs); |
| 9250 | 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 | 9431 | |
| 9429 | 9432 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 9430 | 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 | 9435 | const lhs_ty = sema.typeOf(lhs); |
| 9433 | 9436 | const src: LazySrcLoc = inst_data.src(); |
| 9434 | 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 | 9511 | const lhs_src = src; |
| 9509 | 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 | 9515 | const rhs_ty = sema.typeOf(rhs); |
| 9513 | 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 | 9531 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) |
| 9529 | 9532 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) |
| 9530 | 9533 | else |
| 9531 | | sema.resolveInst(.zero); |
| 9534 | try sema.resolveInst(.zero); |
| 9532 | 9535 | |
| 9533 | 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 | 9542 | const lhs_src = src; |
| 9540 | 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 | 9546 | const rhs_ty = sema.typeOf(rhs); |
| 9544 | 9547 | |
| 9545 | 9548 | const lhs = if (rhs_ty.zigTypeTag() == .Vector) |
| 9546 | 9549 | try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, Value.zero)) |
| 9547 | 9550 | else |
| 9548 | | sema.resolveInst(.zero); |
| 9551 | try sema.resolveInst(.zero); |
| 9549 | 9552 | |
| 9550 | 9553 | return sema.analyzeArithmetic(block, .subwrap, lhs, rhs, src, lhs_src, rhs_src); |
| 9551 | 9554 | } |
| ... | ... | @@ -9564,8 +9567,8 @@ fn zirArithmetic( |
| 9564 | 9567 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 9565 | 9568 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 9566 | 9569 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9567 | | const lhs = sema.resolveInst(extra.lhs); |
| 9568 | | const rhs = sema.resolveInst(extra.rhs); |
| 9570 | const lhs = try sema.resolveInst(extra.lhs); |
| 9571 | const rhs = try sema.resolveInst(extra.rhs); |
| 9569 | 9572 | |
| 9570 | 9573 | return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, sema.src, lhs_src, rhs_src); |
| 9571 | 9574 | } |
| ... | ... | @@ -9586,9 +9589,9 @@ fn zirOverflowArithmetic( |
| 9586 | 9589 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 9587 | 9590 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = extra.node }; |
| 9588 | 9591 | |
| 9589 | | const lhs = sema.resolveInst(extra.lhs); |
| 9590 | | const rhs = sema.resolveInst(extra.rhs); |
| 9591 | | const ptr = sema.resolveInst(extra.ptr); |
| 9592 | const lhs = try sema.resolveInst(extra.lhs); |
| 9593 | const rhs = try sema.resolveInst(extra.rhs); |
| 9594 | const ptr = try sema.resolveInst(extra.ptr); |
| 9592 | 9595 | |
| 9593 | 9596 | const lhs_ty = sema.typeOf(lhs); |
| 9594 | 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 | 10790 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 10788 | 10791 | const src = inst_data.src(); |
| 10789 | 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 | 10794 | return sema.analyzeLoad(block, src, ptr, ptr_src); |
| 10792 | 10795 | } |
| 10793 | 10796 | |
| ... | ... | @@ -10879,7 +10882,7 @@ fn zirAsm( |
| 10879 | 10882 | const input = sema.code.extraData(Zir.Inst.Asm.Input, extra_i); |
| 10880 | 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 | 10886 | const uncasted_arg_ty = sema.typeOf(uncasted_arg); |
| 10884 | 10887 | switch (uncasted_arg_ty.zigTypeTag()) { |
| 10885 | 10888 | .ComptimeInt => arg.* = try sema.coerce(block, Type.initTag(.usize), uncasted_arg, src), |
| ... | ... | @@ -10968,8 +10971,8 @@ fn zirCmpEq( |
| 10968 | 10971 | const src: LazySrcLoc = inst_data.src(); |
| 10969 | 10972 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 10970 | 10973 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 10971 | | const lhs = sema.resolveInst(extra.lhs); |
| 10972 | | const rhs = sema.resolveInst(extra.rhs); |
| 10974 | const lhs = try sema.resolveInst(extra.lhs); |
| 10975 | const rhs = try sema.resolveInst(extra.rhs); |
| 10973 | 10976 | |
| 10974 | 10977 | const lhs_ty = sema.typeOf(lhs); |
| 10975 | 10978 | const rhs_ty = sema.typeOf(rhs); |
| ... | ... | @@ -11080,8 +11083,8 @@ fn zirCmp( |
| 11080 | 11083 | const src: LazySrcLoc = inst_data.src(); |
| 11081 | 11084 | const lhs_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 11082 | 11085 | const rhs_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 11083 | | const lhs = sema.resolveInst(extra.lhs); |
| 11084 | | const rhs = sema.resolveInst(extra.rhs); |
| 11086 | const lhs = try sema.resolveInst(extra.lhs); |
| 11087 | const rhs = try sema.resolveInst(extra.rhs); |
| 11085 | 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 | 11278 | // fn foo(x: anytype) void { const S = struct {field: @TypeOf(x)}; } |
| 11276 | 11279 | // ...in which case the closure_capture instruction has access to a runtime |
| 11277 | 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 | 11282 | const val = (try sema.resolveMaybeUndefValAllowVariables(block, src, operand)) orelse |
| 11280 | 11283 | Value.initTag(.generic_poison); |
| 11281 | 11284 | |
| ... | ... | @@ -12248,7 +12251,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 12248 | 12251 | _ = block; |
| 12249 | 12252 | const zir_datas = sema.code.instructions.items(.data); |
| 12250 | 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 | 12255 | const operand_ty = sema.typeOf(operand); |
| 12253 | 12256 | return sema.addType(operand_ty); |
| 12254 | 12257 | } |
| ... | ... | @@ -12268,6 +12271,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr |
| 12268 | 12271 | .inlining = block.inlining, |
| 12269 | 12272 | .is_comptime = false, |
| 12270 | 12273 | .is_typeof = true, |
| 12274 | .want_safety = false, |
| 12271 | 12275 | }; |
| 12272 | 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 | 12284 | fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 12281 | 12285 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12282 | 12286 | const src = inst_data.src(); |
| 12283 | | const operand = sema.resolveInst(inst_data.operand); |
| 12287 | const operand = try sema.resolveInst(inst_data.operand); |
| 12284 | 12288 | const operand_ty = sema.typeOf(operand); |
| 12285 | 12289 | const res_ty = try sema.log2IntType(block, operand_ty, src); |
| 12286 | 12290 | return sema.addType(res_ty); |
| ... | ... | @@ -12362,8 +12366,7 @@ fn zirTypeofPeer( |
| 12362 | 12366 | defer sema.gpa.free(inst_list); |
| 12363 | 12367 | |
| 12364 | 12368 | for (args) |arg_ref, i| { |
| 12365 | | inst_list[i] = sema.resolveInst(arg_ref); |
| 12366 | | if (sema.typeOf(inst_list[i]).tag() == .generic_poison) return error.GenericPoison; |
| 12369 | inst_list[i] = try sema.resolveInst(arg_ref); |
| 12367 | 12370 | } |
| 12368 | 12371 | |
| 12369 | 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 | 12380 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12378 | 12381 | const src = inst_data.src(); |
| 12379 | 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 | 12385 | const operand = try sema.coerce(block, Type.bool, uncasted_operand, operand_src); |
| 12383 | 12386 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| ... | ... | @@ -12403,7 +12406,7 @@ fn zirBoolBr( |
| 12403 | 12406 | |
| 12404 | 12407 | const datas = sema.code.instructions.items(.data); |
| 12405 | 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 | 12410 | const lhs_src = sema.src; |
| 12408 | 12411 | const extra = sema.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 12409 | 12412 | const body = sema.code.extra[extra.end..][0..extra.data.body_len]; |
| ... | ... | @@ -12488,7 +12491,7 @@ fn zirIsNonNull( |
| 12488 | 12491 | |
| 12489 | 12492 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12490 | 12493 | const src = inst_data.src(); |
| 12491 | | const operand = sema.resolveInst(inst_data.operand); |
| 12494 | const operand = try sema.resolveInst(inst_data.operand); |
| 12492 | 12495 | return sema.analyzeIsNull(block, src, operand, true); |
| 12493 | 12496 | } |
| 12494 | 12497 | |
| ... | ... | @@ -12502,7 +12505,7 @@ fn zirIsNonNullPtr( |
| 12502 | 12505 | |
| 12503 | 12506 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12504 | 12507 | const src = inst_data.src(); |
| 12505 | | const ptr = sema.resolveInst(inst_data.operand); |
| 12508 | const ptr = try sema.resolveInst(inst_data.operand); |
| 12506 | 12509 | if ((try sema.resolveMaybeUndefVal(block, src, ptr)) == null) { |
| 12507 | 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 | 12518 | defer tracy.end(); |
| 12516 | 12519 | |
| 12517 | 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 | 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 | 12528 | |
| 12526 | 12529 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12527 | 12530 | const src = inst_data.src(); |
| 12528 | | const ptr = sema.resolveInst(inst_data.operand); |
| 12531 | const ptr = try sema.resolveInst(inst_data.operand); |
| 12529 | 12532 | const loaded = try sema.analyzeLoad(block, src, ptr, src); |
| 12530 | 12533 | return sema.analyzeIsNonErr(block, src, loaded); |
| 12531 | 12534 | } |
| ... | ... | @@ -12546,7 +12549,7 @@ fn zirCondbr( |
| 12546 | 12549 | const then_body = sema.code.extra[extra.end..][0..extra.data.then_body_len]; |
| 12547 | 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 | 12553 | const cond = try sema.coerce(parent_block, Type.bool, uncasted_cond, cond_src); |
| 12551 | 12554 | |
| 12552 | 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 | 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 | 12661 | const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand); |
| 12659 | 12662 | try labeled_block.label.merges.results.append(sema.gpa, operand); |
| 12660 | 12663 | try labeled_block.label.merges.br_list.append(sema.gpa, Air.refToIndex(br_ref).?); |
| ... | ... | @@ -12705,7 +12708,7 @@ fn zirRetTok( |
| 12705 | 12708 | defer tracy.end(); |
| 12706 | 12709 | |
| 12707 | 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 | 12712 | const src = inst_data.src(); |
| 12710 | 12713 | |
| 12711 | 12714 | return sema.analyzeRet(block, operand, src); |
| ... | ... | @@ -12716,7 +12719,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir |
| 12716 | 12719 | defer tracy.end(); |
| 12717 | 12720 | |
| 12718 | 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 | 12723 | const src = inst_data.src(); |
| 12721 | 12724 | |
| 12722 | 12725 | return sema.analyzeRet(block, operand, src); |
| ... | ... | @@ -12728,7 +12731,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Zir |
| 12728 | 12731 | |
| 12729 | 12732 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 12730 | 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 | 12736 | if (block.is_comptime or block.inlining != null) { |
| 12734 | 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 | 12854 | const abi_align: u32 = if (inst_data.flags.has_align) blk: { |
| 12852 | 12855 | const ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_i]); |
| 12853 | 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 | 12858 | const val = try sema.resolveConstValue(block, src, coerced); |
| 12856 | 12859 | // Check if this happens to be the lazy alignment of our element type, in |
| 12857 | 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 | 12981 | const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; |
| 12979 | 12982 | const union_ty = try sema.resolveType(block, ty_src, extra.union_type); |
| 12980 | 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 | 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 | 13071 | return sema.failWithOwnedErrorMsg(block, msg); |
| 13069 | 13072 | } |
| 13070 | 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 | 13077 | var root_msg: ?*Module.ErrorMsg = null; |
| ... | ... | @@ -13105,7 +13108,7 @@ fn zirStructInit( |
| 13105 | 13108 | const field_name = sema.code.nullTerminatedString(field_type_extra.name_start); |
| 13106 | 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 | 13112 | if (try sema.resolveMaybeUndefVal(block, field_src, init_inst)) |val| { |
| 13110 | 13113 | const tag_val = try Value.Tag.enum_field_index.create(sema.arena, field_index); |
| 13111 | 13114 | return sema.addConstantMaybeRef( |
| ... | ... | @@ -13213,7 +13216,7 @@ fn zirStructInitAnon( |
| 13213 | 13216 | extra_index = item.end; |
| 13214 | 13217 | |
| 13215 | 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 | 13220 | field_ty.* = sema.typeOf(init); |
| 13218 | 13221 | const init_src = src; // TODO better source location |
| 13219 | 13222 | if (try sema.resolveMaybeUndefVal(block, init_src, init)) |init_val| { |
| ... | ... | @@ -13258,7 +13261,7 @@ fn zirStructInitAnon( |
| 13258 | 13261 | .pointee_type = field_ty, |
| 13259 | 13262 | }); |
| 13260 | 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 | 13265 | const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty); |
| 13263 | 13266 | _ = try block.addBinOp(.store, field_ptr, init); |
| 13264 | 13267 | } |
| ... | ... | @@ -13272,7 +13275,7 @@ fn zirStructInitAnon( |
| 13272 | 13275 | for (types) |_, i| { |
| 13273 | 13276 | const item = sema.code.extraData(Zir.Inst.StructInitAnon.Item, extra_index); |
| 13274 | 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 | 13281 | return block.addAggregateInit(tuple_ty, element_refs); |
| ... | ... | @@ -13296,7 +13299,7 @@ fn zirArrayInit( |
| 13296 | 13299 | const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len); |
| 13297 | 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 | 13304 | const elem_ty = sema.typeOf(resolved_args[0]); |
| 13302 | 13305 | const array_ty = blk: { |
| ... | ... | @@ -13380,7 +13383,7 @@ fn zirArrayInitAnon( |
| 13380 | 13383 | const opt_runtime_src = rs: { |
| 13381 | 13384 | var runtime_src: ?LazySrcLoc = null; |
| 13382 | 13385 | for (operands) |operand, i| { |
| 13383 | | const elem = sema.resolveInst(operand); |
| 13386 | const elem = try sema.resolveInst(operand); |
| 13384 | 13387 | types[i] = sema.typeOf(elem); |
| 13385 | 13388 | const operand_src = src; // TODO better source location |
| 13386 | 13389 | if (try sema.resolveMaybeUndefVal(block, operand_src, elem)) |val| { |
| ... | ... | @@ -13421,7 +13424,7 @@ fn zirArrayInitAnon( |
| 13421 | 13424 | }); |
| 13422 | 13425 | if (values[i].tag() == .unreachable_value) { |
| 13423 | 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 | 13433 | |
| 13431 | 13434 | const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len); |
| 13432 | 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 | 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 | 13576 | fn zirBoolToInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 13574 | 13577 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13575 | 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 | 13580 | if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| 13578 | 13581 | if (val.isUndef()) return sema.addConstUndef(Type.initTag(.u1)); |
| 13579 | 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 | 13589 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13587 | 13590 | const src = inst_data.src(); |
| 13588 | 13591 | _ = src; |
| 13589 | | const operand = sema.resolveInst(inst_data.operand); |
| 13592 | const operand = try sema.resolveInst(inst_data.operand); |
| 13590 | 13593 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13591 | 13594 | |
| 13592 | 13595 | if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| { |
| ... | ... | @@ -13610,7 +13613,7 @@ fn zirUnaryMath( |
| 13610 | 13613 | defer tracy.end(); |
| 13611 | 13614 | |
| 13612 | 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 | 13617 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13615 | 13618 | const operand_ty = sema.typeOf(operand); |
| 13616 | 13619 | const target = sema.mod.getTarget(); |
| ... | ... | @@ -13670,7 +13673,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 13670 | 13673 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13671 | 13674 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13672 | 13675 | const src = inst_data.src(); |
| 13673 | | const operand = sema.resolveInst(inst_data.operand); |
| 13676 | const operand = try sema.resolveInst(inst_data.operand); |
| 13674 | 13677 | const operand_ty = sema.typeOf(operand); |
| 13675 | 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 | 13731 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 13729 | 13732 | const src = inst_data.src(); |
| 13730 | 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 | 13735 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 13733 | 13736 | const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src); |
| 13734 | 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 | 14406 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14404 | 14407 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14405 | 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 | 14410 | const operand_ty = sema.typeOf(operand); |
| 14408 | 14411 | |
| 14409 | 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 | 14427 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14425 | 14428 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14426 | 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 | 14431 | const operand_ty = sema.typeOf(operand); |
| 14429 | 14432 | |
| 14430 | 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 | 14450 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 14448 | 14451 | |
| 14449 | 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 | 14454 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); |
| 14452 | 14455 | |
| 14453 | 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 | 14506 | const dest_ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 14504 | 14507 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 14505 | 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 | 14510 | const operand_ty = sema.typeOf(operand); |
| 14508 | 14511 | try sema.checkErrorSetType(block, dest_ty_src, dest_ty); |
| 14509 | 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 | 14594 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14592 | 14595 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 14593 | 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 | 14598 | const operand_ty = sema.typeOf(operand); |
| 14596 | 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 | 14654 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14652 | 14655 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 14653 | 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 | 14658 | const dest_is_comptime_int = try sema.checkIntType(block, dest_ty_src, dest_scalar_ty); |
| 14656 | 14659 | const operand_ty = sema.typeOf(operand); |
| 14657 | 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 | 14737 | const align_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14735 | 14738 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 14736 | 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 | 14741 | const ptr_ty = sema.typeOf(ptr); |
| 14739 | 14742 | |
| 14740 | 14743 | // TODO in addition to pointers, this instruction is supposed to work for |
| ... | ... | @@ -14768,7 +14771,7 @@ fn zirBitCount( |
| 14768 | 14771 | ) CompileError!Air.Inst.Ref { |
| 14769 | 14772 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 14770 | 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 | 14775 | const operand_ty = sema.typeOf(operand); |
| 14773 | 14776 | _ = try checkIntOrVector(sema, block, operand, operand_src); |
| 14774 | 14777 | const target = sema.mod.getTarget(); |
| ... | ... | @@ -14820,7 +14823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14820 | 14823 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 14821 | 14824 | const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 14822 | 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 | 14827 | const operand_ty = sema.typeOf(operand); |
| 14825 | 14828 | const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); |
| 14826 | 14829 | const target = sema.mod.getTarget(); |
| ... | ... | @@ -14877,7 +14880,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14877 | 14880 | fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| 14878 | 14881 | const inst_data = sema.code.instructions.items(.data)[inst].un_node; |
| 14879 | 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 | 14884 | const operand_ty = sema.typeOf(operand); |
| 14882 | 14885 | _ = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); |
| 14883 | 14886 | |
| ... | ... | @@ -15363,7 +15366,7 @@ fn resolveExportOptions( |
| 15363 | 15366 | zir_ref: Zir.Inst.Ref, |
| 15364 | 15367 | ) CompileError!std.builtin.ExportOptions { |
| 15365 | 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 | 15370 | const options = try sema.coerce(block, export_options_ty, air_ref, src); |
| 15368 | 15371 | |
| 15369 | 15372 | const name_operand = try sema.fieldVal(block, src, options, "name", src); |
| ... | ... | @@ -15408,7 +15411,7 @@ fn resolveBuiltinEnum( |
| 15408 | 15411 | comptime name: []const u8, |
| 15409 | 15412 | ) CompileError!@field(std.builtin, name) { |
| 15410 | 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 | 15415 | const coerced = try sema.coerce(block, ty, air_ref, src); |
| 15413 | 15416 | const val = try sema.resolveConstValue(block, src, coerced); |
| 15414 | 15417 | return val.toEnum(@field(std.builtin, name)); |
| ... | ... | @@ -15449,7 +15452,7 @@ fn zirCmpxchg( |
| 15449 | 15452 | const success_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; |
| 15450 | 15453 | const failure_order_src: LazySrcLoc = .{ .node_offset_builtin_call_arg5 = inst_data.src_node }; |
| 15451 | 15454 | // zig fmt: on |
| 15452 | | const expected_value = sema.resolveInst(extra.expected_value); |
| 15455 | const expected_value = try sema.resolveInst(extra.expected_value); |
| 15453 | 15456 | const elem_ty = sema.typeOf(expected_value); |
| 15454 | 15457 | if (elem_ty.zigTypeTag() == .Float) { |
| 15455 | 15458 | return sema.fail( |
| ... | ... | @@ -15459,9 +15462,9 @@ fn zirCmpxchg( |
| 15459 | 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 | 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 | 15468 | const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order); |
| 15466 | 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 | 15532 | const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; |
| 15530 | 15533 | const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; |
| 15531 | 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 | 15536 | const scalar_ty = sema.typeOf(scalar); |
| 15534 | 15537 | try sema.checkVectorElemType(block, scalar_src, scalar_ty); |
| 15535 | 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 | 15558 | const op_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 15556 | 15559 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 15557 | 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 | 15562 | const operand_ty = sema.typeOf(operand); |
| 15560 | 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 | 15630 | |
| 15628 | 15631 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); |
| 15629 | 15632 | try sema.checkVectorElemType(block, elem_ty_src, elem_ty); |
| 15630 | | var a = sema.resolveInst(extra.a); |
| 15631 | | var b = sema.resolveInst(extra.b); |
| 15632 | | var mask = sema.resolveInst(extra.mask); |
| 15633 | var a = try sema.resolveInst(extra.a); |
| 15634 | var b = try sema.resolveInst(extra.b); |
| 15635 | var mask = try sema.resolveInst(extra.mask); |
| 15633 | 15636 | var mask_ty = sema.typeOf(mask); |
| 15634 | 15637 | |
| 15635 | 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 | 15824 | |
| 15822 | 15825 | const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type); |
| 15823 | 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 | 15828 | const pred_ty = sema.typeOf(pred_uncoerced); |
| 15826 | 15829 | |
| 15827 | 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 | 15837 | const pred = try sema.coerce(block, bool_vec_ty, pred_uncoerced, pred_src); |
| 15835 | 15838 | |
| 15836 | 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); |
| 15838 | | const b = try sema.coerce(block, vec_ty, sema.resolveInst(extra.b), b_src); |
| 15840 | const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src); |
| 15841 | const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src); |
| 15839 | 15842 | |
| 15840 | 15843 | const maybe_pred = try sema.resolveMaybeUndefVal(block, pred_src, pred); |
| 15841 | 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 | 15910 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 15908 | 15911 | // zig fmt: on |
| 15909 | 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 | 15914 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true); |
| 15912 | 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 | 15957 | const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; |
| 15955 | 15958 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg4 = inst_data.src_node }; |
| 15956 | 15959 | // zig fmt: on |
| 15957 | | const operand = sema.resolveInst(extra.operand); |
| 15960 | const operand = try sema.resolveInst(extra.operand); |
| 15958 | 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 | 15963 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); |
| 15961 | 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 | 16040 | const operand_src : LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 16038 | 16041 | const order_src : LazySrcLoc = .{ .node_offset_builtin_call_arg3 = inst_data.src_node }; |
| 16039 | 16042 | // zig fmt: on |
| 16040 | | const operand = sema.resolveInst(extra.operand); |
| 16043 | const operand = try sema.resolveInst(extra.operand); |
| 16041 | 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 | 16046 | const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false); |
| 16044 | 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 | 16073 | const mulend2_src: LazySrcLoc = .{ .node_offset_builtin_call_arg2 = inst_data.src_node }; |
| 16071 | 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 | 16077 | const ty = sema.typeOf(addend); |
| 16075 | | const mulend1 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend1), mulend1_src); |
| 16076 | | const mulend2 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend2), mulend2_src); |
| 16078 | const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src); |
| 16079 | const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src); |
| 16077 | 16080 | |
| 16078 | 16081 | const target = sema.mod.getTarget(); |
| 16079 | 16082 | |
| ... | ... | @@ -16137,9 +16140,9 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 16137 | 16140 | const call_src = inst_data.src(); |
| 16138 | 16141 | |
| 16139 | 16142 | const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; |
| 16140 | | var func = sema.resolveInst(extra.callee); |
| 16141 | | const options = sema.resolveInst(extra.options); |
| 16142 | | const args = sema.resolveInst(extra.args); |
| 16143 | var func = try sema.resolveInst(extra.callee); |
| 16144 | const options = try sema.resolveInst(extra.options); |
| 16145 | const args = try sema.resolveInst(extra.args); |
| 16143 | 16146 | |
| 16144 | 16147 | const wanted_modifier: std.builtin.CallOptions.Modifier = modifier: { |
| 16145 | 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 | 16232 | |
| 16230 | 16233 | const struct_ty = try sema.resolveType(block, ty_src, extra.parent_type); |
| 16231 | 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 | 16236 | const field_ptr_ty = sema.typeOf(field_ptr); |
| 16234 | 16237 | |
| 16235 | 16238 | if (struct_ty.zigTypeTag() != .Struct) { |
| ... | ... | @@ -16294,8 +16297,8 @@ fn zirMinMax( |
| 16294 | 16297 | const src = inst_data.src(); |
| 16295 | 16298 | const lhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 16296 | 16299 | const rhs_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 16297 | | const lhs = sema.resolveInst(extra.lhs); |
| 16298 | | const rhs = sema.resolveInst(extra.rhs); |
| 16300 | const lhs = try sema.resolveInst(extra.lhs); |
| 16301 | const rhs = try sema.resolveInst(extra.rhs); |
| 16299 | 16302 | try sema.checkNumericType(block, lhs_src, sema.typeOf(lhs)); |
| 16300 | 16303 | try sema.checkNumericType(block, rhs_src, sema.typeOf(rhs)); |
| 16301 | 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 | 16365 | const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 16363 | 16366 | const src_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 16364 | 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 | 16369 | const dest_ptr_ty = sema.typeOf(dest_ptr); |
| 16367 | 16370 | |
| 16368 | 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 | 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 | 16377 | const uncasted_src_ptr_ty = sema.typeOf(uncasted_src_ptr); |
| 16375 | 16378 | try sema.checkPtrOperand(block, src_src, uncasted_src_ptr_ty); |
| 16376 | 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 | 16387 | .size = .Many, |
| 16385 | 16388 | }); |
| 16386 | 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 | 16392 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |dest_ptr_val| rs: { |
| 16390 | 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 | 16422 | const dest_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 16420 | 16423 | const value_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 16421 | 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 | 16426 | const dest_ptr_ty = sema.typeOf(dest_ptr); |
| 16424 | 16427 | try sema.checkPtrOperand(block, dest_src, dest_ptr_ty); |
| 16425 | 16428 | if (dest_ptr_ty.isConstPtr()) { |
| 16426 | 16429 | return sema.fail(block, dest_src, "cannot store through const pointer '{}'", .{dest_ptr_ty.fmt(sema.mod)}); |
| 16427 | 16430 | } |
| 16428 | 16431 | const elem_ty = dest_ptr_ty.elemType2(); |
| 16429 | | const value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.byte), value_src); |
| 16430 | | const len = try sema.coerce(block, Type.usize, sema.resolveInst(extra.byte_count), len_src); |
| 16432 | const value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.byte), value_src); |
| 16433 | const len = try sema.coerce(block, Type.usize, try sema.resolveInst(extra.byte_count), len_src); |
| 16431 | 16434 | |
| 16432 | 16435 | const runtime_src = if (try sema.resolveDefinedValue(block, dest_src, dest_ptr)) |ptr_val| rs: { |
| 16433 | 16436 | if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src; |
| ... | ... | @@ -16521,7 +16524,7 @@ fn zirVarExtended( |
| 16521 | 16524 | const uncasted_init: Air.Inst.Ref = if (small.has_init) blk: { |
| 16522 | 16525 | const init_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
| 16523 | 16526 | extra_index += 1; |
| 16524 | | break :blk sema.resolveInst(init_ref); |
| 16527 | break :blk try sema.resolveInst(init_ref); |
| 16525 | 16528 | } else .none; |
| 16526 | 16529 | |
| 16527 | 16530 | const have_ty = extra.data.var_type != .none; |
| ... | ... | @@ -16669,7 +16672,7 @@ fn zirCDefine( |
| 16669 | 16672 | const val_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 16670 | 16673 | |
| 16671 | 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 | 16676 | if (sema.typeOf(rhs).zigTypeTag() != .Void) { |
| 16674 | 16677 | const value = try sema.resolveConstString(block, val_src, extra.rhs); |
| 16675 | 16678 | try block.c_import_buf.?.writer().print("#define {s} {s}\n", .{ name, value }); |
| ... | ... | @@ -16718,7 +16721,7 @@ fn zirWasmMemoryGrow( |
| 16718 | 16721 | } |
| 16719 | 16722 | |
| 16720 | 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 | 16726 | try sema.requireRuntimeBlock(block, builtin_src); |
| 16724 | 16727 | return block.addInst(.{ |
| ... | ... | @@ -16739,9 +16742,9 @@ fn zirPrefetch( |
| 16739 | 16742 | const ptr_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 16740 | 16743 | const opts_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 16741 | 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 | 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 | 16748 | const target = sema.mod.getTarget(); |
| 16746 | 16749 | |
| 16747 | 16750 | const rw = try sema.fieldVal(block, opts_src, options, "rw", opts_src); |
| ... | ... | @@ -16782,7 +16785,7 @@ fn zirBuiltinExtern( |
| 16782 | 16785 | const options_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = extra.node }; |
| 16783 | 16786 | |
| 16784 | 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 | 16789 | const mod = sema.mod; |
| 16787 | 16790 | |
| 16788 | 16791 | const options = options: { |
| ... | ... | @@ -20197,7 +20200,11 @@ fn beginComptimePtrLoad( |
| 20197 | 20200 | var deref = try beginComptimePtrLoad(sema, block, src, field_ptr.container_ptr, field_ptr.container_ty); |
| 20198 | 20201 | |
| 20199 | 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 | 20208 | // Update the byte offset (in-place) |
| 20202 | 20209 | try sema.resolveTypeLayout(block, src, field_ptr.container_ty); |
| 20203 | 20210 | const field_offset = field_ptr.container_ty.structFieldOffset(field_index, target); |
| ... | ... | @@ -20828,7 +20835,7 @@ fn analyzeDeclVal( |
| 20828 | 20835 | const decl_ref = try sema.analyzeDeclRef(decl_index); |
| 20829 | 20836 | const result = try sema.analyzeLoad(block, src, decl_ref, src); |
| 20830 | 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 | 20839 | try sema.decl_val_table.put(sema.gpa, decl_index, result); |
| 20833 | 20840 | } |
| 20834 | 20841 | } |
| ... | ... | @@ -20959,8 +20966,14 @@ fn analyzeLoad( |
| 20959 | 20966 | if (try sema.pointerDeref(block, ptr_src, ptr_val, ptr_ty)) |elem_val| { |
| 20960 | 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 | 20977 | try sema.requireRuntimeBlock(block, src); |
| 20965 | 20978 | return block.addTyOp(.load, elem_ty, ptr); |
| 20966 | 20979 | } |
| ... | ... | @@ -22845,7 +22858,7 @@ fn semaStructFields( |
| 22845 | 22858 | if (has_default) { |
| 22846 | 22859 | const default_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); |
| 22847 | 22860 | extra_index += 1; |
| 22848 | | const default_inst = sema.resolveInst(default_ref); |
| 22861 | const default_inst = try sema.resolveInst(default_ref); |
| 22849 | 22862 | // TODO: if we need to report an error here, use a source location |
| 22850 | 22863 | // that points to this default value expression rather than the struct. |
| 22851 | 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 | 23042 | const tag_ref: Zir.Inst.Ref = if (has_tag) blk: { |
| 23030 | 23043 | const tag_ref = @intToEnum(Zir.Inst.Ref, zir.extra[extra_index]); |
| 23031 | 23044 | extra_index += 1; |
| 23032 | | break :blk sema.resolveInst(tag_ref); |
| 23045 | break :blk try sema.resolveInst(tag_ref); |
| 23033 | 23046 | } else .none; |
| 23034 | 23047 | |
| 23035 | 23048 | if (enum_value_map) |map| { |
| ... | ... | @@ -23654,7 +23667,7 @@ fn addIntUnsigned(sema: *Sema, ty: Type, int: u64) CompileError!Air.Inst.Ref { |
| 23654 | 23667 | fn addBool(sema: *Sema, ty: Type, boolean: bool) CompileError!Air.Inst.Ref { |
| 23655 | 23668 | return switch (ty.zigTypeTag()) { |
| 23656 | 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 | 23671 | else => unreachable, |
| 23659 | 23672 | }; |
| 23660 | 23673 | } |