| ... | @@ -29649,50 +29649,6 @@ pub fn coerceInMemoryAllowed( | ... | @@ -29649,50 +29649,6 @@ pub fn coerceInMemoryAllowed( |
| 29649 | return .ok; | 29649 | return .ok; |
| 29650 | } | 29650 | } |
| 29651 | | 29651 | |
| 29652 | // Arrays <-> Vectors | | |
| 29653 | if ((dest_tag == .vector and src_tag == .array) or | | |
| 29654 | (dest_tag == .array and src_tag == .vector)) | | |
| 29655 | { | | |
| 29656 | const dest_len = dest_ty.arrayLen(zcu); | | |
| 29657 | const src_len = src_ty.arrayLen(zcu); | | |
| 29658 | if (dest_len != src_len) { | | |
| 29659 | return .{ .array_len = .{ | | |
| 29660 | .actual = src_len, | | |
| 29661 | .wanted = dest_len, | | |
| 29662 | } }; | | |
| 29663 | } | | |
| 29664 | | | |
| 29665 | const dest_elem_ty = dest_ty.childType(zcu); | | |
| 29666 | const src_elem_ty = src_ty.childType(zcu); | | |
| 29667 | const child = try sema.coerceInMemoryAllowed(block, dest_elem_ty, src_elem_ty, dest_is_mut, target, dest_src, src_src, null); | | |
| 29668 | if (child != .ok) { | | |
| 29669 | return .{ .array_elem = .{ | | |
| 29670 | .child = try child.dupe(sema.arena), | | |
| 29671 | .actual = src_elem_ty, | | |
| 29672 | .wanted = dest_elem_ty, | | |
| 29673 | } }; | | |
| 29674 | } | | |
| 29675 | | | |
| 29676 | if (dest_tag == .array) { | | |
| 29677 | const dest_info = dest_ty.arrayInfo(zcu); | | |
| 29678 | if (dest_info.sentinel != null) { | | |
| 29679 | return .{ .array_sentinel = .{ | | |
| 29680 | .actual = Value.@"unreachable", | | |
| 29681 | .wanted = dest_info.sentinel.?, | | |
| 29682 | .ty = dest_info.elem_type, | | |
| 29683 | } }; | | |
| 29684 | } | | |
| 29685 | } | | |
| 29686 | | | |
| 29687 | // The memory layout of @Vector(N, iM) is the same as the integer type i(N*M), | | |
| 29688 | // that is to say, the padding bits are not in the same place as the array [N]iM. | | |
| 29689 | // If there's no padding, the bitcast is possible. | | |
| 29690 | const elem_bit_size = dest_elem_ty.bitSize(zcu); | | |
| 29691 | const elem_abi_byte_size = dest_elem_ty.abiSize(zcu); | | |
| 29692 | if (elem_abi_byte_size * 8 == elem_bit_size) | | |
| 29693 | return .ok; | | |
| 29694 | } | | |
| 29695 | | | |
| 29696 | // Optionals | 29652 | // Optionals |
| 29697 | if (dest_tag == .optional and src_tag == .optional) { | 29653 | if (dest_tag == .optional and src_tag == .optional) { |
| 29698 | if ((maybe_dest_ptr_ty != null) != (maybe_src_ptr_ty != null)) { | 29654 | if ((maybe_dest_ptr_ty != null) != (maybe_src_ptr_ty != null)) { |