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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#include <cstdint>
#include <map>
#include <string>
#include "asm.hpp"
namespace {
std::map<std::string, instruction_t> instructions = {
{"lb", {}},
{"lh", {}},
{"lw", {}},
{"ld", {}},
{"lbu", {}},
{"lhu", {}},
{"lwu", {}},
{"sb", {}},
{"sh", {}},
{"sw", {}},
{"sd", {}},
{"li", {}},
{"lui", {}},
{"auipc", {}},
{"mv", {}},
{"sext.b", {}},
{"sext.h", {}},
{"sext.w", {}},
{"zext.b", {}},
{"zext.h", {}},
{"zext.w", {}},
{"rev8", {}},
{"czero.eqz", {}},
{"czero.nez", {}},
{"addi", {}},
{"add", {}},
{"sh1add", {}},
{"sh2add", {}},
{"sh3add", {}},
{"add.wu", {}},
{"sh1add.wu", {}},
{"sh2add.wu", {}},
{"sh3add.wu", {}},
{"addiw", {}},
{"addw", {}},
{"sub", {}},
{"subw", {}},
{"neg", {}},
{"negw", {}},
{"mul", {}},
{"mulw", {}},
{"mulh", {}},
{"mulhu", {}},
{"mulhsu", {}},
{"div", {}},
{"divu", {}},
{"rem", {}},
{"remu", {}},
{"min", {}},
{"max", {}},
{"minu", {}},
{"maxu", {}},
{"seqz", {}},
{"snez", {}},
{"slti", {}},
{"slt", {}},
{"sltiu", {}},
{"sltu", {}},
{"bexti", {}},
{"bext", {}},
{"andi", {}},
{"and", {}},
{"andn", {}},
{"bclri", {}},
{"bclr", {}},
{"ori", {}},
{"or", {}},
{"orn", {}},
{"bseti", {}},
{"bset", {}},
{"xori", {}},
{"xor", {}},
{"xnor", {}},
{"binvi", {}},
{"binv", {}},
{"not", {}},
{"orc.b", {}},
{"slli", {}},
{"sll", {}},
{"slliw", {}},
{"sllw", {}},
{"slli.wu", {}},
{"srli", {}},
{"srl", {}},
{"srliw", {}},
{"srlw", {}},
{"srai", {}},
{"sra", {}},
{"sraiw", {}},
{"sraw", {}},
{"rori", {}},
{"ror", {}},
{"rol", {}},
{"roriw", {}},
{"rorw", {}},
{"rolw", {}},
{"clz", {}},
{"clzw", {}},
{"ctz", {}},
{"ctzw", {}},
{"cpop", {}},
{"cpopw", {}},
{"j", {}},
{"jal", {}},
{"jr", {}},
{"jalr", {}},
{"call", {}},
{"tail", {}},
{"ret", {}},
{"beq", {}},
{"bne", {}},
{"blt", {}},
{"bgt", {}},
{"bge", {}},
{"ble", {}},
{"bltu", {}},
{"bgtu", {}},
{"bgeu", {}},
{"bleu", {}},
{"nop", {}},
{"ecall", {}},
{"ebreak", {}},
};
std::map<std::string, uint8_t> registers = {
{"x0", 0}, {"x1", 1}, {"x2", 2}, {"x3", 3}, {"x4", 4}, {"x5", 5}, {"x6", 6}, {"x7", 7}, {"x8", 8},
{"x9", 9}, {"x10", 10}, {"x11", 11}, {"x12", 12}, {"x13", 13}, {"x14", 14}, {"x15", 15}, {"x16", 16}, {"x17", 17},
{"x18", 18}, {"x19", 19}, {"x20", 20}, {"x21", 21}, {"x22", 22}, {"x23", 23}, {"x24", 24}, {"x25", 25}, {"x26", 26},
{"x27", 27}, {"x28", 28}, {"x29", 29}, {"x30", 30}, {"x31", 31}, {"zero", 0}, {"ra", 1}, {"sp", 2}, {"gp", 3},
{"tp", 4}, {"t0", 5}, {"t1", 6}, {"t2", 7}, {"s0", 8}, {"fp", 8}, {"s1", 9}, {"a0", 10}, {"a1", 11},
{"a2", 12}, {"a3", 13}, {"a4", 14}, {"a5", 15}, {"a6", 16}, {"a7", 17}, {"s2", 18}, {"s3", 19}, {"s4", 20},
{"s5", 21}, {"s6", 22}, {"s7", 23}, {"s8", 24}, {"s9", 25}, {"s10", 26}, {"s11", 27}, {"t3", 28}, {"t4", 29},
{"t5", 30}, {"t6", 31},
};
} // namespace
|