Skip to content

Commit b5c6768

Browse files
committed
x86_64: rewrite @splat
1 parent 7e50971 commit b5c6768

15 files changed

Lines changed: 22975 additions & 21094 deletions

File tree

lib/std/zig/Zir.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2142,7 +2142,7 @@ pub const Inst = struct {
21422142
ref_start_index = static_len,
21432143
_,
21442144

2145-
pub const static_len = 100;
2145+
pub const static_len = 101;
21462146

21472147
pub fn toRef(i: Index) Inst.Ref {
21482148
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
@@ -2248,6 +2248,7 @@ pub const Inst = struct {
22482248
vector_4_i64_type,
22492249
vector_2_u64_type,
22502250
vector_4_u64_type,
2251+
vector_2_u128_type,
22512252
vector_4_f16_type,
22522253
vector_8_f16_type,
22532254
vector_2_f32_type,

src/Air.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ pub const Inst = struct {
10201020
vector_4_i64_type = @intFromEnum(InternPool.Index.vector_4_i64_type),
10211021
vector_2_u64_type = @intFromEnum(InternPool.Index.vector_2_u64_type),
10221022
vector_4_u64_type = @intFromEnum(InternPool.Index.vector_4_u64_type),
1023+
vector_2_u128_type = @intFromEnum(InternPool.Index.vector_2_u128_type),
10231024
vector_4_f16_type = @intFromEnum(InternPool.Index.vector_4_f16_type),
10241025
vector_8_f16_type = @intFromEnum(InternPool.Index.vector_8_f16_type),
10251026
vector_2_f32_type = @intFromEnum(InternPool.Index.vector_2_f32_type),

src/InternPool.zig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,7 @@ pub const Index = enum(u32) {
45954595
vector_4_i64_type,
45964596
vector_2_u64_type,
45974597
vector_4_u64_type,
4598+
vector_2_u128_type,
45984599
vector_4_f16_type,
45994600
vector_8_f16_type,
46004601
vector_2_f32_type,
@@ -5139,6 +5140,8 @@ pub const static_keys = [_]Key{
51395140
.{ .vector_type = .{ .len = 2, .child = .u64_type } },
51405141
// @Vector(8, u64)
51415142
.{ .vector_type = .{ .len = 4, .child = .u64_type } },
5143+
// @Vector(2, u128)
5144+
.{ .vector_type = .{ .len = 2, .child = .u128_type } },
51425145
// @Vector(4, f16)
51435146
.{ .vector_type = .{ .len = 4, .child = .f16_type } },
51445147
// @Vector(8, f16)
@@ -11809,6 +11812,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
1180911812
.vector_4_i64_type,
1181011813
.vector_2_u64_type,
1181111814
.vector_4_u64_type,
11815+
.vector_2_u128_type,
1181211816
.vector_4_f16_type,
1181311817
.vector_8_f16_type,
1181411818
.vector_2_f32_type,
@@ -12156,6 +12160,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
1215612160
.vector_4_i64_type,
1215712161
.vector_2_u64_type,
1215812162
.vector_4_u64_type,
12163+
.vector_2_u128_type,
1215912164
.vector_4_f16_type,
1216012165
.vector_8_f16_type,
1216112166
.vector_2_f32_type,

src/Sema.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36540,6 +36540,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
3654036540
.vector_4_i64_type,
3654136541
.vector_2_u64_type,
3654236542
.vector_4_u64_type,
36543+
.vector_2_u128_type,
3654336544
.vector_4_f16_type,
3654436545
.vector_8_f16_type,
3654536546
.vector_2_f32_type,

src/Type.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,6 +4119,7 @@ pub const vector_2_i64: Type = .{ .ip_index = .vector_2_i64_type };
41194119
pub const vector_4_i64: Type = .{ .ip_index = .vector_4_i64_type };
41204120
pub const vector_2_u64: Type = .{ .ip_index = .vector_2_u64_type };
41214121
pub const vector_4_u64: Type = .{ .ip_index = .vector_4_u64_type };
4122+
pub const vector_2_u128: Type = .{ .ip_index = .vector_2_u128_type };
41224123
pub const vector_4_f16: Type = .{ .ip_index = .vector_4_f16_type };
41234124
pub const vector_8_f16: Type = .{ .ip_index = .vector_8_f16_type };
41244125
pub const vector_2_f32: Type = .{ .ip_index = .vector_2_f32_type };

src/arch/x86_64/CodeGen.zig

Lines changed: 22931 additions & 21075 deletions
Large diffs are not rendered by default.

src/codegen/c/Type.zig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,21 @@ pub const Pool = struct {
17881788
};
17891789
return pool.fromFields(allocator, .@"struct", &fields, kind);
17901790
},
1791+
.vector_2_u128_type => {
1792+
const vector_ctype = try pool.getVector(allocator, .{
1793+
.elem_ctype = .u128,
1794+
.len = 2,
1795+
});
1796+
if (!kind.isParameter()) return vector_ctype;
1797+
var fields = [_]Info.Field{
1798+
.{
1799+
.name = .{ .index = .array },
1800+
.ctype = vector_ctype,
1801+
.alignas = AlignAs.fromAbiAlignment(Type.u128.abiAlignment(zcu)),
1802+
},
1803+
};
1804+
return pool.fromFields(allocator, .@"struct", &fields, kind);
1805+
},
17911806
.vector_4_f16_type => {
17921807
const vector_ctype = try pool.getVector(allocator, .{
17931808
.elem_ctype = .f16,

test/behavior/export_builtin.zig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ test "exporting using namespace access" {
5757

5858
test "exporting comptime-known value" {
5959
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
60-
if (builtin.zig_backend == .stage2_x86_64 and
61-
(builtin.target.ofmt != .elf and
62-
builtin.target.ofmt != .macho and
63-
builtin.target.ofmt != .coff)) return error.SkipZigTest;
6460
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
6561
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
6662
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;

test/behavior/vector.zig

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ test "vector wrap operators" {
3131
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
3232
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
3333
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
34-
if (builtin.zig_backend == .stage2_x86_64 and
35-
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sse4_1)) return error.SkipZigTest;
34+
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
3635

3736
const S = struct {
3837
fn doTheTest() !void {
@@ -350,12 +349,12 @@ test "vector casts of sizes not divisible by 8" {
350349
}
351350

352351
test "vector @splat" {
353-
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
354352
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
355353
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
356354
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
357355
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
358356
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
357+
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
359358

360359
if (builtin.zig_backend == .stage2_llvm and
361360
builtin.os.tag == .macos)
@@ -1511,9 +1510,6 @@ test "boolean vector with 2 or more booleans" {
15111510
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
15121511
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
15131512

1514-
// TODO: try removing this after <https://github.com/ziglang/zig/issues/13782>:
1515-
if (!(builtin.os.tag == .linux and builtin.cpu.arch == .x86_64)) return;
1516-
15171513
const vec1 = @Vector(2, bool){ true, true };
15181514
_ = vec1;
15191515

test/behavior/x86_64/unary.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,3 +1818,12 @@ test optionalNotEqualNull {
18181818
try test_optional_not_equal_null.testInts();
18191819
try test_optional_not_equal_null.testFloats();
18201820
}
1821+
1822+
inline fn splat(comptime Type: type, lhs: Type) Type {
1823+
return @splat(lhs[0]);
1824+
}
1825+
test splat {
1826+
const test_splat = unary(splat, .{});
1827+
try test_splat.testIntVectors();
1828+
try test_splat.testFloatVectors();
1829+
}

0 commit comments

Comments
 (0)