Skip to content

Commit

Permalink
Updated all inst handler classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kathlenemagnus committed Dec 10, 2024
1 parent ffb3b81 commit abbf1eb
Show file tree
Hide file tree
Showing 15 changed files with 708 additions and 542 deletions.
19 changes: 10 additions & 9 deletions core/Execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ namespace atlas
execute_action.addTag(ActionTags::EXECUTE_TAG);
execute_action_group_.addAction(execute_action);

// TODO: Get RV32 inst handlers
// Get instruction handlers
RviInsts::getInstHandlers<RV64>(inst_handlers_);
RvmInsts::getInstHandlers(inst_handlers_);
RvaInsts::getInstHandlers(inst_handlers_);
RvfInsts::getInstHandlers(inst_handlers_);
RvdInsts::getInstHandlers(inst_handlers_);
RvzicsrInsts::getInstHandlers(inst_handlers_);
RvzifenceiInsts::getInstHandlers(inst_handlers_);
RvmInsts::getInstHandlers<RV64>(inst_handlers_);
RvaInsts::getInstHandlers<RV64>(inst_handlers_);
RvfInsts::getInstHandlers<RV64>(inst_handlers_);
RvdInsts::getInstHandlers<RV64>(inst_handlers_);
RvzicsrInsts::getInstHandlers<RV64>(inst_handlers_);
RvzifenceiInsts::getInstHandlers<RV64>(inst_handlers_);

// Get instruction compute address handlers
RviInsts::getInstComputeAddressHandlers<RV64>(inst_compute_address_handlers_);
RvaInsts::getInstComputeAddressHandlers(inst_compute_address_handlers_);
RvfInsts::getInstComputeAddressHandlers(inst_compute_address_handlers_);
RvdInsts::getInstComputeAddressHandlers(inst_compute_address_handlers_);
RvaInsts::getInstComputeAddressHandlers<RV64>(inst_compute_address_handlers_);
RvfInsts::getInstComputeAddressHandlers<RV64>(inst_compute_address_handlers_);
RvdInsts::getInstComputeAddressHandlers<RV64>(inst_compute_address_handlers_);
}

ActionGroup* Execute::execute_(AtlasState* state)
Expand Down
355 changes: 198 additions & 157 deletions core/inst_handlers/a/RvaInsts.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/inst_handlers/a/RvaInsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace atlas
public:
using base_type = RvaInsts;

template <typename XLEN>
static void getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers);
template <typename XLEN>
static void getInstHandlers(std::map<std::string, Action> & inst_handlers);

private:
Expand Down
273 changes: 150 additions & 123 deletions core/inst_handlers/d/RvdInsts.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions core/inst_handlers/d/RvdInsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace atlas
public:
using base_type = RvdInsts;

template <typename XLEN>
static void getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers);
template <typename XLEN>
static void getInstHandlers(std::map<std::string, Action> & inst_handlers);

private:
Expand Down
223 changes: 124 additions & 99 deletions core/inst_handlers/f/RvfInsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,109 +4,134 @@

namespace atlas
{
template <typename XLEN>
void RvfInsts::getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers)
{
inst_handlers.emplace(
"flw", atlas::Action::createAction<&RvfInsts::flw_64_compute_address_handler, RvfInsts>(
nullptr, "flw", ActionTags::COMPUTE_ADDR_TAG));
inst_handlers.emplace(
"fsw", atlas::Action::createAction<&RvfInsts::fsw_64_compute_address_handler, RvfInsts>(
nullptr, "fsw", ActionTags::COMPUTE_ADDR_TAG));
}

static_assert(std::is_same<XLEN, RV64>::value || std::is_same<XLEN, RV32>::value);
if constexpr (std::is_same<XLEN, RV64>::value)
{
inst_handlers.emplace(
"flw",
atlas::Action::createAction<&RvfInsts::flw_64_compute_address_handler, RvfInsts>(
nullptr, "flw", ActionTags::COMPUTE_ADDR_TAG));
inst_handlers.emplace(
"fsw",
atlas::Action::createAction<&RvfInsts::fsw_64_compute_address_handler, RvfInsts>(
nullptr, "fsw", ActionTags::COMPUTE_ADDR_TAG));
}
else if constexpr (std::is_same<XLEN, RV32>::value)
{
sparta_assert(false, "RV32 is not supported yet!");
}
}

