xref: /freebsd/sys/cddl/dev/dtrace/riscv/instr_size.c (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1 /*
2  * SPDX-License-Identifier: CDDL 1.0
3  *
4  * Copyright 2023 Christos Margiolis <christos@FreeBSD.org>
5  */
6 
7 #include <sys/types.h>
8 #include <sys/dtrace.h>
9 
10 #include <machine/riscvreg.h>
11 
12 #define RVC_MASK 0x03
13 
14 int
15 dtrace_instr_size(uint8_t *instr)
16 {
17 	/* Detect compressed instructions. */
18 	if ((~(*instr) & RVC_MASK) == 0)
19 		return (INSN_SIZE);
20 	else
21 		return (INSN_C_SIZE);
22 }
23