Added self-hosted x86 CPU detection.

This commit is contained in:
alichay
2020-03-04 07:40:30 -06:00
committed by Andrew Kelley
parent 7f975bf09f
commit e24f29bbad
3 changed files with 681 additions and 4 deletions

View File

@@ -844,8 +844,20 @@ pub const NativeTargetInfo = struct {
}
fn detectNativeCpuAndFeatures(cross_target: CrossTarget) Target.Cpu {
// TODO Detect native CPU model & features. Until that is implemented we use baseline.
return baselineCpuAndFeatures(cross_target);
var baseline = baselineCpuAndFeatures(cross_target);
switch(Target.current.cpu.arch) {
.x86_64, .i386 => {
const x86_detection = @import("system/x86.zig");
x86_detection.detectNativeCpuAndFeatures(&baseline);
return baseline;
},
else => {
// // TODO Detect native CPU model & features. Until that is implemented we use baseline.
return baseline;
}
}
}
fn baselineCpuAndFeatures(cross_target: CrossTarget) Target.Cpu {
@@ -853,4 +865,4 @@ pub const NativeTargetInfo = struct {
cross_target.updateCpuFeatures(&adjusted_baseline.features);
return adjusted_baseline;
}
};
};