Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/log/catalog/mipi_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ template <packer P> struct builder<defn::short32_msg_t, P> {

template <typename Storage, packer P> struct catalog_builder {
template <auto Level, packable... Ts>
static auto build(string_id id, module_id m, unit_t u, Ts... args) {
static auto build(string_id id, module_id m, unit_t u, Ts... args)
-> defn::catalog_msg_t::owner_t<Storage> {
using namespace msg;
defn::catalog_msg_t::owner_t<Storage> message{
"severity"_field = Level, "module_id"_field = m, "unit"_field = u};
Expand Down
15 changes: 10 additions & 5 deletions include/lookup/pseudo_pext_lookup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ constexpr auto with_mask(T const mask, std::array<T, S> const &keys)
}

template <typename T, typename V, std::size_t S>
constexpr auto get_keys(std::array<entry<T, V>, S> const &entries) {
constexpr auto get_keys(std::array<entry<T, V>, S> const &entries)
-> std::array<detail::raw_integral_t<T>, S> {
using raw_t = detail::raw_integral_t<T>;
std::array<raw_t, S> new_keys{};

Expand Down Expand Up @@ -373,7 +374,8 @@ struct pseudo_pext_lookup {
return empty_impl<key_type, value_type, default_value>{};

} else if constexpr (use_indirect_strategy) {
constexpr auto storage = [&]() {
constexpr auto storage =
[&]() -> std::remove_const_t<decltype(input.entries)> {
auto s = input.entries;

// sort by the hashed key to group all the buckets together
Expand Down Expand Up @@ -416,8 +418,9 @@ struct pseudo_pext_lookup {
return s;
}();

constexpr auto lookup_table = [&]() {
using lookup_idx_t = detail::uint_for_<storage.size()>;
using lookup_idx_t = detail::uint_for_<storage.size()>;
constexpr auto lookup_table =
[&]() -> std::array<lookup_idx_t, lookup_table_size> {
std::array<lookup_idx_t, lookup_table_size> t{};

t.fill(0);
Expand All @@ -442,7 +445,9 @@ struct pseudo_pext_lookup {
p, lookup_table, storage};

} else {
constexpr auto storage = [&]() {
constexpr auto storage =
[&]() -> std::array<entry<raw_key_type, value_type>,
lookup_table_size> {
std::array<entry<raw_key_type, value_type>, lookup_table_size>
s{};

Expand Down
26 changes: 15 additions & 11 deletions include/lookup/strategies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,30 @@
#include <lookup/strategy_failed.hpp>

#include <stdx/compiler.hpp>
#include <stdx/type_traits.hpp>

namespace lookup {
template <typename...> struct strategies;
#include <algorithm>
#include <array>
#include <iterator>

template <> struct strategies<> {
namespace lookup {
struct fail_strategy_t {
[[nodiscard]] CONSTEVAL static auto make(compile_time auto)
-> strategy_failed_t {
return {};
}
};

template <typename T, typename... Ts> struct strategies<T, Ts...> {
template <typename... Ts> struct strategies {
[[nodiscard]] CONSTEVAL static auto make(compile_time auto input) {
constexpr auto candidate = T::make(input);

if constexpr (strategy_failed(candidate)) {
return strategies<Ts...>::make(input);
} else {
return candidate;
}
constexpr auto idx = [&] {
constexpr auto results =
std::array{not strategy_failed(Ts::make(input))...};
return std::distance(
std::cbegin(results),
std::find(std::cbegin(results), std::cend(results), true));
}();
return stdx::nth_t<idx, Ts..., fail_strategy_t>::make(input);
}
};
} // namespace lookup
4 changes: 2 additions & 2 deletions include/match/and.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ template <matcher L, matcher R> struct and_t : bin_op_t<and_t, "and", L, R> {
auto r = simplify(m.rhs);

if constexpr (implies(l, r)) {
return l;
return [&] { return l; }();
} else if constexpr (implies(r, l)) {
return r;
return [&] { return r; }();
} else if constexpr (implies(l, negate(r)) or implies(r, negate(l))) {
return never;
} else {
Expand Down
4 changes: 2 additions & 2 deletions include/match/or.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ template <matcher L, matcher R> struct or_t : bin_op_t<or_t, "or", L, R> {
auto r = simplify(m.rhs);

if constexpr (implies(l, r)) {
return r;
return [&] { return r; }();
} else if constexpr (implies(r, l)) {
return l;
return [&] { return l; }();
} else if constexpr (implies(negate(l), r) or implies(negate(r), l)) {
return always;
} else {
Expand Down
Loading