Commit 6ad22cd964
Changed files (17)
lib
src
arch
x86_64
lib/std/compress/deflate/compressor.zig
@@ -1069,8 +1069,6 @@ var deflate_tests = [_]DeflateTest{
};
test "deflate" {
- if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
for (deflate_tests) |dt| {
var output = ArrayList(u8).init(testing.allocator);
defer output.deinit();
lib/std/compress/deflate/compressor_test.zig
@@ -1,5 +1,4 @@
const std = @import("std");
-const builtin = @import("builtin");
const expect = std.testing.expect;
const fifo = std.fifo;
const io = std.io;
@@ -154,8 +153,6 @@ fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void {
}
test "deflate/inflate" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
var limits = [_]u32{0} ** 11;
var test0 = [_]u8{};
@@ -180,8 +177,6 @@ test "deflate/inflate" {
}
test "very long sparse chunk" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
// A SparseReader returns a stream consisting of 0s ending with 65,536 (1<<16) 1s.
// This tests missing hash references in a very large input.
const SparseReader = struct {
@@ -243,7 +238,7 @@ test "very long sparse chunk" {
}
test "compressor reset" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+ if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
for (std.enums.values(deflate.Compression)) |c| {
try testWriterReset(c, null);
@@ -295,8 +290,6 @@ fn testWriterReset(level: deflate.Compression, dict: ?[]const u8) !void {
}
test "decompressor dictionary" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const dict = "hello world"; // dictionary
const text = "hello again world";
@@ -337,8 +330,6 @@ test "decompressor dictionary" {
}
test "compressor dictionary" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const dict = "hello world";
const text = "hello again world";
@@ -385,8 +376,6 @@ test "compressor dictionary" {
// Update the hash for best_speed only if d.index < d.maxInsertIndex
// See https://golang.org/issue/2508
test "Go non-regression test for 2508" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
var comp = try compressor(
testing.allocator,
io.null_writer,
@@ -404,8 +393,6 @@ test "Go non-regression test for 2508" {
}
test "deflate/inflate string" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const StringTest = struct {
filename: []const u8,
limit: [11]u32,
@@ -453,8 +440,6 @@ test "deflate/inflate string" {
}
test "inflate reset" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const strings = [_][]const u8{
"lorem ipsum izzle fo rizzle",
"the quick brown fox jumped over",
@@ -501,8 +486,6 @@ test "inflate reset" {
}
test "inflate reset dictionary" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const dict = "the lorem fox";
const strings = [_][]const u8{
"lorem ipsum izzle fo rizzle",
lib/std/compress/deflate/deflate_fast.zig
@@ -649,8 +649,6 @@ test "best speed shift offsets" {
}
test "best speed reset" {
- if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
// test that encoding is consistent across a warparound of the table offset.
// See https://github.com/golang/go/issues/34121
const fmt = std.fmt;
lib/std/compress/deflate/deflate_fast_test.zig
@@ -1,5 +1,4 @@
const std = @import("std");
-const builtin = @import("builtin");
const expect = std.testing.expect;
const io = std.io;
const mem = std.mem;
@@ -12,8 +11,6 @@ const inflate = @import("decompressor.zig");
const deflate_const = @import("deflate_const.zig");
test "best speed" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
// Tests that round-tripping through deflate and then inflate recovers the original input.
// The Write sizes are near the thresholds in the compressor.encSpeed method (0, 16, 128), as well
// as near `deflate_const.max_store_block_size` (65535).
@@ -96,8 +93,6 @@ test "best speed" {
}
test "best speed max match offset" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const abc = "abcdefgh";
const xyz = "stuvwxyz";
const input_margin = 16 - 1;
lib/std/compress/deflate/huffman_bit_writer.zig
@@ -1,5 +1,4 @@
const std = @import("std");
-const builtin = @import("builtin");
const io = std.io;
const Allocator = std.mem.Allocator;
@@ -845,8 +844,6 @@ const testing = std.testing;
const ArrayList = std.ArrayList;
test "writeBlockHuff" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
// Tests huffman encoding against reference files to detect possible regressions.
// If encoding/bit allocation changes you can regenerate these files
@@ -1571,8 +1568,6 @@ const TestType = enum {
};
test "writeBlock" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
// tests if the writeBlock encoding has changed.
const ttype: TestType = .write_block;
@@ -1588,8 +1583,6 @@ test "writeBlock" {
}
test "writeBlockDynamic" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
// tests if the writeBlockDynamic encoding has changed.
const ttype: TestType = .write_dyn_block;
lib/std/compress/zlib.zig
@@ -264,8 +264,6 @@ test "sanity checks" {
}
test "compress data" {
- if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const allocator = testing.allocator;
const rfc1951_txt = @embedFile("testdata/rfc1951.txt");
lib/std/crypto/25519/ed25519.zig
@@ -685,7 +685,8 @@ test "ed25519 signatures with streaming" {
}
test "ed25519 key pair from secret key" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64 and
+ !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest;
const kp = try Ed25519.KeyPair.create(null);
const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key);
lib/std/crypto/pcurves/p384.zig
@@ -478,10 +478,8 @@ pub const AffineCoordinates = struct {
};
test {
- switch (@import("builtin").zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
+ if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
_ = @import("tests/p384.zig");
}
lib/std/crypto/pcurves/secp256k1.zig
@@ -556,10 +556,8 @@ pub const AffineCoordinates = struct {
};
test {
- switch (@import("builtin").zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
+ if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
_ = @import("tests/secp256k1.zig");
}
lib/std/crypto/chacha20.zig
@@ -1029,8 +1029,6 @@ test "crypto.chacha20 test vector 5" {
}
test "seal" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
{
const m = "";
const ad = "";
@@ -1081,8 +1079,6 @@ test "seal" {
}
test "open" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
{
const c = [_]u8{ 0xa0, 0x78, 0x4d, 0x7a, 0x47, 0x16, 0xf3, 0xfe, 0xb4, 0xf6, 0x4e, 0x7f, 0x4b, 0x39, 0xbf, 0x4 };
const ad = "";
@@ -1147,8 +1143,6 @@ test "open" {
}
test "crypto.xchacha20" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const key = [_]u8{69} ** 32;
const nonce = [_]u8{42} ** 24;
const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
lib/std/crypto/ecdsa.zig
@@ -372,10 +372,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
}
test "ECDSA - Basic operations over EcdsaP384Sha384" {
- switch (builtin.zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null);
@@ -391,10 +389,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {
}
test "ECDSA - Basic operations over Secp256k1" {
- switch (builtin.zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = EcdsaSecp256k1Sha256oSha256;
const kp = try Scheme.KeyPair.create(null);
@@ -410,10 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {
}
test "ECDSA - Basic operations over EcdsaP384Sha256" {
- switch (builtin.zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
const kp = try Scheme.KeyPair.create(null);
@@ -429,10 +423,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
}
test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
- switch (builtin.zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
// zig fmt: off
@@ -476,10 +468,8 @@ const TestVector = struct {
};
test "ECDSA - Test vectors from Project Wycheproof" {
- switch (builtin.zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const vectors = [_]TestVector{
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
@@ -893,10 +883,8 @@ fn tvTry(vector: TestVector) !void {
}
test "ECDSA - Sec1 encoding/decoding" {
- switch (builtin.zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const Scheme = EcdsaP384Sha384;
const kp = try Scheme.KeyPair.create(null);
lib/std/crypto/ff.zig
@@ -6,7 +6,7 @@
//! Parts of that code was ported from the BSD-licensed crypto/internal/bigmod/nat.go file in the Go language, itself inspired from BearSSL.
const std = @import("std");
-const builtin = std.builtin;
+const builtin = @import("builtin");
const crypto = std.crypto;
const math = std.math;
const mem = std.mem;
@@ -14,6 +14,7 @@ const meta = std.meta;
const testing = std.testing;
const BoundedArray = std.BoundedArray;
const assert = std.debug.assert;
+const Endian = std.builtin.Endian;
// A Limb is a single digit in a big integer.
const Limb = usize;
@@ -27,7 +28,7 @@ const t_bits: usize = @bitSizeOf(Limb) - carry_bits;
// A TLimb is a Limb that is truncated to t_bits.
const TLimb = meta.Int(.unsigned, t_bits);
-const native_endian = @import("builtin").target.cpu.arch.endian();
+const native_endian = builtin.target.cpu.arch.endian();
// A WideLimb is a Limb that is twice as wide as a normal Limb.
const WideLimb = struct {
@@ -128,7 +129,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
}
/// Encodes a big integer into a byte array.
- pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
+ pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
if (bytes.len == 0) {
if (self.isZero()) return;
return error.Overflow;
@@ -175,7 +176,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
}
/// Creates a new big integer from a byte array.
- pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) OverflowError!Self {
+ pub fn fromBytes(bytes: []const u8, comptime endian: Endian) OverflowError!Self {
if (bytes.len == 0) return Self.zero;
var shift: usize = 0;
var out = Self.zero;
@@ -335,7 +336,7 @@ fn Fe_(comptime bits: comptime_int) type {
}
/// Creates a field element from a byte string.
- pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: builtin.Endian) (OverflowError || FieldElementError)!Self {
+ pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: Endian) (OverflowError || FieldElementError)!Self {
const v = try FeUint.fromBytes(bytes, endian);
var fe = Self{ .v = v };
try m.shrink(&fe);
@@ -344,7 +345,7 @@ fn Fe_(comptime bits: comptime_int) type {
}
/// Converts the field element to a byte string.
- pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
+ pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
return self.v.toBytes(bytes, endian);
}
@@ -458,13 +459,13 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
}
/// Creates a new modulus from a byte string.
- pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) (InvalidModulusError || OverflowError)!Self {
+ pub fn fromBytes(bytes: []const u8, comptime endian: Endian) (InvalidModulusError || OverflowError)!Self {
const v = try FeUint.fromBytes(bytes, endian);
return try Self.fromUint(v);
}
/// Serializes the modulus to a byte string.
- pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
+ pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
return self.v.toBytes(bytes, endian);
}
@@ -658,7 +659,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
// Returns x^e (mod m), with the exponent provided as a byte string.
// `public` must be set to `false` if the exponent it secret.
- fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: builtin.Endian, comptime public: bool) NullExponentError!Fe {
+ fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: Endian, comptime public: bool) NullExponentError!Fe {
var acc: u8 = 0;
for (e) |b| acc |= b;
if (acc == 0) return error.NullExponent;
@@ -801,7 +802,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
/// doesn't have to be created if a serialized representation is already available.
///
/// If the exponent is public, `powWithEncodedPublicExponent()` can be used instead for a slight speedup.
- pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe {
+ pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe {
return self.powWithEncodedExponentInternal(x, e, endian, false);
}
@@ -810,7 +811,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
/// doesn't have to be created if a serialized representation is already available.
///
/// If the exponent is secret, `powWithEncodedExponent` must be used instead.
- pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe {
+ pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe {
return self.powWithEncodedExponentInternal(x, e, endian, true);
}
};
@@ -912,10 +913,8 @@ const ct_unprotected = struct {
};
test {
- switch (@import("builtin").zig_backend) {
- .stage2_c, .stage2_x86_64 => return error.SkipZigTest,
- else => {},
- }
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
const M = Modulus(256);
const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233);
lib/std/crypto/poly1305.zig
@@ -196,8 +196,6 @@ pub const Poly1305 = struct {
};
test "poly1305 rfc7439 vector1" {
- if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9";
const msg = "Cryptographic Forum Research Group";
lib/std/crypto/salsa20.zig
@@ -623,8 +623,6 @@ test "xsalsa20poly1305 sealedbox" {
}
test "secretbox twoblocks" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
const key = [_]u8{ 0xc9, 0xc9, 0x4d, 0xcf, 0x68, 0xbe, 0x00, 0xe4, 0x7f, 0xe6, 0x13, 0x26, 0xfc, 0xc4, 0x2f, 0xd0, 0xdb, 0x93, 0x91, 0x1c, 0x09, 0x94, 0x89, 0xe1, 0x1b, 0x88, 0x63, 0x18, 0x86, 0x64, 0x8b, 0x7b };
const nonce = [_]u8{ 0xa4, 0x33, 0xe9, 0x0a, 0x07, 0x68, 0x6e, 0x9a, 0x2b, 0x6d, 0xd4, 0x59, 0x04, 0x72, 0x3e, 0xd3, 0x8a, 0x67, 0x55, 0xc7, 0x9e, 0x3e, 0x77, 0xdc };
const msg = [_]u8{'a'} ** 97;
lib/std/crypto/sha2.zig
@@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
return;
},
// C backend doesn't currently support passing vectors to inline asm.
- .x86_64 => if (builtin.zig_backend != .stage2_c and builtin.zig_backend != .stage2_x86_64 and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
+ .x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
const s_v = @as(*[16]v4u32, @ptrCast(&s));
lib/std/treap.zig
@@ -350,8 +350,6 @@ const TestTreap = Treap(u64, std.math.order);
const TestNode = TestTreap.Node;
test "std.Treap: insert, find, replace, remove" {
- if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
-
var treap = TestTreap{};
var nodes: [10]TestNode = undefined;
src/arch/x86_64/CodeGen.zig
@@ -4740,6 +4740,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
// TODO we could allocate register here, but need to expect addr register and potentially
// offset register.
+ try self.spillEflagsIfOccupied();
const dst_mcv = try self.allocRegOrMem(inst, false);
try self.genBinOpMir(
.{ ._, .add },
@@ -14884,6 +14885,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
.bits = @intCast(ty.bitSize(mod)),
};
const max_reg_bit_width = Register.rax.bitSize();
+ try self.spillEflagsIfOccupied();
switch (int_info.signedness) {
.signed => {
const shift: u6 = @intCast(max_reg_bit_width - int_info.bits);