| author | |
| committer | |
| log | edad096b772d58bc39d227b0ba4d13b641ca99e6 |
| tree | d0847c1f3793a1c69e6e93bcde35cd5b1c938f96 |
| parent | 055064a37a24b0150b6c7ae426a8f2279819e7de |
| signature | Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM |
3 files changed, 11 insertions(+), 19 deletions(-)
lib/std/zig/system.zig+5-5| ... | ... | @@ -374,10 +374,10 @@ pub fn resolveTargetQuery(io: Io, query: Target.Query) DetectError!Target { |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | var cpu = switch (query.cpu_model) { |
| 377 | .native => detectNativeCpuAndFeatures(io, query_cpu_arch, os, query), | |
| 377 | .native => detectNativeCpuAndFeatures(io, query_cpu_arch), | |
| 378 | 378 | .baseline => Target.Cpu.baseline(query_cpu_arch, os), |
| 379 | 379 | .determined_by_arch_os => if (query.cpu_arch == null) |
| 380 | detectNativeCpuAndFeatures(io, query_cpu_arch, os, query) | |
| 380 | detectNativeCpuAndFeatures(io, query_cpu_arch) | |
| 381 | 381 | else |
| 382 | 382 | Target.Cpu.baseline(query_cpu_arch, os), |
| 383 | 383 | .explicit => |model| model.toCpu(query_cpu_arch), |
| ... | ... | @@ -535,13 +535,13 @@ fn updateCpuFeatures( |
| 535 | 535 | set.removeFeatureSet(sub_set); |
| 536 | 536 | } |
| 537 | 537 | |
| 538 | fn detectNativeCpuAndFeatures(io: Io, cpu_arch: Target.Cpu.Arch, os: Target.Os, query: Target.Query) ?Target.Cpu { | |
| 538 | fn detectNativeCpuAndFeatures(io: Io, cpu_arch: Target.Cpu.Arch) ?Target.Cpu { | |
| 539 | 539 | // Here we switch on a comptime value rather than `cpu_arch`. This is valid because `cpu_arch`, |
| 540 | 540 | // although it is a runtime value, is guaranteed to be one of the architectures in the set |
| 541 | 541 | // of the respective switch prong. |
| 542 | 542 | switch (builtin.cpu.arch) { |
| 543 | .loongarch32, .loongarch64 => return @import("system/loongarch.zig").detectNativeCpuAndFeatures(cpu_arch, os, query), | |
| 544 | .x86_64, .x86 => return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch, os, query), | |
| 543 | .loongarch32, .loongarch64 => return @import("system/loongarch.zig").detectNativeCpuAndFeatures(cpu_arch), | |
| 544 | .x86_64, .x86 => return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch), | |
| 545 | 545 | else => {}, |
| 546 | 546 | } |
| 547 | 547 |
lib/std/zig/system/loongarch.zig+1-8| ... | ... | @@ -18,14 +18,7 @@ fn setFeature(cpu: *std.Target.Cpu, feature: std.Target.loongarch.Feature, enabl |
| 18 | 18 | if (enabled) cpu.features.addFeature(idx) else cpu.features.removeFeature(idx); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | pub fn detectNativeCpuAndFeatures( | |
| 22 | arch: std.Target.Cpu.Arch, | |
| 23 | os: std.Target.Os, | |
| 24 | query: std.Target.Query, | |
| 25 | ) ?std.Target.Cpu { | |
| 26 | _ = os; | |
| 27 | _ = query; | |
| 28 | ||
| 21 | pub fn detectNativeCpuAndFeatures(arch: std.Target.Cpu.Arch) ?std.Target.Cpu { | |
| 29 | 22 | const variant: Variant = @fromBackingInt(@intCast(cpucfg(1) & 0b11)); |
| 30 | 23 | |
| 31 | 24 | var cpu: std.Target.Cpu = .{ |
lib/std/zig/system/x86.zig+5-6| ... | ... | @@ -41,8 +41,7 @@ inline fn hasMask(input: u32, mask: u32) bool { |
| 41 | 41 | return (input & mask) == mask; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, query: Target.Query) Target.Cpu { | |
| 45 | _ = query; | |
| 44 | pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch) Target.Cpu { | |
| 46 | 45 | var cpu = Target.Cpu{ |
| 47 | 46 | .arch = arch, |
| 48 | 47 | .model = Target.Cpu.Model.generic(arch), |
| ... | ... | @@ -50,7 +49,7 @@ pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, query: T |
| 50 | 49 | }; |
| 51 | 50 | |
| 52 | 51 | // First we detect features, to use as hints when detecting CPU Model. |
| 53 | detectNativeFeatures(&cpu, os.tag); | |
| 52 | detectNativeFeatures(&cpu); | |
| 54 | 53 | |
| 55 | 54 | var leaf = cpuid(0, 0); |
| 56 | 55 | const max_leaf = leaf.eax; |
| ... | ... | @@ -90,7 +89,7 @@ pub fn detectNativeCpuAndFeatures(arch: Target.Cpu.Arch, os: Target.Os, query: T |
| 90 | 89 | // Add the CPU model's feature set into the working set, but then |
| 91 | 90 | // override with actual detected features again. |
| 92 | 91 | cpu.features.addFeatureSet(cpu.model.features); |
| 93 | detectNativeFeatures(&cpu, os.tag); | |
| 92 | detectNativeFeatures(&cpu); | |
| 94 | 93 | |
| 95 | 94 | cpu.features.populateDependencies(cpu.arch.allFeaturesList()); |
| 96 | 95 | |
| ... | ... | @@ -215,7 +214,7 @@ fn detectAmdProcessor(cpu: *const Target.Cpu, family: u32, model: u32) ?*const T |
| 215 | 214 | }; |
| 216 | 215 | } |
| 217 | 216 | |
| 218 | fn detectNativeFeatures(cpu: *Target.Cpu, os_tag: Target.Os.Tag) void { | |
| 217 | fn detectNativeFeatures(cpu: *Target.Cpu) void { | |
| 219 | 218 | var leaf = cpuid(0, 0); |
| 220 | 219 | |
| 221 | 220 | const max_level = leaf.eax; |
| ... | ... | @@ -268,7 +267,7 @@ fn detectNativeFeatures(cpu: *Target.Cpu, os_tag: Target.Os.Tag) void { |
| 268 | 267 | // Darwin lazily saves the AVX512 context on first use: trust that the OS will |
| 269 | 268 | // save the AVX512 context if we use AVX512 instructions, even if the bit is not |
| 270 | 269 | // set right now. |
| 271 | const has_avx512_save = if (os_tag.isDarwin()) | |
| 270 | const has_avx512_save = if (builtin.target.os.tag.isDarwin()) | |
| 272 | 271 | true |
| 273 | 272 | else |
| 274 | 273 | xcr0.zmm_hi256 and xcr0.hi16_zmm; |