authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-03 21:29:06+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-07 00:30:52+02:00
logfe188a3261b5b64dff4f10ada637e0f83ba3d7ab
treece8e202c02576882b32f0c00af984daf362f45a6
parentb56c08c4c5b1dab14d82e213ca22c728ae906f76
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.zig.system.x86: add hygon family CPU detection


1 files changed, 14 insertions(+), 0 deletions(-)

lib/std/zig/system/x86.zig+14
...@@ -74,6 +74,7 @@ pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch) Target.Cpu {...@@ -74,6 +74,7 @@ pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch) Target.Cpu {
74 if (switch (vendor) {74 if (switch (vendor) {
75 0x756e6547 => detectIntelProcessor(&cpu, family, model, brand_id),75 0x756e6547 => detectIntelProcessor(&cpu, family, model, brand_id),
76 0x68747541 => detectAmdProcessor(&cpu, family, model),76 0x68747541 => detectAmdProcessor(&cpu, family, model),
77 0x6f677948 => detectHygonProcessor(family, model),
77 else => null,78 else => null,
78 }) |m| b: {79 }) |m| b: {
79 // Some hypervisors are evil liars and will operate in long mode while identifying as a80 // Some hypervisors are evil liars and will operate in long mode while identifying as a
...@@ -217,6 +218,19 @@ fn detectAmdProcessor(cpu: *const Target.Cpu, family: u32, model: u32) ?*const T...@@ -217,6 +218,19 @@ fn detectAmdProcessor(cpu: *const Target.Cpu, family: u32, model: u32) ?*const T
217 };218 };
218}219}
219220
221fn detectHygonProcessor(family: u32, model: u32) ?*const Target.Cpu.Model {
222 return switch (family) {
223 24 => switch (model) {
224 4 => &Target.x86.cpu.c86_4g_m4,
225 6 => &Target.x86.cpu.c86_4g_m6,
226 7 => &Target.x86.cpu.c86_4g_m7,
227 8 => &Target.x86.cpu.c86_4g_m8,
228 else => null,
229 },
230 else => null,
231 };
232}
233
220fn detectNativeFeatures(cpu: *Target.Cpu) void {234fn detectNativeFeatures(cpu: *Target.Cpu) void {
221 var leaf = cpuid(0, 0);235 var leaf = cpuid(0, 0);
222236