2020-01-20 19:21:45 -08:00
|
|
|
const std = @import("../std.zig");
|
2020-02-19 18:30:36 -08:00
|
|
|
const CpuFeature = std.Target.Cpu.Feature;
|
|
|
|
const CpuModel = std.Target.Cpu.Model;
|
2019-12-20 16:27:13 -08:00
|
|
|
|
2020-01-20 19:21:45 -08:00
|
|
|
pub const Feature = enum {
|
|
|
|
ext,
|
|
|
|
hwmult16,
|
|
|
|
hwmult32,
|
|
|
|
hwmultf5,
|
2019-12-20 16:27:13 -08:00
|
|
|
};
|
|
|
|
|
2020-02-19 18:30:36 -08:00
|
|
|
pub usingnamespace CpuFeature.feature_set_fns(Feature);
|
2019-12-20 16:27:13 -08:00
|
|
|
|
2020-01-20 19:21:45 -08:00
|
|
|
pub const all_features = blk: {
|
|
|
|
const len = @typeInfo(Feature).Enum.fields.len;
|
2020-02-19 18:30:36 -08:00
|
|
|
std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
|
|
|
|
var result: [len]CpuFeature = undefined;
|
2020-01-20 19:21:45 -08:00
|
|
|
result[@enumToInt(Feature.ext)] = .{
|
|
|
|
.llvm_name = "ext",
|
|
|
|
.description = "Enable MSP430-X extensions",
|
2020-01-21 17:11:36 -08:00
|
|
|
.dependencies = featureSet(&[_]Feature{}),
|
2020-01-20 19:21:45 -08:00
|
|
|
};
|
|
|
|
result[@enumToInt(Feature.hwmult16)] = .{
|
|
|
|
.llvm_name = "hwmult16",
|
|
|
|
.description = "Enable 16-bit hardware multiplier",
|
2020-01-21 17:11:36 -08:00
|
|
|
.dependencies = featureSet(&[_]Feature{}),
|
2020-01-20 19:21:45 -08:00
|
|
|
};
|
|
|
|
result[@enumToInt(Feature.hwmult32)] = .{
|
|
|
|
.llvm_name = "hwmult32",
|
|
|
|
.description = "Enable 32-bit hardware multiplier",
|
2020-01-21 17:11:36 -08:00
|
|
|
.dependencies = featureSet(&[_]Feature{}),
|
2020-01-20 19:21:45 -08:00
|
|
|
};
|
|
|
|
result[@enumToInt(Feature.hwmultf5)] = .{
|
|
|
|
.llvm_name = "hwmultf5",
|
|
|
|
.description = "Enable F5 series hardware multiplier",
|
2020-01-21 17:11:36 -08:00
|
|
|
.dependencies = featureSet(&[_]Feature{}),
|
2020-01-20 19:21:45 -08:00
|
|
|
};
|
2020-01-21 16:40:44 -08:00
|
|
|
const ti = @typeInfo(Feature);
|
|
|
|
for (result) |*elem, i| {
|
|
|
|
elem.index = i;
|
|
|
|
elem.name = ti.Enum.fields[i].name;
|
|
|
|
}
|
2020-01-20 19:21:45 -08:00
|
|
|
break :blk result;
|
2019-12-20 16:27:13 -08:00
|
|
|
};
|
|
|
|
|
2020-01-20 19:21:45 -08:00
|
|
|
pub const cpu = struct {
|
2020-02-19 18:30:36 -08:00
|
|
|
pub const generic = CpuModel{
|
2020-01-20 19:21:45 -08:00
|
|
|
.name = "generic",
|
|
|
|
.llvm_name = "generic",
|
2020-01-21 17:11:36 -08:00
|
|
|
.features = featureSet(&[_]Feature{}),
|
2020-01-20 19:21:45 -08:00
|
|
|
};
|
2020-02-19 18:30:36 -08:00
|
|
|
pub const msp430 = CpuModel{
|
2020-01-20 19:21:45 -08:00
|
|
|
.name = "msp430",
|
|
|
|
.llvm_name = "msp430",
|
2020-01-21 17:11:36 -08:00
|
|
|
.features = featureSet(&[_]Feature{}),
|
2020-01-20 19:21:45 -08:00
|
|
|
};
|
2020-02-19 18:30:36 -08:00
|
|
|
pub const msp430x = CpuModel{
|
2020-01-20 19:21:45 -08:00
|
|
|
.name = "msp430x",
|
|
|
|
.llvm_name = "msp430x",
|
2020-01-21 17:11:36 -08:00
|
|
|
.features = featureSet(&[_]Feature{
|
2020-01-20 19:21:45 -08:00
|
|
|
.ext,
|
|
|
|
}),
|
|
|
|
};
|
2019-12-20 16:27:13 -08:00
|
|
|
};
|
|
|
|
|
2020-01-20 19:21:45 -08:00
|
|
|
/// All msp430 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.
|
2020-02-19 18:30:36 -08:00
|
|
|
pub const all_cpus = &[_]*const CpuModel{
|
2020-01-20 19:21:45 -08:00
|
|
|
&cpu.generic,
|
|
|
|
&cpu.msp430,
|
|
|
|
&cpu.msp430x,
|
2019-12-20 16:27:13 -08:00
|
|
|
};
|