pkg: remove unused files, add highway API to get targets

This commit is contained in:
Mitchell Hashimoto
2024-02-05 21:09:20 -08:00
parent 49f9059e0c
commit 8bbcf6821a
7 changed files with 97 additions and 46 deletions

9
pkg/highway/bridge.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <hwy/targets.h>
#include <stdint.h>
extern "C" {
int64_t hwy_supported_targets() {
return HWY_SUPPORTED_TARGETS;
}
}

View File

@ -71,6 +71,7 @@ pub fn build(b: *std.Build) !void {
});
}
lib.addCSourceFiles(.{ .flags = flags.items, .files = &.{"bridge.cpp"} });
lib.addCSourceFiles(.{
.dependency = upstream,
.flags = flags.items,

View File

@ -0,0 +1,57 @@
extern "c" fn hwy_supported_targets() i64;
pub const Targets = packed struct(i64) {
// x86_64
_reserved: u4 = 0,
avx3_spr: bool = false,
_reserved_5: u1 = 0,
avx3_zen4: bool = false,
avx3_dl: bool = false,
avx3: bool = false,
avx2: bool = false,
_reserved_10: u1 = 0,
sse4: bool = false,
ssse3: bool = false,
_reserved_13: u1 = 0, // SSE3 reserved
sse2: bool = false,
_reserved_15_23: u9 = 0,
// aarch64
sve2_128: bool = false,
sve_256: bool = false,
sve2: bool = false,
sve: bool = false,
neon: bool = false,
neon_without_aes: bool = false,
_reserved_30_36: u6 = 0,
// risc-v
rvv: bool = false,
_reserved_38_46: u9 = 0,
// IBM Power
ppc10: bool = false,
ppc9: bool = false,
ppc8: bool = false,
z15: bool = false,
z14: bool = false,
_reserved_52_57: u6 = 0,
// WebAssembly
wasm_emu256: bool = false,
wasm: bool = false,
_reserved_60_61: u2 = 0,
// Emulation
emu128: bool = false,
scalar: bool = false,
_reserved_63: u1 = 0,
};
pub fn supported_targets() Targets {
return @bitCast(hwy_supported_targets());
}
test {
_ = supported_targets();
}

View File

@ -4,12 +4,6 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const module = b.addModule("simdutf", .{
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
});
const lib = b.addStaticLibrary(.{
.name = "simdutf",
.target = target,
@ -17,12 +11,10 @@ pub fn build(b: *std.Build) !void {
});
lib.linkLibCpp();
lib.addIncludePath(.{ .path = "vendor" });
module.addIncludePath(.{ .path = "vendor" });
if (target.result.isDarwin()) {
const apple_sdk = @import("apple_sdk");
try apple_sdk.addPaths(b, &lib.root_module);
try apple_sdk.addPaths(b, module);
}
var flags = std.ArrayList([]const u8).init(b.allocator);
@ -44,19 +36,19 @@ pub fn build(b: *std.Build) !void {
b.installArtifact(lib);
{
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
});
test_exe.linkLibrary(lib);
var it = module.import_table.iterator();
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&tests_run.step);
}
// {
// const test_exe = b.addTest(.{
// .name = "test",
// .root_source_file = .{ .path = "main.zig" },
// .target = target,
// .optimize = optimize,
// });
// test_exe.linkLibrary(lib);
//
// var it = module.import_table.iterator();
// while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
// const tests_run = b.addRunArtifact(test_exe);
// const test_step = b.step("test", "Run tests");
// test_step.dependOn(&tests_run.step);
// }
}

View File

View File

@ -6,12 +6,6 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("utfcpp", .{});
const module = b.addModule("utfcpp", .{
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
});
const lib = b.addStaticLibrary(.{
.name = "utfcpp",
.target = target,
@ -19,12 +13,10 @@ pub fn build(b: *std.Build) !void {
});
lib.linkLibCpp();
lib.addIncludePath(upstream.path(""));
module.addIncludePath(upstream.path(""));
if (target.result.isDarwin()) {
const apple_sdk = @import("apple_sdk");
try apple_sdk.addPaths(b, &lib.root_module);
try apple_sdk.addPaths(b, module);
}
var flags = std.ArrayList([]const u8).init(b.allocator);
@ -44,19 +36,19 @@ pub fn build(b: *std.Build) !void {
b.installArtifact(lib);
{
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "main.zig" },
.target = target,
.optimize = optimize,
});
test_exe.linkLibrary(lib);
var it = module.import_table.iterator();
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&tests_run.step);
}
// {
// const test_exe = b.addTest(.{
// .name = "test",
// .root_source_file = .{ .path = "main.zig" },
// .target = target,
// .optimize = optimize,
// });
// test_exe.linkLibrary(lib);
//
// var it = module.import_table.iterator();
// while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
// const tests_run = b.addRunArtifact(test_exe);
// const test_step = b.step("test", "Run tests");
// test_step.dependOn(&tests_run.step);
// }
}

View File