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