mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
aarch64: workaround some optional/union issues
This commit is contained in:
parent
dea3ed7f59
commit
c334956a54
@ -895,8 +895,8 @@ pub const VaList = switch (builtin.cpu.arch) {
|
|||||||
.windows => *u8,
|
.windows => *u8,
|
||||||
.ios, .macos, .tvos, .watchos, .visionos => *u8,
|
.ios, .macos, .tvos, .watchos, .visionos => *u8,
|
||||||
else => switch (builtin.zig_backend) {
|
else => switch (builtin.zig_backend) {
|
||||||
.stage2_aarch64 => VaListAarch64,
|
else => VaListAarch64,
|
||||||
else => @compileError("disabled due to miscompilations"),
|
.stage2_llvm => @compileError("disabled due to miscompilations"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.arm, .armeb, .thumb, .thumbeb => switch (builtin.os.tag) {
|
.arm, .armeb, .thumb, .thumbeb => switch (builtin.os.tag) {
|
||||||
@ -921,7 +921,10 @@ pub const VaList = switch (builtin.cpu.arch) {
|
|||||||
.wasm32, .wasm64 => *anyopaque,
|
.wasm32, .wasm64 => *anyopaque,
|
||||||
.x86 => *u8,
|
.x86 => *u8,
|
||||||
.x86_64 => switch (builtin.os.tag) {
|
.x86_64 => switch (builtin.os.tag) {
|
||||||
.windows => @compileError("disabled due to miscompilations"), // *u8,
|
.windows => switch (builtin.zig_backend) {
|
||||||
|
else => *u8,
|
||||||
|
.stage2_llvm => @compileError("disabled due to miscompilations"),
|
||||||
|
},
|
||||||
else => VaListX86_64,
|
else => VaListX86_64,
|
||||||
},
|
},
|
||||||
.xtensa => VaListXtensa,
|
.xtensa => VaListXtensa,
|
||||||
|
|||||||
@ -626,7 +626,6 @@ pub inline fn callMain() u8 {
|
|||||||
|
|
||||||
const result = root.main() catch |err| {
|
const result = root.main() catch |err| {
|
||||||
switch (builtin.zig_backend) {
|
switch (builtin.zig_backend) {
|
||||||
.stage2_aarch64,
|
|
||||||
.stage2_powerpc,
|
.stage2_powerpc,
|
||||||
.stage2_riscv64,
|
.stage2_riscv64,
|
||||||
=> {
|
=> {
|
||||||
|
|||||||
@ -3261,7 +3261,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
assert(dst_int_info.bits == src_child_int_info.bits * src_len);
|
assert(dst_int_info.bits == src_child_int_info.bits * src_len);
|
||||||
const src_child_size = src_ty.childType(zcu).abiSize(zcu);
|
const src_child_size = src_ty.childType(zcu).abiSize(zcu);
|
||||||
if (8 * src_child_size == src_child_int_info.bits) {
|
if (8 * src_child_size == src_child_int_info.bits) {
|
||||||
try dst_vi.value.defAddr(isel, dst_ty, dst_int_info, comptime &.initFill(.free)) orelse break :unused;
|
try dst_vi.value.defAddr(isel, dst_ty, .{ .wrap = dst_int_info }) orelse break :unused;
|
||||||
|
|
||||||
try call.prepareReturn(isel);
|
try call.prepareReturn(isel);
|
||||||
try call.finishReturn(isel);
|
try call.finishReturn(isel);
|
||||||
@ -3288,7 +3288,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
assert(dst_child_int_info.bits * dst_len == src_int_info.bits);
|
assert(dst_child_int_info.bits * dst_len == src_int_info.bits);
|
||||||
const dst_child_size = dst_ty.childType(zcu).abiSize(zcu);
|
const dst_child_size = dst_ty.childType(zcu).abiSize(zcu);
|
||||||
if (8 * dst_child_size == dst_child_int_info.bits) {
|
if (8 * dst_child_size == dst_child_int_info.bits) {
|
||||||
try dst_vi.value.defAddr(isel, dst_ty, null, comptime &.initFill(.free)) orelse break :unused;
|
try dst_vi.value.defAddr(isel, dst_ty, .{}) orelse break :unused;
|
||||||
|
|
||||||
try call.prepareReturn(isel);
|
try call.prepareReturn(isel);
|
||||||
try call.finishReturn(isel);
|
try call.finishReturn(isel);
|
||||||
@ -3438,12 +3438,9 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
.value, .constant => unreachable,
|
.value, .constant => unreachable,
|
||||||
.address => |address_vi| {
|
.address => |address_vi| {
|
||||||
maybe_ret_addr_vi = address_vi;
|
maybe_ret_addr_vi = address_vi;
|
||||||
_ = try def_ret_vi.value.defAddr(
|
_ = try def_ret_vi.value.defAddr(isel, isel.air.typeOfIndex(air.inst_index, ip), .{
|
||||||
isel,
|
.expected_live_registers = &call.caller_saved_regs,
|
||||||
isel.air.typeOfIndex(air.inst_index, ip),
|
});
|
||||||
null,
|
|
||||||
&call.caller_saved_regs,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4953,37 +4950,34 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
if (ptr_info.flags.is_volatile) _ = try isel.use(air.inst_index.toRef());
|
if (ptr_info.flags.is_volatile) _ = try isel.use(air.inst_index.toRef());
|
||||||
if (isel.live_values.fetchRemove(air.inst_index)) |dst_vi| unused: {
|
if (isel.live_values.fetchRemove(air.inst_index)) |dst_vi| unused: {
|
||||||
defer dst_vi.value.deref(isel);
|
defer dst_vi.value.deref(isel);
|
||||||
switch (dst_vi.value.size(isel)) {
|
const size = dst_vi.value.size(isel);
|
||||||
0 => unreachable,
|
if (size <= Value.max_parts and ip.zigTypeTag(ptr_info.child) != .@"union") {
|
||||||
1...Value.max_parts => {
|
const ptr_vi = try isel.use(ty_op.operand);
|
||||||
const ptr_vi = try isel.use(ty_op.operand);
|
const ptr_mat = try ptr_vi.matReg(isel);
|
||||||
const ptr_mat = try ptr_vi.matReg(isel);
|
_ = try dst_vi.value.load(isel, ty_op.ty.toType(), ptr_mat.ra, .{
|
||||||
_ = try dst_vi.value.load(isel, ty_op.ty.toType(), ptr_mat.ra, .{
|
.@"volatile" = ptr_info.flags.is_volatile,
|
||||||
.@"volatile" = ptr_info.flags.is_volatile,
|
});
|
||||||
});
|
try ptr_mat.finish(isel);
|
||||||
try ptr_mat.finish(isel);
|
} else {
|
||||||
},
|
try dst_vi.value.defAddr(isel, .fromInterned(ptr_info.child), .{}) orelse break :unused;
|
||||||
else => |size| {
|
|
||||||
try dst_vi.value.defAddr(isel, .fromInterned(ptr_info.child), null, comptime &.initFill(.free)) orelse break :unused;
|
|
||||||
|
|
||||||
try call.prepareReturn(isel);
|
try call.prepareReturn(isel);
|
||||||
try call.finishReturn(isel);
|
try call.finishReturn(isel);
|
||||||
|
|
||||||
try call.prepareCallee(isel);
|
try call.prepareCallee(isel);
|
||||||
try isel.global_relocs.append(gpa, .{
|
try isel.global_relocs.append(gpa, .{
|
||||||
.name = "memcpy",
|
.name = "memcpy",
|
||||||
.reloc = .{ .label = @intCast(isel.instructions.items.len) },
|
.reloc = .{ .label = @intCast(isel.instructions.items.len) },
|
||||||
});
|
});
|
||||||
try isel.emit(.bl(0));
|
try isel.emit(.bl(0));
|
||||||
try call.finishCallee(isel);
|
try call.finishCallee(isel);
|
||||||
|
|
||||||
try call.prepareParams(isel);
|
try call.prepareParams(isel);
|
||||||
const ptr_vi = try isel.use(ty_op.operand);
|
const ptr_vi = try isel.use(ty_op.operand);
|
||||||
try isel.movImmediate(.x2, size);
|
try isel.movImmediate(.x2, size);
|
||||||
try call.paramLiveOut(isel, ptr_vi, .r1);
|
try call.paramLiveOut(isel, ptr_vi, .r1);
|
||||||
try call.paramAddress(isel, dst_vi.value, .r0);
|
try call.paramAddress(isel, dst_vi.value, .r0);
|
||||||
try call.finishParams(isel);
|
try call.finishParams(isel);
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5727,26 +5721,14 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
const error_set_size = error_set_ty.abiSize(zcu);
|
const error_set_size = error_set_ty.abiSize(zcu);
|
||||||
const payload_size = payload_ty.abiSize(zcu);
|
const payload_size = payload_ty.abiSize(zcu);
|
||||||
|
|
||||||
if (payload_size > 0) {
|
|
||||||
var payload_part_it = error_union_vi.value.field(error_union_ty, payload_offset, payload_size);
|
|
||||||
const payload_part_vi = try payload_part_it.only(isel);
|
|
||||||
if (try payload_part_vi.?.defReg(isel)) |payload_part_ra| try isel.emit(switch (payload_size) {
|
|
||||||
else => unreachable,
|
|
||||||
1...4 => .orr(payload_part_ra.w(), .wzr, .{ .immediate = .{
|
|
||||||
.N = .word,
|
|
||||||
.immr = 0b000001,
|
|
||||||
.imms = 0b111100,
|
|
||||||
} }),
|
|
||||||
5...8 => .orr(payload_part_ra.x(), .xzr, .{ .immediate = .{
|
|
||||||
.N = .word,
|
|
||||||
.immr = 0b000001,
|
|
||||||
.imms = 0b111100,
|
|
||||||
} }),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var error_set_part_it = error_union_vi.value.field(error_union_ty, error_set_offset, error_set_size);
|
var error_set_part_it = error_union_vi.value.field(error_union_ty, error_set_offset, error_set_size);
|
||||||
const error_set_part_vi = try error_set_part_it.only(isel);
|
const error_set_part_vi = try error_set_part_it.only(isel);
|
||||||
try error_set_part_vi.?.move(isel, ty_op.operand);
|
try error_set_part_vi.?.move(isel, ty_op.operand);
|
||||||
|
if (payload_size > 0) {
|
||||||
|
var payload_part_it = error_union_vi.value.field(error_union_ty, payload_offset, payload_size);
|
||||||
|
const payload_part_vi = try payload_part_it.only(isel);
|
||||||
|
try payload_part_vi.?.defUndef(isel, payload_ty, .{});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
||||||
},
|
},
|
||||||
@ -5820,7 +5802,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
||||||
},
|
},
|
||||||
.struct_field_val => {
|
.struct_field_val => {
|
||||||
if (isel.live_values.fetchRemove(air.inst_index)) |field_vi| {
|
if (isel.live_values.fetchRemove(air.inst_index)) |field_vi| unused: {
|
||||||
defer field_vi.value.deref(isel);
|
defer field_vi.value.deref(isel);
|
||||||
|
|
||||||
const ty_pl = air.data(air.inst_index).ty_pl;
|
const ty_pl = air.data(air.inst_index).ty_pl;
|
||||||
@ -5847,27 +5829,55 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
});
|
});
|
||||||
|
|
||||||
const agg_vi = try isel.use(extra.struct_operand);
|
const agg_vi = try isel.use(extra.struct_operand);
|
||||||
var agg_part_it = agg_vi.field(agg_ty, @divExact(field_bit_offset, 8), @divExact(field_bit_size, 8));
|
switch (agg_ty.zigTypeTag(zcu)) {
|
||||||
while (try agg_part_it.next(isel)) |agg_part| {
|
else => unreachable,
|
||||||
var field_part_it = field_vi.value.field(ty_pl.ty.toType(), agg_part.offset, agg_part.vi.size(isel));
|
.@"struct" => {
|
||||||
const field_part_vi = try field_part_it.only(isel);
|
var agg_part_it = agg_vi.field(agg_ty, @divExact(field_bit_offset, 8), @divExact(field_bit_size, 8));
|
||||||
if (field_part_vi.? == agg_part.vi) continue;
|
while (try agg_part_it.next(isel)) |agg_part| {
|
||||||
var field_subpart_it = field_part_vi.?.parts(isel);
|
var field_part_it = field_vi.value.field(ty_pl.ty.toType(), agg_part.offset, agg_part.vi.size(isel));
|
||||||
const field_part_offset = if (field_subpart_it.only()) |field_subpart_vi|
|
const field_part_vi = try field_part_it.only(isel);
|
||||||
field_subpart_vi.get(isel).offset_from_parent
|
if (field_part_vi.? == agg_part.vi) continue;
|
||||||
else
|
var field_subpart_it = field_part_vi.?.parts(isel);
|
||||||
0;
|
const field_part_offset = if (field_subpart_it.only()) |field_subpart_vi|
|
||||||
while (field_subpart_it.next()) |field_subpart_vi| {
|
field_subpart_vi.get(isel).offset_from_parent
|
||||||
const field_subpart_ra = try field_subpart_vi.defReg(isel) orelse continue;
|
else
|
||||||
const field_subpart_offset, const field_subpart_size = field_subpart_vi.position(isel);
|
0;
|
||||||
var agg_subpart_it = agg_part.vi.field(
|
while (field_subpart_it.next()) |field_subpart_vi| {
|
||||||
field_ty,
|
const field_subpart_ra = try field_subpart_vi.defReg(isel) orelse continue;
|
||||||
agg_part.offset + field_subpart_offset - field_part_offset,
|
const field_subpart_offset, const field_subpart_size = field_subpart_vi.position(isel);
|
||||||
field_subpart_size,
|
var agg_subpart_it = agg_part.vi.field(
|
||||||
);
|
field_ty,
|
||||||
const agg_subpart_vi = try agg_subpart_it.only(isel);
|
agg_part.offset + field_subpart_offset - field_part_offset,
|
||||||
try agg_subpart_vi.?.liveOut(isel, field_subpart_ra);
|
field_subpart_size,
|
||||||
}
|
);
|
||||||
|
const agg_subpart_vi = try agg_subpart_it.only(isel);
|
||||||
|
try agg_subpart_vi.?.liveOut(isel, field_subpart_ra);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
.@"union" => {
|
||||||
|
try field_vi.value.defAddr(isel, field_ty, .{}) orelse break :unused;
|
||||||
|
|
||||||
|
try call.prepareReturn(isel);
|
||||||
|
try call.finishReturn(isel);
|
||||||
|
|
||||||
|
try call.prepareCallee(isel);
|
||||||
|
try isel.global_relocs.append(gpa, .{
|
||||||
|
.name = "memcpy",
|
||||||
|
.reloc = .{ .label = @intCast(isel.instructions.items.len) },
|
||||||
|
});
|
||||||
|
try isel.emit(.bl(0));
|
||||||
|
try call.finishCallee(isel);
|
||||||
|
|
||||||
|
try call.prepareParams(isel);
|
||||||
|
const union_layout = agg_ty.unionGetLayout(zcu);
|
||||||
|
var payload_it = agg_vi.field(agg_ty, union_layout.payloadOffset(), union_layout.payload_size);
|
||||||
|
const payload_vi = try payload_it.only(isel);
|
||||||
|
try isel.movImmediate(.x2, field_vi.value.size(isel));
|
||||||
|
try call.paramAddress(isel, payload_vi.?, .r1);
|
||||||
|
try call.paramAddress(isel, field_vi.value, .r0);
|
||||||
|
try call.finishParams(isel);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
||||||
@ -6899,16 +6909,45 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
}
|
}
|
||||||
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
||||||
},
|
},
|
||||||
.union_init => {
|
.union_init => |air_tag| {
|
||||||
if (isel.live_values.fetchRemove(air.inst_index)) |un_vi| unused: {
|
if (isel.live_values.fetchRemove(air.inst_index)) |union_vi| unused: {
|
||||||
defer un_vi.value.deref(isel);
|
defer union_vi.value.deref(isel);
|
||||||
|
|
||||||
const ty_pl = air.data(air.inst_index).ty_pl;
|
const ty_pl = air.data(air.inst_index).ty_pl;
|
||||||
const extra = isel.air.extraData(Air.UnionInit, ty_pl.payload).data;
|
const extra = isel.air.extraData(Air.UnionInit, ty_pl.payload).data;
|
||||||
const un_ty = ty_pl.ty.toType();
|
const union_ty = ty_pl.ty.toType();
|
||||||
if (un_ty.containerLayout(zcu) != .@"extern") return isel.fail("bad union init {f}", .{isel.fmtType(un_ty)});
|
const loaded_union = ip.loadUnionType(union_ty.toIntern());
|
||||||
|
const union_layout = ZigType.getUnionLayout(loaded_union, zcu);
|
||||||
|
|
||||||
try un_vi.value.defAddr(isel, un_ty, null, comptime &.initFill(.free)) orelse break :unused;
|
if (union_layout.tag_size > 0) unused_tag: {
|
||||||
|
const loaded_tag = loaded_union.loadTagType(ip);
|
||||||
|
var tag_it = union_vi.value.field(union_ty, union_layout.tagOffset(), union_layout.tag_size);
|
||||||
|
const tag_vi = try tag_it.only(isel);
|
||||||
|
const tag_ra = try tag_vi.?.defReg(isel) orelse break :unused_tag;
|
||||||
|
switch (union_layout.tag_size) {
|
||||||
|
0 => unreachable,
|
||||||
|
1...4 => try isel.movImmediate(tag_ra.w(), @as(u32, switch (loaded_tag.values.len) {
|
||||||
|
0 => extra.field_index,
|
||||||
|
else => switch (ip.indexToKey(loaded_tag.values.get(ip)[extra.field_index]).int.storage) {
|
||||||
|
.u64 => |imm| @intCast(imm),
|
||||||
|
.i64 => |imm| @bitCast(@as(i32, @intCast(imm))),
|
||||||
|
else => unreachable,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
5...8 => try isel.movImmediate(tag_ra.x(), switch (loaded_tag.values.len) {
|
||||||
|
0 => extra.field_index,
|
||||||
|
else => switch (ip.indexToKey(loaded_tag.values.get(ip)[extra.field_index]).int.storage) {
|
||||||
|
.u64 => |imm| imm,
|
||||||
|
.i64 => |imm| @bitCast(imm),
|
||||||
|
else => unreachable,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
else => return isel.fail("too big {s} {f}", .{ @tagName(air_tag), isel.fmtType(union_ty) }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var payload_it = union_vi.value.field(union_ty, union_layout.payloadOffset(), union_layout.payload_size);
|
||||||
|
const payload_vi = try payload_it.only(isel);
|
||||||
|
try payload_vi.?.defAddr(isel, union_ty, .{ .root_vi = union_vi.value }) orelse break :unused;
|
||||||
|
|
||||||
try call.prepareReturn(isel);
|
try call.prepareReturn(isel);
|
||||||
try call.finishReturn(isel);
|
try call.finishReturn(isel);
|
||||||
@ -6925,7 +6964,7 @@ pub fn body(isel: *Select, air_body: []const Air.Inst.Index) error{ OutOfMemory,
|
|||||||
const init_vi = try isel.use(extra.init);
|
const init_vi = try isel.use(extra.init);
|
||||||
try isel.movImmediate(.x2, init_vi.size(isel));
|
try isel.movImmediate(.x2, init_vi.size(isel));
|
||||||
try call.paramAddress(isel, init_vi, .r1);
|
try call.paramAddress(isel, init_vi, .r1);
|
||||||
try call.paramAddress(isel, un_vi.value, .r0);
|
try call.paramAddress(isel, payload_vi.?, .r0);
|
||||||
try call.finishParams(isel);
|
try call.finishParams(isel);
|
||||||
}
|
}
|
||||||
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
if (air.next()) |next_air_tag| continue :air_tag next_air_tag;
|
||||||
@ -8944,9 +8983,18 @@ pub const Value = struct {
|
|||||||
var dst_part_it = dst_vi.parts(isel);
|
var dst_part_it = dst_vi.parts(isel);
|
||||||
if (dst_part_it.only()) |dst_part_vi| {
|
if (dst_part_it.only()) |dst_part_vi| {
|
||||||
var src_part_it = src_vi.parts(isel);
|
var src_part_it = src_vi.parts(isel);
|
||||||
if (src_part_it.only()) |src_part_vi| {
|
if (src_part_it.only()) |src_part_vi| only: {
|
||||||
try src_part_vi.liveOut(isel, try dst_part_vi.defReg(isel) orelse return);
|
const src_part_size = src_part_vi.size(isel);
|
||||||
} else while (src_part_it.next()) |src_part_vi| {
|
if (src_part_size > @as(@TypeOf(src_part_size), if (src_part_vi.isVector(isel)) 16 else 8)) {
|
||||||
|
var subpart_it = root.src_vi.field(root.ty, root.src_offset, src_part_size - 1);
|
||||||
|
_ = try subpart_it.next(isel);
|
||||||
|
src_part_it = src_vi.parts(isel);
|
||||||
|
assert(src_part_it.only() == null);
|
||||||
|
break :only;
|
||||||
|
}
|
||||||
|
return src_part_vi.liveOut(isel, try dst_part_vi.defReg(isel) orelse return);
|
||||||
|
}
|
||||||
|
while (src_part_it.next()) |src_part_vi| {
|
||||||
const src_part_offset, const src_part_size = src_part_vi.position(isel);
|
const src_part_offset, const src_part_size = src_part_vi.position(isel);
|
||||||
var dst_field_it = root.dst_vi.field(root.ty, root.dst_offset + src_part_offset, src_part_size);
|
var dst_field_it = root.dst_vi.field(root.ty, root.dst_offset + src_part_offset, src_part_size);
|
||||||
const dst_field_vi = try dst_field_it.only(isel);
|
const dst_field_vi = try dst_field_it.only(isel);
|
||||||
@ -9420,9 +9468,12 @@ pub const Value = struct {
|
|||||||
fn defAddr(
|
fn defAddr(
|
||||||
def_vi: Value.Index,
|
def_vi: Value.Index,
|
||||||
isel: *Select,
|
isel: *Select,
|
||||||
def_ty: ZigType,
|
root_ty: ZigType,
|
||||||
wrap: ?std.builtin.Type.Int,
|
opts: struct {
|
||||||
expected_live_registers: *const LiveRegisters,
|
root_vi: Value.Index = .free,
|
||||||
|
wrap: ?std.builtin.Type.Int = null,
|
||||||
|
expected_live_registers: *const LiveRegisters = &.initFill(.free),
|
||||||
|
},
|
||||||
) !?void {
|
) !?void {
|
||||||
if (!def_vi.isUsed(isel)) return null;
|
if (!def_vi.isUsed(isel)) return null;
|
||||||
const offset_from_parent: i65, const parent_vi = def_vi.valueParent(isel);
|
const offset_from_parent: i65, const parent_vi = def_vi.valueParent(isel);
|
||||||
@ -9431,11 +9482,12 @@ pub const Value = struct {
|
|||||||
.stack_slot => |stack_slot| .{ stack_slot, false },
|
.stack_slot => |stack_slot| .{ stack_slot, false },
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
};
|
};
|
||||||
_ = try def_vi.load(isel, def_ty, stack_slot.base, .{
|
_ = try def_vi.load(isel, root_ty, stack_slot.base, .{
|
||||||
|
.root_vi = opts.root_vi,
|
||||||
.offset = @intCast(stack_slot.offset + offset_from_parent),
|
.offset = @intCast(stack_slot.offset + offset_from_parent),
|
||||||
.split = false,
|
.split = false,
|
||||||
.wrap = wrap,
|
.wrap = opts.wrap,
|
||||||
.expected_live_registers = expected_live_registers,
|
.expected_live_registers = opts.expected_live_registers,
|
||||||
});
|
});
|
||||||
if (allocated) parent_vi.setParent(isel, .{ .stack_slot = stack_slot });
|
if (allocated) parent_vi.setParent(isel, .{ .stack_slot = stack_slot });
|
||||||
}
|
}
|
||||||
@ -9514,6 +9566,53 @@ pub const Value = struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn defUndef(def_vi: Value.Index, isel: *Select, root_ty: ZigType, opts: struct {
|
||||||
|
root_vi: Value.Index = .free,
|
||||||
|
offset: u64 = 0,
|
||||||
|
split: bool = true,
|
||||||
|
}) !void {
|
||||||
|
const root_vi = switch (opts.root_vi) {
|
||||||
|
_ => |root_vi| root_vi,
|
||||||
|
.allocating => unreachable,
|
||||||
|
.free => def_vi,
|
||||||
|
};
|
||||||
|
var part_it = def_vi.parts(isel);
|
||||||
|
if (part_it.only()) |part_vi| only: {
|
||||||
|
const part_size = part_vi.size(isel);
|
||||||
|
const part_is_vector = part_vi.isVector(isel);
|
||||||
|
if (part_size > @as(@TypeOf(part_size), if (part_is_vector) 16 else 8)) {
|
||||||
|
if (!opts.split) return;
|
||||||
|
var subpart_it = root_vi.field(root_ty, opts.offset, part_size - 1);
|
||||||
|
_ = try subpart_it.next(isel);
|
||||||
|
part_it = def_vi.parts(isel);
|
||||||
|
assert(part_it.only() == null);
|
||||||
|
break :only;
|
||||||
|
}
|
||||||
|
return if (try part_vi.defReg(isel)) |part_ra| try isel.emit(if (part_is_vector)
|
||||||
|
.movi(switch (part_size) {
|
||||||
|
else => unreachable,
|
||||||
|
1...8 => part_ra.@"8b"(),
|
||||||
|
9...16 => part_ra.@"16b"(),
|
||||||
|
}, 0xaa, .{ .lsl = 0 })
|
||||||
|
else switch (part_size) {
|
||||||
|
else => unreachable,
|
||||||
|
1...4 => .orr(part_ra.w(), .wzr, .{ .immediate = .{
|
||||||
|
.N = .word,
|
||||||
|
.immr = 0b000001,
|
||||||
|
.imms = 0b111100,
|
||||||
|
} }),
|
||||||
|
5...8 => .orr(part_ra.x(), .xzr, .{ .immediate = .{
|
||||||
|
.N = .word,
|
||||||
|
.immr = 0b000001,
|
||||||
|
.imms = 0b111100,
|
||||||
|
} }),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
while (part_it.next()) |part_vi| try part_vi.defUndef(isel, root_ty, .{
|
||||||
|
.root_vi = root_vi,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pub fn liveIn(
|
pub fn liveIn(
|
||||||
vi: Value.Index,
|
vi: Value.Index,
|
||||||
isel: *Select,
|
isel: *Select,
|
||||||
@ -9846,24 +9945,31 @@ pub const Value = struct {
|
|||||||
_ = vi.addPart(isel, 8, 8);
|
_ = vi.addPart(isel, 8, 8);
|
||||||
} else unreachable,
|
} else unreachable,
|
||||||
},
|
},
|
||||||
.opt_type => |child_type| if (ty.optionalReprIsPayload(zcu))
|
.opt_type => |child_type| if (ty.optionalReprIsPayload(zcu)) continue :type_key ip.indexToKey(child_type) else {
|
||||||
continue :type_key ip.indexToKey(child_type)
|
const child_ty: ZigType = .fromInterned(child_type);
|
||||||
else switch (ZigType.fromInterned(child_type).abiSize(zcu)) {
|
const child_size = child_ty.abiSize(zcu);
|
||||||
0...8, 16 => |child_size| if (offset == 0 and size == ty_size) {
|
if (offset == 0 and size == child_size) {
|
||||||
vi.setParts(isel, 2);
|
ty = child_ty;
|
||||||
_ = vi.addPart(isel, 0, child_size);
|
ty_size = child_size;
|
||||||
_ = vi.addPart(isel, child_size, 1);
|
continue :type_key ip.indexToKey(child_type);
|
||||||
} else unreachable,
|
}
|
||||||
9...15 => |child_size| if (offset == 0 and size == ty_size) {
|
switch (child_size) {
|
||||||
vi.setParts(isel, 2);
|
0...8, 16 => if (offset == 0 and size == ty_size) {
|
||||||
_ = vi.addPart(isel, 0, 8);
|
vi.setParts(isel, 2);
|
||||||
_ = vi.addPart(isel, 8, ty_size - 8);
|
_ = vi.addPart(isel, 0, child_size);
|
||||||
} else if (offset == 8 and size == ty_size - 8) {
|
_ = vi.addPart(isel, child_size, 1);
|
||||||
vi.setParts(isel, 2);
|
} else unreachable,
|
||||||
_ = vi.addPart(isel, 0, child_size - 8);
|
9...15 => if (offset == 0 and size == ty_size) {
|
||||||
_ = vi.addPart(isel, child_size - 8, 1);
|
vi.setParts(isel, 2);
|
||||||
} else unreachable,
|
_ = vi.addPart(isel, 0, 8);
|
||||||
else => return isel.fail("Value.FieldPartIterator.next({f})", .{isel.fmtType(ty)}),
|
_ = vi.addPart(isel, 8, ty_size - 8);
|
||||||
|
} else if (offset == 8 and size == ty_size - 8) {
|
||||||
|
vi.setParts(isel, 2);
|
||||||
|
_ = vi.addPart(isel, 0, child_size - 8);
|
||||||
|
_ = vi.addPart(isel, child_size - 8, 1);
|
||||||
|
} else unreachable,
|
||||||
|
else => return isel.fail("Value.FieldPartIterator.next({f})", .{isel.fmtType(ty)}),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
.array_type => |array_type| {
|
.array_type => |array_type| {
|
||||||
const min_part_log2_stride: u5 = if (size > 16) 4 else if (size > 8) 3 else 0;
|
const min_part_log2_stride: u5 = if (size > 16) 4 else if (size > 8) 3 else 0;
|
||||||
|
|||||||
@ -395,7 +395,6 @@ test "array literal as argument to function" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "double nested array to const slice cast in array literal" {
|
test "double nested array to const slice cast in array literal" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) 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
|
||||||
@ -650,7 +649,6 @@ test "runtime initialized sentinel-terminated array literal" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "array of array agregate init" {
|
test "array of array agregate init" {
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@ -107,7 +107,6 @@ test "mixing normal and error defers" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "errdefer with payload" {
|
test "errdefer with payload" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -129,7 +128,6 @@ test "errdefer with payload" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "reference to errdefer payload" {
|
test "reference to errdefer payload" {
|
||||||
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_spirv) return error.SkipZigTest; // TODO
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; // TODO
|
||||||
|
|||||||
@ -390,7 +390,6 @@ test "0-bit child type coerced to optional" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "array of optional unaligned types" {
|
test "array of optional unaligned types" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|||||||
@ -246,7 +246,6 @@ test "implicit casting between C pointer and optional non-C pointer" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "implicit cast error unions with non-optional to optional pointer" {
|
test "implicit cast error unions with non-optional to optional pointer" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|||||||
@ -710,7 +710,6 @@ test "slice pointer-to-array zero length" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "type coercion of pointer to anon struct literal to pointer to slice" {
|
test "type coercion of pointer to anon struct literal to pointer to slice" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|||||||
@ -955,7 +955,6 @@ test "tuple element initialized with fn call" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "struct with union field" {
|
test "struct with union field" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) 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
|
||||||
|
|||||||
@ -12,7 +12,6 @@ const NodeAligned = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test "struct contains slice of itself" {
|
test "struct contains slice of itself" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
@ -53,7 +52,6 @@ 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;
|
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
|
|||||||
@ -466,7 +466,6 @@ test "switch on integer with else capturing expr" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "else prong of switch on error set excludes other cases" {
|
test "else prong of switch on error set excludes other cases" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -502,7 +501,6 @@ test "else prong of switch on error set excludes other cases" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "switch prongs with error set cases make a new error set type for capture value" {
|
test "switch prongs with error set cases make a new error set type for capture value" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -733,7 +731,6 @@ test "switch on error set with single else" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "switch capture copies its payload" {
|
test "switch capture copies its payload" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -928,7 +925,6 @@ test "nested break ignores switch conditions and breaks instead" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "peer type resolution on switch captures ignores unused payload bits" {
|
test "peer type resolution on switch captures ignores unused payload bits" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,6 @@ fn doThing(form_id: u64) anyerror!FormValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "switch prong returns error enum" {
|
test "switch prong returns error enum" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) 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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
|
|||||||
@ -47,7 +47,6 @@ test "try then not executed with assignment" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "`try`ing an if/else expression" {
|
test "`try`ing an if/else expression" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
|
|||||||
@ -12,7 +12,6 @@ const FooWithFloats = union {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test "basic unions with floats" {
|
test "basic unions with floats" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) 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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -29,7 +28,6 @@ fn setFloat(foo: *FooWithFloats, x: f64) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "init union with runtime value - floats" {
|
test "init union with runtime value - floats" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) 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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -41,7 +39,6 @@ test "init union with runtime value - floats" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "basic unions" {
|
test "basic unions" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -60,7 +57,6 @@ const Foo = union {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test "init union with runtime value" {
|
test "init union with runtime value" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) 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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -101,7 +97,6 @@ const FooExtern = extern union {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test "basic extern unions" {
|
test "basic extern unions" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
@ -332,7 +327,6 @@ pub const PackThis = union(enum) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test "constant packed union" {
|
test "constant packed union" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) 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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -478,7 +472,6 @@ pub const FooUnion = union(enum) {
|
|||||||
var glbl_array: [2]FooUnion = undefined;
|
var glbl_array: [2]FooUnion = undefined;
|
||||||
|
|
||||||
test "initialize global array of union" {
|
test "initialize global array of union" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_arm) 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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -810,7 +803,6 @@ test "return union init with void payload" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "@unionInit stored to a const" {
|
test "@unionInit stored to a const" {
|
||||||
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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -917,7 +909,6 @@ test "extern union doesn't trigger field check at comptime" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "anonymous union literal syntax" {
|
test "anonymous union literal syntax" {
|
||||||
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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -1086,7 +1077,6 @@ test "union enum type gets a separate scope" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "global variable struct contains union initialized to non-most-aligned field" {
|
test "global variable struct contains union initialized to non-most-aligned field" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -1113,7 +1103,6 @@ test "global variable struct contains union initialized to non-most-aligned fiel
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "union with no result loc initiated with a runtime value" {
|
test "union with no result loc initiated with a runtime value" {
|
||||||
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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -1131,7 +1120,6 @@ test "union with no result loc initiated with a runtime value" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "union with a large struct field" {
|
test "union with a large struct field" {
|
||||||
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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -1286,7 +1274,6 @@ test "noreturn field in union" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "@unionInit uses tag value instead of field index" {
|
test "@unionInit uses tag value instead of field index" {
|
||||||
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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -1395,7 +1382,6 @@ test "union int tag type is properly managed" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "no dependency loop when function pointer in union returns the union" {
|
test "no dependency loop when function pointer in union returns the union" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -1417,7 +1403,6 @@ test "no dependency loop when function pointer in union returns the union" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "union reassignment can use previous value" {
|
test "union reassignment can use previous value" {
|
||||||
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_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
|
|
||||||
@ -1619,7 +1604,6 @@ test "union with 128 bit integer" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "memset extern union" {
|
test "memset extern union" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
const U = extern union {
|
const U = extern union {
|
||||||
@ -1941,7 +1925,6 @@ test "packed union initialized via reintepreted struct field initializer" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "store of comptime reinterpreted memory to extern union" {
|
test "store of comptime reinterpreted memory to extern union" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
const bytes = [_]u8{ 0xaa, 0xbb, 0xcc, 0xdd };
|
const bytes = [_]u8{ 0xaa, 0xbb, 0xcc, 0xdd };
|
||||||
@ -2048,7 +2031,6 @@ test "circular dependency through pointer field of a union" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "pass nested union with rls" {
|
test "pass nested union with rls" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
@ -2070,7 +2052,6 @@ test "pass nested union with rls" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "runtime union init, most-aligned field != largest" {
|
test "runtime union init, most-aligned field != largest" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
@ -2239,7 +2220,6 @@ test "matching captures causes union equivalence" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "signed enum tag with negative value" {
|
test "signed enum tag with negative value" {
|
||||||
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_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||||
@ -2296,7 +2276,6 @@ test "extern union @FieldType" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "assign global tagged union" {
|
test "assign global tagged union" {
|
||||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
||||||
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
||||||
|
|
||||||
const U = union(enum) {
|
const U = union(enum) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user