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 {...@@ -637,21 +637,15 @@ pub const Builder = struct {
637 "target",637 "target",
638 "The CPU architecture, OS, and ABI to build for",638 "The CPU architecture, OS, and ABI to build for",
639 );639 );
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
642 const triple = maybe_triple orelse return args.default_target;642 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
649 var diags: CrossTarget.ParseOptions.Diagnostics = .{};644 var diags: CrossTarget.ParseOptions.Diagnostics = .{};
650 const selected_target = CrossTarget.parse(.{645 const selected_target = CrossTarget.parse(.{
651 .arch_os_abi = triple,646 .arch_os_abi = triple,
652 .cpu_features = mcpu,647 .cpu_features = mcpu,
653 .diagnostics = &diags,648 .diagnostics = &diags,
654 .cpu_features = cpu_features,
655 }) catch |err| switch (err) {649 }) catch |err| switch (err) {
656 error.UnknownCpuModel => {650 error.UnknownCpuModel => {
657 warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{651 warn("Unknown CPU: '{s}'\nAvailable CPUs for architecture '{s}':\n", .{
...@@ -716,7 +710,7 @@ pub const Builder = struct {...@@ -716,7 +710,7 @@ pub const Builder = struct {
716 if (mem.eql(u8, t_triple, selected_canonicalized_triple)) {710 if (mem.eql(u8, t_triple, selected_canonicalized_triple)) {
717 mismatch_triple = false;711 mismatch_triple = false;
718 whitelist_item = t;712 whitelist_item = t;
719 if (t.getCpuFeatures().subSet(selected_target.getCpuFeatures())) {713 if (t.getCpuFeatures().isSuperSetOf(selected_target.getCpuFeatures())) {
720 mismatch_cpu_features = false;714 mismatch_cpu_features = false;
721 break :whitelist_check;715 break :whitelist_check;
722 } else {716 } else {
...@@ -733,7 +727,8 @@ pub const Builder = struct {...@@ -733,7 +727,8 @@ pub const Builder = struct {
733 warn(" {s}\n", .{t_triple});727 warn(" {s}\n", .{t_triple});
734 }728 }
735 warn("\n", .{});729 warn("\n", .{});
736 } else { // mismatch_cpu_features730 } else {
731 assert(mismatch_cpu_features);
737 const whitelist_cpu = whitelist_item.getCpu();732 const whitelist_cpu = whitelist_item.getCpu();
738 const selected_cpu = selected_target.getCpu();733 const selected_cpu = selected_target.getCpu();
739 warn("Chosen CPU model '{s}' does not match one of the supported targets:\n", .{734 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 {...@@ -668,11 +668,11 @@ pub const Target = struct {
668 return mem.eql(usize, &set.ints, &other_set.ints);668 return mem.eql(usize, &set.ints, &other_set.ints);
669 }669 }
670670
671 /// Is the other set a sub set of this set671 pub fn isSuperSetOf(set: Set, other_set: Set) bool {
672 pub fn subSet(set: Set, other_set: Set) bool {672 const V = std.meta.Vector(usize_count, usize);
673 return std.meta.eql((@as(std.meta.Vector(usize_count, usize), set.ints) &673 const set_v: V = set.ints;
674 @as(std.meta.Vector(usize_count, usize), other_set.ints)),674 const other_v: V = other_set.ints;
675 @as(std.meta.Vector(usize_count, usize), other_set.ints));675 return @reduce(.And, (set_v & other_v) == other_v);
676 }676 }
677 };677 };
678678