in favor of CPU features. Also rearrange the `std.Target` data structure. * note: `@import("builtin")` was already deprecated in favor of `@import("std").builtin`. * `std.builtin.arch` is now deprecated in favor of `std.builtin.cpu.arch`. * `std.Target.CpuFeatures.Cpu` is now `std.Target.Cpu.Model`. * `std.Target.CpuFeatures` is now `std.Target.Cpu`. * `std.Target` no longer has an `arch` field. Instead it has a `cpu` field, which has `arch`, `model`, and `features`. * `std.Target` no longer has a `cpu_features` field. * `std.Target.Arch` is moved to `std.Target.Cpu.Arch` and it is an enum instead of a tagged union. * `std.Target.parseOs` is moved to `std.Target.Os.parse`. * `std.Target.parseAbi` is moved to `std.Target.Abi.parse`. * `std.Target.parseArchSub` is only for arch now and moved to `std.Target.Cpu.Arch.parse`. * `std.Target.parse` is improved to accept CPU name and features. * `std.Target.Arch.getBaselineCpuFeatures` is moved to `std.Target.Cpu.baseline`. * `std.Target.allCpus` is renamed to `std.Target.allCpuModels`. * `std.Target.defaultAbi` is moved to `std.Target.Abi.default`. * Significant cleanup of aarch64 and arm CPU features, resulting in the needed bit count for cpu feature set going from 174 to 138. * Add `std.Target.Cpu.Feature.Set.addFeatureSet` for merging feature sets together. `-target-feature` and `-target-cpu` are removed in favor of `-mcpu`, to conform to established conventions, and it gains additional power to support cpu features. The syntax is: -mcpu=name+on1+on2-off1-off2 closes #4261
78 lines
2.2 KiB
Zig
78 lines
2.2 KiB
Zig
const std = @import("../std.zig");
|
|
const CpuFeature = std.Target.Cpu.Feature;
|
|
const CpuModel = std.Target.Cpu.Model;
|
|
|
|
pub const Feature = enum {
|
|
alu32,
|
|
dummy,
|
|
dwarfris,
|
|
};
|
|
|
|
pub usingnamespace CpuFeature.feature_set_fns(Feature);
|
|
|
|
pub const all_features = blk: {
|
|
const len = @typeInfo(Feature).Enum.fields.len;
|
|
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
|
|
var result: [len]CpuFeature = undefined;
|
|
result[@enumToInt(Feature.alu32)] = .{
|
|
.llvm_name = "alu32",
|
|
.description = "Enable ALU32 instructions",
|
|
.dependencies = featureSet(&[_]Feature{}),
|
|
};
|
|
result[@enumToInt(Feature.dummy)] = .{
|
|
.llvm_name = "dummy",
|
|
.description = "unused feature",
|
|
.dependencies = featureSet(&[_]Feature{}),
|
|
};
|
|
result[@enumToInt(Feature.dwarfris)] = .{
|
|
.llvm_name = "dwarfris",
|
|
.description = "Disable MCAsmInfo DwarfUsesRelocationsAcrossSections",
|
|
.dependencies = featureSet(&[_]Feature{}),
|
|
};
|
|
const ti = @typeInfo(Feature);
|
|
for (result) |*elem, i| {
|
|
elem.index = i;
|
|
elem.name = ti.Enum.fields[i].name;
|
|
}
|
|
break :blk result;
|
|
};
|
|
|
|
pub const cpu = struct {
|
|
pub const generic = CpuModel{
|
|
.name = "generic",
|
|
.llvm_name = "generic",
|
|
.features = featureSet(&[_]Feature{}),
|
|
};
|
|
pub const probe = CpuModel{
|
|
.name = "probe",
|
|
.llvm_name = "probe",
|
|
.features = featureSet(&[_]Feature{}),
|
|
};
|
|
pub const v1 = CpuModel{
|
|
.name = "v1",
|
|
.llvm_name = "v1",
|
|
.features = featureSet(&[_]Feature{}),
|
|
};
|
|
pub const v2 = CpuModel{
|
|
.name = "v2",
|
|
.llvm_name = "v2",
|
|
.features = featureSet(&[_]Feature{}),
|
|
};
|
|
pub const v3 = CpuModel{
|
|
.name = "v3",
|
|
.llvm_name = "v3",
|
|
.features = featureSet(&[_]Feature{}),
|
|
};
|
|
};
|
|
|
|
/// All bpf CPUs, sorted alphabetically by name.
|
|
/// TODO: Replace this with usage of `std.meta.declList`. It does work, but stage1
|
|
/// compiler has inefficient memory and CPU usage, affecting build times.
|
|
pub const all_cpus = &[_]*const CpuModel{
|
|
&cpu.generic,
|
|
&cpu.probe,
|
|
&cpu.v1,
|
|
&cpu.v2,
|
|
&cpu.v3,
|
|
};
|