From b62095815137b308a4457c20fec97ca9672c599a Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sat, 25 Jun 2022 12:54:33 -0700 Subject: Testing some actual support for destinations and custom steps. --- aisa/aisa.h | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'aisa') diff --git a/aisa/aisa.h b/aisa/aisa.h index 8cb302e..123b12a 100644 --- a/aisa/aisa.h +++ b/aisa/aisa.h @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,7 @@ namespace aisa { template struct EvalState { CRTP & crtp() noexcept { return static_cast(*this); } + task async_load_reg(regnum_t rn) { while (true) { @@ -24,12 +26,21 @@ namespace aisa { co_await suspend(); } } + + task async_store_reg(regnum_t rn, regval_t rv) + { + while (true) { + if (crtp().store_reg(rn, rv)) + co_return; + co_await suspend(); + } + } }; struct Step { - const std::optional> predicate; - const std::vector source_regs; - const std::vector destination_regs; + std::optional> predicate; + std::vector source_regs; + std::vector destination_regs; std::optional predicate_reg() const { @@ -45,33 +56,22 @@ namespace aisa { return {}; } - template task evaluate(State &state) const + virtual std::vector compute_destinations(const std::vector &source_vals) const = 0; + + template task eval(State &state) const { if (predicate.has_value()) { - std::cout << "checking predicate...\n"; - std::cout << "\texpect " << predicate->second << "\n"; regval_t pval = co_await state.async_load_reg(predicate->first); - std::cout << "\tgot " << pval << "\n"; - if (pval != predicate->second) { - std::cout << "\tpredicate skipped\n"; + if (pval != predicate->second) co_return; - } else { - std::cout << "\tpredicate not skipped\n"; - } } - std::cout << "reading sources...\n"; std::vector source_vals; source_vals.reserve(source_regs.size()); - for (unsigned int i = 0; i < source_regs.size(); ++i) { - std::cout << "\tgetting source " << i << "...\n"; - source_vals.emplace_back(co_await state.async_load_reg(source_regs[i])); - std::cout << "\t\tgot " << source_vals.back() << "\n"; - } - std::cout << "sources:"; for (unsigned int i = 0; i < source_regs.size(); ++i) - std::cout << " " << source_regs[i] << "=" << source_vals[i]; - std::cout << "\n"; - std::cout << "done with evaluate\n"; + source_vals.emplace_back(co_await state.async_load_reg(source_regs[i])); + auto destination_vals = compute_destinations(source_vals); + for (unsigned int i = 0; i < destination_regs.size(); ++i) + co_await state.async_store_reg(destination_regs[i], destination_vals[i]); } }; -- cgit v1.2.3