authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-11 14:01:13-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-06-11 14:01:13-07:00
logda4081fe21f534157a7a88e2d6b2b6a80ee2f32d
tree7e1b177c8e28979af2ceb306c71e2337a67f5b8e
parent7ba175cd8b6fe421cd9c75c03006d2325906076c

cleanups to previous commit

* fix a merge conflict discovered upon rebasing latest master * rename Target.Cpu.Feature.Set.subSet to isSuperSetOf * convert a comment into an assert

2 files changed, 9 insertions(+), 14 deletions(-)

lib/std/build.zig+4-9
......@@ -637,21 +637,15 @@ pub const Builder = struct {
637637 "target",
638638 "The CPU architecture, OS, and ABI to build for",
639639 );
640 const mcpu = self.option([]const u8, "cpu", "Target CPU");
640 const mcpu = self.option([]const u8, "cpu", "Target CPU features to add or subtract");
641641
642642 const triple = maybe_triple orelse return args.default_target;
643 const cpu_features = self.option(
644 []const u8,
645 "mcpu",
646 "The list of CPU features to add or subtract",
647 );
648643
649644 var diags: CrossTarget.ParseOptions.Diagnostics = .{};
650645 const selected_target = CrossTarget.parse(.{
651646 .arch_os_abi = triple,
652647 .cpu_features = mcpu,
653648 .diagnostics = &diags,
654 .cpu_features = cpu_features,
655649 }) catch |err| switch (err) {
656650 error.UnknownCpuModel => {
657651 warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{
......@@ -716,7 +710,7 @@ pub const Builder = struct {
716710 if (mem.eql(u8, t_triple, selected_canonicalized_triple)) {
717711 mismatch_triple = false;
718712 whitelist_item = t;
719 if (t.getCpuFeatures().subSet(selected_target.getCpuFeatures())) {
713 if (t.getCpuFeatures().isSuperSetOf(selected_target.getCpuFeatures())) {
720714 mismatch_cpu_features = false;
721715 break :whitelist_check;
722716 } else {
......@@ -733,7 +727,8 @@ pub const Builder = struct {
733727 warn(" {s}\n", .{t_triple});
734728 }
735729 warn("\n", .{});
736 } else { // mismatch_cpu_features
730 } else {
731 assert(mismatch_cpu_features);
737732 const whitelist_cpu = whitelist_item.getCpu();
738733 const selected_cpu = selected_target.getCpu();
739734 warn("Chosen CPU model '{s}' does not match one of the supported targets:\n", .{
lib/std/target.zig+5-5
......@@ -668,11 +668,11 @@ pub const Target = struct {
668668 return mem.eql(usize, &set.ints, &other_set.ints);
669669 }
670670
671 /// Is the other set a sub set of this set
672 pub fn subSet(set: Set, other_set: Set) bool {
673 return std.meta.eql((@as(std.meta.Vector(usize_count, usize), set.ints) &
674 @as(std.meta.Vector(usize_count, usize), other_set.ints)),
675 @as(std.meta.Vector(usize_count, usize), other_set.ints));
671 pub fn isSuperSetOf(set: Set, other_set: Set) bool {
672 const V = std.meta.Vector(usize_count, usize);
673 const set_v: V = set.ints;
674 const other_v: V = other_set.ints;
675 return @reduce(.And, (set_v & other_v) == other_v);
676676 }
677677 };
678678