Skip to content

Commit

Permalink
Ran clangformat
Browse files Browse the repository at this point in the history
  • Loading branch information
kathlenemagnus committed Nov 25, 2024
1 parent 1c6b1f6 commit 9e50ea1
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 64 deletions.
34 changes: 11 additions & 23 deletions core/inst_handlers/inst_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,23 @@ typedef int64_t sreg_t;
typedef uint64_t reg_t;
#define xlen 64

template <typename T>
inline sreg_t sext32(T x) {
return (sreg_t)(int32_t)(x);
}
template <typename T> inline sreg_t sext32(T x) { return (sreg_t)(int32_t)(x); }

template <typename T>
inline reg_t zext32(T x) {
return (reg_t)(uint32_t)(x);
}
template <typename T> inline reg_t zext32(T x) { return (reg_t)(uint32_t)(x); }

template <typename T>
inline sreg_t sext(T x, uint32_t pos) {
template <typename T> inline sreg_t sext(T x, uint32_t pos)
{
return (((sreg_t)(x) << (64 - (pos))) >> (64 - (pos)));
}

template <typename T>
inline reg_t zext(T x, uint32_t pos) {
template <typename T> inline reg_t zext(T x, uint32_t pos)
{
return (((reg_t)(x) << (64 - (pos))) >> (64 - (pos)));
}

template <typename T>
inline sreg_t sext_xlen(T x) {
return sext(x, xlen);
}
template <typename T> inline sreg_t sext_xlen(T x) { return sext(x, xlen); }

template <typename T>
inline reg_t zext_xlen(T x) {
return zext(x, xlen);
}
template <typename T> inline reg_t zext_xlen(T x) { return zext(x, xlen); }

inline uint64_t mulhu(uint64_t a, uint64_t b)
{
Expand All @@ -43,13 +31,13 @@ inline uint64_t mulhu(uint64_t a, uint64_t b)
uint64_t a0 = (uint32_t)a, a1 = a >> 32;
uint64_t b0 = (uint32_t)b, b1 = b >> 32;

t = a1*b0 + ((a0*b0) >> 32);
t = a1 * b0 + ((a0 * b0) >> 32);
y1 = t;
y2 = t >> 32;

t = a0*b1 + y1;
t = a0 * b1 + y1;

t = a1*b1 + y2 + (t >> 32);
t = a1 * b1 + y2 + (t >> 32);
y2 = t;
y3 = t >> 32;

Expand Down
3 changes: 1 addition & 2 deletions core/inst_handlers/rv64/a/RvaInsts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "core/inst_handlers/rv64/a/RvaInsts.hpp"
#include "include/ActionTags.hpp"
#include "core/ActionGroup.hpp"

namespace atlas
{
void RvaInsts::getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers)
Expand Down Expand Up @@ -165,8 +166,6 @@ namespace atlas
nullptr, "sc_w", ActionTags::EXECUTE_TAG));
}



ActionGroup* RvaInsts::amoadd_w_64_compute_address_handler(atlas::AtlasState* state)
{
(void)state;
Expand Down
3 changes: 1 addition & 2 deletions core/inst_handlers/rv64/d/RvdInsts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "core/inst_handlers/rv64/d/RvdInsts.hpp"
#include "include/ActionTags.hpp"
#include "core/ActionGroup.hpp"

namespace atlas
{
void RvdInsts::getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers)
Expand Down Expand Up @@ -131,8 +132,6 @@ namespace atlas
nullptr, "fsw", ActionTags::EXECUTE_TAG));
}



ActionGroup* RvdInsts::fcvt_d_w_64_handler(atlas::AtlasState* state)
{
(void)state;
Expand Down
3 changes: 1 addition & 2 deletions core/inst_handlers/rv64/f/RvfInsts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "core/inst_handlers/rv64/f/RvfInsts.hpp"
#include "include/ActionTags.hpp"
#include "core/ActionGroup.hpp"

namespace atlas
{
void RvfInsts::getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers)
Expand Down Expand Up @@ -107,8 +108,6 @@ namespace atlas
nullptr, "fsw", ActionTags::EXECUTE_TAG));
}



ActionGroup* RvfInsts::fsqrt_s_64_handler(atlas::AtlasState* state)
{
(void)state;
Expand Down
3 changes: 1 addition & 2 deletions core/inst_handlers/rv64/i/RviInsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "core/ActionGroup.hpp"
#include "core/AtlasState.hpp"
#include "core/AtlasInst.hpp"

namespace atlas
{
void RviInsts::getInstComputeAddressHandlers(std::map<std::string, Action> & inst_handlers)
Expand Down Expand Up @@ -229,8 +230,6 @@ namespace atlas
nullptr, "xori", ActionTags::EXECUTE_TAG));
}



ActionGroup* RviInsts::cflush_i_l1_64_handler(atlas::AtlasState* state)
{
(void)state;
Expand Down
96 changes: 67 additions & 29 deletions core/inst_handlers/rv64/m/RvmInsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ namespace atlas
sreg_t lhs = sext_xlen(rs1_val);
sreg_t rhs = sext_xlen(rs2_val);

if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(UINT64_MAX);
} else if (lhs == INT64_MIN && rhs == -1) {
}
else if (lhs == INT64_MIN && rhs == -1)
{
insn->getRd()->write(lhs);
} else {
}
else
{
insn->getRd()->write(sext_xlen(lhs / rhs));
}

Expand All @@ -78,13 +83,16 @@ namespace atlas

reg_t lhs = zext_xlen(rs1_val);
reg_t rhs = zext_xlen(rs2_val);
if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(UINT64_MAX);
} else {
}
else
{
insn->getRd()->write(sext_xlen(lhs / rhs));
}

