Skip to content

Commit a3b0c24

Browse files
committed
x86_64: rewrite @splat
1 parent 58d2bd6 commit a3b0c24

15 files changed

+22975
-21094
lines changed

lib/std/zig/Zir.zig

+2-1
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

+1
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

+5
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

+1
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

+1
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

+22,931-21,075
Large diffs are not rendered by default.

src/codegen/c/Type.zig

+15
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

-4
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

+2-6
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

+9
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+
}

test/cases/compile_errors/@import_zon_bad_type.zig

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ export fn testMutablePointer() void {
117117
// tmp.zig:37:38: note: imported here
118118
// neg_inf.zon:1:1: error: expected type '?u8'
119119
// tmp.zig:57:28: note: imported here
120-
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_495'
120+
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_496'
121121
// tmp.zig:62:39: note: imported here
122-
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_497'
122+
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_498'
123123
// tmp.zig:67:44: note: imported here
124-
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_500'
124+
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_501'
125125
// tmp.zig:72:50: note: imported here

test/cases/compile_errors/anytype_param_requires_comptime.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ pub export fn entry() void {
1515
// error
1616
//
1717
// :7:25: error: unable to resolve comptime value
18-
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_469.C' must be comptime-known
18+
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_470.C' must be comptime-known
1919
// :4:16: note: struct requires comptime because of this field
2020
// :4:16: note: types are not available at runtime

test/cases/compile_errors/bogus_method_call_on_slice.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ pub export fn entry2() void {
1616
//
1717
// :3:6: error: no field or member function named 'copy' in '[]const u8'
1818
// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
19-
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_473'
19+
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_474'
2020
// :12:6: note: struct declared here

test/cases/compile_errors/coerce_anon_struct.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export fn foo() void {
66

77
// error
88
//
9-
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_462'
9+
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_463'
1010
// :3:16: note: struct declared here
1111
// :1:11: note: struct declared here

test/cases/compile_errors/redundant_try.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ comptime {
4444
//
4545
// :5:23: error: expected error union type, found 'comptime_int'
4646
// :10:23: error: expected error union type, found '@TypeOf(.{})'
47-
// :15:23: error: expected error union type, found 'tmp.test2__struct_499'
47+
// :15:23: error: expected error union type, found 'tmp.test2__struct_500'
4848
// :15:23: note: struct declared here
49-
// :20:27: error: expected error union type, found 'tmp.test3__struct_501'
49+
// :20:27: error: expected error union type, found 'tmp.test3__struct_502'
5050
// :20:27: note: struct declared here
5151
// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'
5252
// :31:13: error: expected error union type, found 'u32'

0 commit comments

Comments
 (0)