authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-03-30 11:12:14-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-03-30 14:12:14-04:00
logb73cf97c93bb23150475ac0c23aadf86dbd71bc4
treea2b144c923c303e815502e683f75fd4a9b79bba8
parentb153e156b1d431995e7f89150c93ec05aa3966f8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

replace other uses of `std.meta.Vector` with `@Vector` (#11346)


17 files changed, 113 insertions(+), 127 deletions(-)

lib/std/crypto/aes/aesni.zig+1-3
......@@ -2,9 +2,7 @@ const std = @import("../../std.zig");
22const builtin = @import("builtin");
33const mem = std.mem;
44const debug = std.debug;
5const Vector = std.meta.Vector;
6
7const BlockVec = Vector(2, u64);
5const BlockVec = @Vector(2, u64);
86
97/// A single AES block.
108pub const Block = struct {
lib/std/crypto/aes/armcrypto.zig+3-5
......@@ -1,9 +1,7 @@
11const std = @import("../../std.zig");
22const mem = std.mem;
33const debug = std.debug;
4const Vector = std.meta.Vector;
5
6const BlockVec = Vector(2, u64);
4const BlockVec = @Vector(2, u64);
75
86/// A single AES block.
97pub const Block = struct {
......@@ -29,7 +27,7 @@ pub const Block = struct {
2927 return mem.toBytes(x);
3028 }
3129
32 const zero = Vector(2, u64){ 0, 0 };
30 const zero = @Vector(2, u64){ 0, 0 };
3331
3432 /// Encrypt a block with a round key.
3533 pub inline fn encrypt(block: Block, round_key: Block) Block {
......@@ -182,7 +180,7 @@ fn KeySchedule(comptime Aes: type) type {
182180 return struct {
183181 const Self = @This();
184182
185 const zero = Vector(2, u64){ 0, 0 };
183 const zero = @Vector(2, u64){ 0, 0 };
186184 const mask1 = @Vector(16, u8){ 13, 14, 15, 12, 13, 14, 15, 12, 13, 14, 15, 12, 13, 14, 15, 12 };
187185 const mask2 = @Vector(16, u8){ 12, 13, 14, 15, 12, 13, 14, 15, 12, 13, 14, 15, 12, 13, 14, 15 };
188186
lib/std/crypto/chacha20.zig+1-2
......@@ -7,7 +7,6 @@ const mem = std.mem;
77const assert = std.debug.assert;
88const testing = std.testing;
99const maxInt = math.maxInt;
10const Vector = std.meta.Vector;
1110const Poly1305 = std.crypto.onetimeauth.Poly1305;
1211const AuthenticationError = std.crypto.errors.AuthenticationError;
1312
......@@ -79,7 +78,7 @@ pub const XChaCha8Poly1305 = XChaChaPoly1305(8);
7978// Vectorized implementation of the core function
8079fn ChaChaVecImpl(comptime rounds_nb: usize) type {
8180 return struct {
82 const Lane = Vector(4, u32);
81 const Lane = @Vector(4, u32);
8382 const BlockVec = [4]Lane;
8483
8584 fn initContext(key: [8]u32, d: [4]u32) BlockVec {
lib/std/crypto/ghash.zig+6-8
......@@ -92,23 +92,21 @@ pub const Ghash = struct {
9292 }
9393
9494 inline fn clmul_pclmul(x: u64, y: u64) u64 {
95 const Vector = std.meta.Vector;
9695 const product = asm (
9796 \\ vpclmulqdq $0x00, %[x], %[y], %[out]
98 : [out] "=x" (-> Vector(2, u64)),
99 : [x] "x" (@bitCast(Vector(2, u64), @as(u128, x))),
100 [y] "x" (@bitCast(Vector(2, u64), @as(u128, y))),
97 : [out] "=x" (-> @Vector(2, u64)),
98 : [x] "x" (@bitCast(@Vector(2, u64), @as(u128, x))),
99 [y] "x" (@bitCast(@Vector(2, u64), @as(u128, y))),
101100 );
102101 return product[0];
103102 }
104103
105104 inline fn clmul_pmull(x: u64, y: u64) u64 {
106 const Vector = std.meta.Vector;
107105 const product = asm (
108106 \\ pmull %[out].1q, %[x].1d, %[y].1d
109 : [out] "=w" (-> Vector(2, u64)),
110 : [x] "w" (@bitCast(Vector(2, u64), @as(u128, x))),
111 [y] "w" (@bitCast(Vector(2, u64), @as(u128, y))),
107 : [out] "=w" (-> @Vector(2, u64)),
108 : [x] "w" (@bitCast(@Vector(2, u64), @as(u128, x))),
109 [y] "w" (@bitCast(@Vector(2, u64), @as(u128, y))),
112110 );
113111 return product[0];
114112 }
lib/std/crypto/gimli.zig+1-2
......@@ -15,7 +15,6 @@ const debug = std.debug;
1515const assert = std.debug.assert;
1616const testing = std.testing;
1717const htest = @import("test.zig");
18const Vector = std.meta.Vector;
1918const AuthenticationError = std.crypto.errors.AuthenticationError;
2019
2120pub const State = struct {
......@@ -111,7 +110,7 @@ pub const State = struct {
111110 self.endianSwap();
112111 }
113112
114 const Lane = Vector(4, u32);
113 const Lane = @Vector(4, u32);
115114
116115 inline fn shift(x: Lane, comptime n: comptime_int) Lane {
117116 return x << @splat(4, @as(u5, n));
lib/std/crypto/salsa20.zig+2-3
......@@ -5,7 +5,6 @@ const debug = std.debug;
55const math = std.math;
66const mem = std.mem;
77const utils = std.crypto.utils;
8const Vector = std.meta.Vector;
98
109const Poly1305 = crypto.onetimeauth.Poly1305;
1110const Blake2b = crypto.hash.blake2.Blake2b;
......@@ -16,8 +15,8 @@ const IdentityElementError = crypto.errors.IdentityElementError;
1615const WeakPublicKeyError = crypto.errors.WeakPublicKeyError;
1716
1817const Salsa20VecImpl = struct {
19 const Lane = Vector(4, u32);
20 const Half = Vector(2, u32);
18 const Lane = @Vector(4, u32);
19 const Half = @Vector(2, u32);
2120 const BlockVec = [4]Lane;
2221
2322 fn initContext(key: [8]u32, d: [4]u32) BlockVec {
lib/std/crypto/utils.zig+5-5
......@@ -149,11 +149,11 @@ test "crypto.utils.timingSafeEql (vectors)" {
149149 var b: [100]u8 = undefined;
150150 random.bytes(a[0..]);
151151 random.bytes(b[0..]);
152 const v1: std.meta.Vector(100, u8) = a;
153 const v2: std.meta.Vector(100, u8) = b;
154 try testing.expect(!timingSafeEql(std.meta.Vector(100, u8), v1, v2));
155 const v3: std.meta.Vector(100, u8) = a;
156 try testing.expect(timingSafeEql(std.meta.Vector(100, u8), v1, v3));
152 const v1: @Vector(100, u8) = a;
153 const v2: @Vector(100, u8) = b;
154 try testing.expect(!timingSafeEql(@Vector(100, u8), v1, v2));
155 const v3: @Vector(100, u8) = a;
156 try testing.expect(timingSafeEql(@Vector(100, u8), v1, v3));
157157}
158158
159159test "crypto.utils.timingSafeCompare" {
lib/std/fmt.zig+3-3
......@@ -2594,9 +2594,9 @@ test "vector" {
25942594 return error.SkipZigTest;
25952595 }
25962596
2597 const vbool: std.meta.Vector(4, bool) = [_]bool{ true, false, true, false };
2598 const vi64: std.meta.Vector(4, i64) = [_]i64{ -2, -1, 0, 1 };
2599 const vu64: std.meta.Vector(4, u64) = [_]u64{ 1000, 2000, 3000, 4000 };
2597 const vbool: @Vector(4, bool) = [_]bool{ true, false, true, false };
2598 const vi64: @Vector(4, i64) = [_]i64{ -2, -1, 0, 1 };
2599 const vu64: @Vector(4, u64) = [_]u64{ 1000, 2000, 3000, 4000 };
26002600
26012601 try expectFmt("{ true, false, true, false }", "{}", .{vbool});
26022602 try expectFmt("{ -2, -1, 0, 1 }", "{}", .{vi64});
lib/std/math.zig+10-10
......@@ -524,9 +524,9 @@ test "shl" {
524524 try testing.expect(shl(u8, 0b11111111, 8) == 0);
525525 try testing.expect(shl(u8, 0b11111111, 9) == 0);
526526 try testing.expect(shl(u8, 0b11111111, -2) == 0b00111111);
527 try testing.expect(shl(std.meta.Vector(1, u32), std.meta.Vector(1, u32){42}, @as(usize, 1))[0] == @as(u32, 42) << 1);
528 try testing.expect(shl(std.meta.Vector(1, u32), std.meta.Vector(1, u32){42}, @as(isize, -1))[0] == @as(u32, 42) >> 1);
529 try testing.expect(shl(std.meta.Vector(1, u32), std.meta.Vector(1, u32){42}, 33)[0] == 0);
527 try testing.expect(shl(@Vector(1, u32), @Vector(1, u32){42}, @as(usize, 1))[0] == @as(u32, 42) << 1);
528 try testing.expect(shl(@Vector(1, u32), @Vector(1, u32){42}, @as(isize, -1))[0] == @as(u32, 42) >> 1);
529 try testing.expect(shl(@Vector(1, u32), @Vector(1, u32){42}, 33)[0] == 0);
530530}
531531
532532/// Shifts right. Overflowed bits are truncated.
......@@ -564,9 +564,9 @@ test "shr" {
564564 try testing.expect(shr(u8, 0b11111111, 8) == 0);
565565 try testing.expect(shr(u8, 0b11111111, 9) == 0);
566566 try testing.expect(shr(u8, 0b11111111, -2) == 0b11111100);
567 try testing.expect(shr(std.meta.Vector(1, u32), std.meta.Vector(1, u32){42}, @as(usize, 1))[0] == @as(u32, 42) >> 1);
568 try testing.expect(shr(std.meta.Vector(1, u32), std.meta.Vector(1, u32){42}, @as(isize, -1))[0] == @as(u32, 42) << 1);
569 try testing.expect(shr(std.meta.Vector(1, u32), std.meta.Vector(1, u32){42}, 33)[0] == 0);
567 try testing.expect(shr(@Vector(1, u32), @Vector(1, u32){42}, @as(usize, 1))[0] == @as(u32, 42) >> 1);
568 try testing.expect(shr(@Vector(1, u32), @Vector(1, u32){42}, @as(isize, -1))[0] == @as(u32, 42) << 1);
569 try testing.expect(shr(@Vector(1, u32), @Vector(1, u32){42}, 33)[0] == 0);
570570}
571571
572572/// Rotates right. Only unsigned values can be rotated. Negative shift
......@@ -593,8 +593,8 @@ test "rotr" {
593593 try testing.expect(rotr(u8, 0b00000001, @as(usize, 8)) == 0b00000001);
594594 try testing.expect(rotr(u8, 0b00000001, @as(usize, 4)) == 0b00010000);
595595 try testing.expect(rotr(u8, 0b00000001, @as(isize, -1)) == 0b00000010);
596 try testing.expect(rotr(std.meta.Vector(1, u32), std.meta.Vector(1, u32){1}, @as(usize, 1))[0] == @as(u32, 1) << 31);
597 try testing.expect(rotr(std.meta.Vector(1, u32), std.meta.Vector(1, u32){1}, @as(isize, -1))[0] == @as(u32, 1) << 1);
596 try testing.expect(rotr(@Vector(1, u32), @Vector(1, u32){1}, @as(usize, 1))[0] == @as(u32, 1) << 31);
597 try testing.expect(rotr(@Vector(1, u32), @Vector(1, u32){1}, @as(isize, -1))[0] == @as(u32, 1) << 1);
598598}
599599
600600/// Rotates left. Only unsigned values can be rotated. Negative shift
......@@ -621,8 +621,8 @@ test "rotl" {
621621 try testing.expect(rotl(u8, 0b00000001, @as(usize, 8)) == 0b00000001);
622622 try testing.expect(rotl(u8, 0b00000001, @as(usize, 4)) == 0b00010000);
623623 try testing.expect(rotl(u8, 0b00000001, @as(isize, -1)) == 0b10000000);
624 try testing.expect(rotl(std.meta.Vector(1, u32), std.meta.Vector(1, u32){1 << 31}, @as(usize, 1))[0] == 1);
625 try testing.expect(rotl(std.meta.Vector(1, u32), std.meta.Vector(1, u32){1 << 31}, @as(isize, -1))[0] == @as(u32, 1) << 30);
624 try testing.expect(rotl(@Vector(1, u32), @Vector(1, u32){1 << 31}, @as(usize, 1))[0] == 1);
625 try testing.expect(rotl(@Vector(1, u32), @Vector(1, u32){1 << 31}, @as(isize, -1))[0] == @as(u32, 1) << 30);
626626}
627627
628628/// Returns an unsigned int type that can hold the number of bits in T
lib/std/simd.zig+37-39
......@@ -6,8 +6,6 @@
66const std = @import("std");
77const builtin = @import("builtin");
88
9pub const Vector = std.meta.Vector;
10
119pub fn suggestVectorSizeForCpu(comptime T: type, cpu: std.Target.Cpu) ?usize {
1210 switch (cpu.arch) {
1311 .x86_64 => {
......@@ -55,7 +53,7 @@ pub fn VectorCount(comptime VectorType: type) type {
5553
5654/// Returns a vector containing the first `len` integers in order from 0 to `len`-1.
5755/// For example, `iota(i32, 8)` will return a vector containing `.{0, 1, 2, 3, 4, 5, 6, 7}`.
58pub fn iota(comptime T: type, comptime len: usize) Vector(len, T) {
56pub fn iota(comptime T: type, comptime len: usize) @Vector(len, T) {
5957 var out: [len]T = undefined;
6058 for (out) |*element, i| {
6159 element.* = switch (@typeInfo(T)) {
......@@ -64,12 +62,12 @@ pub fn iota(comptime T: type, comptime len: usize) Vector(len, T) {
6462 else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."),
6563 };
6664 }
67 return @as(Vector(len, T), out);
65 return @as(@Vector(len, T), out);
6866}
6967
7068/// Returns a vector containing the same elements as the input, but repeated until the desired length is reached.
7169/// For example, `repeat(8, [_]u32{1, 2, 3})` will return a vector containing `.{1, 2, 3, 1, 2, 3, 1, 2}`.
72pub fn repeat(comptime len: usize, vec: anytype) Vector(len, std.meta.Child(@TypeOf(vec))) {
70pub fn repeat(comptime len: usize, vec: anytype) @Vector(len, std.meta.Child(@TypeOf(vec))) {
7371 const Child = std.meta.Child(@TypeOf(vec));
7472
7573 return @shuffle(Child, vec, undefined, iota(i32, len) % @splat(len, @intCast(i32, vectorLength(@TypeOf(vec)))));
......@@ -77,7 +75,7 @@ pub fn repeat(comptime len: usize, vec: anytype) Vector(len, std.meta.Child(@Typ
7775
7876/// Returns a vector containing all elements of the first vector at the lower indices followed by all elements of the second vector
7977/// at the higher indices.
80pub fn join(a: anytype, b: anytype) Vector(vectorLength(@TypeOf(a)) + vectorLength(@TypeOf(b)), std.meta.Child(@TypeOf(a))) {
78pub fn join(a: anytype, b: anytype) @Vector(vectorLength(@TypeOf(a)) + vectorLength(@TypeOf(b)), std.meta.Child(@TypeOf(a))) {
8179 const Child = std.meta.Child(@TypeOf(a));
8280 const a_len = vectorLength(@TypeOf(a));
8381 const b_len = vectorLength(@TypeOf(b));
......@@ -87,7 +85,7 @@ pub fn join(a: anytype, b: anytype) Vector(vectorLength(@TypeOf(a)) + vectorLeng
8785
8886/// Returns a vector whose elements alternates between those of each input vector.
8987/// For example, `interlace(.{[4]u32{11, 12, 13, 14}, [4]u32{21, 22, 23, 24}})` returns a vector containing `.{11, 21, 12, 22, 13, 23, 14, 24}`.
90pub fn interlace(vecs: anytype) Vector(vectorLength(@TypeOf(vecs[0])) * vecs.len, std.meta.Child(@TypeOf(vecs[0]))) {
88pub fn interlace(vecs: anytype) @Vector(vectorLength(@TypeOf(vecs[0])) * vecs.len, std.meta.Child(@TypeOf(vecs[0]))) {
9189 // interlace doesn't work on MIPS, for some reason.
9290 // Notes from earlier debug attempt:
9391 // The indices are correct. The problem seems to be with the @shuffle builtin.
......@@ -128,14 +126,14 @@ pub fn interlace(vecs: anytype) Vector(vectorLength(@TypeOf(vecs[0])) * vecs.len
128126pub fn deinterlace(
129127 comptime vec_count: usize,
130128 interlaced: anytype,
131) [vec_count]Vector(
129) [vec_count]@Vector(
132130 vectorLength(@TypeOf(interlaced)) / vec_count,
133131 std.meta.Child(@TypeOf(interlaced)),
134132) {
135133 const vec_len = vectorLength(@TypeOf(interlaced)) / vec_count;
136134 const Child = std.meta.Child(@TypeOf(interlaced));
137135
138 var out: [vec_count]Vector(vec_len, Child) = undefined;
136 var out: [vec_count]@Vector(vec_len, Child) = undefined;
139137
140138 comptime var i: usize = 0; // for-loops don't work for this, apparently.
141139 inline while (i < out.len) : (i += 1) {
......@@ -150,7 +148,7 @@ pub fn extract(
150148 vec: anytype,
151149 comptime first: VectorIndex(@TypeOf(vec)),
152150 comptime count: VectorCount(@TypeOf(vec)),
153) Vector(count, std.meta.Child(@TypeOf(vec))) {
151) @Vector(count, std.meta.Child(@TypeOf(vec))) {
154152 const Child = std.meta.Child(@TypeOf(vec));
155153 const len = vectorLength(@TypeOf(vec));
156154
......@@ -160,15 +158,15 @@ pub fn extract(
160158}
161159
162160test "vector patterns" {
163 const base = Vector(4, u32){ 10, 20, 30, 40 };
164 const other_base = Vector(4, u32){ 55, 66, 77, 88 };
165
166 const small_bases = [5]Vector(2, u8){
167 Vector(2, u8){ 0, 1 },
168 Vector(2, u8){ 2, 3 },
169 Vector(2, u8){ 4, 5 },
170 Vector(2, u8){ 6, 7 },
171 Vector(2, u8){ 8, 9 },
161 const base = @Vector(4, u32){ 10, 20, 30, 40 };
162 const other_base = @Vector(4, u32){ 55, 66, 77, 88 };
163
164 const small_bases = [5]@Vector(2, u8){
165 @Vector(2, u8){ 0, 1 },
166 @Vector(2, u8){ 2, 3 },
167 @Vector(2, u8){ 4, 5 },
168 @Vector(2, u8){ 6, 7 },
169 @Vector(2, u8){ 8, 9 },
172170 };
173171
174172 try std.testing.expectEqual([6]u32{ 10, 20, 30, 40, 10, 20 }, repeat(6, base));
......@@ -228,7 +226,7 @@ pub fn reverseOrder(vec: anytype) @TypeOf(vec) {
228226}
229227
230228test "vector shifting" {
231 const base = Vector(4, u32){ 10, 20, 30, 40 };
229 const base = @Vector(4, u32){ 10, 20, 30, 40 };
232230
233231 try std.testing.expectEqual([4]u32{ 30, 40, 999, 999 }, shiftElementsLeft(base, 2, 999));
234232 try std.testing.expectEqual([4]u32{ 999, 999, 10, 20 }, shiftElementsRight(base, 2, 999));
......@@ -286,7 +284,7 @@ pub fn countElementsWithValue(vec: anytype, value: std.meta.Child(@TypeOf(vec)))
286284}
287285
288286test "vector searching" {
289 const base = Vector(8, u32){ 6, 4, 7, 4, 4, 2, 3, 7 };
287 const base = @Vector(8, u32){ 6, 4, 7, 4, 4, 2, 3, 7 };
290288
291289 try std.testing.expectEqual(@as(?u3, 1), firstIndexOfValue(base, 4));
292290 try std.testing.expectEqual(@as(?u3, 4), lastIndexOfValue(base, 4));
......@@ -382,28 +380,28 @@ test "vector prefix scan" {
382380 return error.SkipZigTest;
383381 }
384382
385 const int_base = Vector(4, i32){ 11, 23, 9, -21 };
386 const float_base = Vector(4, f32){ 2, 0.5, -10, 6.54321 };
387 const bool_base = Vector(4, bool){ true, false, true, false };
383 const int_base = @Vector(4, i32){ 11, 23, 9, -21 };
384 const float_base = @Vector(4, f32){ 2, 0.5, -10, 6.54321 };
385 const bool_base = @Vector(4, bool){ true, false, true, false };
388386
389387 try std.testing.expectEqual(iota(u8, 32) + @splat(32, @as(u8, 1)), prefixScan(.Add, 1, @splat(32, @as(u8, 1))));
390 try std.testing.expectEqual(Vector(4, i32){ 11, 3, 1, 1 }, prefixScan(.And, 1, int_base));
391 try std.testing.expectEqual(Vector(4, i32){ 11, 31, 31, -1 }, prefixScan(.Or, 1, int_base));
392 try std.testing.expectEqual(Vector(4, i32){ 11, 28, 21, -2 }, prefixScan(.Xor, 1, int_base));
393 try std.testing.expectEqual(Vector(4, i32){ 11, 34, 43, 22 }, prefixScan(.Add, 1, int_base));
394 try std.testing.expectEqual(Vector(4, i32){ 11, 253, 2277, -47817 }, prefixScan(.Mul, 1, int_base));
395 try std.testing.expectEqual(Vector(4, i32){ 11, 11, 9, -21 }, prefixScan(.Min, 1, int_base));
396 try std.testing.expectEqual(Vector(4, i32){ 11, 23, 23, 23 }, prefixScan(.Max, 1, int_base));
388 try std.testing.expectEqual(@Vector(4, i32){ 11, 3, 1, 1 }, prefixScan(.And, 1, int_base));
389 try std.testing.expectEqual(@Vector(4, i32){ 11, 31, 31, -1 }, prefixScan(.Or, 1, int_base));
390 try std.testing.expectEqual(@Vector(4, i32){ 11, 28, 21, -2 }, prefixScan(.Xor, 1, int_base));
391 try std.testing.expectEqual(@Vector(4, i32){ 11, 34, 43, 22 }, prefixScan(.Add, 1, int_base));
392 try std.testing.expectEqual(@Vector(4, i32){ 11, 253, 2277, -47817 }, prefixScan(.Mul, 1, int_base));
393 try std.testing.expectEqual(@Vector(4, i32){ 11, 11, 9, -21 }, prefixScan(.Min, 1, int_base));
394 try std.testing.expectEqual(@Vector(4, i32){ 11, 23, 23, 23 }, prefixScan(.Max, 1, int_base));
397395
398396 // Trying to predict all inaccuracies when adding and multiplying floats with prefixScans would be a mess, so we don't test those.
399 try std.testing.expectEqual(Vector(4, f32){ 2, 0.5, -10, -10 }, prefixScan(.Min, 1, float_base));
400 try std.testing.expectEqual(Vector(4, f32){ 2, 2, 2, 6.54321 }, prefixScan(.Max, 1, float_base));
397 try std.testing.expectEqual(@Vector(4, f32){ 2, 0.5, -10, -10 }, prefixScan(.Min, 1, float_base));
398 try std.testing.expectEqual(@Vector(4, f32){ 2, 2, 2, 6.54321 }, prefixScan(.Max, 1, float_base));
401399
402 try std.testing.expectEqual(Vector(4, bool){ true, true, false, false }, prefixScan(.Xor, 1, bool_base));
403 try std.testing.expectEqual(Vector(4, bool){ true, true, true, true }, prefixScan(.Or, 1, bool_base));
404 try std.testing.expectEqual(Vector(4, bool){ true, false, false, false }, prefixScan(.And, 1, bool_base));
400 try std.testing.expectEqual(@Vector(4, bool){ true, true, false, false }, prefixScan(.Xor, 1, bool_base));
401 try std.testing.expectEqual(@Vector(4, bool){ true, true, true, true }, prefixScan(.Or, 1, bool_base));
402 try std.testing.expectEqual(@Vector(4, bool){ true, false, false, false }, prefixScan(.And, 1, bool_base));
405403
406 try std.testing.expectEqual(Vector(4, i32){ 11, 23, 20, 2 }, prefixScan(.Add, 2, int_base));
407 try std.testing.expectEqual(Vector(4, i32){ 22, 11, -12, -21 }, prefixScan(.Add, -1, int_base));
408 try std.testing.expectEqual(Vector(4, i32){ 11, 23, 9, -10 }, prefixScan(.Add, 3, int_base));
404 try std.testing.expectEqual(@Vector(4, i32){ 11, 23, 20, 2 }, prefixScan(.Add, 2, int_base));
405 try std.testing.expectEqual(@Vector(4, i32){ 22, 11, -12, -21 }, prefixScan(.Add, -1, int_base));
406 try std.testing.expectEqual(@Vector(4, i32){ 11, 23, 9, -10 }, prefixScan(.Add, 3, int_base));
409407}
lib/std/special/compiler_rt/multi3.zig+1-1
......@@ -17,7 +17,7 @@ pub fn __multi3(a: i128, b: i128) callconv(.C) i128 {
1717 return r.all;
1818}
1919
20const v128 = std.meta.Vector(2, u64);
20const v128 = @Vector(2, u64);
2121pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 {
2222 return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{
2323 @bitCast(i128, a),
lib/std/target.zig+3-5
......@@ -673,8 +673,7 @@ pub const Target = struct {
673673
674674 /// Adds the specified feature set but not its dependencies.
675675 pub fn addFeatureSet(set: *Set, other_set: Set) void {
676 set.ints = @as(std.meta.Vector(usize_count, usize), set.ints) |
677 @as(std.meta.Vector(usize_count, usize), other_set.ints);
676 set.ints = @as(@Vector(usize_count, usize), set.ints) | @as(@Vector(usize_count, usize), other_set.ints);
678677 }
679678
680679 /// Removes the specified feature but not its dependents.
......@@ -686,8 +685,7 @@ pub const Target = struct {
686685
687686 /// Removes the specified feature but not its dependents.
688687 pub fn removeFeatureSet(set: *Set, other_set: Set) void {
689 set.ints = @as(std.meta.Vector(usize_count, usize), set.ints) &
690 ~@as(std.meta.Vector(usize_count, usize), other_set.ints);
688 set.ints = @as(@Vector(usize_count, usize), set.ints) & ~@as(@Vector(usize_count, usize), other_set.ints);
691689 }
692690
693691 pub fn populateDependencies(set: *Set, all_features_list: []const Cpu.Feature) void {
......@@ -716,7 +714,7 @@ pub const Target = struct {
716714 }
717715
718716 pub fn isSuperSetOf(set: Set, other_set: Set) bool {
719 const V = std.meta.Vector(usize_count, usize);
717 const V = @Vector(usize_count, usize);
720718 const set_v: V = set.ints;
721719 const other_v: V = other_set.ints;
722720 return @reduce(.And, (set_v & other_v) == other_v);
test/behavior/floatop.zig+12-13
......@@ -4,7 +4,6 @@ const expect = std.testing.expect;
44const math = std.math;
55const pi = std.math.pi;
66const e = std.math.e;
7const Vector = std.meta.Vector;
87const has_f80_rt = switch (builtin.cpu.arch) {
98 .x86_64, .i386 => true,
109 else => false,
......@@ -120,7 +119,7 @@ fn testSqrt() !void {
120119 try expect(math.approxEqAbs(f32, @sqrt(@as(f32, 2.0)), 1.4142135623730950, epsilon));
121120
122121 {
123 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
122 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
124123 var result = @sqrt(v);
125124 try expect(math.approxEqAbs(f32, @sqrt(@as(f32, 1.1)), result[0], epsilon));
126125 try expect(math.approxEqAbs(f32, @sqrt(@as(f32, 2.2)), result[1], epsilon));
......@@ -200,7 +199,7 @@ fn testSin() !void {
200199 }
201200
202201 {
203 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
202 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
204203 var result = @sin(v);
205204 try expect(math.approxEqAbs(f32, @sin(@as(f32, 1.1)), result[0], epsilon));
206205 try expect(math.approxEqAbs(f32, @sin(@as(f32, 2.2)), result[1], epsilon));
......@@ -234,7 +233,7 @@ fn testCos() !void {
234233 }
235234
236235 {
237 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
236 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 3.3, 4.4 };
238237 var result = @cos(v);
239238 try expect(math.approxEqAbs(f32, @cos(@as(f32, 1.1)), result[0], epsilon));
240239 try expect(math.approxEqAbs(f32, @cos(@as(f32, 2.2)), result[1], epsilon));
......@@ -263,7 +262,7 @@ fn testExp() !void {
263262 }
264263
265264 {
266 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
265 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
267266 var result = @exp(v);
268267 try expect(math.approxEqAbs(f32, @exp(@as(f32, 1.1)), result[0], epsilon));
269268 try expect(math.approxEqAbs(f32, @exp(@as(f32, 2.2)), result[1], epsilon));
......@@ -292,7 +291,7 @@ fn testExp2() !void {
292291 }
293292
294293 {
295 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
294 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
296295 var result = @exp2(v);
297296 try expect(math.approxEqAbs(f32, @exp2(@as(f32, 1.1)), result[0], epsilon));
298297 try expect(math.approxEqAbs(f32, @exp2(@as(f32, 2.2)), result[1], epsilon));
......@@ -332,7 +331,7 @@ fn testLog() !void {
332331 }
333332}
334333
335test "@log with vectors" {
334test "@log with @vectors" {
336335 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
337336 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
338337 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
......@@ -369,7 +368,7 @@ fn testLog2() !void {
369368 }
370369
371370 {
372 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
371 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
373372 var result = @log2(v);
374373 try expect(@log2(@as(f32, 1.1)) == result[0]);
375374 try expect(@log2(@as(f32, 2.2)) == result[1]);
......@@ -398,7 +397,7 @@ fn testLog10() !void {
398397 }
399398
400399 {
401 var v: Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
400 var v: @Vector(4, f32) = [_]f32{ 1.1, 2.2, 0.3, 0.4 };
402401 var result = @log10(v);
403402 try expect(@log10(@as(f32, 1.1)) == result[0]);
404403 try expect(@log10(@as(f32, 2.2)) == result[1]);
......@@ -436,7 +435,7 @@ fn testFabs() !void {
436435 // }
437436
438437 {
439 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
438 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
440439 var result = @fabs(v);
441440 try expect(math.approxEqAbs(f32, @fabs(@as(f32, 1.1)), result[0], epsilon));
442441 try expect(math.approxEqAbs(f32, @fabs(@as(f32, -2.2)), result[1], epsilon));
......@@ -469,7 +468,7 @@ fn testFloor() !void {
469468 // }
470469
471470 {
472 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
471 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
473472 var result = @floor(v);
474473 try expect(math.approxEqAbs(f32, @floor(@as(f32, 1.1)), result[0], epsilon));
475474 try expect(math.approxEqAbs(f32, @floor(@as(f32, -2.2)), result[1], epsilon));
......@@ -502,7 +501,7 @@ fn testCeil() !void {
502501 // }
503502
504503 {
505 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
504 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
506505 var result = @ceil(v);
507506 try expect(math.approxEqAbs(f32, @ceil(@as(f32, 1.1)), result[0], epsilon));
508507 try expect(math.approxEqAbs(f32, @ceil(@as(f32, -2.2)), result[1], epsilon));
......@@ -535,7 +534,7 @@ fn testTrunc() !void {
535534 // }
536535
537536 {
538 var v: Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
537 var v: @Vector(4, f32) = [_]f32{ 1.1, -2.2, 0.3, -0.4 };
539538 var result = @trunc(v);
540539 try expect(math.approxEqAbs(f32, @trunc(@as(f32, 1.1)), result[0], epsilon));
541540 try expect(math.approxEqAbs(f32, @trunc(@as(f32, -2.2)), result[1], epsilon));
test/behavior/math.zig+4-4
......@@ -1280,8 +1280,8 @@ test "vector integer addition" {
12801280
12811281 const S = struct {
12821282 fn doTheTest() !void {
1283 var a: std.meta.Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
1284 var b: std.meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
1283 var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
1284 var b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
12851285 var result = a + b;
12861286 var result_array: [4]i32 = result;
12871287 const expected = [_]i32{ 6, 8, 10, 12 };
......@@ -1338,8 +1338,8 @@ test "vector comparison" {
13381338
13391339 const S = struct {
13401340 fn doTheTest() !void {
1341 var a: std.meta.Vector(6, i32) = [_]i32{ 1, 3, -1, 5, 7, 9 };
1342 var b: std.meta.Vector(6, i32) = [_]i32{ -1, 3, 0, 6, 10, -10 };
1341 var a: @Vector(6, i32) = [_]i32{ 1, 3, -1, 5, 7, 9 };
1342 var b: @Vector(6, i32) = [_]i32{ -1, 3, 0, 6, 10, -10 };
13431343 try expect(mem.eql(bool, &@as([6]bool, a < b), &[_]bool{ false, false, true, true, true, false }));
13441344 try expect(mem.eql(bool, &@as([6]bool, a <= b), &[_]bool{ false, true, true, true, true, false }));
13451345 try expect(mem.eql(bool, &@as([6]bool, a == b), &[_]bool{ false, true, false, false, false, false }));
test/behavior/type.zig+3-3
......@@ -223,9 +223,9 @@ test "Type.Vector" {
223223 @Vector(0, u8),
224224 @Vector(4, u8),
225225 @Vector(8, *u8),
226 std.meta.Vector(0, u8),
227 std.meta.Vector(4, u8),
228 std.meta.Vector(8, *u8),
226 @Vector(0, u8),
227 @Vector(4, u8),
228 @Vector(8, *u8),
229229 });
230230}
231231
test/behavior/type_info.zig+1-1
......@@ -447,7 +447,7 @@ test "type info: vectors" {
447447}
448448
449449fn testVector() !void {
450 const vec_info = @typeInfo(std.meta.Vector(4, i32));
450 const vec_info = @typeInfo(@Vector(4, i32));
451451 try expect(vec_info == .Vector);
452452 try expect(vec_info.Vector.len == 4);
453453 try expect(vec_info.Vector.child == i32);
test/runtime_safety.zig+20-20
......@@ -711,12 +711,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
711711 \\ std.os.exit(126);
712712 \\}
713713 \\pub fn main() void {
714 \\ var a: std.meta.Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 };
715 \\ var b: std.meta.Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
714 \\ var a: @Vector(4, i32) = [_]i32{ 1, 2, 2147483643, 4 };
715 \\ var b: @Vector(4, i32) = [_]i32{ 5, 6, 7, 8 };
716716 \\ const x = add(a, b);
717717 \\ _ = x;
718718 \\}
719 \\fn add(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) {
719 \\fn add(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {
720720 \\ return a + b;
721721 \\}
722722 );
......@@ -729,12 +729,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
729729 \\ std.os.exit(126);
730730 \\}
731731 \\pub fn main() void {
732 \\ var a: std.meta.Vector(4, u32) = [_]u32{ 1, 2, 8, 4 };
733 \\ var b: std.meta.Vector(4, u32) = [_]u32{ 5, 6, 7, 8 };
732 \\ var a: @Vector(4, u32) = [_]u32{ 1, 2, 8, 4 };
733 \\ var b: @Vector(4, u32) = [_]u32{ 5, 6, 7, 8 };
734734 \\ const x = sub(b, a);
735735 \\ _ = x;
736736 \\}
737 \\fn sub(a: std.meta.Vector(4, u32), b: std.meta.Vector(4, u32)) std.meta.Vector(4, u32) {
737 \\fn sub(a: @Vector(4, u32), b: @Vector(4, u32)) @Vector(4, u32) {
738738 \\ return a - b;
739739 \\}
740740 );
......@@ -747,12 +747,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
747747 \\ std.os.exit(126);
748748 \\}
749749 \\pub fn main() void {
750 \\ var a: std.meta.Vector(4, u8) = [_]u8{ 1, 2, 200, 4 };
751 \\ var b: std.meta.Vector(4, u8) = [_]u8{ 5, 6, 2, 8 };
750 \\ var a: @Vector(4, u8) = [_]u8{ 1, 2, 200, 4 };
751 \\ var b: @Vector(4, u8) = [_]u8{ 5, 6, 2, 8 };
752752 \\ const x = mul(b, a);
753753 \\ _ = x;
754754 \\}
755 \\fn mul(a: std.meta.Vector(4, u8), b: std.meta.Vector(4, u8)) std.meta.Vector(4, u8) {
755 \\fn mul(a: @Vector(4, u8), b: @Vector(4, u8)) @Vector(4, u8) {
756756 \\ return a * b;
757757 \\}
758758 );
......@@ -765,11 +765,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
765765 \\ std.os.exit(126);
766766 \\}
767767 \\pub fn main() void {
768 \\ var a: std.meta.Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 };
768 \\ var a: @Vector(4, i16) = [_]i16{ 1, -32768, 200, 4 };
769769 \\ const x = neg(a);
770770 \\ _ = x;
771771 \\}
772 \\fn neg(a: std.meta.Vector(4, i16)) std.meta.Vector(4, i16) {
772 \\fn neg(a: @Vector(4, i16)) @Vector(4, i16) {
773773 \\ return -a;
774774 \\}
775775 );
......@@ -846,12 +846,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
846846 \\ std.os.exit(126);
847847 \\}
848848 \\pub fn main() !void {
849 \\ var a: std.meta.Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };
850 \\ var b: std.meta.Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };
849 \\ var a: @Vector(4, i16) = [_]i16{ 1, 2, -32768, 4 };
850 \\ var b: @Vector(4, i16) = [_]i16{ 1, 2, -1, 4 };
851851 \\ const x = div(a, b);
852852 \\ if (x[2] == 32767) return error.Whatever;
853853 \\}
854 \\fn div(a: std.meta.Vector(4, i16), b: std.meta.Vector(4, i16)) std.meta.Vector(4, i16) {
854 \\fn div(a: @Vector(4, i16), b: @Vector(4, i16)) @Vector(4, i16) {
855855 \\ return @divTrunc(a, b);
856856 \\}
857857 );
......@@ -944,12 +944,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
944944 \\ std.os.exit(126);
945945 \\}
946946 \\pub fn main() void {
947 \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444};
948 \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 0, 333, 444};
947 \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};
948 \\ var b: @Vector(4, i32) = [4]i32{111, 0, 333, 444};
949949 \\ const x = div0(a, b);
950950 \\ _ = x;
951951 \\}
952 \\fn div0(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) {
952 \\fn div0(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {
953953 \\ return @divTrunc(a, b);
954954 \\}
955955 );
......@@ -978,12 +978,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
978978 \\ std.os.exit(126);
979979 \\}
980980 \\pub fn main() !void {
981 \\ var a: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 444};
982 \\ var b: std.meta.Vector(4, i32) = [4]i32{111, 222, 333, 441};
981 \\ var a: @Vector(4, i32) = [4]i32{111, 222, 333, 444};
982 \\ var b: @Vector(4, i32) = [4]i32{111, 222, 333, 441};
983983 \\ const x = divExact(a, b);
984984 \\ _ = x;
985985 \\}
986 \\fn divExact(a: std.meta.Vector(4, i32), b: std.meta.Vector(4, i32)) std.meta.Vector(4, i32) {
986 \\fn divExact(a: @Vector(4, i32), b: @Vector(4, i32)) @Vector(4, i32) {
987987 \\ return @divExact(a, b);
988988 \\}
989989 );