1717namespace SST ::RevCPU {
1818
1919class Zaamo : public RevExt {
20- #if 0
2120 template <typename XLEN, RevFlag F_AMO>
2221 static bool amooper ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
2322 static_assert ( std::is_unsigned_v<XLEN>, " XLEN must be unsigned integral type" );
@@ -34,76 +33,57 @@ class Zaamo : public RevExt {
3433 if ( !R->IsRV64 ) {
3534 MemReq req (
3635 R->RV32 [Inst.rs1 ], Inst.rd , RevRegClass::RegGPR, F->GetHartToExecID (), MemOp::MemOpAMO, true , R->GetMarkLoadComplete ()
37- );
36+ );
3837 R->LSQueue ->insert ( req.LSQHashPair () );
39- M->AMOVal( F->GetHartToExecID(), R->RV32[Inst.rs1], &R->RV32[Inst.rs2], &R->RV32[Inst.rd], req, RevFlag{ flags } );
38+ M->AMOVal ( F->GetHartToExecID (), R->RV32 [Inst.rs1 ], &R->RV32 [Inst.rs2 ], &R->RV32 [Inst.rd ], req, flags );
4039 } else {
41- flags |= uint32_t( RevFlag::F_SEXT64 );
40+ flags = RevFlag{ uint32_t ( flags ) | uint32_t ( RevFlag::F_SEXT64 ) } ;
4241 MemReq req (
4342 R->RV64 [Inst.rs1 ], Inst.rd , RevRegClass::RegGPR, F->GetHartToExecID (), MemOp::MemOpAMO, true , R->GetMarkLoadComplete ()
44- );
43+ );
4544 R->LSQueue ->insert ( req.LSQHashPair () );
4645 M->AMOVal (
4746 F->GetHartToExecID (),
4847 R->RV64 [Inst.rs1 ],
49- reinterpret_cast<int32_t *>( &R->RV64[Inst.rs2] ),
50- reinterpret_cast<int32_t *>( &R->RV64[Inst.rd] ),
48+ reinterpret_cast <std:: make_signed_t <XLEN> *>( &R->RV64 [Inst.rs2 ] ),
49+ reinterpret_cast <std:: make_signed_t <XLEN> *>( &R->RV64 [Inst.rd ] ),
5150 req,
52- RevFlag{ flags }
53- );
51+ flags
52+ );
5453 }
5554 // update the cost
5655 R->cost += M->RandCost ( F->GetMinCost (), F->GetMaxCost () );
5756 R->AdvancePC ( Inst );
5857 return true ;
5958 }
6059
61- /// Atomic Memory Operations
62- template<RevFlag F_AMO>
63- static bool amooperd( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
64-
65- MemReq req(
66- R->RV64[Inst.rs1], Inst.rd, RevRegClass::RegGPR, F->GetHartToExecID(), MemOp::MemOpAMO, true, R->GetMarkLoadComplete()
67- );
68- R->LSQueue->insert( req.LSQHashPair() );
69- M->AMOVal( F->GetHartToExecID(), R->RV64[Inst.rs1], &R->RV64[Inst.rs2], &R->RV64[Inst.rd], req, RevFlag{ flags } );
70-
71- R->AdvancePC( Inst );
72-
73- // update the cost
74- R->cost += M->RandCost( F->GetMinCost(), F->GetMaxCost() );
75- return true;
76- }
77-
78- static constexpr auto& amoswapw = amooper<uint32_t, RevFlag::F_AMOSWAP>;
7960 static constexpr auto & amoaddw = amooper<uint32_t , RevFlag::F_AMOADD>;
80- static constexpr auto& amoxorw = amooper<uint32_t, RevFlag::F_AMOXOR>;
8161 static constexpr auto & amoandw = amooper<uint32_t , RevFlag::F_AMOAND>;
82- static constexpr auto& amoorw = amooper<uint32_t, RevFlag::F_AMOOR>;
83- static constexpr auto& amominw = amooper<uint32_t, RevFlag::F_AMOMIN>;
62+ static constexpr auto & amomaxuw = amooper<uint32_t , RevFlag::F_AMOMAXU>;
8463 static constexpr auto & amomaxw = amooper<uint32_t , RevFlag::F_AMOMAX>;
8564 static constexpr auto & amominuw = amooper<uint32_t , RevFlag::F_AMOMINU>;
86- static constexpr auto& amomaxuw = amooper<uint32_t, RevFlag::F_AMOMAXU>;
65+ static constexpr auto & amominw = amooper<uint32_t , RevFlag::F_AMOMIN>;
66+ static constexpr auto & amoorw = amooper<uint32_t , RevFlag::F_AMOOR>;
67+ static constexpr auto & amoswapw = amooper<uint32_t , RevFlag::F_AMOSWAP>;
68+ static constexpr auto & amoxorw = amooper<uint32_t , RevFlag::F_AMOXOR>;
8769
8870 static constexpr auto & amoaddd = amooper<uint64_t , RevFlag::F_AMOADD>;
89- static constexpr auto& amoswapd = amooper<uint64_t, RevFlag::F_AMOSWAP>;
90- static constexpr auto& amoxord = amooper<uint64_t, RevFlag::F_AMOXOR>;
9171 static constexpr auto & amoandd = amooper<uint64_t , RevFlag::F_AMOAND>;
92- static constexpr auto& amoord = amooper<uint64_t, RevFlag::F_AMOOR>;
93- static constexpr auto& amomind = amooper<uint64_t, RevFlag::F_AMOMIN>;
9472 static constexpr auto & amomaxd = amooper<uint64_t , RevFlag::F_AMOMAX>;
95- static constexpr auto& amominud = amooper<uint64_t, RevFlag::F_AMOMINU>;
9673 static constexpr auto & amomaxud = amooper<uint64_t , RevFlag::F_AMOMAXU>;
74+ static constexpr auto & amomind = amooper<uint64_t , RevFlag::F_AMOMIN>;
75+ static constexpr auto & amominud = amooper<uint64_t , RevFlag::F_AMOMINU>;
76+ static constexpr auto & amoord = amooper<uint64_t , RevFlag::F_AMOOR>;
77+ static constexpr auto & amoswapd = amooper<uint64_t , RevFlag::F_AMOSWAP>;
78+ static constexpr auto & amoxord = amooper<uint64_t , RevFlag::F_AMOXOR>;
9779
9880 // ----------------------------------------------------------------------
9981 //
10082 // RISC-V Zaamo Instructions
10183 //
10284 // ----------------------------------------------------------------------
10385 struct ZaamoInstDefaults : RevInstDefaults {
104- ZaamoInstDefaults() {
105- SetOpcode( 0b0101111 );
106- }
86+ ZaamoInstDefaults () { SetOpcode ( 0b0101111 ); }
10787 };
10888
10989 // clang-format off
@@ -130,19 +110,17 @@ class Zaamo : public RevExt {
130110 ZaamoInstDefaults ().SetMnemonic ( " amominu.d %rd, %rs1, %rs2" ).SetFunct3 ( 0b011 ).SetFunct2or7 ( 0b0011000 ).SetImplFunc ( amominud ),
131111 ZaamoInstDefaults ().SetMnemonic ( " amomaxu.d %rd, %rs1, %rs2" ).SetFunct3 ( 0b011 ).SetFunct2or7 ( 0b0011100 ).SetImplFunc ( amomaxud ),
132112 }; }
113+
133114 // clang-format on
134- #endif
135115
136116public:
137117 // / Zaamo: standard constructor
138118 Zaamo ( RevFeature* Feature, RevMem* RevMem, SST::Output* Output ) : RevExt( " Zaamo" , Feature, RevMem, Output ) {
139- #if 0
140- if(Feature->IsRV64()) {
119+ if ( Feature->IsRV64 () ) {
141120 auto Table{ RV64Table () };
142121 ZaamoTable.insert ( ZaamoTable.end (), std::move_iterator ( Table.begin () ), std::move_iterator ( Table.end () ) );
143122 }
144123 SetTable ( std::move ( ZaamoTable ) );
145- #endif
146124 }
147125
148126}; // end class Zaamo
0 commit comments