authorgravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-04-27 23:46:09-06:00
committergravatar for me@tadeo.caTadeo Kondrak <me@tadeo.ca> 2020-04-28 00:47:13-06:00
logf977155fdbee95a68799ec3a2199db6c79487125
tree769ff7293bed855213e6e66cbcfd48a626cee9f5
parentee5b358d71d544b06070681b245c9f1bad8b1a99
signature Commit is signed but in an unrecognized format.

@Vector -> std.meta.Vector


19 files changed, 122 insertions(+), 114 deletions(-)

lib/std/fmt.zig+3-3
...@@ -1670,9 +1670,9 @@ test "vector" {...@@ -1670,9 +1670,9 @@ test "vector" {
1670 return error.SkipZigTest;1670 return error.SkipZigTest;
1671 }1671 }
16721672
1673 const vbool: @Vector(4, bool) = [_]bool{ true, false, true, false };1673 const vbool: std.meta.Vector(4, bool) = [_]bool{ true, false, true, false };
1674 const vi64: @Vector(4, i64) = [_]i64{ -2, -1, 0, 1 };1674 const vi64: std.meta.Vector(4, i64) = [_]i64{ -2, -1, 0, 1 };
1675 const vu64: @Vector(4, u64) = [_]u64{ 1000, 2000, 3000, 4000 };1675 const vu64: std.meta.Vector(4, u64) = [_]u64{ 1000, 2000, 3000, 4000 };
16761676
1677 try testFmt("{ true, false, true, false }", "{}", .{vbool});1677 try testFmt("{ true, false, true, false }", "{}", .{vbool});
1678 try testFmt("{ -2, -1, 0, 1 }", "{}", .{vi64});1678 try testFmt("{ -2, -1, 0, 1 }", "{}", .{vi64});
lib/std/hash/auto_hash.zig+4-4
...@@ -359,13 +359,13 @@ test "testHash vector" {...@@ -359,13 +359,13 @@ test "testHash vector" {
359 // Disabled because of #3317359 // Disabled because of #3317
360 if (@import("builtin").arch == .mipsel or @import("builtin").arch == .mips) return error.SkipZigTest;360 if (@import("builtin").arch == .mipsel or @import("builtin").arch == .mips) return error.SkipZigTest;
361361
362 const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };362 const a: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
363 const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };363 const b: meta.Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
364 testing.expect(testHash(a) == testHash(a));364 testing.expect(testHash(a) == testHash(a));
365 testing.expect(testHash(a) != testHash(b));365 testing.expect(testHash(a) != testHash(b));
366366
367 const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };367 const c: meta.Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
368 const d: @Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };368 const d: meta.Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
369 testing.expect(testHash(c) == testHash(c));369 testing.expect(testHash(c) == testHash(c));
370 testing.expect(testHash(c) != testHash(d));370 testing.expect(testHash(c) != testHash(d));
371}371}
lib/std/special/compiler_rt.zig+1-1
...@@ -291,7 +291,7 @@ comptime {...@@ -291,7 +291,7 @@ comptime {
291 @export(@import("compiler_rt/umodti3.zig").__umodti3, .{ .name = "__umodti3", .linkage = linkage });291 @export(@import("compiler_rt/umodti3.zig").__umodti3, .{ .name = "__umodti3", .linkage = linkage });
292 },292 },
293 .x86_64 => {293 .x86_64 => {
294 // The "ti" functions must use @Vector(2, u64) parameter types to adhere to the ABI294 // The "ti" functions must use Vector(2, u64) parameter types to adhere to the ABI
295 // that LLVM expects compiler-rt to have.295 // that LLVM expects compiler-rt to have.
296 @export(@import("compiler_rt/divti3.zig").__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage });296 @export(@import("compiler_rt/divti3.zig").__divti3_windows_x86_64, .{ .name = "__divti3", .linkage = linkage });
297 @export(@import("compiler_rt/modti3.zig").__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage });297 @export(@import("compiler_rt/modti3.zig").__modti3_windows_x86_64, .{ .name = "__modti3", .linkage = linkage });
lib/std/special/compiler_rt/divti3.zig+1-1
...@@ -15,7 +15,7 @@ pub fn __divti3(a: i128, b: i128) callconv(.C) i128 {...@@ -15,7 +15,7 @@ pub fn __divti3(a: i128, b: i128) callconv(.C) i128 {
15 return (@bitCast(i128, r) ^ s) -% s;15 return (@bitCast(i128, r) ^ s) -% s;
16}16}
1717
18const v128 = @Vector(2, u64);18const v128 = @import("std").meta.Vector(2, u64);
19pub fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {19pub fn __divti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
20 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __divti3, .{20 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __divti3, .{
21 @bitCast(i128, a),21 @bitCast(i128, a),
lib/std/special/compiler_rt/modti3.zig+1-1
...@@ -20,7 +20,7 @@ pub fn __modti3(a: i128, b: i128) callconv(.C) i128 {...@@ -20,7 +20,7 @@ pub fn __modti3(a: i128, b: i128) callconv(.C) i128 {
20 return (@bitCast(i128, r) ^ s_a) -% s_a; // negate if s == -120 return (@bitCast(i128, r) ^ s_a) -% s_a; // negate if s == -1
21}21}
2222
23const v128 = @Vector(2, u64);23const v128 = @import("std").meta.Vector(2, u64);
24pub fn __modti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {24pub fn __modti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
25 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __modti3, .{25 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __modti3, .{
26 @bitCast(i128, a),26 @bitCast(i128, a),
lib/std/special/compiler_rt/multi3.zig+1-1
...@@ -14,7 +14,7 @@ pub fn __multi3(a: i128, b: i128) callconv(.C) i128 {...@@ -14,7 +14,7 @@ pub fn __multi3(a: i128, b: i128) callconv(.C) i128 {
14 return r.all;14 return r.all;
15}15}
1616
17const v128 = @Vector(2, u64);17const v128 = @import("std").meta.Vector(2, u64);
18pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {18pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
19 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{19 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{
20 @bitCast(i128, a),20 @bitCast(i128, a),
lib/std/special/compiler_rt/udivmodti4.zig+1-1
...@@ -7,7 +7,7 @@ pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 {...@@ -7,7 +7,7 @@ pub fn __udivmodti4(a: u128, b: u128, maybe_rem: ?*u128) callconv(.C) u128 {
7 return udivmod(u128, a, b, maybe_rem);7 return udivmod(u128, a, b, maybe_rem);
8}8}
99
10const v128 = @Vector(2, u64);10const v128 = @import("std").meta.Vector(2, u64);
11pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 {11pub fn __udivmodti4_windows_x86_64(a: v128, b: v128, maybe_rem: ?*u128) callconv(.C) v128 {
12 @setRuntimeSafety(builtin.is_test);12 @setRuntimeSafety(builtin.is_test);
13 return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem));13 return @bitCast(v128, udivmod(u128, @bitCast(u128, a), @bitCast(u128, b), maybe_rem));
lib/std/special/compiler_rt/udivti3.zig+1-1
...@@ -6,7 +6,7 @@ pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 {...@@ -6,7 +6,7 @@ pub fn __udivti3(a: u128, b: u128) callconv(.C) u128 {
6 return udivmodti4.__udivmodti4(a, b, null);6 return udivmodti4.__udivmodti4(a, b, null);
7}7}
88
9const v128 = @Vector(2, u64);9const v128 = @import("std").meta.Vector(2, u64);
10pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {10pub fn __udivti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
11 @setRuntimeSafety(builtin.is_test);11 @setRuntimeSafety(builtin.is_test);
12 return udivmodti4.__udivmodti4_windows_x86_64(a, b, null);12 return udivmodti4.__udivmodti4_windows_x86_64(a, b, null);
lib/std/special/compiler_rt/umodti3.zig+1-1
...@@ -9,7 +9,7 @@ pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 {...@@ -9,7 +9,7 @@ pub fn __umodti3(a: u128, b: u128) callconv(.C) u128 {
9 return r;9 return r;
10}10}
1111
12const v128 = @Vector(2, u64);12const v128 = @import("std").meta.Vector(2, u64);
13pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {13pub fn __umodti3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
14 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{14 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __umodti3, .{
15 @bitCast(u128, a),15 @bitCast(u128, a),
lib/std/target.zig+4-4
...@@ -488,8 +488,8 @@ pub const Target = struct {...@@ -488,8 +488,8 @@ pub const Target = struct {
488488
489 /// Adds the specified feature set but not its dependencies.489 /// Adds the specified feature set but not its dependencies.
490 pub fn addFeatureSet(set: *Set, other_set: Set) void {490 pub fn addFeatureSet(set: *Set, other_set: Set) void {
491 set.ints = @as(@Vector(usize_count, usize), set.ints) |491 set.ints = @as(std.meta.Vector(usize_count, usize), set.ints) |
492 @as(@Vector(usize_count, usize), other_set.ints);492 @as(std.meta.Vector(usize_count, usize), other_set.ints);
493 }493 }
494494
495 /// Removes the specified feature but not its dependents.495 /// Removes the specified feature but not its dependents.
...@@ -501,8 +501,8 @@ pub const Target = struct {...@@ -501,8 +501,8 @@ pub const Target = struct {
501501
502 /// Removes the specified feature but not its dependents.502 /// Removes the specified feature but not its dependents.
503 pub fn removeFeatureSet(set: *Set, other_set: Set) void {503 pub fn removeFeatureSet(set: *Set, other_set: Set) void {
504 set.ints = @as(@Vector(usize_count, usize), set.ints) &504 set.ints = @as(std.meta.Vector(usize_count, usize), set.ints) &
505 ~@as(@Vector(usize_count, usize), other_set.ints);505 ~@as(std.meta.Vector(usize_count, usize), other_set.ints);
506 }506 }
507507
508 pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void {508 pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void {
test/compile_errors.zig+11-9
...@@ -984,7 +984,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -984,7 +984,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
984984
985 cases.add("store vector pointer with unknown runtime index",985 cases.add("store vector pointer with unknown runtime index",
986 \\export fn entry() void {986 \\export fn entry() void {
987 \\ var v: @Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };987 \\ var v: @import("std").meta.Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };
988 \\988 \\
989 \\ var i: u32 = 0;989 \\ var i: u32 = 0;
990 \\ storev(&v[i], 42);990 \\ storev(&v[i], 42);
...@@ -999,7 +999,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -999,7 +999,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
999999
1000 cases.add("load vector pointer with unknown runtime index",1000 cases.add("load vector pointer with unknown runtime index",
1001 \\export fn entry() void {1001 \\export fn entry() void {
1002 \\ var v: @Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };1002 \\ var v: @import("std").meta.Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };
1003 \\1003 \\
1004 \\ var i: u32 = 0;1004 \\ var i: u32 = 0;
1005 \\ var x = loadv(&v[i]);1005 \\ var x = loadv(&v[i]);
...@@ -1885,8 +1885,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1885,8 +1885,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18851885
1886 cases.addTest("comptime vector overflow shows the index",1886 cases.addTest("comptime vector overflow shows the index",
1887 \\comptime {1887 \\comptime {
1888 \\ var a: @Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };1888 \\ var a: @import("std").meta.Vector(4, u8) = [_]u8{ 1, 2, 255, 4 };
1889 \\ var b: @Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };1889 \\ var b: @import("std").meta.Vector(4, u8) = [_]u8{ 5, 6, 1, 8 };
1890 \\ var x = a + b;1890 \\ var x = a + b;
1891 \\}1891 \\}
1892 , &[_][]const u8{1892 , &[_][]const u8{
...@@ -6846,8 +6846,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6846,8 +6846,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
68466846
6847 cases.addTest("@shuffle with selected index past first vector length",6847 cases.addTest("@shuffle with selected index past first vector length",
6848 \\export fn entry() void {6848 \\export fn entry() void {
6849 \\ const v: @Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };6849 \\ const v: @import("std").meta.Vector(4, u32) = [4]u32{ 10, 11, 12, 13 };
6850 \\ const x: @Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };6850 \\ const x: @import("std").meta.Vector(4, u32) = [4]u32{ 14, 15, 16, 17 };
6851 \\ var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });6851 \\ var z = @shuffle(u32, v, x, [8]i32{ 0, 1, 2, 3, 7, 6, 5, 4 });
6852 \\}6852 \\}
6853 , &[_][]const u8{6853 , &[_][]const u8{
...@@ -6858,11 +6858,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6858,11 +6858,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
68586858
6859 cases.addTest("nested vectors",6859 cases.addTest("nested vectors",
6860 \\export fn entry() void {6860 \\export fn entry() void {
6861 \\ const V = @Vector(4, @Vector(4, u8));6861 \\ const V1 = @import("std").meta.Vector(4, u8);
6862 \\ var v: V = undefined;6862 \\ const V2 = @Type(@import("builtin").TypeInfo{ .Vector = .{ .len = 4, .child = V1 } });
6863 \\ var v: V2 = undefined;
6863 \\}6864 \\}
6864 , &[_][]const u8{6865 , &[_][]const u8{
6865 "tmp.zig:2:26: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid",6866 "tmp.zig:3:49: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid",
6867 "tmp.zig:3:16: note: referenced here",
6866 });6868 });
68676869
6868 cases.addTest("bad @splat type",6870 cases.addTest("bad @splat type",
test/runtime_safety.zig+20-20
...@@ -472,11 +472,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -472,11 +472,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
472 \\ @import("std").os.exit(126);472 \\ @import("std").os.exit(126);
473 \\}473 \\}
474 \\pub fn main() void {474 \\pub fn main() void {
475 \\ var a: @Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 };475 \\ var a: @import("std").meta.Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 };
476 \\ var b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };476 \\ var b: @import("std").meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
477 \\ const x = add(a, b);477 \\ const x = add(a, b);
478 \\}478 \\}
479 \\fn add(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {479 \\fn add(a: @import("std").meta.Vector(4, i32), b: @import("std").meta.Vector(4, i32)) @import("std").meta.Vector(4, i32) {
480 \\ return a + b;480 \\ return a + b;
481 \\}481 \\}
482 );482 );
...@@ -486,11 +486,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -486,11 +486,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
486 \\ @import("std").os.exit(126);486 \\ @import("std").os.exit(126);
487 \\}487 \\}
488 \\pub fn main() void {488 \\pub fn main() void {
489 \\ var a: @Vector(4, u32) = [_]u32{ 1, 2, 8, 4 };489 \\ var a: @import("std").meta.Vector(4, u32) = [_]u32{ 1, 2, 8, 4 };
490 \\ var b: @Vector(4, u32) = [_]u32{ 5, 6, 7, 8 };490 \\ var b: @import("std").meta.Vector(4, u32) = [_]u32{ 5, 6, 7, 8 };
491 \\ const x = sub(b, a);491 \\ const x = sub(b, a);
492 \\}492 \\}
493 \\fn sub(a: @Vector(4, u32), b: @Vector(4, u32)) @Vector(4, u32) {493 \\fn sub(a: @import("std").meta.Vector(4, u32), b: @import("std").meta.Vector(4, u32)) @import("std").meta.Vector(4, u32) {
494 \\ return a - b;494 \\ return a - b;
495 \\}495 \\}
496 );496 );
...@@ -500,11 +500,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -500,11 +500,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
500 \\ @import("std").os.exit(126);500 \\ @import("std").os.exit(126);
501 \\}501 \\}
502 \\pub fn main() void {502 \\pub fn main() void {
503 \\ var a: @Vector(4, u8) = [_]u8{ 1, 2, 200, 4 };503 \\ var a: @import("std").meta.Vector(4, u8) = [_]u8{ 1, 2, 200, 4 };
504 \\ var b: @Vector(4, u8) = [_]u8{ 5, 6, 2, 8 };504 \\ var b: @import("std").meta.Vector(4, u8) = [_]u8{ 5, 6, 2, 8 };
505 \\ const x = mul(b, a);505 \\ const x = mul(b, a);
506 \\}506 \\}
507 \\fn mul(a: @Vector(4, u8), b: @Vector(4, u8)) @Vector(4, u8) {507 \\fn mul(a: @import("std").meta.Vector(4, u8), b: @import("std").meta.Vector(4, u8)) @import("std").meta.Vector(4, u8) {
508 \\ return a * b;508 \\ return a * b;
509 \\}509 \\}
510 );510 );
...@@ -514,10 +514,10 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -514,10 +514,10 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
514 \\ @import("std").os.exit(126);514 \\ @import("std").os.exit(126);
515 \\}515 \\}
516 \\pub fn main() void {516 \\pub fn main() void {
517 \\ var a: @Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 };517 \\ var a: @import("std").meta.Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 };
518 \\ const x = neg(a);518 \\ const x = neg(a);
519 \\}519 \\}
520 \\fn neg(a: @Vector(4, i16)) @Vector(4, i16) {520 \\fn neg(a: @import("std").meta.Vector(4, i16)) @import("std").meta.Vector(4, i16) {
521 \\ return -a;521 \\ return -a;
522 \\}522 \\}
523 );523 );
...@@ -579,12 +579,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -579,12 +579,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
579 \\ @import("std").os.exit(126);579 \\ @import("std").os.exit(126);
580 \\}580 \\}
581 \\pub fn main() !void {581 \\pub fn main() !void {
582 \\ var a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };582 \\ var a: @import("std").meta.Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };
583 \\ var b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };583 \\ var b: @import("std").meta.Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };
584 \\ const x = div(a, b);584 \\ const x = div(a, b);
585 \\ if (x[2] == 32767) return error.Whatever;585 \\ if (x[2] == 32767) return error.Whatever;
586 \\}586 \\}
587 \\fn div(a: @Vector(4, i16), b: @Vector(4, i16)) @Vector(4, i16) {587 \\fn div(a: @import("std").meta.Vector(4, i16), b: @import("std").meta.Vector(4, i16)) @import("std").meta.Vector(4, i16) {
588 \\ return @divTrunc(a, b);588 \\ return @divTrunc(a, b);
589 \\}589 \\}
590 );590 );
...@@ -658,11 +658,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -658,11 +658,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
658 \\ @import("std").os.exit(126);658 \\ @import("std").os.exit(126);
659 \\}659 \\}
660 \\pub fn main() void {660 \\pub fn main() void {
661 \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};661 \\ var a: @import("std").meta.Vector(4, i32) = [4]i32{111, 222, 333, 444};
662 \\ var b: @Vector(4, i32) = [4]i32{111, 0, 333, 444};662 \\ var b: @import("std").meta.Vector(4, i32) = [4]i32{111, 0, 333, 444};
663 \\ const x = div0(a, b);663 \\ const x = div0(a, b);
664 \\}664 \\}
665 \\fn div0(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {665 \\fn div0(a: @import("std").meta.Vector(4, i32), b: @import("std").meta.Vector(4, i32)) @import("std").meta.Vector(4, i32) {
666 \\ return @divTrunc(a, b);666 \\ return @divTrunc(a, b);
667 \\}667 \\}
668 );668 );
...@@ -685,11 +685,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {...@@ -685,11 +685,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
685 \\ @import("std").os.exit(126);685 \\ @import("std").os.exit(126);
686 \\}686 \\}
687 \\pub fn main() !void {687 \\pub fn main() !void {
688 \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};688 \\ var a: @import("std").meta.Vector(4, i32) = [4]i32{111, 222, 333, 444};
689 \\ var b: @Vector(4, i32) = [4]i32{111, 222, 333, 441};689 \\ var b: @import("std").meta.Vector(4, i32) = [4]i32{111, 222, 333, 441};
690 \\ const x = divExact(a, b);690 \\ const x = divExact(a, b);
691 \\}691 \\}
692 \\fn divExact(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {692 \\fn divExact(a: @import("std").meta.Vector(4, i32), b: @import("std").meta.Vector(4, i32)) @import("std").meta.Vector(4, i32) {
693 \\ return @divExact(a, b);693 \\ return @divExact(a, b);
694 \\}694 \\}
695 );695 );
test/stage1/behavior/byteswap.zig+2-2
...@@ -55,8 +55,8 @@ test "@byteSwap vectors" {...@@ -55,8 +55,8 @@ test "@byteSwap vectors" {
55 fn t(55 fn t(
56 comptime I: type,56 comptime I: type,
57 comptime n: comptime_int,57 comptime n: comptime_int,
58 input: @Vector(n, I),58 input: std.meta.Vector(n, I),
59 expected_vector: @Vector(n, I),59 expected_vector: std.meta.Vector(n, I),
60 ) void {60 ) void {
61 const actual_output: [n]I = @byteSwap(I, input);61 const actual_output: [n]I = @byteSwap(I, input);
62 const expected_output: [n]I = expected_vector;62 const expected_output: [n]I = expected_vector;
test/stage1/behavior/floatop.zig+13-12
...@@ -3,6 +3,7 @@ const expect = std.testing.expect;...@@ -3,6 +3,7 @@ const expect = std.testing.expect;
3const math = std.math;3const math = std.math;
4const pi = std.math.pi;4const pi = std.math.pi;
5const e = std.math.e;5const e = std.math.e;
6const Vector = std.meta.Vector;
67
7const epsilon = 0.000001;8const epsilon = 0.000001;
89
...@@ -36,7 +37,7 @@ fn testSqrt() void {...@@ -36,7 +37,7 @@ fn testSqrt() void {
36 // expect(@sqrt(a) == 7);37 // expect(@sqrt(a) == 7);
37 //}38 //}
38 {39 {
39 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };40 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
40 var result = @sqrt(v);41 var result = @sqrt(v);
41 expect(math.approxEq(f32, @sqrt(@as(f32, 1.1)), result[0], epsilon));42 expect(math.approxEq(f32, @sqrt(@as(f32, 1.1)), result[0], epsilon));
42 expect(math.approxEq(f32, @sqrt(@as(f32, 2.2)), result[1], epsilon));43 expect(math.approxEq(f32, @sqrt(@as(f32, 2.2)), result[1], epsilon));
...@@ -86,7 +87,7 @@ fn testSin() void {...@@ -86,7 +87,7 @@ fn testSin() void {
86 expect(@sin(a) == 0);87 expect(@sin(a) == 0);
87 }88 }
88 {89 {
89 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };90 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
90 var result = @sin(v);91 var result = @sin(v);
91 expect(math.approxEq(f32, @sin(@as(f32, 1.1)), result[0], epsilon));92 expect(math.approxEq(f32, @sin(@as(f32, 1.1)), result[0], epsilon));
92 expect(math.approxEq(f32, @sin(@as(f32, 2.2)), result[1], epsilon));93 expect(math.approxEq(f32, @sin(@as(f32, 2.2)), result[1], epsilon));
...@@ -116,7 +117,7 @@ fn testCos() void {...@@ -116,7 +117,7 @@ fn testCos() void {
116 expect(@cos(a) == 1);117 expect(@cos(a) == 1);
117 }118 }
118 {119 {
119 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };120 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
120 var result = @cos(v);121 var result = @cos(v);
121 expect(math.approxEq(f32, @cos(@as(f32, 1.1)), result[0], epsilon));122 expect(math.approxEq(f32, @cos(@as(f32, 1.1)), result[0], epsilon));
122 expect(math.approxEq(f32, @cos(@as(f32, 2.2)), result[1], epsilon));123 expect(math.approxEq(f32, @cos(@as(f32, 2.2)), result[1], epsilon));
...@@ -146,7 +147,7 @@ fn testExp() void {...@@ -146,7 +147,7 @@ fn testExp() void {
146 expect(@exp(a) == 1);147 expect(@exp(a) == 1);
147 }148 }
148 {149 {
149 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };150 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
150 var result = @exp(v);151 var result = @exp(v);
151 expect(math.approxEq(f32, @exp(@as(f32, 1.1)), result[0], epsilon));152 expect(math.approxEq(f32, @exp(@as(f32, 1.1)), result[0], epsilon));
152 expect(math.approxEq(f32, @exp(@as(f32, 2.2)), result[1], epsilon));153 expect(math.approxEq(f32, @exp(@as(f32, 2.2)), result[1], epsilon));
...@@ -176,7 +177,7 @@ fn testExp2() void {...@@ -176,7 +177,7 @@ fn testExp2() void {
176 expect(@exp2(a) == 4);177 expect(@exp2(a) == 4);
177 }178 }
178 {179 {
179 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };180 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
180 var result = @exp2(v);181 var result = @exp2(v);
181 expect(math.approxEq(f32, @exp2(@as(f32, 1.1)), result[0], epsilon));182 expect(math.approxEq(f32, @exp2(@as(f32, 1.1)), result[0], epsilon));
182 expect(math.approxEq(f32, @exp2(@as(f32, 2.2)), result[1], epsilon));183 expect(math.approxEq(f32, @exp2(@as(f32, 2.2)), result[1], epsilon));
...@@ -208,7 +209,7 @@ fn testLog() void {...@@ -208,7 +209,7 @@ fn testLog() void {
208 expect(@log(a) == 1 or @log(a) == @bitCast(f64, @as(u64, 0x3ff0000000000000)));209 expect(@log(a) == 1 or @log(a) == @bitCast(f64, @as(u64, 0x3ff0000000000000)));
209 }210 }
210 {211 {
211 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };212 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
212 var result = @log(v);213 var result = @log(v);
213 expect(math.approxEq(f32, @log(@as(f32, 1.1)), result[0], epsilon));214 expect(math.approxEq(f32, @log(@as(f32, 1.1)), result[0], epsilon));
214 expect(math.approxEq(f32, @log(@as(f32, 2.2)), result[1], epsilon));215 expect(math.approxEq(f32, @log(@as(f32, 2.2)), result[1], epsilon));
...@@ -238,7 +239,7 @@ fn testLog2() void {...@@ -238,7 +239,7 @@ fn testLog2() void {
238 expect(@log2(a) == 2);239 expect(@log2(a) == 2);
239 }240 }
240 {241 {
241 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };242 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
242 var result = @log2(v);243 var result = @log2(v);
243 expect(math.approxEq(f32, @log2(@as(f32, 1.1)), result[0], epsilon));244 expect(math.approxEq(f32, @log2(@as(f32, 1.1)), result[0], epsilon));
244 expect(math.approxEq(f32, @log2(@as(f32, 2.2)), result[1], epsilon));245 expect(math.approxEq(f32, @log2(@as(f32, 2.2)), result[1], epsilon));
...@@ -268,7 +269,7 @@ fn testLog10() void {...@@ -268,7 +269,7 @@ fn testLog10() void {
268 expect(@log10(a) == 3);269 expect(@log10(a) == 3);
269 }270 }
270 {271 {
271 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };272 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
272 var result = @log10(v);273 var result = @log10(v);
273 expect(math.approxEq(f32, @log10(@as(f32, 1.1)), result[0], epsilon));274 expect(math.approxEq(f32, @log10(@as(f32, 1.1)), result[0], epsilon));
274 expect(math.approxEq(f32, @log10(@as(f32, 2.2)), result[1], epsilon));275 expect(math.approxEq(f32, @log10(@as(f32, 2.2)), result[1], epsilon));
...@@ -304,7 +305,7 @@ fn testFabs() void {...@@ -304,7 +305,7 @@ fn testFabs() void {
304 expect(@fabs(b) == 2.5);305 expect(@fabs(b) == 2.5);
305 }306 }
306 {307 {
307 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };308 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
308 var result = @fabs(v);309 var result = @fabs(v);
309 expect(math.approxEq(f32, @fabs(@as(f32, 1.1)), result[0], epsilon));310 expect(math.approxEq(f32, @fabs(@as(f32, 1.1)), result[0], epsilon));
310 expect(math.approxEq(f32, @fabs(@as(f32, -2.2)), result[1], epsilon));311 expect(math.approxEq(f32, @fabs(@as(f32, -2.2)), result[1], epsilon));
...@@ -334,7 +335,7 @@ fn testFloor() void {...@@ -334,7 +335,7 @@ fn testFloor() void {
334 expect(@floor(a) == 3);335 expect(@floor(a) == 3);
335 }336 }
336 {337 {
337 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };338 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
338 var result = @floor(v);339 var result = @floor(v);
339 expect(math.approxEq(f32, @floor(@as(f32, 1.1)), result[0], epsilon));340 expect(math.approxEq(f32, @floor(@as(f32, 1.1)), result[0], epsilon));
340 expect(math.approxEq(f32, @floor(@as(f32, -2.2)), result[1], epsilon));341 expect(math.approxEq(f32, @floor(@as(f32, -2.2)), result[1], epsilon));
...@@ -364,7 +365,7 @@ fn testCeil() void {...@@ -364,7 +365,7 @@ fn testCeil() void {
364 expect(@ceil(a) == 4);365 expect(@ceil(a) == 4);
365 }366 }
366 {367 {
367 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };368 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
368 var result = @ceil(v);369 var result = @ceil(v);
369 expect(math.approxEq(f32, @ceil(@as(f32, 1.1)), result[0], epsilon));370 expect(math.approxEq(f32, @ceil(@as(f32, 1.1)), result[0], epsilon));
370 expect(math.approxEq(f32, @ceil(@as(f32, -2.2)), result[1], epsilon));371 expect(math.approxEq(f32, @ceil(@as(f32, -2.2)), result[1], epsilon));
...@@ -394,7 +395,7 @@ fn testTrunc() void {...@@ -394,7 +395,7 @@ fn testTrunc() void {
394 expect(@trunc(a) == -3);395 expect(@trunc(a) == -3);
395 }396 }
396 {397 {
397 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };398 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
398 var result = @trunc(v);399 var result = @trunc(v);
399 expect(math.approxEq(f32, @trunc(@as(f32, 1.1)), result[0], epsilon));400 expect(math.approxEq(f32, @trunc(@as(f32, 1.1)), result[0], epsilon));
400 expect(math.approxEq(f32, @trunc(@as(f32, -2.2)), result[1], epsilon));401 expect(math.approxEq(f32, @trunc(@as(f32, -2.2)), result[1], epsilon));
test/stage1/behavior/math.zig+4-4
...@@ -649,8 +649,8 @@ fn comptimeAdd(comptime a: comptime_int, comptime b: comptime_int) comptime_int...@@ -649,8 +649,8 @@ fn comptimeAdd(comptime a: comptime_int, comptime b: comptime_int) comptime_int
649test "vector integer addition" {649test "vector integer addition" {
650 const S = struct {650 const S = struct {
651 fn doTheTest() void {651 fn doTheTest() void {
652 var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };652 var a: std.meta.Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
653 var b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };653 var b: std.meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
654 var result = a + b;654 var result = a + b;
655 var result_array: [4]i32 = result;655 var result_array: [4]i32 = result;
656 const expected = [_]i32{ 6, 8, 10, 12 };656 const expected = [_]i32{ 6, 8, 10, 12 };
...@@ -693,8 +693,8 @@ test "128-bit multiplication" {...@@ -693,8 +693,8 @@ test "128-bit multiplication" {
693test "vector comparison" {693test "vector comparison" {
694 const S = struct {694 const S = struct {
695 fn doTheTest() void {695 fn doTheTest() void {
696 var a: @Vector(6, i32) = [_]i32{ 1, 3, -1, 5, 7, 9 };696 var a: std.meta.Vector(6, i32) = [_]i32{ 1, 3, -1, 5, 7, 9 };
697 var b: @Vector(6, i32) = [_]i32{ -1, 3, 0, 6, 10, -10 };697 var b: std.meta.Vector(6, i32) = [_]i32{ -1, 3, 0, 6, 10, -10 };
698 expect(mem.eql(bool, &@as([6]bool, a < b), &[_]bool{ false, false, true, true, true, false }));698 expect(mem.eql(bool, &@as([6]bool, a < b), &[_]bool{ false, false, true, true, true, false }));
699 expect(mem.eql(bool, &@as([6]bool, a <= b), &[_]bool{ false, true, true, true, true, false }));699 expect(mem.eql(bool, &@as([6]bool, a <= b), &[_]bool{ false, true, true, true, true, false }));
700 expect(mem.eql(bool, &@as([6]bool, a == b), &[_]bool{ false, true, false, false, false, false }));700 expect(mem.eql(bool, &@as([6]bool, a == b), &[_]bool{ false, true, false, false, false, false }));
test/stage1/behavior/shuffle.zig+15-14
...@@ -1,13 +1,14 @@...@@ -1,13 +1,14 @@
1const std = @import("std");1const std = @import("std");
2const mem = std.mem;2const mem = std.mem;
3const expect = std.testing.expect;3const expect = std.testing.expect;
4const Vector = std.meta.Vector;
45
5test "@shuffle" {6test "@shuffle" {
6 const S = struct {7 const S = struct {
7 fn doTheTest() void {8 fn doTheTest() void {
8 var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };9 var v: Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
9 var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };10 var x: Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };
10 const mask: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 2), 3, ~@as(i32, 3) };11 const mask: Vector(4, i32) = [4]i32{ 0, ~@as(i32, 2), 3, ~@as(i32, 3) };
11 var res = @shuffle(i32, v, x, mask);12 var res = @shuffle(i32, v, x, mask);
12 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 40, 4 }));13 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 40, 4 }));
1314
...@@ -16,28 +17,28 @@ test "@shuffle" {...@@ -16,28 +17,28 @@ test "@shuffle" {
16 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 40, 4 }));17 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 40, 4 }));
1718
18 // Undefined19 // Undefined
19 const mask2: @Vector(4, i32) = [4]i32{ 3, 1, 2, 0 };20 const mask2: Vector(4, i32) = [4]i32{ 3, 1, 2, 0 };
20 res = @shuffle(i32, v, undefined, mask2);21 res = @shuffle(i32, v, undefined, mask2);
21 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 40, -2, 30, 2147483647 }));22 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 40, -2, 30, 2147483647 }));
2223
23 // Upcasting of b24 // Upcasting of b
24 var v2: @Vector(2, i32) = [2]i32{ 2147483647, undefined };25 var v2: Vector(2, i32) = [2]i32{ 2147483647, undefined };
25 const mask3: @Vector(4, i32) = [4]i32{ ~@as(i32, 0), 2, ~@as(i32, 0), 3 };26 const mask3: Vector(4, i32) = [4]i32{ ~@as(i32, 0), 2, ~@as(i32, 0), 3 };
26 res = @shuffle(i32, x, v2, mask3);27 res = @shuffle(i32, x, v2, mask3);
27 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 2147483647, 4 }));28 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, 2147483647, 4 }));
2829
29 // Upcasting of a30 // Upcasting of a
30 var v3: @Vector(2, i32) = [2]i32{ 2147483647, -2 };31 var v3: Vector(2, i32) = [2]i32{ 2147483647, -2 };
31 const mask4: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 2), 1, ~@as(i32, 3) };32 const mask4: Vector(4, i32) = [4]i32{ 0, ~@as(i32, 2), 1, ~@as(i32, 3) };
32 res = @shuffle(i32, v3, x, mask4);33 res = @shuffle(i32, v3, x, mask4);
33 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, -2, 4 }));34 expect(mem.eql(i32, &@as([4]i32, res), &[4]i32{ 2147483647, 3, -2, 4 }));
3435
35 // bool36 // bool
36 // Disabled because of #331737 // Disabled because of #3317
37 if (@import("builtin").arch != .mipsel and std.Target.current.cpu.arch != .mips) {38 if (@import("builtin").arch != .mipsel and std.Target.current.cpu.arch != .mips) {
38 var x2: @Vector(4, bool) = [4]bool{ false, true, false, true };39 var x2: Vector(4, bool) = [4]bool{ false, true, false, true };
39 var v4: @Vector(2, bool) = [2]bool{ true, false };40 var v4: Vector(2, bool) = [2]bool{ true, false };
40 const mask5: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 };41 const mask5: Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 };
41 var res2 = @shuffle(bool, x2, v4, mask5);42 var res2 = @shuffle(bool, x2, v4, mask5);
42 expect(mem.eql(bool, &@as([4]bool, res2), &[4]bool{ false, false, true, false }));43 expect(mem.eql(bool, &@as([4]bool, res2), &[4]bool{ false, false, true, false }));
43 }44 }
...@@ -45,9 +46,9 @@ test "@shuffle" {...@@ -45,9 +46,9 @@ test "@shuffle" {
45 // TODO re-enable when LLVM codegen is fixed46 // TODO re-enable when LLVM codegen is fixed
46 // https://github.com/ziglang/zig/issues/324647 // https://github.com/ziglang/zig/issues/3246
47 if (false) {48 if (false) {
48 var x2: @Vector(3, bool) = [3]bool{ false, true, false };49 var x2: Vector(3, bool) = [3]bool{ false, true, false };
49 var v4: @Vector(2, bool) = [2]bool{ true, false };50 var v4: Vector(2, bool) = [2]bool{ true, false };
50 const mask5: @Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 };51 const mask5: Vector(4, i32) = [4]i32{ 0, ~@as(i32, 1), 1, 2 };
51 var res2 = @shuffle(bool, x2, v4, mask5);52 var res2 = @shuffle(bool, x2, v4, mask5);
52 expect(mem.eql(bool, &@as([4]bool, res2), &[4]bool{ false, false, true, false }));53 expect(mem.eql(bool, &@as([4]bool, res2), &[4]bool{ false, false, true, false }));
53 }54 }
test/stage1/behavior/type.zig+3
...@@ -200,6 +200,9 @@ test "Type.Vector" {...@@ -200,6 +200,9 @@ test "Type.Vector" {
200 @Vector(0, u8),200 @Vector(0, u8),
201 @Vector(4, u8),201 @Vector(4, u8),
202 @Vector(8, *u8),202 @Vector(8, *u8),
203 std.meta.Vector(0, u8),
204 std.meta.Vector(4, u8),
205 std.meta.Vector(8, *u8),
203 });206 });
204}207}
205208
test/stage1/behavior/type_info.zig+1-1
...@@ -296,7 +296,7 @@ test "type info: vectors" {...@@ -296,7 +296,7 @@ test "type info: vectors" {
296}296}
297297
298fn testVector() void {298fn testVector() void {
299 const vec_info = @typeInfo(@Vector(4, i32));299 const vec_info = @typeInfo(std.meta.Vector(4, i32));
300 expect(vec_info == .Vector);300 expect(vec_info == .Vector);
301 expect(vec_info.Vector.len == 4);301 expect(vec_info.Vector.len == 4);
302 expect(vec_info.Vector.child == i32);302 expect(vec_info.Vector.child == i32);
test/stage1/behavior/vector.zig+35-34
...@@ -3,11 +3,12 @@ const mem = std.mem;...@@ -3,11 +3,12 @@ const mem = std.mem;
3const math = std.math;3const math = std.math;
4const expect = std.testing.expect;4const expect = std.testing.expect;
5const expectEqual = std.testing.expectEqual;5const expectEqual = std.testing.expectEqual;
6const Vector = std.meta.Vector;
67
7test "implicit cast vector to array - bool" {8test "implicit cast vector to array - bool" {
8 const S = struct {9 const S = struct {
9 fn doTheTest() void {10 fn doTheTest() void {
10 const a: @Vector(4, bool) = [_]bool{ true, false, true, false };11 const a: Vector(4, bool) = [_]bool{ true, false, true, false };
11 const result_array: [4]bool = a;12 const result_array: [4]bool = a;
12 expect(mem.eql(bool, &result_array, &[4]bool{ true, false, true, false }));13 expect(mem.eql(bool, &result_array, &[4]bool{ true, false, true, false }));
13 }14 }
...@@ -19,12 +20,12 @@ test "implicit cast vector to array - bool" {...@@ -19,12 +20,12 @@ test "implicit cast vector to array - bool" {
19test "vector wrap operators" {20test "vector wrap operators" {
20 const S = struct {21 const S = struct {
21 fn doTheTest() void {22 fn doTheTest() void {
22 var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };23 var v: Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
23 var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };24 var x: Vector(4, i32) = [4]i32{ 1, 2147483647, 3, 4 };
24 expect(mem.eql(i32, &@as([4]i32, v +% x), &[4]i32{ -2147483648, 2147483645, 33, 44 }));25 expect(mem.eql(i32, &@as([4]i32, v +% x), &[4]i32{ -2147483648, 2147483645, 33, 44 }));
25 expect(mem.eql(i32, &@as([4]i32, v -% x), &[4]i32{ 2147483646, 2147483647, 27, 36 }));26 expect(mem.eql(i32, &@as([4]i32, v -% x), &[4]i32{ 2147483646, 2147483647, 27, 36 }));
26 expect(mem.eql(i32, &@as([4]i32, v *% x), &[4]i32{ 2147483647, 2, 90, 160 }));27 expect(mem.eql(i32, &@as([4]i32, v *% x), &[4]i32{ 2147483647, 2, 90, 160 }));
27 var z: @Vector(4, i32) = [4]i32{ 1, 2, 3, -2147483648 };28 var z: Vector(4, i32) = [4]i32{ 1, 2, 3, -2147483648 };
28 expect(mem.eql(i32, &@as([4]i32, -%z), &[4]i32{ -1, -2, -3, -2147483648 }));29 expect(mem.eql(i32, &@as([4]i32, -%z), &[4]i32{ -1, -2, -3, -2147483648 }));
29 }30 }
30 };31 };
...@@ -35,8 +36,8 @@ test "vector wrap operators" {...@@ -35,8 +36,8 @@ test "vector wrap operators" {
35test "vector bin compares with mem.eql" {36test "vector bin compares with mem.eql" {
36 const S = struct {37 const S = struct {
37 fn doTheTest() void {38 fn doTheTest() void {
38 var v: @Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };39 var v: Vector(4, i32) = [4]i32{ 2147483647, -2, 30, 40 };
39 var x: @Vector(4, i32) = [4]i32{ 1, 2147483647, 30, 4 };40 var x: Vector(4, i32) = [4]i32{ 1, 2147483647, 30, 4 };
40 expect(mem.eql(bool, &@as([4]bool, v == x), &[4]bool{ false, false, true, false }));41 expect(mem.eql(bool, &@as([4]bool, v == x), &[4]bool{ false, false, true, false }));
41 expect(mem.eql(bool, &@as([4]bool, v != x), &[4]bool{ true, true, false, true }));42 expect(mem.eql(bool, &@as([4]bool, v != x), &[4]bool{ true, true, false, true }));
42 expect(mem.eql(bool, &@as([4]bool, v < x), &[4]bool{ false, true, false, false }));43 expect(mem.eql(bool, &@as([4]bool, v < x), &[4]bool{ false, true, false, false }));
...@@ -52,8 +53,8 @@ test "vector bin compares with mem.eql" {...@@ -52,8 +53,8 @@ test "vector bin compares with mem.eql" {
52test "vector int operators" {53test "vector int operators" {
53 const S = struct {54 const S = struct {
54 fn doTheTest() void {55 fn doTheTest() void {
55 var v: @Vector(4, i32) = [4]i32{ 10, 20, 30, 40 };56 var v: Vector(4, i32) = [4]i32{ 10, 20, 30, 40 };
56 var x: @Vector(4, i32) = [4]i32{ 1, 2, 3, 4 };57 var x: Vector(4, i32) = [4]i32{ 1, 2, 3, 4 };
57 expect(mem.eql(i32, &@as([4]i32, v + x), &[4]i32{ 11, 22, 33, 44 }));58 expect(mem.eql(i32, &@as([4]i32, v + x), &[4]i32{ 11, 22, 33, 44 }));
58 expect(mem.eql(i32, &@as([4]i32, v - x), &[4]i32{ 9, 18, 27, 36 }));59 expect(mem.eql(i32, &@as([4]i32, v - x), &[4]i32{ 9, 18, 27, 36 }));
59 expect(mem.eql(i32, &@as([4]i32, v * x), &[4]i32{ 10, 40, 90, 160 }));60 expect(mem.eql(i32, &@as([4]i32, v * x), &[4]i32{ 10, 40, 90, 160 }));
...@@ -67,8 +68,8 @@ test "vector int operators" {...@@ -67,8 +68,8 @@ test "vector int operators" {
67test "vector float operators" {68test "vector float operators" {
68 const S = struct {69 const S = struct {
69 fn doTheTest() void {70 fn doTheTest() void {
70 var v: @Vector(4, f32) = [4]f32{ 10, 20, 30, 40 };71 var v: Vector(4, f32) = [4]f32{ 10, 20, 30, 40 };
71 var x: @Vector(4, f32) = [4]f32{ 1, 2, 3, 4 };72 var x: Vector(4, f32) = [4]f32{ 1, 2, 3, 4 };
72 expect(mem.eql(f32, &@as([4]f32, v + x), &[4]f32{ 11, 22, 33, 44 }));73 expect(mem.eql(f32, &@as([4]f32, v + x), &[4]f32{ 11, 22, 33, 44 }));
73 expect(mem.eql(f32, &@as([4]f32, v - x), &[4]f32{ 9, 18, 27, 36 }));74 expect(mem.eql(f32, &@as([4]f32, v - x), &[4]f32{ 9, 18, 27, 36 }));
74 expect(mem.eql(f32, &@as([4]f32, v * x), &[4]f32{ 10, 40, 90, 160 }));75 expect(mem.eql(f32, &@as([4]f32, v * x), &[4]f32{ 10, 40, 90, 160 }));
...@@ -82,8 +83,8 @@ test "vector float operators" {...@@ -82,8 +83,8 @@ test "vector float operators" {
82test "vector bit operators" {83test "vector bit operators" {
83 const S = struct {84 const S = struct {
84 fn doTheTest() void {85 fn doTheTest() void {
85 var v: @Vector(4, u8) = [4]u8{ 0b10101010, 0b10101010, 0b10101010, 0b10101010 };86 var v: Vector(4, u8) = [4]u8{ 0b10101010, 0b10101010, 0b10101010, 0b10101010 };
86 var x: @Vector(4, u8) = [4]u8{ 0b11110000, 0b00001111, 0b10101010, 0b01010101 };87 var x: Vector(4, u8) = [4]u8{ 0b11110000, 0b00001111, 0b10101010, 0b01010101 };
87 expect(mem.eql(u8, &@as([4]u8, v ^ x), &[4]u8{ 0b01011010, 0b10100101, 0b00000000, 0b11111111 }));88 expect(mem.eql(u8, &@as([4]u8, v ^ x), &[4]u8{ 0b01011010, 0b10100101, 0b00000000, 0b11111111 }));
88 expect(mem.eql(u8, &@as([4]u8, v | x), &[4]u8{ 0b11111010, 0b10101111, 0b10101010, 0b11111111 }));89 expect(mem.eql(u8, &@as([4]u8, v | x), &[4]u8{ 0b11111010, 0b10101111, 0b10101010, 0b11111111 }));
89 expect(mem.eql(u8, &@as([4]u8, v & x), &[4]u8{ 0b10100000, 0b00001010, 0b10101010, 0b00000000 }));90 expect(mem.eql(u8, &@as([4]u8, v & x), &[4]u8{ 0b10100000, 0b00001010, 0b10101010, 0b00000000 }));
...@@ -96,7 +97,7 @@ test "vector bit operators" {...@@ -96,7 +97,7 @@ test "vector bit operators" {
96test "implicit cast vector to array" {97test "implicit cast vector to array" {
97 const S = struct {98 const S = struct {
98 fn doTheTest() void {99 fn doTheTest() void {
99 var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };100 var a: Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
100 var result_array: [4]i32 = a;101 var result_array: [4]i32 = a;
101 result_array = a;102 result_array = a;
102 expect(mem.eql(i32, &result_array, &[4]i32{ 1, 2, 3, 4 }));103 expect(mem.eql(i32, &result_array, &[4]i32{ 1, 2, 3, 4 }));
...@@ -109,7 +110,7 @@ test "implicit cast vector to array" {...@@ -109,7 +110,7 @@ test "implicit cast vector to array" {
109test "array to vector" {110test "array to vector" {
110 var foo: f32 = 3.14;111 var foo: f32 = 3.14;
111 var arr = [4]f32{ foo, 1.5, 0.0, 0.0 };112 var arr = [4]f32{ foo, 1.5, 0.0, 0.0 };
112 var vec: @Vector(4, f32) = arr;113 var vec: Vector(4, f32) = arr;
113}114}
114115
115test "vector casts of sizes not divisable by 8" {116test "vector casts of sizes not divisable by 8" {
...@@ -119,22 +120,22 @@ test "vector casts of sizes not divisable by 8" {...@@ -119,22 +120,22 @@ test "vector casts of sizes not divisable by 8" {
119 const S = struct {120 const S = struct {
120 fn doTheTest() void {121 fn doTheTest() void {
121 {122 {
122 var v: @Vector(4, u3) = [4]u3{ 5, 2, 3, 0 };123 var v: Vector(4, u3) = [4]u3{ 5, 2, 3, 0 };
123 var x: [4]u3 = v;124 var x: [4]u3 = v;
124 expect(mem.eql(u3, &x, &@as([4]u3, v)));125 expect(mem.eql(u3, &x, &@as([4]u3, v)));
125 }126 }
126 {127 {
127 var v: @Vector(4, u2) = [4]u2{ 1, 2, 3, 0 };128 var v: Vector(4, u2) = [4]u2{ 1, 2, 3, 0 };
128 var x: [4]u2 = v;129 var x: [4]u2 = v;
129 expect(mem.eql(u2, &x, &@as([4]u2, v)));130 expect(mem.eql(u2, &x, &@as([4]u2, v)));
130 }131 }
131 {132 {
132 var v: @Vector(4, u1) = [4]u1{ 1, 0, 1, 0 };133 var v: Vector(4, u1) = [4]u1{ 1, 0, 1, 0 };
133 var x: [4]u1 = v;134 var x: [4]u1 = v;
134 expect(mem.eql(u1, &x, &@as([4]u1, v)));135 expect(mem.eql(u1, &x, &@as([4]u1, v)));
135 }136 }
136 {137 {
137 var v: @Vector(4, bool) = [4]bool{ false, false, true, false };138 var v: Vector(4, bool) = [4]bool{ false, false, true, false };
138 var x: [4]bool = v;139 var x: [4]bool = v;
139 expect(mem.eql(bool, &x, &@as([4]bool, v)));140 expect(mem.eql(bool, &x, &@as([4]bool, v)));
140 }141 }
...@@ -149,7 +150,7 @@ test "vector @splat" {...@@ -149,7 +150,7 @@ test "vector @splat" {
149 fn doTheTest() void {150 fn doTheTest() void {
150 var v: u32 = 5;151 var v: u32 = 5;
151 var x = @splat(4, v);152 var x = @splat(4, v);
152 expect(@TypeOf(x) == @Vector(4, u32));153 expect(@TypeOf(x) == Vector(4, u32));
153 var array_x: [4]u32 = x;154 var array_x: [4]u32 = x;
154 expect(array_x[0] == 5);155 expect(array_x[0] == 5);
155 expect(array_x[1] == 5);156 expect(array_x[1] == 5);
...@@ -164,7 +165,7 @@ test "vector @splat" {...@@ -164,7 +165,7 @@ test "vector @splat" {
164test "load vector elements via comptime index" {165test "load vector elements via comptime index" {
165 const S = struct {166 const S = struct {
166 fn doTheTest() void {167 fn doTheTest() void {
167 var v: @Vector(4, i32) = [_]i32{ 1, 2, 3, undefined };168 var v: Vector(4, i32) = [_]i32{ 1, 2, 3, undefined };
168 expect(v[0] == 1);169 expect(v[0] == 1);
169 expect(v[1] == 2);170 expect(v[1] == 2);
170 expect(loadv(&v[2]) == 3);171 expect(loadv(&v[2]) == 3);
...@@ -181,7 +182,7 @@ test "load vector elements via comptime index" {...@@ -181,7 +182,7 @@ test "load vector elements via comptime index" {
181test "store vector elements via comptime index" {182test "store vector elements via comptime index" {
182 const S = struct {183 const S = struct {
183 fn doTheTest() void {184 fn doTheTest() void {
184 var v: @Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };185 var v: Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };
185186
186 v[2] = 42;187 v[2] = 42;
187 expect(v[1] == 5);188 expect(v[1] == 5);
...@@ -204,7 +205,7 @@ test "store vector elements via comptime index" {...@@ -204,7 +205,7 @@ test "store vector elements via comptime index" {
204test "load vector elements via runtime index" {205test "load vector elements via runtime index" {
205 const S = struct {206 const S = struct {
206 fn doTheTest() void {207 fn doTheTest() void {
207 var v: @Vector(4, i32) = [_]i32{ 1, 2, 3, undefined };208 var v: Vector(4, i32) = [_]i32{ 1, 2, 3, undefined };
208 var i: u32 = 0;209 var i: u32 = 0;
209 expect(v[i] == 1);210 expect(v[i] == 1);
210 i += 1;211 i += 1;
...@@ -221,7 +222,7 @@ test "load vector elements via runtime index" {...@@ -221,7 +222,7 @@ test "load vector elements via runtime index" {
221test "store vector elements via runtime index" {222test "store vector elements via runtime index" {
222 const S = struct {223 const S = struct {
223 fn doTheTest() void {224 fn doTheTest() void {
224 var v: @Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };225 var v: Vector(4, i32) = [_]i32{ 1, 5, 3, undefined };
225 var i: u32 = 2;226 var i: u32 = 2;
226 v[i] = 1;227 v[i] = 1;
227 expect(v[1] == 5);228 expect(v[1] == 5);
...@@ -238,7 +239,7 @@ test "store vector elements via runtime index" {...@@ -238,7 +239,7 @@ test "store vector elements via runtime index" {
238239
239test "initialize vector which is a struct field" {240test "initialize vector which is a struct field" {
240 const Vec4Obj = struct {241 const Vec4Obj = struct {
241 data: @Vector(4, f32),242 data: Vector(4, f32),
242 };243 };
243244
244 const S = struct {245 const S = struct {
...@@ -256,8 +257,8 @@ test "vector comparison operators" {...@@ -256,8 +257,8 @@ test "vector comparison operators" {
256 const S = struct {257 const S = struct {
257 fn doTheTest() void {258 fn doTheTest() void {
258 {259 {
259 const v1: @Vector(4, bool) = [_]bool{ true, false, true, false };260 const v1: Vector(4, bool) = [_]bool{ true, false, true, false };
260 const v2: @Vector(4, bool) = [_]bool{ false, true, false, true };261 const v2: Vector(4, bool) = [_]bool{ false, true, false, true };
261 expectEqual(@splat(4, true), v1 == v1);262 expectEqual(@splat(4, true), v1 == v1);
262 expectEqual(@splat(4, false), v1 == v2);263 expectEqual(@splat(4, false), v1 == v2);
263 expectEqual(@splat(4, true), v1 != v2);264 expectEqual(@splat(4, true), v1 != v2);
...@@ -265,7 +266,7 @@ test "vector comparison operators" {...@@ -265,7 +266,7 @@ test "vector comparison operators" {
265 }266 }
266 {267 {
267 const v1 = @splat(4, @as(u32, 0xc0ffeeee));268 const v1 = @splat(4, @as(u32, 0xc0ffeeee));
268 const v2: @Vector(4, c_uint) = v1;269 const v2: Vector(4, c_uint) = v1;
269 const v3 = @splat(4, @as(u32, 0xdeadbeef));270 const v3 = @splat(4, @as(u32, 0xdeadbeef));
270 expectEqual(@splat(4, true), v1 == v2);271 expectEqual(@splat(4, true), v1 == v2);
271 expectEqual(@splat(4, false), v1 == v3);272 expectEqual(@splat(4, false), v1 == v3);
...@@ -280,7 +281,7 @@ test "vector comparison operators" {...@@ -280,7 +281,7 @@ test "vector comparison operators" {
280281
281test "vector division operators" {282test "vector division operators" {
282 const S = struct {283 const S = struct {
283 fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) void {284 fn doTheTestDiv(comptime T: type, x: Vector(4, T), y: Vector(4, T)) void {
284 if (!comptime std.meta.trait.isSignedInt(T)) {285 if (!comptime std.meta.trait.isSignedInt(T)) {
285 const d0 = x / y;286 const d0 = x / y;
286 for (@as([4]T, d0)) |v, i| {287 for (@as([4]T, d0)) |v, i| {
...@@ -301,7 +302,7 @@ test "vector division operators" {...@@ -301,7 +302,7 @@ test "vector division operators" {
301 }302 }
302 }303 }
303304
304 fn doTheTestMod(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) void {305 fn doTheTestMod(comptime T: type, x: Vector(4, T), y: Vector(4, T)) void {
305 if ((!comptime std.meta.trait.isSignedInt(T)) and @typeInfo(T) != .Float) {306 if ((!comptime std.meta.trait.isSignedInt(T)) and @typeInfo(T) != .Float) {
306 const r0 = x % y;307 const r0 = x % y;
307 for (@as([4]T, r0)) |v, i| {308 for (@as([4]T, r0)) |v, i| {
...@@ -362,7 +363,7 @@ test "vector division operators" {...@@ -362,7 +363,7 @@ test "vector division operators" {
362363
363test "vector bitwise not operator" {364test "vector bitwise not operator" {
364 const S = struct {365 const S = struct {
365 fn doTheTestNot(comptime T: type, x: @Vector(4, T)) void {366 fn doTheTestNot(comptime T: type, x: Vector(4, T)) void {
366 var y = ~x;367 var y = ~x;
367 for (@as([4]T, y)) |v, i| {368 for (@as([4]T, y)) |v, i| {
368 expectEqual(~x[i], v);369 expectEqual(~x[i], v);
...@@ -392,8 +393,8 @@ test "vector shift operators" {...@@ -392,8 +393,8 @@ test "vector shift operators" {
392 const TX = @typeInfo(@TypeOf(x)).Array.child;393 const TX = @typeInfo(@TypeOf(x)).Array.child;
393 const TY = @typeInfo(@TypeOf(y)).Array.child;394 const TY = @typeInfo(@TypeOf(y)).Array.child;
394395
395 var xv = @as(@Vector(N, TX), x);396 var xv = @as(Vector(N, TX), x);
396 var yv = @as(@Vector(N, TY), y);397 var yv = @as(Vector(N, TY), y);
397398
398 var z0 = xv >> yv;399 var z0 = xv >> yv;
399 for (@as([N]TX, z0)) |v, i| {400 for (@as([N]TX, z0)) |v, i| {
...@@ -409,8 +410,8 @@ test "vector shift operators" {...@@ -409,8 +410,8 @@ test "vector shift operators" {
409 const TX = @typeInfo(@TypeOf(x)).Array.child;410 const TX = @typeInfo(@TypeOf(x)).Array.child;
410 const TY = @typeInfo(@TypeOf(y)).Array.child;411 const TY = @typeInfo(@TypeOf(y)).Array.child;
411412
412 var xv = @as(@Vector(N, TX), x);413 var xv = @as(Vector(N, TX), x);
413 var yv = @as(@Vector(N, TY), y);414 var yv = @as(Vector(N, TY), y);
414415
415 var z = if (dir == .Left) @shlExact(xv, yv) else @shrExact(xv, yv);416 var z = if (dir == .Left) @shlExact(xv, yv) else @shrExact(xv, yv);
416 for (@as([N]TX, z)) |v, i| {417 for (@as([N]TX, z)) |v, i| {