1{
2  "License": [
3    "Copyright (C) 2024 The Android Open Source Project",
4    "",
5    "Licensed under the Apache License, Version 2.0 (the “License”);",
6    "you may not use this file except in compliance with the License.",
7    "You may obtain a copy of the License at",
8    "",
9    "     http://www.apache.org/licenses/LICENSE-2.0",
10    "",
11    "Unless required by applicable law or agreed to in writing, software",
12    "distributed under the License is distributed on an “AS IS” BASIS,",
13    "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
14    "See the License for the specific language governing permissions and",
15    "limitations under the License."
16  ],
17  "arch": "common_riscv",
18  "insns": [
19    {
20      "encodings": {
21        "add": { "opcode": "0000_0033", "type": "R-type" },
22        "and": { "opcode": "0000_7033", "type": "R-type" },
23        "div": { "opcode": "0200_4033", "type": "R-type" },
24        "divu": { "opcode": "0200_5033", "type": "R-type" },
25        "mul": { "opcode": "0200_0033", "type": "R-type" },
26        "mulh": { "opcode": "0200_1033", "type": "R-type" },
27        "mulhsu": { "opcode": "0200_2033", "type": "R-type" },
28        "mulhu": { "opcode": "0200_3033", "type": "R-type" },
29        "or": { "opcode": "0000_6033", "type": "R-type" },
30        "rem": { "opcode": "0200_6033", "type": "R-type" },
31        "remu": { "opcode": "0200_7033", "type": "R-type" },
32        "ror": { "opcode": "6000_5033", "type": "R-type" },
33        "sh3add": { "opcode": "2000_6033", "type": "R-type" },
34        "sll": { "opcode": "0000_1033", "type": "R-type" },
35        "slt": { "opcode": "0000_2033", "type": "R-type" },
36        "sltu": { "opcode": "0000_3033", "type": "R-type" },
37        "sra": { "opcode": "4000_5033", "type": "R-type" },
38        "sraw": { "opcode": "4000_503b", "type": "R-type" },
39        "srl": { "opcode": "0000_5033", "type": "R-type" },
40        "srlw": { "opcode": "0000_503b", "type": "R-type" },
41        "sub": { "opcode": "4000_0033", "type": "R-type" },
42        "xor": { "opcode": "0000_4033", "type": "R-type" }
43      },
44      "args": [
45        { "class": "GeneralReg", "usage": "def" },
46        { "class": "GeneralReg", "usage": "use" },
47        { "class": "GeneralReg", "usage": "use" }
48      ]
49    },
50    {
51      "encodings": {
52        "addi": { "opcode": "0000_0013", "type": "I-type" },
53        "andi": { "opcode": "0000_7013", "type": "I-type" },
54        "jalr": { "opcode": "0000_0067", "type": "I-type" },
55        "ori": { "opcode": "0000_6013", "type": "I-type" },
56        "slti": { "opcode": "0000_2013", "type": "I-type" },
57        "sltiu": { "opcode": "0000_3013", "type": "I-type" },
58        "xori": { "opcode": "0000_4013", "type": "I-type" }
59      },
60      "args": [
61        { "class": "GeneralReg", "usage": "def" },
62        { "class": "GeneralReg", "usage": "use" },
63        { "class": "I-Imm" }
64      ]
65    },
66    {
67      "encodings": {
68        "auipc": { "opcode": "0000_0017", "type": "U-Type" },
69        "lui": { "opcode": "0000_0037", "type": "U-Type" }
70      },
71      "args": [
72        { "class": "GeneralReg", "usage": "def" },
73        { "class": "U-Imm" }
74      ]
75    },
76    {
77      "stems": [ "bcc" ],
78      "args": [
79        { "class": "Cond" },
80        { "class": "GeneralReg", "usage": "use" },
81        { "class": "GeneralReg", "usage": "use" },
82        { "class": "B-Imm" }
83      ]
84    },
85    {
86      "stems": [ "bcc" ],
87      "args": [
88        { "class": "Cond" },
89        { "class": "GeneralReg", "usage": "use" },
90        { "class": "GeneralReg", "usage": "use" },
91        { "class": "Label" }
92      ]
93    },
94    {
95      "stems": [ "beq", "bge", "bgeu", "bgt", "bgtu", "ble", "bleu", "blt", "bltu", "bne" ],
96      "args": [
97        { "class": "GeneralReg", "usage": "use" },
98        { "class": "GeneralReg", "usage": "use" },
99        { "class": "Label" }
100      ]
101    },
102    {
103      "encodings": {
104        "beq": { "opcode": "0000_0063", "type": "B-Type" },
105        "bge": { "opcode": "0000_5063", "type": "B-Type" },
106        "bgeu": { "opcode": "0000_7063", "type": "B-Type" },
107        "blt": { "opcode": "0000_4063", "type": "B-Type" },
108        "bltu": { "opcode": "0000_6063", "type": "B-Type" },
109        "bne": { "opcode": "0000_1063", "type": "B-Type" }
110      },
111      "args": [
112        { "class": "GeneralReg", "usage": "use" },
113        { "class": "GeneralReg", "usage": "use" },
114        { "class": "B-Imm" }
115      ]
116    },
117    {
118      "stems": [ "beqz", "bgez", "bgtz", "blez", "bltz", "bnez" ],
119      "args": [
120        { "class": "GeneralReg", "usage": "use" },
121        { "class": "Label" }
122      ]
123    },
124    {
125      "stems": [ "call", "tail" ],
126      "args": [
127        { "class": "Label" }
128      ]
129    },
130    {
131      "encodings": {
132        "csrrc": { "opcode": "0000_7073", "type": "I-type" },
133        "csrrci": { "opcode": "0000_7073", "type": "I-type" },
134        "csrrs": { "opcode": "0000_6073", "type": "I-type" },
135        "csrrsi": { "opcode": "0000_6073", "type": "I-type" },
136        "csrrw": { "opcode": "0000_5073", "type": "I-type" },
137        "csrrwi": { "opcode": "0000_5073", "type": "I-type" }
138      },
139      "args": [
140        { "class": "GeneralReg", "usage": "def" },
141        { "class": "CsrReg", "usage": "use_def" },
142        { "class": "Csr-Imm" }
143      ]
144    },
145    {
146      "encodings": {
147        "csrrc": { "opcode": "0000_3073", "type": "I-type" },
148        "csrrs": { "opcode": "0000_2073", "type": "I-type" },
149        "csrrw": { "opcode": "0000_1073", "type": "I-type" }
150      },
151      "args": [
152        { "class": "GeneralReg", "usage": "def" },
153        { "class": "CsrReg", "usage": "use_def" },
154        { "class": "GeneralReg", "usage": "use" }
155      ]
156    },
157    {
158      "encodings": {
159        "fcvt.d.s": { "opcode": "4200_0053", "type": "R-type" },
160        "fcvt.s.d": { "opcode": "4010_0053", "type": "R-type" },
161        "fsqrt.d": { "opcode": "5a00_0053", "type": "R-type" },
162        "fsqrt.s": { "opcode": "5800_0053", "type": "R-type" }
163      },
164      "args": [
165        { "class": "FpReg", "usage": "def" },
166        { "class": "FpReg", "usage": "use" },
167        { "class": "Rm", "usage": "use" }
168      ]
169    },
170    {
171      "encodings": {
172        "fcvt.d.w": { "opcode": "d200_0053", "type": "R-type" },
173        "fcvt.d.wu": { "opcode": "d210_0053", "type": "R-type" },
174        "fcvt.s.w": { "opcode": "d000_0053", "type": "R-type" },
175        "fcvt.s.wu": { "opcode": "d010_0053", "type": "R-type" }
176      },
177      "args": [
178        { "class": "FpReg", "usage": "def" },
179        { "class": "GeneralReg", "usage": "use" },
180        { "class": "Rm", "usage": "use" }
181      ]
182    },
183    {
184      "encodings": {
185        "fcvt.w.d": { "opcode": "c200_0053", "type": "R-type" },
186        "fcvt.w.s": { "opcode": "c000_0053", "type": "R-type" },
187        "fcvt.wu.d": { "opcode": "c210_0053", "type": "R-type" },
188        "fcvt.wu.s": { "opcode": "c010_0053", "type": "R-type" }
189      },
190      "args": [
191        { "class": "GeneralReg", "usage": "def" },
192        { "class": "FpReg", "usage": "use" },
193        { "class": "Rm", "usage": "use" }
194      ]
195    },
196    {
197      "stems": [ "fld", "flw" ],
198      "args": [
199        { "class": "FpReg", "usage": "def" },
200        { "class": "Label" },
201        { "class": "GeneralReg", "usage": "def" }
202      ]
203    },
204    {
205      "encodings": {
206        "fld": { "opcode": "0000_3007", "type": "I-type" }
207      },
208      "args": [
209        { "class": "FpReg", "usage": "def" },
210        { "class": "Mem64", "usage": "use" }
211      ]
212    },
213    {
214      "encodings": {
215        "flw": { "opcode": "0000_2007", "type": "I-type" }
216      },
217      "args": [
218        { "class": "FpReg", "usage": "def" },
219        { "class": "Mem32", "usage": "use" }
220      ]
221    },
222    {
223      "stems": [ "fsd", "fsw" ],
224      "args": [
225        { "class": "FpReg", "usage": "use" },
226        { "class": "Label" },
227        { "class": "GeneralReg", "usage": "def" }
228      ]
229    },
230    {
231      "encodings": {
232        "fsd": { "opcode": "0000_3027", "type": "S-type" }
233      },
234      "args": [
235        { "class": "FpReg", "usage": "use" },
236        { "class": "Mem64", "usage": "def" }
237      ]
238    },
239    {
240      "encodings": {
241        "fsw": { "opcode": "0000_2027", "type": "S-type" }
242      },
243      "args": [
244        { "class": "FpReg", "usage": "use" },
245        { "class": "Mem32", "usage": "def" }
246      ]
247    },
248    {
249      "stems": [ "j", "jal" ],
250      "args": [
251        { "class": "J-Imm" }
252      ]
253    },
254    {
255      "encodings": {
256        "jal": { "opcode": "0000_006f", "type": "J-Type" }
257      },
258      "args": [
259        { "class": "GeneralReg", "usage": "def" },
260        { "class": "J-Imm" }
261      ]
262    },
263    {
264      "stems": [ "jal" ],
265      "args": [
266        { "class": "GeneralReg", "usage": "def" },
267        { "class": "Label" }
268      ]
269    },
270    {
271      "stems": [ "jalr", "jr" ],
272      "args": [
273        { "class": "GeneralReg", "usage": "use" }
274      ]
275    },
276    {
277      "encodings": {
278        "jalr": { "opcode": "0000_0067", "type": "I-type" }
279      },
280      "args": [
281        { "class": "GeneralReg", "usage": "def" },
282        { "class": "Mem", "usage": "use" }
283      ]
284    },
285    {
286      "stems": [ "la", "lb", "lbu", "lh", "lhu", "lw" ],
287      "args": [
288        { "class": "GeneralReg", "usage": "def" },
289        { "class": "Label" }
290      ]
291    },
292    {
293      "encodings": {
294        "lb": { "opcode": "0000_0003", "type": "I-type" },
295        "lbu": { "opcode": "0000_4003", "type": "I-type" }
296      },
297      "args": [
298        { "class": "GeneralReg", "usage": "def" },
299        { "class": "Mem8", "usage": "use" }
300      ]
301    },
302    {
303      "encodings": {
304        "lh": { "opcode": "0000_1003", "type": "I-type" },
305        "lhu": { "opcode": "0000_5003", "type": "I-type" }
306      },
307      "args": [
308        { "class": "GeneralReg", "usage": "def" },
309        { "class": "Mem16", "usage": "use" }
310      ]
311    },
312    {
313      "stems": [ "li" ],
314      "args": [
315        { "class": "GeneralReg", "usage": "def" },
316        { "class": "Imm32", "usage": "use" }
317      ]
318    },
319    {
320      "encodings": {
321        "lw": { "opcode": "0000_2003", "type": "I-type" }
322      },
323      "args": [
324        { "class": "GeneralReg", "usage": "def" },
325        { "class": "Mem32", "usage": "use" }
326      ]
327    },
328    {
329      "stems": [ "mv", "neg", "not" ],
330      "args": [
331        { "class": "GeneralReg", "usage": "def" },
332        { "class": "GeneralReg", "usage": "use" }
333      ]
334    },
335    {
336      "encodings": {
337        "prefetch.i": { "opcode": "0000_6013", "type": "P-type" },
338        "prefetch.r": { "opcode": "0010_6013", "type": "P-type" },
339        "prefetch.w": { "opcode": "0030_6013", "type": "P-type" }
340      },
341      "args": [
342        { "class": "Mem", "usage": "use" }
343      ]
344    },
345    {
346      "stems": [ "ret" ],
347      "args": []
348    },
349    {
350      "stems": [ "sb", "sh", "sw" ],
351      "args": [
352        { "class": "GeneralReg", "usage": "use" },
353        { "class": "Label" },
354        { "class": "GeneralReg", "usage": "def" }
355      ]
356    },
357    {
358      "encodings": {
359        "sb": { "opcode": "0000_0023", "type": "S-type" }
360      },
361      "args": [
362        { "class": "GeneralReg", "usage": "use" },
363        { "class": "Mem8", "usage": "def" }
364      ]
365    },
366    {
367      "stems": [ "seqz", "sgtz", "sltz", "snez" ],
368      "args": [
369        { "class": "GeneralReg", "usage": "def" },
370        { "class": "GeneralReg", "usage": "use" }
371      ]
372    },
373    {
374      "encodings": {
375        "sext.b": { "opcode": "6040_1013", "type": "R-type" },
376        "sext.h": { "opcode": "6050_1013", "type": "R-type" }
377      },
378      "args": [
379        { "class": "GeneralReg", "usage": "def" },
380        { "class": "GeneralReg", "usage": "use" }
381      ]
382    },
383    {
384      "encodings": {
385        "sh": { "opcode": "0000_1023", "type": "S-type" }
386      },
387      "args": [
388        { "class": "GeneralReg", "usage": "use" },
389        { "class": "Mem16", "usage": "def" }
390      ]
391    },
392    {
393      "encodings": {
394        "sw": { "opcode": "0000_2023", "type": "S-type" }
395      },
396      "args": [
397        { "class": "GeneralReg", "usage": "use" },
398        { "class": "Mem32", "usage": "def" }
399      ]
400    }
401  ]
402}
403