x86_64: rewrite float vector conversions

This commit is contained in:
Jacob Young 2025-01-29 23:55:55 -05:00
parent afa74c6b21
commit b9531f5de6
11 changed files with 1951 additions and 203 deletions

View File

@ -2128,7 +2128,7 @@ pub const Inst = struct {
ref_start_index = static_len,
_,
pub const static_len = 92;
pub const static_len = 93;
pub fn toRef(i: Index) Inst.Ref {
return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i));
@ -2229,6 +2229,7 @@ pub const Inst = struct {
vector_4_u64_type,
vector_4_f16_type,
vector_8_f16_type,
vector_2_f32_type,
vector_4_f32_type,
vector_8_f32_type,
vector_2_f64_type,

View File

@ -1001,6 +1001,7 @@ pub const Inst = struct {
vector_4_u64_type = @intFromEnum(InternPool.Index.vector_4_u64_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),
vector_4_f32_type = @intFromEnum(InternPool.Index.vector_4_f32_type),
vector_8_f32_type = @intFromEnum(InternPool.Index.vector_8_f32_type),
vector_2_f64_type = @intFromEnum(InternPool.Index.vector_2_f64_type),

View File

@ -4593,6 +4593,7 @@ pub const Index = enum(u32) {
vector_4_u64_type,
vector_4_f16_type,
vector_8_f16_type,
vector_2_f32_type,
vector_4_f32_type,
vector_8_f32_type,
vector_2_f64_type,
@ -5124,6 +5125,8 @@ pub const static_keys = [_]Key{
.{ .vector_type = .{ .len = 4, .child = .f16_type } },
// @Vector(8, f16)
.{ .vector_type = .{ .len = 8, .child = .f16_type } },
// @Vector(2, f32)
.{ .vector_type = .{ .len = 2, .child = .f32_type } },
// @Vector(4, f32)
.{ .vector_type = .{ .len = 4, .child = .f32_type } },
// @Vector(8, f32)
@ -11778,6 +11781,7 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index {
.vector_4_u64_type,
.vector_4_f16_type,
.vector_8_f16_type,
.vector_2_f32_type,
.vector_4_f32_type,
.vector_8_f32_type,
.vector_2_f64_type,
@ -12117,6 +12121,7 @@ pub fn zigTypeTag(ip: *const InternPool, index: Index) std.builtin.TypeId {
.vector_4_u64_type,
.vector_4_f16_type,
.vector_8_f16_type,
.vector_2_f32_type,
.vector_4_f32_type,
.vector_8_f32_type,
.vector_2_f64_type,

View File

@ -36733,6 +36733,7 @@ pub fn typeHasOnePossibleValue(sema: *Sema, ty: Type) CompileError!?Value {
.vector_4_u64_type,
.vector_4_f16_type,
.vector_8_f16_type,
.vector_2_f32_type,
.vector_4_f32_type,
.vector_8_f32_type,
.vector_2_f64_type,

View File

@ -4209,6 +4209,7 @@ 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_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 };
pub const vector_4_f32: Type = .{ .ip_index = .vector_4_f32_type };
pub const vector_8_f32: Type = .{ .ip_index = .vector_8_f32_type };
pub const vector_2_f64: Type = .{ .ip_index = .vector_2_f64_type };

File diff suppressed because it is too large Load Diff

View File

@ -1707,6 +1707,21 @@ pub const Pool = struct {
};
return pool.fromFields(allocator, .@"struct", &fields, kind);
},
.vector_2_f32_type => {
const vector_ctype = try pool.getVector(allocator, .{
.elem_ctype = .f32,
.len = 2,
});
if (!kind.isParameter()) return vector_ctype;
var fields = [_]Info.Field{
.{
.name = .{ .index = .array },
.ctype = vector_ctype,
.alignas = AlignAs.fromAbiAlignment(Type.f32.abiAlignment(zcu)),
},
};
return pool.fromFields(allocator, .@"struct", &fields, kind);
},
.vector_4_f32_type => {
const vector_ctype = try pool.getVector(allocator, .{
.elem_ctype = .f32,

View File

@ -10810,6 +10810,7 @@ inline fn floatCast(comptime Result: type, comptime Type: type, rhs: Type) Resul
test floatCast {
const test_float_cast = cast(floatCast, .{ .strict = true });
try test_float_cast.testFloats();
try test_float_cast.testFloatVectors();
}
inline fn equal(comptime Type: type, lhs: Type, rhs: Type) @TypeOf(lhs == rhs) {

View File

@ -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_463.C' must be comptime-known
// :7:25: note: initializer of comptime-only struct 'tmp.S.foo__anon_464.C' must be comptime-known
// :4:16: note: struct requires comptime because of this field
// :4:16: note: types are not available at runtime

View File

@ -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_467'
// :12:18: error: no field or member function named 'bar' in 'tmp.entry2__struct_468'
// :12:6: note: struct declared here

View File

@ -6,6 +6,6 @@ export fn foo() void {
// error
//
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_456'
// :4:16: error: expected type 'tmp.T', found 'tmp.foo__struct_457'
// :3:16: note: struct declared here
// :1:11: note: struct declared here