authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2022-12-17 18:36:15-05:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-01-01 16:44:29-05:00
log6445196fabd9c9c3e40c24d298dc9ac2a19bee35
tree609a07e77c9b2c9508a7fa3ca5e21bb94632faef
parent7b999dae730c2938865df05fdeecf15aaff2254d

tests: disable function alignment test for cbe, add 128-bit atomicrmw tests


2 files changed, 76 insertions(+), 2 deletions(-)

test/behavior/align.zig+1
...@@ -540,6 +540,7 @@ test "align(N) on functions" {...@@ -540,6 +540,7 @@ test "align(N) on functions" {
540 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO540 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
541 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO541 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
542 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO542 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
543 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO this is not supported on MSVC
543544
544 // function alignment is a compile error on wasm32/wasm64545 // function alignment is a compile error on wasm32/wasm64
545 if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest;546 if (native_arch == .wasm32 or native_arch == .wasm64) return error.SkipZigTest;
test/behavior/atomics.zig+75-2
...@@ -251,8 +251,7 @@ test "atomicrmw with ints" {...@@ -251,8 +251,7 @@ test "atomicrmw with ints" {
251 return error.SkipZigTest;251 return error.SkipZigTest;
252 }252 }
253253
254 // TODO: https://github.com/ziglang/zig/issues/13989254 const bit_values = [_]usize{ 8, 16, 32, 64 };
255 const bit_values = [_]usize{ 8, 16, 32, 64 } ++ if (builtin.zig_backend != .stage2_c) [_]usize{ } else [_]usize{ 128 };
256 inline for (bit_values) |bits| {255 inline for (bit_values) |bits| {
257 try testAtomicRmwInt(.unsigned, bits);256 try testAtomicRmwInt(.unsigned, bits);
258 comptime try testAtomicRmwInt(.unsigned, bits);257 comptime try testAtomicRmwInt(.unsigned, bits);
...@@ -308,6 +307,80 @@ fn testAtomicRmwInt(comptime signedness: std.builtin.Signedness, comptime N: usi...@@ -308,6 +307,80 @@ fn testAtomicRmwInt(comptime signedness: std.builtin.Signedness, comptime N: usi
308 try expect(x == y);307 try expect(x == y);
309}308}
310309
310test "atomicrmw with 128-bit ints" {
311 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
312 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
313 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
314 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
315 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
316
317 if (builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
318 return error.SkipZigTest;
319 }
320
321 try testAtomicRmwInt128(.unsigned);
322 comptime try testAtomicRmwInt128(.unsigned);
323}
324
325fn testAtomicRmwInt128(comptime signedness: std.builtin.Signedness) !void {
326 const int = std.meta.Int(signedness, 128);
327
328 const initial: int = 0xaaaaaaaa_bbbbbbbb_cccccccc_dddddddd;
329 const replacement: int = 0x00000000_00000005_00000000_00000003;
330
331 var x: int align(16) = initial;
332 var res = @atomicRmw(int, &x, .Xchg, replacement, .SeqCst);
333 try expect(x == replacement and res == initial);
334
335 var operator: int = 0x00000001_00000000_20000000_00000000;
336 res = @atomicRmw(int, &x, .Add, operator, .SeqCst);
337 var y: int = replacement;
338 try expect(res == y);
339 y = y + operator;
340 try expect(x == y);
341
342 operator = 0x00000000_10000000_00000000_20000000;
343 res = @atomicRmw(int, &x, .Sub, operator, .SeqCst);
344 try expect(res == y);
345 y = y - operator;
346 try expect(x == y);
347
348 operator = 0x12345678_87654321_12345678_87654321;
349 res = @atomicRmw(int, &x, .And, operator, .SeqCst);
350 try expect(res == y);
351 y = y & operator;
352 try expect(x == y);
353
354 operator = 0x00000000_10000000_00000000_20000000;
355 res = @atomicRmw(int, &x, .Nand, operator, .SeqCst);
356 try expect(res == y);
357 y = ~(y & operator);
358 try expect(x == y);
359
360 operator = 0x12340000_56780000_67890000_98760000;
361 res = @atomicRmw(int, &x, .Or, operator, .SeqCst);
362 try expect(res == y);
363 y = y | operator;
364 try expect(x == y);
365
366 operator = 0x0a0b0c0d_0e0f0102_03040506_0708090a;
367 res = @atomicRmw(int, &x, .Xor, operator, .SeqCst);
368 try expect(res == y);
369 y = y ^ operator;
370 try expect(x == y);
371
372 operator = 0x00000000_10000000_00000000_20000000;
373 res = @atomicRmw(int, &x, .Max, operator, .SeqCst);
374 try expect(res == y);
375 y = @max(y, operator);
376 try expect(x == y);
377
378 res = @atomicRmw(int, &x, .Min, operator, .SeqCst);
379 try expect(res == y);
380 y = @min(y, operator);
381 try expect(x == y);
382}
383
311test "atomics with different types" {384test "atomics with different types" {
312 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO385 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
313 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO386 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO