From 86942e3e7cd05a69c3b27f920dedf65dfce9206a Mon Sep 17 00:00:00 2001 From: liya zhu Date: Wed, 4 Dec 2024 14:03:56 -0800 Subject: [PATCH 1/2] AM-1011: add RV64A instruction handlers --- core/inst_handlers/rv64/a/RvaInsts.cpp | 447 ++++++--------------- core/inst_handlers/rv64/a/inst_helpers.hpp | 84 ++++ 2 files changed, 205 insertions(+), 326 deletions(-) create mode 100644 core/inst_handlers/rv64/a/inst_helpers.hpp diff --git a/core/inst_handlers/rv64/a/RvaInsts.cpp b/core/inst_handlers/rv64/a/RvaInsts.cpp index a04fb9d..55a87e5 100644 --- a/core/inst_handlers/rv64/a/RvaInsts.cpp +++ b/core/inst_handlers/rv64/a/RvaInsts.cpp @@ -1,4 +1,5 @@ #include "core/inst_handlers/rv64/a/RvaInsts.hpp" +#include "core/inst_handlers/rv64/a/inst_helpers.hpp" #include "include/ActionTags.hpp" #include "core/ActionGroup.hpp" @@ -166,467 +167,261 @@ namespace atlas nullptr, "sc_w", ActionTags::EXECUTE_TAG)); } - ActionGroup* RvaInsts::amoadd_w_64_compute_address_handler(atlas::AtlasState* state) - { - (void)state; - return nullptr; - } - ActionGroup* RvaInsts::amoadd_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoadd_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t lhs) { return lhs + RS2; }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amomaxu_w_64_compute_address_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoadd_d_64_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amomaxu_w_64_handler(atlas::AtlasState* state) - { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t lhs) { return std::max(lhs, - // uint32_t(RS2)); }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; - } - ActionGroup* RvaInsts::amoadd_d_64_compute_address_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoadd_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoadd_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoadd_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t lhs) { return lhs + RS2; })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amominu_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoand_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amominu_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoand_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t lhs) { return std::min(lhs, RS2); })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amominu_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoand_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amominu_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoand_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t lhs) { return std::min(lhs, - // uint32_t(RS2)); }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoor_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amomax_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoor_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amomax_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t lhs) { return lhs | RS2; })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoxor_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amomax_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoxor_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amomax_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t lhs) { return lhs ^ RS2; })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoswap_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amomaxu_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoswap_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amomaxu_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t UNUSED lhs) { return RS2; }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::lr_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amomaxu_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::lr_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amomaxu_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.load_reserved(RS1)); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoor_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amomin_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoor_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amomin_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t lhs) { return lhs | RS2; }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amomaxu_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amomin_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amomaxu_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amomin_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t lhs) { return std::max(lhs, RS2); })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoswap_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amominu_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoswap_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amominu_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t UNUSED lhs) { return RS2; })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amomax_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amominu_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amomax_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amominu_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](int32_t lhs) { return std::max(lhs, - // int32_t(RS2)); }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amomin_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoor_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amomin_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoor_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](int64_t lhs) { return std::min(lhs, int64_t(RS2)); - // })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoxor_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoor_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoxor_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoor_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t lhs) { return lhs ^ RS2; }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::sc_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoswap_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::sc_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoswap_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - - // bool have_reservation = MMU.store_conditional(RS1, RS2); - - // WRITE_RD(!have_reservation); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoand_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoswap_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoand_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoswap_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](uint64_t lhs) { return lhs & RS2; })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amomin_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoxor_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amomin_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoxor_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](int32_t lhs) { return std::min(lhs, - // int32_t(RS2)); }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amoand_w_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::amoxor_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amoand_w_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::amoxor_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(sext32(MMU.amo(RS1, [&](uint32_t lhs) { return lhs & RS2; }))); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// - return nullptr; + return amo_handler(state); } - ActionGroup* RvaInsts::amomax_d_64_compute_address_handler(atlas::AtlasState* state) + + ActionGroup* RvaInsts::lr_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } - ActionGroup* RvaInsts::amomax_d_64_handler(atlas::AtlasState* state) + ActionGroup* RvaInsts::lr_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; - // WRITE_RD(MMU.amo(RS1, [&](int64_t lhs) { return std::max(lhs, int64_t(RS2)); - // })); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// + const AtlasInstPtr & inst = state->getCurrentInst(); + const uint64_t paddr = state->getTranslationState()->getTranslationResult().getPaddr(); + const uint64_t rd_val = state->readMemory(paddr); + inst->getRd()->write(rd_val); return nullptr; } + ActionGroup* RvaInsts::lr_w_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } ActionGroup* RvaInsts::lr_w_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // WRITE_RD(MMU.load_reserved(RS1)); - - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// + const AtlasInstPtr & inst = state->getCurrentInst(); + const uint64_t paddr = state->getTranslationState()->getTranslationResult().getPaddr(); + const uint64_t rd_val = signExtend(state->readMemory(paddr)); + inst->getRd()->write(rd_val); return nullptr; } + ActionGroup* RvaInsts::sc_d_64_compute_address_handler(atlas::AtlasState* state) { - (void)state; - return nullptr; + return compute_address_handler(state); } ActionGroup* RvaInsts::sc_d_64_handler(atlas::AtlasState* state) { - (void)state; - /////////////////////////////////////////////////////////////////////// - // START OF SPIKE CODE - - // require_extension('A'); - // require_rv64; + const AtlasInstPtr & inst = state->getCurrentInst(); + const uint64_t rs2_val = inst->getRs2()->read(); + const uint64_t paddr = state->getTranslationState()->getTranslationResult().getPaddr(); + state->writeMemory(paddr, rs2_val); + return nullptr; + } - // bool have_reservation = MMU.store_conditional(RS1, RS2); - // WRITE_RD(!have_reservation); + ActionGroup* RvaInsts::sc_w_64_compute_address_handler(atlas::AtlasState* state) + { + return compute_address_handler(state); + } - // END OF SPIKE CODE - /////////////////////////////////////////////////////////////////////// + ActionGroup* RvaInsts::sc_w_64_handler(atlas::AtlasState* state) + { + const AtlasInstPtr & inst = state->getCurrentInst(); + const uint64_t rs2_val = inst->getRs2()->read(); + const uint64_t paddr = state->getTranslationState()->getTranslationResult().getPaddr(); + state->writeMemory(paddr, rs2_val); return nullptr; } - } // namespace atlas \ No newline at end of file diff --git a/core/inst_handlers/rv64/a/inst_helpers.hpp b/core/inst_handlers/rv64/a/inst_helpers.hpp new file mode 100644 index 0000000..3a94b4e --- /dev/null +++ b/core/inst_handlers/rv64/a/inst_helpers.hpp @@ -0,0 +1,84 @@ +#pragma once +#include "core/AtlasState.hpp" +#include "core/AtlasInst.hpp" +#include "include/AtlasUtils.hpp" + +namespace atlas +{ + class ActionGroup; + + using W = uint32_t; + using D = uint64_t; + + template + ActionGroup* compute_address_handler(AtlasState* state) + { + static_assert(std::is_same::value || std::is_same::value); + + const AtlasInstPtr & inst = state->getCurrentInst(); + const T rs1_val = inst->getRs1()->read(); + constexpr uint32_t IMM_SIZE = 12; + const T imm = inst->hasImmediate() ? inst->getSignExtendedImmediate() : 0; + const T vaddr = rs1_val + imm; + state->getTranslationState()->makeTranslationRequest(vaddr, sizeof(T)); + return nullptr; + } + + template class BinaryOp, bool U = true> + ActionGroup* amo_handler(atlas::AtlasState* state) + { + static_assert(std::is_same::value || std::is_same::value); + static_assert(std::is_same::value || std::is_same::value); + static_assert(sizeof(RV) >= sizeof(SIZE)); + + using Op = typename std::conditional< + std::is_same::value, + typename std::conditional::type, + typename std::conditional::type + >::type; + + BinaryOp binary_op; + const AtlasInstPtr & inst = state->getCurrentInst(); + const RV paddr = state->getTranslationState()->getTranslationResult().getPaddr(); + RV rd_val = 0; + if constexpr(sizeof(RV) > sizeof(SIZE)) + { + rd_val = signExtend(state->readMemory(paddr)); + } else + { + rd_val = state->readMemory(paddr); + } + inst->getRd()->write(rd_val); + const RV rs2_val = inst->getRs2()->read(); + state->writeMemory(paddr, binary_op(rd_val, rs2_val)); + return nullptr; + } + + template + struct MaxFunctor + { + constexpr T operator()(const T& lhs, const T& rhs) const + { + return lhs > rhs? lhs : rhs; + } + }; + + template + struct MinFunctor + { + constexpr T operator()(const T& lhs, const T& rhs) const + { + return lhs > rhs? rhs : lhs; + } + }; + + template + struct SwapFunctor + { + constexpr T operator()(const T& lhs, const T& rhs) const + { + (void)lhs; + return rhs; + } + }; +} // namespace atlas \ No newline at end of file From 97db081f89b9d9654fee290e2f94c23c8b89bf7c Mon Sep 17 00:00:00 2001 From: liya zhu Date: Fri, 6 Dec 2024 08:21:09 -0800 Subject: [PATCH 2/2] clang-format --- core/inst_handlers/rv64/a/RvaInsts.cpp | 22 ------------ core/inst_handlers/rv64/a/inst_helpers.hpp | 40 ++++++++-------------- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/core/inst_handlers/rv64/a/RvaInsts.cpp b/core/inst_handlers/rv64/a/RvaInsts.cpp index 55a87e5..6754c2b 100644 --- a/core/inst_handlers/rv64/a/RvaInsts.cpp +++ b/core/inst_handlers/rv64/a/RvaInsts.cpp @@ -167,7 +167,6 @@ namespace atlas nullptr, "sc_w", ActionTags::EXECUTE_TAG)); } - ActionGroup* RvaInsts::amoadd_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -178,7 +177,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoadd_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -189,7 +187,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoand_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -200,7 +197,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoand_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -211,7 +207,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amomax_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -222,7 +217,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amomax_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -233,7 +227,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amomaxu_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -244,7 +237,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amomaxu_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -255,7 +247,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amomin_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -266,7 +257,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amomin_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -277,7 +267,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amominu_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -288,7 +277,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amominu_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -299,7 +287,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoor_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -310,7 +297,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoor_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -321,7 +307,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoswap_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -332,7 +317,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoswap_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -343,7 +327,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoxor_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -354,7 +337,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::amoxor_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -365,7 +347,6 @@ namespace atlas return amo_handler(state); } - ActionGroup* RvaInsts::lr_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -380,7 +361,6 @@ namespace atlas return nullptr; } - ActionGroup* RvaInsts::lr_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -395,7 +375,6 @@ namespace atlas return nullptr; } - ActionGroup* RvaInsts::sc_d_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); @@ -410,7 +389,6 @@ namespace atlas return nullptr; } - ActionGroup* RvaInsts::sc_w_64_compute_address_handler(atlas::AtlasState* state) { return compute_address_handler(state); diff --git a/core/inst_handlers/rv64/a/inst_helpers.hpp b/core/inst_handlers/rv64/a/inst_helpers.hpp index 3a94b4e..6c5a99a 100644 --- a/core/inst_handlers/rv64/a/inst_helpers.hpp +++ b/core/inst_handlers/rv64/a/inst_helpers.hpp @@ -9,9 +9,8 @@ namespace atlas using W = uint32_t; using D = uint64_t; - - template - ActionGroup* compute_address_handler(AtlasState* state) + + template ActionGroup* compute_address_handler(AtlasState* state) { static_assert(std::is_same::value || std::is_same::value); @@ -31,20 +30,20 @@ namespace atlas static_assert(std::is_same::value || std::is_same::value); static_assert(sizeof(RV) >= sizeof(SIZE)); - using Op = typename std::conditional< - std::is_same::value, - typename std::conditional::type, - typename std::conditional::type - >::type; + using Op = + typename std::conditional::value, + typename std::conditional::type, + typename std::conditional::type>::type; BinaryOp binary_op; const AtlasInstPtr & inst = state->getCurrentInst(); const RV paddr = state->getTranslationState()->getTranslationResult().getPaddr(); RV rd_val = 0; - if constexpr(sizeof(RV) > sizeof(SIZE)) + if constexpr (sizeof(RV) > sizeof(SIZE)) { rd_val = signExtend(state->readMemory(paddr)); - } else + } + else { rd_val = state->readMemory(paddr); } @@ -54,28 +53,19 @@ namespace atlas return nullptr; } - template - struct MaxFunctor + template struct MaxFunctor { - constexpr T operator()(const T& lhs, const T& rhs) const - { - return lhs > rhs? lhs : rhs; - } + constexpr T operator()(const T & lhs, const T & rhs) const { return lhs > rhs ? lhs : rhs; } }; - template - struct MinFunctor + template struct MinFunctor { - constexpr T operator()(const T& lhs, const T& rhs) const - { - return lhs > rhs? rhs : lhs; - } + constexpr T operator()(const T & lhs, const T & rhs) const { return lhs > rhs ? rhs : lhs; } }; - template - struct SwapFunctor + template struct SwapFunctor { - constexpr T operator()(const T& lhs, const T& rhs) const + constexpr T operator()(const T & lhs, const T & rhs) const { (void)lhs; return rhs;