forked from chipsalliance/VeeR-ISS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DecodedInst.cpp
103 lines (77 loc) · 1.7 KB
/
DecodedInst.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "Hart.hpp"
#include "DecodedInst.hpp"
using namespace WdRiscv;
uint32_t
DecodedInst::ithOperand(unsigned i) const
{
if (i == 0) return op0();
if (i == 1) return op1();
if (i == 2) return op2();
if (i == 3) return op3();
return 0;
}
int32_t
DecodedInst::ithOperandAsInt(unsigned i) const
{
return ithOperand(i);
}
template <typename URV>
void
DecodedInst::fetchOperands(const Hart<URV>& hart)
{
for (unsigned i = 0; i < 4; ++i)
{
uint32_t operand = ithOperand(i);
uint64_t val = 0;
URV urv = 0;
OperandType type = ithOperandType(i);
switch(type)
{
case OperandType::IntReg:
hart.peekIntReg(operand, urv);
val = urv;
break;
case OperandType::FpReg:
hart.peekUnboxedFpReg(operand, val);
break;
case OperandType::CsReg:
hart.peekCsr(CsrNumber(operand), urv);
val = urv;
break;
case OperandType::Imm:
val = int64_t(ithOperandAsInt(i));
break;
case OperandType::None:
break;
}
assert(i < sizeof(values_));
values_[i] = val;
}
}
// Explicit instantiation of the fetchOperands method for uint32_t.
template<>
void
DecodedInst::fetchOperands(const Hart<uint32_t>&);
// Explicit instantiation of the fetchOperands method for uint64_t.
template<>
void
DecodedInst::fetchOperands(const Hart<uint64_t>&);
void
DecodedInst::setIthOperandValue(unsigned i, uint64_t value)
{
OperandType type = ithOperandType(i);
switch(type)
{
case OperandType::IntReg:
case OperandType::FpReg:
case OperandType::CsReg:
case OperandType::VecReg:
if (i < sizeof(values_))
values_[i] = value;
break;
case OperandType::Imm:
break;
case OperandType::None:
break;
}
}