17
17
namespace SST ::RevCPU {
18
18
19
19
class Zaamo : public RevExt {
20
- #if 0
21
20
template <typename XLEN, RevFlag F_AMO>
22
21
static bool amooper ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
23
22
static_assert ( std::is_unsigned_v<XLEN>, " XLEN must be unsigned integral type" );
@@ -34,76 +33,57 @@ class Zaamo : public RevExt {
34
33
if ( !R->IsRV64 ) {
35
34
MemReq req (
36
35
R->RV32 [Inst.rs1 ], Inst.rd , RevRegClass::RegGPR, F->GetHartToExecID (), MemOp::MemOpAMO, true , R->GetMarkLoadComplete ()
37
- );
36
+ );
38
37
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 );
40
39
} else {
41
- flags |= uint32_t( RevFlag::F_SEXT64 );
40
+ flags = RevFlag{ uint32_t ( flags ) | uint32_t ( RevFlag::F_SEXT64 ) } ;
42
41
MemReq req (
43
42
R->RV64 [Inst.rs1 ], Inst.rd , RevRegClass::RegGPR, F->GetHartToExecID (), MemOp::MemOpAMO, true , R->GetMarkLoadComplete ()
44
- );
43
+ );
45
44
R->LSQueue ->insert ( req.LSQHashPair () );
46
45
M->AMOVal (
47
46
F->GetHartToExecID (),
48
47
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 ] ),
51
50
req,
52
- RevFlag{ flags }
53
- );
51
+ flags
52
+ );
54
53
}
55
54
// update the cost
56
55
R->cost += M->RandCost ( F->GetMinCost (), F->GetMaxCost () );
57
56
R->AdvancePC ( Inst );
58
57
return true ;
59
58
}
60
59
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>;
79
60
static constexpr auto & amoaddw = amooper<uint32_t , RevFlag::F_AMOADD>;
80
- static constexpr auto& amoxorw = amooper<uint32_t, RevFlag::F_AMOXOR>;
81
61
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>;
84
63
static constexpr auto & amomaxw = amooper<uint32_t , RevFlag::F_AMOMAX>;
85
64
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>;
87
69
88
70
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>;
91
71
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>;
94
72
static constexpr auto & amomaxd = amooper<uint64_t , RevFlag::F_AMOMAX>;
95
- static constexpr auto& amominud = amooper<uint64_t, RevFlag::F_AMOMINU>;
96
73
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>;
97
79
98
80
// ----------------------------------------------------------------------
99
81
//
100
82
// RISC-V Zaamo Instructions
101
83
//
102
84
// ----------------------------------------------------------------------
103
85
struct ZaamoInstDefaults : RevInstDefaults {
104
- ZaamoInstDefaults() {
105
- SetOpcode( 0b0101111 );
106
- }
86
+ ZaamoInstDefaults () { SetOpcode ( 0b0101111 ); }
107
87
};
108
88
109
89
// clang-format off
@@ -130,19 +110,17 @@ class Zaamo : public RevExt {
130
110
ZaamoInstDefaults ().SetMnemonic ( " amominu.d %rd, %rs1, %rs2" ).SetFunct3 ( 0b011 ).SetFunct2or7 ( 0b0011000 ).SetImplFunc ( amominud ),
131
111
ZaamoInstDefaults ().SetMnemonic ( " amomaxu.d %rd, %rs1, %rs2" ).SetFunct3 ( 0b011 ).SetFunct2or7 ( 0b0011100 ).SetImplFunc ( amomaxud ),
132
112
}; }
113
+
133
114
// clang-format on
134
- #endif
135
115
136
116
public:
137
117
// / Zaamo: standard constructor
138
118
Zaamo ( RevFeature* Feature, RevMem* RevMem, SST::Output* Output ) : RevExt( " Zaamo" , Feature, RevMem, Output ) {
139
- #if 0
140
- if(Feature->IsRV64()) {
119
+ if ( Feature->IsRV64 () ) {
141
120
auto Table{ RV64Table () };
142
121
ZaamoTable.insert ( ZaamoTable.end (), std::move_iterator ( Table.begin () ), std::move_iterator ( Table.end () ) );
143
122
}
144
123
SetTable ( std::move ( ZaamoTable ) );
145
- #endif
146
124
}
147
125
148
126
}; // end class Zaamo
0 commit comments