From 60e347983bef90ce244123dec1ad270307ee7fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Mon, 3 Aug 2026 21:29:06 +0200 Subject: [PATCH] std.zig.system.x86: add hygon family CPU detection --- lib/std/zig/system/x86.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/std/zig/system/x86.zig b/lib/std/zig/system/x86.zig index 22168aa7541a436b32fd3d47536a6939478a7a68..bf15522b9ff999c7b789d4e983148b6022d091d7 100644 --- a/lib/std/zig/system/x86.zig +++ b/lib/std/zig/system/x86.zig @@ -75,6 +75,7 @@ pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, query: T if (switch (vendor) { 0x756e6547 => detectIntelProcessor(&cpu, family, model, brand_id), 0x68747541 => detectAmdProcessor(&cpu, family, model), + 0x6f677948 => detectHygonProcessor(family, model), else => null, }) |m| b: { // Some hypervisors are evil liars and will operate in long mode while identifying as a @@ -218,6 +219,19 @@ fn detectAmdProcessor(cpu: *const Target.Cpu, family: u32, model: u32) ?*const T }; } +fn detectHygonProcessor(family: u32, model: u32) ?*const Target.Cpu.Model { + return switch (family) { + 24 => switch (model) { + 4 => &Target.x86.cpu.c86_4g_m4, + 6 => &Target.x86.cpu.c86_4g_m6, + 7 => &Target.x86.cpu.c86_4g_m7, + 8 => &Target.x86.cpu.c86_4g_m8, + else => null, + }, + else => null, + }; +} + fn detectNativeFeatures(cpu: *Target.Cpu, os_tag: Target.Os.Tag) void { var leaf = cpuid(0, 0); -- 2.54.0