authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-27 08:29:24-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-10-27 08:29:24-04:00
log3b0dce8ebd252161bfca237953c00b2a40705b90
treef0df484b4b6cf67b28dedff0f9622ba319d425c4
parent8f48533691e93538846993f78f732272a03a600b
parentb0cf620fe3032d485b581c8ab6239f719ef2cada
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #17716 from jacobly0/x86_64

x86_64: pass more tests

46 files changed, 507 insertions(+), 403 deletions(-)

lib/std/Build/Step/Options.zig-2
......@@ -295,8 +295,6 @@ const Arg = struct {
295295test Options {
296296 if (builtin.os.tag == .wasi) return error.SkipZigTest;
297297
298 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
299
300298 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
301299 defer arena.deinit();
302300
lib/std/array_hash_map.zig-2
......@@ -2294,8 +2294,6 @@ test "popOrNull" {
22942294}
22952295
22962296test "reIndex" {
2297 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
2298
22992297 var map = ArrayHashMap(i32, i32, AutoContext(i32), true).init(std.testing.allocator);
23002298 defer map.deinit();
23012299
lib/std/compress/deflate/compressor.zig-2
......@@ -1069,8 +1069,6 @@ var deflate_tests = [_]DeflateTest{
10691069};
10701070
10711071test "deflate" {
1072 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
1073
10741072 for (deflate_tests) |dt| {
10751073 var output = ArrayList(u8).init(testing.allocator);
10761074 defer output.deinit();
lib/std/compress/deflate/compressor_test.zig-19
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const expect = std.testing.expect;
43const fifo = std.fifo;
54const io = std.io;
......@@ -154,8 +153,6 @@ fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void {
154153}
155154
156155test "deflate/inflate" {
157 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
158
159156 var limits = [_]u32{0} ** 11;
160157
161158 var test0 = [_]u8{};
......@@ -180,8 +177,6 @@ test "deflate/inflate" {
180177}
181178
182179test "very long sparse chunk" {
183 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
184
185180 // A SparseReader returns a stream consisting of 0s ending with 65,536 (1<<16) 1s.
186181 // This tests missing hash references in a very large input.
187182 const SparseReader = struct {
......@@ -243,8 +238,6 @@ test "very long sparse chunk" {
243238}
244239
245240test "compressor reset" {
246 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
247
248241 for (std.enums.values(deflate.Compression)) |c| {
249242 try testWriterReset(c, null);
250243 try testWriterReset(c, "dict");
......@@ -295,8 +288,6 @@ fn testWriterReset(level: deflate.Compression, dict: ?[]const u8) !void {
295288}
296289
297290test "decompressor dictionary" {
298 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
299
300291 const dict = "hello world"; // dictionary
301292 const text = "hello again world";
302293
......@@ -337,8 +328,6 @@ test "decompressor dictionary" {
337328}
338329
339330test "compressor dictionary" {
340 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
341
342331 const dict = "hello world";
343332 const text = "hello again world";
344333
......@@ -385,8 +374,6 @@ test "compressor dictionary" {
385374// Update the hash for best_speed only if d.index < d.maxInsertIndex
386375// See https://golang.org/issue/2508
387376test "Go non-regression test for 2508" {
388 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
389
390377 var comp = try compressor(
391378 testing.allocator,
392379 io.null_writer,
......@@ -404,8 +391,6 @@ test "Go non-regression test for 2508" {
404391}
405392
406393test "deflate/inflate string" {
407 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
408
409394 const StringTest = struct {
410395 filename: []const u8,
411396 limit: [11]u32,
......@@ -453,8 +438,6 @@ test "deflate/inflate string" {
453438}
454439
455440test "inflate reset" {
456 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
457
458441 const strings = [_][]const u8{
459442 "lorem ipsum izzle fo rizzle",
460443 "the quick brown fox jumped over",
......@@ -501,8 +484,6 @@ test "inflate reset" {
501484}
502485
503486test "inflate reset dictionary" {
504 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
505
506487 const dict = "the lorem fox";
507488 const strings = [_][]const u8{
508489 "lorem ipsum izzle fo rizzle",
lib/std/compress/deflate/deflate_fast.zig-2
......@@ -649,8 +649,6 @@ test "best speed shift offsets" {
649649}
650650
651651test "best speed reset" {
652 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
653
654652 // test that encoding is consistent across a warparound of the table offset.
655653 // See https://github.com/golang/go/issues/34121
656654 const fmt = std.fmt;
lib/std/compress/deflate/deflate_fast_test.zig-5
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const expect = std.testing.expect;
43const io = std.io;
54const mem = std.mem;
......@@ -12,8 +11,6 @@ const inflate = @import("decompressor.zig");
1211const deflate_const = @import("deflate_const.zig");
1312
1413test "best speed" {
15 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
16
1714 // Tests that round-tripping through deflate and then inflate recovers the original input.
1815 // The Write sizes are near the thresholds in the compressor.encSpeed method (0, 16, 128), as well
1916 // as near `deflate_const.max_store_block_size` (65535).
......@@ -96,8 +93,6 @@ test "best speed" {
9693}
9794
9895test "best speed max match offset" {
99 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
100
10196 const abc = "abcdefgh";
10297 const xyz = "stuvwxyz";
10398 const input_margin = 16 - 1;
lib/std/compress/deflate/huffman_bit_writer.zig-7
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const io = std.io;
43
54const Allocator = std.mem.Allocator;
......@@ -845,8 +844,6 @@ const testing = std.testing;
845844const ArrayList = std.ArrayList;
846845
847846test "writeBlockHuff" {
848 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
849
850847 // Tests huffman encoding against reference files to detect possible regressions.
851848 // If encoding/bit allocation changes you can regenerate these files
852849
......@@ -1571,8 +1568,6 @@ const TestType = enum {
15711568};
15721569
15731570test "writeBlock" {
1574 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1575
15761571 // tests if the writeBlock encoding has changed.
15771572
15781573 const ttype: TestType = .write_block;
......@@ -1588,8 +1583,6 @@ test "writeBlock" {
15881583}
15891584
15901585test "writeBlockDynamic" {
1591 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1592
15931586 // tests if the writeBlockDynamic encoding has changed.
15941587
15951588 const ttype: TestType = .write_dyn_block;
lib/std/compress/lzma/test.zig-11
......@@ -1,5 +1,4 @@
11const std = @import("../../std.zig");
2const builtin = @import("builtin");
32const lzma = @import("../lzma.zig");
43
54fn testDecompress(compressed: []const u8) ![]u8 {
......@@ -33,8 +32,6 @@ test "LZMA: decompress empty world" {
3332}
3433
3534test "LZMA: decompress hello world" {
36 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
37
3835 try testDecompressEqual(
3936 "Hello world\n",
4037 &[_]u8{
......@@ -46,8 +43,6 @@ test "LZMA: decompress hello world" {
4643}
4744
4845test "LZMA: decompress huge dict" {
49 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
50
5146 try testDecompressEqual(
5247 "Hello world\n",
5348 &[_]u8{
......@@ -59,8 +54,6 @@ test "LZMA: decompress huge dict" {
5954}
6055
6156test "LZMA: unknown size with end of payload marker" {
62 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
63
6457 try testDecompressEqual(
6558 "Hello\nWorld!\n",
6659 @embedFile("testdata/good-unknown_size-with_eopm.lzma"),
......@@ -68,8 +61,6 @@ test "LZMA: unknown size with end of payload marker" {
6861}
6962
7063test "LZMA: known size without end of payload marker" {
71 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
72
7364 try testDecompressEqual(
7465 "Hello\nWorld!\n",
7566 @embedFile("testdata/good-known_size-without_eopm.lzma"),
......@@ -77,8 +68,6 @@ test "LZMA: known size without end of payload marker" {
7768}
7869
7970test "LZMA: known size with end of payload marker" {
80 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
81
8271 try testDecompressEqual(
8372 "Hello\nWorld!\n",
8473 @embedFile("testdata/good-known_size-with_eopm.lzma"),
lib/std/compress/lzma/vec2d.zig-2
......@@ -50,8 +50,6 @@ const expectEqualSlices = std.testing.expectEqualSlices;
5050const expectError = std.testing.expectError;
5151
5252test "Vec2D.init" {
53 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
54
5553 const allocator = testing.allocator;
5654 var vec2d = try Vec2D(i32).init(allocator, 1, .{ 2, 3 });
5755 defer vec2d.deinit(allocator);
lib/std/compress/xz/test.zig-2
......@@ -19,8 +19,6 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void {
1919}
2020
2121test "compressed data" {
22 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
23
2422 try testReader(@embedFile("testdata/good-0-empty.xz"), "");
2523
2624 inline for ([_][]const u8{
lib/std/compress/zlib.zig-2
......@@ -264,8 +264,6 @@ test "sanity checks" {
264264}
265265
266266test "compress data" {
267 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
268
269267 const allocator = testing.allocator;
270268 const rfc1951_txt = @embedFile("testdata/rfc1951.txt");
271269
lib/std/crypto/25519/ed25519.zig-2
......@@ -685,8 +685,6 @@ test "ed25519 signatures with streaming" {
685685}
686686
687687test "ed25519 key pair from secret key" {
688 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
689
690688 const kp = try Ed25519.KeyPair.create(null);
691689 const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key);
692690 try std.testing.expectEqualSlices(u8, &kp.secret_key.toBytes(), &kp2.secret_key.toBytes());
lib/std/crypto/chacha20.zig-6
......@@ -1029,8 +1029,6 @@ test "crypto.chacha20 test vector 5" {
10291029}
10301030
10311031test "seal" {
1032 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1033
10341032 {
10351033 const m = "";
10361034 const ad = "";
......@@ -1081,8 +1079,6 @@ test "seal" {
10811079}
10821080
10831081test "open" {
1084 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1085
10861082 {
10871083 const c = [_]u8{ 0xa0, 0x78, 0x4d, 0x7a, 0x47, 0x16, 0xf3, 0xfe, 0xb4, 0xf6, 0x4e, 0x7f, 0x4b, 0x39, 0xbf, 0x4 };
10881084 const ad = "";
......@@ -1147,8 +1143,6 @@ test "open" {
11471143}
11481144
11491145test "crypto.xchacha20" {
1150 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1151
11521146 const key = [_]u8{69} ** 32;
11531147 const nonce = [_]u8{42} ** 24;
11541148 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.";
lib/std/crypto/ecdsa.zig+12-24
......@@ -372,10 +372,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
372372}
373373
374374test "ECDSA - Basic operations over EcdsaP384Sha384" {
375 switch (builtin.zig_backend) {
376 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
377 else => {},
378 }
375 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
376 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
379377
380378 const Scheme = EcdsaP384Sha384;
381379 const kp = try Scheme.KeyPair.create(null);
......@@ -391,10 +389,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {
391389}
392390
393391test "ECDSA - Basic operations over Secp256k1" {
394 switch (builtin.zig_backend) {
395 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
396 else => {},
397 }
392 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
393 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
398394
399395 const Scheme = EcdsaSecp256k1Sha256oSha256;
400396 const kp = try Scheme.KeyPair.create(null);
......@@ -410,10 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {
410406}
411407
412408test "ECDSA - Basic operations over EcdsaP384Sha256" {
413 switch (builtin.zig_backend) {
414 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
415 else => {},
416 }
409 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
410 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
417411
418412 const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
419413 const kp = try Scheme.KeyPair.create(null);
......@@ -429,10 +423,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
429423}
430424
431425test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
432 switch (builtin.zig_backend) {
433 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
434 else => {},
435 }
426 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
427 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
436428
437429 const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
438430 // zig fmt: off
......@@ -476,10 +468,8 @@ const TestVector = struct {
476468};
477469
478470test "ECDSA - Test vectors from Project Wycheproof" {
479 switch (builtin.zig_backend) {
480 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
481 else => {},
482 }
471 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
472 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
483473
484474 const vectors = [_]TestVector{
485475 .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
......@@ -893,10 +883,8 @@ fn tvTry(vector: TestVector) !void {
893883}
894884
895885test "ECDSA - Sec1 encoding/decoding" {
896 switch (builtin.zig_backend) {
897 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
898 else => {},
899 }
886 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
887 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
900888
901889 const Scheme = EcdsaP384Sha384;
902890 const kp = try Scheme.KeyPair.create(null);
lib/std/crypto/ff.zig+14-15
......@@ -6,7 +6,7 @@
66//! Parts of that code was ported from the BSD-licensed crypto/internal/bigmod/nat.go file in the Go language, itself inspired from BearSSL.
77
88const std = @import("std");
9const builtin = std.builtin;
9const builtin = @import("builtin");
1010const crypto = std.crypto;
1111const math = std.math;
1212const mem = std.mem;
......@@ -14,6 +14,7 @@ const meta = std.meta;
1414const testing = std.testing;
1515const BoundedArray = std.BoundedArray;
1616const assert = std.debug.assert;
17const Endian = std.builtin.Endian;
1718
1819// A Limb is a single digit in a big integer.
1920const Limb = usize;
......@@ -27,7 +28,7 @@ const t_bits: usize = @bitSizeOf(Limb) - carry_bits;
2728// A TLimb is a Limb that is truncated to t_bits.
2829const TLimb = meta.Int(.unsigned, t_bits);
2930
30const native_endian = @import("builtin").target.cpu.arch.endian();
31const native_endian = builtin.target.cpu.arch.endian();
3132
3233// A WideLimb is a Limb that is twice as wide as a normal Limb.
3334const WideLimb = struct {
......@@ -128,7 +129,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
128129 }
129130
130131 /// Encodes a big integer into a byte array.
131 pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
132 pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
132133 if (bytes.len == 0) {
133134 if (self.isZero()) return;
134135 return error.Overflow;
......@@ -175,7 +176,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
175176 }
176177
177178 /// Creates a new big integer from a byte array.
178 pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) OverflowError!Self {
179 pub fn fromBytes(bytes: []const u8, comptime endian: Endian) OverflowError!Self {
179180 if (bytes.len == 0) return Self.zero;
180181 var shift: usize = 0;
181182 var out = Self.zero;
......@@ -335,7 +336,7 @@ fn Fe_(comptime bits: comptime_int) type {
335336 }
336337
337338 /// Creates a field element from a byte string.
338 pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: builtin.Endian) (OverflowError || FieldElementError)!Self {
339 pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: Endian) (OverflowError || FieldElementError)!Self {
339340 const v = try FeUint.fromBytes(bytes, endian);
340341 var fe = Self{ .v = v };
341342 try m.shrink(&fe);
......@@ -344,7 +345,7 @@ fn Fe_(comptime bits: comptime_int) type {
344345 }
345346
346347 /// Converts the field element to a byte string.
347 pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
348 pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
348349 return self.v.toBytes(bytes, endian);
349350 }
350351
......@@ -458,13 +459,13 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
458459 }
459460
460461 /// Creates a new modulus from a byte string.
461 pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) (InvalidModulusError || OverflowError)!Self {
462 pub fn fromBytes(bytes: []const u8, comptime endian: Endian) (InvalidModulusError || OverflowError)!Self {
462463 const v = try FeUint.fromBytes(bytes, endian);
463464 return try Self.fromUint(v);
464465 }
465466
466467 /// Serializes the modulus to a byte string.
467 pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
468 pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
468469 return self.v.toBytes(bytes, endian);
469470 }
470471
......@@ -658,7 +659,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
658659
659660 // Returns x^e (mod m), with the exponent provided as a byte string.
660661 // `public` must be set to `false` if the exponent it secret.
661 fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: builtin.Endian, comptime public: bool) NullExponentError!Fe {
662 fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: Endian, comptime public: bool) NullExponentError!Fe {
662663 var acc: u8 = 0;
663664 for (e) |b| acc |= b;
664665 if (acc == 0) return error.NullExponent;
......@@ -801,7 +802,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
801802 /// doesn't have to be created if a serialized representation is already available.
802803 ///
803804 /// If the exponent is public, `powWithEncodedPublicExponent()` can be used instead for a slight speedup.
804 pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe {
805 pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe {
805806 return self.powWithEncodedExponentInternal(x, e, endian, false);
806807 }
807808
......@@ -810,7 +811,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
810811 /// doesn't have to be created if a serialized representation is already available.
811812 ///
812813 /// If the exponent is secret, `powWithEncodedExponent` must be used instead.
813 pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe {
814 pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe {
814815 return self.powWithEncodedExponentInternal(x, e, endian, true);
815816 }
816817 };
......@@ -912,10 +913,8 @@ const ct_unprotected = struct {
912913};
913914
914915test {
915 switch (@import("builtin").zig_backend) {
916 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
917 else => {},
918 }
916 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
917 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
919918
920919 const M = Modulus(256);
921920 const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233);
lib/std/crypto/pcurves/p384.zig+2-4
......@@ -478,10 +478,8 @@ pub const AffineCoordinates = struct {
478478};
479479
480480test {
481 switch (@import("builtin").zig_backend) {
482 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
483 else => {},
484 }
481 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
482 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
485483
486484 _ = @import("tests/p384.zig");
487485}
lib/std/crypto/pcurves/secp256k1.zig+2-4
......@@ -556,10 +556,8 @@ pub const AffineCoordinates = struct {
556556};
557557
558558test {
559 switch (@import("builtin").zig_backend) {
560 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
561 else => {},
562 }
559 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
560 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
563561
564562 _ = @import("tests/secp256k1.zig");
565563}
lib/std/crypto/poly1305.zig-2
......@@ -196,8 +196,6 @@ pub const Poly1305 = struct {
196196};
197197
198198test "poly1305 rfc7439 vector1" {
199 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
200
201199 const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9";
202200
203201 const msg = "Cryptographic Forum Research Group";
lib/std/crypto/salsa20.zig-2
......@@ -623,8 +623,6 @@ test "xsalsa20poly1305 sealedbox" {
623623}
624624
625625test "secretbox twoblocks" {
626 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
627
628626 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 };
629627 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 };
630628 const msg = [_]u8{'a'} ** 97;
lib/std/crypto/sha2.zig+1-1
......@@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
238238 return;
239239 },
240240 // C backend doesn't currently support passing vectors to inline asm.
241 .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 })) {
241 .x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
242242 var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
243243 var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
244244 const s_v = @as(*[16]v4u32, @ptrCast(&s));
lib/std/fs.zig+1-3
......@@ -3248,9 +3248,7 @@ test {
32483248 _ = &makeDirAbsolute;
32493249 _ = &makeDirAbsoluteZ;
32503250 _ = &copyFileAbsolute;
3251 if (builtin.zig_backend != .stage2_x86_64) {
3252 _ = &updateFileAbsolute;
3253 }
3251 _ = &updateFileAbsolute;
32543252 }
32553253 _ = &Dir.copyFile;
32563254 _ = @import("fs/test.zig");
lib/std/fs/test.zig-4
......@@ -1460,8 +1460,6 @@ test "walker without fully iterating" {
14601460test ". and .. in fs.Dir functions" {
14611461 if (builtin.os.tag == .wasi and builtin.link_libc) return error.SkipZigTest;
14621462
1463 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1464
14651463 if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64) {
14661464 // https://github.com/ziglang/zig/issues/17134
14671465 return error.SkipZigTest;
......@@ -1502,8 +1500,6 @@ test ". and .. in fs.Dir functions" {
15021500test ". and .. in absolute functions" {
15031501 if (builtin.os.tag == .wasi) return error.SkipZigTest;
15041502
1505 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1506
15071503 var tmp = tmpDir(.{});
15081504 defer tmp.cleanup();
15091505
lib/std/io/test.zig-2
......@@ -161,8 +161,6 @@ test "setEndPos" {
161161}
162162
163163test "updateTimes" {
164 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
165
166164 var tmp = tmpDir(.{});
167165 defer tmp.cleanup();
168166
lib/std/json/JSONTestSuite_test.zig-6
......@@ -764,8 +764,6 @@ test "y_number_simple_real.json" {
764764 try ok("[123.456789]");
765765}
766766test "y_object.json" {
767 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
768
769767 try ok("{\"asd\":\"sdf\", \"dfg\":\"fgh\"}");
770768}
771769test "y_object_basic.json" {
......@@ -787,13 +785,9 @@ test "y_object_escaped_null_in_key.json" {
787785 try ok("{\"foo\\u0000bar\": 42}");
788786}
789787test "y_object_extreme_numbers.json" {
790 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
791
792788 try ok("{ \"min\": -1.0e+28, \"max\": 1.0e+28 }");
793789}
794790test "y_object_long_strings.json" {
795 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
796
797791 try ok("{\"x\":[{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}], \"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}");
798792}
799793test "y_object_simple.json" {
lib/std/json/dynamic_test.zig-13
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const mem = std.mem;
43const testing = std.testing;
54const ArenaAllocator = std.heap.ArenaAllocator;
......@@ -19,8 +18,6 @@ const jsonReader = @import("scanner.zig").reader;
1918const JsonReader = @import("scanner.zig").Reader;
2019
2120test "json.parser.dynamic" {
22 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
23
2421 const s =
2522 \\{
2623 \\ "Image": {
......@@ -75,8 +72,6 @@ test "json.parser.dynamic" {
7572
7673const writeStream = @import("./stringify.zig").writeStream;
7774test "write json then parse it" {
78 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
79
8075 var out_buffer: [1000]u8 = undefined;
8176
8277 var fixed_buffer_stream = std.io.fixedBufferStream(&out_buffer);
......@@ -143,8 +138,6 @@ test "Value.array allocator should still be usable after parsing" {
143138}
144139
145140test "integer after float has proper type" {
146 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
147
148141 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
149142 defer arena_allocator.deinit();
150143 const parsed = try testParse(arena_allocator.allocator(),
......@@ -157,8 +150,6 @@ test "integer after float has proper type" {
157150}
158151
159152test "escaped characters" {
160 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
161
162153 var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
163154 defer arena_allocator.deinit();
164155 const input =
......@@ -238,8 +229,6 @@ test "Value.jsonStringify" {
238229}
239230
240231test "parseFromValue(std.json.Value,...)" {
241 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
242
243232 const str =
244233 \\{
245234 \\ "int": 32,
......@@ -328,8 +317,6 @@ test "ParseOptions.max_value_len" {
328317}
329318
330319test "many object keys" {
331 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
332
333320 const doc =
334321 \\{
335322 \\ "k1": "v1",
lib/std/json/hashmap_test.zig-13
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const testing = std.testing;
43
54const ArrayHashMap = @import("hashmap.zig").ArrayHashMap;
......@@ -19,8 +18,6 @@ const T = struct {
1918};
2019
2120test "parse json hashmap" {
22 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
23
2421 const doc =
2522 \\{
2623 \\ "abc": {"i": 0, "s": "d"},
......@@ -36,8 +33,6 @@ test "parse json hashmap" {
3633}
3734
3835test "parse json hashmap while streaming" {
39 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
40
4136 const doc =
4237 \\{
4338 \\ "abc": {"i": 0, "s": "d"},
......@@ -63,8 +58,6 @@ test "parse json hashmap while streaming" {
6358}
6459
6560test "parse json hashmap duplicate fields" {
66 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
67
6861 var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
6962 defer arena.deinit();
7063
......@@ -93,8 +86,6 @@ test "parse json hashmap duplicate fields" {
9386}
9487
9588test "stringify json hashmap" {
96 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
97
9889 var value = ArrayHashMap(T){};
9990 defer value.deinit(testing.allocator);
10091 {
......@@ -132,8 +123,6 @@ test "stringify json hashmap" {
132123}
133124
134125test "stringify json hashmap whitespace" {
135 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
136
137126 var value = ArrayHashMap(T){};
138127 defer value.deinit(testing.allocator);
139128 try value.map.put(testing.allocator, "abc", .{ .i = 0, .s = "d" });
......@@ -158,8 +147,6 @@ test "stringify json hashmap whitespace" {
158147}
159148
160149test "json parse from value hashmap" {
161 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
162
163150 const doc =
164151 \\{
165152 \\ "abc": {"i": 0, "s": "d"},
lib/std/json/static_test.zig+1-2
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const testing = std.testing;
43const ArenaAllocator = std.heap.ArenaAllocator;
54const Allocator = std.mem.Allocator;
......@@ -786,7 +785,7 @@ test "max_value_len" {
786785}
787786
788787test "parse into vector" {
789 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
788 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
790789
791790 const T = struct {
792791 vec_i32: @Vector(4, i32),
lib/std/json/stringify_test.zig-3
......@@ -1,5 +1,4 @@
11const std = @import("std");
2const builtin = @import("builtin");
32const mem = std.mem;
43const testing = std.testing;
54
......@@ -16,8 +15,6 @@ const writeStreamMaxDepth = @import("stringify.zig").writeStreamMaxDepth;
1615const writeStreamArbitraryDepth = @import("stringify.zig").writeStreamArbitraryDepth;
1716
1817test "json write stream" {
19 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
20
2118 var out_buf: [1024]u8 = undefined;
2219 var slice_stream = std.io.fixedBufferStream(&out_buf);
2320 const out = slice_stream.writer();
lib/std/json/test.zig-2
......@@ -34,8 +34,6 @@ fn testHighLevelDynamicParser(s: []const u8) !void {
3434
3535// Additional tests not part of test JSONTestSuite.
3636test "y_trailing_comma_after_empty" {
37 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
38
3937 try roundTrip(
4038 \\{"1":[],"2":{},"3":"4"}
4139 );
lib/std/math/big/int_test.zig+12-92
......@@ -517,8 +517,6 @@ test "big.int add multi-single" {
517517}
518518
519519test "big.int add multi-multi" {
520 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
521
522520 var op1: u128 = 0xefefefef7f7f7f7f;
523521 var op2: u128 = 0xfefefefe9f9f9f9f;
524522 var a = try Managed.initSet(testing.allocator, op1);
......@@ -633,8 +631,6 @@ test "big.int subWrap single-single, unsigned" {
633631}
634632
635633test "big.int addWrap multi-multi, unsigned, limb aligned" {
636 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
637
638634 var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb));
639635 defer a.deinit();
640636
......@@ -687,8 +683,6 @@ test "big.int subWrap single-single, signed" {
687683}
688684
689685test "big.int addWrap multi-multi, signed, limb aligned" {
690 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
691
692686 var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));
693687 defer a.deinit();
694688
......@@ -739,8 +733,6 @@ test "big.int subSat single-single, unsigned" {
739733}
740734
741735test "big.int addSat multi-multi, unsigned, limb aligned" {
742 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
743
744736 var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb));
745737 defer a.deinit();
746738
......@@ -826,8 +818,6 @@ test "big.int sub single-single" {
826818}
827819
828820test "big.int sub multi-single" {
829 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
830
831821 var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1);
832822 defer a.deinit();
833823 var b = try Managed.initSet(testing.allocator, 1);
......@@ -841,8 +831,6 @@ test "big.int sub multi-single" {
841831}
842832
843833test "big.int sub multi-multi" {
844 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
845
846834 var op1: u128 = 0xefefefefefefefefefefefef;
847835 var op2: u128 = 0xabababababababababababab;
848836
......@@ -927,10 +915,8 @@ test "big.int mul multi-single" {
927915}
928916
929917test "big.int mul multi-multi" {
930 switch (builtin.zig_backend) {
931 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
932 else => {},
933 }
918 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
919 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
934920
935921 var op1: u256 = 0x998888efefefefefefefef;
936922 var op2: u256 = 0x333000abababababababab;
......@@ -1053,10 +1039,8 @@ test "big.int mulWrap single-single signed" {
10531039}
10541040
10551041test "big.int mulWrap multi-multi unsigned" {
1056 switch (builtin.zig_backend) {
1057 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
1058 else => {},
1059 }
1042 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1043 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
10601044
10611045 var op1: u256 = 0x998888efefefefefefefef;
10621046 var op2: u256 = 0x333000abababababababab;
......@@ -1182,8 +1166,6 @@ test "big.int div single-single with rem" {
11821166}
11831167
11841168test "big.int div multi-single no rem" {
1185 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1186
11871169 var op1: u128 = 0xffffeeeeddddcccc;
11881170 var op2: u128 = 34;
11891171
......@@ -1203,8 +1185,6 @@ test "big.int div multi-single no rem" {
12031185}
12041186
12051187test "big.int div multi-single with rem" {
1206 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1207
12081188 var op1: u128 = 0xffffeeeeddddcccf;
12091189 var op2: u128 = 34;
12101190
......@@ -1224,8 +1204,6 @@ test "big.int div multi-single with rem" {
12241204}
12251205
12261206test "big.int div multi>2-single" {
1227 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1228
12291207 var op1: u128 = 0xfefefefefefefefefefefefefefefefe;
12301208 var op2: u128 = 0xefab8;
12311209
......@@ -1405,8 +1383,6 @@ test "big.int div trunc single-single -/-" {
14051383}
14061384
14071385test "big.int divTrunc #15535" {
1408 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1409
14101386 var one = try Managed.initSet(testing.allocator, 1);
14111387 defer one.deinit();
14121388 var x = try Managed.initSet(testing.allocator, std.math.pow(u128, 2, 64));
......@@ -1420,8 +1396,6 @@ test "big.int divTrunc #15535" {
14201396}
14211397
14221398test "big.int divFloor #10932" {
1423 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1424
14251399 var a = try Managed.init(testing.allocator);
14261400 defer a.deinit();
14271401
......@@ -1446,8 +1420,6 @@ test "big.int divFloor #10932" {
14461420}
14471421
14481422test "big.int divFloor #11166" {
1449 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1450
14511423 var a = try Managed.init(testing.allocator);
14521424 defer a.deinit();
14531425
......@@ -1475,8 +1447,6 @@ test "big.int divFloor #11166" {
14751447}
14761448
14771449test "big.int gcd #10932" {
1478 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1479
14801450 var a = try Managed.init(testing.allocator);
14811451 defer a.deinit();
14821452
......@@ -1668,10 +1638,7 @@ test "big.int div floor positive close to zero" {
16681638}
16691639
16701640test "big.int div multi-multi with rem" {
1671 switch (builtin.zig_backend) {
1672 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
1673 else => {},
1674 }
1641 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
16751642
16761643 var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999);
16771644 defer a.deinit();
......@@ -1689,10 +1656,7 @@ test "big.int div multi-multi with rem" {
16891656}
16901657
16911658test "big.int div multi-multi no rem" {
1692 switch (builtin.zig_backend) {
1693 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
1694 else => {},
1695 }
1659 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
16961660
16971661 var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361);
16981662 defer a.deinit();
......@@ -1728,10 +1692,8 @@ test "big.int div multi-multi (2 branch)" {
17281692}
17291693
17301694test "big.int div multi-multi (3.1/3.3 branch)" {
1731 switch (builtin.zig_backend) {
1732 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
1733 else => {},
1734 }
1695 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
1696 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
17351697
17361698 var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111);
17371699 defer a.deinit();
......@@ -1790,10 +1752,7 @@ test "big.int div multi-multi zero-limb trailing (with rem)" {
17901752}
17911753
17921754test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" {
1793 switch (builtin.zig_backend) {
1794 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
1795 else => {},
1796 }
1755 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
17971756
17981757 var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000);
17991758 defer a.deinit();
......@@ -1814,10 +1773,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li
18141773}
18151774
18161775test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" {
1817 switch (builtin.zig_backend) {
1818 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
1819 else => {},
1820 }
1776 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
18211777
18221778 var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000);
18231779 defer a.deinit();
......@@ -1840,8 +1796,6 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li
18401796}
18411797
18421798test "big.int div multi-multi fuzz case #1" {
1843 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1844
18451799 var a = try Managed.init(testing.allocator);
18461800 defer a.deinit();
18471801 var b = try Managed.init(testing.allocator);
......@@ -1938,8 +1892,6 @@ test "big.int truncate multi to multi unsigned" {
19381892}
19391893
19401894test "big.int truncate multi to multi signed" {
1941 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1942
19431895 var a = try Managed.initSet(testing.allocator, 3 << @bitSizeOf(Limb));
19441896 defer a.deinit();
19451897
......@@ -1949,8 +1901,6 @@ test "big.int truncate multi to multi signed" {
19491901}
19501902
19511903test "big.int truncate negative multi to single" {
1952 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1953
19541904 var a = try Managed.initSet(testing.allocator, -@as(SignedDoubleLimb, maxInt(Limb) + 1));
19551905 defer a.deinit();
19561906
......@@ -2057,8 +2007,6 @@ test "big.int shift-right multi" {
20572007}
20582008
20592009test "big.int shift-left single" {
2060 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2061
20622010 var a = try Managed.initSet(testing.allocator, 0xffff);
20632011 defer a.deinit();
20642012 try a.shiftLeft(&a, 16);
......@@ -2103,8 +2051,6 @@ test "big.int sat shift-left simple unsigned" {
21032051}
21042052
21052053test "big.int sat shift-left simple unsigned no sat" {
2106 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2107
21082054 var a = try Managed.initSet(testing.allocator, 1);
21092055 defer a.deinit();
21102056 try a.shiftLeftSat(&a, 16, .unsigned, 21);
......@@ -2362,8 +2308,6 @@ test "big.int bitwise xor simple" {
23622308}
23632309
23642310test "big.int bitwise xor multi-limb" {
2365 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2366
23672311 var x: DoubleLimb = maxInt(Limb) + 1;
23682312 var y: DoubleLimb = maxInt(Limb);
23692313 var a = try Managed.initSet(testing.allocator, x);
......@@ -2538,8 +2482,6 @@ test "big.int var args" {
25382482}
25392483
25402484test "big.int gcd non-one small" {
2541 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2542
25432485 var a = try Managed.initSet(testing.allocator, 17);
25442486 defer a.deinit();
25452487 var b = try Managed.initSet(testing.allocator, 97);
......@@ -2553,8 +2495,6 @@ test "big.int gcd non-one small" {
25532495}
25542496
25552497test "big.int gcd non-one medium" {
2556 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2557
25582498 var a = try Managed.initSet(testing.allocator, 4864);
25592499 defer a.deinit();
25602500 var b = try Managed.initSet(testing.allocator, 3458);
......@@ -2568,8 +2508,6 @@ test "big.int gcd non-one medium" {
25682508}
25692509
25702510test "big.int gcd non-one large" {
2571 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2572
25732511 var a = try Managed.initSet(testing.allocator, 0xffffffffffffffff);
25742512 defer a.deinit();
25752513 var b = try Managed.initSet(testing.allocator, 0xffffffffffffffff7777);
......@@ -2583,10 +2521,8 @@ test "big.int gcd non-one large" {
25832521}
25842522
25852523test "big.int gcd large multi-limb result" {
2586 switch (builtin.zig_backend) {
2587 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
2588 else => {},
2589 }
2524 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
2525 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
25902526
25912527 var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
25922528 defer a.deinit();
......@@ -2602,8 +2538,6 @@ test "big.int gcd large multi-limb result" {
26022538}
26032539
26042540test "big.int gcd one large" {
2605 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2606
26072541 var a = try Managed.initSet(testing.allocator, 1897056385327307);
26082542 defer a.deinit();
26092543 var b = try Managed.initSet(testing.allocator, 2251799813685248);
......@@ -2695,8 +2629,6 @@ test "big.int pow" {
26952629}
26962630
26972631test "big.int sqrt" {
2698 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2699
27002632 var r = try Managed.init(testing.allocator);
27012633 defer r.deinit();
27022634 var a = try Managed.init(testing.allocator);
......@@ -2727,8 +2659,6 @@ test "big.int sqrt" {
27272659}
27282660
27292661test "big.int regression test for 1 limb overflow with alias" {
2730 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2731
27322662 // Note these happen to be two consecutive Fibonacci sequence numbers, the
27332663 // first two whose sum exceeds 2**64.
27342664 var a = try Managed.initSet(testing.allocator, 7540113804746346429);
......@@ -2743,8 +2673,6 @@ test "big.int regression test for 1 limb overflow with alias" {
27432673}
27442674
27452675test "big.int regression test for realloc with alias" {
2746 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2747
27482676 // Note these happen to be two consecutive Fibonacci sequence numbers, the
27492677 // second of which is the first such number to exceed 2**192.
27502678 var a = try Managed.initSet(testing.allocator, 5611500259351924431073312796924978741056961814867751431689);
......@@ -2759,8 +2687,6 @@ test "big.int regression test for realloc with alias" {
27592687}
27602688
27612689test "big int popcount" {
2762 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2763
27642690 var a = try Managed.init(testing.allocator);
27652691 defer a.deinit();
27662692
......@@ -3126,8 +3052,6 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte
31263052}
31273053
31283054test "big int byte swap" {
3129 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
3130
31313055 var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff);
31323056 defer a.deinit();
31333057
......@@ -3172,8 +3096,6 @@ test "big int byte swap" {
31723096}
31733097
31743098test "big.int mul multi-multi alias r with a and b" {
3175 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
3176
31773099 var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb));
31783100 defer a.deinit();
31793101
......@@ -3190,8 +3112,6 @@ test "big.int mul multi-multi alias r with a and b" {
31903112}
31913113
31923114test "big.int sqr multi alias r with a" {
3193 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
3194
31953115 var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb));
31963116 defer a.deinit();
31973117
lib/std/math/big/rational.zig-28
......@@ -514,8 +514,6 @@ test "big.rational extractLowBits" {
514514}
515515
516516test "big.rational set" {
517 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
518
519517 var a = try Rational.init(testing.allocator);
520518 defer a.deinit();
521519
......@@ -545,8 +543,6 @@ test "big.rational set" {
545543}
546544
547545test "big.rational setFloat" {
548 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
549
550546 var a = try Rational.init(testing.allocator);
551547 defer a.deinit();
552548
......@@ -572,8 +568,6 @@ test "big.rational setFloat" {
572568}
573569
574570test "big.rational setFloatString" {
575 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
576
577571 var a = try Rational.init(testing.allocator);
578572 defer a.deinit();
579573
......@@ -585,8 +579,6 @@ test "big.rational setFloatString" {
585579}
586580
587581test "big.rational toFloat" {
588 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
589
590582 var a = try Rational.init(testing.allocator);
591583 defer a.deinit();
592584
......@@ -600,8 +592,6 @@ test "big.rational toFloat" {
600592}
601593
602594test "big.rational set/to Float round-trip" {
603 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
604
605595 var a = try Rational.init(testing.allocator);
606596 defer a.deinit();
607597 var prng = std.rand.DefaultPrng.init(0x5EED);
......@@ -615,8 +605,6 @@ test "big.rational set/to Float round-trip" {
615605}
616606
617607test "big.rational copy" {
618 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
619
620608 var a = try Rational.init(testing.allocator);
621609 defer a.deinit();
622610
......@@ -681,8 +669,6 @@ test "big.rational abs" {
681669}
682670
683671test "big.rational swap" {
684 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
685
686672 var a = try Rational.init(testing.allocator);
687673 defer a.deinit();
688674 var b = try Rational.init(testing.allocator);
......@@ -707,8 +693,6 @@ test "big.rational swap" {
707693}
708694
709695test "big.rational order" {
710 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
711
712696 var a = try Rational.init(testing.allocator);
713697 defer a.deinit();
714698 var b = try Rational.init(testing.allocator);
......@@ -724,8 +708,6 @@ test "big.rational order" {
724708}
725709
726710test "big.rational order/orderAbs with negative" {
727 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
728
729711 var a = try Rational.init(testing.allocator);
730712 defer a.deinit();
731713 var b = try Rational.init(testing.allocator);
......@@ -738,8 +720,6 @@ test "big.rational order/orderAbs with negative" {
738720}
739721
740722test "big.rational add single-limb" {
741 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
742
743723 var a = try Rational.init(testing.allocator);
744724 defer a.deinit();
745725 var b = try Rational.init(testing.allocator);
......@@ -755,8 +735,6 @@ test "big.rational add single-limb" {
755735}
756736
757737test "big.rational add" {
758 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
759
760738 var a = try Rational.init(testing.allocator);
761739 defer a.deinit();
762740 var b = try Rational.init(testing.allocator);
......@@ -773,8 +751,6 @@ test "big.rational add" {
773751}
774752
775753test "big.rational sub" {
776 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
777
778754 var a = try Rational.init(testing.allocator);
779755 defer a.deinit();
780756 var b = try Rational.init(testing.allocator);
......@@ -791,8 +767,6 @@ test "big.rational sub" {
791767}
792768
793769test "big.rational mul" {
794 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
795
796770 var a = try Rational.init(testing.allocator);
797771 defer a.deinit();
798772 var b = try Rational.init(testing.allocator);
......@@ -809,8 +783,6 @@ test "big.rational mul" {
809783}
810784
811785test "big.rational div" {
812 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
813
814786 {
815787 var a = try Rational.init(testing.allocator);
816788 defer a.deinit();
lib/std/math/ilogb.zig+1-2
......@@ -6,7 +6,6 @@
66// https://git.musl-libc.org/cgit/musl/tree/src/math/ilogb.c
77
88const std = @import("../std.zig");
9const builtin = @import("builtin");
109const math = std.math;
1110const expect = std.testing.expect;
1211const maxInt = std.math.maxInt;
......@@ -109,7 +108,7 @@ test "64" {
109108}
110109
111110test "80" {
112 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
111 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
113112
114113 try expect(ilogbX(f80, 0.0) == fp_ilogb0);
115114 try expect(ilogbX(f80, 0.5) == -1);
lib/std/mem.zig+2-6
......@@ -1025,8 +1025,6 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
10251025}
10261026
10271027test "indexOfSentinel vector paths" {
1028 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1029
10301028 const Types = [_]type{ u8, u16, u32, u64 };
10311029 const allocator = std.testing.allocator;
10321030
......@@ -4661,10 +4659,8 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice
46614659}
46624660
46634661test "read/write(Var)PackedInt" {
4664 switch (builtin.zig_backend) {
4665 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
4666 else => {},
4667 }
4662 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
4663 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
46684664
46694665 switch (builtin.cpu.arch) {
46704666 // This test generates too much code to execute on WASI.
lib/std/net/test.zig-1
......@@ -107,7 +107,6 @@ test "parse and render UNIX addresses" {
107107}
108108
109109test "resolve DNS" {
110 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
111110 if (builtin.os.tag == .wasi) return error.SkipZigTest;
112111
113112 if (builtin.os.tag == .windows) {
lib/std/os/linux/io_uring.zig-4
......@@ -2212,8 +2212,6 @@ test "sendmsg/recvmsg" {
22122212test "timeout (after a relative time)" {
22132213 if (builtin.os.tag != .linux) return error.SkipZigTest;
22142214
2215 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2216
22172215 var ring = IO_Uring.init(1, 0) catch |err| switch (err) {
22182216 error.SystemOutdated => return error.SkipZigTest,
22192217 error.PermissionDenied => return error.SkipZigTest,
......@@ -2278,8 +2276,6 @@ test "timeout (after a number of completions)" {
22782276test "timeout_remove" {
22792277 if (builtin.os.tag != .linux) return error.SkipZigTest;
22802278
2281 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
2282
22832279 var ring = IO_Uring.init(2, 0) catch |err| switch (err) {
22842280 error.SystemOutdated => return error.SkipZigTest,
22852281 error.PermissionDenied => return error.SkipZigTest,
lib/std/rand/Xoshiro256.zig+2-4
......@@ -90,10 +90,8 @@ pub fn fill(self: *Xoshiro256, buf: []u8) void {
9090}
9191
9292test "xoroshiro sequence" {
93 switch (@import("builtin").zig_backend) {
94 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
95 else => {},
96 }
93 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
94 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
9795
9896 var r = Xoshiro256.init(0);
9997
lib/std/simd.zig+1-1
......@@ -436,7 +436,7 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a
436436}
437437
438438test "vector prefix scan" {
439 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
439 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
440440
441441 if (comptime builtin.cpu.arch.isMIPS()) {
442442 return error.SkipZigTest;
lib/std/time.zig-2
......@@ -122,8 +122,6 @@ pub fn nanoTimestamp() i128 {
122122}
123123
124124test "timestamp" {
125 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
126
127125 const margin = ns_per_ms * 50;
128126
129127 const time_0 = milliTimestamp();
lib/std/treap.zig-2
......@@ -350,8 +350,6 @@ const TestTreap = Treap(u64, std.math.order);
350350const TestNode = TestTreap.Node;
351351
352352test "std.Treap: insert, find, replace, remove" {
353 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
354
355353 var treap = TestTreap{};
356354 var nodes: [10]TestNode = undefined;
357355
lib/std/zig/Parse.zig-2
......@@ -4102,7 +4102,5 @@ const TokenIndex = Ast.TokenIndex;
41024102const Token = std.zig.Token;
41034103
41044104test {
4105 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
4106
41074105 _ = @import("parser_test.zig");
41084106}
src/arch/x86_64/CodeGen.zig+159-40
......@@ -2293,7 +2293,11 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
22932293 }
22942294}
22952295
2296fn getValue(self: *Self, value: MCValue, inst: ?Air.Inst.Index) void {
2296fn getValue(self: *Self, value: MCValue, inst: ?Air.Inst.Index) !void {
2297 for (value.getRegs()) |reg| try self.register_manager.getReg(reg, inst);
2298}
2299
2300fn getValueIfFree(self: *Self, value: MCValue, inst: ?Air.Inst.Index) void {
22972301 for (value.getRegs()) |reg| if (self.register_manager.isRegFree(reg))
22982302 self.register_manager.getRegAssumeFree(reg, inst);
22992303}
......@@ -2341,7 +2345,7 @@ fn finishAirResult(self: *Self, inst: Air.Inst.Index, result: MCValue) void {
23412345 // In some cases, an operand may be reused as the result.
23422346 // If that operand died and was a register, it was freed by
23432347 // processDeath, so we have to "re-allocate" the register.
2344 self.getValue(result, inst);
2348 self.getValueIfFree(result, inst);
23452349 }
23462350 self.finishAirBookkeeping();
23472351}
......@@ -3221,6 +3225,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
32213225 .Float, .Vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs),
32223226 else => {},
32233227 }
3228 const dst_abi_size: u32 = @intCast(dst_ty.abiSize(mod));
32243229
32253230 const dst_info = dst_ty.intInfo(mod);
32263231 const src_ty = try mod.intType(dst_info.signedness, switch (tag) {
......@@ -3232,12 +3237,153 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
32323237 ),
32333238 .div_trunc, .div_floor, .div_exact, .rem, .mod => dst_info.bits,
32343239 });
3240 const src_abi_size: u32 = @intCast(src_ty.abiSize(mod));
3241
3242 if (dst_abi_size == 16 and src_abi_size == 16) switch (tag) {
3243 else => unreachable,
3244 .mul, .mul_wrap => {},
3245 .div_trunc, .div_floor, .div_exact, .rem, .mod => {
3246 const signed = dst_ty.isSignedInt(mod);
3247 var callee_buf: ["__udiv?i3".len]u8 = undefined;
3248 const signed_div_floor_state: struct {
3249 frame_index: FrameIndex,
3250 reloc: Mir.Inst.Index,
3251 } = if (signed and tag == .div_floor) state: {
3252 const frame_index = try self.allocFrameIndex(FrameAlloc.initType(Type.usize, mod));
3253 try self.asmMemoryImmediate(
3254 .{ ._, .mov },
3255 Memory.sib(.qword, .{ .base = .{ .frame = frame_index } }),
3256 Immediate.u(0),
3257 );
3258
3259 const tmp_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
3260 const tmp_lock = self.register_manager.lockRegAssumeUnused(tmp_reg);
3261 defer self.register_manager.unlockReg(tmp_lock);
3262
3263 const lhs_mcv = try self.resolveInst(bin_op.lhs);
3264 if (lhs_mcv.isMemory()) try self.asmRegisterMemory(
3265 .{ ._, .mov },
3266 tmp_reg,
3267 lhs_mcv.address().offset(8).deref().mem(.qword),
3268 ) else try self.asmRegisterRegister(
3269 .{ ._, .mov },
3270 tmp_reg,
3271 lhs_mcv.register_pair[1],
3272 );
3273
3274 const rhs_mcv = try self.resolveInst(bin_op.rhs);
3275 if (rhs_mcv.isMemory()) try self.asmRegisterMemory(
3276 .{ ._, .xor },
3277 tmp_reg,
3278 rhs_mcv.address().offset(8).deref().mem(.qword),
3279 ) else try self.asmRegisterRegister(
3280 .{ ._, .xor },
3281 tmp_reg,
3282 rhs_mcv.register_pair[1],
3283 );
3284 const reloc = try self.asmJccReloc(.ns, undefined);
3285
3286 break :state .{ .frame_index = frame_index, .reloc = reloc };
3287 } else undefined;
3288 const call_mcv = try self.genCall(
3289 .{ .lib = .{
3290 .return_type = dst_ty.toIntern(),
3291 .param_types = &.{ src_ty.toIntern(), src_ty.toIntern() },
3292 .callee = std.fmt.bufPrint(&callee_buf, "__{s}{s}{c}i3", .{
3293 if (signed) "" else "u",
3294 switch (tag) {
3295 .div_trunc, .div_exact => "div",
3296 .div_floor => if (signed) "mod" else "div",
3297 .rem, .mod => "mod",
3298 else => unreachable,
3299 },
3300 intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))),
3301 }) catch unreachable,
3302 } },
3303 &.{ src_ty, src_ty },
3304 &.{ .{ .air_ref = bin_op.lhs }, .{ .air_ref = bin_op.rhs } },
3305 );
3306 break :result if (signed) switch (tag) {
3307 .div_floor => {
3308 try self.asmRegisterRegister(
3309 .{ ._, .@"or" },
3310 call_mcv.register_pair[0],
3311 call_mcv.register_pair[1],
3312 );
3313 try self.asmSetccMemory(.nz, Memory.sib(.byte, .{
3314 .base = .{ .frame = signed_div_floor_state.frame_index },
3315 }));
3316 try self.performReloc(signed_div_floor_state.reloc);
3317 const dst_mcv = try self.genCall(
3318 .{ .lib = .{
3319 .return_type = dst_ty.toIntern(),
3320 .param_types = &.{ src_ty.toIntern(), src_ty.toIntern() },
3321 .callee = std.fmt.bufPrint(&callee_buf, "__div{c}i3", .{
3322 intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))),
3323 }) catch unreachable,
3324 } },
3325 &.{ src_ty, src_ty },
3326 &.{ .{ .air_ref = bin_op.lhs }, .{ .air_ref = bin_op.rhs } },
3327 );
3328 try self.asmRegisterMemory(
3329 .{ ._, .sub },
3330 dst_mcv.register_pair[0],
3331 Memory.sib(.qword, .{
3332 .base = .{ .frame = signed_div_floor_state.frame_index },
3333 }),
3334 );
3335 try self.asmRegisterImmediate(
3336 .{ ._, .sbb },
3337 dst_mcv.register_pair[1],
3338 Immediate.u(0),
3339 );
3340 try self.freeValue(
3341 .{ .load_frame = .{ .index = signed_div_floor_state.frame_index } },
3342 );
3343 break :result dst_mcv;
3344 },
3345 .mod => {
3346 const dst_regs = call_mcv.register_pair;
3347 const dst_locks = self.register_manager.lockRegsAssumeUnused(2, dst_regs);
3348 defer for (dst_locks) |lock| self.register_manager.unlockReg(lock);
3349
3350 const tmp_regs =
3351 try self.register_manager.allocRegs(2, .{null} ** 2, abi.RegisterClass.gp);
3352 const tmp_locks = self.register_manager.lockRegsAssumeUnused(2, tmp_regs);
3353 defer for (tmp_locks) |lock| self.register_manager.unlockReg(lock);
3354
3355 const rhs_mcv = try self.resolveInst(bin_op.rhs);
3356
3357 for (tmp_regs, dst_regs) |tmp_reg, dst_reg|
3358 try self.asmRegisterRegister(.{ ._, .mov }, tmp_reg, dst_reg);
3359 if (rhs_mcv.isMemory()) {
3360 try self.asmRegisterMemory(.{ ._, .add }, tmp_regs[0], rhs_mcv.mem(.qword));
3361 try self.asmRegisterMemory(
3362 .{ ._, .adc },
3363 tmp_regs[1],
3364 rhs_mcv.address().offset(8).deref().mem(.qword),
3365 );
3366 } else for (
3367 [_]Mir.Inst.Tag{ .add, .adc },
3368 tmp_regs,
3369 rhs_mcv.register_pair,
3370 ) |op, tmp_reg, rhs_reg|
3371 try self.asmRegisterRegister(.{ ._, op }, tmp_reg, rhs_reg);
3372 try self.asmRegisterRegister(.{ ._, .@"test" }, dst_regs[1], dst_regs[1]);
3373 for (dst_regs, tmp_regs) |dst_reg, tmp_reg|
3374 try self.asmCmovccRegisterRegister(.s, dst_reg, tmp_reg);
3375 break :result call_mcv;
3376 },
3377 else => call_mcv,
3378 } else call_mcv;
3379 },
3380 };
32353381
32363382 try self.spillEflagsIfOccupied();
32373383 try self.spillRegisters(&.{ .rax, .rdx });
3238 const lhs = try self.resolveInst(bin_op.lhs);
3239 const rhs = try self.resolveInst(bin_op.rhs);
3240 break :result try self.genMulDivBinOp(tag, inst, dst_ty, src_ty, lhs, rhs);
3384 const lhs_mcv = try self.resolveInst(bin_op.lhs);
3385 const rhs_mcv = try self.resolveInst(bin_op.rhs);
3386 break :result try self.genMulDivBinOp(tag, inst, dst_ty, src_ty, lhs_mcv, rhs_mcv);
32413387 };
32423388 return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
32433389}
......@@ -4594,6 +4740,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
45944740
45954741 // TODO we could allocate register here, but need to expect addr register and potentially
45964742 // offset register.
4743 try self.spillEflagsIfOccupied();
45974744 const dst_mcv = try self.allocRegOrMem(inst, false);
45984745 try self.genBinOpMir(
45994746 .{ ._, .add },
......@@ -7201,37 +7348,7 @@ fn genMulDivBinOp(
72017348 assert(self.eflags_inst == null);
72027349
72037350 if (dst_abi_size == 16 and src_abi_size == 16) {
7204 switch (tag) {
7205 else => unreachable,
7206 .mul, .mul_wrap => {},
7207 .div_trunc, .div_floor, .div_exact, .rem, .mod => {
7208 const signed = dst_ty.isSignedInt(mod);
7209 if (signed) switch (tag) {
7210 .div_floor, .mod => return self.fail(
7211 "TODO implement genMulDivBinOp for {s} from {} to {}",
7212 .{ @tagName(tag), src_ty.fmt(mod), dst_ty.fmt(mod) },
7213 ),
7214 else => {},
7215 };
7216 var callee_buf: ["__udiv?i3".len]u8 = undefined;
7217 return try self.genCall(.{ .lib = .{
7218 .return_type = dst_ty.toIntern(),
7219 .param_types = &.{ src_ty.toIntern(), src_ty.toIntern() },
7220 .callee = std.fmt.bufPrint(&callee_buf, "__{s}{s}{c}i3", .{
7221 if (signed) "" else "u",
7222 switch (tag) {
7223 .div_trunc, .div_exact => "div",
7224 .div_floor => if (signed) unreachable else "div",
7225 .rem => "mod",
7226 .mod => if (signed) unreachable else "mod",
7227 else => unreachable,
7228 },
7229 intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))),
7230 }) catch unreachable,
7231 } }, &.{ src_ty, src_ty }, &.{ lhs_mcv, rhs_mcv });
7232 },
7233 }
7234
7351 assert(tag == .mul or tag == .mul_wrap);
72357352 const reg_locks = self.register_manager.lockRegsAssumeUnused(2, .{ .rax, .rdx });
72367353 defer for (reg_locks) |lock| self.register_manager.unlockReg(lock);
72377354
......@@ -9436,6 +9553,7 @@ fn genBinOpMir(
94369553fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {
94379554 const mod = self.bin_file.options.module.?;
94389555 const abi_size: u32 = @intCast(dst_ty.abiSize(mod));
9556 try self.spillEflagsIfOccupied();
94399557 switch (dst_mcv) {
94409558 .none,
94419559 .unreach,
......@@ -10509,8 +10627,6 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
1050910627 const else_body = self.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
1051010628 const liveness_cond_br = self.liveness.getCondBr(inst);
1051110629
10512 const reloc = try self.genCondBrMir(cond_ty, cond);
10513
1051410630 // If the condition dies here in this condbr instruction, process
1051510631 // that death now instead of later as this has an effect on
1051610632 // whether it needs to be spilled in the branches
......@@ -10520,6 +10636,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
1052010636
1052110637 self.scope_generation += 1;
1052210638 const state = try self.saveState();
10639 const reloc = try self.genCondBrMir(cond_ty, cond);
1052310640
1052410641 for (liveness_cond_br.then_deaths) |death| try self.processDeath(death);
1052510642 try self.genBody(then_body);
......@@ -10905,7 +11022,7 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void {
1090511022 if (std.debug.runtime_safety) assert(self.inst_tracking.getIndex(inst).? == inst_tracking_i);
1090611023 const tracking = &self.inst_tracking.values()[inst_tracking_i];
1090711024 if (self.liveness.isUnused(inst)) try tracking.die(self, inst);
10908 self.getValue(tracking.short, inst);
11025 self.getValueIfFree(tracking.short, inst);
1090911026 self.finishAirBookkeeping();
1091011027}
1091111028
......@@ -11019,7 +11136,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
1101911136 }
1102011137
1102111138 const dst_mcv = if (first_br) try self.allocRegOrMem(br.block_inst, true) else dst: {
11022 self.getValue(block_tracking.short, br.block_inst);
11139 try self.getValue(block_tracking.short, br.block_inst);
1102311140 break :dst block_tracking.short;
1102411141 };
1102511142 try self.genCopy(block_ty, dst_mcv, src_mcv);
......@@ -13248,6 +13365,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
1324813365 defer self.register_manager.unlockReg(len_lock);
1324913366
1325013367 try self.genSetReg(len_reg, Type.usize, len);
13368 try self.asmRegisterRegister(.{ ._, .@"test" }, len_reg, len_reg);
1325113369
1325213370 const skip_reloc = try self.asmJccReloc(.z, undefined);
1325313371 try self.store(slice_ptr_ty, ptr, src_val);
......@@ -14768,6 +14886,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
1476814886 .bits = @intCast(ty.bitSize(mod)),
1476914887 };
1477014888 const max_reg_bit_width = Register.rax.bitSize();
14889 try self.spillEflagsIfOccupied();
1477114890 switch (int_info.signedness) {
1477214891 .signed => {
1477314892 const shift: u6 = @intCast(max_reg_bit_width - int_info.bits);
src/main.zig+59-7
......@@ -3774,7 +3774,9 @@ fn serve(
37743774 try comp.makeBinFileWritable();
37753775 }
37763776
3777 {
3777 if (builtin.single_threaded) {
3778 try comp.update(main_progress_node);
3779 } else {
37783780 var reset: std.Thread.ResetEvent = .{};
37793781
37803782 var progress_thread = try std.Thread.spawn(.{}, progressThread, .{
......@@ -4920,6 +4922,17 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
49204922 var child_argv = std.ArrayList([]const u8).init(arena);
49214923 var reference_trace: ?u32 = null;
49224924 var debug_compile_errors = false;
4925 var verbose_link = (builtin.os.tag != .wasi or builtin.link_libc) and
4926 EnvVar.ZIG_VERBOSE_LINK.isSet();
4927 var verbose_cc = (builtin.os.tag != .wasi or builtin.link_libc) and
4928 EnvVar.ZIG_VERBOSE_CC.isSet();
4929 var verbose_air = false;
4930 var verbose_intern_pool = false;
4931 var verbose_generic_instances = false;
4932 var verbose_llvm_ir: ?[]const u8 = null;
4933 var verbose_llvm_bc: ?[]const u8 = null;
4934 var verbose_cimport = false;
4935 var verbose_llvm_cpu_features = false;
49234936 var fetch_only = false;
49244937
49254938 const argv_index_exe = child_argv.items.len;
......@@ -4956,7 +4969,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
49564969 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
49574970 i += 1;
49584971 override_lib_dir = args[i];
4959 try child_argv.appendSlice(&[_][]const u8{ arg, args[i] });
4972 try child_argv.appendSlice(&.{ arg, args[i] });
49604973 continue;
49614974 } else if (mem.eql(u8, arg, "--build-runner")) {
49624975 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
49744987 override_global_cache_dir = args[i];
49754988 continue;
49764989 } else if (mem.eql(u8, arg, "-freference-trace")) {
4977 try child_argv.append(arg);
49784990 reference_trace = 256;
49794991 } else if (mem.eql(u8, arg, "--fetch")) {
49804992 fetch_only = true;
49814993 } else if (mem.startsWith(u8, arg, "-freference-trace=")) {
4982 try child_argv.append(arg);
49834994 const num = arg["-freference-trace=".len..];
49844995 reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| {
49854996 fatal("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) });
49864997 };
49874998 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {
4988 try child_argv.append(arg);
49894999 reference_trace = null;
5000 } else if (mem.eql(u8, arg, "--debug-log")) {
5001 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
5002 try child_argv.appendSlice(args[i .. i + 2]);
5003 i += 1;
5004 if (!build_options.enable_logging) {
5005 std.log.warn("Zig was compiled without logging enabled (-Dlog). --debug-log has no effect.", .{});
5006 } else {
5007 try log_scopes.append(gpa, args[i]);
5008 }
5009 continue;
49905010 } else if (mem.eql(u8, arg, "--debug-compile-errors")) {
4991 try child_argv.append(arg);
4992 debug_compile_errors = true;
5011 if (!crash_report.is_enabled) {
5012 std.log.warn("Zig was compiled in a release mode. --debug-compile-errors has no effect.", .{});
5013 } else {
5014 debug_compile_errors = true;
5015 }
5016 } else if (mem.eql(u8, arg, "--verbose-link")) {
5017 verbose_link = true;
5018 } else if (mem.eql(u8, arg, "--verbose-cc")) {
5019 verbose_cc = true;
5020 } else if (mem.eql(u8, arg, "--verbose-air")) {
5021 verbose_air = true;
5022 } else if (mem.eql(u8, arg, "--verbose-intern-pool")) {
5023 verbose_intern_pool = true;
5024 } else if (mem.eql(u8, arg, "--verbose-generic-instances")) {
5025 verbose_generic_instances = true;
5026 } else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
5027 verbose_llvm_ir = "-";
5028 } else if (mem.startsWith(u8, arg, "--verbose-llvm-ir=")) {
5029 verbose_llvm_ir = arg["--verbose-llvm-ir=".len..];
5030 } else if (mem.startsWith(u8, arg, "--verbose-llvm-bc=")) {
5031 verbose_llvm_bc = arg["--verbose-llvm-bc=".len..];
5032 } else if (mem.eql(u8, arg, "--verbose-cimport")) {
5033 verbose_cimport = true;
5034 } else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
5035 verbose_llvm_cpu_features = true;
49935036 } else if (mem.eql(u8, arg, "--seed")) {
49945037 if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
49955038 i += 1;
......@@ -5264,6 +5307,15 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
52645307 .optimize_mode = .Debug,
52655308 .self_exe_path = self_exe_path,
52665309 .thread_pool = &thread_pool,
5310 .verbose_cc = verbose_cc,
5311 .verbose_link = verbose_link,
5312 .verbose_air = verbose_air,
5313 .verbose_intern_pool = verbose_intern_pool,
5314 .verbose_generic_instances = verbose_generic_instances,
5315 .verbose_llvm_ir = verbose_llvm_ir,
5316 .verbose_llvm_bc = verbose_llvm_bc,
5317 .verbose_cimport = verbose_cimport,
5318 .verbose_llvm_cpu_features = verbose_llvm_cpu_features,
52675319 .cache_mode = .whole,
52685320 .reference_trace = reference_trace,
52695321 .debug_compile_errors = debug_compile_errors,
test/behavior/maximum_minimum.zig+1-1
......@@ -282,7 +282,7 @@ test "@min/@max notices bounds from vector types when element of comptime-known
282282 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
283283 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
284284 if (builtin.zig_backend == .stage2_x86_64 and
285 !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sse4_1)) return error.SkipZigTest;
285 !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest;
286286
287287 var x: @Vector(2, u32) = .{ 1_000_000, 12345 };
288288 const y: @Vector(2, u16) = .{ 10, undefined };
test/c_abi/cfuncs.c+7-3
......@@ -73,6 +73,10 @@ static void assert_or_panic(bool ok) {
7373#define ZIG_NO_RAW_F16
7474#endif
7575
76#ifdef ZIG_BACKEND_STAGE2_X86_64
77#define ZIG_NO_COMPLEX
78#endif
79
7680#ifdef __i386__
7781#define ZIG_NO_RAW_F16
7882#endif
......@@ -274,7 +278,7 @@ void run_c_tests(void) {
274278 zig_u32(0xfffffffd);
275279 zig_u64(0xfffffffffffffffc);
276280
277#ifndef ZIG_NO_I128
281#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64
278282 {
279283 struct u128 s = {0xfffffffffffffffc};
280284 zig_struct_u128(s);
......@@ -288,7 +292,7 @@ void run_c_tests(void) {
288292 zig_i32(-3);
289293 zig_i64(-4);
290294
291#ifndef ZIG_NO_I128
295#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64
292296 {
293297 struct i128 s = {-6};
294298 zig_struct_i128(s);
......@@ -429,7 +433,7 @@ void run_c_tests(void) {
429433 }
430434#endif
431435
432#if !defined __mips__ && !defined ZIG_PPC32
436#if !defined __mips__ && !defined ZIG_PPC32 && !defined ZIG_BACKEND_STAGE2_X86_64
433437 {
434438 struct FloatRect r1 = {1, 21, 16, 4};
435439 struct FloatRect r2 = {178, 189, 21, 15};
test/c_abi/main.zig+86
......@@ -49,6 +49,8 @@ export fn zig_five_integers(a: i32, b: i32, c: i32, d: i32, e: i32) void {
4949}
5050
5151test "C ABI integers" {
52 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
53
5254 c_u8(0xff);
5355 c_u16(0xfffe);
5456 c_u32(0xfffffffd);
......@@ -185,6 +187,8 @@ const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.is
185187 !builtin.cpu.arch.isARM() and !builtin.cpu.arch.isPPC() and !builtin.cpu.arch.isRISCV();
186188
187189test "C ABI complex float" {
190 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
191
188192 if (!complex_abi_compatible) return error.SkipZigTest;
189193 if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465
190194
......@@ -197,6 +201,8 @@ test "C ABI complex float" {
197201}
198202
199203test "C ABI complex float by component" {
204 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
205
200206 if (!complex_abi_compatible) return error.SkipZigTest;
201207
202208 const a = ComplexFloat{ .real = 1.25, .imag = 2.6 };
......@@ -208,6 +214,8 @@ test "C ABI complex float by component" {
208214}
209215
210216test "C ABI complex double" {
217 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
218
211219 if (!complex_abi_compatible) return error.SkipZigTest;
212220
213221 const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };
......@@ -219,6 +227,8 @@ test "C ABI complex double" {
219227}
220228
221229test "C ABI complex double by component" {
230 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
231
222232 if (!complex_abi_compatible) return error.SkipZigTest;
223233
224234 const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };
......@@ -230,6 +240,8 @@ test "C ABI complex double by component" {
230240}
231241
232242export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat {
243 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
244
233245 expect(a.real == 1.25) catch @panic("test failure: zig_cmultf 1");
234246 expect(a.imag == 2.6) catch @panic("test failure: zig_cmultf 2");
235247 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 {
239251}
240252
241253export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble {
254 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
255
242256 expect(a.real == 1.25) catch @panic("test failure: zig_cmultd 1");
243257 expect(a.imag == 2.6) catch @panic("test failure: zig_cmultd 2");
244258 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 {
248262}
249263
250264export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat {
265 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
266
251267 expect(a_r == 1.25) catch @panic("test failure: zig_cmultf_comp 1");
252268 expect(a_i == 2.6) catch @panic("test failure: zig_cmultf_comp 2");
253269 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 {
257273}
258274
259275export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble {
276 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
277
260278 expect(a_r == 1.25) catch @panic("test failure: zig_cmultd_comp 1");
261279 expect(a_i == 2.6) catch @panic("test failure: zig_cmultd_comp 2");
262280 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;
334352extern fn c_ret_med_struct_mixed() MedStructMixed;
335353
336354test "C ABI medium struct of ints and floats" {
355 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
356
337357 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
338358 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
339359 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -402,6 +422,8 @@ extern fn c_med_struct_ints(MedStructInts) void;
402422extern fn c_ret_med_struct_ints() MedStructInts;
403423
404424test "C ABI medium struct of ints" {
425 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
426
405427 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
406428 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
407429 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -509,6 +531,8 @@ extern fn c_split_struct_mixed(SplitStructMixed) void;
509531extern fn c_ret_split_struct_mixed() SplitStructMixed;
510532
511533test "C ABI split struct of ints and floats" {
534 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
535
512536 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
513537 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
514538 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -590,6 +614,8 @@ const Vector5 = extern struct {
590614extern fn c_big_struct_floats(Vector5) void;
591615
592616test "C ABI structs of floats as parameter" {
617 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
618
593619 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
594620 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
595621 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
......@@ -657,6 +683,8 @@ const FloatRect = extern struct {
657683};
658684
659685export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
686 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
687
660688 expect(x.left == 1) catch @panic("test failure");
661689 expect(x.right == 21) catch @panic("test failure");
662690 expect(x.top == 16) catch @panic("test failure");
......@@ -668,6 +696,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
668696}
669697
670698test "C ABI structs of floats as multiple parameters" {
699 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
700
671701 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
672702 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
673703
......@@ -724,6 +754,8 @@ export fn zig_ret_small_struct_ints() SmallStructInts {
724754}
725755
726756export fn zig_ret_med_struct_ints() MedStructInts {
757 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
758
727759 return .{
728760 .x = 1,
729761 .y = 2,
......@@ -732,6 +764,8 @@ export fn zig_ret_med_struct_ints() MedStructInts {
732764}
733765
734766export fn zig_ret_med_struct_mixed() MedStructMixed {
767 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
768
735769 return .{
736770 .a = 1234,
737771 .b = 100.0,
......@@ -740,6 +774,8 @@ export fn zig_ret_med_struct_mixed() MedStructMixed {
740774}
741775
742776export fn zig_ret_split_struct_mixed() SplitStructMixed {
777 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
778
743779 return .{
744780 .a = 1234,
745781 .b = 100,
......@@ -780,6 +816,8 @@ extern fn c_struct_with_array(StructWithArray) void;
780816extern fn c_ret_struct_with_array() StructWithArray;
781817
782818test "Struct with array as padding." {
819 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
820
783821 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
784822 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
785823 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -851,6 +889,8 @@ extern fn c_medium_vec(MediumVec) void;
851889extern fn c_ret_medium_vec() MediumVec;
852890
853891test "medium simd vector" {
892 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
893
854894 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
855895
856896 c_medium_vec(.{ 1, 2, 3, 4 });
......@@ -868,6 +908,8 @@ extern fn c_big_vec(BigVec) void;
868908extern fn c_ret_big_vec() BigVec;
869909
870910test "big simd vector" {
911 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
912
871913 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
872914 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
873915 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;
891933extern fn c_ret_ptr_size_float_struct() Vector2;
892934
893935test "C ABI pointer sized float struct" {
936 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
937
894938 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
895939 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
896940 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
......@@ -914,6 +958,8 @@ pub inline fn expectOk(c_err: c_int) !void {
914958/// Tests for Double + Char struct
915959const DC = extern struct { v1: f64, v2: u8 };
916960test "DC: Zig passes to C" {
961 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
962
917963 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
918964 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
919965 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -921,6 +967,8 @@ test "DC: Zig passes to C" {
921967 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
922968}
923969test "DC: Zig returns to C" {
970 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
971
924972 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
925973 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
926974 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
......@@ -929,6 +977,8 @@ test "DC: Zig returns to C" {
929977 try expectOk(c_assert_ret_DC());
930978}
931979test "DC: C passes to Zig" {
980 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
981
932982 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
933983 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
934984 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -936,6 +986,8 @@ test "DC: C passes to Zig" {
936986 try expectOk(c_send_DC());
937987}
938988test "DC: C returns to Zig" {
989 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
990
939991 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
940992 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
941993 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
......@@ -949,6 +1001,8 @@ pub extern fn c_assert_ret_DC() c_int;
9491001pub extern fn c_send_DC() c_int;
9501002pub extern fn c_ret_DC() DC;
9511003pub export fn zig_assert_DC(lv: DC) c_int {
1004 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1005
9521006 var err: c_int = 0;
9531007 if (lv.v1 != -0.25) err = 1;
9541008 if (lv.v2 != 15) err = 2;
......@@ -956,6 +1010,8 @@ pub export fn zig_assert_DC(lv: DC) c_int {
9561010 return err;
9571011}
9581012pub export fn zig_ret_DC() DC {
1013 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1014
9591015 return .{ .v1 = -0.25, .v2 = 15 };
9601016}
9611017
......@@ -963,6 +1019,8 @@ pub export fn zig_ret_DC() DC {
9631019const CFF = extern struct { v1: u8, v2: f32, v3: f32 };
9641020
9651021test "CFF: Zig passes to C" {
1022 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1023
9661024 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
9671025 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
9681026 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -970,6 +1028,8 @@ test "CFF: Zig passes to C" {
9701028 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
9711029}
9721030test "CFF: Zig returns to C" {
1031 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1032
9731033 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
9741034 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
9751035 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -977,6 +1037,8 @@ test "CFF: Zig returns to C" {
9771037 try expectOk(c_assert_ret_CFF());
9781038}
9791039test "CFF: C passes to Zig" {
1040 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1041
9801042 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
9811043 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
9821044 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
......@@ -987,6 +1049,8 @@ test "CFF: C passes to Zig" {
9871049 try expectOk(c_send_CFF());
9881050}
9891051test "CFF: C returns to Zig" {
1052 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1053
9901054 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
9911055 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
9921056 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;
10001064pub extern fn c_send_CFF() c_int;
10011065pub extern fn c_ret_CFF() CFF;
10021066pub export fn zig_assert_CFF(lv: CFF) c_int {
1067 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1068
10031069 var err: c_int = 0;
10041070 if (lv.v1 != 39) err = 1;
10051071 if (lv.v2 != 0.875) err = 2;
......@@ -1008,6 +1074,8 @@ pub export fn zig_assert_CFF(lv: CFF) c_int {
10081074 return err;
10091075}
10101076pub export fn zig_ret_CFF() CFF {
1077 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1078
10111079 return .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 };
10121080}
10131081
......@@ -1015,6 +1083,8 @@ pub export fn zig_ret_CFF() CFF {
10151083const PD = extern struct { v1: ?*anyopaque, v2: f64 };
10161084
10171085test "PD: Zig passes to C" {
1086 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1087
10181088 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
10191089 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
10201090 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -1022,6 +1092,8 @@ test "PD: Zig passes to C" {
10221092 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
10231093}
10241094test "PD: Zig returns to C" {
1095 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1096
10251097 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
10261098 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
10271099 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -1029,6 +1101,8 @@ test "PD: Zig returns to C" {
10291101 try expectOk(c_assert_ret_PD());
10301102}
10311103test "PD: C passes to Zig" {
1104 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1105
10321106 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
10331107 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
10341108 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -1036,6 +1110,8 @@ test "PD: C passes to Zig" {
10361110 try expectOk(c_send_PD());
10371111}
10381112test "PD: C returns to Zig" {
1113 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1114
10391115 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
10401116 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
10411117 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
......@@ -1047,6 +1123,8 @@ pub extern fn c_assert_ret_PD() c_int;
10471123pub extern fn c_send_PD() c_int;
10481124pub extern fn c_ret_PD() PD;
10491125pub export fn zig_c_assert_PD(lv: PD) c_int {
1126 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1127
10501128 var err: c_int = 0;
10511129 if (lv.v1 != null) err = 1;
10521130 if (lv.v2 != 0.5) err = 2;
......@@ -1054,9 +1132,13 @@ pub export fn zig_c_assert_PD(lv: PD) c_int {
10541132 return err;
10551133}
10561134pub export fn zig_ret_PD() PD {
1135 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1136
10571137 return .{ .v1 = null, .v2 = 0.5 };
10581138}
10591139pub export fn zig_assert_PD(lv: PD) c_int {
1140 if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
1141
10601142 var err: c_int = 0;
10611143 if (lv.v1 != null) err = 1;
10621144 if (lv.v2 != 0.5) err = 2;
......@@ -1146,6 +1228,8 @@ const f80_struct = extern struct {
11461228};
11471229extern fn c_f80_struct(f80_struct) f80_struct;
11481230test "f80 struct" {
1231 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1232
11491233 if (!has_f80) return error.SkipZigTest;
11501234 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
11511235 if (builtin.mode != .Debug) return error.SkipZigTest;
......@@ -1233,6 +1317,8 @@ test "Stdcall ABI big union" {
12331317
12341318extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef;
12351319test "explicit SysV calling convention" {
1320 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1321
12361322 if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
12371323
12381324 const res = c_explict_win64(.{ .val = 1, .arr = undefined });
test/tests.zig+144-44
......@@ -94,6 +94,26 @@ const test_targets = blk: {
9494 .use_llvm = false,
9595 .use_lld = false,
9696 },
97 .{
98 .target = .{
99 .cpu_arch = .x86_64,
100 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
101 .os_tag = .linux,
102 .abi = .none,
103 },
104 .use_llvm = false,
105 .use_lld = false,
106 },
107 .{
108 .target = .{
109 .cpu_arch = .x86_64,
110 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
111 .os_tag = .linux,
112 .abi = .none,
113 },
114 .use_llvm = false,
115 .use_lld = false,
116 },
97117 // Doesn't support new liveness
98118 //.{
99119 // .target = .{
......@@ -470,62 +490,123 @@ const test_targets = blk: {
470490 };
471491};
472492
473const c_abi_targets = [_]CrossTarget{
493const CAbiTarget = struct {
494 target: CrossTarget = .{},
495 use_llvm: ?bool = null,
496 use_lld: ?bool = null,
497 c_defines: []const []const u8 = &.{},
498};
499
500const c_abi_targets = [_]CAbiTarget{
474501 .{},
475502 .{
476 .cpu_arch = .x86_64,
477 .os_tag = .linux,
478 .abi = .musl,
503 .target = .{
504 .cpu_arch = .x86_64,
505 .os_tag = .linux,
506 .abi = .musl,
507 },
479508 },
480509 .{
481 .cpu_arch = .x86,
482 .os_tag = .linux,
483 .abi = .musl,
510 .target = .{
511 .cpu_arch = .x86_64,
512 .os_tag = .linux,
513 .abi = .musl,
514 },
515 .use_llvm = false,
516 .use_lld = false,
517 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
484518 },
485519 .{
486 .cpu_arch = .aarch64,
487 .os_tag = .linux,
488 .abi = .musl,
520 .target = .{
521 .cpu_arch = .x86_64,
522 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
523 .os_tag = .linux,
524 .abi = .musl,
525 },
526 .use_llvm = false,
527 .use_lld = false,
528 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
489529 },
490530 .{
491 .cpu_arch = .arm,
492 .os_tag = .linux,
493 .abi = .musleabihf,
531 .target = .{
532 .cpu_arch = .x86_64,
533 .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
534 .os_tag = .linux,
535 .abi = .musl,
536 },
537 .use_llvm = false,
538 .use_lld = false,
539 .c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
494540 },
495541 .{
496 .cpu_arch = .mips,
497 .os_tag = .linux,
498 .abi = .musl,
542 .target = .{
543 .cpu_arch = .x86,
544 .os_tag = .linux,
545 .abi = .musl,
546 },
499547 },
500548 .{
501 .cpu_arch = .riscv64,
502 .os_tag = .linux,
503 .abi = .musl,
549 .target = .{
550 .cpu_arch = .aarch64,
551 .os_tag = .linux,
552 .abi = .musl,
553 },
504554 },
505555 .{
506 .cpu_arch = .wasm32,
507 .os_tag = .wasi,
508 .abi = .musl,
556 .target = .{
557 .cpu_arch = .arm,
558 .os_tag = .linux,
559 .abi = .musleabihf,
560 },
509561 },
510562 .{
511 .cpu_arch = .powerpc,
512 .os_tag = .linux,
513 .abi = .musl,
563 .target = .{
564 .cpu_arch = .mips,
565 .os_tag = .linux,
566 .abi = .musl,
567 },
514568 },
515569 .{
516 .cpu_arch = .powerpc64le,
517 .os_tag = .linux,
518 .abi = .musl,
570 .target = .{
571 .cpu_arch = .riscv64,
572 .os_tag = .linux,
573 .abi = .musl,
574 },
519575 },
520576 .{
521 .cpu_arch = .x86,
522 .os_tag = .windows,
523 .abi = .gnu,
577 .target = .{
578 .cpu_arch = .wasm32,
579 .os_tag = .wasi,
580 .abi = .musl,
581 },
524582 },
525583 .{
526 .cpu_arch = .x86_64,
527 .os_tag = .windows,
528 .abi = .gnu,
584 .target = .{
585 .cpu_arch = .powerpc,
586 .os_tag = .linux,
587 .abi = .musl,
588 },
589 },
590 .{
591 .target = .{
592 .cpu_arch = .powerpc64le,
593 .os_tag = .linux,
594 .abi = .musl,
595 },
596 },
597 .{
598 .target = .{
599 .cpu_arch = .x86,
600 .os_tag = .windows,
601 .abi = .gnu,
602 },
603 },
604 .{
605 .target = .{
606 .cpu_arch = .x86_64,
607 .os_tag = .windows,
608 .abi = .gnu,
609 },
529610 },
530611};
531612
......@@ -1017,6 +1098,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10171098
10181099 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
10191100 const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
1101 const model_txt = test_target.target.getCpuModel().name;
10201102
10211103 // wasm32-wasi builds need more RAM, idk why
10221104 const max_rss = if (test_target.target.getOs().tag == .wasi)
......@@ -1054,9 +1136,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
10541136 these_tests.stack_size = 2 * 1024 * 1024;
10551137 }
10561138
1057 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}{s}", .{
1139 const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}", .{
10581140 options.name,
10591141 triple_txt,
1142 model_txt,
10601143 @tagName(test_target.optimize_mode),
10611144 libc_suffix,
10621145 single_threaded_suffix,
......@@ -1144,33 +1227,50 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
11441227 if (optimize_mode != .Debug and skip_release) continue;
11451228
11461229 for (c_abi_targets) |c_abi_target| {
1147 if (skip_non_native and !c_abi_target.isNative()) continue;
1230 if (skip_non_native and !c_abi_target.target.isNative()) continue;
11481231
1149 if (c_abi_target.isWindows() and c_abi_target.getCpuArch() == .aarch64) {
1232 if (c_abi_target.target.isWindows() and c_abi_target.target.getCpuArch() == .aarch64) {
11501233 // https://github.com/ziglang/zig/issues/14908
11511234 continue;
11521235 }
11531236
1154 const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM");
1237 if (c_abi_target.use_llvm == false and optimize_mode == .ReleaseFast) {
1238 // panic: unrecognized command line argument
1239 continue;
1240 }
11551241
11561242 const test_step = b.addTest(.{
1243 .name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}", .{
1244 c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"),
1245 c_abi_target.target.getCpuModel().name,
1246 @tagName(optimize_mode),
1247 if (c_abi_target.use_llvm == true)
1248 "-llvm"
1249 else if (c_abi_target.target.ofmt == std.Target.ObjectFormat.c)
1250 "-cbe"
1251 else if (c_abi_target.use_llvm == false)
1252 "-selfhosted"
1253 else
1254 "",
1255 if (c_abi_target.use_lld == false) "-no-lld" else "",
1256 }),
11571257 .root_source_file = .{ .path = "test/c_abi/main.zig" },
1258 .target = c_abi_target.target,
11581259 .optimize = optimize_mode,
1159 .target = c_abi_target,
1160 .name = b.fmt("test-c-abi-{s}-{s}", .{
1161 triple_prefix, @tagName(optimize_mode),
1162 }),
1260 .link_libc = true,
1261 .use_llvm = c_abi_target.use_llvm,
1262 .use_lld = c_abi_target.use_lld,
11631263 });
1164 if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) {
1264 if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) {
11651265 // TODO NativeTargetInfo insists on dynamically linking musl
11661266 // for some reason?
11671267 test_step.target_info.dynamic_linker.max_byte = null;
11681268 }
1169 test_step.linkLibC();
11701269 test_step.addCSourceFile(.{
11711270 .file = .{ .path = "test/c_abi/cfuncs.c" },
11721271 .flags = &.{"-std=c99"},
11731272 });
1273 for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);
11741274
11751275 // This test is intentionally trying to check if the external ABI is
11761276 // done properly. LTO would be a hindrance to this.