| ... | @@ -1820,7 +1820,7 @@ pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Ins | ... | @@ -1820,7 +1820,7 @@ pub fn resolveType(sema: *Sema, block: *Block, src: LazySrcLoc, zir_ref: Zir.Ins |
| 1820 | return ty; | 1820 | return ty; |
| 1821 | } | 1821 | } |
| 1822 | | 1822 | |
| 1823 | fn resolveCastDestType( | 1823 | fn resolveDestType( |
| 1824 | sema: *Sema, | 1824 | sema: *Sema, |
| 1825 | block: *Block, | 1825 | block: *Block, |
| 1826 | src: LazySrcLoc, | 1826 | src: LazySrcLoc, |
| ... | @@ -8337,7 +8337,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -8337,7 +8337,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 8337 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 8337 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 8338 | const src = inst_data.src(); | 8338 | const src = inst_data.src(); |
| 8339 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 8339 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 8340 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt"); | 8340 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt"); |
| 8341 | const operand = try sema.resolveInst(extra.rhs); | 8341 | const operand = try sema.resolveInst(extra.rhs); |
| 8342 | | 8342 | |
| 8343 | if (dest_ty.zigTypeTag(mod) != .Enum) { | 8343 | if (dest_ty.zigTypeTag(mod) != .Enum) { |
| ... | @@ -9666,7 +9666,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9666,7 +9666,7 @@ fn zirIntCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9666 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 9666 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 9667 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9667 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9668 | | 9668 | |
| 9669 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast"); | 9669 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intCast"); |
| 9670 | const operand = try sema.resolveInst(extra.rhs); | 9670 | const operand = try sema.resolveInst(extra.rhs); |
| 9671 | | 9671 | |
| 9672 | return sema.intCast(block, inst_data.src(), dest_ty, src, operand, operand_src, true); | 9672 | return sema.intCast(block, inst_data.src(), dest_ty, src, operand, operand_src, true); |
| ... | @@ -9827,7 +9827,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -9827,7 +9827,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 9827 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 9827 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 9828 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9828 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9829 | | 9829 | |
| 9830 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@bitCast"); | 9830 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@bitCast"); |
| 9831 | const operand = try sema.resolveInst(extra.rhs); | 9831 | const operand = try sema.resolveInst(extra.rhs); |
| 9832 | const operand_ty = sema.typeOf(operand); | 9832 | const operand_ty = sema.typeOf(operand); |
| 9833 | switch (dest_ty.zigTypeTag(mod)) { | 9833 | switch (dest_ty.zigTypeTag(mod)) { |
| ... | @@ -9970,7 +9970,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -9970,7 +9970,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 9970 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 9970 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 9971 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 9971 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 9972 | | 9972 | |
| 9973 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@floatCast"); | 9973 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatCast"); |
| 9974 | const operand = try sema.resolveInst(extra.rhs); | 9974 | const operand = try sema.resolveInst(extra.rhs); |
| 9975 | | 9975 | |
| 9976 | const target = mod.getTarget(); | 9976 | const target = mod.getTarget(); |
| ... | @@ -20783,7 +20783,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -20783,7 +20783,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 20783 | const src = inst_data.src(); | 20783 | const src = inst_data.src(); |
| 20784 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 20784 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 20785 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 20785 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 20786 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat"); | 20786 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@intFromFloat"); |
| 20787 | const operand = try sema.resolveInst(extra.rhs); | 20787 | const operand = try sema.resolveInst(extra.rhs); |
| 20788 | const operand_ty = sema.typeOf(operand); | 20788 | const operand_ty = sema.typeOf(operand); |
| 20789 | | 20789 | |
| ... | @@ -20823,7 +20823,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -20823,7 +20823,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 20823 | const src = inst_data.src(); | 20823 | const src = inst_data.src(); |
| 20824 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 20824 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 20825 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 20825 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 20826 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt"); | 20826 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@floatFromInt"); |
| 20827 | const operand = try sema.resolveInst(extra.rhs); | 20827 | const operand = try sema.resolveInst(extra.rhs); |
| 20828 | const operand_ty = sema.typeOf(operand); | 20828 | const operand_ty = sema.typeOf(operand); |
| 20829 | | 20829 | |
| ... | @@ -20852,7 +20852,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -20852,7 +20852,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 20852 | const operand_res = try sema.resolveInst(extra.rhs); | 20852 | const operand_res = try sema.resolveInst(extra.rhs); |
| 20853 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); | 20853 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); |
| 20854 | | 20854 | |
| 20855 | const ptr_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt"); | 20855 | const ptr_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt"); |
| 20856 | try sema.checkPtrType(block, src, ptr_ty); | 20856 | try sema.checkPtrType(block, src, ptr_ty); |
| 20857 | const elem_ty = ptr_ty.elemType2(mod); | 20857 | const elem_ty = ptr_ty.elemType2(mod); |
| 20858 | const ptr_align = try ptr_ty.ptrAlignmentAdvanced(mod, sema); | 20858 | const ptr_align = try ptr_ty.ptrAlignmentAdvanced(mod, sema); |
| ... | @@ -20910,7 +20910,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat | ... | @@ -20910,7 +20910,7 @@ fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDat |
| 20910 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 20910 | const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 20911 | const src = LazySrcLoc.nodeOffset(extra.node); | 20911 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 20912 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; | 20912 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = extra.node }; |
| 20913 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@errSetCast"); | 20913 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@errSetCast"); |
| 20914 | const operand = try sema.resolveInst(extra.rhs); | 20914 | const operand = try sema.resolveInst(extra.rhs); |
| 20915 | const operand_ty = sema.typeOf(operand); | 20915 | const operand_ty = sema.typeOf(operand); |
| 20916 | try sema.checkErrorSetType(block, src, dest_ty); | 20916 | try sema.checkErrorSetType(block, src, dest_ty); |
| ... | @@ -20997,7 +20997,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa | ... | @@ -20997,7 +20997,7 @@ fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstDa |
| 20997 | const src = LazySrcLoc.nodeOffset(extra.node); | 20997 | const src = LazySrcLoc.nodeOffset(extra.node); |
| 20998 | const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node }; | 20998 | const operand_src: LazySrcLoc = .{ .node_offset_ptrcast_operand = extra.node }; |
| 20999 | const operand = try sema.resolveInst(extra.rhs); | 20999 | const operand = try sema.resolveInst(extra.rhs); |
| 21000 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu, flags.needResultTypeBuiltinName()); | 21000 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, flags.needResultTypeBuiltinName()); |
| 21001 | return sema.ptrCastFull( | 21001 | return sema.ptrCastFull( |
| 21002 | block, | 21002 | block, |
| 21003 | flags, | 21003 | flags, |
| ... | @@ -21013,7 +21013,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -21013,7 +21013,7 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 21013 | const src = inst_data.src(); | 21013 | const src = inst_data.src(); |
| 21014 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 21014 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 21015 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 21015 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 21016 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu, "@ptrCast"); | 21016 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrCast"); |
| 21017 | const operand = try sema.resolveInst(extra.rhs); | 21017 | const operand = try sema.resolveInst(extra.rhs); |
| 21018 | | 21018 | |
| 21019 | return sema.ptrCastFull( | 21019 | return sema.ptrCastFull( |
| ... | @@ -21426,7 +21426,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -21426,7 +21426,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 21426 | const src = inst_data.src(); | 21426 | const src = inst_data.src(); |
| 21427 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 21427 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 21428 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 21428 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 21429 | const dest_ty = try sema.resolveCastDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate"); | 21429 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@truncate"); |
| 21430 | const dest_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, dest_ty, src); | 21430 | const dest_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, dest_ty, src); |
| 21431 | const operand = try sema.resolveInst(extra.rhs); | 21431 | const operand = try sema.resolveInst(extra.rhs); |
| 21432 | const operand_ty = sema.typeOf(operand); | 21432 | const operand_ty = sema.typeOf(operand); |
| ... | @@ -22358,23 +22358,22 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -22358,23 +22358,22 @@ fn zirSplat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 22358 | const mod = sema.mod; | 22358 | const mod = sema.mod; |
| 22359 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; | 22359 | const inst_data = sema.code.instructions.items(.data)[inst].pl_node; |
| 22360 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 22360 | const extra = sema.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 22361 | const len_src: LazySrcLoc = .{ .node_offset_bin_lhs = inst_data.src_node }; | 22361 | const src = inst_data.src(); |
| 22362 | const scalar_src: LazySrcLoc = .{ .node_offset_bin_rhs = inst_data.src_node }; | 22362 | const scalar_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 22363 | const len = @as(u32, @intCast(try sema.resolveInt(block, len_src, extra.lhs, Type.u32, "vector splat destination length must be comptime-known"))); | 22363 | const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@splat"); |
| 22364 | const scalar = try sema.resolveInst(extra.rhs); | 22364 | |
| 22365 | const scalar_ty = sema.typeOf(scalar); | 22365 | if (!dest_ty.isVector(mod)) return sema.fail(block, src, "expected vector type, found '{}'", .{dest_ty.fmt(mod)}); |
| 22366 | try sema.checkVectorElemType(block, scalar_src, scalar_ty); | 22366 | |
| 22367 | const vector_ty = try mod.vectorType(.{ | 22367 | const operand = try sema.resolveInst(extra.rhs); |
| 22368 | .len = len, | 22368 | const scalar_ty = dest_ty.childType(mod); |
| 22369 | .child = scalar_ty.toIntern(), | 22369 | const scalar = try sema.coerce(block, scalar_ty, operand, scalar_src); |
| 22370 | }); | | |
| 22371 | if (try sema.resolveMaybeUndefVal(scalar)) |scalar_val| { | 22370 | if (try sema.resolveMaybeUndefVal(scalar)) |scalar_val| { |
| 22372 | if (scalar_val.isUndef(mod)) return sema.addConstUndef(vector_ty); | 22371 | if (scalar_val.isUndef(mod)) return sema.addConstUndef(dest_ty); |
| 22373 | return sema.addConstant(try sema.splat(vector_ty, scalar_val)); | 22372 | return sema.addConstant(try sema.splat(dest_ty, scalar_val)); |
| 22374 | } | 22373 | } |
| 22375 | | 22374 | |
| 22376 | try sema.requireRuntimeBlock(block, inst_data.src(), scalar_src); | 22375 | try sema.requireRuntimeBlock(block, inst_data.src(), scalar_src); |
| 22377 | return block.addTyOp(.splat, vector_ty, scalar); | 22376 | return block.addTyOp(.splat, dest_ty, scalar); |
| 22378 | } | 22377 | } |
| 22379 | | 22378 | |
| 22380 | fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 22379 | fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |