authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-26 21:14:08+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:07+00:00
loge3e9ae12bd3a7c08f3ed41e801f6cf34bec01af2
tree9ff848c9972535e1956939908bbf13cacea4d75d
parent3086c7977bee8cfe41c385d3ba389971b9a28380
signaturelock-open Commit is signed but in an unrecognized format.

Sema: remove unnecessary error sets from resolveInst and resolveValue


1 files changed, 410 insertions(+), 411 deletions(-)

src/Sema.zig+410-411
...@@ -1086,7 +1086,7 @@ fn analyzeInlineBody(...@@ -1086,7 +1086,7 @@ fn analyzeInlineBody(
1086 // This control flow goes further up the stack.1086 // This control flow goes further up the stack.
1087 return error.ComptimeBreak;1087 return error.ComptimeBreak;
1088 }1088 }
1089 return try sema.resolveInst(break_inst.data.@"break".operand);1089 return sema.resolveInst(break_inst.data.@"break".operand);
1090}1090}
10911091
1092/// Like `analyzeInlineBody`, but if the body does not break with a value, returns1092/// Like `analyzeInlineBody`, but if the body does not break with a value, returns
...@@ -1873,7 +1873,7 @@ fn analyzeBodyInner(...@@ -1873,7 +1873,7 @@ fn analyzeBodyInner(
18731873
1874 const break_data = opt_break_data orelse break;1874 const break_data = opt_break_data orelse break;
1875 if (inst == break_data.block_inst) {1875 if (inst == break_data.block_inst) {
1876 break :blk try sema.resolveInst(break_data.operand);1876 break :blk sema.resolveInst(break_data.operand);
1877 } else {1877 } else {
1878 // `comptime_break_inst` preserved from `analyzeBodyInner` above.1878 // `comptime_break_inst` preserved from `analyzeBodyInner` above.
1879 return error.ComptimeBreak;1879 return error.ComptimeBreak;
...@@ -1894,7 +1894,7 @@ fn analyzeBodyInner(...@@ -1894,7 +1894,7 @@ fn analyzeBodyInner(
1894 extra.end + then_body.len,1894 extra.end + then_body.len,
1895 extra.data.else_body_len,1895 extra.data.else_body_len,
1896 );1896 );
1897 const uncasted_cond = try sema.resolveInst(extra.data.condition);1897 const uncasted_cond = sema.resolveInst(extra.data.condition);
1898 const cond = try sema.coerce(block, .bool, uncasted_cond, cond_src);1898 const cond = try sema.coerce(block, .bool, uncasted_cond, cond_src);
1899 const cond_val = try sema.resolveConstDefinedValue(1899 const cond_val = try sema.resolveConstDefinedValue(
1900 block,1900 block,
...@@ -1920,7 +1920,7 @@ fn analyzeBodyInner(...@@ -1920,7 +1920,7 @@ fn analyzeBodyInner(
1920 const operand_src = block.src(.{ .node_offset_try_operand = inst_data.src_node });1920 const operand_src = block.src(.{ .node_offset_try_operand = inst_data.src_node });
1921 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);1921 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1922 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);1922 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
1923 const err_union = try sema.resolveInst(extra.data.operand);1923 const err_union = sema.resolveInst(extra.data.operand);
1924 const err_union_ty = sema.typeOf(err_union);1924 const err_union_ty = sema.typeOf(err_union);
1925 if (err_union_ty.zigTypeTag(zcu) != .error_union) {1925 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
1926 return sema.failWithOwnedErrorMsg(block, msg: {1926 return sema.failWithOwnedErrorMsg(block, msg: {
...@@ -1946,7 +1946,7 @@ fn analyzeBodyInner(...@@ -1946,7 +1946,7 @@ fn analyzeBodyInner(
1946 const operand_src = block.src(.{ .node_offset_try_operand = inst_data.src_node });1946 const operand_src = block.src(.{ .node_offset_try_operand = inst_data.src_node });
1947 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);1947 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
1948 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);1948 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
1949 const operand = try sema.resolveInst(extra.data.operand);1949 const operand = sema.resolveInst(extra.data.operand);
1950 const err_union = try sema.analyzeLoad(block, src, operand, operand_src);1950 const err_union = try sema.analyzeLoad(block, src, operand, operand_src);
1951 const is_non_err_val = (try sema.resolveIsNonErrVal(block, operand_src, err_union)).?;1951 const is_non_err_val = (try sema.resolveIsNonErrVal(block, operand_src, err_union)).?;
1952 if (is_non_err_val.isUndef(zcu)) return sema.failWithUseOfUndef(block, operand_src, null);1952 if (is_non_err_val.isUndef(zcu)) return sema.failWithUseOfUndef(block, operand_src, null);
...@@ -1975,7 +1975,7 @@ fn analyzeBodyInner(...@@ -1975,7 +1975,7 @@ fn analyzeBodyInner(
1975 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].defer_err_code;1975 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].defer_err_code;
1976 const extra = sema.code.extraData(Zir.Inst.DeferErrCode, inst_data.payload_index).data;1976 const extra = sema.code.extraData(Zir.Inst.DeferErrCode, inst_data.payload_index).data;
1977 const defer_body = sema.code.bodySlice(extra.index, extra.len);1977 const defer_body = sema.code.bodySlice(extra.index, extra.len);
1978 const err_code = try sema.resolveInst(inst_data.err_code);1978 const err_code = sema.resolveInst(inst_data.err_code);
1979 try map.ensureSpaceForInstructions(sema.gpa, defer_body);1979 try map.ensureSpaceForInstructions(sema.gpa, defer_body);
1980 map.putAssumeCapacity(extra.remapped_err_code, err_code);1980 map.putAssumeCapacity(extra.remapped_err_code, err_code);
1981 if (sema.analyzeBodyInner(block, defer_body)) {1981 if (sema.analyzeBodyInner(block, defer_body)) {
...@@ -2022,7 +2022,7 @@ fn analyzeBodyInner(...@@ -2022,7 +2022,7 @@ fn analyzeBodyInner(
2022 }2022 }
2023}2023}
20242024
2025pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {2025fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
2026 if (zir_ref == .none) {2026 if (zir_ref == .none) {
2027 return .none;2027 return .none;
2028 } else {2028 } else {
...@@ -2030,7 +2030,7 @@ pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {...@@ -2030,7 +2030,7 @@ pub fn resolveInstAllowNone(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {
2030 }2030 }
2031}2031}
20322032
2033pub fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) !Air.Inst.Ref {2033fn resolveInst(sema: *Sema, zir_ref: Zir.Inst.Ref) Air.Inst.Ref {
2034 assert(zir_ref != .none);2034 assert(zir_ref != .none);
2035 if (zir_ref.toIndex()) |i| {2035 if (zir_ref.toIndex()) |i| {
2036 return sema.inst_map.get(i).?;2036 return sema.inst_map.get(i).?;
...@@ -2047,7 +2047,7 @@ fn resolveConstBool(...@@ -2047,7 +2047,7 @@ fn resolveConstBool(
2047 zir_ref: Zir.Inst.Ref,2047 zir_ref: Zir.Inst.Ref,
2048 reason: ComptimeReason,2048 reason: ComptimeReason,
2049) !bool {2049) !bool {
2050 const air_inst = try sema.resolveInst(zir_ref);2050 const air_inst = sema.resolveInst(zir_ref);
2051 const wanted_type: Type = .bool;2051 const wanted_type: Type = .bool;
2052 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);2052 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
2053 const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason);2053 const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason);
...@@ -2063,7 +2063,7 @@ fn resolveConstString(...@@ -2063,7 +2063,7 @@ fn resolveConstString(
2063 /// being comptime-resolved is that the block is being comptime-evaluated.2063 /// being comptime-resolved is that the block is being comptime-evaluated.
2064 reason: ?ComptimeReason,2064 reason: ?ComptimeReason,
2065) ![]u8 {2065) ![]u8 {
2066 const air_inst = try sema.resolveInst(zir_ref);2066 const air_inst = sema.resolveInst(zir_ref);
2067 return sema.toConstString(block, src, air_inst, reason);2067 return sema.toConstString(block, src, air_inst, reason);
2068}2068}
20692069
...@@ -2090,7 +2090,7 @@ pub fn resolveConstStringIntern(...@@ -2090,7 +2090,7 @@ pub fn resolveConstStringIntern(
2090 zir_ref: Zir.Inst.Ref,2090 zir_ref: Zir.Inst.Ref,
2091 reason: ComptimeReason,2091 reason: ComptimeReason,
2092) !InternPool.NullTerminatedString {2092) !InternPool.NullTerminatedString {
2093 const air_inst = try sema.resolveInst(zir_ref);2093 const air_inst = sema.resolveInst(zir_ref);
2094 const wanted_type: Type = .slice_const_u8;2094 const wanted_type: Type = .slice_const_u8;
2095 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);2095 const coerced_inst = try sema.coerce(block, wanted_type, air_inst, src);
2096 const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason);2096 const val = try sema.resolveConstDefinedValue(block, src, coerced_inst, reason);
...@@ -2098,7 +2098,7 @@ pub fn resolveConstStringIntern(...@@ -2098,7 +2098,7 @@ pub fn resolveConstStringIntern(
2098}2098}
20992099
2100fn resolveTypeOrPoison(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !?Type {2100fn resolveTypeOrPoison(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Inst.Ref) !?Type {
2101 const air_inst = try sema.resolveInst(zir_ref);2101 const air_inst = sema.resolveInst(zir_ref);
2102 const ty = try sema.analyzeAsType(block, src, .type, air_inst);2102 const ty = try sema.analyzeAsType(block, src, .type, air_inst);
2103 if (ty.isGenericPoison()) return null;2103 if (ty.isGenericPoison()) return null;
2104 return ty;2104 return ty;
...@@ -2192,7 +2192,7 @@ fn genericPoisonReason(sema: *Sema, block: *Block, ref: Zir.Inst.Ref) GenericPoi...@@ -2192,7 +2192,7 @@ fn genericPoisonReason(sema: *Sema, block: *Block, ref: Zir.Inst.Ref) GenericPoi
2192 // There are two cases here: the pointer type may already have been2192 // There are two cases here: the pointer type may already have been
2193 // generic poison, or it may have been an anyopaque pointer.2193 // generic poison, or it may have been an anyopaque pointer.
2194 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;2194 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
2195 const operand_ref = try sema.resolveInst(un_node.operand);2195 const operand_ref = sema.resolveInst(un_node.operand);
2196 const operand_val = operand_ref.toInterned() orelse return .unknown;2196 const operand_val = operand_ref.toInterned() orelse return .unknown;
2197 if (operand_val == .generic_poison_type) {2197 if (operand_val == .generic_poison_type) {
2198 // The pointer was generic poison - keep looking.2198 // The pointer was generic poison - keep looking.
...@@ -2271,8 +2271,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize)...@@ -2271,8 +2271,7 @@ pub fn setupErrorReturnTrace(sema: *Sema, block: *Block, last_arg_index: usize)
2271}2271}
22722272
2273/// Return the Value corresponding to a given AIR ref, or `null` if it refers to a runtime value.2273/// Return the Value corresponding to a given AIR ref, or `null` if it refers to a runtime value.
2274/// TODO MLUGG: remove the error union return!2274fn resolveValue(sema: *Sema, inst: Air.Inst.Ref) ?Value {
2275fn resolveValue(sema: *Sema, inst: Air.Inst.Ref) error{}!?Value {
2276 const zcu = sema.pt.zcu;2275 const zcu = sema.pt.zcu;
2277 assert(inst != .none);2276 assert(inst != .none);
22782277
...@@ -2308,7 +2307,7 @@ pub fn resolveConstValue(...@@ -2308,7 +2307,7 @@ pub fn resolveConstValue(
2308 /// being comptime-resolved is that the block is being comptime-evaluated.2307 /// being comptime-resolved is that the block is being comptime-evaluated.
2309 reason: ?ComptimeReason,2308 reason: ?ComptimeReason,
2310) CompileError!Value {2309) CompileError!Value {
2311 return try sema.resolveValue(inst) orelse {2310 return sema.resolveValue(inst) orelse {
2312 return sema.failWithNeededComptime(block, src, reason);2311 return sema.failWithNeededComptime(block, src, reason);
2313 };2312 };
2314}2313}
...@@ -2322,7 +2321,7 @@ fn resolveDefinedValue(...@@ -2322,7 +2321,7 @@ fn resolveDefinedValue(
2322) CompileError!?Value {2321) CompileError!?Value {
2323 const pt = sema.pt;2322 const pt = sema.pt;
2324 const zcu = pt.zcu;2323 const zcu = pt.zcu;
2325 const val = try sema.resolveValue(air_ref) orelse return null;2324 const val = sema.resolveValue(air_ref) orelse return null;
2326 if (val.isUndef(zcu)) return sema.failWithUseOfUndef(block, src, null);2325 if (val.isUndef(zcu)) return sema.failWithUseOfUndef(block, src, null);
2327 return val;2326 return val;
2328}2327}
...@@ -2795,7 +2794,7 @@ fn resolveAlign(...@@ -2795,7 +2794,7 @@ fn resolveAlign(
2795 src: LazySrcLoc,2794 src: LazySrcLoc,
2796 zir_ref: Zir.Inst.Ref,2795 zir_ref: Zir.Inst.Ref,
2797) !Alignment {2796) !Alignment {
2798 const air_ref = try sema.resolveInst(zir_ref);2797 const air_ref = sema.resolveInst(zir_ref);
2799 return sema.analyzeAsAlign(block, src, air_ref);2798 return sema.analyzeAsAlign(block, src, air_ref);
2800}2799}
28012800
...@@ -2807,7 +2806,7 @@ fn resolveInt(...@@ -2807,7 +2806,7 @@ fn resolveInt(
2807 dest_ty: Type,2806 dest_ty: Type,
2808 reason: ComptimeReason,2807 reason: ComptimeReason,
2809) !u64 {2808) !u64 {
2810 const air_ref = try sema.resolveInst(zir_ref);2809 const air_ref = sema.resolveInst(zir_ref);
2811 return sema.analyzeAsInt(block, src, air_ref, dest_ty, reason);2810 return sema.analyzeAsInt(block, src, air_ref, dest_ty, reason);
2812}2811}
28132812
...@@ -2886,7 +2885,7 @@ fn zirTupleDecl(...@@ -2886,7 +2885,7 @@ fn zirTupleDecl(
2886 field_ty.* = field_type.toIntern();2885 field_ty.* = field_type.toIntern();
2887 field_init.* = init: {2886 field_init.* = init: {
2888 if (zir_field_init != .none) {2887 if (zir_field_init != .none) {
2889 const uncoerced_field_init = try sema.resolveInst(zir_field_init);2888 const uncoerced_field_init = sema.resolveInst(zir_field_init);
2890 const coerced_field_init = try sema.coerce(block, field_type, uncoerced_field_init, init_src);2889 const coerced_field_init = try sema.coerce(block, field_type, uncoerced_field_init, init_src);
2891 const field_init_val = try sema.resolveConstDefinedValue(block, init_src, coerced_field_init, .{ .simple = .tuple_field_default_value });2890 const field_init_val = try sema.resolveConstDefinedValue(block, init_src, coerced_field_init, .{ .simple = .tuple_field_default_value });
2892 if (field_init_val.canMutateComptimeVarState(zcu)) {2891 if (field_init_val.canMutateComptimeVarState(zcu)) {
...@@ -2959,8 +2958,8 @@ fn getCaptures(...@@ -2959,8 +2958,8 @@ fn getCaptures(
2959 capture.* = switch (zir_capture.unwrap()) {2958 capture.* = switch (zir_capture.unwrap()) {
2960 .nested => |parent_idx| parent_captures.get(ip)[parent_idx],2959 .nested => |parent_idx| parent_captures.get(ip)[parent_idx],
2961 .instruction_load => |ptr_inst| capture: {2960 .instruction_load => |ptr_inst| capture: {
2962 const ptr_ref = try sema.resolveInst(ptr_inst.toRef());2961 const ptr_ref = sema.resolveInst(ptr_inst.toRef());
2963 const ptr_val = try sema.resolveValue(ptr_ref) orelse {2962 const ptr_val = sema.resolveValue(ptr_ref) orelse {
2964 break :capture .wrap(.{ .runtime = sema.typeOf(ptr_ref).childType(zcu).toIntern() });2963 break :capture .wrap(.{ .runtime = sema.typeOf(ptr_ref).childType(zcu).toIntern() });
2965 };2964 };
2966 // TODO: better source location2965 // TODO: better source location
...@@ -2974,8 +2973,8 @@ fn getCaptures(...@@ -2974,8 +2973,8 @@ fn getCaptures(
2974 break :capture .wrap(.{ .@"comptime" = loaded_val.toIntern() });2973 break :capture .wrap(.{ .@"comptime" = loaded_val.toIntern() });
2975 },2974 },
2976 .instruction => |inst| capture: {2975 .instruction => |inst| capture: {
2977 const air_ref = try sema.resolveInst(inst.toRef());2976 const air_ref = sema.resolveInst(inst.toRef());
2978 if (try sema.resolveValue(air_ref)) |val| {2977 if (sema.resolveValue(air_ref)) |val| {
2979 if (val.canMutateComptimeVarState(zcu)) {2978 if (val.canMutateComptimeVarState(zcu)) {
2980 const field_name = try ip.getOrPutString(gpa, io, pt.tid, zir_name_slice, .no_embedded_nulls);2979 const field_name = try ip.getOrPutString(gpa, io, pt.tid, zir_name_slice, .no_embedded_nulls);
2981 return sema.failWithContainsReferenceToComptimeVar(block, type_src, field_name, "captured value", val);2980 return sema.failWithContainsReferenceToComptimeVar(block, type_src, field_name, "captured value", val);
...@@ -3079,7 +3078,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -3079,7 +3078,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
3079 defer tracy.end();3078 defer tracy.end();
30803079
3081 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;3080 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok;
3082 const operand = try sema.resolveInst(inst_data.operand);3081 const operand = sema.resolveInst(inst_data.operand);
3083 return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand);3082 return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand);
3084}3083}
30853084
...@@ -3088,7 +3087,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile...@@ -3088,7 +3087,7 @@ fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
3088 defer tracy.end();3087 defer tracy.end();
30893088
3090 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3089 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3091 const operand = try sema.resolveInst(inst_data.operand);3090 const operand = sema.resolveInst(inst_data.operand);
3092 const src = block.nodeOffset(inst_data.src_node);3091 const src = block.nodeOffset(inst_data.src_node);
30933092
3094 return sema.ensureResultUsed(block, sema.typeOf(operand), src);3093 return sema.ensureResultUsed(block, sema.typeOf(operand), src);
...@@ -3134,7 +3133,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -3134,7 +3133,7 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
3134 const pt = sema.pt;3133 const pt = sema.pt;
3135 const zcu = pt.zcu;3134 const zcu = pt.zcu;
3136 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3135 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3137 const operand = try sema.resolveInst(inst_data.operand);3136 const operand = sema.resolveInst(inst_data.operand);
3138 const src = block.nodeOffset(inst_data.src_node);3137 const src = block.nodeOffset(inst_data.src_node);
3139 const operand_ty = sema.typeOf(operand);3138 const operand_ty = sema.typeOf(operand);
3140 switch (operand_ty.zigTypeTag(zcu)) {3139 switch (operand_ty.zigTypeTag(zcu)) {
...@@ -3160,7 +3159,7 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index...@@ -3160,7 +3159,7 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index
3160 const zcu = pt.zcu;3159 const zcu = pt.zcu;
3161 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3160 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3162 const src = block.nodeOffset(inst_data.src_node);3161 const src = block.nodeOffset(inst_data.src_node);
3163 const operand = try sema.resolveInst(inst_data.operand);3162 const operand = sema.resolveInst(inst_data.operand);
3164 const operand_ty = sema.typeOf(operand);3163 const operand_ty = sema.typeOf(operand);
3165 const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .pointer)3164 const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .pointer)
3166 operand_ty.childType(zcu)3165 operand_ty.childType(zcu)
...@@ -3185,7 +3184,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -3185,7 +3184,7 @@ fn zirIndexablePtrLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
31853184
3186 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3185 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3187 const src = block.nodeOffset(inst_data.src_node);3186 const src = block.nodeOffset(inst_data.src_node);
3188 const object = try sema.resolveInst(inst_data.operand);3187 const object = sema.resolveInst(inst_data.operand);
31893188
3190 return indexablePtrLen(sema, block, src, object);3189 return indexablePtrLen(sema, block, src, object);
3191}3190}
...@@ -3331,7 +3330,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -3331,7 +3330,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
3331 const pt = sema.pt;3330 const pt = sema.pt;
3332 const zcu = pt.zcu;3331 const zcu = pt.zcu;
3333 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3332 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3334 const alloc = try sema.resolveInst(inst_data.operand);3333 const alloc = sema.resolveInst(inst_data.operand);
3335 const alloc_ty = sema.typeOf(alloc);3334 const alloc_ty = sema.typeOf(alloc);
3336 const ptr_info = alloc_ty.ptrInfo(zcu);3335 const ptr_info = alloc_ty.ptrInfo(zcu);
3337 const elem_ty: Type = .fromInterned(ptr_info.child);3336 const elem_ty: Type = .fromInterned(ptr_info.child);
...@@ -3340,7 +3339,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -3340,7 +3339,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
3340 // However, if the final constructed value does not reference comptime-mutable memory, we wish3339 // However, if the final constructed value does not reference comptime-mutable memory, we wish
3341 // to promote it to an anon decl.3340 // to promote it to an anon decl.
3342 already_ct: {3341 already_ct: {
3343 const ptr_val = try sema.resolveValue(alloc) orelse break :already_ct;3342 const ptr_val = sema.resolveValue(alloc) orelse break :already_ct;
33443343
3345 // If this was a comptime inferred alloc, then `storeToInferredAllocComptime`3344 // If this was a comptime inferred alloc, then `storeToInferredAllocComptime`
3346 // might have already done our job and created an anon decl ref.3345 // might have already done our job and created an anon decl ref.
...@@ -3526,7 +3525,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,...@@ -3526,7 +3525,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
3526 Air.Bin,3525 Air.Bin,
3527 tmp_air.instructions.items(.data)[@intFromEnum(air_ptr)].ty_pl.payload,3526 tmp_air.instructions.items(.data)[@intFromEnum(air_ptr)].ty_pl.payload,
3528 ).data;3527 ).data;
3529 const idx_val = (try sema.resolveValue(data.rhs)).?;3528 const idx_val = sema.resolveValue(data.rhs).?;
3530 break :blk .{3529 break :blk .{
3531 data.lhs,3530 data.lhs,
3532 .{ .elem = idx_val.toUnsignedInt(zcu) },3531 .{ .elem = idx_val.toUnsignedInt(zcu) },
...@@ -3625,7 +3624,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,...@@ -3625,7 +3624,7 @@ fn resolveComptimeKnownAllocPtr(sema: *Sema, block: *Block, alloc: Air.Inst.Ref,
3625 },3624 },
3626 .store, .store_safe => {3625 .store, .store_safe => {
3627 const air_ptr_inst = store_inst.data.bin_op.lhs.toIndex().?;3626 const air_ptr_inst = store_inst.data.bin_op.lhs.toIndex().?;
3628 const store_val = (try sema.resolveValue(store_inst.data.bin_op.rhs)).?;3627 const store_val = sema.resolveValue(store_inst.data.bin_op.rhs).?;
3629 const new_ptr = ptr_mapping.get(air_ptr_inst).?;3628 const new_ptr = ptr_mapping.get(air_ptr_inst).?;
3630 try sema.storePtrVal(block, .unneeded, .fromInterned(new_ptr), store_val, store_val.typeOf(zcu));3629 try sema.storePtrVal(block, .unneeded, .fromInterned(new_ptr), store_val, store_val.typeOf(zcu));
3631 },3630 },
...@@ -3708,7 +3707,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai...@@ -3708,7 +3707,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai
3708 const const_ptr_ty = try sema.makePtrTyConst(alloc_ty);3707 const const_ptr_ty = try sema.makePtrTyConst(alloc_ty);
37093708
3710 // Detect if a comptime value simply needs to have its type changed.3709 // Detect if a comptime value simply needs to have its type changed.
3711 if (try sema.resolveValue(alloc)) |val| {3710 if (sema.resolveValue(alloc)) |val| {
3712 return Air.internedToRef((try sema.pt.getCoerced(val, const_ptr_ty)).toIntern());3711 return Air.internedToRef((try sema.pt.getCoerced(val, const_ptr_ty)).toIntern());
3713 }3712 }
37143713
...@@ -3840,7 +3839,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -3840,7 +3839,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
3840 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;3839 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
3841 const src = block.nodeOffset(inst_data.src_node);3840 const src = block.nodeOffset(inst_data.src_node);
3842 const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node });3841 const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node });
3843 const ptr = try sema.resolveInst(inst_data.operand);3842 const ptr = sema.resolveInst(inst_data.operand);
3844 const ptr_inst = ptr.toIndex().?;3843 const ptr_inst = ptr.toIndex().?;
3845 const target = zcu.getTarget();3844 const target = zcu.getTarget();
38463845
...@@ -4005,7 +4004,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4005,7 +4004,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
40054004
4006 const arg_len_uncoerced = if (zir_arg_pair[1] == .none) l: {4005 const arg_len_uncoerced = if (zir_arg_pair[1] == .none) l: {
4007 // This argument is an indexable.4006 // This argument is an indexable.
4008 const object = try sema.resolveInst(zir_arg_pair[0]);4007 const object = sema.resolveInst(zir_arg_pair[0]);
4009 const object_ty = sema.typeOf(object);4008 const object_ty = sema.typeOf(object);
4010 if (!object_ty.isIndexable(zcu)) {4009 if (!object_ty.isIndexable(zcu)) {
4011 // Instead of using checkIndexable we customize this error.4010 // Instead of using checkIndexable we customize this error.
...@@ -4026,8 +4025,8 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4026,8 +4025,8 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
4026 break :l try sema.fieldVal(block, arg_src, object, try ip.getOrPutString(gpa, io, pt.tid, "len", .no_embedded_nulls), arg_src);4025 break :l try sema.fieldVal(block, arg_src, object, try ip.getOrPutString(gpa, io, pt.tid, "len", .no_embedded_nulls), arg_src);
4027 } else l: {4026 } else l: {
4028 // This argument is a range.4027 // This argument is a range.
4029 const range_start = try sema.resolveInst(zir_arg_pair[0]);4028 const range_start = sema.resolveInst(zir_arg_pair[0]);
4030 const range_end = try sema.resolveInst(zir_arg_pair[1]);4029 const range_end = sema.resolveInst(zir_arg_pair[1]);
4031 if (try sema.resolveDefinedValue(block, arg_src, range_start)) |start| {4030 if (try sema.resolveDefinedValue(block, arg_src, range_start)) |start| {
4032 if (try sema.valuesEqual(start, .zero_usize, .usize)) break :l range_end;4031 if (try sema.valuesEqual(start, .zero_usize, .usize)) break :l range_end;
4033 }4032 }
...@@ -4077,7 +4076,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4077,7 +4076,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
4077 const i: u32 = @intCast(i_usize);4076 const i: u32 = @intCast(i_usize);
4078 if (zir_arg_pair[0] == .none) continue;4077 if (zir_arg_pair[0] == .none) continue;
4079 if (zir_arg_pair[1] != .none) continue;4078 if (zir_arg_pair[1] != .none) continue;
4080 const object = try sema.resolveInst(zir_arg_pair[0]);4079 const object = sema.resolveInst(zir_arg_pair[0]);
4081 const object_ty = sema.typeOf(object);4080 const object_ty = sema.typeOf(object);
4082 const arg_src = block.src(.{ .for_input = .{4081 const arg_src = block.src(.{ .for_input = .{
4083 .for_node_offset = inst_data.src_node,4082 .for_node_offset = inst_data.src_node,
...@@ -4132,7 +4131,7 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL...@@ -4132,7 +4131,7 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL
41324131
4133fn zirOptEuBasePtrInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {4132fn zirOptEuBasePtrInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
4134 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;4133 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4135 const ptr = try sema.resolveInst(un_node.operand);4134 const ptr = sema.resolveInst(un_node.operand);
4136 try sema.ensureLayoutResolved(sema.typeOf(ptr).childType(sema.pt.zcu));4135 try sema.ensureLayoutResolved(sema.typeOf(ptr).childType(sema.pt.zcu));
4137 return sema.optEuBasePtrInit(block, ptr, block.nodeOffset(un_node.src_node));4136 return sema.optEuBasePtrInit(block, ptr, block.nodeOffset(un_node.src_node));
4138}4137}
...@@ -4143,7 +4142,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -4143,7 +4142,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4143 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4142 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4144 const src = block.nodeOffset(pl_node.src_node);4143 const src = block.nodeOffset(pl_node.src_node);
4145 const extra = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;4144 const extra = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
4146 const uncoerced_val = try sema.resolveInst(extra.rhs);4145 const uncoerced_val = sema.resolveInst(extra.rhs);
4147 const maybe_wrapped_ptr_ty = try sema.resolveTypeOrPoison(block, LazySrcLoc.unneeded, extra.lhs) orelse return uncoerced_val;4146 const maybe_wrapped_ptr_ty = try sema.resolveTypeOrPoison(block, LazySrcLoc.unneeded, extra.lhs) orelse return uncoerced_val;
4148 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);4147 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);
4149 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction4148 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
...@@ -4259,7 +4258,7 @@ fn zirValidateConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -4259,7 +4258,7 @@ fn zirValidateConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
42594258
4260 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;4259 const un_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4261 const src = block.nodeOffset(un_node.src_node);4260 const src = block.nodeOffset(un_node.src_node);
4262 const init_ref = try sema.resolveInst(un_node.operand);4261 const init_ref = sema.resolveInst(un_node.operand);
4263 if (!try sema.isComptimeKnown(init_ref)) {4262 if (!try sema.isComptimeKnown(init_ref)) {
4264 return sema.failWithNeededComptime(block, src, null);4263 return sema.failWithNeededComptime(block, src, null);
4265 }4264 }
...@@ -4402,7 +4401,7 @@ fn zirValidatePtrStructInit(...@@ -4402,7 +4401,7 @@ fn zirValidatePtrStructInit(
4402 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);4401 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
4403 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;4402 const field_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
4404 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;4403 const field_ptr_extra = sema.code.extraData(Zir.Inst.Field, field_ptr_data.payload_index).data;
4405 const object_ptr = try sema.resolveInst(field_ptr_extra.lhs);4404 const object_ptr = sema.resolveInst(field_ptr_extra.lhs);
4406 const agg_ty = sema.typeOf(object_ptr).childType(zcu).optEuBaseType(zcu);4405 const agg_ty = sema.typeOf(object_ptr).childType(zcu).optEuBaseType(zcu);
4407 switch (agg_ty.zigTypeTag(zcu)) {4406 switch (agg_ty.zigTypeTag(zcu)) {
4408 .@"struct" => return sema.validateStructInit(4407 .@"struct" => return sema.validateStructInit(
...@@ -4571,7 +4570,7 @@ fn zirValidatePtrArrayInit(...@@ -4571,7 +4570,7 @@ fn zirValidatePtrArrayInit(
4571 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);4570 const instrs = sema.code.bodySlice(validate_extra.end, validate_extra.data.body_len);
4572 const first_elem_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;4571 const first_elem_ptr_data = sema.code.instructions.items(.data)[@intFromEnum(instrs[0])].pl_node;
4573 const elem_ptr_extra = sema.code.extraData(Zir.Inst.ElemPtrImm, first_elem_ptr_data.payload_index).data;4572 const elem_ptr_extra = sema.code.extraData(Zir.Inst.ElemPtrImm, first_elem_ptr_data.payload_index).data;
4574 const array_ptr = try sema.resolveInst(elem_ptr_extra.ptr);4573 const array_ptr = sema.resolveInst(elem_ptr_extra.ptr);
4575 const array_ty = sema.typeOf(array_ptr).childType(zcu).optEuBaseType(zcu);4574 const array_ty = sema.typeOf(array_ptr).childType(zcu).optEuBaseType(zcu);
4576 const array_len = array_ty.arrayLen(zcu);4575 const array_len = array_ty.arrayLen(zcu);
45774576
...@@ -4631,7 +4630,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -4631,7 +4630,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
4631 const zcu = pt.zcu;4630 const zcu = pt.zcu;
4632 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;4631 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
4633 const src = block.nodeOffset(inst_data.src_node);4632 const src = block.nodeOffset(inst_data.src_node);
4634 const operand = try sema.resolveInst(inst_data.operand);4633 const operand = sema.resolveInst(inst_data.operand);
4635 const operand_ty = sema.typeOf(operand);4634 const operand_ty = sema.typeOf(operand);
46364635
4637 if (operand_ty.zigTypeTag(zcu) != .pointer) {4636 if (operand_ty.zigTypeTag(zcu) != .pointer) {
...@@ -4650,7 +4649,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -4650,7 +4649,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
4650 return;4649 return;
4651 }4650 }
46524651
4653 if (try sema.resolveValue(operand)) |val| {4652 if (sema.resolveValue(operand)) |val| {
4654 if (val.isUndef(zcu)) {4653 if (val.isUndef(zcu)) {
4655 return sema.fail(block, src, "cannot dereference undefined value", .{});4654 return sema.fail(block, src, "cannot dereference undefined value", .{});
4656 }4655 }
...@@ -4685,7 +4684,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -4685,7 +4684,7 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
4685 const extra = sema.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data;4684 const extra = sema.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data;
4686 const src = block.nodeOffset(inst_data.src_node);4685 const src = block.nodeOffset(inst_data.src_node);
4687 const destructure_src = block.nodeOffset(extra.destructure_node);4686 const destructure_src = block.nodeOffset(extra.destructure_node);
4688 const operand = try sema.resolveInst(extra.operand);4687 const operand = sema.resolveInst(extra.operand);
4689 const operand_ty = sema.typeOf(operand);4688 const operand_ty = sema.typeOf(operand);
46904689
4691 if (!typeIsDestructurable(operand_ty, zcu)) {4690 if (!typeIsDestructurable(operand_ty, zcu)) {
...@@ -4813,8 +4812,8 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi...@@ -4813,8 +4812,8 @@ fn zirStoreToInferredPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
4813 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;4812 const pl_node = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
4814 const src = block.nodeOffset(pl_node.src_node);4813 const src = block.nodeOffset(pl_node.src_node);
4815 const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;4814 const bin = sema.code.extraData(Zir.Inst.Bin, pl_node.payload_index).data;
4816 const ptr = try sema.resolveInst(bin.lhs);4815 const ptr = sema.resolveInst(bin.lhs);
4817 const operand = try sema.resolveInst(bin.rhs);4816 const operand = sema.resolveInst(bin.rhs);
4818 const ptr_inst = ptr.toIndex().?;4817 const ptr_inst = ptr.toIndex().?;
4819 const air_datas = sema.air_instructions.items(.data);4818 const air_datas = sema.air_instructions.items(.data);
48204819
...@@ -4860,7 +4859,7 @@ fn storeToInferredAllocComptime(...@@ -4860,7 +4859,7 @@ fn storeToInferredAllocComptime(
4860 const operand_ty = sema.typeOf(operand);4859 const operand_ty = sema.typeOf(operand);
4861 // There will be only one store_to_inferred_ptr because we are running at comptime.4860 // There will be only one store_to_inferred_ptr because we are running at comptime.
4862 // The alloc will turn into a Decl or a ComptimeAlloc.4861 // The alloc will turn into a Decl or a ComptimeAlloc.
4863 const operand_val = try sema.resolveValue(operand) orelse {4862 const operand_val = sema.resolveValue(operand) orelse {
4864 return sema.failWithNeededComptime(block, src, .{ .simple = .stored_to_comptime_var });4863 return sema.failWithNeededComptime(block, src, .{ .simple = .stored_to_comptime_var });
4865 };4864 };
4866 const alloc_ty = try pt.ptrType(.{4865 const alloc_ty = try pt.ptrType(.{
...@@ -4909,8 +4908,8 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v...@@ -4909,8 +4908,8 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
4909 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;4908 const inst_data = zir_datas[@intFromEnum(inst)].pl_node;
4910 const src = block.nodeOffset(inst_data.src_node);4909 const src = block.nodeOffset(inst_data.src_node);
4911 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;4910 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
4912 const ptr = try sema.resolveInst(extra.lhs);4911 const ptr = sema.resolveInst(extra.lhs);
4913 const operand = try sema.resolveInst(extra.rhs);4912 const operand = sema.resolveInst(extra.rhs);
49144913
4915 const is_ret = if (extra.lhs.toIndex()) |ptr_index|4914 const is_ret = if (extra.lhs.toIndex()) |ptr_index|
4916 zir_tags[@intFromEnum(ptr_index)] == .ret_ptr4915 zir_tags[@intFromEnum(ptr_index)] == .ret_ptr
...@@ -5044,9 +5043,9 @@ fn zirCompileLog(...@@ -5044,9 +5043,9 @@ fn zirCompileLog(
5044 for (args, 0..) |arg_ref, i| {5043 for (args, 0..) |arg_ref, i| {
5045 if (i != 0) writer.writeAll(", ") catch return error.OutOfMemory;5044 if (i != 0) writer.writeAll(", ") catch return error.OutOfMemory;
50465045
5047 const arg = try sema.resolveInst(arg_ref);5046 const arg = sema.resolveInst(arg_ref);
5048 const arg_ty = sema.typeOf(arg);5047 const arg_ty = sema.typeOf(arg);
5049 if (try sema.resolveValue(arg)) |val| {5048 if (sema.resolveValue(arg)) |val| {
5050 writer.print("@as({f}, {f})", .{5049 writer.print("@as({f}, {f})", .{
5051 arg_ty.fmt(pt), val.fmtValueSema(pt, sema),5050 arg_ty.fmt(pt), val.fmtValueSema(pt, sema),
5052 }) catch return error.OutOfMemory;5051 }) catch return error.OutOfMemory;
...@@ -5094,7 +5093,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -5094,7 +5093,7 @@ fn zirPanic(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
50945093
5095 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;5094 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
5096 const src = block.nodeOffset(inst_data.src_node);5095 const src = block.nodeOffset(inst_data.src_node);
5097 const msg_inst = try sema.resolveInst(inst_data.operand);5096 const msg_inst = sema.resolveInst(inst_data.operand);
50985097
5099 const arg_src = block.builtinCallArgSrc(inst_data.src_node, 0);5098 const arg_src = block.builtinCallArgSrc(inst_data.src_node, 0);
5100 const coerced_msg = try sema.coerce(block, .slice_const_u8, msg_inst, arg_src);5099 const coerced_msg = try sema.coerce(block, .slice_const_u8, msg_inst, arg_src);
...@@ -5464,7 +5463,7 @@ fn resolveBlockBody(...@@ -5464,7 +5463,7 @@ fn resolveBlockBody(
5464 const break_data = sema.code.instructions.items(.data)[@intFromEnum(break_inst)].@"break";5463 const break_data = sema.code.instructions.items(.data)[@intFromEnum(break_inst)].@"break";
5465 const extra = sema.code.extraData(Zir.Inst.Break, break_data.payload_index).data;5464 const extra = sema.code.extraData(Zir.Inst.Break, break_data.payload_index).data;
5466 if (extra.block_inst == body_inst) {5465 if (extra.block_inst == body_inst) {
5467 return try sema.resolveInst(break_data.operand);5466 return sema.resolveInst(break_data.operand);
5468 } else {5467 } else {
5469 return error.ComptimeBreak;5468 return error.ComptimeBreak;
5470 }5469 }
...@@ -5555,7 +5554,7 @@ fn resolveAnalyzedBlock(...@@ -5555,7 +5554,7 @@ fn resolveAnalyzedBlock(
5555 // Okay, we need a runtime block. If the value is comptime-known, the5554 // Okay, we need a runtime block. If the value is comptime-known, the
5556 // block should just return void, and we return the merge result5555 // block should just return void, and we return the merge result
5557 // directly. Otherwise, we can defer to the logic below.5556 // directly. Otherwise, we can defer to the logic below.
5558 if (try sema.resolveValue(merges.results.items[0])) |result_val| {5557 if (sema.resolveValue(merges.results.items[0])) |result_val| {
5559 // Create a block containing all instruction from the body.5558 // Create a block containing all instruction from the body.
5560 try parent_block.instructions.append(gpa, merges.block_inst);5559 try parent_block.instructions.append(gpa, merges.block_inst);
5561 switch (block_tag) {5560 switch (block_tag) {
...@@ -5714,7 +5713,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -5714,7 +5713,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
5714 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);5713 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);
5715 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);5714 const options_src = block.builtinCallArgSrc(inst_data.src_node, 1);
57165715
5717 const ptr = try sema.resolveInst(extra.exported);5716 const ptr = sema.resolveInst(extra.exported);
5718 const ptr_val = try sema.resolveConstDefinedValue(block, ptr_src, ptr, .{ .simple = .export_target });5717 const ptr_val = try sema.resolveConstDefinedValue(block, ptr_src, ptr, .{ .simple = .export_target });
5719 const ptr_ty = ptr_val.typeOf(zcu);5718 const ptr_ty = ptr_val.typeOf(zcu);
57205719
...@@ -5878,7 +5877,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError...@@ -5878,7 +5877,7 @@ fn zirBreak(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) CompileError
58785877
5879 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break";5878 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break";
5880 const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data;5879 const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data;
5881 const operand = try sema.resolveInst(inst_data.operand);5880 const operand = sema.resolveInst(inst_data.operand);
5882 const zir_block = extra.block_inst;5881 const zir_block = extra.block_inst;
58835882
5884 var block = start_block;5883 var block = start_block;
...@@ -5912,7 +5911,7 @@ fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) Com...@@ -5912,7 +5911,7 @@ fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) Com
5912 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break";5911 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].@"break";
5913 const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data;5912 const extra = sema.code.extraData(Zir.Inst.Break, inst_data.payload_index).data;
5914 const operand_src = start_block.nodeOffset(extra.operand_src_node.unwrap().?);5913 const operand_src = start_block.nodeOffset(extra.operand_src_node.unwrap().?);
5915 const uncoerced_operand = try sema.resolveInst(inst_data.operand);5914 const uncoerced_operand = sema.resolveInst(inst_data.operand);
5916 const switch_inst = extra.block_inst;5915 const switch_inst = extra.block_inst;
59175916
5918 switch (sema.code.instructions.items(.tag)[@intFromEnum(switch_inst)]) {5917 switch (sema.code.instructions.items(.tag)[@intFromEnum(switch_inst)]) {
...@@ -5921,7 +5920,7 @@ fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) Com...@@ -5921,7 +5920,7 @@ fn zirSwitchContinue(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index) Com
5921 else => unreachable, // assertion failure5920 else => unreachable, // assertion failure
5922 }5921 }
59235922
5924 const operand_ty = (try sema.resolveInst(switch_inst.toRef())).toType();5923 const operand_ty = (sema.resolveInst(switch_inst.toRef())).toType();
5925 const operand = try sema.coerce(start_block, operand_ty, uncoerced_operand, operand_src);5924 const operand = try sema.coerce(start_block, operand_ty, uncoerced_operand, operand_src);
5926 try sema.validateRuntimeValue(start_block, operand_src, operand);5925 try sema.validateRuntimeValue(start_block, operand_src, operand);
59275926
...@@ -5988,7 +5987,7 @@ fn zirDbgVar(...@@ -5988,7 +5987,7 @@ fn zirDbgVar(
5988 air_tag: Air.Inst.Tag,5987 air_tag: Air.Inst.Tag,
5989) CompileError!void {5988) CompileError!void {
5990 const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op;5989 const str_op = sema.code.instructions.items(.data)[@intFromEnum(inst)].str_op;
5991 const operand = try sema.resolveInst(str_op.operand);5990 const operand = sema.resolveInst(str_op.operand);
5992 const name = str_op.getStr(sema.code);5991 const name = str_op.getStr(sema.code);
5993 try sema.addDbgVar(block, operand, air_tag, name);5992 try sema.addDbgVar(block, operand, air_tag, name);
5994}5993}
...@@ -6012,7 +6011,7 @@ fn addDbgVar(...@@ -6012,7 +6011,7 @@ fn addDbgVar(
6012 };6011 };
6013 if (val_ty.comptimeOnly(zcu)) return;6012 if (val_ty.comptimeOnly(zcu)) return;
6014 if (!val_ty.hasRuntimeBits(zcu)) return;6013 if (!val_ty.hasRuntimeBits(zcu)) return;
6015 if (try sema.resolveValue(operand)) |operand_val| {6014 if (sema.resolveValue(operand)) |operand_val| {
6016 if (operand_val.canMutateComptimeVarState(zcu)) return;6015 if (operand_val.canMutateComptimeVarState(zcu)) return;
6017 }6016 }
60186017
...@@ -6151,7 +6150,7 @@ fn funcDeclSrcInst(sema: *Sema, func_inst: Air.Inst.Ref) !?InternPool.TrackedIns...@@ -6151,7 +6150,7 @@ fn funcDeclSrcInst(sema: *Sema, func_inst: Air.Inst.Ref) !?InternPool.TrackedIns
6151 const pt = sema.pt;6150 const pt = sema.pt;
6152 const zcu = pt.zcu;6151 const zcu = pt.zcu;
6153 const ip = &zcu.intern_pool;6152 const ip = &zcu.intern_pool;
6154 const func_val = try sema.resolveValue(func_inst) orelse return null;6153 const func_val = sema.resolveValue(func_inst) orelse return null;
6155 if (func_val.isUndef(zcu)) return null;6154 if (func_val.isUndef(zcu)) return null;
6156 const nav = switch (ip.indexToKey(func_val.toIntern())) {6155 const nav = switch (ip.indexToKey(func_val.toIntern())) {
6157 .@"extern" => |e| e.owner_nav,6156 .@"extern" => |e| e.owner_nav,
...@@ -6323,9 +6322,9 @@ fn zirCall(...@@ -6323,9 +6322,9 @@ fn zirCall(
6323 const pop_error_return_trace = extra.data.flags.pop_error_return_trace;6322 const pop_error_return_trace = extra.data.flags.pop_error_return_trace;
63246323
6325 const callee: ResolvedFieldCallee = switch (kind) {6324 const callee: ResolvedFieldCallee = switch (kind) {
6326 .direct => .{ .direct = try sema.resolveInst(extra.data.callee) },6325 .direct => .{ .direct = sema.resolveInst(extra.data.callee) },
6327 .field => blk: {6326 .field => blk: {
6328 const object_ptr = try sema.resolveInst(extra.data.obj_ptr);6327 const object_ptr = sema.resolveInst(extra.data.obj_ptr);
6329 const field_name = try zcu.intern_pool.getOrPutString(6328 const field_name = try zcu.intern_pool.getOrPutString(
6330 gpa,6329 gpa,
6331 io,6330 io,
...@@ -7097,7 +7096,7 @@ fn analyzeCall(...@@ -7097,7 +7096,7 @@ fn analyzeCall(
70977096
7098 if (is_comptime) {7097 if (is_comptime) {
7099 // We already emitted an error if the argument isn't comptime-known.7098 // We already emitted an error if the argument isn't comptime-known.
7100 comptime_arg.* = (try sema.resolveValue(arg)).?.toIntern();7099 comptime_arg.* = sema.resolveValue(arg).?.toIntern();
7101 } else {7100 } else {
7102 comptime_arg.* = .none;7101 comptime_arg.* = .none;
7103 if (is_noalias) {7102 if (is_noalias) {
...@@ -7139,7 +7138,7 @@ fn analyzeCall(...@@ -7139,7 +7138,7 @@ fn analyzeCall(
7139 };7138 };
71407139
7141 ref_func: {7140 ref_func: {
7142 const runtime_func_val = try sema.resolveValue(runtime_func) orelse break :ref_func;7141 const runtime_func_val = sema.resolveValue(runtime_func) orelse break :ref_func;
7143 if (!ip.isFuncBody(runtime_func_val.toIntern())) break :ref_func;7142 if (!ip.isFuncBody(runtime_func_val.toIntern())) break :ref_func;
7144 const orig_fn_index = ip.unwrapCoercedFunc(runtime_func_val.toIntern());7143 const orig_fn_index = ip.unwrapCoercedFunc(runtime_func_val.toIntern());
7145 try sema.addReferenceEntry(block, call_src, .wrap(.{ .func = orig_fn_index }));7144 try sema.addReferenceEntry(block, call_src, .wrap(.{ .func = orig_fn_index }));
...@@ -7285,14 +7284,14 @@ fn analyzeCall(...@@ -7285,14 +7284,14 @@ fn analyzeCall(
7285 if (zcu.comp.config.incremental) break :m false;7284 if (zcu.comp.config.incremental) break :m false;
7286 if (!block.isComptime()) break :m false;7285 if (!block.isComptime()) break :m false;
7287 for (args) |a| {7286 for (args) |a| {
7288 const val = (try sema.resolveValue(a)).?;7287 const val = sema.resolveValue(a).?;
7289 if (val.canMutateComptimeVarState(zcu)) break :m false;7288 if (val.canMutateComptimeVarState(zcu)) break :m false;
7290 }7289 }
7291 break :m true;7290 break :m true;
7292 };7291 };
7293 const memoized_arg_values: []const InternPool.Index = if (want_memoize) arg_vals: {7292 const memoized_arg_values: []const InternPool.Index = if (want_memoize) arg_vals: {
7294 const vals = try sema.arena.alloc(InternPool.Index, args.len);7293 const vals = try sema.arena.alloc(InternPool.Index, args.len);
7295 for (vals, args) |*v, a| v.* = (try sema.resolveValue(a)).?.toIntern();7294 for (vals, args) |*v, a| v.* = sema.resolveValue(a).?.toIntern();
7296 break :arg_vals vals;7295 break :arg_vals vals;
7297 } else undefined;7296 } else undefined;
7298 if (want_memoize) memoize: {7297 if (want_memoize) memoize: {
...@@ -7453,7 +7452,7 @@ fn analyzeCall(...@@ -7453,7 +7452,7 @@ fn analyzeCall(
7453 return .unreachable_value;7452 return .unreachable_value;
7454 }7453 }
74557454
7456 const maybe_opv: Air.Inst.Ref = if (try sema.resolveValue(result_raw)) |result_val| r: {7455 const maybe_opv: Air.Inst.Ref = if (sema.resolveValue(result_raw)) |result_val| r: {
7457 const val_resolved = try sema.resolveAdHocInferredErrorSet(block, call_src, result_val.toIntern());7456 const val_resolved = try sema.resolveAdHocInferredErrorSet(block, call_src, result_val.toIntern());
7458 break :r Air.internedToRef(val_resolved);7457 break :r Air.internedToRef(val_resolved);
7459 } else r: {7458 } else r: {
...@@ -7465,7 +7464,7 @@ fn analyzeCall(...@@ -7465,7 +7464,7 @@ fn analyzeCall(
7465 };7464 };
74667465
7467 if (block.isComptime()) {7466 if (block.isComptime()) {
7468 const result_val = (try sema.resolveValue(maybe_opv)).?;7467 const result_val = sema.resolveValue(maybe_opv).?;
7469 if (want_memoize and sema.allow_memoize and !result_val.canMutateComptimeVarState(zcu)) {7468 if (want_memoize and sema.allow_memoize and !result_val.canMutateComptimeVarState(zcu)) {
7470 _ = try pt.intern(.{ .memoized_call = .{7469 _ = try pt.intern(.{ .memoized_call = .{
7471 .func = func_val.?.toIntern(),7470 .func = func_val.?.toIntern(),
...@@ -7641,7 +7640,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil...@@ -7641,7 +7640,7 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
7641 const len = try sema.resolveInt(block, len_src, extra.len, .usize, .{ .simple = .array_length });7640 const len = try sema.resolveInt(block, len_src, extra.len, .usize, .{ .simple = .array_length });
7642 const elem_type = try sema.resolveType(block, elem_src, extra.elem_type);7641 const elem_type = try sema.resolveType(block, elem_src, extra.elem_type);
7643 try sema.validateArrayElemType(block, elem_type, elem_src);7642 try sema.validateArrayElemType(block, elem_type, elem_src);
7644 const uncasted_sentinel = try sema.resolveInst(extra.sentinel);7643 const uncasted_sentinel = sema.resolveInst(extra.sentinel);
7645 const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src);7644 const sentinel = try sema.coerce(block, elem_type, uncasted_sentinel, sentinel_src);
7646 const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel, .{ .simple = .array_sentinel });7645 const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel, .{ .simple = .array_sentinel });
7647 if (sentinel_val.canMutateComptimeVarState(zcu)) {7646 if (sentinel_val.canMutateComptimeVarState(zcu)) {
...@@ -7757,11 +7756,11 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD...@@ -7757,11 +7756,11 @@ fn zirIntFromError(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
7757 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;7756 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
7758 const src = block.nodeOffset(extra.node);7757 const src = block.nodeOffset(extra.node);
7759 const operand_src = block.builtinCallArgSrc(extra.node, 0);7758 const operand_src = block.builtinCallArgSrc(extra.node, 0);
7760 const uncasted_operand = try sema.resolveInst(extra.operand);7759 const uncasted_operand = sema.resolveInst(extra.operand);
7761 const operand = try sema.coerce(block, .anyerror, uncasted_operand, operand_src);7760 const operand = try sema.coerce(block, .anyerror, uncasted_operand, operand_src);
7762 const err_int_ty = try pt.errorIntType();7761 const err_int_ty = try pt.errorIntType();
77637762
7764 if (try sema.resolveValue(operand)) |val| {7763 if (sema.resolveValue(operand)) |val| {
7765 if (val.isUndef(zcu)) {7764 if (val.isUndef(zcu)) {
7766 return pt.undefRef(err_int_ty);7765 return pt.undefRef(err_int_ty);
7767 }7766 }
...@@ -7801,7 +7800,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD...@@ -7801,7 +7800,7 @@ fn zirErrorFromInt(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstD
7801 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;7800 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
7802 const src = block.nodeOffset(extra.node);7801 const src = block.nodeOffset(extra.node);
7803 const operand_src = block.builtinCallArgSrc(extra.node, 0);7802 const operand_src = block.builtinCallArgSrc(extra.node, 0);
7804 const uncasted_operand = try sema.resolveInst(extra.operand);7803 const uncasted_operand = sema.resolveInst(extra.operand);
7805 const err_int_ty = try pt.errorIntType();7804 const err_int_ty = try pt.errorIntType();
7806 const operand = try sema.coerce(block, err_int_ty, uncasted_operand, operand_src);7805 const operand = try sema.coerce(block, err_int_ty, uncasted_operand, operand_src);
78077806
...@@ -7848,8 +7847,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -7848,8 +7847,8 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
7848 const src = block.src(.{ .node_offset_bin_op = inst_data.src_node });7847 const src = block.src(.{ .node_offset_bin_op = inst_data.src_node });
7849 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });7848 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
7850 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });7849 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
7851 const lhs = try sema.resolveInst(extra.lhs);7850 const lhs = sema.resolveInst(extra.lhs);
7852 const rhs = try sema.resolveInst(extra.rhs);7851 const rhs = sema.resolveInst(extra.rhs);
7853 if (sema.typeOf(lhs).zigTypeTag(zcu) == .bool and sema.typeOf(rhs).zigTypeTag(zcu) == .bool) {7852 if (sema.typeOf(lhs).zigTypeTag(zcu) == .bool and sema.typeOf(rhs).zigTypeTag(zcu) == .bool) {
7854 const msg = msg: {7853 const msg = msg: {
7855 const msg = try sema.errMsg(lhs_src, "expected error set type, found 'bool'", .{});7854 const msg = try sema.errMsg(lhs_src, "expected error set type, found 'bool'", .{});
...@@ -7984,7 +7983,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -7984,7 +7983,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
7984 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;7983 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
7985 const src = block.nodeOffset(inst_data.src_node);7984 const src = block.nodeOffset(inst_data.src_node);
7986 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);7985 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
7987 const operand = try sema.resolveInst(inst_data.operand);7986 const operand = sema.resolveInst(inst_data.operand);
7988 const operand_ty = sema.typeOf(operand);7987 const operand_ty = sema.typeOf(operand);
79897988
7990 const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(zcu)) {7989 const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(zcu)) {
...@@ -8018,7 +8017,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8018,7 +8017,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8018 });8017 });
8019 }8018 }
80208019
8021 if (try sema.resolveValue(enum_tag)) |enum_tag_val| {8020 if (sema.resolveValue(enum_tag)) |enum_tag_val| {
8022 if (enum_tag_val.isUndef(zcu)) return pt.undefRef(int_tag_ty);8021 if (enum_tag_val.isUndef(zcu)) return pt.undefRef(int_tag_ty);
8023 return .fromValue(enum_tag_val.intFromEnum(zcu));8022 return .fromValue(enum_tag_val.intFromEnum(zcu));
8024 }8023 }
...@@ -8035,7 +8034,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8035,7 +8034,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8035 const src = block.nodeOffset(inst_data.src_node);8034 const src = block.nodeOffset(inst_data.src_node);
8036 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);8035 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
8037 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");8036 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");
8038 const operand = try sema.resolveInst(extra.rhs);8037 const operand = sema.resolveInst(extra.rhs);
8039 const operand_ty = sema.typeOf(operand);8038 const operand_ty = sema.typeOf(operand);
80408039
8041 if (dest_ty.zigTypeTag(zcu) != .@"enum") {8040 if (dest_ty.zigTypeTag(zcu) != .@"enum") {
...@@ -8044,7 +8043,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8044,7 +8043,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8044 try sema.ensureLayoutResolved(dest_ty);8043 try sema.ensureLayoutResolved(dest_ty);
8045 _ = try sema.checkIntType(block, operand_src, operand_ty);8044 _ = try sema.checkIntType(block, operand_src, operand_ty);
80468045
8047 if (try sema.resolveValue(operand)) |int_val| {8046 if (sema.resolveValue(operand)) |int_val| {
8048 if (dest_ty.isNonexhaustiveEnum(zcu)) {8047 if (dest_ty.isNonexhaustiveEnum(zcu)) {
8049 const int_tag_ty = dest_ty.intTagType(zcu);8048 const int_tag_ty = dest_ty.intTagType(zcu);
8050 if (int_val.intFitsInType(int_tag_ty, null, zcu)) {8049 if (int_val.intFitsInType(int_tag_ty, null, zcu)) {
...@@ -8099,7 +8098,7 @@ fn zirOptionalPayloadPtr(...@@ -8099,7 +8098,7 @@ fn zirOptionalPayloadPtr(
8099 defer tracy.end();8098 defer tracy.end();
81008099
8101 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8100 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8102 const optional_ptr = try sema.resolveInst(inst_data.operand);8101 const optional_ptr = sema.resolveInst(inst_data.operand);
8103 const src = block.nodeOffset(inst_data.src_node);8102 const src = block.nodeOffset(inst_data.src_node);
81048103
8105 const ptr_ty = sema.typeOf(optional_ptr);8104 const ptr_ty = sema.typeOf(optional_ptr);
...@@ -8193,7 +8192,7 @@ fn zirOptionalPayload(...@@ -8193,7 +8192,7 @@ fn zirOptionalPayload(
8193 const zcu = pt.zcu;8192 const zcu = pt.zcu;
8194 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8193 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8195 const src = block.nodeOffset(inst_data.src_node);8194 const src = block.nodeOffset(inst_data.src_node);
8196 const operand = try sema.resolveInst(inst_data.operand);8195 const operand = sema.resolveInst(inst_data.operand);
8197 const operand_ty = sema.typeOf(operand);8196 const operand_ty = sema.typeOf(operand);
8198 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {8197 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {
8199 .optional => operand_ty.optionalChild(zcu),8198 .optional => operand_ty.optionalChild(zcu),
...@@ -8253,7 +8252,7 @@ fn zirErrUnionPayload(...@@ -8253,7 +8252,7 @@ fn zirErrUnionPayload(
8253 const zcu = pt.zcu;8252 const zcu = pt.zcu;
8254 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8253 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8255 const src = block.nodeOffset(inst_data.src_node);8254 const src = block.nodeOffset(inst_data.src_node);
8256 const operand = try sema.resolveInst(inst_data.operand);8255 const operand = sema.resolveInst(inst_data.operand);
8257 const operand_src = src;8256 const operand_src = src;
8258 const err_union_ty = sema.typeOf(operand);8257 const err_union_ty = sema.typeOf(operand);
8259 if (err_union_ty.zigTypeTag(zcu) != .error_union) {8258 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
...@@ -8309,7 +8308,7 @@ fn zirErrUnionPayloadPtr(...@@ -8309,7 +8308,7 @@ fn zirErrUnionPayloadPtr(
8309 defer tracy.end();8308 defer tracy.end();
83108309
8311 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8310 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8312 const operand = try sema.resolveInst(inst_data.operand);8311 const operand = sema.resolveInst(inst_data.operand);
8313 const src = block.nodeOffset(inst_data.src_node);8312 const src = block.nodeOffset(inst_data.src_node);
83148313
8315 const ptr_ty = sema.typeOf(operand);8314 const ptr_ty = sema.typeOf(operand);
...@@ -8402,7 +8401,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -8402,7 +8401,7 @@ fn zirErrUnionCode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
84028401
8403 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8402 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8404 const src = block.nodeOffset(inst_data.src_node);8403 const src = block.nodeOffset(inst_data.src_node);
8405 const operand = try sema.resolveInst(inst_data.operand);8404 const operand = sema.resolveInst(inst_data.operand);
8406 return sema.analyzeErrUnionCode(block, src, operand);8405 return sema.analyzeErrUnionCode(block, src, operand);
8407}8406}
84088407
...@@ -8438,7 +8437,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -8438,7 +8437,7 @@ fn zirErrUnionCodePtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
84388437
8439 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8438 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8440 const src = block.nodeOffset(inst_data.src_node);8439 const src = block.nodeOffset(inst_data.src_node);
8441 const operand = try sema.resolveInst(inst_data.operand);8440 const operand = sema.resolveInst(inst_data.operand);
8442 return sema.analyzeErrUnionCodePtr(block, src, operand);8441 return sema.analyzeErrUnionCodePtr(block, src, operand);
8443}8442}
84448443
...@@ -9201,7 +9200,7 @@ fn analyzeAs(...@@ -9201,7 +9200,7 @@ fn analyzeAs(
9201) CompileError!Air.Inst.Ref {9200) CompileError!Air.Inst.Ref {
9202 const pt = sema.pt;9201 const pt = sema.pt;
9203 const zcu = pt.zcu;9202 const zcu = pt.zcu;
9204 const operand = try sema.resolveInst(zir_operand);9203 const operand = sema.resolveInst(zir_operand);
9205 const dest_ty = try sema.resolveTypeOrPoison(block, src, zir_dest_type) orelse return operand;9204 const dest_ty = try sema.resolveTypeOrPoison(block, src, zir_dest_type) orelse return operand;
9206 switch (dest_ty.zigTypeTag(zcu)) {9205 switch (dest_ty.zigTypeTag(zcu)) {
9207 .@"opaque" => return sema.fail(block, src, "cannot cast to opaque type '{f}'", .{dest_ty.fmt(pt)}),9206 .@"opaque" => return sema.fail(block, src, "cannot cast to opaque type '{f}'", .{dest_ty.fmt(pt)}),
...@@ -9227,7 +9226,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -9227,7 +9226,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
9227 const zcu = pt.zcu;9226 const zcu = pt.zcu;
9228 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;9227 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
9229 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);9228 const ptr_src = block.builtinCallArgSrc(inst_data.src_node, 0);
9230 const operand = try sema.resolveInst(inst_data.operand);9229 const operand = sema.resolveInst(inst_data.operand);
9231 const operand_ty = sema.typeOf(operand);9230 const operand_ty = sema.typeOf(operand);
9232 const ptr_ty = operand_ty.scalarType(zcu);9231 const ptr_ty = operand_ty.scalarType(zcu);
9233 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;9232 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
...@@ -9238,7 +9237,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -9238,7 +9237,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
9238 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;9237 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;
9239 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .usize_type, .len = len }) else .usize;9238 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .usize_type, .len = len }) else .usize;
92409239
9241 if (try sema.resolveValue(operand)) |operand_val| ct: {9240 if (sema.resolveValue(operand)) |operand_val| ct: {
9242 if (!is_vector) {9241 if (!is_vector) {
9243 if (operand_val.isUndef(zcu)) {9242 if (operand_val.isUndef(zcu)) {
9244 return .undef_usize;9243 return .undef_usize;
...@@ -9297,7 +9296,7 @@ fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -9297,7 +9296,7 @@ fn zirFieldPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
9297 sema.code.nullTerminatedString(extra.field_name_start),9296 sema.code.nullTerminatedString(extra.field_name_start),
9298 .no_embedded_nulls,9297 .no_embedded_nulls,
9299 );9298 );
9300 const object_ptr = try sema.resolveInst(extra.lhs);9299 const object_ptr = sema.resolveInst(extra.lhs);
9301 return fieldPtrLoad(sema, block, src, object_ptr, field_name, field_name_src);9300 return fieldPtrLoad(sema, block, src, object_ptr, field_name, field_name_src);
9302}9301}
93039302
...@@ -9322,7 +9321,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -9322,7 +9321,7 @@ fn zirFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
9322 sema.code.nullTerminatedString(extra.field_name_start),9321 sema.code.nullTerminatedString(extra.field_name_start),
9323 .no_embedded_nulls,9322 .no_embedded_nulls,
9324 );9323 );
9325 const object_ptr = try sema.resolveInst(extra.lhs);9324 const object_ptr = sema.resolveInst(extra.lhs);
9326 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);9325 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);
9327}9326}
93289327
...@@ -9347,7 +9346,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi...@@ -9347,7 +9346,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
9347 sema.code.nullTerminatedString(extra.field_name_start),9346 sema.code.nullTerminatedString(extra.field_name_start),
9348 .no_embedded_nulls,9347 .no_embedded_nulls,
9349 );9348 );
9350 const object_ptr = try sema.resolveInst(extra.lhs);9349 const object_ptr = sema.resolveInst(extra.lhs);
9351 const struct_ty = sema.typeOf(object_ptr).childType(zcu);9350 const struct_ty = sema.typeOf(object_ptr).childType(zcu);
9352 switch (struct_ty.zigTypeTag(zcu)) {9351 switch (struct_ty.zigTypeTag(zcu)) {
9353 .@"struct", .@"union" => {9352 .@"struct", .@"union" => {
...@@ -9367,7 +9366,7 @@ fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil...@@ -9367,7 +9366,7 @@ fn zirFieldPtrNamedLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
9367 const src = block.nodeOffset(inst_data.src_node);9366 const src = block.nodeOffset(inst_data.src_node);
9368 const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1);9367 const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1);
9369 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;9368 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
9370 const object_ptr = try sema.resolveInst(extra.lhs);9369 const object_ptr = sema.resolveInst(extra.lhs);
9371 const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name });9370 const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name });
9372 return fieldPtrLoad(sema, block, src, object_ptr, field_name, field_name_src);9371 return fieldPtrLoad(sema, block, src, object_ptr, field_name, field_name_src);
9373}9372}
...@@ -9380,7 +9379,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -9380,7 +9379,7 @@ fn zirFieldPtrNamed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
9380 const src = block.nodeOffset(inst_data.src_node);9379 const src = block.nodeOffset(inst_data.src_node);
9381 const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1);9380 const field_name_src = block.builtinCallArgSrc(inst_data.src_node, 1);
9382 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;9381 const extra = sema.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data;
9383 const object_ptr = try sema.resolveInst(extra.lhs);9382 const object_ptr = sema.resolveInst(extra.lhs);
9384 const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name });9383 const field_name = try sema.resolveConstStringIntern(block, field_name_src, extra.field_name, .{ .simple = .field_name });
9385 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);9384 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, false);
9386}9385}
...@@ -9395,7 +9394,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -9395,7 +9394,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
9395 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;9394 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
93969395
9397 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast");9396 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast");
9398 const operand = try sema.resolveInst(extra.rhs);9397 const operand = sema.resolveInst(extra.rhs);
93999398
9400 return sema.intCast(block, block.nodeOffset(inst_data.src_node), dest_ty, src, operand, operand_src);9399 return sema.intCast(block, block.nodeOffset(inst_data.src_node), dest_ty, src, operand, operand_src);
9401}9400}
...@@ -9470,7 +9469,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -9470,7 +9469,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
9470 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;9469 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
94719470
9472 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@bitCast");9471 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@bitCast");
9473 const operand = try sema.resolveInst(extra.rhs);9472 const operand = sema.resolveInst(extra.rhs);
9474 const operand_ty = sema.typeOf(operand);9473 const operand_ty = sema.typeOf(operand);
9475 switch (dest_ty.zigTypeTag(zcu)) {9474 switch (dest_ty.zigTypeTag(zcu)) {
9476 .@"anyframe",9475 .@"anyframe",
...@@ -9638,7 +9637,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -9638,7 +9637,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
9638 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatCast");9637 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatCast");
9639 const dest_scalar_ty = dest_ty.scalarType(zcu);9638 const dest_scalar_ty = dest_ty.scalarType(zcu);
96409639
9641 const operand = try sema.resolveInst(extra.rhs);9640 const operand = sema.resolveInst(extra.rhs);
9642 const operand_ty = sema.typeOf(operand);9641 const operand_ty = sema.typeOf(operand);
9643 const operand_scalar_ty = operand_ty.scalarType(zcu);9642 const operand_scalar_ty = operand_ty.scalarType(zcu);
96449643
...@@ -9667,7 +9666,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -9667,7 +9666,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
9667 ),9666 ),
9668 }9667 }
96699668
9670 if (try sema.resolveValue(operand)) |operand_val| {9669 if (sema.resolveValue(operand)) |operand_val| {
9671 if (!is_vector) {9670 if (!is_vector) {
9672 return Air.internedToRef((try operand_val.floatCast(dest_ty, pt)).toIntern());9671 return Air.internedToRef((try operand_val.floatCast(dest_ty, pt)).toIntern());
9673 }9672 }
...@@ -9699,8 +9698,8 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -9699,8 +9698,8 @@ fn zirElemVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
9699 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;9698 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
9700 const src = block.nodeOffset(inst_data.src_node);9699 const src = block.nodeOffset(inst_data.src_node);
9701 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;9700 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9702 const array = try sema.resolveInst(extra.lhs);9701 const array = sema.resolveInst(extra.lhs);
9703 const elem_index = try sema.resolveInst(extra.rhs);9702 const elem_index = sema.resolveInst(extra.rhs);
9704 return sema.elemVal(block, src, array, elem_index, src, false);9703 return sema.elemVal(block, src, array, elem_index, src, false);
9705}9704}
97069705
...@@ -9712,8 +9711,8 @@ fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -9712,8 +9711,8 @@ fn zirElemPtrLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
9712 const src = block.nodeOffset(inst_data.src_node);9711 const src = block.nodeOffset(inst_data.src_node);
9713 const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node });9712 const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node });
9714 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;9713 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9715 const array_ptr = try sema.resolveInst(extra.lhs);9714 const array_ptr = sema.resolveInst(extra.lhs);
9716 const uncoerced_elem_index = try sema.resolveInst(extra.rhs);9715 const uncoerced_elem_index = sema.resolveInst(extra.rhs);
9717 if (try sema.resolveDefinedValue(block, src, array_ptr)) |array_ptr_val| {9716 if (try sema.resolveDefinedValue(block, src, array_ptr)) |array_ptr_val| {
9718 const array_ptr_ty = sema.typeOf(array_ptr);9717 const array_ptr_ty = sema.typeOf(array_ptr);
9719 if (try sema.pointerDeref(block, src, array_ptr_val, array_ptr_ty)) |array_val| {9718 if (try sema.pointerDeref(block, src, array_ptr_val, array_ptr_ty)) |array_val| {
...@@ -9731,7 +9730,7 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -9731,7 +9730,7 @@ fn zirElemValImm(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
9731 defer tracy.end();9730 defer tracy.end();
97329731
9733 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm;9732 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm;
9734 const array = try sema.resolveInst(inst_data.operand);9733 const array = sema.resolveInst(inst_data.operand);
9735 const elem_index = try sema.pt.intRef(.usize, inst_data.idx);9734 const elem_index = try sema.pt.intRef(.usize, inst_data.idx);
9736 return sema.elemVal(block, LazySrcLoc.unneeded, array, elem_index, LazySrcLoc.unneeded, false);9735 return sema.elemVal(block, LazySrcLoc.unneeded, array, elem_index, LazySrcLoc.unneeded, false);
9737}9736}
...@@ -9745,8 +9744,8 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -9745,8 +9744,8 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
9745 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;9744 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
9746 const src = block.nodeOffset(inst_data.src_node);9745 const src = block.nodeOffset(inst_data.src_node);
9747 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;9746 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9748 const array_ptr = try sema.resolveInst(extra.lhs);9747 const array_ptr = sema.resolveInst(extra.lhs);
9749 const elem_index = try sema.resolveInst(extra.rhs);9748 const elem_index = sema.resolveInst(extra.rhs);
9750 const indexable_ty = sema.typeOf(array_ptr);9749 const indexable_ty = sema.typeOf(array_ptr);
9751 if (indexable_ty.zigTypeTag(zcu) != .pointer) {9750 if (indexable_ty.zigTypeTag(zcu) != .pointer) {
9752 const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node });9751 const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node });
...@@ -9775,8 +9774,8 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -9775,8 +9774,8 @@ fn zirElemPtrNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
9775 const src = block.nodeOffset(inst_data.src_node);9774 const src = block.nodeOffset(inst_data.src_node);
9776 const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node });9775 const elem_index_src = block.src(.{ .node_offset_array_access_index = inst_data.src_node });
9777 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;9776 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
9778 const array_ptr = try sema.resolveInst(extra.lhs);9777 const array_ptr = sema.resolveInst(extra.lhs);
9779 const uncoerced_elem_index = try sema.resolveInst(extra.rhs);9778 const uncoerced_elem_index = sema.resolveInst(extra.rhs);
9780 const elem_index = try sema.coerce(block, .usize, uncoerced_elem_index, elem_index_src);9779 const elem_index = try sema.coerce(block, .usize, uncoerced_elem_index, elem_index_src);
9781 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src, false, true);9780 return sema.elemPtr(block, src, array_ptr, elem_index, elem_index_src, false, true);
9782}9781}
...@@ -9790,7 +9789,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile...@@ -9790,7 +9789,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
9790 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;9789 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
9791 const src = block.nodeOffset(inst_data.src_node);9790 const src = block.nodeOffset(inst_data.src_node);
9792 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;9791 const extra = sema.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data;
9793 const array_ptr = try sema.resolveInst(extra.ptr);9792 const array_ptr = sema.resolveInst(extra.ptr);
9794 const elem_index = try pt.intRef(.usize, extra.index);9793 const elem_index = try pt.intRef(.usize, extra.index);
9795 const array_ty = sema.typeOf(array_ptr).childType(zcu);9794 const array_ty = sema.typeOf(array_ptr).childType(zcu);
9796 switch (array_ty.zigTypeTag(zcu)) {9795 switch (array_ty.zigTypeTag(zcu)) {
...@@ -9809,8 +9808,8 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -9809,8 +9808,8 @@ fn zirSliceStart(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
9809 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;9808 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
9810 const src = block.nodeOffset(inst_data.src_node);9809 const src = block.nodeOffset(inst_data.src_node);
9811 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;9810 const extra = sema.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data;
9812 const array_ptr = try sema.resolveInst(extra.lhs);9811 const array_ptr = sema.resolveInst(extra.lhs);
9813 const start = try sema.resolveInst(extra.start);9812 const start = sema.resolveInst(extra.start);
9814 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });9813 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
9815 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });9814 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });
9816 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });9815 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
...@@ -9825,9 +9824,9 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -9825,9 +9824,9 @@ fn zirSliceEnd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
9825 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;9824 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
9826 const src = block.nodeOffset(inst_data.src_node);9825 const src = block.nodeOffset(inst_data.src_node);
9827 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;9826 const extra = sema.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data;
9828 const array_ptr = try sema.resolveInst(extra.lhs);9827 const array_ptr = sema.resolveInst(extra.lhs);
9829 const start = try sema.resolveInst(extra.start);9828 const start = sema.resolveInst(extra.start);
9830 const end = try sema.resolveInst(extra.end);9829 const end = sema.resolveInst(extra.end);
9831 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });9830 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
9832 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });9831 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });
9833 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });9832 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
...@@ -9843,10 +9842,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -9843,10 +9842,10 @@ fn zirSliceSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
9843 const src = block.nodeOffset(inst_data.src_node);9842 const src = block.nodeOffset(inst_data.src_node);
9844 const sentinel_src = block.src(.{ .node_offset_slice_sentinel = inst_data.src_node });9843 const sentinel_src = block.src(.{ .node_offset_slice_sentinel = inst_data.src_node });
9845 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;9844 const extra = sema.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data;
9846 const array_ptr = try sema.resolveInst(extra.lhs);9845 const array_ptr = sema.resolveInst(extra.lhs);
9847 const start = try sema.resolveInst(extra.start);9846 const start = sema.resolveInst(extra.start);
9848 const end: Air.Inst.Ref = if (extra.end == .none) .none else try sema.resolveInst(extra.end);9847 const end: Air.Inst.Ref = if (extra.end == .none) .none else sema.resolveInst(extra.end);
9849 const sentinel = try sema.resolveInst(extra.sentinel);9848 const sentinel = sema.resolveInst(extra.sentinel);
9850 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });9849 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
9851 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });9850 const start_src = block.src(.{ .node_offset_slice_start = inst_data.src_node });
9852 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });9851 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
...@@ -9861,10 +9860,10 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -9861,10 +9860,10 @@ fn zirSliceLength(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
9861 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;9860 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
9862 const src = block.nodeOffset(inst_data.src_node);9861 const src = block.nodeOffset(inst_data.src_node);
9863 const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data;9862 const extra = sema.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data;
9864 const array_ptr = try sema.resolveInst(extra.lhs);9863 const array_ptr = sema.resolveInst(extra.lhs);
9865 const start = try sema.resolveInst(extra.start);9864 const start = sema.resolveInst(extra.start);
9866 const len = try sema.resolveInst(extra.len);9865 const len = sema.resolveInst(extra.len);
9867 const sentinel = if (extra.sentinel == .none) .none else try sema.resolveInst(extra.sentinel);9866 const sentinel = if (extra.sentinel == .none) .none else sema.resolveInst(extra.sentinel);
9868 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });9867 const ptr_src = block.src(.{ .node_offset_slice_ptr = inst_data.src_node });
9869 const start_src = block.src(.{ .node_offset_slice_start = extra.start_src_node_offset });9868 const start_src = block.src(.{ .node_offset_slice_start = extra.start_src_node_offset });
9870 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });9869 const end_src = block.src(.{ .node_offset_slice_end = inst_data.src_node });
...@@ -9892,7 +9891,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -9892,7 +9891,7 @@ fn zirSliceSentinelTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
9892 // This is like the logic in `analyzeSlice`; since we've evaluated the LHS as an lvalue, we will9891 // This is like the logic in `analyzeSlice`; since we've evaluated the LHS as an lvalue, we will
9893 // have a double pointer if it was already a pointer.9892 // have a double pointer if it was already a pointer.
98949893
9895 const lhs_ptr_ty = sema.typeOf(try sema.resolveInst(inst_data.operand));9894 const lhs_ptr_ty = sema.typeOf(sema.resolveInst(inst_data.operand));
9896 const lhs_ty = switch (lhs_ptr_ty.zigTypeTag(zcu)) {9895 const lhs_ty = switch (lhs_ptr_ty.zigTypeTag(zcu)) {
9897 .pointer => lhs_ptr_ty.childType(zcu),9896 .pointer => lhs_ptr_ty.childType(zcu),
9898 else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{lhs_ptr_ty.fmt(pt)}),9897 else => return sema.fail(block, ptr_src, "expected pointer, found '{f}'", .{lhs_ptr_ty.fmt(pt)}),
...@@ -9972,7 +9971,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -9972,7 +9971,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
9972 // Lastly, we analyze the error prong(s) as a regular switch.9971 // Lastly, we analyze the error prong(s) as a regular switch.
99739972
9974 const raw_switch_operand, const non_err_cond, const non_err_hint = non_err: {9973 const raw_switch_operand, const non_err_cond, const non_err_hint = non_err: {
9975 const eu_maybe_ptr = try sema.resolveInst(zir_switch.main_operand);9974 const eu_maybe_ptr = sema.resolveInst(zir_switch.main_operand);
9976 const err_union_ty: Type = err_union_ty: {9975 const err_union_ty: Type = err_union_ty: {
9977 const raw_operand_ty = sema.typeOf(eu_maybe_ptr);9976 const raw_operand_ty = sema.typeOf(eu_maybe_ptr);
9978 if (!non_err_case.operand_is_ref) break :err_union_ty raw_operand_ty;9977 if (!non_err_case.operand_is_ref) break :err_union_ty raw_operand_ty;
...@@ -10106,7 +10105,7 @@ fn zirSwitchBlock(...@@ -10106,7 +10105,7 @@ fn zirSwitchBlock(
10106 defer child_block.instructions.deinit(sema.gpa);10105 defer child_block.instructions.deinit(sema.gpa);
10107 defer merges.deinit(sema.gpa);10106 defer merges.deinit(sema.gpa);
1010810107
10109 const raw_operand = try sema.resolveInst(zir_switch.main_operand);10108 const raw_operand = sema.resolveInst(zir_switch.main_operand);
10110 const validated_switch = try sema.validateSwitchBlock(block, raw_operand, operand_is_ref, inst, &zir_switch);10109 const validated_switch = try sema.validateSwitchBlock(block, raw_operand, operand_is_ref, inst, &zir_switch);
10111 const maybe_ref = try sema.analyzeSwitchBlock(block, &child_block, raw_operand, operand_is_ref, merges, inst, &zir_switch, &validated_switch);10110 const maybe_ref = try sema.analyzeSwitchBlock(block, &child_block, raw_operand, operand_is_ref, merges, inst, &zir_switch, &validated_switch);
10112 return maybe_ref orelse {10111 return maybe_ref orelse {
...@@ -10234,7 +10233,7 @@ fn analyzeSwitchBlock(...@@ -10234,7 +10233,7 @@ fn analyzeSwitchBlock(
10234 if (extra.block_inst != switch_inst) return error.ComptimeBreak;10233 if (extra.block_inst != switch_inst) return error.ComptimeBreak;
10235 // This is a `switch_continue` targeting this block. Change the operand and start over.10234 // This is a `switch_continue` targeting this block. Change the operand and start over.
10236 const new_operand_src = child_block.nodeOffset(extra.operand_src_node.unwrap().?);10235 const new_operand_src = child_block.nodeOffset(extra.operand_src_node.unwrap().?);
10237 const new_operand_uncoerced = try sema.resolveInst(break_inst.data.@"break".operand);10236 const new_operand_uncoerced = sema.resolveInst(break_inst.data.@"break".operand);
10238 const new_operand = try sema.coerce(child_block, raw_operand_ty, new_operand_uncoerced, new_operand_src);10237 const new_operand = try sema.coerce(child_block, raw_operand_ty, new_operand_uncoerced, new_operand_src);
1023910238
10240 try sema.emitBackwardBranch(child_block, src);10239 try sema.emitBackwardBranch(child_block, src);
...@@ -12641,7 +12640,7 @@ fn resolveSwitchItem(...@@ -12641,7 +12640,7 @@ fn resolveSwitchItem(
12641 // We allow prongs with errors which are not part of the error set12640 // We allow prongs with errors which are not part of the error set
12642 // being switched on if their prong body is `=> comptime unreachable,`.12641 // being switched on if their prong body is `=> comptime unreachable,`.
12643 switch (try sema.coerceInMemoryAllowedErrorSets(block, item_ty, uncoerced_ty, item_src, item_src)) {12642 switch (try sema.coerceInMemoryAllowedErrorSets(block, item_ty, uncoerced_ty, item_src, item_src)) {
12644 .ok => if (try sema.resolveValue(uncoerced)) |uncoerced_val| {12643 .ok => if (sema.resolveValue(uncoerced)) |uncoerced_val| {
12645 break :item_ref try sema.coerceInMemory(uncoerced_val, item_ty);12644 break :item_ref try sema.coerceInMemory(uncoerced_val, item_ty);
12646 },12645 },
12647 .missing_error => if (prong_is_comptime_unreach) {12646 .missing_error => if (prong_is_comptime_unreach) {
...@@ -12805,7 +12804,7 @@ fn maybeErrorUnwrap(...@@ -12805,7 +12804,7 @@ fn maybeErrorUnwrap(
12805 },12804 },
12806 .panic => {12805 .panic => {
12807 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;12806 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
12808 const msg_inst = try sema.resolveInst(inst_data.operand);12807 const msg_inst = sema.resolveInst(inst_data.operand);
1280912808
12810 const panic_fn = try getBuiltin(sema, operand_src, .@"panic.call");12809 const panic_fn = try getBuiltin(sema, operand_src, .@"panic.call");
12811 const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value };12810 const args: [2]Air.Inst.Ref = .{ msg_inst, .null_value };
...@@ -12828,7 +12827,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind...@@ -12828,7 +12827,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind
12828 if (sema.code.instructions.items(.tag)[@intFromEnum(index)] != .is_non_err) return;12827 if (sema.code.instructions.items(.tag)[@intFromEnum(index)] != .is_non_err) return;
1282912828
12830 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;12829 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;
12831 const err_operand = try sema.resolveInst(err_inst_data.operand);12830 const err_operand = sema.resolveInst(err_inst_data.operand);
12832 const operand_ty = sema.typeOf(err_operand);12831 const operand_ty = sema.typeOf(err_operand);
12833 if (operand_ty.zigTypeTag(zcu) == .error_set) {12832 if (operand_ty.zigTypeTag(zcu) == .error_set) {
12834 try sema.maybeErrorUnwrapComptime(block, body, err_operand);12833 try sema.maybeErrorUnwrapComptime(block, body, err_operand);
...@@ -12960,7 +12959,7 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -12960,7 +12959,7 @@ fn zirImport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
12960 .zon => {12959 .zon => {
12961 const res_ty: InternPool.Index = b: {12960 const res_ty: InternPool.Index = b: {
12962 if (extra.res_ty == .none) break :b .none;12961 if (extra.res_ty == .none) break :b .none;
12963 const res_ty_inst = try sema.resolveInst(extra.res_ty);12962 const res_ty_inst = sema.resolveInst(extra.res_ty);
12964 const res_ty = try sema.analyzeAsType(block, operand_src, .type, res_ty_inst);12963 const res_ty = try sema.analyzeAsType(block, operand_src, .type, res_ty_inst);
12965 if (res_ty.isGenericPoison()) break :b .none;12964 if (res_ty.isGenericPoison()) break :b .none;
12966 break :b res_ty.toIntern();12965 break :b res_ty.toIntern();
...@@ -13048,8 +13047,8 @@ fn zirShl(...@@ -13048,8 +13047,8 @@ fn zirShl(
13048 const zcu = pt.zcu;13047 const zcu = pt.zcu;
13049 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;13048 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
13050 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;13049 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13051 const lhs = try sema.resolveInst(extra.lhs);13050 const lhs = sema.resolveInst(extra.lhs);
13052 const rhs = try sema.resolveInst(extra.rhs);13051 const rhs = sema.resolveInst(extra.rhs);
13053 const lhs_ty = sema.typeOf(lhs);13052 const lhs_ty = sema.typeOf(lhs);
13054 const rhs_ty = sema.typeOf(rhs);13053 const rhs_ty = sema.typeOf(rhs);
1305513054
...@@ -13075,8 +13074,8 @@ fn zirShl(...@@ -13075,8 +13074,8 @@ fn zirShl(
13075 // we already know `scalar_rhs_ty` is valid for `.shl` -- we only need to validate for `.shl_sat`.13074 // we already know `scalar_rhs_ty` is valid for `.shl` -- we only need to validate for `.shl_sat`.
13076 if (air_tag == .shl_sat) _ = try sema.checkIntType(block, rhs_src, scalar_rhs_ty);13075 if (air_tag == .shl_sat) _ = try sema.checkIntType(block, rhs_src, scalar_rhs_ty);
1307713076
13078 const maybe_lhs_val = try sema.resolveValue(lhs);13077 const maybe_lhs_val = sema.resolveValue(lhs);
13079 const maybe_rhs_val = try sema.resolveValue(rhs);13078 const maybe_rhs_val = sema.resolveValue(rhs);
1308013079
13081 const runtime_src = rs: {13080 const runtime_src = rs: {
13082 if (maybe_rhs_val) |rhs_val| {13081 if (maybe_rhs_val) |rhs_val| {
...@@ -13238,8 +13237,8 @@ fn zirShr(...@@ -13238,8 +13237,8 @@ fn zirShr(
13238 const zcu = pt.zcu;13237 const zcu = pt.zcu;
13239 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;13238 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
13240 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;13239 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13241 const lhs = try sema.resolveInst(extra.lhs);13240 const lhs = sema.resolveInst(extra.lhs);
13242 const rhs = try sema.resolveInst(extra.rhs);13241 const rhs = sema.resolveInst(extra.rhs);
13243 const lhs_ty = sema.typeOf(lhs);13242 const lhs_ty = sema.typeOf(lhs);
13244 const rhs_ty = sema.typeOf(rhs);13243 const rhs_ty = sema.typeOf(rhs);
1324513244
...@@ -13258,8 +13257,8 @@ fn zirShr(...@@ -13258,8 +13257,8 @@ fn zirShr(
13258 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);13257 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
13259 const scalar_ty = lhs_ty.scalarType(zcu);13258 const scalar_ty = lhs_ty.scalarType(zcu);
1326013259
13261 const maybe_lhs_val = try sema.resolveValue(lhs);13260 const maybe_lhs_val = sema.resolveValue(lhs);
13262 const maybe_rhs_val = try sema.resolveValue(rhs);13261 const maybe_rhs_val = sema.resolveValue(rhs);
1326313262
13264 const runtime_src = rs: {13263 const runtime_src = rs: {
13265 if (maybe_rhs_val) |rhs_val| {13264 if (maybe_rhs_val) |rhs_val| {
...@@ -13371,8 +13370,8 @@ fn zirBitwise(...@@ -13371,8 +13370,8 @@ fn zirBitwise(
13371 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });13370 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
13372 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });13371 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
13373 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;13372 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13374 const lhs = try sema.resolveInst(extra.lhs);13373 const lhs = sema.resolveInst(extra.lhs);
13375 const rhs = try sema.resolveInst(extra.rhs);13374 const rhs = sema.resolveInst(extra.rhs);
13376 const lhs_ty = sema.typeOf(lhs);13375 const lhs_ty = sema.typeOf(lhs);
13377 const rhs_ty = sema.typeOf(rhs);13376 const rhs_ty = sema.typeOf(rhs);
13378 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);13377 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
...@@ -13394,8 +13393,8 @@ fn zirBitwise(...@@ -13394,8 +13393,8 @@ fn zirBitwise(
13394 const runtime_src = runtime: {13393 const runtime_src = runtime: {
13395 // TODO: ask the linker what kind of relocations are available, and13394 // TODO: ask the linker what kind of relocations are available, and
13396 // in some cases emit a Value that means "this decl's address AND'd with this operand".13395 // in some cases emit a Value that means "this decl's address AND'd with this operand".
13397 if (try sema.resolveValue(casted_lhs)) |lhs_val| {13396 if (sema.resolveValue(casted_lhs)) |lhs_val| {
13398 if (try sema.resolveValue(casted_rhs)) |rhs_val| {13397 if (sema.resolveValue(casted_rhs)) |rhs_val| {
13399 const result_val = switch (air_tag) {13398 const result_val = switch (air_tag) {
13400 // zig fmt: off13399 // zig fmt: off
13401 .bit_and => try arith.bitwiseBin(sema, resolved_type, lhs_val, rhs_val, .@"and"),13400 .bit_and => try arith.bitwiseBin(sema, resolved_type, lhs_val, rhs_val, .@"and"),
...@@ -13423,7 +13422,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -13423,7 +13422,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
13423 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;13422 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
13424 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });13423 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
13425 const src = block.nodeOffset(inst_data.src_node);13424 const src = block.nodeOffset(inst_data.src_node);
13426 const operand = try sema.resolveInst(inst_data.operand);13425 const operand = sema.resolveInst(inst_data.operand);
13427 const operand_ty = sema.typeOf(operand);13426 const operand_ty = sema.typeOf(operand);
13428 const scalar_ty = operand_ty.scalarType(zcu);13427 const scalar_ty = operand_ty.scalarType(zcu);
13429 const scalar_tag = scalar_ty.zigTypeTag(zcu);13428 const scalar_tag = scalar_ty.zigTypeTag(zcu);
...@@ -13441,7 +13440,7 @@ fn analyzeBitNot(...@@ -13441,7 +13440,7 @@ fn analyzeBitNot(
13441 src: LazySrcLoc,13440 src: LazySrcLoc,
13442) CompileError!Air.Inst.Ref {13441) CompileError!Air.Inst.Ref {
13443 const operand_ty = sema.typeOf(operand);13442 const operand_ty = sema.typeOf(operand);
13444 if (try sema.resolveValue(operand)) |operand_val| {13443 if (sema.resolveValue(operand)) |operand_val| {
13445 const result_val = try arith.bitwiseNot(sema, operand_ty, operand_val);13444 const result_val = try arith.bitwiseNot(sema, operand_ty, operand_val);
13446 return Air.internedToRef(result_val.toIntern());13445 return Air.internedToRef(result_val.toIntern());
13447 }13446 }
...@@ -13551,8 +13550,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -13551,8 +13550,8 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
13551 const zcu = pt.zcu;13550 const zcu = pt.zcu;
13552 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;13551 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
13553 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;13552 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
13554 const lhs = try sema.resolveInst(extra.lhs);13553 const lhs = sema.resolveInst(extra.lhs);
13555 const rhs = try sema.resolveInst(extra.rhs);13554 const rhs = sema.resolveInst(extra.rhs);
13556 const lhs_ty = sema.typeOf(lhs);13555 const lhs_ty = sema.typeOf(lhs);
13557 const rhs_ty = sema.typeOf(rhs);13556 const rhs_ty = sema.typeOf(rhs);
13558 const src = block.nodeOffset(inst_data.src_node);13557 const src = block.nodeOffset(inst_data.src_node);
...@@ -13646,12 +13645,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -13646,12 +13645,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
13646 };13645 };
1364713646
13648 const runtime_src = if (switch (lhs_ty.zigTypeTag(zcu)) {13647 const runtime_src = if (switch (lhs_ty.zigTypeTag(zcu)) {
13649 .array, .@"struct" => try sema.resolveValue(lhs),13648 .array, .@"struct" => sema.resolveValue(lhs),
13650 .pointer => try sema.resolveDefinedValue(block, lhs_src, lhs),13649 .pointer => try sema.resolveDefinedValue(block, lhs_src, lhs),
13651 else => unreachable,13650 else => unreachable,
13652 }) |lhs_val| rs: {13651 }) |lhs_val| rs: {
13653 if (switch (rhs_ty.zigTypeTag(zcu)) {13652 if (switch (rhs_ty.zigTypeTag(zcu)) {
13654 .array, .@"struct" => try sema.resolveValue(rhs),13653 .array, .@"struct" => sema.resolveValue(rhs),
13655 .pointer => try sema.resolveDefinedValue(block, rhs_src, rhs),13654 .pointer => try sema.resolveDefinedValue(block, rhs_src, rhs),
13656 else => unreachable,13655 else => unreachable,
13657 }) |rhs_val| {13656 }) |rhs_val| {
...@@ -13989,7 +13988,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -13989,7 +13988,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
13989 const zcu = pt.zcu;13988 const zcu = pt.zcu;
13990 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;13989 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
13991 const extra = sema.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data;13990 const extra = sema.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data;
13992 const uncoerced_lhs = try sema.resolveInst(extra.lhs);13991 const uncoerced_lhs = sema.resolveInst(extra.lhs);
13993 const uncoerced_lhs_ty = sema.typeOf(uncoerced_lhs);13992 const uncoerced_lhs_ty = sema.typeOf(uncoerced_lhs);
13994 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);13993 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
13995 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });13994 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
...@@ -14068,7 +14067,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14068,7 +14067,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14068 const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .pointer) lhs_ty.ptrAddressSpace(zcu) else null;14067 const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .pointer) lhs_ty.ptrAddressSpace(zcu) else null;
14069 const lhs_len = try sema.usizeCast(block, lhs_src, lhs_info.len);14068 const lhs_len = try sema.usizeCast(block, lhs_src, lhs_info.len);
1407014069
14071 if (try sema.resolveValue(lhs)) |lhs_val| ct: {14070 if (sema.resolveValue(lhs)) |lhs_val| ct: {
14072 const lhs_sub_val = if (lhs_ty.isSinglePointer(zcu))14071 const lhs_sub_val = if (lhs_ty.isSinglePointer(zcu))
14073 try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty) orelse break :ct14072 try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty) orelse break :ct
14074 else if (lhs_ty.isSlice(zcu))14073 else if (lhs_ty.isSlice(zcu))
...@@ -14157,7 +14156,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14157,7 +14156,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
14157 const lhs_src = src;14156 const lhs_src = src;
14158 const rhs_src = block.src(.{ .node_offset_un_op = inst_data.src_node });14157 const rhs_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
1415914158
14160 const rhs = try sema.resolveInst(inst_data.operand);14159 const rhs = sema.resolveInst(inst_data.operand);
14161 const rhs_ty = sema.typeOf(rhs);14160 const rhs_ty = sema.typeOf(rhs);
14162 const rhs_scalar_ty = rhs_ty.scalarType(zcu);14161 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
1416314162
...@@ -14170,7 +14169,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14170,7 +14169,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1417014169
14171 if (rhs_scalar_ty.isAnyFloat()) {14170 if (rhs_scalar_ty.isAnyFloat()) {
14172 // We handle float negation here to ensure negative zero is represented in the bits.14171 // We handle float negation here to ensure negative zero is represented in the bits.
14173 if (try sema.resolveValue(rhs)) |rhs_val| {14172 if (sema.resolveValue(rhs)) |rhs_val| {
14174 const result = try arith.negateFloat(sema, rhs_ty, rhs_val);14173 const result = try arith.negateFloat(sema, rhs_ty, rhs_val);
14175 return Air.internedToRef(result.toIntern());14174 return Air.internedToRef(result.toIntern());
14176 }14175 }
...@@ -14190,7 +14189,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -14190,7 +14189,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
14190 const lhs_src = src;14189 const lhs_src = src;
14191 const rhs_src = block.src(.{ .node_offset_un_op = inst_data.src_node });14190 const rhs_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
1419214191
14193 const rhs = try sema.resolveInst(inst_data.operand);14192 const rhs = sema.resolveInst(inst_data.operand);
14194 const rhs_ty = sema.typeOf(rhs);14193 const rhs_ty = sema.typeOf(rhs);
14195 const rhs_scalar_ty = rhs_ty.scalarType(zcu);14194 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
1419614195
...@@ -14218,8 +14217,8 @@ fn zirArithmetic(...@@ -14218,8 +14217,8 @@ fn zirArithmetic(
14218 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });14217 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
14219 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });14218 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
14220 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14219 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14221 const lhs = try sema.resolveInst(extra.lhs);14220 const lhs = sema.resolveInst(extra.lhs);
14222 const rhs = try sema.resolveInst(extra.rhs);14221 const rhs = sema.resolveInst(extra.rhs);
1422314222
14224 return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, src, lhs_src, rhs_src, safety);14223 return sema.analyzeArithmetic(block, zir_tag, lhs, rhs, src, lhs_src, rhs_src, safety);
14225}14224}
...@@ -14232,8 +14231,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -14232,8 +14231,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
14232 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });14231 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
14233 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });14232 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
14234 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14233 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14235 const lhs = try sema.resolveInst(extra.lhs);14234 const lhs = sema.resolveInst(extra.lhs);
14236 const rhs = try sema.resolveInst(extra.rhs);14235 const rhs = sema.resolveInst(extra.rhs);
14237 const lhs_ty = sema.typeOf(lhs);14236 const lhs_ty = sema.typeOf(lhs);
14238 const rhs_ty = sema.typeOf(rhs);14237 const rhs_ty = sema.typeOf(rhs);
14239 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14238 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14255,8 +14254,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -14255,8 +14254,8 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1425514254
14256 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div);14255 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div);
1425714256
14258 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14257 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14259 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14258 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1426014259
14261 if ((lhs_ty.zigTypeTag(zcu) == .comptime_float and rhs_ty.zigTypeTag(zcu) == .comptime_int) or14260 if ((lhs_ty.zigTypeTag(zcu) == .comptime_float and rhs_ty.zigTypeTag(zcu) == .comptime_int) or
14262 (lhs_ty.zigTypeTag(zcu) == .comptime_int and rhs_ty.zigTypeTag(zcu) == .comptime_float))14261 (lhs_ty.zigTypeTag(zcu) == .comptime_int and rhs_ty.zigTypeTag(zcu) == .comptime_float))
...@@ -14341,8 +14340,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14341,8 +14340,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14341 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);14340 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
14342 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);14341 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
14343 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14342 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14344 const lhs = try sema.resolveInst(extra.lhs);14343 const lhs = sema.resolveInst(extra.lhs);
14345 const rhs = try sema.resolveInst(extra.rhs);14344 const rhs = sema.resolveInst(extra.rhs);
14346 const lhs_ty = sema.typeOf(lhs);14345 const lhs_ty = sema.typeOf(lhs);
14347 const rhs_ty = sema.typeOf(rhs);14346 const rhs_ty = sema.typeOf(rhs);
14348 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14347 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14364,8 +14363,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14364,8 +14363,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1436414363
14365 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact);14364 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact);
1436614365
14367 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14366 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14368 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14367 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1436914368
14370 // Because `@divExact` can trigger Illegal Behavior, undefined operands trigger Illegal Behavior.14369 // Because `@divExact` can trigger Illegal Behavior, undefined operands trigger Illegal Behavior.
1437114370
...@@ -14437,8 +14436,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14437,8 +14436,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14437 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);14436 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
14438 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);14437 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
14439 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14438 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14440 const lhs = try sema.resolveInst(extra.lhs);14439 const lhs = sema.resolveInst(extra.lhs);
14441 const rhs = try sema.resolveInst(extra.rhs);14440 const rhs = sema.resolveInst(extra.rhs);
14442 const lhs_ty = sema.typeOf(lhs);14441 const lhs_ty = sema.typeOf(lhs);
14443 const rhs_ty = sema.typeOf(rhs);14442 const rhs_ty = sema.typeOf(rhs);
14444 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14443 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14460,8 +14459,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14460,8 +14459,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1446014459
14461 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor);14460 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor);
1446214461
14463 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14462 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14464 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14463 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1446514464
14466 const allow_div_zero = !is_int and14465 const allow_div_zero = !is_int and
14467 resolved_type.toIntern() != .comptime_float_type and14466 resolved_type.toIntern() != .comptime_float_type and
...@@ -14502,8 +14501,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14502,8 +14501,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14502 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);14501 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
14503 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);14502 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
14504 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14503 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14505 const lhs = try sema.resolveInst(extra.lhs);14504 const lhs = sema.resolveInst(extra.lhs);
14506 const rhs = try sema.resolveInst(extra.rhs);14505 const rhs = sema.resolveInst(extra.rhs);
14507 const lhs_ty = sema.typeOf(lhs);14506 const lhs_ty = sema.typeOf(lhs);
14508 const rhs_ty = sema.typeOf(rhs);14507 const rhs_ty = sema.typeOf(rhs);
14509 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14508 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14525,8 +14524,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14525,8 +14524,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1452514524
14526 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc);14525 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc);
1452714526
14528 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14527 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14529 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14528 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1453014529
14531 const allow_div_zero = !is_int and14530 const allow_div_zero = !is_int and
14532 resolved_type.toIntern() != .comptime_float_type and14531 resolved_type.toIntern() != .comptime_float_type and
...@@ -14713,8 +14712,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14713,8 +14712,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
14713 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });14712 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
14714 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });14713 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
14715 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14714 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14716 const lhs = try sema.resolveInst(extra.lhs);14715 const lhs = sema.resolveInst(extra.lhs);
14717 const rhs = try sema.resolveInst(extra.rhs);14716 const rhs = sema.resolveInst(extra.rhs);
14718 const lhs_ty = sema.typeOf(lhs);14717 const lhs_ty = sema.typeOf(lhs);
14719 const rhs_ty = sema.typeOf(rhs);14718 const rhs_ty = sema.typeOf(rhs);
14720 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14719 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14737,8 +14736,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14737,8 +14736,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
1473714736
14738 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem);14737 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem);
1473914738
14740 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14739 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14741 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14740 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1474214741
14743 const lhs_maybe_negative = a: {14742 const lhs_maybe_negative = a: {
14744 if (lhs_scalar_ty.isUnsignedInt(zcu)) break :a false;14743 if (lhs_scalar_ty.isUnsignedInt(zcu)) break :a false;
...@@ -14814,8 +14813,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -14814,8 +14813,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
14814 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);14813 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
14815 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);14814 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
14816 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14815 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14817 const lhs = try sema.resolveInst(extra.lhs);14816 const lhs = sema.resolveInst(extra.lhs);
14818 const rhs = try sema.resolveInst(extra.rhs);14817 const rhs = sema.resolveInst(extra.rhs);
14819 const lhs_ty = sema.typeOf(lhs);14818 const lhs_ty = sema.typeOf(lhs);
14820 const rhs_ty = sema.typeOf(rhs);14819 const rhs_ty = sema.typeOf(rhs);
14821 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14820 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14836,8 +14835,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -14836,8 +14835,8 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1483614835
14837 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod);14836 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod);
1483814837
14839 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14838 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14840 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14839 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1484114840
14842 const allow_div_zero = !is_int and14841 const allow_div_zero = !is_int and
14843 resolved_type.toIntern() != .comptime_float_type and14842 resolved_type.toIntern() != .comptime_float_type and
...@@ -14878,8 +14877,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -14878,8 +14877,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
14878 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);14877 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
14879 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);14878 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
14880 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;14879 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
14881 const lhs = try sema.resolveInst(extra.lhs);14880 const lhs = sema.resolveInst(extra.lhs);
14882 const rhs = try sema.resolveInst(extra.rhs);14881 const rhs = sema.resolveInst(extra.rhs);
14883 const lhs_ty = sema.typeOf(lhs);14882 const lhs_ty = sema.typeOf(lhs);
14884 const rhs_ty = sema.typeOf(rhs);14883 const rhs_ty = sema.typeOf(rhs);
14885 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);14884 const lhs_zig_ty_tag = lhs_ty.zigTypeTag(zcu);
...@@ -14900,8 +14899,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -14900,8 +14899,8 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1490014899
14901 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem);14900 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem);
1490214901
14903 const maybe_lhs_val = try sema.resolveValue(casted_lhs);14902 const maybe_lhs_val = sema.resolveValue(casted_lhs);
14904 const maybe_rhs_val = try sema.resolveValue(casted_rhs);14903 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1490514904
14906 const allow_div_zero = !is_int and14905 const allow_div_zero = !is_int and
14907 resolved_type.toIntern() != .comptime_float_type and14906 resolved_type.toIntern() != .comptime_float_type and
...@@ -14949,8 +14948,8 @@ fn zirOverflowArithmetic(...@@ -14949,8 +14948,8 @@ fn zirOverflowArithmetic(
14949 const lhs_src = block.builtinCallArgSrc(extra.node, 0);14948 const lhs_src = block.builtinCallArgSrc(extra.node, 0);
14950 const rhs_src = block.builtinCallArgSrc(extra.node, 1);14949 const rhs_src = block.builtinCallArgSrc(extra.node, 1);
1495114950
14952 const uncasted_lhs = try sema.resolveInst(extra.lhs);14951 const uncasted_lhs = sema.resolveInst(extra.lhs);
14953 const uncasted_rhs = try sema.resolveInst(extra.rhs);14952 const uncasted_rhs = sema.resolveInst(extra.rhs);
1495414953
14955 const lhs_ty = sema.typeOf(uncasted_lhs);14954 const lhs_ty = sema.typeOf(uncasted_lhs);
14956 const rhs_ty = sema.typeOf(uncasted_rhs);14955 const rhs_ty = sema.typeOf(uncasted_rhs);
...@@ -14980,8 +14979,8 @@ fn zirOverflowArithmetic(...@@ -14980,8 +14979,8 @@ fn zirOverflowArithmetic(
14980 return sema.fail(block, src, "expected vector of integers or integer tag type, found '{f}'", .{dest_ty.fmt(pt)});14979 return sema.fail(block, src, "expected vector of integers or integer tag type, found '{f}'", .{dest_ty.fmt(pt)});
14981 }14980 }
1498214981
14983 const maybe_lhs_val = try sema.resolveValue(lhs);14982 const maybe_lhs_val = sema.resolveValue(lhs);
14984 const maybe_rhs_val = try sema.resolveValue(rhs);14983 const maybe_rhs_val = sema.resolveValue(rhs);
1498514984
14986 const tuple_ty = try pt.overflowArithmeticTupleType(dest_ty);14985 const tuple_ty = try pt.overflowArithmeticTupleType(dest_ty);
14987 const overflow_ty: Type = .fromInterned(ip.indexToKey(tuple_ty.toIntern()).tuple_type.types.get(ip)[1]);14986 const overflow_ty: Type = .fromInterned(ip.indexToKey(tuple_ty.toIntern()).tuple_type.types.get(ip)[1]);
...@@ -15163,7 +15162,7 @@ fn zirOverflowArithmetic(...@@ -15163,7 +15162,7 @@ fn zirOverflowArithmetic(
15163 };15162 };
1516415163
15165 if (result.inst != .none) {15164 if (result.inst != .none) {
15166 if (try sema.resolveValue(result.inst)) |some| {15165 if (sema.resolveValue(result.inst)) |some| {
15167 result.wrapped = some;15166 result.wrapped = some;
15168 result.inst = .none;15167 result.inst = .none;
15169 }15168 }
...@@ -15227,8 +15226,8 @@ fn analyzeArithmetic(...@@ -15227,8 +15226,8 @@ fn analyzeArithmetic(
15227 }15226 }
1522815227
15229 const runtime_src = runtime_src: {15228 const runtime_src = runtime_src: {
15230 if (try sema.resolveValue(lhs)) |lhs_value| {15229 if (sema.resolveValue(lhs)) |lhs_value| {
15231 if (try sema.resolveValue(rhs)) |rhs_value| {15230 if (sema.resolveValue(rhs)) |rhs_value| {
15232 const lhs_ptr = switch (zcu.intern_pool.indexToKey(lhs_value.toIntern())) {15231 const lhs_ptr = switch (zcu.intern_pool.indexToKey(lhs_value.toIntern())) {
15233 .undef => return sema.failWithUseOfUndef(block, lhs_src, null),15232 .undef => return sema.failWithUseOfUndef(block, lhs_src, null),
15234 .ptr => |ptr| ptr,15233 .ptr => |ptr| ptr,
...@@ -15307,8 +15306,8 @@ fn analyzeArithmetic(...@@ -15307,8 +15306,8 @@ fn analyzeArithmetic(
15307 else => unreachable,15306 else => unreachable,
15308 };15307 };
1530915308
15310 const maybe_lhs_val = try sema.resolveValue(casted_lhs);15309 const maybe_lhs_val = sema.resolveValue(casted_lhs);
15311 const maybe_rhs_val = try sema.resolveValue(casted_rhs);15310 const maybe_rhs_val = sema.resolveValue(casted_rhs);
1531215311
15313 if (maybe_lhs_val) |lhs_val| {15312 if (maybe_lhs_val) |lhs_val| {
15314 if (maybe_rhs_val) |rhs_val| {15313 if (maybe_rhs_val) |rhs_val| {
...@@ -15380,7 +15379,7 @@ fn analyzePtrArithmetic(...@@ -15380,7 +15379,7 @@ fn analyzePtrArithmetic(
15380 const offset = try sema.coerce(block, .usize, uncasted_offset, offset_src);15379 const offset = try sema.coerce(block, .usize, uncasted_offset, offset_src);
15381 const pt = sema.pt;15380 const pt = sema.pt;
15382 const zcu = pt.zcu;15381 const zcu = pt.zcu;
15383 const opt_ptr_val = try sema.resolveValue(ptr);15382 const opt_ptr_val = sema.resolveValue(ptr);
15384 const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);15383 const opt_off_val = try sema.resolveDefinedValue(block, offset_src, offset);
15385 const ptr_ty = sema.typeOf(ptr);15384 const ptr_ty = sema.typeOf(ptr);
15386 const ptr_info = ptr_ty.ptrInfo(zcu);15385 const ptr_info = ptr_ty.ptrInfo(zcu);
...@@ -15473,7 +15472,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In...@@ -15473,7 +15472,7 @@ fn zirLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.In
15473 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;15472 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
15474 const src = block.nodeOffset(inst_data.src_node);15473 const src = block.nodeOffset(inst_data.src_node);
15475 const ptr_src = src; // TODO better source location15474 const ptr_src = src; // TODO better source location
15476 const ptr = try sema.resolveInst(inst_data.operand);15475 const ptr = sema.resolveInst(inst_data.operand);
15477 return sema.analyzeLoad(block, src, ptr, ptr_src);15476 return sema.analyzeLoad(block, src, ptr, ptr_src);
15478}15477}
1547915478
...@@ -15547,7 +15546,7 @@ fn zirAsm(...@@ -15547,7 +15546,7 @@ fn zirAsm(
15547 const out_ty = try sema.resolveType(block, ret_ty_src, output.data.operand);15546 const out_ty = try sema.resolveType(block, ret_ty_src, output.data.operand);
15548 expr_ty = Air.internedToRef(out_ty.toIntern());15547 expr_ty = Air.internedToRef(out_ty.toIntern());
15549 } else {15548 } else {
15550 const inst = try sema.resolveInst(output.data.operand);15549 const inst = sema.resolveInst(output.data.operand);
15551 if (!sema.checkRuntimeValue(inst)) {15550 if (!sema.checkRuntimeValue(inst)) {
15552 const output_name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);15551 const output_name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);
15553 return sema.failWithContainsReferenceToComptimeVar(block, output_src, output_name, "assembly output", .fromInterned(inst.toInterned().?));15552 return sema.failWithContainsReferenceToComptimeVar(block, output_src, output_name, "assembly output", .fromInterned(inst.toInterned().?));
...@@ -15577,7 +15576,7 @@ fn zirAsm(...@@ -15577,7 +15576,7 @@ fn zirAsm(
15577 } });15576 } });
15578 extra_i = input.end;15577 extra_i = input.end;
1557915578
15580 const uncasted_arg = try sema.resolveInst(input.data.operand);15579 const uncasted_arg = sema.resolveInst(input.data.operand);
15581 const name = sema.code.nullTerminatedString(input.data.name);15580 const name = sema.code.nullTerminatedString(input.data.name);
15582 if (!sema.checkRuntimeValue(uncasted_arg)) {15581 if (!sema.checkRuntimeValue(uncasted_arg)) {
15583 const input_name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);15582 const input_name = try ip.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);
...@@ -15600,7 +15599,7 @@ fn zirAsm(...@@ -15600,7 +15599,7 @@ fn zirAsm(
15600 const clobbers = if (extra.data.clobbers == .none) empty: {15599 const clobbers = if (extra.data.clobbers == .none) empty: {
15601 const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers");15600 const clobbers_ty = try sema.getBuiltinType(src, .@"assembly.Clobbers");
15602 break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);15601 break :empty try sema.structInitEmpty(block, clobbers_ty, src, src);
15603 } else try sema.resolveInst(extra.data.clobbers); // Already coerced by AstGen.15602 } else sema.resolveInst(extra.data.clobbers); // Already coerced by AstGen.
15604 const clobbers_val = try sema.resolveConstDefinedValue(block, src, clobbers, .{ .simple = .clobber });15603 const clobbers_val = try sema.resolveConstDefinedValue(block, src, clobbers, .{ .simple = .clobber });
15605 needed_capacity += asm_source.len / 4 + 1;15604 needed_capacity += asm_source.len / 4 + 1;
1560615605
...@@ -15666,8 +15665,8 @@ fn zirCmpEq(...@@ -15666,8 +15665,8 @@ fn zirCmpEq(
15666 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);15665 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
15667 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });15666 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
15668 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });15667 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
15669 const lhs = try sema.resolveInst(extra.lhs);15668 const lhs = sema.resolveInst(extra.lhs);
15670 const rhs = try sema.resolveInst(extra.rhs);15669 const rhs = sema.resolveInst(extra.rhs);
1567115670
15672 const lhs_ty = sema.typeOf(lhs);15671 const lhs_ty = sema.typeOf(lhs);
15673 const rhs_ty = sema.typeOf(rhs);15672 const rhs_ty = sema.typeOf(rhs);
...@@ -15700,8 +15699,8 @@ fn zirCmpEq(...@@ -15700,8 +15699,8 @@ fn zirCmpEq(
1570015699
15701 if (lhs_ty_tag == .error_set and rhs_ty_tag == .error_set) {15700 if (lhs_ty_tag == .error_set and rhs_ty_tag == .error_set) {
15702 const runtime_src: LazySrcLoc = src: {15701 const runtime_src: LazySrcLoc = src: {
15703 if (try sema.resolveValue(lhs)) |lval| {15702 if (sema.resolveValue(lhs)) |lval| {
15704 if (try sema.resolveValue(rhs)) |rval| {15703 if (sema.resolveValue(rhs)) |rval| {
15705 if (lval.isUndef(zcu) or rval.isUndef(zcu)) return .undef_bool;15704 if (lval.isUndef(zcu) or rval.isUndef(zcu)) return .undef_bool;
15706 const lkey = zcu.intern_pool.indexToKey(lval.toIntern());15705 const lkey = zcu.intern_pool.indexToKey(lval.toIntern());
15707 const rkey = zcu.intern_pool.indexToKey(rval.toIntern());15706 const rkey = zcu.intern_pool.indexToKey(rval.toIntern());
...@@ -15754,7 +15753,7 @@ fn analyzeCmpUnionTag(...@@ -15754,7 +15753,7 @@ fn analyzeCmpUnionTag(
15754 const coerced_tag = try sema.coerce(block, union_tag_ty, tag, tag_src);15753 const coerced_tag = try sema.coerce(block, union_tag_ty, tag, tag_src);
15755 const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src);15754 const coerced_union = try sema.coerce(block, union_tag_ty, un, un_src);
1575615755
15757 if (try sema.resolveValue(coerced_tag)) |enum_val| {15756 if (sema.resolveValue(coerced_tag)) |enum_val| {
15758 if (enum_val.isUndef(zcu)) return .undef_bool;15757 if (enum_val.isUndef(zcu)) return .undef_bool;
15759 const field_ty = union_ty.unionFieldType(enum_val, zcu).?;15758 const field_ty = union_ty.unionFieldType(enum_val, zcu).?;
15760 if (field_ty.zigTypeTag(zcu) == .noreturn) {15759 if (field_ty.zigTypeTag(zcu) == .noreturn) {
...@@ -15780,8 +15779,8 @@ fn zirCmp(...@@ -15780,8 +15779,8 @@ fn zirCmp(
15780 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);15779 const src: LazySrcLoc = block.nodeOffset(inst_data.src_node);
15781 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });15780 const lhs_src = block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
15782 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });15781 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
15783 const lhs = try sema.resolveInst(extra.lhs);15782 const lhs = sema.resolveInst(extra.lhs);
15784 const rhs = try sema.resolveInst(extra.rhs);15783 const rhs = sema.resolveInst(extra.rhs);
15785 return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false);15784 return sema.analyzeCmp(block, src, lhs, rhs, op, lhs_src, rhs_src, false);
15786}15785}
1578715786
...@@ -15864,8 +15863,8 @@ fn cmpSelf(...@@ -15864,8 +15863,8 @@ fn cmpSelf(
15864 const zcu = pt.zcu;15863 const zcu = pt.zcu;
15865 const resolved_type = sema.typeOf(casted_lhs);15864 const resolved_type = sema.typeOf(casted_lhs);
1586615865
15867 const maybe_lhs_val = try sema.resolveValue(casted_lhs);15866 const maybe_lhs_val = sema.resolveValue(casted_lhs);
15868 const maybe_rhs_val = try sema.resolveValue(casted_rhs);15867 const maybe_rhs_val = sema.resolveValue(casted_rhs);
15869 if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return .undef_bool;15868 if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return .undef_bool;
15870 if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return .undef_bool;15869 if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return .undef_bool;
1587115870
...@@ -17118,7 +17117,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -17118,7 +17117,7 @@ fn zirTypeof(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
17118 _ = block;17117 _ = block;
17119 const zir_datas = sema.code.instructions.items(.data);17118 const zir_datas = sema.code.instructions.items(.data);
17120 const inst_data = zir_datas[@intFromEnum(inst)].un_node;17119 const inst_data = zir_datas[@intFromEnum(inst)].un_node;
17121 const operand = try sema.resolveInst(inst_data.operand);17120 const operand = sema.resolveInst(inst_data.operand);
17122 const operand_ty = sema.typeOf(operand);17121 const operand_ty = sema.typeOf(operand);
17123 return Air.internedToRef(operand_ty.toIntern());17122 return Air.internedToRef(operand_ty.toIntern());
17124}17123}
...@@ -17150,7 +17149,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -17150,7 +17149,7 @@ fn zirTypeofBuiltin(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
17150fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {17149fn zirTypeofLog2IntType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
17151 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17150 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17152 const src = block.nodeOffset(inst_data.src_node);17151 const src = block.nodeOffset(inst_data.src_node);
17153 const operand = try sema.resolveInst(inst_data.operand);17152 const operand = sema.resolveInst(inst_data.operand);
17154 const operand_ty = sema.typeOf(operand);17153 const operand_ty = sema.typeOf(operand);
17155 const res_ty = try sema.log2IntType(block, operand_ty, src);17154 const res_ty = try sema.log2IntType(block, operand_ty, src);
17156 return Air.internedToRef(res_ty.toIntern());17155 return Air.internedToRef(res_ty.toIntern());
...@@ -17220,7 +17219,7 @@ fn zirTypeofPeer(...@@ -17220,7 +17219,7 @@ fn zirTypeofPeer(
17220 defer sema.gpa.free(inst_list);17219 defer sema.gpa.free(inst_list);
1722117220
17222 for (args, 0..) |arg_ref, i| {17221 for (args, 0..) |arg_ref, i| {
17223 inst_list[i] = try sema.resolveInst(arg_ref);17222 inst_list[i] = sema.resolveInst(arg_ref);
17224 }17223 }
1722517224
17226 const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node });17225 const result_type = try sema.resolvePeerTypes(block, src, inst_list, .{ .typeof_builtin_call_node_offset = extra.data.src_node });
...@@ -17233,7 +17232,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -17233,7 +17232,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
17233 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17232 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17234 const src = block.nodeOffset(inst_data.src_node);17233 const src = block.nodeOffset(inst_data.src_node);
17235 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });17234 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
17236 const uncasted_operand = try sema.resolveInst(inst_data.operand);17235 const uncasted_operand = sema.resolveInst(inst_data.operand);
17237 const uncasted_ty = sema.typeOf(uncasted_operand);17236 const uncasted_ty = sema.typeOf(uncasted_operand);
17238 if (uncasted_ty.isVector(zcu)) {17237 if (uncasted_ty.isVector(zcu)) {
17239 if (uncasted_ty.scalarType(zcu).zigTypeTag(zcu) != .bool) {17238 if (uncasted_ty.scalarType(zcu).zigTypeTag(zcu) != .bool) {
...@@ -17244,7 +17243,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -17244,7 +17243,7 @@ fn zirBoolNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
17244 return analyzeBitNot(sema, block, uncasted_operand, src);17243 return analyzeBitNot(sema, block, uncasted_operand, src);
17245 }17244 }
17246 const operand = try sema.coerce(block, .bool, uncasted_operand, operand_src);17245 const operand = try sema.coerce(block, .bool, uncasted_operand, operand_src);
17247 if (try sema.resolveValue(operand)) |val| {17246 if (sema.resolveValue(operand)) |val| {
17248 return if (val.isUndef(zcu)) .undef_bool else if (val.toBool()) .bool_false else .bool_true;17247 return if (val.isUndef(zcu)) .undef_bool else if (val.toBool()) .bool_false else .bool_true;
17249 }17248 }
17250 try sema.requireRuntimeBlock(block, src, null);17249 try sema.requireRuntimeBlock(block, src, null);
...@@ -17268,7 +17267,7 @@ fn zirBoolBr(...@@ -17268,7 +17267,7 @@ fn zirBoolBr(
17268 const inst_data = datas[@intFromEnum(inst)].pl_node;17267 const inst_data = datas[@intFromEnum(inst)].pl_node;
17269 const extra = sema.code.extraData(Zir.Inst.BoolBr, inst_data.payload_index);17268 const extra = sema.code.extraData(Zir.Inst.BoolBr, inst_data.payload_index);
1727017269
17271 const uncoerced_lhs = try sema.resolveInst(extra.data.lhs);17270 const uncoerced_lhs = sema.resolveInst(extra.data.lhs);
17272 const body = sema.code.bodySlice(extra.end, extra.data.body_len);17271 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
17273 const lhs_src = parent_block.src(.{ .node_offset_bin_lhs = inst_data.src_node });17272 const lhs_src = parent_block.src(.{ .node_offset_bin_lhs = inst_data.src_node });
17274 const rhs_src = parent_block.src(.{ .node_offset_bin_rhs = inst_data.src_node });17273 const rhs_src = parent_block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
...@@ -17431,7 +17430,7 @@ fn zirIsNonNull(...@@ -17431,7 +17430,7 @@ fn zirIsNonNull(
1743117430
17432 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17431 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17433 const src = block.nodeOffset(inst_data.src_node);17432 const src = block.nodeOffset(inst_data.src_node);
17434 const operand = try sema.resolveInst(inst_data.operand);17433 const operand = sema.resolveInst(inst_data.operand);
17435 try sema.checkNullableType(block, src, sema.typeOf(operand));17434 try sema.checkNullableType(block, src, sema.typeOf(operand));
17436 return sema.analyzeIsNull(block, operand, true);17435 return sema.analyzeIsNull(block, operand, true);
17437}17436}
...@@ -17448,12 +17447,12 @@ fn zirIsNonNullPtr(...@@ -17448,12 +17447,12 @@ fn zirIsNonNullPtr(
17448 const zcu = pt.zcu;17447 const zcu = pt.zcu;
17449 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17448 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17450 const src = block.nodeOffset(inst_data.src_node);17449 const src = block.nodeOffset(inst_data.src_node);
17451 const ptr = try sema.resolveInst(inst_data.operand);17450 const ptr = sema.resolveInst(inst_data.operand);
17452 const ptr_ty = sema.typeOf(ptr);17451 const ptr_ty = sema.typeOf(ptr);
17453 assert(ptr_ty.zigTypeTag(zcu) == .pointer);17452 assert(ptr_ty.zigTypeTag(zcu) == .pointer);
17454 const nullable_ty = ptr_ty.childType(zcu);17453 const nullable_ty = ptr_ty.childType(zcu);
17455 try sema.checkNullableType(block, src, nullable_ty);17454 try sema.checkNullableType(block, src, nullable_ty);
17456 if (try sema.resolveValue(ptr)) |ptr_val| {17455 if (sema.resolveValue(ptr)) |ptr_val| {
17457 if (try sema.pointerDeref(block, src, ptr_val, ptr_ty)) |nullable_val| {17456 if (try sema.pointerDeref(block, src, ptr_val, ptr_ty)) |nullable_val| {
17458 return sema.analyzeIsNull(block, .fromValue(nullable_val), true);17457 return sema.analyzeIsNull(block, .fromValue(nullable_val), true);
17459 }17458 }
...@@ -17481,7 +17480,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17481,7 +17480,7 @@ fn zirIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1748117480
17482 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17481 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17483 const src = block.nodeOffset(inst_data.src_node);17482 const src = block.nodeOffset(inst_data.src_node);
17484 const operand = try sema.resolveInst(inst_data.operand);17483 const operand = sema.resolveInst(inst_data.operand);
17485 try sema.checkErrorType(block, src, sema.typeOf(operand));17484 try sema.checkErrorType(block, src, sema.typeOf(operand));
17486 return sema.analyzeIsNonErr(block, src, operand);17485 return sema.analyzeIsNonErr(block, src, operand);
17487}17486}
...@@ -17494,7 +17493,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -17494,7 +17493,7 @@ fn zirIsNonErrPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
17494 const zcu = pt.zcu;17493 const zcu = pt.zcu;
17495 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17494 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17496 const src = block.nodeOffset(inst_data.src_node);17495 const src = block.nodeOffset(inst_data.src_node);
17497 const ptr = try sema.resolveInst(inst_data.operand);17496 const ptr = sema.resolveInst(inst_data.operand);
17498 const ptr_ty = sema.typeOf(ptr);17497 const ptr_ty = sema.typeOf(ptr);
17499 assert(ptr_ty.zigTypeTag(zcu) == .pointer);17498 assert(ptr_ty.zigTypeTag(zcu) == .pointer);
17500 const error_ty = ptr_ty.childType(zcu);17499 const error_ty = ptr_ty.childType(zcu);
...@@ -17509,7 +17508,7 @@ fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -17509,7 +17508,7 @@ fn zirRetIsNonErr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1750917508
17510 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17509 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17511 const src = block.nodeOffset(inst_data.src_node);17510 const src = block.nodeOffset(inst_data.src_node);
17512 const operand = try sema.resolveInst(inst_data.operand);17511 const operand = sema.resolveInst(inst_data.operand);
17513 return sema.analyzeIsNonErr(block, src, operand);17512 return sema.analyzeIsNonErr(block, src, operand);
17514}17513}
1751517514
...@@ -17530,7 +17529,7 @@ fn zirCondbr(...@@ -17530,7 +17529,7 @@ fn zirCondbr(
17530 const then_body = sema.code.bodySlice(extra.end, extra.data.then_body_len);17529 const then_body = sema.code.bodySlice(extra.end, extra.data.then_body_len);
17531 const else_body = sema.code.bodySlice(extra.end + then_body.len, extra.data.else_body_len);17530 const else_body = sema.code.bodySlice(extra.end + then_body.len, extra.data.else_body_len);
1753217531
17533 const uncasted_cond = try sema.resolveInst(extra.data.condition);17532 const uncasted_cond = sema.resolveInst(extra.data.condition);
17534 const cond = try sema.coerce(parent_block, .bool, uncasted_cond, cond_src);17533 const cond = try sema.coerce(parent_block, .bool, uncasted_cond, cond_src);
1753517534
17536 if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| {17535 if (try sema.resolveDefinedValue(parent_block, cond_src, cond)) |cond_val| {
...@@ -17566,7 +17565,7 @@ fn zirCondbr(...@@ -17566,7 +17565,7 @@ fn zirCondbr(
17566 if (sema.code.instructions.items(.tag)[@intFromEnum(index)] != .is_non_err) break :blk null;17565 if (sema.code.instructions.items(.tag)[@intFromEnum(index)] != .is_non_err) break :blk null;
1756717566
17568 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;17567 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;
17569 const err_operand = try sema.resolveInst(err_inst_data.operand);17568 const err_operand = sema.resolveInst(err_inst_data.operand);
17570 const operand_ty = sema.typeOf(err_operand);17569 const operand_ty = sema.typeOf(err_operand);
17571 assert(operand_ty.zigTypeTag(zcu) == .error_union);17570 assert(operand_ty.zigTypeTag(zcu) == .error_union);
17572 const result_ty = operand_ty.errorUnionSet(zcu);17571 const result_ty = operand_ty.errorUnionSet(zcu);
...@@ -17614,7 +17613,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -17614,7 +17613,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
17614 const operand_src = parent_block.src(.{ .node_offset_try_operand = inst_data.src_node });17613 const operand_src = parent_block.src(.{ .node_offset_try_operand = inst_data.src_node });
17615 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);17614 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
17616 const body = sema.code.bodySlice(extra.end, extra.data.body_len);17615 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
17617 const err_union = try sema.resolveInst(extra.data.operand);17616 const err_union = sema.resolveInst(extra.data.operand);
17618 const err_union_ty = sema.typeOf(err_union);17617 const err_union_ty = sema.typeOf(err_union);
17619 const pt = sema.pt;17618 const pt = sema.pt;
17620 const zcu = pt.zcu;17619 const zcu = pt.zcu;
...@@ -17681,7 +17680,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -17681,7 +17680,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
17681 const operand_src = parent_block.src(.{ .node_offset_try_operand = inst_data.src_node });17680 const operand_src = parent_block.src(.{ .node_offset_try_operand = inst_data.src_node });
17682 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);17681 const extra = sema.code.extraData(Zir.Inst.Try, inst_data.payload_index);
17683 const body = sema.code.bodySlice(extra.end, extra.data.body_len);17682 const body = sema.code.bodySlice(extra.end, extra.data.body_len);
17684 const operand = try sema.resolveInst(extra.data.operand);17683 const operand = sema.resolveInst(extra.data.operand);
17685 const err_union = try sema.analyzeLoad(parent_block, src, operand, operand_src);17684 const err_union = try sema.analyzeLoad(parent_block, src, operand, operand_src);
17686 const err_union_ty = sema.typeOf(err_union);17685 const err_union_ty = sema.typeOf(err_union);
17687 const pt = sema.pt;17686 const pt = sema.pt;
...@@ -17802,7 +17801,7 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label...@@ -17802,7 +17801,7 @@ fn ensurePostHoc(sema: *Sema, block: *Block, dest_block: Zir.Inst.Index) !*Label
17802fn addRuntimeBreak(sema: *Sema, child_block: *Block, block_inst: Zir.Inst.Index, break_operand: Zir.Inst.Ref) !void {17801fn addRuntimeBreak(sema: *Sema, child_block: *Block, block_inst: Zir.Inst.Index, break_operand: Zir.Inst.Ref) !void {
17803 const labeled_block = try sema.ensurePostHoc(child_block, block_inst);17802 const labeled_block = try sema.ensurePostHoc(child_block, block_inst);
1780417803
17805 const operand = try sema.resolveInst(break_operand);17804 const operand = sema.resolveInst(break_operand);
17806 const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand);17805 const br_ref = try child_block.addBr(labeled_block.label.merges.block_inst, operand);
1780717806
17808 try labeled_block.label.merges.results.append(sema.gpa, operand);17807 try labeled_block.label.merges.results.append(sema.gpa, operand);
...@@ -17888,7 +17887,7 @@ fn zirRetImplicit(...@@ -17888,7 +17887,7 @@ fn zirRetImplicit(
17888 return;17887 return;
17889 }17888 }
1789017889
17891 const operand = try sema.resolveInst(inst_data.operand);17890 const operand = sema.resolveInst(inst_data.operand);
17892 const ret_ty_src = block.src(.{ .node_offset_fn_type_ret_ty = .zero });17891 const ret_ty_src = block.src(.{ .node_offset_fn_type_ret_ty = .zero });
17893 const base_tag = sema.fn_ret_ty.optEuBaseType(zcu).zigTypeTag(zcu);17892 const base_tag = sema.fn_ret_ty.optEuBaseType(zcu).zigTypeTag(zcu);
17894 if (base_tag == .noreturn) {17893 if (base_tag == .noreturn) {
...@@ -17921,7 +17920,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -17921,7 +17920,7 @@ fn zirRetNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
17921 defer tracy.end();17920 defer tracy.end();
1792217921
17923 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17922 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17924 const operand = try sema.resolveInst(inst_data.operand);17923 const operand = sema.resolveInst(inst_data.operand);
17925 const src = block.nodeOffset(inst_data.src_node);17924 const src = block.nodeOffset(inst_data.src_node);
1792617925
17927 return sema.analyzeRet(block, operand, src, block.src(.{ .node_offset_return_operand = inst_data.src_node }));17926 return sema.analyzeRet(block, operand, src, block.src(.{ .node_offset_return_operand = inst_data.src_node }));
...@@ -17933,7 +17932,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi...@@ -17933,7 +17932,7 @@ fn zirRetLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!voi
1793317932
17934 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;17933 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
17935 const src = block.nodeOffset(inst_data.src_node);17934 const src = block.nodeOffset(inst_data.src_node);
17936 const ret_ptr = try sema.resolveInst(inst_data.operand);17935 const ret_ptr = sema.resolveInst(inst_data.operand);
1793717936
17938 if (block.isComptime() or block.inlining != null or sema.func_is_naked) {17937 if (block.isComptime() or block.inlining != null or sema.func_is_naked) {
17939 const operand = try sema.analyzeLoad(block, src, ret_ptr, src);17938 const operand = try sema.analyzeLoad(block, src, ret_ptr, src);
...@@ -18030,7 +18029,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -18030,7 +18029,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
18030 if (block.isComptime() or block.is_typeof) return;18029 if (block.isComptime() or block.is_typeof) return;
1803118030
18032 const save_index = inst_data.operand == .none or b: {18031 const save_index = inst_data.operand == .none or b: {
18033 const operand = try sema.resolveInst(inst_data.operand);18032 const operand = sema.resolveInst(inst_data.operand);
18034 const operand_ty = sema.typeOf(operand);18033 const operand_ty = sema.typeOf(operand);
18035 break :b operand_ty.isError(zcu);18034 break :b operand_ty.isError(zcu);
18036 };18035 };
...@@ -18079,7 +18078,7 @@ fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_...@@ -18079,7 +18078,7 @@ fn restoreErrRetIndex(sema: *Sema, start_block: *Block, src: LazySrcLoc, target_
18079 return; // No need to restore18078 return; // No need to restore
18080 };18079 };
1808118080
18082 const operand = try sema.resolveInstAllowNone(operand_zir);18081 const operand = sema.resolveInstAllowNone(operand_zir);
1808318082
18084 if (start_block.isComptime() or start_block.is_typeof) {18083 if (start_block.isComptime() or start_block.is_typeof) {
18085 const is_non_error = if (operand != .none) blk: {18084 const is_non_error = if (operand != .none) blk: {
...@@ -18229,7 +18228,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -18229,7 +18228,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
18229 const hostsize_src = block.src(.{ .node_offset_ptr_hostsize = extra.data.src_node });18228 const hostsize_src = block.src(.{ .node_offset_ptr_hostsize = extra.data.src_node });
1823018229
18231 const elem_ty = blk: {18230 const elem_ty = blk: {
18232 const air_inst = try sema.resolveInst(extra.data.elem_type);18231 const air_inst = sema.resolveInst(extra.data.elem_type);
18233 const ty = sema.analyzeAsType(block, elem_ty_src, .type, air_inst) catch |err| {18232 const ty = sema.analyzeAsType(block, elem_ty_src, .type, air_inst) catch |err| {
18234 if (err == error.AnalysisFail and sema.err != null and sema.typeOf(air_inst).isSinglePointer(zcu)) {18233 if (err == error.AnalysisFail and sema.err != null and sema.typeOf(air_inst).isSinglePointer(zcu)) {
18235 try sema.errNote(elem_ty_src, sema.err.?, "use '.*' to dereference pointer", .{});18234 try sema.errNote(elem_ty_src, sema.err.?, "use '.*' to dereference pointer", .{});
...@@ -18250,7 +18249,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -18250,7 +18249,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
18250 const sentinel = if (inst_data.flags.has_sentinel) blk: {18249 const sentinel = if (inst_data.flags.has_sentinel) blk: {
18251 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);18250 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
18252 extra_i += 1;18251 extra_i += 1;
18253 const coerced = try sema.coerce(block, elem_ty, try sema.resolveInst(ref), sentinel_src);18252 const coerced = try sema.coerce(block, elem_ty, sema.resolveInst(ref), sentinel_src);
18254 const val = try sema.resolveConstDefinedValue(block, sentinel_src, coerced, .{ .simple = .pointer_sentinel });18253 const val = try sema.resolveConstDefinedValue(block, sentinel_src, coerced, .{ .simple = .pointer_sentinel });
18255 try checkSentinelType(sema, block, sentinel_src, elem_ty);18254 try checkSentinelType(sema, block, sentinel_src, elem_ty);
18256 if (val.canMutateComptimeVarState(zcu)) {18255 if (val.canMutateComptimeVarState(zcu)) {
...@@ -18263,7 +18262,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -18263,7 +18262,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
18263 const abi_align: Alignment = if (inst_data.flags.has_align) blk: {18262 const abi_align: Alignment = if (inst_data.flags.has_align) blk: {
18264 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);18263 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
18265 extra_i += 1;18264 extra_i += 1;
18266 const coerced = try sema.coerce(block, align_ty, try sema.resolveInst(ref), align_src);18265 const coerced = try sema.coerce(block, align_ty, sema.resolveInst(ref), align_src);
18267 const val = try sema.resolveConstDefinedValue(block, align_src, coerced, .{ .simple = .@"align" });18266 const val = try sema.resolveConstDefinedValue(block, align_src, coerced, .{ .simple = .@"align" });
18268 const align_bytes = val.toUnsignedInt(zcu);18267 const align_bytes = val.toUnsignedInt(zcu);
18269 break :blk try sema.validateAlign(block, align_src, align_bytes);18268 break :blk try sema.validateAlign(block, align_src, align_bytes);
...@@ -18442,7 +18441,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is...@@ -18442,7 +18441,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is
18442 const init_ref = try sema.coerce(block, init_ty, empty_ref, src);18441 const init_ref = try sema.coerce(block, init_ty, empty_ref, src);
1844318442
18444 if (is_byref) {18443 if (is_byref) {
18445 const init_val = (try sema.resolveValue(init_ref)).?;18444 const init_val = sema.resolveValue(init_ref).?;
18446 return sema.uavRef(init_val.toIntern());18445 return sema.uavRef(init_val.toIntern());
18447 } else {18446 } else {
18448 return init_ref;18447 return init_ref;
...@@ -18508,9 +18507,9 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -18508,9 +18507,9 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
18508 const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src);18507 const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_src);
18509 const field_ty: Type = .fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]);18508 const field_ty: Type = .fromInterned(zcu.typeToUnion(union_ty).?.field_types.get(ip)[field_index]);
1851018509
18511 const payload = try sema.coerce(block, field_ty, try sema.resolveInst(extra.init), payload_src);18510 const payload = try sema.coerce(block, field_ty, sema.resolveInst(extra.init), payload_src);
1851218511
18513 if (try sema.resolveValue(payload)) |payload_val| {18512 if (sema.resolveValue(payload)) |payload_val| {
18514 const tag_ty = union_ty.unionTagTypeHypothetical(zcu);18513 const tag_ty = union_ty.unionTagTypeHypothetical(zcu);
18515 const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index);18514 const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index);
18516 return .fromValue(try pt.unionValue(union_ty, tag_val, payload_val));18515 return .fromValue(try pt.unionValue(union_ty, tag_val, payload_val));
...@@ -18590,12 +18589,12 @@ fn zirStructInit(...@@ -18590,12 +18589,12 @@ fn zirStructInit(
18590 assert(field_inits[field_index] == .none);18589 assert(field_inits[field_index] == .none);
18591 field_assign_idxs[field_index] = field_i;18590 field_assign_idxs[field_index] = field_i;
18592 found_fields[field_index] = item.data.field_type;18591 found_fields[field_index] = item.data.field_type;
18593 const uncoerced_init = try sema.resolveInst(item.data.init);18592 const uncoerced_init = sema.resolveInst(item.data.init);
18594 const field_ty = resolved_ty.fieldType(field_index, zcu);18593 const field_ty = resolved_ty.fieldType(field_index, zcu);
18595 field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src);18594 field_inits[field_index] = try sema.coerce(block, field_ty, uncoerced_init, field_src);
18596 if (resolved_ty.structFieldIsComptime(field_index, zcu)) {18595 if (resolved_ty.structFieldIsComptime(field_index, zcu)) {
18597 const default_value = (try resolved_ty.structFieldValueComptime(pt, field_index)).?;18596 const default_value = (try resolved_ty.structFieldValueComptime(pt, field_index)).?;
18598 const init_val = (try sema.resolveValue(field_inits[field_index])) orelse {18597 const init_val = sema.resolveValue(field_inits[field_index]) orelse {
18599 return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field });18598 return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field });
18600 };18599 };
18601 if (!init_val.eql(default_value, resolved_ty.fieldType(field_index, zcu), zcu)) {18600 if (!init_val.eql(default_value, resolved_ty.fieldType(field_index, zcu), zcu)) {
...@@ -18640,17 +18639,17 @@ fn zirStructInit(...@@ -18640,17 +18639,17 @@ fn zirStructInit(
18640 });18639 });
18641 }18640 }
1864218641
18643 const uncoerced_init_inst = try sema.resolveInst(item.data.init);18642 const uncoerced_init_inst = sema.resolveInst(item.data.init);
18644 const init_inst = try sema.coerce(block, field_ty, uncoerced_init_inst, field_src);18643 const init_inst = try sema.coerce(block, field_ty, uncoerced_init_inst, field_src);
1864518644
18646 if (try sema.resolveValue(init_inst)) |val| {18645 if (sema.resolveValue(init_inst)) |val| {
18647 const struct_val = Value.fromInterned(try pt.internUnion(.{18646 const struct_val = Value.fromInterned(try pt.internUnion(.{
18648 .ty = resolved_ty.toIntern(),18647 .ty = resolved_ty.toIntern(),
18649 .tag = tag_val.toIntern(),18648 .tag = tag_val.toIntern(),
18650 .val = val.toIntern(),18649 .val = val.toIntern(),
18651 }));18650 }));
18652 const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src);18651 const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), src);
18653 const final_val = (try sema.resolveValue(final_val_inst)).?;18652 const final_val = sema.resolveValue(final_val_inst).?;
18654 return sema.addConstantMaybeRef(final_val.toIntern(), is_ref);18653 return sema.addConstantMaybeRef(final_val.toIntern(), is_ref);
18655 }18654 }
1865618655
...@@ -18792,11 +18791,11 @@ fn finishStructInit(...@@ -18792,11 +18791,11 @@ fn finishStructInit(
18792 const runtime_index = opt_runtime_index orelse {18791 const runtime_index = opt_runtime_index orelse {
18793 const elems = try sema.arena.alloc(InternPool.Index, field_inits.len);18792 const elems = try sema.arena.alloc(InternPool.Index, field_inits.len);
18794 for (elems, field_inits) |*elem, field_init| {18793 for (elems, field_inits) |*elem, field_init| {
18795 elem.* = (sema.resolveValue(field_init) catch unreachable).?.toIntern();18794 elem.* = sema.resolveValue(field_init).?.toIntern();
18796 }18795 }
18797 const struct_val = try pt.aggregateValue(struct_ty, elems);18796 const struct_val = try pt.aggregateValue(struct_ty, elems);
18798 const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), init_src);18797 const final_val_inst = try sema.coerce(block, result_ty, Air.internedToRef(struct_val.toIntern()), init_src);
18799 const final_val = (try sema.resolveValue(final_val_inst)).?;18798 const final_val = sema.resolveValue(final_val_inst).?;
18800 return sema.addConstantMaybeRef(final_val.toIntern(), is_ref);18799 return sema.addConstantMaybeRef(final_val.toIntern(), is_ref);
18801 };18800 };
1880218801
...@@ -18903,7 +18902,7 @@ fn structInitAnon(...@@ -18903,7 +18902,7 @@ fn structInitAnon(
1890318902
18904 field_name.* = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);18903 field_name.* = try zcu.intern_pool.getOrPutString(gpa, io, pt.tid, name, .no_embedded_nulls);
1890518904
18906 const init = try sema.resolveInst(item.data.init);18905 const init = sema.resolveInst(item.data.init);
18907 field_ty.* = sema.typeOf(init).toIntern();18906 field_ty.* = sema.typeOf(init).toIntern();
18908 if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .@"opaque") {18907 if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .@"opaque") {
18909 const msg = msg: {18908 const msg = msg: {
...@@ -18919,7 +18918,7 @@ fn structInitAnon(...@@ -18919,7 +18918,7 @@ fn structInitAnon(
18919 };18918 };
18920 return sema.failWithOwnedErrorMsg(block, msg);18919 return sema.failWithOwnedErrorMsg(block, msg);
18921 }18920 }
18922 if (try sema.resolveValue(init)) |init_val| {18921 if (sema.resolveValue(init)) |init_val| {
18923 field_val.* = init_val.toIntern();18922 field_val.* = init_val.toIntern();
18924 any_values = true;18923 any_values = true;
18925 } else {18924 } else {
...@@ -19018,7 +19017,7 @@ fn structInitAnon(...@@ -19018,7 +19017,7 @@ fn structInitAnon(
19018 .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) },19017 .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) },
19019 });19018 });
19020 if (values[i] == .none) {19019 if (values[i] == .none) {
19021 const init = try sema.resolveInst(item.data.init);19020 const init = sema.resolveInst(item.data.init);
19022 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);19021 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);
19023 _ = try block.addBinOp(.store, field_ptr, init);19022 _ = try block.addBinOp(.store, field_ptr, init);
19024 }19023 }
...@@ -19035,7 +19034,7 @@ fn structInitAnon(...@@ -19035,7 +19034,7 @@ fn structInitAnon(
19035 .typed_init => sema.code.extraData(Zir.Inst.StructInit.Item, extra_index),19034 .typed_init => sema.code.extraData(Zir.Inst.StructInit.Item, extra_index),
19036 };19035 };
19037 extra_index = item.end;19036 extra_index = item.end;
19038 element_refs[i] = try sema.resolveInst(item.data.init);19037 element_refs[i] = sema.resolveInst(item.data.init);
19039 }19038 }
1904019039
19041 return block.addAggregateInit(struct_ty, element_refs);19040 return block.addAggregateInit(struct_ty, element_refs);
...@@ -19095,7 +19094,7 @@ fn zirArrayInit(...@@ -19095,7 +19094,7 @@ fn zirArrayInit(
19095 };19094 };
1909619095
19097 const arg = args[i + 1];19096 const arg = args[i + 1];
19098 const resolved_arg = try sema.resolveInst(arg);19097 const resolved_arg = sema.resolveInst(arg);
19099 const elem_ty = if (is_tuple)19098 const elem_ty = if (is_tuple)
19100 array_ty.fieldType(i, zcu)19099 array_ty.fieldType(i, zcu)
19101 else19100 else
...@@ -19126,11 +19125,11 @@ fn zirArrayInit(...@@ -19126,11 +19125,11 @@ fn zirArrayInit(
19126 const elem_vals = try sema.arena.alloc(InternPool.Index, resolved_args.len);19125 const elem_vals = try sema.arena.alloc(InternPool.Index, resolved_args.len);
19127 for (elem_vals, resolved_args) |*val, arg| {19126 for (elem_vals, resolved_args) |*val, arg| {
19128 // We checked that all args are comptime above.19127 // We checked that all args are comptime above.
19129 val.* = (sema.resolveValue(arg) catch unreachable).?.toIntern();19128 val.* = sema.resolveValue(arg).?.toIntern();
19130 }19129 }
19131 const arr_val = try pt.aggregateValue(array_ty, elem_vals);19130 const arr_val = try pt.aggregateValue(array_ty, elem_vals);
19132 const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val.toIntern()), src);19131 const result_ref = try sema.coerce(block, result_ty, Air.internedToRef(arr_val.toIntern()), src);
19133 const result_val = (try sema.resolveValue(result_ref)).?;19132 const result_val = (sema.resolveValue(result_ref)).?;
19134 return sema.addConstantMaybeRef(result_val.toIntern(), is_ref);19133 return sema.addConstantMaybeRef(result_val.toIntern(), is_ref);
19135 };19134 };
1913619135
...@@ -19213,7 +19212,7 @@ fn arrayInitAnon(...@@ -19213,7 +19212,7 @@ fn arrayInitAnon(
19213 .init_node_offset = src.offset.node_offset.x,19212 .init_node_offset = src.offset.node_offset.x,
19214 .elem_index = @intCast(i),19213 .elem_index = @intCast(i),
19215 } });19214 } });
19216 const elem = try sema.resolveInst(operand);19215 const elem = sema.resolveInst(operand);
19217 types[i] = sema.typeOf(elem).toIntern();19216 types[i] = sema.typeOf(elem).toIntern();
19218 if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .@"opaque") {19217 if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .@"opaque") {
19219 const msg = msg: {19218 const msg = msg: {
...@@ -19225,7 +19224,7 @@ fn arrayInitAnon(...@@ -19225,7 +19224,7 @@ fn arrayInitAnon(
19225 };19224 };
19226 return sema.failWithOwnedErrorMsg(block, msg);19225 return sema.failWithOwnedErrorMsg(block, msg);
19227 }19226 }
19228 if (try sema.resolveValue(elem)) |val| {19227 if (sema.resolveValue(elem)) |val| {
19229 values[i] = val.toIntern();19228 values[i] = val.toIntern();
19230 any_comptime = true;19229 any_comptime = true;
19231 } else {19230 } else {
...@@ -19265,7 +19264,7 @@ fn arrayInitAnon(...@@ -19265,7 +19264,7 @@ fn arrayInitAnon(
19265 .init_node_offset = src.offset.node_offset.x,19264 .init_node_offset = src.offset.node_offset.x,
19266 .elem_index = @intCast(i),19265 .elem_index = @intCast(i),
19267 } });19266 } });
19268 try sema.validateRuntimeValue(block, operand_src, try sema.resolveInst(operand));19267 try sema.validateRuntimeValue(block, operand_src, sema.resolveInst(operand));
19269 }19268 }
1927019269
19271 if (is_ref) {19270 if (is_ref) {
...@@ -19283,7 +19282,7 @@ fn arrayInitAnon(...@@ -19283,7 +19282,7 @@ fn arrayInitAnon(
19283 });19282 });
19284 if (values[i] == .none) {19283 if (values[i] == .none) {
19285 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);19284 const field_ptr = try block.addStructFieldPtr(alloc, i, field_ptr_ty);
19286 _ = try block.addBinOp(.store, field_ptr, try sema.resolveInst(operand));19285 _ = try block.addBinOp(.store, field_ptr, sema.resolveInst(operand));
19287 }19286 }
19288 }19287 }
1928919288
...@@ -19292,7 +19291,7 @@ fn arrayInitAnon(...@@ -19292,7 +19291,7 @@ fn arrayInitAnon(
1929219291
19293 const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len);19292 const element_refs = try sema.arena.alloc(Air.Inst.Ref, operands.len);
19294 for (operands, 0..) |operand, i| {19293 for (operands, 0..) |operand, i| {
19295 element_refs[i] = try sema.resolveInst(operand);19294 element_refs[i] = sema.resolveInst(operand);
19296 }19295 }
1929719296
19298 return block.addAggregateInit(tuple_ty, element_refs);19297 return block.addAggregateInit(tuple_ty, element_refs);
...@@ -19441,7 +19440,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -19441,7 +19440,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
19441 const zcu = pt.zcu;19440 const zcu = pt.zcu;
19442 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19441 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19443 const src = block.nodeOffset(inst_data.src_node);19442 const src = block.nodeOffset(inst_data.src_node);
19444 const operand = try sema.resolveInst(inst_data.operand);19443 const operand = sema.resolveInst(inst_data.operand);
19445 const operand_ty = sema.typeOf(operand);19444 const operand_ty = sema.typeOf(operand);
19446 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;19445 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
19447 const operand_scalar_ty = operand_ty.scalarType(zcu);19446 const operand_scalar_ty = operand_ty.scalarType(zcu);
...@@ -19450,7 +19449,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -19450,7 +19449,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
19450 }19449 }
19451 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;19450 const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined;
19452 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1;19451 const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1;
19453 if (try sema.resolveValue(operand)) |val| {19452 if (sema.resolveValue(operand)) |val| {
19454 if (!is_vector) {19453 if (!is_vector) {
19455 return if (val.isUndef(zcu)) .undef_u1 else if (val.toBool()) .one_u1 else .zero_u1;19454 return if (val.isUndef(zcu)) .undef_u1 else if (val.toBool()) .one_u1 else .zero_u1;
19456 }19455 }
...@@ -19473,7 +19472,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -19473,7 +19472,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
19473fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {19472fn zirErrorName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
19474 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19473 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19475 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);19474 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
19476 const uncoerced_operand = try sema.resolveInst(inst_data.operand);19475 const uncoerced_operand = sema.resolveInst(inst_data.operand);
19477 const operand = try sema.coerce(block, .anyerror, uncoerced_operand, operand_src);19476 const operand = try sema.coerce(block, .anyerror, uncoerced_operand, operand_src);
1947819477
19479 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {19478 if (try sema.resolveDefinedValue(block, operand_src, operand)) |val| {
...@@ -19494,7 +19493,7 @@ fn zirAbs(...@@ -19494,7 +19493,7 @@ fn zirAbs(
19494 const pt = sema.pt;19493 const pt = sema.pt;
19495 const zcu = pt.zcu;19494 const zcu = pt.zcu;
19496 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19495 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19497 const operand = try sema.resolveInst(inst_data.operand);19496 const operand = sema.resolveInst(inst_data.operand);
19498 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);19497 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
19499 const operand_ty = sema.typeOf(operand);19498 const operand_ty = sema.typeOf(operand);
19500 const scalar_ty = operand_ty.scalarType(zcu);19499 const scalar_ty = operand_ty.scalarType(zcu);
...@@ -19525,7 +19524,7 @@ fn maybeConstantUnaryMath(...@@ -19525,7 +19524,7 @@ fn maybeConstantUnaryMath(
19525 const pt = sema.pt;19524 const pt = sema.pt;
19526 const zcu = pt.zcu;19525 const zcu = pt.zcu;
19527 switch (result_ty.zigTypeTag(zcu)) {19526 switch (result_ty.zigTypeTag(zcu)) {
19528 .vector => if (try sema.resolveValue(operand)) |val| {19527 .vector => if (sema.resolveValue(operand)) |val| {
19529 const scalar_ty = result_ty.scalarType(zcu);19528 const scalar_ty = result_ty.scalarType(zcu);
19530 const vec_len = result_ty.vectorLen(zcu);19529 const vec_len = result_ty.vectorLen(zcu);
19531 if (val.isUndef(zcu))19530 if (val.isUndef(zcu))
...@@ -19538,7 +19537,7 @@ fn maybeConstantUnaryMath(...@@ -19538,7 +19537,7 @@ fn maybeConstantUnaryMath(
19538 }19537 }
19539 return Air.internedToRef((try pt.aggregateValue(result_ty, elems)).toIntern());19538 return Air.internedToRef((try pt.aggregateValue(result_ty, elems)).toIntern());
19540 },19539 },
19541 else => if (try sema.resolveValue(operand)) |operand_val| {19540 else => if (sema.resolveValue(operand)) |operand_val| {
19542 if (operand_val.isUndef(zcu))19541 if (operand_val.isUndef(zcu))
19543 return try pt.undefRef(result_ty);19542 return try pt.undefRef(result_ty);
19544 const result_val = try eval(operand_val, result_ty, sema.arena, pt);19543 const result_val = try eval(operand_val, result_ty, sema.arena, pt);
...@@ -19561,7 +19560,7 @@ fn zirUnaryMath(...@@ -19561,7 +19560,7 @@ fn zirUnaryMath(
19561 const pt = sema.pt;19560 const pt = sema.pt;
19562 const zcu = pt.zcu;19561 const zcu = pt.zcu;
19563 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19562 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19564 const operand = try sema.resolveInst(inst_data.operand);19563 const operand = sema.resolveInst(inst_data.operand);
19565 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);19564 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
19566 const operand_ty = sema.typeOf(operand);19565 const operand_ty = sema.typeOf(operand);
19567 const scalar_ty = operand_ty.scalarType(zcu);19566 const scalar_ty = operand_ty.scalarType(zcu);
...@@ -19586,7 +19585,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -19586,7 +19585,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
19586 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;19585 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
19587 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);19586 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
19588 const src = block.nodeOffset(inst_data.src_node);19587 const src = block.nodeOffset(inst_data.src_node);
19589 const operand = try sema.resolveInst(inst_data.operand);19588 const operand = sema.resolveInst(inst_data.operand);
19590 const operand_ty = sema.typeOf(operand);19589 const operand_ty = sema.typeOf(operand);
19591 const pt = sema.pt;19590 const pt = sema.pt;
19592 const zcu = pt.zcu;19591 const zcu = pt.zcu;
...@@ -19678,7 +19677,7 @@ fn zirReifySliceArgTy(...@@ -19678,7 +19677,7 @@ fn zirReifySliceArgTy(
19678 .flags = .{ .size = .slice, .is_const = true },19677 .flags = .{ .size = .slice, .is_const = true },
19679 });19678 });
1968019679
19681 const operand_uncoerced = try sema.resolveInst(extra.operand);19680 const operand_uncoerced = sema.resolveInst(extra.operand);
19682 const operand_coerced = try sema.coerce(block, operand_ty, operand_uncoerced, src);19681 const operand_coerced = try sema.coerce(block, operand_ty, operand_uncoerced, src);
19683 const operand_val = try sema.resolveConstDefinedValue(block, src, operand_coerced, .{ .simple = comptime_reason });19682 const operand_val = try sema.resolveConstDefinedValue(block, src, operand_coerced, .{ .simple = comptime_reason });
19684 const len_val: Value = .fromInterned(zcu.intern_pool.indexToKey(operand_val.toIntern()).slice.len);19683 const len_val: Value = .fromInterned(zcu.intern_pool.indexToKey(operand_val.toIntern()).slice.len);
...@@ -19706,7 +19705,7 @@ fn zirReifyEnumValueSliceTy(...@@ -19706,7 +19705,7 @@ fn zirReifyEnumValueSliceTy(
1970619705
19707 const int_tag_ty = try sema.resolveType(block, int_tag_ty_src, extra.lhs);19706 const int_tag_ty = try sema.resolveType(block, int_tag_ty_src, extra.lhs);
1970819707
19709 const operand_uncoerced = try sema.resolveInst(extra.rhs);19708 const operand_uncoerced = sema.resolveInst(extra.rhs);
19710 const operand_coerced = try sema.coerce(block, .slice_const_slice_const_u8, operand_uncoerced, field_names_src);19709 const operand_coerced = try sema.coerce(block, .slice_const_slice_const_u8, operand_uncoerced, field_names_src);
19711 const operand_val = try sema.resolveConstDefinedValue(block, field_names_src, operand_coerced, .{ .simple = .enum_field_names });19710 const operand_val = try sema.resolveConstDefinedValue(block, field_names_src, operand_coerced, .{ .simple = .enum_field_names });
19712 const len_val: Value = .fromInterned(zcu.intern_pool.indexToKey(operand_val.toIntern()).slice.len);19711 const len_val: Value = .fromInterned(zcu.intern_pool.indexToKey(operand_val.toIntern()).slice.len);
...@@ -19751,7 +19750,7 @@ fn zirReifyTuple(...@@ -19751,7 +19750,7 @@ fn zirReifyTuple(
19751 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;19750 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
19752 const operand_src = block.builtinCallArgSrc(extra.node, 0);19751 const operand_src = block.builtinCallArgSrc(extra.node, 0);
1975319752
19754 const types_uncoerced = try sema.resolveInst(extra.operand);19753 const types_uncoerced = sema.resolveInst(extra.operand);
19755 const types_coerced = try sema.coerce(block, .slice_const_type, types_uncoerced, operand_src);19754 const types_coerced = try sema.coerce(block, .slice_const_type, types_uncoerced, operand_src);
19756 const types_slice_val = try sema.resolveConstDefinedValue(block, operand_src, types_coerced, .{ .simple = .tuple_field_types });19755 const types_slice_val = try sema.resolveConstDefinedValue(block, operand_src, types_coerced, .{ .simple = .tuple_field_types });
19757 const types_array_val = try sema.derefSliceAsArray(block, operand_src, types_slice_val, .{ .simple = .tuple_field_types });19756 const types_array_val = try sema.derefSliceAsArray(block, operand_src, types_slice_val, .{ .simple = .tuple_field_types });
...@@ -19798,12 +19797,12 @@ fn zirReifyPointer(...@@ -19798,12 +19797,12 @@ fn zirReifyPointer(
19798 const size_ty = try sema.getBuiltinType(size_src, .@"Type.Pointer.Size");19797 const size_ty = try sema.getBuiltinType(size_src, .@"Type.Pointer.Size");
19799 const attrs_ty = try sema.getBuiltinType(attrs_src, .@"Type.Pointer.Attributes");19798 const attrs_ty = try sema.getBuiltinType(attrs_src, .@"Type.Pointer.Attributes");
1980019799
19801 const size_uncoerced = try sema.resolveInst(extra.size);19800 const size_uncoerced = sema.resolveInst(extra.size);
19802 const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src);19801 const size_coerced = try sema.coerce(block, size_ty, size_uncoerced, size_src);
19803 const size_val = try sema.resolveConstDefinedValue(block, size_src, size_coerced, .{ .simple = .pointer_size });19802 const size_val = try sema.resolveConstDefinedValue(block, size_src, size_coerced, .{ .simple = .pointer_size });
19804 const size = try sema.interpretBuiltinType(block, size_src, size_val, std.builtin.Type.Pointer.Size);19803 const size = try sema.interpretBuiltinType(block, size_src, size_val, std.builtin.Type.Pointer.Size);
1980519804
19806 const attrs_uncoerced = try sema.resolveInst(extra.attrs);19805 const attrs_uncoerced = sema.resolveInst(extra.attrs);
19807 const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src);19806 const attrs_coerced = try sema.coerce(block, attrs_ty, attrs_uncoerced, attrs_src);
19808 const attrs_val = try sema.resolveConstDefinedValue(block, attrs_src, attrs_coerced, .{ .simple = .pointer_attrs });19807 const attrs_val = try sema.resolveConstDefinedValue(block, attrs_src, attrs_coerced, .{ .simple = .pointer_attrs });
19809 const attrs = try sema.interpretBuiltinType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes);19808 const attrs = try sema.interpretBuiltinType(block, attrs_src, attrs_val, std.builtin.Type.Pointer.Attributes);
...@@ -19842,7 +19841,7 @@ fn zirReifyPointer(...@@ -19842,7 +19841,7 @@ fn zirReifyPointer(
19842 }19841 }
1984319842
19844 const sentinel_ty = try pt.optionalType(elem_ty.toIntern());19843 const sentinel_ty = try pt.optionalType(elem_ty.toIntern());
19845 const sentinel_uncoerced = try sema.resolveInst(extra.sentinel);19844 const sentinel_uncoerced = sema.resolveInst(extra.sentinel);
19846 const sentinel_coerced = try sema.coerce(block, sentinel_ty, sentinel_uncoerced, sentinel_src);19845 const sentinel_coerced = try sema.coerce(block, sentinel_ty, sentinel_uncoerced, sentinel_src);
19847 const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel_coerced, .{ .simple = .pointer_sentinel });19846 const sentinel_val = try sema.resolveConstDefinedValue(block, sentinel_src, sentinel_coerced, .{ .simple = .pointer_sentinel });
19848 const opt_sentinel = sentinel_val.optionalValue(zcu);19847 const opt_sentinel = sentinel_val.optionalValue(zcu);
...@@ -19896,7 +19895,7 @@ fn zirReifyFn(...@@ -19896,7 +19895,7 @@ fn zirReifyFn(
19896 const single_param_attrs_ty = try sema.getBuiltinType(param_attrs_src, .@"Type.Fn.Param.Attributes");19895 const single_param_attrs_ty = try sema.getBuiltinType(param_attrs_src, .@"Type.Fn.Param.Attributes");
19897 const fn_attrs_ty = try sema.getBuiltinType(fn_attrs_src, .@"Type.Fn.Attributes");19896 const fn_attrs_ty = try sema.getBuiltinType(fn_attrs_src, .@"Type.Fn.Attributes");
1989819897
19899 const param_types_uncoerced = try sema.resolveInst(extra.param_types);19898 const param_types_uncoerced = sema.resolveInst(extra.param_types);
19900 const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src);19899 const param_types_coerced = try sema.coerce(block, .slice_const_type, param_types_uncoerced, param_types_src);
19901 const param_types_slice = try sema.resolveConstDefinedValue(block, param_types_src, param_types_coerced, .{ .simple = .fn_param_types });19900 const param_types_slice = try sema.resolveConstDefinedValue(block, param_types_src, param_types_coerced, .{ .simple = .fn_param_types });
19902 const param_types_arr = try sema.derefSliceAsArray(block, param_types_src, param_types_slice, .{ .simple = .fn_param_types });19901 const param_types_arr = try sema.derefSliceAsArray(block, param_types_src, param_types_slice, .{ .simple = .fn_param_types });
...@@ -19907,7 +19906,7 @@ fn zirReifyFn(...@@ -19907,7 +19906,7 @@ fn zirReifyFn(
19907 .len = params_len,19906 .len = params_len,
19908 .child = single_param_attrs_ty.toIntern(),19907 .child = single_param_attrs_ty.toIntern(),
19909 }));19908 }));
19910 const param_attrs_uncoerced = try sema.resolveInst(extra.param_attrs);19909 const param_attrs_uncoerced = sema.resolveInst(extra.param_attrs);
19911 const param_attrs_coerced = try sema.coerce(block, param_attrs_ty, param_attrs_uncoerced, param_attrs_src);19910 const param_attrs_coerced = try sema.coerce(block, param_attrs_ty, param_attrs_uncoerced, param_attrs_src);
19912 const param_attrs_slice = try sema.resolveConstDefinedValue(block, param_attrs_src, param_attrs_coerced, .{ .simple = .fn_param_attrs });19911 const param_attrs_slice = try sema.resolveConstDefinedValue(block, param_attrs_src, param_attrs_coerced, .{ .simple = .fn_param_attrs });
19913 const param_attrs_arr = try sema.derefSliceAsArray(block, param_attrs_src, param_attrs_slice, .{ .simple = .fn_param_attrs });19912 const param_attrs_arr = try sema.derefSliceAsArray(block, param_attrs_src, param_attrs_slice, .{ .simple = .fn_param_attrs });
...@@ -19915,7 +19914,7 @@ fn zirReifyFn(...@@ -19915,7 +19914,7 @@ fn zirReifyFn(
19915 const ret_ty = try sema.resolveType(block, ret_ty_src, extra.ret_ty);19914 const ret_ty = try sema.resolveType(block, ret_ty_src, extra.ret_ty);
19916 try sema.ensureLayoutResolved(ret_ty);19915 try sema.ensureLayoutResolved(ret_ty);
1991719916
19918 const fn_attrs_uncoerced = try sema.resolveInst(extra.fn_attrs);19917 const fn_attrs_uncoerced = sema.resolveInst(extra.fn_attrs);
19919 const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src);19918 const fn_attrs_coerced = try sema.coerce(block, fn_attrs_ty, fn_attrs_uncoerced, fn_attrs_src);
19920 const fn_attrs_val = try sema.resolveConstDefinedValue(block, fn_attrs_src, fn_attrs_coerced, .{ .simple = .fn_attrs });19919 const fn_attrs_val = try sema.resolveConstDefinedValue(block, fn_attrs_src, fn_attrs_coerced, .{ .simple = .fn_attrs });
19921 const fn_attrs = try sema.interpretBuiltinType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes);19920 const fn_attrs = try sema.interpretBuiltinType(block, fn_attrs_src, fn_attrs_val, std.builtin.Type.Fn.Attributes);
...@@ -20041,16 +20040,16 @@ fn zirReifyStruct(...@@ -20041,16 +20040,16 @@ fn zirReifyStruct(
20041 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");20040 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");
20042 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.StructField.Attributes");20041 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.StructField.Attributes");
2004320042
20044 const layout_uncoerced = try sema.resolveInst(extra.layout);20043 const layout_uncoerced = sema.resolveInst(extra.layout);
20045 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);20044 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
20046 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .struct_layout });20045 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .struct_layout });
20047 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);20046 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
2004820047
20049 const backing_int_ty_uncoerced = try sema.resolveInst(extra.backing_ty);20048 const backing_int_ty_uncoerced = sema.resolveInst(extra.backing_ty);
20050 const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src);20049 const backing_int_ty_coerced = try sema.coerce(block, .optional_type, backing_int_ty_uncoerced, backing_ty_src);
20051 const backing_int_ty_val = try sema.resolveConstDefinedValue(block, backing_ty_src, backing_int_ty_coerced, .{ .simple = .packed_struct_backing_int_type });20050 const backing_int_ty_val = try sema.resolveConstDefinedValue(block, backing_ty_src, backing_int_ty_coerced, .{ .simple = .packed_struct_backing_int_type });
2005220051
20053 const field_names_uncoerced = try sema.resolveInst(extra.field_names);20052 const field_names_uncoerced = sema.resolveInst(extra.field_names);
20054 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);20053 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);
20055 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .struct_field_names });20054 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .struct_field_names });
20056 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .struct_field_names });20055 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .struct_field_names });
...@@ -20066,12 +20065,12 @@ fn zirReifyStruct(...@@ -20066,12 +20065,12 @@ fn zirReifyStruct(
20066 .child = single_field_attrs_ty.toIntern(),20065 .child = single_field_attrs_ty.toIntern(),
20067 }));20066 }));
2006820067
20069 const field_types_uncoerced = try sema.resolveInst(extra.field_types);20068 const field_types_uncoerced = sema.resolveInst(extra.field_types);
20070 const field_types_coerced = try sema.coerce(block, field_types_ty, field_types_uncoerced, field_types_src);20069 const field_types_coerced = try sema.coerce(block, field_types_ty, field_types_uncoerced, field_types_src);
20071 const field_types_slice = try sema.resolveConstDefinedValue(block, field_types_src, field_types_coerced, .{ .simple = .struct_field_types });20070 const field_types_slice = try sema.resolveConstDefinedValue(block, field_types_src, field_types_coerced, .{ .simple = .struct_field_types });
20072 const field_types_arr = try sema.derefSliceAsArray(block, field_types_src, field_types_slice, .{ .simple = .struct_field_types });20071 const field_types_arr = try sema.derefSliceAsArray(block, field_types_src, field_types_slice, .{ .simple = .struct_field_types });
2007320072
20074 const field_attrs_uncoerced = try sema.resolveInst(extra.field_attrs);20073 const field_attrs_uncoerced = sema.resolveInst(extra.field_attrs);
20075 const field_attrs_coerced = try sema.coerce(block, field_attrs_ty, field_attrs_uncoerced, field_attrs_src);20074 const field_attrs_coerced = try sema.coerce(block, field_attrs_ty, field_attrs_uncoerced, field_attrs_src);
20076 const field_attrs_slice = try sema.resolveConstDefinedValue(block, field_attrs_src, field_attrs_coerced, .{ .simple = .struct_field_attrs });20075 const field_attrs_slice = try sema.resolveConstDefinedValue(block, field_attrs_src, field_attrs_coerced, .{ .simple = .struct_field_attrs });
20077 const field_attrs_arr = try sema.derefSliceAsArray(block, field_attrs_src, field_attrs_slice, .{ .simple = .struct_field_attrs });20076 const field_attrs_arr = try sema.derefSliceAsArray(block, field_attrs_src, field_attrs_slice, .{ .simple = .struct_field_attrs });
...@@ -20328,19 +20327,19 @@ fn zirReifyUnion(...@@ -20328,19 +20327,19 @@ fn zirReifyUnion(
20328 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");20327 const container_layout_ty = try sema.getBuiltinType(layout_src, .@"Type.ContainerLayout");
20329 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.UnionField.Attributes");20328 const single_field_attrs_ty = try sema.getBuiltinType(field_attrs_src, .@"Type.UnionField.Attributes");
2033020329
20331 const layout_uncoerced = try sema.resolveInst(extra.layout);20330 const layout_uncoerced = sema.resolveInst(extra.layout);
20332 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);20331 const layout_coerced = try sema.coerce(block, container_layout_ty, layout_uncoerced, layout_src);
20333 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .union_layout });20332 const layout_val = try sema.resolveConstDefinedValue(block, layout_src, layout_coerced, .{ .simple = .union_layout });
20334 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);20333 const layout = try sema.interpretBuiltinType(block, layout_src, layout_val, std.builtin.Type.ContainerLayout);
2033520334
20336 const arg_ty_uncoerced = try sema.resolveInst(extra.arg_ty);20335 const arg_ty_uncoerced = sema.resolveInst(extra.arg_ty);
20337 const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src);20336 const arg_ty_coerced = try sema.coerce(block, .optional_type, arg_ty_uncoerced, arg_ty_src);
20338 const arg_ty_val = try sema.resolveConstDefinedValue(block, arg_ty_src, arg_ty_coerced, switch (layout) {20337 const arg_ty_val = try sema.resolveConstDefinedValue(block, arg_ty_src, arg_ty_coerced, switch (layout) {
20339 .@"packed" => .{ .simple = .packed_union_backing_int_type },20338 .@"packed" => .{ .simple = .packed_union_backing_int_type },
20340 .auto, .@"extern" => .{ .simple = .union_enum_tag_type },20339 .auto, .@"extern" => .{ .simple = .union_enum_tag_type },
20341 });20340 });
2034220341
20343 const field_names_uncoerced = try sema.resolveInst(extra.field_names);20342 const field_names_uncoerced = sema.resolveInst(extra.field_names);
20344 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);20343 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);
20345 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .union_field_names });20344 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .union_field_names });
20346 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .union_field_names });20345 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .union_field_names });
...@@ -20356,12 +20355,12 @@ fn zirReifyUnion(...@@ -20356,12 +20355,12 @@ fn zirReifyUnion(
20356 .child = single_field_attrs_ty.toIntern(),20355 .child = single_field_attrs_ty.toIntern(),
20357 }));20356 }));
2035820357
20359 const field_types_uncoerced = try sema.resolveInst(extra.field_types);20358 const field_types_uncoerced = sema.resolveInst(extra.field_types);
20360 const field_types_coerced = try sema.coerce(block, field_types_ty, field_types_uncoerced, field_types_src);20359 const field_types_coerced = try sema.coerce(block, field_types_ty, field_types_uncoerced, field_types_src);
20361 const field_types_slice = try sema.resolveConstDefinedValue(block, field_types_src, field_types_coerced, .{ .simple = .union_field_types });20360 const field_types_slice = try sema.resolveConstDefinedValue(block, field_types_src, field_types_coerced, .{ .simple = .union_field_types });
20362 const field_types_arr = try sema.derefSliceAsArray(block, field_types_src, field_types_slice, .{ .simple = .union_field_types });20361 const field_types_arr = try sema.derefSliceAsArray(block, field_types_src, field_types_slice, .{ .simple = .union_field_types });
2036320362
20364 const field_attrs_uncoerced = try sema.resolveInst(extra.field_attrs);20363 const field_attrs_uncoerced = sema.resolveInst(extra.field_attrs);
20365 const field_attrs_coerced = try sema.coerce(block, field_attrs_ty, field_attrs_uncoerced, field_attrs_src);20364 const field_attrs_coerced = try sema.coerce(block, field_attrs_ty, field_attrs_uncoerced, field_attrs_src);
20366 const field_attrs_slice = try sema.resolveConstDefinedValue(block, field_attrs_src, field_attrs_coerced, .{ .simple = .union_field_attrs });20365 const field_attrs_slice = try sema.resolveConstDefinedValue(block, field_attrs_src, field_attrs_coerced, .{ .simple = .union_field_attrs });
20367 const field_attrs_arr = try sema.derefSliceAsArray(block, field_attrs_src, field_attrs_slice, .{ .simple = .union_field_attrs });20366 const field_attrs_arr = try sema.derefSliceAsArray(block, field_attrs_src, field_attrs_slice, .{ .simple = .union_field_attrs });
...@@ -20549,12 +20548,12 @@ fn zirReifyEnum(...@@ -20549,12 +20548,12 @@ fn zirReifyEnum(
2054920548
20550 const enum_mode_ty = try sema.getBuiltinType(mode_src, .@"Type.Enum.Mode");20549 const enum_mode_ty = try sema.getBuiltinType(mode_src, .@"Type.Enum.Mode");
2055120550
20552 const tag_ty_uncoerced = try sema.resolveInst(extra.tag_ty);20551 const tag_ty_uncoerced = sema.resolveInst(extra.tag_ty);
20553 const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src);20552 const tag_ty_coerced = try sema.coerce(block, .type, tag_ty_uncoerced, tag_ty_src);
20554 const tag_ty_val = try sema.resolveConstDefinedValue(block, tag_ty_src, tag_ty_coerced, .{ .simple = .enum_int_tag_type });20553 const tag_ty_val = try sema.resolveConstDefinedValue(block, tag_ty_src, tag_ty_coerced, .{ .simple = .enum_int_tag_type });
20555 const tag_ty = tag_ty_val.toType();20554 const tag_ty = tag_ty_val.toType();
2055620555
20557 const mode_uncoerced = try sema.resolveInst(extra.mode);20556 const mode_uncoerced = sema.resolveInst(extra.mode);
20558 const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src);20557 const mode_coerced = try sema.coerce(block, enum_mode_ty, mode_uncoerced, mode_src);
20559 const mode_val = try sema.resolveConstDefinedValue(block, mode_src, mode_coerced, .{ .simple = .type });20558 const mode_val = try sema.resolveConstDefinedValue(block, mode_src, mode_coerced, .{ .simple = .type });
20560 const nonexhaustive = switch (try sema.interpretBuiltinType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) {20559 const nonexhaustive = switch (try sema.interpretBuiltinType(block, mode_src, mode_val, std.builtin.Type.Enum.Mode)) {
...@@ -20562,7 +20561,7 @@ fn zirReifyEnum(...@@ -20562,7 +20561,7 @@ fn zirReifyEnum(
20562 .nonexhaustive => true,20561 .nonexhaustive => true,
20563 };20562 };
2056420563
20565 const field_names_uncoerced = try sema.resolveInst(extra.field_names);20564 const field_names_uncoerced = sema.resolveInst(extra.field_names);
20566 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);20565 const field_names_coerced = try sema.coerce(block, .slice_const_slice_const_u8, field_names_uncoerced, field_names_src);
20567 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .enum_field_names });20566 const field_names_slice = try sema.resolveConstDefinedValue(block, field_names_src, field_names_coerced, .{ .simple = .enum_field_names });
20568 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .enum_field_names });20567 const field_names_arr = try sema.derefSliceAsArray(block, field_names_src, field_names_slice, .{ .simple = .enum_field_names });
...@@ -20574,7 +20573,7 @@ fn zirReifyEnum(...@@ -20574,7 +20573,7 @@ fn zirReifyEnum(
20574 .child = tag_ty.toIntern(),20573 .child = tag_ty.toIntern(),
20575 }));20574 }));
2057620575
20577 const field_values_uncoerced = try sema.resolveInst(extra.field_values);20576 const field_values_uncoerced = sema.resolveInst(extra.field_values);
20578 const field_values_coerced = try sema.coerce(block, field_values_ty, field_values_uncoerced, field_values_src);20577 const field_values_coerced = try sema.coerce(block, field_values_ty, field_values_uncoerced, field_values_src);
20579 const field_values_slice = try sema.resolveConstDefinedValue(block, field_values_src, field_values_coerced, .{ .simple = .enum_field_values });20578 const field_values_slice = try sema.resolveConstDefinedValue(block, field_values_src, field_values_coerced, .{ .simple = .enum_field_values });
20580 const field_values_arr = try sema.derefSliceAsArray(block, field_values_src, field_values_slice, .{ .simple = .enum_field_values });20579 const field_values_arr = try sema.derefSliceAsArray(block, field_values_src, field_values_slice, .{ .simple = .enum_field_values });
...@@ -20663,7 +20662,7 @@ fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.In...@@ -20663,7 +20662,7 @@ fn resolveVaListRef(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.In
20663 const va_list_ty = try sema.getBuiltinType(src, .VaList);20662 const va_list_ty = try sema.getBuiltinType(src, .VaList);
20664 const va_list_ptr = try pt.singleMutPtrType(va_list_ty);20663 const va_list_ptr = try pt.singleMutPtrType(va_list_ty);
2066520664
20666 const inst = try sema.resolveInst(zir_ref);20665 const inst = sema.resolveInst(zir_ref);
20667 return sema.coerce(block, va_list_ptr, inst, src);20666 return sema.coerce(block, va_list_ptr, inst, src);
20668}20667}
2066920668
...@@ -20759,7 +20758,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -20759,7 +20758,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
20759 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;20758 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
20760 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);20759 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
20761 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat");20760 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat");
20762 const operand = try sema.resolveInst(extra.rhs);20761 const operand = sema.resolveInst(extra.rhs);
20763 const operand_ty = sema.typeOf(operand);20762 const operand_ty = sema.typeOf(operand);
2076420763
20765 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);20764 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
...@@ -20771,7 +20770,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -20771,7 +20770,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
20771 _ = try sema.checkIntType(block, src, dest_scalar_ty);20770 _ = try sema.checkIntType(block, src, dest_scalar_ty);
20772 try sema.checkFloatType(block, operand_src, operand_scalar_ty);20771 try sema.checkFloatType(block, operand_src, operand_scalar_ty);
2077320772
20774 if (try sema.resolveValue(operand)) |operand_val| {20773 if (sema.resolveValue(operand)) |operand_val| {
20775 const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate);20774 const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate);
20776 return Air.internedToRef(result_val.toIntern());20775 return Air.internedToRef(result_val.toIntern());
20777 } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) {20776 } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) {
...@@ -20812,7 +20811,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -20812,7 +20811,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
20812 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;20811 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
20813 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);20812 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
20814 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt");20813 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt");
20815 const operand = try sema.resolveInst(extra.rhs);20814 const operand = sema.resolveInst(extra.rhs);
20816 const operand_ty = sema.typeOf(operand);20815 const operand_ty = sema.typeOf(operand);
2081720816
20818 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);20817 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
...@@ -20823,7 +20822,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -20823,7 +20822,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
20823 try sema.checkFloatType(block, src, dest_scalar_ty);20822 try sema.checkFloatType(block, src, dest_scalar_ty);
20824 _ = try sema.checkIntType(block, operand_src, operand_scalar_ty);20823 _ = try sema.checkIntType(block, operand_src, operand_scalar_ty);
2082520824
20826 if (try sema.resolveValue(operand)) |operand_val| {20825 if (sema.resolveValue(operand)) |operand_val| {
20827 if (operand_val.isUndef(zcu)) return .fromValue(try pt.undefValue(dest_ty));20826 if (operand_val.isUndef(zcu)) return .fromValue(try pt.undefValue(dest_ty));
20828 if (dest_ty.zigTypeTag(zcu) != .vector) {20827 if (dest_ty.zigTypeTag(zcu) != .vector) {
20829 return .fromValue(try pt.floatValue(dest_ty, operand_val.toFloat(f128, zcu)));20828 return .fromValue(try pt.floatValue(dest_ty, operand_val.toFloat(f128, zcu)));
...@@ -20855,7 +20854,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -20855,7 +20854,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
20855 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;20854 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
2085620855
20857 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);20856 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
20858 const operand_res = try sema.resolveInst(extra.rhs);20857 const operand_res = sema.resolveInst(extra.rhs);
2085920858
20860 const uncoerced_operand_ty = sema.typeOf(operand_res);20859 const uncoerced_operand_ty = sema.typeOf(operand_res);
20861 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt");20860 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt");
...@@ -20983,7 +20982,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -20983,7 +20982,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
20983 const src = block.nodeOffset(extra.node);20982 const src = block.nodeOffset(extra.node);
20984 const operand_src = block.builtinCallArgSrc(extra.node, 0);20983 const operand_src = block.builtinCallArgSrc(extra.node, 0);
20985 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_opt, "@errorCast");20984 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_opt, "@errorCast");
20986 const operand = try sema.resolveInst(extra.rhs);20985 const operand = sema.resolveInst(extra.rhs);
20987 const operand_ty = sema.typeOf(operand);20986 const operand_ty = sema.typeOf(operand);
2098820987
20989 const dest_tag = dest_ty.zigTypeTag(zcu);20988 const dest_tag = dest_ty.zigTypeTag(zcu);
...@@ -21134,7 +21133,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa...@@ -21134,7 +21133,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa
21134 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;21133 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
21135 const src = block.nodeOffset(extra.node);21134 const src = block.nodeOffset(extra.node);
21136 const operand_src = block.src(.{ .node_offset_ptrcast_operand = extra.node });21135 const operand_src = block.src(.{ .node_offset_ptrcast_operand = extra.node });
21137 const operand = try sema.resolveInst(extra.rhs);21136 const operand = sema.resolveInst(extra.rhs);
21138 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, flags.needResultTypeBuiltinName());21137 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, flags.needResultTypeBuiltinName());
21139 return sema.ptrCastFull(21138 return sema.ptrCastFull(
21140 block,21139 block,
...@@ -21153,7 +21152,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -21153,7 +21152,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
21153 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);21152 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21154 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;21153 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
21155 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrCast");21154 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrCast");
21156 const operand = try sema.resolveInst(extra.rhs);21155 const operand = sema.resolveInst(extra.rhs);
2115721156
21158 return sema.ptrCastFull(21157 return sema.ptrCastFull(
21159 block,21158 block,
...@@ -21219,7 +21218,7 @@ fn ptrCastFull(...@@ -21219,7 +21218,7 @@ fn ptrCastFull(
21219 };21218 };
21220 },21219 },
21221 .slice => src: {21220 .slice => src: {
21222 const operand_val = try sema.resolveValue(operand) orelse break :src .{ .fromInterned(src_info.child), null };21221 const operand_val = sema.resolveValue(operand) orelse break :src .{ .fromInterned(src_info.child), null };
21223 if (operand_val.isUndef(zcu)) break :len .undef;21222 if (operand_val.isUndef(zcu)) break :len .undef;
21224 const slice_val = switch (operand_ty.zigTypeTag(zcu)) {21223 const slice_val = switch (operand_ty.zigTypeTag(zcu)) {
21225 .optional => operand_val.optionalValue(zcu) orelse break :len .undef,21224 .optional => operand_val.optionalValue(zcu) orelse break :len .undef,
...@@ -21516,7 +21515,7 @@ fn ptrCastFull(...@@ -21516,7 +21515,7 @@ fn ptrCastFull(
2151621515
21517 ct: {21516 ct: {
21518 if (flags.addrspace_cast) break :ct; // cannot `@addrSpaceCast` at comptime21517 if (flags.addrspace_cast) break :ct; // cannot `@addrSpaceCast` at comptime
21519 const operand_val = try sema.resolveValue(operand) orelse break :ct;21518 const operand_val = sema.resolveValue(operand) orelse break :ct;
2152021519
21521 if (operand_val.isUndef(zcu)) {21520 if (operand_val.isUndef(zcu)) {
21522 if (!dest_ty.ptrAllowsZero(zcu)) {21521 if (!dest_ty.ptrAllowsZero(zcu)) {
...@@ -21776,7 +21775,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst...@@ -21776,7 +21775,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
21776 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;21775 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
21777 const src = block.nodeOffset(extra.node);21776 const src = block.nodeOffset(extra.node);
21778 const operand_src = block.src(.{ .node_offset_ptrcast_operand = extra.node });21777 const operand_src = block.src(.{ .node_offset_ptrcast_operand = extra.node });
21779 const operand = try sema.resolveInst(extra.operand);21778 const operand = sema.resolveInst(extra.operand);
21780 const operand_ty = sema.typeOf(operand);21779 const operand_ty = sema.typeOf(operand);
21781 try sema.checkPtrOperand(block, operand_src, operand_ty);21780 try sema.checkPtrOperand(block, operand_src, operand_ty);
2178221781
...@@ -21792,7 +21791,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst...@@ -21792,7 +21791,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
21792 break :blk dest_ty;21791 break :blk dest_ty;
21793 };21792 };
2179421793
21795 if (try sema.resolveValue(operand)) |operand_val| {21794 if (sema.resolveValue(operand)) |operand_val| {
21796 return Air.internedToRef((try pt.getCoerced(operand_val, dest_ty)).toIntern());21795 return Air.internedToRef((try pt.getCoerced(operand_val, dest_ty)).toIntern());
21797 }21796 }
2179821797
...@@ -21811,7 +21810,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -21811,7 +21810,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
21811 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;21810 const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data;
21812 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate");21811 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate");
21813 const dest_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, dest_ty, src);21812 const dest_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, dest_ty, src);
21814 const operand = try sema.resolveInst(extra.rhs);21813 const operand = sema.resolveInst(extra.rhs);
21815 const operand_ty = sema.typeOf(operand);21814 const operand_ty = sema.typeOf(operand);
21816 const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);21815 const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);
2181721816
...@@ -21842,7 +21841,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -21842,7 +21841,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
21842 }21841 }
21843 }21842 }
2184421843
21845 if (try sema.resolveValue(operand)) |val| {21844 if (sema.resolveValue(operand)) |val| {
21846 const result_val = try arith.truncate(sema, val, operand_ty, dest_ty, dest_info.signedness, dest_info.bits);21845 const result_val = try arith.truncate(sema, val, operand_ty, dest_ty, dest_info.signedness, dest_info.bits);
21847 return Air.internedToRef(result_val.toIntern());21846 return Air.internedToRef(result_val.toIntern());
21848 }21847 }
...@@ -21863,7 +21862,7 @@ fn zirBitCount(...@@ -21863,7 +21862,7 @@ fn zirBitCount(
21863 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;21862 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
21864 const src = block.nodeOffset(inst_data.src_node);21863 const src = block.nodeOffset(inst_data.src_node);
21865 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);21864 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21866 const operand = try sema.resolveInst(inst_data.operand);21865 const operand = sema.resolveInst(inst_data.operand);
21867 const operand_ty = sema.typeOf(operand);21866 const operand_ty = sema.typeOf(operand);
21868 _ = try sema.checkIntOrVector(block, operand, operand_src);21867 _ = try sema.checkIntOrVector(block, operand, operand_src);
21869 const bits = operand_ty.intInfo(zcu).bits;21868 const bits = operand_ty.intInfo(zcu).bits;
...@@ -21876,7 +21875,7 @@ fn zirBitCount(...@@ -21876,7 +21875,7 @@ fn zirBitCount(
21876 .len = vec_len,21875 .len = vec_len,
21877 .child = result_scalar_ty.toIntern(),21876 .child = result_scalar_ty.toIntern(),
21878 });21877 });
21879 if (try sema.resolveValue(operand)) |val| {21878 if (sema.resolveValue(operand)) |val| {
21880 if (val.isUndef(zcu)) return pt.undefRef(result_ty);21879 if (val.isUndef(zcu)) return pt.undefRef(result_ty);
2188121880
21882 const elems = try sema.arena.alloc(InternPool.Index, vec_len);21881 const elems = try sema.arena.alloc(InternPool.Index, vec_len);
...@@ -21893,7 +21892,7 @@ fn zirBitCount(...@@ -21893,7 +21892,7 @@ fn zirBitCount(
21893 }21892 }
21894 },21893 },
21895 .int => {21894 .int => {
21896 if (try sema.resolveValue(operand)) |val| {21895 if (sema.resolveValue(operand)) |val| {
21897 if (val.isUndef(zcu)) return pt.undefRef(result_scalar_ty);21896 if (val.isUndef(zcu)) return pt.undefRef(result_scalar_ty);
21898 return pt.intRef(result_scalar_ty, comptimeOp(val, operand_ty, zcu));21897 return pt.intRef(result_scalar_ty, comptimeOp(val, operand_ty, zcu));
21899 } else {21898 } else {
...@@ -21910,7 +21909,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -21910,7 +21909,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
21910 const zcu = pt.zcu;21909 const zcu = pt.zcu;
21911 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;21910 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
21912 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);21911 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21913 const operand = try sema.resolveInst(inst_data.operand);21912 const operand = sema.resolveInst(inst_data.operand);
21914 const operand_ty = sema.typeOf(operand);21913 const operand_ty = sema.typeOf(operand);
21915 const scalar_ty = try sema.checkIntOrVector(block, operand, operand_src);21914 const scalar_ty = try sema.checkIntOrVector(block, operand, operand_src);
21916 const bits = scalar_ty.intInfo(zcu).bits;21915 const bits = scalar_ty.intInfo(zcu).bits;
...@@ -21922,7 +21921,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -21922,7 +21921,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
21922 .{ scalar_ty.fmt(pt), bits },21921 .{ scalar_ty.fmt(pt), bits },
21923 );21922 );
21924 }21923 }
21925 if (try sema.resolveValue(operand)) |operand_val| {21924 if (sema.resolveValue(operand)) |operand_val| {
21926 return .fromValue(try arith.byteSwap(sema, operand_val, operand_ty));21925 return .fromValue(try arith.byteSwap(sema, operand_val, operand_ty));
21927 }21926 }
21928 return block.addTyOp(.byte_swap, operand_ty, operand);21927 return block.addTyOp(.byte_swap, operand_ty, operand);
...@@ -21931,11 +21930,11 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -21931,11 +21930,11 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
21931fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {21930fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
21932 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;21931 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
21933 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);21932 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
21934 const operand = try sema.resolveInst(inst_data.operand);21933 const operand = sema.resolveInst(inst_data.operand);
21935 const operand_ty = sema.typeOf(operand);21934 const operand_ty = sema.typeOf(operand);
21936 _ = try sema.checkIntOrVector(block, operand, operand_src);21935 _ = try sema.checkIntOrVector(block, operand, operand_src);
2193721936
21938 if (try sema.resolveValue(operand)) |operand_val| {21937 if (sema.resolveValue(operand)) |operand_val| {
21939 return .fromValue(try arith.bitReverse(sema, operand_val, operand_ty));21938 return .fromValue(try arith.bitReverse(sema, operand_val, operand_ty));
21940 }21939 }
21941 return block.addTyOp(.bit_reverse, operand_ty, operand);21940 return block.addTyOp(.bit_reverse, operand_ty, operand);
...@@ -22359,8 +22358,8 @@ fn checkSimdBinOp(...@@ -22359,8 +22358,8 @@ fn checkSimdBinOp(
22359 .len = vec_len,22358 .len = vec_len,
22360 .lhs = lhs,22359 .lhs = lhs,
22361 .rhs = rhs,22360 .rhs = rhs,
22362 .lhs_val = try sema.resolveValue(lhs),22361 .lhs_val = sema.resolveValue(lhs),
22363 .rhs_val = try sema.resolveValue(rhs),22362 .rhs_val = sema.resolveValue(rhs),
22364 .result_ty = result_ty,22363 .result_ty = result_ty,
22365 .scalar_ty = result_ty.scalarType(zcu),22364 .scalar_ty = result_ty.scalarType(zcu),
22366 };22365 };
...@@ -22452,7 +22451,7 @@ fn resolveExportOptions(...@@ -22452,7 +22451,7 @@ fn resolveExportOptions(
22452 const ip = &zcu.intern_pool;22451 const ip = &zcu.intern_pool;
2245322452
22454 const export_options_ty = try sema.getBuiltinType(src, .ExportOptions);22453 const export_options_ty = try sema.getBuiltinType(src, .ExportOptions);
22455 const air_ref = try sema.resolveInst(zir_ref);22454 const air_ref = sema.resolveInst(zir_ref);
22456 const options = try sema.coerce(block, export_options_ty, air_ref, src);22455 const options = try sema.coerce(block, export_options_ty, air_ref, src);
2245722456
22458 const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node });22457 const name_src = block.src(.{ .init_field_name = src.offset.node_offset_builtin_call_arg.builtin_call_node });
...@@ -22505,7 +22504,7 @@ fn resolveBuiltinEnum(...@@ -22505,7 +22504,7 @@ fn resolveBuiltinEnum(
22505 reason: ComptimeReason,22504 reason: ComptimeReason,
22506) CompileError!@field(std.builtin, @tagName(name)) {22505) CompileError!@field(std.builtin, @tagName(name)) {
22507 const ty = try sema.getBuiltinType(src, name);22506 const ty = try sema.getBuiltinType(src, name);
22508 const air_ref = try sema.resolveInst(zir_ref);22507 const air_ref = sema.resolveInst(zir_ref);
22509 const coerced = try sema.coerce(block, ty, air_ref, src);22508 const coerced = try sema.coerce(block, ty, air_ref, src);
22510 const val = try sema.resolveConstDefinedValue(block, src, coerced, reason);22509 const val = try sema.resolveConstDefinedValue(block, src, coerced, reason);
22511 return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name)));22510 return sema.interpretBuiltinType(block, src, val, @field(std.builtin, @tagName(name)));
...@@ -22552,7 +22551,7 @@ fn zirCmpxchg(...@@ -22552,7 +22551,7 @@ fn zirCmpxchg(
22552 const success_order_src = block.builtinCallArgSrc(extra.node, 4);22551 const success_order_src = block.builtinCallArgSrc(extra.node, 4);
22553 const failure_order_src = block.builtinCallArgSrc(extra.node, 5);22552 const failure_order_src = block.builtinCallArgSrc(extra.node, 5);
22554 // zig fmt: on22553 // zig fmt: on
22555 const expected_value = try sema.resolveInst(extra.expected_value);22554 const expected_value = sema.resolveInst(extra.expected_value);
22556 const elem_ty = sema.typeOf(expected_value);22555 const elem_ty = sema.typeOf(expected_value);
22557 if (elem_ty.zigTypeTag(zcu) == .float) {22556 if (elem_ty.zigTypeTag(zcu) == .float) {
22558 return sema.fail(22557 return sema.fail(
...@@ -22562,9 +22561,9 @@ fn zirCmpxchg(...@@ -22562,9 +22561,9 @@ fn zirCmpxchg(
22562 .{elem_ty.fmt(pt)},22561 .{elem_ty.fmt(pt)},
22563 );22562 );
22564 }22563 }
22565 const uncasted_ptr = try sema.resolveInst(extra.ptr);22564 const uncasted_ptr = sema.resolveInst(extra.ptr);
22566 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);22565 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
22567 const new_value = try sema.coerce(block, elem_ty, try sema.resolveInst(extra.new_value), new_value_src);22566 const new_value = try sema.coerce(block, elem_ty, sema.resolveInst(extra.new_value), new_value_src);
22568 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, .{ .simple = .atomic_order });22567 const success_order = try sema.resolveAtomicOrder(block, success_order_src, extra.success_order, .{ .simple = .atomic_order });
22569 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, .{ .simple = .atomic_order });22568 const failure_order = try sema.resolveAtomicOrder(block, failure_order_src, extra.failure_order, .{ .simple = .atomic_order });
2257022569
...@@ -22589,8 +22588,8 @@ fn zirCmpxchg(...@@ -22589,8 +22588,8 @@ fn zirCmpxchg(
22589 }22588 }
2259022589
22591 const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: {22590 const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: {
22592 if (try sema.resolveValue(expected_value)) |expected_val| {22591 if (sema.resolveValue(expected_value)) |expected_val| {
22593 if (try sema.resolveValue(new_value)) |new_val| {22592 if (sema.resolveValue(new_value)) |new_val| {
22594 if (expected_val.isUndef(zcu) or new_val.isUndef(zcu)) {22593 if (expected_val.isUndef(zcu) or new_val.isUndef(zcu)) {
22595 // TODO: this should probably cause the memory stored at the pointer22594 // TODO: this should probably cause the memory stored at the pointer
22596 // to become undef as well22595 // to become undef as well
...@@ -22642,7 +22641,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -22642,7 +22641,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
22642 else => return sema.fail(block, src, "expected array or vector type, found '{f}'", .{dest_ty.fmt(pt)}),22641 else => return sema.fail(block, src, "expected array or vector type, found '{f}'", .{dest_ty.fmt(pt)}),
22643 }22642 }
2264422643
22645 const operand = try sema.resolveInst(extra.rhs);22644 const operand = sema.resolveInst(extra.rhs);
22646 const scalar_ty = dest_ty.childType(zcu);22645 const scalar_ty = dest_ty.childType(zcu);
22647 const scalar = try sema.coerce(block, scalar_ty, operand, scalar_src);22646 const scalar = try sema.coerce(block, scalar_ty, operand, scalar_src);
2264822647
...@@ -22653,7 +22652,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I...@@ -22653,7 +22652,7 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
2265322652
22654 const maybe_sentinel = dest_ty.sentinel(zcu);22653 const maybe_sentinel = dest_ty.sentinel(zcu);
2265522654
22656 if (try sema.resolveValue(scalar)) |scalar_val| {22655 if (sema.resolveValue(scalar)) |scalar_val| {
22657 full: {22656 full: {
22658 if (dest_ty.zigTypeTag(zcu) == .vector) break :full;22657 if (dest_ty.zigTypeTag(zcu) == .vector) break :full;
22659 const sentinel = maybe_sentinel orelse break :full;22658 const sentinel = maybe_sentinel orelse break :full;
...@@ -22688,7 +22687,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -22688,7 +22687,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
22688 const op_src = block.builtinCallArgSrc(inst_data.src_node, 0);22687 const op_src = block.builtinCallArgSrc(inst_data.src_node, 0);
22689 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 1);22688 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 1);
22690 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation });22689 const operation = try sema.resolveBuiltinEnum(block, op_src, extra.lhs, .ReduceOp, .{ .simple = .operand_reduce_operation });
22691 const operand = try sema.resolveInst(extra.rhs);22690 const operand = sema.resolveInst(extra.rhs);
22692 const operand_ty = sema.typeOf(operand);22691 const operand_ty = sema.typeOf(operand);
22693 const pt = sema.pt;22692 const pt = sema.pt;
22694 const zcu = pt.zcu;22693 const zcu = pt.zcu;
...@@ -22722,7 +22721,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -22722,7 +22721,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
22722 return sema.fail(block, operand_src, "@reduce operation requires a vector with nonzero length", .{});22721 return sema.fail(block, operand_src, "@reduce operation requires a vector with nonzero length", .{});
22723 }22722 }
2272422723
22725 if (try sema.resolveValue(operand)) |operand_val| {22724 if (sema.resolveValue(operand)) |operand_val| {
22726 if (operand_val.isUndef(zcu)) return pt.undefRef(scalar_ty);22725 if (operand_val.isUndef(zcu)) return pt.undefRef(scalar_ty);
2272722726
22728 var accum: Value = try operand_val.elemValue(pt, 0);22727 var accum: Value = try operand_val.elemValue(pt, 0);
...@@ -22758,9 +22757,9 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -22758,9 +22757,9 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2275822757
22759 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);22758 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
22760 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);22759 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
22761 const a = try sema.resolveInst(extra.a);22760 const a = sema.resolveInst(extra.a);
22762 const b = try sema.resolveInst(extra.b);22761 const b = sema.resolveInst(extra.b);
22763 var mask = try sema.resolveInst(extra.mask);22762 var mask = sema.resolveInst(extra.mask);
22764 var mask_ty = sema.typeOf(mask);22763 var mask_ty = sema.typeOf(mask);
2276522764
22766 const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) {22765 const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) {
...@@ -22867,8 +22866,8 @@ fn analyzeShuffle(...@@ -22867,8 +22866,8 @@ fn analyzeShuffle(
22867 }22866 }
22868 }22867 }
2286922868
22870 const maybe_a_val = try sema.resolveValue(a_coerced);22869 const maybe_a_val = sema.resolveValue(a_coerced);
22871 const maybe_b_val = try sema.resolveValue(b_coerced);22870 const maybe_b_val = sema.resolveValue(b_coerced);
2287222871
22873 const a_rt = a_used and maybe_a_val == null;22872 const a_rt = a_used and maybe_a_val == null;
22874 const b_rt = b_used and maybe_b_val == null;22873 const b_rt = b_used and maybe_b_val == null;
...@@ -22956,7 +22955,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C...@@ -22956,7 +22955,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
2295622955
22957 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);22956 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
22958 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);22957 try sema.checkVectorElemType(block, elem_ty_src, elem_ty);
22959 const pred_uncoerced = try sema.resolveInst(extra.pred);22958 const pred_uncoerced = sema.resolveInst(extra.pred);
22960 const pred_ty = sema.typeOf(pred_uncoerced);22959 const pred_ty = sema.typeOf(pred_uncoerced);
2296122960
22962 const vec_len_u64 = switch (pred_ty.zigTypeTag(zcu)) {22961 const vec_len_u64 = switch (pred_ty.zigTypeTag(zcu)) {
...@@ -22975,12 +22974,12 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C...@@ -22975,12 +22974,12 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
22975 .len = vec_len,22974 .len = vec_len,
22976 .child = elem_ty.toIntern(),22975 .child = elem_ty.toIntern(),
22977 });22976 });
22978 const a = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.a), a_src);22977 const a = try sema.coerce(block, vec_ty, sema.resolveInst(extra.a), a_src);
22979 const b = try sema.coerce(block, vec_ty, try sema.resolveInst(extra.b), b_src);22978 const b = try sema.coerce(block, vec_ty, sema.resolveInst(extra.b), b_src);
2298022979
22981 const maybe_pred = try sema.resolveValue(pred);22980 const maybe_pred = sema.resolveValue(pred);
22982 const maybe_a = try sema.resolveValue(a);22981 const maybe_a = sema.resolveValue(a);
22983 const maybe_b = try sema.resolveValue(b);22982 const maybe_b = sema.resolveValue(b);
2298422983
22985 const runtime_src = if (maybe_pred) |pred_val| rs: {22984 const runtime_src = if (maybe_pred) |pred_val| rs: {
22986 if (pred_val.isUndef(zcu)) return pt.undefRef(vec_ty);22985 if (pred_val.isUndef(zcu)) return pt.undefRef(vec_ty);
...@@ -23041,7 +23040,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -23041,7 +23040,7 @@ fn zirAtomicLoad(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
23041 const order_src = block.builtinCallArgSrc(inst_data.src_node, 2);23040 const order_src = block.builtinCallArgSrc(inst_data.src_node, 2);
23042 // zig fmt: on23041 // zig fmt: on
23043 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);23042 const elem_ty = try sema.resolveType(block, elem_ty_src, extra.elem_type);
23044 const uncasted_ptr = try sema.resolveInst(extra.ptr);23043 const uncasted_ptr = sema.resolveInst(extra.ptr);
23045 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true);23044 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, true);
23046 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, .{ .simple = .atomic_order });23045 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, .{ .simple = .atomic_order });
2304723046
...@@ -23090,9 +23089,9 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -23090,9 +23089,9 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
23090 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 3);23089 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 3);
23091 const order_src = block.builtinCallArgSrc(inst_data.src_node, 4);23090 const order_src = block.builtinCallArgSrc(inst_data.src_node, 4);
23092 // zig fmt: on23091 // zig fmt: on
23093 const operand = try sema.resolveInst(extra.operand);23092 const operand = sema.resolveInst(extra.operand);
23094 const elem_ty = sema.typeOf(operand);23093 const elem_ty = sema.typeOf(operand);
23095 const uncasted_ptr = try sema.resolveInst(extra.ptr);23094 const uncasted_ptr = sema.resolveInst(extra.ptr);
23096 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);23095 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
23097 const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation);23096 const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation);
2309823097
...@@ -23119,7 +23118,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -23119,7 +23118,7 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
23119 if (try elem_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);23118 if (try elem_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);
2312023119
23121 const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: {23120 const runtime_src = if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| rs: {
23122 const maybe_operand_val = try sema.resolveValue(operand);23121 const maybe_operand_val = sema.resolveValue(operand);
23123 const operand_val = maybe_operand_val orelse {23122 const operand_val = maybe_operand_val orelse {
23124 try sema.checkPtrIsNotComptimeMutable(block, ptr_val, ptr_src, operand_src);23123 try sema.checkPtrIsNotComptimeMutable(block, ptr_val, ptr_src, operand_src);
23125 break :rs operand_src;23124 break :rs operand_src;
...@@ -23170,9 +23169,9 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -23170,9 +23169,9 @@ fn zirAtomicStore(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
23170 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 2);23169 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 2);
23171 const order_src = block.builtinCallArgSrc(inst_data.src_node, 3);23170 const order_src = block.builtinCallArgSrc(inst_data.src_node, 3);
23172 // zig fmt: on23171 // zig fmt: on
23173 const operand = try sema.resolveInst(extra.operand);23172 const operand = sema.resolveInst(extra.operand);
23174 const elem_ty = sema.typeOf(operand);23173 const elem_ty = sema.typeOf(operand);
23175 const uncasted_ptr = try sema.resolveInst(extra.ptr);23174 const uncasted_ptr = sema.resolveInst(extra.ptr);
23176 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);23175 const ptr = try sema.checkAtomicPtrOperand(block, elem_ty, elem_ty_src, uncasted_ptr, ptr_src, false);
23177 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, .{ .simple = .atomic_order });23176 const order = try sema.resolveAtomicOrder(block, order_src, extra.ordering, .{ .simple = .atomic_order });
2317823177
...@@ -23203,14 +23202,14 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -23203,14 +23202,14 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
23203 const mulend2_src = block.builtinCallArgSrc(inst_data.src_node, 2);23202 const mulend2_src = block.builtinCallArgSrc(inst_data.src_node, 2);
23204 const addend_src = block.builtinCallArgSrc(inst_data.src_node, 3);23203 const addend_src = block.builtinCallArgSrc(inst_data.src_node, 3);
2320523204
23206 const addend = try sema.resolveInst(extra.addend);23205 const addend = sema.resolveInst(extra.addend);
23207 const ty = sema.typeOf(addend);23206 const ty = sema.typeOf(addend);
23208 const mulend1 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend1), mulend1_src);23207 const mulend1 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend1), mulend1_src);
23209 const mulend2 = try sema.coerce(block, ty, try sema.resolveInst(extra.mulend2), mulend2_src);23208 const mulend2 = try sema.coerce(block, ty, sema.resolveInst(extra.mulend2), mulend2_src);
2321023209
23211 const maybe_mulend1 = try sema.resolveValue(mulend1);23210 const maybe_mulend1 = sema.resolveValue(mulend1);
23212 const maybe_mulend2 = try sema.resolveValue(mulend2);23211 const maybe_mulend2 = sema.resolveValue(mulend2);
23213 const maybe_addend = try sema.resolveValue(addend);23212 const maybe_addend = sema.resolveValue(addend);
23214 const pt = sema.pt;23213 const pt = sema.pt;
23215 const zcu = pt.zcu;23214 const zcu = pt.zcu;
2321623215
...@@ -23272,10 +23271,10 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -23272,10 +23271,10 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
23272 const call_src = block.nodeOffset(inst_data.src_node);23271 const call_src = block.nodeOffset(inst_data.src_node);
2327323272
23274 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;23273 const extra = sema.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data;
23275 const func = try sema.resolveInst(extra.callee);23274 const func = sema.resolveInst(extra.callee);
2327623275
23277 const modifier_ty = try sema.getBuiltinType(call_src, .CallModifier);23276 const modifier_ty = try sema.getBuiltinType(call_src, .CallModifier);
23278 const air_ref = try sema.resolveInst(extra.modifier);23277 const air_ref = sema.resolveInst(extra.modifier);
23279 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);23278 const modifier_ref = try sema.coerce(block, modifier_ty, air_ref, modifier_src);
23280 const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier });23279 const modifier_val = try sema.resolveConstDefinedValue(block, modifier_src, modifier_ref, .{ .simple = .call_modifier });
23281 var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier);23280 var modifier = try sema.interpretBuiltinType(block, modifier_src, modifier_val, std.builtin.CallModifier);
...@@ -23313,7 +23312,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -23313,7 +23312,7 @@ fn zirBuiltinCall(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
23313 },23312 },
23314 }23313 }
2331523314
23316 const args = try sema.resolveInst(extra.args);23315 const args = sema.resolveInst(extra.args);
2331723316
23318 const args_ty = sema.typeOf(args);23317 const args_ty = sema.typeOf(args);
23319 if (!args_ty.isTuple(zcu)) {23318 if (!args_ty.isTuple(zcu)) {
...@@ -23390,7 +23389,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -23390,7 +23389,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
23390 return sema.fail(block, field_name_src, "cannot get @fieldParentPtr of a comptime field", .{});23389 return sema.fail(block, field_name_src, "cannot get @fieldParentPtr of a comptime field", .{});
23391 }23390 }
2339223391
23393 const field_ptr = try sema.resolveInst(extra.field_ptr);23392 const field_ptr = sema.resolveInst(extra.field_ptr);
23394 const field_ptr_ty = sema.typeOf(field_ptr);23393 const field_ptr_ty = sema.typeOf(field_ptr);
23395 try sema.checkPtrOperand(block, field_ptr_src, field_ptr_ty);23394 try sema.checkPtrOperand(block, field_ptr_src, field_ptr_ty);
23396 const field_ptr_info = field_ptr_ty.ptrInfo(zcu);23395 const field_ptr_info = field_ptr_ty.ptrInfo(zcu);
...@@ -23555,8 +23554,8 @@ fn zirMinMax(...@@ -23555,8 +23554,8 @@ fn zirMinMax(
23555 const src = block.nodeOffset(inst_data.src_node);23554 const src = block.nodeOffset(inst_data.src_node);
23556 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);23555 const lhs_src = block.builtinCallArgSrc(inst_data.src_node, 0);
23557 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);23556 const rhs_src = block.builtinCallArgSrc(inst_data.src_node, 1);
23558 const lhs = try sema.resolveInst(extra.lhs);23557 const lhs = sema.resolveInst(extra.lhs);
23559 const rhs = try sema.resolveInst(extra.rhs);23558 const rhs = sema.resolveInst(extra.rhs);
23560 return sema.analyzeMinMax(block, src, air_tag, &.{ lhs, rhs }, &.{ lhs_src, rhs_src });23559 return sema.analyzeMinMax(block, src, air_tag, &.{ lhs, rhs }, &.{ lhs_src, rhs_src });
23561}23560}
2356223561
...@@ -23576,7 +23575,7 @@ fn zirMinMaxMulti(...@@ -23576,7 +23575,7 @@ fn zirMinMaxMulti(
2357623575
23577 for (operands, air_refs, operand_srcs, 0..) |zir_ref, *air_ref, *op_src, i| {23576 for (operands, air_refs, operand_srcs, 0..) |zir_ref, *air_ref, *op_src, i| {
23578 op_src.* = block.builtinCallArgSrc(src_node, @intCast(i));23577 op_src.* = block.builtinCallArgSrc(src_node, @intCast(i));
23579 air_ref.* = try sema.resolveInst(zir_ref);23578 air_ref.* = sema.resolveInst(zir_ref);
23580 }23579 }
2358123580
23582 return sema.analyzeMinMax(block, src, air_tag, air_refs, operand_srcs);23581 return sema.analyzeMinMax(block, src, air_tag, air_refs, operand_srcs);
...@@ -23679,7 +23678,7 @@ fn analyzeMinMax(...@@ -23679,7 +23678,7 @@ fn analyzeMinMax(
23679 const operand_scalar_ty = sema.typeOf(operand).scalarType(zcu);23678 const operand_scalar_ty = sema.typeOf(operand).scalarType(zcu);
23680 const want_strat: TypeStrat = switch (operand_scalar_ty.zigTypeTag(zcu)) {23679 const want_strat: TypeStrat = switch (operand_scalar_ty.zigTypeTag(zcu)) {
23681 .comptime_int => s: {23680 .comptime_int => s: {
23682 const val = (try sema.resolveValue(operand)).?;23681 const val = sema.resolveValue(operand).?;
23683 if (val.isUndef(zcu)) break :s .none;23682 if (val.isUndef(zcu)) break :s .none;
23684 break :s .{ .int = .{23683 break :s .{ .int = .{
23685 .all_comptime_int = true,23684 .all_comptime_int = true,
...@@ -23698,7 +23697,7 @@ fn analyzeMinMax(...@@ -23698,7 +23697,7 @@ fn analyzeMinMax(
23698 // (replaced with just the simple calls to `Type.minInt`/`Type.maxInt`) so that we only23697 // (replaced with just the simple calls to `Type.minInt`/`Type.maxInt`) so that we only
23699 // use the input *types* to determine the result type.23698 // use the input *types* to determine the result type.
23700 const min: Value, const max: Value = bounds: {23699 const min: Value, const max: Value = bounds: {
23701 if (try sema.resolveValue(operand)) |operand_val| {23700 if (sema.resolveValue(operand)) |operand_val| {
23702 if (vector_len) |len| {23701 if (vector_len) |len| {
23703 var min = try operand_val.elemValue(pt, 0);23702 var min = try operand_val.elemValue(pt, 0);
23704 var max = min;23703 var max = min;
...@@ -23804,7 +23803,7 @@ fn analyzeMinMax(...@@ -23804,7 +23803,7 @@ fn analyzeMinMax(
23804 var opt_runtime_src: ?LazySrcLoc = null;23803 var opt_runtime_src: ?LazySrcLoc = null;
2380523804
23806 for (operands, operand_srcs) |operand, operand_src| {23805 for (operands, operand_srcs) |operand, operand_src| {
23807 const operand_val = try sema.resolveValue(operand) orelse {23806 const operand_val = sema.resolveValue(operand) orelse {
23808 if (opt_runtime_src == null) opt_runtime_src = operand_src;23807 if (opt_runtime_src == null) opt_runtime_src = operand_src;
23809 continue;23808 continue;
23810 };23809 };
...@@ -23944,8 +23943,8 @@ fn zirMemcpy(...@@ -23944,8 +23943,8 @@ fn zirMemcpy(
23944 const src = block.nodeOffset(inst_data.src_node);23943 const src = block.nodeOffset(inst_data.src_node);
23945 const dest_src = block.builtinCallArgSrc(inst_data.src_node, 0);23944 const dest_src = block.builtinCallArgSrc(inst_data.src_node, 0);
23946 const src_src = block.builtinCallArgSrc(inst_data.src_node, 1);23945 const src_src = block.builtinCallArgSrc(inst_data.src_node, 1);
23947 const dest_ptr = try sema.resolveInst(extra.lhs);23946 const dest_ptr = sema.resolveInst(extra.lhs);
23948 const src_ptr = try sema.resolveInst(extra.rhs);23947 const src_ptr = sema.resolveInst(extra.rhs);
23949 const dest_ty = sema.typeOf(dest_ptr);23948 const dest_ty = sema.typeOf(dest_ptr);
23950 const src_ty = sema.typeOf(src_ptr);23949 const src_ty = sema.typeOf(src_ptr);
23951 const dest_len = try indexablePtrLenOrNone(sema, block, dest_src, dest_ptr);23950 const dest_len = try indexablePtrLenOrNone(sema, block, dest_src, dest_ptr);
...@@ -24208,8 +24207,8 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -24208,8 +24207,8 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
24208 const src = block.nodeOffset(inst_data.src_node);24207 const src = block.nodeOffset(inst_data.src_node);
24209 const dest_src = block.builtinCallArgSrc(inst_data.src_node, 0);24208 const dest_src = block.builtinCallArgSrc(inst_data.src_node, 0);
24210 const value_src = block.builtinCallArgSrc(inst_data.src_node, 1);24209 const value_src = block.builtinCallArgSrc(inst_data.src_node, 1);
24211 const dest_ptr = try sema.resolveInst(extra.lhs);24210 const dest_ptr = sema.resolveInst(extra.lhs);
24212 const uncoerced_elem = try sema.resolveInst(extra.rhs);24211 const uncoerced_elem = sema.resolveInst(extra.rhs);
24213 const dest_ptr_ty = sema.typeOf(dest_ptr);24212 const dest_ptr_ty = sema.typeOf(dest_ptr);
24214 try checkMemOperand(sema, block, dest_src, dest_ptr_ty);24213 try checkMemOperand(sema, block, dest_src, dest_ptr_ty);
2421524214
...@@ -24252,7 +24251,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -24252,7 +24251,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
2425224251
24253 const ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr) orelse break :rs dest_src;24252 const ptr_val = try sema.resolveDefinedValue(block, dest_src, dest_ptr) orelse break :rs dest_src;
24254 if (!sema.isComptimeMutablePtr(ptr_val)) break :rs dest_src;24253 if (!sema.isComptimeMutablePtr(ptr_val)) break :rs dest_src;
24255 const elem_val = try sema.resolveValue(elem) orelse break :rs value_src;24254 const elem_val = sema.resolveValue(elem) orelse break :rs value_src;
24256 const array_ty = try pt.arrayType(.{24255 const array_ty = try pt.arrayType(.{
24257 .child = dest_elem_ty.toIntern(),24256 .child = dest_elem_ty.toIntern(),
24258 .len = len_u64,24257 .len = len_u64,
...@@ -24322,7 +24321,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -24322,7 +24321,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
24322 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);24321 const cc_ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_index]);
24323 extra_index += 1;24322 extra_index += 1;
24324 const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention);24323 const cc_ty = try sema.getBuiltinType(cc_src, .CallingConvention);
24325 const uncoerced_cc = try sema.resolveInst(cc_ref);24324 const uncoerced_cc = sema.resolveInst(cc_ref);
24326 const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src);24325 const coerced_cc = try sema.coerce(block, cc_ty, uncoerced_cc, cc_src);
24327 const cc_val = try sema.resolveConstDefinedValue(block, cc_src, coerced_cc, .{ .simple = .@"callconv" });24326 const cc_val = try sema.resolveConstDefinedValue(block, cc_src, coerced_cc, .{ .simple = .@"callconv" });
24328 break :blk try sema.analyzeValueAsCallconv(block, cc_src, cc_val);24327 break :blk try sema.analyzeValueAsCallconv(block, cc_src, cc_val);
...@@ -24439,7 +24438,7 @@ fn zirCDefine(...@@ -24439,7 +24438,7 @@ fn zirCDefine(
24439 const val_src = block.builtinCallArgSrc(extra.node, 1);24438 const val_src = block.builtinCallArgSrc(extra.node, 1);
2444024439
24441 const name = try sema.resolveConstString(block, name_src, extra.lhs, .{ .simple = .operand_cDefine_macro_name });24440 const name = try sema.resolveConstString(block, name_src, extra.lhs, .{ .simple = .operand_cDefine_macro_name });
24442 const rhs = try sema.resolveInst(extra.rhs);24441 const rhs = sema.resolveInst(extra.rhs);
24443 if (sema.typeOf(rhs).zigTypeTag(zcu) != .void) {24442 if (sema.typeOf(rhs).zigTypeTag(zcu) != .void) {
24444 const value = try sema.resolveConstString(block, val_src, extra.rhs, .{ .simple = .operand_cDefine_macro_value });24443 const value = try sema.resolveConstString(block, val_src, extra.rhs, .{ .simple = .operand_cDefine_macro_value });
24445 try block.c_import_buf.?.print("#define {s} {s}\n", .{ name, value });24444 try block.c_import_buf.?.print("#define {s} {s}\n", .{ name, value });
...@@ -24488,7 +24487,7 @@ fn zirWasmMemoryGrow(...@@ -24488,7 +24487,7 @@ fn zirWasmMemoryGrow(
24488 }24487 }
2448924488
24490 const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, .u32, .{ .simple = .wasm_memory_index }));24489 const index: u32 = @intCast(try sema.resolveInt(block, index_src, extra.lhs, .u32, .{ .simple = .wasm_memory_index }));
24491 const delta = try sema.coerce(block, .usize, try sema.resolveInst(extra.rhs), delta_src);24490 const delta = try sema.coerce(block, .usize, sema.resolveInst(extra.rhs), delta_src);
2449224491
24493 try sema.requireRuntimeBlock(block, builtin_src, null);24492 try sema.requireRuntimeBlock(block, builtin_src, null);
24494 return block.addInst(.{24493 return block.addInst(.{
...@@ -24514,7 +24513,7 @@ fn resolvePrefetchOptions(...@@ -24514,7 +24513,7 @@ fn resolvePrefetchOptions(
24514 const ip = &zcu.intern_pool;24513 const ip = &zcu.intern_pool;
2451524514
24516 const options_ty = try sema.getBuiltinType(src, .PrefetchOptions);24515 const options_ty = try sema.getBuiltinType(src, .PrefetchOptions);
24517 const options = try sema.coerce(block, options_ty, try sema.resolveInst(zir_ref), src);24516 const options = try sema.coerce(block, options_ty, sema.resolveInst(zir_ref), src);
2451824517
24519 const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node });24518 const rw_src = block.src(.{ .init_field_rw = src.offset.node_offset_builtin_call_arg.builtin_call_node });
24520 const locality_src = block.src(.{ .init_field_locality = src.offset.node_offset_builtin_call_arg.builtin_call_node });24519 const locality_src = block.src(.{ .init_field_locality = src.offset.node_offset_builtin_call_arg.builtin_call_node });
...@@ -24544,7 +24543,7 @@ fn zirPrefetch(...@@ -24544,7 +24543,7 @@ fn zirPrefetch(
24544 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;24543 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
24545 const ptr_src = block.builtinCallArgSrc(extra.node, 0);24544 const ptr_src = block.builtinCallArgSrc(extra.node, 0);
24546 const opts_src = block.builtinCallArgSrc(extra.node, 1);24545 const opts_src = block.builtinCallArgSrc(extra.node, 1);
24547 const ptr = try sema.resolveInst(extra.lhs);24546 const ptr = sema.resolveInst(extra.lhs);
24548 try sema.checkPtrOperand(block, ptr_src, sema.typeOf(ptr));24547 try sema.checkPtrOperand(block, ptr_src, sema.typeOf(ptr));
2454924548
24550 const options = try sema.resolvePrefetchOptions(block, opts_src, extra.rhs);24549 const options = try sema.resolvePrefetchOptions(block, opts_src, extra.rhs);
...@@ -24586,7 +24585,7 @@ fn resolveExternOptions(...@@ -24586,7 +24585,7 @@ fn resolveExternOptions(
24586 const io = comp.io;24585 const io = comp.io;
24587 const ip = &zcu.intern_pool;24586 const ip = &zcu.intern_pool;
2458824587
24589 const options_inst = try sema.resolveInst(zir_ref);24588 const options_inst = sema.resolveInst(zir_ref);
24590 const extern_options_ty = try sema.getBuiltinType(src, .ExternOptions);24589 const extern_options_ty = try sema.getBuiltinType(src, .ExternOptions);
24591 const options = try sema.coerce(block, extern_options_ty, options_inst, src);24590 const options = try sema.coerce(block, extern_options_ty, options_inst, src);
2459224591
...@@ -24738,7 +24737,7 @@ fn zirBuiltinExtern(...@@ -24738,7 +24737,7 @@ fn zirBuiltinExtern(
2473824737
24739 const uncasted_ptr = try sema.analyzeNavRef(block, src, ip.indexToKey(extern_val).@"extern".owner_nav);24738 const uncasted_ptr = try sema.analyzeNavRef(block, src, ip.indexToKey(extern_val).@"extern".owner_nav);
24740 // We want to cast to `ty`, but that isn't necessarily an allowed coercion.24739 // We want to cast to `ty`, but that isn't necessarily an allowed coercion.
24741 if (try sema.resolveValue(uncasted_ptr)) |uncasted_ptr_val| {24740 if (sema.resolveValue(uncasted_ptr)) |uncasted_ptr_val| {
24742 const casted_ptr_val = try pt.getCoerced(uncasted_ptr_val, ty);24741 const casted_ptr_val = try pt.getCoerced(uncasted_ptr_val, ty);
24743 return Air.internedToRef(casted_ptr_val.toIntern());24742 return Air.internedToRef(casted_ptr_val.toIntern());
24744 } else {24743 } else {
...@@ -24854,7 +24853,7 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co...@@ -24854,7 +24853,7 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
24854 const pt = sema.pt;24853 const pt = sema.pt;
24855 const zcu = pt.zcu;24854 const zcu = pt.zcu;
2485624855
24857 const lhs = try sema.resolveInst(@enumFromInt(extended.operand));24856 const lhs = sema.resolveInst(@enumFromInt(extended.operand));
24858 const lhs_ty = sema.typeOf(lhs);24857 const lhs_ty = sema.typeOf(lhs);
2485924858
24860 const op: Zir.Inst.InplaceOp = @enumFromInt(extended.small);24859 const op: Zir.Inst.InplaceOp = @enumFromInt(extended.small);
...@@ -24879,7 +24878,7 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co...@@ -24879,7 +24878,7 @@ fn zirInplaceArithResultTy(sema: *Sema, extended: Zir.Inst.Extended.InstData) Co
2487924878
24880fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {24879fn zirBranchHint(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!void {
24881 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;24880 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
24882 const uncoerced_hint = try sema.resolveInst(extra.operand);24881 const uncoerced_hint = sema.resolveInst(extra.operand);
24883 const operand_src = block.builtinCallArgSrc(extra.node, 0);24882 const operand_src = block.builtinCallArgSrc(extra.node, 0);
2488424883
24885 const hint_ty = try sema.getBuiltinType(operand_src, .BranchHint);24884 const hint_ty = try sema.getBuiltinType(operand_src, .BranchHint);
...@@ -26333,7 +26332,7 @@ fn structFieldVal(...@@ -26333,7 +26332,7 @@ fn structFieldVal(
26333 if (try field_ty.onePossibleValue(pt)) |field_val|26332 if (try field_ty.onePossibleValue(pt)) |field_val|
26334 return .fromValue(field_val);26333 return .fromValue(field_val);
2633526334
26336 if (try sema.resolveValue(struct_byval)) |struct_val| {26335 if (sema.resolveValue(struct_byval)) |struct_val| {
26337 if (struct_val.isUndef(zcu)) return pt.undefRef(field_ty);26336 if (struct_val.isUndef(zcu)) return pt.undefRef(field_ty);
26338 return .fromValue(try struct_val.fieldValue(pt, field_index));26337 return .fromValue(try struct_val.fieldValue(pt, field_index));
26339 }26338 }
...@@ -26404,7 +26403,7 @@ fn tupleFieldValByIndex(...@@ -26404,7 +26403,7 @@ fn tupleFieldValByIndex(
2640426403
26405 if (try field_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);26404 if (try field_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);
2640626405
26407 if (try sema.resolveValue(tuple_byval)) |tuple_val| {26406 if (sema.resolveValue(tuple_byval)) |tuple_val| {
26408 return switch (zcu.intern_pool.indexToKey(tuple_val.toIntern())) {26407 return switch (zcu.intern_pool.indexToKey(tuple_val.toIntern())) {
26409 .undef => pt.undefRef(field_ty),26408 .undef => pt.undefRef(field_ty),
26410 .aggregate => |aggregate| Air.internedToRef(switch (aggregate.storage) {26409 .aggregate => |aggregate| Air.internedToRef(switch (aggregate.storage) {
...@@ -26564,7 +26563,7 @@ fn unionFieldVal(...@@ -26564,7 +26563,7 @@ fn unionFieldVal(
26564 const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]);26563 const field_ty: Type = .fromInterned(union_obj.field_types.get(ip)[field_index]);
26565 const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_type).enumFieldIndex(field_name, zcu).?);26564 const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_type).enumFieldIndex(field_name, zcu).?);
2656626565
26567 if (try sema.resolveValue(union_byval)) |union_val| {26566 if (sema.resolveValue(union_byval)) |union_val| {
26568 if (union_val.isUndef(zcu)) return pt.undefRef(field_ty);26567 if (union_val.isUndef(zcu)) return pt.undefRef(field_ty);
2656926568
26570 const un = ip.indexToKey(union_val.toIntern()).un;26569 const un = ip.indexToKey(union_val.toIntern()).un;
...@@ -26895,7 +26894,7 @@ fn tupleFieldPtr(...@@ -26895,7 +26894,7 @@ fn tupleFieldPtr(
26895 } })));26894 } })));
26896 }26895 }
2689726896
26898 if (try sema.resolveValue(tuple_ptr)) |tuple_ptr_val| {26897 if (sema.resolveValue(tuple_ptr)) |tuple_ptr_val| {
26899 const field_ptr_val = try tuple_ptr_val.ptrField(field_index, pt);26898 const field_ptr_val = try tuple_ptr_val.ptrField(field_index, pt);
26900 return Air.internedToRef(field_ptr_val.toIntern());26899 return Air.internedToRef(field_ptr_val.toIntern());
26901 }26900 }
...@@ -26936,7 +26935,7 @@ fn tupleField(...@@ -26936,7 +26935,7 @@ fn tupleField(
26936 return Air.internedToRef(default_value.toIntern()); // comptime field26935 return Air.internedToRef(default_value.toIntern()); // comptime field
26937 }26936 }
2693826937
26939 if (try sema.resolveValue(tuple)) |tuple_val| {26938 if (sema.resolveValue(tuple)) |tuple_val| {
26940 if (tuple_val.isUndef(zcu)) return pt.undefRef(field_ty);26939 if (tuple_val.isUndef(zcu)) return pt.undefRef(field_ty);
26941 return Air.internedToRef((try tuple_val.fieldValue(pt, field_index)).toIntern());26940 return Air.internedToRef((try tuple_val.fieldValue(pt, field_index)).toIntern());
26942 }26941 }
...@@ -26968,7 +26967,7 @@ fn elemValArray(...@@ -26968,7 +26967,7 @@ fn elemValArray(
26968 return sema.fail(block, array_src, "indexing into empty array is not allowed", .{});26967 return sema.fail(block, array_src, "indexing into empty array is not allowed", .{});
26969 }26968 }
2697026969
26971 const maybe_undef_array_val = try sema.resolveValue(array);26970 const maybe_undef_array_val = sema.resolveValue(array);
26972 // index must be defined since it can access out of bounds26971 // index must be defined since it can access out of bounds
26973 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);26972 const maybe_index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index);
2697426973
...@@ -27035,7 +27034,7 @@ fn elemPtrArray(...@@ -27035,7 +27034,7 @@ fn elemPtrArray(
27035 return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{});27034 return sema.fail(block, array_ptr_src, "indexing into empty array is not allowed", .{});
27036 }27035 }
2703727036
27038 const maybe_undef_array_ptr_val = try sema.resolveValue(array_ptr);27037 const maybe_undef_array_ptr_val = sema.resolveValue(array_ptr);
27039 // The index must not be undefined since it can be out of bounds.27038 // The index must not be undefined since it can be out of bounds.
27040 const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: {27039 const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: {
27041 const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(zcu));27040 const index = try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(zcu));
...@@ -27159,7 +27158,7 @@ fn elemPtrSlice(...@@ -27159,7 +27158,7 @@ fn elemPtrSlice(
2715927158
27160 slice_ty.childType(zcu).assertHasLayout(zcu);27159 slice_ty.childType(zcu).assertHasLayout(zcu);
2716127160
27162 const maybe_undef_slice_val = try sema.resolveValue(slice);27161 const maybe_undef_slice_val = sema.resolveValue(slice);
27163 // The index must not be undefined since it can be out of bounds.27162 // The index must not be undefined since it can be out of bounds.
27164 const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: {27163 const offset: ?usize = if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| o: {
27165 break :o try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(zcu));27164 break :o try sema.usizeCast(block, elem_index_src, index_val.toUnsignedInt(zcu));
...@@ -27280,7 +27279,7 @@ fn coerceExtra(...@@ -27280,7 +27279,7 @@ fn coerceExtra(
27280 if (dest_ty.eql(inst_ty, zcu))27279 if (dest_ty.eql(inst_ty, zcu))
27281 return inst;27280 return inst;
2728227281
27283 const maybe_inst_val = try sema.resolveValue(inst);27282 const maybe_inst_val = sema.resolveValue(inst);
2728427283
27285 var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, maybe_inst_val);27284 var in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, maybe_inst_val);
27286 if (in_memory_result == .ok) {27285 if (in_memory_result == .ok) {
...@@ -29104,7 +29103,7 @@ fn storePtr2(...@@ -29104,7 +29103,7 @@ fn storePtr2(
29104 error.NotCoercible => unreachable,29103 error.NotCoercible => unreachable,
29105 else => |e| return e,29104 else => |e| return e,
29106 };29105 };
29107 const maybe_operand_val = try sema.resolveValue(operand);29106 const maybe_operand_val = sema.resolveValue(operand);
2910829107
29109 const runtime_src = rs: {29108 const runtime_src = rs: {
29110 const ptr_val = try sema.resolveDefinedValue(block, ptr_src, ptr) orelse break :rs ptr_src;29109 const ptr_val = try sema.resolveDefinedValue(block, ptr_src, ptr) orelse break :rs ptr_src;
...@@ -29157,7 +29156,7 @@ fn checkComptimeKnownStore(sema: *Sema, block: *Block, store_inst_ref: Air.Inst....@@ -29157,7 +29156,7 @@ fn checkComptimeKnownStore(sema: *Sema, block: *Block, store_inst_ref: Air.Inst.
29157 const maybe_base_alloc = sema.base_allocs.get(ptr) orelse break :known;29156 const maybe_base_alloc = sema.base_allocs.get(ptr) orelse break :known;
29158 const maybe_comptime_alloc = sema.maybe_comptime_allocs.getPtr(maybe_base_alloc) orelse break :known;29157 const maybe_comptime_alloc = sema.maybe_comptime_allocs.getPtr(maybe_base_alloc) orelse break :known;
2915929158
29160 if ((try sema.resolveValue(operand)) != null and29159 if (sema.resolveValue(operand) != null and
29161 block.runtime_index == maybe_comptime_alloc.runtime_index)29160 block.runtime_index == maybe_comptime_alloc.runtime_index)
29162 {29161 {
29163 try maybe_comptime_alloc.stores.append(sema.arena, .{29162 try maybe_comptime_alloc.stores.append(sema.arena, .{
...@@ -29206,7 +29205,7 @@ fn checkKnownAllocPtr(sema: *Sema, block: *Block, base_ptr: Air.Inst.Ref, new_pt...@@ -29206,7 +29205,7 @@ fn checkKnownAllocPtr(sema: *Sema, block: *Block, base_ptr: Air.Inst.Ref, new_pt
2920629205
29207 // If the index value is runtime-known, this pointer is also runtime-known, so29206 // If the index value is runtime-known, this pointer is also runtime-known, so
29208 // we must in turn make the alloc value runtime-known.29207 // we must in turn make the alloc value runtime-known.
29209 if (null == try sema.resolveValue(index_ref)) {29208 if (null == sema.resolveValue(index_ref)) {
29210 try sema.markMaybeComptimeAllocRuntime(block, alloc_inst);29209 try sema.markMaybeComptimeAllocRuntime(block, alloc_inst);
29211 }29210 }
29212 },29211 },
...@@ -29312,7 +29311,7 @@ fn bitCast(...@@ -29312,7 +29311,7 @@ fn bitCast(
29312 });29311 });
29313 }29312 }
2931429313
29315 if (try sema.resolveValue(inst)) |val| {29314 if (sema.resolveValue(inst)) |val| {
29316 if (val.isUndef(zcu))29315 if (val.isUndef(zcu))
29317 return pt.undefRef(dest_ty);29316 return pt.undefRef(dest_ty);
29318 if (old_ty.zigTypeTag(zcu) == .error_set and dest_ty.zigTypeTag(zcu) == .error_set) {29317 if (old_ty.zigTypeTag(zcu) == .error_set and dest_ty.zigTypeTag(zcu) == .error_set) {
...@@ -29338,7 +29337,7 @@ fn coerceArrayPtrToSlice(...@@ -29338,7 +29337,7 @@ fn coerceArrayPtrToSlice(
29338) CompileError!Air.Inst.Ref {29337) CompileError!Air.Inst.Ref {
29339 const pt = sema.pt;29338 const pt = sema.pt;
29340 const zcu = pt.zcu;29339 const zcu = pt.zcu;
29341 if (try sema.resolveValue(inst)) |val| {29340 if (sema.resolveValue(inst)) |val| {
29342 const ptr_array_ty = sema.typeOf(inst);29341 const ptr_array_ty = sema.typeOf(inst);
29343 const array_ty = ptr_array_ty.childType(zcu);29342 const array_ty = ptr_array_ty.childType(zcu);
29344 const slice_ptr_ty = dest_ty.slicePtrFieldType(zcu);29343 const slice_ptr_ty = dest_ty.slicePtrFieldType(zcu);
...@@ -29433,7 +29432,7 @@ fn coerceCompatiblePtrs(...@@ -29433,7 +29432,7 @@ fn coerceCompatiblePtrs(
29433 const pt = sema.pt;29432 const pt = sema.pt;
29434 const zcu = pt.zcu;29433 const zcu = pt.zcu;
29435 const inst_ty = sema.typeOf(inst);29434 const inst_ty = sema.typeOf(inst);
29436 if (try sema.resolveValue(inst)) |val| {29435 if (sema.resolveValue(inst)) |val| {
29437 if (!val.isUndef(zcu) and val.isNull(zcu) and !dest_ty.isAllowzeroPtr(zcu)) {29436 if (!val.isUndef(zcu) and val.isNull(zcu) and !dest_ty.isAllowzeroPtr(zcu)) {
29438 return sema.fail(block, inst_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(pt)});29437 return sema.fail(block, inst_src, "null pointer casted to type '{f}'", .{dest_ty.fmt(pt)});
29439 }29438 }
...@@ -29611,7 +29610,7 @@ fn coerceArrayLike(...@@ -29611,7 +29610,7 @@ fn coerceArrayLike(
29611 // try coercion of the whole array29610 // try coercion of the whole array
29612 const in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, null);29611 const in_memory_result = try sema.coerceInMemoryAllowed(block, dest_ty, inst_ty, false, target, dest_ty_src, inst_src, null);
29613 if (in_memory_result == .ok) {29612 if (in_memory_result == .ok) {
29614 if (try sema.resolveValue(inst)) |inst_val| {29613 if (sema.resolveValue(inst)) |inst_val| {
29615 // These types share the same comptime value representation.29614 // These types share the same comptime value representation.
29616 return sema.coerceInMemory(inst_val, dest_ty);29615 return sema.coerceInMemory(inst_val, dest_ty);
29617 }29616 }
...@@ -29634,7 +29633,7 @@ fn coerceArrayLike(...@@ -29634,7 +29633,7 @@ fn coerceArrayLike(
29634 }29633 }
2963529634
29636 const dest_elem_ty = dest_ty.childType(zcu);29635 const dest_elem_ty = dest_ty.childType(zcu);
29637 if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and (try sema.resolveValue(inst)) == null) {29636 if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and sema.resolveValue(inst) == null) {
29638 const inst_elem_ty = inst_ty.childType(zcu);29637 const inst_elem_ty = inst_ty.childType(zcu);
29639 switch (dest_elem_ty.zigTypeTag(zcu)) {29638 switch (dest_elem_ty.zigTypeTag(zcu)) {
29640 .int => if (inst_elem_ty.isInt(zcu)) {29639 .int => if (inst_elem_ty.isInt(zcu)) {
...@@ -29674,7 +29673,7 @@ fn coerceArrayLike(...@@ -29674,7 +29673,7 @@ fn coerceArrayLike(
29674 const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src);29673 const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src);
29675 ref.* = coerced;29674 ref.* = coerced;
29676 if (runtime_src == null) {29675 if (runtime_src == null) {
29677 if (try sema.resolveValue(coerced)) |elem_val| {29676 if (sema.resolveValue(coerced)) |elem_val| {
29678 val.* = elem_val.toIntern();29677 val.* = elem_val.toIntern();
29679 } else {29678 } else {
29680 runtime_src = elem_src;29679 runtime_src = elem_src;
...@@ -29735,7 +29734,7 @@ fn coerceTupleToArray(...@@ -29735,7 +29734,7 @@ fn coerceTupleToArray(
29735 const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src);29734 const coerced = try sema.coerce(block, dest_elem_ty, elem_ref, elem_src);
29736 ref.* = coerced;29735 ref.* = coerced;
29737 if (runtime_src == null) {29736 if (runtime_src == null) {
29738 if (try sema.resolveValue(coerced)) |elem_val| {29737 if (sema.resolveValue(coerced)) |elem_val| {
29739 val.* = elem_val.toIntern();29738 val.* = elem_val.toIntern();
29740 } else {29739 } else {
29741 runtime_src = elem_src;29740 runtime_src = elem_src;
...@@ -29844,7 +29843,7 @@ fn coerceTupleToTuple(...@@ -29844,7 +29843,7 @@ fn coerceTupleToTuple(
29844 const coerced = try sema.coerce(block, .fromInterned(field_ty), elem_ref, field_src);29843 const coerced = try sema.coerce(block, .fromInterned(field_ty), elem_ref, field_src);
29845 field_refs[field_index] = coerced;29844 field_refs[field_index] = coerced;
29846 if (default_val != .none) {29845 if (default_val != .none) {
29847 const init_val = (try sema.resolveValue(coerced)) orelse {29846 const init_val = sema.resolveValue(coerced) orelse {
29848 return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field });29847 return sema.failWithNeededComptime(block, field_src, .{ .simple = .stored_to_comptime_field });
29849 };29848 };
2985029849
...@@ -29853,7 +29852,7 @@ fn coerceTupleToTuple(...@@ -29853,7 +29852,7 @@ fn coerceTupleToTuple(
29853 }29852 }
29854 }29853 }
29855 if (runtime_src == null) {29854 if (runtime_src == null) {
29856 if (try sema.resolveValue(coerced)) |field_val| {29855 if (sema.resolveValue(coerced)) |field_val| {
29857 field_vals[field_index] = field_val.toIntern();29856 field_vals[field_index] = field_val.toIntern();
29858 } else {29857 } else {
29859 runtime_src = field_src;29858 runtime_src = field_src;
...@@ -30125,7 +30124,7 @@ fn analyzeRef(...@@ -30125,7 +30124,7 @@ fn analyzeRef(
30125 const zcu = pt.zcu;30124 const zcu = pt.zcu;
30126 const operand_ty = sema.typeOf(operand);30125 const operand_ty = sema.typeOf(operand);
3012730126
30128 if (try sema.resolveValue(operand)) |val| {30127 if (sema.resolveValue(operand)) |val| {
30129 switch (zcu.intern_pool.indexToKey(val.toIntern())) {30128 switch (zcu.intern_pool.indexToKey(val.toIntern())) {
30130 .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav),30129 .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav),
30131 .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav),30130 .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav),
...@@ -30209,7 +30208,7 @@ fn analyzeSlicePtr(...@@ -30209,7 +30208,7 @@ fn analyzeSlicePtr(
30209 const pt = sema.pt;30208 const pt = sema.pt;
30210 const zcu = pt.zcu;30209 const zcu = pt.zcu;
30211 const result_ty = slice_ty.slicePtrFieldType(zcu);30210 const result_ty = slice_ty.slicePtrFieldType(zcu);
30212 if (try sema.resolveValue(slice)) |val| {30211 if (sema.resolveValue(slice)) |val| {
30213 if (val.isUndef(zcu)) return pt.undefRef(result_ty);30212 if (val.isUndef(zcu)) return pt.undefRef(result_ty);
30214 return Air.internedToRef(val.slicePtr(zcu).toIntern());30213 return Air.internedToRef(val.slicePtr(zcu).toIntern());
30215 }30214 }
...@@ -30229,7 +30228,7 @@ fn analyzeOptionalSlicePtr(...@@ -30229,7 +30228,7 @@ fn analyzeOptionalSlicePtr(
30229 const slice_ty = opt_slice_ty.optionalChild(zcu);30228 const slice_ty = opt_slice_ty.optionalChild(zcu);
30230 const result_ty = slice_ty.slicePtrFieldType(zcu);30229 const result_ty = slice_ty.slicePtrFieldType(zcu);
3023130230
30232 if (try sema.resolveValue(opt_slice)) |opt_val| {30231 if (sema.resolveValue(opt_slice)) |opt_val| {
30233 if (opt_val.isUndef(zcu)) return pt.undefRef(result_ty);30232 if (opt_val.isUndef(zcu)) return pt.undefRef(result_ty);
30234 const slice_ptr: InternPool.Index = if (opt_val.optionalValue(zcu)) |val|30233 const slice_ptr: InternPool.Index = if (opt_val.optionalValue(zcu)) |val|
30235 val.slicePtr(zcu).toIntern()30234 val.slicePtr(zcu).toIntern()
...@@ -30253,7 +30252,7 @@ fn analyzeSliceLen(...@@ -30253,7 +30252,7 @@ fn analyzeSliceLen(
30253) CompileError!Air.Inst.Ref {30252) CompileError!Air.Inst.Ref {
30254 const pt = sema.pt;30253 const pt = sema.pt;
30255 const zcu = pt.zcu;30254 const zcu = pt.zcu;
30256 if (try sema.resolveValue(slice_inst)) |slice_val| {30255 if (sema.resolveValue(slice_inst)) |slice_val| {
30257 if (slice_val.isUndef(zcu)) {30256 if (slice_val.isUndef(zcu)) {
30258 return .undef_usize;30257 return .undef_usize;
30259 }30258 }
...@@ -30272,7 +30271,7 @@ fn analyzeIsNull(...@@ -30272,7 +30271,7 @@ fn analyzeIsNull(
30272 const pt = sema.pt;30271 const pt = sema.pt;
30273 const zcu = pt.zcu;30272 const zcu = pt.zcu;
30274 const result_ty: Type = .bool;30273 const result_ty: Type = .bool;
30275 if (try sema.resolveValue(operand)) |opt_val| {30274 if (sema.resolveValue(operand)) |opt_val| {
30276 if (opt_val.isUndef(zcu)) {30275 if (opt_val.isUndef(zcu)) {
30277 return pt.undefRef(result_ty);30276 return pt.undefRef(result_ty);
30278 }30277 }
...@@ -30306,7 +30305,7 @@ fn resolvePtrIsNonErrVal(...@@ -30306,7 +30305,7 @@ fn resolvePtrIsNonErrVal(
30306 }30305 }
30307 assert(child_ty.zigTypeTag(zcu) == .error_union);30306 assert(child_ty.zigTypeTag(zcu) == .error_union);
3030830307
30309 if (try sema.resolveValue(operand)) |eu_ptr_val| {30308 if (sema.resolveValue(operand)) |eu_ptr_val| {
30310 if (eu_ptr_val.isUndef(zcu)) return .undef_bool;30309 if (eu_ptr_val.isUndef(zcu)) return .undef_bool;
30311 if (try sema.pointerDeref(block, src, eu_ptr_val, ptr_ty)) |err_union| {30310 if (try sema.pointerDeref(block, src, eu_ptr_val, ptr_ty)) |err_union| {
30312 if (err_union.isUndef(zcu)) return .undef_bool;30311 if (err_union.isUndef(zcu)) return .undef_bool;
...@@ -30329,7 +30328,7 @@ fn resolveIsNonErrVal(...@@ -30329,7 +30328,7 @@ fn resolveIsNonErrVal(
30329 }30328 }
30330 assert(sema.typeOf(operand).zigTypeTag(zcu) == .error_union);30329 assert(sema.typeOf(operand).zigTypeTag(zcu) == .error_union);
3033130330
30332 if (try sema.resolveValue(operand)) |err_union| {30331 if (sema.resolveValue(operand)) |err_union| {
30333 if (err_union.isUndef(zcu)) return .undef_bool;30332 if (err_union.isUndef(zcu)) return .undef_bool;
30334 return .makeBool(err_union.getErrorName(zcu) == .none);30333 return .makeBool(err_union.getErrorName(zcu) == .none);
30335 }30334 }
...@@ -30681,7 +30680,7 @@ fn analyzeSlice(...@@ -30681,7 +30680,7 @@ fn analyzeSlice(
30681 break :end try sema.coerce(block, .usize, uncasted_end, end_src);30680 break :end try sema.coerce(block, .usize, uncasted_end, end_src);
30682 } else try sema.coerce(block, .usize, uncasted_end_opt, end_src);30681 } else try sema.coerce(block, .usize, uncasted_end_opt, end_src);
30683 if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| {30682 if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| {
30684 if (try sema.resolveValue(ptr_or_slice)) |slice_val| {30683 if (sema.resolveValue(ptr_or_slice)) |slice_val| {
30685 if (slice_val.isUndef(zcu)) {30684 if (slice_val.isUndef(zcu)) {
30686 return sema.fail(block, src, "slice of undefined", .{});30685 return sema.fail(block, src, "slice of undefined", .{});
30687 }30686 }
...@@ -30803,7 +30802,7 @@ fn analyzeSlice(...@@ -30803,7 +30802,7 @@ fn analyzeSlice(
30803 );30802 );
30804 }30803 }
30805 checked_start_lte_end = true;30804 checked_start_lte_end = true;
30806 if (try sema.resolveValue(new_ptr)) |ptr_val| sentinel_check: {30805 if (sema.resolveValue(new_ptr)) |ptr_val| sentinel_check: {
30807 const expected_sentinel = sentinel orelse break :sentinel_check;30806 const expected_sentinel = sentinel orelse break :sentinel_check;
30808 const start_int = start_val.toUnsignedInt(zcu);30807 const start_int = start_val.toUnsignedInt(zcu);
30809 const end_int = end_val.toUnsignedInt(zcu);30808 const end_int = end_val.toUnsignedInt(zcu);
...@@ -30887,7 +30886,7 @@ fn analyzeSlice(...@@ -30887,7 +30886,7 @@ fn analyzeSlice(
30887 },30886 },
30888 });30887 });
3088930888
30890 const opt_new_ptr_val = try sema.resolveValue(new_ptr);30889 const opt_new_ptr_val = sema.resolveValue(new_ptr);
30891 const new_ptr_val = opt_new_ptr_val orelse {30890 const new_ptr_val = opt_new_ptr_val orelse {
30892 const result = try block.addBitCast(return_ty, new_ptr);30891 const result = try block.addBitCast(return_ty, new_ptr);
30893 if (block.wantSafety()) {30892 if (block.wantSafety()) {
...@@ -31034,8 +31033,8 @@ fn cmpNumeric(...@@ -31034,8 +31033,8 @@ fn cmpNumeric(
31034 else31033 else
31035 uncasted_rhs;31034 uncasted_rhs;
3103631035
31037 const maybe_lhs_val = try sema.resolveValue(lhs);31036 const maybe_lhs_val = sema.resolveValue(lhs);
31038 const maybe_rhs_val = try sema.resolveValue(rhs);31037 const maybe_rhs_val = sema.resolveValue(rhs);
3103931038
31040 // If the LHS is const, check if there is a guaranteed result which does not depend on ths RHS value.31039 // If the LHS is const, check if there is a guaranteed result which does not depend on ths RHS value.
31041 if (maybe_lhs_val) |lhs_val| {31040 if (maybe_lhs_val) |lhs_val| {
...@@ -31320,8 +31319,8 @@ fn cmpVector(...@@ -31320,8 +31319,8 @@ fn cmpVector(
31320 .child = .bool_type,31319 .child = .bool_type,
31321 });31320 });
3132231321
31323 const maybe_lhs_val = try sema.resolveValue(casted_lhs);31322 const maybe_lhs_val = sema.resolveValue(casted_lhs);
31324 const maybe_rhs_val = try sema.resolveValue(casted_rhs);31323 const maybe_rhs_val = sema.resolveValue(casted_rhs);
31325 if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(result_ty);31324 if (maybe_lhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(result_ty);
31326 if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(result_ty);31325 if (maybe_rhs_val) |v| if (v.isUndef(zcu)) return pt.undefRef(result_ty);
3132731326
...@@ -31343,7 +31342,7 @@ fn wrapOptional(...@@ -31343,7 +31342,7 @@ fn wrapOptional(
31343 inst: Air.Inst.Ref,31342 inst: Air.Inst.Ref,
31344 inst_src: LazySrcLoc,31343 inst_src: LazySrcLoc,
31345) !Air.Inst.Ref {31344) !Air.Inst.Ref {
31346 if (try sema.resolveValue(inst)) |val| {31345 if (sema.resolveValue(inst)) |val| {
31347 return Air.internedToRef((try sema.pt.intern(.{ .opt = .{31346 return Air.internedToRef((try sema.pt.intern(.{ .opt = .{
31348 .ty = dest_ty.toIntern(),31347 .ty = dest_ty.toIntern(),
31349 .val = val.toIntern(),31348 .val = val.toIntern(),
...@@ -31365,7 +31364,7 @@ fn wrapErrorUnionPayload(...@@ -31365,7 +31364,7 @@ fn wrapErrorUnionPayload(
31365 const zcu = pt.zcu;31364 const zcu = pt.zcu;
31366 const dest_payload_ty = dest_ty.errorUnionPayload(zcu);31365 const dest_payload_ty = dest_ty.errorUnionPayload(zcu);
31367 const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, .{ .report_err = false });31366 const coerced = try sema.coerceExtra(block, dest_payload_ty, inst, inst_src, .{ .report_err = false });
31368 if (try sema.resolveValue(coerced)) |val| {31367 if (sema.resolveValue(coerced)) |val| {
31369 return Air.internedToRef((try pt.intern(.{ .error_union = .{31368 return Air.internedToRef((try pt.intern(.{ .error_union = .{
31370 .ty = dest_ty.toIntern(),31369 .ty = dest_ty.toIntern(),
31371 .val = .{ .payload = val.toIntern() },31370 .val = .{ .payload = val.toIntern() },
...@@ -31387,7 +31386,7 @@ fn wrapErrorUnionSet(...@@ -31387,7 +31386,7 @@ fn wrapErrorUnionSet(
31387 const ip = &zcu.intern_pool;31386 const ip = &zcu.intern_pool;
31388 const inst_ty = sema.typeOf(inst);31387 const inst_ty = sema.typeOf(inst);
31389 const dest_err_set_ty = dest_ty.errorUnionSet(zcu);31388 const dest_err_set_ty = dest_ty.errorUnionSet(zcu);
31390 if (try sema.resolveValue(inst)) |val| {31389 if (sema.resolveValue(inst)) |val| {
31391 const expected_name = zcu.intern_pool.indexToKey(val.toIntern()).err.name;31390 const expected_name = zcu.intern_pool.indexToKey(val.toIntern()).err.name;
31392 switch (dest_err_set_ty.toIntern()) {31391 switch (dest_err_set_ty.toIntern()) {
31393 .anyerror_type => {},31392 .anyerror_type => {},
...@@ -31449,7 +31448,7 @@ fn unionToTag(...@@ -31449,7 +31448,7 @@ fn unionToTag(
31449 const pt = sema.pt;31448 const pt = sema.pt;
31450 const zcu = pt.zcu;31449 const zcu = pt.zcu;
31451 if (try enum_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);31450 if (try enum_ty.onePossibleValue(pt)) |opv| return .fromValue(opv);
31452 if (try sema.resolveValue(un)) |un_val| {31451 if (sema.resolveValue(un)) |un_val| {
31453 const tag_val = un_val.unionTag(zcu).?;31452 const tag_val = un_val.unionTag(zcu).?;
31454 if (tag_val.isUndef(zcu))31453 if (tag_val.isUndef(zcu))
31455 return try pt.undefRef(enum_ty);31454 return try pt.undefRef(enum_ty);
...@@ -31796,7 +31795,7 @@ fn resolvePeerTypes(...@@ -31796,7 +31795,7 @@ fn resolvePeerTypes(
3179631795
31797 for (instructions, peer_tys, peer_vals) |inst, *ty, *val| {31796 for (instructions, peer_tys, peer_vals) |inst, *ty, *val| {
31798 ty.* = sema.typeOf(inst);31797 ty.* = sema.typeOf(inst);
31799 val.* = try sema.resolveValue(inst);31798 val.* = sema.resolveValue(inst);
31800 }31799 }
3180131800
31802 switch (try sema.resolvePeerTypesInner(block, src, peer_tys, peer_vals)) {31801 switch (try sema.resolvePeerTypesInner(block, src, peer_tys, peer_vals)) {
...@@ -32863,7 +32862,7 @@ fn resolvePeerTypesInner(...@@ -32863,7 +32862,7 @@ fn resolvePeerTypesInner(
32863 },32862 },
32864 else => |e| return e,32863 else => |e| return e,
32865 };32864 };
32866 const coerced_val = (try sema.resolveValue(coerced_inst)) orelse continue;32865 const coerced_val = sema.resolveValue(coerced_inst) orelse continue;
32867 const existing = comptime_val orelse {32866 const existing = comptime_val orelse {
32868 comptime_val = coerced_val;32867 comptime_val = coerced_val;
32869 continue;32868 continue;
...@@ -33225,7 +33224,7 @@ fn isComptimeKnown(...@@ -33225,7 +33224,7 @@ fn isComptimeKnown(
33225 sema: *Sema,33224 sema: *Sema,
33226 inst: Air.Inst.Ref,33225 inst: Air.Inst.Ref,
33227) !bool {33226) !bool {
33228 return (try sema.resolveValue(inst)) != null;33227 return sema.resolveValue(inst) != null;
33229}33228}
3323033229
33231/// Asserts that the layout of `var_type` has already been resolved.33230/// Asserts that the layout of `var_type` has already been resolved.
...@@ -33275,7 +33274,7 @@ fn resolveAddressSpace(...@@ -33275,7 +33274,7 @@ fn resolveAddressSpace(
33275 zir_ref: Zir.Inst.Ref,33274 zir_ref: Zir.Inst.Ref,
33276 ctx: std.Target.AddressSpaceContext,33275 ctx: std.Target.AddressSpaceContext,
33277) !std.builtin.AddressSpace {33276) !std.builtin.AddressSpace {
33278 const air_ref = try sema.resolveInst(zir_ref);33277 const air_ref = sema.resolveInst(zir_ref);
33279 return sema.analyzeAsAddressSpace(block, src, air_ref, ctx);33278 return sema.analyzeAsAddressSpace(block, src, air_ref, ctx);
33280}33279}
3328133280
...@@ -34305,7 +34304,7 @@ fn setTypeName(...@@ -34305,7 +34304,7 @@ fn setTypeName(
34305 // If not then this is a struct type being returned from a non-generic34304 // If not then this is a struct type being returned from a non-generic
34306 // function and the name doesn't matter since it will later34305 // function and the name doesn't matter since it will later
34307 // result in a compile error.34306 // result in a compile error.
34308 const arg_val = try sema.resolveValue(arg) orelse {34307 const arg_val = sema.resolveValue(arg) orelse {
34309 continue :strat .anon;34308 continue :strat .anon;
34310 };34309 };
3431134310