From 5e83441096ca77b379be55ad2c197f70ce374eac Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Wed, 25 Oct 2023 17:15:48 -0400 Subject: [PATCH 1/8] x86_64: implement `@divFloor` and `@mod` for `i128` --- lib/std/fs.zig | 4 +- lib/std/fs/test.zig | 4 - lib/std/io/test.zig | 2 - lib/std/math/big/int_test.zig | 20 ---- lib/std/math/big/rational.zig | 20 ---- lib/std/os/linux/io_uring.zig | 2 - lib/std/time.zig | 2 - src/arch/x86_64/CodeGen.zig | 180 +++++++++++++++++++++++++++------- 8 files changed, 147 insertions(+), 87 deletions(-) diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 187e2d7ec1..6cda6716b7 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -3248,9 +3248,7 @@ test { _ = &makeDirAbsolute; _ = &makeDirAbsoluteZ; _ = ©FileAbsolute; - if (builtin.zig_backend != .stage2_x86_64) { - _ = &updateFileAbsolute; - } + _ = &updateFileAbsolute; } _ = &Dir.copyFile; _ = @import("fs/test.zig"); diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 782d9e9265..9a11c7cb29 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1460,8 +1460,6 @@ test "walker without fully iterating" { test ". and .. in fs.Dir functions" { if (builtin.os.tag == .wasi and builtin.link_libc) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64) { // https://github.com/ziglang/zig/issues/17134 return error.SkipZigTest; @@ -1502,8 +1500,6 @@ test ". and .. in fs.Dir functions" { test ". and .. in absolute functions" { if (builtin.os.tag == .wasi) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var tmp = tmpDir(.{}); defer tmp.cleanup(); diff --git a/lib/std/io/test.zig b/lib/std/io/test.zig index 46c40512e2..5774b74b61 100644 --- a/lib/std/io/test.zig +++ b/lib/std/io/test.zig @@ -161,8 +161,6 @@ test "setEndPos" { } test "updateTimes" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var tmp = tmpDir(.{}); defer tmp.cleanup(); diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig index b5ad916c20..66060d6b4b 100644 --- a/lib/std/math/big/int_test.zig +++ b/lib/std/math/big/int_test.zig @@ -1182,8 +1182,6 @@ test "big.int div single-single with rem" { } test "big.int div multi-single no rem" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var op1: u128 = 0xffffeeeeddddcccc; var op2: u128 = 34; @@ -1203,8 +1201,6 @@ test "big.int div multi-single no rem" { } test "big.int div multi-single with rem" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var op1: u128 = 0xffffeeeeddddcccf; var op2: u128 = 34; @@ -1224,8 +1220,6 @@ test "big.int div multi-single with rem" { } test "big.int div multi>2-single" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var op1: u128 = 0xfefefefefefefefefefefefefefefefe; var op2: u128 = 0xefab8; @@ -1405,8 +1399,6 @@ test "big.int div trunc single-single -/-" { } test "big.int divTrunc #15535" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var one = try Managed.initSet(testing.allocator, 1); defer one.deinit(); var x = try Managed.initSet(testing.allocator, std.math.pow(u128, 2, 64)); @@ -1949,8 +1941,6 @@ test "big.int truncate multi to multi signed" { } test "big.int truncate negative multi to single" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, -@as(SignedDoubleLimb, maxInt(Limb) + 1)); defer a.deinit(); @@ -2362,8 +2352,6 @@ test "big.int bitwise xor simple" { } test "big.int bitwise xor multi-limb" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var x: DoubleLimb = maxInt(Limb) + 1; var y: DoubleLimb = maxInt(Limb); var a = try Managed.initSet(testing.allocator, x); @@ -2538,8 +2526,6 @@ test "big.int var args" { } test "big.int gcd non-one small" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 17); defer a.deinit(); var b = try Managed.initSet(testing.allocator, 97); @@ -2553,8 +2539,6 @@ test "big.int gcd non-one small" { } test "big.int gcd non-one medium" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 4864); defer a.deinit(); var b = try Managed.initSet(testing.allocator, 3458); @@ -2568,8 +2552,6 @@ test "big.int gcd non-one medium" { } test "big.int gcd non-one large" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 0xffffffffffffffff); defer a.deinit(); var b = try Managed.initSet(testing.allocator, 0xffffffffffffffff7777); @@ -2602,8 +2584,6 @@ test "big.int gcd large multi-limb result" { } test "big.int gcd one large" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 1897056385327307); defer a.deinit(); var b = try Managed.initSet(testing.allocator, 2251799813685248); diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index f3812fe35d..2558aff38f 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -514,8 +514,6 @@ test "big.rational extractLowBits" { } test "big.rational set" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); @@ -615,8 +613,6 @@ test "big.rational set/to Float round-trip" { } test "big.rational copy" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); @@ -681,8 +677,6 @@ test "big.rational abs" { } test "big.rational swap" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -707,8 +701,6 @@ test "big.rational swap" { } test "big.rational order" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -724,8 +716,6 @@ test "big.rational order" { } test "big.rational order/orderAbs with negative" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -738,8 +728,6 @@ test "big.rational order/orderAbs with negative" { } test "big.rational add single-limb" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -755,8 +743,6 @@ test "big.rational add single-limb" { } test "big.rational add" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -773,8 +759,6 @@ test "big.rational add" { } test "big.rational sub" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -791,8 +775,6 @@ test "big.rational sub" { } test "big.rational mul" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var b = try Rational.init(testing.allocator); @@ -809,8 +791,6 @@ test "big.rational mul" { } test "big.rational div" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - { var a = try Rational.init(testing.allocator); defer a.deinit(); diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 915036d962..0f7fa22d80 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -2204,8 +2204,6 @@ test "sendmsg/recvmsg" { test "timeout (after a relative time)" { if (builtin.os.tag != .linux) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var ring = IO_Uring.init(1, 0) catch |err| switch (err) { error.SystemOutdated => return error.SkipZigTest, error.PermissionDenied => return error.SkipZigTest, diff --git a/lib/std/time.zig b/lib/std/time.zig index 010c1af291..c078e97793 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -122,8 +122,6 @@ pub fn nanoTimestamp() i128 { } test "timestamp" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const margin = ns_per_ms * 50; const time_0 = milliTimestamp(); diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 721216032c..0752f1b8f1 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -3221,6 +3221,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void { .Float, .Vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs), else => {}, } + const dst_abi_size: u32 = @intCast(dst_ty.abiSize(mod)); const dst_info = dst_ty.intInfo(mod); const src_ty = try mod.intType(dst_info.signedness, switch (tag) { @@ -3232,12 +3233,153 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void { ), .div_trunc, .div_floor, .div_exact, .rem, .mod => dst_info.bits, }); + const src_abi_size: u32 = @intCast(src_ty.abiSize(mod)); + + if (dst_abi_size == 16 and src_abi_size == 16) switch (tag) { + else => unreachable, + .mul, .mul_wrap => {}, + .div_trunc, .div_floor, .div_exact, .rem, .mod => { + const signed = dst_ty.isSignedInt(mod); + var callee_buf: ["__udiv?i3".len]u8 = undefined; + const signed_div_floor_state: struct { + frame_index: FrameIndex, + reloc: Mir.Inst.Index, + } = if (signed and tag == .div_floor) state: { + const frame_index = try self.allocFrameIndex(FrameAlloc.initType(Type.usize, mod)); + try self.asmMemoryImmediate( + .{ ._, .mov }, + Memory.sib(.qword, .{ .base = .{ .frame = frame_index } }), + Immediate.u(0), + ); + + const tmp_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp); + const tmp_lock = self.register_manager.lockRegAssumeUnused(tmp_reg); + defer self.register_manager.unlockReg(tmp_lock); + + const lhs_mcv = try self.resolveInst(bin_op.lhs); + if (lhs_mcv.isMemory()) try self.asmRegisterMemory( + .{ ._, .mov }, + tmp_reg, + lhs_mcv.address().offset(8).deref().mem(.qword), + ) else try self.asmRegisterRegister( + .{ ._, .mov }, + tmp_reg, + lhs_mcv.register_pair[1], + ); + + const rhs_mcv = try self.resolveInst(bin_op.rhs); + if (rhs_mcv.isMemory()) try self.asmRegisterMemory( + .{ ._, .xor }, + tmp_reg, + rhs_mcv.address().offset(8).deref().mem(.qword), + ) else try self.asmRegisterRegister( + .{ ._, .xor }, + tmp_reg, + rhs_mcv.register_pair[1], + ); + const reloc = try self.asmJccReloc(.ns, undefined); + + break :state .{ .frame_index = frame_index, .reloc = reloc }; + } else undefined; + const call_mcv = try self.genCall( + .{ .lib = .{ + .return_type = dst_ty.toIntern(), + .param_types = &.{ src_ty.toIntern(), src_ty.toIntern() }, + .callee = std.fmt.bufPrint(&callee_buf, "__{s}{s}{c}i3", .{ + if (signed) "" else "u", + switch (tag) { + .div_trunc, .div_exact => "div", + .div_floor => if (signed) "mod" else "div", + .rem, .mod => "mod", + else => unreachable, + }, + intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))), + }) catch unreachable, + } }, + &.{ src_ty, src_ty }, + &.{ .{ .air_ref = bin_op.lhs }, .{ .air_ref = bin_op.rhs } }, + ); + break :result if (signed) switch (tag) { + .div_floor => { + try self.asmRegisterRegister( + .{ ._, .@"or" }, + call_mcv.register_pair[0], + call_mcv.register_pair[1], + ); + try self.asmSetccMemory(.nz, Memory.sib(.byte, .{ + .base = .{ .frame = signed_div_floor_state.frame_index }, + })); + try self.performReloc(signed_div_floor_state.reloc); + const dst_mcv = try self.genCall( + .{ .lib = .{ + .return_type = dst_ty.toIntern(), + .param_types = &.{ src_ty.toIntern(), src_ty.toIntern() }, + .callee = std.fmt.bufPrint(&callee_buf, "__div{c}i3", .{ + intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))), + }) catch unreachable, + } }, + &.{ src_ty, src_ty }, + &.{ .{ .air_ref = bin_op.lhs }, .{ .air_ref = bin_op.rhs } }, + ); + try self.asmRegisterMemory( + .{ ._, .sub }, + dst_mcv.register_pair[0], + Memory.sib(.qword, .{ + .base = .{ .frame = signed_div_floor_state.frame_index }, + }), + ); + try self.asmRegisterImmediate( + .{ ._, .sbb }, + dst_mcv.register_pair[1], + Immediate.u(0), + ); + try self.freeValue( + .{ .load_frame = .{ .index = signed_div_floor_state.frame_index } }, + ); + break :result dst_mcv; + }, + .mod => { + const dst_regs = call_mcv.register_pair; + const dst_locks = self.register_manager.lockRegsAssumeUnused(2, dst_regs); + defer for (dst_locks) |lock| self.register_manager.unlockReg(lock); + + const tmp_regs = + try self.register_manager.allocRegs(2, .{null} ** 2, abi.RegisterClass.gp); + const tmp_locks = self.register_manager.lockRegsAssumeUnused(2, tmp_regs); + defer for (tmp_locks) |lock| self.register_manager.unlockReg(lock); + + const rhs_mcv = try self.resolveInst(bin_op.rhs); + + for (tmp_regs, dst_regs) |tmp_reg, dst_reg| + try self.asmRegisterRegister(.{ ._, .mov }, tmp_reg, dst_reg); + if (rhs_mcv.isMemory()) { + try self.asmRegisterMemory(.{ ._, .add }, tmp_regs[0], rhs_mcv.mem(.qword)); + try self.asmRegisterMemory( + .{ ._, .adc }, + tmp_regs[1], + rhs_mcv.address().offset(8).deref().mem(.qword), + ); + } else for ( + [_]Mir.Inst.Tag{ .add, .adc }, + tmp_regs, + rhs_mcv.register_pair, + ) |op, tmp_reg, rhs_reg| + try self.asmRegisterRegister(.{ ._, op }, tmp_reg, rhs_reg); + try self.asmRegisterRegister(.{ ._, .@"test" }, dst_regs[1], dst_regs[1]); + for (dst_regs, tmp_regs) |dst_reg, tmp_reg| + try self.asmCmovccRegisterRegister(.s, dst_reg, tmp_reg); + break :result call_mcv; + }, + else => call_mcv, + } else call_mcv; + }, + }; try self.spillEflagsIfOccupied(); try self.spillRegisters(&.{ .rax, .rdx }); - const lhs = try self.resolveInst(bin_op.lhs); - const rhs = try self.resolveInst(bin_op.rhs); - break :result try self.genMulDivBinOp(tag, inst, dst_ty, src_ty, lhs, rhs); + const lhs_mcv = try self.resolveInst(bin_op.lhs); + const rhs_mcv = try self.resolveInst(bin_op.rhs); + break :result try self.genMulDivBinOp(tag, inst, dst_ty, src_ty, lhs_mcv, rhs_mcv); }; return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none }); } @@ -7201,37 +7343,7 @@ fn genMulDivBinOp( assert(self.eflags_inst == null); if (dst_abi_size == 16 and src_abi_size == 16) { - switch (tag) { - else => unreachable, - .mul, .mul_wrap => {}, - .div_trunc, .div_floor, .div_exact, .rem, .mod => { - const signed = dst_ty.isSignedInt(mod); - if (signed) switch (tag) { - .div_floor, .mod => return self.fail( - "TODO implement genMulDivBinOp for {s} from {} to {}", - .{ @tagName(tag), src_ty.fmt(mod), dst_ty.fmt(mod) }, - ), - else => {}, - }; - var callee_buf: ["__udiv?i3".len]u8 = undefined; - return try self.genCall(.{ .lib = .{ - .return_type = dst_ty.toIntern(), - .param_types = &.{ src_ty.toIntern(), src_ty.toIntern() }, - .callee = std.fmt.bufPrint(&callee_buf, "__{s}{s}{c}i3", .{ - if (signed) "" else "u", - switch (tag) { - .div_trunc, .div_exact => "div", - .div_floor => if (signed) unreachable else "div", - .rem => "mod", - .mod => if (signed) unreachable else "mod", - else => unreachable, - }, - intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))), - }) catch unreachable, - } }, &.{ src_ty, src_ty }, &.{ lhs_mcv, rhs_mcv }); - }, - } - + assert(tag == .mul or tag == .mul_wrap); const reg_locks = self.register_manager.lockRegsAssumeUnused(2, .{ .rax, .rdx }); defer for (reg_locks) |lock| self.register_manager.unlockReg(lock); From 3faa4ea9594f058da7522808ffc9587b77ac94a6 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Thu, 26 Oct 2023 01:14:01 -0400 Subject: [PATCH 2/8] main: enable debug modes in build scripts --- src/main.zig | 66 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/src/main.zig b/src/main.zig index 96d8551b70..961047c45c 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3774,7 +3774,9 @@ fn serve( try comp.makeBinFileWritable(); } - { + if (builtin.single_threaded) { + try comp.update(main_progress_node); + } else { var reset: std.Thread.ResetEvent = .{}; var progress_thread = try std.Thread.spawn(.{}, progressThread, .{ @@ -4920,6 +4922,17 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi var child_argv = std.ArrayList([]const u8).init(arena); var reference_trace: ?u32 = null; var debug_compile_errors = false; + var verbose_link = (builtin.os.tag != .wasi or builtin.link_libc) and + EnvVar.ZIG_VERBOSE_LINK.isSet(); + var verbose_cc = (builtin.os.tag != .wasi or builtin.link_libc) and + EnvVar.ZIG_VERBOSE_CC.isSet(); + var verbose_air = false; + var verbose_intern_pool = false; + var verbose_generic_instances = false; + var verbose_llvm_ir: ?[]const u8 = null; + var verbose_llvm_bc: ?[]const u8 = null; + var verbose_cimport = false; + var verbose_llvm_cpu_features = false; var fetch_only = false; const argv_index_exe = child_argv.items.len; @@ -4956,7 +4969,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); i += 1; override_lib_dir = args[i]; - try child_argv.appendSlice(&[_][]const u8{ arg, args[i] }); + try child_argv.appendSlice(&.{ arg, args[i] }); continue; } else if (mem.eql(u8, arg, "--build-runner")) { if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); @@ -4974,22 +4987,52 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi override_global_cache_dir = args[i]; continue; } else if (mem.eql(u8, arg, "-freference-trace")) { - try child_argv.append(arg); reference_trace = 256; } else if (mem.eql(u8, arg, "--fetch")) { fetch_only = true; } else if (mem.startsWith(u8, arg, "-freference-trace=")) { - try child_argv.append(arg); const num = arg["-freference-trace=".len..]; reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| { fatal("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) }); }; } else if (mem.eql(u8, arg, "-fno-reference-trace")) { - try child_argv.append(arg); reference_trace = null; + } else if (mem.eql(u8, arg, "--debug-log")) { + if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); + try child_argv.appendSlice(args[i .. i + 2]); + i += 1; + if (!build_options.enable_logging) { + std.log.warn("Zig was compiled without logging enabled (-Dlog). --debug-log has no effect.", .{}); + } else { + try log_scopes.append(gpa, args[i]); + } + continue; } else if (mem.eql(u8, arg, "--debug-compile-errors")) { - try child_argv.append(arg); - debug_compile_errors = true; + if (!crash_report.is_enabled) { + std.log.warn("Zig was compiled in a release mode. --debug-compile-errors has no effect.", .{}); + } else { + debug_compile_errors = true; + } + } else if (mem.eql(u8, arg, "--verbose-link")) { + verbose_link = true; + } else if (mem.eql(u8, arg, "--verbose-cc")) { + verbose_cc = true; + } else if (mem.eql(u8, arg, "--verbose-air")) { + verbose_air = true; + } else if (mem.eql(u8, arg, "--verbose-intern-pool")) { + verbose_intern_pool = true; + } else if (mem.eql(u8, arg, "--verbose-generic-instances")) { + verbose_generic_instances = true; + } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) { + verbose_llvm_ir = "-"; + } else if (mem.startsWith(u8, arg, "--verbose-llvm-ir=")) { + verbose_llvm_ir = arg["--verbose-llvm-ir=".len..]; + } else if (mem.startsWith(u8, arg, "--verbose-llvm-bc=")) { + verbose_llvm_bc = arg["--verbose-llvm-bc=".len..]; + } else if (mem.eql(u8, arg, "--verbose-cimport")) { + verbose_cimport = true; + } else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) { + verbose_llvm_cpu_features = true; } else if (mem.eql(u8, arg, "--seed")) { if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg}); i += 1; @@ -5264,6 +5307,15 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi .optimize_mode = .Debug, .self_exe_path = self_exe_path, .thread_pool = &thread_pool, + .verbose_cc = verbose_cc, + .verbose_link = verbose_link, + .verbose_air = verbose_air, + .verbose_intern_pool = verbose_intern_pool, + .verbose_generic_instances = verbose_generic_instances, + .verbose_llvm_ir = verbose_llvm_ir, + .verbose_llvm_bc = verbose_llvm_bc, + .verbose_cimport = verbose_cimport, + .verbose_llvm_cpu_features = verbose_llvm_cpu_features, .cache_mode = .whole, .reference_trace = reference_trace, .debug_compile_errors = debug_compile_errors, From 98cd3782087d198425cfa19906f43d53b8106837 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Thu, 26 Oct 2023 02:11:54 -0400 Subject: [PATCH 3/8] x86_64: fix behavior of `getValue` Old behavior renamed to `getValueIfFree`. --- lib/std/Build/Step/Options.zig | 2 - lib/std/array_hash_map.zig | 2 - lib/std/json/JSONTestSuite_test.zig | 6 - lib/std/json/dynamic_test.zig | 13 -- lib/std/json/hashmap_test.zig | 13 -- lib/std/json/static_test.zig | 3 +- lib/std/json/stringify_test.zig | 3 - lib/std/json/test.zig | 2 - lib/std/math/ilogb.zig | 3 +- lib/std/mem.zig | 6 +- lib/std/net/test.zig | 1 - lib/std/os/linux/io_uring.zig | 2 - lib/std/rand/Xoshiro256.zig | 6 +- lib/std/zig/Parse.zig | 2 - lib/std/zig/parser_test.zig | 320 ++++++++++++++++++++++++++++ src/arch/x86_64/CodeGen.zig | 12 +- 16 files changed, 334 insertions(+), 62 deletions(-) diff --git a/lib/std/Build/Step/Options.zig b/lib/std/Build/Step/Options.zig index 669803b627..8255be5cf4 100644 --- a/lib/std/Build/Step/Options.zig +++ b/lib/std/Build/Step/Options.zig @@ -295,8 +295,6 @@ const Arg = struct { test Options { if (builtin.os.tag == .wasi) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena.deinit(); diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 13ade92ceb..75a86f63f6 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -2294,8 +2294,6 @@ test "popOrNull" { } test "reIndex" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - var map = ArrayHashMap(i32, i32, AutoContext(i32), true).init(std.testing.allocator); defer map.deinit(); diff --git a/lib/std/json/JSONTestSuite_test.zig b/lib/std/json/JSONTestSuite_test.zig index 5d75e72159..30c5907f8b 100644 --- a/lib/std/json/JSONTestSuite_test.zig +++ b/lib/std/json/JSONTestSuite_test.zig @@ -764,8 +764,6 @@ test "y_number_simple_real.json" { try ok("[123.456789]"); } test "y_object.json" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try ok("{\"asd\":\"sdf\", \"dfg\":\"fgh\"}"); } test "y_object_basic.json" { @@ -787,13 +785,9 @@ test "y_object_escaped_null_in_key.json" { try ok("{\"foo\\u0000bar\": 42}"); } test "y_object_extreme_numbers.json" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try ok("{ \"min\": -1.0e+28, \"max\": 1.0e+28 }"); } test "y_object_long_strings.json" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try ok("{\"x\":[{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}], \"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}"); } test "y_object_simple.json" { diff --git a/lib/std/json/dynamic_test.zig b/lib/std/json/dynamic_test.zig index c3500b6826..ad737502ed 100644 --- a/lib/std/json/dynamic_test.zig +++ b/lib/std/json/dynamic_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const mem = std.mem; const testing = std.testing; const ArenaAllocator = std.heap.ArenaAllocator; @@ -19,8 +18,6 @@ const jsonReader = @import("scanner.zig").reader; const JsonReader = @import("scanner.zig").Reader; test "json.parser.dynamic" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const s = \\{ \\ "Image": { @@ -75,8 +72,6 @@ test "json.parser.dynamic" { const writeStream = @import("./stringify.zig").writeStream; test "write json then parse it" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var out_buffer: [1000]u8 = undefined; var fixed_buffer_stream = std.io.fixedBufferStream(&out_buffer); @@ -143,8 +138,6 @@ test "Value.array allocator should still be usable after parsing" { } test "integer after float has proper type" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena_allocator.deinit(); const parsed = try testParse(arena_allocator.allocator(), @@ -157,8 +150,6 @@ test "integer after float has proper type" { } test "escaped characters" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena_allocator.deinit(); const input = @@ -238,8 +229,6 @@ test "Value.jsonStringify" { } test "parseFromValue(std.json.Value,...)" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const str = \\{ \\ "int": 32, @@ -328,8 +317,6 @@ test "ParseOptions.max_value_len" { } test "many object keys" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const doc = \\{ \\ "k1": "v1", diff --git a/lib/std/json/hashmap_test.zig b/lib/std/json/hashmap_test.zig index 1f71d91f7b..49d8caffae 100644 --- a/lib/std/json/hashmap_test.zig +++ b/lib/std/json/hashmap_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const testing = std.testing; const ArrayHashMap = @import("hashmap.zig").ArrayHashMap; @@ -19,8 +18,6 @@ const T = struct { }; test "parse json hashmap" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const doc = \\{ \\ "abc": {"i": 0, "s": "d"}, @@ -36,8 +33,6 @@ test "parse json hashmap" { } test "parse json hashmap while streaming" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const doc = \\{ \\ "abc": {"i": 0, "s": "d"}, @@ -63,8 +58,6 @@ test "parse json hashmap while streaming" { } test "parse json hashmap duplicate fields" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var arena = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena.deinit(); @@ -93,8 +86,6 @@ test "parse json hashmap duplicate fields" { } test "stringify json hashmap" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var value = ArrayHashMap(T){}; defer value.deinit(testing.allocator); { @@ -132,8 +123,6 @@ test "stringify json hashmap" { } test "stringify json hashmap whitespace" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var value = ArrayHashMap(T){}; defer value.deinit(testing.allocator); try value.map.put(testing.allocator, "abc", .{ .i = 0, .s = "d" }); @@ -158,8 +147,6 @@ test "stringify json hashmap whitespace" { } test "json parse from value hashmap" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const doc = \\{ \\ "abc": {"i": 0, "s": "d"}, diff --git a/lib/std/json/static_test.zig b/lib/std/json/static_test.zig index e447000674..0e071eefe3 100644 --- a/lib/std/json/static_test.zig +++ b/lib/std/json/static_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const testing = std.testing; const ArenaAllocator = std.heap.ArenaAllocator; const Allocator = std.mem.Allocator; @@ -786,7 +785,7 @@ test "max_value_len" { } test "parse into vector" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; const T = struct { vec_i32: @Vector(4, i32), diff --git a/lib/std/json/stringify_test.zig b/lib/std/json/stringify_test.zig index 6c27d392fe..9baeae9389 100644 --- a/lib/std/json/stringify_test.zig +++ b/lib/std/json/stringify_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const mem = std.mem; const testing = std.testing; @@ -16,8 +15,6 @@ const writeStreamMaxDepth = @import("stringify.zig").writeStreamMaxDepth; const writeStreamArbitraryDepth = @import("stringify.zig").writeStreamArbitraryDepth; test "json write stream" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var out_buf: [1024]u8 = undefined; var slice_stream = std.io.fixedBufferStream(&out_buf); const out = slice_stream.writer(); diff --git a/lib/std/json/test.zig b/lib/std/json/test.zig index 51c54a14aa..9530ab37a6 100644 --- a/lib/std/json/test.zig +++ b/lib/std/json/test.zig @@ -34,8 +34,6 @@ fn testHighLevelDynamicParser(s: []const u8) !void { // Additional tests not part of test JSONTestSuite. test "y_trailing_comma_after_empty" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try roundTrip( \\{"1":[],"2":{},"3":"4"} ); diff --git a/lib/std/math/ilogb.zig b/lib/std/math/ilogb.zig index b03d82bcbf..aad29a627e 100644 --- a/lib/std/math/ilogb.zig +++ b/lib/std/math/ilogb.zig @@ -6,7 +6,6 @@ // https://git.musl-libc.org/cgit/musl/tree/src/math/ilogb.c const std = @import("../std.zig"); -const builtin = @import("builtin"); const math = std.math; const expect = std.testing.expect; const maxInt = std.math.maxInt; @@ -109,7 +108,7 @@ test "64" { } test "80" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; try expect(ilogbX(f80, 0.0) == fp_ilogb0); try expect(ilogbX(f80, 0.5) == -1); diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 356a9389ee..0abc76ee29 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -4661,10 +4661,8 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice } test "read/write(Var)PackedInt" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; switch (builtin.cpu.arch) { // This test generates too much code to execute on WASI. diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig index 3adbe9eb15..fd92c64f35 100644 --- a/lib/std/net/test.zig +++ b/lib/std/net/test.zig @@ -107,7 +107,6 @@ test "parse and render UNIX addresses" { } test "resolve DNS" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest; if (builtin.os.tag == .windows) { diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 0f7fa22d80..7f7dd21f95 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -2268,8 +2268,6 @@ test "timeout (after a number of completions)" { test "timeout_remove" { if (builtin.os.tag != .linux) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var ring = IO_Uring.init(2, 0) catch |err| switch (err) { error.SystemOutdated => return error.SkipZigTest, error.PermissionDenied => return error.SkipZigTest, diff --git a/lib/std/rand/Xoshiro256.zig b/lib/std/rand/Xoshiro256.zig index 29988f1166..5c30dc3fa7 100644 --- a/lib/std/rand/Xoshiro256.zig +++ b/lib/std/rand/Xoshiro256.zig @@ -90,10 +90,8 @@ pub fn fill(self: *Xoshiro256, buf: []u8) void { } test "xoroshiro sequence" { - switch (@import("builtin").zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; var r = Xoshiro256.init(0); diff --git a/lib/std/zig/Parse.zig b/lib/std/zig/Parse.zig index 84c80214e5..0187c09108 100644 --- a/lib/std/zig/Parse.zig +++ b/lib/std/zig/Parse.zig @@ -4102,7 +4102,5 @@ const TokenIndex = Ast.TokenIndex; const Token = std.zig.Token; test { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - _ = @import("parser_test.zig"); } diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 203976ec1a..2be1c4399b 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -26,6 +26,8 @@ test "zig fmt: tuple struct" { } test "zig fmt: preserves clobbers in inline asm with stray comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ asm volatile ("" @@ -44,6 +46,8 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" { } test "zig fmt: remove trailing comma at the end of assembly clobber" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\fn foo() void { \\ asm volatile ("" @@ -66,6 +70,8 @@ test "zig fmt: remove trailing comma at the end of assembly clobber" { } test "zig fmt: respect line breaks in struct field value declaration" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const Foo = struct { \\ bar: u32 = @@ -220,6 +226,8 @@ test "zig fmt: file ends in comment after var decl" { } test "zig fmt: if statement" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ if (optional()) |some| @@ -318,6 +326,8 @@ test "zig fmt: decl between fields" { } test "zig fmt: errdefer with payload" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn main() anyerror!void { \\ errdefer |a| x += 1; @@ -331,6 +341,8 @@ test "zig fmt: errdefer with payload" { } test "zig fmt: nosuspend block" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn main() anyerror!void { \\ nosuspend { @@ -342,6 +354,8 @@ test "zig fmt: nosuspend block" { } test "zig fmt: nosuspend await" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ x = nosuspend await y; @@ -362,6 +376,8 @@ test "zig fmt: container declaration, single line" { } test "zig fmt: container declaration, one item, multi line trailing comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ comptime { @@ -375,6 +391,8 @@ test "zig fmt: container declaration, one item, multi line trailing comma" { } test "zig fmt: container declaration, no trailing comma on separate line" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test "" { \\ comptime { @@ -501,6 +519,8 @@ test "zig fmt: remove empty lines at start/end of container decl" { } test "zig fmt: remove empty lines at start/end of block" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test { \\ @@ -521,6 +541,8 @@ test "zig fmt: remove empty lines at start/end of block" { } test "zig fmt: allow empty line before comment at start of block" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ @@ -584,6 +606,8 @@ test "zig fmt: comptime struct field" { } test "zig fmt: break from block" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const a = blk: { \\ break :blk 42; @@ -616,6 +640,8 @@ test "zig fmt: c pointer type" { } test "zig fmt: builtin call with trailing comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn main() void { \\ @breakpoint(); @@ -631,6 +657,8 @@ test "zig fmt: builtin call with trailing comma" { } test "zig fmt: asm expression with comptime content" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ asm ("foo" ++ "bar"); @@ -655,6 +683,8 @@ test "zig fmt: asm expression with comptime content" { } test "zig fmt: array types last token" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = [40]u32; @@ -668,6 +698,8 @@ test "zig fmt: array types last token" { } test "zig fmt: sentinel-terminated array type" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn cStrToPrefixedFileW(s: [*:0]const u8) ![PATH_MAX_WIDE:0]u16 { \\ return sliceToPrefixedFileW(mem.toSliceConst(u8, s)); @@ -677,6 +709,8 @@ test "zig fmt: sentinel-terminated array type" { } test "zig fmt: sentinel-terminated slice type" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn toSlice(self: Buffer) [:0]u8 { \\ return self.list.toSlice()[0..self.len()]; @@ -748,6 +782,8 @@ test "zig fmt: anon literal in array" { } test "zig fmt: alignment in anonymous literal" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const a = .{ \\ "U", "L", "F", @@ -766,6 +802,8 @@ test "zig fmt: alignment in anonymous literal" { } test "zig fmt: anon struct literal 0 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{}; @@ -775,6 +813,8 @@ test "zig fmt: anon struct literal 0 element" { } test "zig fmt: anon struct literal 1 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ .a = b }; @@ -784,6 +824,8 @@ test "zig fmt: anon struct literal 1 element" { } test "zig fmt: anon struct literal 1 element comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ @@ -795,6 +837,8 @@ test "zig fmt: anon struct literal 1 element comma" { } test "zig fmt: anon struct literal 2 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ .a = b, .c = d }; @@ -804,6 +848,8 @@ test "zig fmt: anon struct literal 2 element" { } test "zig fmt: anon struct literal 2 element comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ @@ -816,6 +862,8 @@ test "zig fmt: anon struct literal 2 element comma" { } test "zig fmt: anon struct literal 3 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ .a = b, .c = d, .e = f }; @@ -825,6 +873,8 @@ test "zig fmt: anon struct literal 3 element" { } test "zig fmt: anon struct literal 3 element comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ @@ -838,6 +888,8 @@ test "zig fmt: anon struct literal 3 element comma" { } test "zig fmt: struct literal 0 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{}; @@ -847,6 +899,8 @@ test "zig fmt: struct literal 0 element" { } test "zig fmt: struct literal 1 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{ .a = b }; @@ -856,6 +910,8 @@ test "zig fmt: struct literal 1 element" { } test "zig fmt: Unicode code point literal larger than u8" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{ @@ -867,6 +923,8 @@ test "zig fmt: Unicode code point literal larger than u8" { } test "zig fmt: struct literal 2 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{ .a = b, .c = d }; @@ -876,6 +934,8 @@ test "zig fmt: struct literal 2 element" { } test "zig fmt: struct literal 2 element comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{ @@ -888,6 +948,8 @@ test "zig fmt: struct literal 2 element comma" { } test "zig fmt: struct literal 3 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{ .a = b, .c = d, .e = f }; @@ -897,6 +959,8 @@ test "zig fmt: struct literal 3 element" { } test "zig fmt: struct literal 3 element comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = X{ @@ -910,6 +974,8 @@ test "zig fmt: struct literal 3 element comma" { } test "zig fmt: anon list literal 1 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{a}; @@ -930,6 +996,8 @@ test "zig fmt: anon list literal 1 element comma" { } test "zig fmt: anon list literal 2 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ a, b }; @@ -951,6 +1019,8 @@ test "zig fmt: anon list literal 2 element comma" { } test "zig fmt: anon list literal 3 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = .{ a, b, c }; @@ -975,6 +1045,8 @@ test "zig fmt: anon list literal 3 element comma" { } test "zig fmt: array literal 0 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = [_]u32{}; @@ -984,6 +1056,8 @@ test "zig fmt: array literal 0 element" { } test "zig fmt: array literal 1 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = [_]u32{a}; @@ -1004,6 +1078,8 @@ test "zig fmt: array literal 1 element comma" { } test "zig fmt: array literal 2 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = [_]u32{ a, b }; @@ -1025,6 +1101,8 @@ test "zig fmt: array literal 2 element comma" { } test "zig fmt: array literal 3 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = [_]u32{ a, b, c }; @@ -1047,6 +1125,8 @@ test "zig fmt: array literal 3 element comma" { } test "zig fmt: sentinel array literal 1 element" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const x = [_:9000]u32{a}; @@ -1076,6 +1156,8 @@ test "zig fmt: slices with spaces in bounds" { } test "zig fmt: block in slice expression" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const a = b[{ \\ _ = x; @@ -1094,6 +1176,8 @@ test "zig fmt: block in slice expression" { } test "zig fmt: async function" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub const Server = struct { \\ handleRequestFn: fn (*Server, *const std.net.Address, File) callconv(.Async) void, @@ -1106,6 +1190,8 @@ test "zig fmt: async function" { } test "zig fmt: whitespace fixes" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform("test \"\" {\r\n\tconst hi = x;\r\n}\n// zig fmt: off\ntest \"\"{\r\n\tconst a = b;}\r\n", \\test "" { \\ const hi = x; @@ -1118,6 +1204,8 @@ test "zig fmt: whitespace fixes" { } test "zig fmt: while else err prong with no block" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ const result = while (returnError()) |value| { @@ -1147,6 +1235,8 @@ test "zig fmt: tagged union with enum values" { } test "zig fmt: tagged union enum tag last token" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const U = union(enum(u32)) {}; @@ -1482,6 +1572,8 @@ test "zig fmt: doc and line comment following 'zig fmt: on'" { } test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test "" { \\ const x = 42; @@ -1508,6 +1600,8 @@ test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" { } test "zig fmt: 'zig fmt: on' indentation is unchanged" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn initOptionsAndLayouts(output: *Output, context: *Context) !void { \\ // zig fmt: off @@ -1550,6 +1644,8 @@ test "zig fmt: spaces around slice operator" { } test "zig fmt: async call in if condition" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ if (async b()) { @@ -1561,6 +1657,8 @@ test "zig fmt: async call in if condition" { } test "zig fmt: 2nd arg multiline string" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ cases.addAsm("hello world linux x86_64", @@ -1589,6 +1687,8 @@ test "zig fmt: 2nd arg multiline string" { } test "zig fmt: 2nd arg multiline string many args" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ cases.addAsm("hello world linux x86_64", @@ -1600,6 +1700,8 @@ test "zig fmt: 2nd arg multiline string many args" { } test "zig fmt: final arg multiline string" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ cases.addAsm("hello world linux x86_64", "Hello, world!\n", @@ -1611,6 +1713,8 @@ test "zig fmt: final arg multiline string" { } test "zig fmt: if condition wraps" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\comptime { \\ if (cond and @@ -1692,6 +1796,8 @@ test "zig fmt: if condition wraps" { } test "zig fmt: if condition has line break but must not wrap" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ if (self.user_input_options.put( @@ -1716,6 +1822,8 @@ test "zig fmt: if condition has line break but must not wrap" { } test "zig fmt: if condition has line break but must not wrap (no fn call comma)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ if (self.user_input_options.put(name, UserInputOption{ @@ -1737,6 +1845,8 @@ test "zig fmt: if condition has line break but must not wrap (no fn call comma)" } test "zig fmt: function call with multiline argument" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ self.user_input_options.put(name, UserInputOption{ @@ -1749,6 +1859,8 @@ test "zig fmt: function call with multiline argument" { } test "zig fmt: if-else with comment before else" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ // cexp(finite|nan +- i inf|nan) = nan + i nan @@ -1767,6 +1879,8 @@ test "zig fmt: if-else with comment before else" { } test "zig fmt: if nested" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn foo() void { \\ return if ((aInt & bInt) >= 0) @@ -1790,6 +1904,8 @@ test "zig fmt: if nested" { } test "zig fmt: respect line breaks in if-else" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ return if (cond) a else b; @@ -1809,6 +1925,8 @@ test "zig fmt: respect line breaks in if-else" { } test "zig fmt: respect line breaks after infix operators" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ self.crc = @@ -1872,6 +1990,8 @@ test "zig fmt: switch comment after prong" { } test "zig fmt: struct literal no trailing comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const a = foo{ .x = 1, .y = 2 }; \\const a = foo{ .x = 1, @@ -1890,6 +2010,8 @@ test "zig fmt: struct literal no trailing comma" { } test "zig fmt: struct literal containing a multiline expression" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const a = A{ .x = if (f1()) 10 else 20 }; \\const a = A{ .x = if (f1()) 10 else 20, }; @@ -1951,6 +2073,8 @@ test "zig fmt: struct literal containing a multiline expression" { } test "zig fmt: array literal with hint" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const a = []u8{ \\ 1, 2, // @@ -2028,6 +2152,8 @@ test "zig fmt: array literal with hint" { } test "zig fmt: array literal vertical column alignment" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const a = []u8{ \\ 1000, 200, @@ -2075,6 +2201,8 @@ test "zig fmt: array literal vertical column alignment" { } test "zig fmt: multiline string with backslash at end of line" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ err( @@ -2086,6 +2214,8 @@ test "zig fmt: multiline string with backslash at end of line" { } test "zig fmt: multiline string parameter in fn call with trailing comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ try stdout.print( @@ -2104,6 +2234,8 @@ test "zig fmt: multiline string parameter in fn call with trailing comma" { } test "zig fmt: trailing comma on fn call" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ var module = try Module.create( @@ -2117,6 +2249,8 @@ test "zig fmt: trailing comma on fn call" { } test "zig fmt: multi line arguments without last comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\pub fn foo( \\ a: usize, @@ -2178,6 +2312,8 @@ test "zig fmt: extra newlines at the end" { } test "zig fmt: simple asm" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\comptime { \\ asm volatile ( @@ -2215,6 +2351,8 @@ test "zig fmt: simple asm" { } test "zig fmt: nested struct literal with one item" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const a = foo{ \\ .item = bar{ .a = b }, @@ -2258,6 +2396,8 @@ test "zig fmt: slice align" { } test "zig fmt: add trailing comma to array literal" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\comptime { \\ return []u16{'m', 's', 'y', 's', '-' // hi @@ -2299,6 +2439,8 @@ test "zig fmt: line comment after doc comment" { } test "zig fmt: bit field alignment" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ assert(@TypeOf(&blah.b) == *align(1:3:6) const u3); @@ -2330,6 +2472,8 @@ test "zig fmt: float literal with exponent" { } test "zig fmt: if-else end of comptime" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ if (a) { @@ -2343,6 +2487,8 @@ test "zig fmt: if-else end of comptime" { } test "zig fmt: nested blocks" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ { @@ -2358,6 +2504,8 @@ test "zig fmt: nested blocks" { } test "zig fmt: block with same line comment after end brace" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ { @@ -2369,6 +2517,8 @@ test "zig fmt: block with same line comment after end brace" { } test "zig fmt: statements with comment between" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ a = b; @@ -2380,6 +2530,8 @@ test "zig fmt: statements with comment between" { } test "zig fmt: statements with empty line between" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ a = b; @@ -2399,6 +2551,8 @@ test "zig fmt: ptr deref operator and unwrap optional operator" { } test "zig fmt: comment after if before another if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "aoeu" { \\ // comment @@ -2421,6 +2575,8 @@ test "zig fmt: comment after if before another if" { } test "zig fmt: line comment between if block and else keyword" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "aoeu" { \\ // cexp(finite|nan +- i inf|nan) = nan + i nan @@ -2442,6 +2598,8 @@ test "zig fmt: line comment between if block and else keyword" { } test "zig fmt: same line comments in expression" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "aoeu" { \\ const x = ( // a @@ -2482,6 +2640,8 @@ test "zig fmt: add comma on last switch prong" { } test "zig fmt: same-line comment after a statement" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ a = b; @@ -2527,6 +2687,8 @@ test "zig fmt: same-line comment after switch prong" { } test "zig fmt: same-line comment after non-block if expression" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\comptime { \\ if (sr > n_uword_bits - 1) // d > r @@ -2537,6 +2699,8 @@ test "zig fmt: same-line comment after non-block if expression" { } test "zig fmt: same-line comment on comptime expression" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt @@ -2546,6 +2710,8 @@ test "zig fmt: same-line comment on comptime expression" { } test "zig fmt: switch with empty body" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ foo() catch |err| switch (err) {}; @@ -2555,6 +2721,8 @@ test "zig fmt: switch with empty body" { } test "zig fmt: line comments in struct initializer" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ return Self{ @@ -2577,6 +2745,8 @@ test "zig fmt: line comments in struct initializer" { } test "zig fmt: first line comment in struct initializer" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn acquire(self: *Self) HeldLock { \\ return HeldLock{ @@ -2645,6 +2815,8 @@ test "zig fmt: union(enum(u32)) with assigned enum values" { } test "zig fmt: resume from suspend block" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ suspend { @@ -2730,6 +2902,8 @@ test "zig fmt: comments before global variables" { } test "zig fmt: comments in statements" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "std" { \\ // statement comment @@ -2757,6 +2931,8 @@ test "zig fmt: comments before test decl" { } test "zig fmt: preserve spacing" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const std = @import("std"); \\ @@ -2825,6 +3001,8 @@ test "zig fmt: alignment" { } test "zig fmt: C main" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn main(argc: c_int, argv: **u8) c_int { \\ const a = b; @@ -2834,6 +3012,8 @@ test "zig fmt: C main" { } test "zig fmt: return" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo(argc: c_int, argv: **u8) c_int { \\ return 0; @@ -2896,6 +3076,8 @@ test "zig fmt: slice attributes" { } test "zig fmt: test declaration" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "test name" { \\ const a = 1; @@ -2906,6 +3088,8 @@ test "zig fmt: test declaration" { } test "zig fmt: infix operators" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ var i = undefined; @@ -2958,6 +3142,8 @@ test "zig fmt: infix operators" { } test "zig fmt: precedence" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "precedence" { \\ a!b(); @@ -2990,6 +3176,8 @@ test "zig fmt: precedence" { } test "zig fmt: prefix operators" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "prefix operators" { \\ try return --%~!&0; @@ -2999,6 +3187,8 @@ test "zig fmt: prefix operators" { } test "zig fmt: call expression" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "test calls" { \\ a(); @@ -3018,6 +3208,8 @@ test "zig fmt: anytype type" { } test "zig fmt: functions" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\extern fn puts(s: *const u8) c_int; \\extern "c" fn puts(s: *const u8) c_int; @@ -3042,6 +3234,8 @@ test "zig fmt: functions" { } test "zig fmt: multiline string" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "" { \\ const s1 = @@ -3060,6 +3254,8 @@ test "zig fmt: multiline string" { } test "zig fmt: values" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "values" { \\ 1; @@ -3079,6 +3275,8 @@ test "zig fmt: values" { } test "zig fmt: indexing" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "test index" { \\ a[0]; @@ -3099,6 +3297,8 @@ test "zig fmt: indexing" { } test "zig fmt: struct declaration" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const S = struct { \\ const Self = @This(); @@ -3205,6 +3405,8 @@ test "zig fmt: union declaration" { } test "zig fmt: arrays" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "test array" { \\ const a: [2]u8 = [2]u8{ @@ -3223,6 +3425,8 @@ test "zig fmt: arrays" { } test "zig fmt: container initializers" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const a0 = []u8{}; \\const a1 = []u8{1}; @@ -3243,6 +3447,8 @@ test "zig fmt: container initializers" { } test "zig fmt: catch" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "catch" { \\ const a: anyerror!u8 = 0; @@ -3258,6 +3464,8 @@ test "zig fmt: catch" { } test "zig fmt: blocks" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "blocks" { \\ { @@ -3280,6 +3488,8 @@ test "zig fmt: blocks" { } test "zig fmt: switch" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "switch" { \\ switch (0) { @@ -3335,6 +3545,8 @@ test "zig fmt: switch" { } test "zig fmt: switch multiline string" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "switch multiline string" { \\ const x: u32 = 0; @@ -3366,6 +3578,8 @@ test "zig fmt: switch multiline string" { } test "zig fmt: while" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "while" { \\ while (10 < 1) unreachable; @@ -3441,6 +3655,8 @@ test "zig fmt: while" { } test "zig fmt: for" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "for" { \\ for (a) |v| { @@ -3542,6 +3758,8 @@ test "zig fmt: for" { } test "zig fmt: for if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ for (a) |x| if (x) f(x); @@ -3567,6 +3785,8 @@ test "zig fmt: for if" { } test "zig fmt: if for" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ if (a) for (x) |x| f(x); @@ -3592,6 +3812,8 @@ test "zig fmt: if for" { } test "zig fmt: while if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ while (a) if (x) f(x); @@ -3617,6 +3839,8 @@ test "zig fmt: while if" { } test "zig fmt: if while" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ if (a) while (x) : (cont) f(x); @@ -3642,6 +3866,8 @@ test "zig fmt: if while" { } test "zig fmt: while for" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ while (a) for (x) |x| f(x); @@ -3667,6 +3893,8 @@ test "zig fmt: while for" { } test "zig fmt: for while" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ for (a) |a| while (x) |x| f(x); @@ -3692,6 +3920,8 @@ test "zig fmt: for while" { } test "zig fmt: if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "if" { \\ if (10 < 0) { @@ -3741,6 +3971,8 @@ test "zig fmt: if" { } test "zig fmt: fix single statement if/for/while line breaks" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test { \\ if (cond) a @@ -3793,6 +4025,8 @@ test "zig fmt: fix single statement if/for/while line breaks" { } test "zig fmt: anon struct/array literal in if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const a = if (cond) .{ @@ -3817,6 +4051,8 @@ test "zig fmt: anon struct/array literal in if" { } test "zig fmt: defer" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "defer" { \\ var i: usize = 0; @@ -3837,6 +4073,8 @@ test "zig fmt: defer" { } test "zig fmt: comptime" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn a() u8 { \\ return 5; @@ -3876,6 +4114,8 @@ test "zig fmt: comptime" { } test "zig fmt: fn type" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn a(i: u8) u8 { \\ return i + 1; @@ -3889,6 +4129,8 @@ test "zig fmt: fn type" { } test "zig fmt: inline asm" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn syscall1(number: usize, arg1: usize) usize { \\ return asm volatile ("syscall" @@ -3903,6 +4145,8 @@ test "zig fmt: inline asm" { } test "zig fmt: async functions" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn simpleAsyncFn() void { \\ const a = async a.b(); @@ -3931,6 +4175,8 @@ test "zig fmt: nosuspend" { } test "zig fmt: Block after if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ if (true) { @@ -3962,6 +4208,8 @@ test "zig fmt: string identifier" { } test "zig fmt: error return" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn err() anyerror { \\ call(); @@ -3972,6 +4220,8 @@ test "zig fmt: error return" { } test "zig fmt: comptime block in container" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn container() type { \\ return struct { @@ -3987,6 +4237,8 @@ test "zig fmt: comptime block in container" { } test "zig fmt: inline asm parameter alignment" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn main() void { \\ asm volatile ( @@ -4025,6 +4277,8 @@ test "zig fmt: inline asm parameter alignment" { } test "zig fmt: multiline string in array" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const Foo = [][]const u8{ \\ \\aaa @@ -4050,6 +4304,8 @@ test "zig fmt: multiline string in array" { } test "zig fmt: if type expr" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const mycond = true; \\pub fn foo() if (mycond) i32 else void { @@ -4078,6 +4334,8 @@ test "zig fmt: comment after empty comment" { } test "zig fmt: line comment in array" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test "a" { \\ var arr = [_]u32{ @@ -4136,6 +4394,8 @@ test "zig fmt: comment after params" { } test "zig fmt: comment in array initializer/access" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "a" { \\ var a = x{ //aa @@ -4172,6 +4432,8 @@ test "zig fmt: comment in array initializer/access" { } test "zig fmt: comments at several places in struct init" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\var bar = Bar{ \\ .x = 10, // test @@ -4395,6 +4657,8 @@ test "zig fmt: integer literals with underscore separators" { } test "zig fmt: hex literals with underscore separators" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\pub fn orMask(a: [ 1_000 ]u64, b: [ 1_000] u64) [1_000]u64 { \\ var c: [1_000]u64 = [1]u64{ 0xFFFF_FFFF_FFFF_FFFF}**1_000; @@ -4418,6 +4682,8 @@ test "zig fmt: hex literals with underscore separators" { } test "zig fmt: decimal float literals with underscore separators" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\pub fn main() void { \\ const a:f64=(10.0e-0+(10.0e+0))+10_00.00_00e-2+20_00.00_10e+4; @@ -4435,6 +4701,8 @@ test "zig fmt: decimal float literals with underscore separators" { } test "zig fmt: hexadeciaml float literals with underscore separators" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\pub fn main() void { \\ const a: f64 = (0x10.0p-0+(0x10.0p+0))+0x10_00.00_00p-8+0x00_00.00_10p+16; @@ -4459,6 +4727,8 @@ test "zig fmt: C var args" { } test "zig fmt: Only indent multiline string literals in function calls" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test "zig fmt:" { \\ try testTransform( @@ -4476,6 +4746,8 @@ test "zig fmt: Only indent multiline string literals in function calls" { } test "zig fmt: Don't add extra newline after if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn atomicSymLink(allocator: Allocator, existing_path: []const u8, new_path: []const u8) !void { \\ if (cwd().symLink(existing_path, new_path, .{})) { @@ -4487,6 +4759,8 @@ test "zig fmt: Don't add extra newline after if" { } test "zig fmt: comments in ternary ifs" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const x = if (true) { \\ 1; @@ -4506,6 +4780,8 @@ test "zig fmt: comments in ternary ifs" { } test "zig fmt: while statement in blockless if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn main() void { \\ const zoom_node = if (focused_node == layout_first) @@ -4555,6 +4831,8 @@ test "zig fmt: test comments in field access chain" { } test "zig fmt: allow line break before field access" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ const w = foo.bar().zippy(zag).iguessthisisok(); @@ -4603,6 +4881,8 @@ test "zig fmt: allow line break before field access" { } test "zig fmt: Indent comma correctly after multiline string literals in arg list (trailing comma)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ z.display_message_dialog( @@ -4628,6 +4908,8 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis } test "zig fmt: Control flow statement as body of blockless if" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn main() void { \\ const zoom_node = if (focused_node == layout_first) @@ -4663,6 +4945,8 @@ test "zig fmt: Control flow statement as body of blockless if" { } test "zig fmt: regression test for #5722" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn sendViewTags(self: Self) void { \\ var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32)); @@ -4685,6 +4969,8 @@ test "zig fmt: regression test for #8974" { } test "zig fmt: allow trailing line comments to do manual array formatting" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ self.code.appendSliceAssumeCapacity(&[_]u8{ @@ -4723,6 +5009,8 @@ test "zig fmt: allow trailing line comments to do manual array formatting" { } test "zig fmt: multiline string literals should play nice with array initializers" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn main() void { \\ var a = .{.{.{.{.{.{.{.{ @@ -4789,6 +5077,8 @@ test "zig fmt: multiline string literals should play nice with array initializer } test "zig fmt: use of comments and multiline string literals may force the parameters over multiple lines" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn makeMemUndefined(qzz: []u8) i1 { \\ cases.add( // fixed bug foo @@ -4829,6 +5119,8 @@ test "zig fmt: use of comments and multiline string literals may force the param } test "zig fmt: single argument trailing commas in @builtins()" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn foo(qzz: []u8) i1 { \\ @panic( @@ -4862,6 +5154,8 @@ test "zig fmt: trailing comma should force multiline 1 column" { } test "zig fmt: function params should align nicely" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\pub fn foo() void { \\ cases.addRuntimeSafety("slicing operator with sentinel", @@ -4918,6 +5212,8 @@ test "zig fmt: remove trailing whitespace after doc comment" { } test "zig fmt: for loop with ptr payload and index" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ for (self.entries.items, 0..) |*item, i| {} @@ -4930,6 +5226,8 @@ test "zig fmt: for loop with ptr payload and index" { } test "zig fmt: proper indent line comment after multi-line single expr while loop" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ while (a) : (b) @@ -4943,6 +5241,8 @@ test "zig fmt: proper indent line comment after multi-line single expr while loo } test "zig fmt: function with labeled block as return type" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() t: { \\ break :t bar; @@ -4965,6 +5265,8 @@ test "zig fmt: extern function with missing param name" { } test "zig fmt: line comment after multiline single expr if statement with multiline string" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ if (foo) @@ -4997,6 +5299,8 @@ test "zig fmt: line comment after multiline single expr if statement with multil } test "zig fmt: respect extra newline between fn and pub usingnamespace" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\fn foo() void { \\ bar(); @@ -5121,6 +5425,8 @@ test "zig fmt: insert trailing comma if comments in array init" { } test "zig fmt: make single-line if no trailing comma" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test "function call no trailing comma" { \\ foo( @@ -5300,6 +5606,8 @@ test "zig fmt: missing const/var before local variable" { } test "zig fmt: while continue expr" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\test { \\ while (i > 0) @@ -5319,6 +5627,8 @@ test "zig fmt: while continue expr" { } test "zig fmt: canonicalize symbols (simple)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const val_normal: Normal = .{}; \\const @"val_unesc_me": @"UnescMe" = .{}; @@ -5468,6 +5778,8 @@ test "zig fmt: canonicalize symbols (simple)" { // Contextually unescape when shadowing primitive types and values. test "zig fmt: canonicalize symbols (primitive types)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const @"anyopaque" = struct { \\ @"u8": @"type" = true, @@ -5577,6 +5889,8 @@ test "zig fmt: canonicalize symbols (primitive types)" { // Never unescape names spelled like keywords. test "zig fmt: canonicalize symbols (keywords)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const @"enum" = struct { \\ @"error": @"struct" = true, @@ -5604,6 +5918,8 @@ test "zig fmt: canonicalize symbols (keywords)" { } test "zig fmt: no space before newline before multiline string" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testCanonical( \\const S = struct { \\ text: []const u8, @@ -5634,6 +5950,8 @@ test "zig fmt: no space before newline before multiline string" { // Normalize \xNN and \u{NN} escapes and unicode inside @"" escapes. test "zig fmt: canonicalize symbols (character escapes)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\const @"\x46\x6f\x6f\x64" = struct { \\ @"\x62\x61\x72\x6E": @"\x43\x72\x61\x62" = false, @@ -5676,6 +5994,8 @@ test "zig fmt: canonicalize symbols (character escapes)" { } test "zig fmt: canonicalize symbols (asm)" { + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + try testTransform( \\test "asm" { \\ const @"null" = usize; diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 0752f1b8f1..58e89d3ecc 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -2293,7 +2293,11 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void { } } -fn getValue(self: *Self, value: MCValue, inst: ?Air.Inst.Index) void { +fn getValue(self: *Self, value: MCValue, inst: ?Air.Inst.Index) !void { + for (value.getRegs()) |reg| try self.register_manager.getReg(reg, inst); +} + +fn getValueIfFree(self: *Self, value: MCValue, inst: ?Air.Inst.Index) void { for (value.getRegs()) |reg| if (self.register_manager.isRegFree(reg)) self.register_manager.getRegAssumeFree(reg, inst); } @@ -2341,7 +2345,7 @@ fn finishAirResult(self: *Self, inst: Air.Inst.Index, result: MCValue) void { // In some cases, an operand may be reused as the result. // If that operand died and was a register, it was freed by // processDeath, so we have to "re-allocate" the register. - self.getValue(result, inst); + self.getValueIfFree(result, inst); } self.finishAirBookkeeping(); } @@ -11017,7 +11021,7 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void { if (std.debug.runtime_safety) assert(self.inst_tracking.getIndex(inst).? == inst_tracking_i); const tracking = &self.inst_tracking.values()[inst_tracking_i]; if (self.liveness.isUnused(inst)) try tracking.die(self, inst); - self.getValue(tracking.short, inst); + self.getValueIfFree(tracking.short, inst); self.finishAirBookkeeping(); } @@ -11131,7 +11135,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void { } const dst_mcv = if (first_br) try self.allocRegOrMem(br.block_inst, true) else dst: { - self.getValue(block_tracking.short, br.block_inst); + try self.getValue(block_tracking.short, br.block_inst); break :dst block_tracking.short; }; try self.genCopy(block_ty, dst_mcv, src_mcv); From 48526c0eb6c394b778cba11559a66daf8d5ec3c7 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Thu, 26 Oct 2023 05:30:41 -0400 Subject: [PATCH 4/8] test: enable `c-abi-tests` for the x86_64 backend Add testing for `x86_64_v2` and `x86_64_v3` with the x86_64 backend. --- test/behavior/maximum_minimum.zig | 2 +- test/c_abi/cfuncs.c | 10 +- test/c_abi/main.zig | 86 ++++++++++++++ test/tests.zig | 190 +++++++++++++++++++++++------- 4 files changed, 239 insertions(+), 49 deletions(-) diff --git a/test/behavior/maximum_minimum.zig b/test/behavior/maximum_minimum.zig index 3fabe1aa59..7d19f1dcdc 100644 --- a/test/behavior/maximum_minimum.zig +++ b/test/behavior/maximum_minimum.zig @@ -282,7 +282,7 @@ test "@min/@max notices bounds from vector types when element of comptime-known if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64 and - !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sse4_1)) return error.SkipZigTest; + !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest; var x: @Vector(2, u32) = .{ 1_000_000, 12345 }; const y: @Vector(2, u16) = .{ 10, undefined }; diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index 34aab7f934..010dae791e 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -73,6 +73,10 @@ static void assert_or_panic(bool ok) { #define ZIG_NO_RAW_F16 #endif +#ifdef ZIG_BACKEND_STAGE2_X86_64 +#define ZIG_NO_COMPLEX +#endif + #ifdef __i386__ #define ZIG_NO_RAW_F16 #endif @@ -274,7 +278,7 @@ void run_c_tests(void) { zig_u32(0xfffffffd); zig_u64(0xfffffffffffffffc); -#ifndef ZIG_NO_I128 +#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64 { struct u128 s = {0xfffffffffffffffc}; zig_struct_u128(s); @@ -288,7 +292,7 @@ void run_c_tests(void) { zig_i32(-3); zig_i64(-4); -#ifndef ZIG_NO_I128 +#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64 { struct i128 s = {-6}; zig_struct_i128(s); @@ -429,7 +433,7 @@ void run_c_tests(void) { } #endif -#if !defined __mips__ && !defined ZIG_PPC32 +#if !defined __mips__ && !defined ZIG_PPC32 && !defined ZIG_BACKEND_STAGE2_X86_64 { struct FloatRect r1 = {1, 21, 16, 4}; struct FloatRect r2 = {178, 189, 21, 15}; diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index 1aa306ab14..a92ccc8e2e 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -49,6 +49,8 @@ export fn zig_five_integers(a: i32, b: i32, c: i32, d: i32, e: i32) void { } test "C ABI integers" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + c_u8(0xff); c_u16(0xfffe); c_u32(0xfffffffd); @@ -185,6 +187,8 @@ const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.is !builtin.cpu.arch.isARM() and !builtin.cpu.arch.isPPC() and !builtin.cpu.arch.isRISCV(); test "C ABI complex float" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (!complex_abi_compatible) return error.SkipZigTest; if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465 @@ -197,6 +201,8 @@ test "C ABI complex float" { } test "C ABI complex float by component" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (!complex_abi_compatible) return error.SkipZigTest; const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; @@ -208,6 +214,8 @@ test "C ABI complex float by component" { } test "C ABI complex double" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (!complex_abi_compatible) return error.SkipZigTest; const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; @@ -219,6 +227,8 @@ test "C ABI complex double" { } test "C ABI complex double by component" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (!complex_abi_compatible) return error.SkipZigTest; const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; @@ -230,6 +240,8 @@ test "C ABI complex double by component" { } export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + expect(a.real == 1.25) catch @panic("test failure: zig_cmultf 1"); expect(a.imag == 2.6) catch @panic("test failure: zig_cmultf 2"); expect(b.real == 11.3) catch @panic("test failure: zig_cmultf 3"); @@ -239,6 +251,8 @@ export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat { } export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + expect(a.real == 1.25) catch @panic("test failure: zig_cmultd 1"); expect(a.imag == 2.6) catch @panic("test failure: zig_cmultd 2"); expect(b.real == 11.3) catch @panic("test failure: zig_cmultd 3"); @@ -248,6 +262,8 @@ export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble { } export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + expect(a_r == 1.25) catch @panic("test failure: zig_cmultf_comp 1"); expect(a_i == 2.6) catch @panic("test failure: zig_cmultf_comp 2"); expect(b_r == 11.3) catch @panic("test failure: zig_cmultf_comp 3"); @@ -257,6 +273,8 @@ export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat { } export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + expect(a_r == 1.25) catch @panic("test failure: zig_cmultd_comp 1"); expect(a_i == 2.6) catch @panic("test failure: zig_cmultd_comp 2"); expect(b_r == 11.3) catch @panic("test failure: zig_cmultd_comp 3"); @@ -334,6 +352,8 @@ extern fn c_med_struct_mixed(MedStructMixed) void; extern fn c_ret_med_struct_mixed() MedStructMixed; test "C ABI medium struct of ints and floats" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -402,6 +422,8 @@ extern fn c_med_struct_ints(MedStructInts) void; extern fn c_ret_med_struct_ints() MedStructInts; test "C ABI medium struct of ints" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -509,6 +531,8 @@ extern fn c_split_struct_mixed(SplitStructMixed) void; extern fn c_ret_split_struct_mixed() SplitStructMixed; test "C ABI split struct of ints and floats" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -590,6 +614,8 @@ const Vector5 = extern struct { extern fn c_big_struct_floats(Vector5) void; test "C ABI structs of floats as parameter" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; @@ -657,6 +683,8 @@ const FloatRect = extern struct { }; export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + expect(x.left == 1) catch @panic("test failure"); expect(x.right == 21) catch @panic("test failure"); expect(x.top == 16) catch @panic("test failure"); @@ -668,6 +696,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { } test "C ABI structs of floats as multiple parameters" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -724,6 +754,8 @@ export fn zig_ret_small_struct_ints() SmallStructInts { } export fn zig_ret_med_struct_ints() MedStructInts { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + return .{ .x = 1, .y = 2, @@ -732,6 +764,8 @@ export fn zig_ret_med_struct_ints() MedStructInts { } export fn zig_ret_med_struct_mixed() MedStructMixed { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + return .{ .a = 1234, .b = 100.0, @@ -740,6 +774,8 @@ export fn zig_ret_med_struct_mixed() MedStructMixed { } export fn zig_ret_split_struct_mixed() SplitStructMixed { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + return .{ .a = 1234, .b = 100, @@ -780,6 +816,8 @@ extern fn c_struct_with_array(StructWithArray) void; extern fn c_ret_struct_with_array() StructWithArray; test "Struct with array as padding." { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -851,6 +889,8 @@ extern fn c_medium_vec(MediumVec) void; extern fn c_ret_medium_vec() MediumVec; test "medium simd vector" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; c_medium_vec(.{ 1, 2, 3, 4 }); @@ -868,6 +908,8 @@ extern fn c_big_vec(BigVec) void; extern fn c_ret_big_vec() BigVec; test "big simd vector" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; if (builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest; @@ -891,6 +933,8 @@ extern fn c_ptr_size_float_struct(Vector2) void; extern fn c_ret_ptr_size_float_struct() Vector2; test "C ABI pointer sized float struct" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; @@ -914,6 +958,8 @@ pub inline fn expectOk(c_err: c_int) !void { /// Tests for Double + Char struct const DC = extern struct { v1: f64, v2: u8 }; test "DC: Zig passes to C" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -921,6 +967,8 @@ test "DC: Zig passes to C" { try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 })); } test "DC: Zig returns to C" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; @@ -929,6 +977,8 @@ test "DC: Zig returns to C" { try expectOk(c_assert_ret_DC()); } test "DC: C passes to Zig" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -936,6 +986,8 @@ test "DC: C passes to Zig" { try expectOk(c_send_DC()); } test "DC: C returns to Zig" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; @@ -949,6 +1001,8 @@ pub extern fn c_assert_ret_DC() c_int; pub extern fn c_send_DC() c_int; pub extern fn c_ret_DC() DC; pub export fn zig_assert_DC(lv: DC) c_int { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + var err: c_int = 0; if (lv.v1 != -0.25) err = 1; if (lv.v2 != 15) err = 2; @@ -956,6 +1010,8 @@ pub export fn zig_assert_DC(lv: DC) c_int { return err; } pub export fn zig_ret_DC() DC { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + return .{ .v1 = -0.25, .v2 = 15 }; } @@ -963,6 +1019,8 @@ pub export fn zig_ret_DC() DC { const CFF = extern struct { v1: u8, v2: f32, v3: f32 }; test "CFF: Zig passes to C" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -970,6 +1028,8 @@ test "CFF: Zig passes to C" { try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 })); } test "CFF: Zig returns to C" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -977,6 +1037,8 @@ test "CFF: Zig returns to C" { try expectOk(c_assert_ret_CFF()); } test "CFF: C passes to Zig" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest; @@ -987,6 +1049,8 @@ test "CFF: C passes to Zig" { try expectOk(c_send_CFF()); } test "CFF: C returns to Zig" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; @@ -1000,6 +1064,8 @@ pub extern fn c_assert_ret_CFF() c_int; pub extern fn c_send_CFF() c_int; pub extern fn c_ret_CFF() CFF; pub export fn zig_assert_CFF(lv: CFF) c_int { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + var err: c_int = 0; if (lv.v1 != 39) err = 1; if (lv.v2 != 0.875) err = 2; @@ -1008,6 +1074,8 @@ pub export fn zig_assert_CFF(lv: CFF) c_int { return err; } pub export fn zig_ret_CFF() CFF { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + return .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }; } @@ -1015,6 +1083,8 @@ pub export fn zig_ret_CFF() CFF { const PD = extern struct { v1: ?*anyopaque, v2: f64 }; test "PD: Zig passes to C" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -1022,6 +1092,8 @@ test "PD: Zig passes to C" { try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 })); } test "PD: Zig returns to C" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -1029,6 +1101,8 @@ test "PD: Zig returns to C" { try expectOk(c_assert_ret_PD()); } test "PD: C passes to Zig" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -1036,6 +1110,8 @@ test "PD: C passes to Zig" { try expectOk(c_send_PD()); } test "PD: C returns to Zig" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; @@ -1047,6 +1123,8 @@ pub extern fn c_assert_ret_PD() c_int; pub extern fn c_send_PD() c_int; pub extern fn c_ret_PD() PD; pub export fn zig_c_assert_PD(lv: PD) c_int { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + var err: c_int = 0; if (lv.v1 != null) err = 1; if (lv.v2 != 0.5) err = 2; @@ -1054,9 +1132,13 @@ pub export fn zig_c_assert_PD(lv: PD) c_int { return err; } pub export fn zig_ret_PD() PD { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + return .{ .v1 = null, .v2 = 0.5 }; } pub export fn zig_assert_PD(lv: PD) c_int { + if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); + var err: c_int = 0; if (lv.v1 != null) err = 1; if (lv.v2 != 0.5) err = 2; @@ -1146,6 +1228,8 @@ const f80_struct = extern struct { }; extern fn c_f80_struct(f80_struct) f80_struct; test "f80 struct" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (!has_f80) return error.SkipZigTest; if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; if (builtin.mode != .Debug) return error.SkipZigTest; @@ -1233,6 +1317,8 @@ test "Stdcall ABI big union" { extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef; test "explicit SysV calling convention" { + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; const res = c_explict_win64(.{ .val = 1, .arr = undefined }); diff --git a/test/tests.zig b/test/tests.zig index 050faa1ffa..7d6160084b 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -94,6 +94,26 @@ const test_targets = blk: { .use_llvm = false, .use_lld = false, }, + .{ + .target = .{ + .cpu_arch = .x86_64, + .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 }, + .os_tag = .linux, + .abi = .none, + }, + .use_llvm = false, + .use_lld = false, + }, + .{ + .target = .{ + .cpu_arch = .x86_64, + .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 }, + .os_tag = .linux, + .abi = .none, + }, + .use_llvm = false, + .use_lld = false, + }, // Doesn't support new liveness //.{ // .target = .{ @@ -470,62 +490,123 @@ const test_targets = blk: { }; }; -const c_abi_targets = [_]CrossTarget{ +const CAbiTarget = struct { + target: CrossTarget = .{}, + use_llvm: ?bool = null, + use_lld: ?bool = null, + c_defines: []const []const u8 = &.{}, +}; + +const c_abi_targets = [_]CAbiTarget{ .{}, .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .x86_64, + .os_tag = .linux, + .abi = .musl, + }, }, .{ - .cpu_arch = .x86, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .x86_64, + .os_tag = .linux, + .abi = .musl, + }, + .use_llvm = false, + .use_lld = false, + .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"}, }, .{ - .cpu_arch = .aarch64, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .x86_64, + .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 }, + .os_tag = .linux, + .abi = .musl, + }, + .use_llvm = false, + .use_lld = false, + .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"}, }, .{ - .cpu_arch = .arm, - .os_tag = .linux, - .abi = .musleabihf, + .target = .{ + .cpu_arch = .x86_64, + .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 }, + .os_tag = .linux, + .abi = .musl, + }, + .use_llvm = false, + .use_lld = false, + .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"}, }, .{ - .cpu_arch = .mips, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .x86, + .os_tag = .linux, + .abi = .musl, + }, }, .{ - .cpu_arch = .riscv64, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .aarch64, + .os_tag = .linux, + .abi = .musl, + }, }, .{ - .cpu_arch = .wasm32, - .os_tag = .wasi, - .abi = .musl, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .musleabihf, + }, }, .{ - .cpu_arch = .powerpc, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .mips, + .os_tag = .linux, + .abi = .musl, + }, }, .{ - .cpu_arch = .powerpc64le, - .os_tag = .linux, - .abi = .musl, + .target = .{ + .cpu_arch = .riscv64, + .os_tag = .linux, + .abi = .musl, + }, }, .{ - .cpu_arch = .x86, - .os_tag = .windows, - .abi = .gnu, + .target = .{ + .cpu_arch = .wasm32, + .os_tag = .wasi, + .abi = .musl, + }, }, .{ - .cpu_arch = .x86_64, - .os_tag = .windows, - .abi = .gnu, + .target = .{ + .cpu_arch = .powerpc, + .os_tag = .linux, + .abi = .musl, + }, + }, + .{ + .target = .{ + .cpu_arch = .powerpc64le, + .os_tag = .linux, + .abi = .musl, + }, + }, + .{ + .target = .{ + .cpu_arch = .x86, + .os_tag = .windows, + .abi = .gnu, + }, + }, + .{ + .target = .{ + .cpu_arch = .x86_64, + .os_tag = .windows, + .abi = .gnu, + }, }, }; @@ -1017,6 +1098,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { const libc_suffix = if (test_target.link_libc == true) "-libc" else ""; const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM"); + const model_txt = test_target.target.getCpuModel().name; // wasm32-wasi builds need more RAM, idk why const max_rss = if (test_target.target.getOs().tag == .wasi) @@ -1054,9 +1136,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { these_tests.stack_size = 2 * 1024 * 1024; } - const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}{s}", .{ + const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}", .{ options.name, triple_txt, + model_txt, @tagName(test_target.optimize_mode), libc_suffix, single_threaded_suffix, @@ -1144,33 +1227,50 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S if (optimize_mode != .Debug and skip_release) continue; for (c_abi_targets) |c_abi_target| { - if (skip_non_native and !c_abi_target.isNative()) continue; + if (skip_non_native and !c_abi_target.target.isNative()) continue; - if (c_abi_target.isWindows() and c_abi_target.getCpuArch() == .aarch64) { + if (c_abi_target.target.isWindows() and c_abi_target.target.getCpuArch() == .aarch64) { // https://github.com/ziglang/zig/issues/14908 continue; } - const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM"); + if (c_abi_target.use_llvm == false and optimize_mode == .ReleaseFast) { + // panic: unrecognized command line argument + continue; + } const test_step = b.addTest(.{ - .root_source_file = .{ .path = "test/c_abi/main.zig" }, - .optimize = optimize_mode, - .target = c_abi_target, - .name = b.fmt("test-c-abi-{s}-{s}", .{ - triple_prefix, @tagName(optimize_mode), + .name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}", .{ + c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"), + c_abi_target.target.getCpuModel().name, + @tagName(optimize_mode), + if (c_abi_target.use_llvm == true) + "-llvm" + else if (c_abi_target.target.ofmt == std.Target.ObjectFormat.c) + "-cbe" + else if (c_abi_target.use_llvm == false) + "-selfhosted" + else + "", + if (c_abi_target.use_lld == false) "-no-lld" else "", }), + .root_source_file = .{ .path = "test/c_abi/main.zig" }, + .target = c_abi_target.target, + .optimize = optimize_mode, + .link_libc = true, + .use_llvm = c_abi_target.use_llvm, + .use_lld = c_abi_target.use_lld, }); - if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) { + if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) { // TODO NativeTargetInfo insists on dynamically linking musl // for some reason? test_step.target_info.dynamic_linker.max_byte = null; } - test_step.linkLibC(); test_step.addCSourceFile(.{ .file = .{ .path = "test/c_abi/cfuncs.c" }, .flags = &.{"-std=c99"}, }); + for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null); // This test is intentionally trying to check if the external ABI is // done properly. LTO would be a hindrance to this. From 6ad22cd964741ec646eb551877591d719e0c41f5 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Thu, 26 Oct 2023 21:45:45 -0400 Subject: [PATCH 5/8] x86_64: add missing spills --- lib/std/compress/deflate/compressor.zig | 2 -- lib/std/compress/deflate/compressor_test.zig | 19 +--------- lib/std/compress/deflate/deflate_fast.zig | 2 -- .../compress/deflate/deflate_fast_test.zig | 5 --- .../compress/deflate/huffman_bit_writer.zig | 7 ---- lib/std/compress/zlib.zig | 2 -- lib/std/crypto/25519/ed25519.zig | 3 +- lib/std/crypto/chacha20.zig | 6 ---- lib/std/crypto/ecdsa.zig | 36 +++++++------------ lib/std/crypto/ff.zig | 29 ++++++++------- lib/std/crypto/pcurves/p384.zig | 6 ++-- lib/std/crypto/pcurves/secp256k1.zig | 6 ++-- lib/std/crypto/poly1305.zig | 2 -- lib/std/crypto/salsa20.zig | 2 -- lib/std/crypto/sha2.zig | 2 +- lib/std/treap.zig | 2 -- src/arch/x86_64/CodeGen.zig | 2 ++ 17 files changed, 36 insertions(+), 97 deletions(-) diff --git a/lib/std/compress/deflate/compressor.zig b/lib/std/compress/deflate/compressor.zig index c50fee8f6c..72de63f162 100644 --- a/lib/std/compress/deflate/compressor.zig +++ b/lib/std/compress/deflate/compressor.zig @@ -1069,8 +1069,6 @@ var deflate_tests = [_]DeflateTest{ }; test "deflate" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - for (deflate_tests) |dt| { var output = ArrayList(u8).init(testing.allocator); defer output.deinit(); diff --git a/lib/std/compress/deflate/compressor_test.zig b/lib/std/compress/deflate/compressor_test.zig index a363d170e6..39eabd9306 100644 --- a/lib/std/compress/deflate/compressor_test.zig +++ b/lib/std/compress/deflate/compressor_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const expect = std.testing.expect; const fifo = std.fifo; const io = std.io; @@ -154,8 +153,6 @@ fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void { } test "deflate/inflate" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var limits = [_]u32{0} ** 11; var test0 = [_]u8{}; @@ -180,8 +177,6 @@ test "deflate/inflate" { } test "very long sparse chunk" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // A SparseReader returns a stream consisting of 0s ending with 65,536 (1<<16) 1s. // This tests missing hash references in a very large input. const SparseReader = struct { @@ -243,7 +238,7 @@ test "very long sparse chunk" { } test "compressor reset" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; for (std.enums.values(deflate.Compression)) |c| { try testWriterReset(c, null); @@ -295,8 +290,6 @@ fn testWriterReset(level: deflate.Compression, dict: ?[]const u8) !void { } test "decompressor dictionary" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const dict = "hello world"; // dictionary const text = "hello again world"; @@ -337,8 +330,6 @@ test "decompressor dictionary" { } test "compressor dictionary" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const dict = "hello world"; const text = "hello again world"; @@ -385,8 +376,6 @@ test "compressor dictionary" { // Update the hash for best_speed only if d.index < d.maxInsertIndex // See https://golang.org/issue/2508 test "Go non-regression test for 2508" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var comp = try compressor( testing.allocator, io.null_writer, @@ -404,8 +393,6 @@ test "Go non-regression test for 2508" { } test "deflate/inflate string" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const StringTest = struct { filename: []const u8, limit: [11]u32, @@ -453,8 +440,6 @@ test "deflate/inflate string" { } test "inflate reset" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const strings = [_][]const u8{ "lorem ipsum izzle fo rizzle", "the quick brown fox jumped over", @@ -501,8 +486,6 @@ test "inflate reset" { } test "inflate reset dictionary" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const dict = "the lorem fox"; const strings = [_][]const u8{ "lorem ipsum izzle fo rizzle", diff --git a/lib/std/compress/deflate/deflate_fast.zig b/lib/std/compress/deflate/deflate_fast.zig index 74982ee2b1..a11548fa1f 100644 --- a/lib/std/compress/deflate/deflate_fast.zig +++ b/lib/std/compress/deflate/deflate_fast.zig @@ -649,8 +649,6 @@ test "best speed shift offsets" { } test "best speed reset" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - // test that encoding is consistent across a warparound of the table offset. // See https://github.com/golang/go/issues/34121 const fmt = std.fmt; diff --git a/lib/std/compress/deflate/deflate_fast_test.zig b/lib/std/compress/deflate/deflate_fast_test.zig index b592bd07a7..08f6079aa5 100644 --- a/lib/std/compress/deflate/deflate_fast_test.zig +++ b/lib/std/compress/deflate/deflate_fast_test.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const expect = std.testing.expect; const io = std.io; const mem = std.mem; @@ -12,8 +11,6 @@ const inflate = @import("decompressor.zig"); const deflate_const = @import("deflate_const.zig"); test "best speed" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // Tests that round-tripping through deflate and then inflate recovers the original input. // The Write sizes are near the thresholds in the compressor.encSpeed method (0, 16, 128), as well // as near `deflate_const.max_store_block_size` (65535). @@ -96,8 +93,6 @@ test "best speed" { } test "best speed max match offset" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const abc = "abcdefgh"; const xyz = "stuvwxyz"; const input_margin = 16 - 1; diff --git a/lib/std/compress/deflate/huffman_bit_writer.zig b/lib/std/compress/deflate/huffman_bit_writer.zig index f2ee8fd338..18813b0b28 100644 --- a/lib/std/compress/deflate/huffman_bit_writer.zig +++ b/lib/std/compress/deflate/huffman_bit_writer.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const io = std.io; const Allocator = std.mem.Allocator; @@ -845,8 +844,6 @@ const testing = std.testing; const ArrayList = std.ArrayList; test "writeBlockHuff" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // Tests huffman encoding against reference files to detect possible regressions. // If encoding/bit allocation changes you can regenerate these files @@ -1571,8 +1568,6 @@ const TestType = enum { }; test "writeBlock" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // tests if the writeBlock encoding has changed. const ttype: TestType = .write_block; @@ -1588,8 +1583,6 @@ test "writeBlock" { } test "writeBlockDynamic" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // tests if the writeBlockDynamic encoding has changed. const ttype: TestType = .write_dyn_block; diff --git a/lib/std/compress/zlib.zig b/lib/std/compress/zlib.zig index 2e2edce434..5580192537 100644 --- a/lib/std/compress/zlib.zig +++ b/lib/std/compress/zlib.zig @@ -264,8 +264,6 @@ test "sanity checks" { } test "compress data" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - const allocator = testing.allocator; const rfc1951_txt = @embedFile("testdata/rfc1951.txt"); diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index 8836082ae8..9d3115a540 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -685,7 +685,8 @@ test "ed25519 signatures with streaming" { } test "ed25519 key pair from secret key" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64 and + !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest; const kp = try Ed25519.KeyPair.create(null); const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key); diff --git a/lib/std/crypto/chacha20.zig b/lib/std/crypto/chacha20.zig index dc7e989f92..26743232cb 100644 --- a/lib/std/crypto/chacha20.zig +++ b/lib/std/crypto/chacha20.zig @@ -1029,8 +1029,6 @@ test "crypto.chacha20 test vector 5" { } test "seal" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - { const m = ""; const ad = ""; @@ -1081,8 +1079,6 @@ test "seal" { } test "open" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - { const c = [_]u8{ 0xa0, 0x78, 0x4d, 0x7a, 0x47, 0x16, 0xf3, 0xfe, 0xb4, 0xf6, 0x4e, 0x7f, 0x4b, 0x39, 0xbf, 0x4 }; const ad = ""; @@ -1147,8 +1143,6 @@ test "open" { } test "crypto.xchacha20" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{69} ** 32; const nonce = [_]u8{42} ** 24; const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it."; diff --git a/lib/std/crypto/ecdsa.zig b/lib/std/crypto/ecdsa.zig index acb054d8cd..8da7100f8f 100644 --- a/lib/std/crypto/ecdsa.zig +++ b/lib/std/crypto/ecdsa.zig @@ -372,10 +372,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { } test "ECDSA - Basic operations over EcdsaP384Sha384" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const Scheme = EcdsaP384Sha384; const kp = try Scheme.KeyPair.create(null); @@ -391,10 +389,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" { } test "ECDSA - Basic operations over Secp256k1" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const Scheme = EcdsaSecp256k1Sha256oSha256; const kp = try Scheme.KeyPair.create(null); @@ -410,10 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" { } test "ECDSA - Basic operations over EcdsaP384Sha256" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); const kp = try Scheme.KeyPair.create(null); @@ -429,10 +423,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" { } test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); // zig fmt: off @@ -476,10 +468,8 @@ const TestVector = struct { }; test "ECDSA - Test vectors from Project Wycheproof" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const vectors = [_]TestVector{ .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid }, @@ -893,10 +883,8 @@ fn tvTry(vector: TestVector) !void { } test "ECDSA - Sec1 encoding/decoding" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const Scheme = EcdsaP384Sha384; const kp = try Scheme.KeyPair.create(null); diff --git a/lib/std/crypto/ff.zig b/lib/std/crypto/ff.zig index 037feae5ed..e00a3741da 100644 --- a/lib/std/crypto/ff.zig +++ b/lib/std/crypto/ff.zig @@ -6,7 +6,7 @@ //! Parts of that code was ported from the BSD-licensed crypto/internal/bigmod/nat.go file in the Go language, itself inspired from BearSSL. const std = @import("std"); -const builtin = std.builtin; +const builtin = @import("builtin"); const crypto = std.crypto; const math = std.math; const mem = std.mem; @@ -14,6 +14,7 @@ const meta = std.meta; const testing = std.testing; const BoundedArray = std.BoundedArray; const assert = std.debug.assert; +const Endian = std.builtin.Endian; // A Limb is a single digit in a big integer. const Limb = usize; @@ -27,7 +28,7 @@ const t_bits: usize = @bitSizeOf(Limb) - carry_bits; // A TLimb is a Limb that is truncated to t_bits. const TLimb = meta.Int(.unsigned, t_bits); -const native_endian = @import("builtin").target.cpu.arch.endian(); +const native_endian = builtin.target.cpu.arch.endian(); // A WideLimb is a Limb that is twice as wide as a normal Limb. const WideLimb = struct { @@ -128,7 +129,7 @@ pub fn Uint(comptime max_bits: comptime_int) type { } /// Encodes a big integer into a byte array. - pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void { + pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void { if (bytes.len == 0) { if (self.isZero()) return; return error.Overflow; @@ -175,7 +176,7 @@ pub fn Uint(comptime max_bits: comptime_int) type { } /// Creates a new big integer from a byte array. - pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) OverflowError!Self { + pub fn fromBytes(bytes: []const u8, comptime endian: Endian) OverflowError!Self { if (bytes.len == 0) return Self.zero; var shift: usize = 0; var out = Self.zero; @@ -335,7 +336,7 @@ fn Fe_(comptime bits: comptime_int) type { } /// Creates a field element from a byte string. - pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: builtin.Endian) (OverflowError || FieldElementError)!Self { + pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: Endian) (OverflowError || FieldElementError)!Self { const v = try FeUint.fromBytes(bytes, endian); var fe = Self{ .v = v }; try m.shrink(&fe); @@ -344,7 +345,7 @@ fn Fe_(comptime bits: comptime_int) type { } /// Converts the field element to a byte string. - pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void { + pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void { return self.v.toBytes(bytes, endian); } @@ -458,13 +459,13 @@ pub fn Modulus(comptime max_bits: comptime_int) type { } /// Creates a new modulus from a byte string. - pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) (InvalidModulusError || OverflowError)!Self { + pub fn fromBytes(bytes: []const u8, comptime endian: Endian) (InvalidModulusError || OverflowError)!Self { const v = try FeUint.fromBytes(bytes, endian); return try Self.fromUint(v); } /// Serializes the modulus to a byte string. - pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void { + pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void { return self.v.toBytes(bytes, endian); } @@ -658,7 +659,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { // Returns x^e (mod m), with the exponent provided as a byte string. // `public` must be set to `false` if the exponent it secret. - fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: builtin.Endian, comptime public: bool) NullExponentError!Fe { + fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: Endian, comptime public: bool) NullExponentError!Fe { var acc: u8 = 0; for (e) |b| acc |= b; if (acc == 0) return error.NullExponent; @@ -801,7 +802,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { /// doesn't have to be created if a serialized representation is already available. /// /// If the exponent is public, `powWithEncodedPublicExponent()` can be used instead for a slight speedup. - pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe { + pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe { return self.powWithEncodedExponentInternal(x, e, endian, false); } @@ -810,7 +811,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { /// doesn't have to be created if a serialized representation is already available. /// /// If the exponent is secret, `powWithEncodedExponent` must be used instead. - pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe { + pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe { return self.powWithEncodedExponentInternal(x, e, endian, true); } }; @@ -912,10 +913,8 @@ const ct_unprotected = struct { }; test { - switch (@import("builtin").zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; const M = Modulus(256); const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233); diff --git a/lib/std/crypto/pcurves/p384.zig b/lib/std/crypto/pcurves/p384.zig index 44dd4e50b7..9fb84625fb 100644 --- a/lib/std/crypto/pcurves/p384.zig +++ b/lib/std/crypto/pcurves/p384.zig @@ -478,10 +478,8 @@ pub const AffineCoordinates = struct { }; test { - switch (@import("builtin").zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; _ = @import("tests/p384.zig"); } diff --git a/lib/std/crypto/pcurves/secp256k1.zig b/lib/std/crypto/pcurves/secp256k1.zig index 6286b96249..b871306ade 100644 --- a/lib/std/crypto/pcurves/secp256k1.zig +++ b/lib/std/crypto/pcurves/secp256k1.zig @@ -556,10 +556,8 @@ pub const AffineCoordinates = struct { }; test { - switch (@import("builtin").zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; + if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; _ = @import("tests/secp256k1.zig"); } diff --git a/lib/std/crypto/poly1305.zig b/lib/std/crypto/poly1305.zig index 7bdbabae49..5bcb75169d 100644 --- a/lib/std/crypto/poly1305.zig +++ b/lib/std/crypto/poly1305.zig @@ -196,8 +196,6 @@ pub const Poly1305 = struct { }; test "poly1305 rfc7439 vector1" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9"; const msg = "Cryptographic Forum Research Group"; diff --git a/lib/std/crypto/salsa20.zig b/lib/std/crypto/salsa20.zig index 3dbd626242..a2368fc3b6 100644 --- a/lib/std/crypto/salsa20.zig +++ b/lib/std/crypto/salsa20.zig @@ -623,8 +623,6 @@ test "xsalsa20poly1305 sealedbox" { } test "secretbox twoblocks" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{ 0xc9, 0xc9, 0x4d, 0xcf, 0x68, 0xbe, 0x00, 0xe4, 0x7f, 0xe6, 0x13, 0x26, 0xfc, 0xc4, 0x2f, 0xd0, 0xdb, 0x93, 0x91, 0x1c, 0x09, 0x94, 0x89, 0xe1, 0x1b, 0x88, 0x63, 0x18, 0x86, 0x64, 0x8b, 0x7b }; const nonce = [_]u8{ 0xa4, 0x33, 0xe9, 0x0a, 0x07, 0x68, 0x6e, 0x9a, 0x2b, 0x6d, 0xd4, 0x59, 0x04, 0x72, 0x3e, 0xd3, 0x8a, 0x67, 0x55, 0xc7, 0x9e, 0x3e, 0x77, 0xdc }; const msg = [_]u8{'a'} ** 97; diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig index bbb51cc3a3..f87ea90d92 100644 --- a/lib/std/crypto/sha2.zig +++ b/lib/std/crypto/sha2.zig @@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type { return; }, // C backend doesn't currently support passing vectors to inline asm. - .x86_64 => if (builtin.zig_backend != .stage2_c and builtin.zig_backend != .stage2_x86_64 and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) { + .x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) { var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] }; var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] }; const s_v = @as(*[16]v4u32, @ptrCast(&s)); diff --git a/lib/std/treap.zig b/lib/std/treap.zig index f25ba527fe..383dc1802a 100644 --- a/lib/std/treap.zig +++ b/lib/std/treap.zig @@ -350,8 +350,6 @@ const TestTreap = Treap(u64, std.math.order); const TestNode = TestTreap.Node; test "std.Treap: insert, find, replace, remove" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - var treap = TestTreap{}; var nodes: [10]TestNode = undefined; diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 58e89d3ecc..0e515bffb8 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -4740,6 +4740,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void { // TODO we could allocate register here, but need to expect addr register and potentially // offset register. + try self.spillEflagsIfOccupied(); const dst_mcv = try self.allocRegOrMem(inst, false); try self.genBinOpMir( .{ ._, .add }, @@ -14884,6 +14885,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void { .bits = @intCast(ty.bitSize(mod)), }; const max_reg_bit_width = Register.rax.bitSize(); + try self.spillEflagsIfOccupied(); switch (int_info.signedness) { .signed => { const shift: u6 = @intCast(max_reg_bit_width - int_info.bits); From 434a7db986d1ffd2d1e6b7d4bb69873ed05c7980 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 27 Oct 2023 01:39:06 -0400 Subject: [PATCH 6/8] x86_64: add missing spill --- lib/std/zig/parser_test.zig | 302 ------------------------------------ src/arch/x86_64/CodeGen.zig | 1 + 2 files changed, 1 insertion(+), 302 deletions(-) diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 2be1c4399b..86ea5fb4c2 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -26,8 +26,6 @@ test "zig fmt: tuple struct" { } test "zig fmt: preserves clobbers in inline asm with stray comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ asm volatile ("" @@ -46,8 +44,6 @@ test "zig fmt: preserves clobbers in inline asm with stray comma" { } test "zig fmt: remove trailing comma at the end of assembly clobber" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\fn foo() void { \\ asm volatile ("" @@ -70,8 +66,6 @@ test "zig fmt: remove trailing comma at the end of assembly clobber" { } test "zig fmt: respect line breaks in struct field value declaration" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const Foo = struct { \\ bar: u32 = @@ -226,8 +220,6 @@ test "zig fmt: file ends in comment after var decl" { } test "zig fmt: if statement" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ if (optional()) |some| @@ -326,8 +318,6 @@ test "zig fmt: decl between fields" { } test "zig fmt: errdefer with payload" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn main() anyerror!void { \\ errdefer |a| x += 1; @@ -341,8 +331,6 @@ test "zig fmt: errdefer with payload" { } test "zig fmt: nosuspend block" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn main() anyerror!void { \\ nosuspend { @@ -354,8 +342,6 @@ test "zig fmt: nosuspend block" { } test "zig fmt: nosuspend await" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ x = nosuspend await y; @@ -376,8 +362,6 @@ test "zig fmt: container declaration, single line" { } test "zig fmt: container declaration, one item, multi line trailing comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ comptime { @@ -391,8 +375,6 @@ test "zig fmt: container declaration, one item, multi line trailing comma" { } test "zig fmt: container declaration, no trailing comma on separate line" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test "" { \\ comptime { @@ -519,8 +501,6 @@ test "zig fmt: remove empty lines at start/end of container decl" { } test "zig fmt: remove empty lines at start/end of block" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test { \\ @@ -541,8 +521,6 @@ test "zig fmt: remove empty lines at start/end of block" { } test "zig fmt: allow empty line before comment at start of block" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ @@ -606,8 +584,6 @@ test "zig fmt: comptime struct field" { } test "zig fmt: break from block" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const a = blk: { \\ break :blk 42; @@ -640,8 +616,6 @@ test "zig fmt: c pointer type" { } test "zig fmt: builtin call with trailing comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn main() void { \\ @breakpoint(); @@ -657,8 +631,6 @@ test "zig fmt: builtin call with trailing comma" { } test "zig fmt: asm expression with comptime content" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ asm ("foo" ++ "bar"); @@ -683,8 +655,6 @@ test "zig fmt: asm expression with comptime content" { } test "zig fmt: array types last token" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = [40]u32; @@ -698,8 +668,6 @@ test "zig fmt: array types last token" { } test "zig fmt: sentinel-terminated array type" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn cStrToPrefixedFileW(s: [*:0]const u8) ![PATH_MAX_WIDE:0]u16 { \\ return sliceToPrefixedFileW(mem.toSliceConst(u8, s)); @@ -709,8 +677,6 @@ test "zig fmt: sentinel-terminated array type" { } test "zig fmt: sentinel-terminated slice type" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn toSlice(self: Buffer) [:0]u8 { \\ return self.list.toSlice()[0..self.len()]; @@ -802,8 +768,6 @@ test "zig fmt: alignment in anonymous literal" { } test "zig fmt: anon struct literal 0 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{}; @@ -813,8 +777,6 @@ test "zig fmt: anon struct literal 0 element" { } test "zig fmt: anon struct literal 1 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ .a = b }; @@ -824,8 +786,6 @@ test "zig fmt: anon struct literal 1 element" { } test "zig fmt: anon struct literal 1 element comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ @@ -837,8 +797,6 @@ test "zig fmt: anon struct literal 1 element comma" { } test "zig fmt: anon struct literal 2 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ .a = b, .c = d }; @@ -848,8 +806,6 @@ test "zig fmt: anon struct literal 2 element" { } test "zig fmt: anon struct literal 2 element comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ @@ -862,8 +818,6 @@ test "zig fmt: anon struct literal 2 element comma" { } test "zig fmt: anon struct literal 3 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ .a = b, .c = d, .e = f }; @@ -873,8 +827,6 @@ test "zig fmt: anon struct literal 3 element" { } test "zig fmt: anon struct literal 3 element comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ @@ -888,8 +840,6 @@ test "zig fmt: anon struct literal 3 element comma" { } test "zig fmt: struct literal 0 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{}; @@ -899,8 +849,6 @@ test "zig fmt: struct literal 0 element" { } test "zig fmt: struct literal 1 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{ .a = b }; @@ -910,8 +858,6 @@ test "zig fmt: struct literal 1 element" { } test "zig fmt: Unicode code point literal larger than u8" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{ @@ -923,8 +869,6 @@ test "zig fmt: Unicode code point literal larger than u8" { } test "zig fmt: struct literal 2 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{ .a = b, .c = d }; @@ -934,8 +878,6 @@ test "zig fmt: struct literal 2 element" { } test "zig fmt: struct literal 2 element comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{ @@ -948,8 +890,6 @@ test "zig fmt: struct literal 2 element comma" { } test "zig fmt: struct literal 3 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{ .a = b, .c = d, .e = f }; @@ -959,8 +899,6 @@ test "zig fmt: struct literal 3 element" { } test "zig fmt: struct literal 3 element comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = X{ @@ -974,8 +912,6 @@ test "zig fmt: struct literal 3 element comma" { } test "zig fmt: anon list literal 1 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{a}; @@ -996,8 +932,6 @@ test "zig fmt: anon list literal 1 element comma" { } test "zig fmt: anon list literal 2 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ a, b }; @@ -1019,8 +953,6 @@ test "zig fmt: anon list literal 2 element comma" { } test "zig fmt: anon list literal 3 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = .{ a, b, c }; @@ -1045,8 +977,6 @@ test "zig fmt: anon list literal 3 element comma" { } test "zig fmt: array literal 0 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = [_]u32{}; @@ -1056,8 +986,6 @@ test "zig fmt: array literal 0 element" { } test "zig fmt: array literal 1 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = [_]u32{a}; @@ -1078,8 +1006,6 @@ test "zig fmt: array literal 1 element comma" { } test "zig fmt: array literal 2 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = [_]u32{ a, b }; @@ -1101,8 +1027,6 @@ test "zig fmt: array literal 2 element comma" { } test "zig fmt: array literal 3 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = [_]u32{ a, b, c }; @@ -1125,8 +1049,6 @@ test "zig fmt: array literal 3 element comma" { } test "zig fmt: sentinel array literal 1 element" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const x = [_:9000]u32{a}; @@ -1156,8 +1078,6 @@ test "zig fmt: slices with spaces in bounds" { } test "zig fmt: block in slice expression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const a = b[{ \\ _ = x; @@ -1176,8 +1096,6 @@ test "zig fmt: block in slice expression" { } test "zig fmt: async function" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub const Server = struct { \\ handleRequestFn: fn (*Server, *const std.net.Address, File) callconv(.Async) void, @@ -1190,8 +1108,6 @@ test "zig fmt: async function" { } test "zig fmt: whitespace fixes" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform("test \"\" {\r\n\tconst hi = x;\r\n}\n// zig fmt: off\ntest \"\"{\r\n\tconst a = b;}\r\n", \\test "" { \\ const hi = x; @@ -1204,8 +1120,6 @@ test "zig fmt: whitespace fixes" { } test "zig fmt: while else err prong with no block" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ const result = while (returnError()) |value| { @@ -1235,8 +1149,6 @@ test "zig fmt: tagged union with enum values" { } test "zig fmt: tagged union enum tag last token" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const U = union(enum(u32)) {}; @@ -1572,8 +1484,6 @@ test "zig fmt: doc and line comment following 'zig fmt: on'" { } test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test "" { \\ const x = 42; @@ -1600,8 +1510,6 @@ test "zig fmt: 'zig fmt: (off|on)' works in the middle of code" { } test "zig fmt: 'zig fmt: on' indentation is unchanged" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn initOptionsAndLayouts(output: *Output, context: *Context) !void { \\ // zig fmt: off @@ -1644,8 +1552,6 @@ test "zig fmt: spaces around slice operator" { } test "zig fmt: async call in if condition" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ if (async b()) { @@ -1657,8 +1563,6 @@ test "zig fmt: async call in if condition" { } test "zig fmt: 2nd arg multiline string" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ cases.addAsm("hello world linux x86_64", @@ -1687,8 +1591,6 @@ test "zig fmt: 2nd arg multiline string" { } test "zig fmt: 2nd arg multiline string many args" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ cases.addAsm("hello world linux x86_64", @@ -1700,8 +1602,6 @@ test "zig fmt: 2nd arg multiline string many args" { } test "zig fmt: final arg multiline string" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ cases.addAsm("hello world linux x86_64", "Hello, world!\n", @@ -1713,8 +1613,6 @@ test "zig fmt: final arg multiline string" { } test "zig fmt: if condition wraps" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\comptime { \\ if (cond and @@ -1796,8 +1694,6 @@ test "zig fmt: if condition wraps" { } test "zig fmt: if condition has line break but must not wrap" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ if (self.user_input_options.put( @@ -1822,8 +1718,6 @@ test "zig fmt: if condition has line break but must not wrap" { } test "zig fmt: if condition has line break but must not wrap (no fn call comma)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ if (self.user_input_options.put(name, UserInputOption{ @@ -1845,8 +1739,6 @@ test "zig fmt: if condition has line break but must not wrap (no fn call comma)" } test "zig fmt: function call with multiline argument" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ self.user_input_options.put(name, UserInputOption{ @@ -1859,8 +1751,6 @@ test "zig fmt: function call with multiline argument" { } test "zig fmt: if-else with comment before else" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ // cexp(finite|nan +- i inf|nan) = nan + i nan @@ -1879,8 +1769,6 @@ test "zig fmt: if-else with comment before else" { } test "zig fmt: if nested" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn foo() void { \\ return if ((aInt & bInt) >= 0) @@ -1904,8 +1792,6 @@ test "zig fmt: if nested" { } test "zig fmt: respect line breaks in if-else" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ return if (cond) a else b; @@ -1925,8 +1811,6 @@ test "zig fmt: respect line breaks in if-else" { } test "zig fmt: respect line breaks after infix operators" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ self.crc = @@ -1990,8 +1874,6 @@ test "zig fmt: switch comment after prong" { } test "zig fmt: struct literal no trailing comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const a = foo{ .x = 1, .y = 2 }; \\const a = foo{ .x = 1, @@ -2010,8 +1892,6 @@ test "zig fmt: struct literal no trailing comma" { } test "zig fmt: struct literal containing a multiline expression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const a = A{ .x = if (f1()) 10 else 20 }; \\const a = A{ .x = if (f1()) 10 else 20, }; @@ -2201,8 +2081,6 @@ test "zig fmt: array literal vertical column alignment" { } test "zig fmt: multiline string with backslash at end of line" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ err( @@ -2234,8 +2112,6 @@ test "zig fmt: multiline string parameter in fn call with trailing comma" { } test "zig fmt: trailing comma on fn call" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ var module = try Module.create( @@ -2249,8 +2125,6 @@ test "zig fmt: trailing comma on fn call" { } test "zig fmt: multi line arguments without last comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\pub fn foo( \\ a: usize, @@ -2312,8 +2186,6 @@ test "zig fmt: extra newlines at the end" { } test "zig fmt: simple asm" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\comptime { \\ asm volatile ( @@ -2351,8 +2223,6 @@ test "zig fmt: simple asm" { } test "zig fmt: nested struct literal with one item" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const a = foo{ \\ .item = bar{ .a = b }, @@ -2439,8 +2309,6 @@ test "zig fmt: line comment after doc comment" { } test "zig fmt: bit field alignment" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ assert(@TypeOf(&blah.b) == *align(1:3:6) const u3); @@ -2472,8 +2340,6 @@ test "zig fmt: float literal with exponent" { } test "zig fmt: if-else end of comptime" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ if (a) { @@ -2487,8 +2353,6 @@ test "zig fmt: if-else end of comptime" { } test "zig fmt: nested blocks" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ { @@ -2504,8 +2368,6 @@ test "zig fmt: nested blocks" { } test "zig fmt: block with same line comment after end brace" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ { @@ -2517,8 +2379,6 @@ test "zig fmt: block with same line comment after end brace" { } test "zig fmt: statements with comment between" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ a = b; @@ -2530,8 +2390,6 @@ test "zig fmt: statements with comment between" { } test "zig fmt: statements with empty line between" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ a = b; @@ -2551,8 +2409,6 @@ test "zig fmt: ptr deref operator and unwrap optional operator" { } test "zig fmt: comment after if before another if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "aoeu" { \\ // comment @@ -2575,8 +2431,6 @@ test "zig fmt: comment after if before another if" { } test "zig fmt: line comment between if block and else keyword" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "aoeu" { \\ // cexp(finite|nan +- i inf|nan) = nan + i nan @@ -2598,8 +2452,6 @@ test "zig fmt: line comment between if block and else keyword" { } test "zig fmt: same line comments in expression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "aoeu" { \\ const x = ( // a @@ -2640,8 +2492,6 @@ test "zig fmt: add comma on last switch prong" { } test "zig fmt: same-line comment after a statement" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ a = b; @@ -2687,8 +2537,6 @@ test "zig fmt: same-line comment after switch prong" { } test "zig fmt: same-line comment after non-block if expression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\comptime { \\ if (sr > n_uword_bits - 1) // d > r @@ -2699,8 +2547,6 @@ test "zig fmt: same-line comment after non-block if expression" { } test "zig fmt: same-line comment on comptime expression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt @@ -2710,8 +2556,6 @@ test "zig fmt: same-line comment on comptime expression" { } test "zig fmt: switch with empty body" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ foo() catch |err| switch (err) {}; @@ -2721,8 +2565,6 @@ test "zig fmt: switch with empty body" { } test "zig fmt: line comments in struct initializer" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ return Self{ @@ -2745,8 +2587,6 @@ test "zig fmt: line comments in struct initializer" { } test "zig fmt: first line comment in struct initializer" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn acquire(self: *Self) HeldLock { \\ return HeldLock{ @@ -2815,8 +2655,6 @@ test "zig fmt: union(enum(u32)) with assigned enum values" { } test "zig fmt: resume from suspend block" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ suspend { @@ -2902,8 +2740,6 @@ test "zig fmt: comments before global variables" { } test "zig fmt: comments in statements" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "std" { \\ // statement comment @@ -2931,8 +2767,6 @@ test "zig fmt: comments before test decl" { } test "zig fmt: preserve spacing" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const std = @import("std"); \\ @@ -3001,8 +2835,6 @@ test "zig fmt: alignment" { } test "zig fmt: C main" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn main(argc: c_int, argv: **u8) c_int { \\ const a = b; @@ -3012,8 +2844,6 @@ test "zig fmt: C main" { } test "zig fmt: return" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo(argc: c_int, argv: **u8) c_int { \\ return 0; @@ -3076,8 +2906,6 @@ test "zig fmt: slice attributes" { } test "zig fmt: test declaration" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "test name" { \\ const a = 1; @@ -3088,8 +2916,6 @@ test "zig fmt: test declaration" { } test "zig fmt: infix operators" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ var i = undefined; @@ -3142,8 +2968,6 @@ test "zig fmt: infix operators" { } test "zig fmt: precedence" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "precedence" { \\ a!b(); @@ -3176,8 +3000,6 @@ test "zig fmt: precedence" { } test "zig fmt: prefix operators" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "prefix operators" { \\ try return --%~!&0; @@ -3187,8 +3009,6 @@ test "zig fmt: prefix operators" { } test "zig fmt: call expression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "test calls" { \\ a(); @@ -3208,8 +3028,6 @@ test "zig fmt: anytype type" { } test "zig fmt: functions" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\extern fn puts(s: *const u8) c_int; \\extern "c" fn puts(s: *const u8) c_int; @@ -3234,8 +3052,6 @@ test "zig fmt: functions" { } test "zig fmt: multiline string" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "" { \\ const s1 = @@ -3254,8 +3070,6 @@ test "zig fmt: multiline string" { } test "zig fmt: values" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "values" { \\ 1; @@ -3275,8 +3089,6 @@ test "zig fmt: values" { } test "zig fmt: indexing" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "test index" { \\ a[0]; @@ -3297,8 +3109,6 @@ test "zig fmt: indexing" { } test "zig fmt: struct declaration" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const S = struct { \\ const Self = @This(); @@ -3405,8 +3215,6 @@ test "zig fmt: union declaration" { } test "zig fmt: arrays" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "test array" { \\ const a: [2]u8 = [2]u8{ @@ -3425,8 +3233,6 @@ test "zig fmt: arrays" { } test "zig fmt: container initializers" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const a0 = []u8{}; \\const a1 = []u8{1}; @@ -3447,8 +3253,6 @@ test "zig fmt: container initializers" { } test "zig fmt: catch" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "catch" { \\ const a: anyerror!u8 = 0; @@ -3464,8 +3268,6 @@ test "zig fmt: catch" { } test "zig fmt: blocks" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "blocks" { \\ { @@ -3488,8 +3290,6 @@ test "zig fmt: blocks" { } test "zig fmt: switch" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "switch" { \\ switch (0) { @@ -3545,8 +3345,6 @@ test "zig fmt: switch" { } test "zig fmt: switch multiline string" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "switch multiline string" { \\ const x: u32 = 0; @@ -3578,8 +3376,6 @@ test "zig fmt: switch multiline string" { } test "zig fmt: while" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "while" { \\ while (10 < 1) unreachable; @@ -3655,8 +3451,6 @@ test "zig fmt: while" { } test "zig fmt: for" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "for" { \\ for (a) |v| { @@ -3758,8 +3552,6 @@ test "zig fmt: for" { } test "zig fmt: for if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ for (a) |x| if (x) f(x); @@ -3785,8 +3577,6 @@ test "zig fmt: for if" { } test "zig fmt: if for" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ if (a) for (x) |x| f(x); @@ -3812,8 +3602,6 @@ test "zig fmt: if for" { } test "zig fmt: while if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ while (a) if (x) f(x); @@ -3839,8 +3627,6 @@ test "zig fmt: while if" { } test "zig fmt: if while" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ if (a) while (x) : (cont) f(x); @@ -3866,8 +3652,6 @@ test "zig fmt: if while" { } test "zig fmt: while for" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ while (a) for (x) |x| f(x); @@ -3893,8 +3677,6 @@ test "zig fmt: while for" { } test "zig fmt: for while" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ for (a) |a| while (x) |x| f(x); @@ -3920,8 +3702,6 @@ test "zig fmt: for while" { } test "zig fmt: if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "if" { \\ if (10 < 0) { @@ -3971,8 +3751,6 @@ test "zig fmt: if" { } test "zig fmt: fix single statement if/for/while line breaks" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test { \\ if (cond) a @@ -4051,8 +3829,6 @@ test "zig fmt: anon struct/array literal in if" { } test "zig fmt: defer" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "defer" { \\ var i: usize = 0; @@ -4073,8 +3849,6 @@ test "zig fmt: defer" { } test "zig fmt: comptime" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn a() u8 { \\ return 5; @@ -4114,8 +3888,6 @@ test "zig fmt: comptime" { } test "zig fmt: fn type" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn a(i: u8) u8 { \\ return i + 1; @@ -4129,8 +3901,6 @@ test "zig fmt: fn type" { } test "zig fmt: inline asm" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn syscall1(number: usize, arg1: usize) usize { \\ return asm volatile ("syscall" @@ -4145,8 +3915,6 @@ test "zig fmt: inline asm" { } test "zig fmt: async functions" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn simpleAsyncFn() void { \\ const a = async a.b(); @@ -4175,8 +3943,6 @@ test "zig fmt: nosuspend" { } test "zig fmt: Block after if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ if (true) { @@ -4208,8 +3974,6 @@ test "zig fmt: string identifier" { } test "zig fmt: error return" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn err() anyerror { \\ call(); @@ -4220,8 +3984,6 @@ test "zig fmt: error return" { } test "zig fmt: comptime block in container" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn container() type { \\ return struct { @@ -4237,8 +3999,6 @@ test "zig fmt: comptime block in container" { } test "zig fmt: inline asm parameter alignment" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn main() void { \\ asm volatile ( @@ -4277,8 +4037,6 @@ test "zig fmt: inline asm parameter alignment" { } test "zig fmt: multiline string in array" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const Foo = [][]const u8{ \\ \\aaa @@ -4304,8 +4062,6 @@ test "zig fmt: multiline string in array" { } test "zig fmt: if type expr" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const mycond = true; \\pub fn foo() if (mycond) i32 else void { @@ -4334,8 +4090,6 @@ test "zig fmt: comment after empty comment" { } test "zig fmt: line comment in array" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test "a" { \\ var arr = [_]u32{ @@ -4394,8 +4148,6 @@ test "zig fmt: comment after params" { } test "zig fmt: comment in array initializer/access" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "a" { \\ var a = x{ //aa @@ -4432,8 +4184,6 @@ test "zig fmt: comment in array initializer/access" { } test "zig fmt: comments at several places in struct init" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\var bar = Bar{ \\ .x = 10, // test @@ -4657,8 +4407,6 @@ test "zig fmt: integer literals with underscore separators" { } test "zig fmt: hex literals with underscore separators" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\pub fn orMask(a: [ 1_000 ]u64, b: [ 1_000] u64) [1_000]u64 { \\ var c: [1_000]u64 = [1]u64{ 0xFFFF_FFFF_FFFF_FFFF}**1_000; @@ -4682,8 +4430,6 @@ test "zig fmt: hex literals with underscore separators" { } test "zig fmt: decimal float literals with underscore separators" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\pub fn main() void { \\ const a:f64=(10.0e-0+(10.0e+0))+10_00.00_00e-2+20_00.00_10e+4; @@ -4701,8 +4447,6 @@ test "zig fmt: decimal float literals with underscore separators" { } test "zig fmt: hexadeciaml float literals with underscore separators" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\pub fn main() void { \\ const a: f64 = (0x10.0p-0+(0x10.0p+0))+0x10_00.00_00p-8+0x00_00.00_10p+16; @@ -4727,8 +4471,6 @@ test "zig fmt: C var args" { } test "zig fmt: Only indent multiline string literals in function calls" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test "zig fmt:" { \\ try testTransform( @@ -4746,8 +4488,6 @@ test "zig fmt: Only indent multiline string literals in function calls" { } test "zig fmt: Don't add extra newline after if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn atomicSymLink(allocator: Allocator, existing_path: []const u8, new_path: []const u8) !void { \\ if (cwd().symLink(existing_path, new_path, .{})) { @@ -4759,8 +4499,6 @@ test "zig fmt: Don't add extra newline after if" { } test "zig fmt: comments in ternary ifs" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const x = if (true) { \\ 1; @@ -4780,8 +4518,6 @@ test "zig fmt: comments in ternary ifs" { } test "zig fmt: while statement in blockless if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn main() void { \\ const zoom_node = if (focused_node == layout_first) @@ -4831,8 +4567,6 @@ test "zig fmt: test comments in field access chain" { } test "zig fmt: allow line break before field access" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const w = foo.bar().zippy(zag).iguessthisisok(); @@ -4908,8 +4642,6 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis } test "zig fmt: Control flow statement as body of blockless if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn main() void { \\ const zoom_node = if (focused_node == layout_first) @@ -4945,8 +4677,6 @@ test "zig fmt: Control flow statement as body of blockless if" { } test "zig fmt: regression test for #5722" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn sendViewTags(self: Self) void { \\ var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32)); @@ -5077,8 +4807,6 @@ test "zig fmt: multiline string literals should play nice with array initializer } test "zig fmt: use of comments and multiline string literals may force the parameters over multiple lines" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn makeMemUndefined(qzz: []u8) i1 { \\ cases.add( // fixed bug foo @@ -5119,8 +4847,6 @@ test "zig fmt: use of comments and multiline string literals may force the param } test "zig fmt: single argument trailing commas in @builtins()" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn foo(qzz: []u8) i1 { \\ @panic( @@ -5154,8 +4880,6 @@ test "zig fmt: trailing comma should force multiline 1 column" { } test "zig fmt: function params should align nicely" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\pub fn foo() void { \\ cases.addRuntimeSafety("slicing operator with sentinel", @@ -5212,8 +4936,6 @@ test "zig fmt: remove trailing whitespace after doc comment" { } test "zig fmt: for loop with ptr payload and index" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ for (self.entries.items, 0..) |*item, i| {} @@ -5226,8 +4948,6 @@ test "zig fmt: for loop with ptr payload and index" { } test "zig fmt: proper indent line comment after multi-line single expr while loop" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ while (a) : (b) @@ -5241,8 +4961,6 @@ test "zig fmt: proper indent line comment after multi-line single expr while loo } test "zig fmt: function with labeled block as return type" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() t: { \\ break :t bar; @@ -5265,8 +4983,6 @@ test "zig fmt: extern function with missing param name" { } test "zig fmt: line comment after multiline single expr if statement with multiline string" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ if (foo) @@ -5299,8 +5015,6 @@ test "zig fmt: line comment after multiline single expr if statement with multil } test "zig fmt: respect extra newline between fn and pub usingnamespace" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ bar(); @@ -5425,8 +5139,6 @@ test "zig fmt: insert trailing comma if comments in array init" { } test "zig fmt: make single-line if no trailing comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test "function call no trailing comma" { \\ foo( @@ -5606,8 +5318,6 @@ test "zig fmt: missing const/var before local variable" { } test "zig fmt: while continue expr" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ while (i > 0) @@ -5627,8 +5337,6 @@ test "zig fmt: while continue expr" { } test "zig fmt: canonicalize symbols (simple)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const val_normal: Normal = .{}; \\const @"val_unesc_me": @"UnescMe" = .{}; @@ -5778,8 +5486,6 @@ test "zig fmt: canonicalize symbols (simple)" { // Contextually unescape when shadowing primitive types and values. test "zig fmt: canonicalize symbols (primitive types)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const @"anyopaque" = struct { \\ @"u8": @"type" = true, @@ -5889,8 +5595,6 @@ test "zig fmt: canonicalize symbols (primitive types)" { // Never unescape names spelled like keywords. test "zig fmt: canonicalize symbols (keywords)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const @"enum" = struct { \\ @"error": @"struct" = true, @@ -5918,8 +5622,6 @@ test "zig fmt: canonicalize symbols (keywords)" { } test "zig fmt: no space before newline before multiline string" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\const S = struct { \\ text: []const u8, @@ -5950,8 +5652,6 @@ test "zig fmt: no space before newline before multiline string" { // Normalize \xNN and \u{NN} escapes and unicode inside @"" escapes. test "zig fmt: canonicalize symbols (character escapes)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const @"\x46\x6f\x6f\x64" = struct { \\ @"\x62\x61\x72\x6E": @"\x43\x72\x61\x62" = false, @@ -5994,8 +5694,6 @@ test "zig fmt: canonicalize symbols (character escapes)" { } test "zig fmt: canonicalize symbols (asm)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\test "asm" { \\ const @"null" = usize; diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 0e515bffb8..5ad426b78d 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -9553,6 +9553,7 @@ fn genBinOpMir( fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void { const mod = self.bin_file.options.module.?; const abi_size: u32 = @intCast(dst_ty.abiSize(mod)); + try self.spillEflagsIfOccupied(); switch (dst_mcv) { .none, .unreach, From 42bca3e2ee3adcfcdb7282c6eaa60f93ad6625cd Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 27 Oct 2023 01:39:57 -0400 Subject: [PATCH 7/8] x86_64: fix `@memset` --- lib/std/zig/parser_test.zig | 14 -------------- src/arch/x86_64/CodeGen.zig | 1 + 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 86ea5fb4c2..f1c252b477 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -748,8 +748,6 @@ test "zig fmt: anon literal in array" { } test "zig fmt: alignment in anonymous literal" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const a = .{ \\ "U", "L", "F", @@ -1953,8 +1951,6 @@ test "zig fmt: struct literal containing a multiline expression" { } test "zig fmt: array literal with hint" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const a = []u8{ \\ 1, 2, // @@ -2032,8 +2028,6 @@ test "zig fmt: array literal with hint" { } test "zig fmt: array literal vertical column alignment" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\const a = []u8{ \\ 1000, 200, @@ -2266,8 +2260,6 @@ test "zig fmt: slice align" { } test "zig fmt: add trailing comma to array literal" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTransform( \\comptime { \\ return []u16{'m', 's', 'y', 's', '-' // hi @@ -3803,8 +3795,6 @@ test "zig fmt: fix single statement if/for/while line breaks" { } test "zig fmt: anon struct/array literal in if" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\test { \\ const a = if (cond) .{ @@ -4699,8 +4689,6 @@ test "zig fmt: regression test for #8974" { } test "zig fmt: allow trailing line comments to do manual array formatting" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ self.code.appendSliceAssumeCapacity(&[_]u8{ @@ -4739,8 +4727,6 @@ test "zig fmt: allow trailing line comments to do manual array formatting" { } test "zig fmt: multiline string literals should play nice with array initializers" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn main() void { \\ var a = .{.{.{.{.{.{.{.{ diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 5ad426b78d..8b65f17aea 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -13366,6 +13366,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void { defer self.register_manager.unlockReg(len_lock); try self.genSetReg(len_reg, Type.usize, len); + try self.asmRegisterRegister(.{ ._, .@"test" }, len_reg, len_reg); const skip_reloc = try self.asmJccReloc(.z, undefined); try self.store(slice_ptr_ty, ptr, src_val); From b0cf620fe3032d485b581c8ab6239f719ef2cada Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 27 Oct 2023 01:40:14 -0400 Subject: [PATCH 8/8] x86_64: fix `cond_br` --- lib/std/compress/deflate/compressor_test.zig | 2 - lib/std/compress/lzma/test.zig | 11 --- lib/std/compress/lzma/vec2d.zig | 2 - lib/std/compress/xz/test.zig | 2 - lib/std/crypto/25519/ed25519.zig | 3 - lib/std/math/big/int_test.zig | 84 +++----------------- lib/std/math/big/rational.zig | 8 -- lib/std/mem.zig | 2 - lib/std/simd.zig | 2 +- lib/std/zig/parser_test.zig | 4 - src/arch/x86_64/CodeGen.zig | 3 +- 11 files changed, 14 insertions(+), 109 deletions(-) diff --git a/lib/std/compress/deflate/compressor_test.zig b/lib/std/compress/deflate/compressor_test.zig index 39eabd9306..140284ea5e 100644 --- a/lib/std/compress/deflate/compressor_test.zig +++ b/lib/std/compress/deflate/compressor_test.zig @@ -238,8 +238,6 @@ test "very long sparse chunk" { } test "compressor reset" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - for (std.enums.values(deflate.Compression)) |c| { try testWriterReset(c, null); try testWriterReset(c, "dict"); diff --git a/lib/std/compress/lzma/test.zig b/lib/std/compress/lzma/test.zig index 67adeb31c1..bdfe2909d8 100644 --- a/lib/std/compress/lzma/test.zig +++ b/lib/std/compress/lzma/test.zig @@ -1,5 +1,4 @@ const std = @import("../../std.zig"); -const builtin = @import("builtin"); const lzma = @import("../lzma.zig"); fn testDecompress(compressed: []const u8) ![]u8 { @@ -33,8 +32,6 @@ test "LZMA: decompress empty world" { } test "LZMA: decompress hello world" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDecompressEqual( "Hello world\n", &[_]u8{ @@ -46,8 +43,6 @@ test "LZMA: decompress hello world" { } test "LZMA: decompress huge dict" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDecompressEqual( "Hello world\n", &[_]u8{ @@ -59,8 +54,6 @@ test "LZMA: decompress huge dict" { } test "LZMA: unknown size with end of payload marker" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDecompressEqual( "Hello\nWorld!\n", @embedFile("testdata/good-unknown_size-with_eopm.lzma"), @@ -68,8 +61,6 @@ test "LZMA: unknown size with end of payload marker" { } test "LZMA: known size without end of payload marker" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDecompressEqual( "Hello\nWorld!\n", @embedFile("testdata/good-known_size-without_eopm.lzma"), @@ -77,8 +68,6 @@ test "LZMA: known size without end of payload marker" { } test "LZMA: known size with end of payload marker" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDecompressEqual( "Hello\nWorld!\n", @embedFile("testdata/good-known_size-with_eopm.lzma"), diff --git a/lib/std/compress/lzma/vec2d.zig b/lib/std/compress/lzma/vec2d.zig index aa805ee521..1ea3d1e8d5 100644 --- a/lib/std/compress/lzma/vec2d.zig +++ b/lib/std/compress/lzma/vec2d.zig @@ -50,8 +50,6 @@ const expectEqualSlices = std.testing.expectEqualSlices; const expectError = std.testing.expectError; test "Vec2D.init" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - const allocator = testing.allocator; var vec2d = try Vec2D(i32).init(allocator, 1, .{ 2, 3 }); defer vec2d.deinit(allocator); diff --git a/lib/std/compress/xz/test.zig b/lib/std/compress/xz/test.zig index fd960bc071..08180e45c0 100644 --- a/lib/std/compress/xz/test.zig +++ b/lib/std/compress/xz/test.zig @@ -19,8 +19,6 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void { } test "compressed data" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testReader(@embedFile("testdata/good-0-empty.xz"), ""); inline for ([_][]const u8{ diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index 9d3115a540..faeab59a0b 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -685,9 +685,6 @@ test "ed25519 signatures with streaming" { } test "ed25519 key pair from secret key" { - if (builtin.zig_backend == .stage2_x86_64 and - !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest; - const kp = try Ed25519.KeyPair.create(null); const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key); try std.testing.expectEqualSlices(u8, &kp.secret_key.toBytes(), &kp2.secret_key.toBytes()); diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig index 66060d6b4b..98cb2c52c2 100644 --- a/lib/std/math/big/int_test.zig +++ b/lib/std/math/big/int_test.zig @@ -517,8 +517,6 @@ test "big.int add multi-single" { } test "big.int add multi-multi" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var op1: u128 = 0xefefefef7f7f7f7f; var op2: u128 = 0xfefefefe9f9f9f9f; var a = try Managed.initSet(testing.allocator, op1); @@ -633,8 +631,6 @@ test "big.int subWrap single-single, unsigned" { } test "big.int addWrap multi-multi, unsigned, limb aligned" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); defer a.deinit(); @@ -687,8 +683,6 @@ test "big.int subWrap single-single, signed" { } test "big.int addWrap multi-multi, signed, limb aligned" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb)); defer a.deinit(); @@ -739,8 +733,6 @@ test "big.int subSat single-single, unsigned" { } test "big.int addSat multi-multi, unsigned, limb aligned" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb)); defer a.deinit(); @@ -826,8 +818,6 @@ test "big.int sub single-single" { } test "big.int sub multi-single" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1); defer a.deinit(); var b = try Managed.initSet(testing.allocator, 1); @@ -841,8 +831,6 @@ test "big.int sub multi-single" { } test "big.int sub multi-multi" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var op1: u128 = 0xefefefefefefefefefefefef; var op2: u128 = 0xabababababababababababab; @@ -927,10 +915,8 @@ test "big.int mul multi-single" { } test "big.int mul multi-multi" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; var op1: u256 = 0x998888efefefefefefefef; var op2: u256 = 0x333000abababababababab; @@ -1053,10 +1039,8 @@ test "big.int mulWrap single-single signed" { } test "big.int mulWrap multi-multi unsigned" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; var op1: u256 = 0x998888efefefefefefefef; var op2: u256 = 0x333000abababababababab; @@ -1412,8 +1396,6 @@ test "big.int divTrunc #15535" { } test "big.int divFloor #10932" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.init(testing.allocator); defer a.deinit(); @@ -1438,8 +1420,6 @@ test "big.int divFloor #10932" { } test "big.int divFloor #11166" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.init(testing.allocator); defer a.deinit(); @@ -1467,8 +1447,6 @@ test "big.int divFloor #11166" { } test "big.int gcd #10932" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.init(testing.allocator); defer a.deinit(); @@ -1660,10 +1638,7 @@ test "big.int div floor positive close to zero" { } test "big.int div multi-multi with rem" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999); defer a.deinit(); @@ -1681,10 +1656,7 @@ test "big.int div multi-multi with rem" { } test "big.int div multi-multi no rem" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361); defer a.deinit(); @@ -1720,10 +1692,8 @@ test "big.int div multi-multi (2 branch)" { } test "big.int div multi-multi (3.1/3.3 branch)" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111); defer a.deinit(); @@ -1782,10 +1752,7 @@ test "big.int div multi-multi zero-limb trailing (with rem)" { } test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000); defer a.deinit(); @@ -1806,10 +1773,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li } test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000); defer a.deinit(); @@ -1832,8 +1796,6 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li } test "big.int div multi-multi fuzz case #1" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.init(testing.allocator); defer a.deinit(); var b = try Managed.init(testing.allocator); @@ -1930,8 +1892,6 @@ test "big.int truncate multi to multi unsigned" { } test "big.int truncate multi to multi signed" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 3 << @bitSizeOf(Limb)); defer a.deinit(); @@ -2047,8 +2007,6 @@ test "big.int shift-right multi" { } test "big.int shift-left single" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 0xffff); defer a.deinit(); try a.shiftLeft(&a, 16); @@ -2093,8 +2051,6 @@ test "big.int sat shift-left simple unsigned" { } test "big.int sat shift-left simple unsigned no sat" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 1); defer a.deinit(); try a.shiftLeftSat(&a, 16, .unsigned, 21); @@ -2565,10 +2521,8 @@ test "big.int gcd non-one large" { } test "big.int gcd large multi-limb result" { - switch (builtin.zig_backend) { - .stage2_c, .stage2_x86_64 => return error.SkipZigTest, - else => {}, - } + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678); defer a.deinit(); @@ -2675,8 +2629,6 @@ test "big.int pow" { } test "big.int sqrt" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var r = try Managed.init(testing.allocator); defer r.deinit(); var a = try Managed.init(testing.allocator); @@ -2707,8 +2659,6 @@ test "big.int sqrt" { } test "big.int regression test for 1 limb overflow with alias" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // Note these happen to be two consecutive Fibonacci sequence numbers, the // first two whose sum exceeds 2**64. var a = try Managed.initSet(testing.allocator, 7540113804746346429); @@ -2723,8 +2673,6 @@ test "big.int regression test for 1 limb overflow with alias" { } test "big.int regression test for realloc with alias" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // Note these happen to be two consecutive Fibonacci sequence numbers, the // second of which is the first such number to exceed 2**192. var a = try Managed.initSet(testing.allocator, 5611500259351924431073312796924978741056961814867751431689); @@ -2739,8 +2687,6 @@ test "big.int regression test for realloc with alias" { } test "big int popcount" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.init(testing.allocator); defer a.deinit(); @@ -3106,8 +3052,6 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte } test "big int byte swap" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff); defer a.deinit(); @@ -3152,8 +3096,6 @@ test "big int byte swap" { } test "big.int mul multi-multi alias r with a and b" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb)); defer a.deinit(); @@ -3170,8 +3112,6 @@ test "big.int mul multi-multi alias r with a and b" { } test "big.int sqr multi alias r with a" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb)); defer a.deinit(); diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 2558aff38f..5529a6ef26 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -543,8 +543,6 @@ test "big.rational set" { } test "big.rational setFloat" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); @@ -570,8 +568,6 @@ test "big.rational setFloat" { } test "big.rational setFloatString" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); @@ -583,8 +579,6 @@ test "big.rational setFloatString" { } test "big.rational toFloat" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); @@ -598,8 +592,6 @@ test "big.rational toFloat" { } test "big.rational set/to Float round-trip" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Rational.init(testing.allocator); defer a.deinit(); var prng = std.rand.DefaultPrng.init(0x5EED); diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 0abc76ee29..4e2d5a805f 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1025,8 +1025,6 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co } test "indexOfSentinel vector paths" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const Types = [_]type{ u8, u16, u32, u64 }; const allocator = std.testing.allocator; diff --git a/lib/std/simd.zig b/lib/std/simd.zig index 53df15aa18..72b71938cb 100644 --- a/lib/std/simd.zig +++ b/lib/std/simd.zig @@ -436,7 +436,7 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a } test "vector prefix scan" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (comptime builtin.cpu.arch.isMIPS()) { return error.SkipZigTest; diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index f1c252b477..203976ec1a 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -2086,8 +2086,6 @@ test "zig fmt: multiline string with backslash at end of line" { } test "zig fmt: multiline string parameter in fn call with trailing comma" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ try stdout.print( @@ -4605,8 +4603,6 @@ test "zig fmt: allow line break before field access" { } test "zig fmt: Indent comma correctly after multiline string literals in arg list (trailing comma)" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testCanonical( \\fn foo() void { \\ z.display_message_dialog( diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 8b65f17aea..c18aa94716 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -10627,8 +10627,6 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { const else_body = self.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len]; const liveness_cond_br = self.liveness.getCondBr(inst); - const reloc = try self.genCondBrMir(cond_ty, cond); - // If the condition dies here in this condbr instruction, process // that death now instead of later as this has an effect on // whether it needs to be spilled in the branches @@ -10638,6 +10636,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void { self.scope_generation += 1; const state = try self.saveState(); + const reloc = try self.genCondBrMir(cond_ty, cond); for (liveness_cond_br.then_deaths) |death| try self.processDeath(death); try self.genBody(then_body);