31 const std::vector<match_t> matches_;
39 bool operator()(
const match_t &a,
const match_t &b)
const {
40 return std::tie(a.word1, a.word0) < std::tie(b.word1, b.word0);
44 bool is_power_of_2(big_int value) {
return value && !(value & (value - 1)); }
55 std::set<match_t, cmp> reduce(
const std::set<match_t, cmp> matches) {
56 std::set<match_t, cmp> transformed_matches;
57 for (
const auto &match1 : matches) {
58 bool combined_matches =
false;
59 for (
const auto &match2 : matches) {
60 big_int xor0 = match1.word0 ^ match2.word0, xor1 = match1.word1 ^ match2.word1;
62 if (xor0 == 0 && xor1 == 0)
continue;
63 if (xor0 != xor1)
continue;
64 if (!is_power_of_2(xor0))
continue;
66 match_t combined_match((match1.word0 | xor0), (match1.word1 | xor1));
67 transformed_matches.insert(combined_match);
68 combined_matches =
true;
70 if (!combined_matches) transformed_matches.insert(match1);
72 if (transformed_matches != matches)
return reduce(transformed_matches);
81 void has_full_match_coverage() {
82 auto is_unconditional_match = [](match_t match) {
83 return match == match_t::dont_care(0) || match == match_t::dont_care(8) ||
84 match == match_t::dont_care(16) || match == match_t::dont_care(24) ||
85 match == match_t::dont_care(32);
88 rv = std::any_of(matches_.begin(), matches_.end(), is_unconditional_match);
91 std::set<match_t, cmp> reduced_matches =
92 reduce(std::set<match_t, cmp>(matches_.begin(), matches_.end()));
93 rv = std::any_of(reduced_matches.begin(), reduced_matches.end(), is_unconditional_match);
100 has_full_match_coverage();