-
Notifications
You must be signed in to change notification settings - Fork 0
/
match.go
169 lines (166 loc) · 4.79 KB
/
match.go
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// AUTOGENERATED: DO NOT EDIT!
// Built from RISC-V ISA opcode definitions: https://github.com/riscv/riscv-opcodes
package disassemble
import (
"fmt"
"github.com/hawkowl/biscuit/pkg/opcodes"
)
func Match(inst uint32) (Opcode, error) {
if (inst^opcodes.MATCH_LUI)&opcodes.MASK_LUI == 0 {
return DecodeLUI(inst), nil
}
if (inst^opcodes.MATCH_AUIPC)&opcodes.MASK_AUIPC == 0 {
return DecodeAUIPC(inst), nil
}
if (inst^opcodes.MATCH_JAL)&opcodes.MASK_JAL == 0 {
return DecodeJAL(inst), nil
}
if (inst^opcodes.MATCH_JALR)&opcodes.MASK_JALR == 0 {
return DecodeJALR(inst), nil
}
if (inst^opcodes.MATCH_BEQ)&opcodes.MASK_BEQ == 0 {
return DecodeBEQ(inst), nil
}
if (inst^opcodes.MATCH_BNE)&opcodes.MASK_BNE == 0 {
return DecodeBNE(inst), nil
}
if (inst^opcodes.MATCH_BLT)&opcodes.MASK_BLT == 0 {
return DecodeBLT(inst), nil
}
if (inst^opcodes.MATCH_BGE)&opcodes.MASK_BGE == 0 {
return DecodeBGE(inst), nil
}
if (inst^opcodes.MATCH_BLTU)&opcodes.MASK_BLTU == 0 {
return DecodeBLTU(inst), nil
}
if (inst^opcodes.MATCH_BGEU)&opcodes.MASK_BGEU == 0 {
return DecodeBGEU(inst), nil
}
if (inst^opcodes.MATCH_LB)&opcodes.MASK_LB == 0 {
return DecodeLB(inst), nil
}
if (inst^opcodes.MATCH_LH)&opcodes.MASK_LH == 0 {
return DecodeLH(inst), nil
}
if (inst^opcodes.MATCH_LW)&opcodes.MASK_LW == 0 {
return DecodeLW(inst), nil
}
if (inst^opcodes.MATCH_LBU)&opcodes.MASK_LBU == 0 {
return DecodeLBU(inst), nil
}
if (inst^opcodes.MATCH_LHU)&opcodes.MASK_LHU == 0 {
return DecodeLHU(inst), nil
}
if (inst^opcodes.MATCH_SB)&opcodes.MASK_SB == 0 {
return DecodeSB(inst), nil
}
if (inst^opcodes.MATCH_SH)&opcodes.MASK_SH == 0 {
return DecodeSH(inst), nil
}
if (inst^opcodes.MATCH_SW)&opcodes.MASK_SW == 0 {
return DecodeSW(inst), nil
}
if (inst^opcodes.MATCH_ADDI)&opcodes.MASK_ADDI == 0 {
return DecodeADDI(inst), nil
}
if (inst^opcodes.MATCH_SLTI)&opcodes.MASK_SLTI == 0 {
return DecodeSLTI(inst), nil
}
if (inst^opcodes.MATCH_SLTIU)&opcodes.MASK_SLTIU == 0 {
return DecodeSLTIU(inst), nil
}
if (inst^opcodes.MATCH_XORI)&opcodes.MASK_XORI == 0 {
return DecodeXORI(inst), nil
}
if (inst^opcodes.MATCH_ORI)&opcodes.MASK_ORI == 0 {
return DecodeORI(inst), nil
}
if (inst^opcodes.MATCH_ANDI)&opcodes.MASK_ANDI == 0 {
return DecodeANDI(inst), nil
}
if (inst^opcodes.MATCH_ADD)&opcodes.MASK_ADD == 0 {
return DecodeADD(inst), nil
}
if (inst^opcodes.MATCH_SUB)&opcodes.MASK_SUB == 0 {
return DecodeSUB(inst), nil
}
if (inst^opcodes.MATCH_SLL)&opcodes.MASK_SLL == 0 {
return DecodeSLL(inst), nil
}
if (inst^opcodes.MATCH_SLT)&opcodes.MASK_SLT == 0 {
return DecodeSLT(inst), nil
}
if (inst^opcodes.MATCH_SLTU)&opcodes.MASK_SLTU == 0 {
return DecodeSLTU(inst), nil
}
if (inst^opcodes.MATCH_XOR)&opcodes.MASK_XOR == 0 {
return DecodeXOR(inst), nil
}
if (inst^opcodes.MATCH_SRL)&opcodes.MASK_SRL == 0 {
return DecodeSRL(inst), nil
}
if (inst^opcodes.MATCH_SRA)&opcodes.MASK_SRA == 0 {
return DecodeSRA(inst), nil
}
if (inst^opcodes.MATCH_OR)&opcodes.MASK_OR == 0 {
return DecodeOR(inst), nil
}
if (inst^opcodes.MATCH_AND)&opcodes.MASK_AND == 0 {
return DecodeAND(inst), nil
}
if (inst^opcodes.MATCH_FENCE)&opcodes.MASK_FENCE == 0 {
return DecodeFENCE(inst), nil
}
if (inst^opcodes.MATCH_ECALL)&opcodes.MASK_ECALL == 0 {
return DecodeECALL(inst), nil
}
if (inst^opcodes.MATCH_EBREAK)&opcodes.MASK_EBREAK == 0 {
return DecodeEBREAK(inst), nil
}
if (inst^opcodes.MATCH_SLLI)&opcodes.MASK_SLLI == 0 {
return DecodeSLLI(inst), nil
}
if (inst^opcodes.MATCH_SRLI)&opcodes.MASK_SRLI == 0 {
return DecodeSRLI(inst), nil
}
if (inst^opcodes.MATCH_SRAI)&opcodes.MASK_SRAI == 0 {
return DecodeSRAI(inst), nil
}
if (inst^opcodes.MATCH_SFENCE_VMA)&opcodes.MASK_SFENCE_VMA == 0 {
return DecodeSFENCE_VMA(inst), nil
}
if (inst^opcodes.MATCH_SRET)&opcodes.MASK_SRET == 0 {
return DecodeSRET(inst), nil
}
if (inst^opcodes.MATCH_CSRRW)&opcodes.MASK_CSRRW == 0 {
return DecodeCSRRW(inst), nil
}
if (inst^opcodes.MATCH_CSRRS)&opcodes.MASK_CSRRS == 0 {
return DecodeCSRRS(inst), nil
}
if (inst^opcodes.MATCH_CSRRC)&opcodes.MASK_CSRRC == 0 {
return DecodeCSRRC(inst), nil
}
if (inst^opcodes.MATCH_CSRRWI)&opcodes.MASK_CSRRWI == 0 {
return DecodeCSRRWI(inst), nil
}
if (inst^opcodes.MATCH_CSRRSI)&opcodes.MASK_CSRRSI == 0 {
return DecodeCSRRSI(inst), nil
}
if (inst^opcodes.MATCH_CSRRCI)&opcodes.MASK_CSRRCI == 0 {
return DecodeCSRRCI(inst), nil
}
if (inst^opcodes.MATCH_FENCE_I)&opcodes.MASK_FENCE_I == 0 {
return DecodeFENCE_I(inst), nil
}
if (inst^opcodes.MATCH_MRET)&opcodes.MASK_MRET == 0 {
return DecodeMRET(inst), nil
}
if (inst^opcodes.MATCH_DRET)&opcodes.MASK_DRET == 0 {
return DecodeDRET(inst), nil
}
if (inst^opcodes.MATCH_WFI)&opcodes.MASK_WFI == 0 {
return DecodeWFI(inst), nil
}
return nil, fmt.Errorf("Not found: %#032b %#08x", inst, inst)
}