| author | |
| committer | |
| log | 98046b4c3c09d3d115b38a943fce328a2dc20dc4 |
| tree | e42ec5c302a5bd32cbfcb08645a788afede54d48 |
| parent | 6f55a689644fa85a6f650e6d33bcb882b1f507cd |
2 files changed, 45 insertions(+), 60 deletions(-)
src/codegen/spirv.zig+45-41| ... | @@ -1662,13 +1662,11 @@ pub const DeclGen = struct { | ... | @@ -1662,13 +1662,11 @@ pub const DeclGen = struct { |
| 1662 | return try self.convertToDirect(result_ty, result_id); | 1662 | return try self.convertToDirect(result_ty, result_id); |
| 1663 | } | 1663 | } |
| 1664 | 1664 | ||
| 1665 | fn load(self: *DeclGen, ptr_ty: Type, ptr_id: IdRef) !IdRef { | 1665 | fn load(self: *DeclGen, value_ty: Type, ptr_id: IdRef, is_volatile: bool) !IdRef { |
| 1666 | const mod = self.module; | ||
| 1667 | const value_ty = ptr_ty.childType(mod); | ||
| 1668 | const indirect_value_ty_ref = try self.resolveType(value_ty, .indirect); | 1666 | const indirect_value_ty_ref = try self.resolveType(value_ty, .indirect); |
| 1669 | const result_id = self.spv.allocId(); | 1667 | const result_id = self.spv.allocId(); |
| 1670 | const access = spec.MemoryAccess.Extended{ | 1668 | const access = spec.MemoryAccess.Extended{ |
| 1671 | .Volatile = ptr_ty.isVolatilePtr(mod), | 1669 | .Volatile = is_volatile, |
| 1672 | }; | 1670 | }; |
| 1673 | try self.func.body.emit(self.spv.gpa, .OpLoad, .{ | 1671 | try self.func.body.emit(self.spv.gpa, .OpLoad, .{ |
| 1674 | .id_result_type = self.typeId(indirect_value_ty_ref), | 1672 | .id_result_type = self.typeId(indirect_value_ty_ref), |
| ... | @@ -1679,12 +1677,10 @@ pub const DeclGen = struct { | ... | @@ -1679,12 +1677,10 @@ pub const DeclGen = struct { |
| 1679 | return try self.convertToDirect(value_ty, result_id); | 1677 | return try self.convertToDirect(value_ty, result_id); |
| 1680 | } | 1678 | } |
| 1681 | 1679 | ||
| 1682 | fn store(self: *DeclGen, ptr_ty: Type, ptr_id: IdRef, value_id: IdRef) !void { | 1680 | fn store(self: *DeclGen, value_ty: Type, ptr_id: IdRef, value_id: IdRef, is_volatile: bool) !void { |
| 1683 | const mod = self.module; | ||
| 1684 | const value_ty = ptr_ty.childType(mod); | ||
| 1685 | const indirect_value_id = try self.convertToIndirect(value_ty, value_id); | 1681 | const indirect_value_id = try self.convertToIndirect(value_ty, value_id); |
| 1686 | const access = spec.MemoryAccess.Extended{ | 1682 | const access = spec.MemoryAccess.Extended{ |
| 1687 | .Volatile = ptr_ty.isVolatilePtr(mod), | 1683 | .Volatile = is_volatile, |
| 1688 | }; | 1684 | }; |
| 1689 | try self.func.body.emit(self.spv.gpa, .OpStore, .{ | 1685 | try self.func.body.emit(self.spv.gpa, .OpStore, .{ |
| 1690 | .pointer = ptr_id, | 1686 | .pointer = ptr_id, |
| ... | @@ -1754,6 +1750,7 @@ pub const DeclGen = struct { | ... | @@ -1754,6 +1750,7 @@ pub const DeclGen = struct { |
| 1754 | .ptr_elem_ptr => try self.airPtrElemPtr(inst), | 1750 | .ptr_elem_ptr => try self.airPtrElemPtr(inst), |
| 1755 | .ptr_elem_val => try self.airPtrElemVal(inst), | 1751 | .ptr_elem_val => try self.airPtrElemVal(inst), |
| 1756 | 1752 | ||
| 1753 | .set_union_tag => return try self.airSetUnionTag(inst), | ||
| 1757 | .get_union_tag => try self.airGetUnionTag(inst), | 1754 | .get_union_tag => try self.airGetUnionTag(inst), |
| 1758 | .struct_field_val => try self.airStructFieldVal(inst), | 1755 | .struct_field_val => try self.airStructFieldVal(inst), |
| 1759 | 1756 | ||
| ... | @@ -2512,7 +2509,7 @@ pub const DeclGen = struct { | ... | @@ -2512,7 +2509,7 @@ pub const DeclGen = struct { |
| 2512 | 2509 | ||
| 2513 | const slice_ptr = try self.extractField(ptr_ty, slice_id, 0); | 2510 | const slice_ptr = try self.extractField(ptr_ty, slice_id, 0); |
| 2514 | const elem_ptr = try self.ptrAccessChain(ptr_ty_ref, slice_ptr, index_id, &.{}); | 2511 | const elem_ptr = try self.ptrAccessChain(ptr_ty_ref, slice_ptr, index_id, &.{}); |
| 2515 | return try self.load(slice_ty, elem_ptr); | 2512 | return try self.load(slice_ty.childType(mod), elem_ptr, slice_ty.isVolatilePtr(mod)); |
| 2516 | } | 2513 | } |
| 2517 | 2514 | ||
| 2518 | fn ptrElemPtr(self: *DeclGen, ptr_ty: Type, ptr_id: IdRef, index_id: IdRef) !IdRef { | 2515 | fn ptrElemPtr(self: *DeclGen, ptr_ty: Type, ptr_id: IdRef, index_id: IdRef) !IdRef { |
| ... | @@ -2548,25 +2545,41 @@ pub const DeclGen = struct { | ... | @@ -2548,25 +2545,41 @@ pub const DeclGen = struct { |
| 2548 | } | 2545 | } |
| 2549 | 2546 | ||
| 2550 | fn airPtrElemVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 2547 | fn airPtrElemVal(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2548 | if (self.liveness.isUnused(inst)) return null; | ||
| 2549 | |||
| 2551 | const mod = self.module; | 2550 | const mod = self.module; |
| 2552 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; | 2551 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; |
| 2553 | const ptr_ty = self.typeOf(bin_op.lhs); | 2552 | const ptr_ty = self.typeOf(bin_op.lhs); |
| 2553 | const elem_ty = self.typeOfIndex(inst); | ||
| 2554 | const ptr_id = try self.resolve(bin_op.lhs); | 2554 | const ptr_id = try self.resolve(bin_op.lhs); |
| 2555 | const index_id = try self.resolve(bin_op.rhs); | 2555 | const index_id = try self.resolve(bin_op.rhs); |
| 2556 | |||
| 2557 | const elem_ptr_id = try self.ptrElemPtr(ptr_ty, ptr_id, index_id); | 2556 | const elem_ptr_id = try self.ptrElemPtr(ptr_ty, ptr_id, index_id); |
| 2557 | return try self.load(elem_ty, elem_ptr_id, ptr_ty.isVolatilePtr(mod)); | ||
| 2558 | } | ||
| 2559 | |||
| 2560 | fn airSetUnionTag(self: *DeclGen, inst: Air.Inst.Index) !void { | ||
| 2561 | const mod = self.module; | ||
| 2562 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; | ||
| 2563 | const un_ptr_ty = self.typeOf(bin_op.lhs); | ||
| 2564 | const un_ty = un_ptr_ty.childType(mod); | ||
| 2565 | const layout = self.unionLayout(un_ty, null); | ||
| 2566 | |||
| 2567 | if (layout.tag_size == 0) return; | ||
| 2568 | |||
| 2569 | const tag_ty = un_ty.unionTagTypeSafety(mod).?; | ||
| 2570 | const tag_ty_ref = try self.resolveType(tag_ty, .indirect); | ||
| 2571 | const tag_ptr_ty_ref = try self.spv.ptrType(tag_ty_ref, spvStorageClass(un_ptr_ty.ptrAddressSpace(mod))); | ||
| 2558 | 2572 | ||
| 2559 | // If we have a pointer-to-array, construct an element pointer to use with load() | 2573 | const union_ptr_id = try self.resolve(bin_op.lhs); |
| 2560 | // If we pass ptr_ty directly, it will attempt to load the entire array rather than | 2574 | const new_tag_id = try self.resolve(bin_op.rhs); |
| 2561 | // just an element. | ||
| 2562 | var elem_ptr_info = ptr_ty.ptrInfo(mod); | ||
| 2563 | elem_ptr_info.flags.size = .One; | ||
| 2564 | const elem_ptr_ty = try mod.intern_pool.get(mod.gpa, .{ .ptr_type = elem_ptr_info }); | ||
| 2565 | 2575 | ||
| 2566 | return try self.load(elem_ptr_ty.toType(), elem_ptr_id); | 2576 | const ptr_id = try self.accessChain(tag_ptr_ty_ref, union_ptr_id, &.{layout.tag_index}); |
| 2577 | try self.store(tag_ty, ptr_id, new_tag_id, un_ptr_ty.isVolatilePtr(mod)); | ||
| 2567 | } | 2578 | } |
| 2568 | 2579 | ||
| 2569 | fn airGetUnionTag(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { | 2580 | fn airGetUnionTag(self: *DeclGen, inst: Air.Inst.Index) !?IdRef { |
| 2581 | if (self.liveness.isUnused(inst)) return null; | ||
| 2582 | |||
| 2570 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 2583 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 2571 | const un_ty = self.typeOf(ty_op.operand); | 2584 | const un_ty = self.typeOf(ty_op.operand); |
| 2572 | 2585 | ||
| ... | @@ -2588,25 +2601,25 @@ pub const DeclGen = struct { | ... | @@ -2588,25 +2601,25 @@ pub const DeclGen = struct { |
| 2588 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 2601 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 2589 | const struct_field = self.air.extraData(Air.StructField, ty_pl.payload).data; | 2602 | const struct_field = self.air.extraData(Air.StructField, ty_pl.payload).data; |
| 2590 | 2603 | ||
| 2591 | const container_ty = self.typeOf(struct_field.struct_operand); | 2604 | const object_ty = self.typeOf(struct_field.struct_operand); |
| 2592 | const object_id = try self.resolve(struct_field.struct_operand); | 2605 | const object_id = try self.resolve(struct_field.struct_operand); |
| 2593 | const field_index = struct_field.field_index; | 2606 | const field_index = struct_field.field_index; |
| 2594 | const field_ty = container_ty.structFieldType(field_index, mod); | 2607 | const field_ty = object_ty.structFieldType(field_index, mod); |
| 2595 | 2608 | ||
| 2596 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return null; | 2609 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return null; |
| 2597 | 2610 | ||
| 2598 | switch (container_ty.zigTypeTag(mod)) { | 2611 | switch (object_ty.zigTypeTag(mod)) { |
| 2599 | .Struct => switch (container_ty.containerLayout(mod)) { | 2612 | .Struct => switch (object_ty.containerLayout(mod)) { |
| 2600 | .Packed => unreachable, // TODO | 2613 | .Packed => unreachable, // TODO |
| 2601 | else => return try self.extractField(field_ty, object_id, field_index), | 2614 | else => return try self.extractField(field_ty, object_id, field_index), |
| 2602 | }, | 2615 | }, |
| 2603 | .Union => switch (container_ty.containerLayout(mod)) { | 2616 | .Union => switch (object_ty.containerLayout(mod)) { |
| 2604 | .Packed => unreachable, // TODO | 2617 | .Packed => unreachable, // TODO |
| 2605 | else => { | 2618 | else => { |
| 2606 | // Store, pointer-cast, load | 2619 | // Store, pointer-cast, load |
| 2607 | const un_general_ty_ref = try self.resolveType(container_ty, .indirect); | 2620 | const un_general_ty_ref = try self.resolveType(object_ty, .indirect); |
| 2608 | const un_general_ptr_ty_ref = try self.spv.ptrType(un_general_ty_ref, .Function); | 2621 | const un_general_ptr_ty_ref = try self.spv.ptrType(un_general_ty_ref, .Function); |
| 2609 | const un_active_ty_ref = try self.resolveUnionType(container_ty, field_index); | 2622 | const un_active_ty_ref = try self.resolveUnionType(object_ty, field_index); |
| 2610 | const un_active_ptr_ty_ref = try self.spv.ptrType(un_active_ty_ref, .Function); | 2623 | const un_active_ptr_ty_ref = try self.spv.ptrType(un_active_ty_ref, .Function); |
| 2611 | const field_ty_ref = try self.resolveType(field_ty, .indirect); | 2624 | const field_ty_ref = try self.resolveType(field_ty, .indirect); |
| 2612 | const field_ptr_ty_ref = try self.spv.ptrType(field_ty_ref, .Function); | 2625 | const field_ptr_ty_ref = try self.spv.ptrType(field_ty_ref, .Function); |
| ... | @@ -2617,31 +2630,20 @@ pub const DeclGen = struct { | ... | @@ -2617,31 +2630,20 @@ pub const DeclGen = struct { |
| 2617 | .id_result = tmp_id, | 2630 | .id_result = tmp_id, |
| 2618 | .storage_class = .Function, | 2631 | .storage_class = .Function, |
| 2619 | }); | 2632 | }); |
| 2620 | try self.func.body.emit(self.spv.gpa, .OpStore, .{ | 2633 | try self.store(object_ty, tmp_id, object_id, false); |
| 2621 | .pointer = tmp_id, | ||
| 2622 | .object = object_id, | ||
| 2623 | }); | ||
| 2624 | const casted_tmp_id = self.spv.allocId(); | 2634 | const casted_tmp_id = self.spv.allocId(); |
| 2625 | try self.func.body.emit(self.spv.gpa, .OpBitcast, .{ | 2635 | try self.func.body.emit(self.spv.gpa, .OpBitcast, .{ |
| 2626 | .id_result_type = self.typeId(un_active_ptr_ty_ref), | 2636 | .id_result_type = self.typeId(un_active_ptr_ty_ref), |
| 2627 | .id_result = casted_tmp_id, | 2637 | .id_result = casted_tmp_id, |
| 2628 | .operand = tmp_id, | 2638 | .operand = tmp_id, |
| 2629 | }); | 2639 | }); |
| 2630 | const layout = self.unionLayout(container_ty, field_index); | 2640 | const layout = self.unionLayout(object_ty, field_index); |
| 2631 | const field_ptr_id = try self.accessChain(field_ptr_ty_ref, casted_tmp_id, &.{layout.active_field_index}); | 2641 | const field_ptr_id = try self.accessChain(field_ptr_ty_ref, casted_tmp_id, &.{layout.active_field_index}); |
| 2632 | const result_id = self.spv.allocId(); | 2642 | return try self.load(field_ty, field_ptr_id, false); |
| 2633 | try self.func.body.emit(self.spv.gpa, .OpLoad, .{ | ||
| 2634 | .id_result_type = self.typeId(field_ty_ref), | ||
| 2635 | .id_result = result_id, | ||
| 2636 | .pointer = field_ptr_id, | ||
| 2637 | }); | ||
| 2638 | return try self.convertToDirect(field_ty, result_id); | ||
| 2639 | }, | 2643 | }, |
| 2640 | }, | 2644 | }, |
| 2641 | else => unreachable, | 2645 | else => unreachable, |
| 2642 | } | 2646 | } |
| 2643 | |||
| 2644 | // return try self.extractField(field_ty, object_id, field_index); | ||
| 2645 | } | 2647 | } |
| 2646 | 2648 | ||
| 2647 | fn structFieldPtr( | 2649 | fn structFieldPtr( |
| ... | @@ -2866,19 +2868,21 @@ pub const DeclGen = struct { | ... | @@ -2866,19 +2868,21 @@ pub const DeclGen = struct { |
| 2866 | const mod = self.module; | 2868 | const mod = self.module; |
| 2867 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; | 2869 | const ty_op = self.air.instructions.items(.data)[inst].ty_op; |
| 2868 | const ptr_ty = self.typeOf(ty_op.operand); | 2870 | const ptr_ty = self.typeOf(ty_op.operand); |
| 2871 | const elem_ty = self.typeOfIndex(inst); | ||
| 2869 | const operand = try self.resolve(ty_op.operand); | 2872 | const operand = try self.resolve(ty_op.operand); |
| 2870 | if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) return null; | 2873 | if (!ptr_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) return null; |
| 2871 | 2874 | ||
| 2872 | return try self.load(ptr_ty, operand); | 2875 | return try self.load(elem_ty, operand, ptr_ty.isVolatilePtr(mod)); |
| 2873 | } | 2876 | } |
| 2874 | 2877 | ||
| 2875 | fn airStore(self: *DeclGen, inst: Air.Inst.Index) !void { | 2878 | fn airStore(self: *DeclGen, inst: Air.Inst.Index) !void { |
| 2876 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; | 2879 | const bin_op = self.air.instructions.items(.data)[inst].bin_op; |
| 2877 | const ptr_ty = self.typeOf(bin_op.lhs); | 2880 | const ptr_ty = self.typeOf(bin_op.lhs); |
| 2881 | const elem_ty = ptr_ty.childType(self.module); | ||
| 2878 | const ptr = try self.resolve(bin_op.lhs); | 2882 | const ptr = try self.resolve(bin_op.lhs); |
| 2879 | const value = try self.resolve(bin_op.rhs); | 2883 | const value = try self.resolve(bin_op.rhs); |
| 2880 | 2884 | ||
| 2881 | try self.store(ptr_ty, ptr, value); | 2885 | try self.store(elem_ty, ptr, value, ptr_ty.isVolatilePtr(self.module)); |
| 2882 | } | 2886 | } |
| 2883 | 2887 | ||
| 2884 | fn airLoop(self: *DeclGen, inst: Air.Inst.Index) !void { | 2888 | fn airLoop(self: *DeclGen, inst: Air.Inst.Index) !void { |
| ... | @@ -2922,7 +2926,7 @@ pub const DeclGen = struct { | ... | @@ -2922,7 +2926,7 @@ pub const DeclGen = struct { |
| 2922 | } | 2926 | } |
| 2923 | 2927 | ||
| 2924 | const ptr = try self.resolve(un_op); | 2928 | const ptr = try self.resolve(un_op); |
| 2925 | const value = try self.load(ptr_ty, ptr); | 2929 | const value = try self.load(ret_ty, ptr, ptr_ty.isVolatilePtr(mod)); |
| 2926 | try self.func.body.emit(self.spv.gpa, .OpReturnValue, .{ | 2930 | try self.func.body.emit(self.spv.gpa, .OpReturnValue, .{ |
| 2927 | .value = value, | 2931 | .value = value, |
| 2928 | }); | 2932 | }); |
test/behavior/union.zig-19| ... | @@ -29,7 +29,6 @@ test "init union with runtime value - floats" { | ... | @@ -29,7 +29,6 @@ test "init union with runtime value - floats" { |
| 29 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 29 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 30 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 30 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 31 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 31 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 32 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 33 | 32 | ||
| 34 | var foo: FooWithFloats = undefined; | 33 | var foo: FooWithFloats = undefined; |
| 35 | 34 | ||
| ... | @@ -59,7 +58,6 @@ test "init union with runtime value" { | ... | @@ -59,7 +58,6 @@ test "init union with runtime value" { |
| 59 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 58 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 60 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 59 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 61 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 60 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 62 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 63 | 61 | ||
| 64 | var foo: Foo = undefined; | 62 | var foo: Foo = undefined; |
| 65 | 63 | ||
| ... | @@ -170,7 +168,6 @@ test "constant tagged union with payload" { | ... | @@ -170,7 +168,6 @@ test "constant tagged union with payload" { |
| 170 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 168 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 171 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 169 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 172 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 170 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 173 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 174 | 171 | ||
| 175 | var empty = TaggedUnionWithPayload{ .Empty = {} }; | 172 | var empty = TaggedUnionWithPayload{ .Empty = {} }; |
| 176 | var full = TaggedUnionWithPayload{ .Full = 13 }; | 173 | var full = TaggedUnionWithPayload{ .Full = 13 }; |
| ... | @@ -508,7 +505,6 @@ test "union initializer generates padding only if needed" { | ... | @@ -508,7 +505,6 @@ test "union initializer generates padding only if needed" { |
| 508 | test "runtime tag name with single field" { | 505 | test "runtime tag name with single field" { |
| 509 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 506 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 510 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 507 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 511 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 512 | 508 | ||
| 513 | const U = union(enum) { | 509 | const U = union(enum) { |
| 514 | A: i32, | 510 | A: i32, |
| ... | @@ -585,7 +581,6 @@ test "tagged union as return value" { | ... | @@ -585,7 +581,6 @@ test "tagged union as return value" { |
| 585 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 581 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 586 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 582 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 587 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 583 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 588 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 589 | 584 | ||
| 590 | switch (returnAnInt(13)) { | 585 | switch (returnAnInt(13)) { |
| 591 | TaggedFoo.One => |value| try expect(value == 13), | 586 | TaggedFoo.One => |value| try expect(value == 13), |
| ... | @@ -630,7 +625,6 @@ test "union(enum(u32)) with specified and unspecified tag values" { | ... | @@ -630,7 +625,6 @@ test "union(enum(u32)) with specified and unspecified tag values" { |
| 630 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 625 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 631 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 626 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 632 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 627 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 633 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 634 | 628 | ||
| 635 | try comptime expect(Tag(Tag(MultipleChoice2)) == u32); | 629 | try comptime expect(Tag(Tag(MultipleChoice2)) == u32); |
| 636 | try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 }); | 630 | try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 }); |
| ... | @@ -668,7 +662,6 @@ test "switch on union with only 1 field" { | ... | @@ -668,7 +662,6 @@ test "switch on union with only 1 field" { |
| 668 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 662 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 669 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 663 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 670 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 664 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 671 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 672 | 665 | ||
| 673 | var r: PartialInst = undefined; | 666 | var r: PartialInst = undefined; |
| 674 | r = PartialInst.Compiled; | 667 | r = PartialInst.Compiled; |
| ... | @@ -697,7 +690,6 @@ const PartialInstWithPayload = union(enum) { | ... | @@ -697,7 +690,6 @@ const PartialInstWithPayload = union(enum) { |
| 697 | 690 | ||
| 698 | test "union with only 1 field casted to its enum type which has enum value specified" { | 691 | test "union with only 1 field casted to its enum type which has enum value specified" { |
| 699 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 692 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 700 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 701 | 693 | ||
| 702 | const Literal = union(enum) { | 694 | const Literal = union(enum) { |
| 703 | Number: f64, | 695 | Number: f64, |
| ... | @@ -782,7 +774,6 @@ test "return union init with void payload" { | ... | @@ -782,7 +774,6 @@ test "return union init with void payload" { |
| 782 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; | 774 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 783 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; | 775 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 784 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 776 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 785 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 786 | 777 | ||
| 787 | const S = struct { | 778 | const S = struct { |
| 788 | fn entry() !void { | 779 | fn entry() !void { |
| ... | @@ -836,7 +827,6 @@ test "@unionInit can modify a union type" { | ... | @@ -836,7 +827,6 @@ test "@unionInit can modify a union type" { |
| 836 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 827 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 837 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 828 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 838 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 829 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 839 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 840 | 830 | ||
| 841 | const UnionInitEnum = union(enum) { | 831 | const UnionInitEnum = union(enum) { |
| 842 | Boolean: bool, | 832 | Boolean: bool, |
| ... | @@ -860,7 +850,6 @@ test "@unionInit can modify a pointer value" { | ... | @@ -860,7 +850,6 @@ test "@unionInit can modify a pointer value" { |
| 860 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 850 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 861 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 851 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 862 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 852 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 863 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 864 | 853 | ||
| 865 | const UnionInitEnum = union(enum) { | 854 | const UnionInitEnum = union(enum) { |
| 866 | Boolean: bool, | 855 | Boolean: bool, |
| ... | @@ -917,7 +906,6 @@ test "anonymous union literal syntax" { | ... | @@ -917,7 +906,6 @@ test "anonymous union literal syntax" { |
| 917 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 906 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 918 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 907 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 919 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 908 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 920 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 921 | 909 | ||
| 922 | const S = struct { | 910 | const S = struct { |
| 923 | const Number = union { | 911 | const Number = union { |
| ... | @@ -1041,7 +1029,6 @@ test "switching on non exhaustive union" { | ... | @@ -1041,7 +1029,6 @@ test "switching on non exhaustive union" { |
| 1041 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1029 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1042 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1030 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1043 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1031 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1044 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1045 | 1032 | ||
| 1046 | const S = struct { | 1033 | const S = struct { |
| 1047 | const E = enum(u8) { | 1034 | const E = enum(u8) { |
| ... | @@ -1225,7 +1212,6 @@ test "union tag is set when initiated as a temporary value at runtime" { | ... | @@ -1225,7 +1212,6 @@ test "union tag is set when initiated as a temporary value at runtime" { |
| 1225 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1212 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1226 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1213 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1227 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1214 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1228 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1229 | 1215 | ||
| 1230 | const U = union(enum) { | 1216 | const U = union(enum) { |
| 1231 | a, | 1217 | a, |
| ... | @@ -1263,7 +1249,6 @@ test "return an extern union from C calling convention" { | ... | @@ -1263,7 +1249,6 @@ test "return an extern union from C calling convention" { |
| 1263 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1249 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1264 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1250 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1265 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1251 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1266 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1267 | 1252 | ||
| 1268 | const namespace = struct { | 1253 | const namespace = struct { |
| 1269 | const S = extern struct { | 1254 | const S = extern struct { |
| ... | @@ -1294,7 +1279,6 @@ test "noreturn field in union" { | ... | @@ -1294,7 +1279,6 @@ test "noreturn field in union" { |
| 1294 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1279 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1295 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1280 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1296 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | 1281 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 1297 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1298 | 1282 | ||
| 1299 | const U = union(enum) { | 1283 | const U = union(enum) { |
| 1300 | a: u32, | 1284 | a: u32, |
| ... | @@ -1475,7 +1459,6 @@ test "no dependency loop when function pointer in union returns the union" { | ... | @@ -1475,7 +1459,6 @@ test "no dependency loop when function pointer in union returns the union" { |
| 1475 | test "union reassignment can use previous value" { | 1459 | test "union reassignment can use previous value" { |
| 1476 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1460 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1477 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | 1461 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 1478 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1479 | 1462 | ||
| 1480 | const U = union { | 1463 | const U = union { |
| 1481 | a: u32, | 1464 | a: u32, |
| ... | @@ -1527,7 +1510,6 @@ test "reinterpreting enum value inside packed union" { | ... | @@ -1527,7 +1510,6 @@ test "reinterpreting enum value inside packed union" { |
| 1527 | 1510 | ||
| 1528 | test "access the tag of a global tagged union" { | 1511 | test "access the tag of a global tagged union" { |
| 1529 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1512 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1530 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1531 | 1513 | ||
| 1532 | const U = union(enum) { | 1514 | const U = union(enum) { |
| 1533 | a, | 1515 | a, |
| ... | @@ -1539,7 +1521,6 @@ test "access the tag of a global tagged union" { | ... | @@ -1539,7 +1521,6 @@ test "access the tag of a global tagged union" { |
| 1539 | 1521 | ||
| 1540 | test "coerce enum literal to union in result loc" { | 1522 | test "coerce enum literal to union in result loc" { |
| 1541 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | 1523 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 1542 | if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; | ||
| 1543 | 1524 | ||
| 1544 | const U = union(enum) { | 1525 | const U = union(enum) { |
| 1545 | a, | 1526 | a, |