mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
x86_64: rewrite @splat
This commit is contained in:
parent
58d2bd601e
commit
a3b0c242b0
@ -2142,7 +2142,7 @@ pub const Inst = struct {
|
||||
ref_start_index = static_len,
|
||||
_,
|
||||
|
||||
pub const static_len = 100;
|
||||
pub const static_len = 101;
|
||||
|
||||
pub fn toRef(i: Index) Inst.Ref {
|
||||
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
|
||||
@ -2248,6 +2248,7 @@ pub const Inst = struct {
|
||||
vector_4_i64_type,
|
||||
vector_2_u64_type,
|
||||
vector_4_u64_type,
|
||||
vector_2_u128_type,
|
||||
vector_4_f16_type,
|
||||
vector_8_f16_type,
|
||||
vector_2_f32_type,
|
||||
|
||||
@ -1020,6 +1020,7 @@ pub const Inst = struct {
|
||||
vector_4_i64_type = @intFromEnum(InternPool.Index.vector_4_i64_type),
|
||||
vector_2_u64_type = @intFromEnum(InternPool.Index.vector_2_u64_type),
|
||||
vector_4_u64_type = @intFromEnum(InternPool.Index.vector_4_u64_type),
|
||||
vector_2_u128_type = @intFromEnum(InternPool.Index.vector_2_u128_type),
|
||||
vector_4_f16_type = @intFromEnum(InternPool.Index.vector_4_f16_type),
|
||||
vector_8_f16_type = @intFromEnum(InternPool.Index.vector_8_f16_type),
|
||||
vector_2_f32_type = @intFromEnum(InternPool.Index.vector_2_f32_type),
|
||||
|
||||
@ -4595,6 +4595,7 @@ pub const Index = enum(u32) {
|
||||
vector_4_i64_type,
|
||||
vector_2_u64_type,
|
||||
vector_4_u64_type,
|
||||
vector_2_u128_type,
|
||||
vector_4_f16_type,
|
||||
vector_8_f16_type,
|
||||
vector_2_f32_type,
|
||||
@ -5139,6 +5140,8 @@ pub const static_keys = [_]Key{
|
||||
.{ .vector_type = .{ .len = 2, .child = .u64_type } },
|
||||
// @Vector(8, u64)
|
||||
.{ .vector_type = .{ .len = 4, .child = .u64_type } },
|
||||
// @Vector(2, u128)
|
||||
.{ .vector_type = .{ .len = 2, .child = .u128_type } },
|
||||
// @Vector(4, f16)
|
||||
.{ .vector_type = .{ .len = 4, .child = .f16_type } },
|
||||
// @Vector(8, f16)
|
||||
@ -11809,6 +11812,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
|
||||
.vector_4_i64_type,
|
||||
.vector_2_u64_type,
|
||||
.vector_4_u64_type,
|
||||
.vector_2_u128_type,
|
||||
.vector_4_f16_type,
|
||||
.vector_8_f16_type,
|
||||
.vector_2_f32_type,
|
||||
@ -12156,6 +12160,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
|
||||
.vector_4_i64_type,
|
||||
.vector_2_u64_type,
|
||||
.vector_4_u64_type,
|
||||
.vector_2_u128_type,
|
||||
.vector_4_f16_type,
|
||||
.vector_8_f16_type,
|
||||
.vector_2_f32_type,
|
||||
|
||||
@ -36540,6 +36540,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
|
||||
.vector_4_i64_type,
|
||||
.vector_2_u64_type,
|
||||
.vector_4_u64_type,
|
||||
.vector_2_u128_type,
|
||||
.vector_4_f16_type,
|
||||
.vector_8_f16_type,
|
||||
.vector_2_f32_type,
|
||||
|
||||
@ -4119,6 +4119,7 @@ pub const vector_2_i64: Type = .{ .ip_index = .vector_2_i64_type };
|
||||
pub const vector_4_i64: Type = .{ .ip_index = .vector_4_i64_type };
|
||||
pub const vector_2_u64: Type = .{ .ip_index = .vector_2_u64_type };
|
||||
pub const vector_4_u64: Type = .{ .ip_index = .vector_4_u64_type };
|
||||
pub const vector_2_u128: Type = .{ .ip_index = .vector_2_u128_type };
|
||||
pub const vector_4_f16: Type = .{ .ip_index = .vector_4_f16_type };
|
||||
pub const vector_8_f16: Type = .{ .ip_index = .vector_8_f16_type };
|
||||
pub const vector_2_f32: Type = .{ .ip_index = .vector_2_f32_type };
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1788,6 +1788,21 @@ pub const Pool = struct {
|
||||
};
|
||||
return pool.fromFields(allocator, .@"struct", &fields, kind);
|
||||
},
|
||||
.vector_2_u128_type => {
|
||||
const vector_ctype = try pool.getVector(allocator, .{
|
||||
.elem_ctype = .u128,
|
||||
.len = 2,
|
||||
});
|
||||
if (!kind.isParameter()) return vector_ctype;
|
||||
var fields = [_]Info.Field{
|
||||
.{
|
||||
.name = .{ .index = .array },
|
||||
.ctype = vector_ctype,
|
||||
.alignas = AlignAs.fromAbiAlignment(Type.u128.abiAlignment(zcu)),
|
||||
},
|
||||
};
|
||||
return pool.fromFields(allocator, .@"struct", &fields, kind);
|
||||
},
|
||||
.vector_4_f16_type => {
|
||||
const vector_ctype = try pool.getVector(allocator, .{
|
||||
.elem_ctype = .f16,
|
||||
|
||||
@ -57,10 +57,6 @@ test "exporting using namespace access" {
|
||||
|
||||
test "exporting comptime-known value" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and
|
||||
(builtin.target.ofmt != .elf and
|
||||
builtin.target.ofmt != .macho and
|
||||
builtin.target.ofmt != .coff)) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
@ -31,8 +31,7 @@ test "vector wrap operators" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and
|
||||
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sse4_1)) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
@ -350,12 +349,12 @@ test "vector casts of sizes not divisible by 8" {
|
||||
}
|
||||
|
||||
test "vector @splat" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_llvm and
|
||||
builtin.os.tag == .macos)
|
||||
@ -1511,9 +1510,6 @@ test "boolean vector with 2 or more booleans" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
|
||||
// TODO: try removing this after <https://github.com/ziglang/zig/issues/13782>:
|
||||
if (!(builtin.os.tag == .linux and builtin.cpu.arch == .x86_64)) return;
|
||||
|
||||
const vec1 = @Vector(2, bool){ true, true };
|
||||
_ = vec1;
|
||||
|
||||
|
||||
@ -1818,3 +1818,12 @@ test optionalNotEqualNull {
|
||||
try test_optional_not_equal_null.testInts();
|
||||
try test_optional_not_equal_null.testFloats();
|
||||
}
|
||||
|
||||
inline fn splat(comptime Type: type, lhs: Type) Type {
|
||||
return @splat(lhs[0]);
|
||||
}
|
||||
test splat {
|
||||
const test_splat = unary(splat, .{});
|
||||
try test_splat.testIntVectors();
|
||||
try test_splat.testFloatVectors();
|
||||
}
|
||||
|
||||
@ -117,9 +117,9 @@ export fn testMutablePointer() void {
|
||||
// tmp.zig:37:38: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type '?u8'
|
||||
// tmp.zig:57:28: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_495'
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testNonExhaustiveEnum__enum_496'
|
||||
// tmp.zig:62:39: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_497'
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testUntaggedUnion__union_498'
|
||||
// tmp.zig:67:44: note: imported here
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_500'
|
||||
// neg_inf.zon:1:1: error: expected type 'tmp.testTaggedUnionVoid__union_501'
|
||||
// tmp.zig:72:50: note: imported here
|
||||
|
||||
@ -15,6 +15,6 @@ pub export fn entry() void {
|
||||
// error
|
||||
//
|
||||
// :7:25: error: unable to resolve comptime value
|
||||
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_469.C' must be comptime-known
|
||||
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_470.C' must be comptime-known
|
||||
// :4:16: note: struct requires comptime because of this field
|
||||
// :4:16: note: types are not available at runtime
|
||||
|
||||
@ -16,5 +16,5 @@ pub export fn entry2() void {
|
||||
//
|
||||
// :3:6: error: no field or member function named 'copy' in '[]const u8'
|
||||
// :9:8: error: no field or member function named 'bar' in '@TypeOf(.{})'
|
||||
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_473'
|
||||
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_474'
|
||||
// :12:6: note: struct declared here
|
||||
|
||||
@ -6,6 +6,6 @@ export fn foo() void {
|
||||
|
||||
// error
|
||||
//
|
||||
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_462'
|
||||
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_463'
|
||||
// :3:16: note: struct declared here
|
||||
// :1:11: note: struct declared here
|
||||
|
||||
@ -44,9 +44,9 @@ comptime {
|
||||
//
|
||||
// :5:23: error: expected error union type, found 'comptime_int'
|
||||
// :10:23: error: expected error union type, found '@TypeOf(.{})'
|
||||
// :15:23: error: expected error union type, found 'tmp.test2__struct_499'
|
||||
// :15:23: error: expected error union type, found 'tmp.test2__struct_500'
|
||||
// :15:23: note: struct declared here
|
||||
// :20:27: error: expected error union type, found 'tmp.test3__struct_501'
|
||||
// :20:27: error: expected error union type, found 'tmp.test3__struct_502'
|
||||
// :20:27: note: struct declared here
|
||||
// :25:23: error: expected error union type, found 'struct { comptime *const [5:0]u8 = "hello" }'
|
||||
// :31:13: error: expected error union type, found 'u32'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user