@@ -133,7 +133,7 @@ uint32_t fclass( T val ) {
133
133
// / Load template
134
134
template <typename T>
135
135
bool load ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
136
- if ( sizeof ( T ) < sizeof ( int64_t ) && R->IsRV32 ) {
136
+ if ( sizeof ( T ) < sizeof ( int64_t ) && ! R->IsRV64 ) {
137
137
static constexpr RevFlag flags =
138
138
sizeof ( T ) < sizeof ( int32_t ) ? std::is_signed_v<T> ? RevFlag::F_SEXT32 : RevFlag::F_ZEXT32 : RevFlag::F_NONE;
139
139
auto rs1 = R->GetX <uint64_t >( Inst.rs1 ); // read once for tracer
@@ -284,7 +284,7 @@ enum class OpKind { Imm, Reg };
284
284
// The optional fourth parameter indicates W mode (32-bit on XLEN == 64)
285
285
template <template <class > class OP , OpKind KIND, template <class > class SIGN = std::make_signed_t , bool W_MODE = false >
286
286
bool oper ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
287
- if ( !W_MODE && R->IsRV32 ) {
287
+ if ( !W_MODE && ! R->IsRV64 ) {
288
288
using T = SIGN<int32_t >;
289
289
T rs1 = R->GetX <T>( Inst.rs1 );
290
290
T rs2 = KIND == OpKind::Imm ? T ( Inst.ImmSignExt ( 12 ) ) : R->GetX <T>( Inst.rs2 );
@@ -323,16 +323,7 @@ struct ShiftRight {
323
323
// Computes the UPPER half of multiplication, based on signedness
324
324
template <bool rs1_is_signed, bool rs2_is_signed>
325
325
bool uppermul ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
326
- if ( R->IsRV32 ) {
327
- uint32_t rs1 = R->GetX <uint32_t >( Inst.rs1 );
328
- uint32_t rs2 = R->GetX <uint32_t >( Inst.rs2 );
329
- uint32_t mul = static_cast <uint32_t >( rs1 * int64_t ( rs2 ) >> 32 );
330
- if ( rs1_is_signed && ( rs1 & ( uint32_t { 1 } << 31 ) ) != 0 )
331
- mul -= rs2;
332
- if ( rs2_is_signed && ( rs2 & ( uint32_t { 1 } << 31 ) ) != 0 )
333
- mul -= rs1;
334
- R->SetX ( Inst.rd , mul );
335
- } else {
326
+ if ( R->IsRV64 ) {
336
327
uint64_t rs1 = R->GetX <uint64_t >( Inst.rs1 );
337
328
uint64_t rs2 = R->GetX <uint64_t >( Inst.rs2 );
338
329
uint64_t mul = static_cast <uint64_t >( rs1 * __int128 ( rs2 ) >> 64 );
@@ -341,6 +332,15 @@ bool uppermul( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
341
332
if ( rs2_is_signed && ( rs2 & ( uint64_t { 1 } << 63 ) ) != 0 )
342
333
mul -= rs1;
343
334
R->SetX ( Inst.rd , mul );
335
+ } else {
336
+ uint32_t rs1 = R->GetX <uint32_t >( Inst.rs1 );
337
+ uint32_t rs2 = R->GetX <uint32_t >( Inst.rs2 );
338
+ uint32_t mul = static_cast <uint32_t >( rs1 * int64_t ( rs2 ) >> 32 );
339
+ if ( rs1_is_signed && ( rs1 & ( uint32_t { 1 } << 31 ) ) != 0 )
340
+ mul -= rs2;
341
+ if ( rs2_is_signed && ( rs2 & ( uint32_t { 1 } << 31 ) ) != 0 )
342
+ mul -= rs1;
343
+ R->SetX ( Inst.rd , mul );
344
344
}
345
345
R->AdvancePC ( Inst );
346
346
return true ;
@@ -354,7 +354,7 @@ enum class DivRem { Div, Rem };
354
354
// The optional third parameter indicates W mode (32-bit on XLEN == 64)
355
355
template <DivRem DIVREM, template <class > class SIGN , bool W_MODE = false >
356
356
bool divrem ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
357
- if ( !W_MODE && R->IsRV32 ) {
357
+ if ( !W_MODE && ! R->IsRV64 ) {
358
358
using T = SIGN<int32_t >;
359
359
T rs1 = R->GetX <T>( Inst.rs1 );
360
360
T rs2 = R->GetX <T>( Inst.rs2 );
@@ -388,10 +388,10 @@ bool divrem( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
388
388
template <template <class > class OP , template <class > class SIGN = std::make_unsigned_t >
389
389
bool bcond ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
390
390
bool cond;
391
- if ( R->IsRV32 ) {
392
- cond = OP ()( R->GetX <SIGN<int32_t >>( Inst.rs1 ), R->GetX <SIGN<int32_t >>( Inst.rs2 ) );
393
- } else {
391
+ if ( R->IsRV64 ) {
394
392
cond = OP ()( R->GetX <SIGN<int64_t >>( Inst.rs1 ), R->GetX <SIGN<int64_t >>( Inst.rs2 ) );
393
+ } else {
394
+ cond = OP ()( R->GetX <SIGN<int32_t >>( Inst.rs1 ), R->GetX <SIGN<int32_t >>( Inst.rs2 ) );
395
395
}
396
396
if ( cond ) {
397
397
R->SetPC ( R->GetPC () + Inst.ImmSignExt ( 13 ) );
0 commit comments