From bbaf58c9fd0f485266d86868dc35f1d2be3589cd Mon Sep 17 00:00:00 2001 From: Julian Blake Kongslie Date: Sun, 26 Jun 2022 16:24:13 -0700 Subject: Significant changes, and a working "ISA" that just computes fib(n). --- aisa/eval.h | 65 ------------------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 aisa/eval.h (limited to 'aisa/eval.h') diff --git a/aisa/eval.h b/aisa/eval.h deleted file mode 100644 index a301e93..0000000 --- a/aisa/eval.h +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include - -#include "aisa/aisa.h" -#include "aisa/coroutine.h" // IWYU pragma: export - -namespace aisa { - - template struct EvalState { - struct EvalContext { - task coroutine; - - bool resume() { return coroutine(); } - }; - - CRTP & crtp() noexcept { return static_cast(*this); } - - task async_load_reg(regnum_t rn) - { - while (true) { - if (auto rv = crtp().load_reg(rn); rv.has_value()) - co_return *rv; - co_await std::suspend_always{}; - } - } - - task async_store_reg(regnum_t rn, regval_t rv) - { - while (true) { - if (crtp().store_reg(rn, rv)) - co_return; - co_await std::suspend_always{}; - } - } - - task async_evaluate(EvalContext &contex, const Step &step) - { - if (step.predicate.has_value()) { - regval_t pval = co_await async_load_reg(step.predicate->first); - if (pval != step.predicate->second) - co_return; - } - std::vector source_vals; - source_vals.reserve(step.source_regs.size()); - for (unsigned int i = 0; i < step.source_regs.size(); ++i) - source_vals.emplace_back(co_await async_load_reg(step.source_regs[i])); - auto destination_vals = step.compute_destinations(source_vals); - for (unsigned int i = 0; i < step.destination_regs.size(); ++i) - co_await async_store_reg(step.destination_regs[i], destination_vals[i]); - } - - std::unique_ptr operator()(const Step &step) - { - auto context = std::make_unique(); - context->coroutine = async_evaluate(*context, step); - return context; - } - }; - -} -- cgit v1.2.3