RTEMS 6.1-rc6
Loading...
Searching...
No Matches
riscv-utility.h
Go to the documentation of this file.
1/* Copyright (c) 2013, The Regents of the University of California (Regents).
2 * All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * 3. Neither the name of the Regents nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written
14 * permission.
15 *
16 * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT,
17 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST
18 * PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
19 * REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 *
21 * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
24 * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
25 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
26 */
27
33/*
34 * COPYRIGHT (c) 2015 Hesham Almatary <hesham@alumni.york.ac.uk>
35 *
36 * The license and distribution terms for this file may be
37 * found in the file LICENSE in this distribution or at
38 * http://www.rtems.org/license/LICENSE.
39 */
40
41/* This file is copied from riscv-tools/encoding.h with additions/modifications to work
42 * with RTEMS.
43 */
44#ifndef _RTEMS_SCORE_RISCV_UTILITY_H
45#define _RTEMS_SCORE_RISCV_UTILITY_H
46
47#define MSTATUS_UIE 0x00000001
48#define MSTATUS_SIE 0x00000002
49#define MSTATUS_HIE 0x00000004
50#define MSTATUS_MIE 0x00000008
51#define MSTATUS_UPIE 0x00000010
52#define MSTATUS_SPIE 0x00000020
53#define MSTATUS_HPIE 0x00000040
54#define MSTATUS_MPIE 0x00000080
55#define MSTATUS_SPP 0x00000100
56#define MSTATUS_HPP 0x00000600
57#define MSTATUS_MPP 0x00001800
58#define MSTATUS_FS 0x00006000
59#define MSTATUS_XS 0x00018000
60#define MSTATUS_MPRV 0x00020000
61#define MSTATUS_SUM 0x00040000
62#define MSTATUS_MXR 0x00080000
63#define MSTATUS_TVM 0x00100000
64#define MSTATUS_TW 0x00200000
65#define MSTATUS_TSR 0x00400000
66#define MSTATUS32_SD 0x80000000
67#define MSTATUS64_SD 0x8000000000000000
68
69#define SSTATUS_UIE 0x00000001
70#define SSTATUS_SIE 0x00000002
71#define SSTATUS_UPIE 0x00000010
72#define SSTATUS_SPIE 0x00000020
73#define SSTATUS_SPP 0x00000100
74#define SSTATUS_FS 0x00006000
75#define SSTATUS_XS 0x00018000
76#define SSTATUS_SUM 0x00040000
77#define SSTATUS_MXR 0x00080000
78#define SSTATUS32_SD 0x80000000
79#define SSTATUS64_SD 0x8000000000000000
80
81#define DCSR_XDEBUGVER (3U<<30)
82#define DCSR_NDRESET (1<<29)
83#define DCSR_FULLRESET (1<<28)
84#define DCSR_EBREAKM (1<<15)
85#define DCSR_EBREAKH (1<<14)
86#define DCSR_EBREAKS (1<<13)
87#define DCSR_EBREAKU (1<<12)
88#define DCSR_STOPCYCLE (1<<10)
89#define DCSR_STOPTIME (1<<9)
90#define DCSR_CAUSE (7<<6)
91#define DCSR_DEBUGINT (1<<5)
92#define DCSR_HALT (1<<3)
93#define DCSR_STEP (1<<2)
94#define DCSR_PRV (3<<0)
95
96#define DCSR_CAUSE_NONE 0
97#define DCSR_CAUSE_SWBP 1
98#define DCSR_CAUSE_HWBP 2
99#define DCSR_CAUSE_DEBUGINT 3
100#define DCSR_CAUSE_STEP 4
101#define DCSR_CAUSE_HALT 5
102
103#define MCONTROL_TYPE(xlen) (0xfULL<<((xlen)-4))
104#define MCONTROL_DMODE(xlen) (1ULL<<((xlen)-5))
105#define MCONTROL_MASKMAX(xlen) (0x3fULL<<((xlen)-11))
106
107#define MCONTROL_SELECT (1<<19)
108#define MCONTROL_TIMING (1<<18)
109#define MCONTROL_ACTION (0x3f<<12)
110#define MCONTROL_CHAIN (1<<11)
111#define MCONTROL_MATCH (0xf<<7)
112#define MCONTROL_M (1<<6)
113#define MCONTROL_H (1<<5)
114#define MCONTROL_S (1<<4)
115#define MCONTROL_U (1<<3)
116#define MCONTROL_EXECUTE (1<<2)
117#define MCONTROL_STORE (1<<1)
118#define MCONTROL_LOAD (1<<0)
119
120#define MCONTROL_TYPE_NONE 0
121#define MCONTROL_TYPE_MATCH 2
122
123#define MCONTROL_ACTION_DEBUG_EXCEPTION 0
124#define MCONTROL_ACTION_DEBUG_MODE 1
125#define MCONTROL_ACTION_TRACE_START 2
126#define MCONTROL_ACTION_TRACE_STOP 3
127#define MCONTROL_ACTION_TRACE_EMIT 4
128
129#define MCONTROL_MATCH_EQUAL 0
130#define MCONTROL_MATCH_NAPOT 1
131#define MCONTROL_MATCH_GE 2
132#define MCONTROL_MATCH_LT 3
133#define MCONTROL_MATCH_MASK_LOW 4
134#define MCONTROL_MATCH_MASK_HIGH 5
135
136#define MIP_SSIP (1 << IRQ_S_SOFT)
137#define MIP_HSIP (1 << IRQ_H_SOFT)
138#define MIP_MSIP (1 << IRQ_M_SOFT)
139#define MIP_STIP (1 << IRQ_S_TIMER)
140#define MIP_HTIP (1 << IRQ_H_TIMER)
141#define MIP_MTIP (1 << IRQ_M_TIMER)
142#define MIP_SEIP (1 << IRQ_S_EXT)
143#define MIP_HEIP (1 << IRQ_H_EXT)
144#define MIP_MEIP (1 << IRQ_M_EXT)
145
146#define SIP_SSIP MIP_SSIP
147#define SIP_STIP MIP_STIP
148
149#define PRV_U 0
150#define PRV_S 1
151#define PRV_H 2
152#define PRV_M 3
153
154#define SPTBR32_MODE 0x80000000
155#define SPTBR32_ASID 0x7FC00000
156#define SPTBR32_PPN 0x003FFFFF
157#define SPTBR64_MODE 0xF000000000000000
158#define SPTBR64_ASID 0x0FFFF00000000000
159#define SPTBR64_PPN 0x00000FFFFFFFFFFF
160
161#define SPTBR_MODE_OFF 0
162#define SPTBR_MODE_SV32 1
163#define SPTBR_MODE_SV39 8
164#define SPTBR_MODE_SV48 9
165#define SPTBR_MODE_SV57 10
166#define SPTBR_MODE_SV64 11
167
168#define PMP_R 0x01
169#define PMP_W 0x02
170#define PMP_X 0x04
171#define PMP_A 0x18
172#define PMP_L 0x80
173#define PMP_SHIFT 2
174
175#define PMP_TOR 0x08
176#define PMP_NA4 0x10
177#define PMP_NAPOT 0x18
178
179#define IRQ_S_SOFT 1
180#define IRQ_H_SOFT 2
181#define IRQ_M_SOFT 3
182#define IRQ_S_TIMER 5
183#define IRQ_H_TIMER 6
184#define IRQ_M_TIMER 7
185#define IRQ_S_EXT 9
186#define IRQ_H_EXT 10
187#define IRQ_M_EXT 11
188#define IRQ_COP 12
189#define IRQ_HOST 13
190
191#define DEFAULT_RSTVEC 0x00001000
192#define CLINT_BASE 0x02000000
193#define CLINT_SIZE 0x000c0000
194#define EXT_IO_BASE 0x40000000
195#define DRAM_BASE 0x80000000
196
197// page table entry (PTE) fields
198#define PTE_V 0x001 // Valid
199#define PTE_R 0x002 // Read
200#define PTE_W 0x004 // Write
201#define PTE_X 0x008 // Execute
202#define PTE_U 0x010 // User
203#define PTE_G 0x020 // Global
204#define PTE_A 0x040 // Accessed
205#define PTE_D 0x080 // Dirty
206#define PTE_SOFT 0x300 // Reserved for Software
207
208#define PTE_PPN_SHIFT 10
209
210#define PTE_TABLE(PTE) (((PTE) & (PTE_V | PTE_R | PTE_W | PTE_X)) == PTE_V)
211
212#ifdef __riscv
213
214#if __riscv_xlen == 64
215# define MSTATUS_SD MSTATUS64_SD
216# define SSTATUS_SD SSTATUS64_SD
217# define RISCV_PGLEVEL_BITS 9
218# define SPTBR_MODE SPTBR64_MODE
219#else
220# define MSTATUS_SD MSTATUS32_SD
221# define SSTATUS_SD SSTATUS32_SD
222# define RISCV_PGLEVEL_BITS 10
223# define SPTBR_MODE SPTBR32_MODE
224#endif
225#define RISCV_PGSHIFT 12
226#define RISCV_PGSIZE (1 << RISCV_PGSHIFT)
227
228#ifndef __ASSEMBLER__
229
235typedef enum {
236 RISCV_USER_INTERRUPT = 0,
237 RISCV_SUPERVISOR_SW_INTERRUPT = 1,
238 RISCV_MACHINE_SW_INTERRUPT = 3,
239 RISCV_USER_TIMER_INTERRUPT = 4,
240 RISCV_SUPERVISOR_TIMER_INTERRUPT = 4,
241 RISCV_MACHINE_TIMER_INTERRUPT = 7,
242 RISCV_USER_EXTERNAL_INTERRUPT = 8,
243 RISCV_SUPERVISOR_EXTERNAL_INTERRUPT = 9,
244 RISCV_MACHINE_EXTERNAL_INTERRUPT = 11
245} RISCV_Symbolic_interrupt_name;
246
247#ifdef __GNUC__
248
249#define read_csr(reg) ({ unsigned long __tmp; \
250 asm volatile (".option push\n.option arch, +zicsr\n" \
251 "csrr %0, " #reg "\n.option pop ": "=r"(__tmp)); \
252 __tmp; })
253
254#define write_csr(reg, val) ({ \
255 asm volatile (".option push\n.option arch, +zicsr\n" \
256 "csrw " #reg ", %0\n.option pop" :: "rK"(val)); })
257
258#define swap_csr(reg, val) ({ unsigned long __tmp; \
259 asm volatile (".option push\n.option arch, +zicsr\n" \
260 "csrrw %0, " #reg ", %1\n.option pop" : "=r"(__tmp) : "rK"(val)); \
261 __tmp; })
262
263#define set_csr(reg, bit) ({ unsigned long __tmp; \
264 asm volatile (".option push\n.option arch, +zicsr\nc" \
265 "srrs %0, " #reg ", %1\n.option pop" : "=r"(__tmp) : "rK"(bit)); \
266 __tmp; })
267
268#define clear_csr(reg, bit) ({ unsigned long __tmp; \
269 asm volatile (".option push\n.option arch, +zicsr\n" \
270 "csrrc %0, " #reg ", %1\n.option pop" : "=r"(__tmp) : "rK"(bit)); \
271 __tmp; })
272
273#define rdtime() read_csr(time)
274#define rdcycle() read_csr(cycle)
275#define rdinstret() read_csr(instret)
276
277#endif
278
279#endif
280
281#endif
282
283#endif
284/* Automatically generated by parse-opcodes. */
285#ifndef RISCV_ENCODING_H
286#define RISCV_ENCODING_H
287#define MATCH_BEQ 0x63
288#define MASK_BEQ 0x707f
289#define MATCH_BNE 0x1063
290#define MASK_BNE 0x707f
291#define MATCH_BLT 0x4063
292#define MASK_BLT 0x707f
293#define MATCH_BGE 0x5063
294#define MASK_BGE 0x707f
295#define MATCH_BLTU 0x6063
296#define MASK_BLTU 0x707f
297#define MATCH_BGEU 0x7063
298#define MASK_BGEU 0x707f
299#define MATCH_JALR 0x67
300#define MASK_JALR 0x707f
301#define MATCH_JAL 0x6f
302#define MASK_JAL 0x7f
303#define MATCH_LUI 0x37
304#define MASK_LUI 0x7f
305#define MATCH_AUIPC 0x17
306#define MASK_AUIPC 0x7f
307#define MATCH_ADDI 0x13
308#define MASK_ADDI 0x707f
309#define MATCH_SLLI 0x1013
310#define MASK_SLLI 0xfc00707f
311#define MATCH_SLTI 0x2013
312#define MASK_SLTI 0x707f
313#define MATCH_SLTIU 0x3013
314#define MASK_SLTIU 0x707f
315#define MATCH_XORI 0x4013
316#define MASK_XORI 0x707f
317#define MATCH_SRLI 0x5013
318#define MASK_SRLI 0xfc00707f
319#define MATCH_SRAI 0x40005013
320#define MASK_SRAI 0xfc00707f
321#define MATCH_ORI 0x6013
322#define MASK_ORI 0x707f
323#define MATCH_ANDI 0x7013
324#define MASK_ANDI 0x707f
325#define MATCH_ADD 0x33
326#define MASK_ADD 0xfe00707f
327#define MATCH_SUB 0x40000033
328#define MASK_SUB 0xfe00707f
329#define MATCH_SLL 0x1033
330#define MASK_SLL 0xfe00707f
331#define MATCH_SLT 0x2033
332#define MASK_SLT 0xfe00707f
333#define MATCH_SLTU 0x3033
334#define MASK_SLTU 0xfe00707f
335#define MATCH_XOR 0x4033
336#define MASK_XOR 0xfe00707f
337#define MATCH_SRL 0x5033
338#define MASK_SRL 0xfe00707f
339#define MATCH_SRA 0x40005033
340#define MASK_SRA 0xfe00707f
341#define MATCH_OR 0x6033
342#define MASK_OR 0xfe00707f
343#define MATCH_AND 0x7033
344#define MASK_AND 0xfe00707f
345#define MATCH_ADDIW 0x1b
346#define MASK_ADDIW 0x707f
347#define MATCH_SLLIW 0x101b
348#define MASK_SLLIW 0xfe00707f
349#define MATCH_SRLIW 0x501b
350#define MASK_SRLIW 0xfe00707f
351#define MATCH_SRAIW 0x4000501b
352#define MASK_SRAIW 0xfe00707f
353#define MATCH_ADDW 0x3b
354#define MASK_ADDW 0xfe00707f
355#define MATCH_SUBW 0x4000003b
356#define MASK_SUBW 0xfe00707f
357#define MATCH_SLLW 0x103b
358#define MASK_SLLW 0xfe00707f
359#define MATCH_SRLW 0x503b
360#define MASK_SRLW 0xfe00707f
361#define MATCH_SRAW 0x4000503b
362#define MASK_SRAW 0xfe00707f
363#define MATCH_LB 0x3
364#define MASK_LB 0x707f
365#define MATCH_LH 0x1003
366#define MASK_LH 0x707f
367#define MATCH_LW 0x2003
368#define MASK_LW 0x707f
369#define MATCH_LD 0x3003
370#define MASK_LD 0x707f
371#define MATCH_LBU 0x4003
372#define MASK_LBU 0x707f
373#define MATCH_LHU 0x5003
374#define MASK_LHU 0x707f
375#define MATCH_LWU 0x6003
376#define MASK_LWU 0x707f
377#define MATCH_SB 0x23
378#define MASK_SB 0x707f
379#define MATCH_SH 0x1023
380#define MASK_SH 0x707f
381#define MATCH_SW 0x2023
382#define MASK_SW 0x707f
383#define MATCH_SD 0x3023
384#define MASK_SD 0x707f
385#define MATCH_FENCE 0xf
386#define MASK_FENCE 0x707f
387#define MATCH_FENCE_I 0x100f
388#define MASK_FENCE_I 0x707f
389#define MATCH_MUL 0x2000033
390#define MASK_MUL 0xfe00707f
391#define MATCH_MULH 0x2001033
392#define MASK_MULH 0xfe00707f
393#define MATCH_MULHSU 0x2002033
394#define MASK_MULHSU 0xfe00707f
395#define MATCH_MULHU 0x2003033
396#define MASK_MULHU 0xfe00707f
397#define MATCH_DIV 0x2004033
398#define MASK_DIV 0xfe00707f
399#define MATCH_DIVU 0x2005033
400#define MASK_DIVU 0xfe00707f
401#define MATCH_REM 0x2006033
402#define MASK_REM 0xfe00707f
403#define MATCH_REMU 0x2007033
404#define MASK_REMU 0xfe00707f
405#define MATCH_MULW 0x200003b
406#define MASK_MULW 0xfe00707f
407#define MATCH_DIVW 0x200403b
408#define MASK_DIVW 0xfe00707f
409#define MATCH_DIVUW 0x200503b
410#define MASK_DIVUW 0xfe00707f
411#define MATCH_REMW 0x200603b
412#define MASK_REMW 0xfe00707f
413#define MATCH_REMUW 0x200703b
414#define MASK_REMUW 0xfe00707f
415#define MATCH_AMOADD_W 0x202f
416#define MASK_AMOADD_W 0xf800707f
417#define MATCH_AMOXOR_W 0x2000202f
418#define MASK_AMOXOR_W 0xf800707f
419#define MATCH_AMOOR_W 0x4000202f
420#define MASK_AMOOR_W 0xf800707f
421#define MATCH_AMOAND_W 0x6000202f
422#define MASK_AMOAND_W 0xf800707f
423#define MATCH_AMOMIN_W 0x8000202f
424#define MASK_AMOMIN_W 0xf800707f
425#define MATCH_AMOMAX_W 0xa000202f
426#define MASK_AMOMAX_W 0xf800707f
427#define MATCH_AMOMINU_W 0xc000202f
428#define MASK_AMOMINU_W 0xf800707f
429#define MATCH_AMOMAXU_W 0xe000202f
430#define MASK_AMOMAXU_W 0xf800707f
431#define MATCH_AMOSWAP_W 0x800202f
432#define MASK_AMOSWAP_W 0xf800707f
433#define MATCH_LR_W 0x1000202f
434#define MASK_LR_W 0xf9f0707f
435#define MATCH_SC_W 0x1800202f
436#define MASK_SC_W 0xf800707f
437#define MATCH_AMOADD_D 0x302f
438#define MASK_AMOADD_D 0xf800707f
439#define MATCH_AMOXOR_D 0x2000302f
440#define MASK_AMOXOR_D 0xf800707f
441#define MATCH_AMOOR_D 0x4000302f
442#define MASK_AMOOR_D 0xf800707f
443#define MATCH_AMOAND_D 0x6000302f
444#define MASK_AMOAND_D 0xf800707f
445#define MATCH_AMOMIN_D 0x8000302f
446#define MASK_AMOMIN_D 0xf800707f
447#define MATCH_AMOMAX_D 0xa000302f
448#define MASK_AMOMAX_D 0xf800707f
449#define MATCH_AMOMINU_D 0xc000302f
450#define MASK_AMOMINU_D 0xf800707f
451#define MATCH_AMOMAXU_D 0xe000302f
452#define MASK_AMOMAXU_D 0xf800707f
453#define MATCH_AMOSWAP_D 0x800302f
454#define MASK_AMOSWAP_D 0xf800707f
455#define MATCH_LR_D 0x1000302f
456#define MASK_LR_D 0xf9f0707f
457#define MATCH_SC_D 0x1800302f
458#define MASK_SC_D 0xf800707f
459#define MATCH_ECALL 0x73
460#define MASK_ECALL 0xffffffff
461#define MATCH_EBREAK 0x100073
462#define MASK_EBREAK 0xffffffff
463#define MATCH_URET 0x200073
464#define MASK_URET 0xffffffff
465#define MATCH_SRET 0x10200073
466#define MASK_SRET 0xffffffff
467#define MATCH_MRET 0x30200073
468#define MASK_MRET 0xffffffff
469#define MATCH_DRET 0x7b200073
470#define MASK_DRET 0xffffffff
471#define MATCH_SFENCE_VMA 0x12000073
472#define MASK_SFENCE_VMA 0xfe007fff
473#define MATCH_WFI 0x10500073
474#define MASK_WFI 0xffffffff
475#define MATCH_CSRRW 0x1073
476#define MASK_CSRRW 0x707f
477#define MATCH_CSRRS 0x2073
478#define MASK_CSRRS 0x707f
479#define MATCH_CSRRC 0x3073
480#define MASK_CSRRC 0x707f
481#define MATCH_CSRRWI 0x5073
482#define MASK_CSRRWI 0x707f
483#define MATCH_CSRRSI 0x6073
484#define MASK_CSRRSI 0x707f
485#define MATCH_CSRRCI 0x7073
486#define MASK_CSRRCI 0x707f
487#define MATCH_FADD_S 0x53
488#define MASK_FADD_S 0xfe00007f
489#define MATCH_FSUB_S 0x8000053
490#define MASK_FSUB_S 0xfe00007f
491#define MATCH_FMUL_S 0x10000053
492#define MASK_FMUL_S 0xfe00007f
493#define MATCH_FDIV_S 0x18000053
494#define MASK_FDIV_S 0xfe00007f
495#define MATCH_FSGNJ_S 0x20000053
496#define MASK_FSGNJ_S 0xfe00707f
497#define MATCH_FSGNJN_S 0x20001053
498#define MASK_FSGNJN_S 0xfe00707f
499#define MATCH_FSGNJX_S 0x20002053
500#define MASK_FSGNJX_S 0xfe00707f
501#define MATCH_FMIN_S 0x28000053
502#define MASK_FMIN_S 0xfe00707f
503#define MATCH_FMAX_S 0x28001053
504#define MASK_FMAX_S 0xfe00707f
505#define MATCH_FSQRT_S 0x58000053
506#define MASK_FSQRT_S 0xfff0007f
507#define MATCH_FADD_D 0x2000053
508#define MASK_FADD_D 0xfe00007f
509#define MATCH_FSUB_D 0xa000053
510#define MASK_FSUB_D 0xfe00007f
511#define MATCH_FMUL_D 0x12000053
512#define MASK_FMUL_D 0xfe00007f
513#define MATCH_FDIV_D 0x1a000053
514#define MASK_FDIV_D 0xfe00007f
515#define MATCH_FSGNJ_D 0x22000053
516#define MASK_FSGNJ_D 0xfe00707f
517#define MATCH_FSGNJN_D 0x22001053
518#define MASK_FSGNJN_D 0xfe00707f
519#define MATCH_FSGNJX_D 0x22002053
520#define MASK_FSGNJX_D 0xfe00707f
521#define MATCH_FMIN_D 0x2a000053
522#define MASK_FMIN_D 0xfe00707f
523#define MATCH_FMAX_D 0x2a001053
524#define MASK_FMAX_D 0xfe00707f
525#define MATCH_FCVT_S_D 0x40100053
526#define MASK_FCVT_S_D 0xfff0007f
527#define MATCH_FCVT_D_S 0x42000053
528#define MASK_FCVT_D_S 0xfff0007f
529#define MATCH_FSQRT_D 0x5a000053
530#define MASK_FSQRT_D 0xfff0007f
531#define MATCH_FADD_Q 0x6000053
532#define MASK_FADD_Q 0xfe00007f
533#define MATCH_FSUB_Q 0xe000053
534#define MASK_FSUB_Q 0xfe00007f
535#define MATCH_FMUL_Q 0x16000053
536#define MASK_FMUL_Q 0xfe00007f
537#define MATCH_FDIV_Q 0x1e000053
538#define MASK_FDIV_Q 0xfe00007f
539#define MATCH_FSGNJ_Q 0x26000053
540#define MASK_FSGNJ_Q 0xfe00707f
541#define MATCH_FSGNJN_Q 0x26001053
542#define MASK_FSGNJN_Q 0xfe00707f
543#define MATCH_FSGNJX_Q 0x26002053
544#define MASK_FSGNJX_Q 0xfe00707f
545#define MATCH_FMIN_Q 0x2e000053
546#define MASK_FMIN_Q 0xfe00707f
547#define MATCH_FMAX_Q 0x2e001053
548#define MASK_FMAX_Q 0xfe00707f
549#define MATCH_FCVT_S_Q 0x40300053
550#define MASK_FCVT_S_Q 0xfff0007f
551#define MATCH_FCVT_Q_S 0x46000053
552#define MASK_FCVT_Q_S 0xfff0007f
553#define MATCH_FCVT_D_Q 0x42300053
554#define MASK_FCVT_D_Q 0xfff0007f
555#define MATCH_FCVT_Q_D 0x46100053
556#define MASK_FCVT_Q_D 0xfff0007f
557#define MATCH_FSQRT_Q 0x5e000053
558#define MASK_FSQRT_Q 0xfff0007f
559#define MATCH_FLE_S 0xa0000053
560#define MASK_FLE_S 0xfe00707f
561#define MATCH_FLT_S 0xa0001053
562#define MASK_FLT_S 0xfe00707f
563#define MATCH_FEQ_S 0xa0002053
564#define MASK_FEQ_S 0xfe00707f
565#define MATCH_FLE_D 0xa2000053
566#define MASK_FLE_D 0xfe00707f
567#define MATCH_FLT_D 0xa2001053
568#define MASK_FLT_D 0xfe00707f
569#define MATCH_FEQ_D 0xa2002053
570#define MASK_FEQ_D 0xfe00707f
571#define MATCH_FLE_Q 0xa6000053
572#define MASK_FLE_Q 0xfe00707f
573#define MATCH_FLT_Q 0xa6001053
574#define MASK_FLT_Q 0xfe00707f
575#define MATCH_FEQ_Q 0xa6002053
576#define MASK_FEQ_Q 0xfe00707f
577#define MATCH_FCVT_W_S 0xc0000053
578#define MASK_FCVT_W_S 0xfff0007f
579#define MATCH_FCVT_WU_S 0xc0100053
580#define MASK_FCVT_WU_S 0xfff0007f
581#define MATCH_FCVT_L_S 0xc0200053
582#define MASK_FCVT_L_S 0xfff0007f
583#define MATCH_FCVT_LU_S 0xc0300053
584#define MASK_FCVT_LU_S 0xfff0007f
585#define MATCH_FMV_X_W 0xe0000053
586#define MASK_FMV_X_W 0xfff0707f
587#define MATCH_FCLASS_S 0xe0001053
588#define MASK_FCLASS_S 0xfff0707f
589#define MATCH_FCVT_W_D 0xc2000053
590#define MASK_FCVT_W_D 0xfff0007f
591#define MATCH_FCVT_WU_D 0xc2100053
592#define MASK_FCVT_WU_D 0xfff0007f
593#define MATCH_FCVT_L_D 0xc2200053
594#define MASK_FCVT_L_D 0xfff0007f
595#define MATCH_FCVT_LU_D 0xc2300053
596#define MASK_FCVT_LU_D 0xfff0007f
597#define MATCH_FMV_X_D 0xe2000053
598#define MASK_FMV_X_D 0xfff0707f
599#define MATCH_FCLASS_D 0xe2001053
600#define MASK_FCLASS_D 0xfff0707f
601#define MATCH_FCVT_W_Q 0xc6000053
602#define MASK_FCVT_W_Q 0xfff0007f
603#define MATCH_FCVT_WU_Q 0xc6100053
604#define MASK_FCVT_WU_Q 0xfff0007f
605#define MATCH_FCVT_L_Q 0xc6200053
606#define MASK_FCVT_L_Q 0xfff0007f
607#define MATCH_FCVT_LU_Q 0xc6300053
608#define MASK_FCVT_LU_Q 0xfff0007f
609#define MATCH_FMV_X_Q 0xe6000053
610#define MASK_FMV_X_Q 0xfff0707f
611#define MATCH_FCLASS_Q 0xe6001053
612#define MASK_FCLASS_Q 0xfff0707f
613#define MATCH_FCVT_S_W 0xd0000053
614#define MASK_FCVT_S_W 0xfff0007f
615#define MATCH_FCVT_S_WU 0xd0100053
616#define MASK_FCVT_S_WU 0xfff0007f
617#define MATCH_FCVT_S_L 0xd0200053
618#define MASK_FCVT_S_L 0xfff0007f
619#define MATCH_FCVT_S_LU 0xd0300053
620#define MASK_FCVT_S_LU 0xfff0007f
621#define MATCH_FMV_W_X 0xf0000053
622#define MASK_FMV_W_X 0xfff0707f
623#define MATCH_FCVT_D_W 0xd2000053
624#define MASK_FCVT_D_W 0xfff0007f
625#define MATCH_FCVT_D_WU 0xd2100053
626#define MASK_FCVT_D_WU 0xfff0007f
627#define MATCH_FCVT_D_L 0xd2200053
628#define MASK_FCVT_D_L 0xfff0007f
629#define MATCH_FCVT_D_LU 0xd2300053
630#define MASK_FCVT_D_LU 0xfff0007f
631#define MATCH_FMV_D_X 0xf2000053
632#define MASK_FMV_D_X 0xfff0707f
633#define MATCH_FCVT_Q_W 0xd6000053
634#define MASK_FCVT_Q_W 0xfff0007f
635#define MATCH_FCVT_Q_WU 0xd6100053
636#define MASK_FCVT_Q_WU 0xfff0007f
637#define MATCH_FCVT_Q_L 0xd6200053
638#define MASK_FCVT_Q_L 0xfff0007f
639#define MATCH_FCVT_Q_LU 0xd6300053
640#define MASK_FCVT_Q_LU 0xfff0007f
641#define MATCH_FMV_Q_X 0xf6000053
642#define MASK_FMV_Q_X 0xfff0707f
643#define MATCH_FLW 0x2007
644#define MASK_FLW 0x707f
645#define MATCH_FLD 0x3007
646#define MASK_FLD 0x707f
647#define MATCH_FLQ 0x4007
648#define MASK_FLQ 0x707f
649#define MATCH_FSW 0x2027
650#define MASK_FSW 0x707f
651#define MATCH_FSD 0x3027
652#define MASK_FSD 0x707f
653#define MATCH_FSQ 0x4027
654#define MASK_FSQ 0x707f
655#define MATCH_FMADD_S 0x43
656#define MASK_FMADD_S 0x600007f
657#define MATCH_FMSUB_S 0x47
658#define MASK_FMSUB_S 0x600007f
659#define MATCH_FNMSUB_S 0x4b
660#define MASK_FNMSUB_S 0x600007f
661#define MATCH_FNMADD_S 0x4f
662#define MASK_FNMADD_S 0x600007f
663#define MATCH_FMADD_D 0x2000043
664#define MASK_FMADD_D 0x600007f
665#define MATCH_FMSUB_D 0x2000047
666#define MASK_FMSUB_D 0x600007f
667#define MATCH_FNMSUB_D 0x200004b
668#define MASK_FNMSUB_D 0x600007f
669#define MATCH_FNMADD_D 0x200004f
670#define MASK_FNMADD_D 0x600007f
671#define MATCH_FMADD_Q 0x6000043
672#define MASK_FMADD_Q 0x600007f
673#define MATCH_FMSUB_Q 0x6000047
674#define MASK_FMSUB_Q 0x600007f
675#define MATCH_FNMSUB_Q 0x600004b
676#define MASK_FNMSUB_Q 0x600007f
677#define MATCH_FNMADD_Q 0x600004f
678#define MASK_FNMADD_Q 0x600007f
679#define MATCH_C_NOP 0x1
680#define MASK_C_NOP 0xffff
681#define MATCH_C_ADDI16SP 0x6101
682#define MASK_C_ADDI16SP 0xef83
683#define MATCH_C_JR 0x8002
684#define MASK_C_JR 0xf07f
685#define MATCH_C_JALR 0x9002
686#define MASK_C_JALR 0xf07f
687#define MATCH_C_EBREAK 0x9002
688#define MASK_C_EBREAK 0xffff
689#define MATCH_C_LD 0x6000
690#define MASK_C_LD 0xe003
691#define MATCH_C_SD 0xe000
692#define MASK_C_SD 0xe003
693#define MATCH_C_ADDIW 0x2001
694#define MASK_C_ADDIW 0xe003
695#define MATCH_C_LDSP 0x6002
696#define MASK_C_LDSP 0xe003
697#define MATCH_C_SDSP 0xe002
698#define MASK_C_SDSP 0xe003
699#define MATCH_C_ADDI4SPN 0x0
700#define MASK_C_ADDI4SPN 0xe003
701#define MATCH_C_FLD 0x2000
702#define MASK_C_FLD 0xe003
703#define MATCH_C_LW 0x4000
704#define MASK_C_LW 0xe003
705#define MATCH_C_FLW 0x6000
706#define MASK_C_FLW 0xe003
707#define MATCH_C_FSD 0xa000
708#define MASK_C_FSD 0xe003
709#define MATCH_C_SW 0xc000
710#define MASK_C_SW 0xe003
711#define MATCH_C_FSW 0xe000
712#define MASK_C_FSW 0xe003
713#define MATCH_C_ADDI 0x1
714#define MASK_C_ADDI 0xe003
715#define MATCH_C_JAL 0x2001
716#define MASK_C_JAL 0xe003
717#define MATCH_C_LI 0x4001
718#define MASK_C_LI 0xe003
719#define MATCH_C_LUI 0x6001
720#define MASK_C_LUI 0xe003
721#define MATCH_C_SRLI 0x8001
722#define MASK_C_SRLI 0xec03
723#define MATCH_C_SRAI 0x8401
724#define MASK_C_SRAI 0xec03
725#define MATCH_C_ANDI 0x8801
726#define MASK_C_ANDI 0xec03
727#define MATCH_C_SUB 0x8c01
728#define MASK_C_SUB 0xfc63
729#define MATCH_C_XOR 0x8c21
730#define MASK_C_XOR 0xfc63
731#define MATCH_C_OR 0x8c41
732#define MASK_C_OR 0xfc63
733#define MATCH_C_AND 0x8c61
734#define MASK_C_AND 0xfc63
735#define MATCH_C_SUBW 0x9c01
736#define MASK_C_SUBW 0xfc63
737#define MATCH_C_ADDW 0x9c21
738#define MASK_C_ADDW 0xfc63
739#define MATCH_C_J 0xa001
740#define MASK_C_J 0xe003
741#define MATCH_C_BEQZ 0xc001
742#define MASK_C_BEQZ 0xe003
743#define MATCH_C_BNEZ 0xe001
744#define MASK_C_BNEZ 0xe003
745#define MATCH_C_SLLI 0x2
746#define MASK_C_SLLI 0xe003
747#define MATCH_C_FLDSP 0x2002
748#define MASK_C_FLDSP 0xe003
749#define MATCH_C_LWSP 0x4002
750#define MASK_C_LWSP 0xe003
751#define MATCH_C_FLWSP 0x6002
752#define MASK_C_FLWSP 0xe003
753#define MATCH_C_MV 0x8002
754#define MASK_C_MV 0xf003
755#define MATCH_C_ADD 0x9002
756#define MASK_C_ADD 0xf003
757#define MATCH_C_FSDSP 0xa002
758#define MASK_C_FSDSP 0xe003
759#define MATCH_C_SWSP 0xc002
760#define MASK_C_SWSP 0xe003
761#define MATCH_C_FSWSP 0xe002
762#define MASK_C_FSWSP 0xe003
763#define MATCH_CUSTOM0 0xb
764#define MASK_CUSTOM0 0x707f
765#define MATCH_CUSTOM0_RS1 0x200b
766#define MASK_CUSTOM0_RS1 0x707f
767#define MATCH_CUSTOM0_RS1_RS2 0x300b
768#define MASK_CUSTOM0_RS1_RS2 0x707f
769#define MATCH_CUSTOM0_RD 0x400b
770#define MASK_CUSTOM0_RD 0x707f
771#define MATCH_CUSTOM0_RD_RS1 0x600b
772#define MASK_CUSTOM0_RD_RS1 0x707f
773#define MATCH_CUSTOM0_RD_RS1_RS2 0x700b
774#define MASK_CUSTOM0_RD_RS1_RS2 0x707f
775#define MATCH_CUSTOM1 0x2b
776#define MASK_CUSTOM1 0x707f
777#define MATCH_CUSTOM1_RS1 0x202b
778#define MASK_CUSTOM1_RS1 0x707f
779#define MATCH_CUSTOM1_RS1_RS2 0x302b
780#define MASK_CUSTOM1_RS1_RS2 0x707f
781#define MATCH_CUSTOM1_RD 0x402b
782#define MASK_CUSTOM1_RD 0x707f
783#define MATCH_CUSTOM1_RD_RS1 0x602b
784#define MASK_CUSTOM1_RD_RS1 0x707f
785#define MATCH_CUSTOM1_RD_RS1_RS2 0x702b
786#define MASK_CUSTOM1_RD_RS1_RS2 0x707f
787#define MATCH_CUSTOM2 0x5b
788#define MASK_CUSTOM2 0x707f
789#define MATCH_CUSTOM2_RS1 0x205b
790#define MASK_CUSTOM2_RS1 0x707f
791#define MATCH_CUSTOM2_RS1_RS2 0x305b
792#define MASK_CUSTOM2_RS1_RS2 0x707f
793#define MATCH_CUSTOM2_RD 0x405b
794#define MASK_CUSTOM2_RD 0x707f
795#define MATCH_CUSTOM2_RD_RS1 0x605b
796#define MASK_CUSTOM2_RD_RS1 0x707f
797#define MATCH_CUSTOM2_RD_RS1_RS2 0x705b
798#define MASK_CUSTOM2_RD_RS1_RS2 0x707f
799#define MATCH_CUSTOM3 0x7b
800#define MASK_CUSTOM3 0x707f
801#define MATCH_CUSTOM3_RS1 0x207b
802#define MASK_CUSTOM3_RS1 0x707f
803#define MATCH_CUSTOM3_RS1_RS2 0x307b
804#define MASK_CUSTOM3_RS1_RS2 0x707f
805#define MATCH_CUSTOM3_RD 0x407b
806#define MASK_CUSTOM3_RD 0x707f
807#define MATCH_CUSTOM3_RD_RS1 0x607b
808#define MASK_CUSTOM3_RD_RS1 0x707f
809#define MATCH_CUSTOM3_RD_RS1_RS2 0x707b
810#define MASK_CUSTOM3_RD_RS1_RS2 0x707f
811#define CSR_FFLAGS 0x1
812#define CSR_FRM 0x2
813#define CSR_FCSR 0x3
814#define CSR_CYCLE 0xc00
815#define CSR_TIME 0xc01
816#define CSR_INSTRET 0xc02
817#define CSR_HPMCOUNTER3 0xc03
818#define CSR_HPMCOUNTER4 0xc04
819#define CSR_HPMCOUNTER5 0xc05
820#define CSR_HPMCOUNTER6 0xc06
821#define CSR_HPMCOUNTER7 0xc07
822#define CSR_HPMCOUNTER8 0xc08
823#define CSR_HPMCOUNTER9 0xc09
824#define CSR_HPMCOUNTER10 0xc0a
825#define CSR_HPMCOUNTER11 0xc0b
826#define CSR_HPMCOUNTER12 0xc0c
827#define CSR_HPMCOUNTER13 0xc0d
828#define CSR_HPMCOUNTER14 0xc0e
829#define CSR_HPMCOUNTER15 0xc0f
830#define CSR_HPMCOUNTER16 0xc10
831#define CSR_HPMCOUNTER17 0xc11
832#define CSR_HPMCOUNTER18 0xc12
833#define CSR_HPMCOUNTER19 0xc13
834#define CSR_HPMCOUNTER20 0xc14
835#define CSR_HPMCOUNTER21 0xc15
836#define CSR_HPMCOUNTER22 0xc16
837#define CSR_HPMCOUNTER23 0xc17
838#define CSR_HPMCOUNTER24 0xc18
839#define CSR_HPMCOUNTER25 0xc19
840#define CSR_HPMCOUNTER26 0xc1a
841#define CSR_HPMCOUNTER27 0xc1b
842#define CSR_HPMCOUNTER28 0xc1c
843#define CSR_HPMCOUNTER29 0xc1d
844#define CSR_HPMCOUNTER30 0xc1e
845#define CSR_HPMCOUNTER31 0xc1f
846#define CSR_SSTATUS 0x100
847#define CSR_SIE 0x104
848#define CSR_STVEC 0x105
849#define CSR_SCOUNTEREN 0x106
850#define CSR_SSCRATCH 0x140
851#define CSR_SEPC 0x141
852#define CSR_SCAUSE 0x142
853#define CSR_SBADADDR 0x143
854#define CSR_SIP 0x144
855#define CSR_SPTBR 0x180
856#define CSR_MSTATUS 0x300
857#define CSR_MISA 0x301
858#define CSR_MEDELEG 0x302
859#define CSR_MIDELEG 0x303
860#define CSR_MIE 0x304
861#define CSR_MTVEC 0x305
862#define CSR_MCOUNTEREN 0x306
863#define CSR_MSCRATCH 0x340
864#define CSR_MEPC 0x341
865#define CSR_MCAUSE 0x342
866#define CSR_MBADADDR 0x343
867#define CSR_MIP 0x344
868#define CSR_PMPCFG0 0x3a0
869#define CSR_PMPCFG1 0x3a1
870#define CSR_PMPCFG2 0x3a2
871#define CSR_PMPCFG3 0x3a3
872#define CSR_PMPADDR0 0x3b0
873#define CSR_PMPADDR1 0x3b1
874#define CSR_PMPADDR2 0x3b2
875#define CSR_PMPADDR3 0x3b3
876#define CSR_PMPADDR4 0x3b4
877#define CSR_PMPADDR5 0x3b5
878#define CSR_PMPADDR6 0x3b6
879#define CSR_PMPADDR7 0x3b7
880#define CSR_PMPADDR8 0x3b8
881#define CSR_PMPADDR9 0x3b9
882#define CSR_PMPADDR10 0x3ba
883#define CSR_PMPADDR11 0x3bb
884#define CSR_PMPADDR12 0x3bc
885#define CSR_PMPADDR13 0x3bd
886#define CSR_PMPADDR14 0x3be
887#define CSR_PMPADDR15 0x3bf
888#define CSR_TSELECT 0x7a0
889#define CSR_TDATA1 0x7a1
890#define CSR_TDATA2 0x7a2
891#define CSR_TDATA3 0x7a3
892#define CSR_DCSR 0x7b0
893#define CSR_DPC 0x7b1
894#define CSR_DSCRATCH 0x7b2
895#define CSR_MCYCLE 0xb00
896#define CSR_MINSTRET 0xb02
897#define CSR_MHPMCOUNTER3 0xb03
898#define CSR_MHPMCOUNTER4 0xb04
899#define CSR_MHPMCOUNTER5 0xb05
900#define CSR_MHPMCOUNTER6 0xb06
901#define CSR_MHPMCOUNTER7 0xb07
902#define CSR_MHPMCOUNTER8 0xb08
903#define CSR_MHPMCOUNTER9 0xb09
904#define CSR_MHPMCOUNTER10 0xb0a
905#define CSR_MHPMCOUNTER11 0xb0b
906#define CSR_MHPMCOUNTER12 0xb0c
907#define CSR_MHPMCOUNTER13 0xb0d
908#define CSR_MHPMCOUNTER14 0xb0e
909#define CSR_MHPMCOUNTER15 0xb0f
910#define CSR_MHPMCOUNTER16 0xb10
911#define CSR_MHPMCOUNTER17 0xb11
912#define CSR_MHPMCOUNTER18 0xb12
913#define CSR_MHPMCOUNTER19 0xb13
914#define CSR_MHPMCOUNTER20 0xb14
915#define CSR_MHPMCOUNTER21 0xb15
916#define CSR_MHPMCOUNTER22 0xb16
917#define CSR_MHPMCOUNTER23 0xb17
918#define CSR_MHPMCOUNTER24 0xb18
919#define CSR_MHPMCOUNTER25 0xb19
920#define CSR_MHPMCOUNTER26 0xb1a
921#define CSR_MHPMCOUNTER27 0xb1b
922#define CSR_MHPMCOUNTER28 0xb1c
923#define CSR_MHPMCOUNTER29 0xb1d
924#define CSR_MHPMCOUNTER30 0xb1e
925#define CSR_MHPMCOUNTER31 0xb1f
926#define CSR_MHPMEVENT3 0x323
927#define CSR_MHPMEVENT4 0x324
928#define CSR_MHPMEVENT5 0x325
929#define CSR_MHPMEVENT6 0x326
930#define CSR_MHPMEVENT7 0x327
931#define CSR_MHPMEVENT8 0x328
932#define CSR_MHPMEVENT9 0x329
933#define CSR_MHPMEVENT10 0x32a
934#define CSR_MHPMEVENT11 0x32b
935#define CSR_MHPMEVENT12 0x32c
936#define CSR_MHPMEVENT13 0x32d
937#define CSR_MHPMEVENT14 0x32e
938#define CSR_MHPMEVENT15 0x32f
939#define CSR_MHPMEVENT16 0x330
940#define CSR_MHPMEVENT17 0x331
941#define CSR_MHPMEVENT18 0x332
942#define CSR_MHPMEVENT19 0x333
943#define CSR_MHPMEVENT20 0x334
944#define CSR_MHPMEVENT21 0x335
945#define CSR_MHPMEVENT22 0x336
946#define CSR_MHPMEVENT23 0x337
947#define CSR_MHPMEVENT24 0x338
948#define CSR_MHPMEVENT25 0x339
949#define CSR_MHPMEVENT26 0x33a
950#define CSR_MHPMEVENT27 0x33b
951#define CSR_MHPMEVENT28 0x33c
952#define CSR_MHPMEVENT29 0x33d
953#define CSR_MHPMEVENT30 0x33e
954#define CSR_MHPMEVENT31 0x33f
955#define CSR_MVENDORID 0xf11
956#define CSR_MARCHID 0xf12
957#define CSR_MIMPID 0xf13
958#define CSR_MHARTID 0xf14
959#define CSR_CYCLEH 0xc80
960#define CSR_TIMEH 0xc81
961#define CSR_INSTRETH 0xc82
962#define CSR_HPMCOUNTER3H 0xc83
963#define CSR_HPMCOUNTER4H 0xc84
964#define CSR_HPMCOUNTER5H 0xc85
965#define CSR_HPMCOUNTER6H 0xc86
966#define CSR_HPMCOUNTER7H 0xc87
967#define CSR_HPMCOUNTER8H 0xc88
968#define CSR_HPMCOUNTER9H 0xc89
969#define CSR_HPMCOUNTER10H 0xc8a
970#define CSR_HPMCOUNTER11H 0xc8b
971#define CSR_HPMCOUNTER12H 0xc8c
972#define CSR_HPMCOUNTER13H 0xc8d
973#define CSR_HPMCOUNTER14H 0xc8e
974#define CSR_HPMCOUNTER15H 0xc8f
975#define CSR_HPMCOUNTER16H 0xc90
976#define CSR_HPMCOUNTER17H 0xc91
977#define CSR_HPMCOUNTER18H 0xc92
978#define CSR_HPMCOUNTER19H 0xc93
979#define CSR_HPMCOUNTER20H 0xc94
980#define CSR_HPMCOUNTER21H 0xc95
981#define CSR_HPMCOUNTER22H 0xc96
982#define CSR_HPMCOUNTER23H 0xc97
983#define CSR_HPMCOUNTER24H 0xc98
984#define CSR_HPMCOUNTER25H 0xc99
985#define CSR_HPMCOUNTER26H 0xc9a
986#define CSR_HPMCOUNTER27H 0xc9b
987#define CSR_HPMCOUNTER28H 0xc9c
988#define CSR_HPMCOUNTER29H 0xc9d
989#define CSR_HPMCOUNTER30H 0xc9e
990#define CSR_HPMCOUNTER31H 0xc9f
991#define CSR_MCYCLEH 0xb80
992#define CSR_MINSTRETH 0xb82
993#define CSR_MHPMCOUNTER3H 0xb83
994#define CSR_MHPMCOUNTER4H 0xb84
995#define CSR_MHPMCOUNTER5H 0xb85
996#define CSR_MHPMCOUNTER6H 0xb86
997#define CSR_MHPMCOUNTER7H 0xb87
998#define CSR_MHPMCOUNTER8H 0xb88
999#define CSR_MHPMCOUNTER9H 0xb89
1000#define CSR_MHPMCOUNTER10H 0xb8a
1001#define CSR_MHPMCOUNTER11H 0xb8b
1002#define CSR_MHPMCOUNTER12H 0xb8c
1003#define CSR_MHPMCOUNTER13H 0xb8d
1004#define CSR_MHPMCOUNTER14H 0xb8e
1005#define CSR_MHPMCOUNTER15H 0xb8f
1006#define CSR_MHPMCOUNTER16H 0xb90
1007#define CSR_MHPMCOUNTER17H 0xb91
1008#define CSR_MHPMCOUNTER18H 0xb92
1009#define CSR_MHPMCOUNTER19H 0xb93
1010#define CSR_MHPMCOUNTER20H 0xb94
1011#define CSR_MHPMCOUNTER21H 0xb95
1012#define CSR_MHPMCOUNTER22H 0xb96
1013#define CSR_MHPMCOUNTER23H 0xb97
1014#define CSR_MHPMCOUNTER24H 0xb98
1015#define CSR_MHPMCOUNTER25H 0xb99
1016#define CSR_MHPMCOUNTER26H 0xb9a
1017#define CSR_MHPMCOUNTER27H 0xb9b
1018#define CSR_MHPMCOUNTER28H 0xb9c
1019#define CSR_MHPMCOUNTER29H 0xb9d
1020#define CSR_MHPMCOUNTER30H 0xb9e
1021#define CSR_MHPMCOUNTER31H 0xb9f
1022#define CAUSE_MISALIGNED_FETCH 0x0
1023#define CAUSE_FETCH_ACCESS 0x1
1024#define CAUSE_ILLEGAL_INSTRUCTION 0x2
1025#define CAUSE_BREAKPOINT 0x3
1026#define CAUSE_MISALIGNED_LOAD 0x4
1027#define CAUSE_LOAD_ACCESS 0x5
1028#define CAUSE_MISALIGNED_STORE 0x6
1029#define CAUSE_STORE_ACCESS 0x7
1030#define CAUSE_USER_ECALL 0x8
1031#define CAUSE_SUPERVISOR_ECALL 0x9
1032#define CAUSE_HYPERVISOR_ECALL 0xa
1033#define CAUSE_MACHINE_ECALL 0xb
1034#define CAUSE_FETCH_PAGE_FAULT 0xc
1035#define CAUSE_LOAD_PAGE_FAULT 0xd
1036#define CAUSE_STORE_PAGE_FAULT 0xf
1037#endif
1038#ifdef DECLARE_INSN
1039DECLARE_INSN(beq, MATCH_BEQ, MASK_BEQ)
1040DECLARE_INSN(bne, MATCH_BNE, MASK_BNE)
1041DECLARE_INSN(blt, MATCH_BLT, MASK_BLT)
1042DECLARE_INSN(bge, MATCH_BGE, MASK_BGE)
1043DECLARE_INSN(bltu, MATCH_BLTU, MASK_BLTU)
1044DECLARE_INSN(bgeu, MATCH_BGEU, MASK_BGEU)
1045DECLARE_INSN(jalr, MATCH_JALR, MASK_JALR)
1046DECLARE_INSN(jal, MATCH_JAL, MASK_JAL)
1047DECLARE_INSN(lui, MATCH_LUI, MASK_LUI)
1048DECLARE_INSN(auipc, MATCH_AUIPC, MASK_AUIPC)
1049DECLARE_INSN(addi, MATCH_ADDI, MASK_ADDI)
1050DECLARE_INSN(slli, MATCH_SLLI, MASK_SLLI)
1051DECLARE_INSN(slti, MATCH_SLTI, MASK_SLTI)
1052DECLARE_INSN(sltiu, MATCH_SLTIU, MASK_SLTIU)
1053DECLARE_INSN(xori, MATCH_XORI, MASK_XORI)
1054DECLARE_INSN(srli, MATCH_SRLI, MASK_SRLI)
1055DECLARE_INSN(srai, MATCH_SRAI, MASK_SRAI)
1056DECLARE_INSN(ori, MATCH_ORI, MASK_ORI)
1057DECLARE_INSN(andi, MATCH_ANDI, MASK_ANDI)
1058DECLARE_INSN(add, MATCH_ADD, MASK_ADD)
1059DECLARE_INSN(sub, MATCH_SUB, MASK_SUB)
1060DECLARE_INSN(sll, MATCH_SLL, MASK_SLL)
1061DECLARE_INSN(slt, MATCH_SLT, MASK_SLT)
1062DECLARE_INSN(sltu, MATCH_SLTU, MASK_SLTU)
1063DECLARE_INSN(xor, MATCH_XOR, MASK_XOR)
1064DECLARE_INSN(srl, MATCH_SRL, MASK_SRL)
1065DECLARE_INSN(sra, MATCH_SRA, MASK_SRA)
1066DECLARE_INSN( or , MATCH_OR, MASK_OR)
1067DECLARE_INSN( and , MATCH_AND, MASK_AND)
1068DECLARE_INSN(addiw, MATCH_ADDIW, MASK_ADDIW)
1069DECLARE_INSN(slliw, MATCH_SLLIW, MASK_SLLIW)
1070DECLARE_INSN(srliw, MATCH_SRLIW, MASK_SRLIW)
1071DECLARE_INSN(sraiw, MATCH_SRAIW, MASK_SRAIW)
1072DECLARE_INSN(addw, MATCH_ADDW, MASK_ADDW)
1073DECLARE_INSN(subw, MATCH_SUBW, MASK_SUBW)
1074DECLARE_INSN(sllw, MATCH_SLLW, MASK_SLLW)
1075DECLARE_INSN(srlw, MATCH_SRLW, MASK_SRLW)
1076DECLARE_INSN(sraw, MATCH_SRAW, MASK_SRAW)
1077DECLARE_INSN(lb, MATCH_LB, MASK_LB)
1078DECLARE_INSN(lh, MATCH_LH, MASK_LH)
1079DECLARE_INSN(lw, MATCH_LW, MASK_LW)
1080DECLARE_INSN(ld, MATCH_LD, MASK_LD)
1081DECLARE_INSN(lbu, MATCH_LBU, MASK_LBU)
1082DECLARE_INSN(lhu, MATCH_LHU, MASK_LHU)
1083DECLARE_INSN(lwu, MATCH_LWU, MASK_LWU)
1084DECLARE_INSN(sb, MATCH_SB, MASK_SB)
1085DECLARE_INSN(sh, MATCH_SH, MASK_SH)
1086DECLARE_INSN(sw, MATCH_SW, MASK_SW)
1087DECLARE_INSN(sd, MATCH_SD, MASK_SD)
1088DECLARE_INSN(fence, MATCH_FENCE, MASK_FENCE)
1089DECLARE_INSN(fence_i, MATCH_FENCE_I, MASK_FENCE_I)
1090DECLARE_INSN(mul, MATCH_MUL, MASK_MUL)
1091DECLARE_INSN(mulh, MATCH_MULH, MASK_MULH)
1092DECLARE_INSN(mulhsu, MATCH_MULHSU, MASK_MULHSU)
1093DECLARE_INSN(mulhu, MATCH_MULHU, MASK_MULHU)
1094DECLARE_INSN(div, MATCH_DIV, MASK_DIV)
1095DECLARE_INSN(divu, MATCH_DIVU, MASK_DIVU)
1096DECLARE_INSN(rem, MATCH_REM, MASK_REM)
1097DECLARE_INSN(remu, MATCH_REMU, MASK_REMU)
1098DECLARE_INSN(mulw, MATCH_MULW, MASK_MULW)
1099DECLARE_INSN(divw, MATCH_DIVW, MASK_DIVW)
1100DECLARE_INSN(divuw, MATCH_DIVUW, MASK_DIVUW)
1101DECLARE_INSN(remw, MATCH_REMW, MASK_REMW)
1102DECLARE_INSN(remuw, MATCH_REMUW, MASK_REMUW)
1103DECLARE_INSN(amoadd_w, MATCH_AMOADD_W, MASK_AMOADD_W)
1104DECLARE_INSN(amoxor_w, MATCH_AMOXOR_W, MASK_AMOXOR_W)
1105DECLARE_INSN(amoor_w, MATCH_AMOOR_W, MASK_AMOOR_W)
1106DECLARE_INSN(amoand_w, MATCH_AMOAND_W, MASK_AMOAND_W)
1107DECLARE_INSN(amomin_w, MATCH_AMOMIN_W, MASK_AMOMIN_W)
1108DECLARE_INSN(amomax_w, MATCH_AMOMAX_W, MASK_AMOMAX_W)
1109DECLARE_INSN(amominu_w, MATCH_AMOMINU_W, MASK_AMOMINU_W)
1110DECLARE_INSN(amomaxu_w, MATCH_AMOMAXU_W, MASK_AMOMAXU_W)
1111DECLARE_INSN(amoswap_w, MATCH_AMOSWAP_W, MASK_AMOSWAP_W)
1112DECLARE_INSN(lr_w, MATCH_LR_W, MASK_LR_W)
1113DECLARE_INSN(sc_w, MATCH_SC_W, MASK_SC_W)
1114DECLARE_INSN(amoadd_d, MATCH_AMOADD_D, MASK_AMOADD_D)
1115DECLARE_INSN(amoxor_d, MATCH_AMOXOR_D, MASK_AMOXOR_D)
1116DECLARE_INSN(amoor_d, MATCH_AMOOR_D, MASK_AMOOR_D)
1117DECLARE_INSN(amoand_d, MATCH_AMOAND_D, MASK_AMOAND_D)
1118DECLARE_INSN(amomin_d, MATCH_AMOMIN_D, MASK_AMOMIN_D)
1119DECLARE_INSN(amomax_d, MATCH_AMOMAX_D, MASK_AMOMAX_D)
1120DECLARE_INSN(amominu_d, MATCH_AMOMINU_D, MASK_AMOMINU_D)
1121DECLARE_INSN(amomaxu_d, MATCH_AMOMAXU_D, MASK_AMOMAXU_D)
1122DECLARE_INSN(amoswap_d, MATCH_AMOSWAP_D, MASK_AMOSWAP_D)
1123DECLARE_INSN(lr_d, MATCH_LR_D, MASK_LR_D)
1124DECLARE_INSN(sc_d, MATCH_SC_D, MASK_SC_D)
1125DECLARE_INSN(ecall, MATCH_ECALL, MASK_ECALL)
1126DECLARE_INSN(ebreak, MATCH_EBREAK, MASK_EBREAK)
1127DECLARE_INSN(uret, MATCH_URET, MASK_URET)
1128DECLARE_INSN(sret, MATCH_SRET, MASK_SRET)
1129DECLARE_INSN(mret, MATCH_MRET, MASK_MRET)
1130DECLARE_INSN(dret, MATCH_DRET, MASK_DRET)
1131DECLARE_INSN(sfence_vma, MATCH_SFENCE_VMA, MASK_SFENCE_VMA)
1132DECLARE_INSN(wfi, MATCH_WFI, MASK_WFI)
1133DECLARE_INSN(csrrw, MATCH_CSRRW, MASK_CSRRW)
1134DECLARE_INSN(csrrs, MATCH_CSRRS, MASK_CSRRS)
1135DECLARE_INSN(csrrc, MATCH_CSRRC, MASK_CSRRC)
1136DECLARE_INSN(csrrwi, MATCH_CSRRWI, MASK_CSRRWI)
1137DECLARE_INSN(csrrsi, MATCH_CSRRSI, MASK_CSRRSI)
1138DECLARE_INSN(csrrci, MATCH_CSRRCI, MASK_CSRRCI)
1139DECLARE_INSN(fadd_s, MATCH_FADD_S, MASK_FADD_S)
1140DECLARE_INSN(fsub_s, MATCH_FSUB_S, MASK_FSUB_S)
1141DECLARE_INSN(fmul_s, MATCH_FMUL_S, MASK_FMUL_S)
1142DECLARE_INSN(fdiv_s, MATCH_FDIV_S, MASK_FDIV_S)
1143DECLARE_INSN(fsgnj_s, MATCH_FSGNJ_S, MASK_FSGNJ_S)
1144DECLARE_INSN(fsgnjn_s, MATCH_FSGNJN_S, MASK_FSGNJN_S)
1145DECLARE_INSN(fsgnjx_s, MATCH_FSGNJX_S, MASK_FSGNJX_S)
1146DECLARE_INSN(fmin_s, MATCH_FMIN_S, MASK_FMIN_S)
1147DECLARE_INSN(fmax_s, MATCH_FMAX_S, MASK_FMAX_S)
1148DECLARE_INSN(fsqrt_s, MATCH_FSQRT_S, MASK_FSQRT_S)
1149DECLARE_INSN(fadd_d, MATCH_FADD_D, MASK_FADD_D)
1150DECLARE_INSN(fsub_d, MATCH_FSUB_D, MASK_FSUB_D)
1151DECLARE_INSN(fmul_d, MATCH_FMUL_D, MASK_FMUL_D)
1152DECLARE_INSN(fdiv_d, MATCH_FDIV_D, MASK_FDIV_D)
1153DECLARE_INSN(fsgnj_d, MATCH_FSGNJ_D, MASK_FSGNJ_D)
1154DECLARE_INSN(fsgnjn_d, MATCH_FSGNJN_D, MASK_FSGNJN_D)
1155DECLARE_INSN(fsgnjx_d, MATCH_FSGNJX_D, MASK_FSGNJX_D)
1156DECLARE_INSN(fmin_d, MATCH_FMIN_D, MASK_FMIN_D)
1157DECLARE_INSN(fmax_d, MATCH_FMAX_D, MASK_FMAX_D)
1158DECLARE_INSN(fcvt_s_d, MATCH_FCVT_S_D, MASK_FCVT_S_D)
1159DECLARE_INSN(fcvt_d_s, MATCH_FCVT_D_S, MASK_FCVT_D_S)
1160DECLARE_INSN(fsqrt_d, MATCH_FSQRT_D, MASK_FSQRT_D)
1161DECLARE_INSN(fadd_q, MATCH_FADD_Q, MASK_FADD_Q)
1162DECLARE_INSN(fsub_q, MATCH_FSUB_Q, MASK_FSUB_Q)
1163DECLARE_INSN(fmul_q, MATCH_FMUL_Q, MASK_FMUL_Q)
1164DECLARE_INSN(fdiv_q, MATCH_FDIV_Q, MASK_FDIV_Q)
1165DECLARE_INSN(fsgnj_q, MATCH_FSGNJ_Q, MASK_FSGNJ_Q)
1166DECLARE_INSN(fsgnjn_q, MATCH_FSGNJN_Q, MASK_FSGNJN_Q)
1167DECLARE_INSN(fsgnjx_q, MATCH_FSGNJX_Q, MASK_FSGNJX_Q)
1168DECLARE_INSN(fmin_q, MATCH_FMIN_Q, MASK_FMIN_Q)
1169DECLARE_INSN(fmax_q, MATCH_FMAX_Q, MASK_FMAX_Q)
1170DECLARE_INSN(fcvt_s_q, MATCH_FCVT_S_Q, MASK_FCVT_S_Q)
1171DECLARE_INSN(fcvt_q_s, MATCH_FCVT_Q_S, MASK_FCVT_Q_S)
1172DECLARE_INSN(fcvt_d_q, MATCH_FCVT_D_Q, MASK_FCVT_D_Q)
1173DECLARE_INSN(fcvt_q_d, MATCH_FCVT_Q_D, MASK_FCVT_Q_D)
1174DECLARE_INSN(fsqrt_q, MATCH_FSQRT_Q, MASK_FSQRT_Q)
1175DECLARE_INSN(fle_s, MATCH_FLE_S, MASK_FLE_S)
1176DECLARE_INSN(flt_s, MATCH_FLT_S, MASK_FLT_S)
1177DECLARE_INSN(feq_s, MATCH_FEQ_S, MASK_FEQ_S)
1178DECLARE_INSN(fle_d, MATCH_FLE_D, MASK_FLE_D)
1179DECLARE_INSN(flt_d, MATCH_FLT_D, MASK_FLT_D)
1180DECLARE_INSN(feq_d, MATCH_FEQ_D, MASK_FEQ_D)
1181DECLARE_INSN(fle_q, MATCH_FLE_Q, MASK_FLE_Q)
1182DECLARE_INSN(flt_q, MATCH_FLT_Q, MASK_FLT_Q)
1183DECLARE_INSN(feq_q, MATCH_FEQ_Q, MASK_FEQ_Q)
1184DECLARE_INSN(fcvt_w_s, MATCH_FCVT_W_S, MASK_FCVT_W_S)
1185DECLARE_INSN(fcvt_wu_s, MATCH_FCVT_WU_S, MASK_FCVT_WU_S)
1186DECLARE_INSN(fcvt_l_s, MATCH_FCVT_L_S, MASK_FCVT_L_S)
1187DECLARE_INSN(fcvt_lu_s, MATCH_FCVT_LU_S, MASK_FCVT_LU_S)
1188DECLARE_INSN(fmv_x_w, MATCH_FMV_X_W, MASK_FMV_X_W)
1189DECLARE_INSN(fclass_s, MATCH_FCLASS_S, MASK_FCLASS_S)
1190DECLARE_INSN(fcvt_w_d, MATCH_FCVT_W_D, MASK_FCVT_W_D)
1191DECLARE_INSN(fcvt_wu_d, MATCH_FCVT_WU_D, MASK_FCVT_WU_D)
1192DECLARE_INSN(fcvt_l_d, MATCH_FCVT_L_D, MASK_FCVT_L_D)
1193DECLARE_INSN(fcvt_lu_d, MATCH_FCVT_LU_D, MASK_FCVT_LU_D)
1194DECLARE_INSN(fmv_x_d, MATCH_FMV_X_D, MASK_FMV_X_D)
1195DECLARE_INSN(fclass_d, MATCH_FCLASS_D, MASK_FCLASS_D)
1196DECLARE_INSN(fcvt_w_q, MATCH_FCVT_W_Q, MASK_FCVT_W_Q)
1197DECLARE_INSN(fcvt_wu_q, MATCH_FCVT_WU_Q, MASK_FCVT_WU_Q)
1198DECLARE_INSN(fcvt_l_q, MATCH_FCVT_L_Q, MASK_FCVT_L_Q)
1199DECLARE_INSN(fcvt_lu_q, MATCH_FCVT_LU_Q, MASK_FCVT_LU_Q)
1200DECLARE_INSN(fmv_x_q, MATCH_FMV_X_Q, MASK_FMV_X_Q)
1201DECLARE_INSN(fclass_q, MATCH_FCLASS_Q, MASK_FCLASS_Q)
1202DECLARE_INSN(fcvt_s_w, MATCH_FCVT_S_W, MASK_FCVT_S_W)
1203DECLARE_INSN(fcvt_s_wu, MATCH_FCVT_S_WU, MASK_FCVT_S_WU)
1204DECLARE_INSN(fcvt_s_l, MATCH_FCVT_S_L, MASK_FCVT_S_L)
1205DECLARE_INSN(fcvt_s_lu, MATCH_FCVT_S_LU, MASK_FCVT_S_LU)
1206DECLARE_INSN(fmv_w_x, MATCH_FMV_W_X, MASK_FMV_W_X)
1207DECLARE_INSN(fcvt_d_w, MATCH_FCVT_D_W, MASK_FCVT_D_W)
1208DECLARE_INSN(fcvt_d_wu, MATCH_FCVT_D_WU, MASK_FCVT_D_WU)
1209DECLARE_INSN(fcvt_d_l, MATCH_FCVT_D_L, MASK_FCVT_D_L)
1210DECLARE_INSN(fcvt_d_lu, MATCH_FCVT_D_LU, MASK_FCVT_D_LU)
1211DECLARE_INSN(fmv_d_x, MATCH_FMV_D_X, MASK_FMV_D_X)
1212DECLARE_INSN(fcvt_q_w, MATCH_FCVT_Q_W, MASK_FCVT_Q_W)
1213DECLARE_INSN(fcvt_q_wu, MATCH_FCVT_Q_WU, MASK_FCVT_Q_WU)
1214DECLARE_INSN(fcvt_q_l, MATCH_FCVT_Q_L, MASK_FCVT_Q_L)
1215DECLARE_INSN(fcvt_q_lu, MATCH_FCVT_Q_LU, MASK_FCVT_Q_LU)
1216DECLARE_INSN(fmv_q_x, MATCH_FMV_Q_X, MASK_FMV_Q_X)
1217DECLARE_INSN(flw, MATCH_FLW, MASK_FLW)
1218DECLARE_INSN(fld, MATCH_FLD, MASK_FLD)
1219DECLARE_INSN(flq, MATCH_FLQ, MASK_FLQ)
1220DECLARE_INSN(fsw, MATCH_FSW, MASK_FSW)
1221DECLARE_INSN(fsd, MATCH_FSD, MASK_FSD)
1222DECLARE_INSN(fsq, MATCH_FSQ, MASK_FSQ)
1223DECLARE_INSN(fmadd_s, MATCH_FMADD_S, MASK_FMADD_S)
1224DECLARE_INSN(fmsub_s, MATCH_FMSUB_S, MASK_FMSUB_S)
1225DECLARE_INSN(fnmsub_s, MATCH_FNMSUB_S, MASK_FNMSUB_S)
1226DECLARE_INSN(fnmadd_s, MATCH_FNMADD_S, MASK_FNMADD_S)
1227DECLARE_INSN(fmadd_d, MATCH_FMADD_D, MASK_FMADD_D)
1228DECLARE_INSN(fmsub_d, MATCH_FMSUB_D, MASK_FMSUB_D)
1229DECLARE_INSN(fnmsub_d, MATCH_FNMSUB_D, MASK_FNMSUB_D)
1230DECLARE_INSN(fnmadd_d, MATCH_FNMADD_D, MASK_FNMADD_D)
1231DECLARE_INSN(fmadd_q, MATCH_FMADD_Q, MASK_FMADD_Q)
1232DECLARE_INSN(fmsub_q, MATCH_FMSUB_Q, MASK_FMSUB_Q)
1233DECLARE_INSN(fnmsub_q, MATCH_FNMSUB_Q, MASK_FNMSUB_Q)
1234DECLARE_INSN(fnmadd_q, MATCH_FNMADD_Q, MASK_FNMADD_Q)
1235DECLARE_INSN(c_nop, MATCH_C_NOP, MASK_C_NOP)
1236DECLARE_INSN(c_addi16sp, MATCH_C_ADDI16SP, MASK_C_ADDI16SP)
1237DECLARE_INSN(c_jr, MATCH_C_JR, MASK_C_JR)
1238DECLARE_INSN(c_jalr, MATCH_C_JALR, MASK_C_JALR)
1239DECLARE_INSN(c_ebreak, MATCH_C_EBREAK, MASK_C_EBREAK)
1240DECLARE_INSN(c_ld, MATCH_C_LD, MASK_C_LD)
1241DECLARE_INSN(c_sd, MATCH_C_SD, MASK_C_SD)
1242DECLARE_INSN(c_addiw, MATCH_C_ADDIW, MASK_C_ADDIW)
1243DECLARE_INSN(c_ldsp, MATCH_C_LDSP, MASK_C_LDSP)
1244DECLARE_INSN(c_sdsp, MATCH_C_SDSP, MASK_C_SDSP)
1245DECLARE_INSN(c_addi4spn, MATCH_C_ADDI4SPN, MASK_C_ADDI4SPN)
1246DECLARE_INSN(c_fld, MATCH_C_FLD, MASK_C_FLD)
1247DECLARE_INSN(c_lw, MATCH_C_LW, MASK_C_LW)
1248DECLARE_INSN(c_flw, MATCH_C_FLW, MASK_C_FLW)
1249DECLARE_INSN(c_fsd, MATCH_C_FSD, MASK_C_FSD)
1250DECLARE_INSN(c_sw, MATCH_C_SW, MASK_C_SW)
1251DECLARE_INSN(c_fsw, MATCH_C_FSW, MASK_C_FSW)
1252DECLARE_INSN(c_addi, MATCH_C_ADDI, MASK_C_ADDI)
1253DECLARE_INSN(c_jal, MATCH_C_JAL, MASK_C_JAL)
1254DECLARE_INSN(c_li, MATCH_C_LI, MASK_C_LI)
1255DECLARE_INSN(c_lui, MATCH_C_LUI, MASK_C_LUI)
1256DECLARE_INSN(c_srli, MATCH_C_SRLI, MASK_C_SRLI)
1257DECLARE_INSN(c_srai, MATCH_C_SRAI, MASK_C_SRAI)
1258DECLARE_INSN(c_andi, MATCH_C_ANDI, MASK_C_ANDI)
1259DECLARE_INSN(c_sub, MATCH_C_SUB, MASK_C_SUB)
1260DECLARE_INSN(c_xor, MATCH_C_XOR, MASK_C_XOR)
1261DECLARE_INSN(c_or, MATCH_C_OR, MASK_C_OR)
1262DECLARE_INSN(c_and, MATCH_C_AND, MASK_C_AND)
1263DECLARE_INSN(c_subw, MATCH_C_SUBW, MASK_C_SUBW)
1264DECLARE_INSN(c_addw, MATCH_C_ADDW, MASK_C_ADDW)
1265DECLARE_INSN(c_j, MATCH_C_J, MASK_C_J)
1266DECLARE_INSN(c_beqz, MATCH_C_BEQZ, MASK_C_BEQZ)
1267DECLARE_INSN(c_bnez, MATCH_C_BNEZ, MASK_C_BNEZ)
1268DECLARE_INSN(c_slli, MATCH_C_SLLI, MASK_C_SLLI)
1269DECLARE_INSN(c_fldsp, MATCH_C_FLDSP, MASK_C_FLDSP)
1270DECLARE_INSN(c_lwsp, MATCH_C_LWSP, MASK_C_LWSP)
1271DECLARE_INSN(c_flwsp, MATCH_C_FLWSP, MASK_C_FLWSP)
1272DECLARE_INSN(c_mv, MATCH_C_MV, MASK_C_MV)
1273DECLARE_INSN(c_add, MATCH_C_ADD, MASK_C_ADD)
1274DECLARE_INSN(c_fsdsp, MATCH_C_FSDSP, MASK_C_FSDSP)
1275DECLARE_INSN(c_swsp, MATCH_C_SWSP, MASK_C_SWSP)
1276DECLARE_INSN(c_fswsp, MATCH_C_FSWSP, MASK_C_FSWSP)
1277DECLARE_INSN(custom0, MATCH_CUSTOM0, MASK_CUSTOM0)
1278DECLARE_INSN(custom0_rs1, MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1)
1279DECLARE_INSN(custom0_rs1_rs2, MATCH_CUSTOM0_RS1_RS2, MASK_CUSTOM0_RS1_RS2)
1280DECLARE_INSN(custom0_rd, MATCH_CUSTOM0_RD, MASK_CUSTOM0_RD)
1281DECLARE_INSN(custom0_rd_rs1, MATCH_CUSTOM0_RD_RS1, MASK_CUSTOM0_RD_RS1)
1282DECLARE_INSN(custom0_rd_rs1_rs2, MATCH_CUSTOM0_RD_RS1_RS2, MASK_CUSTOM0_RD_RS1_RS2)
1283DECLARE_INSN(custom1, MATCH_CUSTOM1, MASK_CUSTOM1)
1284DECLARE_INSN(custom1_rs1, MATCH_CUSTOM1_RS1, MASK_CUSTOM1_RS1)
1285DECLARE_INSN(custom1_rs1_rs2, MATCH_CUSTOM1_RS1_RS2, MASK_CUSTOM1_RS1_RS2)
1286DECLARE_INSN(custom1_rd, MATCH_CUSTOM1_RD, MASK_CUSTOM1_RD)
1287DECLARE_INSN(custom1_rd_rs1, MATCH_CUSTOM1_RD_RS1, MASK_CUSTOM1_RD_RS1)
1288DECLARE_INSN(custom1_rd_rs1_rs2, MATCH_CUSTOM1_RD_RS1_RS2, MASK_CUSTOM1_RD_RS1_RS2)
1289DECLARE_INSN(custom2, MATCH_CUSTOM2, MASK_CUSTOM2)
1290DECLARE_INSN(custom2_rs1, MATCH_CUSTOM2_RS1, MASK_CUSTOM2_RS1)
1291DECLARE_INSN(custom2_rs1_rs2, MATCH_CUSTOM2_RS1_RS2, MASK_CUSTOM2_RS1_RS2)
1292DECLARE_INSN(custom2_rd, MATCH_CUSTOM2_RD, MASK_CUSTOM2_RD)
1293DECLARE_INSN(custom2_rd_rs1, MATCH_CUSTOM2_RD_RS1, MASK_CUSTOM2_RD_RS1)
1294DECLARE_INSN(custom2_rd_rs1_rs2, MATCH_CUSTOM2_RD_RS1_RS2, MASK_CUSTOM2_RD_RS1_RS2)
1295DECLARE_INSN(custom3, MATCH_CUSTOM3, MASK_CUSTOM3)
1296DECLARE_INSN(custom3_rs1, MATCH_CUSTOM3_RS1, MASK_CUSTOM3_RS1)
1297DECLARE_INSN(custom3_rs1_rs2, MATCH_CUSTOM3_RS1_RS2, MASK_CUSTOM3_RS1_RS2)
1298DECLARE_INSN(custom3_rd, MATCH_CUSTOM3_RD, MASK_CUSTOM3_RD)
1299DECLARE_INSN(custom3_rd_rs1, MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1)
1300DECLARE_INSN(custom3_rd_rs1_rs2, MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2)
1301#endif
1302#ifdef DECLARE_CSR
1303DECLARE_CSR(fflags, CSR_FFLAGS)
1304DECLARE_CSR(frm, CSR_FRM)
1305DECLARE_CSR(fcsr, CSR_FCSR)
1306DECLARE_CSR(cycle, CSR_CYCLE)
1307DECLARE_CSR(time, CSR_TIME)
1308DECLARE_CSR(instret, CSR_INSTRET)
1309DECLARE_CSR(hpmcounter3, CSR_HPMCOUNTER3)
1310DECLARE_CSR(hpmcounter4, CSR_HPMCOUNTER4)
1311DECLARE_CSR(hpmcounter5, CSR_HPMCOUNTER5)
1312DECLARE_CSR(hpmcounter6, CSR_HPMCOUNTER6)
1313DECLARE_CSR(hpmcounter7, CSR_HPMCOUNTER7)
1314DECLARE_CSR(hpmcounter8, CSR_HPMCOUNTER8)
1315DECLARE_CSR(hpmcounter9, CSR_HPMCOUNTER9)
1316DECLARE_CSR(hpmcounter10, CSR_HPMCOUNTER10)
1317DECLARE_CSR(hpmcounter11, CSR_HPMCOUNTER11)
1318DECLARE_CSR(hpmcounter12, CSR_HPMCOUNTER12)
1319DECLARE_CSR(hpmcounter13, CSR_HPMCOUNTER13)
1320DECLARE_CSR(hpmcounter14, CSR_HPMCOUNTER14)
1321DECLARE_CSR(hpmcounter15, CSR_HPMCOUNTER15)
1322DECLARE_CSR(hpmcounter16, CSR_HPMCOUNTER16)
1323DECLARE_CSR(hpmcounter17, CSR_HPMCOUNTER17)
1324DECLARE_CSR(hpmcounter18, CSR_HPMCOUNTER18)
1325DECLARE_CSR(hpmcounter19, CSR_HPMCOUNTER19)
1326DECLARE_CSR(hpmcounter20, CSR_HPMCOUNTER20)
1327DECLARE_CSR(hpmcounter21, CSR_HPMCOUNTER21)
1328DECLARE_CSR(hpmcounter22, CSR_HPMCOUNTER22)
1329DECLARE_CSR(hpmcounter23, CSR_HPMCOUNTER23)
1330DECLARE_CSR(hpmcounter24, CSR_HPMCOUNTER24)
1331DECLARE_CSR(hpmcounter25, CSR_HPMCOUNTER25)
1332DECLARE_CSR(hpmcounter26, CSR_HPMCOUNTER26)
1333DECLARE_CSR(hpmcounter27, CSR_HPMCOUNTER27)
1334DECLARE_CSR(hpmcounter28, CSR_HPMCOUNTER28)
1335DECLARE_CSR(hpmcounter29, CSR_HPMCOUNTER29)
1336DECLARE_CSR(hpmcounter30, CSR_HPMCOUNTER30)
1337DECLARE_CSR(hpmcounter31, CSR_HPMCOUNTER31)
1338DECLARE_CSR(sstatus, CSR_SSTATUS)
1339DECLARE_CSR(sie, CSR_SIE)
1340DECLARE_CSR(stvec, CSR_STVEC)
1341DECLARE_CSR(scounteren, CSR_SCOUNTEREN)
1342DECLARE_CSR(sscratch, CSR_SSCRATCH)
1343DECLARE_CSR(sepc, CSR_SEPC)
1344DECLARE_CSR(scause, CSR_SCAUSE)
1345DECLARE_CSR(sbadaddr, CSR_SBADADDR)
1346DECLARE_CSR(sip, CSR_SIP)
1347DECLARE_CSR(sptbr, CSR_SPTBR)
1348DECLARE_CSR(mstatus, CSR_MSTATUS)
1349DECLARE_CSR(misa, CSR_MISA)
1350DECLARE_CSR(medeleg, CSR_MEDELEG)
1351DECLARE_CSR(mideleg, CSR_MIDELEG)
1352DECLARE_CSR(mie, CSR_MIE)
1353DECLARE_CSR(mtvec, CSR_MTVEC)
1354DECLARE_CSR(mcounteren, CSR_MCOUNTEREN)
1355DECLARE_CSR(mscratch, CSR_MSCRATCH)
1356DECLARE_CSR(mepc, CSR_MEPC)
1357DECLARE_CSR(mcause, CSR_MCAUSE)
1358DECLARE_CSR(mbadaddr, CSR_MBADADDR)
1359DECLARE_CSR(mip, CSR_MIP)
1360DECLARE_CSR(pmpcfg0, CSR_PMPCFG0)
1361DECLARE_CSR(pmpcfg1, CSR_PMPCFG1)
1362DECLARE_CSR(pmpcfg2, CSR_PMPCFG2)
1363DECLARE_CSR(pmpcfg3, CSR_PMPCFG3)
1364DECLARE_CSR(pmpaddr0, CSR_PMPADDR0)
1365DECLARE_CSR(pmpaddr1, CSR_PMPADDR1)
1366DECLARE_CSR(pmpaddr2, CSR_PMPADDR2)
1367DECLARE_CSR(pmpaddr3, CSR_PMPADDR3)
1368DECLARE_CSR(pmpaddr4, CSR_PMPADDR4)
1369DECLARE_CSR(pmpaddr5, CSR_PMPADDR5)
1370DECLARE_CSR(pmpaddr6, CSR_PMPADDR6)
1371DECLARE_CSR(pmpaddr7, CSR_PMPADDR7)
1372DECLARE_CSR(pmpaddr8, CSR_PMPADDR8)
1373DECLARE_CSR(pmpaddr9, CSR_PMPADDR9)
1374DECLARE_CSR(pmpaddr10, CSR_PMPADDR10)
1375DECLARE_CSR(pmpaddr11, CSR_PMPADDR11)
1376DECLARE_CSR(pmpaddr12, CSR_PMPADDR12)
1377DECLARE_CSR(pmpaddr13, CSR_PMPADDR13)
1378DECLARE_CSR(pmpaddr14, CSR_PMPADDR14)
1379DECLARE_CSR(pmpaddr15, CSR_PMPADDR15)
1380DECLARE_CSR(tselect, CSR_TSELECT)
1381DECLARE_CSR(tdata1, CSR_TDATA1)
1382DECLARE_CSR(tdata2, CSR_TDATA2)
1383DECLARE_CSR(tdata3, CSR_TDATA3)
1384DECLARE_CSR(dcsr, CSR_DCSR)
1385DECLARE_CSR(dpc, CSR_DPC)
1386DECLARE_CSR(dscratch, CSR_DSCRATCH)
1387DECLARE_CSR(mcycle, CSR_MCYCLE)
1388DECLARE_CSR(minstret, CSR_MINSTRET)
1389DECLARE_CSR(mhpmcounter3, CSR_MHPMCOUNTER3)
1390DECLARE_CSR(mhpmcounter4, CSR_MHPMCOUNTER4)
1391DECLARE_CSR(mhpmcounter5, CSR_MHPMCOUNTER5)
1392DECLARE_CSR(mhpmcounter6, CSR_MHPMCOUNTER6)
1393DECLARE_CSR(mhpmcounter7, CSR_MHPMCOUNTER7)
1394DECLARE_CSR(mhpmcounter8, CSR_MHPMCOUNTER8)
1395DECLARE_CSR(mhpmcounter9, CSR_MHPMCOUNTER9)
1396DECLARE_CSR(mhpmcounter10, CSR_MHPMCOUNTER10)
1397DECLARE_CSR(mhpmcounter11, CSR_MHPMCOUNTER11)
1398DECLARE_CSR(mhpmcounter12, CSR_MHPMCOUNTER12)
1399DECLARE_CSR(mhpmcounter13, CSR_MHPMCOUNTER13)
1400DECLARE_CSR(mhpmcounter14, CSR_MHPMCOUNTER14)
1401DECLARE_CSR(mhpmcounter15, CSR_MHPMCOUNTER15)
1402DECLARE_CSR(mhpmcounter16, CSR_MHPMCOUNTER16)
1403DECLARE_CSR(mhpmcounter17, CSR_MHPMCOUNTER17)
1404DECLARE_CSR(mhpmcounter18, CSR_MHPMCOUNTER18)
1405DECLARE_CSR(mhpmcounter19, CSR_MHPMCOUNTER19)
1406DECLARE_CSR(mhpmcounter20, CSR_MHPMCOUNTER20)
1407DECLARE_CSR(mhpmcounter21, CSR_MHPMCOUNTER21)
1408DECLARE_CSR(mhpmcounter22, CSR_MHPMCOUNTER22)
1409DECLARE_CSR(mhpmcounter23, CSR_MHPMCOUNTER23)
1410DECLARE_CSR(mhpmcounter24, CSR_MHPMCOUNTER24)
1411DECLARE_CSR(mhpmcounter25, CSR_MHPMCOUNTER25)
1412DECLARE_CSR(mhpmcounter26, CSR_MHPMCOUNTER26)
1413DECLARE_CSR(mhpmcounter27, CSR_MHPMCOUNTER27)
1414DECLARE_CSR(mhpmcounter28, CSR_MHPMCOUNTER28)
1415DECLARE_CSR(mhpmcounter29, CSR_MHPMCOUNTER29)
1416DECLARE_CSR(mhpmcounter30, CSR_MHPMCOUNTER30)
1417DECLARE_CSR(mhpmcounter31, CSR_MHPMCOUNTER31)
1418DECLARE_CSR(mhpmevent3, CSR_MHPMEVENT3)
1419DECLARE_CSR(mhpmevent4, CSR_MHPMEVENT4)
1420DECLARE_CSR(mhpmevent5, CSR_MHPMEVENT5)
1421DECLARE_CSR(mhpmevent6, CSR_MHPMEVENT6)
1422DECLARE_CSR(mhpmevent7, CSR_MHPMEVENT7)
1423DECLARE_CSR(mhpmevent8, CSR_MHPMEVENT8)
1424DECLARE_CSR(mhpmevent9, CSR_MHPMEVENT9)
1425DECLARE_CSR(mhpmevent10, CSR_MHPMEVENT10)
1426DECLARE_CSR(mhpmevent11, CSR_MHPMEVENT11)
1427DECLARE_CSR(mhpmevent12, CSR_MHPMEVENT12)
1428DECLARE_CSR(mhpmevent13, CSR_MHPMEVENT13)
1429DECLARE_CSR(mhpmevent14, CSR_MHPMEVENT14)
1430DECLARE_CSR(mhpmevent15, CSR_MHPMEVENT15)
1431DECLARE_CSR(mhpmevent16, CSR_MHPMEVENT16)
1432DECLARE_CSR(mhpmevent17, CSR_MHPMEVENT17)
1433DECLARE_CSR(mhpmevent18, CSR_MHPMEVENT18)
1434DECLARE_CSR(mhpmevent19, CSR_MHPMEVENT19)
1435DECLARE_CSR(mhpmevent20, CSR_MHPMEVENT20)
1436DECLARE_CSR(mhpmevent21, CSR_MHPMEVENT21)
1437DECLARE_CSR(mhpmevent22, CSR_MHPMEVENT22)
1438DECLARE_CSR(mhpmevent23, CSR_MHPMEVENT23)
1439DECLARE_CSR(mhpmevent24, CSR_MHPMEVENT24)
1440DECLARE_CSR(mhpmevent25, CSR_MHPMEVENT25)
1441DECLARE_CSR(mhpmevent26, CSR_MHPMEVENT26)
1442DECLARE_CSR(mhpmevent27, CSR_MHPMEVENT27)
1443DECLARE_CSR(mhpmevent28, CSR_MHPMEVENT28)
1444DECLARE_CSR(mhpmevent29, CSR_MHPMEVENT29)
1445DECLARE_CSR(mhpmevent30, CSR_MHPMEVENT30)
1446DECLARE_CSR(mhpmevent31, CSR_MHPMEVENT31)
1447DECLARE_CSR(mvendorid, CSR_MVENDORID)
1448DECLARE_CSR(marchid, CSR_MARCHID)
1449DECLARE_CSR(mimpid, CSR_MIMPID)
1450DECLARE_CSR(mhartid, CSR_MHARTID)
1451DECLARE_CSR(cycleh, CSR_CYCLEH)
1452DECLARE_CSR(timeh, CSR_TIMEH)
1453DECLARE_CSR(instreth, CSR_INSTRETH)
1454DECLARE_CSR(hpmcounter3h, CSR_HPMCOUNTER3H)
1455DECLARE_CSR(hpmcounter4h, CSR_HPMCOUNTER4H)
1456DECLARE_CSR(hpmcounter5h, CSR_HPMCOUNTER5H)
1457DECLARE_CSR(hpmcounter6h, CSR_HPMCOUNTER6H)
1458DECLARE_CSR(hpmcounter7h, CSR_HPMCOUNTER7H)
1459DECLARE_CSR(hpmcounter8h, CSR_HPMCOUNTER8H)
1460DECLARE_CSR(hpmcounter9h, CSR_HPMCOUNTER9H)
1461DECLARE_CSR(hpmcounter10h, CSR_HPMCOUNTER10H)
1462DECLARE_CSR(hpmcounter11h, CSR_HPMCOUNTER11H)
1463DECLARE_CSR(hpmcounter12h, CSR_HPMCOUNTER12H)
1464DECLARE_CSR(hpmcounter13h, CSR_HPMCOUNTER13H)
1465DECLARE_CSR(hpmcounter14h, CSR_HPMCOUNTER14H)
1466DECLARE_CSR(hpmcounter15h, CSR_HPMCOUNTER15H)
1467DECLARE_CSR(hpmcounter16h, CSR_HPMCOUNTER16H)
1468DECLARE_CSR(hpmcounter17h, CSR_HPMCOUNTER17H)
1469DECLARE_CSR(hpmcounter18h, CSR_HPMCOUNTER18H)
1470DECLARE_CSR(hpmcounter19h, CSR_HPMCOUNTER19H)
1471DECLARE_CSR(hpmcounter20h, CSR_HPMCOUNTER20H)
1472DECLARE_CSR(hpmcounter21h, CSR_HPMCOUNTER21H)
1473DECLARE_CSR(hpmcounter22h, CSR_HPMCOUNTER22H)
1474DECLARE_CSR(hpmcounter23h, CSR_HPMCOUNTER23H)
1475DECLARE_CSR(hpmcounter24h, CSR_HPMCOUNTER24H)
1476DECLARE_CSR(hpmcounter25h, CSR_HPMCOUNTER25H)
1477DECLARE_CSR(hpmcounter26h, CSR_HPMCOUNTER26H)
1478DECLARE_CSR(hpmcounter27h, CSR_HPMCOUNTER27H)
1479DECLARE_CSR(hpmcounter28h, CSR_HPMCOUNTER28H)
1480DECLARE_CSR(hpmcounter29h, CSR_HPMCOUNTER29H)
1481DECLARE_CSR(hpmcounter30h, CSR_HPMCOUNTER30H)
1482DECLARE_CSR(hpmcounter31h, CSR_HPMCOUNTER31H)
1483DECLARE_CSR(mcycleh, CSR_MCYCLEH)
1484DECLARE_CSR(minstreth, CSR_MINSTRETH)
1485DECLARE_CSR(mhpmcounter3h, CSR_MHPMCOUNTER3H)
1486DECLARE_CSR(mhpmcounter4h, CSR_MHPMCOUNTER4H)
1487DECLARE_CSR(mhpmcounter5h, CSR_MHPMCOUNTER5H)
1488DECLARE_CSR(mhpmcounter6h, CSR_MHPMCOUNTER6H)
1489DECLARE_CSR(mhpmcounter7h, CSR_MHPMCOUNTER7H)
1490DECLARE_CSR(mhpmcounter8h, CSR_MHPMCOUNTER8H)
1491DECLARE_CSR(mhpmcounter9h, CSR_MHPMCOUNTER9H)
1492DECLARE_CSR(mhpmcounter10h, CSR_MHPMCOUNTER10H)
1493DECLARE_CSR(mhpmcounter11h, CSR_MHPMCOUNTER11H)
1494DECLARE_CSR(mhpmcounter12h, CSR_MHPMCOUNTER12H)
1495DECLARE_CSR(mhpmcounter13h, CSR_MHPMCOUNTER13H)
1496DECLARE_CSR(mhpmcounter14h, CSR_MHPMCOUNTER14H)
1497DECLARE_CSR(mhpmcounter15h, CSR_MHPMCOUNTER15H)
1498DECLARE_CSR(mhpmcounter16h, CSR_MHPMCOUNTER16H)
1499DECLARE_CSR(mhpmcounter17h, CSR_MHPMCOUNTER17H)
1500DECLARE_CSR(mhpmcounter18h, CSR_MHPMCOUNTER18H)
1501DECLARE_CSR(mhpmcounter19h, CSR_MHPMCOUNTER19H)
1502DECLARE_CSR(mhpmcounter20h, CSR_MHPMCOUNTER20H)
1503DECLARE_CSR(mhpmcounter21h, CSR_MHPMCOUNTER21H)
1504DECLARE_CSR(mhpmcounter22h, CSR_MHPMCOUNTER22H)
1505DECLARE_CSR(mhpmcounter23h, CSR_MHPMCOUNTER23H)
1506DECLARE_CSR(mhpmcounter24h, CSR_MHPMCOUNTER24H)
1507DECLARE_CSR(mhpmcounter25h, CSR_MHPMCOUNTER25H)
1508DECLARE_CSR(mhpmcounter26h, CSR_MHPMCOUNTER26H)
1509DECLARE_CSR(mhpmcounter27h, CSR_MHPMCOUNTER27H)
1510DECLARE_CSR(mhpmcounter28h, CSR_MHPMCOUNTER28H)
1511DECLARE_CSR(mhpmcounter29h, CSR_MHPMCOUNTER29H)
1512DECLARE_CSR(mhpmcounter30h, CSR_MHPMCOUNTER30H)
1513DECLARE_CSR(mhpmcounter31h, CSR_MHPMCOUNTER31H)
1514#endif
1515#ifdef DECLARE_CAUSE
1516DECLARE_CAUSE("misaligned fetch", CAUSE_MISALIGNED_FETCH)
1517DECLARE_CAUSE("fetch access", CAUSE_FETCH_ACCESS)
1518DECLARE_CAUSE("illegal instruction", CAUSE_ILLEGAL_INSTRUCTION)
1519DECLARE_CAUSE("breakpoint", CAUSE_BREAKPOINT)
1520DECLARE_CAUSE("misaligned load", CAUSE_MISALIGNED_LOAD)
1521DECLARE_CAUSE("load access", CAUSE_LOAD_ACCESS)
1522DECLARE_CAUSE("misaligned store", CAUSE_MISALIGNED_STORE)
1523DECLARE_CAUSE("store access", CAUSE_STORE_ACCESS)
1524DECLARE_CAUSE("user_ecall", CAUSE_USER_ECALL)
1525DECLARE_CAUSE("supervisor_ecall", CAUSE_SUPERVISOR_ECALL)
1526DECLARE_CAUSE("hypervisor_ecall", CAUSE_HYPERVISOR_ECALL)
1527DECLARE_CAUSE("machine_ecall", CAUSE_MACHINE_ECALL)
1528DECLARE_CAUSE("fetch page fault", CAUSE_FETCH_PAGE_FAULT)
1529DECLARE_CAUSE("load page fault", CAUSE_LOAD_PAGE_FAULT)
1530DECLARE_CAUSE("store page fault", CAUSE_STORE_PAGE_FAULT)
1531#endif