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 
libunwind__arch_reg_id(int regnum)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