diff --git a/src/simd/isa.zig b/src/simd/isa.zig index 55a77162a..f77fd66d4 100644 --- a/src/simd/isa.zig +++ b/src/simd/isa.zig @@ -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; }, } diff --git a/src/simd/utf8_count.zig b/src/simd/utf8_count.zig index a463654d2..24089f49e 100644 --- a/src/simd/utf8_count.zig +++ b/src/simd/utf8_count.zig @@ -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 }, }); } diff --git a/src/simd/utf8_validate.zig b/src/simd/utf8_validate.zig index c152d2086..2cad03324 100644 --- a/src/simd/utf8_validate.zig +++ b/src/simd/utf8_validate.zig @@ -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 }, }); }