x86_64: fix std test failures

This commit is contained in:
Jacob Young 2023-11-03 23:18:21 -04:00
parent f6de3ec963
commit 509be7cf1f
45 changed files with 1412 additions and 841 deletions

View File

@ -324,8 +324,6 @@ test "Condition - wait and signal" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const num_threads = 4; const num_threads = 4;
const MultiWait = struct { const MultiWait = struct {
@ -371,8 +369,6 @@ test "Condition - signal" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const num_threads = 4; const num_threads = 4;
const SignalTest = struct { const SignalTest = struct {
@ -440,8 +436,6 @@ test "Condition - multi signal" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const num_threads = 4; const num_threads = 4;
const num_iterations = 4; const num_iterations = 4;
@ -504,8 +498,6 @@ test "Condition - broadcasting" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const num_threads = 10; const num_threads = 10;
const BroadcastTest = struct { const BroadcastTest = struct {
@ -573,8 +565,6 @@ test "Condition - broadcasting - wake all threads" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var num_runs: usize = 1; var num_runs: usize = 1;
const num_threads = 10; const num_threads = 10;

View File

@ -289,8 +289,6 @@ test "Mutex - many contended" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const num_threads = 4; const num_threads = 4;
const num_increments = 1000; const num_increments = 1000;

View File

@ -297,8 +297,6 @@ test "RwLock - concurrent access" {
if (builtin.single_threaded) if (builtin.single_threaded)
return; return;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const num_writers: usize = 2; const num_writers: usize = 2;
const num_readers: usize = 4; const num_readers: usize = 4;
const num_writes: usize = 10000; const num_writes: usize = 10000;

View File

@ -39,8 +39,6 @@ test "Thread.Semaphore" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const TestContext = struct { const TestContext = struct {
sem: *Semaphore, sem: *Semaphore,
n: *i32, n: *i32,

View File

@ -467,8 +467,6 @@ test "Atomic.fetchSub" {
} }
test "Atomic.fetchMin" { test "Atomic.fetchMin" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
inline for (atomicIntTypes()) |Int| { inline for (atomicIntTypes()) |Int| {
inline for (atomic_rmw_orderings) |ordering| { inline for (atomic_rmw_orderings) |ordering| {
var x = Atomic(Int).init(5); var x = Atomic(Int).init(5);

View File

@ -175,8 +175,6 @@ const puts_per_thread = 500;
const put_thread_count = 3; const put_thread_count = 3;
test "std.atomic.Queue" { test "std.atomic.Queue" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var plenty_of_memory = try std.heap.page_allocator.alloc(u8, 300 * 1024); var plenty_of_memory = try std.heap.page_allocator.alloc(u8, 300 * 1024);
defer std.heap.page_allocator.free(plenty_of_memory); defer std.heap.page_allocator.free(plenty_of_memory);

View File

@ -355,8 +355,6 @@ pub const Base64DecoderWithIgnore = struct {
}; };
test "base64" { test "base64" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
@setEvalBranchQuota(8000); @setEvalBranchQuota(8000);
try testBase64(); try testBase64();
try comptime testAllApis(standard, "comptime", "Y29tcHRpbWU="); try comptime testAllApis(standard, "comptime", "Y29tcHRpbWU=");
@ -377,8 +375,6 @@ test "base64 padding dest overflow" {
} }
test "base64 url_safe_no_pad" { test "base64 url_safe_no_pad" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
@setEvalBranchQuota(8000); @setEvalBranchQuota(8000);
try testBase64UrlSafeNoPad(); try testBase64UrlSafeNoPad();
try comptime testAllApis(url_safe_no_pad, "comptime", "Y29tcHRpbWU"); try comptime testAllApis(url_safe_no_pad, "comptime", "Y29tcHRpbWU");

View File

@ -1638,7 +1638,6 @@ fn testStaticBitSet(comptime Set: type) !void {
test "IntegerBitSet" { test "IntegerBitSet" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testStaticBitSet(IntegerBitSet(0)); try testStaticBitSet(IntegerBitSet(0));
try testStaticBitSet(IntegerBitSet(1)); try testStaticBitSet(IntegerBitSet(1));
@ -1651,8 +1650,6 @@ test "IntegerBitSet" {
} }
test "ArrayBitSet" { test "ArrayBitSet" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| { inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| {
try testStaticBitSet(ArrayBitSet(u8, size)); try testStaticBitSet(ArrayBitSet(u8, size));
try testStaticBitSet(ArrayBitSet(u16, size)); try testStaticBitSet(ArrayBitSet(u16, size));

View File

@ -264,8 +264,6 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void {
} }
test "zstandard decompression" { test "zstandard decompression" {
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
const uncompressed = @embedFile("testdata/rfc8478.txt"); const uncompressed = @embedFile("testdata/rfc8478.txt");
const compressed3 = @embedFile("testdata/rfc8478.txt.zst.3"); const compressed3 = @embedFile("testdata/rfc8478.txt.zst.3");
const compressed19 = @embedFile("testdata/rfc8478.txt.zst.19"); const compressed19 = @embedFile("testdata/rfc8478.txt.zst.19");

View File

@ -1,5 +1,4 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const crypto = std.crypto; const crypto = std.crypto;
const debug = std.debug; const debug = std.debug;
const fmt = std.fmt; const fmt = std.fmt;
@ -276,8 +275,8 @@ pub const Ed25519 = struct {
pub fn fromSecretKey(secret_key: SecretKey) (NonCanonicalError || EncodingError || IdentityElementError)!KeyPair { pub fn fromSecretKey(secret_key: SecretKey) (NonCanonicalError || EncodingError || IdentityElementError)!KeyPair {
// It is critical for EdDSA to use the correct public key. // It is critical for EdDSA to use the correct public key.
// In order to enforce this, a SecretKey implicitly includes a copy of the public key. // In order to enforce this, a SecretKey implicitly includes a copy of the public key.
// In Debug mode, we can still afford checking that the public key is correct for extra safety. // With runtime safety, we can still afford checking that the public key is correct.
if (builtin.mode == .Debug) { if (std.debug.runtime_safety) {
const pk_p = try Curve.fromBytes(secret_key.publicKeyBytes()); const pk_p = try Curve.fromBytes(secret_key.publicKeyBytes());
const recomputed_kp = try create(secret_key.seed()); const recomputed_kp = try create(secret_key.seed());
debug.assert(mem.eql(u8, &recomputed_kp.public_key.toBytes(), &pk_p.toBytes())); debug.assert(mem.eql(u8, &recomputed_kp.public_key.toBytes(), &pk_p.toBytes()));
@ -493,8 +492,6 @@ test "ed25519 key pair creation" {
} }
test "ed25519 signature" { test "ed25519 signature" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var seed: [32]u8 = undefined; var seed: [32]u8 = undefined;
_ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166");
const key_pair = try Ed25519.KeyPair.create(seed); const key_pair = try Ed25519.KeyPair.create(seed);
@ -507,8 +504,6 @@ test "ed25519 signature" {
} }
test "ed25519 batch verification" { test "ed25519 batch verification" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var i: usize = 0; var i: usize = 0;
while (i < 100) : (i += 1) { while (i < 100) : (i += 1) {
const key_pair = try Ed25519.KeyPair.create(null); const key_pair = try Ed25519.KeyPair.create(null);
@ -538,8 +533,6 @@ test "ed25519 batch verification" {
} }
test "ed25519 test vectors" { test "ed25519 test vectors" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Vec = struct { const Vec = struct {
msg_hex: *const [64:0]u8, msg_hex: *const [64:0]u8,
public_key_hex: *const [64:0]u8, public_key_hex: *const [64:0]u8,
@ -642,8 +635,6 @@ test "ed25519 test vectors" {
} }
test "ed25519 with blind keys" { test "ed25519 with blind keys" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair; const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair;
// Create a standard Ed25519 key pair // Create a standard Ed25519 key pair
@ -667,8 +658,6 @@ test "ed25519 with blind keys" {
} }
test "ed25519 signatures with streaming" { test "ed25519 signatures with streaming" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const kp = try Ed25519.KeyPair.create(null); const kp = try Ed25519.KeyPair.create(null);
var signer = try kp.signer(null); var signer = try kp.signer(null);

View File

@ -614,18 +614,18 @@ const Date = struct {
}; };
pub fn parseTimeDigits(text: *const [2]u8, min: u8, max: u8) !u8 { pub fn parseTimeDigits(text: *const [2]u8, min: u8, max: u8) !u8 {
const result = if (use_vectors) result: {
const nn: @Vector(2, u16) = .{ text[0], text[1] }; const nn: @Vector(2, u16) = .{ text[0], text[1] };
const zero: @Vector(2, u16) = .{ '0', '0' }; const zero: @Vector(2, u16) = .{ '0', '0' };
const mm: @Vector(2, u16) = .{ 10, 1 }; const mm: @Vector(2, u16) = .{ 10, 1 };
const result = @reduce(.Add, (nn -% zero) *% mm); break :result @reduce(.Add, (nn -% zero) *% mm);
} else std.fmt.parseInt(u8, text, 10) catch return error.CertificateTimeInvalid;
if (result < min) return error.CertificateTimeInvalid; if (result < min) return error.CertificateTimeInvalid;
if (result > max) return error.CertificateTimeInvalid; if (result > max) return error.CertificateTimeInvalid;
return @truncate(result); return @truncate(result);
} }
test parseTimeDigits { test parseTimeDigits {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const expectEqual = std.testing.expectEqual; const expectEqual = std.testing.expectEqual;
try expectEqual(@as(u8, 0), try parseTimeDigits("00", 0, 99)); try expectEqual(@as(u8, 0), try parseTimeDigits("00", 0, 99));
try expectEqual(@as(u8, 99), try parseTimeDigits("99", 0, 99)); try expectEqual(@as(u8, 99), try parseTimeDigits("99", 0, 99));
@ -638,17 +638,17 @@ test parseTimeDigits {
} }
pub fn parseYear4(text: *const [4]u8) !u16 { pub fn parseYear4(text: *const [4]u8) !u16 {
const result = if (use_vectors) result: {
const nnnn: @Vector(4, u32) = .{ text[0], text[1], text[2], text[3] }; const nnnn: @Vector(4, u32) = .{ text[0], text[1], text[2], text[3] };
const zero: @Vector(4, u32) = .{ '0', '0', '0', '0' }; const zero: @Vector(4, u32) = .{ '0', '0', '0', '0' };
const mmmm: @Vector(4, u32) = .{ 1000, 100, 10, 1 }; const mmmm: @Vector(4, u32) = .{ 1000, 100, 10, 1 };
const result = @reduce(.Add, (nnnn -% zero) *% mmmm); break :result @reduce(.Add, (nnnn -% zero) *% mmmm);
} else std.fmt.parseInt(u16, text, 10) catch return error.CertificateTimeInvalid;
if (result > 9999) return error.CertificateTimeInvalid; if (result > 9999) return error.CertificateTimeInvalid;
return @truncate(result); return @truncate(result);
} }
test parseYear4 { test parseYear4 {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const expectEqual = std.testing.expectEqual; const expectEqual = std.testing.expectEqual;
try expectEqual(@as(u16, 0), try parseYear4("0000")); try expectEqual(@as(u16, 0), try parseYear4("0000"));
try expectEqual(@as(u16, 9999), try parseYear4("9999")); try expectEqual(@as(u16, 9999), try parseYear4("9999"));
@ -1124,4 +1124,4 @@ pub const rsa = struct {
} }
}; };
const builtin = @import("builtin"); const use_vectors = @import("builtin").zig_backend != .stage2_x86_64;

View File

@ -318,8 +318,6 @@ const MapContext = struct {
test "scan for OS-provided certificates" { test "scan for OS-provided certificates" {
if (builtin.os.tag == .wasi) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var bundle: Bundle = .{}; var bundle: Bundle = .{};
defer bundle.deinit(std.testing.allocator); defer bundle.deinit(std.testing.allocator);

View File

@ -28,8 +28,6 @@ pub const Aes128 = impl.Aes128;
pub const Aes256 = impl.Aes256; pub const Aes256 = impl.Aes256;
test "ctr" { test "ctr" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
// NIST SP 800-38A pp 55-58 // NIST SP 800-38A pp 55-58
const ctr = @import("modes.zig").ctr; const ctr = @import("modes.zig").ctr;

View File

@ -1,5 +1,4 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert; const assert = std.debug.assert;
const crypto = std.crypto; const crypto = std.crypto;
const debug = std.debug; const debug = std.debug;
@ -42,7 +41,7 @@ fn AesGcm(comptime Aes: anytype) type {
mac.pad(); mac.pad();
mem.writeInt(u32, j[nonce_length..][0..4], 2, .big); mem.writeInt(u32, j[nonce_length..][0..4], 2, .big);
modes.ctr(@TypeOf(aes), aes, c, m, j, std.builtin.Endian.big); modes.ctr(@TypeOf(aes), aes, c, m, j, .big);
mac.update(c[0..m.len][0..]); mac.update(c[0..m.len][0..]);
mac.pad(); mac.pad();
@ -104,7 +103,7 @@ fn AesGcm(comptime Aes: anytype) type {
} }
mem.writeInt(u32, j[nonce_length..][0..4], 2, .big); mem.writeInt(u32, j[nonce_length..][0..4], 2, .big);
modes.ctr(@TypeOf(aes), aes, m, c, j, std.builtin.Endian.big); modes.ctr(@TypeOf(aes), aes, m, c, j, .big);
} }
}; };
} }
@ -113,8 +112,6 @@ const htest = @import("test.zig");
const testing = std.testing; const testing = std.testing;
test "Aes256Gcm - Empty message and no associated data" { test "Aes256Gcm - Empty message and no associated data" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length;
const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length;
const ad = ""; const ad = "";
@ -127,8 +124,6 @@ test "Aes256Gcm - Empty message and no associated data" {
} }
test "Aes256Gcm - Associated data only" { test "Aes256Gcm - Associated data only" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length;
const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length;
const m = ""; const m = "";
@ -141,8 +136,6 @@ test "Aes256Gcm - Associated data only" {
} }
test "Aes256Gcm - Message only" { test "Aes256Gcm - Message only" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length;
const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length;
const m = "Test with message only"; const m = "Test with message only";
@ -160,8 +153,6 @@ test "Aes256Gcm - Message only" {
} }
test "Aes256Gcm - Message and associated data" { test "Aes256Gcm - Message and associated data" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length;
const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length;
const m = "Test with message"; const m = "Test with message";

View File

@ -896,8 +896,6 @@ test "kdf" {
} }
test "phc format hasher" { test "phc format hasher" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const password = "testpass"; const password = "testpass";
@ -913,8 +911,6 @@ test "phc format hasher" {
} }
test "password hash and password verify" { test "password hash and password verify" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const allocator = std.testing.allocator; const allocator = std.testing.allocator;
const password = "testpass"; const password = "testpass";

View File

@ -1,5 +1,4 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const base64 = std.base64; const base64 = std.base64;
const crypto = std.crypto; const crypto = std.crypto;
const debug = std.debug; const debug = std.debug;
@ -754,8 +753,6 @@ pub fn strVerify(
} }
test "bcrypt codec" { test "bcrypt codec" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var salt: [salt_length]u8 = undefined; var salt: [salt_length]u8 = undefined;
crypto.random.bytes(&salt); crypto.random.bytes(&salt);
var salt_str: [salt_str_length]u8 = undefined; var salt_str: [salt_str_length]u8 = undefined;
@ -766,8 +763,6 @@ test "bcrypt codec" {
} }
test "bcrypt crypt format" { test "bcrypt crypt format" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var hash_options = HashOptions{ var hash_options = HashOptions{
.params = .{ .rounds_log = 5 }, .params = .{ .rounds_log = 5 },
.encoding = .crypt, .encoding = .crypt,
@ -808,8 +803,6 @@ test "bcrypt crypt format" {
} }
test "bcrypt phc format" { test "bcrypt phc format" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var hash_options = HashOptions{ var hash_options = HashOptions{
.params = .{ .rounds_log = 5 }, .params = .{ .rounds_log = 5 },
.encoding = .phc, .encoding = .phc,

View File

@ -1,5 +1,4 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const crypto = std.crypto; const crypto = std.crypto;
const mem = std.mem; const mem = std.mem;
@ -94,8 +93,6 @@ pub fn Cmac(comptime BlockCipher: type) type {
const testing = std.testing; const testing = std.testing;
test "CmacAes128 - Example 1: len = 0" { test "CmacAes128 - Example 1: len = 0" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key = [_]u8{ const key = [_]u8{
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
}; };
@ -109,8 +106,6 @@ test "CmacAes128 - Example 1: len = 0" {
} }
test "CmacAes128 - Example 2: len = 16" { test "CmacAes128 - Example 2: len = 16" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key = [_]u8{ const key = [_]u8{
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
}; };
@ -126,8 +121,6 @@ test "CmacAes128 - Example 2: len = 16" {
} }
test "CmacAes128 - Example 3: len = 40" { test "CmacAes128 - Example 3: len = 40" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key = [_]u8{ const key = [_]u8{
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
}; };
@ -145,8 +138,6 @@ test "CmacAes128 - Example 3: len = 40" {
} }
test "CmacAes128 - Example 4: len = 64" { test "CmacAes128 - Example 4: len = 64" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key = [_]u8{ const key = [_]u8{
0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
}; };

View File

@ -373,7 +373,6 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
test "ECDSA - Basic operations over EcdsaP384Sha384" { test "ECDSA - Basic operations over EcdsaP384Sha384" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = EcdsaP384Sha384; const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null); const kp = try Scheme.KeyPair.create(null);
@ -407,7 +406,6 @@ test "ECDSA - Basic operations over Secp256k1" {
test "ECDSA - Basic operations over EcdsaP384Sha256" { test "ECDSA - Basic operations over EcdsaP384Sha256" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
const kp = try Scheme.KeyPair.create(null); const kp = try Scheme.KeyPair.create(null);
@ -424,7 +422,6 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" { test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256); const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
// zig fmt: off // zig fmt: off
@ -469,7 +466,6 @@ const TestVector = struct {
test "ECDSA - Test vectors from Project Wycheproof" { test "ECDSA - Test vectors from Project Wycheproof" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const vectors = [_]TestVector{ const vectors = [_]TestVector{
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid }, .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
@ -884,7 +880,6 @@ fn tvTry(vector: TestVector) !void {
test "ECDSA - Sec1 encoding/decoding" { test "ECDSA - Sec1 encoding/decoding" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = EcdsaP384Sha384; const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null); const kp = try Scheme.KeyPair.create(null);

View File

@ -422,8 +422,6 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
const htest = @import("test.zig"); const htest = @import("test.zig");
test "ghash" { test "ghash" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const key = [_]u8{0x42} ** 16; const key = [_]u8{0x42} ** 16;
const m = [_]u8{0x69} ** 256; const m = [_]u8{0x69} ** 256;
@ -441,8 +439,6 @@ test "ghash" {
} }
test "ghash2" { test "ghash2" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var key: [16]u8 = undefined; var key: [16]u8 = undefined;
var i: usize = 0; var i: usize = 0;
while (i < key.len) : (i += 1) { while (i < key.len) : (i += 1) {

View File

@ -478,7 +478,5 @@ pub const AffineCoordinates = struct {
}; };
test { test {
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
_ = @import("tests/p256.zig"); _ = @import("tests/p256.zig");
} }

View File

@ -1,7 +1,6 @@
// https://github.com/P-H-C/phc-string-format // https://github.com/P-H-C/phc-string-format
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin");
const fmt = std.fmt; const fmt = std.fmt;
const io = std.io; const io = std.io;
const mem = std.mem; const mem = std.mem;
@ -264,8 +263,6 @@ fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } {
} }
test "phc format - encoding/decoding" { test "phc format - encoding/decoding" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Input = struct { const Input = struct {
str: []const u8, str: []const u8,
HashResult: type, HashResult: type,

View File

@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
return; return;
}, },
// C backend doesn't currently support passing vectors to inline asm. // C backend doesn't currently support passing vectors to inline asm.
.x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) { .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 })) {
var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] }; var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] }; var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
const s_v = @as(*[16]v4u32, @ptrCast(&s)); const s_v = @as(*[16]v4u32, @ptrCast(&s));

View File

@ -83,8 +83,6 @@ test "fmt.parseFloat #11169" {
} }
test "fmt.parseFloat hex.special" { test "fmt.parseFloat hex.special" {
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testing.expect(math.isNan(try parseFloat(f32, "nAn"))); try testing.expect(math.isNan(try parseFloat(f32, "nAn")));
try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf"))); try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf")));
try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf"))); try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf")));

View File

@ -2,6 +2,7 @@ const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const mem = std.mem; const mem = std.mem;
const expectEqual = std.testing.expectEqual; const expectEqual = std.testing.expectEqual;
const native_endian = builtin.cpu.arch.endian();
const rotl = std.math.rotl; const rotl = std.math.rotl;
@ -472,7 +473,7 @@ pub const XxHash3 = struct {
} }
inline fn swap(x: anytype) @TypeOf(x) { inline fn swap(x: anytype) @TypeOf(x) {
return if (builtin.cpu.arch.endian() == .big) @byteSwap(x) else x; return if (native_endian == .big) @byteSwap(x) else x;
} }
inline fn disableAutoVectorization(x: anytype) void { inline fn disableAutoVectorization(x: anytype) void {

View File

@ -9,6 +9,7 @@ const net = std.net;
const Uri = std.Uri; const Uri = std.Uri;
const Allocator = mem.Allocator; const Allocator = mem.Allocator;
const assert = std.debug.assert; const assert = std.debug.assert;
const use_vectors = builtin.zig_backend != .stage2_x86_64;
const Client = @This(); const Client = @This();
const proto = @import("protocol.zig"); const proto = @import("protocol.zig");
@ -408,7 +409,7 @@ pub const Response = struct {
else => return error.HttpHeadersInvalid, else => return error.HttpHeadersInvalid,
}; };
if (first_line[8] != ' ') return error.HttpHeadersInvalid; if (first_line[8] != ' ') return error.HttpHeadersInvalid;
const status = @as(http.Status, @enumFromInt(parseInt3(first_line[9..12].*))); const status: http.Status = @enumFromInt(parseInt3(first_line[9..12]));
const reason = mem.trimLeft(u8, first_line[12..], " "); const reason = mem.trimLeft(u8, first_line[12..], " ");
res.version = version; res.version = version;
@ -481,20 +482,24 @@ pub const Response = struct {
} }
inline fn int64(array: *const [8]u8) u64 { inline fn int64(array: *const [8]u8) u64 {
return @as(u64, @bitCast(array.*)); return @bitCast(array.*);
} }
fn parseInt3(nnn: @Vector(3, u8)) u10 { fn parseInt3(text: *const [3]u8) u10 {
if (use_vectors) {
const nnn: @Vector(3, u8) = text.*;
const zero: @Vector(3, u8) = .{ '0', '0', '0' }; const zero: @Vector(3, u8) = .{ '0', '0', '0' };
const mmm: @Vector(3, u10) = .{ 100, 10, 1 }; const mmm: @Vector(3, u10) = .{ 100, 10, 1 };
return @reduce(.Add, @as(@Vector(3, u10), nnn -% zero) *% mmm); return @reduce(.Add, @as(@Vector(3, u10), nnn -% zero) *% mmm);
} }
return std.fmt.parseInt(u10, text, 10) catch unreachable;
}
test parseInt3 { test parseInt3 {
const expectEqual = testing.expectEqual; const expectEqual = testing.expectEqual;
try expectEqual(@as(u10, 0), parseInt3("000".*)); try expectEqual(@as(u10, 0), parseInt3("000"));
try expectEqual(@as(u10, 418), parseInt3("418".*)); try expectEqual(@as(u10, 418), parseInt3("418"));
try expectEqual(@as(u10, 999), parseInt3("999".*)); try expectEqual(@as(u10, 999), parseInt3("999"));
} }
version: http.Version, version: http.Version,
@ -1588,7 +1593,8 @@ test {
if (builtin.os.tag == .wasi) return error.SkipZigTest; if (builtin.os.tag == .wasi) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64 and
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest;
std.testing.refAllDecls(@This()); std.testing.refAllDecls(@This());
} }

View File

@ -736,8 +736,6 @@ test "HTTP server handles a chunked transfer coding request" {
return error.SkipZigTest; return error.SkipZigTest;
} }
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const native_endian = comptime builtin.cpu.arch.endian(); const native_endian = comptime builtin.cpu.arch.endian();
if (builtin.zig_backend == .stage2_llvm and native_endian == .big) { if (builtin.zig_backend == .stage2_llvm and native_endian == .big) {
// https://github.com/ziglang/zig/issues/13782 // https://github.com/ziglang/zig/issues/13782

View File

@ -1,8 +1,10 @@
const std = @import("../std.zig"); const std = @import("../std.zig");
const builtin = @import("builtin");
const testing = std.testing; const testing = std.testing;
const mem = std.mem; const mem = std.mem;
const assert = std.debug.assert; const assert = std.debug.assert;
const use_vectors = builtin.zig_backend != .stage2_x86_64;
pub const State = enum { pub const State = enum {
/// Begin header parsing states. /// Begin header parsing states.
@ -83,7 +85,7 @@ pub const HeadersParser = struct {
/// first byte of content is located at `bytes[result]`. /// first byte of content is located at `bytes[result]`.
pub fn findHeadersEnd(r: *HeadersParser, bytes: []const u8) u32 { pub fn findHeadersEnd(r: *HeadersParser, bytes: []const u8) u32 {
const vector_len: comptime_int = @max(std.simd.suggestVectorSize(u8) orelse 1, 8); const vector_len: comptime_int = @max(std.simd.suggestVectorSize(u8) orelse 1, 8);
const len = @as(u32, @intCast(bytes.len)); const len: u32 = @intCast(bytes.len);
var index: u32 = 0; var index: u32 = 0;
while (true) { while (true) {
@ -175,18 +177,27 @@ pub const HeadersParser = struct {
continue; continue;
}, },
else => { else => {
const chunk = bytes[index..][0..vector_len];
const matches = if (use_vectors) matches: {
const Vector = @Vector(vector_len, u8); const Vector = @Vector(vector_len, u8);
// const BoolVector = @Vector(vector_len, bool); // const BoolVector = @Vector(vector_len, bool);
const BitVector = @Vector(vector_len, u1); const BitVector = @Vector(vector_len, u1);
const SizeVector = @Vector(vector_len, u8); const SizeVector = @Vector(vector_len, u8);
const chunk = bytes[index..][0..vector_len];
const v: Vector = chunk.*; const v: Vector = chunk.*;
const matches_r = @as(BitVector, @bitCast(v == @as(Vector, @splat('\r')))); const matches_r: BitVector = @bitCast(v == @as(Vector, @splat('\r')));
const matches_n = @as(BitVector, @bitCast(v == @as(Vector, @splat('\n')))); const matches_n: BitVector = @bitCast(v == @as(Vector, @splat('\n')));
const matches_or: SizeVector = matches_r | matches_n; const matches_or: SizeVector = matches_r | matches_n;
const matches = @reduce(.Add, matches_or); break :matches @reduce(.Add, matches_or);
} else matches: {
var matches: u8 = 0;
for (chunk) |byte| switch (byte) {
'\r', '\n' => matches += 1,
else => {},
};
break :matches matches;
};
switch (matches) { switch (matches) {
0 => {}, 0 => {},
1 => switch (chunk[vector_len - 1]) { 1 => switch (chunk[vector_len - 1]) {

View File

@ -492,8 +492,6 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T {
} }
test "shl" { test "shl" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) {
// https://github.com/ziglang/zig/issues/12012 // https://github.com/ziglang/zig/issues/12012
return error.SkipZigTest; return error.SkipZigTest;
@ -539,8 +537,6 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T {
} }
test "shr" { test "shr" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) {
// https://github.com/ziglang/zig/issues/12012 // https://github.com/ziglang/zig/issues/12012
return error.SkipZigTest; return error.SkipZigTest;
@ -587,8 +583,6 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T {
} }
test "rotr" { test "rotr" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) {
// https://github.com/ziglang/zig/issues/12012 // https://github.com/ziglang/zig/issues/12012
return error.SkipZigTest; return error.SkipZigTest;
@ -634,8 +628,6 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T {
} }
test "rotl" { test "rotl" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) {
// https://github.com/ziglang/zig/issues/12012 // https://github.com/ziglang/zig/issues/12012
return error.SkipZigTest; return error.SkipZigTest;
@ -764,8 +756,6 @@ pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {
} }
test "divTrunc" { test "divTrunc" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testDivTrunc(); try testDivTrunc();
try comptime testDivTrunc(); try comptime testDivTrunc();
} }
@ -790,8 +780,6 @@ pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {
} }
test "divFloor" { test "divFloor" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testDivFloor(); try testDivFloor();
try comptime testDivFloor(); try comptime testDivFloor();
} }
@ -829,8 +817,6 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
} }
test "divCeil" { test "divCeil" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testDivCeil(); try testDivCeil();
try comptime testDivCeil(); try comptime testDivCeil();
} }
@ -875,8 +861,6 @@ pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {
} }
test "divExact" { test "divExact" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testDivExact(); try testDivExact();
try comptime testDivExact(); try comptime testDivExact();
} }
@ -903,8 +887,6 @@ pub fn mod(comptime T: type, numerator: T, denominator: T) !T {
} }
test "mod" { test "mod" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testMod(); try testMod();
try comptime testMod(); try comptime testMod();
} }
@ -931,8 +913,6 @@ pub fn rem(comptime T: type, numerator: T, denominator: T) !T {
} }
test "rem" { test "rem" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testRem(); try testRem();
try comptime testRem(); try comptime testRem();
} }
@ -1285,7 +1265,8 @@ pub fn lerp(a: anytype, b: anytype, t: anytype) @TypeOf(a, b, t) {
} }
test "lerp" { test "lerp" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64 and
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .fma)) return error.SkipZigTest;
try testing.expectEqual(@as(f64, 75), lerp(50, 100, 0.5)); try testing.expectEqual(@as(f64, 75), lerp(50, 100, 0.5));
try testing.expectEqual(@as(f32, 43.75), lerp(50, 25, 0.25)); try testing.expectEqual(@as(f32, 43.75), lerp(50, 25, 0.25));

View File

@ -1318,7 +1318,7 @@ pub const Mutable = struct {
/// ///
/// `limbs_buffer` is used for temporary storage. /// `limbs_buffer` is used for temporary storage.
/// The amount required is given by `calcPowLimbsBufferLen`. /// The amount required is given by `calcPowLimbsBufferLen`.
pub fn pow(r: *Mutable, a: Const, b: u32, limbs_buffer: []Limb) !void { pub fn pow(r: *Mutable, a: Const, b: u32, limbs_buffer: []Limb) void {
assert(r.limbs.ptr != a.limbs.ptr); // illegal aliasing assert(r.limbs.ptr != a.limbs.ptr); // illegal aliasing
// Handle all the trivial cases first // Handle all the trivial cases first
@ -3213,7 +3213,7 @@ pub const Managed = struct {
var m = try Managed.initCapacity(rma.allocator, needed_limbs); var m = try Managed.initCapacity(rma.allocator, needed_limbs);
errdefer m.deinit(); errdefer m.deinit();
var m_mut = m.toMutable(); var m_mut = m.toMutable();
try m_mut.pow(a.toConst(), b, limbs_buffer); m_mut.pow(a.toConst(), b, limbs_buffer);
m.setMetadata(m_mut.positive, m_mut.len); m.setMetadata(m_mut.positive, m_mut.len);
rma.deinit(); rma.deinit();
@ -3221,7 +3221,7 @@ pub const Managed = struct {
} else { } else {
try rma.ensureCapacity(needed_limbs); try rma.ensureCapacity(needed_limbs);
var rma_mut = rma.toMutable(); var rma_mut = rma.toMutable();
try rma_mut.pow(a.toConst(), b, limbs_buffer); rma_mut.pow(a.toConst(), b, limbs_buffer);
rma.setMetadata(rma_mut.positive, rma_mut.len); rma.setMetadata(rma_mut.positive, rma_mut.len);
} }
} }

View File

@ -2568,8 +2568,6 @@ test "big.int const to managed" {
} }
test "big.int pow" { test "big.int pow" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
{ {
var a = try Managed.initSet(testing.allocator, -3); var a = try Managed.initSet(testing.allocator, -3);
defer a.deinit(); defer a.deinit();
@ -2763,8 +2761,6 @@ fn popCountTest(val: *const Managed, bit_count: usize, expected: usize) !void {
} }
test "big int conversion read/write twos complement" { test "big int conversion read/write twos complement" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, (1 << 493) - 1); var a = try Managed.initSet(testing.allocator, (1 << 493) - 1);
defer a.deinit(); defer a.deinit();
var b = try Managed.initSet(testing.allocator, (1 << 493) - 1); var b = try Managed.initSet(testing.allocator, (1 << 493) - 1);
@ -2863,8 +2859,6 @@ test "big int write twos complement +/- zero" {
} }
test "big int conversion write twos complement with padding" { test "big int conversion write twos complement with padding" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff); var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff);
defer a.deinit(); defer a.deinit();

View File

@ -315,8 +315,6 @@ pub fn zeroes(comptime T: type) T {
} }
test "zeroes" { test "zeroes" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const C_struct = extern struct { const C_struct = extern struct {
x: u32, x: u32,
y: u32 align(128), y: u32 align(128),
@ -4342,8 +4340,6 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice
} }
test "read/write(Var)PackedInt" { test "read/write(Var)PackedInt" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
switch (builtin.cpu.arch) { switch (builtin.cpu.arch) {
// This test generates too much code to execute on WASI. // This test generates too much code to execute on WASI.
// LLVM backend fails with "too many locals: locals exceed maximum" // LLVM backend fails with "too many locals: locals exceed maximum"

View File

@ -60,7 +60,7 @@ test "parse and render IPv6 addresses" {
} }
test "invalid but parseable IPv6 scope ids" { test "invalid but parseable IPv6 scope ids" {
if (builtin.os.tag != .linux or comptime !builtin.os.tag.isDarwin()) { if (builtin.os.tag != .linux and comptime !builtin.os.tag.isDarwin()) {
// Currently, resolveIp6 with alphanumerical scope IDs only works on Linux. // Currently, resolveIp6 with alphanumerical scope IDs only works on Linux.
// TODO Make this test pass on other operating systems. // TODO Make this test pass on other operating systems.
return error.SkipZigTest; return error.SkipZigTest;

View File

@ -46,8 +46,6 @@ fn incr() void {
} }
test "Once executes its function just once" { test "Once executes its function just once" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.single_threaded) { if (builtin.single_threaded) {
global_once.call(); global_once.call();
global_once.call(); global_once.call();

View File

@ -375,8 +375,6 @@ fn testThreadIdFn(thread_id: *Thread.Id) void {
test "std.Thread.getCurrentId" { test "std.Thread.getCurrentId" {
if (builtin.single_threaded) return error.SkipZigTest; if (builtin.single_threaded) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var thread_current_id: Thread.Id = undefined; var thread_current_id: Thread.Id = undefined;
const thread = try Thread.spawn(.{}, testThreadIdFn, .{&thread_current_id}); const thread = try Thread.spawn(.{}, testThreadIdFn, .{&thread_current_id});
thread.join(); thread.join();
@ -420,8 +418,6 @@ test "cpu count" {
test "thread local storage" { test "thread local storage" {
if (builtin.single_threaded) return error.SkipZigTest; if (builtin.single_threaded) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const thread1 = try Thread.spawn(.{}, testTls, .{}); const thread1 = try Thread.spawn(.{}, testTls, .{});
const thread2 = try Thread.spawn(.{}, testTls, .{}); const thread2 = try Thread.spawn(.{}, testTls, .{});
try testTls(); try testTls();

View File

@ -1,5 +1,4 @@
const std = @import("../std.zig"); const std = @import("../std.zig");
const builtin = @import("builtin");
const math = std.math; const math = std.math;
const DefaultPrng = std.rand.DefaultPrng; const DefaultPrng = std.rand.DefaultPrng;
const Random = std.rand.Random; const Random = std.rand.Random;
@ -200,8 +199,6 @@ fn testRandomIntLessThan() !void {
} }
test "Random intAtMost" { test "Random intAtMost" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
@setEvalBranchQuota(10000); @setEvalBranchQuota(10000);
try testRandomIntAtMost(); try testRandomIntAtMost();
try comptime testRandomIntAtMost(); try comptime testRandomIntAtMost();
@ -242,8 +239,6 @@ fn testRandomIntAtMost() !void {
} }
test "Random Biased" { test "Random Biased" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
var prng = DefaultPrng.init(0); var prng = DefaultPrng.init(0);
const random = prng.random(); const random = prng.random();
// Not thoroughly checking the logic here. // Not thoroughly checking the logic here.
@ -452,8 +447,6 @@ test "CSPRNG" {
} }
test "Random weightedIndex" { test "Random weightedIndex" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
// Make sure weightedIndex works for various integers and floats // Make sure weightedIndex works for various integers and floats
inline for (.{ u64, i4, f32, f64 }) |T| { inline for (.{ u64, i4, f32, f64 }) |T| {
var prng = DefaultPrng.init(0); var prng = DefaultPrng.init(0);

View File

@ -1,5 +1,4 @@
const std = @import("../std.zig"); const std = @import("../std.zig");
const builtin = @import("builtin");
pub const Token = struct { pub const Token = struct {
tag: Tag, tag: Tag,
@ -1450,8 +1449,6 @@ test "chars" {
} }
test "invalid token characters" { test "invalid token characters" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testTokenize("#", &.{.invalid}); try testTokenize("#", &.{.invalid});
try testTokenize("`", &.{.invalid}); try testTokenize("`", &.{.invalid});
try testTokenize("'c", &.{.invalid}); try testTokenize("'c", &.{.invalid});
@ -1571,8 +1568,6 @@ test "pipe and then invalid" {
} }
test "line comment and doc comment" { test "line comment and doc comment" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testTokenize("//", &.{}); try testTokenize("//", &.{});
try testTokenize("// a / b", &.{}); try testTokenize("// a / b", &.{});
try testTokenize("// /", &.{}); try testTokenize("// /", &.{});
@ -1647,8 +1642,6 @@ test "range literals" {
} }
test "number literals decimal" { test "number literals decimal" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testTokenize("0", &.{.number_literal}); try testTokenize("0", &.{.number_literal});
try testTokenize("1", &.{.number_literal}); try testTokenize("1", &.{.number_literal});
try testTokenize("2", &.{.number_literal}); try testTokenize("2", &.{.number_literal});
@ -1897,8 +1890,6 @@ test "invalid token with unfinished escape right before eof" {
} }
test "saturating operators" { test "saturating operators" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
try testTokenize("<<", &.{.angle_bracket_angle_bracket_left}); try testTokenize("<<", &.{.angle_bracket_angle_bracket_left});
try testTokenize("<<|", &.{.angle_bracket_angle_bracket_left_pipe}); try testTokenize("<<|", &.{.angle_bracket_angle_bracket_left_pipe});
try testTokenize("<<|=", &.{.angle_bracket_angle_bracket_left_pipe_equal}); try testTokenize("<<|=", &.{.angle_bracket_angle_bracket_left_pipe_equal});

View File

@ -1121,7 +1121,9 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols; const include_compiler_rt = options.want_compiler_rt orelse needs_c_symbols;
const must_single_thread = target_util.isSingleThreaded(options.target); const must_single_thread = target_util.isSingleThreaded(options.target);
const single_threaded = options.single_threaded orelse must_single_thread; const single_threaded = options.single_threaded orelse must_single_thread or
// x86_64 codegen doesn't support TLV for most object formats
(!use_llvm and options.target.cpu.arch == .x86_64 and options.target.ofmt != .macho);
if (must_single_thread and !single_threaded) { if (must_single_thread and !single_threaded) {
return error.TargetRequiresSingleThreaded; return error.TargetRequiresSingleThreaded;
} }

File diff suppressed because it is too large Load Diff

View File

@ -410,6 +410,8 @@ pub const Mnemonic = enum {
vfmadd132ps, vfmadd213ps, vfmadd231ps, vfmadd132ps, vfmadd213ps, vfmadd231ps,
vfmadd132sd, vfmadd213sd, vfmadd231sd, vfmadd132sd, vfmadd213sd, vfmadd231sd,
vfmadd132ss, vfmadd213ss, vfmadd231ss, vfmadd132ss, vfmadd213ss, vfmadd231ss,
// AVX2
vpbroadcastb, vpbroadcastd, vpbroadcasti128, vpbroadcastq, vpbroadcastw,
// zig fmt: on // zig fmt: on
}; };
@ -444,7 +446,7 @@ pub const Op = enum {
moffs, moffs,
sreg, sreg,
st, mm, mm_m64, st, mm, mm_m64,
xmm0, xmm, xmm_m32, xmm_m64, xmm_m128, xmm0, xmm, xmm_m8, xmm_m16, xmm_m32, xmm_m64, xmm_m128,
ymm, ymm_m256, ymm, ymm_m256,
// zig fmt: on // zig fmt: on
@ -534,7 +536,7 @@ pub const Op = enum {
.eax, .r32, .rm32, .r32_m16 => unreachable, .eax, .r32, .rm32, .r32_m16 => unreachable,
.rax, .r64, .rm64, .r64_m16 => unreachable, .rax, .r64, .rm64, .r64_m16 => unreachable,
.st, .mm, .mm_m64 => unreachable, .st, .mm, .mm_m64 => unreachable,
.xmm0, .xmm, .xmm_m32, .xmm_m64, .xmm_m128 => unreachable, .xmm0, .xmm, .xmm_m8, .xmm_m16, .xmm_m32, .xmm_m64, .xmm_m128 => unreachable,
.ymm, .ymm_m256 => unreachable, .ymm, .ymm_m256 => unreachable,
.m8, .m16, .m32, .m64, .m80, .m128, .m256 => unreachable, .m8, .m16, .m32, .m64, .m80, .m128, .m256 => unreachable,
.unity => 1, .unity => 1,
@ -556,7 +558,7 @@ pub const Op = enum {
.eax, .r32, .rm32, .r32_m8, .r32_m16 => 32, .eax, .r32, .rm32, .r32_m8, .r32_m16 => 32,
.rax, .r64, .rm64, .r64_m16, .mm, .mm_m64 => 64, .rax, .r64, .rm64, .r64_m16, .mm, .mm_m64 => 64,
.st => 80, .st => 80,
.xmm0, .xmm, .xmm_m32, .xmm_m64, .xmm_m128 => 128, .xmm0, .xmm, .xmm_m8, .xmm_m16, .xmm_m32, .xmm_m64, .xmm_m128 => 128,
.ymm, .ymm_m256 => 256, .ymm, .ymm_m256 => 256,
}; };
} }
@ -568,8 +570,8 @@ pub const Op = enum {
.rel8, .rel16, .rel32 => unreachable, .rel8, .rel16, .rel32 => unreachable,
.al, .cl, .r8, .ax, .r16, .eax, .r32, .rax, .r64 => unreachable, .al, .cl, .r8, .ax, .r16, .eax, .r32, .rax, .r64 => unreachable,
.st, .mm, .xmm0, .xmm, .ymm => unreachable, .st, .mm, .xmm0, .xmm, .ymm => unreachable,
.m8, .rm8, .r32_m8 => 8, .m8, .rm8, .r32_m8, .xmm_m8 => 8,
.m16, .rm16, .r32_m16, .r64_m16 => 16, .m16, .rm16, .r32_m16, .r64_m16, .xmm_m16 => 16,
.m32, .rm32, .xmm_m32 => 32, .m32, .rm32, .xmm_m32 => 32,
.m64, .rm64, .mm_m64, .xmm_m64 => 64, .m64, .rm64, .mm_m64, .xmm_m64 => 64,
.m80 => 80, .m80 => 80,
@ -600,7 +602,7 @@ pub const Op = enum {
.rm8, .rm16, .rm32, .rm64, .rm8, .rm16, .rm32, .rm64,
.r32_m8, .r32_m16, .r64_m16, .r32_m8, .r32_m16, .r64_m16,
.st, .mm, .mm_m64, .st, .mm, .mm_m64,
.xmm0, .xmm, .xmm_m32, .xmm_m64, .xmm_m128, .xmm0, .xmm, .xmm_m8, .xmm_m16, .xmm_m32, .xmm_m64, .xmm_m128,
.ymm, .ymm_m256, .ymm, .ymm_m256,
=> true, => true,
else => false, else => false,
@ -629,7 +631,7 @@ pub const Op = enum {
.m8, .m16, .m32, .m64, .m80, .m128, .m256, .m8, .m16, .m32, .m64, .m80, .m128, .m256,
.m, .m,
.mm_m64, .mm_m64,
.xmm_m32, .xmm_m64, .xmm_m128, .xmm_m8, .xmm_m16, .xmm_m32, .xmm_m64, .xmm_m128,
.ymm_m256, .ymm_m256,
=> true, => true,
else => false, else => false,
@ -654,7 +656,7 @@ pub const Op = enum {
.sreg => .segment, .sreg => .segment,
.st => .x87, .st => .x87,
.mm, .mm_m64 => .mmx, .mm, .mm_m64 => .mmx,
.xmm0, .xmm, .xmm_m32, .xmm_m64, .xmm_m128 => .sse, .xmm0, .xmm, .xmm_m8, .xmm_m16, .xmm_m32, .xmm_m64, .xmm_m128 => .sse,
.ymm, .ymm_m256 => .sse, .ymm, .ymm_m256 => .sse,
}; };
} }

View File

@ -255,6 +255,8 @@ pub const Inst = struct {
vp_q, vp_q,
/// VEX-Encoded Packed ___ Double Quadword /// VEX-Encoded Packed ___ Double Quadword
vp_dq, vp_dq,
/// VEX-Encoded Packed ___ Integer Data
vp_i128,
/// VEX-Encoded ___ Scalar Single-Precision Values /// VEX-Encoded ___ Scalar Single-Precision Values
v_ss, v_ss,
/// VEX-Encoded ___ Packed Single-Precision Values /// VEX-Encoded ___ Packed Single-Precision Values

View File

@ -237,7 +237,7 @@ pub const Register = enum(u7) {
return @intCast(@intFromEnum(reg) - base); return @intCast(@intFromEnum(reg) - base);
} }
pub fn bitSize(reg: Register) u64 { pub fn bitSize(reg: Register) u10 {
return switch (@intFromEnum(reg)) { return switch (@intFromEnum(reg)) {
// zig fmt: off // zig fmt: off
@intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => 64, @intFromEnum(Register.rax) ... @intFromEnum(Register.r15) => 64,

View File

@ -1742,6 +1742,16 @@ pub const table = [_]Entry{
.{ .vpandn, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0xdf }, 0, .vex_256_wig, .avx2 }, .{ .vpandn, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0xdf }, 0, .vex_256_wig, .avx2 },
.{ .vpbroadcastb, .rm, &.{ .xmm, .xmm_m8 }, &.{ 0x66, 0x0f, 0x38, 0x78 }, 0, .vex_128_w0, .avx2 },
.{ .vpbroadcastb, .rm, &.{ .ymm, .xmm_m8 }, &.{ 0x66, 0x0f, 0x38, 0x78 }, 0, .vex_256_w0, .avx2 },
.{ .vpbroadcastw, .rm, &.{ .xmm, .xmm_m16 }, &.{ 0x66, 0x0f, 0x38, 0x79 }, 0, .vex_128_w0, .avx2 },
.{ .vpbroadcastw, .rm, &.{ .ymm, .xmm_m16 }, &.{ 0x66, 0x0f, 0x38, 0x79 }, 0, .vex_256_w0, .avx2 },
.{ .vpbroadcastd, .rm, &.{ .xmm, .xmm_m32 }, &.{ 0x66, 0x0f, 0x38, 0x58 }, 0, .vex_128_w0, .avx2 },
.{ .vpbroadcastd, .rm, &.{ .ymm, .xmm_m32 }, &.{ 0x66, 0x0f, 0x38, 0x58 }, 0, .vex_256_w0, .avx2 },
.{ .vpbroadcastq, .rm, &.{ .xmm, .xmm_m64 }, &.{ 0x66, 0x0f, 0x38, 0x59 }, 0, .vex_128_w0, .avx2 },
.{ .vpbroadcastq, .rm, &.{ .ymm, .xmm_m64 }, &.{ 0x66, 0x0f, 0x38, 0x59 }, 0, .vex_256_w0, .avx2 },
.{ .vpbroadcasti128, .rm, &.{ .ymm, .m128 }, &.{ 0x66, 0x0f, 0x38, 0x5a }, 0, .vex_256_w0, .avx2 },
.{ .vpcmpeqb, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0x74 }, 0, .vex_256_wig, .avx2 }, .{ .vpcmpeqb, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0x74 }, 0, .vex_256_wig, .avx2 },
.{ .vpcmpeqw, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0x75 }, 0, .vex_256_wig, .avx2 }, .{ .vpcmpeqw, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0x75 }, 0, .vex_256_wig, .avx2 },
.{ .vpcmpeqd, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0x76 }, 0, .vex_256_wig, .avx2 }, .{ .vpcmpeqd, .rvm, &.{ .ymm, .ymm, .ymm_m256 }, &.{ 0x66, 0x0f, 0x76 }, 0, .vex_256_wig, .avx2 },

View File

@ -376,7 +376,10 @@ pub fn generateSymbol(
.val = switch (aggregate.storage) { .val = switch (aggregate.storage) {
.bytes => unreachable, .bytes => unreachable,
.elems => |elems| elems[@as(usize, @intCast(index))], .elems => |elems| elems[@as(usize, @intCast(index))],
.repeated_elem => |elem| elem, .repeated_elem => |elem| if (index < array_type.len)
elem
else
array_type.sentinel,
}.toValue(), }.toValue(),
}, code, debug_output, reloc_info)) { }, code, debug_output, reloc_info)) {
.ok => {}, .ok => {},

View File

@ -388,6 +388,7 @@ fn populateMissingMetadata(self: *Coff) !void {
self.rdata_section_index = try self.allocateSection(".rdata", file_size, .{ self.rdata_section_index = try self.allocateSection(".rdata", file_size, .{
.CNT_INITIALIZED_DATA = 1, .CNT_INITIALIZED_DATA = 1,
.MEM_READ = 1, .MEM_READ = 1,
.MEM_WRITE = 1,
}); });
} }

View File

@ -1260,7 +1260,6 @@ test "zero multiplicand" {
test "@intCast to u0" { test "@intCast to u0" {
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO