| ... | @@ -2629,7 +2629,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -2629,7 +2629,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 2629 | defer trash_block.instructions.deinit(sema.gpa); | 2629 | defer trash_block.instructions.deinit(sema.gpa); |
| 2630 | const operand = try trash_block.addBitCast(pointee_ty, .void_value); | 2630 | const operand = try trash_block.addBitCast(pointee_ty, .void_value); |
| 2631 | | 2631 | |
| 2632 | const ptr_ty = try mod.ptrType(.{ | 2632 | const ptr_ty = try sema.ptrType(.{ |
| 2633 | .child = pointee_ty.toIntern(), | 2633 | .child = pointee_ty.toIntern(), |
| 2634 | .flags = .{ | 2634 | .flags = .{ |
| 2635 | .alignment = ia1.alignment, | 2635 | .alignment = ia1.alignment, |
| ... | @@ -2660,7 +2660,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -2660,7 +2660,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 2660 | if (alignment != .none) { | 2660 | if (alignment != .none) { |
| 2661 | try sema.resolveTypeLayout(pointee_ty); | 2661 | try sema.resolveTypeLayout(pointee_ty); |
| 2662 | } | 2662 | } |
| 2663 | const ptr_ty = try mod.ptrType(.{ | 2663 | const ptr_ty = try sema.ptrType(.{ |
| 2664 | .child = pointee_ty.toIntern(), | 2664 | .child = pointee_ty.toIntern(), |
| 2665 | .flags = .{ | 2665 | .flags = .{ |
| 2666 | .alignment = alignment, | 2666 | .alignment = alignment, |
| ... | @@ -2730,7 +2730,7 @@ fn coerceResultPtr( | ... | @@ -2730,7 +2730,7 @@ fn coerceResultPtr( |
| 2730 | } | 2730 | } |
| 2731 | } | 2731 | } |
| 2732 | | 2732 | |
| 2733 | const ptr_ty = try mod.ptrType(.{ | 2733 | const ptr_ty = try sema.ptrType(.{ |
| 2734 | .child = pointee_ty.toIntern(), | 2734 | .child = pointee_ty.toIntern(), |
| 2735 | .flags = .{ .address_space = addr_space }, | 2735 | .flags = .{ .address_space = addr_space }, |
| 2736 | }); | 2736 | }); |
| ... | @@ -2759,7 +2759,7 @@ fn coerceResultPtr( | ... | @@ -2759,7 +2759,7 @@ fn coerceResultPtr( |
| 2759 | // Array coerced to Vector where element size is not equal but coercible. | 2759 | // Array coerced to Vector where element size is not equal but coercible. |
| 2760 | .aggregate_init => { | 2760 | .aggregate_init => { |
| 2761 | const ty_pl = air_datas[trash_inst].ty_pl; | 2761 | const ty_pl = air_datas[trash_inst].ty_pl; |
| 2762 | const ptr_operand_ty = try mod.ptrType(.{ | 2762 | const ptr_operand_ty = try sema.ptrType(.{ |
| 2763 | .child = (try sema.analyzeAsType(block, src, ty_pl.ty)).toIntern(), | 2763 | .child = (try sema.analyzeAsType(block, src, ty_pl.ty)).toIntern(), |
| 2764 | .flags = .{ .address_space = addr_space }, | 2764 | .flags = .{ .address_space = addr_space }, |
| 2765 | }); | 2765 | }); |
| ... | @@ -2773,7 +2773,7 @@ fn coerceResultPtr( | ... | @@ -2773,7 +2773,7 @@ fn coerceResultPtr( |
| 2773 | .bitcast => { | 2773 | .bitcast => { |
| 2774 | const ty_op = air_datas[trash_inst].ty_op; | 2774 | const ty_op = air_datas[trash_inst].ty_op; |
| 2775 | const operand_ty = sema.typeOf(ty_op.operand); | 2775 | const operand_ty = sema.typeOf(ty_op.operand); |
| 2776 | const ptr_operand_ty = try mod.ptrType(.{ | 2776 | const ptr_operand_ty = try sema.ptrType(.{ |
| 2777 | .child = operand_ty.toIntern(), | 2777 | .child = operand_ty.toIntern(), |
| 2778 | .flags = .{ .address_space = addr_space }, | 2778 | .flags = .{ .address_space = addr_space }, |
| 2779 | }); | 2779 | }); |
| ... | @@ -3508,7 +3508,7 @@ fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { | ... | @@ -3508,7 +3508,7 @@ fn zirRetPtr(sema: *Sema, block: *Block) CompileError!Air.Inst.Ref { |
| 3508 | } | 3508 | } |
| 3509 | | 3509 | |
| 3510 | const target = sema.mod.getTarget(); | 3510 | const target = sema.mod.getTarget(); |
| 3511 | const ptr_type = try sema.mod.ptrType(.{ | 3511 | const ptr_type = try sema.ptrType(.{ |
| 3512 | .child = sema.fn_ret_ty.toIntern(), | 3512 | .child = sema.fn_ret_ty.toIntern(), |
| 3513 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 3513 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 3514 | }); | 3514 | }); |
| ... | @@ -3711,7 +3711,7 @@ fn zirAllocExtended( | ... | @@ -3711,7 +3711,7 @@ fn zirAllocExtended( |
| 3711 | } | 3711 | } |
| 3712 | const target = sema.mod.getTarget(); | 3712 | const target = sema.mod.getTarget(); |
| 3713 | try sema.resolveTypeLayout(var_ty); | 3713 | try sema.resolveTypeLayout(var_ty); |
| 3714 | const ptr_type = try sema.mod.ptrType(.{ | 3714 | const ptr_type = try sema.ptrType(.{ |
| 3715 | .child = var_ty.toIntern(), | 3715 | .child = var_ty.toIntern(), |
| 3716 | .flags = .{ | 3716 | .flags = .{ |
| 3717 | .alignment = alignment, | 3717 | .alignment = alignment, |
| ... | @@ -3820,7 +3820,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai | ... | @@ -3820,7 +3820,7 @@ fn makePtrConst(sema: *Sema, block: *Block, alloc: Air.Inst.Ref) CompileError!Ai |
| 3820 | | 3820 | |
| 3821 | var ptr_info = alloc_ty.ptrInfo(mod); | 3821 | var ptr_info = alloc_ty.ptrInfo(mod); |
| 3822 | ptr_info.flags.is_const = true; | 3822 | ptr_info.flags.is_const = true; |
| 3823 | const const_ptr_ty = try mod.ptrType(ptr_info); | 3823 | const const_ptr_ty = try sema.ptrType(ptr_info); |
| 3824 | | 3824 | |
| 3825 | // Detect if a comptime value simply needs to have its type changed. | 3825 | // Detect if a comptime value simply needs to have its type changed. |
| 3826 | if (try sema.resolveMaybeUndefVal(alloc)) |val| { | 3826 | if (try sema.resolveMaybeUndefVal(alloc)) |val| { |
| ... | @@ -3862,7 +3862,7 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I | ... | @@ -3862,7 +3862,7 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 3862 | return sema.analyzeComptimeAlloc(block, var_ty, .none); | 3862 | return sema.analyzeComptimeAlloc(block, var_ty, .none); |
| 3863 | } | 3863 | } |
| 3864 | const target = sema.mod.getTarget(); | 3864 | const target = sema.mod.getTarget(); |
| 3865 | const ptr_type = try sema.mod.ptrType(.{ | 3865 | const ptr_type = try sema.ptrType(.{ |
| 3866 | .child = var_ty.toIntern(), | 3866 | .child = var_ty.toIntern(), |
| 3867 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 3867 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 3868 | }); | 3868 | }); |
| ... | @@ -3882,7 +3882,7 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -3882,7 +3882,7 @@ fn zirAllocMut(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 3882 | } | 3882 | } |
| 3883 | try sema.validateVarType(block, ty_src, var_ty, false); | 3883 | try sema.validateVarType(block, ty_src, var_ty, false); |
| 3884 | const target = sema.mod.getTarget(); | 3884 | const target = sema.mod.getTarget(); |
| 3885 | const ptr_type = try sema.mod.ptrType(.{ | 3885 | const ptr_type = try sema.ptrType(.{ |
| 3886 | .child = var_ty.toIntern(), | 3886 | .child = var_ty.toIntern(), |
| 3887 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 3887 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 3888 | }); | 3888 | }); |
| ... | @@ -3948,7 +3948,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3948,7 +3948,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3948 | const decl = mod.declPtr(decl_index); | 3948 | const decl = mod.declPtr(decl_index); |
| 3949 | if (iac.is_const) _ = try decl.internValue(mod); | 3949 | if (iac.is_const) _ = try decl.internValue(mod); |
| 3950 | const final_elem_ty = decl.ty; | 3950 | const final_elem_ty = decl.ty; |
| 3951 | const final_ptr_ty = try mod.ptrType(.{ | 3951 | const final_ptr_ty = try sema.ptrType(.{ |
| 3952 | .child = final_elem_ty.toIntern(), | 3952 | .child = final_elem_ty.toIntern(), |
| 3953 | .flags = .{ | 3953 | .flags = .{ |
| 3954 | .is_const = false, | 3954 | .is_const = false, |
| ... | @@ -3981,7 +3981,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3981,7 +3981,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3981 | const peer_inst_list = ia2.prongs.items(.stored_inst); | 3981 | const peer_inst_list = ia2.prongs.items(.stored_inst); |
| 3982 | const final_elem_ty = try sema.resolvePeerTypes(block, ty_src, peer_inst_list, .none); | 3982 | const final_elem_ty = try sema.resolvePeerTypes(block, ty_src, peer_inst_list, .none); |
| 3983 | | 3983 | |
| 3984 | const final_ptr_ty = try mod.ptrType(.{ | 3984 | const final_ptr_ty = try sema.ptrType(.{ |
| 3985 | .child = final_elem_ty.toIntern(), | 3985 | .child = final_elem_ty.toIntern(), |
| 3986 | .flags = .{ | 3986 | .flags = .{ |
| 3987 | .alignment = ia1.alignment, | 3987 | .alignment = ia1.alignment, |
| ... | @@ -4103,7 +4103,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -4103,7 +4103,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 4103 | trash_block.is_comptime = false; | 4103 | trash_block.is_comptime = false; |
| 4104 | defer trash_block.instructions.deinit(gpa); | 4104 | defer trash_block.instructions.deinit(gpa); |
| 4105 | | 4105 | |
| 4106 | const mut_final_ptr_ty = try mod.ptrType(.{ | 4106 | const mut_final_ptr_ty = try sema.ptrType(.{ |
| 4107 | .child = final_elem_ty.toIntern(), | 4107 | .child = final_elem_ty.toIntern(), |
| 4108 | .flags = .{ | 4108 | .flags = .{ |
| 4109 | .alignment = ia1.alignment, | 4109 | .alignment = ia1.alignment, |
| ... | @@ -8650,7 +8650,7 @@ fn analyzeOptionalPayloadPtr( | ... | @@ -8650,7 +8650,7 @@ fn analyzeOptionalPayloadPtr( |
| 8650 | } | 8650 | } |
| 8651 | | 8651 | |
| 8652 | const child_type = opt_type.optionalChild(mod); | 8652 | const child_type = opt_type.optionalChild(mod); |
| 8653 | const child_pointer = try mod.ptrType(.{ | 8653 | const child_pointer = try sema.ptrType(.{ |
| 8654 | .child = child_type.toIntern(), | 8654 | .child = child_type.toIntern(), |
| 8655 | .flags = .{ | 8655 | .flags = .{ |
| 8656 | .is_const = optional_ptr_ty.isConstPtr(mod), | 8656 | .is_const = optional_ptr_ty.isConstPtr(mod), |
| ... | @@ -8719,7 +8719,7 @@ fn zirOptionalPayload( | ... | @@ -8719,7 +8719,7 @@ fn zirOptionalPayload( |
| 8719 | // TODO https://github.com/ziglang/zig/issues/6597 | 8719 | // TODO https://github.com/ziglang/zig/issues/6597 |
| 8720 | if (true) break :t operand_ty; | 8720 | if (true) break :t operand_ty; |
| 8721 | const ptr_info = operand_ty.ptrInfo(mod); | 8721 | const ptr_info = operand_ty.ptrInfo(mod); |
| 8722 | break :t try mod.ptrType(.{ | 8722 | break :t try sema.ptrType(.{ |
| 8723 | .child = ptr_info.child, | 8723 | .child = ptr_info.child, |
| 8724 | .flags = .{ | 8724 | .flags = .{ |
| 8725 | .alignment = ptr_info.flags.alignment, | 8725 | .alignment = ptr_info.flags.alignment, |
| ... | @@ -8837,7 +8837,7 @@ fn analyzeErrUnionPayloadPtr( | ... | @@ -8837,7 +8837,7 @@ fn analyzeErrUnionPayloadPtr( |
| 8837 | | 8837 | |
| 8838 | const err_union_ty = operand_ty.childType(mod); | 8838 | const err_union_ty = operand_ty.childType(mod); |
| 8839 | const payload_ty = err_union_ty.errorUnionPayload(mod); | 8839 | const payload_ty = err_union_ty.errorUnionPayload(mod); |
| 8840 | const operand_pointer_ty = try mod.ptrType(.{ | 8840 | const operand_pointer_ty = try sema.ptrType(.{ |
| 8841 | .child = payload_ty.toIntern(), | 8841 | .child = payload_ty.toIntern(), |
| 8842 | .flags = .{ | 8842 | .flags = .{ |
| 8843 | .is_const = operand_ty.isConstPtr(mod), | 8843 | .is_const = operand_ty.isConstPtr(mod), |
| ... | @@ -10692,7 +10692,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10692,7 +10692,7 @@ const SwitchProngAnalysis = struct { |
| 10692 | const union_obj = mod.typeToUnion(operand_ty).?; | 10692 | const union_obj = mod.typeToUnion(operand_ty).?; |
| 10693 | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); | 10693 | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); |
| 10694 | if (capture_byref) { | 10694 | if (capture_byref) { |
| 10695 | const ptr_field_ty = try mod.ptrType(.{ | 10695 | const ptr_field_ty = try sema.ptrType(.{ |
| 10696 | .child = field_ty.toIntern(), | 10696 | .child = field_ty.toIntern(), |
| 10697 | .flags = .{ | 10697 | .flags = .{ |
| 10698 | .is_const = !operand_ptr_ty.ptrIsMutable(mod), | 10698 | .is_const = !operand_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -10798,7 +10798,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10798,7 +10798,7 @@ const SwitchProngAnalysis = struct { |
| 10798 | // By-reference captures have some further restrictions which make them easier to emit | 10798 | // By-reference captures have some further restrictions which make them easier to emit |
| 10799 | if (capture_byref) { | 10799 | if (capture_byref) { |
| 10800 | const operand_ptr_info = operand_ptr_ty.ptrInfo(mod); | 10800 | const operand_ptr_info = operand_ptr_ty.ptrInfo(mod); |
| 10801 | const capture_ptr_ty = try mod.ptrType(.{ | 10801 | const capture_ptr_ty = try sema.ptrType(.{ |
| 10802 | .child = capture_ty.toIntern(), | 10802 | .child = capture_ty.toIntern(), |
| 10803 | .flags = .{ | 10803 | .flags = .{ |
| 10804 | // TODO: alignment! | 10804 | // TODO: alignment! |
| ... | @@ -10812,7 +10812,7 @@ const SwitchProngAnalysis = struct { | ... | @@ -10812,7 +10812,7 @@ const SwitchProngAnalysis = struct { |
| 10812 | // pointer type is in-memory coercible to the capture pointer type. | 10812 | // pointer type is in-memory coercible to the capture pointer type. |
| 10813 | if (!same_types) { | 10813 | if (!same_types) { |
| 10814 | for (field_tys, 0..) |field_ty, i| { | 10814 | for (field_tys, 0..) |field_ty, i| { |
| 10815 | const field_ptr_ty = try mod.ptrType(.{ | 10815 | const field_ptr_ty = try sema.ptrType(.{ |
| 10816 | .child = field_ty.toIntern(), | 10816 | .child = field_ty.toIntern(), |
| 10817 | .flags = .{ | 10817 | .flags = .{ |
| 10818 | // TODO: alignment! | 10818 | // TODO: alignment! |
| ... | @@ -13776,12 +13776,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13776,12 +13776,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13776 | try sema.requireRuntimeBlock(block, src, runtime_src); | 13776 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 13777 | | 13777 | |
| 13778 | if (ptr_addrspace) |ptr_as| { | 13778 | if (ptr_addrspace) |ptr_as| { |
| 13779 | const alloc_ty = try mod.ptrType(.{ | 13779 | const alloc_ty = try sema.ptrType(.{ |
| 13780 | .child = result_ty.toIntern(), | 13780 | .child = result_ty.toIntern(), |
| 13781 | .flags = .{ .address_space = ptr_as }, | 13781 | .flags = .{ .address_space = ptr_as }, |
| 13782 | }); | 13782 | }); |
| 13783 | const alloc = try block.addTy(.alloc, alloc_ty); | 13783 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 13784 | const elem_ptr_ty = try mod.ptrType(.{ | 13784 | const elem_ptr_ty = try sema.ptrType(.{ |
| 13785 | .child = resolved_elem_ty.toIntern(), | 13785 | .child = resolved_elem_ty.toIntern(), |
| 13786 | .flags = .{ .address_space = ptr_as }, | 13786 | .flags = .{ .address_space = ptr_as }, |
| 13787 | }); | 13787 | }); |
| ... | @@ -14041,12 +14041,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -14041,12 +14041,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 14041 | try sema.requireRuntimeBlock(block, src, lhs_src); | 14041 | try sema.requireRuntimeBlock(block, src, lhs_src); |
| 14042 | | 14042 | |
| 14043 | if (ptr_addrspace) |ptr_as| { | 14043 | if (ptr_addrspace) |ptr_as| { |
| 14044 | const alloc_ty = try mod.ptrType(.{ | 14044 | const alloc_ty = try sema.ptrType(.{ |
| 14045 | .child = result_ty.toIntern(), | 14045 | .child = result_ty.toIntern(), |
| 14046 | .flags = .{ .address_space = ptr_as }, | 14046 | .flags = .{ .address_space = ptr_as }, |
| 14047 | }); | 14047 | }); |
| 14048 | const alloc = try block.addTy(.alloc, alloc_ty); | 14048 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 14049 | const elem_ptr_ty = try mod.ptrType(.{ | 14049 | const elem_ptr_ty = try sema.ptrType(.{ |
| 14050 | .child = lhs_info.elem_type.toIntern(), | 14050 | .child = lhs_info.elem_type.toIntern(), |
| 14051 | .flags = .{ .address_space = ptr_as }, | 14051 | .flags = .{ .address_space = ptr_as }, |
| 14052 | }); | 14052 | }); |
| ... | @@ -15988,7 +15988,7 @@ fn analyzePtrArithmetic( | ... | @@ -15988,7 +15988,7 @@ fn analyzePtrArithmetic( |
| 15988 | )); | 15988 | )); |
| 15989 | assert(new_align != .none); | 15989 | assert(new_align != .none); |
| 15990 | | 15990 | |
| 15991 | break :t try mod.ptrType(.{ | 15991 | break :t try sema.ptrType(.{ |
| 15992 | .child = ptr_info.child, | 15992 | .child = ptr_info.child, |
| 15993 | .sentinel = ptr_info.sentinel, | 15993 | .sentinel = ptr_info.sentinel, |
| 15994 | .flags = .{ | 15994 | .flags = .{ |
| ... | @@ -16891,7 +16891,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -16891,7 +16891,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 16891 | .none, // default alignment | 16891 | .none, // default alignment |
| 16892 | ); | 16892 | ); |
| 16893 | break :v try mod.intern(.{ .ptr = .{ | 16893 | break :v try mod.intern(.{ .ptr = .{ |
| 16894 | .ty = (try mod.ptrType(.{ | 16894 | .ty = (try sema.ptrType(.{ |
| 16895 | .child = param_info_ty.toIntern(), | 16895 | .child = param_info_ty.toIntern(), |
| 16896 | .flags = .{ | 16896 | .flags = .{ |
| 16897 | .size = .Slice, | 16897 | .size = .Slice, |
| ... | @@ -17210,7 +17210,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17210,7 +17210,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17210 | }; | 17210 | }; |
| 17211 | | 17211 | |
| 17212 | // Build our ?[]const Error value | 17212 | // Build our ?[]const Error value |
| 17213 | const slice_errors_ty = try mod.ptrType(.{ | 17213 | const slice_errors_ty = try sema.ptrType(.{ |
| 17214 | .child = error_field_ty.toIntern(), | 17214 | .child = error_field_ty.toIntern(), |
| 17215 | .flags = .{ | 17215 | .flags = .{ |
| 17216 | .size = .Slice, | 17216 | .size = .Slice, |
| ... | @@ -17359,7 +17359,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17359,7 +17359,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17359 | .none, // default alignment | 17359 | .none, // default alignment |
| 17360 | ); | 17360 | ); |
| 17361 | break :v try mod.intern(.{ .ptr = .{ | 17361 | break :v try mod.intern(.{ .ptr = .{ |
| 17362 | .ty = (try mod.ptrType(.{ | 17362 | .ty = (try sema.ptrType(.{ |
| 17363 | .child = enum_field_ty.toIntern(), | 17363 | .child = enum_field_ty.toIntern(), |
| 17364 | .flags = .{ | 17364 | .flags = .{ |
| 17365 | .size = .Slice, | 17365 | .size = .Slice, |
| ... | @@ -17503,7 +17503,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17503,7 +17503,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17503 | .none, // default alignment | 17503 | .none, // default alignment |
| 17504 | ); | 17504 | ); |
| 17505 | break :v try mod.intern(.{ .ptr = .{ | 17505 | break :v try mod.intern(.{ .ptr = .{ |
| 17506 | .ty = (try mod.ptrType(.{ | 17506 | .ty = (try sema.ptrType(.{ |
| 17507 | .child = union_field_ty.toIntern(), | 17507 | .child = union_field_ty.toIntern(), |
| 17508 | .flags = .{ | 17508 | .flags = .{ |
| 17509 | .size = .Slice, | 17509 | .size = .Slice, |
| ... | @@ -17731,7 +17731,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17731,7 +17731,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17731 | .none, // default alignment | 17731 | .none, // default alignment |
| 17732 | ); | 17732 | ); |
| 17733 | break :v try mod.intern(.{ .ptr = .{ | 17733 | break :v try mod.intern(.{ .ptr = .{ |
| 17734 | .ty = (try mod.ptrType(.{ | 17734 | .ty = (try sema.ptrType(.{ |
| 17735 | .child = struct_field_ty.toIntern(), | 17735 | .child = struct_field_ty.toIntern(), |
| 17736 | .flags = .{ | 17736 | .flags = .{ |
| 17737 | .size = .Slice, | 17737 | .size = .Slice, |
| ... | @@ -17877,7 +17877,7 @@ fn typeInfoDecls( | ... | @@ -17877,7 +17877,7 @@ fn typeInfoDecls( |
| 17877 | .none, // default alignment | 17877 | .none, // default alignment |
| 17878 | ); | 17878 | ); |
| 17879 | return try mod.intern(.{ .ptr = .{ | 17879 | return try mod.intern(.{ .ptr = .{ |
| 17880 | .ty = (try mod.ptrType(.{ | 17880 | .ty = (try sema.ptrType(.{ |
| 17881 | .child = declaration_ty.toIntern(), | 17881 | .child = declaration_ty.toIntern(), |
| 17882 | .flags = .{ | 17882 | .flags = .{ |
| 17883 | .size = .Slice, | 17883 | .size = .Slice, |
| ... | @@ -18447,7 +18447,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr | ... | @@ -18447,7 +18447,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr |
| 18447 | | 18447 | |
| 18448 | const operand_ty = sema.typeOf(operand); | 18448 | const operand_ty = sema.typeOf(operand); |
| 18449 | const ptr_info = operand_ty.ptrInfo(mod); | 18449 | const ptr_info = operand_ty.ptrInfo(mod); |
| 18450 | const res_ty = try mod.ptrType(.{ | 18450 | const res_ty = try sema.ptrType(.{ |
| 18451 | .child = err_union_ty.errorUnionPayload(mod).toIntern(), | 18451 | .child = err_union_ty.errorUnionPayload(mod).toIntern(), |
| 18452 | .flags = .{ | 18452 | .flags = .{ |
| 18453 | .is_const = ptr_info.flags.is_const, | 18453 | .is_const = ptr_info.flags.is_const, |
| ... | @@ -19001,7 +19001,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -19001,7 +19001,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 19001 | } | 19001 | } |
| 19002 | } | 19002 | } |
| 19003 | | 19003 | |
| 19004 | const ty = try mod.ptrType(.{ | 19004 | const ty = try sema.ptrType(.{ |
| 19005 | .child = elem_ty.toIntern(), | 19005 | .child = elem_ty.toIntern(), |
| 19006 | .sentinel = sentinel, | 19006 | .sentinel = sentinel, |
| 19007 | .flags = .{ | 19007 | .flags = .{ |
| ... | @@ -19239,7 +19239,7 @@ fn zirStructInit( | ... | @@ -19239,7 +19239,7 @@ fn zirStructInit( |
| 19239 | | 19239 | |
| 19240 | if (is_ref) { | 19240 | if (is_ref) { |
| 19241 | const target = mod.getTarget(); | 19241 | const target = mod.getTarget(); |
| 19242 | const alloc_ty = try mod.ptrType(.{ | 19242 | const alloc_ty = try sema.ptrType(.{ |
| 19243 | .child = resolved_ty.toIntern(), | 19243 | .child = resolved_ty.toIntern(), |
| 19244 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19244 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19245 | }); | 19245 | }); |
| ... | @@ -19363,7 +19363,7 @@ fn finishStructInit( | ... | @@ -19363,7 +19363,7 @@ fn finishStructInit( |
| 19363 | if (is_ref) { | 19363 | if (is_ref) { |
| 19364 | try sema.resolveStructLayout(struct_ty); | 19364 | try sema.resolveStructLayout(struct_ty); |
| 19365 | const target = sema.mod.getTarget(); | 19365 | const target = sema.mod.getTarget(); |
| 19366 | const alloc_ty = try mod.ptrType(.{ | 19366 | const alloc_ty = try sema.ptrType(.{ |
| 19367 | .child = struct_ty.toIntern(), | 19367 | .child = struct_ty.toIntern(), |
| 19368 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19368 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19369 | }); | 19369 | }); |
| ... | @@ -19516,7 +19516,7 @@ fn structInitAnon( | ... | @@ -19516,7 +19516,7 @@ fn structInitAnon( |
| 19516 | | 19516 | |
| 19517 | if (is_ref) { | 19517 | if (is_ref) { |
| 19518 | const target = mod.getTarget(); | 19518 | const target = mod.getTarget(); |
| 19519 | const alloc_ty = try mod.ptrType(.{ | 19519 | const alloc_ty = try sema.ptrType(.{ |
| 19520 | .child = tuple_ty, | 19520 | .child = tuple_ty, |
| 19521 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19521 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19522 | }); | 19522 | }); |
| ... | @@ -19530,7 +19530,7 @@ fn structInitAnon( | ... | @@ -19530,7 +19530,7 @@ fn structInitAnon( |
| 19530 | }; | 19530 | }; |
| 19531 | extra_index = item.end; | 19531 | extra_index = item.end; |
| 19532 | | 19532 | |
| 19533 | const field_ptr_ty = try mod.ptrType(.{ | 19533 | const field_ptr_ty = try sema.ptrType(.{ |
| 19534 | .child = field_ty, | 19534 | .child = field_ty, |
| 19535 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19535 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19536 | }); | 19536 | }); |
| ... | @@ -19654,7 +19654,7 @@ fn zirArrayInit( | ... | @@ -19654,7 +19654,7 @@ fn zirArrayInit( |
| 19654 | | 19654 | |
| 19655 | if (is_ref) { | 19655 | if (is_ref) { |
| 19656 | const target = mod.getTarget(); | 19656 | const target = mod.getTarget(); |
| 19657 | const alloc_ty = try mod.ptrType(.{ | 19657 | const alloc_ty = try sema.ptrType(.{ |
| 19658 | .child = array_ty.toIntern(), | 19658 | .child = array_ty.toIntern(), |
| 19659 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19659 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19660 | }); | 19660 | }); |
| ... | @@ -19662,7 +19662,7 @@ fn zirArrayInit( | ... | @@ -19662,7 +19662,7 @@ fn zirArrayInit( |
| 19662 | | 19662 | |
| 19663 | if (array_ty.isTuple(mod)) { | 19663 | if (array_ty.isTuple(mod)) { |
| 19664 | for (resolved_args, 0..) |arg, i| { | 19664 | for (resolved_args, 0..) |arg, i| { |
| 19665 | const elem_ptr_ty = try mod.ptrType(.{ | 19665 | const elem_ptr_ty = try sema.ptrType(.{ |
| 19666 | .child = array_ty.structFieldType(i, mod).toIntern(), | 19666 | .child = array_ty.structFieldType(i, mod).toIntern(), |
| 19667 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19667 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19668 | }); | 19668 | }); |
| ... | @@ -19675,7 +19675,7 @@ fn zirArrayInit( | ... | @@ -19675,7 +19675,7 @@ fn zirArrayInit( |
| 19675 | return sema.makePtrConst(block, alloc); | 19675 | return sema.makePtrConst(block, alloc); |
| 19676 | } | 19676 | } |
| 19677 | | 19677 | |
| 19678 | const elem_ptr_ty = try mod.ptrType(.{ | 19678 | const elem_ptr_ty = try sema.ptrType(.{ |
| 19679 | .child = array_ty.elemType2(mod).toIntern(), | 19679 | .child = array_ty.elemType2(mod).toIntern(), |
| 19680 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19680 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19681 | }); | 19681 | }); |
| ... | @@ -19763,14 +19763,14 @@ fn arrayInitAnon( | ... | @@ -19763,14 +19763,14 @@ fn arrayInitAnon( |
| 19763 | | 19763 | |
| 19764 | if (is_ref) { | 19764 | if (is_ref) { |
| 19765 | const target = sema.mod.getTarget(); | 19765 | const target = sema.mod.getTarget(); |
| 19766 | const alloc_ty = try mod.ptrType(.{ | 19766 | const alloc_ty = try sema.ptrType(.{ |
| 19767 | .child = tuple_ty, | 19767 | .child = tuple_ty, |
| 19768 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19768 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19769 | }); | 19769 | }); |
| 19770 | const alloc = try block.addTy(.alloc, alloc_ty); | 19770 | const alloc = try block.addTy(.alloc, alloc_ty); |
| 19771 | for (operands, 0..) |operand, i_usize| { | 19771 | for (operands, 0..) |operand, i_usize| { |
| 19772 | const i: u32 = @intCast(i_usize); | 19772 | const i: u32 = @intCast(i_usize); |
| 19773 | const field_ptr_ty = try mod.ptrType(.{ | 19773 | const field_ptr_ty = try sema.ptrType(.{ |
| 19774 | .child = types[i], | 19774 | .child = types[i], |
| 19775 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, | 19775 | .flags = .{ .address_space = target_util.defaultAddressSpace(target, .local) }, |
| 19776 | }); | 19776 | }); |
| ... | @@ -20332,7 +20332,7 @@ fn zirReify( | ... | @@ -20332,7 +20332,7 @@ fn zirReify( |
| 20332 | } | 20332 | } |
| 20333 | } | 20333 | } |
| 20334 | | 20334 | |
| 20335 | const ty = try mod.ptrType(.{ | 20335 | const ty = try sema.ptrType(.{ |
| 20336 | .child = elem_ty.toIntern(), | 20336 | .child = elem_ty.toIntern(), |
| 20337 | .sentinel = actual_sentinel, | 20337 | .sentinel = actual_sentinel, |
| 20338 | .flags = .{ | 20338 | .flags = .{ |
| ... | @@ -21936,7 +21936,7 @@ fn ptrCastFull( | ... | @@ -21936,7 +21936,7 @@ fn ptrCastFull( |
| 21936 | // Only convert to a many-pointer at first | 21936 | // Only convert to a many-pointer at first |
| 21937 | var info = dest_info; | 21937 | var info = dest_info; |
| 21938 | info.flags.size = .Many; | 21938 | info.flags.size = .Many; |
| 21939 | const ty = try mod.ptrType(info); | 21939 | const ty = try sema.ptrType(info); |
| 21940 | if (dest_ty.zigTypeTag(mod) == .Optional) { | 21940 | if (dest_ty.zigTypeTag(mod) == .Optional) { |
| 21941 | break :blk try mod.optionalType(ty.toIntern()); | 21941 | break :blk try mod.optionalType(ty.toIntern()); |
| 21942 | } else { | 21942 | } else { |
| ... | @@ -22015,7 +22015,7 @@ fn ptrCastFull( | ... | @@ -22015,7 +22015,7 @@ fn ptrCastFull( |
| 22015 | // We can't change address spaces with a bitcast, so this requires two instructions | 22015 | // We can't change address spaces with a bitcast, so this requires two instructions |
| 22016 | var intermediate_info = src_info; | 22016 | var intermediate_info = src_info; |
| 22017 | intermediate_info.flags.address_space = dest_info.flags.address_space; | 22017 | intermediate_info.flags.address_space = dest_info.flags.address_space; |
| 22018 | const intermediate_ptr_ty = try mod.ptrType(intermediate_info); | 22018 | const intermediate_ptr_ty = try sema.ptrType(intermediate_info); |
| 22019 | const intermediate_ty = if (dest_ptr_ty.zigTypeTag(mod) == .Optional) blk: { | 22019 | const intermediate_ty = if (dest_ptr_ty.zigTypeTag(mod) == .Optional) blk: { |
| 22020 | break :blk try mod.optionalType(intermediate_ptr_ty.toIntern()); | 22020 | break :blk try mod.optionalType(intermediate_ptr_ty.toIntern()); |
| 22021 | } else intermediate_ptr_ty; | 22021 | } else intermediate_ptr_ty; |
| ... | @@ -22071,7 +22071,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst | ... | @@ -22071,7 +22071,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst |
| 22071 | var ptr_info = operand_ty.ptrInfo(mod); | 22071 | var ptr_info = operand_ty.ptrInfo(mod); |
| 22072 | if (flags.const_cast) ptr_info.flags.is_const = false; | 22072 | if (flags.const_cast) ptr_info.flags.is_const = false; |
| 22073 | if (flags.volatile_cast) ptr_info.flags.is_volatile = false; | 22073 | if (flags.volatile_cast) ptr_info.flags.is_volatile = false; |
| 22074 | const dest_ty = try mod.ptrType(ptr_info); | 22074 | const dest_ty = try sema.ptrType(ptr_info); |
| 22075 | | 22075 | |
| 22076 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { | 22076 | if (try sema.resolveMaybeUndefVal(operand)) |operand_val| { |
| 22077 | return Air.internedToRef((try mod.getCoerced(operand_val, dest_ty)).toIntern()); | 22077 | return Air.internedToRef((try mod.getCoerced(operand_val, dest_ty)).toIntern()); |
| ... | @@ -22606,7 +22606,7 @@ fn checkAtomicPtrOperand( | ... | @@ -22606,7 +22606,7 @@ fn checkAtomicPtrOperand( |
| 22606 | const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(mod)) { | 22606 | const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(mod)) { |
| 22607 | .Pointer => ptr_ty.ptrInfo(mod), | 22607 | .Pointer => ptr_ty.ptrInfo(mod), |
| 22608 | else => { | 22608 | else => { |
| 22609 | const wanted_ptr_ty = try mod.ptrType(wanted_ptr_data); | 22609 | const wanted_ptr_ty = try sema.ptrType(wanted_ptr_data); |
| 22610 | _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); | 22610 | _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); |
| 22611 | unreachable; | 22611 | unreachable; |
| 22612 | }, | 22612 | }, |
| ... | @@ -22616,7 +22616,7 @@ fn checkAtomicPtrOperand( | ... | @@ -22616,7 +22616,7 @@ fn checkAtomicPtrOperand( |
| 22616 | wanted_ptr_data.flags.is_allowzero = ptr_data.flags.is_allowzero; | 22616 | wanted_ptr_data.flags.is_allowzero = ptr_data.flags.is_allowzero; |
| 22617 | wanted_ptr_data.flags.is_volatile = ptr_data.flags.is_volatile; | 22617 | wanted_ptr_data.flags.is_volatile = ptr_data.flags.is_volatile; |
| 22618 | | 22618 | |
| 22619 | const wanted_ptr_ty = try mod.ptrType(wanted_ptr_data); | 22619 | const wanted_ptr_ty = try sema.ptrType(wanted_ptr_data); |
| 22620 | const casted_ptr = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); | 22620 | const casted_ptr = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src); |
| 22621 | | 22621 | |
| 22622 | return casted_ptr; | 22622 | return casted_ptr; |
| ... | @@ -23798,11 +23798,11 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr | ... | @@ -23798,11 +23798,11 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 23798 | }; | 23798 | }; |
| 23799 | } | 23799 | } |
| 23800 | | 23800 | |
| 23801 | const actual_field_ptr_ty = try mod.ptrType(ptr_ty_data); | 23801 | const actual_field_ptr_ty = try sema.ptrType(ptr_ty_data); |
| 23802 | const casted_field_ptr = try sema.coerce(block, actual_field_ptr_ty, field_ptr, ptr_src); | 23802 | const casted_field_ptr = try sema.coerce(block, actual_field_ptr_ty, field_ptr, ptr_src); |
| 23803 | | 23803 | |
| 23804 | ptr_ty_data.child = parent_ty.toIntern(); | 23804 | ptr_ty_data.child = parent_ty.toIntern(); |
| 23805 | const result_ptr = try mod.ptrType(ptr_ty_data); | 23805 | const result_ptr = try sema.ptrType(ptr_ty_data); |
| 23806 | | 23806 | |
| 23807 | if (try sema.resolveDefinedValue(block, src, casted_field_ptr)) |field_ptr_val| { | 23807 | if (try sema.resolveDefinedValue(block, src, casted_field_ptr)) |field_ptr_val| { |
| 23808 | const field = switch (ip.indexToKey(field_ptr_val.toIntern())) { | 23808 | const field = switch (ip.indexToKey(field_ptr_val.toIntern())) { |
| ... | @@ -24133,7 +24133,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A | ... | @@ -24133,7 +24133,7 @@ fn upgradeToArrayPtr(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, len: u64) !A |
| 24133 | // Already an array pointer. | 24133 | // Already an array pointer. |
| 24134 | return ptr; | 24134 | return ptr; |
| 24135 | } | 24135 | } |
| 24136 | const new_ty = try mod.ptrType(.{ | 24136 | const new_ty = try sema.ptrType(.{ |
| 24137 | .child = (try mod.arrayType(.{ | 24137 | .child = (try mod.arrayType(.{ |
| 24138 | .len = len, | 24138 | .len = len, |
| 24139 | .sentinel = info.sentinel, | 24139 | .sentinel = info.sentinel, |
| ... | @@ -24337,7 +24337,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -24337,7 +24337,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 24337 | assert(dest_manyptr_ty_key.flags.size == .One); | 24337 | assert(dest_manyptr_ty_key.flags.size == .One); |
| 24338 | dest_manyptr_ty_key.child = dest_elem_ty.toIntern(); | 24338 | dest_manyptr_ty_key.child = dest_elem_ty.toIntern(); |
| 24339 | dest_manyptr_ty_key.flags.size = .Many; | 24339 | dest_manyptr_ty_key.flags.size = .Many; |
| 24340 | break :ptr try sema.coerceCompatiblePtrs(block, try mod.ptrType(dest_manyptr_ty_key), new_dest_ptr, dest_src); | 24340 | break :ptr try sema.coerceCompatiblePtrs(block, try sema.ptrType(dest_manyptr_ty_key), new_dest_ptr, dest_src); |
| 24341 | } else new_dest_ptr; | 24341 | } else new_dest_ptr; |
| 24342 | | 24342 | |
| 24343 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); | 24343 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); |
| ... | @@ -24348,7 +24348,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -24348,7 +24348,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 24348 | assert(src_manyptr_ty_key.flags.size == .One); | 24348 | assert(src_manyptr_ty_key.flags.size == .One); |
| 24349 | src_manyptr_ty_key.child = src_elem_ty.toIntern(); | 24349 | src_manyptr_ty_key.child = src_elem_ty.toIntern(); |
| 24350 | src_manyptr_ty_key.flags.size = .Many; | 24350 | src_manyptr_ty_key.flags.size = .Many; |
| 24351 | break :ptr try sema.coerceCompatiblePtrs(block, try mod.ptrType(src_manyptr_ty_key), new_src_ptr, src_src); | 24351 | break :ptr try sema.coerceCompatiblePtrs(block, try sema.ptrType(src_manyptr_ty_key), new_src_ptr, src_src); |
| 24352 | } else new_src_ptr; | 24352 | } else new_src_ptr; |
| 24353 | | 24353 | |
| 24354 | // ok1: dest >= src + len | 24354 | // ok1: dest >= src + len |
| ... | @@ -25579,7 +25579,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { | ... | @@ -25579,7 +25579,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { |
| 25579 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); | 25579 | const stack_trace_ty = try sema.getBuiltinType("StackTrace"); |
| 25580 | try sema.resolveTypeFields(stack_trace_ty); | 25580 | try sema.resolveTypeFields(stack_trace_ty); |
| 25581 | const target = mod.getTarget(); | 25581 | const target = mod.getTarget(); |
| 25582 | const ptr_stack_trace_ty = try mod.ptrType(.{ | 25582 | const ptr_stack_trace_ty = try sema.ptrType(.{ |
| 25583 | .child = stack_trace_ty.toIntern(), | 25583 | .child = stack_trace_ty.toIntern(), |
| 25584 | .flags = .{ | 25584 | .flags = .{ |
| 25585 | .address_space = target_util.defaultAddressSpace(target, .global_constant), | 25585 | .address_space = target_util.defaultAddressSpace(target, .global_constant), |
| ... | @@ -25931,7 +25931,7 @@ fn fieldVal( | ... | @@ -25931,7 +25931,7 @@ fn fieldVal( |
| 25931 | return Air.internedToRef((try mod.intValue(Type.usize, inner_ty.arrayLen(mod))).toIntern()); | 25931 | return Air.internedToRef((try mod.intValue(Type.usize, inner_ty.arrayLen(mod))).toIntern()); |
| 25932 | } else if (ip.stringEqlSlice(field_name, "ptr") and is_pointer_to) { | 25932 | } else if (ip.stringEqlSlice(field_name, "ptr") and is_pointer_to) { |
| 25933 | const ptr_info = object_ty.ptrInfo(mod); | 25933 | const ptr_info = object_ty.ptrInfo(mod); |
| 25934 | const result_ty = try mod.ptrType(.{ | 25934 | const result_ty = try sema.ptrType(.{ |
| 25935 | .child = ptr_info.child.toType().childType(mod).toIntern(), | 25935 | .child = ptr_info.child.toType().childType(mod).toIntern(), |
| 25936 | .sentinel = ptr_info.sentinel, | 25936 | .sentinel = ptr_info.sentinel, |
| 25937 | .flags = .{ | 25937 | .flags = .{ |
| ... | @@ -26150,7 +26150,7 @@ fn fieldPtr( | ... | @@ -26150,7 +26150,7 @@ fn fieldPtr( |
| 26150 | if (ip.stringEqlSlice(field_name, "ptr")) { | 26150 | if (ip.stringEqlSlice(field_name, "ptr")) { |
| 26151 | const slice_ptr_ty = inner_ty.slicePtrFieldType(mod); | 26151 | const slice_ptr_ty = inner_ty.slicePtrFieldType(mod); |
| 26152 | | 26152 | |
| 26153 | const result_ty = try mod.ptrType(.{ | 26153 | const result_ty = try sema.ptrType(.{ |
| 26154 | .child = slice_ptr_ty.toIntern(), | 26154 | .child = slice_ptr_ty.toIntern(), |
| 26155 | .flags = .{ | 26155 | .flags = .{ |
| 26156 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), | 26156 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -26172,7 +26172,7 @@ fn fieldPtr( | ... | @@ -26172,7 +26172,7 @@ fn fieldPtr( |
| 26172 | | 26172 | |
| 26173 | return block.addTyOp(.ptr_slice_ptr_ptr, result_ty, inner_ptr); | 26173 | return block.addTyOp(.ptr_slice_ptr_ptr, result_ty, inner_ptr); |
| 26174 | } else if (ip.stringEqlSlice(field_name, "len")) { | 26174 | } else if (ip.stringEqlSlice(field_name, "len")) { |
| 26175 | const result_ty = try mod.ptrType(.{ | 26175 | const result_ty = try sema.ptrType(.{ |
| 26176 | .child = .usize_type, | 26176 | .child = .usize_type, |
| 26177 | .flags = .{ | 26177 | .flags = .{ |
| 26178 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), | 26178 | .is_const = !attr_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -26497,7 +26497,7 @@ fn finishFieldCallBind( | ... | @@ -26497,7 +26497,7 @@ fn finishFieldCallBind( |
| 26497 | object_ptr: Air.Inst.Ref, | 26497 | object_ptr: Air.Inst.Ref, |
| 26498 | ) CompileError!ResolvedFieldCallee { | 26498 | ) CompileError!ResolvedFieldCallee { |
| 26499 | const mod = sema.mod; | 26499 | const mod = sema.mod; |
| 26500 | const ptr_field_ty = try mod.ptrType(.{ | 26500 | const ptr_field_ty = try sema.ptrType(.{ |
| 26501 | .child = field_ty.toIntern(), | 26501 | .child = field_ty.toIntern(), |
| 26502 | .flags = .{ | 26502 | .flags = .{ |
| 26503 | .is_const = !ptr_ty.ptrIsMutable(mod), | 26503 | .is_const = !ptr_ty.ptrIsMutable(mod), |
| ... | @@ -26715,7 +26715,7 @@ fn structFieldPtrByIndex( | ... | @@ -26715,7 +26715,7 @@ fn structFieldPtrByIndex( |
| 26715 | ptr_ty_data.flags.alignment = field_align.min(parent_align); | 26715 | ptr_ty_data.flags.alignment = field_align.min(parent_align); |
| 26716 | } | 26716 | } |
| 26717 | | 26717 | |
| 26718 | const ptr_field_ty = try mod.ptrType(ptr_ty_data); | 26718 | const ptr_field_ty = try sema.ptrType(ptr_ty_data); |
| 26719 | | 26719 | |
| 26720 | if (struct_type.fieldIsComptime(ip, field_index)) { | 26720 | if (struct_type.fieldIsComptime(ip, field_index)) { |
| 26721 | const val = try mod.intern(.{ .ptr = .{ | 26721 | const val = try mod.intern(.{ .ptr = .{ |
| ... | @@ -26888,7 +26888,7 @@ fn unionFieldPtr( | ... | @@ -26888,7 +26888,7 @@ fn unionFieldPtr( |
| 26888 | const union_obj = mod.typeToUnion(union_ty).?; | 26888 | const union_obj = mod.typeToUnion(union_ty).?; |
| 26889 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); | 26889 | const field_index = try sema.unionFieldIndex(block, union_ty, field_name, field_name_src); |
| 26890 | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); | 26890 | const field_ty = union_obj.field_types.get(ip)[field_index].toType(); |
| 26891 | const ptr_field_ty = try mod.ptrType(.{ | 26891 | const ptr_field_ty = try sema.ptrType(.{ |
| 26892 | .child = field_ty.toIntern(), | 26892 | .child = field_ty.toIntern(), |
| 26893 | .flags = .{ | 26893 | .flags = .{ |
| 26894 | .is_const = union_ptr_info.flags.is_const, | 26894 | .is_const = union_ptr_info.flags.is_const, |
| ... | @@ -27269,7 +27269,7 @@ fn tupleFieldPtr( | ... | @@ -27269,7 +27269,7 @@ fn tupleFieldPtr( |
| 27269 | } | 27269 | } |
| 27270 | | 27270 | |
| 27271 | const field_ty = tuple_ty.structFieldType(field_index, mod); | 27271 | const field_ty = tuple_ty.structFieldType(field_index, mod); |
| 27272 | const ptr_field_ty = try mod.ptrType(.{ | 27272 | const ptr_field_ty = try sema.ptrType(.{ |
| 27273 | .child = field_ty.toIntern(), | 27273 | .child = field_ty.toIntern(), |
| 27274 | .flags = .{ | 27274 | .flags = .{ |
| 27275 | .is_const = !tuple_ptr_ty.ptrIsMutable(mod), | 27275 | .is_const = !tuple_ptr_ty.ptrIsMutable(mod), |
| ... | @@ -31309,7 +31309,7 @@ fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: boo | ... | @@ -31309,7 +31309,7 @@ fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: boo |
| 31309 | | 31309 | |
| 31310 | const decl = mod.declPtr(decl_index); | 31310 | const decl = mod.declPtr(decl_index); |
| 31311 | const decl_tv = try decl.typedValue(); | 31311 | const decl_tv = try decl.typedValue(); |
| 31312 | const ptr_ty = try mod.ptrType(.{ | 31312 | const ptr_ty = try sema.ptrType(.{ |
| 31313 | .child = decl_tv.ty.toIntern(), | 31313 | .child = decl_tv.ty.toIntern(), |
| 31314 | .flags = .{ | 31314 | .flags = .{ |
| 31315 | .alignment = decl.alignment, | 31315 | .alignment = decl.alignment, |
| ... | @@ -31363,14 +31363,14 @@ fn analyzeRef( | ... | @@ -31363,14 +31363,14 @@ fn analyzeRef( |
| 31363 | | 31363 | |
| 31364 | try sema.requireRuntimeBlock(block, src, null); | 31364 | try sema.requireRuntimeBlock(block, src, null); |
| 31365 | const address_space = target_util.defaultAddressSpace(mod.getTarget(), .local); | 31365 | const address_space = target_util.defaultAddressSpace(mod.getTarget(), .local); |
| 31366 | const ptr_type = try mod.ptrType(.{ | 31366 | const ptr_type = try sema.ptrType(.{ |
| 31367 | .child = operand_ty.toIntern(), | 31367 | .child = operand_ty.toIntern(), |
| 31368 | .flags = .{ | 31368 | .flags = .{ |
| 31369 | .is_const = true, | 31369 | .is_const = true, |
| 31370 | .address_space = address_space, | 31370 | .address_space = address_space, |
| 31371 | }, | 31371 | }, |
| 31372 | }); | 31372 | }); |
| 31373 | const mut_ptr_type = try mod.ptrType(.{ | 31373 | const mut_ptr_type = try sema.ptrType(.{ |
| 31374 | .child = operand_ty.toIntern(), | 31374 | .child = operand_ty.toIntern(), |
| 31375 | .flags = .{ .address_space = address_space }, | 31375 | .flags = .{ .address_space = address_space }, |
| 31376 | }); | 31376 | }); |
| ... | @@ -31742,7 +31742,7 @@ fn analyzeSlice( | ... | @@ -31742,7 +31742,7 @@ fn analyzeSlice( |
| 31742 | assert(manyptr_ty_key.flags.size == .One); | 31742 | assert(manyptr_ty_key.flags.size == .One); |
| 31743 | manyptr_ty_key.child = elem_ty.toIntern(); | 31743 | manyptr_ty_key.child = elem_ty.toIntern(); |
| 31744 | manyptr_ty_key.flags.size = .Many; | 31744 | manyptr_ty_key.flags.size = .Many; |
| 31745 | break :ptr try sema.coerceCompatiblePtrs(block, try mod.ptrType(manyptr_ty_key), ptr_or_slice, ptr_src); | 31745 | break :ptr try sema.coerceCompatiblePtrs(block, try sema.ptrType(manyptr_ty_key), ptr_or_slice, ptr_src); |
| 31746 | } else ptr_or_slice; | 31746 | } else ptr_or_slice; |
| 31747 | | 31747 | |
| 31748 | const start = try sema.coerce(block, Type.usize, uncasted_start, start_src); | 31748 | const start = try sema.coerce(block, Type.usize, uncasted_start, start_src); |
| ... | @@ -31965,7 +31965,7 @@ fn analyzeSlice( | ... | @@ -31965,7 +31965,7 @@ fn analyzeSlice( |
| 31965 | if (opt_new_len_val) |new_len_val| { | 31965 | if (opt_new_len_val) |new_len_val| { |
| 31966 | const new_len_int = new_len_val.toUnsignedInt(mod); | 31966 | const new_len_int = new_len_val.toUnsignedInt(mod); |
| 31967 | | 31967 | |
| 31968 | const return_ty = try mod.ptrType(.{ | 31968 | const return_ty = try sema.ptrType(.{ |
| 31969 | .child = (try mod.arrayType(.{ | 31969 | .child = (try mod.arrayType(.{ |
| 31970 | .len = new_len_int, | 31970 | .len = new_len_int, |
| 31971 | .sentinel = if (sentinel) |s| s.toIntern() else .none, | 31971 | .sentinel = if (sentinel) |s| s.toIntern() else .none, |
| ... | @@ -32026,7 +32026,7 @@ fn analyzeSlice( | ... | @@ -32026,7 +32026,7 @@ fn analyzeSlice( |
| 32026 | return sema.fail(block, src, "non-zero length slice of undefined pointer", .{}); | 32026 | return sema.fail(block, src, "non-zero length slice of undefined pointer", .{}); |
| 32027 | } | 32027 | } |
| 32028 | | 32028 | |
| 32029 | const return_ty = try mod.ptrType(.{ | 32029 | const return_ty = try sema.ptrType(.{ |
| 32030 | .child = elem_ty.toIntern(), | 32030 | .child = elem_ty.toIntern(), |
| 32031 | .sentinel = if (sentinel) |s| s.toIntern() else .none, | 32031 | .sentinel = if (sentinel) |s| s.toIntern() else .none, |
| 32032 | .flags = .{ | 32032 | .flags = .{ |
| ... | @@ -33293,7 +33293,7 @@ fn resolvePeerTypesInner( | ... | @@ -33293,7 +33293,7 @@ fn resolvePeerTypesInner( |
| 33293 | | 33293 | |
| 33294 | opt_ptr_info = ptr_info; | 33294 | opt_ptr_info = ptr_info; |
| 33295 | } | 33295 | } |
| 33296 | return .{ .success = try mod.ptrType(opt_ptr_info.?) }; | 33296 | return .{ .success = try sema.ptrType(opt_ptr_info.?) }; |
| 33297 | }, | 33297 | }, |
| 33298 | | 33298 | |
| 33299 | .ptr => { | 33299 | .ptr => { |
| ... | @@ -33603,7 +33603,7 @@ fn resolvePeerTypesInner( | ... | @@ -33603,7 +33603,7 @@ fn resolvePeerTypesInner( |
| 33603 | }, | 33603 | }, |
| 33604 | } | 33604 | } |
| 33605 | | 33605 | |
| 33606 | return .{ .success = try mod.ptrType(opt_ptr_info.?) }; | 33606 | return .{ .success = try sema.ptrType(opt_ptr_info.?) }; |
| 33607 | }, | 33607 | }, |
| 33608 | | 33608 | |
| 33609 | .func => { | 33609 | .func => { |
| ... | @@ -36418,7 +36418,7 @@ fn analyzeComptimeAlloc( | ... | @@ -36418,7 +36418,7 @@ fn analyzeComptimeAlloc( |
| 36418 | // Needed to make an anon decl with type `var_type` (the `finish()` call below). | 36418 | // Needed to make an anon decl with type `var_type` (the `finish()` call below). |
| 36419 | _ = try sema.typeHasOnePossibleValue(var_type); | 36419 | _ = try sema.typeHasOnePossibleValue(var_type); |
| 36420 | | 36420 | |
| 36421 | const ptr_type = try mod.ptrType(.{ | 36421 | const ptr_type = try sema.ptrType(.{ |
| 36422 | .child = var_type.toIntern(), | 36422 | .child = var_type.toIntern(), |
| 36423 | .flags = .{ | 36423 | .flags = .{ |
| 36424 | .alignment = alignment, | 36424 | .alignment = alignment, |
| ... | @@ -37576,7 +37576,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { | ... | @@ -37576,7 +37576,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { |
| 37576 | assert(new_align != .none); | 37576 | assert(new_align != .none); |
| 37577 | break :a new_align; | 37577 | break :a new_align; |
| 37578 | }; | 37578 | }; |
| 37579 | return mod.ptrType(.{ | 37579 | return sema.ptrType(.{ |
| 37580 | .child = elem_ty.toIntern(), | 37580 | .child = elem_ty.toIntern(), |
| 37581 | .flags = .{ | 37581 | .flags = .{ |
| 37582 | .alignment = alignment, | 37582 | .alignment = alignment, |
| ... | @@ -37631,3 +37631,10 @@ fn isKnownZigType(sema: *Sema, ref: Air.Inst.Ref, tag: std.builtin.TypeId) bool | ... | @@ -37631,3 +37631,10 @@ fn isKnownZigType(sema: *Sema, ref: Air.Inst.Ref, tag: std.builtin.TypeId) bool |
| 37631 | }; | 37631 | }; |
| 37632 | return sema.typeOf(ref).zigTypeTag(sema.mod) == tag; | 37632 | return sema.typeOf(ref).zigTypeTag(sema.mod) == tag; |
| 37633 | } | 37633 | } |
| | 37634 | |
| | 37635 | fn ptrType(sema: *Sema, info: InternPool.Key.PtrType) CompileError!Type { |
| | 37636 | if (info.flags.alignment != .none) { |
| | 37637 | _ = try sema.typeAbiAlignment(info.child.toType()); |
| | 37638 | } |
| | 37639 | return sema.mod.ptrType(info); |
| | 37640 | } |