x86_64: rewrite scalar @bitReverse

This commit is contained in:
Jacob Young 2025-02-21 11:07:57 -05:00 committed by Andrew Kelley
parent fc7a0c4878
commit 300cb4881f
3 changed files with 3434 additions and 187 deletions

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,11 @@ pub fn build(b: *std.Build) void {
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64 }, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64 },
}, },
.{
.cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64 },
.cpu_features_add = std.Target.x86.featureSet(&.{ .adx, .gfni }),
},
.{ .{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64 }, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64 },
@ -79,6 +84,11 @@ pub fn build(b: *std.Build) void {
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 }, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
}, },
.{
.cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
.cpu_features_add = std.Target.x86.featureSet(&.{ .adx, .gfni }),
},
.{ .{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 }, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
@ -96,7 +106,7 @@ pub fn build(b: *std.Build) void {
.{ .{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 }, .cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
.cpu_features_add = std.Target.x86.featureSet(&.{.adx}), .cpu_features_add = std.Target.x86.featureSet(&.{ .adx, .gfni }),
}, },
.{ .{
.cpu_arch = .x86_64, .cpu_arch = .x86_64,

View File

@ -672,6 +672,33 @@ fn unary(comptime op: anytype, comptime opts: struct {
try testArgs(u257, 1 << 255); try testArgs(u257, 1 << 255);
try testArgs(u257, 1 << 256); try testArgs(u257, 1 << 256);
try testArgs(i383, -1 << 382);
try testArgs(i383, -1);
try testArgs(i383, 0);
try testArgs(u383, 0);
try testArgs(u383, 1 << 0);
try testArgs(u383, 1 << 1);
try testArgs(u383, 1 << 381);
try testArgs(u383, 1 << 382);
try testArgs(i384, -1 << 383);
try testArgs(i384, -1);
try testArgs(i384, 0);
try testArgs(u384, 0);
try testArgs(u384, 1 << 0);
try testArgs(u384, 1 << 1);
try testArgs(u384, 1 << 382);
try testArgs(u384, 1 << 383);
try testArgs(i385, -1 << 384);
try testArgs(i385, -1);
try testArgs(i385, 0);
try testArgs(u385, 0);
try testArgs(u385, 1 << 0);
try testArgs(u385, 1 << 1);
try testArgs(u385, 1 << 383);
try testArgs(u385, 1 << 384);
try testArgs(i511, -1 << 510); try testArgs(i511, -1 << 510);
try testArgs(i511, -1); try testArgs(i511, -1);
try testArgs(i511, 0); try testArgs(i511, 0);
@ -19297,6 +19324,14 @@ test byteSwap {
try test_byte_swap.testInts(); try test_byte_swap.testInts();
} }
inline fn bitReverse(comptime Type: type, rhs: Type) @TypeOf(@bitReverse(rhs)) {
return @bitReverse(rhs);
}
test bitReverse {
const test_bit_reverse = unary(bitReverse, .{});
try test_bit_reverse.testInts();
}
inline fn sqrt(comptime Type: type, rhs: Type) @TypeOf(@sqrt(rhs)) { inline fn sqrt(comptime Type: type, rhs: Type) @TypeOf(@sqrt(rhs)) {
return @sqrt(rhs); return @sqrt(rhs);
} }