return nullptr;
return nullptr;
}

ActionGroup* RvmInsts::divuw_64_handler(atlas::AtlasState* state)
Expand All @@ -95,9 +103,12 @@ namespace atlas

reg_t lhs = zext32(rs1_val);
reg_t rhs = zext32(rs2_val);
if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(UINT64_MAX);
} else {
}
else
{
insn->getRd()->write(sext32(lhs / rhs));
}

Expand All @@ -112,9 +123,12 @@ namespace atlas

sreg_t lhs = sext32(rs1_val);
sreg_t rhs = sext32(rs2_val);
if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(UINT64_MAX);
} else {
}
else
{
insn->getRd()->write(sext32(lhs / rhs));
}

Expand All @@ -139,9 +153,12 @@ namespace atlas
const uint64_t rs1_val = insn->getRs1()->read();
const uint64_t rs2_val = insn->getRs2()->read();

if (xlen == 64) {
if (xlen == 64)
{
insn->getRd()->write(mulh(rs1_val, rs2_val));
} else {
}
else
{
insn->getRd()->write(sext32((sext32(rs1_val) * sext32(rs2_val)) >> 32));
}

Expand All @@ -154,9 +171,12 @@ namespace atlas
const uint64_t rs1_val = insn->getRs1()->read();
const uint64_t rs2_val = insn->getRs2()->read();

if (xlen == 64) {
if (xlen == 64)
{
insn->getRd()->write(mulhsu(rs1_val, rs2_val));
} else {
}
else
{
insn->getRd()->write(sext32((sext32(rs1_val) * reg_t((uint32_t)rs2_val)) >> 32));
}

Expand All @@ -165,17 +185,21 @@ namespace atlas

ActionGroup* RvmInsts::mulhu_64_handler(atlas::AtlasState* state)
{
const AtlasInstPtr & insn = state->getCurrentInst();
const AtlasInstPtr & insn = state->getCurrentInst();
const uint64_t rs1_val = insn->getRs1()->read();
const uint64_t rs2_val = insn->getRs2()->read();

if (xlen == 64) {
if (xlen == 64)
{
insn->getRd()->write(mulhu(rs1_val, rs2_val));
} else {
insn->getRd()->write(sext32(((uint64_t)(uint32_t)rs1_val * (uint64_t)(uint32_t)rs2_val) >> 32));
}
else
{
insn->getRd()->write(
sext32(((uint64_t)(uint32_t)rs1_val * (uint64_t)(uint32_t)rs2_val) >> 32));
}

return nullptr;
return nullptr;
}

ActionGroup* RvmInsts::mulw_64_handler(atlas::AtlasState* state)
Expand All @@ -198,11 +222,16 @@ namespace atlas
sreg_t lhs = sext_xlen(rs1_val);
sreg_t rhs = sext_xlen(rs2_val);

if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(lhs);
} else if (lhs == INT64_MIN && rhs == -1) {
}
else if (lhs == INT64_MIN && rhs == -1)
{
insn->getRd()->write(0);
} else {
}
else
{
insn->getRd()->write(sext_xlen(lhs % rhs));
}

Expand All @@ -217,9 +246,12 @@ namespace atlas

reg_t lhs = zext_xlen(rs1_val);
reg_t rhs = zext_xlen(rs2_val);
if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(sext_xlen(lhs));
} else {
}
else
{
insn->getRd()->write(sext_xlen(lhs % rhs));
}

Expand All @@ -234,9 +266,12 @@ namespace atlas

reg_t lhs = zext32(rs1_val);
reg_t rhs = zext32(rs2_val);
if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(sext32(lhs));
} else {
}
else
{
insn->getRd()->write(sext32(lhs % rhs));
}

Expand All @@ -251,12 +286,15 @@ namespace atlas

sreg_t lhs = sext32(rs1_val);
sreg_t rhs = sext32(rs2_val);
if (rhs == 0) {
if (rhs == 0)
{
insn->getRd()->write(lhs);
} else {
}
else
{
insn->getRd()->write(sext32(lhs % rhs));
}

return nullptr;
return nullptr;
}
} // namespace atlas
3 changes: 1 addition & 2 deletions core/inst_handlers/rv64/zicsr/RvzicsrInsts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "core/inst_handlers/rv64/zicsr/RvzicsrInsts.hpp"
#include "include/ActionTags.hpp"
#include "core/ActionGroup.hpp"

namespace atlas
{
void RvzicsrInsts::getInstHandlers(std::map<std::string, Action> & inst_handlers)
Expand All @@ -25,8 +26,6 @@ namespace atlas
nullptr, "csrrwi", ActionTags::EXECUTE_TAG));
}



ActionGroup* RvzicsrInsts::csrrs_64_handler(atlas::AtlasState* state)
{
(void)state;
Expand Down
3 changes: 1 addition & 2 deletions core/inst_handlers/rv64/zifencei/RvzifenceiInsts.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "core/inst_handlers/rv64/zifencei/RvzifenceiInsts.hpp"
#include "include/ActionTags.hpp"
#include "core/ActionGroup.hpp"

namespace atlas
{
void RvzifenceiInsts::getInstHandlers(std::map<std::string, Action> & inst_handlers)
Expand All @@ -11,8 +12,6 @@ namespace atlas
nullptr, "fence_i", ActionTags::EXECUTE_TAG));
}



ActionGroup* RvzifenceiInsts::fence_i_64_handler(atlas::AtlasState* state)
{
(void)state;
Expand Down

0 comments on commit 9e50ea1

Please sign in to comment.