authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-26 21:45:45-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-10-26 22:35:38-04:00
log6ad22cd964741ec646eb551877591d719e0c41f5
tree3101238c5e330ba642a0f4625cf4862870533d02
parent48526c0eb6c394b778cba11559a66daf8d5ec3c7

x86_64: add missing spills


17 files changed, 36 insertions(+), 97 deletions(-)

lib/std/compress/deflate/compressor.zig-2
...@@ -1069,8 +1069,6 @@ var deflate_tests = [_]DeflateTest{...@@ -1069,8 +1069,6 @@ var deflate_tests = [_]DeflateTest{
1069};1069};
10701070
1071test "deflate" {1071test "deflate" {
1072 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
1073
1074 for (deflate_tests) |dt| {1072 for (deflate_tests) |dt| {
1075 var output = ArrayList(u8).init(testing.allocator);1073 var output = ArrayList(u8).init(testing.allocator);
1076 defer output.deinit();1074 defer output.deinit();
lib/std/compress/deflate/compressor_test.zig+1-18
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
3const expect = std.testing.expect;2const expect = std.testing.expect;
4const fifo = std.fifo;3const fifo = std.fifo;
5const io = std.io;4const io = std.io;
...@@ -154,8 +153,6 @@ fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void {...@@ -154,8 +153,6 @@ fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void {
154}153}
155154
156test "deflate/inflate" {155test "deflate/inflate" {
157 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
158
159 var limits = [_]u32{0} ** 11;156 var limits = [_]u32{0} ** 11;
160157
161 var test0 = [_]u8{};158 var test0 = [_]u8{};
...@@ -180,8 +177,6 @@ test "deflate/inflate" {...@@ -180,8 +177,6 @@ test "deflate/inflate" {
180}177}
181178
182test "very long sparse chunk" {179test "very long sparse chunk" {
183 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
184
185 // A SparseReader returns a stream consisting of 0s ending with 65,536 (1<<16) 1s.180 // A SparseReader returns a stream consisting of 0s ending with 65,536 (1<<16) 1s.
186 // This tests missing hash references in a very large input.181 // This tests missing hash references in a very large input.
187 const SparseReader = struct {182 const SparseReader = struct {
...@@ -243,7 +238,7 @@ test "very long sparse chunk" {...@@ -243,7 +238,7 @@ test "very long sparse chunk" {
243}238}
244239
245test "compressor reset" {240test "compressor reset" {
246 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;241 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
247242
248 for (std.enums.values(deflate.Compression)) |c| {243 for (std.enums.values(deflate.Compression)) |c| {
249 try testWriterReset(c, null);244 try testWriterReset(c, null);
...@@ -295,8 +290,6 @@ fn testWriterReset(level: deflate.Compression, dict: ?[]const u8) !void {...@@ -295,8 +290,6 @@ fn testWriterReset(level: deflate.Compression, dict: ?[]const u8) !void {
295}290}
296291
297test "decompressor dictionary" {292test "decompressor dictionary" {
298 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
299
300 const dict = "hello world"; // dictionary293 const dict = "hello world"; // dictionary
301 const text = "hello again world";294 const text = "hello again world";
302295
...@@ -337,8 +330,6 @@ test "decompressor dictionary" {...@@ -337,8 +330,6 @@ test "decompressor dictionary" {
337}330}
338331
339test "compressor dictionary" {332test "compressor dictionary" {
340 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
341
342 const dict = "hello world";333 const dict = "hello world";
343 const text = "hello again world";334 const text = "hello again world";
344335
...@@ -385,8 +376,6 @@ test "compressor dictionary" {...@@ -385,8 +376,6 @@ test "compressor dictionary" {
385// Update the hash for best_speed only if d.index < d.maxInsertIndex376// Update the hash for best_speed only if d.index < d.maxInsertIndex
386// See https://golang.org/issue/2508377// See https://golang.org/issue/2508
387test "Go non-regression test for 2508" {378test "Go non-regression test for 2508" {
388 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
389
390 var comp = try compressor(379 var comp = try compressor(
391 testing.allocator,380 testing.allocator,
392 io.null_writer,381 io.null_writer,
...@@ -404,8 +393,6 @@ test "Go non-regression test for 2508" {...@@ -404,8 +393,6 @@ test "Go non-regression test for 2508" {
404}393}
405394
406test "deflate/inflate string" {395test "deflate/inflate string" {
407 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
408
409 const StringTest = struct {396 const StringTest = struct {
410 filename: []const u8,397 filename: []const u8,
411 limit: [11]u32,398 limit: [11]u32,
...@@ -453,8 +440,6 @@ test "deflate/inflate string" {...@@ -453,8 +440,6 @@ test "deflate/inflate string" {
453}440}
454441
455test "inflate reset" {442test "inflate reset" {
456 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
457
458 const strings = [_][]const u8{443 const strings = [_][]const u8{
459 "lorem ipsum izzle fo rizzle",444 "lorem ipsum izzle fo rizzle",
460 "the quick brown fox jumped over",445 "the quick brown fox jumped over",
...@@ -501,8 +486,6 @@ test "inflate reset" {...@@ -501,8 +486,6 @@ test "inflate reset" {
501}486}
502487
503test "inflate reset dictionary" {488test "inflate reset dictionary" {
504 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
505
506 const dict = "the lorem fox";489 const dict = "the lorem fox";
507 const strings = [_][]const u8{490 const strings = [_][]const u8{
508 "lorem ipsum izzle fo rizzle",491 "lorem ipsum izzle fo rizzle",
lib/std/compress/deflate/deflate_fast.zig-2
...@@ -649,8 +649,6 @@ test "best speed shift offsets" {...@@ -649,8 +649,6 @@ test "best speed shift offsets" {
649}649}
650650
651test "best speed reset" {651test "best speed reset" {
652 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
653
654 // test that encoding is consistent across a warparound of the table offset.652 // test that encoding is consistent across a warparound of the table offset.
655 // See https://github.com/golang/go/issues/34121653 // See https://github.com/golang/go/issues/34121
656 const fmt = std.fmt;654 const fmt = std.fmt;
lib/std/compress/deflate/deflate_fast_test.zig-5
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
3const expect = std.testing.expect;2const expect = std.testing.expect;
4const io = std.io;3const io = std.io;
5const mem = std.mem;4const mem = std.mem;
...@@ -12,8 +11,6 @@ const inflate = @import("decompressor.zig");...@@ -12,8 +11,6 @@ const inflate = @import("decompressor.zig");
12const deflate_const = @import("deflate_const.zig");11const deflate_const = @import("deflate_const.zig");
1312
14test "best speed" {13test "best speed" {
15 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
16
17 // Tests that round-tripping through deflate and then inflate recovers the original input.14 // Tests that round-tripping through deflate and then inflate recovers the original input.
18 // The Write sizes are near the thresholds in the compressor.encSpeed method (0, 16, 128), as well15 // The Write sizes are near the thresholds in the compressor.encSpeed method (0, 16, 128), as well
19 // as near `deflate_const.max_store_block_size` (65535).16 // as near `deflate_const.max_store_block_size` (65535).
...@@ -96,8 +93,6 @@ test "best speed" {...@@ -96,8 +93,6 @@ test "best speed" {
96}93}
9794
98test "best speed max match offset" {95test "best speed max match offset" {
99 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
100
101 const abc = "abcdefgh";96 const abc = "abcdefgh";
102 const xyz = "stuvwxyz";97 const xyz = "stuvwxyz";
103 const input_margin = 16 - 1;98 const input_margin = 16 - 1;
lib/std/compress/deflate/huffman_bit_writer.zig-7
...@@ -1,5 +1,4 @@...@@ -1,5 +1,4 @@
1const std = @import("std");1const std = @import("std");
2const builtin = @import("builtin");
3const io = std.io;2const io = std.io;
43
5const Allocator = std.mem.Allocator;4const Allocator = std.mem.Allocator;
...@@ -845,8 +844,6 @@ const testing = std.testing;...@@ -845,8 +844,6 @@ const testing = std.testing;
845const ArrayList = std.ArrayList;844const ArrayList = std.ArrayList;
846845
847test "writeBlockHuff" {846test "writeBlockHuff" {
848 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
849
850 // Tests huffman encoding against reference files to detect possible regressions.847 // Tests huffman encoding against reference files to detect possible regressions.
851 // If encoding/bit allocation changes you can regenerate these files848 // If encoding/bit allocation changes you can regenerate these files
852849
...@@ -1571,8 +1568,6 @@ const TestType = enum {...@@ -1571,8 +1568,6 @@ const TestType = enum {
1571};1568};
15721569
1573test "writeBlock" {1570test "writeBlock" {
1574 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1575
1576 // tests if the writeBlock encoding has changed.1571 // tests if the writeBlock encoding has changed.
15771572
1578 const ttype: TestType = .write_block;1573 const ttype: TestType = .write_block;
...@@ -1588,8 +1583,6 @@ test "writeBlock" {...@@ -1588,8 +1583,6 @@ test "writeBlock" {
1588}1583}
15891584
1590test "writeBlockDynamic" {1585test "writeBlockDynamic" {
1591 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1592
1593 // tests if the writeBlockDynamic encoding has changed.1586 // tests if the writeBlockDynamic encoding has changed.
15941587
1595 const ttype: TestType = .write_dyn_block;1588 const ttype: TestType = .write_dyn_block;
lib/std/compress/zlib.zig-2
...@@ -264,8 +264,6 @@ test "sanity checks" {...@@ -264,8 +264,6 @@ test "sanity checks" {
264}264}
265265
266test "compress data" {266test "compress data" {
267 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
268
269 const allocator = testing.allocator;267 const allocator = testing.allocator;
270 const rfc1951_txt = @embedFile("testdata/rfc1951.txt");268 const rfc1951_txt = @embedFile("testdata/rfc1951.txt");
271269
lib/std/crypto/25519/ed25519.zig+2-1
...@@ -685,7 +685,8 @@ test "ed25519 signatures with streaming" {...@@ -685,7 +685,8 @@ test "ed25519 signatures with streaming" {
685}685}
686686
687test "ed25519 key pair from secret key" {687test "ed25519 key pair from secret key" {
688 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;688 if (builtin.zig_backend == .stage2_x86_64 and
689 !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest;
689690
690 const kp = try Ed25519.KeyPair.create(null);691 const kp = try Ed25519.KeyPair.create(null);
691 const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key);692 const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key);
lib/std/crypto/chacha20.zig-6
...@@ -1029,8 +1029,6 @@ test "crypto.chacha20 test vector 5" {...@@ -1029,8 +1029,6 @@ test "crypto.chacha20 test vector 5" {
1029}1029}
10301030
1031test "seal" {1031test "seal" {
1032 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1033
1034 {1032 {
1035 const m = "";1033 const m = "";
1036 const ad = "";1034 const ad = "";
...@@ -1081,8 +1079,6 @@ test "seal" {...@@ -1081,8 +1079,6 @@ test "seal" {
1081}1079}
10821080
1083test "open" {1081test "open" {
1084 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1085
1086 {1082 {
1087 const c = [_]u8{ 0xa0, 0x78, 0x4d, 0x7a, 0x47, 0x16, 0xf3, 0xfe, 0xb4, 0xf6, 0x4e, 0x7f, 0x4b, 0x39, 0xbf, 0x4 };1083 const c = [_]u8{ 0xa0, 0x78, 0x4d, 0x7a, 0x47, 0x16, 0xf3, 0xfe, 0xb4, 0xf6, 0x4e, 0x7f, 0x4b, 0x39, 0xbf, 0x4 };
1088 const ad = "";1084 const ad = "";
...@@ -1147,8 +1143,6 @@ test "open" {...@@ -1147,8 +1143,6 @@ test "open" {
1147}1143}
11481144
1149test "crypto.xchacha20" {1145test "crypto.xchacha20" {
1150 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1151
1152 const key = [_]u8{69} ** 32;1146 const key = [_]u8{69} ** 32;
1153 const nonce = [_]u8{42} ** 24;1147 const nonce = [_]u8{42} ** 24;
1154 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.";1148 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 {...@@ -372,10 +372,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
372}372}
373373
374test "ECDSA - Basic operations over EcdsaP384Sha384" {374test "ECDSA - Basic operations over EcdsaP384Sha384" {
375 switch (builtin.zig_backend) {375 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
376 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,376 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
377 else => {},
378 }
379377
380 const Scheme = EcdsaP384Sha384;378 const Scheme = EcdsaP384Sha384;
381 const kp = try Scheme.KeyPair.create(null);379 const kp = try Scheme.KeyPair.create(null);
...@@ -391,10 +389,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {...@@ -391,10 +389,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {
391}389}
392390
393test "ECDSA - Basic operations over Secp256k1" {391test "ECDSA - Basic operations over Secp256k1" {
394 switch (builtin.zig_backend) {392 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
395 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,393 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
396 else => {},
397 }
398394
399 const Scheme = EcdsaSecp256k1Sha256oSha256;395 const Scheme = EcdsaSecp256k1Sha256oSha256;
400 const kp = try Scheme.KeyPair.create(null);396 const kp = try Scheme.KeyPair.create(null);
...@@ -410,10 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {...@@ -410,10 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {
410}406}
411407
412test "ECDSA - Basic operations over EcdsaP384Sha256" {408test "ECDSA - Basic operations over EcdsaP384Sha256" {
413 switch (builtin.zig_backend) {409 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
414 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,410 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
415 else => {},
416 }
417411
418 const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);412 const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
419 const kp = try Scheme.KeyPair.create(null);413 const kp = try Scheme.KeyPair.create(null);
...@@ -429,10 +423,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {...@@ -429,10 +423,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
429}423}
430424
431test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {425test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
432 switch (builtin.zig_backend) {426 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
433 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,427 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
434 else => {},
435 }
436428
437 const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);429 const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
438 // zig fmt: off430 // zig fmt: off
...@@ -476,10 +468,8 @@ const TestVector = struct {...@@ -476,10 +468,8 @@ const TestVector = struct {
476};468};
477469
478test "ECDSA - Test vectors from Project Wycheproof" {470test "ECDSA - Test vectors from Project Wycheproof" {
479 switch (builtin.zig_backend) {471 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
480 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,472 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
481 else => {},
482 }
483473
484 const vectors = [_]TestVector{474 const vectors = [_]TestVector{
485 .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },475 .{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
...@@ -893,10 +883,8 @@ fn tvTry(vector: TestVector) !void {...@@ -893,10 +883,8 @@ fn tvTry(vector: TestVector) !void {
893}883}
894884
895test "ECDSA - Sec1 encoding/decoding" {885test "ECDSA - Sec1 encoding/decoding" {
896 switch (builtin.zig_backend) {886 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
897 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,887 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
898 else => {},
899 }
900888
901 const Scheme = EcdsaP384Sha384;889 const Scheme = EcdsaP384Sha384;
902 const kp = try Scheme.KeyPair.create(null);890 const kp = try Scheme.KeyPair.create(null);
lib/std/crypto/ff.zig+14-15
...@@ -6,7 +6,7 @@...@@ -6,7 +6,7 @@
6//! Parts of that code was ported from the BSD-licensed crypto/internal/bigmod/nat.go file in the Go language, itself inspired from BearSSL.6//! 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
8const std = @import("std");8const std = @import("std");
9const builtin = std.builtin;9const builtin = @import("builtin");
10const crypto = std.crypto;10const crypto = std.crypto;
11const math = std.math;11const math = std.math;
12const mem = std.mem;12const mem = std.mem;
...@@ -14,6 +14,7 @@ const meta = std.meta;...@@ -14,6 +14,7 @@ const meta = std.meta;
14const testing = std.testing;14const testing = std.testing;
15const BoundedArray = std.BoundedArray;15const BoundedArray = std.BoundedArray;
16const assert = std.debug.assert;16const assert = std.debug.assert;
17const Endian = std.builtin.Endian;
1718
18// A Limb is a single digit in a big integer.19// A Limb is a single digit in a big integer.
19const Limb = usize;20const Limb = usize;
...@@ -27,7 +28,7 @@ const t_bits: usize = @bitSizeOf(Limb) - carry_bits;...@@ -27,7 +28,7 @@ const t_bits: usize = @bitSizeOf(Limb) - carry_bits;
27// A TLimb is a Limb that is truncated to t_bits.28// A TLimb is a Limb that is truncated to t_bits.
28const TLimb = meta.Int(.unsigned, t_bits);29const 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
32// A WideLimb is a Limb that is twice as wide as a normal Limb.33// A WideLimb is a Limb that is twice as wide as a normal Limb.
33const WideLimb = struct {34const WideLimb = struct {
...@@ -128,7 +129,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {...@@ -128,7 +129,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
128 }129 }
129130
130 /// Encodes a big integer into a byte array.131 /// 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 {
132 if (bytes.len == 0) {133 if (bytes.len == 0) {
133 if (self.isZero()) return;134 if (self.isZero()) return;
134 return error.Overflow;135 return error.Overflow;
...@@ -175,7 +176,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {...@@ -175,7 +176,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
175 }176 }
176177
177 /// Creates a new big integer from a byte array.178 /// 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 {
179 if (bytes.len == 0) return Self.zero;180 if (bytes.len == 0) return Self.zero;
180 var shift: usize = 0;181 var shift: usize = 0;
181 var out = Self.zero;182 var out = Self.zero;
...@@ -335,7 +336,7 @@ fn Fe_(comptime bits: comptime_int) type {...@@ -335,7 +336,7 @@ fn Fe_(comptime bits: comptime_int) type {
335 }336 }
336337
337 /// Creates a field element from a byte string.338 /// 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 {
339 const v = try FeUint.fromBytes(bytes, endian);340 const v = try FeUint.fromBytes(bytes, endian);
340 var fe = Self{ .v = v };341 var fe = Self{ .v = v };
341 try m.shrink(&fe);342 try m.shrink(&fe);
...@@ -344,7 +345,7 @@ fn Fe_(comptime bits: comptime_int) type {...@@ -344,7 +345,7 @@ fn Fe_(comptime bits: comptime_int) type {
344 }345 }
345346
346 /// Converts the field element to a byte string.347 /// 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 {
348 return self.v.toBytes(bytes, endian);349 return self.v.toBytes(bytes, endian);
349 }350 }
350351
...@@ -458,13 +459,13 @@ pub fn Modulus(comptime max_bits: comptime_int) type {...@@ -458,13 +459,13 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
458 }459 }
459460
460 /// Creates a new modulus from a byte string.461 /// 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 {
462 const v = try FeUint.fromBytes(bytes, endian);463 const v = try FeUint.fromBytes(bytes, endian);
463 return try Self.fromUint(v);464 return try Self.fromUint(v);
464 }465 }
465466
466 /// Serializes the modulus to a byte string.467 /// 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 {
468 return self.v.toBytes(bytes, endian);469 return self.v.toBytes(bytes, endian);
469 }470 }
470471
...@@ -658,7 +659,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {...@@ -658,7 +659,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
658659
659 // Returns x^e (mod m), with the exponent provided as a byte string.660 // Returns x^e (mod m), with the exponent provided as a byte string.
660 // `public` must be set to `false` if the exponent it secret.661 // `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 {
662 var acc: u8 = 0;663 var acc: u8 = 0;
663 for (e) |b| acc |= b;664 for (e) |b| acc |= b;
664 if (acc == 0) return error.NullExponent;665 if (acc == 0) return error.NullExponent;
...@@ -801,7 +802,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {...@@ -801,7 +802,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
801 /// doesn't have to be created if a serialized representation is already available.802 /// doesn't have to be created if a serialized representation is already available.
802 ///803 ///
803 /// If the exponent is public, `powWithEncodedPublicExponent()` can be used instead for a slight speedup.804 /// 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 {
805 return self.powWithEncodedExponentInternal(x, e, endian, false);806 return self.powWithEncodedExponentInternal(x, e, endian, false);
806 }807 }
807808
...@@ -810,7 +811,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {...@@ -810,7 +811,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
810 /// doesn't have to be created if a serialized representation is already available.811 /// doesn't have to be created if a serialized representation is already available.
811 ///812 ///
812 /// If the exponent is secret, `powWithEncodedExponent` must be used instead.813 /// 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 {
814 return self.powWithEncodedExponentInternal(x, e, endian, true);815 return self.powWithEncodedExponentInternal(x, e, endian, true);
815 }816 }
816 };817 };
...@@ -912,10 +913,8 @@ const ct_unprotected = struct {...@@ -912,10 +913,8 @@ const ct_unprotected = struct {
912};913};
913914
914test {915test {
915 switch (@import("builtin").zig_backend) {916 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
916 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,917 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
917 else => {},
918 }
919918
920 const M = Modulus(256);919 const M = Modulus(256);
921 const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233);920 const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233);
lib/std/crypto/pcurves/p384.zig+2-4
...@@ -478,10 +478,8 @@ pub const AffineCoordinates = struct {...@@ -478,10 +478,8 @@ pub const AffineCoordinates = struct {
478};478};
479479
480test {480test {
481 switch (@import("builtin").zig_backend) {481 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
482 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,482 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
483 else => {},
484 }
485483
486 _ = @import("tests/p384.zig");484 _ = @import("tests/p384.zig");
487}485}
lib/std/crypto/pcurves/secp256k1.zig+2-4
...@@ -556,10 +556,8 @@ pub const AffineCoordinates = struct {...@@ -556,10 +556,8 @@ pub const AffineCoordinates = struct {
556};556};
557557
558test {558test {
559 switch (@import("builtin").zig_backend) {559 if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
560 .stage2_c, .stage2_x86_64 => return error.SkipZigTest,560 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
561 else => {},
562 }
563561
564 _ = @import("tests/secp256k1.zig");562 _ = @import("tests/secp256k1.zig");
565}563}
lib/std/crypto/poly1305.zig-2
...@@ -196,8 +196,6 @@ pub const Poly1305 = struct {...@@ -196,8 +196,6 @@ pub const Poly1305 = struct {
196};196};
197197
198test "poly1305 rfc7439 vector1" {198test "poly1305 rfc7439 vector1" {
199 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
200
201 const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9";199 const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9";
202200
203 const msg = "Cryptographic Forum Research Group";201 const msg = "Cryptographic Forum Research Group";
lib/std/crypto/salsa20.zig-2
...@@ -623,8 +623,6 @@ test "xsalsa20poly1305 sealedbox" {...@@ -623,8 +623,6 @@ test "xsalsa20poly1305 sealedbox" {
623}623}
624624
625test "secretbox twoblocks" {625test "secretbox twoblocks" {
626 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
627
628 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 };626 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 };
629 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 };627 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 };
630 const msg = [_]u8{'a'} ** 97;628 const msg = [_]u8{'a'} ** 97;
lib/std/crypto/sha2.zig+1-1
...@@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {...@@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
238 return;238 return;
239 },239 },
240 // C backend doesn't currently support passing vectors to inline asm.240 // 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 })) {
242 var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };242 var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
243 var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };243 var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
244 const s_v = @as(*[16]v4u32, @ptrCast(&s));244 const s_v = @as(*[16]v4u32, @ptrCast(&s));
lib/std/treap.zig-2
...@@ -350,8 +350,6 @@ const TestTreap = Treap(u64, std.math.order);...@@ -350,8 +350,6 @@ const TestTreap = Treap(u64, std.math.order);
350const TestNode = TestTreap.Node;350const TestNode = TestTreap.Node;
351351
352test "std.Treap: insert, find, replace, remove" {352test "std.Treap: insert, find, replace, remove" {
353 if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
354
355 var treap = TestTreap{};353 var treap = TestTreap{};
356 var nodes: [10]TestNode = undefined;354 var nodes: [10]TestNode = undefined;
357355
src/arch/x86_64/CodeGen.zig+2
...@@ -4740,6 +4740,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {...@@ -4740,6 +4740,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
47404740
4741 // TODO we could allocate register here, but need to expect addr register and potentially4741 // TODO we could allocate register here, but need to expect addr register and potentially
4742 // offset register.4742 // offset register.
4743 try self.spillEflagsIfOccupied();
4743 const dst_mcv = try self.allocRegOrMem(inst, false);4744 const dst_mcv = try self.allocRegOrMem(inst, false);
4744 try self.genBinOpMir(4745 try self.genBinOpMir(
4745 .{ ._, .add },4746 .{ ._, .add },
...@@ -14884,6 +14885,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {...@@ -14884,6 +14885,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
14884 .bits = @intCast(ty.bitSize(mod)),14885 .bits = @intCast(ty.bitSize(mod)),
14885 };14886 };
14886 const max_reg_bit_width = Register.rax.bitSize();14887 const max_reg_bit_width = Register.rax.bitSize();
14888 try self.spillEflagsIfOccupied();
14887 switch (int_info.signedness) {14889 switch (int_info.signedness) {
14888 .signed => {14890 .signed => {
14889 const shift: u6 = @intCast(max_reg_bit_width - int_info.bits);14891 const shift: u6 = @intCast(max_reg_bit_width - int_info.bits);