Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs"

This reverts commit b822e841cda0adabe3fec260ff51c18508f7ee32, reversing
changes made to 0c99ba1eab63865592bb084feb271cd4e4b0357e.

This caused a CI failure when it landed in master branch.
This commit is contained in:
Andrew Kelley 2023-10-22 12:15:31 -07:00
parent fd2239bde9
commit 9f0359d78f
21 changed files with 487 additions and 484 deletions

File diff suppressed because it is too large Load Diff

View File

@ -304,16 +304,10 @@ fn processTypeInstruction(self: *Assembler) !AsmValue {
// and so some consideration must be taken when entering this in the type system. // and so some consideration must be taken when entering this in the type system.
return self.todo("process OpTypeArray", .{}); return self.todo("process OpTypeArray", .{});
}, },
.OpTypePointer => blk: { .OpTypePointer => try self.spv.ptrType(
break :blk try self.spv.resolve(.{ try self.resolveTypeRef(operands[2].ref_id),
.ptr_type = .{ @as(spec.StorageClass, @enumFromInt(operands[1].value)),
.storage_class = @enumFromInt(operands[1].value), ),
.child_type = try self.resolveTypeRef(operands[2].ref_id),
// TODO: This should be a proper reference resolved via OpTypeForwardPointer
.fwd = @enumFromInt(std.math.maxInt(u32)),
},
});
},
.OpTypeFunction => blk: { .OpTypeFunction => blk: {
const param_operands = operands[2..]; const param_operands = operands[2..];
const param_types = try self.spv.gpa.alloc(CacheRef, param_operands.len); const param_types = try self.spv.gpa.alloc(CacheRef, param_operands.len);

View File

@ -22,8 +22,6 @@ const Opcode = spec.Opcode;
const IdResult = spec.IdResult; const IdResult = spec.IdResult;
const StorageClass = spec.StorageClass; const StorageClass = spec.StorageClass;
const InternPool = @import("../../InternPool.zig");
const Self = @This(); const Self = @This();
map: std.AutoArrayHashMapUnmanaged(void, void) = .{}, map: std.AutoArrayHashMapUnmanaged(void, void) = .{},
@ -33,8 +31,6 @@ extra: std.ArrayListUnmanaged(u32) = .{},
string_bytes: std.ArrayListUnmanaged(u8) = .{}, string_bytes: std.ArrayListUnmanaged(u8) = .{},
strings: std.AutoArrayHashMapUnmanaged(void, u32) = .{}, strings: std.AutoArrayHashMapUnmanaged(void, u32) = .{},
recursive_ptrs: std.AutoHashMapUnmanaged(Ref, void) = .{},
const Item = struct { const Item = struct {
tag: Tag, tag: Tag,
/// The result-id that this item uses. /// The result-id that this item uses.
@ -66,21 +62,18 @@ const Tag = enum {
/// Function (proto)type /// Function (proto)type
/// data is payload to FunctionType /// data is payload to FunctionType
type_function, type_function,
// /// Pointer type in the CrossWorkgroup storage class /// Pointer type in the CrossWorkgroup storage class
// /// data is child type /// data is child type
// type_ptr_generic, type_ptr_generic,
// /// Pointer type in the CrossWorkgroup storage class /// Pointer type in the CrossWorkgroup storage class
// /// data is child type /// data is child type
// type_ptr_crosswgp, type_ptr_crosswgp,
// /// Pointer type in the Function storage class /// Pointer type in the Function storage class
// /// data is child type /// data is child type
// type_ptr_function, type_ptr_function,
/// Simple pointer type that does not have any decorations. /// Simple pointer type that does not have any decorations.
/// data is payload to SimplePointerType /// data is payload to SimplePointerType
type_ptr_simple, type_ptr_simple,
/// A forward declaration for a pointer.
/// data is ForwardPointerType
type_fwd_ptr,
/// Simple structure type that does not have any decorations. /// Simple structure type that does not have any decorations.
/// data is payload to SimpleStructType /// data is payload to SimpleStructType
type_struct_simple, type_struct_simple,
@ -149,12 +142,6 @@ const Tag = enum {
const SimplePointerType = struct { const SimplePointerType = struct {
storage_class: StorageClass, storage_class: StorageClass,
child_type: Ref, child_type: Ref,
fwd: Ref,
};
const ForwardPointerType = struct {
storage_class: StorageClass,
zig_child_type: InternPool.Index,
}; };
/// Trailing: /// Trailing:
@ -176,14 +163,14 @@ const Tag = enum {
fn encode(value: f64) Float64 { fn encode(value: f64) Float64 {
const bits = @as(u64, @bitCast(value)); const bits = @as(u64, @bitCast(value));
return .{ return .{
.low = @truncate(bits), .low = @as(u32, @truncate(bits)),
.high = @truncate(bits >> 32), .high = @as(u32, @truncate(bits >> 32)),
}; };
} }
fn decode(self: Float64) f64 { fn decode(self: Float64) f64 {
const bits = @as(u64, self.low) | (@as(u64, self.high) << 32); const bits = @as(u64, self.low) | (@as(u64, self.high) << 32);
return @bitCast(bits); return @as(f64, @bitCast(bits));
} }
}; };
@ -205,8 +192,8 @@ const Tag = enum {
fn encode(ty: Ref, value: u64) Int64 { fn encode(ty: Ref, value: u64) Int64 {
return .{ return .{
.ty = ty, .ty = ty,
.low = @truncate(value), .low = @as(u32, @truncate(value)),
.high = @truncate(value >> 32), .high = @as(u32, @truncate(value >> 32)),
}; };
} }
@ -223,8 +210,8 @@ const Tag = enum {
fn encode(ty: Ref, value: i64) Int64 { fn encode(ty: Ref, value: i64) Int64 {
return .{ return .{
.ty = ty, .ty = ty,
.low = @truncate(@as(u64, @bitCast(value))), .low = @as(u32, @truncate(@as(u64, @bitCast(value)))),
.high = @truncate(@as(u64, @bitCast(value)) >> 32), .high = @as(u32, @truncate(@as(u64, @bitCast(value)) >> 32)),
}; };
} }
@ -250,7 +237,6 @@ pub const Key = union(enum) {
array_type: ArrayType, array_type: ArrayType,
function_type: FunctionType, function_type: FunctionType,
ptr_type: PointerType, ptr_type: PointerType,
fwd_ptr_type: ForwardPointerType,
struct_type: StructType, struct_type: StructType,
opaque_type: OpaqueType, opaque_type: OpaqueType,
@ -287,18 +273,12 @@ pub const Key = union(enum) {
pub const PointerType = struct { pub const PointerType = struct {
storage_class: StorageClass, storage_class: StorageClass,
child_type: Ref, child_type: Ref,
fwd: Ref,
// TODO: Decorations: // TODO: Decorations:
// - Alignment // - Alignment
// - ArrayStride, // - ArrayStride,
// - MaxByteOffset, // - MaxByteOffset,
}; };
pub const ForwardPointerType = struct {
zig_child_type: InternPool.Index,
storage_class: StorageClass,
};
pub const StructType = struct { pub const StructType = struct {
// TODO: Decorations. // TODO: Decorations.
/// The name of the structure. Can be `.none`. /// The name of the structure. Can be `.none`.
@ -333,21 +313,21 @@ pub const Key = union(enum) {
/// Turns this value into the corresponding 32-bit literal, 2s complement signed. /// Turns this value into the corresponding 32-bit literal, 2s complement signed.
fn toBits32(self: Int) u32 { fn toBits32(self: Int) u32 {
return switch (self.value) { return switch (self.value) {
.uint64 => |val| @intCast(val), .uint64 => |val| @as(u32, @intCast(val)),
.int64 => |val| if (val < 0) @bitCast(@as(i32, @intCast(val))) else @intCast(val), .int64 => |val| if (val < 0) @as(u32, @bitCast(@as(i32, @intCast(val)))) else @as(u32, @intCast(val)),
}; };
} }
fn toBits64(self: Int) u64 { fn toBits64(self: Int) u64 {
return switch (self.value) { return switch (self.value) {
.uint64 => |val| val, .uint64 => |val| val,
.int64 => |val| @bitCast(val), .int64 => |val| @as(u64, @bitCast(val)),
}; };
} }
fn to(self: Int, comptime T: type) T { fn to(self: Int, comptime T: type) T {
return switch (self.value) { return switch (self.value) {
inline else => |val| @intCast(val), inline else => |val| @as(T, @intCast(val)),
}; };
} }
}; };
@ -407,7 +387,7 @@ pub const Key = union(enum) {
}, },
inline else => |key| std.hash.autoHash(&hasher, key), inline else => |key| std.hash.autoHash(&hasher, key),
} }
return @truncate(hasher.final()); return @as(u32, @truncate(hasher.final()));
} }
fn eql(a: Key, b: Key) bool { fn eql(a: Key, b: Key) bool {
@ -439,7 +419,7 @@ pub const Key = union(enum) {
pub fn eql(ctx: @This(), a: Key, b_void: void, b_index: usize) bool { pub fn eql(ctx: @This(), a: Key, b_void: void, b_index: usize) bool {
_ = b_void; _ = b_void;
return ctx.self.lookup(@enumFromInt(b_index)).eql(a); return ctx.self.lookup(@as(Ref, @enumFromInt(b_index))).eql(a);
} }
pub fn hash(ctx: @This(), a: Key) u32 { pub fn hash(ctx: @This(), a: Key) u32 {
@ -470,7 +450,6 @@ pub fn deinit(self: *Self, spv: *const Module) void {
self.extra.deinit(spv.gpa); self.extra.deinit(spv.gpa);
self.string_bytes.deinit(spv.gpa); self.string_bytes.deinit(spv.gpa);
self.strings.deinit(spv.gpa); self.strings.deinit(spv.gpa);
self.recursive_ptrs.deinit(spv.gpa);
} }
/// Actually materialize the database into spir-v instructions. /// Actually materialize the database into spir-v instructions.
@ -481,7 +460,7 @@ pub fn materialize(self: *const Self, spv: *Module) !Section {
var section = Section{}; var section = Section{};
errdefer section.deinit(spv.gpa); errdefer section.deinit(spv.gpa);
for (self.items.items(.result_id), 0..) |result_id, index| { for (self.items.items(.result_id), 0..) |result_id, index| {
try self.emit(spv, result_id, @enumFromInt(index), &section); try self.emit(spv, result_id, @as(Ref, @enumFromInt(index)), &section);
} }
return section; return section;
} }
@ -559,15 +538,6 @@ fn emit(
}); });
// TODO: Decorations? // TODO: Decorations?
}, },
.fwd_ptr_type => |fwd| {
// Only emit the OpTypeForwardPointer if its actually required.
if (self.recursive_ptrs.contains(ref)) {
try section.emit(spv.gpa, .OpTypeForwardPointer, .{
.pointer_type = result_id,
.storage_class = fwd.storage_class,
});
}
},
.struct_type => |struct_type| { .struct_type => |struct_type| {
try section.emitRaw(spv.gpa, .OpTypeStruct, 1 + struct_type.member_types.len); try section.emitRaw(spv.gpa, .OpTypeStruct, 1 + struct_type.member_types.len);
section.writeOperand(IdResult, result_id); section.writeOperand(IdResult, result_id);
@ -579,7 +549,7 @@ fn emit(
} }
for (struct_type.memberNames(), 0..) |member_name, i| { for (struct_type.memberNames(), 0..) |member_name, i| {
if (self.getString(member_name)) |name| { if (self.getString(member_name)) |name| {
try spv.memberDebugName(result_id, @intCast(i), name); try spv.memberDebugName(result_id, @as(u32, @intCast(i)), name);
} }
} }
// TODO: Decorations? // TODO: Decorations?
@ -655,12 +625,13 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
const adapter: Key.Adapter = .{ .self = self }; const adapter: Key.Adapter = .{ .self = self };
const entry = try self.map.getOrPutAdapted(spv.gpa, key, adapter); const entry = try self.map.getOrPutAdapted(spv.gpa, key, adapter);
if (entry.found_existing) { if (entry.found_existing) {
return @enumFromInt(entry.index); return @as(Ref, @enumFromInt(entry.index));
} }
const result_id = spv.allocId();
const item: Item = switch (key) { const item: Item = switch (key) {
inline .void_type, .bool_type => .{ inline .void_type, .bool_type => .{
.tag = .type_simple, .tag = .type_simple,
.result_id = spv.allocId(), .result_id = result_id,
.data = @intFromEnum(key.toSimpleType()), .data = @intFromEnum(key.toSimpleType()),
}, },
.int_type => |int| blk: { .int_type => |int| blk: {
@ -670,104 +641,87 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
}; };
break :blk .{ break :blk .{
.tag = t, .tag = t,
.result_id = spv.allocId(), .result_id = result_id,
.data = int.bits, .data = int.bits,
}; };
}, },
.float_type => |float| .{ .float_type => |float| .{
.tag = .type_float, .tag = .type_float,
.result_id = spv.allocId(), .result_id = result_id,
.data = float.bits, .data = float.bits,
}, },
.vector_type => |vector| .{ .vector_type => |vector| .{
.tag = .type_vector, .tag = .type_vector,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, vector), .data = try self.addExtra(spv, vector),
}, },
.array_type => |array| .{ .array_type => |array| .{
.tag = .type_array, .tag = .type_array,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, array), .data = try self.addExtra(spv, array),
}, },
.function_type => |function| blk: { .function_type => |function| blk: {
const extra = try self.addExtra(spv, Tag.FunctionType{ const extra = try self.addExtra(spv, Tag.FunctionType{
.param_len = @intCast(function.parameters.len), .param_len = @as(u32, @intCast(function.parameters.len)),
.return_type = function.return_type, .return_type = function.return_type,
}); });
try self.extra.appendSlice(spv.gpa, @ptrCast(function.parameters)); try self.extra.appendSlice(spv.gpa, @as([]const u32, @ptrCast(function.parameters)));
break :blk .{ break :blk .{
.tag = .type_function, .tag = .type_function,
.result_id = spv.allocId(), .result_id = result_id,
.data = extra, .data = extra,
}; };
}, },
// .ptr_type => |ptr| switch (ptr.storage_class) { .ptr_type => |ptr| switch (ptr.storage_class) {
// .Generic => Item{ .Generic => Item{
// .tag = .type_ptr_generic, .tag = .type_ptr_generic,
// .result_id = spv.allocId(), .result_id = result_id,
// .data = @intFromEnum(ptr.child_type), .data = @intFromEnum(ptr.child_type),
// }, },
// .CrossWorkgroup => Item{ .CrossWorkgroup => Item{
// .tag = .type_ptr_crosswgp, .tag = .type_ptr_crosswgp,
// .result_id = spv.allocId(), .result_id = result_id,
// .data = @intFromEnum(ptr.child_type), .data = @intFromEnum(ptr.child_type),
// }, },
// .Function => Item{ .Function => Item{
// .tag = .type_ptr_function, .tag = .type_ptr_function,
// .result_id = spv.allocId(), .result_id = result_id,
// .data = @intFromEnum(ptr.child_type), .data = @intFromEnum(ptr.child_type),
// }, },
// else => |storage_class| Item{ else => |storage_class| Item{
// .tag = .type_ptr_simple,
// .result_id = spv.allocId(),
// .data = try self.addExtra(spv, Tag.SimplePointerType{
// .storage_class = storage_class,
// .child_type = ptr.child_type,
// }),
// },
// },
.ptr_type => |ptr| Item{
.tag = .type_ptr_simple, .tag = .type_ptr_simple,
.result_id = self.resultId(ptr.fwd), .result_id = result_id,
.data = try self.addExtra(spv, Tag.SimplePointerType{ .data = try self.addExtra(spv, Tag.SimplePointerType{
.storage_class = ptr.storage_class, .storage_class = storage_class,
.child_type = ptr.child_type, .child_type = ptr.child_type,
.fwd = ptr.fwd,
}), }),
}, },
.fwd_ptr_type => |fwd| Item{
.tag = .type_fwd_ptr,
.result_id = spv.allocId(),
.data = try self.addExtra(spv, Tag.ForwardPointerType{
.zig_child_type = fwd.zig_child_type,
.storage_class = fwd.storage_class,
}),
}, },
.struct_type => |struct_type| blk: { .struct_type => |struct_type| blk: {
const extra = try self.addExtra(spv, Tag.SimpleStructType{ const extra = try self.addExtra(spv, Tag.SimpleStructType{
.name = struct_type.name, .name = struct_type.name,
.members_len = @intCast(struct_type.member_types.len), .members_len = @as(u32, @intCast(struct_type.member_types.len)),
}); });
try self.extra.appendSlice(spv.gpa, @ptrCast(struct_type.member_types)); try self.extra.appendSlice(spv.gpa, @as([]const u32, @ptrCast(struct_type.member_types)));
if (struct_type.member_names) |member_names| { if (struct_type.member_names) |member_names| {
try self.extra.appendSlice(spv.gpa, @ptrCast(member_names)); try self.extra.appendSlice(spv.gpa, @as([]const u32, @ptrCast(member_names)));
break :blk Item{ break :blk Item{
.tag = .type_struct_simple_with_member_names, .tag = .type_struct_simple_with_member_names,
.result_id = spv.allocId(), .result_id = result_id,
.data = extra, .data = extra,
}; };
} else { } else {
break :blk Item{ break :blk Item{
.tag = .type_struct_simple, .tag = .type_struct_simple,
.result_id = spv.allocId(), .result_id = result_id,
.data = extra, .data = extra,
}; };
} }
}, },
.opaque_type => |opaque_type| Item{ .opaque_type => |opaque_type| Item{
.tag = .type_opaque, .tag = .type_opaque,
.result_id = spv.allocId(), .result_id = result_id,
.data = @intFromEnum(opaque_type.name), .data = @intFromEnum(opaque_type.name),
}, },
.int => |int| blk: { .int => |int| blk: {
@ -775,13 +729,13 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
if (int_type.signedness == .unsigned and int_type.bits == 8) { if (int_type.signedness == .unsigned and int_type.bits == 8) {
break :blk .{ break :blk .{
.tag = .uint8, .tag = .uint8,
.result_id = spv.allocId(), .result_id = result_id,
.data = int.to(u8), .data = int.to(u8),
}; };
} else if (int_type.signedness == .unsigned and int_type.bits == 32) { } else if (int_type.signedness == .unsigned and int_type.bits == 32) {
break :blk .{ break :blk .{
.tag = .uint32, .tag = .uint32,
.result_id = spv.allocId(), .result_id = result_id,
.data = int.to(u32), .data = int.to(u32),
}; };
} }
@ -791,32 +745,32 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
if (val >= 0 and val <= std.math.maxInt(u32)) { if (val >= 0 and val <= std.math.maxInt(u32)) {
break :blk .{ break :blk .{
.tag = .uint_small, .tag = .uint_small,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, Tag.UInt32{ .data = try self.addExtra(spv, Tag.UInt32{
.ty = int.ty, .ty = int.ty,
.value = @intCast(val), .value = @as(u32, @intCast(val)),
}), }),
}; };
} else if (val >= std.math.minInt(i32) and val <= std.math.maxInt(i32)) { } else if (val >= std.math.minInt(i32) and val <= std.math.maxInt(i32)) {
break :blk .{ break :blk .{
.tag = .int_small, .tag = .int_small,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, Tag.Int32{ .data = try self.addExtra(spv, Tag.Int32{
.ty = int.ty, .ty = int.ty,
.value = @intCast(val), .value = @as(i32, @intCast(val)),
}), }),
}; };
} else if (val < 0) { } else if (val < 0) {
break :blk .{ break :blk .{
.tag = .int_large, .tag = .int_large,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, Tag.Int64.encode(int.ty, @intCast(val))), .data = try self.addExtra(spv, Tag.Int64.encode(int.ty, @as(i64, @intCast(val)))),
}; };
} else { } else {
break :blk .{ break :blk .{
.tag = .uint_large, .tag = .uint_large,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, Tag.UInt64.encode(int.ty, @intCast(val))), .data = try self.addExtra(spv, Tag.UInt64.encode(int.ty, @as(u64, @intCast(val)))),
}; };
} }
}, },
@ -825,29 +779,29 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
.float => |float| switch (self.lookup(float.ty).float_type.bits) { .float => |float| switch (self.lookup(float.ty).float_type.bits) {
16 => .{ 16 => .{
.tag = .float16, .tag = .float16,
.result_id = spv.allocId(), .result_id = result_id,
.data = @as(u16, @bitCast(float.value.float16)), .data = @as(u16, @bitCast(float.value.float16)),
}, },
32 => .{ 32 => .{
.tag = .float32, .tag = .float32,
.result_id = spv.allocId(), .result_id = result_id,
.data = @as(u32, @bitCast(float.value.float32)), .data = @as(u32, @bitCast(float.value.float32)),
}, },
64 => .{ 64 => .{
.tag = .float64, .tag = .float64,
.result_id = spv.allocId(), .result_id = result_id,
.data = try self.addExtra(spv, Tag.Float64.encode(float.value.float64)), .data = try self.addExtra(spv, Tag.Float64.encode(float.value.float64)),
}, },
else => unreachable, else => unreachable,
}, },
.undef => |undef| .{ .undef => |undef| .{
.tag = .undef, .tag = .undef,
.result_id = spv.allocId(), .result_id = result_id,
.data = @intFromEnum(undef.ty), .data = @intFromEnum(undef.ty),
}, },
.null => |null_info| .{ .null => |null_info| .{
.tag = .null, .tag = .null,
.result_id = spv.allocId(), .result_id = result_id,
.data = @intFromEnum(null_info.ty), .data = @intFromEnum(null_info.ty),
}, },
.bool => |bool_info| .{ .bool => |bool_info| .{
@ -855,13 +809,13 @@ pub fn resolve(self: *Self, spv: *Module, key: Key) !Ref {
true => Tag.bool_true, true => Tag.bool_true,
false => Tag.bool_false, false => Tag.bool_false,
}, },
.result_id = spv.allocId(), .result_id = result_id,
.data = @intFromEnum(bool_info.ty), .data = @intFromEnum(bool_info.ty),
}, },
}; };
try self.items.append(spv.gpa, item); try self.items.append(spv.gpa, item);
return @enumFromInt(entry.index); return @as(Ref, @enumFromInt(entry.index));
} }
/// Turn a Ref back into a Key. /// Turn a Ref back into a Key.
@ -876,14 +830,14 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
}, },
.type_int_signed => .{ .int_type = .{ .type_int_signed => .{ .int_type = .{
.signedness = .signed, .signedness = .signed,
.bits = @intCast(data), .bits = @as(u16, @intCast(data)),
} }, } },
.type_int_unsigned => .{ .int_type = .{ .type_int_unsigned => .{ .int_type = .{
.signedness = .unsigned, .signedness = .unsigned,
.bits = @intCast(data), .bits = @as(u16, @intCast(data)),
} }, } },
.type_float => .{ .float_type = .{ .type_float => .{ .float_type = .{
.bits = @intCast(data), .bits = @as(u16, @intCast(data)),
} }, } },
.type_vector => .{ .vector_type = self.extraData(Tag.VectorType, data) }, .type_vector => .{ .vector_type = self.extraData(Tag.VectorType, data) },
.type_array => .{ .array_type = self.extraData(Tag.ArrayType, data) }, .type_array => .{ .array_type = self.extraData(Tag.ArrayType, data) },
@ -892,50 +846,40 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
return .{ return .{
.function_type = .{ .function_type = .{
.return_type = payload.data.return_type, .return_type = payload.data.return_type,
.parameters = @ptrCast(self.extra.items[payload.trail..][0..payload.data.param_len]), .parameters = @as([]const Ref, @ptrCast(self.extra.items[payload.trail..][0..payload.data.param_len])),
}, },
}; };
}, },
// .type_ptr_generic => .{ .type_ptr_generic => .{
// .ptr_type = .{ .ptr_type = .{
// .storage_class = .Generic, .storage_class = .Generic,
// .child_type = @enumFromInt(data), .child_type = @as(Ref, @enumFromInt(data)),
// }, },
// }, },
// .type_ptr_crosswgp => .{ .type_ptr_crosswgp => .{
// .ptr_type = .{ .ptr_type = .{
// .storage_class = .CrossWorkgroup, .storage_class = .CrossWorkgroup,
// .child_type = @enumFromInt(data), .child_type = @as(Ref, @enumFromInt(data)),
// }, },
// }, },
// .type_ptr_function => .{ .type_ptr_function => .{
// .ptr_type = .{ .ptr_type = .{
// .storage_class = .Function, .storage_class = .Function,
// .child_type = @enumFromInt(data), .child_type = @as(Ref, @enumFromInt(data)),
// }, },
// }, },
.type_ptr_simple => { .type_ptr_simple => {
const payload = self.extraData(Tag.SimplePointerType, data); const payload = self.extraData(Tag.SimplePointerType, data);
return .{ return .{
.ptr_type = .{ .ptr_type = .{
.storage_class = payload.storage_class, .storage_class = payload.storage_class,
.child_type = payload.child_type, .child_type = payload.child_type,
.fwd = payload.fwd,
},
};
},
.type_fwd_ptr => {
const payload = self.extraData(Tag.ForwardPointerType, data);
return .{
.fwd_ptr_type = .{
.zig_child_type = payload.zig_child_type,
.storage_class = payload.storage_class,
}, },
}; };
}, },
.type_struct_simple => { .type_struct_simple => {
const payload = self.extraDataTrail(Tag.SimpleStructType, data); const payload = self.extraDataTrail(Tag.SimpleStructType, data);
const member_types: []const Ref = @ptrCast(self.extra.items[payload.trail..][0..payload.data.members_len]); const member_types = @as([]const Ref, @ptrCast(self.extra.items[payload.trail..][0..payload.data.members_len]));
return .{ return .{
.struct_type = .{ .struct_type = .{
.name = payload.data.name, .name = payload.data.name,
@ -947,8 +891,8 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
.type_struct_simple_with_member_names => { .type_struct_simple_with_member_names => {
const payload = self.extraDataTrail(Tag.SimpleStructType, data); const payload = self.extraDataTrail(Tag.SimpleStructType, data);
const trailing = self.extra.items[payload.trail..]; const trailing = self.extra.items[payload.trail..];
const member_types: []const Ref = @ptrCast(trailing[0..payload.data.members_len]); const member_types = @as([]const Ref, @ptrCast(trailing[0..payload.data.members_len]));
const member_names: []const String = @ptrCast(trailing[payload.data.members_len..][0..payload.data.members_len]); const member_names = @as([]const String, @ptrCast(trailing[payload.data.members_len..][0..payload.data.members_len]));
return .{ return .{
.struct_type = .{ .struct_type = .{
.name = payload.data.name, .name = payload.data.name,
@ -959,16 +903,16 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
}, },
.type_opaque => .{ .type_opaque => .{
.opaque_type = .{ .opaque_type = .{
.name = @enumFromInt(data), .name = @as(String, @enumFromInt(data)),
}, },
}, },
.float16 => .{ .float = .{ .float16 => .{ .float = .{
.ty = self.get(.{ .float_type = .{ .bits = 16 } }), .ty = self.get(.{ .float_type = .{ .bits = 16 } }),
.value = .{ .float16 = @bitCast(@as(u16, @intCast(data))) }, .value = .{ .float16 = @as(f16, @bitCast(@as(u16, @intCast(data)))) },
} }, } },
.float32 => .{ .float = .{ .float32 => .{ .float = .{
.ty = self.get(.{ .float_type = .{ .bits = 32 } }), .ty = self.get(.{ .float_type = .{ .bits = 32 } }),
.value = .{ .float32 = @bitCast(data) }, .value = .{ .float32 = @as(f32, @bitCast(data)) },
} }, } },
.float64 => .{ .float = .{ .float64 => .{ .float = .{
.ty = self.get(.{ .float_type = .{ .bits = 64 } }), .ty = self.get(.{ .float_type = .{ .bits = 64 } }),
@ -1011,17 +955,17 @@ pub fn lookup(self: *const Self, ref: Ref) Key {
} }; } };
}, },
.undef => .{ .undef = .{ .undef => .{ .undef = .{
.ty = @enumFromInt(data), .ty = @as(Ref, @enumFromInt(data)),
} }, } },
.null => .{ .null = .{ .null => .{ .null = .{
.ty = @enumFromInt(data), .ty = @as(Ref, @enumFromInt(data)),
} }, } },
.bool_true => .{ .bool = .{ .bool_true => .{ .bool = .{
.ty = @enumFromInt(data), .ty = @as(Ref, @enumFromInt(data)),
.value = true, .value = true,
} }, } },
.bool_false => .{ .bool = .{ .bool_false => .{ .bool = .{
.ty = @enumFromInt(data), .ty = @as(Ref, @enumFromInt(data)),
.value = false, .value = false,
} }, } },
}; };
@ -1037,7 +981,7 @@ pub fn resultId(self: Self, ref: Ref) IdResult {
fn get(self: *const Self, key: Key) Ref { fn get(self: *const Self, key: Key) Ref {
const adapter: Key.Adapter = .{ .self = self }; const adapter: Key.Adapter = .{ .self = self };
const index = self.map.getIndexAdapted(key, adapter).?; const index = self.map.getIndexAdapted(key, adapter).?;
return @enumFromInt(index); return @as(Ref, @enumFromInt(index));
} }
fn addExtra(self: *Self, spv: *Module, extra: anytype) !u32 { fn addExtra(self: *Self, spv: *Module, extra: anytype) !u32 {
@ -1047,16 +991,15 @@ fn addExtra(self: *Self, spv: *Module, extra: anytype) !u32 {
} }
fn addExtraAssumeCapacity(self: *Self, extra: anytype) !u32 { fn addExtraAssumeCapacity(self: *Self, extra: anytype) !u32 {
const payload_offset: u32 = @intCast(self.extra.items.len); const payload_offset = @as(u32, @intCast(self.extra.items.len));
inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {
const field_val = @field(extra, field.name); const field_val = @field(extra, field.name);
const word: u32 = switch (field.type) { const word = switch (field.type) {
u32 => field_val, u32 => field_val,
i32 => @bitCast(field_val), i32 => @as(u32, @bitCast(field_val)),
Ref => @intFromEnum(field_val), Ref => @intFromEnum(field_val),
StorageClass => @intFromEnum(field_val), StorageClass => @intFromEnum(field_val),
String => @intFromEnum(field_val), String => @intFromEnum(field_val),
InternPool.Index => @intFromEnum(field_val),
else => @compileError("Invalid type: " ++ @typeName(field.type)), else => @compileError("Invalid type: " ++ @typeName(field.type)),
}; };
self.extra.appendAssumeCapacity(word); self.extra.appendAssumeCapacity(word);
@ -1075,11 +1018,10 @@ fn extraDataTrail(self: Self, comptime T: type, offset: u32) struct { data: T, t
const word = self.extra.items[offset + i]; const word = self.extra.items[offset + i];
@field(result, field.name) = switch (field.type) { @field(result, field.name) = switch (field.type) {
u32 => word, u32 => word,
i32 => @bitCast(word), i32 => @as(i32, @bitCast(word)),
Ref => @enumFromInt(word), Ref => @as(Ref, @enumFromInt(word)),
StorageClass => @enumFromInt(word), StorageClass => @as(StorageClass, @enumFromInt(word)),
String => @enumFromInt(word), String => @as(String, @enumFromInt(word)),
InternPool.Index => @enumFromInt(word),
else => @compileError("Invalid type: " ++ @typeName(field.type)), else => @compileError("Invalid type: " ++ @typeName(field.type)),
}; };
} }
@ -1107,7 +1049,7 @@ pub const String = enum(u32) {
_ = ctx; _ = ctx;
var hasher = std.hash.Wyhash.init(0); var hasher = std.hash.Wyhash.init(0);
hasher.update(a); hasher.update(a);
return @truncate(hasher.final()); return @as(u32, @truncate(hasher.final()));
} }
}; };
}; };
@ -1122,10 +1064,10 @@ pub fn addString(self: *Self, spv: *Module, str: []const u8) !String {
try self.string_bytes.ensureUnusedCapacity(spv.gpa, 1 + str.len); try self.string_bytes.ensureUnusedCapacity(spv.gpa, 1 + str.len);
self.string_bytes.appendSliceAssumeCapacity(str); self.string_bytes.appendSliceAssumeCapacity(str);
self.string_bytes.appendAssumeCapacity(0); self.string_bytes.appendAssumeCapacity(0);
entry.value_ptr.* = @intCast(offset); entry.value_ptr.* = @as(u32, @intCast(offset));
} }
return @enumFromInt(entry.index); return @as(String, @enumFromInt(entry.index));
} }
pub fn getString(self: *const Self, ref: String) ?[]const u8 { pub fn getString(self: *const Self, ref: String) ?[]const u8 {

View File

@ -507,6 +507,17 @@ pub fn arrayType(self: *Module, len: u32, elem_ty_ref: CacheRef) !CacheRef {
} }); } });
} }
pub fn ptrType(
self: *Module,
child: CacheRef,
storage_class: spec.StorageClass,
) !CacheRef {
return try self.resolve(.{ .ptr_type = .{
.storage_class = storage_class,
.child_type = child,
} });
}
pub fn constInt(self: *Module, ty_ref: CacheRef, value: anytype) !IdRef { pub fn constInt(self: *Module, ty_ref: CacheRef, value: anytype) !IdRef {
const ty = self.cache.lookup(ty_ref).int_type; const ty = self.cache.lookup(ty_ref).int_type;
const Value = Cache.Key.Int.Value; const Value = Cache.Key.Int.Value;

View File

@ -9,6 +9,7 @@ test {
if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var t: T = .{ .next = null }; var t: T = .{ .next = null };
try std.testing.expect(t.next == null); try std.testing.expect(t.next == null);

View File

@ -44,6 +44,7 @@ const a = struct {
test "initialization" { test "initialization" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var t = a.init(); var t = a.init();
try std.testing.expect(t.foo.len == 0); try std.testing.expect(t.foo.len == 0);

View File

@ -12,6 +12,8 @@ const b_list: []B = &[_]B{};
const a = A{ .b_list_pointer = &b_list }; const a = A{ .b_list_pointer = &b_list };
test "segfault bug" { test "segfault bug" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const assert = std.debug.assert; const assert = std.debug.assert;
const obj = B{ .a_pointer = &a }; const obj = B{ .a_pointer = &a };
assert(obj.a_pointer == &a); // this makes zig crash assert(obj.a_pointer == &a); // this makes zig crash
@ -28,5 +30,7 @@ pub const B2 = struct {
var b_value = B2{ .pointer_array = &[_]*A2{} }; var b_value = B2{ .pointer_array = &[_]*A2{} };
test "basic stuff" { test "basic stuff" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
std.debug.assert(&b_value == &b_value); std.debug.assert(&b_value == &b_value);
} }

View File

@ -7,6 +7,7 @@ const S = struct {
}; };
test "bug 2006" { test "bug 2006" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var a: S = undefined; var a: S = undefined;
a = S{ .p = undefined }; a = S{ .p = undefined };

View File

@ -22,6 +22,7 @@ test "fixed" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
default_foo = get_foo() catch null; // This Line default_foo = get_foo() catch null; // This Line
try std.testing.expect(!default_foo.?.free); try std.testing.expect(!default_foo.?.free);

View File

@ -8,6 +8,7 @@ test {
if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var slice: []void = undefined; var slice: []void = undefined;
destroy(&slice[0]); destroy(&slice[0]);

View File

@ -81,6 +81,7 @@ test {
if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var param: ParamType = .{ var param: ParamType = .{
.one_of = .{ .name = "name" }, .one_of = .{ .name = "name" },

View File

@ -943,6 +943,7 @@ test "returning an error union containing a type with no runtime bits" {
test "try used in recursive function with inferred error set" { test "try used in recursive function with inferred error set" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const Value = union(enum) { const Value = union(enum) {
values: []const @This(), values: []const @This(),

View File

@ -391,6 +391,7 @@ test "return 0 from function that has u0 return type" {
test "statically initialized struct" { test "statically initialized struct" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
st_init_str_foo.x += 1; st_init_str_foo.x += 1;
try expect(st_init_str_foo.x == 14); try expect(st_init_str_foo.x == 14);
@ -497,6 +498,7 @@ test "comptime shlWithOverflow" {
test "const ptr to variable data changes at runtime" { test "const ptr to variable data changes at runtime" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
try expect(foo_ref.name[0] == 'a'); try expect(foo_ref.name[0] == 'a');
foo_ref.name = "b"; foo_ref.name = "b";
@ -1549,6 +1551,8 @@ test "comptime function turns function value to function pointer" {
} }
test "container level const and var have unique addresses" { test "container level const and var have unique addresses" {
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
x: i32, x: i32,
y: i32, y: i32,

View File

@ -205,6 +205,7 @@ fn foo2(arg: anytype) bool {
test "generic struct" { test "generic struct" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var a1 = GenNode(i32){ var a1 = GenNode(i32){
.value = 13, .value = 13,

View File

@ -185,6 +185,7 @@ test "unwrap optional which is field of global var" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
struct_with_optional.field = null; struct_with_optional.field = null;
if (struct_with_optional.field) |payload| { if (struct_with_optional.field) |payload| {

View File

@ -193,6 +193,7 @@ test "nested orelse" {
test "self-referential struct through a slice of optional" { test "self-referential struct through a slice of optional" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
const Node = struct { const Node = struct {

View File

@ -130,6 +130,7 @@ test "lower reinterpreted comptime field ptr (with under-aligned fields)" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
// Test lowering a field ptr // Test lowering a field ptr
comptime var bytes align(2) = [_]u8{ 1, 2, 3, 4, 5, 6 }; comptime var bytes align(2) = [_]u8{ 1, 2, 3, 4, 5, 6 };
@ -152,6 +153,7 @@ test "lower reinterpreted comptime field ptr" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
// Test lowering a field ptr // Test lowering a field ptr
comptime var bytes align(4) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 }; comptime var bytes align(4) = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8 };

View File

@ -292,6 +292,7 @@ const Val = struct {
test "struct point to self" { test "struct point to self" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var root: Node = undefined; var root: Node = undefined;
root.val.x = 1; root.val.x = 1;
@ -346,6 +347,7 @@ test "self-referencing struct via array member" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const T = struct { const T = struct {
children: [1]*@This(), children: [1]*@This(),
@ -368,6 +370,7 @@ const EmptyStruct = struct {
test "align 1 field before self referential align 8 field as slice return type" { test "align 1 field before self referential align 8 field as slice return type" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const result = alloc(Expr); const result = alloc(Expr);
try expect(result.len == 0); try expect(result.len == 0);
@ -733,6 +736,7 @@ test "packed struct with u0 field access" {
test "access to global struct fields" { test "access to global struct fields" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
g_foo.bar.value = 42; g_foo.bar.value = 42;
try expect(g_foo.bar.value == 42); try expect(g_foo.bar.value == 42);
@ -1419,6 +1423,7 @@ test "fieldParentPtr of a zero-bit field" {
test "struct field has a pointer to an aligned version of itself" { test "struct field has a pointer to an aligned version of itself" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const E = struct { const E = struct {
next: *align(1) @This(), next: *align(1) @This(),
@ -1514,6 +1519,7 @@ test "function pointer in struct returns the struct" {
test "no dependency loop on optional field wrapped in generic function" { test "no dependency loop on optional field wrapped in generic function" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
fn Atomic(comptime T: type) type { fn Atomic(comptime T: type) type {

View File

@ -5,6 +5,7 @@ const builtin = @import("builtin");
test "struct contains null pointer which contains original struct" { test "struct contains null pointer which contains original struct" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var x: ?*NodeLineComment = null; var x: ?*NodeLineComment = null;
try expect(x == null); try expect(x == null);

View File

@ -13,6 +13,7 @@ const NodeAligned = struct {
test "struct contains slice of itself" { test "struct contains slice of itself" {
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var other_nodes = [_]Node{ var other_nodes = [_]Node{
Node{ Node{
@ -53,6 +54,7 @@ test "struct contains slice of itself" {
test "struct contains aligned slice of itself" { test "struct contains aligned slice of itself" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
var other_nodes = [_]NodeAligned{ var other_nodes = [_]NodeAligned{
NodeAligned{ NodeAligned{

View File

@ -399,6 +399,7 @@ test "tagged union with no payloads" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const a = UnionEnumNoPayloads{ .B = {} }; const a = UnionEnumNoPayloads{ .B = {} };
switch (a) { switch (a) {
@ -473,6 +474,7 @@ test "update the tag value for zero-sized unions" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = union(enum) { const S = union(enum) {
U0: void, U0: void,
@ -513,6 +515,7 @@ test "method call on an empty union" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
const MyUnion = union(MyUnionTag) { const MyUnion = union(MyUnionTag) {
@ -590,6 +593,7 @@ test "tagged union with all void fields but a meaningful tag" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
const B = union(enum) { const B = union(enum) {
@ -791,6 +795,7 @@ test "@unionInit stored to a const" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
const U = union(enum) { const U = union(enum) {
@ -862,6 +867,7 @@ test "union no tag with struct member" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const Struct = struct {}; const Struct = struct {};
const Union = union { const Union = union {
@ -1073,6 +1079,7 @@ test "@unionInit on union with tag but no fields" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = struct { const S = struct {
const Type = enum(u8) { no_op = 105 }; const Type = enum(u8) { no_op = 105 };
@ -1121,6 +1128,7 @@ test "global variable struct contains union initialized to non-most-aligned fiel
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const T = struct { const T = struct {
const U = union(enum) { const U = union(enum) {
@ -1340,6 +1348,7 @@ test "union field ptr - zero sized payload" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const U = union { const U = union {
foo: void, foo: void,
@ -1354,6 +1363,7 @@ test "union field ptr - zero sized field" {
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const U = union { const U = union {
foo: void, foo: void,