@@ -66,7 +66,7 @@ inline constexpr double fpmin<double, uint64_t> = 0x0p+0;
66
66
// / FP values outside the range of the target integer type are clipped
67
67
// / at the integer type's numerical limits, whether signed or unsigned.
68
68
template <typename INT, typename FP>
69
- bool fcvtif ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
69
+ bool fcvtif ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
70
70
// Read the FP register. Round to integer according to current rounding mode.
71
71
FP fp = std::rint ( R->GetFP <FP>( Inst.rs1 ) );
72
72
@@ -132,7 +132,7 @@ uint32_t fclass( T val ) {
132
132
133
133
// / Load template
134
134
template <typename T>
135
- bool load ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
135
+ bool load ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
136
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;
@@ -175,15 +175,15 @@ bool load( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
175
175
176
176
// / Store template
177
177
template <typename T>
178
- bool store ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
178
+ bool store ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
179
179
M->Write ( F->GetHartToExecID (), R->GetX <uint64_t >( Inst.rs1 ) + Inst.ImmSignExt ( 12 ), R->GetX <T>( Inst.rs2 ) );
180
180
R->AdvancePC ( Inst );
181
181
return true ;
182
182
}
183
183
184
184
// / Floating-point load template
185
185
template <typename T>
186
- bool fload ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
186
+ bool fload ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
187
187
if ( std::is_same_v<T, double > || F->HasD () ) {
188
188
static constexpr RevFlag flags = sizeof ( T ) < sizeof ( double ) ? RevFlag::F_BOXNAN : RevFlag::F_NONE;
189
189
uint64_t rs1 = R->GetX <uint64_t >( Inst.rs1 );
@@ -220,7 +220,7 @@ bool fload( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
220
220
221
221
// / Floating-point store template
222
222
template <typename T>
223
- bool fstore ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
223
+ bool fstore ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
224
224
T val = R->GetFP <T, true >( Inst.rs2 );
225
225
M->Write ( F->GetHartToExecID (), R->GetX <uint64_t >( Inst.rs1 ) + Inst.ImmSignExt ( 12 ), val );
226
226
R->AdvancePC ( Inst );
@@ -229,7 +229,7 @@ bool fstore( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
229
229
230
230
// / Floating-point operation template
231
231
template <typename T, template <class > class OP >
232
- bool foper ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
232
+ bool foper ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
233
233
R->SetFP ( Inst.rd , OP ()( R->GetFP <T>( Inst.rs1 ), R->GetFP <T>( Inst.rs2 ) ) );
234
234
R->AdvancePC ( Inst );
235
235
return true ;
@@ -267,7 +267,7 @@ struct FMax {
267
267
268
268
// / Floating-point conditional operation template
269
269
template <typename T, template <class > class OP >
270
- bool fcondop ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
270
+ bool fcondop ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
271
271
bool res = OP ()( R->GetFP <T>( Inst.rs1 ), R->GetFP <T>( Inst.rs2 ) );
272
272
R->SetX ( Inst.rd , res );
273
273
R->AdvancePC ( Inst );
@@ -283,7 +283,7 @@ enum class OpKind { Imm, Reg };
283
283
// The third parameter is std::make_unsigned_t or std::make_signed_t (default)
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
- bool oper ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
286
+ bool oper ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
287
287
if ( !W_MODE && !R->IsRV64 ) {
288
288
using T = SIGN<int32_t >;
289
289
T rs1 = R->GetX <T>( Inst.rs1 );
@@ -322,7 +322,7 @@ struct ShiftRight {
322
322
323
323
// Computes the UPPER half of multiplication, based on signedness
324
324
template <bool rs1_is_signed, bool rs2_is_signed>
325
- bool uppermul ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
325
+ bool uppermul ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
326
326
if ( R->IsRV64 ) {
327
327
uint64_t rs1 = R->GetX <uint64_t >( Inst.rs1 );
328
328
uint64_t rs2 = R->GetX <uint64_t >( Inst.rs2 );
@@ -353,7 +353,7 @@ enum class DivRem { Div, Rem };
353
353
// The second parameter is std::make_signed_t or std::make_unsigned_t
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
- bool divrem ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
356
+ bool divrem ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
357
357
if ( !W_MODE && !R->IsRV64 ) {
358
358
using T = SIGN<int32_t >;
359
359
T rs1 = R->GetX <T>( Inst.rs1 );
@@ -386,7 +386,7 @@ bool divrem( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
386
386
// The first template parameter is the comparison functor
387
387
// The second template parameter is std::make_signed_t or std::make_unsigned_t
388
388
template <template <class > class OP , template <class > class SIGN = std::make_unsigned_t >
389
- bool bcond ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
389
+ bool bcond ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
390
390
bool cond;
391
391
if ( R->IsRV64 ) {
392
392
cond = OP ()( R->GetX <SIGN<int64_t >>( Inst.rs1 ), R->GetX <SIGN<int64_t >>( Inst.rs2 ) );
@@ -419,63 +419,63 @@ inline auto revFMA( T x, T y, T z ) {
419
419
420
420
// / Fused Multiply+Add
421
421
template <typename T>
422
- bool fmadd ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
422
+ bool fmadd ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
423
423
R->SetFP ( Inst.rd , revFMA ( R->GetFP <T>( Inst.rs1 ), R->GetFP <T>( Inst.rs2 ), R->GetFP <T>( Inst.rs3 ) ) );
424
424
R->AdvancePC ( Inst );
425
425
return true ;
426
426
}
427
427
428
428
// / Fused Multiply-Subtract
429
429
template <typename T>
430
- bool fmsub ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
430
+ bool fmsub ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
431
431
R->SetFP ( Inst.rd , revFMA ( R->GetFP <T>( Inst.rs1 ), R->GetFP <T>( Inst.rs2 ), negate ( R->GetFP <T>( Inst.rs3 ) ) ) );
432
432
R->AdvancePC ( Inst );
433
433
return true ;
434
434
}
435
435
436
436
// / Fused Negated (Multiply-Subtract)
437
437
template <typename T>
438
- bool fnmsub ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
438
+ bool fnmsub ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
439
439
R->SetFP ( Inst.rd , revFMA ( negate ( R->GetFP <T>( Inst.rs1 ) ), R->GetFP <T>( Inst.rs2 ), R->GetFP <T>( Inst.rs3 ) ) );
440
440
R->AdvancePC ( Inst );
441
441
return true ;
442
442
}
443
443
444
444
// / Fused Negated (Multiply+Add)
445
445
template <typename T>
446
- bool fnmadd ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
446
+ bool fnmadd ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
447
447
R->SetFP ( Inst.rd , negate ( revFMA ( R->GetFP <T>( Inst.rs1 ), R->GetFP <T>( Inst.rs2 ), R->GetFP <T>( Inst.rs3 ) ) ) );
448
448
R->AdvancePC ( Inst );
449
449
return true ;
450
450
}
451
451
452
452
// Square root
453
453
template <typename T>
454
- static bool fsqrt ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
454
+ static bool fsqrt ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
455
455
R->SetFP ( Inst.rd , std::sqrt ( R->GetFP <T>( Inst.rs1 ) ) );
456
456
R->AdvancePC ( Inst );
457
457
return true ;
458
458
}
459
459
460
460
// Transfer sign bit
461
461
template <typename T>
462
- static bool fsgnj ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
462
+ static bool fsgnj ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
463
463
R->SetFP ( Inst.rd , std::copysign ( R->GetFP <T>( Inst.rs1 ), R->GetFP <T>( Inst.rs2 ) ) );
464
464
R->AdvancePC ( Inst );
465
465
return true ;
466
466
}
467
467
468
468
// Negated transfer sign bit
469
469
template <typename T>
470
- static bool fsgnjn ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
470
+ static bool fsgnjn ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
471
471
R->SetFP ( Inst.rd , std::copysign ( R->GetFP <T>( Inst.rs1 ), negate ( R->GetFP <T>( Inst.rs2 ) ) ) );
472
472
R->AdvancePC ( Inst );
473
473
return true ;
474
474
}
475
475
476
476
// Xor transfer sign bit
477
477
template <typename T>
478
- static bool fsgnjx ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
478
+ static bool fsgnjx ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
479
479
T rs1 = R->GetFP <T>( Inst.rs1 ), rs2 = R->GetFP <T>( Inst.rs2 );
480
480
R->SetFP ( Inst.rd , std::copysign ( rs1, std::signbit ( rs1 ) ? negate ( rs2 ) : rs2 ) );
481
481
R->AdvancePC ( Inst );
@@ -484,7 +484,7 @@ static bool fsgnjx( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst
484
484
485
485
// Move floating-point register to integer register
486
486
template <typename T>
487
- static bool fmvif ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
487
+ static bool fmvif ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
488
488
std::make_signed_t <uint_type_t <T>> i;
489
489
T fp = R->GetFP <T, true >( Inst.rs1 ); // The FP value
490
490
static_assert ( sizeof ( i ) == sizeof ( fp ) );
@@ -496,7 +496,7 @@ static bool fmvif( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst
496
496
497
497
// Move integer register to floating-point register
498
498
template <typename T>
499
- static bool fmvfi ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
499
+ static bool fmvfi ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
500
500
T fp;
501
501
auto i = R->GetX <uint_type_t <T>>( Inst.rs1 ); // The X register
502
502
static_assert ( sizeof ( i ) == sizeof ( fp ) );
@@ -508,23 +508,23 @@ static bool fmvfi( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst
508
508
509
509
// Floating-point classify
510
510
template <typename T>
511
- static bool fclassify ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
511
+ static bool fclassify ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
512
512
R->SetX ( Inst.rd , fclass ( R->GetFP <T>( Inst.rs1 ) ) );
513
513
R->AdvancePC ( Inst );
514
514
return true ;
515
515
}
516
516
517
517
// Convert integer to floating point
518
518
template <typename FP, typename INT>
519
- static bool fcvtfi ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
519
+ static bool fcvtfi ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
520
520
R->SetFP ( Inst.rd , static_cast <FP>( R->GetX <INT>( Inst.rs1 ) ) );
521
521
R->AdvancePC ( Inst );
522
522
return true ;
523
523
}
524
524
525
525
// Convert floating point to floating point
526
526
template <typename FP2, typename FP1>
527
- static bool fcvtff ( RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
527
+ static bool fcvtff ( const RevFeature* F, RevRegFile* R, RevMem* M, const RevInst& Inst ) {
528
528
R->SetFP ( Inst.rd , static_cast <FP2>( R->GetFP <FP1>( Inst.rs1 ) ) );
529
529
R->AdvancePC ( Inst );
530
530
return true ;
0 commit comments