xref: /linux/tools/perf/arch/mips/util/unwind-libunwind.c (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <errno.h>
4 #include <libunwind.h>
5 #include "perf_regs.h"
6 #include "../../util/unwind.h"
7 #include "util/debug.h"
8 
9 int libunwind__arch_reg_id(int regnum)
10 {
11 	switch (regnum) {
12 	case UNW_MIPS_R1 ... UNW_MIPS_R25:
13 		return regnum - UNW_MIPS_R1 + PERF_REG_MIPS_R1;
14 	case UNW_MIPS_R28 ... UNW_MIPS_R31:
15 		return regnum - UNW_MIPS_R28 + PERF_REG_MIPS_R28;
16 	case UNW_MIPS_PC:
17 		return PERF_REG_MIPS_PC;
18 	default:
19 		pr_err("unwind: invalid reg id %d\n", regnum);
20 		return -EINVAL;
21 	}
22 }
23