| ... | @@ -3081,7 +3081,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins | ... | @@ -3081,7 +3081,7 @@ fn zirRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins |
| 3081 | | 3081 | |
| 3082 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; | 3082 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| 3083 | const operand = sema.resolveInst(inst_data.operand); | 3083 | const operand = sema.resolveInst(inst_data.operand); |
| 3084 | return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand); | 3084 | return sema.analyzeRef(block, block.tokenOffset(inst_data.src_tok), operand, .none); |
| 3085 | } | 3085 | } |
| 3086 | | 3086 | |
| 3087 | fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { | 3087 | fn zirEnsureResultUsed(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void { |
| ... | @@ -18690,7 +18690,7 @@ fn zirStructInit( | ... | @@ -18690,7 +18690,7 @@ fn zirStructInit( |
| 18690 | const union_val = try sema.bitCast(block, resolved_ty, init_inst, src, field_src); | 18690 | const union_val = try sema.bitCast(block, resolved_ty, init_inst, src, field_src); |
| 18691 | const result_val = try sema.coerce(block, result_ty, union_val, src); | 18691 | const result_val = try sema.coerce(block, result_ty, union_val, src); |
| 18692 | if (is_ref) { | 18692 | if (is_ref) { |
| 18693 | return sema.analyzeRef(block, src, result_val); | 18693 | return sema.analyzeRef(block, src, result_val, .none); |
| 18694 | } else { | 18694 | } else { |
| 18695 | return result_val; | 18695 | return result_val; |
| 18696 | } | 18696 | } |
| ... | @@ -24192,7 +24192,7 @@ fn zirMemcpy( | ... | @@ -24192,7 +24192,7 @@ fn zirMemcpy( |
| 24192 | } | 24192 | } |
| 24193 | } else if (dest_len == .none and len_val == null) { | 24193 | } else if (dest_len == .none and len_val == null) { |
| 24194 | // Change the dest to a slice, since its type must have the length. | 24194 | // Change the dest to a slice, since its type must have the length. |
| 24195 | const dest_ptr_ptr = try sema.analyzeRef(block, dest_src, new_dest_ptr); | 24195 | const dest_ptr_ptr = try sema.analyzeRef(block, dest_src, new_dest_ptr, .none); |
| 24196 | new_dest_ptr = try sema.analyzeSlice(block, dest_src, dest_ptr_ptr, .zero, src_len, .none, LazySrcLoc.unneeded, dest_src, dest_src, dest_src, false); | 24196 | new_dest_ptr = try sema.analyzeSlice(block, dest_src, dest_ptr_ptr, .zero, src_len, .none, LazySrcLoc.unneeded, dest_src, dest_src, dest_src, false); |
| 24197 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); | 24197 | const new_src_ptr_ty = sema.typeOf(new_src_ptr); |
| 24198 | if (new_src_ptr_ty.isSlice(zcu)) { | 24198 | if (new_src_ptr_ty.isSlice(zcu)) { |
| ... | @@ -26301,7 +26301,7 @@ fn structFieldPtr( | ... | @@ -26301,7 +26301,7 @@ fn structFieldPtr( |
| 26301 | const field_index: u32 = if (struct_ty.isTuple(zcu)) field_index: { | 26301 | const field_index: u32 = if (struct_ty.isTuple(zcu)) field_index: { |
| 26302 | if (field_name.eqlSlice("len", ip)) { | 26302 | if (field_name.eqlSlice("len", ip)) { |
| 26303 | const len_inst = try pt.intRef(.usize, struct_ty.structFieldCount(zcu)); | 26303 | const len_inst = try pt.intRef(.usize, struct_ty.structFieldCount(zcu)); |
| 26304 | return sema.analyzeRef(block, src, len_inst); | 26304 | return sema.analyzeRef(block, src, len_inst, .none); |
| 26305 | } | 26305 | } |
| 26306 | break :field_index try sema.tupleFieldIndex(block, struct_ty, field_name, field_name_src); | 26306 | break :field_index try sema.tupleFieldIndex(block, struct_ty, field_name, field_name_src); |
| 26307 | } else field_index: { | 26307 | } else field_index: { |
| ... | @@ -29787,10 +29787,7 @@ fn coerceTupleToSlicePtrs( | ... | @@ -29787,10 +29787,7 @@ fn coerceTupleToSlicePtrs( |
| 29787 | .child = slice_info.child, | 29787 | .child = slice_info.child, |
| 29788 | }); | 29788 | }); |
| 29789 | const array_inst = try sema.coerceTupleToArray(block, array_ty, slice_ty_src, tuple, tuple_src); | 29789 | const array_inst = try sema.coerceTupleToArray(block, array_ty, slice_ty_src, tuple, tuple_src); |
| 29790 | if (slice_info.flags.alignment != .none) { | 29790 | const ptr_array = try sema.analyzeRef(block, slice_ty_src, array_inst, slice_info.flags.alignment); |
| 29791 | return sema.fail(block, slice_ty_src, "TODO: override the alignment of the array decl we create here", .{}); | | |
| 29792 | } | | |
| 29793 | const ptr_array = try sema.analyzeRef(block, slice_ty_src, array_inst); | | |
| 29794 | return sema.coerceArrayPtrToSlice(block, slice_ty, ptr_array, slice_ty_src); | 29791 | return sema.coerceArrayPtrToSlice(block, slice_ty, ptr_array, slice_ty_src); |
| 29795 | } | 29792 | } |
| 29796 | | 29793 | |
| ... | @@ -29809,10 +29806,7 @@ fn coerceTupleToArrayPtrs( | ... | @@ -29809,10 +29806,7 @@ fn coerceTupleToArrayPtrs( |
| 29809 | const ptr_info = ptr_array_ty.ptrInfo(zcu); | 29806 | const ptr_info = ptr_array_ty.ptrInfo(zcu); |
| 29810 | const array_ty: Type = .fromInterned(ptr_info.child); | 29807 | const array_ty: Type = .fromInterned(ptr_info.child); |
| 29811 | const array_inst = try sema.coerceTupleToArray(block, array_ty, array_ty_src, tuple, tuple_src); | 29808 | const array_inst = try sema.coerceTupleToArray(block, array_ty, array_ty_src, tuple, tuple_src); |
| 29812 | if (ptr_info.flags.alignment != .none) { | 29809 | const ptr_array = try sema.analyzeRef(block, array_ty_src, array_inst, ptr_info.flags.alignment); |
| 29813 | return sema.fail(block, array_ty_src, "TODO: override the alignment of the array decl we create here", .{}); | | |
| 29814 | } | | |
| 29815 | const ptr_array = try sema.analyzeRef(block, array_ty_src, array_inst); | | |
| 29816 | return ptr_array; | 29810 | return ptr_array; |
| 29817 | } | 29811 | } |
| 29818 | | 29812 | |
| ... | @@ -30137,34 +30131,48 @@ fn analyzeRef( | ... | @@ -30137,34 +30131,48 @@ fn analyzeRef( |
| 30137 | block: *Block, | 30131 | block: *Block, |
| 30138 | src: LazySrcLoc, | 30132 | src: LazySrcLoc, |
| 30139 | operand: Air.Inst.Ref, | 30133 | operand: Air.Inst.Ref, |
| | 30134 | alignment: Alignment, |
| 30140 | ) CompileError!Air.Inst.Ref { | 30135 | ) CompileError!Air.Inst.Ref { |
| 30141 | const pt = sema.pt; | 30136 | const pt = sema.pt; |
| 30142 | const zcu = pt.zcu; | 30137 | const zcu = pt.zcu; |
| 30143 | const operand_ty = sema.typeOf(operand); | 30138 | const operand_ty = sema.typeOf(operand); |
| 30144 | | 30139 | |
| | 30140 | const address_space = target_util.defaultAddressSpace(zcu.getTarget(), .local); |
| | 30141 | const ptr_type = try pt.ptrType(.{ |
| | 30142 | .child = operand_ty.toIntern(), |
| | 30143 | .flags = .{ |
| | 30144 | .alignment = alignment, |
| | 30145 | .is_const = true, |
| | 30146 | .address_space = address_space, |
| | 30147 | }, |
| | 30148 | }); |
| | 30149 | |
| 30145 | if (sema.resolveValue(operand)) |val| { | 30150 | if (sema.resolveValue(operand)) |val| { |
| 30146 | switch (zcu.intern_pool.indexToKey(val.toIntern())) { | 30151 | switch (zcu.intern_pool.indexToKey(val.toIntern())) { |
| 30147 | .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav), | 30152 | .@"extern" => |e| return sema.analyzeNavRef(block, src, e.owner_nav), |
| 30148 | .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav), | 30153 | .func => |f| return sema.analyzeNavRef(block, src, f.owner_nav), |
| 30149 | else => return uavRef(sema, val), | 30154 | else => return .fromIntern(try pt.intern(.{ .ptr = .{ |
| | 30155 | .ty = ptr_type.toIntern(), |
| | 30156 | .base_addr = .{ .uav = .{ |
| | 30157 | .val = val.toIntern(), |
| | 30158 | .orig_ty = ptr_type.toIntern(), |
| | 30159 | } }, |
| | 30160 | .byte_offset = 0, |
| | 30161 | } })), |
| 30150 | } | 30162 | } |
| 30151 | } | 30163 | } |
| 30152 | | 30164 | |
| 30153 | // No `requireRuntimeBlock`; it's okay to `ref` to a runtime value in a comptime context, | 30165 | // No `requireRuntimeBlock`; it's okay to `ref` to a runtime value in a comptime context, |
| 30154 | // it's just that we can only use the *type* of the result, since the value is runtime-known. | 30166 | // it's just that we can only use the *type* of the result, since the value is runtime-known. |
| 30155 | | 30167 | |
| 30156 | const address_space = target_util.defaultAddressSpace(zcu.getTarget(), .local); | 30168 | const mut_ptr_type = try pt.ptrType(.{ |
| 30157 | const ptr_type = try pt.ptrType(.{ | | |
| 30158 | .child = operand_ty.toIntern(), | 30169 | .child = operand_ty.toIntern(), |
| 30159 | .flags = .{ | 30170 | .flags = .{ |
| 30160 | .is_const = true, | 30171 | .alignment = alignment, |
| | 30172 | .is_const = false, |
| 30161 | .address_space = address_space, | 30173 | .address_space = address_space, |
| 30162 | }, | 30174 | }, |
| 30163 | }); | 30175 | }); |
| 30164 | const mut_ptr_type = try pt.ptrType(.{ | | |
| 30165 | .child = operand_ty.toIntern(), | | |
| 30166 | .flags = .{ .address_space = address_space }, | | |
| 30167 | }); | | |
| 30168 | const alloc = try block.addTy(.alloc, mut_ptr_type); | 30176 | const alloc = try block.addTy(.alloc, mut_ptr_type); |
| 30169 | | 30177 | |
| 30170 | // In a comptime context, the store would fail, since the operand is runtime-known. But that's | 30178 | // In a comptime context, the store would fail, since the operand is runtime-known. But that's |