mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
simd: simplify isa.funcMap, find Zig compiler bug
This commit is contained in:
@ -142,7 +142,6 @@ inline fn hasMask(input: u32, mask: u32) bool {
|
||||
/// will not be included on x86_64.
|
||||
pub fn funcMap(
|
||||
comptime Func: type,
|
||||
comptime name: []const u8,
|
||||
v: ISA,
|
||||
comptime map: anytype,
|
||||
) *const Func {
|
||||
@ -153,7 +152,12 @@ pub fn funcMap(
|
||||
|
||||
// Find the entry for this tag and return the function.
|
||||
inline for (map) |entry| {
|
||||
if (entry[0] == tag) return @field(entry[1], name);
|
||||
if (entry[0] == tag) {
|
||||
// If we return &entry[1] directly the compiler crashes:
|
||||
// https://github.com/ziglang/zig/issues/18754
|
||||
const func = entry[1];
|
||||
return &func;
|
||||
}
|
||||
} else unreachable;
|
||||
},
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ pub const Count = fn ([]const u8) usize;
|
||||
|
||||
/// Returns the count function for the given ISA.
|
||||
pub fn countFunc(v: isa.ISA) *const Count {
|
||||
return isa.funcMap(Count, "count", v, .{
|
||||
.{ .avx2, Scalar }, // todo
|
||||
.{ .neon, Neon },
|
||||
.{ .scalar, Scalar },
|
||||
return isa.funcMap(Count, v, .{
|
||||
.{ .avx2, Scalar.count }, // todo
|
||||
.{ .neon, Neon.count },
|
||||
.{ .scalar, Scalar.count },
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,10 @@ const Validate = fn ([]const u8) bool;
|
||||
// - https://simdutf.github.io/simdutf/ (MIT License)
|
||||
|
||||
pub fn validateFunc(v: isa.ISA) *const Validate {
|
||||
return isa.funcMap(Validate, "validate", v, .{
|
||||
.{ .avx2, Scalar }, // todo
|
||||
.{ .neon, Neon },
|
||||
.{ .scalar, Scalar },
|
||||
return isa.funcMap(Validate, v, .{
|
||||
.{ .avx2, Scalar.validate }, // todo
|
||||
.{ .neon, Neon.validate },
|
||||
.{ .scalar, Scalar.validate },
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user