diff --git a/InstructionSets/CachingExecutor.hpp b/InstructionSets/CachingExecutor.hpp index ebd555b19..c6a3f4cd4 100644 --- a/InstructionSets/CachingExecutor.hpp +++ b/InstructionSets/CachingExecutor.hpp @@ -9,16 +9,55 @@ #ifndef CachingExecutor_hpp #define CachingExecutor_hpp +#include +#include +#include + namespace InstructionSet { -template class CachingExecutor { +/*! + Maps to the smallest of the following integers that can contain max_value: + + * uint8_t; + * uint16_t; + * uint32_t; or + * uint64_t. +*/ +template struct MinIntTypeValue { + using type = + std::conditional_t< + max_value <= std::numeric_limits::max(), uint8_t, + std::conditional_t< + max_value <= std::numeric_limits::max(), uint16_t, + std::conditional_t< + max_value <= std::numeric_limits::max(), uint32_t, + uint64_t + > + > + >; +}; + + + +template < + /// Indicates the Executor for this platform. + typename Executor, + /// Indicates the greatest value the program counter might take. + uint64_t max_address, + /// Indicates the maximum number of potential performers that will be provided. + uint64_t max_performer_count, + /// Indicates whether performers will acess their decoded instructions; if @c false then instructions are not retained. + bool keep_instruction_structs +> class CachingExecutor { public: protected: - AddressType program_counter_; + using Performer = void (*)(Executor *); + std::array performers_; + typename MinIntTypeValue::type program_counter_; private: - Action actions_[100]; // TODO: just a test declaration; these actually need to be bucketed by page, etc. + typename MinIntTypeValue::type actions_[100]; }; } diff --git a/InstructionSets/M50740/Executor.hpp b/InstructionSets/M50740/Executor.hpp index 27a6354ee..3ed004322 100644 --- a/InstructionSets/M50740/Executor.hpp +++ b/InstructionSets/M50740/Executor.hpp @@ -29,11 +29,11 @@ struct Action { inline Action(Performer performer) noexcept : perform(performer) {} }; -class Executor: public CachingExecutor { +class Executor: public CachingExecutor { public: private: - friend CachingExecutor; + friend CachingExecutor; Action action_for(Instruction); /*!