template <typename XLEN>
void RvfInsts::getInstHandlers(std::map<std::string, Action> & inst_handlers)
{
inst_handlers.emplace("fadd.s",
atlas::Action::createAction<&RvfInsts::fadd_s_64_handler, RvfInsts>(
nullptr, "fadd_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fclass.s",
atlas::Action::createAction<&RvfInsts::fclass_s_64_handler, RvfInsts>(
nullptr, "fclass_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fcvt.l.s",
atlas::Action::createAction<&RvfInsts::fcvt_l_s_64_handler, RvfInsts>(
nullptr, "fcvt_l_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.lu.s", atlas::Action::createAction<&RvfInsts::fcvt_lu_s_64_handler, RvfInsts>(
nullptr, "fcvt_lu_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fcvt.s.l",
atlas::Action::createAction<&RvfInsts::fcvt_s_l_64_handler, RvfInsts>(
nullptr, "fcvt_s_l", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.s.lu", atlas::Action::createAction<&RvfInsts::fcvt_s_lu_64_handler, RvfInsts>(
nullptr, "fcvt_s_lu", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fcvt.s.w",
atlas::Action::createAction<&RvfInsts::fcvt_s_w_64_handler, RvfInsts>(
nullptr, "fcvt_s_w", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.s.wu", atlas::Action::createAction<&RvfInsts::fcvt_s_wu_64_handler, RvfInsts>(
nullptr, "fcvt_s_wu", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fcvt.w.s",
atlas::Action::createAction<&RvfInsts::fcvt_w_s_64_handler, RvfInsts>(
nullptr, "fcvt_w_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.wu.s", atlas::Action::createAction<&RvfInsts::fcvt_wu_s_64_handler, RvfInsts>(
nullptr, "fcvt_wu_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fdiv.s",
atlas::Action::createAction<&RvfInsts::fdiv_s_64_handler, RvfInsts>(
nullptr, "fdiv_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("feq.s",
atlas::Action::createAction<&RvfInsts::feq_s_64_handler, RvfInsts>(
nullptr, "feq_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fle.s",
atlas::Action::createAction<&RvfInsts::fle_s_64_handler, RvfInsts>(
nullptr, "fle_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("flt.s",
atlas::Action::createAction<&RvfInsts::flt_s_64_handler, RvfInsts>(
nullptr, "flt_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("flw",
atlas::Action::createAction<&RvfInsts::flw_64_handler, RvfInsts>(
nullptr, "flw", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmadd.s",
atlas::Action::createAction<&RvfInsts::fmadd_s_64_handler, RvfInsts>(
nullptr, "fmadd_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmax.s",
atlas::Action::createAction<&RvfInsts::fmax_s_64_handler, RvfInsts>(
nullptr, "fmax_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmin.s",
atlas::Action::createAction<&RvfInsts::fmin_s_64_handler, RvfInsts>(
nullptr, "fmin_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmsub.s",
atlas::Action::createAction<&RvfInsts::fmsub_s_64_handler, RvfInsts>(
nullptr, "fmsub_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmul.s",
atlas::Action::createAction<&RvfInsts::fmul_s_64_handler, RvfInsts>(
nullptr, "fmul_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmv.w.x",
atlas::Action::createAction<&RvfInsts::fmv_w_x_64_handler, RvfInsts>(
nullptr, "fmv_w_x", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fmv.x.w",
atlas::Action::createAction<&RvfInsts::fmv_x_w_64_handler, RvfInsts>(
nullptr, "fmv_x_w", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fnmadd.s",
atlas::Action::createAction<&RvfInsts::fnmadd_s_64_handler, RvfInsts>(
nullptr, "fnmadd_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fnmsub.s",
atlas::Action::createAction<&RvfInsts::fnmsub_s_64_handler, RvfInsts>(
nullptr, "fnmsub_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsgnj.s",
atlas::Action::createAction<&RvfInsts::fsgnj_s_64_handler, RvfInsts>(
nullptr, "fsgnj_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsgnjn.s",
atlas::Action::createAction<&RvfInsts::fsgnjn_s_64_handler, RvfInsts>(
nullptr, "fsgnjn_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsgnjx.s",
atlas::Action::createAction<&RvfInsts::fsgnjx_s_64_handler, RvfInsts>(
nullptr, "fsgnjx_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsqrt.s",
atlas::Action::createAction<&RvfInsts::fsqrt_s_64_handler, RvfInsts>(
nullptr, "fsqrt_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsub.s",
atlas::Action::createAction<&RvfInsts::fsub_s_64_handler, RvfInsts>(
nullptr, "fsub_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsw",
atlas::Action::createAction<&RvfInsts::fsw_64_handler, RvfInsts>(
nullptr, "fsw", ActionTags::EXECUTE_TAG));
}
static_assert(std::is_same<XLEN, RV64>::value || std::is_same<XLEN, RV32>::value);
if constexpr (std::is_same<XLEN, RV64>::value)
{
inst_handlers.emplace(
"fadd.s", atlas::Action::createAction<&RvfInsts::fadd_s_64_handler, RvfInsts>(
nullptr, "fadd_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fclass.s", atlas::Action::createAction<&RvfInsts::fclass_s_64_handler, RvfInsts>(
nullptr, "fclass_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.l.s", atlas::Action::createAction<&RvfInsts::fcvt_l_s_64_handler, RvfInsts>(
nullptr, "fcvt_l_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.lu.s", atlas::Action::createAction<&RvfInsts::fcvt_lu_s_64_handler, RvfInsts>(
nullptr, "fcvt_lu_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.s.l", atlas::Action::createAction<&RvfInsts::fcvt_s_l_64_handler, RvfInsts>(
nullptr, "fcvt_s_l", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.s.lu", atlas::Action::createAction<&RvfInsts::fcvt_s_lu_64_handler, RvfInsts>(
nullptr, "fcvt_s_lu", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.s.w", atlas::Action::createAction<&RvfInsts::fcvt_s_w_64_handler, RvfInsts>(
nullptr, "fcvt_s_w", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.s.wu", atlas::Action::createAction<&RvfInsts::fcvt_s_wu_64_handler, RvfInsts>(
nullptr, "fcvt_s_wu", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.w.s", atlas::Action::createAction<&RvfInsts::fcvt_w_s_64_handler, RvfInsts>(
nullptr, "fcvt_w_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fcvt.wu.s", atlas::Action::createAction<&RvfInsts::fcvt_wu_s_64_handler, RvfInsts>(
nullptr, "fcvt_wu_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fdiv.s", atlas::Action::createAction<&RvfInsts::fdiv_s_64_handler, RvfInsts>(
nullptr, "fdiv_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"feq.s", atlas::Action::createAction<&RvfInsts::feq_s_64_handler, RvfInsts>(
nullptr, "feq_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fle.s", atlas::Action::createAction<&RvfInsts::fle_s_64_handler, RvfInsts>(
nullptr, "fle_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"flt.s", atlas::Action::createAction<&RvfInsts::flt_s_64_handler, RvfInsts>(
nullptr, "flt_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("flw",
atlas::Action::createAction<&RvfInsts::flw_64_handler, RvfInsts>(
nullptr, "flw", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmadd.s", atlas::Action::createAction<&RvfInsts::fmadd_s_64_handler, RvfInsts>(
nullptr, "fmadd_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmax.s", atlas::Action::createAction<&RvfInsts::fmax_s_64_handler, RvfInsts>(
nullptr, "fmax_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmin.s", atlas::Action::createAction<&RvfInsts::fmin_s_64_handler, RvfInsts>(
nullptr, "fmin_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmsub.s", atlas::Action::createAction<&RvfInsts::fmsub_s_64_handler, RvfInsts>(
nullptr, "fmsub_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmul.s", atlas::Action::createAction<&RvfInsts::fmul_s_64_handler, RvfInsts>(
nullptr, "fmul_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmv.w.x", atlas::Action::createAction<&RvfInsts::fmv_w_x_64_handler, RvfInsts>(
nullptr, "fmv_w_x", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fmv.x.w", atlas::Action::createAction<&RvfInsts::fmv_x_w_64_handler, RvfInsts>(
nullptr, "fmv_x_w", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fnmadd.s", atlas::Action::createAction<&RvfInsts::fnmadd_s_64_handler, RvfInsts>(
nullptr, "fnmadd_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fnmsub.s", atlas::Action::createAction<&RvfInsts::fnmsub_s_64_handler, RvfInsts>(
nullptr, "fnmsub_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fsgnj.s", atlas::Action::createAction<&RvfInsts::fsgnj_s_64_handler, RvfInsts>(
nullptr, "fsgnj_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fsgnjn.s", atlas::Action::createAction<&RvfInsts::fsgnjn_s_64_handler, RvfInsts>(
nullptr, "fsgnjn_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fsgnjx.s", atlas::Action::createAction<&RvfInsts::fsgnjx_s_64_handler, RvfInsts>(
nullptr, "fsgnjx_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fsqrt.s", atlas::Action::createAction<&RvfInsts::fsqrt_s_64_handler, RvfInsts>(
nullptr, "fsqrt_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace(
"fsub.s", atlas::Action::createAction<&RvfInsts::fsub_s_64_handler, RvfInsts>(
nullptr, "fsub_s", ActionTags::EXECUTE_TAG));
inst_handlers.emplace("fsw",
atlas::Action::createAction<&RvfInsts::fsw_64_handler, RvfInsts>(
nullptr, "fsw", ActionTags::EXECUTE_TAG));
}
else if constexpr (std::is_same<XLEN, RV32>::value)
{
sparta_assert(false, "RV32 is not supported yet!");
}
}

template void RvfInsts::getInstComputeAddressHandlers<RV32>(std::map<std::string, Action> &);
template void RvfInsts::getInstComputeAddressHandlers<RV64>(std::map<std::string, Action> &);
template void RvfInsts::getInstHandlers<RV32>(std::map<std::string, Action> &);
template void RvfInsts::getInstHandlers<RV64>(std::map<std::string, Action> &);

ActionGroup* RvfInsts::fsqrt_s_64_handler(atlas::AtlasState* state)
{
Expand Down
2 changes: 2 additions & 0 deletions core/inst_handlers/f/RvfInsts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace atlas
public:
using base_type = RvfInsts;

template <typename XLEN>
static void getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers);
template <typename XLEN>
static void getInstHandlers(std::map<std::string, Action> & inst_handlers);

private:
Expand Down
Loading

0 comments on commit abbf1eb

Please sign in to comment.